summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Libraries/LibLine/Editor.cpp46
-rw-r--r--Libraries/LibLine/Editor.h12
-rw-r--r--Libraries/LibLine/SuggestionDisplay.h14
-rw-r--r--Libraries/LibLine/XtermSuggestionDisplay.cpp8
4 files changed, 40 insertions, 40 deletions
diff --git a/Libraries/LibLine/Editor.cpp b/Libraries/LibLine/Editor.cpp
index 697f6f3634..e67d212294 100644
--- a/Libraries/LibLine/Editor.cpp
+++ b/Libraries/LibLine/Editor.cpp
@@ -339,8 +339,8 @@ void Editor::save_to(JsonObject& object)
object.set("current_prompt", m_new_prompt);
object.set("was_interrupted", m_was_interrupted);
JsonObject display_area;
- display_area.set("top_left_x", m_origin_x);
- display_area.set("top_left_y", m_origin_y);
+ display_area.set("top_left_row", m_origin_row);
+ display_area.set("top_left_column", m_origin_column);
display_area.set("line_count", num_lines());
object.set("used_display_area", move(display_area));
}
@@ -658,7 +658,7 @@ void Editor::handle_read_event()
m_suggestion_display->display(m_suggestion_manager);
- m_origin_x = m_suggestion_display->origin_x();
+ m_origin_row = m_suggestion_display->origin_row();
}
}
@@ -940,7 +940,7 @@ void Editor::recalculate_origin()
// compensate for that.
if (m_cached_prompt_length >= m_num_columns) {
auto added_lines = (m_cached_prompt_length + 1) / m_num_columns - 1;
- m_origin_x += added_lines;
+ m_origin_row += added_lines;
}
// We also need to recalculate our cursor position,
@@ -1016,7 +1016,7 @@ void Editor::refresh_display()
if (!has_cleaned_up) {
cleanup();
}
- VT::move_absolute(m_origin_x, m_origin_y);
+ VT::move_absolute(m_origin_row, m_origin_column);
fputs(m_new_prompt.characters(), stdout);
@@ -1097,32 +1097,32 @@ void Editor::reposition_cursor()
auto line = cursor_line() - 1;
auto column = offset_in_line();
- VT::move_absolute(line + m_origin_x, column + m_origin_y);
+ VT::move_absolute(line + m_origin_row, column + m_origin_column);
}
-void VT::move_absolute(u32 x, u32 y)
+void VT::move_absolute(u32 row, u32 col)
{
- printf("\033[%d;%dH", x, y);
+ printf("\033[%d;%dH", row, col);
fflush(stdout);
}
-void VT::move_relative(int x, int y)
+void VT::move_relative(int row, int col)
{
char x_op = 'A', y_op = 'D';
- if (x > 0)
+ if (row > 0)
x_op = 'B';
else
- x = -x;
- if (y > 0)
+ row = -row;
+ if (col > 0)
y_op = 'C';
else
- y = -y;
+ col = -col;
- if (x > 0)
- printf("\033[%d%c", x, x_op);
- if (y > 0)
- printf("\033[%d%c", y, y_op);
+ if (row > 0)
+ printf("\033[%d%c", row, x_op);
+ if (col > 0)
+ printf("\033[%d%c", col, y_op);
}
Style Editor::find_applicable_style(size_t offset) const
@@ -1416,21 +1416,21 @@ Vector<size_t, 2> Editor::vt_dsr()
}
length += nread;
} while (buf[length - 1] != 'R' && length < 16);
- size_t x { 1 }, y { 1 };
+ size_t row { 1 }, col { 1 };
if (buf[0] == '\033' && buf[1] == '[') {
auto parts = StringView(buf + 2, length - 3).split_view(';');
bool ok;
- x = parts[0].to_int(ok);
+ row = parts[0].to_int(ok);
if (!ok) {
- dbg() << "Terminal DSR issue; received garbage x";
+ dbg() << "Terminal DSR issue; received garbage row";
}
- y = parts[1].to_int(ok);
+ col = parts[1].to_int(ok);
if (!ok) {
- dbg() << "Terminal DSR issue; received garbage y";
+ dbg() << "Terminal DSR issue; received garbage col";
}
}
- return { x, y };
+ return { row, col };
}
String Editor::line(size_t up_to_index) const
diff --git a/Libraries/LibLine/Editor.h b/Libraries/LibLine/Editor.h
index 3ebb9e1d52..c6846d851e 100644
--- a/Libraries/LibLine/Editor.h
+++ b/Libraries/LibLine/Editor.h
@@ -264,11 +264,11 @@ private:
set_origin(position[0], position[1]);
}
- void set_origin(int x, int y)
+ void set_origin(int row, int col)
{
- m_origin_x = x;
- m_origin_y = y;
- m_suggestion_display->set_origin(x, y, {});
+ m_origin_row = row;
+ m_origin_column = col;
+ m_suggestion_display->set_origin(row, col, {});
}
bool should_break_token(Vector<u32, 1024>& buffer, size_t index);
@@ -312,8 +312,8 @@ private:
bool m_cached_prompt_valid { false };
// Exact position before our prompt in the terminal.
- size_t m_origin_x { 0 };
- size_t m_origin_y { 0 };
+ size_t m_origin_row { 0 };
+ size_t m_origin_column { 0 };
OwnPtr<SuggestionDisplay> m_suggestion_display;
diff --git a/Libraries/LibLine/SuggestionDisplay.h b/Libraries/LibLine/SuggestionDisplay.h
index 6798ada5d8..346ee4bc59 100644
--- a/Libraries/LibLine/SuggestionDisplay.h
+++ b/Libraries/LibLine/SuggestionDisplay.h
@@ -45,18 +45,18 @@ public:
virtual void set_vt_size(size_t lines, size_t columns) = 0;
- size_t origin_x() const { return m_origin_x; }
- size_t origin_y() const { return m_origin_y; }
+ size_t origin_row() const { return m_origin_row; }
+ size_t origin_col() const { return m_origin_column; }
- void set_origin(int x, int y, Badge<Editor>)
+ void set_origin(int row, int col, Badge<Editor>)
{
- m_origin_x = x;
- m_origin_y = y;
+ m_origin_row = row;
+ m_origin_column = col;
}
protected:
- int m_origin_x { 0 };
- int m_origin_y { 0 };
+ int m_origin_row { 0 };
+ int m_origin_column { 0 };
};
class XtermSuggestionDisplay : public SuggestionDisplay {
diff --git a/Libraries/LibLine/XtermSuggestionDisplay.cpp b/Libraries/LibLine/XtermSuggestionDisplay.cpp
index d482e287ee..7cfff9999b 100644
--- a/Libraries/LibLine/XtermSuggestionDisplay.cpp
+++ b/Libraries/LibLine/XtermSuggestionDisplay.cpp
@@ -65,7 +65,7 @@ void XtermSuggestionDisplay::display(const SuggestionManager& manager)
longest_suggestion_length = 0;
}
- VT::move_absolute(max_line_count + m_origin_x, 1);
+ VT::move_absolute(max_line_count + m_origin_row, 1);
if (m_pages.is_empty()) {
size_t num_printed = 0;
@@ -142,8 +142,8 @@ void XtermSuggestionDisplay::display(const SuggestionManager& manager)
m_lines_used_for_last_suggestions = lines_used;
// If we filled the screen, move back the origin.
- if (m_origin_x + lines_used >= m_num_lines) {
- m_origin_x = m_num_lines - lines_used;
+ if (m_origin_row + lines_used >= m_num_lines) {
+ m_origin_row = m_num_lines - lines_used;
}
if (m_pages.size() > 1) {
@@ -156,7 +156,7 @@ void XtermSuggestionDisplay::display(const SuggestionManager& manager)
return;
}
- VT::move_absolute(m_origin_x + lines_used, m_num_columns - string.length() - 1);
+ VT::move_absolute(m_origin_row + lines_used, m_num_columns - string.length() - 1);
VT::apply_style({ Style::Background(Style::XtermColor::Green) });
fputs(string.characters(), stdout);
VT::apply_style(Style::reset_style());