From 57167b7a43dc409578ec488265b69d02014cc6d6 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Wed, 15 Apr 2009 20:04:14 +0400 Subject: [PATCH 1/3] Unification of panel frame painting. myslang.h: modified definition of ACS_LTEE symbol. Added definition of ACS_RTEE symbol. screen.c (show_dir): paint left and right symbols of mini infor separator as for S-Lang library as for NCurses one. --- src/myslang.h | 3 ++- src/screen.c | 12 +++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/myslang.h b/src/myslang.h index a8c8b42b8..eb22bbfbd 100644 --- a/src/myslang.h +++ b/src/myslang.h @@ -18,12 +18,13 @@ enum { #define ACS_VLINE SLSMG_VLINE_CHAR #define ACS_HLINE SLSMG_HLINE_CHAR +#define ACS_LTEE SLSMG_LTEE_CHAR +#define ACS_RTEE SLSMG_RTEE_CHAR #define ACS_ULCORNER SLSMG_ULCORN_CHAR #define ACS_LLCORNER SLSMG_LLCORN_CHAR #define ACS_URCORNER SLSMG_URCORN_CHAR #define ACS_LRCORNER SLSMG_LRCORN_CHAR -#define ACS_LTEE 't' #define acs() SLsmg_set_char_set(1) #define noacs() SLsmg_set_char_set (0) #define baudrate() SLang_TT_Baud_Rate diff --git a/src/screen.c b/src/screen.c index 24ddc85c1..a02fc536a 100644 --- a/src/screen.c +++ b/src/screen.c @@ -774,15 +774,13 @@ show_dir (WPanel *panel) panel->widget.y, panel->widget.x, panel->widget.lines, panel->widget.cols); -#ifdef HAVE_SLANG if (show_mini_info) { - SLsmg_draw_object (panel->widget.y + llines (panel) + 2, - panel->widget.x, SLSMG_LTEE_CHAR); - SLsmg_draw_object (panel->widget.y + llines (panel) + 2, - panel->widget.x + panel->widget.cols - 1, - SLSMG_RTEE_CHAR); + widget_move (&panel->widget, llines (panel) + 2, 0); + tty_print_alt_char (ACS_LTEE); + widget_move (&panel->widget, llines (panel) + 2, + panel->widget.cols - 1); + tty_print_alt_char (ACS_RTEE); } -#endif /* HAVE_SLANG */ if (panel->active) attrset (REVERSE_COLOR); From e029489fb61aa8f806e68fc405e5b7fe3edc14f3 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Wed, 15 Apr 2009 20:12:47 +0400 Subject: [PATCH 2/3] Type accuracy. dialog.h: define values for cb_ret_t enum. widget.c: removed trailing spaces. Formatting. (insert_char): type accuracy for cb_ret_t. (listbox_key): likewise. --- src/dialog.h | 4 ++-- src/widget.c | 65 +++++++++++++++++++++++++++------------------------- 2 files changed, 36 insertions(+), 33 deletions(-) diff --git a/src/dialog.h b/src/dialog.h index 27464c220..b9c1e8b49 100644 --- a/src/dialog.h +++ b/src/dialog.h @@ -49,8 +49,8 @@ typedef enum { } widget_msg_t; typedef enum { - MSG_NOT_HANDLED, - MSG_HANDLED + MSG_NOT_HANDLED = 0, + MSG_HANDLED = 1 } cb_ret_t; /* Widgets are expected to answer to the following messages: diff --git a/src/widget.c b/src/widget.c index 62fcef101..ea8e394da 100644 --- a/src/widget.c +++ b/src/widget.c @@ -156,10 +156,9 @@ button_callback (Widget *w, widget_msg_t msg, int parm) if (b->text.hotkey != NULL) { if (g_ascii_tolower ((gchar)b->text.hotkey[0]) == g_ascii_tolower ((gchar)parm)) { - - button_callback (w, WIDGET_KEY, ' '); - return MSG_HANDLED; - } + button_callback (w, WIDGET_KEY, ' '); + return MSG_HANDLED; + } } return MSG_NOT_HANDLED; @@ -204,7 +203,7 @@ button_callback (Widget *w, widget_msg_t msg, int parm) widget_selectcolor (w, b->selected, FALSE); widget_move (w, 0, 0); - + switch (b->flags) { case DEFPUSH_BUTTON: addstr ("[< "); @@ -221,11 +220,11 @@ button_callback (Widget *w, widget_msg_t msg, int parm) } addstr (str_term_form (b->text.start)); - + if (b->text.hotkey != NULL) { widget_selectcolor (w, b->selected, TRUE); addstr (str_term_form (b->text.hotkey)); - widget_selectcolor (w, b->selected, FALSE); + widget_selectcolor (w, b->selected, FALSE); } if (b->text.end != NULL) { @@ -243,7 +242,6 @@ button_callback (Widget *w, widget_msg_t msg, int parm) addstr ("]"); break; } - return MSG_HANDLED; case WIDGET_DESTROY: @@ -411,7 +409,7 @@ radio_callback (Widget *w, widget_msg_t msg, int parm) widget_move (&r->widget, i, 0); addstr ((r->sel == i) ? "(*) " : "( ) "); - + addstr (str_term_form (r->texts[i].start)); if (r->texts[i].hotkey != NULL) { @@ -431,7 +429,7 @@ radio_callback (Widget *w, widget_msg_t msg, int parm) } g_free (r->texts); return MSG_HANDLED; - + default: return default_proc (msg, parm); } @@ -501,10 +499,10 @@ check_callback (Widget *w, widget_msg_t msg, int parm) if (c->text.hotkey != NULL) { if (g_ascii_tolower ((gchar)c->text.hotkey[0]) == g_ascii_tolower ((gchar)parm)) { - - check_callback (w, WIDGET_KEY, ' '); /* make action */ - return MSG_HANDLED; - } + + check_callback (w, WIDGET_KEY, ' '); /* make action */ + return MSG_HANDLED; + } } return MSG_NOT_HANDLED; @@ -535,7 +533,7 @@ check_callback (Widget *w, widget_msg_t msg, int parm) addstr (str_term_form (c->text.hotkey)); widget_selectcolor (w, msg == WIDGET_FOCUS, FALSE); } - + if (c->text.end != NULL) { addstr (str_term_form (c->text.end)); } @@ -624,7 +622,7 @@ label_callback (Widget *w, widget_msg_t msg, int parm) widget_move (&l->widget, y, 0); addstr (str_fit_to_term (p, l->widget.cols, J_LEFT)); - + if (q == NULL) break; q[0] = c; @@ -704,7 +702,7 @@ gauge_callback (Widget *w, widget_msg_t msg, int parm) if (msg == WIDGET_INIT) return MSG_HANDLED; - + /* We don't want to get the focus */ if (msg == WIDGET_FOCUS) return MSG_NOT_HANDLED; @@ -717,7 +715,7 @@ gauge_callback (Widget *w, widget_msg_t msg, int parm) else { int percentage, columns; long total = g->max, done = g->current; - + if (total <= 0 || done < 0) { done = 0; total = 100; @@ -738,6 +736,7 @@ gauge_callback (Widget *w, widget_msg_t msg, int parm) } return MSG_HANDLED; } + return default_proc (msg, parm); } @@ -1230,16 +1229,18 @@ insert_char (WInput *in, int c_code) if (c_code == -1) return MSG_NOT_HANDLED; - - if (in->charpoint >= MB_LEN_MAX) return 1; + + if (in->charpoint >= MB_LEN_MAX) + return MSG_HANDLED; in->charbuf[in->charpoint] = c_code; in->charpoint++; res = str_is_valid_char (in->charbuf, in->charpoint); if (res < 0) { - if (res != -2) in->charpoint = 0; /* broken multibyte char, skip */ - return 1; + if (res != -2) + in->charpoint = 0; /* broken multibyte char, skip */ + return MSG_HANDLED; } in->need_push = 1; @@ -1253,7 +1254,7 @@ insert_char (WInput *in, int c_code) in->current_max_size = new_length; } } - + if (strlen (in->buffer) + in->charpoint < in->current_max_size) { /* bytes from begin */ size_t ins_point = str_offset_to_pos (in->buffer, in->point); @@ -1267,7 +1268,7 @@ insert_char (WInput *in, int c_code) memcpy(in->buffer + ins_point, in->charbuf, in->charpoint); in->point++; } - + in->charpoint = 0; return MSG_HANDLED; } @@ -2090,11 +2091,11 @@ static cb_ret_t listbox_key (WListbox *l, int key) { int i; - int j = 0; + cb_ret_t j = MSG_NOT_HANDLED; if (!l->list) return MSG_NOT_HANDLED; - + switch (key){ case KEY_HOME: case KEY_A1: @@ -2125,14 +2126,16 @@ listbox_key (WListbox *l, int key) case KEY_NPAGE: case XCTRL('v'): for (i = 0; i < l->height-1; i++) - j |= listbox_fwd (l); - return (j > 0) ? MSG_HANDLED : MSG_NOT_HANDLED; + if (listbox_fwd (l) != MSG_NOT_HANDLED) + j = MSG_HANDLED; + return j; case KEY_PPAGE: case ALT('v'): for (i = 0; i < l->height-1; i++) - j |= listbox_back (l); - return (j > 0) ? MSG_HANDLED : MSG_NOT_HANDLED; + if (listbox_back (l) != MSG_NOT_HANDLED) + j = MSG_HANDLED; + return j; } return MSG_NOT_HANDLED; } @@ -2434,7 +2437,7 @@ buttonbat_get_button_width () { int result = COLS / 10; return (result >= 7) ? result : 7; -} +} static cb_ret_t From 004bc0077efff1b76bcbc528ce5826fa7e4151ae Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Wed, 15 Apr 2009 20:22:26 +0400 Subject: [PATCH 3/3] Unification of widgets API. widget.h: chaged paremeters order of listbox_new() and groupbox_new() functions. widget.c: likewise. src/achown.c: sync with modified API of WListbox and WGroupbox widgets. src/boxes.c: likewise. src/chown.c: likewise. src/complete.c: likewise. src/find.c: likewise. src/hotlist.c: likewise. src/layout.c: likewise. src/listmode.c: likewise. src/option.c: likewise. src/panelize.c: likewise. src/wtools.c: likewise. edit/editcmd.c: likewise. --- edit/editcmd.c | 4 ++-- src/achown.c | 2 +- src/boxes.c | 2 +- src/chown.c | 4 ++-- src/complete.c | 2 +- src/find.c | 2 +- src/hotlist.c | 6 +++--- src/layout.c | 6 +++--- src/listmode.c | 8 ++++---- src/option.c | 6 +++--- src/panelize.c | 2 +- src/widget.c | 6 +++--- src/widget.h | 4 ++-- src/wtools.c | 2 +- 14 files changed, 28 insertions(+), 28 deletions(-) diff --git a/edit/editcmd.c b/edit/editcmd.c index d93a9fe34..9cfd27a1b 100644 --- a/edit/editcmd.c +++ b/edit/editcmd.c @@ -2840,7 +2840,7 @@ edit_completion_dialog (WEdit * edit, int max_len, int word_len, /* create the listbox */ compl_list = - listbox_new (1, 1, compl_dlg_w - 2, compl_dlg_h - 2, NULL); + listbox_new (1, 1, compl_dlg_h - 2, compl_dlg_w - 2, NULL); /* add the dialog */ add_widget (compl_dlg, compl_list); @@ -3078,7 +3078,7 @@ edit_select_definition_dialog (WEdit * edit, char *match_expr, int max_len, int DLG_COMPACT); /* create the listbox */ - def_list = listbox_new (1, 1, def_dlg_w - 2, def_dlg_h - 2, NULL); + def_list = listbox_new (1, 1, def_dlg_h - 2, def_dlg_w - 2, NULL); /* add the dialog */ add_widget (def_dlg, def_list); diff --git a/src/achown.c b/src/achown.c index 32c6d07db..444d7bc68 100644 --- a/src/achown.c +++ b/src/achown.c @@ -258,7 +258,7 @@ do_enter_key (Dlg_head * h, int f_pos) "[Advanced Chown]", title, DLG_COMPACT | DLG_REVERSE); /* get new listboxes */ - chl_list = listbox_new (1, 1, 15, 11, NULL); + chl_list = listbox_new (1, 1, 11, 15, NULL); listbox_add_item (chl_list, LISTBOX_APPEND_AT_END, 0, "", NULL); diff --git a/src/boxes.c b/src/boxes.c index a2cd88051..43c80b7c5 100644 --- a/src/boxes.c +++ b/src/boxes.c @@ -999,7 +999,7 @@ jobs_cmd (void) "[Background jobs]", _("Background Jobs"), DLG_CENTER | DLG_REVERSE); - bg_list = listbox_new (2, 3, JOBS_X-7, JOBS_Y-9, 0); + bg_list = listbox_new (2, 3, JOBS_Y - 9, JOBS_X - 7, NULL); add_widget (jobs_dlg, bg_list); i = n_buttons; diff --git a/src/chown.c b/src/chown.c index 9d27fe75b..f165c8df4 100644 --- a/src/chown.c +++ b/src/chown.c @@ -172,8 +172,8 @@ init_chown (void) } /* get new listboxes */ - l_user = listbox_new (UY + 1, UX + 1, 19, 10, NULL); - l_group = listbox_new (GY + 1, GX + 1, 19, 10, NULL); + l_user = listbox_new (UY + 1, UX + 1, 10, 19, NULL); + l_group = listbox_new (GY + 1, GX + 1, 10, 19, NULL); /* add fields for unknown names (numbers) */ listbox_add_item (l_user, 0, 0, _(""), NULL); diff --git a/src/complete.c b/src/complete.c index 4e62da6f6..ae6aa80f8 100644 --- a/src/complete.c +++ b/src/complete.c @@ -1088,7 +1088,7 @@ complete_engine (WInput *in, int what_to_do) query_dlg = create_dlg (y, x, query_height, query_width, dialog_colors, query_callback, "[Completion]", NULL, DLG_COMPACT); - query_list = listbox_new (1, 1, w - 2, h - 2, NULL); + query_list = listbox_new (1, 1, h - 2, w - 2, NULL); add_widget (query_dlg, query_list); for (p = in->completions + 1; *p; p++) listbox_add_item (query_list, 0, 0, *p, NULL); diff --git a/src/find.c b/src/find.c index eb38055d5..dcf283ce0 100644 --- a/src/find.c +++ b/src/find.c @@ -944,7 +944,7 @@ setup_gui (void) add_widget (find_dlg, status_label); find_list = - listbox_new (2, 2, FIND2_X - 4, FIND2_Y - 9, 0); + listbox_new (2, 2, FIND2_Y - 9, FIND2_X - 4, NULL); add_widget (find_dlg, find_list); } diff --git a/src/hotlist.c b/src/hotlist.c index 4c81ebb93..2d7bc7638 100644 --- a/src/hotlist.c +++ b/src/hotlist.c @@ -652,7 +652,7 @@ init_hotlist (int list_type) } /* get new listbox */ l_hotlist = - listbox_new (UY + 1, UX + 1, COLS - 2 * UX - 8, LINES - 14, + listbox_new (UY + 1, UX + 1, LINES - 14, COLS - 2 * UX - 8, l_call); /* Fill the hotlist with the active VFS or the hotlist */ @@ -700,8 +700,8 @@ init_movelist (int list_type, struct hotlist *item) add_widget (movelist_dlg, movelist_group); /* get new listbox */ l_movelist = - listbox_new (UY + 1, UX + 1, movelist_dlg->cols - 2 * UX - 2, - movelist_dlg->lines - 8, l_call); + listbox_new (UY + 1, UX + 1, movelist_dlg->lines - 8, + movelist_dlg->cols - 2 * UX - 2, l_call); fill_listbox (); diff --git a/src/layout.c b/src/layout.c index e325f6fee..da902f931 100644 --- a/src/layout.c +++ b/src/layout.c @@ -439,10 +439,10 @@ init_layout (void) dialog_colors, layout_callback, "[Layout]", _("Layout"), DLG_CENTER | DLG_REVERSE); - add_widget (layout_dlg, groupbox_new (4, 2, first_width, 6, title1)); - add_widget (layout_dlg, groupbox_new (4, 8, first_width, 4, title2)); + add_widget (layout_dlg, groupbox_new (2, 4, 6, first_width, title1)); + add_widget (layout_dlg, groupbox_new (8, 4, 4, first_width, title2)); add_widget (layout_dlg, - groupbox_new (5 + first_width, 2, second_width, 10, + groupbox_new (2, 5 + first_width, 10, second_width, title3)); add_widget (layout_dlg, diff --git a/src/listmode.c b/src/listmode.c index 69e499d70..8f4ccc3e4 100644 --- a/src/listmode.c +++ b/src/listmode.c @@ -173,10 +173,10 @@ init_listmode (char *oldlistformat) "Listing format edit", DLG_CENTER | DLG_REVERSE); add_widget (listmode_dlg, - groupbox_new (UX, UY, 63, 4, "General options")); - add_widget (listmode_dlg, groupbox_new (UX, UY + 4, 18, 11, "Items")); + groupbox_new (UY, UX, 4, 63, "General options")); + add_widget (listmode_dlg, groupbox_new (UY + 4, UX, 11, 18, "Items")); add_widget (listmode_dlg, - groupbox_new (UX + 20, UY + 4, 43, 11, "Item options")); + groupbox_new (UY + 4, UX + 20, 11, 43, "Item options")); for (i = 0; i < sizeof (listmode_but) / sizeof (struct listmode_button); i++) @@ -205,7 +205,7 @@ init_listmode (char *oldlistformat) radio_justify->sel = 1; /* get new listbox */ - l_listmode = listbox_new (UY + 5, UX + 1, 16, 9, NULL); + l_listmode = listbox_new (UY + 5, UX + 1, 9, 16, NULL); if (strncmp (oldlistformat, "full ", 5) == 0) { format_width = 1; diff --git a/src/option.c b/src/option.c index bc1bb2663..5d9d912b7 100644 --- a/src/option.c +++ b/src/option.c @@ -172,13 +172,13 @@ init_configure (void) _("Configure options"), DLG_CENTER | DLG_REVERSE); add_widget (conf_dlg, - groupbox_new (PX, PY, first_width, PANEL_OPTIONS + 2, title1)); + groupbox_new (PY, PX, PANEL_OPTIONS + 2, first_width, title1)); add_widget (conf_dlg, - groupbox_new (RX, RY, first_width, PAUSE_OPTIONS + 2, title2)); + groupbox_new (RY, RX, PAUSE_OPTIONS + 2, first_width, title2)); add_widget (conf_dlg, - groupbox_new (OX, OY, second_width, OTHER_OPTIONS + 2, title3)); + groupbox_new (OY, OX, OTHER_OPTIONS + 2, second_width, title3)); add_widget (conf_dlg, button_new (BY, b3, B_CANCEL, NORMAL_BUTTON, diff --git a/src/panelize.c b/src/panelize.c index 03358e55f..ee0076454 100644 --- a/src/panelize.c +++ b/src/panelize.c @@ -172,7 +172,7 @@ init_panelize (void) /* get new listbox */ l_panelize = - listbox_new (UY + 1, UX + 1, panelize_dlg->cols - 12, 10, NULL); + listbox_new (UY + 1, UX + 1, 10, panelize_dlg->cols - 12, NULL); while (current) { listbox_add_item (l_panelize, 0, 0, current->label, current); diff --git a/src/widget.c b/src/widget.c index ea8e394da..eb4d9ddb8 100644 --- a/src/widget.c +++ b/src/widget.c @@ -1059,7 +1059,7 @@ show_hist (GList *history, int widget_x, int widget_y) query_dlg = create_dlg (y, x, h, w, dialog_colors, NULL, "[History-query]", i18n_htitle (), DLG_COMPACT); - query_list = listbox_new (1, 1, w - 2, h - 2, 0); + query_list = listbox_new (1, 1, h - 2, w - 2, NULL); add_widget (query_dlg, query_list); hi = z; if (y < widget_y) { @@ -2278,7 +2278,7 @@ listbox_event (Gpm_Event *event, void *data) } WListbox * -listbox_new (int y, int x, int width, int height, lcback callback) +listbox_new (int y, int x, int height, int width, lcback callback) { WListbox *l = g_new (WListbox, 1); @@ -2635,7 +2635,7 @@ groupbox_callback (Widget *w, widget_msg_t msg, int parm) } WGroupbox * -groupbox_new (int x, int y, int width, int height, const char *title) +groupbox_new (int y, int x, int height, int width, const char *title) { WGroupbox *g = g_new (WGroupbox, 1); diff --git a/src/widget.h b/src/widget.h index 5252d0b32..8c2881548 100644 --- a/src/widget.h +++ b/src/widget.h @@ -167,8 +167,8 @@ WCheck *check_new (int y, int x, int state, const char *text); WInput *input_new (int y, int x, int color, int len, const char *text, const char *histname, INPUT_COMPLETE_FLAGS completion_flags); WLabel *label_new (int y, int x, const char *text); WGauge *gauge_new (int y, int x, int shown, int max, int current); -WListbox *listbox_new (int x, int y, int width, int height, lcback callback); -WGroupbox *groupbox_new (int x, int y, int width, int height, const char *title); +WListbox *listbox_new (int y, int x, int height, int width, lcback callback); +WGroupbox *groupbox_new (int y, int x, int height, int width, const char *title); /* Input lines */ void winput_set_origin (WInput *i, int x, int field_width); diff --git a/src/wtools.c b/src/wtools.c index a6f27a62b..a619acd58 100644 --- a/src/wtools.c +++ b/src/wtools.c @@ -66,7 +66,7 @@ create_listbox_window (int cols, int lines, const char *title, const char *help) create_dlg (ypos, xpos, lines + 6, cols + 4, dialog_colors, NULL, help, title, DLG_CENTER | DLG_REVERSE); - listbox->list = listbox_new (2, 2, cols, lines, 0); + listbox->list = listbox_new (2, 2, lines, cols, NULL); add_widget (listbox->dlg, button_new (lines + 3, (cols / 2 + 2) - len / 2, B_CANCEL,