Browse Source

Reorder fields in mc_global struct and change type for some of them.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Andrew Borodin 13 years ago
parent
commit
dea3aa9023
10 changed files with 60 additions and 69 deletions
  1. 15 17
      lib/global.c
  2. 30 39
      lib/global.h
  3. 2 2
      lib/skin/common.c
  4. 3 3
      lib/widget/dialog-switch.c
  5. 1 1
      lib/widget/dialog.c
  6. 1 1
      lib/widget/menu.c
  7. 1 1
      src/args.c
  8. 1 1
      src/background.c
  9. 2 2
      src/diffviewer/ydiff.c
  10. 4 2
      src/editor/edit.c

+ 15 - 17
lib/global.c

@@ -32,7 +32,6 @@
 
 #include "global.h"
 
-
 /* *INDENT-OFF* */
 #ifdef HAVE_SUBSHELL_SUPPORT
 #  ifdef SUBSHELL_OPTIONAL
@@ -49,13 +48,11 @@
 
 /* *INDENT-OFF* */
 mc_global_t mc_global = {
-#ifdef ENABLE_BACKGROUND
-    .we_are_background = 0,
-#endif /* ENABLE_BACKGROUND */
-
-    .message_visible = 1,
-    .keybar_visible = 1,
     .mc_run_mode = MC_RUN_FULL,
+    .midnight_shutdown = FALSE,
+
+    .sysconfig_dir = NULL,
+    .share_data_dir = NULL,
 
 #ifdef HAVE_CHARSET
     .source_codepage = -1,
@@ -64,27 +61,29 @@ mc_global_t mc_global = {
     .eight_bit_clean = 1,
     .full_eight_bits = 0,
 #endif /* !HAVE_CHARSET */
+    .utf8_display = FALSE,
 
-    .utf8_display = 0,
-    .sysconfig_dir = NULL,
-    .share_data_dir = NULL,
-
-    .is_right = FALSE,
+    .message_visible = 1,
+    .keybar_visible = 1,
 
-    .skin = NULL,
+#ifdef ENABLE_BACKGROUND
+    .we_are_background = FALSE,
+#endif /* ENABLE_BACKGROUND */
 
     .widget =
     {
-        .midnight_shutdown = FALSE,
         .confirm_history_cleanup = TRUE,
-        .show_all_if_ambiguous = FALSE
+        .show_all_if_ambiguous = FALSE,
+        .is_right = FALSE
     },
 
     .tty =
     {
+        .skin = NULL,
         .setup_color_string = NULL,
         .term_color_string = NULL,
         .color_terminal_string = NULL,
+        .command_line_colors = NULL,
 #ifndef LINUX_CONS_SAVER_C
         .console_flag = '\0',
 #endif /* !LINUX_CONS_SAVER_C */
@@ -95,8 +94,6 @@ mc_global_t mc_global = {
         .subshell_pty = 0,
 #endif /* !HAVE_SUBSHELL_SUPPORT */
 
-        .winch_flag = FALSE,
-        .command_line_colors = NULL,
         .xterm_flag = FALSE,
         .disable_x11 = FALSE,
         .slow_terminal = FALSE,
@@ -104,6 +101,7 @@ mc_global_t mc_global = {
         .ugly_line_drawing = FALSE,
         .old_mouse = FALSE,
         .alternate_plus_minus = FALSE,
+        .winch_flag = FALSE
     },
 
     .vfs =

+ 30 - 39
lib/global.h

@@ -159,24 +159,15 @@ typedef enum
 
 typedef struct
 {
-#ifdef ENABLE_BACKGROUND
-    /* If true, this is a background process */
-    int we_are_background;
-#endif                          /* ENABLE_BACKGROUND */
-
-    /*
-     * If utf-8 terminal utf8_display = 1
-     * Display bits set UTF-8
-     */
-    int utf8_display;
-
-    /* Set if the nice message (hint) bar is visible */
-    int message_visible;
-
-    /* Set if the nice and useful keybar is visible */
-    int keybar_visible;
-
     mc_run_mode_t mc_run_mode;
+    /* Used so that widgets know if they are being destroyed or shut down */
+    gboolean midnight_shutdown;
+
+    /* sysconfig_dir: Area for default settings from maintainers of distributuves
+       default is /etc/mc or may be defined by MC_DATADIR */
+    char *sysconfig_dir;
+    /* share_data_dir: Area for default settings from developers */
+    char *share_data_dir;
 
 #ifdef HAVE_CHARSET
     /* Numbers of (file I/O) and (input/display) codepages. -1 if not selected */
@@ -191,43 +182,45 @@ typedef struct
      */
     int full_eight_bits;
 #endif                          /* !HAVE_CHARSET */
-
-    /* sysconfig_dir: Area for default settings from maintainers of distributuves
-       default is /etc/mc or may be defined by MC_DATADIR
+    /*
+     * If utf-8 terminal utf8_display = TRUE
+     * Display bits set UTF-8
      */
-    char *sysconfig_dir;
+    gboolean utf8_display;
 
-    /* share_data_dir: Area for default settings from developers */
-    char *share_data_dir;
-
-    /* Ugly hack in order to distinguish between left and right panel in menubar */
-    /* Set if the command is being run from the "Right" menu */
-    gboolean is_right;          /* If the selected menu was the right */
+    /* Set if the nice message (hint) bar is visible */
+    int message_visible;
+    /* Set if the nice and useful keybar is visible */
+    int keybar_visible;
 
-    /* Use the specified skin */
-    char *skin;
+#ifdef ENABLE_BACKGROUND
+    /* If true, this is a background process */
+    gboolean we_are_background;
+#endif                          /* ENABLE_BACKGROUND */
 
     struct
     {
-        /* Used so that widgets know if they are being destroyed or shut down */
-        gboolean midnight_shutdown;
-
         /* Asks for confirmation before clean up of history */
         gboolean confirm_history_cleanup;
 
         /* Set if you want the possible completions dialog for the first time */
         gboolean show_all_if_ambiguous;
 
+        /* Ugly hack in order to distinguish between left and right panel in menubar */
+        /* Set if the command is being run from the "Right" menu */
+        gboolean is_right;          /* If the selected menu was the right */
     } widget;
 
     struct
     {
+        /* Use the specified skin */
+        char *skin;
+
         char *setup_color_string;
         char *term_color_string;
         char *color_terminal_string;
-
-        /* Set if the window has changed it's size */
-        gboolean winch_flag;
+        /* colors specified on the command line: they override any other setting */
+        char *command_line_colors;
 
 #ifndef LINUX_CONS_SAVER_C
         /* Used only in mc, not in cons.saver */
@@ -240,9 +233,6 @@ typedef struct
         int subshell_pty;
 #endif                          /* !HAVE_SUBSHELL_SUPPORT */
 
-        /* colors specified on the command line: they override any other setting */
-        char *command_line_colors;
-
         /* This flag is set by xterm detection routine in function main() */
         /* It is used by function view_other_cmd() */
         gboolean xterm_flag;
@@ -267,6 +257,8 @@ typedef struct
            and M-- and keypad + / - */
         gboolean alternate_plus_minus;
 
+        /* Set if the window has changed it's size */
+        gboolean winch_flag;
     } tty;
 
     struct
@@ -278,7 +270,6 @@ typedef struct
         gboolean preallocate_space;
 
     } vfs;
-
 } mc_global_t;
 
 /*** global variables defined in .c file *********************************************************/

+ 2 - 2
lib/skin/common.c

@@ -66,8 +66,8 @@ mc_skin_get_default_name (void)
     char *tmp_str;
 
     /* from command line */
-    if (mc_global.skin != NULL)
-        return g_strdup (mc_global.skin);
+    if (mc_global.tty.skin != NULL)
+        return g_strdup (mc_global.tty.skin);
 
     /* from envirovement variable */
     tmp_str = getenv ("MC_SKIN");

+ 3 - 3
lib/widget/dialog-switch.c

@@ -198,7 +198,7 @@ dialog_switch_next (void)
 {
     GList *next;
 
-    if (mc_global.widget.midnight_shutdown || mc_current == NULL)
+    if (mc_global.midnight_shutdown || mc_current == NULL)
         return;
 
     next = g_list_next (mc_current);
@@ -215,7 +215,7 @@ dialog_switch_prev (void)
 {
     GList *prev;
 
-    if (mc_global.widget.midnight_shutdown || mc_current == NULL)
+    if (mc_global.midnight_shutdown || mc_current == NULL)
         return;
 
     prev = g_list_previous (mc_current);
@@ -237,7 +237,7 @@ dialog_switch_list (void)
     int i = 0;
     int rv;
 
-    if (mc_global.widget.midnight_shutdown || mc_current == NULL)
+    if (mc_global.midnight_shutdown || mc_current == NULL)
         return;
 
     lines = min ((size_t) (LINES * 2 / 3), dlg_num);

+ 1 - 1
lib/widget/dialog.c

@@ -529,7 +529,7 @@ frontend_run_dlg (Dlg_head * h)
     event.x = -1;
 
     /* close opened editors, viewers, etc */
-    if (!h->modal && mc_global.widget.midnight_shutdown)
+    if (!h->modal && mc_global.midnight_shutdown)
     {
         h->callback (h, NULL, DLG_VALIDATE, 0, NULL);
         return;

+ 1 - 1
lib/widget/menu.c

@@ -315,7 +315,7 @@ menubar_execute (WMenuBar * menubar)
 
     if ((entry != NULL) && (entry->command != CK_IgnoreKey))
     {
-        mc_global.is_right = (menubar->selected != 0);
+        mc_global.widget.is_right = (menubar->selected != 0);
         menubar_finish (menubar);
         menubar->widget.owner->callback (menubar->widget.owner, &menubar->widget,
                                          DLG_ACTION, entry->command, NULL);

+ 1 - 1
src/args.c

@@ -304,7 +304,7 @@ static const GOptionEntry argument_color_table[] = {
 
     {
      "skin", 'S', ARGS_COLOR_OPTIONS, G_OPTION_ARG_STRING,
-     &mc_global.skin,
+     &mc_global.tty.skin,
      N_("Show mc with specified skin"),
      "<string>"
     },

+ 1 - 1
src/background.c

@@ -540,7 +540,7 @@ do_background (struct FileOpContext *ctx, char *info)
         parent_fd = comm[1];
         from_parent_fd = back_comm[0];
 
-        mc_global.we_are_background = 1;
+        mc_global.we_are_background = TRUE;
         top_dlg = NULL;
 
         /* Make stdin/stdout/stderr point somewhere */

+ 2 - 2
src/diffviewer/ydiff.c

@@ -2961,13 +2961,13 @@ dview_ok_to_exit (WDiff * dview)
     if (!dview->merged)
         return res;
 
-    act = query_dialog (_("Quit"), !mc_global.widget.midnight_shutdown ?
+    act = query_dialog (_("Quit"), !mc_global.midnight_shutdown ?
                         _("File was modified. Save with exit?") :
                         _("Midnight Commander is being shut down.\nSave modified file?"),
                         D_NORMAL, 2, _("&Yes"), _("&No"));
 
     /* Esc is No */
-    if (mc_global.widget.midnight_shutdown || (act == -1))
+    if (mc_global.midnight_shutdown || (act == -1))
         act = 1;
 
     switch (act)

+ 4 - 2
src/editor/edit.c

@@ -3634,11 +3634,13 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
         if (option_cursor_beyond_eol && edit->over_col > 0)
             edit_insert_over (edit);
 #ifdef HAVE_CHARSET
-        if (char_for_insertion > 255 && mc_global.utf8_display == 0)
+        if (char_for_insertion > 255 && !mc_global.utf8_display)
         {
             unsigned char str[6 + 1];
             size_t i = 0;
-            int res = g_unichar_to_utf8 (char_for_insertion, (char *) str);
+            int res;
+
+            res = g_unichar_to_utf8 (char_for_insertion, (char *) str);
             if (res == 0)
             {
                 str[0] = '.';

Some files were not shown because too many files changed in this diff