24
24
#define ANSI_SAVE_CURSOR ESCAPE " 7"
25
25
#define ANSI_RESTORE_CURSOR ESCAPE " 8"
26
26
#define ANSI_CLEAR_BELOW ESCAPE " [J"
27
- #define ANSI_CURSOR_DOWN ESCAPE " [B"
28
- #define ANSI_CLEAR_LINE ESCAPE " [2K"
29
- #define ANSI_SET_SCROLL_ROWS ESCAPE " [0;%ur"
30
- #define ANSI_TO_START_OF_ROW ESCAPE " [%u;0f"
27
+ #define ANSI_CLEAR_SCREEN ESCAPE " [2J"
28
+ #define ANSI_SET_SCROLL_ROWS ESCAPE " [1;%ur"
29
+ #define ANSI_TO_START_OF_ROW ESCAPE " [%u;1f"
31
30
#define ANSI_REVERSE_VIDEO ESCAPE " [7m"
32
31
#define ANSI_UP_ROWS ESCAPE " [%dA"
33
32
@@ -43,10 +42,12 @@ Statusline::Statusline(Debugger &debugger)
43
42
Statusline::~Statusline () { Disable (); }
44
43
45
44
void Statusline::TerminalSizeChanged () {
46
- UpdateTerminalProperties ();
45
+ m_terminal_width = m_debugger.GetTerminalWidth ();
46
+ m_terminal_height = m_debugger.GetTerminalHeight ();
47
+
48
+ UpdateScrollWindow (ResizeStatusline);
47
49
48
- // This definitely isn't signal safe, but the best we can do, until we
49
- // have proper signal-catching thread.
50
+ // Draw the old statusline.
50
51
Redraw (/* update=*/ false );
51
52
}
52
53
@@ -87,38 +88,43 @@ void Statusline::Draw(std::string str) {
87
88
locked_stream << ANSI_RESTORE_CURSOR;
88
89
}
89
90
90
- void Statusline::UpdateTerminalProperties () {
91
- UpdateScrollWindow (DisableStatusline);
92
- m_terminal_width = m_debugger.GetTerminalWidth ();
93
- m_terminal_height = m_debugger.GetTerminalHeight ();
94
- UpdateScrollWindow (EnableStatusline);
95
- }
96
-
97
91
void Statusline::UpdateScrollWindow (ScrollWindowMode mode) {
98
92
assert (m_terminal_width != 0 && m_terminal_height != 0 );
99
93
100
94
lldb::LockableStreamFileSP stream_sp = m_debugger.GetOutputStreamSP ();
101
95
if (!stream_sp)
102
96
return ;
103
97
104
- const unsigned scroll_height =
105
- (mode == DisableStatusline) ? m_terminal_height : m_terminal_height - 1 ;
106
-
98
+ const unsigned reduced_scroll_window = m_terminal_height - 1 ;
107
99
LockedStreamFile locked_stream = stream_sp->Lock ();
108
- locked_stream << ANSI_SAVE_CURSOR;
109
- locked_stream.Printf (ANSI_SET_SCROLL_ROWS, scroll_height);
110
- locked_stream << ANSI_RESTORE_CURSOR;
100
+
111
101
switch (mode) {
112
102
case EnableStatusline:
113
103
// Move everything on the screen up.
114
- locked_stream.Printf (ANSI_UP_ROWS, 1 );
115
104
locked_stream << ' \n ' ;
105
+ locked_stream.Printf (ANSI_UP_ROWS, 1 );
106
+ // Reduce the scroll window.
107
+ locked_stream << ANSI_SAVE_CURSOR;
108
+ locked_stream.Printf (ANSI_SET_SCROLL_ROWS, reduced_scroll_window);
109
+ locked_stream << ANSI_RESTORE_CURSOR;
116
110
break ;
117
111
case DisableStatusline:
112
+ // Reset the scroll window.
113
+ locked_stream << ANSI_SAVE_CURSOR;
114
+ locked_stream.Printf (ANSI_SET_SCROLL_ROWS, 0 );
115
+ locked_stream << ANSI_RESTORE_CURSOR;
118
116
// Clear the screen below to hide the old statusline.
119
117
locked_stream << ANSI_CLEAR_BELOW;
120
118
break ;
119
+ case ResizeStatusline:
120
+ // Clear the screen and update the scroll window.
121
+ // FIXME: Find a better solution (#146919).
122
+ locked_stream << ANSI_CLEAR_SCREEN;
123
+ locked_stream.Printf (ANSI_SET_SCROLL_ROWS, reduced_scroll_window);
124
+ break ;
121
125
}
126
+
127
+ m_debugger.RefreshIOHandler ();
122
128
}
123
129
124
130
void Statusline::Redraw (bool update) {
0 commit comments