forked from enlightenment/enventor
edc_editor: Support auto save to update preview.
auto save function saves edc file and updates preview by using timer. auto save timer is applied when entry is changed or redo/undo is done. auto save timer is cancelled when candidate list or auto complete list appears.
This commit is contained in:
parent
b488c57a9c
commit
509b9bd628
|
@ -506,6 +506,8 @@ list_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||||
{
|
{
|
||||||
autocomp_data *ad = data;
|
autocomp_data *ad = data;
|
||||||
ad->list = NULL;
|
ad->list = NULL;
|
||||||
|
|
||||||
|
edit_auto_save_timer_apply(ad->ed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -579,6 +581,8 @@ entry_tooltip_content_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||||
elm_list_go(ad->list);
|
elm_list_go(ad->list);
|
||||||
evas_object_show(ad->list);
|
evas_object_show(ad->list);
|
||||||
|
|
||||||
|
edit_auto_save_timer_cancel(ad->ed);
|
||||||
|
|
||||||
return ad->list;
|
return ad->list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ const int MAX_LINE_DIGIT_CNT = 10;
|
||||||
const int SYNTAX_COLOR_SPARE_LINES = 42;
|
const int SYNTAX_COLOR_SPARE_LINES = 42;
|
||||||
const double SYNTAX_COLOR_DEFAULT_TIME = 0.25;
|
const double SYNTAX_COLOR_DEFAULT_TIME = 0.25;
|
||||||
const double SYNTAX_COLOR_SHORT_TIME = 0.025;
|
const double SYNTAX_COLOR_SHORT_TIME = 0.025;
|
||||||
|
const double AUTO_SAVE_TIME = 2.0;
|
||||||
|
|
||||||
typedef struct syntax_color_thread_data_s
|
typedef struct syntax_color_thread_data_s
|
||||||
{
|
{
|
||||||
|
@ -48,6 +49,7 @@ struct editor_s
|
||||||
int right;
|
int right;
|
||||||
} bracket;
|
} bracket;
|
||||||
|
|
||||||
|
Ecore_Timer *auto_save_timer;
|
||||||
Ecore_Timer *syntax_color_timer;
|
Ecore_Timer *syntax_color_timer;
|
||||||
Ecore_Thread *syntax_color_thread;
|
Ecore_Thread *syntax_color_thread;
|
||||||
|
|
||||||
|
@ -457,6 +459,8 @@ edit_changed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
|
||||||
syntax_color_partial_update(ed, SYNTAX_COLOR_DEFAULT_TIME);
|
syntax_color_partial_update(ed, SYNTAX_COLOR_DEFAULT_TIME);
|
||||||
|
|
||||||
parser_bracket_cancel(ed->pd);
|
parser_bracket_cancel(ed->pd);
|
||||||
|
|
||||||
|
edit_auto_save_timer_apply(ed);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -547,6 +551,8 @@ ctxpopup_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||||
{
|
{
|
||||||
edit_data *ed = data;
|
edit_data *ed = data;
|
||||||
ed->ctxpopup = NULL;
|
ed->ctxpopup = NULL;
|
||||||
|
|
||||||
|
edit_auto_save_timer_apply(ed);
|
||||||
}
|
}
|
||||||
|
|
||||||
//This function is called when user press up/down key or mouse wheel up/down
|
//This function is called when user press up/down key or mouse wheel up/down
|
||||||
|
@ -708,6 +714,8 @@ candidate_list_show(edit_data *ed, char *text, char *cur, char *selected)
|
||||||
evas_object_event_callback_add(ctxpopup, EVAS_CALLBACK_DEL, ctxpopup_del_cb, ed);
|
evas_object_event_callback_add(ctxpopup, EVAS_CALLBACK_DEL, ctxpopup_del_cb, ed);
|
||||||
ed->ctxpopup = ctxpopup;
|
ed->ctxpopup = ctxpopup;
|
||||||
elm_object_tree_focus_allow_set(ed->layout, EINA_FALSE);
|
elm_object_tree_focus_allow_set(ed->layout, EINA_FALSE);
|
||||||
|
|
||||||
|
edit_auto_save_timer_cancel(ed);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1106,6 +1114,16 @@ edit_focused_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||||
evas_object_smart_callback_call(ed->enventor, SIG_FOCUSED, NULL);
|
evas_object_smart_callback_call(ed->enventor, SIG_FOCUSED, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
auto_save_timer_cb(void *data)
|
||||||
|
{
|
||||||
|
edit_data *ed = data;
|
||||||
|
edit_save(ed, build_edc_path_get());
|
||||||
|
build_edc();
|
||||||
|
ed->auto_save_timer = NULL;
|
||||||
|
return ECORE_CALLBACK_CANCEL;
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Externally accessible calls */
|
/* Externally accessible calls */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1858,5 +1876,24 @@ edit_redoundo(edit_data *ed, Eina_Bool undo)
|
||||||
edit_changed_set(ed, EINA_TRUE);
|
edit_changed_set(ed, EINA_TRUE);
|
||||||
syntax_color_full_update(ed, EINA_TRUE);
|
syntax_color_full_update(ed, EINA_TRUE);
|
||||||
|
|
||||||
|
edit_auto_save_timer_apply(ed);
|
||||||
|
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
edit_auto_save_timer_apply(edit_data *ed)
|
||||||
|
{
|
||||||
|
if (ed->auto_save_timer)
|
||||||
|
ecore_timer_del(ed->auto_save_timer);
|
||||||
|
ed->auto_save_timer = ecore_timer_add(AUTO_SAVE_TIME, auto_save_timer_cb,
|
||||||
|
ed);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
edit_auto_save_timer_cancel(edit_data *ed)
|
||||||
|
{
|
||||||
|
if (ed->auto_save_timer)
|
||||||
|
ecore_timer_del(ed->auto_save_timer);
|
||||||
|
ed->auto_save_timer = NULL;
|
||||||
|
}
|
||||||
|
|
|
@ -296,5 +296,7 @@ void edit_disabled_set(edit_data *ed, Eina_Bool disabled);
|
||||||
void edit_error_set(edit_data *ed, int line, const char *target);
|
void edit_error_set(edit_data *ed, int line, const char *target);
|
||||||
void edit_text_insert(edit_data *ed, const char *text);
|
void edit_text_insert(edit_data *ed, const char *text);
|
||||||
void edit_part_cursor_set(edit_data *ed, const char *group_name, const char *part_name);
|
void edit_part_cursor_set(edit_data *ed, const char *group_name, const char *part_name);
|
||||||
|
void edit_auto_save_timer_apply(edit_data *ed);
|
||||||
|
void edit_auto_save_timer_cancel(edit_data *ed);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue