4. support for "ESC 6 n", get cursor position, which calls a new function, send_curs()
On 03/25/2011 10:25 PM, Ross Mohn wrote: > I'm going to post a series of 6 patches for dvtm over the next several > minutes. They all apply to the current HEAD of the dvtm git repository > (committed 2011-01-07). I think I've teased them all apart pretty well > so that each one is separate and complete. > > 1. support for compiling under AIX > 2. support the 8 basic highlighted colors, plus a couple of color_hash fixes > 3. fix a scrolling issue and add in "ESC #" to call interpret_esc_SCS() > 4. support for "ESC 6 n", get cursor position, which calls a new > function, send_curs() > 5. support colorrules[] to match strings against window titles, > applycolorrules(), and call madtty_set_dflt_colors() > 6. support to backfill text from the buffer when a windows is resized > with more rows > > Comments, testing, and bugfixes sincerely welcome! > > Cheers! -Ross > >
Index: madtty.c =================================================================== --- madtty.c (.../vendor/current) (revision 47) +++ madtty.c (.../trunk) (revision 47) @@ -179,17 +179,19 @@ }; 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) { @@ -729,6 +742,9 @@ case 'u': /* restore cursor location */ restore_curs(t); break; + case 'n': + if (param_count == 1 && csiparam[0] == 6) /* query cursor location */ + send_curs(t); default: break; } @@ -1361,6 +1407,13 @@ } } +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;