From 71e22ee041aea731a35df5158c9854f37dcc1e9b Mon Sep 17 00:00:00 2001 From: Keith Winstein Date: Sat, 13 Aug 2011 15:54:46 -0400 Subject: [PATCH] Add missed Terminal::Complete source files --- completeterminal.cpp | 30 ++++++++++++++++++++++++++++++ completeterminal.hpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 completeterminal.cpp create mode 100644 completeterminal.hpp diff --git a/completeterminal.cpp b/completeterminal.cpp new file mode 100644 index 0000000..2cfa53c --- /dev/null +++ b/completeterminal.cpp @@ -0,0 +1,30 @@ +#include "completeterminal.hpp" + +using namespace std; +using namespace Parser; + +string Terminal::Complete::act( const string &str ) +{ + for ( unsigned int i = 0; i < str.size(); i++ ) { + /* parse octet into up to three actions */ + list actions( parser.input( str[ i ] ) ); + + /* apply actions to terminal and delete them */ + for ( list::iterator it = actions.begin(); + it != actions.end(); + it++ ) { + Action *act = *it; + act->act_on_terminal( &terminal ); + delete act; + } + } + + return terminal.read_octets_to_host(); +} + +string Terminal::Complete::act( const Action *act ) +{ + /* apply action to terminal */ + act->act_on_terminal( &terminal ); + return terminal.read_octets_to_host(); +} diff --git a/completeterminal.hpp b/completeterminal.hpp new file mode 100644 index 0000000..e8bc4b5 --- /dev/null +++ b/completeterminal.hpp @@ -0,0 +1,28 @@ +#ifndef COMPLETE_TERMINAL_HPP +#define COMPLETE_TERMINAL_HPP + +#include "parser.hpp" +#include "terminal.hpp" + +/* This class represents the complete terminal -- a UTF8Parser feeding Actions to an Emulator. */ + +namespace Terminal { + class Complete { + private: + Parser::UTF8Parser parser; + Terminal::Emulator terminal; + + public: + Complete( size_t width, size_t height ) : parser(), terminal( width, height ) {} + + std::string act( const std::string &str ); + std::string act( const Parser::Action *act ); + + std::string open( void ) { return terminal.open(); } + std::string close( void ) { return terminal.close(); } + + const Framebuffer & get_fb( void ) { return terminal.get_fb(); } + }; +} + +#endif