ajwillia-ms pushed a commit to branch master.

http://git.enlightenment.org/tools/edi.git/commit/?id=bc6ec2dd6f13332e63471795e629508ddc535c74

commit bc6ec2dd6f13332e63471795e629508ddc535c74
Author: Andy Williams <a...@andywilliams.me>
Date:   Sun Apr 12 23:04:46 2015 +0100

    syntax: reset status and hints when we reset token
    
    re-use elm_code methods when we do this in edi
---
 elm_code/src/lib/elm_code_line.c  | 21 +++++++++++++++++++++
 elm_code/src/lib/elm_code_line.h  |  6 +++++-
 elm_code/src/lib/elm_code_parse.c |  2 ++
 src/bin/editor/edi_editor.c       | 16 +++++++++++++---
 4 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/elm_code/src/lib/elm_code_line.c b/elm_code/src/lib/elm_code_line.c
index 852ed36..5195972 100644
--- a/elm_code/src/lib/elm_code_line.c
+++ b/elm_code/src/lib/elm_code_line.c
@@ -28,6 +28,17 @@ EAPI void elm_code_line_status_set(Elm_Code_Line *line, 
Elm_Code_Status_Type sta
    line->status = status;
 }
 
+EAPI void elm_code_line_status_text_set(Elm_Code_Line *line, const char *text)
+{
+   if (line->status_text)
+     free(line->status_text);
+
+   if (text)
+     line->status_text = strdup(text);
+   else
+     line->status_text = NULL;
+}
+
 EAPI void elm_code_line_token_add(Elm_Code_Line *line, int start, int end, int 
lines,
                                   Elm_Code_Token_Type type)
 {
@@ -67,3 +78,13 @@ EAPI void elm_code_line_tokens_clear(Elm_Code_Line *line)
    line->tokens = NULL;
 }
 
+EAPI void elm_code_line_status_clear(Elm_Code_Line *line)
+{
+   line->status = ELM_CODE_STATUS_TYPE_DEFAULT;
+   if (line->status_text)
+     {
+        free((char *)line->status_text);
+        line->status_text = NULL;
+     }
+}
+
diff --git a/elm_code/src/lib/elm_code_line.h b/elm_code/src/lib/elm_code_line.h
index 64e3e35..e3ad128 100644
--- a/elm_code/src/lib/elm_code_line.h
+++ b/elm_code/src/lib/elm_code_line.h
@@ -32,7 +32,7 @@ typedef struct _Elm_Code_Line
    Eina_List *tokens;
 
    void *data;
-   const char *status_text;
+   char *status_text;
 } Elm_Code_Line;
 
 EAPI void elm_code_line_free(Elm_Code_Line *line);
@@ -49,6 +49,10 @@ EAPI void elm_code_line_free(Elm_Code_Line *line);
 
 EAPI void elm_code_line_status_set(Elm_Code_Line *line, Elm_Code_Status_Type 
status);
 
+EAPI void elm_code_line_status_text_set(Elm_Code_Line *line, const char *text);
+
+EAPI void elm_code_line_status_clear(Elm_Code_Line *line);
+
 EAPI void elm_code_line_token_add(Elm_Code_Line *line, int start, int end, int 
lines, Elm_Code_Token_Type type);
 
 EAPI void elm_code_line_tokens_clear(Elm_Code_Line *line);
diff --git a/elm_code/src/lib/elm_code_parse.c 
b/elm_code/src/lib/elm_code_parse.c
index 9a70ca4..02c878a 100644
--- a/elm_code/src/lib/elm_code_parse.c
+++ b/elm_code/src/lib/elm_code_parse.c
@@ -23,6 +23,7 @@ _elm_code_parse_line(Elm_Code *code, Elm_Code_Line *line)
    Eina_List *item;
 
    elm_code_line_tokens_clear(line);
+   elm_code_line_status_clear(line);
 
    EINA_LIST_FOREACH(code->parsers, item, parser)
      {
@@ -41,6 +42,7 @@ _elm_code_parse_file(Elm_Code *code, Elm_Code_File *file)
    EINA_LIST_FOREACH(file->lines, item, line)
      {
         elm_code_line_tokens_clear(line);
+        elm_code_line_status_clear(line);
      }
 
    EINA_LIST_FOREACH(code->parsers, item, parser)
diff --git a/src/bin/editor/edi_editor.c b/src/bin/editor/edi_editor.c
index 19c1a29..9cad2d5 100644
--- a/src/bin/editor/edi_editor.c
+++ b/src/bin/editor/edi_editor.c
@@ -301,7 +301,7 @@ _edi_line_status_set(Edi_Editor *editor, unsigned int 
number, Elm_Code_Status_Ty
 
    elm_code_line_status_set(line, status);
    if (text)
-     line->status_text = strdup(text);
+     elm_code_line_status_text_set(line, text);
 
    eo_do(editor->entry,
          elm_code_widget_line_refresh(line));
@@ -446,8 +446,6 @@ _clang_load_errors(const char *path EINA_UNUSED, Edi_Editor 
*editor)
    unsigned i = 0;
 
    eo_do(editor->entry, code = elm_code_widget_code_get());
-   for (i = 1; i <= elm_code_file_lines_get(code->file); i++)
-     _edi_line_status_set(editor, i, ELM_CODE_STATUS_TYPE_DEFAULT, NULL);
 
    for(i = 0, n = clang_getNumDiagnostics(editor->tx_unit); i != n; ++i)
      {
@@ -533,9 +531,21 @@ _edi_clang_dispose(Edi_Editor *editor)
 static void
 _reset_highlight(Edi_Editor *editor)
 {
+   Eina_List *item;
+   Elm_Code *code;
+   Elm_Code_Line *line;
+
    if (!editor->show_highlight)
      return;
 
+   eo_do(editor->entry,
+         code = elm_code_widget_code_get());
+   EINA_LIST_FOREACH(code->file->lines, item, line)
+     {
+        elm_code_line_tokens_clear(line);
+        elm_code_line_status_clear(line);
+     }
+
 #if HAVE_LIBCLANG
    pthread_attr_t attr;
    pthread_t thread_id;

-- 


Reply via email to