Implement first DEC set/reset modes
This commit is contained in:
@@ -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 ];
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -44,6 +44,7 @@ namespace Terminal {
|
||||
|
||||
public:
|
||||
bool next_print_will_wrap;
|
||||
bool origin_mode;
|
||||
bool auto_wrap_mode;
|
||||
|
||||
/* bold, etc. */
|
||||
|
||||
@@ -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 );
|
||||
|
||||
Reference in New Issue
Block a user