dvtm

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

commit dfa33e38c2764bacd7579aad3597c80c5b0b3cbb
parent 274281aa33702ea2b902d7d91575d15ab4333384
Author: Ross Mohn <rpmohn@waxandwane.org>
Date:   Mon, 18 Apr 2011 13:17:41 +0200

madtty: support for "ESC 6 n", get cursor position

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

Diffstat:
madtty.c | 12++++++++++++
1 file changed, 12 insertions(+), 0 deletions(-)

diff --git a/madtty.c b/madtty.c @@ -189,6 +189,7 @@ static char const * const keytable[KEY_MAX+1] = { }; static void madtty_process_nonprinting(madtty_t *t, wchar_t wc); +static void send_curs(madtty_t *t); __attribute__((const)) static uint16_t build_attrs(unsigned curattrs) { @@ -736,6 +737,10 @@ static void es_interpret_csi(madtty_t *t) case 'u': /* restore cursor location */ restore_curs(t); break; + case 'n': /* query cursor location */ + if (param_count == 1 && csiparam[0] == 6) + send_curs(t); + break; default: break; } @@ -1371,6 +1376,13 @@ static void term_write(madtty_t *t, const char *buf, int len) } } +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)); +} + void madtty_keypress(madtty_t *t, int keycode) { char c = (char)keycode;