Lines Matching +full:state +full:- +full:labels

4  *  buttons.c -- draw buttons, e.g., OK/Cancel
6 * Copyright 2000-2020,2021 Thomas E. Dickey
31 #define MIN_BUTTON (-dialog_state.visit_cols)
42 int left = (longest - len) / 2; in center_label()
43 right = (longest - len - left); in center_label()
65 mbstate_t state; in string_to_char() local
67 memset(&state, 0, sizeof(state)); in string_to_char()
68 len = mbrlen(string, have, &state); in string_to_char()
73 memset(&state, 0, sizeof(state)); in string_to_char()
75 check = mbrtowc(cmp2, string, len, &state); in string_to_char()
93 count_labels(const char **labels) in count_labels() argument
96 if (labels != 0) { in count_labels()
97 while (*labels++ != 0) { in count_labels()
125 * Determine the hot-keys for a set of button-labels. Normally these are
127 * button has the same first-uppercase, then we will (attempt to) look for
133 get_hotkeys(const char **labels) in get_hotkeys() argument
136 size_t count = count_labels(labels); in get_hotkeys()
142 const char *label = labels[n]; in get_hotkeys()
152 if ((last - first) != 1) { in get_hotkeys()
180 HOTKEY state = sFIND_KEY; in print_button() local
201 switch (state) { in print_button()
205 if ((last - first) != 1) { in print_button()
212 state = sHAVE_KEY; in print_button()
217 state = sHAD_KEY; in print_button()
222 waddnstr(win, label + first, last - first); in print_button()
237 dlg_button_count(const char **labels) in dlg_button_count() argument
240 while (*labels++ != 0) in dlg_button_count()
250 dlg_button_sizes(const char **labels, in dlg_button_sizes() argument
259 for (n = 0; labels[n] != 0; n++) { in dlg_button_sizes()
264 int len = dlg_count_columns(labels[n]); in dlg_button_sizes()
274 if (*longest < 6 - (*longest & 1)) in dlg_button_sizes()
275 *longest = 6 - (*longest & 1); in dlg_button_sizes()
284 dlg_button_x_step(const char **labels, int limit, int *gap, int *margin, int *step) in dlg_button_x_step() argument
286 int count = dlg_button_count(labels); in dlg_button_x_step()
296 dlg_button_sizes(labels, FALSE, &longest, &length); in dlg_button_x_step()
298 unused = limit - used; in dlg_button_x_step()
307 *step = *gap + (used + count - 1) / count; in dlg_button_x_step()
319 dlg_button_layout(const char **labels, int *limit) in dlg_button_layout() argument
323 if (labels != 0 && dlg_button_count(labels)) { in dlg_button_layout()
326 while (!dlg_button_x_step(labels, width, &gap, &margin, &step)) in dlg_button_layout()
342 const char **labels, in dlg_draw_buttons() argument
361 dlg_button_sizes(labels, vertical, &longest, &length); in dlg_draw_buttons()
367 dlg_button_x_step(labels, limit, &gap, &margin, &step); in dlg_draw_buttons()
378 int *hotkeys = get_hotkeys(labels); in dlg_draw_buttons()
382 for (n = 0; labels[n] != 0; ++n) { in dlg_draw_buttons()
383 need += strlen(labels[n]) + 1; in dlg_draw_buttons()
389 * Draw the labels. in dlg_draw_buttons()
391 for (n = 0; labels[n] != 0; n++) { in dlg_draw_buttons()
392 center_label(buffer, longest, labels[n]); in dlg_draw_buttons()
395 CHR_BUTTON ? hotkeys[n] : -1, in dlg_draw_buttons()
451 int cmp = -1; in dlg_button_to_char()
464 * Given a list of button labels, and a character which may be the abbreviation
469 dlg_char_to_button(int ch, const char **labels) in dlg_char_to_button() argument
473 if (labels != 0) { in dlg_char_to_button()
474 int *hotkeys = get_hotkeys(labels); in dlg_char_to_button()
481 for (j = 0; labels[j] != 0; ++j) { in dlg_char_to_button()
552 * Return a list of button labels.
566 static const char *labels[3]; in dlg_exit_label() local
570 labels[n++] = my_exit_label(); in dlg_exit_label()
572 labels[n++] = my_help_label(); in dlg_exit_label()
574 labels[n++] = my_exit_label(); in dlg_exit_label()
575 labels[n] = 0; in dlg_exit_label()
577 result = labels; in dlg_exit_label()
583 * Map the given button index for dlg_exit_label() into our exit-code.
602 finish_ok_label(const char **labels, int n) in finish_ok_label() argument
605 labels[n++] = my_ok_label(); in finish_ok_label()
607 dlg_trace_msg("# ignore --nook, since at least one button is needed\n"); in finish_ok_label()
610 labels[n] = NULL; in finish_ok_label()
611 return labels; in finish_ok_label()
615 * Return a list of button labels for the OK (no Cancel) group, used in msgbox
621 static const char *labels[4]; in dlg_ok_label() local
625 labels[n++] = my_ok_label(); in dlg_ok_label()
627 labels[n++] = my_extra_label(); in dlg_ok_label()
629 labels[n++] = my_help_label(); in dlg_ok_label()
631 return finish_ok_label(labels, n); in dlg_ok_label()
635 * Return a list of button labels for the OK/Cancel group, used in most widgets
641 static const char *labels[5]; in dlg_ok_labels() local
645 labels[n++] = my_ok_label(); in dlg_ok_labels()
647 labels[n++] = my_extra_label(); in dlg_ok_labels()
649 labels[n++] = my_cancel_label(); in dlg_ok_labels()
651 labels[n++] = my_help_label(); in dlg_ok_labels()
653 return finish_ok_label(labels, n); in dlg_ok_labels()
657 * Map the given button index for dlg_ok_labels() into our exit-code
701 int result = current - 1; in dlg_prev_ok_buttonindex()
712 * Find the button-index for the "OK" or "Cancel" button, according to
713 * whether --defaultno is given. If --nocancel was given, we always return
714 * the index for the first button (usually "OK" unless --nook was used).
730 * Find the button-index for a button named with --default-button. If the
732 * the index of the first button (usually "OK" unless --nook was used).
754 * Return a list of buttons for Yes/No labels.
764 static const char *labels[4]; in dlg_yes_labels() local
767 labels[n++] = my_yes_label(); in dlg_yes_labels()
768 labels[n++] = my_no_label(); in dlg_yes_labels()
770 labels[n++] = my_help_label(); in dlg_yes_labels()
771 labels[n] = 0; in dlg_yes_labels()
773 result = labels; in dlg_yes_labels()
780 * Map the given button index for dlg_yes_labels() into our exit-code.
801 * Return the next index in labels[];
804 dlg_next_button(const char **labels, int button) in dlg_next_button() argument
806 if (button < -1) in dlg_next_button()
807 button = -1; in dlg_next_button()
809 if (labels[button + 1] != 0) { in dlg_next_button()
818 * Return the previous index in labels[];
821 dlg_prev_button(const char **labels, int button) in dlg_prev_button() argument
824 --button; in dlg_prev_button()
826 if (button < -1) in dlg_prev_button()
827 button = -1; in dlg_prev_button()
829 while (labels[button + 1] != 0) in dlg_prev_button()