1
1

* widget.c (history_callback): Eliminate in favor of

common_dialog_callback().
(show_hist): Set dialog title and flag DLG_COMPACT.
Этот коммит содержится в:
Pavel Roskin 2002-09-02 08:01:35 +00:00
родитель 43509ea980
Коммит 0df513bcc2
2 изменённых файлов: 48 добавлений и 61 удалений

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

@ -1,5 +1,9 @@
2002-09-02 Pavel Roskin <proski@gnu.org> 2002-09-02 Pavel Roskin <proski@gnu.org>
* widget.c (history_callback): Eliminate in favor of
common_dialog_callback().
(show_hist): Set dialog title and flag DLG_COMPACT.
* help.c (help_callback): Use common_dialog_callback(). * help.c (help_callback): Use common_dialog_callback().
(interactive_display): Set dialog title. (interactive_display): Set dialog title.

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

@ -42,6 +42,7 @@
#include "complete.h" #include "complete.h"
#include "key.h" /* XCTRL and ALT macros */ #include "key.h" /* XCTRL and ALT macros */
#include "profile.h" /* for history loading and saving */ #include "profile.h" /* for history loading and saving */
#include "wtools.h" /* For common_dialog_repaint() */
static int button_event (Gpm_Event *event, WButton *b); static int button_event (Gpm_Event *event, WButton *b);
@ -898,29 +899,13 @@ i18n_htitle (void)
return history_title; return history_title;
} }
static int
history_callback (Dlg_head * h, int Par, int Msg)
{
switch (Msg) {
case DLG_DRAW:
attrset (COLOR_NORMAL);
dlg_erase (h);
draw_box (h, 0, 0, h->lines, h->cols);
attrset (COLOR_HOT_NORMAL);
dlg_move (h, 0, (h->cols - strlen (i18n_htitle())) / 2);
printw (i18n_htitle());
break;
}
return 0;
}
static inline int listbox_fwd (WListbox *l); static inline int listbox_fwd (WListbox *l);
char * char *
show_hist (Hist *history, int widget_x, int widget_y) show_hist (Hist * history, int widget_x, int widget_y)
{ {
Hist *hi, *z; Hist *hi, *z;
size_t maxlen = strlen (i18n_htitle()), i, count = 0; size_t maxlen = strlen (i18n_htitle ()), i, count = 0;
int x, y, w, h; int x, y, w, h;
char *q, *r = 0; char *q, *r = 0;
Dlg_head *query_dlg; Dlg_head *query_dlg;
@ -928,66 +913,64 @@ show_hist (Hist *history, int widget_x, int widget_y)
z = history; z = history;
if (!z) if (!z)
return 0; return 0;
while (z->prev) /* goto first */ while (z->prev) /* goto first */
z = z->prev; z = z->prev;
hi = z; hi = z;
while (hi) { while (hi) {
if ((i = strlen (hi->text)) > maxlen) if ((i = strlen (hi->text)) > maxlen)
maxlen = i; maxlen = i;
count++; count++;
hi = hi->next; hi = hi->next;
} }
y = widget_y; y = widget_y;
h = count + 2; h = count + 2;
if (h <= y || y > LINES - 6) if (h <= y || y > LINES - 6) {
{ h = min (h, y - 1);
h = min(h, y - 1); y -= h;
y -= h; } else {
} y++;
else h = min (h, LINES - y);
{ }
y++;
h = min(h, LINES - y);
}
if (widget_x > 2) if (widget_x > 2)
x = widget_x - 2; x = widget_x - 2;
else else
x = 0; x = 0;
if ((w = maxlen + 4) + x > COLS) if ((w = maxlen + 4) + x > COLS) {
{ w = min (w, COLS);
w = min(w,COLS); x = COLS - w;
x = COLS - w; }
}
query_dlg = create_dlg (y, x, h, w, dialog_colors, history_callback, query_dlg =
"[History-query]", "history", DLG_NONE); create_dlg (y, x, h, w, dialog_colors, common_dialog_callback,
"[History-query]", "history", DLG_COMPACT);
x_set_dialog_title (query_dlg, i18n_htitle ());
query_list = listbox_new (1, 1, w - 2, h - 2, listbox_finish, 0, NULL); query_list = listbox_new (1, 1, w - 2, h - 2, listbox_finish, 0, NULL);
add_widget (query_dlg, query_list); add_widget (query_dlg, query_list);
hi = z; hi = z;
if (y < widget_y) { if (y < widget_y) {
while (hi) { /* traverse */ while (hi) { /* traverse */
listbox_add_item (query_list, 0, 0, hi->text, NULL); listbox_add_item (query_list, 0, 0, hi->text, NULL);
hi = hi->next; hi = hi->next;
} }
while (listbox_fwd (query_list)); while (listbox_fwd (query_list));
} else { } else {
while (hi->next) while (hi->next)
hi = hi->next; hi = hi->next;
while (hi) { /* traverse backwards */ while (hi) { /* traverse backwards */
listbox_add_item (query_list, 0, 0, hi->text, NULL); listbox_add_item (query_list, 0, 0, hi->text, NULL);
hi = hi->prev; hi = hi->prev;
} }
} }
run_dlg (query_dlg); run_dlg (query_dlg);
q = NULL; q = NULL;
if (query_dlg->ret_value != B_CANCEL) { if (query_dlg->ret_value != B_CANCEL) {
listbox_get_current (query_list, &q, NULL); listbox_get_current (query_list, &q, NULL);
if (q) if (q)
r = g_strdup (q); r = g_strdup (q);
} }
destroy_dlg (query_dlg); destroy_dlg (query_dlg);
return r; return r;