LCOV - code coverage report
Current view: top level - src/terminal - terminaldispatcher.h (source / functions) Hit Total Coverage
Test: mosh-1.3.2 Code Coverage Lines: 2 2 100.0 %
Date: 2022-02-06 20:19:53 Functions: 0 0 -
Legend: Lines: hit not hit

          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 TERMINALDISPATCHER_HPP
      34             : #define TERMINALDISPATCHER_HPP
      35             : 
      36             : #include <vector>
      37             : #include <string>
      38             : #include <map>
      39             : 
      40             : namespace Parser {
      41             :   class Action;
      42             :   class Param;
      43             :   class Collect;
      44             :   class Clear;
      45             :   class Esc_Dispatch;
      46             :   class CSI_Dispatch;
      47             :   class Execute;
      48             :   class OSC_Start;
      49             :   class OSC_Put;
      50             :   class OSC_End;
      51             : }
      52             : 
      53             : namespace Terminal {
      54             :   class Framebuffer;
      55             :   class Dispatcher;
      56             : 
      57             :   enum Function_Type { ESCAPE, CSI, CONTROL };
      58             : 
      59             :   class Function {
      60             :   public:
      61             :     Function() : function( NULL ), clears_wrap_state( true ) {}
      62             :     Function( Function_Type type, const std::string & dispatch_chars,
      63             :               void (*s_function)( Framebuffer *, Dispatcher * ),
      64             :               bool s_clears_wrap_state = true );
      65             :     void (*function)( Framebuffer *, Dispatcher * );
      66             :     bool clears_wrap_state;
      67             :   };
      68             : 
      69             :   typedef std::map<std::string, Function> dispatch_map_t;
      70             : 
      71             :   class DispatchRegistry {
      72             :   public:
      73             :     dispatch_map_t escape;
      74             :     dispatch_map_t CSI;
      75             :     dispatch_map_t control;
      76             : 
      77        1352 :     DispatchRegistry() : escape(), CSI(), control() {}
      78             :   };
      79             : 
      80             :   DispatchRegistry & get_global_dispatch_registry( void );
      81             : 
      82             :   class Dispatcher {
      83             :   private:
      84             :     std::string params;
      85             :     std::vector<int> parsed_params;
      86             :     bool parsed;
      87             : 
      88             :     std::string dispatch_chars;
      89             :     std::vector<wchar_t> OSC_string; /* only used to set the window title */
      90             : 
      91             :     void parse_params( void );
      92             : 
      93             :   public:
      94             :     static const int PARAM_MAX = 65535;
      95             :     /* prevent evil escape sequences from causing long loops */
      96             : 
      97             :     std::string terminal_to_host; /* this is the reply string */
      98             : 
      99             :     Dispatcher();
     100             :     int getparam( size_t N, int defaultval );
     101             :     int param_count( void );
     102             : 
     103             :     void newparamchar( const Parser::Param *act );
     104             :     void collect( const Parser::Collect *act );
     105             :     void clear( const Parser::Clear *act );
     106             :     
     107             :     std::string str( void );
     108             : 
     109             :     void dispatch( Function_Type type, const Parser::Action *act, Framebuffer *fb );
     110        3775 :     std::string get_dispatch_chars( void ) const { return dispatch_chars; }
     111             :     std::vector<wchar_t> get_OSC_string( void ) const { return OSC_string; }
     112             : 
     113             :     void OSC_put( const Parser::OSC_Put *act );
     114             :     void OSC_start( const Parser::OSC_Start *act );
     115             :     void OSC_dispatch( const Parser::OSC_End *act, Framebuffer *fb );
     116             : 
     117             :     bool operator==( const Dispatcher &x ) const;
     118             :   };
     119             : }
     120             : 
     121             : #endif

Generated by: LCOV version 1.14