forked from enlightenment/efl
elm_code: Add a matched token so we can highlight searches
Should make dense matches in a text editor clearer.
This commit is contained in:
parent
3e2d62d408
commit
a7830b9c42
|
@ -68,6 +68,11 @@ _elm_code_test_welcome_setup(Evas_Object *parent)
|
|||
_append_line(code->file, "");
|
||||
_append_line(code->file, "This is a demo of elm_code's capabilities.");
|
||||
|
||||
line = elm_code_file_line_get(code->file, 1);
|
||||
elm_code_line_token_add(line, 17, 19, 1, ELM_CODE_TOKEN_TYPE_MATCH);
|
||||
line = elm_code_file_line_get(code->file, 4);
|
||||
elm_code_line_token_add(line, 18, 20, 1, ELM_CODE_TOKEN_TYPE_MATCH);
|
||||
|
||||
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_show(widget);
|
||||
|
|
|
@ -48,6 +48,8 @@ typedef enum {
|
|||
ELM_CODE_TOKEN_TYPE_REMOVED,
|
||||
ELM_CODE_TOKEN_TYPE_CHANGED,
|
||||
|
||||
ELM_CODE_TOKEN_TYPE_MATCH,
|
||||
|
||||
ELM_CODE_TOKEN_TYPE_COUNT
|
||||
} Elm_Code_Token_Type;
|
||||
|
||||
|
|
|
@ -139,7 +139,11 @@ _elm_code_widget_fill_line_token(Evas_Textgrid_Cell *cells, int count, int start
|
|||
|
||||
for (x = start; x <= end && x < count; x++)
|
||||
{
|
||||
cells[x - 1].fg = type;
|
||||
// TODO find a way to mark if a token is themes fg or bg
|
||||
if (type == ELM_CODE_TOKEN_TYPE_MATCH)
|
||||
cells[x - 1].bg = type;
|
||||
else
|
||||
cells[x - 1].fg = type;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -345,9 +349,6 @@ _elm_code_widget_fill_line(Elm_Code_Widget *widget, Elm_Code_Line *line)
|
|||
grid = eina_list_nth(pd->grids, line->number - 1);
|
||||
cells = evas_object_textgrid_cellrow_get(grid, 0);
|
||||
|
||||
_elm_code_widget_fill_gutter(widget, cells, w, line->status, line->number);
|
||||
_elm_code_widget_fill_line_tokens(widget, cells, w, line);
|
||||
|
||||
length = elm_code_widget_line_text_column_width_get(widget, line);
|
||||
chrpos = 0;
|
||||
chr = (char *)elm_code_line_text_get(line, NULL);
|
||||
|
@ -376,6 +377,9 @@ _elm_code_widget_fill_line(Elm_Code_Widget *widget, Elm_Code_Line *line)
|
|||
cells[x].bg = _elm_code_widget_status_type_get(widget, line, x - gutter + 1);
|
||||
}
|
||||
|
||||
_elm_code_widget_fill_gutter(widget, cells, w, line->status, line->number);
|
||||
_elm_code_widget_fill_line_tokens(widget, cells, w, line);
|
||||
|
||||
_elm_code_widget_fill_selection(widget, line, cells, gutter, w);
|
||||
_elm_code_widget_fill_cursor(widget, line->number, gutter, w);
|
||||
if (line->number < elm_code_file_lines_get(line->file))
|
||||
|
@ -1799,6 +1803,9 @@ _elm_code_widget_setup_palette(Evas_Object *o)
|
|||
evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_CHANGED,
|
||||
54, 54, 255, 255);
|
||||
|
||||
evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_MATCH,
|
||||
187, 187, 51, 255);
|
||||
|
||||
// other styles that the widget uses
|
||||
evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_WIDGET_COLOR_SELECTION,
|
||||
51, 153, 255, 255);
|
||||
|
|
Loading…
Reference in New Issue