global.h 6.4 KB

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