ajwillia-ms pushed a commit to branch master.

http://git.enlightenment.org/tools/edi.git/commit/?id=1971583e5e7914c66cd96d802befe0536e556d73

commit 1971583e5e7914c66cd96d802befe0536e556d73
Author: Andy Williams <[email protected]>
Date:   Thu Apr 7 17:44:12 2016 +0100

    [help] Stub out a right-click-help UI
    
    Not looking anything up yet but we're getting started
---
 elm_code/src/lib/widget/elm_code_widget.c  |  6 +++--
 elm_code/src/lib/widget/elm_code_widget.eo | 10 +++++++++
 src/bin/editor/edi_editor.c                | 35 ++++++++++++++++++++++++------
 3 files changed, 42 insertions(+), 9 deletions(-)

diff --git a/elm_code/src/lib/widget/elm_code_widget.c 
b/elm_code/src/lib/widget/elm_code_widget.c
index 7c4d681..2ce6496 100644
--- a/elm_code/src/lib/widget/elm_code_widget.c
+++ b/elm_code/src/lib/widget/elm_code_widget.c
@@ -603,11 +603,12 @@ _elm_code_widget_cursor_move(Elm_Code_Widget *widget, 
Elm_Code_Widget_Data *pd,
    _elm_code_widget_fill_line(widget, elm_code_file_line_get(pd->code->file, 
pd->cursor_line));
 }
 
-static Eina_Bool
-_elm_code_widget_position_at_coordinates_get(Elm_Code_Widget *widget, 
Elm_Code_Widget_Data *pd,
+EOLIAN static Eina_Bool
+_elm_code_widget_position_at_coordinates_get(Eo *obj, Elm_Code_Widget_Data *pd,
                                              Evas_Coord x, Evas_Coord y,
                                              unsigned int *row, int *col)
 {
+   Elm_Code_Widget *widget;
    Eina_List *item;
    Elm_Code_Line *line;
    Evas_Coord ox, oy, sx, sy, rowy;
@@ -615,6 +616,7 @@ 
_elm_code_widget_position_at_coordinates_get(Elm_Code_Widget *widget, Elm_Code_W
    int cw, ch, gutter;
    unsigned int guess, number;
 
+   widget = (Elm_Code_Widget *)obj;
    evas_object_geometry_get(widget, &ox, &oy, NULL, NULL);
    elm_scroller_region_get(pd->scroller, &sx, &sy, NULL, NULL);
    x = x + sx - ox;
diff --git a/elm_code/src/lib/widget/elm_code_widget.eo 
b/elm_code/src/lib/widget/elm_code_widget.eo
index b55b2fc..6354ecd 100644
--- a/elm_code/src/lib/widget/elm_code_widget.eo
+++ b/elm_code/src/lib/widget/elm_code_widget.eo
@@ -177,6 +177,16 @@ class Elm.Code_Widget (Elm.Layout, 
Elm.Interface_Atspi_Text)
       lines_visible_get {
          return: uint; [[the number of lines currently visible in the widget.]]
       }
+      position_at_coordinates_get {
+         [[get the row, col position for a given coordinate on the widget.]]
+         params {
+            x: Evas_Coord; [[the x coordinate in the widget]]
+            y: Evas_Coord; [[the y coordinate in the widget]]
+            row: uint *; [[the row for the coordinates]]
+            col: int *; [[the column for the coordinates]]
+         }
+         return: bool; [[true if a line exists at these coordinates]]
+      }
 
       //text functions
       text_left_gutter_width_get {
diff --git a/src/bin/editor/edi_editor.c b/src/bin/editor/edi_editor.c
index 453bcb7..7bdea91 100644
--- a/src/bin/editor/edi_editor.c
+++ b/src/bin/editor/edi_editor.c
@@ -466,15 +466,36 @@ _unfocused_cb(void *data, Evas_Object *obj EINA_UNUSED, 
void *event_info EINA_UN
 }
 
 static void
-_gutter_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
-                   void *event_info)
+_mouse_up_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED,
+             Evas_Object *obj EINA_UNUSED, void *event_info)
 {
-   Elm_Code_Line *line;
+   Elm_Code_Widget *widget;
+   Evas_Object *popup;
+   Evas_Event_Mouse_Up *event;
+   unsigned int row;
+   int col;
+   const char *word;
+
+   widget = (Elm_Code_Widget *)data;
+   event = (Evas_Event_Mouse_Up *)event_info;
+
+   if (event->button != 3)
+     return;
+
+   elm_code_widget_position_at_coordinates_get(widget, event->canvas.x, 
event->canvas.y, &row, &col);
+   elm_code_widget_selection_select_word(widget, row, col);
+   word = elm_code_widget_selection_text_get(widget);
+   if (!word || !strlen(word))
+     return;
+
+   popup = elm_popup_add(widget);
+   elm_popup_timeout_set(popup,1.5);
 
-   line = (Elm_Code_Line *)event_info;
+   elm_object_style_set(popup, "transparent");
+   elm_object_part_text_set(popup, "title,text", word);
+   elm_object_text_set(popup, "No help available for this term");
 
-   if (line->status_text)
-     printf("CLANG %s\n", line->status_text);
+   evas_object_show(popup);
 }
 
 static void
@@ -557,7 +578,7 @@ edi_editor_add(Evas_Object *parent, Edi_Mainview_Item *item)
    evas_object_event_callback_add(widget, EVAS_CALLBACK_KEY_DOWN,
                                   _smart_cb_key_down, editor);
    evas_object_smart_callback_add(widget, "changed,user", _changed_cb, editor);
-   evas_object_smart_callback_add(widget, "line,gutter,clicked", 
_gutter_clicked_cb, editor);
+   evas_object_event_callback_add(widget, EVAS_CALLBACK_MOUSE_UP, 
_mouse_up_cb, widget);
    evas_object_smart_callback_add(widget, "unfocused", _unfocused_cb, editor);
 
    elm_code_parser_standard_add(code, ELM_CODE_PARSER_STANDARD_TODO);

-- 


Reply via email to