hermet pushed a commit to branch master.

http://git.enlightenment.org/tools/enventor.git/commit/?id=c6b7f30c5d07cc6b300bea28b3a785ba0ade5a28

commit c6b7f30c5d07cc6b300bea28b3a785ba0ade5a28
Author: ChunEon Park <[email protected]>
Date:   Fri May 23 13:43:15 2014 +0900

    syntax_color: improve logic for applying color elaborately.
    
    Until this patch, it applied the color to subwords.
    Now, it applies the color to only independet words.
---
 data/color/color.src   |  3 +++
 src/bin/syntax_color.c | 47 +++++++++++++++++++++++++++++++++++++----------
 2 files changed, 40 insertions(+), 10 deletions(-)

diff --git a/data/color/color.src b/data/color/color.src
index fd4d33b..1b509d6 100644
--- a/data/color/color.src
+++ b/data/color/color.src
@@ -17,6 +17,9 @@ group "syntax_color_group" struct {
             value "key" string: "(";
             value "key" string: ")";
             value "key" string: "!";
+            value "key" string: "=";
+            value "key" string: "&";
+            value "key" string: "|";
          }
       }
       group "color" struct {
diff --git a/src/bin/syntax_color.c b/src/bin/syntax_color.c
index cf6cb90..cc52d5b 100644
--- a/src/bin/syntax_color.c
+++ b/src/bin/syntax_color.c
@@ -605,22 +605,49 @@ static int
 color_markup_insert(Eina_Strbuf *strbuf, const char **src, int length, char 
**cur,
                     char **prev, color_data *cd)
 {
-   char key[2];
-   key[0] = (*cur)[0];
-   key[1] = '\0';
+   const char *SYMBOLS = " {}[];:.()!<>=&|";
+   char tmp[2];
+   Eina_Bool symbol = EINA_FALSE;
 
-   Eina_Inarray *inarray = eina_hash_find(cd->color_hash, key);
-   color_tuple *tuple;
+   tmp[0] = (*cur)[0];
+   tmp[1] = '\0';
+   if (strstr(SYMBOLS, tmp)) symbol = EINA_TRUE;
 
-   //Found tuple list. Search in detail.
-   if (inarray)
+   if (!symbol && (*cur > *src))
      {
-        Eina_Bool found = EINA_FALSE;
+        tmp[0] = *(*cur - 1);
+        tmp[1] = '\0';
+        if (!strstr(SYMBOLS, tmp)) return 0;
+     }
+
+   tmp[0] = (*cur)[0];
+   tmp[1] = '\0';
 
-        EINA_INARRAY_FOREACH(inarray, tuple)
+   Eina_Inarray *inarray = eina_hash_find(cd->color_hash, tmp);
+   if (!inarray) return 0;
+
+   //Found tuple list. Search in detail.
+   color_tuple *tuple;
+   int len;
+
+   EINA_INARRAY_FOREACH(inarray, tuple)
+     {
+        len = strlen(tuple->key);
+        char *p = *cur + len;
+        if (!strncmp(*cur, tuple->key, len))
           {
-             if (!strncmp(*cur, tuple->key, strlen(tuple->key)))
+             if (p <= (*src + length))
                {
+                  if (!symbol &&
+                      /* Exceptional Case. For duplicated keywords, it
+                         subdivides with '.' ' '. See the config.src */
+                      (*(p - 1) != '.') &&
+                      (*(p - 1) != ' '))
+                    {
+                       tmp[0] = *p;
+                       tmp[1] = '\0';
+                       if (!strstr(SYMBOLS, tmp)) return 0;
+                    }
                   if (color_markup_insert_internal(strbuf, src, length, cur,
                                                    prev, tuple->key,
                                                    tuple->col))

-- 


Reply via email to