Coverage Report

Created: 2025-08-03 06:02

/src/mosh/src/terminal/terminaldisplay.h
Line
Count
Source (jump to first uncovered line)
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 TERMINALDISPLAY_HPP
34
#define TERMINALDISPLAY_HPP
35
36
#include "src/terminal/terminalframebuffer.h"
37
38
namespace Terminal {
39
/* variables used within a new_frame */
40
class FrameState
41
{
42
public:
43
  std::string str;
44
45
  int cursor_x, cursor_y;
46
  Renditions current_rendition;
47
  bool cursor_visible;
48
49
  const Framebuffer& last_frame;
50
51
  FrameState( const Framebuffer& s_last );
52
53
0
  void append( char c ) { str.append( 1, c ); }
54
0
  void append( size_t s, char c ) { str.append( s, c ); }
55
0
  void append( wchar_t wc ) { Cell::append_to_str( str, wc ); }
56
0
  void append( const char* s ) { str.append( s ); }
57
0
  void append_string( const std::string& append ) { str.append( append ); }
58
59
0
  void append_cell( const Cell& cell ) { cell.print_grapheme( str ); }
60
  void append_silent_move( int y, int x );
61
  void append_move( int y, int x );
62
  void update_rendition( const Renditions& r, bool force = false );
63
};
64
65
class Display
66
{
67
private:
68
  bool has_ech; /* erase character is part of vt200 but not supported by tmux
69
                   (or by "screen" terminfo entry, which is what tmux advertises) */
70
71
  bool has_bce; /* erases result in cell filled with background color */
72
73
  bool has_title; /* supports window title and icon name */
74
75
  const char *smcup, *rmcup; /* enter and exit alternate screen mode */
76
77
  bool put_row( bool initialized,
78
                FrameState& frame,
79
                const Framebuffer& f,
80
                int frame_y,
81
                const Row& old_row,
82
                bool wrap ) const;
83
84
public:
85
  std::string open() const;
86
  std::string close() const;
87
88
  std::string new_frame( bool initialized, const Framebuffer& last, const Framebuffer& f ) const;
89
90
  Display( bool use_environment );
91
};
92
}
93
94
#endif