From e4dce8f6e2bb7e79d5e738bfe6d644af44964579 Mon Sep 17 00:00:00 2001 From: Keith Winstein Date: Mon, 31 Jan 2011 05:35:12 -0500 Subject: [PATCH] Now passes first vttest test (implemented RI and NEL) --- terminalframebuffer.cpp | 20 +++++++++++++++----- terminalfunctions.cpp | 14 ++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/terminalframebuffer.cpp b/terminalframebuffer.cpp index 82467ed..e9e7193 100644 --- a/terminalframebuffer.cpp +++ b/terminalframebuffer.cpp @@ -66,12 +66,20 @@ Framebuffer::Framebuffer( int s_width, int s_height ) void Framebuffer::scroll( int N ) { - assert( N >= 0 ); + if ( N >= 0 ) { + for ( int i = 0; i < N; i++ ) { + rows.pop_front(); + rows.push_back( Row( ds.get_width() ) ); + ds.move_row( -1, true ); + } + } else { + N = -N; - for ( int i = 0; i < N; i++ ) { - rows.pop_front(); - rows.push_back( Row( ds.get_width() ) ); - ds.move_row( -1, true ); + for ( int i = 0; i < N; i++ ) { + rows.pop_back(); + rows.push_front( Row( ds.get_width() ) ); + ds.move_row( 1, true ); + } } } @@ -129,6 +137,8 @@ void Framebuffer::move_rows_autoscroll( int rows ) { if ( ds.get_cursor_row() + rows >= ds.get_height() ) { scroll( ds.get_height() - ds.get_cursor_row() - rows + 1 ); + } else if ( ds.get_cursor_row() + rows < 0 ) { + scroll( ds.get_cursor_row() + rows ); } ds.move_row( rows, true ); diff --git a/terminalfunctions.cpp b/terminalfunctions.cpp index a7abec9..6e5b3a2 100644 --- a/terminalfunctions.cpp +++ b/terminalfunctions.cpp @@ -127,3 +127,17 @@ void Ctrl_BS( Framebuffer *fb, Dispatcher *dispatch __attribute((unused)) ) static Function func_Ctrl_BS( CONTROL, "\x08", Ctrl_BS ); +void Ctrl_RI( Framebuffer *fb, Dispatcher *dispatch __attribute((unused)) ) +{ + fb->move_rows_autoscroll( -1 ); +} + +static Function func_Ctrl_RI( CONTROL, "\x8D", Ctrl_RI ); + +void Ctrl_NEL( Framebuffer *fb, Dispatcher *dispatch __attribute((unused)) ) +{ + fb->ds.move_col( 0 ); + fb->move_rows_autoscroll( 1 ); +} + +static Function func_Ctrl_NEL( CONTROL, "\x85", Ctrl_NEL );