+ unsigned start, end;
+ get_selection(start, end);
+
+ unsigned row, col;
+ text.offset_to_coords(start, row, col);
+ unsigned end_row, end_col;
+ text.offset_to_coords(end, end_row, end_col);
+
+ if(end_row<first_row || row>=first_row+visible_rows)
+ return;
+
+ if(row<first_row)
+ {
+ row = first_row;
+ col = 0;
+ }
+
+ if(end_row>=first_row+visible_rows)
+ {
+ end_row = first_row+visible_rows-1;
+ end_col = text.get_line_length(end_row);
+ }
+
+ while(row<=end_row)
+ {
+ unsigned ec = (row==end_row ? end_col : text.get_line_length(row));
+ if(ec>col)
+ {
+ Geometry rgeom = text.coords_to_geometry(*text_part, geom, first_row, row, col);
+ Geometry egeom = text.coords_to_geometry(*text_part, geom, first_row, row, ec);
+
+ GL::MeshBuilder bld(part_cache.create_mesh(part, *graphic->get_texture()));
+ bld.matrix() *= GL::Matrix::translation(rgeom.x, rgeom.y, 0);
+ graphic->build(egeom.x-rgeom.x, part.get_geometry().h, bld);
+ }
+
+ ++row;
+ col = 0;
+ }
+ }
+ else if(part.get_name()=="slider")
+ {
+ if(multiline)
+ {
+ reposition_child(*slider, part);
+ Widget::rebuild_special(part);
+ }
+ }
+ else
+ Widget::rebuild_special(part);
+}
+
+void Entry::render_special(const Part &part, GL::Renderer &renderer) const
+{
+ if(part.get_name()=="slider" && multiline)
+ slider->render(renderer);
+}
+
+void Entry::touch_press(int x, int y, unsigned finger)
+{
+ if(finger==0)
+ set_focus();
+ Widget::touch_press(x, y, finger);
+}
+
+bool Entry::key_press(unsigned key, unsigned mod)
+{
+ got_key_press = true;
+ if(key==Input::KEY_BACKSPACE)
+ {
+ if(selection_active)
+ erase_selection(true);
+ else if(edit_pos>0)
+ {
+ 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
+ {
+ 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");
+ else if(key==Input::KEY_END)
+ {
+ unsigned row, col;
+ text.offset_to_coords(edit_pos, row, col);
+ set_edit_position(text.coords_to_offset(row, text.get_line_length(row)), mod==MOD_SHIFT);
+ }
+ else if(key==Input::KEY_HOME)
+ {
+ unsigned row, col;
+ 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((row<visible_rows ? 0 : row-visible_rows), col), mod==MOD_SHIFT);
+ }
+ else if(key==Input::KEY_PGDN)
+ {
+ unsigned row, col;
+ text.offset_to_coords(edit_pos, row, col);
+ set_edit_position(text.coords_to_offset(row+visible_rows, col), mod==MOD_SHIFT);
+ }
+ else if(key==Input::KEY_LEFT && mod==MOD_SHIFT)
+ move_edit_position(NAV_LEFT, true);
+ else if(key==Input::KEY_RIGHT && mod==MOD_SHIFT)
+ move_edit_position(NAV_RIGHT, true);
+ else if(key==Input::KEY_UP && mod==MOD_SHIFT && multiline)
+ move_edit_position(NAV_UP, true);
+ else if(key==Input::KEY_DOWN && mod==MOD_SHIFT && multiline)
+ move_edit_position(NAV_DOWN, true);
+ else
+ return false;