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
This commit is contained in:
Taehyub Kim 2016-08-19 12:52:31 +09:00 committed by Hermet Park
parent 74938a0f66
commit 644d004f93
1 changed files with 40 additions and 32 deletions

View File

@ -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;
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);
//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);
//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;
if (matched == NULL)
{
free(utf8);
return;
}
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);
int start, end;
start = matched - utf8;
end = start + strlen(error_word);
free(utf8);
//Select error word
enventor_item_select_region_set(it, start, end);
free(utf8);
//select error word
enventor_item_select_region_set(it, start, end);
end:
free(console_text);
}
static void