mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 12:32:40 +03:00
Switch windows using keyboard.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
f1839a9a80
commit
3b72e4275b
@ -314,6 +314,9 @@ static name_keymap_t command_names[] = {
|
||||
{"ExecuteScript", CK_PipeBlock (0)},
|
||||
{"WindowMove", CK_WindowMove},
|
||||
{"WindowResize", CK_WindowResize},
|
||||
{"WindowList", CK_WindowList},
|
||||
{"WindowNext", CK_WindowNext},
|
||||
{"WindowPrev", CK_WindowPrev},
|
||||
#endif /* USE_INTERNAL_EDIT */
|
||||
|
||||
/* viewer */
|
||||
|
@ -282,6 +282,9 @@ enum
|
||||
/* window commands */
|
||||
CK_WindowMove,
|
||||
CK_WindowResize,
|
||||
CK_WindowList,
|
||||
CK_WindowNext,
|
||||
CK_WindowPrev,
|
||||
/* misc commands */
|
||||
CK_InsertOverwrite,
|
||||
CK_ParagraphFormat,
|
||||
|
@ -340,6 +340,9 @@ OptionsSaveMode =
|
||||
LearnKeys =
|
||||
WindowMove =
|
||||
WindowResize =
|
||||
WindowList =
|
||||
WindowNext =
|
||||
WindowPrev =
|
||||
ExtendedKeyMap =
|
||||
|
||||
[viewer]
|
||||
|
@ -340,6 +340,9 @@ OptionsSaveMode =
|
||||
LearnKeys =
|
||||
WindowMove =
|
||||
WindowResize =
|
||||
WindowList =
|
||||
WindowNext =
|
||||
WindowPrev =
|
||||
ExtendedKeyMap = ctrl-x
|
||||
|
||||
[editor:xmap]
|
||||
|
@ -3453,13 +3453,6 @@ edit_execute_key_command (WEdit * edit, unsigned long command, int char_for_inse
|
||||
void
|
||||
edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
|
||||
{
|
||||
/* at first, handle CK_Quit command */
|
||||
if (command == CK_Quit)
|
||||
{
|
||||
dlg_stop (((Widget *) edit)->owner);
|
||||
return;
|
||||
}
|
||||
|
||||
/* handle window state */
|
||||
if (edit_handle_move_resize (edit, command))
|
||||
return;
|
||||
|
@ -216,6 +216,10 @@ create_window_menu (void)
|
||||
|
||||
entries = g_list_prepend (entries, menu_entry_create (_("&Move"), CK_WindowMove));
|
||||
entries = g_list_prepend (entries, menu_entry_create (_("&Resize"), CK_WindowResize));
|
||||
entries = g_list_prepend (entries, menu_separator_create ());
|
||||
entries = g_list_prepend (entries, menu_entry_create (_("&Next"), CK_WindowNext));
|
||||
entries = g_list_prepend (entries, menu_entry_create (_("&Previous"), CK_WindowPrev));
|
||||
entries = g_list_prepend (entries, menu_entry_create (_("&List..."), CK_WindowList));
|
||||
|
||||
return g_list_reverse (entries);
|
||||
}
|
||||
|
@ -240,6 +240,64 @@ edit_window_resize (WEdit * edit, unsigned long command)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static unsigned char
|
||||
get_hotkey (int n)
|
||||
{
|
||||
return (n <= 9) ? '0' + n : 'a' + n - 10;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
edit_window_list (const Dlg_head * h)
|
||||
{
|
||||
const size_t offset = 2; /* skip menu and buttonbar */
|
||||
const size_t dlg_num = g_list_length (h->widgets) - offset;
|
||||
int lines, cols;
|
||||
Listbox *listbox;
|
||||
GList *w;
|
||||
int i = 0;
|
||||
int rv;
|
||||
|
||||
lines = min ((size_t) (LINES * 2 / 3), dlg_num);
|
||||
cols = COLS * 2 / 3;
|
||||
|
||||
listbox = create_listbox_window (lines, cols, _("Open files"), "[Open files]");
|
||||
|
||||
for (w = h->widgets; w != NULL; w = g_list_next (w))
|
||||
if (edit_widget_is_editor ((Widget *) w->data))
|
||||
{
|
||||
WEdit *e = (WEdit *) w->data;
|
||||
char *fname;
|
||||
|
||||
if (e->filename_vpath == NULL)
|
||||
fname = g_strdup_printf ("%c [%s]", e->modified ? '*' : ' ', _("NoName"));
|
||||
else
|
||||
{
|
||||
char *fname2;
|
||||
|
||||
fname2 = vfs_path_to_str (e->filename_vpath);
|
||||
fname = g_strdup_printf ("%c%s", e->modified ? '*' : ' ', fname2);
|
||||
g_free (fname2);
|
||||
}
|
||||
|
||||
listbox_add_item (listbox->list, LISTBOX_APPEND_AT_END, get_hotkey (i++),
|
||||
str_term_trim (fname, listbox->list->widget.cols - 2), NULL);
|
||||
g_free (fname);
|
||||
}
|
||||
|
||||
rv = g_list_position (h->widgets, h->current) - offset;
|
||||
listbox_select_entry (listbox->list, rv);
|
||||
rv = run_listbox (listbox);
|
||||
if (rv >= 0)
|
||||
{
|
||||
w = g_list_nth (h->widgets, rv + offset);
|
||||
dlg_set_top_widget (w->data);
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static char *
|
||||
edit_get_shortcut (unsigned long command)
|
||||
{
|
||||
@ -534,6 +592,17 @@ edit_dialog_command_execute (Dlg_head * h, unsigned long command)
|
||||
if (edit_widget_is_editor ((Widget *) h->current->data))
|
||||
edit_handle_move_resize ((WEdit *) h->current->data, command);
|
||||
break;
|
||||
case CK_WindowList:
|
||||
edit_window_list (h);
|
||||
break;
|
||||
case CK_WindowNext:
|
||||
dlg_one_down (h);
|
||||
dlg_set_top_widget (h->current->data);
|
||||
break;
|
||||
case CK_WindowPrev:
|
||||
dlg_one_up (h);
|
||||
dlg_set_top_widget (h->current->data);
|
||||
break;
|
||||
case CK_OptionsSaveMode:
|
||||
edit_save_mode_cmd ();
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user