summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Williams <andy@andywilliams.me>2017-06-26 22:17:07 +0100
committerAndy Williams <andy@andywilliams.me>2017-06-26 22:17:07 +0100
commita7830b9c42b5f3e228bd264d1cf76980623d851a (patch)
treecee062729845c453d53f95525bece070d73c95e5
parent3e2d62d408db08155d119ede71799c252095c440 (diff)
downloadefl-a7830b9c42b5f3e228bd264d1cf76980623d851a.tar.gz
elm_code: Add a matched token so we can highlight searches
Should make dense matches in a text editor clearer.
-rw-r--r--src/bin/elementary/test_code.c5
-rw-r--r--src/lib/elementary/elm_code_common.h2
-rw-r--r--src/lib/elementary/elm_code_widget.c15
3 files changed, 18 insertions, 4 deletions
diff --git a/src/bin/elementary/test_code.c b/src/bin/elementary/test_code.c
index 4dd43a5db2..30290dba65 100644
--- a/src/bin/elementary/test_code.c
+++ b/src/bin/elementary/test_code.c
@@ -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);
diff --git a/src/lib/elementary/elm_code_common.h b/src/lib/elementary/elm_code_common.h
index 7af9131838..2c0c88e922 100644
--- a/src/lib/elementary/elm_code_common.h
+++ b/src/lib/elementary/elm_code_common.h
@@ -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;
diff --git a/src/lib/elementary/elm_code_widget.c b/src/lib/elementary/elm_code_widget.c
index 436dd27cc0..59a4fb0b64 100644
--- a/src/lib/elementary/elm_code_widget.c
+++ b/src/lib/elementary/elm_code_widget.c
@@ -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);