diff --git a/lib/global.c b/lib/global.c index 10e4759e8..0c63dc5b2 100644 --- a/lib/global.c +++ b/lib/global.c @@ -65,8 +65,8 @@ mc_global_t mc_global = { #endif /* !HAVE_CHARSET */ .utf8_display = FALSE, - .message_visible = 1, - .keybar_visible = 1, + .message_visible = TRUE, + .keybar_visible = TRUE, #ifdef ENABLE_BACKGROUND .we_are_background = FALSE, diff --git a/lib/global.h b/lib/global.h index 8edccf625..244781df6 100644 --- a/lib/global.h +++ b/lib/global.h @@ -200,9 +200,9 @@ typedef struct gboolean utf8_display; /* Set if the nice message (hint) bar is visible */ - int message_visible; + gboolean message_visible; /* Set if the nice and useful keybar is visible */ - int keybar_visible; + gboolean keybar_visible; #ifdef ENABLE_BACKGROUND /* If true, this is a background process */ diff --git a/lib/tty/win.c b/lib/tty/win.c index d5f684215..fca5ee702 100644 --- a/lib/tty/win.c +++ b/lib/tty/win.c @@ -103,8 +103,8 @@ show_rxvt_contents (int starty, unsigned char y1, unsigned char y2) unsigned char *k; int bytes, i, j, cols = 0; - y1 += (mc_global.keybar_visible != 0); /* i don't knwo why we need this - paul */ - y2 += (mc_global.keybar_visible != 0); + y1 += mc_global.keybar_visible != 0 ? 1 : 0; /* i don't knwo why we need this - paul */ + y2 += mc_global.keybar_visible != 0 ? 1 : 0; while (anything_ready ()) tty_lowlevel_getch (); diff --git a/src/execute.c b/src/execute.c index 3233959d7..846581d1a 100644 --- a/src/execute.c +++ b/src/execute.c @@ -554,10 +554,10 @@ toggle_subshell (void) do_load_prompt (); if (new_dir_vpath != NULL) do_possible_cd (new_dir_vpath); - if (mc_global.tty.console_flag != '\0' && output_lines) + if (mc_global.tty.console_flag != '\0' && output_lines != 0) show_console_contents (output_start_y, - LINES - mc_global.keybar_visible - output_lines - - 1, LINES - mc_global.keybar_visible - 1); + LINES - (mc_global.keybar_visible ? 1 : 0) - output_lines - + 1, LINES - (mc_global.keybar_visible ? 1 : 0) - 1); } else if (new_dir_vpath != NULL && mc_chdir (new_dir_vpath) != -1) vfs_setup_cwd (); diff --git a/src/filemanager/command.c b/src/filemanager/command.c index 7e71f4d37..8b4323661 100644 --- a/src/filemanager/command.c +++ b/src/filemanager/command.c @@ -52,7 +52,7 @@ #include "src/usermenu.h" /* expand_format */ #include "midnight.h" /* current_panel */ -#include "layout.h" /* for command_prompt variable */ +#include "layout.h" /* command_prompt */ #include "tree.h" /* sync_tree() */ #include "command.h" diff --git a/src/filemanager/ext.c b/src/filemanager/ext.c index 5bedaa586..3000dfc87 100644 --- a/src/filemanager/ext.c +++ b/src/filemanager/ext.c @@ -509,10 +509,10 @@ exec_extension (void *target, const vfs_path_t * filename_vpath, const char *lc_ if (mc_global.tty.console_flag != '\0') { handle_console (CONSOLE_SAVE); - if (output_lines && mc_global.keybar_visible) + if (output_lines != 0 && mc_global.keybar_visible) show_console_contents (output_start_y, - LINES - mc_global.keybar_visible - - output_lines - 1, LINES - mc_global.keybar_visible - 1); + LINES - (mc_global.keybar_visible ? 1 : 0) - output_lines - + 1, LINES - (mc_global.keybar_visible ? 1 : 0) - 1); } } diff --git a/src/filemanager/layout.c b/src/filemanager/layout.c index 99ab3177f..c47843a92 100644 --- a/src/filemanager/layout.c +++ b/src/filemanager/layout.c @@ -71,14 +71,14 @@ panels_layout_t panels_layout = { /* Set if the panels are split horizontally */ - .horizontal_split = 0, + .horizontal_split = FALSE, /* vertical split */ - .vertical_equal = 1, + .vertical_equal = TRUE, .left_panel_size = 0, /* horizontal split */ - .horizontal_equal = 1, + .horizontal_equal = TRUE, .top_panel_size = 0 }; @@ -92,13 +92,13 @@ int output_lines = 0; gboolean command_prompt = TRUE; /* Set if the main menu is visible */ -int menubar_visible = 1; +gboolean menubar_visible = TRUE; /* Set to show current working dir in xterm window title */ gboolean xterm_title = TRUE; /* Set to show free space on device assigned to current directory */ -int free_space = 1; +gboolean free_space = TRUE; /* The starting line for the output of the subprogram */ int output_start_y = 0; @@ -157,7 +157,7 @@ static WRadio *radio_widget; static struct { const char *text; - int *variable; + gboolean *variable; WCheck *widget; } check_options[] = { @@ -226,9 +226,9 @@ update_split (const WDialog * h) check_split (&panels_layout); if (panels_layout.horizontal_split) - check_options[0].widget->state = panels_layout.horizontal_equal ? 1 : 0; + check_options[0].widget->state = panels_layout.horizontal_equal; else - check_options[0].widget->state = panels_layout.vertical_equal ? 1 : 0; + check_options[0].widget->state = panels_layout.vertical_equal; widget_draw (WIDGET (check_options[0].widget)); tty_setcolor (check_options[0].widget->state ? DISABLED_COLOR : COLOR_NORMAL); @@ -335,7 +335,7 @@ layout_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void * case MSG_POST_KEY: { const Widget *mw = CONST_WIDGET (midnight_dlg); - int _menubar_visible, _command_prompt, _keybar_visible, _message_visible; + gboolean _menubar_visible, _command_prompt, _keybar_visible, _message_visible; _menubar_visible = check_options[1].widget->state; _command_prompt = check_options[2].widget->state; @@ -344,8 +344,8 @@ layout_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void * if (mc_global.tty.console_flag == '\0') height = - mw->lines - _keybar_visible - _command_prompt - _menubar_visible - - _output_lines - _message_visible; + mw->lines - (_keybar_visible ? 1 : 0) - (_command_prompt ? 1 : 0) - + (_menubar_visible ? 1 : 0) - _output_lines - (_message_visible ? 1 : 0); else { int minimum; @@ -353,9 +353,9 @@ layout_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void * if (_output_lines < 0) _output_lines = 0; height = - mw->lines - _keybar_visible - _command_prompt - _menubar_visible - - _output_lines - _message_visible; - minimum = MINHEIGHT * (1 + panels_layout.horizontal_split); + mw->lines - (_keybar_visible ? 1 : 0) - (_command_prompt ? 1 : 0) - + (_menubar_visible ? 1 : 0) - _output_lines - (_message_visible ? 1 : 0); + minimum = MINHEIGHT * (1 + (panels_layout.horizontal_split ? 1 : 0)); if (height < minimum) { _output_lines -= minimum - height; @@ -376,13 +376,13 @@ layout_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void * case MSG_NOTIFY: if (sender == WIDGET (radio_widget)) { - if (panels_layout.horizontal_split == radio_widget->sel) + if ((panels_layout.horizontal_split ? 1 : 0) == radio_widget->sel) update_split (h); else { int eq; - panels_layout.horizontal_split = radio_widget->sel; + panels_layout.horizontal_split = radio_widget->sel != 0; if (panels_layout.horizontal_split) { @@ -410,7 +410,7 @@ layout_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void * if (sender == WIDGET (check_options[0].widget)) { - int eq; + gboolean eq; if (panels_layout.horizontal_split) { @@ -523,7 +523,7 @@ layout_dlg_create (void) add_widget (layout_dlg, groupbox_new (2, 3, 6, l1, title1)); radio_widget = radio_new (3, 5, 2, s_split_direction); - radio_widget->sel = panels_layout.horizontal_split; + radio_widget->sel = panels_layout.horizontal_split ? 1 : 0; add_widget (layout_dlg, radio_widget); check_options[0].widget = check_new (5, 5, XTRACT (0)); @@ -747,8 +747,8 @@ setup_panels (void) /* iniitial height of panels */ height = - mw->lines - menubar_visible - mc_global.message_visible - (command_prompt ? 1 : 0) - - mc_global.keybar_visible; + mw->lines - (menubar_visible ? 1 : 0) - (mc_global.message_visible ? 1 : 0) - + (command_prompt ? 1 : 0) - (mc_global.keybar_visible ? 1 : 0); if (mc_global.tty.console_flag != '\0') { @@ -758,7 +758,7 @@ setup_panels (void) output_lines = 0; else height -= output_lines; - minimum = MINHEIGHT * (1 + panels_layout.horizontal_split); + minimum = MINHEIGHT * (1 + (panels_layout.horizontal_split ? 1 : 0)); if (height < minimum) { output_lines -= minimum - height; @@ -770,7 +770,7 @@ setup_panels (void) menubar_set_visible (the_menubar, menubar_visible); check_split (&panels_layout); - start_y = mw->y + menubar_visible; + start_y = mw->y + (menubar_visible ? 1 : 0); /* update columns first... */ panel_do_cols (0); @@ -798,13 +798,14 @@ setup_panels (void) widget_set_size (WIDGET (the_hint), 0, 0, 0, 0); /* Output window */ - if (mc_global.tty.console_flag != '\0' && output_lines) + if (mc_global.tty.console_flag != '\0' && output_lines != 0) { output_start_y = - mw->lines - (command_prompt ? 1 : 0) - mc_global.keybar_visible - output_lines; + mw->lines - (command_prompt ? 1 : 0) - (mc_global.keybar_visible ? 1 : 0) - + output_lines; show_console_contents (output_start_y, - mw->lines - output_lines - mc_global.keybar_visible - 1, - mw->lines - mc_global.keybar_visible - 1); + mw->lines - output_lines - (mc_global.keybar_visible ? 1 : 0) - 1, + mw->lines - (mc_global.keybar_visible ? 1 : 0) - 1); } if (command_prompt) @@ -821,7 +822,8 @@ setup_panels (void) widget_set_size (WIDGET (the_prompt), mw->lines, mw->cols, 0, 0); } - widget_set_size (WIDGET (the_bar), mw->lines - 1, mw->x, mc_global.keybar_visible, mw->cols); + widget_set_size (WIDGET (the_bar), mw->lines - 1, mw->x, mc_global.keybar_visible ? 1 : 0, + mw->cols); buttonbar_set_visible (the_bar, mc_global.keybar_visible); update_xterm_title_path (); @@ -919,7 +921,7 @@ setup_cmdline (void) } #endif - y = mw->lines - 1 - mc_global.keybar_visible; + y = mw->lines - 1 - (mc_global.keybar_visible ? 1 : 0); widget_set_size (WIDGET (the_prompt), y, mw->x, 1, prompt_width); label_set_text (the_prompt, mc_prompt); @@ -964,7 +966,7 @@ rotate_dash (gboolean show) if (show && !mc_time_elapsed (×tamp, delay)) return; - widget_gotoyx (w, (menubar_visible != 0) ? 1 : 0, w->cols - 1); + widget_gotoyx (w, menubar_visible != 0 ? 1 : 0, w->cols - 1); tty_setcolor (NORMAL_COLOR); if (!show) diff --git a/src/filemanager/layout.h b/src/filemanager/layout.h index 18ce3fbbb..2566cfa32 100644 --- a/src/filemanager/layout.h +++ b/src/filemanager/layout.h @@ -27,14 +27,14 @@ typedef enum typedef struct { - int horizontal_split; + gboolean horizontal_split; /* vertical split */ - int vertical_equal; + gboolean vertical_equal; int left_panel_size; /* horizontal split */ - int horizontal_equal; + gboolean horizontal_equal; int top_panel_size; } panels_layout_t; @@ -42,10 +42,10 @@ typedef struct extern int output_lines; extern gboolean command_prompt; -extern int menubar_visible; +extern gboolean menubar_visible; extern int output_start_y; extern gboolean xterm_title; -extern int free_space; +extern gboolean free_space; extern gboolean nice_rotating_dash; extern int ok_to_refresh; diff --git a/src/filemanager/midnight.c b/src/filemanager/midnight.c index b557f4c4f..e108686e7 100644 --- a/src/filemanager/midnight.c +++ b/src/filemanager/midnight.c @@ -1501,10 +1501,10 @@ midnight_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void case MSG_DRAW: load_hint (TRUE); /* We handle the special case of the output lines */ - if (mc_global.tty.console_flag != '\0' && output_lines) + if (mc_global.tty.console_flag != '\0' && output_lines != 0) show_console_contents (output_start_y, - LINES - output_lines - mc_global.keybar_visible - - 1, LINES - mc_global.keybar_visible - 1); + LINES - output_lines - (mc_global.keybar_visible ? 1 : 0) - 1, + LINES - (mc_global.keybar_visible ? 1 : 0) - 1); return MSG_HANDLED; case MSG_RESIZE: diff --git a/src/main.c b/src/main.c index c08f588ba..a4a33e18e 100644 --- a/src/main.c +++ b/src/main.c @@ -57,7 +57,7 @@ #include "filemanager/midnight.h" /* current_panel */ #include "filemanager/treestore.h" /* tree_store_save */ -#include "filemanager/layout.h" /* command_prompt */ +#include "filemanager/layout.h" #include "filemanager/ext.h" /* flush_extension_file() */ #include "filemanager/command.h" /* cmdline */ #include "filemanager/panel.h" /* panalized_panel */ diff --git a/src/setup.c b/src/setup.c index 277b8363a..47ab7aeec 100644 --- a/src/setup.c +++ b/src/setup.c @@ -258,19 +258,27 @@ static const struct { const char *opt_name; int *opt_addr; -} layout [] = { +} layout_int_options [] = { + { "output_lines", &output_lines }, + { "left_panel_size", &panels_layout.left_panel_size }, + { "top_panel_size", &panels_layout.top_panel_size }, + { NULL, NULL } +}; + +static const struct +{ + const char *opt_name; + gboolean *opt_addr; +} layout_bool_options [] = { { "message_visible", &mc_global.message_visible }, { "keybar_visible", &mc_global.keybar_visible }, { "xterm_title", &xterm_title }, - { "output_lines", &output_lines }, { "command_prompt", &command_prompt }, { "menubar_visible", &menubar_visible }, { "free_space", &free_space }, { "horizontal_split", &panels_layout.horizontal_split }, { "vertical_equal", &panels_layout.vertical_equal }, - { "left_panel_size", &panels_layout.left_panel_size }, { "horizontal_equal", &panels_layout.horizontal_equal }, - { "top_panel_size", &panels_layout.top_panel_size }, { NULL, NULL } }; @@ -670,13 +678,13 @@ static void load_layout (void) { size_t i; - int equal_split; + gboolean equal_split; int first_panel_size; /* legacy options */ panels_layout.horizontal_split = mc_config_get_int (mc_global.main_config, CONFIG_APP_SECTION, - "horizontal_split", 0); - equal_split = mc_config_get_int (mc_global.main_config, "Layout", "equal_split", 1); + "horizontal_split", 0) != 0; + equal_split = mc_config_get_int (mc_global.main_config, "Layout", "equal_split", 1) != 0; first_panel_size = mc_config_get_int (mc_global.main_config, "Layout", "first_panel_size", 1); if (panels_layout.horizontal_split) { @@ -690,9 +698,15 @@ load_layout (void) } /* actual options override legacy ones */ - for (i = 0; layout[i].opt_name != NULL; i++) - *layout[i].opt_addr = mc_config_get_int (mc_global.main_config, CONFIG_LAYOUT_SECTION, - layout[i].opt_name, *layout[i].opt_addr); + for (i = 0; layout_int_options[i].opt_name != NULL; i++) + *layout_int_options[i].opt_addr = + mc_config_get_int (mc_global.main_config, CONFIG_LAYOUT_SECTION, + layout_int_options[i].opt_name, *layout_int_options[i].opt_addr); + + for (i = 0; layout_bool_options[i].opt_name != NULL; i++) + *layout_bool_options[i].opt_addr = + mc_config_get_int (mc_global.main_config, CONFIG_LAYOUT_SECTION, + layout_bool_options[i].opt_name, *layout_bool_options[i].opt_addr); /* remove legacy options */ mc_config_del_key (mc_global.main_config, CONFIG_APP_SECTION, "horizontal_split"); @@ -981,9 +995,14 @@ save_layout (void) size_t i; /* Save integer options */ - for (i = 0; layout[i].opt_name != NULL; i++) - mc_config_set_int (mc_global.main_config, CONFIG_LAYOUT_SECTION, layout[i].opt_name, - *layout[i].opt_addr); + for (i = 0; layout_int_options[i].opt_name != NULL; i++) + mc_config_set_int (mc_global.main_config, CONFIG_LAYOUT_SECTION, + layout_int_options[i].opt_name, *layout_int_options[i].opt_addr); + + /* Save boolean options */ + for (i = 0; layout_bool_options[i].opt_name != NULL; i++) + mc_config_set_bool (mc_global.main_config, CONFIG_LAYOUT_SECTION, + layout_bool_options[i].opt_name, *layout_bool_options[i].opt_addr); } /* --------------------------------------------------------------------------------------------- */ diff --git a/src/viewer/mcviewer.c b/src/viewer/mcviewer.c index 15b0c3ef5..ca341e735 100644 --- a/src/viewer/mcviewer.c +++ b/src/viewer/mcviewer.c @@ -43,7 +43,7 @@ #include "lib/util.h" /* load_file_position() */ #include "lib/widget.h" -#include "src/filemanager/layout.h" /* menubar_visible */ +#include "src/filemanager/layout.h" #include "src/filemanager/midnight.h" /* the_menubar */ #include "internal.h"