From 405cd3a703a745813485ecd315c58ba47ece3613 Mon Sep 17 00:00:00 2001 From: Keith Winstein Date: Mon, 31 Jan 2011 23:42:21 -0500 Subject: [PATCH] Device status report (e.g. cursor position) --- terminalfunctions.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/terminalfunctions.cpp b/terminalfunctions.cpp index 43d350c..7c23b7b 100644 --- a/terminalfunctions.cpp +++ b/terminalfunctions.cpp @@ -288,3 +288,24 @@ void Esc_DECRC( Framebuffer *fb, Dispatcher *dispatch __attribute((unused)) ) static Function func_Esc_DECSC( ESCAPE, "7", Esc_DECSC ); static Function func_Esc_DECRC( ESCAPE, "8", Esc_DECRC ); + +/* device status report -- e.g., cursor position (used by resize) */ +void CSI_DSR( Framebuffer *fb, Dispatcher *dispatch ) +{ + int param = dispatch->getparam( 0, 0 ); + + switch ( param ) { + case 5: /* device status report requested */ + dispatch->terminal_to_host.append( "\033[0n" ); + break; + case 6: /* report of active position requested */ + char cpr[ 32 ]; + snprintf( cpr, 32, "\033[%d;%dR", + fb->ds.get_cursor_row() + 1, + fb->ds.get_cursor_col() + 1 ); + dispatch->terminal_to_host.append( cpr ); + break; + } +} + +static Function func_CSI_DSR( CSI, "n", CSI_DSR );