X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fentry.cpp;h=6554f7cb1b5ada9e52cf6cad423baedc9f30337d;hb=2aa99730d8c3106deeac1186e057055604835752;hp=8b638dea2206f07fd4fb6bace8353c336fcc67c5;hpb=4ac5101da154d8130b606b4509c9750332365fef;p=libs%2Fgltk.git diff --git a/source/entry.cpp b/source/entry.cpp index 8b638de..6554f7c 100644 --- a/source/entry.cpp +++ b/source/entry.cpp @@ -269,14 +269,20 @@ bool Entry::key_press(unsigned key, unsigned mod) if(selection_active) erase_selection(true); else if(edit_pos>0) - erase(edit_pos-1, 1); + { + unsigned start_pos = text.move_offset(edit_pos, -1); + erase(start_pos, edit_pos-start_pos); + } } else if(key==Input::KEY_DELETE) { if(selection_active) erase_selection(true); else - erase(edit_pos, 1); + { + unsigned end_pos = text.move_offset(edit_pos, 1); + erase(edit_pos, end_pos-edit_pos); + } } else if(key==Input::KEY_ENTER && multiline) insert(edit_pos, "\n"); @@ -378,15 +384,9 @@ void Entry::on_style_change() void Entry::move_edit_position(Navigation nav, bool select) { if(nav==NAV_LEFT) - { - if(edit_pos>0) - set_edit_position(edit_pos-1, select); - } + set_edit_position(text.move_offset(edit_pos, -1), select); else if(nav==NAV_RIGHT) - { - if(edit_pos0 ? text.coords_to_offset(row-1, col) : 0), select); } + else + throw invalid_argument("Entry::move_edit_position"); } void Entry::set_edit_position(unsigned ep, bool select)