static cb_ret_t listbox_execute_cmd (WListbox * l, long command) { cb_ret_t ret = MSG_HANDLED; Widget *w = WIDGET (l); if (l->list == NULL || g_queue_is_empty (l->list)) return MSG_NOT_HANDLED; switch (command) { case CK_Up: listbox_back (l, TRUE); break; case CK_Down: listbox_fwd (l, TRUE); break; case CK_Top: listbox_select_first (l); break; case CK_Bottom: listbox_select_last (l); break; case CK_PageUp: listbox_back_n (l, w->lines - 1); break; case CK_PageDown: listbox_fwd_n (l, w->lines - 1); break; case CK_Delete: if (l->deletable) { gboolean is_last, is_more; int length; length = g_queue_get_length (l->list); is_last = (l->pos + 1 >= length); is_more = (l->top + w->lines >= length); listbox_remove_current (l); if ((l->top > 0) && (is_last || is_more)) l->top--; } break; case CK_Clear: if (l->deletable && mc_global.widget.confirm_history_cleanup /* TRANSLATORS: no need to translate 'DialogTitle', it's just a context prefix */ && (query_dialog (Q_ ("DialogTitle|History cleanup"), _("Do you want clean this history?"), D_ERROR, 2, _("&Yes"), _("&No")) == 0)) listbox_remove_list (l); break; default: ret = MSG_NOT_HANDLED; } return ret; }
char *listmode_edit (char *oldlistformat) { char *newformat = NULL; char *s; s = strdup (oldlistformat); init_listmode (s); free (s); while (newformat == NULL) { /* display file info */ attrset (SELECTED_COLOR); run_dlg (listmode_dlg); switch (listmode_dlg->ret_value) { case B_CANCEL: newformat = strdup (oldlistformat); break; case B_ADD: s = select_new_item (); if (s) listbox_add_item (l_listmode, 0, 0, s, NULL); break; case B_REMOVE: listbox_remove_current (l_listmode, 0); break; case B_ENTER: newformat = collect_new_format (); break; } } listmode_done (); return newformat; }
static int bremove_cback (int action) { listbox_remove_current (l_listmode); return 0; }