Renamed ActionState to Dispatcher

This commit is contained in:
Keith Winstein
2011-01-31 02:20:37 -05:00
parent ec328ecdee
commit 19e809b16e
7 changed files with 33 additions and 33 deletions
+2 -2
View File
@@ -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 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 terminalactionstate.o objects = parserstate.o parser.o templates.o terminal.o parseraction.o terminalcsi.o swrite.o terminalframebuffer.o terminaldispatcher.o
repos = templates.rpo repos = templates.rpo
executables = parse termemu executables = parse termemu
+3 -3
View File
@@ -28,17 +28,17 @@ void Execute::act_on_terminal( Terminal::Emulator *emu )
void Clear::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 ) void Param::act_on_terminal( Terminal::Emulator *emu )
{ {
emu->as.newparamchar( this ); emu->dispatch.newparamchar( this );
} }
void Collect::act_on_terminal( Terminal::Emulator *emu ) 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 ) void CSI_Dispatch::act_on_terminal( Terminal::Emulator *emu )
+6 -6
View File
@@ -10,7 +10,7 @@
using namespace Terminal; using namespace Terminal;
Emulator::Emulator( size_t s_width, size_t s_height ) 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 ) std::string Emulator::input( char c, int actfd )
@@ -29,7 +29,7 @@ std::string Emulator::input( char c, int actfd )
/* print out debugging information */ /* print out debugging information */
if ( (actfd > 0) && ( !act->handled ) ) { if ( (actfd > 0) && ( !act->handled ) ) {
char actsum[ 64 ]; 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 ); swrite( actfd, actsum );
} }
delete act; delete act;
@@ -123,9 +123,9 @@ void Emulator::CSI_dispatch( Parser::CSI_Dispatch *act )
Parser::Collect act2; Parser::Collect act2;
act2.char_present = true; act2.char_present = true;
act2.ch = act->ch; 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" ) { if ( dispatch_chars == "K" ) {
CSI_EL(); CSI_EL();
@@ -154,9 +154,9 @@ void Emulator::Esc_dispatch( Parser::Esc_Dispatch *act )
Parser::Collect act2; Parser::Collect act2;
act2.char_present = true; act2.char_present = true;
act2.ch = act->ch; act2.ch = act->ch;
as.collect( &act2 ); dispatch.collect( &act2 );
if ( as.dispatch_chars == "#8" ) { if ( dispatch.dispatch_chars == "#8" ) {
Esc_DECALN(); Esc_DECALN();
act->handled = true; act->handled = true;
} }
+2 -2
View File
@@ -8,7 +8,7 @@
#include "parser.hpp" #include "parser.hpp"
#include "terminalframebuffer.hpp" #include "terminalframebuffer.hpp"
#include "terminalactionstate.hpp" #include "terminaldispatcher.hpp"
namespace Terminal { namespace Terminal {
class Emulator { class Emulator {
@@ -23,7 +23,7 @@ namespace Terminal {
private: private:
Parser::UTF8Parser parser; Parser::UTF8Parser parser;
Framebuffer fb; Framebuffer fb;
ActionState as; Dispatcher dispatch;
std::string terminal_to_host; std::string terminal_to_host;
+8 -8
View File
@@ -16,10 +16,10 @@ void Emulator::CSI_EL( void )
/* default: active position to end of line, inclusive */ /* default: active position to end of line, inclusive */
int start = fb.ds.get_cursor_col(), end = fb.ds.get_width() - 1; 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; start = 0;
end = fb.ds.get_cursor_col(); end = fb.ds.get_cursor_col();
} else if ( as.params == "2" ) { /* all of line */ } else if ( dispatch.params == "2" ) { /* all of line */
start = 0; start = 0;
} }
@@ -27,12 +27,12 @@ void Emulator::CSI_EL( void )
} }
void Emulator::CSI_ED( 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++ ) { for ( int y = 0; y < fb.ds.get_cursor_row(); y++ ) {
clearline( &fb, y, 0, fb.ds.get_width() - 1 ); clearline( &fb, y, 0, fb.ds.get_width() - 1 );
} }
clearline( &fb, -1, 0, fb.ds.get_cursor_col() ); 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++ ) { for ( int y = 0; y < fb.ds.get_height(); y++ ) {
clearline( &fb, y, 0, fb.ds.get_width() - 1 ); clearline( &fb, y, 0, fb.ds.get_width() - 1 );
} }
@@ -46,9 +46,9 @@ void Emulator::CSI_ED( void ) {
void Emulator::CSI_cursormove( 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': case 'A':
fb.ds.move_row( -num, true ); fb.ds.move_row( -num, true );
break; break;
@@ -63,8 +63,8 @@ void Emulator::CSI_cursormove( void )
break; break;
case 'H': case 'H':
case 'f': case 'f':
int x = as.getparam( 0, 1 ); int x = dispatch.getparam( 0, 1 );
int y = as.getparam( 1, 1 ); int y = dispatch.getparam( 1, 1 );
fb.ds.move_row( x - 1 ); fb.ds.move_row( x - 1 );
fb.ds.move_col( y - 1 ); fb.ds.move_col( y - 1 );
} }
@@ -2,16 +2,16 @@
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include "terminalactionstate.hpp" #include "terminaldispatcher.hpp"
#include "parseraction.hpp" #include "parseraction.hpp"
using namespace Terminal; using namespace Terminal;
ActionState::ActionState() Dispatcher::Dispatcher()
: params(), parsed_params(), parsed( false ), dispatch_chars() : 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->char_present );
assert( (act->ch == ';') || ( (act->ch >= '0') && (act->ch <= '9') ) ); assert( (act->ch == ';') || ( (act->ch >= '0') && (act->ch <= '9') ) );
@@ -23,7 +23,7 @@ void ActionState::newparamchar( Parser::Param *act )
parsed = false; parsed = false;
} }
void ActionState::collect( Parser::Collect *act ) void Dispatcher::collect( Parser::Collect *act )
{ {
assert( act->char_present ); assert( act->char_present );
if ( ( dispatch_chars.length() < 8 ) /* never should need more than 2 */ 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(); params.clear();
dispatch_chars.clear(); dispatch_chars.clear();
@@ -41,7 +41,7 @@ void ActionState::clear( Parser::Clear *act )
act->handled = true; act->handled = true;
} }
void ActionState::parse_params( void ) void Dispatcher::parse_params( void )
{ {
if ( parsed ) { if ( parsed ) {
return; return;
@@ -84,7 +84,7 @@ void ActionState::parse_params( void )
parsed = true; parsed = true;
} }
int ActionState::getparam( size_t N, int defaultval ) int Dispatcher::getparam( size_t N, int defaultval )
{ {
int ret = defaultval; int ret = defaultval;
if ( !parsed ) { if ( !parsed ) {
@@ -99,7 +99,7 @@ int ActionState::getparam( size_t N, int defaultval )
return ret; return ret;
} }
std::string ActionState::str( void ) std::string Dispatcher::str( void )
{ {
char assum[ 64 ]; char assum[ 64 ];
snprintf( assum, 64, "[dispatch=\"%s\" params=\"%s\"]", snprintf( assum, 64, "[dispatch=\"%s\" params=\"%s\"]",
@@ -1,5 +1,5 @@
#ifndef TERMINALACTIONSTATE_HPP #ifndef TERMINALDISPATCHER_HPP
#define TERMINALACTIONSTATE_HPP #define TERMINALDISPATCHER_HPP
#include <vector> #include <vector>
#include <string> #include <string>
@@ -11,7 +11,7 @@ namespace Parser {
} }
namespace Terminal { namespace Terminal {
class ActionState { class Dispatcher {
private: private:
public: /* tmp */ public: /* tmp */
std::string params; std::string params;
@@ -23,7 +23,7 @@ namespace Terminal {
void parse_params( void ); void parse_params( void );
public: public:
ActionState(); Dispatcher();
int getparam( size_t N, int defaultval ); int getparam( size_t N, int defaultval );
void newparamchar( Parser::Param *act ); void newparamchar( Parser::Param *act );