diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2019-07-10 12:57:26 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2019-07-10 12:57:26 +0000 |
| commit | 0bc3b29b0fef9c3dc8fd1e54f56438d809e45a91 (patch) | |
| tree | f2a7653f5f5e4a4ff00725609e0bfbaf095839c8 /input.c | |
| parent | input: fix backspace escape sequences (diff) | |
| parent | scrollback: disable debug logging (diff) | |
Merge branch 'scrollback'
Diffstat (limited to 'input.c')
| -rw-r--r-- | input.c | 51 |
1 files changed, 51 insertions, 0 deletions
@@ -7,6 +7,8 @@ #include <locale.h> #include <sys/mman.h> +#include <linux/input-event-codes.h> + #include <xkbcommon/xkbcommon.h> #include <xkbcommon/xkbcommon-keysyms.h> #include <xkbcommon/xkbcommon-compose.h> @@ -17,6 +19,7 @@ #include "terminal.h" #include "render.h" #include "keymap.h" +#include "commands.h" static void keyboard_keymap(void *data, struct wl_keyboard *wl_keyboard, @@ -140,6 +143,18 @@ keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial, keymap_mods |= term->kbd.alt ? MOD_ALT : MOD_NONE; keymap_mods |= term->kbd.ctrl ? MOD_CTRL : MOD_NONE; + if (effective_mods == shift) { + if (sym == XKB_KEY_Page_Up) { + cmd_scrollback_up(term, term->rows); + found_map = true; + } + + else if (sym == XKB_KEY_Page_Down) { + cmd_scrollback_down(term, term->rows); + found_map = true; + } + } + for (size_t i = 0; i < sizeof(key_map) / sizeof(key_map[0]) && !found_map; i++) { const struct key_map *k = &key_map[i]; if (k->sym != sym) @@ -160,6 +175,13 @@ keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial, write(term->ptmx, info->seq, strlen(info->seq)); found_map = true; + + if (term->grid->view != term->grid->offset) { + term->grid->view = term->grid->offset; + /* TODO: damage view */ + term_damage_all(term); + } + break; } } @@ -182,6 +204,13 @@ keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial, write(term->ptmx, "\x1b", 1); write(term->ptmx, buf, count); + + if (term->grid->view != term->grid->offset) { + term->grid->view = term->grid->offset; + /* TODO: damage view */ + term_damage_all(term); + } + } } @@ -315,6 +344,28 @@ static void wl_pointer_axis(void *data, struct wl_pointer *wl_pointer, uint32_t time, uint32_t axis, wl_fixed_t value) { + struct terminal *term = data; + + /* TODO: generate button event for BTN_FORWARD/BTN_BACK? */ + + if (axis != WL_POINTER_AXIS_VERTICAL_SCROLL) + return; + + int amount = wl_fixed_to_int(value); + + if (amount < 0) { + for (int i = 0; i < -amount; i++) { + term_mouse_down(term, BTN_BACK, term->mouse.row, term->mouse.col, + term->kbd.shift, term->kbd.alt, term->kbd.ctrl); + } + cmd_scrollback_up(term, -amount); + } else { + for (int i = 0; i < amount; i++) { + term_mouse_down(term, BTN_FORWARD, term->mouse.row, term->mouse.col, + term->kbd.shift, term->kbd.alt, term->kbd.ctrl); + } + cmd_scrollback_down(term, amount); + } } static void |
