elm_code: display a line-width marker if requested
This commit is contained in:
parent
b08274d8b1
commit
ca9b64e3c8
|
@ -37,4 +37,5 @@ typedef struct
|
|||
unsigned int cursor_line, cursor_col;
|
||||
Eina_Bool editable, focussed;
|
||||
Eina_Bool show_line_numbers;
|
||||
unsigned int line_width_marker;
|
||||
} Elm_Code_Widget_Data;
|
||||
|
|
|
@ -108,6 +108,22 @@ _elm_code_widget_fill_line_token(Evas_Textgrid_Cell *cells, int count, int start
|
|||
}
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
_elm_code_widget_status_type_get(Elm_Code_Widget *widget, Elm_Code_Status_Type set_type, unsigned int col)
|
||||
{
|
||||
Elm_Code_Widget_Data *pd;
|
||||
|
||||
pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
|
||||
|
||||
if (set_type != ELM_CODE_STATUS_TYPE_DEFAULT)
|
||||
return set_type;
|
||||
|
||||
if (pd->line_width_marker == col)
|
||||
return ELM_CODE_WIDGET_COLOR_GUTTER_BG;
|
||||
|
||||
return ELM_CODE_STATUS_TYPE_DEFAULT;
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_code_widget_fill_line_tokens(Elm_Code_Widget *widget, Evas_Textgrid_Cell *cells,
|
||||
unsigned int count, Elm_Code_Line *line)
|
||||
|
@ -203,14 +219,14 @@ _elm_code_widget_fill_line(Elm_Code_Widget *widget, Elm_Code_Line *line)
|
|||
for (x = gutter; x < (unsigned int) w && x < length + gutter; x++)
|
||||
{
|
||||
cells[x].codepoint = *chr;
|
||||
cells[x].bg = line->status;
|
||||
cells[x].bg = _elm_code_widget_status_type_get(widget, line->status, x - gutter + 1);
|
||||
|
||||
chr++;
|
||||
}
|
||||
for (; x < (unsigned int) w; x++)
|
||||
{
|
||||
cells[x].codepoint = 0;
|
||||
cells[x].bg = line->status;
|
||||
cells[x].bg = _elm_code_widget_status_type_get(widget, line->status, x - gutter + 1);
|
||||
}
|
||||
|
||||
_elm_code_widget_fill_line_tokens(widget, cells, w, line);
|
||||
|
@ -241,7 +257,7 @@ _elm_code_widget_empty_line(Elm_Code_Widget *widget, unsigned int number)
|
|||
for (x = gutter; x < (unsigned int) w; x++)
|
||||
{
|
||||
cells[x].codepoint = 0;
|
||||
cells[x].bg = ELM_CODE_STATUS_TYPE_DEFAULT;
|
||||
cells[x].bg = _elm_code_widget_status_type_get(widget, ELM_CODE_STATUS_TYPE_DEFAULT, x - gutter + 1);
|
||||
}
|
||||
|
||||
evas_object_textgrid_update_add(pd->grid, 0, number - 1, w, 1);
|
||||
|
@ -709,6 +725,19 @@ _elm_code_widget_line_numbers_get(Eo *obj EINA_UNUSED, Elm_Code_Widget_Data *pd)
|
|||
return pd->show_line_numbers;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_elm_code_widget_line_width_marker_set(Eo *obj, Elm_Code_Widget_Data *pd, unsigned int col)
|
||||
{
|
||||
pd->line_width_marker = col;
|
||||
_elm_code_widget_fill(obj);
|
||||
}
|
||||
|
||||
EOLIAN static unsigned int
|
||||
_elm_code_widget_line_width_marker_get(Eo *obj EINA_UNUSED, Elm_Code_Widget_Data *pd)
|
||||
{
|
||||
return pd->line_width_marker;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_elm_code_widget_cursor_position_set(Eo *obj, Elm_Code_Widget_Data *pd, unsigned int col, unsigned int line)
|
||||
{
|
||||
|
|
|
@ -103,6 +103,26 @@ class Elm_Code_Widget (Elm_Layout, Elm_Interface_Atspi_Text)
|
|||
Eina_Bool line_numbers; /*@ Whether or not line numbers (or their placeholder) should be shown */
|
||||
}
|
||||
}
|
||||
line_width_marker {
|
||||
set {
|
||||
/*@
|
||||
Set where the line width market should be shown.
|
||||
|
||||
Passing a non-zero value will set which line width to mark with a vertical line.
|
||||
Passing 0 will hide this marker.
|
||||
|
||||
@ingroup Features */
|
||||
}
|
||||
get {
|
||||
/*@
|
||||
Get the position of the line width marker, any positive return indicates where the marker appears.
|
||||
|
||||
@ingroup Features */
|
||||
}
|
||||
values {
|
||||
uint line_width_marker; /*@ Where to display a line width marker, if at all */
|
||||
}
|
||||
}
|
||||
cursor_position {
|
||||
set {
|
||||
/*@
|
||||
|
|
Loading…
Reference in New Issue