diff --git a/src/boxes.c b/src/boxes.c index 7a9bfc2d5..23bc2ae32 100644 --- a/src/boxes.c +++ b/src/boxes.c @@ -4,7 +4,7 @@ 2005, 2006, 2009 Free Software Foundation, Inc. Authors: 1994, 1995 Miguel de Icaza - 1995 Jakub Jelinek + 1995 Jakub Jelinek This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -37,9 +37,9 @@ #include "lib/global.h" #include "lib/tty/tty.h" -#include "lib/skin.h" /* INPUT_COLOR */ -#include "lib/tty/key.h" /* XCTRL and ALT macros */ -#include "lib/mcconfig.h" /* Load/save user formats */ +#include "lib/skin.h" /* INPUT_COLOR */ +#include "lib/tty/key.h" /* XCTRL and ALT macros */ +#include "lib/mcconfig.h" /* Load/save user formats */ #include "lib/strutil.h" #ifdef ENABLE_VFS @@ -51,18 +51,18 @@ # include "lib/vfs/mc-vfs/ftpfs.h" #endif -#include "dialog.h" /* The nice dialog manager */ -#include "widget.h" /* The widgets for the nice dialog manager */ +#include "dialog.h" /* The nice dialog manager */ +#include "widget.h" /* The widgets for the nice dialog manager */ #include "wtools.h" -#include "setup.h" /* For profile_name */ -#include "command.h" /* For cmdline */ +#include "setup.h" /* For profile_name */ +#include "command.h" /* For cmdline */ #include "dir.h" -#include "panel.h" /* LIST_TYPES */ +#include "panel.h" /* LIST_TYPES */ #include "boxes.h" -#include "main.h" /* For the confirm_* variables */ +#include "main.h" /* For the confirm_* variables */ #include "tree.h" -#include "layout.h" /* for get_nth_panel_name proto */ -#include "background.h" /* task_list */ +#include "layout.h" /* for get_nth_panel_name proto */ +#include "background.h" /* task_list */ #ifdef HAVE_CHARSET #include "charsets.h" @@ -78,128 +78,132 @@ static char **displays_status; static int display_user_hotkey = 'u'; static cb_ret_t -display_callback (Dlg_head *h, Widget *sender, - dlg_msg_t msg, int parm, void *data) +display_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data) { - switch (msg) { + switch (msg) + { case DLG_UNFOCUS: - if (dlg_widget_active (display_radio)) { - assign_text (display_mini_status, displays_status[display_radio->sel]); - input_set_point (display_mini_status, 0); - } - return MSG_HANDLED; + if (dlg_widget_active (display_radio)) + { + assign_text (display_mini_status, displays_status[display_radio->sel]); + input_set_point (display_mini_status, 0); + } + return MSG_HANDLED; case DLG_KEY: - if (parm == '\n') { - if (dlg_widget_active (display_radio)) { - assign_text (display_mini_status, displays_status[display_radio->sel]); - dlg_stop (h); - return MSG_HANDLED; - } + if (parm == '\n') + { + if (dlg_widget_active (display_radio)) + { + assign_text (display_mini_status, displays_status[display_radio->sel]); + dlg_stop (h); + return MSG_HANDLED; + } - if (dlg_widget_active (display_user_format)) { - h->ret_value = B_USER + 6; - dlg_stop (h); - return MSG_HANDLED; - } + if (dlg_widget_active (display_user_format)) + { + h->ret_value = B_USER + 6; + dlg_stop (h); + return MSG_HANDLED; + } - if (dlg_widget_active (display_mini_status)) { - h->ret_value = B_USER + 7; - dlg_stop (h); - return MSG_HANDLED; - } - } + if (dlg_widget_active (display_mini_status)) + { + h->ret_value = B_USER + 7; + dlg_stop (h); + return MSG_HANDLED; + } + } - if (g_ascii_tolower (parm) == display_user_hotkey && dlg_widget_active (display_user_format) - && dlg_widget_active (display_mini_status)) { - display_radio->sel = 3; - dlg_select_widget (display_radio); /* force redraw */ - dlg_select_widget (display_user_format); - return MSG_HANDLED; - } - return MSG_NOT_HANDLED; + if (g_ascii_tolower (parm) == display_user_hotkey && dlg_widget_active (display_user_format) + && dlg_widget_active (display_mini_status)) + { + display_radio->sel = 3; + dlg_select_widget (display_radio); /* force redraw */ + dlg_select_widget (display_user_format); + return MSG_HANDLED; + } + return MSG_NOT_HANDLED; default: - return default_dlg_callback (h, sender, msg, parm, data); + return default_dlg_callback (h, sender, msg, parm, data); } } static Dlg_head * -display_init (int radio_sel, char *init_text, int _check_status, - char **_status) +display_init (int radio_sel, char *init_text, int _check_status, char **_status) { int dlg_width = 48, dlg_height = 15; Dlg_head *dd; /* Controls whether the array strings have been translated */ - const char *displays [LIST_TYPES] = - { - N_("&Full file list"), - N_("&Brief file list"), - N_("&Long file list"), - N_("&User defined:") + const char *displays[LIST_TYPES] = { + N_("&Full file list"), + N_("&Brief file list"), + N_("&Long file list"), + N_("&User defined:") }; /* Index in displays[] for "user defined" */ const int user_type_idx = 3; const char *display_title = N_("Listing mode"); - const char *user_mini_status = N_("user &Mini status"); + const char *user_mini_status = N_("User &mini status"); const char *ok_name = N_("&OK"); const char *cancel_name = N_("&Cancel"); WButton *ok_button, *cancel_button; { - int i, maxlen = 0; - const char *cp; - int ok_len, cancel_len; + int i, maxlen = 0; + const char *cp; + int ok_len, cancel_len; #ifdef ENABLE_NLS - display_title = _(display_title); - user_mini_status = _(user_mini_status); - ok_name = _(ok_name); - cancel_name = _(cancel_name); + display_title = _(display_title); + user_mini_status = _(user_mini_status); + ok_name = _(ok_name); + cancel_name = _(cancel_name); - for (i = 0; i < LIST_TYPES; i++) - displays[i] = _(displays[i]); + for (i = 0; i < LIST_TYPES; i++) + displays[i] = _(displays[i]); #endif - /* get hotkey of user-defined format string */ - cp = strchr (displays[user_type_idx], '&'); - if (cp != NULL && *++cp != '\0') - display_user_hotkey = g_ascii_tolower (*cp); + /* get hotkey of user-defined format string */ + cp = strchr (displays[user_type_idx], '&'); + if (cp != NULL && *++cp != '\0') + display_user_hotkey = g_ascii_tolower (*cp); - /* xpos will be fixed later */ - ok_button = button_new (dlg_height - 3, 0, B_ENTER, DEFPUSH_BUTTON, ok_name, 0); - ok_len = button_get_len (ok_button); - cancel_button = button_new (dlg_height - 3, 0, B_CANCEL, NORMAL_BUTTON, cancel_name, 0); - cancel_len = button_get_len (cancel_button); + /* xpos will be fixed later */ + ok_button = button_new (dlg_height - 3, 0, B_ENTER, DEFPUSH_BUTTON, ok_name, 0); + ok_len = button_get_len (ok_button); + cancel_button = button_new (dlg_height - 3, 0, B_CANCEL, NORMAL_BUTTON, cancel_name, 0); + cancel_len = button_get_len (cancel_button); - dlg_width = max (dlg_width, str_term_width1 (display_title) + 10); - /* calculate max width of radiobutons */ - for (i = 0; i < LIST_TYPES; i++) - maxlen = max (maxlen, str_term_width1 (displays[i])); - dlg_width = max (dlg_width, maxlen); - dlg_width = max (dlg_width, str_term_width1 (user_mini_status) + 13); + dlg_width = max (dlg_width, str_term_width1 (display_title) + 10); + /* calculate max width of radiobutons */ + for (i = 0; i < LIST_TYPES; i++) + maxlen = max (maxlen, str_term_width1 (displays[i])); + dlg_width = max (dlg_width, maxlen); + dlg_width = max (dlg_width, str_term_width1 (user_mini_status) + 13); - /* buttons */ - dlg_width = max (dlg_width, ok_len + cancel_len + 8); - ok_button->widget.x = dlg_width/3 - ok_len/2; - cancel_button->widget.x = dlg_width * 2/3 - cancel_len/2; + /* buttons */ + dlg_width = max (dlg_width, ok_len + cancel_len + 8); + ok_button->widget.x = dlg_width / 3 - ok_len / 2; + cancel_button->widget.x = dlg_width * 2 / 3 - cancel_len / 2; } displays_status = _status; dd = create_dlg (0, 0, dlg_height, dlg_width, dialog_colors, - display_callback, "[Listing Mode...]", display_title, - DLG_CENTER | DLG_REVERSE); + display_callback, "[Listing Mode...]", display_title, + DLG_CENTER | DLG_REVERSE); add_widget (dd, cancel_button); add_widget (dd, ok_button); display_mini_status = input_new (10, 8, INPUT_COLOR, dlg_width - 12, _status[radio_sel], - "mini-input", INPUT_COMPLETE_DEFAULT); + "mini-input", INPUT_COMPLETE_DEFAULT); add_widget (dd, display_mini_status); input_set_point (display_mini_status, 0); @@ -207,7 +211,7 @@ display_init (int radio_sel, char *init_text, int _check_status, add_widget (dd, display_check_status); display_user_format = input_new (7, 8, INPUT_COLOR, dlg_width - 12, init_text, - "user-fmt-input", INPUT_COMPLETE_DEFAULT); + "user-fmt-input", INPUT_COMPLETE_DEFAULT); add_widget (dd, display_user_format); input_set_point (display_user_format, 0); @@ -220,14 +224,15 @@ display_init (int radio_sel, char *init_text, int _check_status, /* return list type */ int -display_box (WPanel *panel, char **userp, char **minip, int *use_msformat, int num) +display_box (WPanel * panel, char **userp, char **minip, int *use_msformat, int num) { int result = -1; Dlg_head *dd; char *section = NULL; size_t i; - if (panel == NULL) { + if (panel == NULL) + { const char *p = get_nth_panel_name (num); panel = g_new (WPanel, 1); panel->list_type = list_full; @@ -236,7 +241,8 @@ display_box (WPanel *panel, char **userp, char **minip, int *use_msformat, int n for (i = 0; i < LIST_TYPES; i++) panel->user_status_format[i] = g_strdup (DEFAULT_USER_FORMAT); section = g_strconcat ("Temporal:", p, (char *) NULL); - if (! mc_config_has_group (mc_main_config, section)) { + if (!mc_config_has_group (mc_main_config, section)) + { g_free (section); section = g_strdup (p); } @@ -245,19 +251,21 @@ display_box (WPanel *panel, char **userp, char **minip, int *use_msformat, int n } dd = display_init (panel->list_type, panel->user_format, - panel->user_mini_status, panel->user_status_format); + panel->user_mini_status, panel->user_status_format); - if (run_dlg (dd) != B_CANCEL) { - result = display_radio->sel; - *userp = g_strdup (display_user_format->buffer); - *minip = g_strdup (display_mini_status->buffer); - *use_msformat = display_check_status->state & C_BOOL; + if (run_dlg (dd) != B_CANCEL) + { + result = display_radio->sel; + *userp = g_strdup (display_user_format->buffer); + *minip = g_strdup (display_mini_status->buffer); + *use_msformat = display_check_status->state & C_BOOL; } - if (section != NULL) { + if (section != NULL) + { g_free (panel->user_format); - for (i = 0; i < LIST_TYPES; i++) - g_free (panel->user_status_format [i]); + for (i = 0; i < LIST_TYPES; i++) + g_free (panel->user_status_format[i]); g_free (panel); } @@ -267,7 +275,7 @@ display_box (WPanel *panel, char **userp, char **minip, int *use_msformat, int n } const panel_field_t * -sort_box (const panel_field_t *sort_format, int *reverse, int *case_sensitive, int *exec_first) +sort_box (const panel_field_t * sort_format, int *reverse, int *case_sensitive, int *exec_first) { int dlg_width = 40, dlg_height = 7; @@ -278,93 +286,92 @@ sort_box (const panel_field_t *sort_format, int *reverse, int *case_sensitive, i const panel_field_t *result = sort_format; - sort_orders_names = panel_get_sortable_fields(&sort_names_num); + sort_orders_names = panel_get_sortable_fields (&sort_names_num); dlg_height += sort_names_num; { - int max_radio = 0, max_check = 0; - int ok_len, cancel_len; - gsize i; + int max_radio = 0, max_check = 0; + int ok_len, cancel_len; + gsize i; - QuickWidget quick_widgets[] = - { - /* 0 */ - QUICK_BUTTON (0, dlg_width, dlg_height - 3, dlg_height, N_("&Cancel"), B_CANCEL, NULL), - /* 1 */ - QUICK_BUTTON (0, dlg_width, dlg_height - 3, dlg_height, N_("&OK"), B_ENTER, NULL), - /* 2 */ - QUICK_CHECKBOX (0, dlg_width, 5, dlg_height, N_("&Reverse"), reverse), - /* 3 */ - QUICK_CHECKBOX (0, dlg_width, 4, dlg_height, N_("Case sensi&tive"), case_sensitive), - /* 4 */ - QUICK_CHECKBOX (0, dlg_width, 3, dlg_height, N_("Executable &first"), exec_first), - /* 5 */ - QUICK_RADIO (4, dlg_width, 3, dlg_height, 0, - NULL, &sort_idx), - QUICK_END - }; + QuickWidget quick_widgets[] = { + /* 0 */ + QUICK_BUTTON (0, dlg_width, dlg_height - 3, dlg_height, N_("&Cancel"), B_CANCEL, NULL), + /* 1 */ + QUICK_BUTTON (0, dlg_width, dlg_height - 3, dlg_height, N_("&OK"), B_ENTER, NULL), + /* 2 */ + QUICK_CHECKBOX (0, dlg_width, 5, dlg_height, N_("&Reverse"), reverse), + /* 3 */ + QUICK_CHECKBOX (0, dlg_width, 4, dlg_height, N_("Case sensi&tive"), case_sensitive), + /* 4 */ + QUICK_CHECKBOX (0, dlg_width, 3, dlg_height, N_("Executable &first"), exec_first), + /* 5 */ + QUICK_RADIO (4, dlg_width, 3, dlg_height, 0, + NULL, &sort_idx), + QUICK_END + }; - QuickDialog quick_dlg = - { - dlg_width, dlg_height, -1, -1, - N_("Sort order"), "[Sort Order...]", - quick_widgets, TRUE - }; + QuickDialog quick_dlg = { + dlg_width, dlg_height, -1, -1, + N_("Sort order"), "[Sort Order...]", + quick_widgets, TRUE + }; - quick_widgets[5].u.radio.items = sort_orders_names; - quick_widgets[5].u.radio.count = sort_names_num; + quick_widgets[5].u.radio.items = sort_orders_names; + quick_widgets[5].u.radio.count = sort_names_num; - for (i = 0; i < sort_names_num; i++) - if (strcmp (sort_orders_names[i], _(sort_format->title_hotkey)) == 0 ) { - sort_idx = i; - break; - } + for (i = 0; i < sort_names_num; i++) + if (strcmp (sort_orders_names[i], _(sort_format->title_hotkey)) == 0) + { + sort_idx = i; + break; + } #ifdef ENABLE_NLS - quick_dlg.title = _(quick_dlg.title); - /* buttons */ - for (i = 0; i < 2; i++) - quick_widgets[i].u.button.text = _(quick_widgets[i].u.button.text); - /* checkboxes */ - for (i = 2; i < 5; i++) - quick_widgets[i].u.checkbox.text = _(quick_widgets[i].u.checkbox.text); -#endif /* ENABLE_NlS */ + quick_dlg.title = _(quick_dlg.title); + /* buttons */ + for (i = 0; i < 2; i++) + quick_widgets[i].u.button.text = _(quick_widgets[i].u.button.text); + /* checkboxes */ + for (i = 2; i < 5; i++) + quick_widgets[i].u.checkbox.text = _(quick_widgets[i].u.checkbox.text); +#endif /* ENABLE_NlS */ - /* buttons */ - cancel_len = str_term_width1 (quick_widgets[0].u.button.text) + 4; - ok_len = str_term_width1 (quick_widgets[1].u.button.text) + 6; - /* checkboxes */ - for (i = 2; i < 5; i++) - max_check = max (max_check, str_term_width1 (quick_widgets[i].u.checkbox.text) + 4); - /* radiobuttons */ - for (i = 0; i < sort_names_num; i++) - max_radio = max (max_radio, str_term_width1 (sort_orders_names[i]) + 4); + /* buttons */ + cancel_len = str_term_width1 (quick_widgets[0].u.button.text) + 4; + ok_len = str_term_width1 (quick_widgets[1].u.button.text) + 6; + /* checkboxes */ + for (i = 2; i < 5; i++) + max_check = max (max_check, str_term_width1 (quick_widgets[i].u.checkbox.text) + 4); + /* radiobuttons */ + for (i = 0; i < sort_names_num; i++) + max_radio = max (max_radio, str_term_width1 (sort_orders_names[i]) + 4); - /* dialog width */ - dlg_width = max (dlg_width, str_term_width1 (quick_dlg.title) + 8); - dlg_width = max (dlg_width, ok_len + cancel_len + 8); - dlg_width = max (dlg_width, 2 * max (max_radio, max_check) + 8); + /* dialog width */ + dlg_width = max (dlg_width, str_term_width1 (quick_dlg.title) + 8); + dlg_width = max (dlg_width, ok_len + cancel_len + 8); + dlg_width = max (dlg_width, 2 * max (max_radio, max_check) + 8); - /* fix widget and dialog parameters */ - /* dialog */ - quick_dlg.xlen = dlg_width; - /* widgets */ - for (i = 0; (size_t) i < sizeof (quick_widgets)/sizeof (quick_widgets[0]) - 1; i++) - quick_widgets[i].x_divisions = dlg_width; - /* buttons */ - quick_widgets[0].relative_x = dlg_width * 2/3 - cancel_len/2; - quick_widgets[1].relative_x = dlg_width/3 - ok_len/2; - /* checkboxes */ - for (i = 2; i < 5; i++) - quick_widgets[i].relative_x = dlg_width/2 + 2; + /* fix widget and dialog parameters */ + /* dialog */ + quick_dlg.xlen = dlg_width; + /* widgets */ + for (i = 0; (size_t) i < sizeof (quick_widgets) / sizeof (quick_widgets[0]) - 1; i++) + quick_widgets[i].x_divisions = dlg_width; + /* buttons */ + quick_widgets[0].relative_x = dlg_width * 2 / 3 - cancel_len / 2; + quick_widgets[1].relative_x = dlg_width / 3 - ok_len / 2; + /* checkboxes */ + for (i = 2; i < 5; i++) + quick_widgets[i].relative_x = dlg_width / 2 + 2; - if (quick_dialog (&quick_dlg) != B_CANCEL) - result = panel_get_field_by_title_hotkey(sort_orders_names[sort_idx]); + if (quick_dialog (&quick_dlg) != B_CANCEL) + result = panel_get_field_by_title_hotkey (sort_orders_names[sort_idx]); - if (result == NULL) - result = sort_format; + if (result == NULL) + result = sort_format; } - g_strfreev((gchar **)sort_orders_names); + g_strfreev ((gchar **) sort_orders_names); return result; } @@ -374,18 +381,19 @@ confirm_box (void) { const char *title = _("Confirmation"); - QuickWidget conf_widgets [] = - { - /* 0 */ QUICK_BUTTON (29, 46, 10, 13, N_("&Cancel"), B_CANCEL, NULL), - /* 1 */ QUICK_BUTTON (12, 46, 10, 13, N_("&OK"), B_ENTER, NULL), -/* TRANSLATORS: no need to translate 'Confirmation', it's just a context prefix */ - /* 2 */ QUICK_CHECKBOX (3, 46, 8, 13, N_("Confirmation|&History cleanup"), &confirm_history_cleanup), - /* 3 */ QUICK_CHECKBOX (3, 46, 7, 13, N_("Confirmation|&Directory hotlist delete"), &confirm_directory_hotlist_delete), - /* 4 */ QUICK_CHECKBOX (3, 46, 6, 13, N_("Confirmation|E&xit"), &confirm_exit), - /* 5 */ QUICK_CHECKBOX (3, 46, 5, 13, N_("Confirmation|&Execute"), &confirm_execute), - /* 6 */ QUICK_CHECKBOX (3, 46, 4, 13, N_("Confirmation|O&verwrite"), &confirm_overwrite), - /* 7 */ QUICK_CHECKBOX (3, 46, 3, 13, N_("Confirmation|&Delete"), &confirm_delete), - QUICK_END + QuickWidget conf_widgets[] = { + /* 0 */ QUICK_BUTTON (29, 46, 10, 13, N_("&Cancel"), B_CANCEL, NULL), + /* 1 */ QUICK_BUTTON (12, 46, 10, 13, N_("&OK"), B_ENTER, NULL), + /* TRANSLATORS: no need to translate 'Confirmation', it's just a context prefix */ + /* 2 */ QUICK_CHECKBOX (3, 46, 8, 13, N_("Confirmation|&History cleanup"), + &confirm_history_cleanup), + /* 3 */ QUICK_CHECKBOX (3, 46, 7, 13, N_("Confirmation|&Directory hotlist delete"), + &confirm_directory_hotlist_delete), + /* 4 */ QUICK_CHECKBOX (3, 46, 6, 13, N_("Confirmation|E&xit"), &confirm_exit), + /* 5 */ QUICK_CHECKBOX (3, 46, 5, 13, N_("Confirmation|&Execute"), &confirm_execute), + /* 6 */ QUICK_CHECKBOX (3, 46, 4, 13, N_("Confirmation|O&verwrite"), &confirm_overwrite), + /* 7 */ QUICK_CHECKBOX (3, 46, 3, 13, N_("Confirmation|&Delete"), &confirm_delete), + QUICK_END }; const size_t w_num = sizeof (conf_widgets) / sizeof (conf_widgets[0]) - 1; @@ -402,19 +410,19 @@ confirm_box (void) title = _(title); for (i = 0; i < 2; i++) - conf_widgets [i].u.button.text = _(conf_widgets [i].u.button.text); + conf_widgets[i].u.button.text = _(conf_widgets[i].u.button.text); for (i = 2; i < w_num; i++) - conf_widgets [i].u.checkbox.text = Q_(conf_widgets [i].u.checkbox.text); + conf_widgets[i].u.checkbox.text = Q_ (conf_widgets[i].u.checkbox.text); #endif /* ENABLE_NLS */ /* maximumr length of checkboxes */ for (i = 2; i < w_num; i++) - maxlen = max (maxlen, str_term_width1 (conf_widgets [i].u.checkbox.text) + 4); + maxlen = max (maxlen, str_term_width1 (conf_widgets[i].u.checkbox.text) + 4); /* length of buttons */ - cancel_len = str_term_width1 (conf_widgets [0].u.button.text) + 3; - ok_len = str_term_width1 (conf_widgets [1].u.button.text) + 5; /* default button */ + cancel_len = str_term_width1 (conf_widgets[0].u.button.text) + 3; + ok_len = str_term_width1 (conf_widgets[1].u.button.text) + 5; /* default button */ blen = cancel_len + ok_len + 2; @@ -422,29 +430,29 @@ confirm_box (void) dlg_width = max (dlg_width, str_term_width1 (title) + 4); /* correct widget parameters */ - for (i = 0; i < w_num; i++) { - conf_widgets[i].x_divisions = dlg_width; - conf_widgets[i].y_divisions = dlg_height; + for (i = 0; i < w_num; i++) + { + conf_widgets[i].x_divisions = dlg_width; + conf_widgets[i].y_divisions = dlg_height; } - conf_widgets[1].relative_x = dlg_width/2 - blen/2; + conf_widgets[1].relative_x = dlg_width / 2 - blen / 2; conf_widgets[0].relative_x = conf_widgets[1].relative_x + ok_len + 2; { - QuickDialog confirmation = - { - dlg_width, dlg_height, -1, -1, title, - "[Confirmation]", conf_widgets, 1 - }; + QuickDialog confirmation = { + dlg_width, dlg_height, -1, -1, title, + "[Confirmation]", conf_widgets, 1 + }; - (void) quick_dialog (&confirmation); + (void) quick_dialog (&confirmation); } } #ifndef HAVE_CHARSET void -display_bits_box (void) /* AB:FIXME: test dialog */ +display_bits_box (void) /* AB:FIXME: test dialog */ { /* dialog sizes */ const int DISPY = 13; @@ -453,27 +461,24 @@ display_bits_box (void) /* AB:FIXME: test dialog */ int new_meta = 0; int current_mode; - const char *display_bits_str [] = - { - N_("UTF-8 output"), - N_("Full 8 bits output"), - N_("ISO 8859-1"), - N_("7 bits") + const char *display_bits_str[] = { + N_("UTF-8 output"), + N_("Full 8 bits output"), + N_("ISO 8859-1"), + N_("7 bits") }; - QuickWidget display_widgets[] = - { - /* 0 */ QUICK_BUTTON (15, DISPX, DISPY - 3, DISPY, N_("&Cancel"), B_CANCEL, NULL), - /* 1 */ QUICK_BUTTON (29, DISPX, DISPY - 3, DISPY, N_("&OK"), B_ENTER, NULL), - /* 2 */ QUICK_CHECKBOX (3, DISPX, 8, DISPY, N_("F&ull 8 bits input"), &new_meta), - /* 3 */ QUICK_RADIO (3, DISPX, 3, DISPY, 4, display_bits_str, ¤t_mode), - QUICK_END + QuickWidget display_widgets[] = { + /* 0 */ QUICK_BUTTON (15, DISPX, DISPY - 3, DISPY, N_("&Cancel"), B_CANCEL, NULL), + /* 1 */ QUICK_BUTTON (29, DISPX, DISPY - 3, DISPY, N_("&OK"), B_ENTER, NULL), + /* 2 */ QUICK_CHECKBOX (3, DISPX, 8, DISPY, N_("F&ull 8 bits input"), &new_meta), + /* 3 */ QUICK_RADIO (3, DISPX, 3, DISPY, 4, display_bits_str, ¤t_mode), + QUICK_END }; - QuickDialog display_bits = - { - DISPX, DISPY, -1, -1, _(" Display bits "), - "[Display bits]", display_widgets, TRUE + QuickDialog display_bits = { + DISPX, DISPY, -1, -1, _(" Display bits "), + "[Display bits]", display_widgets, TRUE }; int i; @@ -483,55 +488,58 @@ display_bits_box (void) /* AB:FIXME: test dialog */ #ifdef ENABLE_NLS static gboolean i18n_flag = FALSE; - if (!i18n_flag) { - for (i = 0; i < 3; i++) { - display_bits_str[i] = _(display_bits_str [i]); - } + if (!i18n_flag) + { + for (i = 0; i < 3; i++) + { + display_bits_str[i] = _(display_bits_str[i]); + } - display_widgets[0].u.button.text = _(display_widgets[0].u.button.text); - display_widgets[1].u.button.text = _(display_widgets[1].u.button.text); - display_widgets[2].u.checkbox.text = _(display_widgets[2].u.checkbox.text); + display_widgets[0].u.button.text = _(display_widgets[0].u.button.text); + display_widgets[1].u.button.text = _(display_widgets[1].u.button.text); + display_widgets[2].u.checkbox.text = _(display_widgets[2].u.checkbox.text); - i18n_flag = TRUE; + i18n_flag = TRUE; } #endif /* ENABLE_NLS */ /* radiobuttons */ for (i = 0; i < 3; i++) - maxlen = max (maxlen, str_term_width1 (display_bits_str [i])); + maxlen = max (maxlen, str_term_width1 (display_bits_str[i])); /* buttons */ - cancel_len = str_term_width1 (display_widgets [0].u.button.text) + 2; - ok_len = str_term_width1 (display_widgets [1].u.button.text) + 4; /* default button */ + cancel_len = str_term_width1 (display_widgets[0].u.button.text) + 2; + ok_len = str_term_width1 (display_widgets[1].u.button.text) + 4; /* default button */ l1 = max (cancel_len, ok_len); display_bits.xlen = max (maxlen, l1) + 20; for (i = 0; i < 4; i++) - display_widgets[i].x_divisions = display_bits.xlen; + display_widgets[i].x_divisions = display_bits.xlen; - display_widgets[0].relative_x = display_bits.xlen * 2/3 - cancel_len/2; - display_widgets[1].relative_x = display_bits.xlen/3 - ok_len/2; + display_widgets[0].relative_x = display_bits.xlen * 2 / 3 - cancel_len / 2; + display_widgets[1].relative_x = display_bits.xlen / 3 - ok_len / 2; if (full_eight_bits) - current_mode = 0; + current_mode = 0; else if (eight_bit_clean) - current_mode = 1; + current_mode = 1; else - current_mode = 2; + current_mode = 2; new_meta = !use_8th_bit_as_meta; - if (quick_dialog (&display_bits) != B_CANCEL) { - eight_bit_clean = current_mode < 3; - full_eight_bits = current_mode < 2; + if (quick_dialog (&display_bits) != B_CANCEL) + { + eight_bit_clean = current_mode < 3; + full_eight_bits = current_mode < 2; #ifndef HAVE_SLANG - meta (stdscr, eight_bit_clean); + meta (stdscr, eight_bit_clean); #else - SLsmg_Display_Eight_Bit = full_eight_bits ? 128 : 160; + SLsmg_Display_Eight_Bit = full_eight_bits ? 128 : 160; #endif - use_8th_bit_as_meta = !new_meta; + use_8th_bit_as_meta = !new_meta; } } @@ -551,18 +559,19 @@ sel_charset_button (int action) new_dcp = select_charset (-1, -1, new_display_codepage, TRUE); - if (new_dcp != SELECT_CHARSET_CANCEL) { - const char *cpname; - char buf[BUF_TINY]; + if (new_dcp != SELECT_CHARSET_CANCEL) + { + const char *cpname; + char buf[BUF_TINY]; - new_display_codepage = new_dcp; - cpname = (new_display_codepage == SELECT_CHARSET_OTHER_8BIT) ? - _("Other 8 bit") : codepages[new_display_codepage].name; - if (cpname != NULL) - utf8_display = str_isutf8 (cpname); - /* avoid strange bug with label repainting */ - g_snprintf (buf, sizeof (buf), "%-27s", cpname); - label_set_text (cplabel, buf); + new_display_codepage = new_dcp; + cpname = (new_display_codepage == SELECT_CHARSET_OTHER_8BIT) ? + _("Other 8 bit") : codepages[new_display_codepage].name; + if (cpname != NULL) + utf8_display = str_isutf8 (cpname); + /* avoid strange bug with label repainting */ + g_snprintf (buf, sizeof (buf), "%-27s", cpname); + label_set_text (cplabel, buf); } return 0; @@ -581,33 +590,26 @@ init_disp_bits_box (void) do_refresh (); dbits_dlg = - create_dlg (0, 0, DISPY, DISPX, dialog_colors, NULL, - "[Display bits]", _(" Display bits "), DLG_CENTER | DLG_REVERSE); + create_dlg (0, 0, DISPY, DISPX, dialog_colors, NULL, + "[Display bits]", _(" Display bits "), DLG_CENTER | DLG_REVERSE); - add_widget (dbits_dlg, - label_new (3, 4, _("Input / display codepage:"))); + add_widget (dbits_dlg, label_new (3, 4, _("Input / display codepage:"))); - cpname = (new_display_codepage < 0) - ? _("Other 8 bit") - : codepages[new_display_codepage].name; + cpname = (new_display_codepage < 0) ? _("Other 8 bit") : codepages[new_display_codepage].name; cplabel = label_new (4, 4, cpname); add_widget (dbits_dlg, cplabel); add_widget (dbits_dlg, - button_new (DISPY - 3, DISPX / 2 + 3, B_CANCEL, - NORMAL_BUTTON, _("&Cancel"), 0)); - add_widget (dbits_dlg, - button_new (DISPY - 3, 7, B_ENTER, NORMAL_BUTTON, _("&OK"), - 0)); + button_new (DISPY - 3, DISPX / 2 + 3, B_CANCEL, NORMAL_BUTTON, _("&Cancel"), 0)); + add_widget (dbits_dlg, button_new (DISPY - 3, 7, B_ENTER, NORMAL_BUTTON, _("&OK"), 0)); - inpcheck = - check_new (6, 4, !use_8th_bit_as_meta, _("F&ull 8 bits input")); + inpcheck = check_new (6, 4, !use_8th_bit_as_meta, _("F&ull 8 bits input")); add_widget (dbits_dlg, inpcheck); cpname = _("&Select"); add_widget (dbits_dlg, - button_new (4, DISPX - 7 - str_term_width1 (cpname), B_USER, - NORMAL_BUTTON, cpname, sel_charset_button)); + button_new (4, DISPX - 7 - str_term_width1 (cpname), B_USER, + NORMAL_BUTTON, cpname, sel_charset_button)); return dbits_dlg; } @@ -623,21 +625,23 @@ display_bits_box (void) run_dlg (dbits_dlg); - if (dbits_dlg->ret_value == B_ENTER) { - char *errmsg; + if (dbits_dlg->ret_value == B_ENTER) + { + char *errmsg; - display_codepage = new_display_codepage; - errmsg = init_translation_table (source_codepage, display_codepage); - if (errmsg != NULL) { - message (D_ERROR, MSG_ERROR, "%s", errmsg); - g_free (errmsg); - } + display_codepage = new_display_codepage; + errmsg = init_translation_table (source_codepage, display_codepage); + if (errmsg != NULL) + { + message (D_ERROR, MSG_ERROR, "%s", errmsg); + g_free (errmsg); + } #ifdef HAVE_SLANG - tty_display_8bit (display_codepage != 0 && display_codepage != 1); + tty_display_8bit (display_codepage != 0 && display_codepage != 1); #else - tty_display_8bit (display_codepage != 0); + tty_display_8bit (display_codepage != 0); #endif - use_8th_bit_as_meta = !(inpcheck->state & C_BOOL); + use_8th_bit_as_meta = !(inpcheck->state & C_BOOL); } destroy_dlg (dbits_dlg); repaint_screen (); @@ -646,24 +650,25 @@ display_bits_box (void) #endif /* HAVE_CHARSET */ static cb_ret_t -tree_callback (Dlg_head *h, Widget *sender, - dlg_msg_t msg, int parm, void *data) +tree_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data) { - switch (msg) { + switch (msg) + { case DLG_POST_KEY: - /* The enter key will be processed by the tree widget */ - if (parm == '\n') { - h->ret_value = B_ENTER; - dlg_stop (h); - } - return MSG_HANDLED; + /* The enter key will be processed by the tree widget */ + if (parm == '\n') + { + h->ret_value = B_ENTER; + dlg_stop (h); + } + return MSG_HANDLED; case DLG_ACTION: - /* command from buttonbar */ - return send_message ((Widget *) find_tree (h), WIDGET_COMMAND, parm); + /* command from buttonbar */ + return send_message ((Widget *) find_tree (h), WIDGET_COMMAND, parm); default: - return default_dlg_callback (h, sender, msg, parm, data); + return default_dlg_callback (h, sender, msg, parm, data); } } @@ -671,17 +676,16 @@ tree_callback (Dlg_head *h, Widget *sender, char * tree_box (const char *current_dir) { - WTree *mytree; + WTree *mytree; Dlg_head *dlg; - char *val = NULL; + char *val = NULL; WButtonBar *bar; (void) current_dir; /* Create the components */ dlg = create_dlg (0, 0, LINES - 9, COLS - 20, dialog_colors, - tree_callback, "[Directory Tree]", - NULL, DLG_CENTER | DLG_REVERSE); + tree_callback, "[Directory Tree]", NULL, DLG_CENTER | DLG_REVERSE); mytree = tree_new (0, 2, 2, dlg->lines - 6, dlg->cols - 5); add_widget (dlg, mytree); @@ -692,7 +696,7 @@ tree_box (const char *current_dir) ((Widget *) bar)->y = LINES - 1; if (run_dlg (dlg) == B_ENTER) - val = g_strdup (tree_selected_name (mytree)); + val = g_strdup (tree_selected_name (mytree)); destroy_dlg (dlg); return val; @@ -719,37 +723,41 @@ configure_vfs (void) #define VFSY 8 #endif - char buffer2 [BUF_TINY]; + char buffer2[BUF_TINY]; #ifdef USE_NETCODE - char buffer3 [BUF_TINY]; + char buffer3[BUF_TINY]; #endif - QuickWidget confvfs_widgets [] = - { - /* 0 */ QUICK_BUTTON (30, VFSX, VFSY - 3, VFSY, N_("&Cancel"), B_CANCEL, NULL), - /* 1 */ QUICK_BUTTON (12, VFSX, VFSY - 3, VFSY, N_("&OK"), B_ENTER, NULL), + QuickWidget confvfs_widgets[] = { + /* 0 */ QUICK_BUTTON (30, VFSX, VFSY - 3, VFSY, N_("&Cancel"), B_CANCEL, NULL), + /* 1 */ QUICK_BUTTON (12, VFSX, VFSY - 3, VFSY, N_("&OK"), B_ENTER, NULL), #ifdef USE_NETCODE - /* 2 */ QUICK_CHECKBOX (4, VFSX, 12, VFSY, N_("Use passive mode over pro&xy"), &ftpfs_use_passive_connections_over_proxy), - /* 3 */ QUICK_CHECKBOX (4, VFSX, 11, VFSY, N_("Use &passive mode"), &ftpfs_use_passive_connections), - /* 4 */ QUICK_CHECKBOX (4, VFSX, 10, VFSY, N_("&Use ~/.netrc"), &use_netrc), - /* 5 */ QUICK_INPUT (4, VFSX, 9, VFSY, ftpfs_proxy_host, 48, 0, "input-ftp-proxy", &ret_ftp_proxy), - /* 6 */ QUICK_CHECKBOX (4, VFSX, 8, VFSY, N_("&Always use ftp proxy"), &ftpfs_always_use_proxy), - /* 7 */ QUICK_LABEL (49, VFSX, 7, VFSY, N_("sec")), - /* 8 */ QUICK_INPUT (38, VFSX, 7, VFSY, buffer3, 10, 0, "input-timeout", &ret_directory_timeout), - /* 9 */ QUICK_LABEL (4, VFSX, 7, VFSY, N_("ftpfs directory cache timeout:")), - /* 10 */ QUICK_INPUT (4, VFSX, 6, VFSY, ftpfs_anonymous_passwd, 48, 0, "input-passwd", &ret_passwd), - /* 11 */ QUICK_LABEL (4, VFSX, 5, VFSY, N_("ftp anonymous password:")), + /* 2 */ QUICK_CHECKBOX (4, VFSX, 12, VFSY, N_("Use passive mode over pro&xy"), + &ftpfs_use_passive_connections_over_proxy), + /* 3 */ QUICK_CHECKBOX (4, VFSX, 11, VFSY, N_("Use &passive mode"), + &ftpfs_use_passive_connections), + /* 4 */ QUICK_CHECKBOX (4, VFSX, 10, VFSY, N_("&Use ~/.netrc"), &use_netrc), + /* 5 */ QUICK_INPUT (4, VFSX, 9, VFSY, ftpfs_proxy_host, 48, 0, "input-ftp-proxy", + &ret_ftp_proxy), + /* 6 */ QUICK_CHECKBOX (4, VFSX, 8, VFSY, N_("&Always use ftp proxy"), + &ftpfs_always_use_proxy), + /* 7 */ QUICK_LABEL (49, VFSX, 7, VFSY, N_("sec")), + /* 8 */ QUICK_INPUT (38, VFSX, 7, VFSY, buffer3, 10, 0, "input-timeout", + &ret_directory_timeout), + /* 9 */ QUICK_LABEL (4, VFSX, 7, VFSY, N_("ftpfs directory cache timeout:")), + /* 10 */ QUICK_INPUT (4, VFSX, 6, VFSY, ftpfs_anonymous_passwd, 48, 0, "input-passwd", + &ret_passwd), + /* 11 */ QUICK_LABEL (4, VFSX, 5, VFSY, N_("ftp anonymous password:")), #endif - /* 12 */ QUICK_LABEL (49, VFSX, 3, VFSY, N_("sec")), - /* 13 */ QUICK_INPUT (38, VFSX, 3, VFSY, buffer2, 10, 0, "input-timo-vfs", &ret_timeout), - /* 14 */ QUICK_LABEL (4, VFSX, 3, VFSY, N_("Timeout for freeing VFSs:")), - QUICK_END + /* 12 */ QUICK_LABEL (49, VFSX, 3, VFSY, N_("sec")), + /* 13 */ QUICK_INPUT (38, VFSX, 3, VFSY, buffer2, 10, 0, "input-timo-vfs", &ret_timeout), + /* 14 */ QUICK_LABEL (4, VFSX, 3, VFSY, N_("Timeout for freeing VFSs:")), + QUICK_END }; - QuickDialog confvfs_dlg = - { - VFSX, VFSY, -1, -1, N_(" Virtual File System Setting "), - "[Virtual FS]", confvfs_widgets, FALSE + QuickDialog confvfs_dlg = { + VFSX, VFSY, -1, -1, N_(" Virtual File System Setting "), + "[Virtual FS]", confvfs_widgets, FALSE }; #ifdef USE_NETCODE @@ -757,19 +765,20 @@ configure_vfs (void) #endif g_snprintf (buffer2, sizeof (buffer2), "%i", vfs_timeout); - if (quick_dialog (&confvfs_dlg) != B_CANCEL) { + if (quick_dialog (&confvfs_dlg) != B_CANCEL) + { vfs_timeout = atoi (ret_timeout); g_free (ret_timeout); if (vfs_timeout < 0 || vfs_timeout > 10000) vfs_timeout = 10; #ifdef USE_NETCODE - g_free (ftpfs_anonymous_passwd); - ftpfs_anonymous_passwd = ret_passwd; - g_free (ftpfs_proxy_host); - ftpfs_proxy_host = ret_ftp_proxy; - ftpfs_directory_timeout = atoi(ret_directory_timeout); - g_free (ret_directory_timeout); + g_free (ftpfs_anonymous_passwd); + ftpfs_anonymous_passwd = ret_passwd; + g_free (ftpfs_proxy_host); + ftpfs_proxy_host = ret_ftp_proxy; + ftpfs_directory_timeout = atoi (ret_directory_timeout); + g_free (ret_directory_timeout); #endif } @@ -777,7 +786,7 @@ configure_vfs (void) #undef VFSY } -#endif /* ENABLE_VFS */ +#endif /* ENABLE_VFS */ char * cd_dialog (void) @@ -795,49 +804,46 @@ cd_dialog (void) len = str_term_width1 (label); { - char *my_str; + char *my_str; - QuickWidget quick_widgets [] = - { - /* 0 */ QUICK_INPUT (4 + len, xlen, 2, ylen, "", xlen - 7 - len, 2, "input" , &my_str), - /* 1 */ QUICK_LABEL (3, xlen, 2, ylen, label), - QUICK_END - }; + QuickWidget quick_widgets[] = { + /* 0 */ QUICK_INPUT (4 + len, xlen, 2, ylen, "", xlen - 7 - len, 2, "input", &my_str), + /* 1 */ QUICK_LABEL (3, xlen, 2, ylen, label), + QUICK_END + }; - QuickDialog Quick_input = - { - xlen, ylen, 2, LINES - 2 - ylen, _("Quick cd"), - "[Quick cd]", quick_widgets, TRUE - }; + QuickDialog Quick_input = { + xlen, ylen, 2, LINES - 2 - ylen, _("Quick cd"), + "[Quick cd]", quick_widgets, TRUE + }; - return (quick_dialog (&Quick_input) != B_CANCEL) ? my_str : NULL; + return (quick_dialog (&Quick_input) != B_CANCEL) ? my_str : NULL; } } void -symlink_dialog (const char *existing, const char *new, char **ret_existing, - char **ret_new) +symlink_dialog (const char *existing, const char *new, char **ret_existing, char **ret_new) { - QuickWidget quick_widgets[] = - { - /* 0 */ QUICK_BUTTON (50, 80, 6, 8, N_("&Cancel"), B_CANCEL, NULL), - /* 1 */ QUICK_BUTTON (16, 80, 6, 8, N_("&OK"), B_ENTER, NULL), - /* 2 */ QUICK_INPUT (4, 80, 5, 8, new, 58, 0, "input-1", ret_new), - /* 3 */ QUICK_LABEL (4, 80, 4, 8, N_("Symbolic link filename:")), - /* 4 */ QUICK_INPUT (4, 80, 3, 8, existing, 58, 0, "input-2", ret_existing), - /* 5 */ QUICK_LABEL (4, 80, 2, 8, N_("Existing filename (filename symlink will point to):")), - QUICK_END + QuickWidget quick_widgets[] = { + /* 0 */ QUICK_BUTTON (50, 80, 6, 8, N_("&Cancel"), B_CANCEL, NULL), + /* 1 */ QUICK_BUTTON (16, 80, 6, 8, N_("&OK"), B_ENTER, NULL), + /* 2 */ QUICK_INPUT (4, 80, 5, 8, new, 58, 0, "input-1", ret_new), + /* 3 */ QUICK_LABEL (4, 80, 4, 8, N_("Symbolic link filename:")), + /* 4 */ QUICK_INPUT (4, 80, 3, 8, existing, 58, 0, "input-2", ret_existing), + /* 5 */ QUICK_LABEL (4, 80, 2, 8, + N_("Existing filename (filename symlink will point to):")), + QUICK_END }; - QuickDialog Quick_input = - { - 64, 12, -1, -1, N_("Symbolic link"), - "[File Menu]", quick_widgets, FALSE + QuickDialog Quick_input = { + 64, 12, -1, -1, N_("Symbolic link"), + "[File Menu]", quick_widgets, FALSE }; - if (quick_dialog (&Quick_input) == B_CANCEL) { - *ret_new = NULL; - *ret_existing = NULL; + if (quick_dialog (&Quick_input) == B_CANCEL) + { + *ret_new = NULL; + *ret_existing = NULL; } } @@ -854,21 +860,23 @@ static Dlg_head *jobs_dlg; static void jobs_fill_listbox (void) { - static const char *state_str [2]; + static const char *state_str[2]; TaskList *tl = task_list; - if (!state_str [0]){ - state_str [0] = _("Running "); - state_str [1] = _("Stopped"); + if (!state_str[0]) + { + state_str[0] = _("Running "); + state_str[1] = _("Stopped"); } - while (tl){ - char *s; + while (tl) + { + char *s; - s = g_strconcat (state_str [tl->state], " ", tl->info, (char *) NULL); - listbox_add_item (bg_list, LISTBOX_APPEND_AT_END, 0, s, (void *) tl); - g_free (s); - tl = tl->next; + s = g_strconcat (state_str[tl->state], " ", tl->info, (char *) NULL); + listbox_add_item (bg_list, LISTBOX_APPEND_AT_END, 0, s, (void *) tl); + g_free (s); + tl = tl->next; } } @@ -879,26 +887,31 @@ task_cb (int action) int sig = 0; if (!bg_list->list) - return 0; + return 0; /* Get this instance information */ listbox_get_current (bg_list, NULL, (void **) &tl); # ifdef SIGTSTP - if (action == B_STOP){ - sig = SIGSTOP; - tl->state = Task_Stopped; - } else if (action == B_RESUME){ - sig = SIGCONT; - tl->state = Task_Running; - } else -# endif - if (action == B_KILL){ - sig = SIGKILL; + if (action == B_STOP) + { + sig = SIGSTOP; + tl->state = Task_Stopped; } - + else if (action == B_RESUME) + { + sig = SIGCONT; + tl->state = Task_Running; + } + else +# endif + if (action == B_KILL) + { + sig = SIGKILL; + } + if (sig == SIGKILL) - unregister_task_running (tl->pid, tl->fd); + unregister_task_running (tl->pid, tl->fd); kill (tl->pid, sig); listbox_remove_list (bg_list); @@ -906,91 +919,94 @@ task_cb (int action) /* This can be optimized to just redraw this widget :-) */ dlg_redraw (jobs_dlg); - + return 0; } -static struct +static struct { - const char* name; - int xpos; - int value; - int (*callback)(int); -} -job_buttons [] = + const char *name; + int xpos; + int value; + int (*callback) (int); +} +job_buttons[] = { - {N_("&Stop"), 3, B_STOP, task_cb}, - {N_("&Resume"), 12, B_RESUME, task_cb}, - {N_("&Kill"), 23, B_KILL, task_cb}, - {N_("&OK"), 35, B_CANCEL, NULL } + { + N_("&Stop"), 3, B_STOP, task_cb}, + { + N_("&Resume"), 12, B_RESUME, task_cb}, + { + N_("&Kill"), 23, B_KILL, task_cb}, + { + N_("&OK"), 35, B_CANCEL, NULL} }; void jobs_cmd (void) { - register int i; - int n_buttons = sizeof (job_buttons) / sizeof (job_buttons[0]); + register int i; + int n_buttons = sizeof (job_buttons) / sizeof (job_buttons[0]); #ifdef ENABLE_NLS - static int i18n_flag = 0; - if (!i18n_flag) - { - int startx = job_buttons [0].xpos; - int len; + static int i18n_flag = 0; + if (!i18n_flag) + { + int startx = job_buttons[0].xpos; + int len; - for (i = 0; i < n_buttons; i++) - { - job_buttons [i].name = _(job_buttons [i].name); + for (i = 0; i < n_buttons; i++) + { + job_buttons[i].name = _(job_buttons[i].name); - len = str_term_width1 (job_buttons [i].name) + 4; - JOBS_X = max (JOBS_X, startx + len + 3); + len = str_term_width1 (job_buttons[i].name) + 4; + JOBS_X = max (JOBS_X, startx + len + 3); - job_buttons [i].xpos = startx; - startx += len; - } + job_buttons[i].xpos = startx; + startx += len; + } - /* Last button - Ok a.k.a. Cancel :) */ - job_buttons [n_buttons - 1].xpos = - JOBS_X - str_term_width1 (job_buttons [n_buttons - 1].name) - 7; + /* Last button - Ok a.k.a. Cancel :) */ + job_buttons[n_buttons - 1].xpos = + JOBS_X - str_term_width1 (job_buttons[n_buttons - 1].name) - 7; - i18n_flag = 1; - } + i18n_flag = 1; + } #endif /* ENABLE_NLS */ jobs_dlg = create_dlg (0, 0, JOBS_Y, JOBS_X, dialog_colors, NULL, - "[Background jobs]", _("Background Jobs"), - DLG_CENTER | DLG_REVERSE); + "[Background jobs]", _("Background Jobs"), DLG_CENTER | DLG_REVERSE); bg_list = listbox_new (2, 3, JOBS_Y - 9, JOBS_X - 7, FALSE, NULL); add_widget (jobs_dlg, bg_list); - i = n_buttons; - while (i--) - { - add_widget (jobs_dlg, button_new (JOBS_Y-4, - job_buttons [i].xpos, job_buttons [i].value, - NORMAL_BUTTON, job_buttons [i].name, - job_buttons [i].callback)); - } - + i = n_buttons; + while (i--) + { + add_widget (jobs_dlg, button_new (JOBS_Y - 4, + job_buttons[i].xpos, job_buttons[i].value, + NORMAL_BUTTON, job_buttons[i].name, + job_buttons[i].callback)); + } + /* Insert all of task information in the list */ jobs_fill_listbox (); run_dlg (jobs_dlg); - + destroy_dlg (jobs_dlg); } #endif /* WITH_BACKGROUND */ #ifdef ENABLE_VFS_SMB struct smb_authinfo * -vfs_smb_get_authinfo (const char *host, const char *share, const char *domain, - const char *user) +vfs_smb_get_authinfo (const char *host, const char *share, const char *domain, const char *user) { static int dialog_x = 44; - enum { b0 = 3, dialog_y = 12}; + enum + { b0 = 3, dialog_y = 12 }; struct smb_authinfo *return_value; - static const char* lc_labs[] = {N_("Domain:"), N_("Username:"), N_("Password:")}; - static const char* buts[] = {N_("&OK"), N_("&Cancel")}; + static const char *lc_labs[] = { N_("Domain:"), N_("Username:"), N_("Password:") }; + static const char *buts[] = { N_("&OK"), N_("&Cancel") }; static int ilen = 30, istart = 14; static int b2 = 30; char *title; @@ -1001,63 +1017,63 @@ vfs_smb_get_authinfo (const char *host, const char *share, const char *domain, #ifdef ENABLE_NLS static int i18n_flag = 0; - + if (!i18n_flag) { - register int i = sizeof(lc_labs)/sizeof(lc_labs[0]); + register int i = sizeof (lc_labs) / sizeof (lc_labs[0]); int l1, maxlen = 0; - + while (i--) { - l1 = str_term_width1 (lc_labs [i] = _(lc_labs [i])); + l1 = str_term_width1 (lc_labs[i] = _(lc_labs[i])); if (l1 > maxlen) maxlen = l1; } i = maxlen + ilen + 7; if (i > dialog_x) dialog_x = i; - - for (i = sizeof(buts)/sizeof(buts[0]), l1 = 0; i--; ) + + for (i = sizeof (buts) / sizeof (buts[0]), l1 = 0; i--;) { - l1 += str_term_width1 (buts [i] = _(buts [i])); + l1 += str_term_width1 (buts[i] = _(buts[i])); } l1 += 15; if (l1 > dialog_x) dialog_x = l1; - ilen = dialog_x - 7 - maxlen; /* for the case of very long buttons :) */ + ilen = dialog_x - 7 - maxlen; /* for the case of very long buttons :) */ istart = dialog_x - 3 - ilen; - + b2 = dialog_x - (str_term_width1 (buts[1]) + 6); - + i18n_flag = 1; } - + #endif /* ENABLE_NLS */ if (!domain) - domain = ""; + domain = ""; if (!user) - user = ""; + user = ""; title = g_strdup_printf (_("Password for \\\\%s\\%s"), host, share); auth_dlg = create_dlg (0, 0, dialog_y, dialog_x, dialog_colors, NULL, - "[Smb Authinfo]", title, DLG_CENTER | DLG_REVERSE); + "[Smb Authinfo]", title, DLG_CENTER | DLG_REVERSE); g_free (title); - in_user = input_new (5, istart, INPUT_COLOR, ilen, user, "auth_name", INPUT_COMPLETE_DEFAULT); + in_user = input_new (5, istart, INPUT_COLOR, ilen, user, "auth_name", INPUT_COMPLETE_DEFAULT); add_widget (auth_dlg, in_user); - in_domain = input_new (3, istart, INPUT_COLOR, ilen, domain, "auth_domain", INPUT_COMPLETE_DEFAULT); + in_domain = + input_new (3, istart, INPUT_COLOR, ilen, domain, "auth_domain", INPUT_COMPLETE_DEFAULT); add_widget (auth_dlg, in_domain); - add_widget (auth_dlg, button_new (9, b2, B_CANCEL, NORMAL_BUTTON, - buts[1], 0)); - add_widget (auth_dlg, button_new (9, b0, B_ENTER, DEFPUSH_BUTTON, - buts[0], 0)); + add_widget (auth_dlg, button_new (9, b2, B_CANCEL, NORMAL_BUTTON, buts[1], 0)); + add_widget (auth_dlg, button_new (9, b0, B_ENTER, DEFPUSH_BUTTON, buts[0], 0)); - in_password = input_new (7, istart, INPUT_COLOR, ilen, "", "auth_password", INPUT_COMPLETE_DEFAULT); + in_password = + input_new (7, istart, INPUT_COLOR, ilen, "", "auth_password", INPUT_COMPLETE_DEFAULT); in_password->completion_flags = 0; in_password->is_password = 1; add_widget (auth_dlg, in_password); @@ -1068,13 +1084,15 @@ vfs_smb_get_authinfo (const char *host, const char *share, const char *domain, run_dlg (auth_dlg); - switch (auth_dlg->ret_value) { + switch (auth_dlg->ret_value) + { case B_CANCEL: return_value = 0; break; default: return_value = g_try_new (struct smb_authinfo, 1); - if (return_value) { + if (return_value) + { return_value->host = g_strdup (host); return_value->share = g_strdup (share); return_value->domain = g_strdup (in_domain->buffer); @@ -1084,7 +1102,7 @@ vfs_smb_get_authinfo (const char *host, const char *share, const char *domain, } destroy_dlg (auth_dlg); - + return return_value; } #endif /* ENABLE_VFS_SMB */ diff --git a/src/diffviewer/search.c b/src/diffviewer/search.c index 2fe083d6d..cffbd29e4 100644 --- a/src/diffviewer/search.c +++ b/src/diffviewer/search.c @@ -118,7 +118,7 @@ mcdiffview_dialog_search (WDiff * dview) QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 6, SEARCH_DLG_HEIGHT, N_("&Backwards"), &mcdiffview_search_options.backwards), /* 4 */ - QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT, N_("case &Sensitive"), + QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT, N_("Case &sensitive"), &mcdiffview_search_options.case_sens), /* 5 */ QUICK_RADIO (3, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT, diff --git a/src/editor/editcmd_dialogs.c b/src/editor/editcmd_dialogs.c index 9ab731d32..5e895cf3e 100644 --- a/src/editor/editcmd_dialogs.c +++ b/src/editor/editcmd_dialogs.c @@ -118,7 +118,7 @@ editcmd_dialog_replace_show (WEdit * edit, const char *search_default, const cha /* 5 */ QUICK_CHECKBOX (33, REPLACE_DLG_WIDTH, 8, REPLACE_DLG_HEIGHT, N_("&Backwards"), &edit_search_options.backwards), /* 6 */ QUICK_CHECKBOX (33, REPLACE_DLG_WIDTH, 7, REPLACE_DLG_HEIGHT, - N_("case &Sensitive"), + N_("Case &sensitive"), &edit_search_options.case_sens), /* 7 */ QUICK_RADIO (3, REPLACE_DLG_WIDTH, 7, REPLACE_DLG_HEIGHT, num_of_types, (const char **) list_of_types, @@ -195,7 +195,7 @@ editcmd_dialog_search_show (WEdit * edit, char **search_text) QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 6, SEARCH_DLG_HEIGHT, N_("&Backwards"), &edit_search_options.backwards), /* 7 */ - QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT, N_("case &Sensitive"), + QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT, N_("Case &sensitive"), &edit_search_options.case_sens), /* 8 */ QUICK_RADIO (3, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT, diff --git a/src/filegui.c b/src/filegui.c index cd6683308..eebb4138f 100644 --- a/src/filegui.c +++ b/src/filegui.c @@ -932,12 +932,12 @@ file_mask_dialog (FileOpContext * ctx, FileOperation operation, /* 3 - OFFSET */ QUICK_CHECKBOX (42, FMDX, 8, FMDY, N_("&Stable Symlinks"), &ctx->stable_symlinks), /* 4 - OFFSET */ - QUICK_CHECKBOX (31, FMDX, 7, FMDY, N_("di&Ve into subdir if exists"), + QUICK_CHECKBOX (31, FMDX, 7, FMDY, N_("Di&ve into subdir if exists"), &ctx->dive_into_subdirs), /* 5 - OFFSET */ - QUICK_CHECKBOX (3, FMDX, 8, FMDY, N_("preserve &Attributes"), &ctx->op_preserve), + QUICK_CHECKBOX (3, FMDX, 8, FMDY, N_("Preserve &attributes"), &ctx->op_preserve), /* 6 - OFFSET */ - QUICK_CHECKBOX (3, FMDX, 7, FMDY, N_("follow &Links"), &ctx->follow_links), + QUICK_CHECKBOX (3, FMDX, 7, FMDY, N_("Follow &links"), &ctx->follow_links), /* 7 - OFFSET */ QUICK_INPUT (3, FMDX, 6, FMDY, "", 58, 0, "input2", &dest_dir), /* 8 - OFFSET */ diff --git a/src/hotlist.c b/src/hotlist.c index b80c376a8..f495e449d 100644 --- a/src/hotlist.c +++ b/src/hotlist.c @@ -138,9 +138,9 @@ static struct _hotlist_but LIST_MOVELIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM }, { B_INSERT, NORMAL_BUTTON, 1, 0, N_("&Insert"), LIST_MOVELIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM }, - { B_NEW_ENTRY, NORMAL_BUTTON, 1, 15, N_("New &Entry"), + { B_NEW_ENTRY, NORMAL_BUTTON, 1, 15, N_("New &entry"), LIST_HOTLIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM }, - { B_NEW_GROUP, NORMAL_BUTTON, 1, 0, N_("New &Group"), + { B_NEW_GROUP, NORMAL_BUTTON, 1, 0, N_("New &group"), LIST_HOTLIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM }, { B_CANCEL, NORMAL_BUTTON, 0, 53, N_("&Cancel"), LIST_HOTLIST | LIST_VFSLIST | LIST_MOVELIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM }, @@ -154,7 +154,7 @@ static struct _hotlist_but { B_FREE_ALL_VFS, NORMAL_BUTTON, 0, 20, N_("Fr&ee VFSs now"), LIST_VFSLIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM }, #endif - { B_ENTER, DEFPUSH_BUTTON, 0, 0, N_("Change &To"), + { B_ENTER, DEFPUSH_BUTTON, 0, 0, N_("Change &to"), LIST_HOTLIST | LIST_VFSLIST | LIST_MOVELIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM } /* *INDENT-ON* */ }; diff --git a/src/layout.c b/src/layout.c index 0cb014a07..ff1edb0a4 100644 --- a/src/layout.c +++ b/src/layout.c @@ -1,9 +1,9 @@ /* Panel layout module for the Midnight Commander Copyright (C) 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc. - + Written: 1995 Janne Kukonlehto - 1995 Miguel de Icaza + 1995 Miguel de Icaza This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -49,9 +49,9 @@ #include "lib/skin.h" #include "lib/tty/key.h" #include "lib/tty/mouse.h" -#include "lib/tty/win.h" /* do_enter_ca_mode() */ +#include "lib/tty/win.h" /* do_enter_ca_mode() */ #include "lib/mcconfig.h" -#include "lib/vfs/mc-vfs/vfs.h" /* For vfs_translate_url() */ +#include "lib/vfs/mc-vfs/vfs.h" /* For vfs_translate_url() */ #include "lib/strutil.h" #include "dialog.h" @@ -59,19 +59,19 @@ #include "command.h" #include "main-widgets.h" #include "main.h" -#include "subshell.h" /* For use_subshell and resize_subshell() */ +#include "subshell.h" /* For use_subshell and resize_subshell() */ #include "tree.h" #include "menu.h" #include "background.h" /* we_are_background */ /* Needed for the extern declarations of integer parameters */ #include "dir.h" -#include "panel.h" /* The Panel widget */ +#include "panel.h" /* The Panel widget */ #include "consaver/cons.saver.h" #include "layout.h" -#include "info.h" /* The Info widget */ -#include "src/viewer/mcviewer.h" /* The view widget */ +#include "info.h" /* The Info widget */ +#include "src/viewer/mcviewer.h" /* The view widget */ -#include "setup.h" /* For save_setup() */ +#include "setup.h" /* For save_setup() */ /* Controls the display of the rotating dash on the verbose mode */ int nice_rotating_dash = 1; @@ -114,14 +114,18 @@ int output_start_y = 0; /* Janne gets around this, we will only manage two of them :-) */ #define MAX_VIEWS 2 -static struct { +static struct +{ panel_view_mode_t type; Widget *widget; - char *last_saved_dir; /* last view_list working directory */ -} panels [MAX_VIEWS] = { + char *last_saved_dir; /* last view_list working directory */ +} panels[MAX_VIEWS] = +{ + /* *INDENT-OFF* */ /* init MAX_VIEWS items */ - { view_listing, NULL, NULL }, - { view_listing, NULL, NULL } + { view_listing, NULL, NULL}, + { view_listing, NULL, NULL} + /* *INDENT-ON* */ }; /* These variables are used to avoid updating the information unless */ @@ -155,26 +159,30 @@ static int height; static Dlg_head *layout_dlg; -static const char *s_split_direction [2] = { - N_("&Vertical"), +static const char *s_split_direction[2] = { + N_("&Vertical"), N_("&Horizontal") }; static WRadio *radio_widget; -static struct { - const char *text; - int *variable; +static struct +{ + const char *text; + int *variable; WCheck *widget; -} check_options [] = { - { N_("show free sp&Ace"), &free_space, NULL }, - { N_("&XTerm window title"), &xterm_title, NULL }, - { N_("h&Intbar visible"), &message_visible, NULL }, - { N_("&Keybar visible"), &keybar_visible, NULL }, - { N_("command &Prompt"), &command_prompt, NULL }, - { N_("show &Mini status"), &show_mini_info, NULL }, - { N_("menu&Bar visible"), &menubar_visible, NULL }, - { N_("&Equal split"), &equal_split, NULL } +} check_options[] = +{ + /* *INDENT-OFF* */ + { N_("Show free sp&ace"), &free_space, NULL}, + { N_("&XTerm window title"), &xterm_title, NULL}, + { N_("H&intbar visible"), &message_visible, NULL}, + { N_("&Keybar visible"), &keybar_visible, NULL}, + { N_("Command &prompt"), &command_prompt, NULL}, + { N_("Show &mini status"), &show_mini_info, NULL}, + { N_("Menu&bar visible"), &menubar_visible, NULL}, + { N_("&Equal split"), &equal_split, NULL} + /* *INDENT-ON* */ }; #define LAYOUT_OPTIONS_COUNT sizeof (check_options) / sizeof (check_options[0]) @@ -186,168 +194,186 @@ static int output_lines_label_len; static WButton *bleft_widget, *bright_widget; -static void _check_split (void) +static void +_check_split (void) { - if (_horizontal_split){ - if (_equal_split) - _first_panel_size = height / 2; - else if (_first_panel_size < MINHEIGHT) - _first_panel_size = MINHEIGHT; - else if (_first_panel_size > height - MINHEIGHT) - _first_panel_size = height - MINHEIGHT; - } else { - if (_equal_split) - _first_panel_size = COLS / 2; - else if (_first_panel_size < MINWIDTH) - _first_panel_size = MINWIDTH; - else if (_first_panel_size > COLS - MINWIDTH) - _first_panel_size = COLS - MINWIDTH; + if (_horizontal_split) + { + if (_equal_split) + _first_panel_size = height / 2; + else if (_first_panel_size < MINHEIGHT) + _first_panel_size = MINHEIGHT; + else if (_first_panel_size > height - MINHEIGHT) + _first_panel_size = height - MINHEIGHT; + } + else + { + if (_equal_split) + _first_panel_size = COLS / 2; + else if (_first_panel_size < MINWIDTH) + _first_panel_size = MINWIDTH; + else if (_first_panel_size > COLS - MINWIDTH) + _first_panel_size = COLS - MINWIDTH; } } -static void update_split (void) +static void +update_split (void) { /* Check split has to be done before testing if it changed, since - it can change due to calling _check_split() as well*/ + it can change due to calling _check_split() as well */ _check_split (); - + /* To avoid setting the cursor to the wrong place */ - if ((old_first_panel_size == _first_panel_size) && - (old_horizontal_split == _horizontal_split)){ - return; - } + if ((old_first_panel_size == _first_panel_size) && (old_horizontal_split == _horizontal_split)) + return; old_first_panel_size = _first_panel_size; - old_horizontal_split = _horizontal_split; - + old_horizontal_split = _horizontal_split; + tty_setcolor (COLOR_NORMAL); dlg_move (layout_dlg, 6, 6); tty_printf ("%03d", _first_panel_size); dlg_move (layout_dlg, 6, 18); if (_horizontal_split) - tty_printf ("%03d", height - _first_panel_size); + tty_printf ("%03d", height - _first_panel_size); else - tty_printf ("%03d", COLS - _first_panel_size); + tty_printf ("%03d", COLS - _first_panel_size); } -static int b2left_cback (int action) +static int +b2left_cback (int action) { (void) action; - if (_equal_split){ - /* Turn equal split off */ - _equal_split = 0; - check_options [7].widget->state = check_options [7].widget->state & ~C_BOOL; - dlg_select_widget (check_options [7].widget); - dlg_select_widget (bleft_widget); + if (_equal_split) + { + /* Turn equal split off */ + _equal_split = 0; + check_options[7].widget->state = check_options[7].widget->state & ~C_BOOL; + dlg_select_widget (check_options[7].widget); + dlg_select_widget (bleft_widget); } _first_panel_size++; return 0; } -static int b2right_cback (int action) +static int +b2right_cback (int action) { (void) action; - if (_equal_split){ - /* Turn equal split off */ - _equal_split = 0; - check_options [7].widget->state = check_options [7].widget->state & ~C_BOOL; - dlg_select_widget (check_options [7].widget); - dlg_select_widget (bright_widget); + if (_equal_split) + { + /* Turn equal split off */ + _equal_split = 0; + check_options[7].widget->state = check_options[7].widget->state & ~C_BOOL; + dlg_select_widget (check_options[7].widget); + dlg_select_widget (bright_widget); } _first_panel_size--; return 0; } -static int bplus_cback (int action) +static int +bplus_cback (int action) { (void) action; if (_output_lines < 99) - _output_lines++; + _output_lines++; return 0; } -static int bminus_cback (int action) +static int +bminus_cback (int action) { (void) action; if (_output_lines > 0) - _output_lines--; + _output_lines--; return 0; } static cb_ret_t -layout_callback (Dlg_head *h, Widget *sender, - dlg_msg_t msg, int parm, void *data) +layout_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data) { - switch (msg) { + switch (msg) + { case DLG_DRAW: - /*When repainting the whole dialog (e.g. with C-l) we have to - update everything*/ - common_dialog_repaint (h); + /*When repainting the whole dialog (e.g. with C-l) we have to + update everything */ + common_dialog_repaint (h); - old_first_panel_size = -1; - old_horizontal_split = -1; - old_output_lines = -1; + old_first_panel_size = -1; + old_horizontal_split = -1; + old_output_lines = -1; - tty_setcolor (COLOR_HOT_NORMAL); - update_split (); - dlg_move (h, 6, 13); - tty_print_char ('='); - if (console_flag){ - if (old_output_lines != _output_lines){ - old_output_lines = _output_lines; - tty_setcolor (COLOR_NORMAL); - dlg_move (h, 9, 6); - tty_print_string (output_lines_label); - dlg_move (h, 9, 6 + 3 + output_lines_label_len); - tty_printf ("%02d", _output_lines); - } - } - return MSG_HANDLED; + tty_setcolor (COLOR_HOT_NORMAL); + update_split (); + dlg_move (h, 6, 13); + tty_print_char ('='); + if (console_flag) + { + if (old_output_lines != _output_lines) + { + old_output_lines = _output_lines; + tty_setcolor (COLOR_NORMAL); + dlg_move (h, 9, 6); + tty_print_string (output_lines_label); + dlg_move (h, 9, 6 + 3 + output_lines_label_len); + tty_printf ("%02d", _output_lines); + } + } + return MSG_HANDLED; case DLG_POST_KEY: - _equal_split = check_options [7].widget->state & C_BOOL; - _menubar_visible = check_options [6].widget->state & C_BOOL; - _command_prompt = check_options [5].widget->state & C_BOOL; - _keybar_visible = check_options [3].widget->state & C_BOOL; - _message_visible = check_options [2].widget->state & C_BOOL; - _xterm_title = check_options [1].widget->state & C_BOOL; - _free_space = check_options [0].widget->state & C_BOOL; - if (console_flag){ - int minimum; - if (_output_lines < 0) - _output_lines = 0; - height = LINES - _keybar_visible - _command_prompt - - _menubar_visible - _output_lines - _message_visible; - minimum = MINHEIGHT * (1 + _horizontal_split); - if (height < minimum){ - _output_lines -= minimum - height; - height = minimum; - } - } else { - height = LINES - _keybar_visible - _command_prompt - - _menubar_visible - _output_lines - _message_visible; - } - if (_horizontal_split != radio_widget->sel){ - _horizontal_split = radio_widget->sel; - if (_horizontal_split) - _first_panel_size = height / 2; - else - _first_panel_size = COLS / 2; - } - update_split (); - if (console_flag){ - if (old_output_lines != _output_lines){ - old_output_lines = _output_lines; - tty_setcolor (COLOR_NORMAL); - dlg_move (h, 9, 6 + 3 + output_lines_label_len); - tty_printf ("%02d", _output_lines); - } - } - return MSG_HANDLED; + _equal_split = check_options[7].widget->state & C_BOOL; + _menubar_visible = check_options[6].widget->state & C_BOOL; + _command_prompt = check_options[5].widget->state & C_BOOL; + _keybar_visible = check_options[3].widget->state & C_BOOL; + _message_visible = check_options[2].widget->state & C_BOOL; + _xterm_title = check_options[1].widget->state & C_BOOL; + _free_space = check_options[0].widget->state & C_BOOL; + if (console_flag) + { + int minimum; + if (_output_lines < 0) + _output_lines = 0; + height = LINES - _keybar_visible - _command_prompt - + _menubar_visible - _output_lines - _message_visible; + minimum = MINHEIGHT * (1 + _horizontal_split); + if (height < minimum) + { + _output_lines -= minimum - height; + height = minimum; + } + } + else + { + height = LINES - _keybar_visible - _command_prompt - + _menubar_visible - _output_lines - _message_visible; + } + if (_horizontal_split != radio_widget->sel) + { + _horizontal_split = radio_widget->sel; + if (_horizontal_split) + _first_panel_size = height / 2; + else + _first_panel_size = COLS / 2; + } + update_split (); + if (console_flag) + { + if (old_output_lines != _output_lines) + { + old_output_lines = _output_lines; + tty_setcolor (COLOR_NORMAL); + dlg_move (h, 9, 6 + 3 + output_lines_label_len); + tty_printf ("%02d", _output_lines); + } + } + return MSG_HANDLED; default: return default_dlg_callback (h, sender, msg, parm, data); @@ -365,92 +391,89 @@ init_layout (void) const char *save_button = _("&Save"); static const char *title1, *title2, *title3; - if (!i18n_layt_flag) { - gsize l1; + if (!i18n_layt_flag) + { + gsize l1; - first_width = 0; + first_width = 0; - title1 = _(" Panel split "); - title2 = _(" Console output "); - title3 = _(" Other options "); - output_lines_label = _("Output lines: "); + title1 = _(" Panel split "); + title2 = _(" Console output "); + title3 = _(" Other options "); + output_lines_label = _("Output lines: "); - while (i--) { - s_split_direction[i] = _(s_split_direction[i]); + while (i--) + { + s_split_direction[i] = _(s_split_direction[i]); l1 = str_term_width1 (s_split_direction[i]) + 7; - if (l1 > first_width) - first_width = l1; - } + if (l1 > first_width) + first_width = l1; + } - for (i = 0; i < LAYOUT_OPTIONS_COUNT; i++) { - check_options[i].text = _(check_options[i].text); + for (i = 0; i < LAYOUT_OPTIONS_COUNT; i++) + { + check_options[i].text = _(check_options[i].text); l1 = str_term_width1 (check_options[i].text) + 7; - if (l1 > first_width) - first_width = l1; - } + if (l1 > first_width) + first_width = l1; + } - l1 = str_term_width1 (title1) + 1; - if (l1 > first_width) - first_width = l1; + l1 = str_term_width1 (title1) + 1; + if (l1 > first_width) + first_width = l1; - l1 = str_term_width1 (title2) + 1; - if (l1 > first_width) - first_width = l1; + l1 = str_term_width1 (title2) + 1; + if (l1 > first_width) + first_width = l1; - if (console_flag) { - output_lines_label_len = str_term_width1 (output_lines_label); + if (console_flag) + { + output_lines_label_len = str_term_width1 (output_lines_label); l1 = output_lines_label_len + 12; - if (l1 > first_width) - first_width = l1; - } + if (l1 > first_width) + first_width = l1; + } - /* - * alex@bcs.zp.ua: - * To be completely correct, one need to check if the title - * does not exceed dialog length and total length of 3 buttons - * allows their placement in one row. But assuming this dialog - * is wide enough, I don't include such a tests. - * - * Now the last thing to do - properly space buttons... - */ - l1 = 11 + str_term_width1 (ok_button) /* 14 - all brackets and inner space */ - + str_term_width1 (save_button) /* notice: it is 3 char less because */ - + str_term_width1 (cancel_button); /* of '&' char in button text */ + /* + * alex@bcs.zp.ua: + * To be completely correct, one need to check if the title + * does not exceed dialog length and total length of 3 buttons + * allows their placement in one row. But assuming this dialog + * is wide enough, I don't include such a tests. + * + * Now the last thing to do - properly space buttons... + */ + l1 = 11 + str_term_width1 (ok_button) /* 14 - all brackets and inner space */ + + str_term_width1 (save_button) /* notice: it is 3 char less because */ + + str_term_width1 (cancel_button); /* of '&' char in button text */ - i = (first_width * 2 - l1) / 4; - b1 = 5 + i; + i = (first_width * 2 - l1) / 4; + b1 = 5 + i; b2 = b1 + str_term_width1 (ok_button) + i + 6; b3 = b2 + str_term_width1 (save_button) + i + 4; - i18n_layt_flag = 1; + i18n_layt_flag = 1; } layout_dlg = - create_dlg (0, 0, 14, first_width * 2 + 9, - dialog_colors, layout_callback, "[Layout]", - _("Layout"), DLG_CENTER | DLG_REVERSE); + create_dlg (0, 0, 14, first_width * 2 + 9, + dialog_colors, layout_callback, "[Layout]", + _("Layout"), DLG_CENTER | DLG_REVERSE); add_widget (layout_dlg, groupbox_new (2, 4, 6, first_width, title1)); - add_widget (layout_dlg, - groupbox_new (2, 5 + first_width, 9, first_width, - title3)); + add_widget (layout_dlg, groupbox_new (2, 5 + first_width, 9, first_width, title3)); - add_widget (layout_dlg, - button_new (11, b3, B_CANCEL, NORMAL_BUTTON, cancel_button, - 0)); - add_widget (layout_dlg, - button_new (11, b2, B_EXIT, NORMAL_BUTTON, save_button, - 0)); - add_widget (layout_dlg, - button_new (11, b1, B_ENTER, DEFPUSH_BUTTON, ok_button, - 0)); + add_widget (layout_dlg, button_new (11, b3, B_CANCEL, NORMAL_BUTTON, cancel_button, 0)); + add_widget (layout_dlg, button_new (11, b2, B_EXIT, NORMAL_BUTTON, save_button, 0)); + add_widget (layout_dlg, button_new (11, b1, B_ENTER, DEFPUSH_BUTTON, ok_button, 0)); #define XTRACT(i) *check_options[i].variable, check_options[i].text - for (i = 0; i < OTHER_OPTIONS_COUNT; i++) { - check_options[i].widget = - check_new (OTHER_OPTIONS_COUNT - i + 2, 7 + first_width, XTRACT (i)); - add_widget (layout_dlg, check_options[i].widget); + for (i = 0; i < OTHER_OPTIONS_COUNT; i++) + { + check_options[i].widget = + check_new (OTHER_OPTIONS_COUNT - i + 2, 7 + first_width, XTRACT (i)); + add_widget (layout_dlg, check_options[i].widget); } _equal_split = equal_split; @@ -461,22 +484,21 @@ init_layout (void) _xterm_title = xterm_title; _free_space = free_space; - if (console_flag) { - add_widget (layout_dlg, groupbox_new (8, 4, 3, first_width, title2)); + if (console_flag) + { + add_widget (layout_dlg, groupbox_new (8, 4, 3, first_width, title2)); - add_widget (layout_dlg, - button_new (9, output_lines_label_len + 6 + 5, B_MINUS, - NARROW_BUTTON, "&-", bminus_cback)); - add_widget (layout_dlg, - button_new (9, output_lines_label_len + 6, B_PLUS, - NARROW_BUTTON, "&+", bplus_cback)); + add_widget (layout_dlg, + button_new (9, output_lines_label_len + 6 + 5, B_MINUS, + NARROW_BUTTON, "&-", bminus_cback)); + add_widget (layout_dlg, + button_new (9, output_lines_label_len + 6, B_PLUS, + NARROW_BUTTON, "&+", bplus_cback)); } - bright_widget = - button_new (6, 15, B_2RIGHT, NARROW_BUTTON, "&>", b2right_cback); + bright_widget = button_new (6, 15, B_2RIGHT, NARROW_BUTTON, "&>", b2right_cback); add_widget (layout_dlg, bright_widget); - bleft_widget = - button_new (6, 9, B_2LEFT, NARROW_BUTTON, "&<", b2left_cback); + bleft_widget = button_new (6, 9, B_2LEFT, NARROW_BUTTON, "&<", b2left_cback); add_widget (layout_dlg, bleft_widget); check_options[7].widget = check_new (5, 6, XTRACT (7)); @@ -505,7 +527,8 @@ layout_change (void) load_hint (1); } -void layout_box (void) +void +layout_box (void) { int result; int i; @@ -515,41 +538,47 @@ void layout_box (void) run_dlg (layout_dlg); result = layout_dlg->ret_value; - if (result == B_ENTER || result == B_EXIT){ - for (i = 0; i < LAYOUT_OPTIONS_COUNT; i++) - if (check_options [i].widget) - *check_options [i].variable = check_options [i].widget->state & C_BOOL; - horizontal_split = radio_widget->sel; - first_panel_size = _first_panel_size; - output_lines = _output_lines; - layout_do_change = 1; + if (result == B_ENTER || result == B_EXIT) + { + for (i = 0; i < LAYOUT_OPTIONS_COUNT; i++) + if (check_options[i].widget) + *check_options[i].variable = check_options[i].widget->state & C_BOOL; + horizontal_split = radio_widget->sel; + first_panel_size = _first_panel_size; + output_lines = _output_lines; + layout_do_change = 1; } - if (result == B_EXIT){ - save_layout (); - mc_config_save_file (mc_main_config, NULL); + if (result == B_EXIT) + { + save_layout (); + mc_config_save_file (mc_main_config, NULL); } destroy_dlg (layout_dlg); if (layout_do_change) - layout_change (); + layout_change (); } -static void check_split (void) +static void +check_split (void) { - if (horizontal_split){ - if (equal_split) - first_panel_size = height / 2; - else if (first_panel_size < MINHEIGHT) - first_panel_size = MINHEIGHT; - else if (first_panel_size > height - MINHEIGHT) - first_panel_size = height - MINHEIGHT; - } else { - if (equal_split) - first_panel_size = COLS / 2; - else if (first_panel_size < MINWIDTH) - first_panel_size = MINWIDTH; - else if (first_panel_size > COLS - MINWIDTH) - first_panel_size = COLS - MINWIDTH; + if (horizontal_split) + { + if (equal_split) + first_panel_size = height / 2; + else if (first_panel_size < MINHEIGHT) + first_panel_size = MINHEIGHT; + else if (first_panel_size > height - MINHEIGHT) + first_panel_size = height - MINHEIGHT; + } + else + { + if (equal_split) + first_panel_size = COLS / 2; + else if (first_panel_size < MINWIDTH) + first_panel_size = MINWIDTH; + else if (first_panel_size > COLS - MINWIDTH) + first_panel_size = COLS - MINWIDTH; } } @@ -573,14 +602,15 @@ mc_refresh (void) { #ifdef WITH_BACKGROUND if (we_are_background) - return; -#endif /* WITH_BACKGROUND */ + return; +#endif /* WITH_BACKGROUND */ if (winch_flag == 0) - tty_refresh (); - else { - /* if winch was caugth, we should do not only redraw screen, but - reposition/resize all */ - change_screen_size (); + tty_refresh (); + else + { + /* if winch was caugth, we should do not only redraw screen, but + reposition/resize all */ + change_screen_size (); } } @@ -588,50 +618,54 @@ static void panel_do_cols (int idx) { if (get_display_type (idx) == view_listing) - set_panel_formats ((WPanel *) panels [idx].widget); + set_panel_formats ((WPanel *) panels[idx].widget); else - panel_update_cols (panels [idx].widget, frame_half); + panel_update_cols (panels[idx].widget, frame_half); } void setup_panels (void) { int start_y; - int promptl; /* the prompt len */ + int promptl; /* the prompt len */ - if (console_flag) { - int minimum; - if (output_lines < 0) - output_lines = 0; - height = - LINES - keybar_visible - command_prompt - menubar_visible - - output_lines - message_visible; - minimum = MINHEIGHT * (1 + horizontal_split); - if (height < minimum) { - output_lines -= minimum - height; - height = minimum; - } - } else { - height = - LINES - menubar_visible - command_prompt - keybar_visible - - message_visible; + if (console_flag) + { + int minimum; + if (output_lines < 0) + output_lines = 0; + height = + LINES - keybar_visible - command_prompt - menubar_visible - + output_lines - message_visible; + minimum = MINHEIGHT * (1 + horizontal_split); + if (height < minimum) + { + output_lines -= minimum - height; + height = minimum; + } + } + else + { + height = LINES - menubar_visible - command_prompt - keybar_visible - message_visible; } check_split (); start_y = menubar_visible; /* The column computing is defered until panel_do_cols */ - if (horizontal_split) { - widget_set_size (panels[0].widget, start_y, 0, first_panel_size, - 0); + if (horizontal_split) + { + widget_set_size (panels[0].widget, start_y, 0, first_panel_size, 0); - widget_set_size (panels[1].widget, start_y + first_panel_size, 0, - height - first_panel_size, 0); - } else { - int first_x = first_panel_size; + widget_set_size (panels[1].widget, start_y + first_panel_size, 0, + height - first_panel_size, 0); + } + else + { + int first_x = first_panel_size; - widget_set_size (panels[0].widget, start_y, 0, height, 0); + widget_set_size (panels[0].widget, start_y, 0, height, 0); - widget_set_size (panels[1].widget, start_y, first_x, height, 0); + widget_set_size (panels[1].widget, start_y, first_x, height, 0); } panel_do_cols (0); @@ -641,33 +675,34 @@ setup_panels (void) widget_set_size (&the_menubar->widget, 0, 0, 1, COLS); - if (command_prompt) { - widget_set_size (&cmdline->widget, LINES - 1 - keybar_visible, - promptl, 1, COLS - promptl); - winput_set_origin (cmdline, promptl, COLS - promptl); - widget_set_size (&the_prompt->widget, LINES - 1 - keybar_visible, - 0, 1, promptl); - } else { - widget_set_size (&cmdline->widget, 0, 0, 0, 0); - winput_set_origin (cmdline, 0, 0); - widget_set_size (&the_prompt->widget, LINES, COLS, 0, 0); + if (command_prompt) + { + widget_set_size (&cmdline->widget, LINES - 1 - keybar_visible, promptl, 1, COLS - promptl); + winput_set_origin (cmdline, promptl, COLS - promptl); + widget_set_size (&the_prompt->widget, LINES - 1 - keybar_visible, 0, 1, promptl); + } + else + { + widget_set_size (&cmdline->widget, 0, 0, 0, 0); + winput_set_origin (cmdline, 0, 0); + widget_set_size (&the_prompt->widget, LINES, COLS, 0, 0); } widget_set_size (&the_bar->widget, LINES - 1, 0, keybar_visible, COLS); buttonbar_set_visible (the_bar, keybar_visible); /* Output window */ - if (console_flag && output_lines) { - output_start_y = - LINES - command_prompt - keybar_visible - output_lines; - show_console_contents (output_start_y, - LINES - output_lines - keybar_visible - 1, - LINES - keybar_visible - 1); + if (console_flag && output_lines) + { + output_start_y = LINES - command_prompt - keybar_visible - output_lines; + show_console_contents (output_start_y, + LINES - output_lines - keybar_visible - 1, + LINES - keybar_visible - 1); } if (message_visible) - widget_set_size (&the_hint->widget, height + start_y, 0, 1, COLS); + widget_set_size (&the_hint->widget, height + start_y, 0, 1, COLS); else - widget_set_size (&the_hint->widget, 0, 0, 0, 0); + widget_set_size (&the_hint->widget, 0, 0, 0, 0); update_xterm_title_path (); } @@ -682,16 +717,17 @@ low_level_change_screen_size (void) winsz.ws_col = winsz.ws_row = 0; /* Ioctl on the STDIN_FILENO */ ioctl (0, TIOCGWINSZ, &winsz); - if (winsz.ws_col && winsz.ws_row){ + if (winsz.ws_col && winsz.ws_row) + { #if defined(NCURSES_VERSION) && defined(HAVE_RESIZETERM) - resizeterm(winsz.ws_row, winsz.ws_col); - clearok(stdscr,TRUE); /* sigwinch's should use a semaphore! */ + resizeterm (winsz.ws_row, winsz.ws_col); + clearok (stdscr, TRUE); /* sigwinch's should use a semaphore! */ #else - COLS = winsz.ws_col; - LINES = winsz.ws_row; + COLS = winsz.ws_col; + LINES = winsz.ws_row; #endif #ifdef HAVE_SUBSHELL_SUPPORT - resize_subshell (); + resize_subshell (); #endif } #endif /* TIOCGWINSZ */ @@ -702,7 +738,7 @@ void sigwinch_handler (int dummy) { (void) dummy; -#if !(defined(USE_NCURSES) || defined(USE_NCURSESW)) /* don't do malloc in a signal handler */ +#if !(defined(USE_NCURSES) || defined(USE_NCURSESW)) /* don't do malloc in a signal handler */ low_level_change_screen_size (); #endif winch_flag = 1; @@ -737,96 +773,103 @@ change_screen_size (void) /* Inform all running dialogs */ d = current_dlg; - while (d != NULL) { - (*d->callback) (d, NULL, DLG_RESIZE, 0, NULL); - d = d->parent; + while (d != NULL) + { + (*d->callback) (d, NULL, DLG_RESIZE, 0, NULL); + d = d->parent; } /* Now, force the redraw */ repaint_screen (); -#endif /* TIOCGWINSZ */ -#endif /* defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4 */ +#endif /* TIOCGWINSZ */ +#endif /* defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4 */ } static int ok_to_refresh = 1; -void use_dash (int flag) +void +use_dash (int flag) { if (flag) - ok_to_refresh++; + ok_to_refresh++; else - ok_to_refresh--; + ok_to_refresh--; } -void set_hintbar(const char *str) +void +set_hintbar (const char *str) { label_set_text (the_hint, str); if (ok_to_refresh > 0) - mc_refresh(); + mc_refresh (); } -void print_vfs_message (const char *msg, ...) +void +print_vfs_message (const char *msg, ...) { va_list ap; - char str [128]; + char str[128]; va_start (ap, msg); g_vsnprintf (str, sizeof (str), msg, ap); va_end (ap); if (midnight_shutdown) - return; + return; - if (!message_visible || !the_hint || !the_hint->widget.parent) { - int col, row; + if (!message_visible || !the_hint || !the_hint->widget.parent) + { + int col, row; - if (!nice_rotating_dash || (ok_to_refresh <= 0)) - return; + if (!nice_rotating_dash || (ok_to_refresh <= 0)) + return; - /* Preserve current cursor position */ - tty_getyx (&row, &col); + /* Preserve current cursor position */ + tty_getyx (&row, &col); - tty_gotoyx (0, 0); - tty_setcolor (NORMAL_COLOR); - tty_print_string (str_fit_to_term (str, COLS - 1, J_LEFT)); + tty_gotoyx (0, 0); + tty_setcolor (NORMAL_COLOR); + tty_print_string (str_fit_to_term (str, COLS - 1, J_LEFT)); - /* Restore cursor position */ - tty_gotoyx (row, col); - mc_refresh (); - return; + /* Restore cursor position */ + tty_gotoyx (row, col); + mc_refresh (); + return; } - if (message_visible) { - set_hintbar(str); - } + if (message_visible) + set_hintbar (str); } -void rotate_dash (void) +void +rotate_dash (void) { - static const char rotating_dash [] = "|/-\\"; + static const char rotating_dash[] = "|/-\\"; static size_t pos = 0; if (!nice_rotating_dash || (ok_to_refresh <= 0)) - return; + return; - if (pos >= sizeof (rotating_dash)-1) - pos = 0; + if (pos >= sizeof (rotating_dash) - 1) + pos = 0; tty_gotoyx (0, COLS - 1); tty_setcolor (NORMAL_COLOR); - tty_print_char (rotating_dash [pos]); + tty_print_char (rotating_dash[pos]); mc_refresh (); pos++; } -const char *get_nth_panel_name (int num) +const char * +get_nth_panel_name (int num) { - static char buffer [BUF_SMALL]; - + static char buffer[BUF_SMALL]; + if (!num) return "New Left Panel"; else if (num == 1) return "New Right Panel"; - else { + else + { g_snprintf (buffer, sizeof (buffer), "%ith Panel", num); return buffer; } @@ -847,84 +890,91 @@ void set_display_type (int num, panel_view_mode_t type) { int x = 0, y = 0, cols = 0, lines = 0; - int the_other = 0; /* Index to the other panel */ - const char *file_name = NULL; /* For Quick view */ + int the_other = 0; /* Index to the other panel */ + const char *file_name = NULL; /* For Quick view */ Widget *new_widget = NULL, *old_widget = NULL; WPanel *the_other_panel = NULL; - if (num >= MAX_VIEWS){ - fprintf (stderr, "Cannot allocate more that %d views\n", MAX_VIEWS); - abort (); + if (num >= MAX_VIEWS) + { + fprintf (stderr, "Cannot allocate more that %d views\n", MAX_VIEWS); + abort (); } /* Check that we will have a WPanel * at least */ - if (type != view_listing) { - the_other = num == 0 ? 1 : 0; + if (type != view_listing) + { + the_other = num == 0 ? 1 : 0; - if (panels [the_other].type != view_listing) - return; + if (panels[the_other].type != view_listing) + return; } /* Get rid of it */ - if (panels [num].widget) { - Widget *w = panels [num].widget; - WPanel *panel = (WPanel *) panels [num].widget; + if (panels[num].widget) + { + Widget *w = panels[num].widget; + WPanel *panel = (WPanel *) panels[num].widget; - x = w->x; - y = w->y; - cols = w->cols; - lines = w->lines; - old_widget = panels [num].widget; + x = w->x; + y = w->y; + cols = w->cols; + lines = w->lines; + old_widget = panels[num].widget; - if (panels [num].type == view_listing) { - if (panel->frame_size == frame_full && type != view_listing) { - cols = COLS - first_panel_size; - if (num == 1) - x = first_panel_size; - } - } + if (panels[num].type == view_listing) + { + if (panel->frame_size == frame_full && type != view_listing) + { + cols = COLS - first_panel_size; + if (num == 1) + x = first_panel_size; + } + } } /* Restoring saved path from panels.ini for nonlist panel */ /* when it's first creation (for example view_info) */ - if (old_widget == NULL && type != view_listing) { - char panel_dir [MC_MAXPATHLEN]; - mc_get_current_wd (panel_dir, sizeof (panel_dir)); - panels[num].last_saved_dir = g_strdup (panel_dir); + if (old_widget == NULL && type != view_listing) + { + char panel_dir[MC_MAXPATHLEN]; + mc_get_current_wd (panel_dir, sizeof (panel_dir)); + panels[num].last_saved_dir = g_strdup (panel_dir); } - switch (type) { + switch (type) + { case view_nothing: case view_listing: - new_widget = restore_into_right_dir_panel (num, old_widget); - break; - + new_widget = restore_into_right_dir_panel (num, old_widget); + break; + case view_info: - new_widget = (Widget *) info_new (); - break; + new_widget = (Widget *) info_new (); + break; case view_tree: - new_widget = (Widget *) tree_new (1, 0, 0, 0, 0); - break; + new_widget = (Widget *) tree_new (1, 0, 0, 0, 0); + break; case view_quick: - new_widget = (Widget *) mcview_new (0, 0, 0, 0, 1); - the_other_panel = (WPanel *) panels [the_other].widget; - if (the_other_panel) - file_name = the_other_panel->dir.list[the_other_panel->selected].fname; - else - file_name = ""; - - mcview_load ((struct mcview_struct *) new_widget, 0, file_name, 0); - break; + new_widget = (Widget *) mcview_new (0, 0, 0, 0, 1); + the_other_panel = (WPanel *) panels[the_other].widget; + if (the_other_panel) + file_name = the_other_panel->dir.list[the_other_panel->selected].fname; + else + file_name = ""; + + mcview_load ((struct mcview_struct *) new_widget, 0, file_name, 0); + break; } if (type != view_listing) - /* Must save dir, for restoring after change type to */ - /* view_listing */ - save_panel_dir (num); + /* Must save dir, for restoring after change type to */ + /* view_listing */ + save_panel_dir (num); - panels [num].type = type; - panels [num].widget = new_widget; + panels[num].type = type; + panels[num].widget = new_widget; /* We set the same size the old widget had */ widget_set_size (new_widget, y, x, lines, cols); @@ -932,17 +982,18 @@ set_display_type (int num, panel_view_mode_t type) /* We use replace to keep the circular list of the dialog in the */ /* same state. Maybe we could just kill it and then replace it */ if ((midnight_dlg != NULL) && (old_widget != NULL)) - dlg_replace_widget (old_widget, panels [num].widget); + dlg_replace_widget (old_widget, panels[num].widget); - if (type == view_listing) { - if (num == 0) - left_panel = (WPanel *) new_widget; - else - right_panel = (WPanel *) new_widget; + if (type == view_listing) + { + if (num == 0) + left_panel = (WPanel *) new_widget; + else + right_panel = (WPanel *) new_widget; } if (type == view_tree) - the_tree = (WTree *) new_widget; + the_tree = (WTree *) new_widget; /* Prevent current_panel's value from becoming invalid. * It's just a quick hack to prevent segfaults. Comment out and @@ -953,15 +1004,15 @@ set_display_type (int num, panel_view_mode_t type) * current_panel causes segfault, e.g. C-Enter, C-x c, ... */ - if ((type != view_listing) - && (current_panel == (WPanel *) old_widget)) - current_panel = num == 0 ? right_panel : left_panel; + if ((type != view_listing) && (current_panel == (WPanel *) old_widget)) + current_panel = num == 0 ? right_panel : left_panel; } /* This routine is deeply sticked to the two panels idea. What should it do in more panels. ANSWER - don't use it in any multiple panels environment. */ -void swap_panels () +void +swap_panels (void) { Widget tmp; Widget *tmp_widget; @@ -974,9 +1025,10 @@ void swap_panels () #define panelswapstr(e) strcpy (panel. e, panel1-> e); \ strcpy (panel1-> e, panel2-> e); \ strcpy (panel2-> e, panel. e); - panel1 = (WPanel *) panels [0].widget; - panel2 = (WPanel *) panels [1].widget; - if (panels [0].type == view_listing && panels [1].type == view_listing) { + panel1 = (WPanel *) panels[0].widget; + panel2 = (WPanel *) panels[1].widget; + if (panels[0].type == view_listing && panels[1].type == view_listing) + { /* Change everything except format/sort/panel_name etc. */ panelswap (dir); panelswap (active); @@ -999,57 +1051,63 @@ void swap_panels () current_panel = panel1; if (dlg_widget_active (panels[0].widget)) - dlg_select_widget (panels [1].widget); + dlg_select_widget (panels[1].widget); else if (dlg_widget_active (panels[1].widget)) - dlg_select_widget (panels [0].widget); - } else { - WPanel *tmp_panel; - - tmp_panel = right_panel; - right_panel = left_panel; - left_panel = tmp_panel; - - if (panels [0].type == view_listing) { - if (!strcmp (panel1->panel_name, get_nth_panel_name (0))) { + dlg_select_widget (panels[0].widget); + } + else + { + WPanel *tmp_panel; + + tmp_panel = right_panel; + right_panel = left_panel; + left_panel = tmp_panel; + + if (panels[0].type == view_listing) + { + if (!strcmp (panel1->panel_name, get_nth_panel_name (0))) + { g_free (panel1->panel_name); panel1->panel_name = g_strdup (get_nth_panel_name (1)); } } - if (panels [1].type == view_listing) { - if (!strcmp (panel2->panel_name, get_nth_panel_name (1))) { + if (panels[1].type == view_listing) + { + if (!strcmp (panel2->panel_name, get_nth_panel_name (1))) + { g_free (panel2->panel_name); panel2->panel_name = g_strdup (get_nth_panel_name (0)); } } - tmp.x = panels [0].widget->x; - tmp.y = panels [0].widget->y; - tmp.cols = panels [0].widget->cols; - tmp.lines = panels [0].widget->lines; + tmp.x = panels[0].widget->x; + tmp.y = panels[0].widget->y; + tmp.cols = panels[0].widget->cols; + tmp.lines = panels[0].widget->lines; - panels [0].widget->x = panels [1].widget->x; - panels [0].widget->y = panels [1].widget->y; - panels [0].widget->cols = panels [1].widget->cols; - panels [0].widget->lines = panels [1].widget->lines; + panels[0].widget->x = panels[1].widget->x; + panels[0].widget->y = panels[1].widget->y; + panels[0].widget->cols = panels[1].widget->cols; + panels[0].widget->lines = panels[1].widget->lines; - panels [1].widget->x = tmp.x; - panels [1].widget->y = tmp.y; - panels [1].widget->cols = tmp.cols; - panels [1].widget->lines = tmp.lines; + panels[1].widget->x = tmp.x; + panels[1].widget->y = tmp.y; + panels[1].widget->cols = tmp.cols; + panels[1].widget->lines = tmp.lines; - tmp_widget = panels [0].widget; - panels [0].widget = panels [1].widget; - panels [1].widget = tmp_widget; - tmp_type = panels [0].type; - panels [0].type = panels [1].type; - panels [1].type = tmp_type; + tmp_widget = panels[0].widget; + panels[0].widget = panels[1].widget; + panels[1].widget = tmp_widget; + tmp_type = panels[0].type; + panels[0].type = panels[1].type; + panels[1].type = tmp_type; } } panel_view_mode_t get_display_type (int idx) { - return panels [idx].type; + return panels[idx].type; } struct Widget * @@ -1058,15 +1116,17 @@ get_panel_widget (int idx) return panels[idx].widget; } -int get_current_index (void) +int +get_current_index (void) { - if (panels [0].widget == ((Widget *) current_panel)) - return 0; + if (panels[0].widget == ((Widget *) current_panel)) + return 0; else - return 1; + return 1; } -int get_other_index (void) +int +get_other_index (void) { return !get_current_index (); } @@ -1081,20 +1141,20 @@ get_other_panel (void) panel_view_mode_t get_current_type (void) { - if (panels [0].widget == (Widget *) current_panel) - return panels [0].type; + if (panels[0].widget == (Widget *) current_panel) + return panels[0].type; else - return panels [1].type; + return panels[1].type; } /* Returns the view type of the unselected panel */ panel_view_mode_t get_other_type (void) { - if (panels [0].widget == (Widget *) current_panel) - return panels [1].type; + if (panels[0].widget == (Widget *) current_panel) + return panels[1].type; else - return panels [0].type; + return panels[0].type; } /* Save current list_view widget directory into panel */ @@ -1104,30 +1164,30 @@ save_panel_dir (int idx) panel_view_mode_t type = get_display_type (idx); Widget *widget = get_panel_widget (idx); - if ((type == view_listing) && (widget != NULL)) { - WPanel *w = (WPanel *) widget; - char *widget_work_dir = w->cwd; + if ((type == view_listing) && (widget != NULL)) + { + WPanel *w = (WPanel *) widget; + char *widget_work_dir = w->cwd; - g_free(panels [idx].last_saved_dir); /* last path no needed */ + g_free (panels[idx].last_saved_dir); /* last path no needed */ /* Because path can be nonlocal */ - panels [idx].last_saved_dir = vfs_translate_url (widget_work_dir); + panels[idx].last_saved_dir = vfs_translate_url (widget_work_dir); } } /* Save current list_view widget directory into panel */ Widget * -restore_into_right_dir_panel (int idx, Widget *from_widget) +restore_into_right_dir_panel (int idx, Widget * from_widget) { Widget *new_widget = NULL; - const char *saved_dir = panels [idx].last_saved_dir; - gboolean last_was_panel = (from_widget && - get_display_type(idx) != view_listing); + const char *saved_dir = panels[idx].last_saved_dir; + gboolean last_was_panel = (from_widget && get_display_type (idx) != view_listing); const char *p_name = get_nth_panel_name (idx); if (last_was_panel) - new_widget = (Widget *) panel_new_with_dir (p_name, saved_dir); + new_widget = (Widget *) panel_new_with_dir (p_name, saved_dir); else - new_widget = (Widget *) panel_new (p_name); + new_widget = (Widget *) panel_new (p_name); return new_widget; } @@ -1135,19 +1195,19 @@ restore_into_right_dir_panel (int idx, Widget *from_widget) /* Return working dir, if it's view_listing - cwd, but for other types - last_saved_dir */ const char * -get_panel_dir_for (const WPanel *widget) +get_panel_dir_for (const WPanel * widget) { int i; for (i = 0; i < MAX_VIEWS; i++) - if ((WPanel *) get_panel_widget (i) == widget) - break; + if ((WPanel *) get_panel_widget (i) == widget) + break; if (i >= MAX_VIEWS) - return "."; + return "."; if (get_display_type (i) == view_listing) - return ((WPanel *) get_panel_widget (i))->cwd; + return ((WPanel *) get_panel_widget (i))->cwd; return panels[i].last_saved_dir; } diff --git a/src/screen.c b/src/screen.c index 2afa846b1..5759b55c9 100644 --- a/src/screen.c +++ b/src/screen.c @@ -532,7 +532,7 @@ panel_field_t panel_fields[] = { /* TRANSLATORS: one single character to represent 'Change time' sort mode */ /* TRANSLATORS: no need to translate 'sort', it's just a context prefix */ N_("sort|h"), - N_("C&Hange time"), TRUE, TRUE, + N_("C&hange time"), TRUE, TRUE, string_file_ctime, (sortfn *) sort_ctime } diff --git a/src/viewer/dialogs.c b/src/viewer/dialogs.c index 789e3bd7e..389074a1c 100644 --- a/src/viewer/dialogs.c +++ b/src/viewer/dialogs.c @@ -99,7 +99,7 @@ mcview_dialog_search (mcview_t * view) QUICK_CHECKBOX (SEARCH_DLG_WIDTH / 2 + 3, SEARCH_DLG_WIDTH, 6, SEARCH_DLG_HEIGHT, N_("&Backwards"), &mcview_search_options.backwards), QUICK_CHECKBOX (SEARCH_DLG_WIDTH / 2 + 3, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT, - N_("case &Sensitive"), &mcview_search_options.case_sens), + N_("Case &sensitive"), &mcview_search_options.case_sens), QUICK_RADIO (3, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT, num_of_types, (const char **) list_of_types, (int *) &mcview_search_options.type),