* 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>
|
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 ...
|
* keys.h: Remove, include ...
|
||||||
* myslang.h: ... here.
|
* myslang.h: ... here.
|
||||||
* Makefile.am: Remove keys.h.
|
* Makefile.am: Remove keys.h.
|
||||||
|
@ -814,13 +814,12 @@ static int insert_text (WInput *in, char *text, int len)
|
|||||||
return len != 0;
|
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) {
|
switch (Msg) {
|
||||||
case DLG_DRAW:
|
case DLG_DRAW:
|
||||||
attrset (COLOR_NORMAL);
|
common_dialog_repaint (h);
|
||||||
dlg_erase (h);
|
|
||||||
draw_box (h, 0, 0, query_height, query_width);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DLG_KEY:
|
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;
|
e1 = e = ((WListbox *) (h->current->widget))->list;
|
||||||
do {
|
do {
|
||||||
if (!strncmp (input->buffer + start, e1->text, end - start - 1)){
|
if (!strncmp
|
||||||
listbox_select_entry((WListbox *)(h->current->widget), e1);
|
(input->buffer + start, e1->text,
|
||||||
|
end - start - 1)) {
|
||||||
|
listbox_select_entry ((WListbox *) (h->current->
|
||||||
|
widget), e1);
|
||||||
handle_char (input, Par);
|
handle_char (input, Par);
|
||||||
end--;
|
end--;
|
||||||
send_message (h, h->current->widget,
|
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;
|
e1 = e = ((WListbox *) (h->current->widget))->list;
|
||||||
do {
|
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 (e1->text[end - start] == Par) {
|
||||||
if (need_redraw) {
|
if (need_redraw) {
|
||||||
register int c1, c2, si;
|
register int c1, c2, si;
|
||||||
@ -891,7 +894,10 @@ static int query_callback (Dlg_head * h, int Par, int Msg)
|
|||||||
need_redraw = 2;
|
need_redraw = 2;
|
||||||
} else {
|
} else {
|
||||||
need_redraw = 1;
|
need_redraw = 1;
|
||||||
listbox_select_entry((WListbox *)(h->current->widget), e1);
|
listbox_select_entry ((WListbox *) (h->
|
||||||
|
current->
|
||||||
|
widget),
|
||||||
|
e1);
|
||||||
last_text = e1->text;
|
last_text = e1->text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -988,7 +994,7 @@ complete_engine (WInput *in, int what_to_do)
|
|||||||
query_width = w;
|
query_width = w;
|
||||||
query_dlg = create_dlg (y, x, query_height, query_width,
|
query_dlg = create_dlg (y, x, query_height, query_width,
|
||||||
dialog_colors, query_callback,
|
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);
|
query_list = listbox_new (1, 1, w - 2, h - 2, 0, querylist_callback, NULL);
|
||||||
add_widget (query_dlg, query_list);
|
add_widget (query_dlg, query_list);
|
||||||
for (p = in->completions + 1; *p; p++)
|
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->y = y1;
|
||||||
new_d->cols = cols;
|
new_d->cols = cols;
|
||||||
new_d->lines = lines;
|
new_d->lines = lines;
|
||||||
|
new_d->flags = flags;
|
||||||
return (new_d);
|
return (new_d);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -663,7 +664,8 @@ static int dlg_try_hotkey (Dlg_head *h, int d_key)
|
|||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dlg_key_event (Dlg_head *h, int d_key)
|
int
|
||||||
|
dlg_key_event (Dlg_head * h, int d_key)
|
||||||
{
|
{
|
||||||
int handled;
|
int handled;
|
||||||
|
|
||||||
@ -671,12 +673,13 @@ int dlg_key_event (Dlg_head *h, int d_key)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* TAB used to cycle */
|
/* 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')
|
if (d_key == '\t')
|
||||||
dlg_one_down (h);
|
dlg_one_down (h);
|
||||||
else
|
else
|
||||||
dlg_one_up (h);
|
dlg_one_up (h);
|
||||||
else {
|
} else {
|
||||||
|
|
||||||
/* first can dlg_callback handle the key */
|
/* first can dlg_callback handle the key */
|
||||||
handled = (*h->callback) (h, d_key, DLG_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 */
|
/* not used - then try widget_callback */
|
||||||
if (!handled)
|
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 */
|
/* not used- try to use the unhandled case */
|
||||||
if (!handled)
|
if (!handled)
|
||||||
@ -702,7 +706,8 @@ int dlg_key_event (Dlg_head *h, int d_key)
|
|||||||
return 1;
|
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 *item;
|
||||||
Widget_Item *starting_widget = h->current;
|
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;
|
int ret_value;
|
||||||
|
|
||||||
/* kludge for the menubar: start at h->first, not current */
|
/* kludge for the menubar: start at h->first, not current */
|
||||||
/* Must be carefull in the insertion order to the dlg list */
|
/* Must be careful in the insertion order to the dlg list */
|
||||||
if (y == 1 && h->has_menubar)
|
if (y == 1 && (h->flags & DLG_HAS_MENUBAR))
|
||||||
starting_widget = h->first;
|
starting_widget = h->first;
|
||||||
|
|
||||||
item = starting_widget;
|
item = starting_widget;
|
||||||
|
@ -99,8 +99,7 @@ typedef struct Dlg_head {
|
|||||||
int lines;
|
int lines;
|
||||||
void *data;
|
void *data;
|
||||||
|
|
||||||
int has_menubar; /* GrossHack: Send events on row 1 to a menubar? */
|
int flags; /* Different flags, specified in create_dlg() */
|
||||||
int raw; /* Should the tab key be sent to the dialog? */
|
|
||||||
} Dlg_head;
|
} Dlg_head;
|
||||||
|
|
||||||
/* Every Widget must have this as it's first element */
|
/* 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);
|
char *help_ctx, char *name, int flags);
|
||||||
|
|
||||||
/* The 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_TRYUP 2 /* Try to move two lines up the dialog */
|
||||||
#define DLG_CENTER 1 /* Center the dialog */
|
#define DLG_CENTER 1 /* Center the dialog */
|
||||||
#define DLG_NONE 0 /* No options */
|
#define DLG_NONE 0 /* No options */
|
||||||
|
@ -784,10 +784,8 @@ interactive_display (char *filename, char *node)
|
|||||||
help_lines = LINES - 4;
|
help_lines = LINES - 4;
|
||||||
|
|
||||||
whelp = create_dlg (0, 0, help_lines+4, HELP_WINDOW_WIDTH+4, dialog_colors,
|
whelp = create_dlg (0, 0, help_lines+4, HELP_WINDOW_WIDTH+4, dialog_colors,
|
||||||
help_callback, "[Help]", "help", DLG_TRYUP|DLG_CENTER);
|
help_callback, "[Help]", "help",
|
||||||
|
DLG_TRYUP | DLG_CENTER | DLG_WANT_TAB);
|
||||||
/* allow us to process the tab key */
|
|
||||||
whelp->raw = 1;
|
|
||||||
|
|
||||||
selected_item = search_string_node (main_node, STRING_LINK_START) - 1;
|
selected_item = search_string_node (main_node, STRING_LINK_START) - 1;
|
||||||
currentpoint = startpoint = main_node + 1;
|
currentpoint = startpoint = main_node + 1;
|
||||||
|
@ -1914,8 +1914,9 @@ mc_maybe_editor_or_viewer (void)
|
|||||||
static void
|
static void
|
||||||
do_nc (void)
|
do_nc (void)
|
||||||
{
|
{
|
||||||
midnight_dlg = create_dlg (0, 0, LINES, COLS, midnight_colors, midnight_callback, "[main]", "midnight", 0);
|
midnight_dlg = create_dlg (0, 0, LINES, COLS, midnight_colors,
|
||||||
midnight_dlg->has_menubar = 1;
|
midnight_callback, "[main]", "midnight",
|
||||||
|
DLG_HAS_MENUBAR);
|
||||||
|
|
||||||
/* Check if we were invoked as an editor or file viewer */
|
/* Check if we were invoked as an editor or file viewer */
|
||||||
if (mc_maybe_editor_or_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->start_display -= view->start_display % view->bytes_per_line;
|
||||||
view->edit_cursor = view->start_display;
|
view->edit_cursor = view->start_display;
|
||||||
view->widget.options |= W_WANT_CURSOR;
|
view->widget.options |= W_WANT_CURSOR;
|
||||||
view->widget.parent->raw = 1;
|
view->widget.parent->flags |= DLG_WANT_TAB;
|
||||||
} else {
|
} else {
|
||||||
view->start_display = view->start_save;
|
view->start_display = view->start_save;
|
||||||
view->widget.parent->raw = 0;
|
view->widget.parent->flags &= ~DLG_WANT_TAB;
|
||||||
view->widget.options &= ~W_WANT_CURSOR;
|
view->widget.options &= ~W_WANT_CURSOR;
|
||||||
}
|
}
|
||||||
altered_hex_mode = 1;
|
altered_hex_mode = 1;
|
||||||
|
@ -55,12 +55,16 @@
|
|||||||
void
|
void
|
||||||
dialog_repaint (struct Dlg_head *h, int back, int title_fore)
|
dialog_repaint (struct Dlg_head *h, int back, int title_fore)
|
||||||
{
|
{
|
||||||
|
int space;
|
||||||
|
|
||||||
|
space = (h->flags & DLG_COMPACT) ? 0 : 1;
|
||||||
|
|
||||||
attrset (back);
|
attrset (back);
|
||||||
dlg_erase (h);
|
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);
|
attrset (title_fore);
|
||||||
if (h->title) {
|
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);
|
addstr (h->title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user