Changing renditions no longer clears wrap state

This commit is contained in:
Keith Winstein
2011-09-30 19:02:28 -04:00
parent ad8cb166de
commit 3f2956ee61
4 changed files with 15 additions and 10 deletions
-4
View File
@@ -22,7 +22,6 @@ std::string Emulator::read_octets_to_host( void )
void Emulator::execute( const Parser::Execute *act ) void Emulator::execute( const Parser::Execute *act )
{ {
fb.ds.next_print_will_wrap = false;
dispatch.dispatch( CONTROL, act, &fb ); dispatch.dispatch( CONTROL, act, &fb );
} }
@@ -111,19 +110,16 @@ void Emulator::print( const Parser::Print *act )
void Emulator::CSI_dispatch( const Parser::CSI_Dispatch *act ) void Emulator::CSI_dispatch( const Parser::CSI_Dispatch *act )
{ {
fb.ds.next_print_will_wrap = false;
dispatch.dispatch( CSI, act, &fb ); dispatch.dispatch( CSI, act, &fb );
} }
void Emulator::OSC_end( const Parser::OSC_End *act ) void Emulator::OSC_end( const Parser::OSC_End *act )
{ {
fb.ds.next_print_will_wrap = false;
dispatch.OSC_dispatch( act, &fb ); dispatch.OSC_dispatch( act, &fb );
} }
void Emulator::Esc_dispatch( const Parser::Esc_Dispatch *act ) void Emulator::Esc_dispatch( const Parser::Esc_Dispatch *act )
{ {
fb.ds.next_print_will_wrap = false;
/* handle 7-bit ESC-encoding of C1 control characters */ /* handle 7-bit ESC-encoding of C1 control characters */
if ( (dispatch.get_dispatch_chars().size() == 0) if ( (dispatch.get_dispatch_chars().size() == 0)
&& (0x40 <= act->ch) && (0x40 <= act->ch)
+10 -3
View File
@@ -4,6 +4,7 @@
#include "terminaldispatcher.hpp" #include "terminaldispatcher.hpp"
#include "parseraction.hpp" #include "parseraction.hpp"
#include "terminalframebuffer.hpp"
using namespace Terminal; using namespace Terminal;
@@ -135,8 +136,9 @@ static void register_function( Function_Type type,
} }
Function::Function( Function_Type type, std::string dispatch_chars, Function::Function( Function_Type type, std::string dispatch_chars,
void (*s_function)( Framebuffer *, Dispatcher * ) ) void (*s_function)( Framebuffer *, Dispatcher * ),
: function( s_function ) bool s_clears_wrap_state )
: function( s_function ), clears_wrap_state( s_clears_wrap_state )
{ {
register_function( type, dispatch_chars, *this ); register_function( type, dispatch_chars, *this );
} }
@@ -163,14 +165,19 @@ void Dispatcher::dispatch( Function_Type type, const Parser::Action *act, Frameb
if ( type == CONTROL ) { if ( type == CONTROL ) {
assert( act->ch <= 255 ); assert( act->ch <= 255 );
char ctrlstr[ 2 ] = { (char)act->ch, 0 }; char ctrlstr[ 2 ] = { (char)act->ch, 0 };
key = std::string( ctrlstr ); key = std::string( ctrlstr, 1 );
} }
dispatch_map_t::const_iterator i = map->find( key ); dispatch_map_t::const_iterator i = map->find( key );
if ( i == map->end() ) { if ( i == map->end() ) {
/* unknown function */
fb->ds.next_print_will_wrap = false;
return; return;
} else { } else {
act->handled = true; act->handled = true;
if ( i->second.clears_wrap_state ) {
fb->ds.next_print_will_wrap = false;
}
return i->second.function( fb, this ); return i->second.function( fb, this );
} }
} }
+4 -2
View File
@@ -26,10 +26,12 @@ namespace Terminal {
class Function { class Function {
public: public:
Function() : function( NULL ) {} Function() : function( NULL ), clears_wrap_state( true ) {}
Function( Function_Type type, std::string dispatch_chars, Function( Function_Type type, std::string dispatch_chars,
void (*s_function)( Framebuffer *, Dispatcher * ) ); void (*s_function)( Framebuffer *, Dispatcher * ),
bool s_clears_wrap_state = true );
void (*function)( Framebuffer *, Dispatcher * ); void (*function)( Framebuffer *, Dispatcher * );
bool clears_wrap_state;
}; };
typedef std::map<std::string, Function> dispatch_map_t; typedef std::map<std::string, Function> dispatch_map_t;
+1 -1
View File
@@ -318,7 +318,7 @@ void CSI_SGR( Framebuffer *fb, Dispatcher *dispatch )
} }
} }
static Function func_CSI_SGR( CSI, "m", CSI_SGR ); static Function func_CSI_SGR( CSI, "m", CSI_SGR, false ); /* changing renditions doesn't clear wrap flag */
/* save and restore cursor */ /* save and restore cursor */
void Esc_DECSC( Framebuffer *fb, Dispatcher *dispatch __attribute((unused)) ) void Esc_DECSC( Framebuffer *fb, Dispatcher *dispatch __attribute((unused)) )