forked from enlightenment/efl
Elm: Dont insert errors by default in code
Instead insert the line if the gutter is clicked. And provide a tooltip!
This commit is contained in:
parent
d7e261c3e6
commit
8f96646605
|
@ -316,7 +316,7 @@ _elm_code_widget_fill_line(Elm_Code_Widget *widget, Elm_Code_Line *line)
|
||||||
Eina_Unicode unichr;
|
Eina_Unicode unichr;
|
||||||
unsigned int length, x, charwidth, i, w;
|
unsigned int length, x, charwidth, i, w;
|
||||||
int chrpos, gutter;
|
int chrpos, gutter;
|
||||||
Evas_Object *grid, *status;
|
Evas_Object *grid;
|
||||||
Evas_Textgrid_Cell *cells;
|
Evas_Textgrid_Cell *cells;
|
||||||
Elm_Code_Widget_Data *pd;
|
Elm_Code_Widget_Data *pd;
|
||||||
|
|
||||||
|
@ -365,30 +365,8 @@ _elm_code_widget_fill_line(Elm_Code_Widget *widget, Elm_Code_Line *line)
|
||||||
if (line->number < elm_code_file_lines_get(line->file))
|
if (line->number < elm_code_file_lines_get(line->file))
|
||||||
_elm_code_widget_fill_whitespace(widget, '\n', &cells[length + gutter]);
|
_elm_code_widget_fill_whitespace(widget, '\n', &cells[length + gutter]);
|
||||||
|
|
||||||
|
elm_object_tooltip_text_set(grid, line->status_text);
|
||||||
evas_object_textgrid_update_add(grid, 0, 0, w, 1);
|
evas_object_textgrid_update_add(grid, 0, 0, w, 1);
|
||||||
|
|
||||||
// add a status below the line if needed (and remove those no longer needed)
|
|
||||||
status = evas_object_data_get(grid, "status");
|
|
||||||
if (line->status_text)
|
|
||||||
{
|
|
||||||
if (!status)
|
|
||||||
{
|
|
||||||
status = elm_label_add(pd->gridbox);
|
|
||||||
evas_object_size_hint_weight_set(status, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
||||||
evas_object_size_hint_align_set(status, 0.05, EVAS_HINT_FILL);
|
|
||||||
evas_object_show(status);
|
|
||||||
|
|
||||||
elm_box_pack_after(pd->gridbox, status, grid);
|
|
||||||
evas_object_data_set(grid, "status", status);
|
|
||||||
}
|
|
||||||
elm_object_text_set(status, line->status_text);
|
|
||||||
}
|
|
||||||
else if (status)
|
|
||||||
{
|
|
||||||
elm_box_unpack(pd->gridbox, status);
|
|
||||||
evas_object_hide(status);
|
|
||||||
evas_object_data_set(grid, "status", NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -654,6 +632,36 @@ _elm_code_widget_position_at_coordinates_get(Eo *obj, Elm_Code_Widget_Data *pd,
|
||||||
return !!line;
|
return !!line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_elm_code_widget_status_toggle(Elm_Code_Widget *widget, Elm_Code_Line *line)
|
||||||
|
{
|
||||||
|
Evas_Object *status, *grid;
|
||||||
|
Elm_Code_Widget_Data *pd;
|
||||||
|
|
||||||
|
// 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");
|
||||||
|
|
||||||
|
if (status)
|
||||||
|
{
|
||||||
|
elm_box_unpack(pd->gridbox, status);
|
||||||
|
evas_object_hide(status);
|
||||||
|
evas_object_data_set(grid, "status", NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status = elm_label_add(pd->gridbox);
|
||||||
|
evas_object_size_hint_weight_set(status, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
|
evas_object_size_hint_align_set(status, 0.05, EVAS_HINT_FILL);
|
||||||
|
evas_object_show(status);
|
||||||
|
|
||||||
|
elm_box_pack_after(pd->gridbox, status, grid);
|
||||||
|
evas_object_data_set(grid, "status", status);
|
||||||
|
elm_object_text_set(status, line->status_text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_elm_code_widget_clicked_gutter_cb(Elm_Code_Widget *widget, unsigned int row)
|
_elm_code_widget_clicked_gutter_cb(Elm_Code_Widget *widget, unsigned int row)
|
||||||
{
|
{
|
||||||
|
@ -666,6 +674,12 @@ _elm_code_widget_clicked_gutter_cb(Elm_Code_Widget *widget, unsigned int row)
|
||||||
if (!line)
|
if (!line)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (line->status_text)
|
||||||
|
{
|
||||||
|
_elm_code_widget_status_toggle(widget, line);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
efl_event_callback_legacy_call(widget, ELM_OBJ_CODE_WIDGET_EVENT_LINE_GUTTER_CLICKED, line);
|
efl_event_callback_legacy_call(widget, ELM_OBJ_CODE_WIDGET_EVENT_LINE_GUTTER_CLICKED, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue