Implement ED (clear screen)
This commit is contained in:
+21
-13
@@ -139,26 +139,15 @@ void Emulator::print( Parser::Print *act )
|
|||||||
autoscroll();
|
autoscroll();
|
||||||
|
|
||||||
this_cell = &rows[ cursor_row ].cells[ cursor_col ];
|
this_cell = &rows[ cursor_row ].cells[ cursor_col ];
|
||||||
this_cell->contents.clear();
|
this_cell->reset();
|
||||||
this_cell->contents.push_back( act->ch );
|
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();
|
newgrapheme();
|
||||||
|
|
||||||
if ( cursor_col < width - 1 ) {
|
if ( (cursor_col < width - 1) && (chwidth == 2) ) {
|
||||||
Cell *next_cell = &rows[ cursor_row ].cells[ cursor_col + 1 ];
|
Cell *next_cell = &rows[ cursor_row ].cells[ cursor_col + 1 ];
|
||||||
if ( chwidth == 2 ) {
|
|
||||||
this_cell->overlapped_cells.push_back( next_cell );
|
this_cell->overlapped_cells.push_back( next_cell );
|
||||||
next_cell->overlapping_cell = this_cell;
|
next_cell->overlapping_cell = this_cell;
|
||||||
} else {
|
|
||||||
next_cell->overlapping_cell = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor_col += chwidth;
|
cursor_col += chwidth;
|
||||||
@@ -232,6 +221,8 @@ void Emulator::CSI_dispatch( Parser::CSI_Dispatch *act )
|
|||||||
|
|
||||||
if ( dispatch_chars == "K" ) {
|
if ( dispatch_chars == "K" ) {
|
||||||
CSI_EL();
|
CSI_EL();
|
||||||
|
} else if ( dispatch_chars == "J" ) {
|
||||||
|
CSI_ED();
|
||||||
} else if ( (dispatch_chars == "A")
|
} else if ( (dispatch_chars == "A")
|
||||||
|| (dispatch_chars == "B")
|
|| (dispatch_chars == "B")
|
||||||
|| (dispatch_chars == "C")
|
|| (dispatch_chars == "C")
|
||||||
@@ -288,3 +279,20 @@ int Emulator::getparam( size_t N, int defaultval )
|
|||||||
|
|
||||||
return ret;
|
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( const Cell & );
|
||||||
Cell & operator=( const Cell & );
|
Cell & operator=( const Cell & );
|
||||||
|
|
||||||
|
void reset( void );
|
||||||
};
|
};
|
||||||
|
|
||||||
class Row {
|
class Row {
|
||||||
@@ -66,6 +68,7 @@ namespace Terminal {
|
|||||||
|
|
||||||
/* CSI methods */
|
/* CSI methods */
|
||||||
void CSI_EL( void );
|
void CSI_EL( void );
|
||||||
|
void CSI_ED( void );
|
||||||
void CSI_cursormove( void );
|
void CSI_cursormove( void );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
+34
-2
@@ -8,13 +8,45 @@ void Emulator::CSI_EL( void )
|
|||||||
{
|
{
|
||||||
if ( params == "1" ) { /* start of screen to active position, inclusive */
|
if ( params == "1" ) { /* start of screen to active position, inclusive */
|
||||||
for ( int x = 0; x <= cursor_col; x++ ) {
|
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 */
|
} else if ( params == "2" ) { /* all of line */
|
||||||
rows[ cursor_row ] = Row( width );
|
rows[ cursor_row ] = Row( width );
|
||||||
} else { /* active position to end of line, inclusive */
|
} else { /* active position to end of line, inclusive */
|
||||||
for ( int x = cursor_col; x < width; x++ ) {
|
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