1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:37:35 +00:00

LibVT: Make selection follow terminal history scrollback :^)

The buffer positions referred to by a VT::Position now include history
scrollback, meaning that a VT::Position with row=0 is at the start of
the history.

The active terminal buffer keeps moving in VT::Position coordinates
whenever we scroll. This allows selection to follow history. It also
allows us to click hyperlinks in history.

Fixes #957.
This commit is contained in:
Andreas Kling 2020-05-10 16:59:02 +02:00
parent c50672a19d
commit 901d2e3236
3 changed files with 27 additions and 25 deletions

View file

@ -37,7 +37,7 @@ namespace VT {
class TerminalClient {
public:
virtual ~TerminalClient() { }
virtual ~TerminalClient() {}
virtual void beep() = 0;
virtual void set_window_title(const StringView&) = 0;
@ -126,15 +126,22 @@ public:
u16 m_length { 0 };
};
size_t line_count() const
{
return m_history.size() + m_lines.size();
}
Line& line(size_t index)
{
ASSERT(index < m_rows);
return m_lines[index];
if (index < m_history.size())
return m_history[index];
return m_lines[index - m_history.size()];
}
const Line& line(size_t index) const
{
ASSERT(index < m_rows);
return m_lines[index];
if (index < m_history.size())
return m_history[index];
return m_lines[index - m_history.size()];
}
size_t max_history_size() const { return 500; }