hermet pushed a commit to branch master.

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

commit 644d004f93450eddc6492b7b45add00a8e79c2da
Author: Taehyub Kim <taehyub....@samsung.com>
Date:   Fri Aug 19 12:52:31 2016 +0900

    console: fix the selection function of console error message
    
    Summary:
    fix the selection function of console error message,
    it was behavior broken since there is markup text in console message.
    so I fixed it work well.
    
    Test Plan:
    1. launch enventor
    2. make some error in text view
    3. save
    4. check the selection region in text view
    
    Reviewers: Hermet, Jaehyun_Cho, NikaWhite, bowonryu
    
    Differential Revision: https://phab.enlightenment.org/D4239
---
 src/bin/console.c | 84 ++++++++++++++++++++++++++++++-------------------------
 1 file changed, 46 insertions(+), 38 deletions(-)

diff --git a/src/bin/console.c b/src/bin/console.c
index 1eabfae..88dcf8b 100644
--- a/src/bin/console.c
+++ b/src/bin/console.c
@@ -9,7 +9,7 @@ token_value_get(char *src, char *key_str, char end_key, int 
offset, char *dst)
 {
    char *psrc = src;
    int count = 0;
-   psrc += (strlen(key_str) + offset ) * sizeof(char);
+   psrc += strlen(key_str) + offset;
    while (*psrc != end_key)
      dst[count++] = *psrc++;
    dst[count] = '\0';
@@ -18,51 +18,59 @@ token_value_get(char *src, char *key_str, char end_key, int 
offset, char *dst)
 static void
 error_word_select(Evas_Object *console)
 {
-   const char *console_text = elm_entry_entry_get(console);
-   if (console_text == NULL) return;
+   //Convert console text including markup text to the plain text
+   const char *markup_text = elm_entry_entry_get(console);
+   if (!markup_text) return;
+   char *console_text = elm_entry_markup_to_utf8(markup_text);
+   if (!console_text) return;
 
    char error_word[1024];
    char error_line[1024];
    char *error_token, *edc_token;
 
-   //parse edc line
-   if ((edc_token = strstr(console_text, "edc:")))
-     token_value_get(edc_token, "edc:", ' ', 0, error_line);
-   else return;
+   //Parse edc line
+   if ((edc_token = strstr(console_text, "edc : ")))
+     token_value_get(edc_token, "edc : ", ' ', 0, error_line);
+   else
+     goto end;
 
-   //parse error word
+   //Parse error word
    if ((error_token = strstr(console_text, "keyword")))
-     token_value_get(error_token, "keyword", '\0', 1, error_word);
+     token_value_get(error_token, "keyword", ' ', 1, error_word);
    else if ((error_token = strstr(console_text, "name")))
-     token_value_get(error_token, "name", '\0', 1, error_word);
-   else return;
-
-    //FIXME: Need to get the file that contains errors.
-    Enventor_Item *it = file_mgr_focused_item_get();
-    EINA_SAFETY_ON_NULL_RETURN(it);
-
-    //find error word position
-    enventor_item_line_goto(it, atoi(error_line));
-    int pos = enventor_item_cursor_pos_get(it);
-    const char *entry_text = enventor_item_text_get(it);
-    char *utf8 = elm_entry_markup_to_utf8(entry_text);
-    const char *search_line = utf8 + pos * sizeof(char);
-    const char *matched = strstr(search_line, error_word);
-
-    if (matched == NULL)
-      {
-         free(utf8);
-         return;
-      }
-
-    int start, end;
-    start = matched - utf8;
-    end = start + strlen(error_word);
-
-    free(utf8);
-
-    //select error word
-    enventor_item_select_region_set(it, start, end);
+     token_value_get(error_token, "name", ' ', 1, error_word);
+   else
+     goto end;
+
+   //FIXME: Need to get the file that contains errors.
+   Enventor_Item *it = file_mgr_focused_item_get();
+   EINA_SAFETY_ON_NULL_RETURN(it);
+
+   //Find error word position
+   enventor_item_line_goto(it, atoi(error_line));
+   int pos = enventor_item_cursor_pos_get(it);
+   const char *entry_text = enventor_item_text_get(it);
+   char *utf8 = elm_entry_markup_to_utf8(entry_text);
+   if(!utf8) goto end;
+
+   const char *search_line = utf8 + pos;
+   const char *matched = strstr(search_line, error_word);
+   if (!matched)
+     {
+        free(utf8);
+        goto end;
+     }
+
+   int start, end;
+   start = matched - utf8;
+   end = start + strlen(error_word);
+
+   //Select error word
+   enventor_item_select_region_set(it, start, end);
+   free(utf8);
+
+end:
+   free(console_text);
 }
 
 static void

-- 


Reply via email to