degesch: Alt-Tab switch to the last buffer

This commit is contained in:
Přemysl Eric Janouch 2015-12-31 03:55:32 +01:00
parent 8f229f41e1
commit 74bed4bc02
2 changed files with 33 additions and 0 deletions

2
NEWS
View File

@ -13,6 +13,8 @@
* degesch: added capability to edit the input line using VISUAL/EDITOR * degesch: added capability to edit the input line using VISUAL/EDITOR
* degesch: added Meta-Tab to switch to the last used buffer
* degesch: correctly respond to stopping and resuming (SIGTSTP) * degesch: correctly respond to stopping and resuming (SIGTSTP)
* degesch: fixed decoding of text formatting * degesch: fixed decoding of text formatting

View File

@ -10655,6 +10655,7 @@ bind_common_keys (struct app_context *ctx)
for (int i = 0; i <= 9; i++) for (int i = 0; i <= 9; i++)
input_bind_meta (self, '0' + i, "goto-buffer"); input_bind_meta (self, '0' + i, "goto-buffer");
input_bind_meta (self, '\t', "switch-buffer");
input_bind_meta (self, 'm', "insert-attribute"); input_bind_meta (self, 'm', "insert-attribute");
input_bind_meta (self, 'h', "display-full-log"); input_bind_meta (self, 'h', "display-full-log");
input_bind_meta (self, 'e', "edit-input"); input_bind_meta (self, 'e', "edit-input");
@ -10707,6 +10708,20 @@ on_readline_next_buffer (int count, int key)
return 0; return 0;
} }
static int
on_readline_switch_buffer (int count, int key)
{
(void) count;
(void) key;
struct app_context *ctx = g_ctx;
if (ctx->last_buffer)
buffer_activate (ctx, ctx->last_buffer);
else
input_ding (&ctx->input);
return 0;
}
static int static int
on_readline_display_backlog (int count, int key) on_readline_display_backlog (int count, int key)
{ {
@ -10843,6 +10858,7 @@ app_readline_init (void)
rl_add_defun ("previous-buffer", on_readline_previous_buffer, -1); rl_add_defun ("previous-buffer", on_readline_previous_buffer, -1);
rl_add_defun ("next-buffer", on_readline_next_buffer, -1); rl_add_defun ("next-buffer", on_readline_next_buffer, -1);
rl_add_defun ("goto-buffer", on_readline_goto_buffer, -1); rl_add_defun ("goto-buffer", on_readline_goto_buffer, -1);
rl_add_defun ("switch-buffer", on_readline_switch_buffer, -1);
rl_add_defun ("display-backlog", on_readline_display_backlog, -1); rl_add_defun ("display-backlog", on_readline_display_backlog, -1);
rl_add_defun ("display-full-log", on_readline_display_full_log, -1); rl_add_defun ("display-full-log", on_readline_display_full_log, -1);
rl_add_defun ("edit-input", on_readline_edit_input, -1); rl_add_defun ("edit-input", on_readline_edit_input, -1);
@ -10906,6 +10922,20 @@ on_editline_next_buffer (EditLine *editline, int key)
return CC_NORM; return CC_NORM;
} }
static unsigned char
on_editline_switch_buffer (EditLine *editline, int key)
{
(void) editline;
(void) key;
struct app_context *ctx = g_ctx;
if (ctx->last_buffer)
buffer_activate (ctx, ctx->last_buffer);
else
input_ding (&ctx->input);
return CC_NORM;
}
static unsigned char static unsigned char
on_editline_display_backlog (EditLine *editline, int key) on_editline_display_backlog (EditLine *editline, int key)
{ {
@ -11062,6 +11092,7 @@ app_editline_init (struct input *self)
{ "goto-buffer", "Go to buffer", on_editline_goto_buffer }, { "goto-buffer", "Go to buffer", on_editline_goto_buffer },
{ "previous-buffer", "Previous buffer", on_editline_previous_buffer }, { "previous-buffer", "Previous buffer", on_editline_previous_buffer },
{ "next-buffer", "Next buffer", on_editline_next_buffer }, { "next-buffer", "Next buffer", on_editline_next_buffer },
{ "switch-buffer", "Switch buffer", on_editline_switch_buffer },
{ "display-backlog", "Show backlog", on_editline_display_backlog }, { "display-backlog", "Show backlog", on_editline_display_backlog },
{ "display-full-log", "Show full log", on_editline_display_full_log }, { "display-full-log", "Show full log", on_editline_display_full_log },
{ "edit-input", "Edit input", on_editline_edit_input }, { "edit-input", "Edit input", on_editline_edit_input },