Implement first DEC set/reset modes

This commit is contained in:
Keith Winstein
2011-01-31 06:45:12 -05:00
parent 92d80accf9
commit 1a2fe97b88
5 changed files with 52 additions and 2 deletions
+11
View File
@@ -90,6 +90,7 @@ int Dispatcher::getparam( size_t N, int defaultval )
int ret = defaultval;
if ( !parsed ) {
parse_params();
parsed = true;
}
if ( parsed_params.size() > N ) {
@@ -100,6 +101,16 @@ int Dispatcher::getparam( size_t N, int defaultval )
return ret;
}
int Dispatcher::param_count( void )
{
if ( !parsed ) {
parse_params();
parsed = true;
}
return parsed_params.size();
}
std::string Dispatcher::str( void )
{
char assum[ 64 ];
+1
View File
@@ -57,6 +57,7 @@ namespace Terminal {
Dispatcher();
int getparam( size_t N, int defaultval );
int param_count( void );
void newparamchar( Parser::Param *act );
void collect( Parser::Collect *act );
+6 -2
View File
@@ -57,8 +57,12 @@ DrawState::DrawState( int s_width, int s_height )
: width( s_width ), height( s_height ),
cursor_col( 0 ), cursor_row( 0 ),
combining_char_col( 0 ), combining_char_row( 0 ), tabs( s_width ),
next_print_will_wrap( false ), auto_wrap_mode( true )
{}
next_print_will_wrap( false ), origin_mode( false ), auto_wrap_mode( true )
{
for ( int i = 0; i < width; i++ ) {
tabs[ i ] = ( (i % 8) == 0 );
}
}
Framebuffer::Framebuffer( int s_width, int s_height )
: rows( s_height, Row( s_width ) ), ds( s_width, s_height )
+1
View File
@@ -44,6 +44,7 @@ namespace Terminal {
public:
bool next_print_will_wrap;
bool origin_mode;
bool auto_wrap_mode;
/* bold, etc. */
+33
View File
@@ -173,3 +173,36 @@ void CSI_TBC( Framebuffer *fb, Dispatcher *dispatch )
}
static Function func_CSI_TBC( CSI, "g", CSI_TBC );
static bool *get_DEC_mode( int param, Framebuffer *fb ) {
switch ( param ) {
case 6: /* origin */
return &(fb->ds.origin_mode);
case 7: /* auto wrap */
return &(fb->ds.auto_wrap_mode);
}
return NULL;
}
void CSI_DECSM( Framebuffer *fb, Dispatcher *dispatch )
{
for ( int i = 0; i < dispatch->param_count(); i++ ) {
bool *mode = get_DEC_mode( dispatch->getparam( i, 0 ), fb );
if ( mode ) {
*mode = true;
}
}
}
void CSI_DECRM( Framebuffer *fb, Dispatcher *dispatch )
{
for ( int i = 0; i < dispatch->param_count(); i++ ) {
bool *mode = get_DEC_mode( dispatch->getparam( i, 0 ), fb );
if ( mode ) {
*mode = false;
}
}
}
static Function func_CSI_DECSM( CSI, "?h", CSI_DECSM );
static Function func_CSI_DECRM( CSI, "?l", CSI_DECRM );