3 This is the developers' hint guide.
4 Some parts are based on mail messages.
6 Please feel free to add your name to this list:
9 * Working with the Midnight Commander
11 If you plan on working on the Midnight Commander, here are some
12 tips on how to make your development easier and my job of merging
13 your code easier, I find them useful.
15 o Run make depend if you modify the source code structure (e.g. you
16 add/remove include files). This is very important, it will help you
17 to get an accurate compilation.
19 o It's recommended that you use GNU Make (if you want to use the
22 o I work with the tags feature of GNU emacs. Run the make tags
23 command to get an updated TAGS file. The command Alt-. will take
24 you to any function or variable definition.
26 o Try to keep the indenting style as it is currently. Normally if you
27 just created a new file with a different coding style, run the GNU
28 indent program on it (remember to make a backup copy first) like
29 this: indent -kr -pcs filename.c
31 o This code is distributed under the GNU General Public License and
32 Keep this in mind when adding code to the program.
36 The program uses extensively the dialog manager written by Radek
37 Doulik. To understand how the dialog manager works, please read
38 the dlg.c and dlg.h. You will find the basic widgets in the file
39 widget.c and the widget.h file. If you understand this two files,
40 you are done. The files option.c and boxes.c contain some examples
41 of how the dialog manager functions are used. For a more complete
42 example, take a look at the main.c file.
44 Take a look at the FILES file in the doc/ directory. It has a
45 roadmap of the files that make up the Midnight Commander.
47 The file util.c has a lot of utility functions. Get familiar with
48 them, they are very simple.
50 The code has almost no hardcoded limits, there are a lot of ways of
51 avoiding them. For example, when you want to concatenate strings,
52 use the copy_strings functions, it is used like this:
54 new_text = copy_strings (username, " ", password, NULL);
56 This mallocs the required area, so it still needs to be freed.
64 The routines for input handling on the Midnight Commander are:
65 xgetch, get_key_code, mi_getch and get_event.
67 xgetch is an interface to the low level system input mechanism. It
68 does not deal with the mouse.
70 In the case of curses, this is a macro that translates to getch, on
71 BSD curses, it is an interface to x_getch. This routine on curses
72 translates key sequences to key codes (\E[A to something like
75 In the case of slang there is no such conversion, that's why we
76 load a set of extra definitions.
78 The get_key_code routine converts the data from xgetch to the
79 constants the Midnight Commander uses.
81 In the case of slang, it will actually do all the jobs that getch
82 does for curses. In the case of curses it patches a couple of
83 sequences that are not available on some terminal databases. This
84 routine is the one you want to use if you want a character without
87 get_event is the routine you want to use if you want to handle mouse
88 events, it will return 0 on a mouse event, ERR if no input is
89 available or a key code if there is some input available. This
90 routine in turn uses get_key_code to decode the input stream and
91 convert it to useful constants.
93 mi_getch is just a wrapper around get_event that ignores all the mouse
94 events. It's used only in a couple of places, this routine may return
95 ERR if no input is available (if you have set the nodelay option of
96 curses or slang with nodelay) or a character code if no such option is
101 The mouse support in the Midnight Commander is based on the get_event
102 routine. The core of the mouse event dispatching is in the
103 dlg.c:run_dlg routine.
107 We are dropping it in favor of slang, but we will still support it. We
108 basically are using a small subset of ncurses because we want to be
109 compatible with Slang.
112 * The Dialog manager and the Widgets