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 PARSERACTION_HPP 34 : #define PARSERACTION_HPP 35 : 36 : #include <string> 37 : #include <vector> 38 : 39 : #include "shared.h" 40 : 41 : namespace Terminal { 42 : class Emulator; 43 : } 44 : 45 : namespace Parser { 46 18439 : class Action 47 : { 48 : public: 49 : wchar_t ch; 50 : bool char_present; 51 : 52 : virtual std::string name( void ) = 0; 53 : 54 0 : virtual void act_on_terminal( Terminal::Emulator * ) const {}; 55 : 56 72189527 : virtual bool ignore() const { return false; } 57 : 58 72455904 : Action() : ch( -1 ), char_present( false ) {}; 59 40163 : virtual ~Action() {}; 60 : }; 61 : 62 : typedef shared::shared_ptr<Action> ActionPointer; 63 : typedef std::vector<ActionPointer> Actions; 64 : 65 229564 : class Ignore : public Action { 66 : public: 67 0 : std::string name( void ) { return std::string( "Ignore" ); } 68 229564 : bool ignore() const { return true; } 69 : }; 70 24029016 : class Print : public Action { 71 : public: 72 0 : std::string name( void ) { return std::string( "Print" ); } 73 : void act_on_terminal( Terminal::Emulator *emu ) const; 74 : }; 75 47873869 : class Execute : public Action { 76 : public: 77 0 : std::string name( void ) { return std::string( "Execute" ); } 78 : void act_on_terminal( Terminal::Emulator *emu ) const; 79 : }; 80 60038 : class Clear : public Action { 81 : public: 82 0 : std::string name( void ) { return std::string( "Clear" ); } 83 : void act_on_terminal( Terminal::Emulator *emu ) const; 84 : }; 85 39253 : class Collect : public Action { 86 : public: 87 0 : std::string name( void ) { return std::string( "Collect" ); } 88 : void act_on_terminal( Terminal::Emulator *emu ) const; 89 : }; 90 187351 : class Param : public Action { 91 : public: 92 0 : std::string name( void ) { return std::string( "Param" ); } 93 : void act_on_terminal( Terminal::Emulator *emu ) const; 94 : }; 95 4 : class Esc_Dispatch : public Action { 96 : public: 97 0 : std::string name( void ) { return std::string( "Esc_Dispatch" ); } 98 : void act_on_terminal( Terminal::Emulator *emu ) const; 99 : }; 100 30017 : class CSI_Dispatch : public Action { 101 : public: 102 0 : std::string name( void ) { return std::string( "CSI_Dispatch" ); } 103 : void act_on_terminal( Terminal::Emulator *emu ) const; 104 : }; 105 0 : class Hook : public Action { 106 0 : public: std::string name( void ) { return std::string( "Hook" ); } 107 : }; 108 0 : class Put : public Action { 109 0 : public: std::string name( void ) { return std::string( "Put" ); } 110 : }; 111 0 : class Unhook : public Action { 112 0 : public: std::string name( void ) { return std::string( "Unhook" ); } 113 : }; 114 0 : class OSC_Start : public Action { 115 : public: 116 0 : std::string name( void ) { return std::string( "OSC_Start" ); } 117 : void act_on_terminal( Terminal::Emulator *emu ) const; 118 : }; 119 0 : class OSC_Put : public Action { 120 : public: 121 0 : std::string name( void ) { return std::string( "OSC_Put" ); } 122 : void act_on_terminal( Terminal::Emulator *emu ) const; 123 : }; 124 0 : class OSC_End : public Action { 125 : public: 126 0 : std::string name( void ) { return std::string( "OSC_End" ); } 127 : void act_on_terminal( Terminal::Emulator *emu ) const; 128 : }; 129 : 130 20311 : class UserByte : public Action { 131 : /* user keystroke -- not part of the host-source state machine*/ 132 : public: 133 : char c; /* The user-source byte. We don't try to interpret the charset */ 134 : 135 0 : std::string name( void ) { return std::string( "UserByte" ); } 136 : void act_on_terminal( Terminal::Emulator *emu ) const; 137 : 138 3545 : UserByte( int s_c ) : c( s_c ) {} 139 : 140 8773 : bool operator==( const UserByte &other ) const 141 : { 142 8773 : return c == other.c; 143 : } 144 : }; 145 : 146 21069 : class Resize : public Action { 147 : /* resize event -- not part of the host-source state machine*/ 148 : public: 149 : size_t width, height; 150 : 151 0 : std::string name( void ) { return std::string( "Resize" ); } 152 : void act_on_terminal( Terminal::Emulator *emu ) const; 153 : 154 5117 : Resize( size_t s_width, size_t s_height ) 155 4125 : : width( s_width ), 156 5117 : height( s_height ) 157 : {} 158 : 159 8773 : bool operator==( const Resize &other ) const 160 : { 161 8773 : return ( width == other.width ) && ( height == other.height ); 162 : } 163 : }; 164 : } 165 : 166 : #endif