* 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.
|
||||||
|
192
src/complete.c
192
src/complete.c
@ -814,101 +814,107 @@ 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);
|
break;
|
||||||
draw_box (h, 0, 0, query_height, query_width);
|
|
||||||
break;
|
case DLG_KEY:
|
||||||
|
switch (Par) {
|
||||||
case DLG_KEY:
|
case KEY_LEFT:
|
||||||
switch (Par) {
|
case KEY_RIGHT:
|
||||||
case KEY_LEFT:
|
h->ret_value = 0;
|
||||||
case KEY_RIGHT:
|
dlg_stop (h);
|
||||||
h->ret_value = 0;
|
return 1;
|
||||||
dlg_stop (h);
|
|
||||||
return 1;
|
case 0177:
|
||||||
|
case KEY_BACKSPACE:
|
||||||
case 0177:
|
case XCTRL ('h'):
|
||||||
case KEY_BACKSPACE:
|
if (end == min_end) {
|
||||||
case XCTRL('h'):
|
h->ret_value = 0;
|
||||||
if (end == min_end){
|
dlg_stop (h);
|
||||||
h->ret_value = 0;
|
return 1;
|
||||||
dlg_stop (h);
|
} else {
|
||||||
return 1;
|
WLEntry *e, *e1;
|
||||||
} else {
|
|
||||||
WLEntry *e, *e1;
|
e1 = e = ((WListbox *) (h->current->widget))->list;
|
||||||
|
do {
|
||||||
e1 = e = ((WListbox *)(h->current->widget))->list;
|
if (!strncmp
|
||||||
do {
|
(input->buffer + start, e1->text,
|
||||||
if (!strncmp (input->buffer + start, e1->text, end - start - 1)){
|
end - start - 1)) {
|
||||||
listbox_select_entry((WListbox *)(h->current->widget), e1);
|
listbox_select_entry ((WListbox *) (h->current->
|
||||||
handle_char (input, Par);
|
widget), e1);
|
||||||
end--;
|
handle_char (input, Par);
|
||||||
send_message (h, h->current->widget,
|
end--;
|
||||||
WIDGET_DRAW, 0);
|
send_message (h, h->current->widget,
|
||||||
break;
|
WIDGET_DRAW, 0);
|
||||||
}
|
break;
|
||||||
e1 = e1->next;
|
}
|
||||||
} while (e != e1);
|
e1 = e1->next;
|
||||||
}
|
} while (e != e1);
|
||||||
return 1;
|
|
||||||
|
|
||||||
default:
|
|
||||||
if (Par > 0xff || !is_printable (Par)){
|
|
||||||
if (is_in_input_map (input, Par) == 2){
|
|
||||||
if (end == min_end)
|
|
||||||
return 1;
|
|
||||||
h->ret_value = B_USER; /* This means we want to refill the
|
|
||||||
list box and start again */
|
|
||||||
dlg_stop (h);
|
|
||||||
return 1;
|
|
||||||
} else
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
WLEntry *e, *e1;
|
|
||||||
int need_redraw = 0;
|
|
||||||
int low = 4096;
|
|
||||||
char *last_text = NULL;
|
|
||||||
|
|
||||||
e1 = e = ((WListbox *)(h->current->widget))->list;
|
|
||||||
do {
|
|
||||||
if (!strncmp (input->buffer + start, e1->text, end - start)){
|
|
||||||
if (e1->text [end - start] == Par){
|
|
||||||
if (need_redraw){
|
|
||||||
register int c1, c2, si;
|
|
||||||
|
|
||||||
for (si = end - start + 1;
|
|
||||||
(c1 = last_text [si]) &&
|
|
||||||
(c2 = e1->text [si]); si++)
|
|
||||||
if (c1 != c2)
|
|
||||||
break;
|
|
||||||
if (low > si)
|
|
||||||
low = si;
|
|
||||||
last_text = e1->text;
|
|
||||||
need_redraw = 2;
|
|
||||||
} else {
|
|
||||||
need_redraw = 1;
|
|
||||||
listbox_select_entry((WListbox *)(h->current->widget), e1);
|
|
||||||
last_text = e1->text;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
e1 = e1->next;
|
|
||||||
} while (e != e1);
|
|
||||||
if (need_redraw == 2){
|
|
||||||
insert_text (input, last_text, low);
|
|
||||||
send_message (h, h->current->widget,WIDGET_DRAW,0);
|
|
||||||
} else if (need_redraw == 1){
|
|
||||||
h->ret_value = B_ENTER;
|
|
||||||
dlg_stop (h);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
break;
|
return 1;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if (Par > 0xff || !is_printable (Par)) {
|
||||||
|
if (is_in_input_map (input, Par) == 2) {
|
||||||
|
if (end == min_end)
|
||||||
|
return 1;
|
||||||
|
h->ret_value = B_USER; /* This means we want to refill the
|
||||||
|
list box and start again */
|
||||||
|
dlg_stop (h);
|
||||||
|
return 1;
|
||||||
|
} else
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
WLEntry *e, *e1;
|
||||||
|
int need_redraw = 0;
|
||||||
|
int low = 4096;
|
||||||
|
char *last_text = NULL;
|
||||||
|
|
||||||
|
e1 = e = ((WListbox *) (h->current->widget))->list;
|
||||||
|
do {
|
||||||
|
if (!strncmp
|
||||||
|
(input->buffer + start, e1->text, end - start)) {
|
||||||
|
if (e1->text[end - start] == Par) {
|
||||||
|
if (need_redraw) {
|
||||||
|
register int c1, c2, si;
|
||||||
|
|
||||||
|
for (si = end - start + 1;
|
||||||
|
(c1 = last_text[si]) &&
|
||||||
|
(c2 = e1->text[si]); si++)
|
||||||
|
if (c1 != c2)
|
||||||
|
break;
|
||||||
|
if (low > si)
|
||||||
|
low = si;
|
||||||
|
last_text = e1->text;
|
||||||
|
need_redraw = 2;
|
||||||
|
} else {
|
||||||
|
need_redraw = 1;
|
||||||
|
listbox_select_entry ((WListbox *) (h->
|
||||||
|
current->
|
||||||
|
widget),
|
||||||
|
e1);
|
||||||
|
last_text = e1->text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
e1 = e1->next;
|
||||||
|
} while (e != e1);
|
||||||
|
if (need_redraw == 2) {
|
||||||
|
insert_text (input, last_text, low);
|
||||||
|
send_message (h, h->current->widget, WIDGET_DRAW, 0);
|
||||||
|
} else if (need_redraw == 1) {
|
||||||
|
h->ret_value = B_ENTER;
|
||||||
|
dlg_stop (h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -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++)
|
||||||
|
29
src/dlg.c
29
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,20 +664,22 @@ 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;
|
||||||
|
|
||||||
if (!h->current)
|
if (!h->current)
|
||||||
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,18 +706,19 @@ 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;
|
||||||
Gpm_Event new_event;
|
Gpm_Event new_event;
|
||||||
int x = event->x;
|
int x = event->x;
|
||||||
int y = event->y;
|
int y = event->y;
|
||||||
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;
|
||||||
@ -722,8 +727,8 @@ static inline int dlg_mouse_event (Dlg_head *h, Gpm_Event *event)
|
|||||||
|
|
||||||
item = item->next;
|
item = item->next;
|
||||||
|
|
||||||
if (!((x > widget->x) && (x <= widget->x+widget->cols)
|
if (!((x > widget->x) && (x <= widget->x + widget->cols)
|
||||||
&& (y > widget->y) && (y <= widget->y+widget->lines)))
|
&& (y > widget->y) && (y <= widget->y + widget->lines)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
new_event = *event;
|
new_event = *event;
|
||||||
|
@ -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;
|
||||||
|
10
src/wtools.c
10
src/wtools.c
@ -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