summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Williams <andy@andywilliams.me>2017-03-17 10:07:04 +0000
committerAndy Williams <andy@andywilliams.me>2017-03-17 10:07:04 +0000
commitf6434c0e0d91d353185a1ffc9dd5ce57f7a9db84 (patch)
treeb869b469b537f5ca8a369d27511339285e3887aa
parent85a27be447878084ebb8bd6f8a25c14ef4a1f50e (diff)
elm_code: Update and demo status messages inline
-rw-r--r--src/bin/elementary/test_code.c13
-rw-r--r--src/lib/elementary/elm_code_widget.c17
-rw-r--r--src/lib/elementary/elm_code_widget.eo11
3 files changed, 28 insertions, 13 deletions
diff --git a/src/bin/elementary/test_code.c b/src/bin/elementary/test_code.c
index 92f868fece..d385d2095a 100644
--- a/src/bin/elementary/test_code.c
+++ b/src/bin/elementary/test_code.c
@@ -42,8 +42,11 @@ _elm_code_test_line_done_cb(void *data EINA_UNUSED, const Efl_Event *event)
42 42
43 if (line->number == 1) 43 if (line->number == 1)
44 elm_code_line_token_add(line, 17, 24, 1, ELM_CODE_TOKEN_TYPE_COMMENT); 44 elm_code_line_token_add(line, 17, 24, 1, ELM_CODE_TOKEN_TYPE_COMMENT);
45 else if (line->number == 4) 45 else if (line->number == 2)
46 line->status = ELM_CODE_STATUS_TYPE_ERROR; 46 {
47 line->status = ELM_CODE_STATUS_TYPE_ERROR;
48 line->status_text = " -> This warning is important!";
49 }
47 50
48 efl_event_callback_stop(event->object); 51 efl_event_callback_stop(event->object);
49} 52}
@@ -52,6 +55,7 @@ static Evas_Object *
52_elm_code_test_welcome_setup(Evas_Object *parent) 55_elm_code_test_welcome_setup(Evas_Object *parent)
53{ 56{
54 Elm_Code *code; 57 Elm_Code *code;
58 Elm_Code_Line *line;
55 Elm_Code_Widget *widget; 59 Elm_Code_Widget *widget;
56 60
57 code = elm_code_create(); 61 code = elm_code_create();
@@ -61,9 +65,9 @@ _elm_code_test_welcome_setup(Evas_Object *parent)
61 efl_event_callback_add(widget, ELM_OBJ_CODE_WIDGET_EVENT_LINE_CLICKED, _elm_code_test_line_clicked_cb, code); 65 efl_event_callback_add(widget, ELM_OBJ_CODE_WIDGET_EVENT_LINE_CLICKED, _elm_code_test_line_clicked_cb, code);
62 66
63 _append_line(code->file, "❤ Hello World, Elm Code! ❤"); 67 _append_line(code->file, "❤ Hello World, Elm Code! ❤");
68 _append_line(code->file, "*** Currently experimental ***");
64 _append_line(code->file, ""); 69 _append_line(code->file, "");
65 _append_line(code->file, "This is a demo of elm_code's capabilities."); 70 _append_line(code->file, "This is a demo of elm_code's capabilities.");
66 _append_line(code->file, "⚑ *** Currently experimental ***");
67 71
68 evas_object_size_hint_weight_set(widget, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 72 evas_object_size_hint_weight_set(widget, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
69 evas_object_size_hint_align_set(widget, EVAS_HINT_FILL, EVAS_HINT_FILL); 73 evas_object_size_hint_align_set(widget, EVAS_HINT_FILL, EVAS_HINT_FILL);
@@ -72,6 +76,9 @@ _elm_code_test_welcome_setup(Evas_Object *parent)
72 elm_code_widget_selection_start(widget, 1, 3); 76 elm_code_widget_selection_start(widget, 1, 3);
73 elm_code_widget_selection_end(widget, 1, 13); 77 elm_code_widget_selection_end(widget, 1, 13);
74 78
79 line = elm_code_file_line_get(code->file, 2);
80 elm_code_widget_line_status_toggle(widget, line);
81
75 return widget; 82 return widget;
76} 83}
77 84
diff --git a/src/lib/elementary/elm_code_widget.c b/src/lib/elementary/elm_code_widget.c
index bc89223f74..8db374c056 100644
--- a/src/lib/elementary/elm_code_widget.c
+++ b/src/lib/elementary/elm_code_widget.c
@@ -722,14 +722,15 @@ _elm_code_widget_geometry_for_position_get(Elm_Code_Widget *widget, Elm_Code_Wid
722 return !!line && col <= (int) length; 722 return !!line && col <= (int) length;
723} 723}
724 724
725static void 725EOLIAN static void
726_elm_code_widget_status_toggle(Elm_Code_Widget *widget, Elm_Code_Line *line) 726_elm_code_widget_line_status_toggle(Elm_Code_Widget *widget EINA_UNUSED, Elm_Code_Widget_Data *pd,
727 Elm_Code_Line *line)
727{ 728{
728 Evas_Object *status, *grid; 729 Evas_Object *status, *grid;
729 Elm_Code_Widget_Data *pd; 730 const char *template = "<color=#8B8B8B>%s</color>";
731 char *text;
730 732
731 // add a status below the line if needed (and remove those no longer needed) 733 // add a status below the line if needed (and remove those no longer needed)
732 pd = efl_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
733 grid = eina_list_nth(pd->grids, line->number - 1); 734 grid = eina_list_nth(pd->grids, line->number - 1);
734 status = evas_object_data_get(grid, "status"); 735 status = evas_object_data_get(grid, "status");
735 736
@@ -748,7 +749,11 @@ _elm_code_widget_status_toggle(Elm_Code_Widget *widget, Elm_Code_Line *line)
748 749
749 elm_box_pack_after(pd->gridbox, status, grid); 750 elm_box_pack_after(pd->gridbox, status, grid);
750 evas_object_data_set(grid, "status", status); 751 evas_object_data_set(grid, "status", status);
751 elm_object_text_set(status, line->status_text); 752
753 text = malloc((strlen(template) + strlen(line->status_text) + 1) * sizeof(char));
754 sprintf(text, template, line->status_text);
755 elm_object_text_set(status, text);
756 free(text);
752 } 757 }
753} 758}
754 759
@@ -903,7 +908,7 @@ _elm_code_widget_clicked_gutter_cb(Elm_Code_Widget *widget, unsigned int row)
903 908
904 if (line->status_text) 909 if (line->status_text)
905 { 910 {
906 _elm_code_widget_status_toggle(widget, line); 911 elm_code_widget_line_status_toggle(widget, line);
907 return; 912 return;
908 } 913 }
909 914
diff --git a/src/lib/elementary/elm_code_widget.eo b/src/lib/elementary/elm_code_widget.eo
index 49a2ad81ba..ab129ca39b 100644
--- a/src/lib/elementary/elm_code_widget.eo
+++ b/src/lib/elementary/elm_code_widget.eo
@@ -227,10 +227,6 @@ class Elm.Code_Widget (Elm.Layout, Elm.Interface.Atspi.Text)
227 [[Get the column width of the gutter]] 227 [[Get the column width of the gutter]]
228 return: int; [[The current column width of the gutter for the widget.]] 228 return: int; [[The current column width of the gutter for the widget.]]
229 } 229 }
230 text_line_number_width_get {
231 [[Get the required column width]]
232 return: int; [[The column width required to represent the number of lines in the widget.]]
233 }
234 text_between_positions_get { 230 text_between_positions_get {
235 [[Get text between given positions]] 231 [[Get text between given positions]]
236 params { 232 params {
@@ -272,6 +268,13 @@ class Elm.Code_Widget (Elm.Layout, Elm.Interface.Atspi.Text)
272 } 268 }
273 return: uint; [[Tabwidth]] 269 return: uint; [[Tabwidth]]
274 } 270 }
271 line_status_toggle {
272 [[Toggle the display of the line status widget]]
273 params {
274 line: ptr(Elm_Code_Line); [[Code line]]
275 }
276 }
277
275 undo { 278 undo {
276 [[Undo last action]] 279 [[Undo last action]]
277 } 280 }