elm_code: Update and demo status messages inline

This commit is contained in:
Andy Williams 2017-03-17 10:07:04 +00:00
parent 85a27be447
commit f6434c0e0d
3 changed files with 28 additions and 13 deletions

View File

@ -42,8 +42,11 @@ _elm_code_test_line_done_cb(void *data EINA_UNUSED, const Efl_Event *event)
if (line->number == 1) if (line->number == 1)
elm_code_line_token_add(line, 17, 24, 1, ELM_CODE_TOKEN_TYPE_COMMENT); elm_code_line_token_add(line, 17, 24, 1, ELM_CODE_TOKEN_TYPE_COMMENT);
else if (line->number == 4) else if (line->number == 2)
line->status = ELM_CODE_STATUS_TYPE_ERROR; {
line->status = ELM_CODE_STATUS_TYPE_ERROR;
line->status_text = " -> This warning is important!";
}
efl_event_callback_stop(event->object); efl_event_callback_stop(event->object);
} }
@ -52,6 +55,7 @@ static Evas_Object *
_elm_code_test_welcome_setup(Evas_Object *parent) _elm_code_test_welcome_setup(Evas_Object *parent)
{ {
Elm_Code *code; Elm_Code *code;
Elm_Code_Line *line;
Elm_Code_Widget *widget; Elm_Code_Widget *widget;
code = elm_code_create(); 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); 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, "❤ Hello World, Elm Code! ❤");
_append_line(code->file, "*** Currently experimental ***");
_append_line(code->file, ""); _append_line(code->file, "");
_append_line(code->file, "This is a demo of elm_code's capabilities."); _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_weight_set(widget, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(widget, EVAS_HINT_FILL, EVAS_HINT_FILL); 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_start(widget, 1, 3);
elm_code_widget_selection_end(widget, 1, 13); 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; return widget;
} }

View File

@ -722,14 +722,15 @@ _elm_code_widget_geometry_for_position_get(Elm_Code_Widget *widget, Elm_Code_Wid
return !!line && col <= (int) length; return !!line && col <= (int) length;
} }
static void EOLIAN static void
_elm_code_widget_status_toggle(Elm_Code_Widget *widget, Elm_Code_Line *line) _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; Evas_Object *status, *grid;
Elm_Code_Widget_Data *pd; const char *template = "<color=#8B8B8B>%s</color>";
char *text;
// add a status below the line if needed (and remove those no longer needed) // 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); grid = eina_list_nth(pd->grids, line->number - 1);
status = evas_object_data_get(grid, "status"); 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); elm_box_pack_after(pd->gridbox, status, grid);
evas_object_data_set(grid, "status", status); 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) if (line->status_text)
{ {
_elm_code_widget_status_toggle(widget, line); elm_code_widget_line_status_toggle(widget, line);
return; return;
} }

View File

@ -227,10 +227,6 @@ class Elm.Code_Widget (Elm.Layout, Elm.Interface.Atspi.Text)
[[Get the column width of the gutter]] [[Get the column width of the gutter]]
return: int; [[The current column width of the gutter for the widget.]] 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 { text_between_positions_get {
[[Get text between given positions]] [[Get text between given positions]]
params { params {
@ -272,6 +268,13 @@ class Elm.Code_Widget (Elm.Layout, Elm.Interface.Atspi.Text)
} }
return: uint; [[Tabwidth]] return: uint; [[Tabwidth]]
} }
line_status_toggle {
[[Toggle the display of the line status widget]]
params {
line: ptr(Elm_Code_Line); [[Code line]]
}
}
undo { undo {
[[Undo last action]] [[Undo last action]]
} }