1
1

Applied MC indentation policy.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Этот коммит содержится в:
Andrew Borodin 2010-05-26 10:07:56 +04:00
родитель 9a97d08c16
Коммит eb284bcef8
2 изменённых файлов: 990 добавлений и 912 удалений

Просмотреть файл

@ -78,32 +78,37 @@ 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)) {
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)) {
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)) {
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)) {
if (dlg_widget_active (display_mini_status))
{
h->ret_value = B_USER + 7;
dlg_stop (h);
return MSG_HANDLED;
@ -111,7 +116,8 @@ display_callback (Dlg_head *h, Widget *sender,
}
if (g_ascii_tolower (parm) == display_user_hotkey && dlg_widget_active (display_user_format)
&& dlg_widget_active (display_mini_status)) {
&& dlg_widget_active (display_mini_status))
{
display_radio->sel = 3;
dlg_select_widget (display_radio); /* force redraw */
dlg_select_widget (display_user_format);
@ -125,15 +131,13 @@ display_callback (Dlg_head *h, Widget *sender,
}
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] =
{
const char *displays[LIST_TYPES] = {
N_("&Full file list"),
N_("&Brief file list"),
N_("&Long file list"),
@ -185,8 +189,8 @@ display_init (int radio_sel, char *init_text, int _check_status,
/* 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;
ok_button->widget.x = dlg_width / 3 - ok_len / 2;
cancel_button->widget.x = dlg_width * 2 / 3 - cancel_len / 2;
}
displays_status = _status;
@ -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);
}
@ -247,17 +253,19 @@ 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);
if (run_dlg (dd) != B_CANCEL) {
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]);
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,7 +286,7 @@ 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;
{
@ -286,8 +294,7 @@ sort_box (const panel_field_t *sort_format, int *reverse, int *case_sensitive, i
int ok_len, cancel_len;
gsize i;
QuickWidget quick_widgets[] =
{
QuickWidget quick_widgets[] = {
/* 0 */
QUICK_BUTTON (0, dlg_width, dlg_height - 3, dlg_height, N_("&Cancel"), B_CANCEL, NULL),
/* 1 */
@ -304,8 +311,7 @@ sort_box (const panel_field_t *sort_format, int *reverse, int *case_sensitive, i
QUICK_END
};
QuickDialog quick_dlg =
{
QuickDialog quick_dlg = {
dlg_width, dlg_height, -1, -1,
N_("Sort order"), "[Sort Order...]",
quick_widgets, TRUE
@ -315,7 +321,8 @@ sort_box (const panel_field_t *sort_format, int *reverse, int *case_sensitive, i
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 ) {
if (strcmp (sort_orders_names[i], _(sort_format->title_hotkey)) == 0)
{
sort_idx = i;
break;
}
@ -349,22 +356,22 @@ sort_box (const panel_field_t *sort_format, int *reverse, int *case_sensitive, i
/* dialog */
quick_dlg.xlen = dlg_width;
/* widgets */
for (i = 0; (size_t) i < sizeof (quick_widgets)/sizeof (quick_widgets[0]) - 1; i++)
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;
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;
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]);
result = panel_get_field_by_title_hotkey (sort_orders_names[sort_idx]);
if (result == NULL)
result = sort_format;
}
g_strfreev((gchar **)sort_orders_names);
g_strfreev ((gchar **) sort_orders_names);
return result;
}
@ -374,13 +381,14 @@ confirm_box (void)
{
const char *title = _("Confirmation");
QuickWidget conf_widgets [] =
{
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),
/* 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),
@ -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,17 +430,17 @@ confirm_box (void)
dlg_width = max (dlg_width, str_term_width1 (title) + 4);
/* correct widget parameters */
for (i = 0; i < w_num; i++) {
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 =
{
QuickDialog confirmation = {
dlg_width, dlg_height, -1, -1, title,
"[Confirmation]", conf_widgets, 1
};
@ -453,16 +461,14 @@ display_bits_box (void) /* AB:FIXME: test dialog */
int new_meta = 0;
int current_mode;
const char *display_bits_str [] =
{
const char *display_bits_str[] = {
N_("UTF-8 output"),
N_("Full 8 bits output"),
N_("ISO 8859-1"),
N_("7 bits")
};
QuickWidget display_widgets[] =
{
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),
@ -470,8 +476,7 @@ display_bits_box (void) /* AB:FIXME: test dialog */
QUICK_END
};
QuickDialog display_bits =
{
QuickDialog display_bits = {
DISPX, DISPY, -1, -1, _(" Display bits "),
"[Display bits]", display_widgets, TRUE
};
@ -483,9 +488,11 @@ 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);
@ -498,11 +505,11 @@ display_bits_box (void) /* AB:FIXME: test dialog */
/* 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);
@ -511,8 +518,8 @@ display_bits_box (void) /* AB:FIXME: test dialog */
for (i = 0; i < 4; i++)
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;
@ -523,7 +530,8 @@ display_bits_box (void) /* AB:FIXME: test dialog */
new_meta = !use_8th_bit_as_meta;
if (quick_dialog (&display_bits) != B_CANCEL) {
if (quick_dialog (&display_bits) != B_CANCEL)
{
eight_bit_clean = current_mode < 3;
full_eight_bits = current_mode < 2;
#ifndef HAVE_SLANG
@ -551,7 +559,8 @@ sel_charset_button (int action)
new_dcp = select_charset (-1, -1, new_display_codepage, TRUE);
if (new_dcp != SELECT_CHARSET_CANCEL) {
if (new_dcp != SELECT_CHARSET_CANCEL)
{
const char *cpname;
char buf[BUF_TINY];
@ -584,24 +593,17 @@ init_disp_bits_box (void)
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");
@ -623,12 +625,14 @@ display_bits_box (void)
run_dlg (dbits_dlg);
if (dbits_dlg->ret_value == B_ENTER) {
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) {
if (errmsg != NULL)
{
message (D_ERROR, MSG_ERROR, "%s", errmsg);
g_free (errmsg);
}
@ -646,13 +650,14 @@ 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') {
if (parm == '\n')
{
h->ret_value = B_ENTER;
dlg_stop (h);
}
@ -680,8 +685,7 @@ tree_box (const char *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);
@ -719,25 +723,30 @@ 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 [] =
{
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),
/* 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),
/* 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),
/* 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),
/* 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")),
@ -746,8 +755,7 @@ configure_vfs (void)
QUICK_END
};
QuickDialog confvfs_dlg =
{
QuickDialog confvfs_dlg = {
VFSX, VFSY, -1, -1, N_(" Virtual File System Setting "),
"[Virtual FS]", confvfs_widgets, FALSE
};
@ -757,7 +765,8 @@ 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);
@ -768,7 +777,7 @@ configure_vfs (void)
ftpfs_anonymous_passwd = ret_passwd;
g_free (ftpfs_proxy_host);
ftpfs_proxy_host = ret_ftp_proxy;
ftpfs_directory_timeout = atoi(ret_directory_timeout);
ftpfs_directory_timeout = atoi (ret_directory_timeout);
g_free (ret_directory_timeout);
#endif
}
@ -797,15 +806,13 @@ cd_dialog (void)
{
char *my_str;
QuickWidget quick_widgets [] =
{
/* 0 */ QUICK_INPUT (4 + len, xlen, 2, ylen, "", xlen - 7 - len, 2, "input" , &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
};
QuickDialog Quick_input =
{
QuickDialog Quick_input = {
xlen, ylen, 2, LINES - 2 - ylen, _("Quick cd"),
"[Quick cd]", quick_widgets, TRUE
};
@ -815,27 +822,26 @@ cd_dialog (void)
}
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[] =
{
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):")),
/* 5 */ QUICK_LABEL (4, 80, 2, 8,
N_("Existing filename (filename symlink will point to):")),
QUICK_END
};
QuickDialog Quick_input =
{
QuickDialog Quick_input = {
64, 12, -1, -1, N_("Symbolic link"),
"[File Menu]", quick_widgets, FALSE
};
if (quick_dialog (&Quick_input) == B_CANCEL) {
if (quick_dialog (&Quick_input) == B_CANCEL)
{
*ret_new = NULL;
*ret_existing = NULL;
}
@ -854,18 +860,20 @@ 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){
while (tl)
{
char *s;
s = g_strconcat (state_str [tl->state], " ", tl->info, (char *) NULL);
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;
@ -885,15 +893,20 @@ task_cb (int action)
listbox_get_current (bg_list, NULL, (void **) &tl);
# ifdef SIGTSTP
if (action == B_STOP){
if (action == B_STOP)
{
sig = SIGSTOP;
tl->state = Task_Stopped;
} else if (action == B_RESUME){
}
else if (action == B_RESUME)
{
sig = SIGCONT;
tl->state = Task_Running;
} else
}
else
# endif
if (action == B_KILL){
if (action == B_KILL)
{
sig = SIGKILL;
}
@ -912,17 +925,21 @@ task_cb (int action)
static struct
{
const char* name;
const char *name;
int xpos;
int value;
int (*callback)(int);
int (*callback) (int);
}
job_buttons [] =
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
@ -935,31 +952,30 @@ jobs_cmd (void)
static int i18n_flag = 0;
if (!i18n_flag)
{
int startx = job_buttons [0].xpos;
int startx = job_buttons[0].xpos;
int len;
for (i = 0; i < n_buttons; i++)
{
job_buttons [i].name = _(job_buttons [i].name);
job_buttons[i].name = _(job_buttons[i].name);
len = str_term_width1 (job_buttons [i].name) + 4;
len = str_term_width1 (job_buttons[i].name) + 4;
JOBS_X = max (JOBS_X, startx + len + 3);
job_buttons [i].xpos = startx;
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;
job_buttons[n_buttons - 1].xpos =
JOBS_X - str_term_width1 (job_buttons[n_buttons - 1].name) - 7;
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);
@ -967,10 +983,10 @@ jobs_cmd (void)
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));
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 */
@ -983,14 +999,14 @@ jobs_cmd (void)
#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;
@ -1004,12 +1020,12 @@ vfs_smb_get_authinfo (const char *host, const char *share, const char *domain,
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;
}
@ -1017,9 +1033,9 @@ vfs_smb_get_authinfo (const char *host, const char *share, const char *domain,
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)
@ -1050,14 +1066,14 @@ vfs_smb_get_authinfo (const char *host, const char *share, const char *domain,
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);

Просмотреть файл

@ -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] = {
} 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] = {
static const char *s_split_direction[2] = {
N_("&Vertical"),
N_("&Horizontal")
};
static WRadio *radio_widget;
static struct {
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,16 +194,20 @@ 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 (_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 {
}
else
{
if (_equal_split)
_first_panel_size = COLS / 2;
else if (_first_panel_size < MINWIDTH)
@ -205,17 +217,16 @@ static void _check_split (void)
}
}
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)){
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;
@ -230,37 +241,42 @@ static void update_split (void)
tty_printf ("%03d", COLS - _first_panel_size);
}
static int b2left_cback (int action)
static int
b2left_cback (int action)
{
(void) action;
if (_equal_split){
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);
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){
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);
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;
@ -269,7 +285,8 @@ static int bplus_cback (int action)
return 0;
}
static int bminus_cback (int action)
static int
bminus_cback (int action)
{
(void) action;
@ -279,13 +296,13 @@ static int bminus_cback (int action)
}
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*/
update everything */
common_dialog_repaint (h);
old_first_panel_size = -1;
@ -296,8 +313,10 @@ layout_callback (Dlg_head *h, Widget *sender,
update_split ();
dlg_move (h, 6, 13);
tty_print_char ('=');
if (console_flag){
if (old_output_lines != _output_lines){
if (console_flag)
{
if (old_output_lines != _output_lines)
{
old_output_lines = _output_lines;
tty_setcolor (COLOR_NORMAL);
dlg_move (h, 9, 6);
@ -309,29 +328,34 @@ layout_callback (Dlg_head *h, Widget *sender,
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){
_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){
if (height < minimum)
{
_output_lines -= minimum - height;
height = minimum;
}
} else {
}
else
{
height = LINES - _keybar_visible - _command_prompt -
_menubar_visible - _output_lines - _message_visible;
}
if (_horizontal_split != radio_widget->sel){
if (_horizontal_split != radio_widget->sel)
{
_horizontal_split = radio_widget->sel;
if (_horizontal_split)
_first_panel_size = height / 2;
@ -339,8 +363,10 @@ layout_callback (Dlg_head *h, Widget *sender,
_first_panel_size = COLS / 2;
}
update_split ();
if (console_flag){
if (old_output_lines != _output_lines){
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);
@ -365,7 +391,8 @@ init_layout (void)
const char *save_button = _("&Save");
static const char *title1, *title2, *title3;
if (!i18n_layt_flag) {
if (!i18n_layt_flag)
{
gsize l1;
first_width = 0;
@ -375,14 +402,16 @@ init_layout (void)
title3 = _(" Other options ");
output_lines_label = _("Output lines: ");
while (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;
}
for (i = 0; i < LAYOUT_OPTIONS_COUNT; i++) {
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)
@ -397,7 +426,8 @@ init_layout (void)
if (l1 > first_width)
first_width = l1;
if (console_flag) {
if (console_flag)
{
output_lines_label_len = str_term_width1 (output_lines_label);
l1 = output_lines_label_len + 12;
if (l1 > first_width)
@ -432,22 +462,15 @@ init_layout (void)
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++) {
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);
@ -461,7 +484,8 @@ init_layout (void)
_xterm_title = xterm_title;
_free_space = free_space;
if (console_flag) {
if (console_flag)
{
add_widget (layout_dlg, groupbox_new (8, 4, 3, first_width, title2));
add_widget (layout_dlg,
@ -472,11 +496,9 @@ init_layout (void)
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,16 +538,18 @@ void layout_box (void)
run_dlg (layout_dlg);
result = layout_dlg->ret_value;
if (result == B_ENTER || result == B_EXIT){
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;
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){
if (result == B_EXIT)
{
save_layout ();
mc_config_save_file (mc_main_config, NULL);
}
@ -534,16 +559,20 @@ void layout_box (void)
layout_change ();
}
static void check_split (void)
static void
check_split (void)
{
if (horizontal_split){
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 {
}
else
{
if (equal_split)
first_panel_size = COLS / 2;
else if (first_panel_size < MINWIDTH)
@ -577,7 +606,8 @@ mc_refresh (void)
#endif /* WITH_BACKGROUND */
if (winch_flag == 0)
tty_refresh ();
else {
else
{
/* if winch was caugth, we should do not only redraw screen, but
reposition/resize all */
change_screen_size ();
@ -588,9 +618,9 @@ 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
@ -599,7 +629,8 @@ setup_panels (void)
int start_y;
int promptl; /* the prompt len */
if (console_flag) {
if (console_flag)
{
int minimum;
if (output_lines < 0)
output_lines = 0;
@ -607,26 +638,29 @@ setup_panels (void)
LINES - keybar_visible - command_prompt - menubar_visible -
output_lines - message_visible;
minimum = MINHEIGHT * (1 + horizontal_split);
if (height < minimum) {
if (height < minimum)
{
output_lines -= minimum - height;
height = minimum;
}
} else {
height =
LINES - menubar_visible - command_prompt - keybar_visible -
message_visible;
}
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 {
}
else
{
int first_x = first_panel_size;
widget_set_size (panels[0].widget, start_y, 0, height, 0);
@ -641,13 +675,14 @@ 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);
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 (&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);
@ -657,9 +692,9 @@ setup_panels (void)
buttonbar_set_visible (the_bar, keybar_visible);
/* Output window */
if (console_flag && output_lines) {
output_start_y =
LINES - command_prompt - keybar_visible - output_lines;
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);
@ -682,10 +717,11 @@ 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;
@ -737,7 +773,8 @@ change_screen_size (void)
/* Inform all running dialogs */
d = current_dlg;
while (d != NULL) {
while (d != NULL)
{
(*d->callback) (d, NULL, DLG_RESIZE, 0, NULL);
d = d->parent;
}
@ -750,7 +787,8 @@ change_screen_size (void)
static int ok_to_refresh = 1;
void use_dash (int flag)
void
use_dash (int flag)
{
if (flag)
ok_to_refresh++;
@ -758,17 +796,19 @@ void use_dash (int flag)
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);
@ -777,7 +817,8 @@ void print_vfs_message (const char *msg, ...)
if (midnight_shutdown)
return;
if (!message_visible || !the_hint || !the_hint->widget.parent) {
if (!message_visible || !the_hint || !the_hint->widget.parent)
{
int col, row;
if (!nice_rotating_dash || (ok_to_refresh <= 0))
@ -796,37 +837,39 @@ void print_vfs_message (const char *msg, ...)
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;
if (pos >= sizeof (rotating_dash)-1)
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;
}
@ -852,31 +895,36 @@ set_display_type (int num, panel_view_mode_t type)
Widget *new_widget = NULL, *old_widget = NULL;
WPanel *the_other_panel = NULL;
if (num >= MAX_VIEWS){
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) {
if (type != view_listing)
{
the_other = num == 0 ? 1 : 0;
if (panels [the_other].type != view_listing)
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;
old_widget = panels[num].widget;
if (panels [num].type == view_listing) {
if (panel->frame_size == frame_full && type != view_listing) {
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;
@ -886,13 +934,15 @@ set_display_type (int num, panel_view_mode_t type)
/* 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];
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);
@ -908,7 +958,7 @@ set_display_type (int num, panel_view_mode_t type)
case view_quick:
new_widget = (Widget *) mcview_new (0, 0, 0, 0, 1);
the_other_panel = (WPanel *) panels [the_other].widget;
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
@ -923,8 +973,8 @@ set_display_type (int num, panel_view_mode_t type)
/* 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,9 +982,10 @@ 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 (type == view_listing)
{
if (num == 0)
left_panel = (WPanel *) new_widget;
else
@ -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))
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 {
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))) {
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))
if (panels[0].widget == ((Widget *) current_panel))
return 0;
else
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,24 +1164,24 @@ 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)) {
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)
@ -1135,7 +1195,7 @@ 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;