forked from enlightenment/enventor
Build: marks line, that contain error in edc_editor.
Summary: parse error messages from edje_cc, and marked by underline the mistaken line. In cases for messages that does not contain line numbers, trying to parse name of wrong parameter. Trying to searching the parsed name in edc code, and highlight the first entity. Reviewers: Hermet Differential Revision: https://phab.enlightenment.org/D2791
This commit is contained in:
parent
281c9e667e
commit
9c66f6fcf0
|
@ -14,6 +14,7 @@
|
|||
#define ENABLED_TEXTBLOCK_TAGS \
|
||||
tag: "em" "+ font_style=Oblique"; \
|
||||
tag: "hilight" "+ font_weight=Bold style=glow glow_color=#3399ff80"; \
|
||||
tag: "error" "+ underline=single underline_color=#ff0000 underline2_color=#ff0000"; \
|
||||
tag: "link" "+ color=#3399ff underline=on underline_color=#3399ff"; \
|
||||
tag: "preedit" "+ underline=on underline_color=#3399ff"; \
|
||||
tag: "preedit_sel" "+ backing=on backing_color=#000000 color=#ffffff"; \
|
||||
|
@ -47,6 +48,7 @@
|
|||
#define DISABLED_TEXTBLOCK_TAGS \
|
||||
tag: "em" "+ font_style=Oblique"; \
|
||||
tag: "hilight" "+ font_weight=Bold style=glow glow_color=#3399ff20"; \
|
||||
tag: "error" "+ underline=double underline_color=#ff0000 underline2_color=#ff0000"; \
|
||||
tag: "link" "+ color=#101820 shadow_color=#66aaff28 underline=on underline_color=#101820"; \
|
||||
tag: "preedit" "+ underline=on underline_color=#3399ff88"; \
|
||||
tag: "preedit_sel" "+ backing=on backing_color=#000000 color=#888888"; \
|
||||
|
|
|
@ -36,6 +36,7 @@ struct editor_s
|
|||
|
||||
int cur_line;
|
||||
int line_max;
|
||||
int error_line;
|
||||
int syntax_color_lock;
|
||||
Evas_Coord scroller_h;
|
||||
|
||||
|
@ -49,6 +50,7 @@ struct editor_s
|
|||
double font_scale;
|
||||
const char *font_name;
|
||||
const char *font_style;
|
||||
const char *error_target;
|
||||
|
||||
Eina_Bool edit_changed : 1;
|
||||
Eina_Bool linenumber : 1;
|
||||
|
@ -136,6 +138,39 @@ edit_font_apply(edit_data *ed, const char *font_name, const char *font_style)
|
|||
entry_recover(ed, pos);
|
||||
}
|
||||
|
||||
static void
|
||||
error_highlight(edit_data *ed, Evas_Object *tb)
|
||||
{
|
||||
Evas_Textblock_Cursor *cur1 = evas_object_textblock_cursor_new(tb);
|
||||
if (ed->error_line)
|
||||
{
|
||||
evas_textblock_cursor_line_set(cur1, ed->error_line);
|
||||
evas_textblock_cursor_line_char_first(cur1);
|
||||
while(evas_textblock_cursor_content_get(cur1)[0] == ' ')
|
||||
evas_textblock_cursor_char_next(cur1);
|
||||
evas_object_textblock_text_markup_prepend(cur1, "<error>");
|
||||
evas_textblock_cursor_line_char_last(cur1);
|
||||
evas_object_textblock_text_markup_prepend(cur1, "</error>");
|
||||
}
|
||||
else if (ed->error_target)
|
||||
{
|
||||
const char *ptr = NULL;
|
||||
const char *par = NULL;
|
||||
while (evas_textblock_cursor_paragraph_next(cur1))
|
||||
{
|
||||
par = evas_textblock_cursor_paragraph_text_get(cur1);
|
||||
if (par && (ptr = strstr(par, ed->error_target)))
|
||||
break;
|
||||
}
|
||||
evas_textblock_cursor_paragraph_char_first(cur1);
|
||||
while(evas_textblock_cursor_content_get(cur1)[0] == ' ')
|
||||
evas_textblock_cursor_char_next(cur1);
|
||||
evas_object_textblock_text_markup_prepend(cur1, "<error>");
|
||||
evas_textblock_cursor_paragraph_char_last(cur1);
|
||||
evas_object_textblock_text_markup_prepend(cur1, "</error>");
|
||||
}
|
||||
evas_textblock_cursor_free(cur1);
|
||||
}
|
||||
static void
|
||||
syntax_color_apply(edit_data *ed, Eina_Bool partial)
|
||||
{
|
||||
|
@ -162,7 +197,7 @@ syntax_color_apply(edit_data *ed, Eina_Bool partial)
|
|||
But it can avoid entry_object_text_escaped_set() in Edje.
|
||||
Logically that's unnecessary in this case. */
|
||||
evas_object_textblock_text_markup_set(tb, translated);
|
||||
|
||||
error_highlight(ed, tb);
|
||||
entry_recover(ed, pos);
|
||||
}
|
||||
|
||||
|
@ -213,7 +248,7 @@ syntax_color_thread_end_cb(void *data, Ecore_Thread *thread EINA_UNUSED)
|
|||
But it can avoid entry_object_text_escaped_set() in Edje.
|
||||
Logically that's unnecessary in this case. */
|
||||
evas_object_textblock_text_markup_set(tb, td->translated);
|
||||
|
||||
error_highlight(td->ed, tb);
|
||||
entry_recover(td->ed, pos);
|
||||
|
||||
td->ed->syntax_color_thread = NULL;
|
||||
|
@ -224,6 +259,8 @@ static void
|
|||
syntax_color_thread_cancel_cb(void *data, Ecore_Thread *thread EINA_UNUSED)
|
||||
{
|
||||
syntax_color_td *td = data;
|
||||
Evas_Object *tb = elm_entry_textblock_get(td->ed->en_edit);
|
||||
error_highlight(td->ed, tb);
|
||||
td->ed->syntax_color_thread = NULL;
|
||||
free(td);
|
||||
}
|
||||
|
@ -236,6 +273,9 @@ edit_changed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
|
|||
edit_changed_set(ed, EINA_TRUE);
|
||||
|
||||
Eina_Bool syntax_color = EINA_TRUE;
|
||||
ed->error_line = 0;
|
||||
eina_stringshare_del(ed->error_target);
|
||||
ed->error_target = NULL;
|
||||
|
||||
if (info->insert)
|
||||
{
|
||||
|
@ -1360,6 +1400,13 @@ edit_auto_indent_get(edit_data *ed)
|
|||
return ed->auto_indent;
|
||||
}
|
||||
|
||||
void
|
||||
edit_error_set(edit_data *ed, int line, const char *target)
|
||||
{
|
||||
ed->error_line = line;
|
||||
ed->error_target = target;
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
edit_ctxpopup_enabled_get(edit_data *ed)
|
||||
{
|
||||
|
|
|
@ -257,5 +257,6 @@ Eina_Bool edit_load(edit_data *ed, const char *edc_path);
|
|||
void edit_selection_clear(edit_data *ed);
|
||||
Eina_Bool edit_redoundo(edit_data *ed, Eina_Bool undo);
|
||||
void edit_disabled_set(edit_data *ed, Eina_Bool disabled);
|
||||
void edit_error_set(edit_data *ed, int line, const char *target);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -134,7 +134,7 @@ edit_view_sync_cb(void *data, Eina_Stringshare *state_name, double state_value,
|
|||
prev_part_name = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ((part_name) && (part_name != prev_part_name))
|
||||
{
|
||||
view_part_state_set(VIEW_DATA, prev_part_name, "default", 0.0);
|
||||
|
@ -149,8 +149,41 @@ edit_view_sync_cb(void *data, Eina_Stringshare *state_name, double state_value,
|
|||
static void
|
||||
build_err_noti_cb(void *data, const char *msg)
|
||||
{
|
||||
Evas_Object *enventor = data;
|
||||
evas_object_smart_callback_call(enventor, SIG_COMPILE_ERROR, (char *)msg);
|
||||
Enventor_Object_Data *pd = data;
|
||||
|
||||
int line_num = 1;
|
||||
Eina_Stringshare *target = NULL;
|
||||
char *ptr = NULL;
|
||||
char *utf8 = evas_textblock_text_markup_to_utf8(NULL, msg);
|
||||
|
||||
if (!utf8) goto call_error;
|
||||
|
||||
if ((ptr = strstr(utf8, ".edc")))
|
||||
{
|
||||
ptr += strlen(".edc");
|
||||
if (!ptr || (ptr[0] != ':')) goto call_error;
|
||||
if (!(ptr++)) goto call_error;
|
||||
line_num = atoi(ptr);
|
||||
}
|
||||
else if ((ptr = strstr(utf8, "image")) ||
|
||||
(ptr = strstr(utf8, "group")) ||
|
||||
(ptr = strstr(utf8, "part")))
|
||||
{
|
||||
ptr = strchr(ptr, '\"');
|
||||
if (!ptr || !(ptr++)) goto call_error;
|
||||
char *ptr2 = strchr(ptr, '\"');
|
||||
if (!ptr2) goto call_error;
|
||||
int length = ptr2 - ptr;
|
||||
target = eina_stringshare_add_length(ptr, length);
|
||||
}
|
||||
|
||||
call_error:
|
||||
free(utf8);
|
||||
edit_error_set(pd->ed, line_num - 1, target);
|
||||
if (line_num || target)
|
||||
edit_syntax_color_full_apply(pd->ed, EINA_TRUE);
|
||||
evas_object_smart_callback_call(pd->obj, SIG_COMPILE_ERROR, (char *)msg);
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -176,7 +209,7 @@ _enventor_object_evas_object_smart_add(Eo *obj, Enventor_Object_Data *pd)
|
|||
edj_mgr_init(obj);
|
||||
pd->ed = edit_init(obj);
|
||||
edit_view_sync_cb_set(pd->ed, edit_view_sync_cb, pd);
|
||||
build_err_noti_cb_set(build_err_noti_cb, obj);
|
||||
build_err_noti_cb_set(build_err_noti_cb, pd);
|
||||
|
||||
evas_object_smart_member_add(edit_obj_get(pd->ed), obj);
|
||||
elm_widget_can_focus_set(obj, EINA_FALSE);
|
||||
|
|
Loading…
Reference in New Issue