aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarvin Borner2021-04-22 21:26:39 +0200
committerMarvin Borner2021-04-22 21:26:39 +0200
commit3f745223b871390a92791f3c04fd703a5a66de38 (patch)
treefc591f25ad14a0855b61ecf2c3e321cf4f28429b
parent825034a089901a58dd62b5a39f4c24761b6d5b4c (diff)
Added unhighlighter
-rw-r--r--src/gui.c9
-rw-r--r--src/inc/gui.h2
-rw-r--r--src/syntax.c1
3 files changed, 12 insertions, 0 deletions
diff --git a/src/gui.c b/src/gui.c
index 2a948cc..5e0f379 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -75,6 +75,15 @@ static void gui_init_highlighter(void)
gtk_text_buffer_create_tag(buffer, "regs", "foreground", "#00ff00", NULL);
}
+void gui_unhighlight(void)
+{
+ GtkTextIter start, end;
+ GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view));
+
+ gtk_text_buffer_get_bounds(buffer, &start, &end);
+ gtk_text_buffer_remove_all_tags(buffer, &start, &end);
+}
+
void gui_highlight(u32 column, u32 line, u32 length, const char *tag_name)
{
GtkTextIter start, end;
diff --git a/src/inc/gui.h b/src/inc/gui.h
index aa059e5..db68fee 100644
--- a/src/inc/gui.h
+++ b/src/inc/gui.h
@@ -6,6 +6,8 @@
int gui_init(int argc, char *argv[]);
void gui_show_warning(const char *text);
void gui_show_info(const char *text);
+
+void gui_unhighlight(void);
void gui_highlight(u32 column, u32 line, u32 length, const char *color);
#endif
diff --git a/src/syntax.c b/src/syntax.c
index 400f6e1..4367394 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -52,6 +52,7 @@ void syntax_highlight(char *buf, u32 size)
u32 diff = 0;
char *start = buf;
+ gui_unhighlight();
for (u32 i = 0; i < size; i++) {
// TODO: Fix highlighting of last line without \n
if (buf[i] == '\0')