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

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2012-01-28 13:13:32 +03:00 committed by Slava Zanko
parent 0960ef2541
commit dea3aa9023
18 changed files with 74 additions and 83 deletions

View File

@ -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,
.message_visible = 1,
.keybar_visible = 1,
.is_right = FALSE,
.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 =

View File

@ -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;
/* Set if the nice message (hint) bar is visible */
int message_visible;
/* Set if the nice and useful keybar is visible */
int keybar_visible;
/* 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 */
/* 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 *********************************************************/

View File

@ -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");

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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>"
},

View File

@ -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 */

View File

@ -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)

View File

@ -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] = '.';

View File

@ -2560,7 +2560,7 @@ edit_ok_to_exit (WEdit * edit)
if (!edit->modified)
return TRUE;
if (!mc_global.widget.midnight_shutdown)
if (!mc_global.midnight_shutdown)
{
if (!edit_check_newline (edit))
return FALSE;
@ -2586,8 +2586,8 @@ edit_ok_to_exit (WEdit * edit)
case 0: /* Yes */
edit_push_markers (edit);
edit_set_markers (edit, 0, 0, 0, 0);
if (!edit_save_cmd (edit) || mc_global.widget.midnight_shutdown)
return mc_global.widget.midnight_shutdown;
if (!edit_save_cmd (edit) || mc_global.midnight_shutdown)
return mc_global.midnight_shutdown;
break;
case 1: /* No */
break;

View File

@ -534,7 +534,7 @@ print_vfs_message (const gchar * event_group_name, const gchar * event_name,
g_vsnprintf (str, sizeof (str), event_data->msg, event_data->ap);
if (mc_global.widget.midnight_shutdown)
if (mc_global.midnight_shutdown)
return TRUE;
if (!mc_global.message_visible || !the_hint || !the_hint->widget.owner)
@ -1700,7 +1700,7 @@ do_nc (void)
}
/* Program end */
mc_global.widget.midnight_shutdown = TRUE;
mc_global.midnight_shutdown = TRUE;
dialog_switch_shutdown ();
done_mc ();
destroy_dlg (midnight_dlg);

View File

@ -14,9 +14,9 @@
/*** typedefs(not structures) and defined constants **********************************************/
#define MENU_PANEL (mc_global.is_right ? right_panel : left_panel)
#define MENU_PANEL_IDX (mc_global.is_right ? 1 : 0)
#define SELECTED_IS_PANEL (get_display_type (mc_global.is_right ? 1 : 0) == view_listing)
#define MENU_PANEL (mc_global.widget.is_right ? right_panel : left_panel)
#define MENU_PANEL_IDX (mc_global.widget.is_right ? 1 : 0)
#define SELECTED_IS_PANEL (get_display_type (mc_global.widget.is_right ? 1 : 0) == view_listing)
#define other_panel get_other_panel()

View File

@ -1374,7 +1374,7 @@ static char *
panel_save_name (WPanel * panel)
{
/* If the program is shuting down */
if ((mc_global.widget.midnight_shutdown && auto_save_setup) || saving_setup)
if ((mc_global.midnight_shutdown && auto_save_setup) || saving_setup)
return g_strdup (panel->panel_name);
else
return g_strconcat ("Temporal:", panel->panel_name, (char *) NULL);

View File

@ -560,7 +560,7 @@ main (int argc, char *argv[])
mc_prompt = (geteuid () == 0) ? "# " : "$ ";
/* Program main loop */
if (mc_global.widget.midnight_shutdown)
if (mc_global.midnight_shutdown)
exit_code = EXIT_SUCCESS;
else
exit_code = do_nc () ? EXIT_SUCCESS : EXIT_FAILURE;

View File

@ -774,7 +774,7 @@ init_subshell (void)
return;
case 2:
mc_global.tty.use_subshell = FALSE;
mc_global.widget.midnight_shutdown = TRUE;
mc_global.midnight_shutdown = TRUE;
return;
}

View File

@ -510,7 +510,7 @@ mcview_callback (Widget * w, widget_msg_t msg, int parm)
{
delete_hook (&select_file_hook, mcview_hook);
if (mc_global.widget.midnight_shutdown)
if (mc_global.midnight_shutdown)
mcview_ok_to_quit (view);
}
mcview_done (view);

View File

@ -147,7 +147,7 @@ mcview_ok_to_quit (mcview_t * view)
if (view->change_list == NULL)
return TRUE;
if (!mc_global.widget.midnight_shutdown)
if (!mc_global.midnight_shutdown)
{
query_set_sel (2);
r = query_dialog (_("Quit"),
@ -167,7 +167,7 @@ mcview_ok_to_quit (mcview_t * view)
switch (r)
{
case 0: /* Yes */
return mcview_hexedit_save_changes (view) || mc_global.widget.midnight_shutdown;
return mcview_hexedit_save_changes (view) || mc_global.midnight_shutdown;
case 1: /* No */
mcview_hexedit_free_change_list (view);
return TRUE;