* dlg.h (struct Dlg_head): Fold fields "raw" and "has_menubar"
into one field "flags". Adjust all dependencies. Add new flag DLG_COMPACT. * wtools.c (dialog_repaint): Draw frame without spaces if DLG_COMPACT flag is set. * complete.c (complete_engine): Set DLG_COMPACT. (query_callback): Use common_dialog_repaint().
Этот коммит содержится в:
родитель
c221153512
Коммит
8aa61fffa3
@ -1,5 +1,13 @@
|
||||
2002-08-22 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* dlg.h (struct Dlg_head): Fold fields "raw" and "has_menubar"
|
||||
into one field "flags". Adjust all dependencies. Add new flag
|
||||
DLG_COMPACT.
|
||||
* wtools.c (dialog_repaint): Draw frame without spaces if
|
||||
DLG_COMPACT flag is set.
|
||||
* complete.c (complete_engine): Set DLG_COMPACT.
|
||||
(query_callback): Use common_dialog_repaint().
|
||||
|
||||
* keys.h: Remove, include ...
|
||||
* myslang.h: ... here.
|
||||
* Makefile.am: Remove keys.h.
|
||||
|
@ -814,13 +814,12 @@ static int insert_text (WInput *in, char *text, int len)
|
||||
return len != 0;
|
||||
}
|
||||
|
||||
static int query_callback (Dlg_head * h, int Par, int Msg)
|
||||
static int
|
||||
query_callback (Dlg_head * h, int Par, int Msg)
|
||||
{
|
||||
switch (Msg) {
|
||||
case DLG_DRAW:
|
||||
attrset (COLOR_NORMAL);
|
||||
dlg_erase (h);
|
||||
draw_box (h, 0, 0, query_height, query_width);
|
||||
common_dialog_repaint (h);
|
||||
break;
|
||||
|
||||
case DLG_KEY:
|
||||
@ -843,8 +842,11 @@ static int query_callback (Dlg_head * h, int Par, int Msg)
|
||||
|
||||
e1 = e = ((WListbox *) (h->current->widget))->list;
|
||||
do {
|
||||
if (!strncmp (input->buffer + start, e1->text, end - start - 1)){
|
||||
listbox_select_entry((WListbox *)(h->current->widget), e1);
|
||||
if (!strncmp
|
||||
(input->buffer + start, e1->text,
|
||||
end - start - 1)) {
|
||||
listbox_select_entry ((WListbox *) (h->current->
|
||||
widget), e1);
|
||||
handle_char (input, Par);
|
||||
end--;
|
||||
send_message (h, h->current->widget,
|
||||
@ -875,7 +877,8 @@ static int query_callback (Dlg_head * h, int Par, int Msg)
|
||||
|
||||
e1 = e = ((WListbox *) (h->current->widget))->list;
|
||||
do {
|
||||
if (!strncmp (input->buffer + start, e1->text, end - start)){
|
||||
if (!strncmp
|
||||
(input->buffer + start, e1->text, end - start)) {
|
||||
if (e1->text[end - start] == Par) {
|
||||
if (need_redraw) {
|
||||
register int c1, c2, si;
|
||||
@ -891,7 +894,10 @@ static int query_callback (Dlg_head * h, int Par, int Msg)
|
||||
need_redraw = 2;
|
||||
} else {
|
||||
need_redraw = 1;
|
||||
listbox_select_entry((WListbox *)(h->current->widget), e1);
|
||||
listbox_select_entry ((WListbox *) (h->
|
||||
current->
|
||||
widget),
|
||||
e1);
|
||||
last_text = e1->text;
|
||||
}
|
||||
}
|
||||
@ -988,7 +994,7 @@ complete_engine (WInput *in, int what_to_do)
|
||||
query_width = w;
|
||||
query_dlg = create_dlg (y, x, query_height, query_width,
|
||||
dialog_colors, query_callback,
|
||||
"[Completion]", "complete", DLG_NONE);
|
||||
"[Completion]", "complete", DLG_COMPACT);
|
||||
query_list = listbox_new (1, 1, w - 2, h - 2, 0, querylist_callback, NULL);
|
||||
add_widget (query_dlg, query_list);
|
||||
for (p = in->completions + 1; *p; p++)
|
||||
|
19
src/dlg.c
19
src/dlg.c
@ -210,6 +210,7 @@ Dlg_head *create_dlg (int y1, int x1, int lines, int cols,
|
||||
new_d->y = y1;
|
||||
new_d->cols = cols;
|
||||
new_d->lines = lines;
|
||||
new_d->flags = flags;
|
||||
return (new_d);
|
||||
}
|
||||
|
||||
@ -663,7 +664,8 @@ static int dlg_try_hotkey (Dlg_head *h, int d_key)
|
||||
return handled;
|
||||
}
|
||||
|
||||
int dlg_key_event (Dlg_head *h, int d_key)
|
||||
int
|
||||
dlg_key_event (Dlg_head * h, int d_key)
|
||||
{
|
||||
int handled;
|
||||
|
||||
@ -671,12 +673,13 @@ int dlg_key_event (Dlg_head *h, int d_key)
|
||||
return 0;
|
||||
|
||||
/* TAB used to cycle */
|
||||
if (!h->raw && (d_key == '\t' || d_key == KEY_BTAB))
|
||||
if (!(h->flags & DLG_WANT_TAB)
|
||||
&& (d_key == '\t' || d_key == KEY_BTAB)) {
|
||||
if (d_key == '\t')
|
||||
dlg_one_down (h);
|
||||
else
|
||||
dlg_one_up (h);
|
||||
else {
|
||||
} else {
|
||||
|
||||
/* first can dlg_callback handle the key */
|
||||
handled = (*h->callback) (h, d_key, DLG_KEY);
|
||||
@ -687,7 +690,8 @@ int dlg_key_event (Dlg_head *h, int d_key)
|
||||
|
||||
/* not used - then try widget_callback */
|
||||
if (!handled)
|
||||
handled |= callback (h)(h, h->current->widget, WIDGET_KEY, d_key);
|
||||
handled |=
|
||||
callback (h) (h, h->current->widget, WIDGET_KEY, d_key);
|
||||
|
||||
/* not used- try to use the unhandled case */
|
||||
if (!handled)
|
||||
@ -702,7 +706,8 @@ int dlg_key_event (Dlg_head *h, int d_key)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline int dlg_mouse_event (Dlg_head *h, Gpm_Event *event)
|
||||
static inline int
|
||||
dlg_mouse_event (Dlg_head * h, Gpm_Event * event)
|
||||
{
|
||||
Widget_Item *item;
|
||||
Widget_Item *starting_widget = h->current;
|
||||
@ -712,8 +717,8 @@ static inline int dlg_mouse_event (Dlg_head *h, Gpm_Event *event)
|
||||
int ret_value;
|
||||
|
||||
/* kludge for the menubar: start at h->first, not current */
|
||||
/* Must be carefull in the insertion order to the dlg list */
|
||||
if (y == 1 && h->has_menubar)
|
||||
/* Must be careful in the insertion order to the dlg list */
|
||||
if (y == 1 && (h->flags & DLG_HAS_MENUBAR))
|
||||
starting_widget = h->first;
|
||||
|
||||
item = starting_widget;
|
||||
|
@ -99,8 +99,7 @@ typedef struct Dlg_head {
|
||||
int lines;
|
||||
void *data;
|
||||
|
||||
int has_menubar; /* GrossHack: Send events on row 1 to a menubar? */
|
||||
int raw; /* Should the tab key be sent to the dialog? */
|
||||
int flags; /* Different flags, specified in create_dlg() */
|
||||
} Dlg_head;
|
||||
|
||||
/* Every Widget must have this as it's first element */
|
||||
@ -143,6 +142,9 @@ Dlg_head *create_dlg (int y1, int x1, int lines, int cols,
|
||||
char *help_ctx, char *name, int flags);
|
||||
|
||||
/* The flags: */
|
||||
#define DLG_WANT_TAB 16 /* Should the tab key be sent to the dialog? */
|
||||
#define DLG_HAS_MENUBAR 8 /* GrossHack: Send events on row 1 to a menubar? */
|
||||
#define DLG_COMPACT 4 /* Suppress spaces around the frame */
|
||||
#define DLG_TRYUP 2 /* Try to move two lines up the dialog */
|
||||
#define DLG_CENTER 1 /* Center the dialog */
|
||||
#define DLG_NONE 0 /* No options */
|
||||
|
@ -784,10 +784,8 @@ interactive_display (char *filename, char *node)
|
||||
help_lines = LINES - 4;
|
||||
|
||||
whelp = create_dlg (0, 0, help_lines+4, HELP_WINDOW_WIDTH+4, dialog_colors,
|
||||
help_callback, "[Help]", "help", DLG_TRYUP|DLG_CENTER);
|
||||
|
||||
/* allow us to process the tab key */
|
||||
whelp->raw = 1;
|
||||
help_callback, "[Help]", "help",
|
||||
DLG_TRYUP | DLG_CENTER | DLG_WANT_TAB);
|
||||
|
||||
selected_item = search_string_node (main_node, STRING_LINK_START) - 1;
|
||||
currentpoint = startpoint = main_node + 1;
|
||||
|
@ -1914,8 +1914,9 @@ mc_maybe_editor_or_viewer (void)
|
||||
static void
|
||||
do_nc (void)
|
||||
{
|
||||
midnight_dlg = create_dlg (0, 0, LINES, COLS, midnight_colors, midnight_callback, "[main]", "midnight", 0);
|
||||
midnight_dlg->has_menubar = 1;
|
||||
midnight_dlg = create_dlg (0, 0, LINES, COLS, midnight_colors,
|
||||
midnight_callback, "[main]", "midnight",
|
||||
DLG_HAS_MENUBAR);
|
||||
|
||||
/* Check if we were invoked as an editor or file viewer */
|
||||
if (mc_maybe_editor_or_viewer ())
|
||||
|
@ -1825,10 +1825,10 @@ toggle_hex_mode (WView *view)
|
||||
view->start_display -= view->start_display % view->bytes_per_line;
|
||||
view->edit_cursor = view->start_display;
|
||||
view->widget.options |= W_WANT_CURSOR;
|
||||
view->widget.parent->raw = 1;
|
||||
view->widget.parent->flags |= DLG_WANT_TAB;
|
||||
} else {
|
||||
view->start_display = view->start_save;
|
||||
view->widget.parent->raw = 0;
|
||||
view->widget.parent->flags &= ~DLG_WANT_TAB;
|
||||
view->widget.options &= ~W_WANT_CURSOR;
|
||||
}
|
||||
altered_hex_mode = 1;
|
||||
|
@ -55,12 +55,16 @@
|
||||
void
|
||||
dialog_repaint (struct Dlg_head *h, int back, int title_fore)
|
||||
{
|
||||
int space;
|
||||
|
||||
space = (h->flags & DLG_COMPACT) ? 0 : 1;
|
||||
|
||||
attrset (back);
|
||||
dlg_erase (h);
|
||||
draw_box (h, 1, 1, h->lines - 2, h->cols - 2);
|
||||
draw_box (h, space, space, h->lines - 2 * space, h->cols - 2 * space);
|
||||
attrset (title_fore);
|
||||
if (h->title) {
|
||||
dlg_move (h, 1, (h->cols-strlen (h->title))/2);
|
||||
dlg_move (h, space, (h->cols - strlen (h->title)) / 2);
|
||||
addstr (h->title);
|
||||
}
|
||||
}
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user