Deleted Added
full compact
2c2
< * $Id: dlg_keys.c,v 1.26 2009/02/22 16:19:51 tom Exp $
---
> * $Id: dlg_keys.c,v 1.34 2011/10/14 00:41:08 tom Exp $
4c4
< * dlg_keys.c -- runtime binding support for dialog
---
> * dlg_keys.c -- runtime binding support for dialog
6c6
< * Copyright 2006-2007,2009 Thomas E. Dickey
---
> * Copyright 2006-2009,2011 Thomas E. Dickey
36a37
> #define WILDNAME "*"
63a65,75
> #if defined(HAVE_DLG_TRACE) && defined(HAVE_RC_FILE)
> /*
> * Trace the binding information assigned to this window. For most widgets
> * there is only one binding table. forms have two, so the trace will be
> * longer. Since compiled-in bindings are only visible when the widget is
> * registered, there is no other way to see what bindings are available,
> * than by running dialog and tracing it.
> */
> dlg_trace_msg("# dlg_register_window %s\n", name);
> dlg_dump_window_keys(dialog_state.trace_output, win);
> #endif
192c204
< int n;
---
> DLG_KEYS_BINDING *q;
210a223,231
> const char *name = WILDNAME;
> if (win != 0) {
> for (p = all_bindings; p != 0; p = p->link) {
> if (p->win == win) {
> name = p->name;
> break;
> }
> }
> }
212c233
< if (p->win == win || p->win == 0) {
---
> if (p->win == win || (p->win == 0 && !strcmp(p->name, name))) {
214c235
< for (n = 0; p->binding[n].is_function_key >= 0; ++n) {
---
> for (q = p->binding; q->is_function_key >= 0; ++q) {
217c238
< && p->binding[n].curses_key == (int) dlg_toupper(curses_key)) {
---
> && q->curses_key == (int) dlg_toupper(curses_key)) {
219c240
< return p->binding[n].dialog_key;
---
> return q->dialog_key;
221,223c242,244
< if (p->binding[n].curses_key == curses_key
< && p->binding[n].is_function_key == function_key) {
< *fkey = p->binding[n].dialog_key;
---
> if (q->curses_key == curses_key
> && q->is_function_key == function_key) {
> *fkey = q->dialog_key;
297a319
> #define ASCII_NAME(name,code) { #name, code }
301a324,330
> ASCII_NAME(ESC, '\033'),
> ASCII_NAME(CR, '\r'),
> ASCII_NAME(LF, '\n'),
> ASCII_NAME(FF, '\f'),
> ASCII_NAME(TAB, '\t'),
> ASCII_NAME(DEL, '\177'),
>
410a440,443
> DIALOG_NAME(FORM_FIRST),
> DIALOG_NAME(FORM_LAST),
> DIALOG_NAME(FORM_NEXT),
> DIALOG_NAME(FORM_PREV),
421c454,456
< DIALOG_NAME(SELECT)
---
> DIALOG_NAME(SELECT),
> DIALOG_NAME(HELPFILE),
> DIALOG_NAME(TRACE)
475c510
< } else if (!strcmp(b->name, "*")) {
---
> } else if (!strcmp(b->name, WILDNAME)) {
477c512
< } else if (!strcmp(a->name, "*")) {
---
> } else if (!strcmp(a->name, WILDNAME)) {
574a610
> p = skip_white(p);
616c652
< is_function = TRUE;
---
> is_function = (curses_key >= KEY_MIN);
702a739,743
> /*
> * Dump bindings for the given window. If it is a null, then this dumps the
> * initial bindings which were loaded from the rc-file that are used as
> * overall defaults.
> */
704c745
< dlg_dump_keys(FILE *fp)
---
> dlg_dump_window_keys(FILE *fp, WINDOW *win)
706,709c747,750
< LIST_BINDINGS *p;
< const char *last = "";
< unsigned n;
< unsigned count = 0;
---
> if (fp != 0) {
> LIST_BINDINGS *p;
> DLG_KEYS_BINDING *q;
> const char *last = "";
711,718c752,753
< for (p = all_bindings; p != 0; p = p->link) {
< if (p->win == 0) {
< ++count;
< }
< }
< if (count != 0) {
< for (p = all_bindings, n = 0; p != 0; p = p->link) {
< if (p->win == 0) {
---
> for (p = all_bindings; p != 0; p = p->link) {
> if (p->win == win) {
721c756
< !strcmp(p->name, "*") ? "all" : p->name);
---
> !strcmp(p->name, WILDNAME) ? "all" : p->name);
724c759,761
< dump_one_binding(fp, p->name, p->binding);
---
> for (q = p->binding; q->is_function_key >= 0; ++q) {
> dump_one_binding(fp, p->name, q);
> }
728a766,787
>
> /*
> * Dump all of the bindings which are not specific to a given widget, i.e.,
> * the "win" member is null.
> */
> void
> dlg_dump_keys(FILE *fp)
> {
> if (fp != 0) {
> LIST_BINDINGS *p;
> unsigned count = 0;
>
> for (p = all_bindings; p != 0; p = p->link) {
> if (p->win == 0) {
> ++count;
> }
> }
> if (count != 0) {
> dlg_dump_window_keys(fp, 0);
> }
> }
> }