@@ -60,7 +60,7 @@ void Statusline::Enable() {
6060 UpdateTerminalProperties ();
6161
6262 // Reduce the scroll window to make space for the status bar below.
63- SetScrollWindow (m_terminal_height - 1 );
63+ UpdateScrollWindow (ScrollWindowShrink );
6464
6565 // Draw the statusline.
6666 Redraw ();
@@ -70,7 +70,7 @@ void Statusline::Disable() {
7070 UpdateTerminalProperties ();
7171
7272 // Extend the scroll window to cover the status bar.
73- SetScrollWindow (m_terminal_height );
73+ UpdateScrollWindow (ScrollWindowExtend );
7474}
7575
7676std::string Statusline::TrimAndPad (std::string str, size_t max_width) {
@@ -153,24 +153,35 @@ void Statusline::UpdateTerminalProperties() {
153153 m_terminal_height = m_debugger.GetTerminalHeight ();
154154
155155 // Set the scroll window based on the new terminal height.
156- SetScrollWindow (m_terminal_height - 1 );
156+ UpdateScrollWindow (ScrollWindowShrink );
157157
158158 // Clear the flag.
159159 m_terminal_size_has_changed = 0 ;
160160}
161161
162- void Statusline::SetScrollWindow (uint64_t height) {
163- if (lldb::LockableStreamFileSP stream_sp = m_debugger.GetOutputStreamSP ()) {
164- LockedStreamFile locked_stream = stream_sp->Lock ();
165- locked_stream << ' \n ' ;
166- locked_stream << ANSI_SAVE_CURSOR;
167- locked_stream.Printf (ANSI_SET_SCROLL_ROWS, static_cast <unsigned >(height));
168- locked_stream << ANSI_RESTORE_CURSOR;
169- locked_stream.Printf (ANSI_UP_ROWS, 1 );
162+ void Statusline::UpdateScrollWindow (ScrollWindowMode mode) {
163+ lldb::LockableStreamFileSP stream_sp = m_debugger.GetOutputStreamSP ();
164+ if (!stream_sp)
165+ return ;
166+
167+ const unsigned scroll_height =
168+ (mode == ScrollWindowExtend) ? m_terminal_height : m_terminal_height - 1 ;
169+
170+ LockedStreamFile locked_stream = stream_sp->Lock ();
171+ locked_stream << ANSI_SAVE_CURSOR;
172+ locked_stream.Printf (ANSI_SET_SCROLL_ROWS, scroll_height);
173+ locked_stream << ANSI_RESTORE_CURSOR;
174+ switch (mode) {
175+ case ScrollWindowExtend:
176+ // Clear the screen below to hide the old statusline.
170177 locked_stream << ANSI_CLEAR_BELOW;
178+ break ;
179+ case ScrollWindowShrink:
180+ // Move everything on the screen up.
181+ locked_stream.Printf (ANSI_UP_ROWS, 1 );
182+ locked_stream << ' \n ' ;
183+ break ;
171184 }
172-
173- m_scroll_height = height;
174185}
175186
176187void Statusline::Redraw (bool update) {
0 commit comments