mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 09:37:34 +00:00
LibVT: Make terminal scrollback max size configurable
This commit is contained in:
parent
158fe9d9ca
commit
5c8b48053e
2 changed files with 32 additions and 1 deletions
|
@ -93,7 +93,31 @@ public:
|
||||||
return m_lines[index];
|
return m_lines[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t max_history_size() const { return 500; }
|
size_t max_history_size() const { return m_max_history_lines; }
|
||||||
|
void set_max_history_size(size_t value)
|
||||||
|
{
|
||||||
|
if (value == 0) {
|
||||||
|
m_max_history_lines = 0;
|
||||||
|
m_history_start = 0;
|
||||||
|
m_history.clear();
|
||||||
|
m_client.terminal_history_changed();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_max_history_lines > value) {
|
||||||
|
NonnullOwnPtrVector<Line> new_history;
|
||||||
|
new_history.ensure_capacity(value);
|
||||||
|
auto existing_line_count = min(m_history.size(), value);
|
||||||
|
for (size_t i = m_history.size() - existing_line_count; i < m_history.size(); ++i) {
|
||||||
|
auto j = (m_history_start + i) % m_history.size();
|
||||||
|
new_history.unchecked_append(move(static_cast<Vector<NonnullOwnPtr<Line>>&>(m_history).at(j)));
|
||||||
|
}
|
||||||
|
m_history = move(new_history);
|
||||||
|
m_history_start = 0;
|
||||||
|
m_client.terminal_history_changed();
|
||||||
|
}
|
||||||
|
m_max_history_lines = value;
|
||||||
|
}
|
||||||
size_t history_size() const { return m_history.size(); }
|
size_t history_size() const { return m_history.size(); }
|
||||||
|
|
||||||
void inject_string(const StringView&);
|
void inject_string(const StringView&);
|
||||||
|
@ -156,6 +180,9 @@ private:
|
||||||
NonnullOwnPtrVector<Line> m_history;
|
NonnullOwnPtrVector<Line> m_history;
|
||||||
void add_line_to_history(NonnullOwnPtr<Line>&& line)
|
void add_line_to_history(NonnullOwnPtr<Line>&& line)
|
||||||
{
|
{
|
||||||
|
if (max_history_size() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
if (m_history.size() < max_history_size()) {
|
if (m_history.size() < max_history_size()) {
|
||||||
ASSERT(m_history_start == 0);
|
ASSERT(m_history_start == 0);
|
||||||
m_history.append(move(line));
|
m_history.append(move(line));
|
||||||
|
@ -210,6 +237,7 @@ private:
|
||||||
Vector<bool> m_horizontal_tabs;
|
Vector<bool> m_horizontal_tabs;
|
||||||
u8 m_final { 0 };
|
u8 m_final { 0 };
|
||||||
u32 m_last_code_point { 0 };
|
u32 m_last_code_point { 0 };
|
||||||
|
size_t m_max_history_lines { 1024 };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,6 +79,9 @@ public:
|
||||||
int scroll_length() const;
|
int scroll_length() const;
|
||||||
void set_scroll_length(int);
|
void set_scroll_length(int);
|
||||||
|
|
||||||
|
size_t max_history_size() const { return m_terminal.max_history_size(); }
|
||||||
|
void set_max_history_size(size_t value) { m_terminal.set_max_history_size(value); }
|
||||||
|
|
||||||
GUI::Action& copy_action() { return *m_copy_action; }
|
GUI::Action& copy_action() { return *m_copy_action; }
|
||||||
GUI::Action& paste_action() { return *m_paste_action; }
|
GUI::Action& paste_action() { return *m_paste_action; }
|
||||||
GUI::Action& clear_including_history_action() { return *m_clear_including_history_action; }
|
GUI::Action& clear_including_history_action() { return *m_clear_including_history_action; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue