aboutsummaryrefslogtreecommitdiff
path: root/degesch.c
diff options
context:
space:
mode:
Diffstat (limited to 'degesch.c')
-rw-r--r--degesch.c70
1 files changed, 66 insertions, 4 deletions
diff --git a/degesch.c b/degesch.c
index eb3c27a..e60f1ad 100644
--- a/degesch.c
+++ b/degesch.c
@@ -2220,11 +2220,8 @@ buffer_remove (struct app_context *ctx, struct buffer *buffer)
}
static void
-buffer_activate (struct app_context *ctx, struct buffer *buffer)
+buffer_print_backlog (struct app_context *ctx, struct buffer *buffer)
{
- if (ctx->current_buffer == buffer)
- return;
-
print_status ("%s", buffer->name);
// That is, minus the buffer switch line and the readline prompt
@@ -2238,6 +2235,16 @@ buffer_activate (struct app_context *ctx, struct buffer *buffer)
buffer_line_display (ctx, line, false);
buffer->unseen_messages_count = 0;
+ refresh_prompt (ctx);
+}
+
+static void
+buffer_activate (struct app_context *ctx, struct buffer *buffer)
+{
+ if (ctx->current_buffer == buffer)
+ return;
+
+ buffer_print_backlog (ctx, buffer);
input_switch_buffer (&ctx->input, buffer->input_data);
// Now at last we can switch the pointers
@@ -5365,6 +5372,25 @@ make_completions (struct app_context *ctx, char *line, int start, int end)
return completions;
}
+// --- Common code for user actions --------------------------------------------
+
+static bool
+redraw_screen (struct app_context *ctx)
+{
+ if (!soft_assert (clear_screen != NULL))
+ return false;
+
+ input_hide (&ctx->input);
+
+ terminal_printer_fn printer = get_attribute_printer (stdout);
+ tputs (clear_screen, 1, printer);
+ fflush (stdout);
+ buffer_print_backlog (ctx, ctx->current_buffer);
+
+ input_show (&ctx->input);
+ return true;
+}
+
// --- GNU Readline user actions -----------------------------------------------
#ifdef HAVE_READLINE
@@ -5412,6 +5438,18 @@ on_readline_next_buffer (int count, int key)
}
static int
+on_readline_redraw_screen (int count, int key)
+{
+ (void) count;
+ (void) key;
+
+ struct app_context *ctx = g_ctx;
+ if (!redraw_screen (ctx))
+ input_ding (&ctx->input);
+ return 0;
+}
+
+static int
on_readline_return (int count, int key)
{
(void) count;
@@ -5503,6 +5541,12 @@ app_readline_init (void)
if (key_f6)
rl_bind_keyseq (key_f6, rl_named_function ("next-buffer"));
+ if (clear_screen)
+ {
+ rl_add_defun ("redraw-screen", on_readline_redraw_screen, -1);
+ rl_bind_keyseq ("\\C-l", rl_named_function ("redraw-screen"));
+ }
+
// We need to hide the prompt first
rl_bind_key (RETURN, on_readline_return);
@@ -5565,6 +5609,17 @@ on_editline_next_buffer (EditLine *editline, int key)
}
static unsigned char
+on_editline_redraw_screen (EditLine *editline, int key)
+{
+ (void) editline;
+ (void) key;
+
+ if (!redraw_screen (g_ctx))
+ return CC_ERROR;
+ return CC_NORM;
+}
+
+static unsigned char
on_editline_complete (EditLine *editline, int key)
{
(void) key;
@@ -5676,6 +5731,13 @@ app_editline_init (struct input *self)
if (key_f6)
el_set (self->editline, EL_BIND, key_f6, "next-buffer", NULL);
+ if (clear_screen)
+ {
+ el_set (self->editline, EL_ADDFN, "redraw-screen",
+ "Redraw screen", on_editline_redraw_screen);
+ el_set (self->editline, EL_BIND, "^L", "redraw-screen", NULL);
+ }
+
// Source the user's defaults file
el_source (self->editline, NULL);