From 7f727c13666f20adc48513a3c039cd201d2f2d68 Mon Sep 17 00:00:00 2001 From: Alastair Poole Date: Sun, 9 Feb 2020 21:14:42 +0000 Subject: [PATCH] elm_code_widget: Display cursor within widget. Only render the cursor when its within the bounds of the widget. --- src/lib/elementary/elm_code_widget.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/lib/elementary/elm_code_widget.c b/src/lib/elementary/elm_code_widget.c index 32dcbf80b9..9b488caaba 100644 --- a/src/lib/elementary/elm_code_widget.c +++ b/src/lib/elementary/elm_code_widget.c @@ -311,6 +311,7 @@ _elm_code_widget_fill_whitespace(Elm_Code_Widget *widget, Eina_Unicode character static void _elm_code_widget_cursor_update(Elm_Code_Widget *widget, Elm_Code_Widget_Data *pd) { + Evas_Coord oy, oh; Evas_Coord cx = 0, cy = 0, cw = 0, ch = 0; elm_code_widget_geometry_for_position_get(widget, pd->cursor_line, pd->cursor_col, &cx, &cy, &cw, &ch); @@ -324,8 +325,15 @@ _elm_code_widget_cursor_update(Elm_Code_Widget *widget, Elm_Code_Widget_Data *pd elm_layout_signal_emit(pd->cursor_rect, "elm,action,focus", "elm"); } - evas_object_geometry_set(pd->cursor_rect, cx, cy, cw/8, ch); - evas_object_show(pd->cursor_rect); + evas_object_geometry_get(widget, NULL, &oy, NULL, &oh); + + if ((cy < oy) || (cy > (oy + oh - ch))) + evas_object_hide(pd->cursor_rect); + else + { + evas_object_geometry_set(pd->cursor_rect, cx, cy, cw/8, ch); + evas_object_show(pd->cursor_rect); + } } static void @@ -1110,7 +1118,7 @@ _elm_code_widget_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj _popup_menu_show(widget, event->canvas.x, event->canvas.y); return; } - else if (event->button == 2) + else if (event->button == 2) { _mouse_selection_paste_at_position(widget, row, col); return;