Simplify constructing of file operation progress dialog.
[midnight-commander.git] / lib / global.h
blob39c660362b8b5c632699c63d18a06d9c717b9f69
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(STDC_HEADERS) || defined(HAVE_STRING_H)
11 #include <string.h>
12 /* An ANSI string.h and pre-ANSI memory.h might conflict */
13 #if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
14 #include <memory.h>
15 #endif /* !STDC_HEADERS & HAVE_MEMORY_H */
17 #else /* !STDC_HEADERS & !HAVE_STRING_H */
18 #include <strings.h>
19 /* memory and strings.h conflict on other systems */
20 #endif /* !STDC_HEADERS & !HAVE_STRING_H */
22 #ifdef HAVE_SYS_PARAM_H
23 #include <sys/param.h>
24 #endif
26 /*** typedefs(not structures) and defined constants **********************************************/
28 /* The O_BINARY definition was taken from gettext */
29 #if !defined O_BINARY && defined _O_BINARY
30 /* For MSC-compatible compilers. */
31 #define O_BINARY _O_BINARY
32 #endif
33 #ifdef __BEOS__
34 /* BeOS 5 has O_BINARY, but is has no effect. */
35 #undef O_BINARY
36 #endif
37 /* On reasonable systems, binary I/O is the default. */
38 #ifndef O_BINARY
39 #define O_BINARY 0
40 #endif
42 /* Replacement for O_NONBLOCK */
43 #ifndef O_NONBLOCK
44 #ifdef O_NDELAY /* SYSV */
45 #define O_NONBLOCK O_NDELAY
46 #else /* BSD */
47 #define O_NONBLOCK FNDELAY
48 #endif /* !O_NDELAY */
49 #endif /* !O_NONBLOCK */
51 #ifdef HAVE_SYS_SELECT_H
52 #include <sys/select.h>
53 #endif
55 #if defined(__QNX__) && !defined(__QNXNTO__)
56 /* exec*() from <process.h> */
57 #include <unix.h>
58 #endif
60 #include <glib.h>
61 #include "glibcompat.h"
63 #ifndef __GNUC__
64 #define __attribute__(x)
65 #endif
67 /* Solaris9 doesn't have PRIXMAX */
68 #ifndef PRIXMAX
69 #define PRIXMAX PRIxMAX
70 #endif
72 #ifdef ENABLE_NLS
73 #include <libintl.h>
74 #define _(String) gettext (String)
75 #ifdef gettext_noop
76 #define N_(String) gettext_noop (String)
77 #else
78 #define N_(String) (String)
79 #endif
80 #else /* Stubs that do something close enough. */
81 #define textdomain(String) 1
82 #define gettext(String) (String)
83 #define ngettext(String1,String2,Num) (((Num) == 1) ? (String1) : (String2))
84 #define dgettext(Domain,Message) (Message)
85 #define dcgettext(Domain,Message,Type) (Message)
86 #define bindtextdomain(Domain,Directory) 1
87 #define _(String) (String)
88 #define N_(String) (String)
89 #endif /* !ENABLE_NLS */
91 #include "fs.h"
93 #ifdef USE_MAINTAINER_MODE
94 #include "lib/logging.h"
95 #endif
97 #ifdef min
98 #undef min
99 #endif
101 #ifdef max
102 #undef max
103 #endif
105 #define min(x, y) ((x) > (y) ? (y) : (x))
106 #define max(x, y) ((x) > (y) ? (x) : (y))
108 /* Just for keeping Your's brains from invention a proper size of the buffer :-) */
109 #define BUF_10K 10240L
110 #define BUF_8K 8192L
111 #define BUF_4K 4096L
112 #define BUF_1K 1024L
114 #define BUF_LARGE BUF_1K
115 #define BUF_MEDIUM 512
116 #define BUF_SMALL 128
117 #define BUF_TINY 64
119 /* AIX compiler doesn't understand '\e' */
120 #define ESC_CHAR '\033'
121 #define ESC_STR "\033"
123 /* OS specific defines */
124 #define PATH_SEP '/'
125 #define PATH_SEP_STR "/"
126 #define PATH_ENV_SEP ':'
127 #define TMPDIR_DEFAULT "/tmp"
128 #define SCRIPT_SUFFIX ""
129 #define get_default_editor() "vi"
130 #define OS_SORT_CASE_SENSITIVE_DEFAULT 1
131 #define UTF8_CHAR_LEN 6
133 /* C++ style type casts */
134 #define const_cast(m_type, m_expr) ((m_type) (m_expr))
136 #if 0
137 #ifdef MC_ENABLE_DEBUGGING_CODE
138 #undef NDEBUG
139 #else
140 #define NDEBUG
141 #endif
142 #include <assert.h>
143 #endif
145 #define MC_ERROR g_quark_from_static_string (PACKAGE)
147 /*** enums ***************************************************************************************/
149 /* run mode and params */
150 typedef enum
152 MC_RUN_FULL = 0,
153 MC_RUN_EDITOR,
154 MC_RUN_VIEWER,
155 MC_RUN_DIFFVIEWER
156 } mc_run_mode_t;
158 /*** structures declarations (and typedefs of structures)*****************************************/
160 typedef struct
162 #ifdef WITH_BACKGROUND
163 /* If true, this is a background process */
164 int we_are_background;
165 #endif /* WITH_BACKGROUND */
168 * If utf-8 terminal utf8_display = 1
169 * Display bits set UTF-8
171 int utf8_display;
173 /* Set if the nice message (hint) bar is visible */
174 int message_visible;
176 /* Set if the nice and useful keybar is visible */
177 int keybar_visible;
179 mc_run_mode_t mc_run_mode;
181 #ifdef HAVE_CHARSET
182 /* Numbers of (file I/O) and (input/display) codepages. -1 if not selected */
183 int source_codepage;
184 int display_codepage;
185 #else
186 /* If true, allow characters in the range 160-255 */
187 int eight_bit_clean;
189 * If true, also allow characters in the range 128-159.
190 * This is reported to break on many terminals (xterm, qansi-m).
192 int full_eight_bits;
193 #endif /* !HAVE_CHARSET */
195 /* sysconfig_dir: Area for default settings from maintainers of distributuves
196 default is /etc/mc or may be defined by MC_DATADIR
198 char *sysconfig_dir;
200 /* share_data_dir: Area for default settings from developers */
201 char *share_data_dir;
203 /* Ugly hack in order to distinguish between left and right panel in menubar */
204 /* Set if the command is being run from the "Right" menu */
205 gboolean is_right; /* If the selected menu was the right */
207 /* Use the specified skin */
208 char *skin;
210 struct
212 /* Used so that widgets know if they are being destroyed or shut down */
213 gboolean midnight_shutdown;
215 /* Asks for confirmation before clean up of history */
216 gboolean confirm_history_cleanup;
218 /* Set if you want the possible completions dialog for the first time */
219 gboolean show_all_if_ambiguous;
221 } widget;
223 struct
225 char *setup_color_string;
226 char *term_color_string;
227 char *color_terminal_string;
229 /* Set if the window has changed it's size */
230 gboolean winch_flag;
232 #ifndef LINUX_CONS_SAVER_C
233 /* Used only in mc, not in cons.saver */
234 char console_flag;
235 #endif /* !LINUX_CONS_SAVER_C */
236 /* If using a subshell for evaluating commands this is true */
237 gboolean use_subshell;
238 #ifdef HAVE_SUBSHELL_SUPPORT
239 /* File descriptors of the pseudoterminal used by the subshell */
240 int subshell_pty;
241 #endif /* !HAVE_SUBSHELL_SUPPORT */
243 /* colors specified on the command line: they override any other setting */
244 char *command_line_colors;
246 /* This flag is set by xterm detection routine in function main() */
247 /* It is used by function view_other_cmd() */
248 gboolean xterm_flag;
250 /* disable x11 support */
251 gboolean disable_x11;
253 /* For slow terminals */
254 /* If true lines are shown by spaces */
255 gboolean slow_terminal;
257 /* Set to force black and white display at program startup */
258 gboolean disable_colors;
260 /* If true use +, -, | for line drawing */
261 gboolean ugly_line_drawing;
263 /* Tries to use old highlight mouse tracking */
264 gboolean old_mouse;
266 /* If true, use + and \ keys normally and select/unselect do if M-+ / M-\.
267 and M-- and keypad + / - */
268 gboolean alternate_plus_minus;
270 } tty;
272 struct
274 /* Set when cd symlink following is desirable (bash mode) */
275 gboolean cd_symlinks;
277 /* Preallocate space before file copying */
278 gboolean preallocate_space;
280 } vfs;
282 } mc_global_t;
284 /*** global variables defined in .c file *********************************************************/
286 extern mc_global_t mc_global;
288 /*** declarations of public functions ************************************************************/
290 void refresh_screen (void *);
292 /*** inline functions ****************************************************************************/
293 #endif