diff --git a/src/terminal/terminalfunctions.cc b/src/terminal/terminalfunctions.cc index c167c63..a1902a8 100644 --- a/src/terminal/terminalfunctions.cc +++ b/src/terminal/terminalfunctions.cc @@ -282,6 +282,12 @@ static bool *get_DEC_mode( int param, Framebuffer *fb ) { return NULL; } +/* helper for CSI_DECSM and CSI_DECRM */ +void set_if_available( bool *mode, bool value ) +{ + if ( mode ) { *mode = value; } +} + /* set private mode */ void CSI_DECSM( Framebuffer *fb, Dispatcher *dispatch ) { @@ -289,21 +295,16 @@ void CSI_DECSM( Framebuffer *fb, Dispatcher *dispatch ) int param = dispatch->getparam( i, 0 ); if ( (param == 1000) || (param == 1002) ) { - // clear the other mouse modes before setting this one - bool *c_mode = get_DEC_mode( 1000, fb ); - if ( c_mode ) { *c_mode = false; } - *c_mode = get_DEC_mode( 1002, fb ); - if ( c_mode ) { *c_mode = false; } - *c_mode = get_DEC_mode( 1005, fb ); - if ( c_mode ) { *c_mode = false; } - *c_mode = get_DEC_mode( 1006, fb ); - if ( c_mode ) { *c_mode = false; } + /* we believe all mouse modes should be set to false + when either of these two modes are enabled */ + /* XXX can we cite something for this? -KJW 15Dec2014 */ + set_if_available( get_DEC_mode( 1000, fb ), false ); + set_if_available( get_DEC_mode( 1002, fb ), false ); + set_if_available( get_DEC_mode( 1005, fb ), false ); + set_if_available( get_DEC_mode( 1006, fb ), false ); } - bool *mode = get_DEC_mode( param, fb ); - if ( mode ) { - *mode = true; - } + set_if_available( get_DEC_mode( param, fb ), true ); } } @@ -311,10 +312,7 @@ void CSI_DECSM( Framebuffer *fb, Dispatcher *dispatch ) 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; - } + set_if_available( get_DEC_mode( dispatch->getparam( i, 0 ), fb ), false ); } }