Merge branch '4600_filter_segfault'
[midnight-commander.git] / lib / global.h
blob65454d15c5a99c79f03d527d0428c518421dfb1d
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 #include <glib.h>
12 #if defined(HAVE_FUNC_ATTRIBUTE_WEAK) && defined(HAVE_TESTS)
13 #define MC_MOCKABLE __attribute__((weak))
14 #else
15 #define MC_MOCKABLE
16 #endif
18 #include "glibcompat.h"
20 #include "unixcompat.h"
22 #include "fs.h"
23 #include "shell.h"
24 #include "mcconfig.h"
26 /*** typedefs(not structures) and defined constants **********************************************/
28 #ifdef ENABLE_NLS
29 #include <libintl.h>
30 #define _(String) gettext (String)
31 #ifdef gettext_noop
32 #define N_(String) gettext_noop (String)
33 #else
34 #define N_(String) (String)
35 #endif
36 #else /* Stubs that do something close enough. */
37 #define textdomain(String) 1
38 #define gettext(String) (String)
39 #define ngettext(String1,String2,Num) (((Num) == 1) ? (String1) : (String2))
40 #define dgettext(Domain,Message) (Message)
41 #define dcgettext(Domain,Message,Type) (Message)
42 #define bindtextdomain(Domain,Directory) 1
43 #define _(String) (String)
44 #define N_(String) (String)
45 #endif /* !ENABLE_NLS */
47 #ifdef HAVE_FUNC_ATTRIBUTE_FALLTHROUGH
48 #define MC_FALLTHROUGH __attribute__((fallthrough))
49 #else
50 #define MC_FALLTHROUGH
51 #endif
53 #ifdef USE_MAINTAINER_MODE
54 #include "lib/logging.h"
55 #endif
57 /* Just for keeping Your's brains from invention a proper size of the buffer :-) */
58 #define BUF_10K 10240L
59 #define BUF_8K 8192L
60 #define BUF_4K 4096L
61 #define BUF_1K 1024L
63 #define BUF_LARGE BUF_1K
64 #define BUF_MEDIUM 512
65 #define BUF_SMALL 128
66 #define BUF_TINY 64
68 #define UTF8_CHAR_LEN 6
70 /* Used to distinguish between a normal MC termination and */
71 /* one caused by typing 'exit' or 'logout' in the subshell */
72 #define SUBSHELL_EXIT 128
74 #define MC_ERROR g_quark_from_static_string (PACKAGE)
76 #define DEFAULT_CHARSET "ASCII"
78 /*** enums ***************************************************************************************/
80 /* run mode and params */
81 typedef enum
83 MC_RUN_FULL = 0,
84 MC_RUN_EDITOR,
85 MC_RUN_VIEWER,
86 MC_RUN_DIFFVIEWER
87 } mc_run_mode_t;
89 /*** structures declarations (and typedefs of structures)*****************************************/
91 typedef struct
93 const char *mc_version;
95 mc_run_mode_t mc_run_mode;
96 gboolean run_from_parent_mc;
97 /* Used so that widgets know if they are being destroyed or shut down */
98 gboolean midnight_shutdown;
100 /* sysconfig_dir: Area for default settings from maintainers of distributuves
101 default is /etc/mc or may be defined by MC_DATADIR */
102 char *sysconfig_dir;
103 /* share_data_dir: Area for default settings from developers */
104 char *share_data_dir;
106 char *profile_name;
108 mc_config_t *main_config;
109 mc_config_t *panels_config;
111 #ifdef HAVE_CHARSET
112 /* Numbers of (file I/O) and (input/display) codepages. -1 if not selected */
113 int source_codepage;
114 int display_codepage;
115 #else
116 /* If true, allow characters in the range 160-255 */
117 gboolean eight_bit_clean;
119 * If true, also allow characters in the range 128-159.
120 * This is reported to break on many terminals (xterm, qansi-m).
122 gboolean full_eight_bits;
123 #endif /* !HAVE_CHARSET */
125 * If utf-8 terminal utf8_display = TRUE
126 * Display bits set UTF-8
128 gboolean utf8_display;
130 /* Set if the nice message (hint) bar is visible */
131 gboolean message_visible;
132 /* Set if the nice and useful keybar is visible */
133 gboolean keybar_visible;
135 #ifdef ENABLE_BACKGROUND
136 /* If true, this is a background process */
137 gboolean we_are_background;
138 #endif /* ENABLE_BACKGROUND */
140 struct
142 /* Asks for confirmation before clean up of history */
143 gboolean confirm_history_cleanup;
145 /* Set if you want the possible completions dialog for the first time */
146 gboolean show_all_if_ambiguous;
148 /* Ugly hack in order to distinguish between left and right panel in menubar */
149 /* Set if the command is being run from the "Right" menu */
150 gboolean is_right; /* If the selected menu was the right */
151 } widget;
153 /* The user's shell */
154 mc_shell_t *shell;
156 struct
158 /* Use the specified skin */
159 char *skin;
160 /* Dialog window and drop down menu have a shadow */
161 gboolean shadows;
163 char *setup_color_string;
164 char *term_color_string;
165 char *color_terminal_string;
166 /* colors specified on the command line: they override any other setting */
167 char *command_line_colors;
169 #ifndef LINUX_CONS_SAVER_C
170 /* Used only in mc, not in cons.saver */
171 char console_flag;
172 #endif /* !LINUX_CONS_SAVER_C */
173 /* If using a subshell for evaluating commands this is true */
174 gboolean use_subshell;
176 #ifdef ENABLE_SUBSHELL
177 /* File descriptors of the pseudoterminal used by the subshell */
178 int subshell_pty;
179 #endif /* !ENABLE_SUBSHELL */
181 /* This flag is set by xterm detection routine in function main() */
182 /* It is used by function toggle_subshell() */
183 gboolean xterm_flag;
185 /* disable x11 support */
186 gboolean disable_x11;
188 /* For slow terminals */
189 /* If true lines are shown by spaces */
190 gboolean slow_terminal;
192 /* Set to force black and white display at program startup */
193 gboolean disable_colors;
195 /* If true use +, -, | for line drawing */
196 gboolean ugly_line_drawing;
198 /* Tries to use old highlight mouse tracking */
199 gboolean old_mouse;
201 /* If true, use + and \ keys normally and select/unselect do if M-+ / M-\.
202 and M-- and keypad + / - */
203 gboolean alternate_plus_minus;
204 } tty;
206 struct
208 /* Set when cd symlink following is desirable (bash mode) */
209 gboolean cd_symlinks;
211 /* Preallocate space before file copying */
212 gboolean preallocate_space;
214 } vfs;
215 } mc_global_t;
217 /*** global variables defined in .c file *********************************************************/
219 extern mc_global_t mc_global;
221 /*** declarations of public functions ************************************************************/
223 /*** inline functions ****************************************************************************/
224 #endif