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) if (line->number == 1) elm_code_line_token_add(line, 17, 24, 1, ELM_CODE_TOKEN_TYPE_COMMENT); - else if (line->number == 4) - line->status = ELM_CODE_STATUS_TYPE_ERROR; + else if (line->number == 2) + { + line->status = ELM_CODE_STATUS_TYPE_ERROR; + line->status_text = " -> This warning is important!"; + } efl_event_callback_stop(event->object); } @@ -52,6 +55,7 @@ static Evas_Object * _elm_code_test_welcome_setup(Evas_Object *parent) { Elm_Code *code; + Elm_Code_Line *line; Elm_Code_Widget *widget; code = elm_code_create(); @@ -61,9 +65,9 @@ _elm_code_test_welcome_setup(Evas_Object *parent) efl_event_callback_add(widget, ELM_OBJ_CODE_WIDGET_EVENT_LINE_CLICKED, _elm_code_test_line_clicked_cb, code); _append_line(code->file, "❤ Hello World, Elm Code! ❤"); + _append_line(code->file, "*** Currently experimental ***"); _append_line(code->file, ""); _append_line(code->file, "This is a demo of elm_code's capabilities."); - _append_line(code->file, "⚑ *** Currently experimental ***"); evas_object_size_hint_weight_set(widget, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 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) elm_code_widget_selection_start(widget, 1, 3); elm_code_widget_selection_end(widget, 1, 13); + line = elm_code_file_line_get(code->file, 2); + elm_code_widget_line_status_toggle(widget, line); + return widget; } 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 return !!line && col <= (int) length; } -static void -_elm_code_widget_status_toggle(Elm_Code_Widget *widget, Elm_Code_Line *line) +EOLIAN static void +_elm_code_widget_line_status_toggle(Elm_Code_Widget *widget EINA_UNUSED, Elm_Code_Widget_Data *pd, + Elm_Code_Line *line) { Evas_Object *status, *grid; - Elm_Code_Widget_Data *pd; + const char *template = "%s"; + char *text; // add a status below the line if needed (and remove those no longer needed) - pd = efl_data_scope_get(widget, ELM_CODE_WIDGET_CLASS); grid = eina_list_nth(pd->grids, line->number - 1); status = evas_object_data_get(grid, "status"); @@ -748,7 +749,11 @@ _elm_code_widget_status_toggle(Elm_Code_Widget *widget, Elm_Code_Line *line) elm_box_pack_after(pd->gridbox, status, grid); evas_object_data_set(grid, "status", status); - elm_object_text_set(status, line->status_text); + + text = malloc((strlen(template) + strlen(line->status_text) + 1) * sizeof(char)); + sprintf(text, template, line->status_text); + elm_object_text_set(status, text); + free(text); } } @@ -903,7 +908,7 @@ _elm_code_widget_clicked_gutter_cb(Elm_Code_Widget *widget, unsigned int row) if (line->status_text) { - _elm_code_widget_status_toggle(widget, line); + elm_code_widget_line_status_toggle(widget, line); return; } 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) [[Get the column width of the gutter]] return: int; [[The current column width of the gutter for the widget.]] } - text_line_number_width_get { - [[Get the required column width]] - return: int; [[The column width required to represent the number of lines in the widget.]] - } text_between_positions_get { [[Get text between given positions]] params { @@ -272,6 +268,13 @@ class Elm.Code_Widget (Elm.Layout, Elm.Interface.Atspi.Text) } return: uint; [[Tabwidth]] } + line_status_toggle { + [[Toggle the display of the line status widget]] + params { + line: ptr(Elm_Code_Line); [[Code line]] + } + } + undo { [[Undo last action]] }