Line data Source code
1 : /* 2 : Mosh: the mobile shell 3 : Copyright 2012 Keith Winstein 4 : 5 : This program is free software: you can redistribute it and/or modify 6 : it under the terms of the GNU General Public License as published by 7 : the Free Software Foundation, either version 3 of the License, or 8 : (at your option) any later version. 9 : 10 : This program is distributed in the hope that it will be useful, 11 : but WITHOUT ANY WARRANTY; without even the implied warranty of 12 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 : GNU General Public License for more details. 14 : 15 : You should have received a copy of the GNU General Public License 16 : along with this program. If not, see <http://www.gnu.org/licenses/>. 17 : 18 : In addition, as a special exception, the copyright holders give 19 : permission to link the code of portions of this program with the 20 : OpenSSL library under certain conditions as described in each 21 : individual source file, and distribute linked combinations including 22 : the two. 23 : 24 : You must obey the GNU General Public License in all respects for all 25 : of the code used other than OpenSSL. If you modify file(s) with this 26 : exception, you may extend this exception to your version of the 27 : file(s), but you are not obligated to do so. If you do not wish to do 28 : so, delete this exception statement from your version. If you delete 29 : this exception statement from all source files in the program, then 30 : also delete it here. 31 : */ 32 : 33 : #ifndef TERMINAL_CPP 34 : #define TERMINAL_CPP 35 : 36 : #include <wchar.h> 37 : #include <stdio.h> 38 : #include <vector> 39 : #include <deque> 40 : 41 : #include "parseraction.h" 42 : #include "terminalframebuffer.h" 43 : #include "terminaldispatcher.h" 44 : #include "terminaluserinput.h" 45 : #include "terminaldisplay.h" 46 : 47 : namespace Terminal { 48 0 : class Emulator { 49 : friend void Parser::Print::act_on_terminal( Emulator * ) const; 50 : friend void Parser::Execute::act_on_terminal( Emulator * ) const; 51 : friend void Parser::Clear::act_on_terminal( Emulator * ) const; 52 : friend void Parser::Param::act_on_terminal( Emulator * ) const; 53 : friend void Parser::Collect::act_on_terminal( Emulator * ) const; 54 : friend void Parser::CSI_Dispatch::act_on_terminal( Emulator * ) const; 55 : friend void Parser::Esc_Dispatch::act_on_terminal( Emulator * ) const; 56 : friend void Parser::OSC_Start::act_on_terminal( Emulator * ) const; 57 : friend void Parser::OSC_Put::act_on_terminal( Emulator * ) const; 58 : friend void Parser::OSC_End::act_on_terminal( Emulator * ) const; 59 : 60 : friend void Parser::UserByte::act_on_terminal( Emulator * ) const; 61 : friend void Parser::Resize::act_on_terminal( Emulator * ) const; 62 : 63 : private: 64 : Framebuffer fb; 65 : Dispatcher dispatch; 66 : UserInput user; 67 : 68 : /* action methods */ 69 : void print( const Parser::Print *act ); 70 : void execute( const Parser::Execute *act ); 71 : void CSI_dispatch( const Parser::CSI_Dispatch *act ); 72 : void Esc_dispatch( const Parser::Esc_Dispatch *act ); 73 : void OSC_end( const Parser::OSC_End *act ); 74 : void resize( size_t s_width, size_t s_height ); 75 : 76 : public: 77 : Emulator( size_t s_width, size_t s_height ); 78 : 79 : std::string read_octets_to_host( void ); 80 : 81 30104 : const Framebuffer & get_fb( void ) const { return fb; } 82 : 83 : bool operator==( Emulator const &x ) const; 84 : }; 85 : } 86 : 87 : #endif