dvtm

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

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

Replace bogus madtty_keypress_sequence with madtty_write

We need to pass some escape sequences to the underlying app
so simply removing keypress_sequence without a replacement
breaks things.

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

Diffstat:
dvtm.c | 5++---
madtty.c | 36++++++++++++------------------------
madtty.h | 2+-
3 files changed, 15 insertions(+), 28 deletions(-)

diff --git a/dvtm.c b/dvtm.c @@ -1001,16 +1001,15 @@ keypress(int code) { 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++) + for (int t; len < sizeof(buf) && (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)) { if (code == '\e') - madtty_keypress_sequence(c->term, buf); + madtty_write(c->term, buf, len); else madtty_keypress(c->term, code); } diff --git a/madtty.c b/madtty.c @@ -1401,23 +1401,27 @@ int madtty_getpty(madtty_t *t) return t->pty; } -static void term_write(madtty_t *t, const char *buf, int len) +int madtty_write(madtty_t *t, const char *buf, int len) { + int ret = len; + while (len > 0) { int res = write(t->pty, buf, len); if (res < 0 && errno != EAGAIN && errno != EINTR) - return; + return -1; buf += res; len -= res; } + + return ret; } static void send_curs(madtty_t *t) { char keyseq[16]; sprintf(keyseq, "\e[%d;%dR", (int)(t->curs_row - t->lines), t->curs_col); - term_write(t, keyseq, strlen(keyseq)); + madtty_write(t, keyseq, strlen(keyseq)); } void madtty_keypress(madtty_t *t, int keycode) @@ -1433,30 +1437,14 @@ void madtty_keypress(madtty_t *t, int keycode) case KEY_RIGHT: case KEY_LEFT: { char keyseq[3] = { '\e', (t->curskeymode ? 'O' : '['), keytable[keycode][0] }; - term_write(t, keyseq, sizeof keyseq); + madtty_write(t, keyseq, sizeof keyseq); break; } default: - term_write(t, keytable[keycode], strlen(keytable[keycode])); + madtty_write(t, keytable[keycode], strlen(keytable[keycode])); } } else - 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); + madtty_write(t, &c, 1); } void madtty_mouse(madtty_t *t, int x, int y, mmask_t mask) @@ -1486,13 +1474,13 @@ void madtty_mouse(madtty_t *t, int x, int y, mmask_t mask) seq[4] = 32 + x; seq[5] = 32 + y; - term_write(t, seq, sizeof seq); + madtty_write(t, seq, sizeof seq); if (mask & (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED)) { /* send a button release event */ button = 3; seq[3] = 32 + button + state; - term_write(t, seq, sizeof seq); + madtty_write(t, seq, sizeof seq); } } diff --git a/madtty.h b/madtty.h @@ -68,7 +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); +int madtty_write(madtty_t *t, const char *buf, int len); 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);