dvtm

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

commit dd9fedb657c7ba2522a8b2066c63eb5ff9baf1f9
parent d9a1ac8295f6387d97bc32c3d893f25892109697
Author: Marc Andre Tanner <mat@brain-dump.org>
Date:   Mon, 25 Feb 2008 16:34:24 +0100

Move terminal output code to a separate function.

Diffstat:
madtty.c | 24+++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/madtty.c b/madtty.c @@ -1032,20 +1032,8 @@ int madtty_getpty(madtty_t *t) return t->pty; } -void madtty_keypress(madtty_t *t, int keycode) +static void term_write(madtty_t *t, const char *buf, int len) { - char c = (char)keycode; - const char *buf; - int len; - - if (keycode >= 0 && keycode < KEY_MAX && keytable[keycode]) { - buf = keytable[keycode]; - len = strlen(keytable[keycode]); - } else { - buf = &c; - len = 1; - } - while (len > 0) { int res = write(t->pty, buf, len); if (res < 0 && errno != EAGAIN && errno != EINTR) @@ -1056,6 +1044,16 @@ void madtty_keypress(madtty_t *t, int keycode) } } +void madtty_keypress(madtty_t *t, int keycode) +{ + char c = (char)keycode; + + if (keycode >= 0 && keycode < KEY_MAX && keytable[keycode]) + term_write(t, keytable[keycode], strlen(keytable[keycode])); + else + term_write(t, &c, 1); +} + void madtty_init_colors(void) { if (COLOR_PAIRS > 64) {