Save and restore cursor
This commit is contained in:
+29
-1
@@ -63,7 +63,7 @@ DrawState::DrawState( int s_width, int s_height )
|
|||||||
cursor_col( 0 ), cursor_row( 0 ),
|
cursor_col( 0 ), cursor_row( 0 ),
|
||||||
combining_char_col( 0 ), combining_char_row( 0 ), tabs( s_width ),
|
combining_char_col( 0 ), combining_char_row( 0 ), tabs( s_width ),
|
||||||
scrolling_region_top_row( 0 ), scrolling_region_bottom_row( height - 1 ),
|
scrolling_region_top_row( 0 ), scrolling_region_bottom_row( height - 1 ),
|
||||||
renditions(),
|
renditions(), save(),
|
||||||
next_print_will_wrap( false ), origin_mode( false ), auto_wrap_mode( true )
|
next_print_will_wrap( false ), origin_mode( false ), auto_wrap_mode( true )
|
||||||
{
|
{
|
||||||
for ( int i = 0; i < width; i++ ) {
|
for ( int i = 0; i < width; i++ ) {
|
||||||
@@ -270,3 +270,31 @@ void Framebuffer::apply_renditions_to_current_cell( void )
|
|||||||
|
|
||||||
this_cell->renditions = ds.get_renditions();
|
this_cell->renditions = ds.get_renditions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SavedCursor::SavedCursor()
|
||||||
|
: cursor_col( 0 ), cursor_row( 0 ),
|
||||||
|
renditions(),
|
||||||
|
auto_wrap_mode( true ),
|
||||||
|
origin_mode( false )
|
||||||
|
{}
|
||||||
|
|
||||||
|
void DrawState::save_cursor( void )
|
||||||
|
{
|
||||||
|
save.cursor_col = cursor_col;
|
||||||
|
save.cursor_row = cursor_row;
|
||||||
|
save.renditions = renditions;
|
||||||
|
save.auto_wrap_mode = auto_wrap_mode;
|
||||||
|
save.origin_mode = origin_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawState::restore_cursor( void )
|
||||||
|
{
|
||||||
|
cursor_col = save.cursor_col;
|
||||||
|
cursor_row = save.cursor_row;
|
||||||
|
renditions = save.renditions;
|
||||||
|
auto_wrap_mode = save.auto_wrap_mode;
|
||||||
|
origin_mode = save.origin_mode;
|
||||||
|
|
||||||
|
snap_cursor_to_border();
|
||||||
|
new_grapheme();
|
||||||
|
}
|
||||||
|
|||||||
@@ -31,6 +31,18 @@ namespace Terminal {
|
|||||||
Row( size_t s_width );
|
Row( size_t s_width );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class SavedCursor {
|
||||||
|
public:
|
||||||
|
int cursor_col, cursor_row;
|
||||||
|
std::vector<int> renditions;
|
||||||
|
/* character set shift state */
|
||||||
|
bool auto_wrap_mode;
|
||||||
|
bool origin_mode;
|
||||||
|
/* state of selective erase */
|
||||||
|
|
||||||
|
SavedCursor();
|
||||||
|
};
|
||||||
|
|
||||||
class DrawState {
|
class DrawState {
|
||||||
private:
|
private:
|
||||||
int width, height;
|
int width, height;
|
||||||
@@ -47,6 +59,8 @@ namespace Terminal {
|
|||||||
|
|
||||||
std::vector<int> renditions;
|
std::vector<int> renditions;
|
||||||
|
|
||||||
|
SavedCursor save;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool next_print_will_wrap;
|
bool next_print_will_wrap;
|
||||||
bool origin_mode;
|
bool origin_mode;
|
||||||
@@ -82,6 +96,9 @@ namespace Terminal {
|
|||||||
void add_rendition( int x ) { renditions.push_back( x ); }
|
void add_rendition( int x ) { renditions.push_back( x ); }
|
||||||
const std::vector<int> get_renditions( void ) { return renditions; }
|
const std::vector<int> get_renditions( void ) { return renditions; }
|
||||||
|
|
||||||
|
void save_cursor( void );
|
||||||
|
void restore_cursor( void );
|
||||||
|
|
||||||
DrawState( int s_width, int s_height );
|
DrawState( int s_width, int s_height );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -274,3 +274,17 @@ void CSI_SGR( Framebuffer *fb, Dispatcher *dispatch )
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Function func_CSI_SGR( CSI, "m", CSI_SGR );
|
static Function func_CSI_SGR( CSI, "m", CSI_SGR );
|
||||||
|
|
||||||
|
/* save and restore cursor */
|
||||||
|
void Esc_DECSC( Framebuffer *fb, Dispatcher *dispatch __attribute((unused)) )
|
||||||
|
{
|
||||||
|
fb->ds.save_cursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Esc_DECRC( Framebuffer *fb, Dispatcher *dispatch __attribute((unused)) )
|
||||||
|
{
|
||||||
|
fb->ds.restore_cursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
static Function func_Esc_DECSC( ESCAPE, "7", Esc_DECSC );
|
||||||
|
static Function func_Esc_DECRC( ESCAPE, "8", Esc_DECRC );
|
||||||
|
|||||||
Reference in New Issue
Block a user