static Widget yn_label; /* label for yn function (created once) */
static boolean yn_getting_num; /* TRUE if accepting digits */
static boolean yn_preserve_case; /* default is to force yn to lower case */
+static boolean yn_no_default; /* don't convert ESC or quitchars to def */
static int yn_ndigits; /* digit count */
static long yn_val; /* accumulated value */
return;
}
- if (!yn_choices) { /* accept any input */
+ if (!yn_choices /* accept any input */
+ || (yn_no_default && (ch == '\033' || index(yn_quitchars, ch)))) {
yn_return = ch;
} else {
if (!yn_preserve_case)
char buf[BUFSZ], buf2[BUFSZ];
Arg args[4];
Cardinal num_args;
- boolean suppress_logging = (ynflags & YN_NO_LOGMESG) != 0U;
+ boolean suppress_logging = (ynflags & YN_NO_LOGMESG) != 0U,
+ no_default_cnvrt = (ynflags & YN_NO_DEFAULT) != 0U;
yn_choices = choices; /* set up globals for callback to use */
yn_def = def;
+ yn_no_default = no_default_cnvrt;
yn_preserve_case = !choices; /* preserve case when an arbitrary
* response is allowed */
static void invert_match(struct xwindow *, char *);
static void menu_popdown(struct xwindow *);
static unsigned menu_scrollmask(struct xwindow *);
+static void menu_unscroll(struct xwindow *);
static Widget menu_create_buttons(struct xwindow *, Widget, Widget);
static void menu_create_entries(struct xwindow *, struct menu *);
static void destroy_menu_entry_widgets(struct xwindow *);
ch = map_menu_cmd(ch);
if (ch == '\033') { /* quit */
- if (menu_info->counting) {
+ if (menu_info->counting || perminv_scrolling) {
/* when there's a count in progress, ESC discards it
rather than dismissing the whole menu */
reset_menu_count(menu_info);
}
select_none(wp);
} else if (ch == '\n' || ch == '\r') {
+ if (perminv_scrolling) {
+ menu_unscroll(wp);
+ return; /* skip menu_popdown() */
+ }
; /* accept */
} else if (digit(ch)) {
/* special case: '0' is also the default ball class */
return scrlmask;
}
+/* if a menu is scrolled vertically and/horizontallty, return it to the top
+ and far left */
+static void
+menu_unscroll(struct xwindow *wp)
+{
+ float top, left, zero = 0.0;
+ Arg arg;
+ Widget hbar = (Widget) 0, vbar = (Widget) 0;
+
+ find_scrollbars(wp->w, wp->popup, &hbar, &vbar);
+ if (hbar) {
+ XtSetArg(arg, nhStr(XtNtopOfThumb), &left);
+ XtGetValues(hbar, &arg, ONE);
+ if (left > 0.0)
+ XtCallCallbacks(hbar, XtNjumpProc, &zero);
+ }
+ if (vbar) {
+ XtSetArg(arg, nhStr(XtNtopOfThumb), &top);
+ XtGetValues(vbar, &arg, ONE);
+ if (top > 0.0)
+ XtCallCallbacks(vbar, XtNjumpProc, &zero);
+ }
+ return;
+}
+
/* Global functions ======================================================= */
/* called by X11_update_inventory() if persistent inventory is currently
save_is_active = wp->menu_information->is_active;
wp->menu_information->is_active = TRUE;
ch = X11_yn_function_core("Inventory scroll:", menukeys,
- 0, YN_NO_LOGMESG);
+ 0, (YN_NO_LOGMESG | YN_NO_DEFAULT));
if (wp->menu_information->is_up)
wp->menu_information->is_active = save_is_active;
else
favor of easy to handle union type code; might conceivably
confuse a sophisticated debugger so we should possibly redo
this to set it up properly: event->keyevent->keycode */
- fake_perminv_event.type = !index(quitchars, ch) ? ch
- : MENU_FIRST_PAGE;
+ fake_perminv_event.type = ch;
menu_key(wp->w, &fake_perminv_event, (String *) 0, &no_args);
fake_perminv_event.type = 0;
}