forked from enlightenment/edi
editor: Control the auto-save function locally so we can re-sync with clang.
This should mean that highlighting, whilst still slow and flickery, does not corrupt.
This commit is contained in:
parent
87c35fcf27
commit
3a3bf2b6db
|
@ -49,8 +49,8 @@ _edi_content_provider_diff_add(Evas_Object *parent, Edi_Mainview_Item *item)
|
|||
|
||||
static Edi_Content_Provider _edi_content_provider_registry[] =
|
||||
{
|
||||
{"text", EINA_TRUE, EINA_TRUE, _edi_editor_add},
|
||||
{"code", EINA_TRUE, EINA_TRUE, _edi_editor_add},
|
||||
{"text", EINA_TRUE, EINA_TRUE, edi_editor_add},
|
||||
{"code", EINA_TRUE, EINA_TRUE, edi_editor_add},
|
||||
{"image", EINA_FALSE, EINA_FALSE, _edi_content_provider_image_add},
|
||||
{"diff", EINA_TRUE, EINA_FALSE, _edi_content_provider_diff_add},
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ extern int _edi_log_dom;
|
|||
#define DBG(...) EINA_LOG_DOM_DBG(_edi_log_dom, __VA_ARGS__)
|
||||
|
||||
#define EDI_CONTENT_AUTOSAVE EINA_TRUE
|
||||
#define EDI_CONTENT_SAVE_TIMEOUT 2
|
||||
|
||||
Evas_Object *edi_open(const char *path);
|
||||
|
||||
|
|
|
@ -61,6 +61,30 @@ _update_highlight(Edi_Editor *editor);
|
|||
static void
|
||||
_reset_highlight(Edi_Editor *editor);
|
||||
|
||||
void
|
||||
edi_editor_save(Edi_Editor *editor)
|
||||
{
|
||||
edi_mainview_save();
|
||||
_reset_highlight(editor);
|
||||
|
||||
editor->modified = EINA_FALSE;
|
||||
|
||||
ecore_timer_del(editor->save_timer);
|
||||
editor->save_timer = NULL;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_edi_editor_autosave_cb(void *data)
|
||||
{
|
||||
Edi_Editor *editor;
|
||||
|
||||
editor = (Edi_Editor *)data;
|
||||
|
||||
edi_editor_save(editor);
|
||||
return ECORE_CALLBACK_CANCEL;
|
||||
}
|
||||
|
||||
|
||||
static const char *
|
||||
_edi_editor_font_get()
|
||||
{
|
||||
|
@ -154,6 +178,13 @@ _changed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
|
|||
}
|
||||
|
||||
editor->undo_stack = eina_list_prepend(editor->undo_stack, change);
|
||||
editor->modified = EINA_TRUE;
|
||||
|
||||
if (editor->save_timer)
|
||||
ecore_timer_reset(editor->save_timer);
|
||||
else
|
||||
editor->save_timer = ecore_timer_add(EDI_CONTENT_SAVE_TIMEOUT, _edi_editor_autosave_cb, editor);
|
||||
|
||||
_update_lines(editor);
|
||||
}
|
||||
|
||||
|
@ -191,8 +222,7 @@ _smart_cb_key_down(void *data EINA_UNUSED, Evas *e EINA_UNUSED,
|
|||
}
|
||||
else if (!strcmp(ev->key, "s"))
|
||||
{
|
||||
edi_mainview_save();
|
||||
_reset_highlight(editor);
|
||||
edi_editor_save(editor);
|
||||
}
|
||||
else if (!strcmp(ev->key, "f"))
|
||||
{
|
||||
|
@ -710,7 +740,8 @@ _text_set_done(void *data, Evas_Object *obj EINA_UNUSED, void *source EINA_UNUSE
|
|||
_reset_highlight(editor);
|
||||
}
|
||||
|
||||
Evas_Object *_edi_editor_add(Evas_Object *parent, Edi_Mainview_Item *item)
|
||||
Evas_Object *
|
||||
edi_editor_add(Evas_Object *parent, Edi_Mainview_Item *item)
|
||||
{
|
||||
Evas_Object *txt, *lines, *vbox, *box, *searchbar, *statusbar;
|
||||
Evas_Modifier_Mask ctrl, shift, alt;
|
||||
|
@ -773,13 +804,13 @@ Evas_Object *_edi_editor_add(Evas_Object *parent, Edi_Mainview_Item *item)
|
|||
|
||||
elm_entry_file_set(txt, item->path, ELM_TEXT_FORMAT_PLAIN_UTF8);
|
||||
|
||||
elm_entry_autosave_set(txt, EDI_CONTENT_AUTOSAVE);
|
||||
elm_entry_autosave_set(txt, EINA_FALSE);
|
||||
evas_object_size_hint_weight_set(txt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(txt, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_show(txt);
|
||||
elm_box_pack_end(box, txt);
|
||||
|
||||
_edi_editor_search_add(searchbar, editor);
|
||||
edi_editor_search_add(searchbar, editor);
|
||||
_edi_editor_statusbar_add(statusbar, editor, item);
|
||||
|
||||
e = evas_object_evas_get(txt);
|
||||
|
|
|
@ -42,6 +42,8 @@ struct _Edi_Editor
|
|||
/* Private */
|
||||
Evas_Object *lines;
|
||||
Edi_Editor_Search *search;
|
||||
Eina_Bool modified;
|
||||
Ecore_Timer *save_timer;
|
||||
|
||||
/* Add new members here. */
|
||||
|
||||
|
@ -76,7 +78,7 @@ struct _Edi_Editor
|
|||
*
|
||||
* @ingroup Editor
|
||||
*/
|
||||
Evas_Object *_edi_editor_add(Evas_Object *parent, Edi_Mainview_Item *item);
|
||||
Evas_Object *edi_editor_add(Evas_Object *parent, Edi_Mainview_Item *item);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
@ -96,7 +98,7 @@ Evas_Object *_edi_editor_add(Evas_Object *parent, Edi_Mainview_Item *item);
|
|||
*
|
||||
* @ingroup Widgets
|
||||
*/
|
||||
void _edi_editor_search_add(Evas_Object *parent, Edi_Editor *editor);
|
||||
void edi_editor_search_add(Evas_Object *parent, Edi_Editor *editor);
|
||||
|
||||
/**
|
||||
* Start a search in the specified editor.
|
||||
|
@ -105,7 +107,16 @@ void _edi_editor_search_add(Evas_Object *parent, Edi_Editor *editor);
|
|||
*
|
||||
* @ingroup Widgets
|
||||
*/
|
||||
void _edi_editor_search(Edi_Editor *editor);
|
||||
void edi_editor_search(Edi_Editor *editor);
|
||||
|
||||
/**
|
||||
* Save the content of the specified editor.
|
||||
*
|
||||
* @param editor the text editor instance to save.
|
||||
*
|
||||
* @ingroup Widgets
|
||||
*/
|
||||
void edi_editor_save(Edi_Editor *editor);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
|
@ -188,7 +188,7 @@ _edi_editor_search_hide(Edi_Editor *editor)
|
|||
}
|
||||
|
||||
void
|
||||
_edi_editor_search(Edi_Editor *editor)
|
||||
edi_editor_search(Edi_Editor *editor)
|
||||
{
|
||||
Edi_Editor_Search *search;
|
||||
|
||||
|
@ -270,7 +270,7 @@ _edi_search_key_up_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj,
|
|||
}
|
||||
|
||||
void
|
||||
_edi_editor_search_add(Evas_Object *parent, Edi_Editor *editor)
|
||||
edi_editor_search_add(Evas_Object *parent, Edi_Editor *editor)
|
||||
{
|
||||
Evas_Object *entry, *lbl, *btn, *box, *big_box;
|
||||
Evas_Object *replace_entry, *replace_lbl, *replace_btn, *replace_box;
|
||||
|
|
|
@ -549,7 +549,7 @@ edi_mainview_search()
|
|||
editor = (Edi_Editor *)evas_object_data_get(content, "editor");
|
||||
|
||||
if (editor)
|
||||
_edi_editor_search(editor);
|
||||
edi_editor_search(editor);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
// Add some no-op methods here so linking works without having to import the whole UI!
|
||||
EAPI Evas_Object *
|
||||
_edi_editor_add(Evas_Object *parent EINA_UNUSED, Edi_Mainview_Item *item EINA_UNUSED)
|
||||
edi_editor_add(Evas_Object *parent EINA_UNUSED, Edi_Mainview_Item *item EINA_UNUSED)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue