]> git.tdb.fi Git - libs/gltk.git/commitdiff
Use the public functions also in internal edit operations of Entry
authorMikko Rasa <tdb@tdb.fi>
Thu, 12 Sep 2019 11:05:33 +0000 (14:05 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 12 Sep 2019 11:05:33 +0000 (14:05 +0300)
source/entry.cpp

index 6d13ccdd0377eaaff11b29db0c27981d5b9cacc0..21064f728d151bbdd709ef8ab3869b85353c1e37 100644 (file)
@@ -252,25 +252,17 @@ bool Entry::key_press(unsigned key, unsigned mod)
                if(selection_active)
                        erase_selection();
                else if(edit_pos>0)
-               {
-                       text.erase(--edit_pos, 1);
-                       check_view_range();
-                       rebuild();
-               }
+                       erase(edit_pos-1, 1);
        }
        else if(key==Input::KEY_DELETE)
        {
                if(selection_active)
                        erase_selection();
                else
-                       text.erase(edit_pos, 1);
+                       erase(edit_pos, 1);
        }
        else if(key==Input::KEY_ENTER && multiline)
-       {
-               text.insert(edit_pos++, "\n");
-               check_view_range();
-               rebuild();
-       }
+               insert(edit_pos, "\n");
        else if(key==Input::KEY_END)
        {
                unsigned row, col;
@@ -303,9 +295,7 @@ bool Entry::character(wchar_t ch)
        {
                if(selection_active)
                        erase_selection();
-               text.insert(edit_pos, StringCodec::encode<StringCodec::Utf8>(StringCodec::ustring(1, ch)));
-               ++edit_pos;
-               rebuild();
+               insert(edit_pos, StringCodec::encode<StringCodec::Utf8>(StringCodec::ustring(1, ch)));
                return true;
        }