mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
LibVT: Add scrollback history to VT::Terminal
The default (hard-coded) history size is 500 lines. When the history is altered, the TerminalClient is notified via terminal_history_changed().
This commit is contained in:
parent
a5cdd0afa5
commit
462336ed49
Notes:
sideshowbarker
2024-07-19 12:35:37 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/462336ed495
@ -666,6 +666,13 @@ void Terminal::scroll_up()
|
|||||||
{
|
{
|
||||||
// NOTE: We have to invalidate the cursor first.
|
// NOTE: We have to invalidate the cursor first.
|
||||||
invalidate_cursor();
|
invalidate_cursor();
|
||||||
|
if (m_scroll_region_top == 0) {
|
||||||
|
auto line = move(m_lines.ptr_at(m_scroll_region_top));
|
||||||
|
m_history.append(move(line));
|
||||||
|
while (m_history.size() > max_history_size())
|
||||||
|
m_history.take_first();
|
||||||
|
m_client.terminal_history_changed();
|
||||||
|
}
|
||||||
m_lines.remove(m_scroll_region_top);
|
m_lines.remove(m_scroll_region_top);
|
||||||
m_lines.insert(m_scroll_region_bottom, make<Line>(m_columns));
|
m_lines.insert(m_scroll_region_bottom, make<Line>(m_columns));
|
||||||
m_need_full_flush = true;
|
m_need_full_flush = true;
|
||||||
|
@ -14,6 +14,7 @@ public:
|
|||||||
virtual void beep() = 0;
|
virtual void beep() = 0;
|
||||||
virtual void set_window_title(const StringView&) = 0;
|
virtual void set_window_title(const StringView&) = 0;
|
||||||
virtual void terminal_did_resize(u16 columns, u16 rows) = 0;
|
virtual void terminal_did_resize(u16 columns, u16 rows) = 0;
|
||||||
|
virtual void terminal_history_changed() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Attribute {
|
struct Attribute {
|
||||||
@ -98,6 +99,9 @@ public:
|
|||||||
return m_lines[index];
|
return m_lines[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int max_history_size() const { return 500; }
|
||||||
|
const NonnullOwnPtrVector<Line>& history() const { return m_history; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef Vector<unsigned, 4> ParamVector;
|
typedef Vector<unsigned, 4> ParamVector;
|
||||||
|
|
||||||
@ -137,6 +141,7 @@ private:
|
|||||||
|
|
||||||
TerminalClient& m_client;
|
TerminalClient& m_client;
|
||||||
|
|
||||||
|
NonnullOwnPtrVector<Line> m_history;
|
||||||
NonnullOwnPtrVector<Line> m_lines;
|
NonnullOwnPtrVector<Line> m_lines;
|
||||||
|
|
||||||
int m_scroll_region_top { 0 };
|
int m_scroll_region_top { 0 };
|
||||||
|
Loading…
Reference in New Issue
Block a user