From e5e81a0b4c0bc5cb59c5fab78e3a532a84b2a5d3 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Mon, 1 Oct 2012 12:24:03 +0200 Subject: [PATCH] wlt: add scrollback-buffer grabs This copies the grabs from kmscon over to wlterm. It is now possible to scroll up and down in the scrollback-buffer if you manually increase the buffer size. Signed-off-by: David Herrmann --- src/wlt_main.c | 34 ++++++++++++++++++++++++++++++++++ src/wlt_main.h | 10 ++++++++++ src/wlt_terminal.c | 27 +++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) diff --git a/src/wlt_main.c b/src/wlt_main.c index afe9f05..f046bac 100644 --- a/src/wlt_main.c +++ b/src/wlt_main.c @@ -37,6 +37,7 @@ #include "conf.h" #include "eloop.h" #include "log.h" +#include "shl_misc.h" #include "text.h" #include "wlt_main.h" #include "wlt_terminal.h" @@ -206,6 +207,15 @@ static void print_help() "\t --debug [off] Enable debug mode\n" "\t --silent [off] Suppress notices and warnings\n" "\n" + "Keyboard Shortcuts and Grabs:\n" + "\t --grab-scroll-up [Up]\n" + "\t Shortcut to scroll up\n" + "\t --grab-scroll-down [Down]\n" + "\t Shortcut to scroll down\n" + "\t --grab-page-up [Prior]\n" + "\t Shortcut to scroll page up\n" + "\t --grab-page-down [Next]\n" + "\t Shortcut to scroll page down\n" "Font Options:\n" "\t --font-engine [pango]\n" "\t Font engine\n" @@ -248,11 +258,35 @@ static int aftercheck_help(struct conf_option *opt, int argc, char **argv, return 0; } +static struct conf_grab def_grab_scroll_up = { + .mods = SHL_SHIFT_MASK, + .keysym = XKB_KEY_Up, +}; + +static struct conf_grab def_grab_scroll_down = { + .mods = SHL_SHIFT_MASK, + .keysym = XKB_KEY_Down, +}; + +static struct conf_grab def_grab_page_up = { + .mods = SHL_SHIFT_MASK, + .keysym = XKB_KEY_Prior, +}; + +static struct conf_grab def_grab_page_down = { + .mods = SHL_SHIFT_MASK, + .keysym = XKB_KEY_Next, +}; + struct conf_option options[] = { CONF_OPTION_BOOL('h', "help", aftercheck_help, &wlt_conf.help, false), CONF_OPTION_BOOL('v', "verbose", NULL, &wlt_conf.verbose, false), CONF_OPTION_BOOL(0, "debug", aftercheck_debug, &wlt_conf.debug, false), CONF_OPTION_BOOL(0, "silent", NULL, &wlt_conf.silent, false), + CONF_OPTION_GRAB(0, "grab-scroll-up", NULL, &wlt_conf.grab_scroll_up, &def_grab_scroll_up), + CONF_OPTION_GRAB(0, "grab-scroll-down", NULL, &wlt_conf.grab_scroll_down, &def_grab_scroll_down), + CONF_OPTION_GRAB(0, "grab-page-up", NULL, &wlt_conf.grab_page_up, &def_grab_page_up), + CONF_OPTION_GRAB(0, "grab-page-down", NULL, &wlt_conf.grab_page_down, &def_grab_page_down), CONF_OPTION_STRING(0, "font-engine", NULL, &wlt_conf.font_engine, "pango"), CONF_OPTION_UINT(0, "font-size", NULL, &wlt_conf.font_size, 12), CONF_OPTION_STRING(0, "font-name", NULL, &wlt_conf.font_name, "monospace"), diff --git a/src/wlt_main.h b/src/wlt_main.h index fad8d44..ce14606 100644 --- a/src/wlt_main.h +++ b/src/wlt_main.h @@ -32,6 +32,7 @@ #include #include +#include "conf.h" struct wlt_conf_t { /* show help/usage information */ @@ -45,6 +46,15 @@ struct wlt_conf_t { /* disable notices and warnings */ bool silent; + /* scroll-up grab */ + struct conf_grab *grab_scroll_up; + /* scroll-down grab */ + struct conf_grab *grab_scroll_down; + /* page-up grab */ + struct conf_grab *grab_page_up; + /* page-down grab */ + struct conf_grab *grab_page_down; + /* font engine */ char *font_engine; /* font size */ diff --git a/src/wlt_terminal.c b/src/wlt_terminal.c index 8d38e81..0c02eda 100644 --- a/src/wlt_terminal.c +++ b/src/wlt_terminal.c @@ -33,9 +33,11 @@ #include #include #include +#include "conf.h" #include "eloop.h" #include "log.h" #include "pty.h" +#include "shl_misc.h" #include "text.h" #include "tsm_unicode.h" #include "tsm_screen.h" @@ -260,6 +262,31 @@ static void widget_key(struct wlt_widget *widget, unsigned int mask, ucs4 = xkb_keysym_to_utf32(sym) ? : TSM_VTE_INVALID; + if (SHL_HAS_BITS(mask, wlt_conf.grab_scroll_up->mods) && + sym == wlt_conf.grab_scroll_up->keysym) { + tsm_screen_sb_up(term->scr, 1); + wlt_window_schedule_redraw(term->wnd); + return; + } + if (SHL_HAS_BITS(mask, wlt_conf.grab_scroll_down->mods) && + sym == wlt_conf.grab_scroll_down->keysym) { + tsm_screen_sb_down(term->scr, 1); + wlt_window_schedule_redraw(term->wnd); + return; + } + if (SHL_HAS_BITS(mask, wlt_conf.grab_page_up->mods) && + sym == wlt_conf.grab_page_up->keysym) { + tsm_screen_sb_page_up(term->scr, 1); + wlt_window_schedule_redraw(term->wnd); + return; + } + if (SHL_HAS_BITS(mask, wlt_conf.grab_page_down->mods) && + sym == wlt_conf.grab_page_down->keysym) { + tsm_screen_sb_page_down(term->scr, 1); + wlt_window_schedule_redraw(term->wnd); + return; + } + if (tsm_vte_handle_keyboard(term->vte, sym, mask, ucs4)) wlt_window_schedule_redraw(term->wnd); }