Coverage Report

Created: 2025-11-24 06:39

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