mceditor: refactoring.
[midnight-commander.git] / lib / global.h
blob9b245377a3e2997c3637dfa99238c0b0408cbd5b
1 /** \file global.h
2 * \brief Header: %global definitions for compatibility
4 * This file should be included after all system includes and before all local includes.
5 */
7 #ifndef MC_GLOBAL_H
8 #define MC_GLOBAL_H
10 #if defined(HAVE_STRING_H)
11 #include <string.h>
12 /* An ANSI string.h and pre-ANSI memory.h might conflict */
13 #elif defined(HAVE_MEMORY_H)
14 #include <memory.h>
15 #else
16 #include <strings.h>
17 /* memory and strings.h conflict on other systems */
18 #endif /* !STDC_HEADERS & !HAVE_STRING_H */
20 #ifdef HAVE_SYS_PARAM_H
21 #include <sys/param.h>
22 #endif
24 /* for O_* macros */
25 #include <fcntl.h>
27 /* for sig_atomic_t */
28 #include <signal.h>
30 #ifdef HAVE_FUNC_ATTRIBUTE_FALLTHROUGH
31 #define MC_FALLTHROUGH __attribute__((fallthrough))
32 #else
33 #define MC_FALLTHROUGH
34 #endif
36 /*** typedefs(not structures) and defined constants **********************************************/
38 /* The O_BINARY definition was taken from gettext */
39 #if !defined O_BINARY && defined _O_BINARY
40 /* For MSC-compatible compilers. */
41 #define O_BINARY _O_BINARY
42 #endif
43 #ifdef __BEOS__
44 /* BeOS 5 has O_BINARY, but is has no effect. */
45 #undef O_BINARY
46 #endif
47 /* On reasonable systems, binary I/O is the default. */
48 #ifndef O_BINARY
49 #define O_BINARY 0
50 #endif
52 /* Replacement for O_NONBLOCK */
53 #ifndef O_NONBLOCK
54 #ifdef O_NDELAY /* SYSV */
55 #define O_NONBLOCK O_NDELAY
56 #else /* BSD */
57 #define O_NONBLOCK FNDELAY
58 #endif /* !O_NDELAY */
59 #endif /* !O_NONBLOCK */
61 #if defined(__QNX__) && !defined(__QNXNTO__)
62 /* exec*() from <process.h> */
63 #include <unix.h>
64 #endif
66 #include <glib.h>
67 #include "glibcompat.h"
69 /* Solaris9 doesn't have PRIXMAX */
70 #ifndef PRIXMAX
71 #define PRIXMAX PRIxMAX
72 #endif
74 #ifdef ENABLE_NLS
75 #include <libintl.h>
76 #define _(String) gettext (String)
77 #ifdef gettext_noop
78 #define N_(String) gettext_noop (String)
79 #else
80 #define N_(String) (String)
81 #endif
82 #else /* Stubs that do something close enough. */
83 #define textdomain(String) 1
84 #define gettext(String) (String)
85 #define ngettext(String1,String2,Num) (((Num) == 1) ? (String1) : (String2))
86 #define dgettext(Domain,Message) (Message)
87 #define dcgettext(Domain,Message,Type) (Message)
88 #define bindtextdomain(Domain,Directory) 1
89 #define _(String) (String)
90 #define N_(String) (String)
91 #endif /* !ENABLE_NLS */
93 #include "fs.h"
94 #include "shell.h"
95 #include "mcconfig.h"
97 #ifdef USE_MAINTAINER_MODE
98 #include "lib/logging.h"
99 #endif
101 /* Just for keeping Your's brains from invention a proper size of the buffer :-) */
102 #define BUF_10K 10240L
103 #define BUF_8K 8192L
104 #define BUF_4K 4096L
105 #define BUF_1K 1024L
107 #define BUF_LARGE BUF_1K
108 #define BUF_MEDIUM 512
109 #define BUF_SMALL 128
110 #define BUF_TINY 64
112 /* ESC_CHAR is defined in /usr/include/langinfo.h in some systems */
113 #ifdef ESC_CHAR
114 #undef ESC_CHAR
115 #endif
116 /* AIX compiler doesn't understand '\e' */
117 #define ESC_CHAR '\033'
118 #define ESC_STR "\033"
120 /* OS specific defines */
121 #define PATH_SEP '/'
122 #define PATH_SEP_STR "/"
123 #define IS_PATH_SEP(c) ((c) == PATH_SEP)
124 #define PATH_ENV_SEP ':'
125 #define TMPDIR_DEFAULT "/tmp"
126 #define SCRIPT_SUFFIX ""
127 #define get_default_editor() "vi"
128 #define OS_SORT_CASE_SENSITIVE_DEFAULT TRUE
129 #define UTF8_CHAR_LEN 6
131 /* struct stat members */
132 #ifdef __APPLE__
133 #define st_atim st_atimespec
134 #define st_ctim st_ctimespec
135 #define st_mtim st_mtimespec
136 #endif
138 /* Used to distinguish between a normal MC termination and */
139 /* one caused by typing 'exit' or 'logout' in the subshell */
140 #define SUBSHELL_EXIT 128
142 #define MC_ERROR g_quark_from_static_string (PACKAGE)
144 #define DEFAULT_CHARSET "ASCII"
146 /*** enums ***************************************************************************************/
148 /* run mode and params */
149 typedef enum
151 MC_RUN_FULL = 0,
152 MC_RUN_EDITOR,
153 MC_RUN_VIEWER,
154 MC_RUN_DIFFVIEWER
155 } mc_run_mode_t;
157 /*** structures declarations (and typedefs of structures)*****************************************/
159 typedef struct
161 const char *mc_version;
163 mc_run_mode_t mc_run_mode;
164 gboolean run_from_parent_mc;
165 /* Used so that widgets know if they are being destroyed or shut down */
166 gboolean midnight_shutdown;
168 /* sysconfig_dir: Area for default settings from maintainers of distributuves
169 default is /etc/mc or may be defined by MC_DATADIR */
170 char *sysconfig_dir;
171 /* share_data_dir: Area for default settings from developers */
172 char *share_data_dir;
174 char *profile_name;
176 mc_config_t *main_config;
177 mc_config_t *panels_config;
179 #ifdef HAVE_CHARSET
180 /* Numbers of (file I/O) and (input/display) codepages. -1 if not selected */
181 int source_codepage;
182 int display_codepage;
183 #else
184 /* If true, allow characters in the range 160-255 */
185 gboolean eight_bit_clean;
187 * If true, also allow characters in the range 128-159.
188 * This is reported to break on many terminals (xterm, qansi-m).
190 gboolean full_eight_bits;
191 #endif /* !HAVE_CHARSET */
193 * If utf-8 terminal utf8_display = TRUE
194 * Display bits set UTF-8
196 gboolean utf8_display;
198 /* Set if the nice message (hint) bar is visible */
199 gboolean message_visible;
200 /* Set if the nice and useful keybar is visible */
201 gboolean keybar_visible;
203 #ifdef ENABLE_BACKGROUND
204 /* If true, this is a background process */
205 gboolean we_are_background;
206 #endif /* ENABLE_BACKGROUND */
208 struct
210 /* Asks for confirmation before clean up of history */
211 gboolean confirm_history_cleanup;
213 /* Set if you want the possible completions dialog for the first time */
214 gboolean show_all_if_ambiguous;
216 /* Ugly hack in order to distinguish between left and right panel in menubar */
217 /* Set if the command is being run from the "Right" menu */
218 gboolean is_right; /* If the selected menu was the right */
219 } widget;
221 /* The user's shell */
222 mc_shell_t *shell;
224 struct
226 /* Use the specified skin */
227 char *skin;
228 /* Dialog window and drop down menu have a shadow */
229 gboolean shadows;
231 char *setup_color_string;
232 char *term_color_string;
233 char *color_terminal_string;
234 /* colors specified on the command line: they override any other setting */
235 char *command_line_colors;
237 #ifndef LINUX_CONS_SAVER_C
238 /* Used only in mc, not in cons.saver */
239 char console_flag;
240 #endif /* !LINUX_CONS_SAVER_C */
241 /* If using a subshell for evaluating commands this is true */
242 gboolean use_subshell;
244 #ifdef ENABLE_SUBSHELL
245 /* File descriptors of the pseudoterminal used by the subshell */
246 int subshell_pty;
247 #endif /* !ENABLE_SUBSHELL */
249 /* This flag is set by xterm detection routine in function main() */
250 /* It is used by function toggle_subshell() */
251 gboolean xterm_flag;
253 /* disable x11 support */
254 gboolean disable_x11;
256 /* For slow terminals */
257 /* If true lines are shown by spaces */
258 gboolean slow_terminal;
260 /* Set to force black and white display at program startup */
261 gboolean disable_colors;
263 /* If true use +, -, | for line drawing */
264 gboolean ugly_line_drawing;
266 /* Tries to use old highlight mouse tracking */
267 gboolean old_mouse;
269 /* If true, use + and \ keys normally and select/unselect do if M-+ / M-\.
270 and M-- and keypad + / - */
271 gboolean alternate_plus_minus;
272 } tty;
274 struct
276 /* Set when cd symlink following is desirable (bash mode) */
277 gboolean cd_symlinks;
279 /* Preallocate space before file copying */
280 gboolean preallocate_space;
282 } vfs;
283 } mc_global_t;
285 /*** global variables defined in .c file *********************************************************/
287 extern mc_global_t mc_global;
289 /*** declarations of public functions ************************************************************/
291 /*** inline functions ****************************************************************************/
292 #endif