mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:27:35 +00:00
LibVT: Store all-ASCII terminal lines as 8-bit characters
To conserve memory, we now use byte storage for terminal lines until we encounter a non-ASCII codepoint. At that point, we transparently switch to UTF-32 storage for that one line.
This commit is contained in:
parent
a398898c12
commit
7b5b4bee70
4 changed files with 78 additions and 26 deletions
|
@ -339,7 +339,7 @@ void TerminalWidget::paint_event(GUI::PaintEvent& event)
|
|||
painter.clear_rect(row_rect, color_from_rgb(line.attributes()[0].background_color).with_alpha(m_opacity));
|
||||
|
||||
for (size_t column = 0; column < line.length(); ++column) {
|
||||
u32 codepoint = line.codepoints()[column];
|
||||
u32 codepoint = line.codepoint(column);
|
||||
bool should_reverse_fill_for_cursor_or_selection = m_cursor_blink_state
|
||||
&& m_has_logical_focus
|
||||
&& visual_row == row_with_cursor
|
||||
|
@ -560,16 +560,16 @@ void TerminalWidget::doubleclick_event(GUI::MouseEvent& event)
|
|||
|
||||
auto position = buffer_position_at(event.position());
|
||||
auto& line = m_terminal.line(position.row());
|
||||
bool want_whitespace = line.codepoints()[position.column()] == ' ';
|
||||
bool want_whitespace = line.codepoint(position.column()) == ' ';
|
||||
|
||||
int start_column = 0;
|
||||
int end_column = 0;
|
||||
|
||||
for (int column = position.column(); column >= 0 && (line.codepoints()[column] == ' ') == want_whitespace; --column) {
|
||||
for (int column = position.column(); column >= 0 && (line.codepoint(column) == ' ') == want_whitespace; --column) {
|
||||
start_column = column;
|
||||
}
|
||||
|
||||
for (int column = position.column(); column < m_terminal.columns() && (line.codepoints()[column] == ' ') == want_whitespace; ++column) {
|
||||
for (int column = position.column(); column < m_terminal.columns() && (line.codepoint(column) == ' ') == want_whitespace; ++column) {
|
||||
end_column = column;
|
||||
}
|
||||
|
||||
|
@ -739,7 +739,7 @@ String TerminalWidget::selected_text() const
|
|||
builder.append('\n');
|
||||
break;
|
||||
}
|
||||
builder.append(line.codepoints()[column]);
|
||||
builder.append(line.codepoint(column));
|
||||
if (column == line.length() - 1 || (m_rectangle_selection && column == last_column)) {
|
||||
builder.append('\n');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue