diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-03-08 18:28:24 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-03-08 18:28:24 +0100 |
commit | 032549d7bf6c6fe1a54ca95a95941eb349c95a33 (patch) | |
tree | fc1b42140ee00502a972a3399b42ebbace687536 /Applications | |
parent | f40d11f06d78734d080cd1103c143da52204d20f (diff) | |
download | serenity-032549d7bf6c6fe1a54ca95a95941eb349c95a33.zip |
GTextEditor: Refactor selection into a GTextRange class.
This is a bit more expressive than "selection start + current cursor".
Diffstat (limited to 'Applications')
-rw-r--r-- | Applications/TextEditor/main.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
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()); }; |