Refactor in progress for more modular terminal

This commit is contained in:
Keith Winstein
2011-01-27 18:56:50 -05:00
parent 82a18ce978
commit 5e0cc8c2b8
7 changed files with 99 additions and 89 deletions
+43 -44
View File
@@ -6,46 +6,46 @@ using namespace Terminal;
void Emulator::CSI_EL( void )
{
if ( params == "1" ) { /* start of screen to active position, inclusive */
for ( int x = 0; x <= cursor_col; x++ ) {
if ( x < width ) {
rows[ cursor_row ].cells[ x ].reset();
if ( as.params == "1" ) { /* start of screen to active position, inclusive */
for ( int x = 0; x <= fb.cursor_col; x++ ) {
if ( x < fb.width ) {
fb.rows[ fb.cursor_row ].cells[ x ].reset();
}
}
} else if ( params == "2" ) { /* all of line */
rows[ cursor_row ] = Row( width );
} else if ( as.params == "2" ) { /* all of line */
fb.rows[ fb.cursor_row ] = Row( fb.width );
} else { /* active position to end of line, inclusive */
for ( int x = cursor_col; x < width; x++ ) {
rows[ cursor_row ].cells[ x ].reset();
for ( int x = fb.cursor_col; x < fb.width; x++ ) {
fb.rows[ fb.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();
if ( as.params == "1" ) { /* start of screen to active position, inclusive */
for ( int y = 0; y < fb.cursor_row; y++ ) {
for ( int x = 0; x < fb.width; x++ ) {
fb.rows[ y ].cells[ x ].reset();
}
}
for ( int x = 0; x <= cursor_col; x++ ) {
if ( x < width ) {
rows[ cursor_row ].cells[ x ].reset();
for ( int x = 0; x <= fb.cursor_col; x++ ) {
if ( x < fb.width ) {
fb.rows[ fb.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 if ( as.params == "2" ) { /* entire screen */
for ( int y = 0; y < fb.height; y++ ) {
for ( int x = 0; x < fb.width; x++ ) {
fb.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 x = fb.cursor_col; x < fb.width; x++ ) {
fb.rows[ fb.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();
for ( int y = fb.cursor_row + 1; y < fb.height; y++ ) {
for ( int x = 0; x < fb.width; x++ ) {
fb.rows[ y ].cells[ x ].reset();
}
}
}
@@ -53,36 +53,35 @@ void Emulator::CSI_ED( void ) {
void Emulator::CSI_cursormove( void )
{
parse_params();
int num = getparam( 0, 1 );
int num = as.getparam( 0, 1 );
switch ( dispatch_chars[ 0 ] ) {
switch ( as.dispatch_chars[ 0 ] ) {
case 'A':
cursor_row -= num;
fb.cursor_row -= num;
break;
case 'B':
cursor_row += num;
fb.cursor_row += num;
break;
case 'C':
cursor_col += num;
fb.cursor_col += num;
break;
case 'D':
cursor_col -= num;
fb.cursor_col -= num;
break;
case 'H':
case 'f':
int x = getparam( 0, 1 );
int y = getparam( 1, 1 );
cursor_row = x - 1;
cursor_col = y - 1;
int x = as.getparam( 0, 1 );
int y = as.getparam( 1, 1 );
fb.cursor_row = x - 1;
fb.cursor_col = y - 1;
}
if ( cursor_row < 0 ) cursor_row = 0;
if ( cursor_row >= height ) cursor_row = height - 1;
if ( cursor_col < 0 ) cursor_col = 0;
if ( cursor_col >= width ) cursor_col = width - 1;
if ( fb.cursor_row < 0 ) fb.cursor_row = 0;
if ( fb.cursor_row >= fb.height ) fb.cursor_row = fb.height - 1;
if ( fb.cursor_col < 0 ) fb.cursor_col = 0;
if ( fb.cursor_col >= fb.width ) fb.cursor_col = fb.width - 1;
newgrapheme();
fb.newgrapheme();
}
void Emulator::CSI_DA( void )
@@ -92,10 +91,10 @@ void Emulator::CSI_DA( void )
void Emulator::Esc_DECALN( void )
{
for ( int y = 0; y < height; y++ ) {
for ( int x = 0; x < width; x++ ) {
rows[ y ].cells[ x ].reset();
rows[ y ].cells[ x ].contents.push_back( L'E' );
for ( int y = 0; y < fb.height; y++ ) {
for ( int x = 0; x < fb.width; x++ ) {
fb.rows[ y ].cells[ x ].reset();
fb.rows[ y ].cells[ x ].contents.push_back( L'E' );
}
}
}