diff --git a/Makefile b/Makefile index 40e89c6..84e718a 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -source = parse.cpp parserstate.cpp parser.cpp templates.cpp terminal.cpp termemu.cpp parseraction.cpp terminalcsi.cpp swrite.cpp terminalframebuffer.cpp terminalactionstate.cpp -objects = parserstate.o parser.o templates.o terminal.o parseraction.o terminalcsi.o swrite.o terminalframebuffer.o terminalactionstate.o +source = parse.cpp parserstate.cpp parser.cpp templates.cpp terminal.cpp termemu.cpp parseraction.cpp terminalcsi.cpp swrite.cpp terminalframebuffer.cpp terminaldispatcher.cpp +objects = parserstate.o parser.o templates.o terminal.o parseraction.o terminalcsi.o swrite.o terminalframebuffer.o terminaldispatcher.o repos = templates.rpo executables = parse termemu diff --git a/parseraction.cpp b/parseraction.cpp index 3052cf7..b3374e7 100644 --- a/parseraction.cpp +++ b/parseraction.cpp @@ -28,17 +28,17 @@ void Execute::act_on_terminal( Terminal::Emulator *emu ) void Clear::act_on_terminal( Terminal::Emulator *emu ) { - emu->as.clear( this ); + emu->dispatch.clear( this ); } void Param::act_on_terminal( Terminal::Emulator *emu ) { - emu->as.newparamchar( this ); + emu->dispatch.newparamchar( this ); } void Collect::act_on_terminal( Terminal::Emulator *emu ) { - emu->as.collect( this ); + emu->dispatch.collect( this ); } void CSI_Dispatch::act_on_terminal( Terminal::Emulator *emu ) diff --git a/terminal.cpp b/terminal.cpp index d8071a2..885f9fa 100644 --- a/terminal.cpp +++ b/terminal.cpp @@ -10,7 +10,7 @@ using namespace Terminal; Emulator::Emulator( size_t s_width, size_t s_height ) - : parser(), fb( s_width, s_height ), as(), terminal_to_host() + : parser(), fb( s_width, s_height ), dispatch(), terminal_to_host() {} std::string Emulator::input( char c, int actfd ) @@ -29,7 +29,7 @@ std::string Emulator::input( char c, int actfd ) /* print out debugging information */ if ( (actfd > 0) && ( !act->handled ) ) { char actsum[ 64 ]; - snprintf( actsum, 64, "%s%s ", act->str().c_str(), as.str().c_str() ); + snprintf( actsum, 64, "%s%s ", act->str().c_str(), dispatch.str().c_str() ); swrite( actfd, actsum ); } delete act; @@ -123,9 +123,9 @@ void Emulator::CSI_dispatch( Parser::CSI_Dispatch *act ) Parser::Collect act2; act2.char_present = true; act2.ch = act->ch; - as.collect( &act2 ); + dispatch.collect( &act2 ); - std::string dispatch_chars = as.dispatch_chars; + std::string dispatch_chars = dispatch.dispatch_chars; if ( dispatch_chars == "K" ) { CSI_EL(); @@ -154,9 +154,9 @@ void Emulator::Esc_dispatch( Parser::Esc_Dispatch *act ) Parser::Collect act2; act2.char_present = true; act2.ch = act->ch; - as.collect( &act2 ); + dispatch.collect( &act2 ); - if ( as.dispatch_chars == "#8" ) { + if ( dispatch.dispatch_chars == "#8" ) { Esc_DECALN(); act->handled = true; } diff --git a/terminal.hpp b/terminal.hpp index 805e72f..76f2823 100644 --- a/terminal.hpp +++ b/terminal.hpp @@ -8,7 +8,7 @@ #include "parser.hpp" #include "terminalframebuffer.hpp" -#include "terminalactionstate.hpp" +#include "terminaldispatcher.hpp" namespace Terminal { class Emulator { @@ -23,7 +23,7 @@ namespace Terminal { private: Parser::UTF8Parser parser; Framebuffer fb; - ActionState as; + Dispatcher dispatch; std::string terminal_to_host; diff --git a/terminalcsi.cpp b/terminalcsi.cpp index b3d6f11..c04e61f 100644 --- a/terminalcsi.cpp +++ b/terminalcsi.cpp @@ -16,10 +16,10 @@ void Emulator::CSI_EL( void ) /* default: active position to end of line, inclusive */ int start = fb.ds.get_cursor_col(), end = fb.ds.get_width() - 1; - if ( as.params == "1" ) { /* start of screen to active position, inclusive */ + if ( dispatch.params == "1" ) { /* start of screen to active position, inclusive */ start = 0; end = fb.ds.get_cursor_col(); - } else if ( as.params == "2" ) { /* all of line */ + } else if ( dispatch.params == "2" ) { /* all of line */ start = 0; } @@ -27,12 +27,12 @@ void Emulator::CSI_EL( void ) } void Emulator::CSI_ED( void ) { - if ( as.params == "1" ) { /* start of screen to active position, inclusive */ + if ( dispatch.params == "1" ) { /* start of screen to active position, inclusive */ for ( int y = 0; y < fb.ds.get_cursor_row(); y++ ) { clearline( &fb, y, 0, fb.ds.get_width() - 1 ); } clearline( &fb, -1, 0, fb.ds.get_cursor_col() ); - } else if ( as.params == "2" ) { /* entire screen */ + } else if ( dispatch.params == "2" ) { /* entire screen */ for ( int y = 0; y < fb.ds.get_height(); y++ ) { clearline( &fb, y, 0, fb.ds.get_width() - 1 ); } @@ -46,9 +46,9 @@ void Emulator::CSI_ED( void ) { void Emulator::CSI_cursormove( void ) { - int num = as.getparam( 0, 1 ); + int num = dispatch.getparam( 0, 1 ); - switch ( as.dispatch_chars[ 0 ] ) { + switch ( dispatch.dispatch_chars[ 0 ] ) { case 'A': fb.ds.move_row( -num, true ); break; @@ -63,8 +63,8 @@ void Emulator::CSI_cursormove( void ) break; case 'H': case 'f': - int x = as.getparam( 0, 1 ); - int y = as.getparam( 1, 1 ); + int x = dispatch.getparam( 0, 1 ); + int y = dispatch.getparam( 1, 1 ); fb.ds.move_row( x - 1 ); fb.ds.move_col( y - 1 ); } diff --git a/terminalactionstate.cpp b/terminaldispatcher.cpp similarity index 84% rename from terminalactionstate.cpp rename to terminaldispatcher.cpp index 79ded85..413f00f 100644 --- a/terminalactionstate.cpp +++ b/terminaldispatcher.cpp @@ -2,16 +2,16 @@ #include #include -#include "terminalactionstate.hpp" +#include "terminaldispatcher.hpp" #include "parseraction.hpp" using namespace Terminal; -ActionState::ActionState() +Dispatcher::Dispatcher() : params(), parsed_params(), parsed( false ), dispatch_chars() {} -void ActionState::newparamchar( Parser::Param *act ) +void Dispatcher::newparamchar( Parser::Param *act ) { assert( act->char_present ); assert( (act->ch == ';') || ( (act->ch >= '0') && (act->ch <= '9') ) ); @@ -23,7 +23,7 @@ void ActionState::newparamchar( Parser::Param *act ) parsed = false; } -void ActionState::collect( Parser::Collect *act ) +void Dispatcher::collect( Parser::Collect *act ) { assert( act->char_present ); if ( ( dispatch_chars.length() < 8 ) /* never should need more than 2 */ @@ -33,7 +33,7 @@ void ActionState::collect( Parser::Collect *act ) } } -void ActionState::clear( Parser::Clear *act ) +void Dispatcher::clear( Parser::Clear *act ) { params.clear(); dispatch_chars.clear(); @@ -41,7 +41,7 @@ void ActionState::clear( Parser::Clear *act ) act->handled = true; } -void ActionState::parse_params( void ) +void Dispatcher::parse_params( void ) { if ( parsed ) { return; @@ -84,7 +84,7 @@ void ActionState::parse_params( void ) parsed = true; } -int ActionState::getparam( size_t N, int defaultval ) +int Dispatcher::getparam( size_t N, int defaultval ) { int ret = defaultval; if ( !parsed ) { @@ -99,7 +99,7 @@ int ActionState::getparam( size_t N, int defaultval ) return ret; } -std::string ActionState::str( void ) +std::string Dispatcher::str( void ) { char assum[ 64 ]; snprintf( assum, 64, "[dispatch=\"%s\" params=\"%s\"]", diff --git a/terminalactionstate.hpp b/terminaldispatcher.hpp similarity index 83% rename from terminalactionstate.hpp rename to terminaldispatcher.hpp index a7031e7..67e80fa 100644 --- a/terminalactionstate.hpp +++ b/terminaldispatcher.hpp @@ -1,5 +1,5 @@ -#ifndef TERMINALACTIONSTATE_HPP -#define TERMINALACTIONSTATE_HPP +#ifndef TERMINALDISPATCHER_HPP +#define TERMINALDISPATCHER_HPP #include #include @@ -11,7 +11,7 @@ namespace Parser { } namespace Terminal { - class ActionState { + class Dispatcher { private: public: /* tmp */ std::string params; @@ -23,7 +23,7 @@ namespace Terminal { void parse_params( void ); public: - ActionState(); + Dispatcher(); int getparam( size_t N, int defaultval ); void newparamchar( Parser::Param *act );