X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fentry.cpp;h=606f447b68c99ffdf8da7fce0495ed4709a73610;hb=720455325086e08bc9fdcd822d713480d0c2e0a0;hp=8b638dea2206f07fd4fb6bace8353c336fcc67c5;hpb=4ac5101da154d8130b606b4509c9750332365fef;p=libs%2Fgltk.git diff --git a/source/entry.cpp b/source/entry.cpp index 8b638de..606f447 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"); @@ -292,6 +298,18 @@ bool Entry::key_press(unsigned key, unsigned mod) text.offset_to_coords(edit_pos, row, col); set_edit_position(text.coords_to_offset(row, 0), mod==MOD_SHIFT); } + else if(key==Input::KEY_PGUP) + { + unsigned row, col; + text.offset_to_coords(edit_pos, row, col); + set_edit_position(text.coords_to_offset((row0) - 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)