From bc5caae26b8249dffd5ea2e2085eca20edf9c9f9 Mon Sep 17 00:00:00 2001 From: Keith Winstein Date: Mon, 31 Jan 2011 20:26:32 -0500 Subject: [PATCH] Fix tabbing bug --- terminalframebuffer.cpp | 13 +++++++++++++ terminalframebuffer.hpp | 2 ++ terminalfunctions.cpp | 10 +++++++--- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/terminalframebuffer.cpp b/terminalframebuffer.cpp index 1f79ab1..f93108d 100644 --- a/terminalframebuffer.cpp +++ b/terminalframebuffer.cpp @@ -236,3 +236,16 @@ int DrawState::limit_bottom( void ) { return origin_mode ? scrolling_region_bottom_row : height - 1; } + +std::vector DrawState::get_tabs( void ) +{ + std::vector ret; + + for ( int i = 0; i < width; i++ ) { + if ( tabs[ i ] ) { + ret.push_back( i ); + } + } + + return ret; +} diff --git a/terminalframebuffer.hpp b/terminalframebuffer.hpp index 3190e7d..845a447 100644 --- a/terminalframebuffer.hpp +++ b/terminalframebuffer.hpp @@ -65,6 +65,8 @@ namespace Terminal { void clear_tab( int col ); int get_next_tab( void ); + std::vector get_tabs( void ); + void set_scrolling_region( int top, int bottom ); int limit_top( void ); diff --git a/terminalfunctions.cpp b/terminalfunctions.cpp index 9ccafa4..0952bea 100644 --- a/terminalfunctions.cpp +++ b/terminalfunctions.cpp @@ -163,12 +163,16 @@ static Function func_Ctrl_HTS( CONTROL, "\x88", Ctrl_HTS ); void CSI_TBC( Framebuffer *fb, Dispatcher *dispatch ) { - if ( dispatch->getparam( 0, 0 ) == 3 ) { /* clear all tab stops */ + int param = dispatch->getparam( 0, 0 ); + switch ( param ) { + case 0: /* clear this tab stop */ + fb->ds.clear_tab( fb->ds.get_cursor_col() ); + break; + case 3: /* clear all tab stops */ for ( int x = 0; x < fb->ds.get_width(); x++ ) { fb->ds.clear_tab( x ); } - } else { - fb->ds.clear_tab( fb->ds.get_cursor_col() ); + break; } }