From fa949807cca17c8c247e37a885e83b90c6176a21 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 12 Sep 2019 15:03:10 +0300 Subject: [PATCH] Avoid duplicating the logic in Entry::get_selection --- source/entry.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/source/entry.cpp b/source/entry.cpp index 19bb7cc..fec2739 100644 --- a/source/entry.cpp +++ b/source/entry.cpp @@ -165,10 +165,8 @@ void Entry::rebuild_special(const Part &part) if(!text_part || !graphic || !graphic->get_texture()) return; - unsigned start = selection_pos; - unsigned end = edit_pos; - if(start>end) - swap(start, end); + unsigned start, end; + get_selection(start, end); unsigned row, col; text.offset_to_coords(start, row, col); @@ -386,14 +384,10 @@ void Entry::set_edit_position(unsigned ep, bool select) void Entry::erase_selection() { - if(!selection_active) + unsigned start, end; + if(!get_selection(start, end)) return; - unsigned start = selection_pos; - unsigned end = edit_pos; - if(start>end) - swap(start, end); - text.erase(start, end-start); set_edit_position(start, false); } -- 2.43.0