From 032549d7bf6c6fe1a54ca95a95941eb349c95a33 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 8 Mar 2019 18:28:24 +0100 Subject: GTextEditor: Refactor selection into a GTextRange class. This is a bit more expressive than "selection start + current cursor". --- Applications/TextEditor/main.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Applications') diff --git a/Applications/TextEditor/main.cpp b/Applications/TextEditor/main.cpp index 3ee579032c..b2381a8e48 100644 --- a/Applications/TextEditor/main.cpp +++ b/Applications/TextEditor/main.cpp @@ -29,8 +29,9 @@ int main(int argc, char** argv) text_editor->on_cursor_change = [statusbar] (GTextEditor& editor) { StringBuilder builder; builder.appendf("Line: %d, Column: %d", editor.cursor().line(), editor.cursor().column()); - if (editor.selection_start().is_valid()) { - builder.appendf(" Selection: [%d,%d]-[%d,%d]", editor.selection_start().line(), editor.selection_start().column(), editor.cursor().line(), editor.cursor().column()); + auto selection = editor.normalized_selection(); + if (selection.is_valid()) { + builder.appendf(" Selection: [%d,%d]-[%d,%d]", selection.start().line(), selection.start().column(), selection.end().line(), selection.end().column()); } statusbar->set_text(builder.to_string()); }; -- cgit v1.2.3