Implement ED (clear screen)
This commit is contained in:
+24
-16
@@ -138,27 +138,16 @@ void Emulator::print( Parser::Print *act )
|
||||
|
||||
autoscroll();
|
||||
|
||||
this_cell = &rows[ cursor_row ].cells[ cursor_col ];
|
||||
this_cell->contents.clear();
|
||||
this_cell = &rows[ cursor_row ].cells[ cursor_col ];
|
||||
this_cell->reset();
|
||||
this_cell->contents.push_back( act->ch );
|
||||
for ( std::vector<Cell *>::iterator i
|
||||
= this_cell->overlapped_cells.begin();
|
||||
i != this_cell->overlapped_cells.end();
|
||||
i++ ) {
|
||||
**i = Cell();
|
||||
}
|
||||
this_cell->overlapped_cells.clear();
|
||||
|
||||
newgrapheme();
|
||||
|
||||
if ( cursor_col < width - 1 ) {
|
||||
if ( (cursor_col < width - 1) && (chwidth == 2) ) {
|
||||
Cell *next_cell = &rows[ cursor_row ].cells[ cursor_col + 1 ];
|
||||
if ( chwidth == 2 ) {
|
||||
this_cell->overlapped_cells.push_back( next_cell );
|
||||
next_cell->overlapping_cell = this_cell;
|
||||
} else {
|
||||
next_cell->overlapping_cell = NULL;
|
||||
}
|
||||
this_cell->overlapped_cells.push_back( next_cell );
|
||||
next_cell->overlapping_cell = this_cell;
|
||||
}
|
||||
|
||||
cursor_col += chwidth;
|
||||
@@ -232,6 +221,8 @@ void Emulator::CSI_dispatch( Parser::CSI_Dispatch *act )
|
||||
|
||||
if ( dispatch_chars == "K" ) {
|
||||
CSI_EL();
|
||||
} else if ( dispatch_chars == "J" ) {
|
||||
CSI_ED();
|
||||
} else if ( (dispatch_chars == "A")
|
||||
|| (dispatch_chars == "B")
|
||||
|| (dispatch_chars == "C")
|
||||
@@ -288,3 +279,20 @@ int Emulator::getparam( size_t N, int defaultval )
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Cell::reset( void )
|
||||
{
|
||||
if ( overlapping_cell ) {
|
||||
assert( overlapped_cells.size() == 0 );
|
||||
contents.clear();
|
||||
} else {
|
||||
contents.clear();
|
||||
for ( std::vector<Cell *>::iterator i = overlapped_cells.begin();
|
||||
i != overlapped_cells.end();
|
||||
i++ ) {
|
||||
(*i)->overlapping_cell = NULL;
|
||||
(*i)->reset();
|
||||
}
|
||||
overlapped_cells.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ namespace Terminal {
|
||||
|
||||
Cell( const Cell & );
|
||||
Cell & operator=( const Cell & );
|
||||
|
||||
void reset( void );
|
||||
};
|
||||
|
||||
class Row {
|
||||
@@ -66,6 +68,7 @@ namespace Terminal {
|
||||
|
||||
/* CSI methods */
|
||||
void CSI_EL( void );
|
||||
void CSI_ED( void );
|
||||
void CSI_cursormove( void );
|
||||
|
||||
public:
|
||||
|
||||
+34
-2
@@ -8,13 +8,45 @@ void Emulator::CSI_EL( void )
|
||||
{
|
||||
if ( params == "1" ) { /* start of screen to active position, inclusive */
|
||||
for ( int x = 0; x <= cursor_col; x++ ) {
|
||||
rows[ cursor_row ].cells[ x ].contents.clear();
|
||||
if ( x < width ) {
|
||||
rows[ cursor_row ].cells[ x ].reset();
|
||||
}
|
||||
}
|
||||
} else if ( params == "2" ) { /* all of line */
|
||||
rows[ cursor_row ] = Row( width );
|
||||
} else { /* active position to end of line, inclusive */
|
||||
for ( int x = cursor_col; x < width; x++ ) {
|
||||
rows[ cursor_row ].cells[ x ].contents.clear();
|
||||
rows[ cursor_row ].cells[ x ].reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Emulator::CSI_ED( void ) {
|
||||
if ( params == "1" ) { /* start of screen to active position, inclusive */
|
||||
for ( int y = 0; y < cursor_row; y++ ) {
|
||||
for ( int x = 0; x < width; x++ ) {
|
||||
rows[ y ].cells[ x ].reset();
|
||||
}
|
||||
}
|
||||
for ( int x = 0; x <= cursor_col; x++ ) {
|
||||
if ( x < width ) {
|
||||
rows[ cursor_row ].cells[ x ].reset();
|
||||
}
|
||||
}
|
||||
} else if ( params == "2" ) { /* entire screen */
|
||||
for ( int y = 0; y < height; y++ ) {
|
||||
for ( int x = 0; x < width; x++ ) {
|
||||
rows[ y ].cells[ x ].reset();
|
||||
}
|
||||
}
|
||||
} else { /* active position to end of screen, inclusive */
|
||||
for ( int x = cursor_col; x < width; x++ ) {
|
||||
rows[ cursor_row ].cells[ x ].reset();
|
||||
}
|
||||
for ( int y = cursor_row + 1; y < height; y++ ) {
|
||||
for ( int x = 0; x < width; x++ ) {
|
||||
rows[ y ].cells[ x ].reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user