dvtm

dynamic virtual terminal manager - with my changes
git clone https://pi.duncano.de/git/dvtm.git
Log | Files | Refs | README | LICENSE

commit 73a7d2101299f7658464f5ad43010f429043417e
parent 3e28e21cff8444bf89f24aa700a8600c1bdbc086
Author: Marc Andre Tanner <mat@brain-dump.org>
Date:   Thu, 26 May 2011 20:20:40 +0200

Revert "madtty: remove madtty_keypress_sequence"

This reverts commit f17d1cfb4e06e0635accf829ecfcd39569a3fb6d.

Signed-off-by: Marc Andre Tanner <mat@brain-dump.org>

Diffstat:
dvtm.c | 19+++++++++++++++++--
madtty.c | 16++++++++++++++++
madtty.h | 1+
3 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/dvtm.c b/dvtm.c @@ -995,10 +995,25 @@ parse_args(int argc, char *argv[]) { void keypress(int code) { Client *c; + unsigned int len = 1; + char buf[8] = { '\e' }; + + if (code == '\e') { + /* pass characters following escape to the underlying app */ + nodelay(stdscr, TRUE); + for (int t; len < sizeof(buf) - 1 && (t = getch()) != ERR; len++) + buf[len] = t; + buf[len] = '\0'; + nodelay(stdscr, FALSE); + } for (c = runinall ? clients : sel; c; c = c->next) { - if (!c->minimized || isarrange(fullscreen)) - madtty_keypress(c->term, code); + if (!c->minimized || isarrange(fullscreen)) { + if (code == '\e') + madtty_keypress_sequence(c->term, buf); + else + madtty_keypress(c->term, code); + } if (!runinall) break; } diff --git a/madtty.c b/madtty.c @@ -1443,6 +1443,22 @@ void madtty_keypress(madtty_t *t, int keycode) term_write(t, &c, 1); } +void madtty_keypress_sequence(madtty_t *t, const char *seq) +{ + int key, len = strlen(seq); + /* check for function keys from putty, this makes the + * keypad work but it's probably not the right way to + * do it. the sequence we look for is \eO + a character + * representing the number. + */ + if (len == 3 && seq[0] == '\e' && seq[1] == 'O') { + key = seq[2] - 64; + if (key >= '0' && key <= '9') + madtty_keypress(t, key); + } else + term_write(t, seq, len); +} + void madtty_mouse(madtty_t *t, int x, int y, mmask_t mask) { char seq[6] = { '\e', '[', 'M' }, state = 0, button = 0; diff --git a/madtty.h b/madtty.h @@ -68,6 +68,7 @@ unsigned madtty_cursor(madtty_t *t); int madtty_process(madtty_t *); void madtty_keypress(madtty_t *, int keycode); +void madtty_keypress_sequence(madtty_t *, const char *seq); void madtty_mouse(madtty_t *t, int x, int y, mmask_t mask); void madtty_dirty(madtty_t *t); void madtty_draw(madtty_t *, WINDOW *win, int startrow, int startcol);