summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-12-31 03:55:32 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2015-12-31 05:07:28 +0100
commit74bed4bc02ef08ef3cb71f8179f9f398f91b2a02 (patch)
treefb830fdd75ba065cc3a8948692aaa060b5c7a86d
parent8f229f41e1fe580ed30cd47ebb7af5ce5f225532 (diff)
downloadxK-74bed4bc02ef08ef3cb71f8179f9f398f91b2a02.tar.gz
xK-74bed4bc02ef08ef3cb71f8179f9f398f91b2a02.tar.xz
xK-74bed4bc02ef08ef3cb71f8179f9f398f91b2a02.zip
degesch: Alt-Tab switch to the last buffer
-rw-r--r--NEWS2
-rw-r--r--degesch.c31
2 files changed, 33 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 8c4fb3b..8c01cbc 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,8 @@
* 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: fixed decoding of text formatting
diff --git a/degesch.c b/degesch.c
index 5dce5a9..b7adad7 100644
--- a/degesch.c
+++ b/degesch.c
@@ -10655,6 +10655,7 @@ bind_common_keys (struct app_context *ctx)
for (int i = 0; i <= 9; i++)
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, 'h', "display-full-log");
input_bind_meta (self, 'e', "edit-input");
@@ -10708,6 +10709,20 @@ on_readline_next_buffer (int count, int key)
}
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
on_readline_display_backlog (int count, int key)
{
(void) count;
@@ -10843,6 +10858,7 @@ app_readline_init (void)
rl_add_defun ("previous-buffer", on_readline_previous_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 ("switch-buffer", on_readline_switch_buffer, -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 ("edit-input", on_readline_edit_input, -1);
@@ -10907,6 +10923,20 @@ on_editline_next_buffer (EditLine *editline, int key)
}
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
on_editline_display_backlog (EditLine *editline, int key)
{
(void) editline;
@@ -11062,6 +11092,7 @@ app_editline_init (struct input *self)
{ "goto-buffer", "Go to buffer", on_editline_goto_buffer },
{ "previous-buffer", "Previous buffer", on_editline_previous_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-full-log", "Show full log", on_editline_display_full_log },
{ "edit-input", "Edit input", on_editline_edit_input },