From: Mikko Rasa Date: Thu, 12 Sep 2019 11:05:33 +0000 (+0300) Subject: Use the public functions also in internal edit operations of Entry X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=c0d7f013782ed5c55a8dd05f389ed110c7ebf982;p=libs%2Fgltk.git Use the public functions also in internal edit operations of Entry --- diff --git a/source/entry.cpp b/source/entry.cpp index 6d13ccd..21064f7 100644 --- a/source/entry.cpp +++ b/source/entry.cpp @@ -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::ustring(1, ch))); - ++edit_pos; - rebuild(); + insert(edit_pos, StringCodec::encode(StringCodec::ustring(1, ch))); return true; }