]> git.tdb.fi Git - libs/gltk.git/commitdiff
Collapse the two implementations of Entry::set_edit_position
authorMikko Rasa <tdb@tdb.fi>
Thu, 12 Sep 2019 11:15:08 +0000 (14:15 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 12 Sep 2019 11:15:08 +0000 (14:15 +0300)
source/entry.cpp
source/entry.h

index 21064f728d151bbdd709ef8ab3869b85353c1e37..19bb7cc48b9f038d86d95401941e5b30f71cbe02 100644 (file)
@@ -93,18 +93,6 @@ void Entry::erase(unsigned pos, unsigned len)
 
        if(multiline)
                check_view_range();
-
-       rebuild();
-}
-
-void Entry::set_edit_position(unsigned pos)
-{
-       edit_pos = min(pos, text.size());
-       selection_active = false;
-
-       if(multiline)
-               check_view_range();
-
        rebuild();
 }
 
@@ -390,8 +378,9 @@ void Entry::set_edit_position(unsigned ep, bool select)
                selection_pos = edit_pos;
        selection_active = select;
 
-       edit_pos = ep;
-       check_view_range();
+       edit_pos = min(ep, text.size());
+       if(multiline)
+               check_view_range();
        rebuild();
 }
 
index a350ea8890d2e91b75093c73bf601983eafc2c54..b6b4998662a91cba957fe43396ec90316e34a15e 100644 (file)
@@ -63,7 +63,7 @@ public:
        void erase(unsigned, unsigned);
        const std::string &get_text() const { return text.get(); }
 
-       void set_edit_position(unsigned);
+       void set_edit_position(unsigned p) { set_edit_position(p, false); }
        unsigned get_edit_position() const { return edit_pos; }
        bool get_selection(unsigned &, unsigned &) const;