global.h 6.3 KB

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