nikawhite pushed a commit to branch master.

http://git.enlightenment.org/tools/enventor.git/commit/?id=02b45c0719b81518ec2c92d95958464fe023f1c3

commit 02b45c0719b81518ec2c92d95958464fe023f1c3
Author: Mykyta Biliavskyi <m.biliavs...@samsung.com>
Date:   Mon Feb 22 18:41:22 2016 +0900

    Redoundo: Support the real-time preview when we undo/redo the code.
    
    When user undo or redo change, the edc file will be recompiled and the
    live view will be updated. There are two flow: in case if the change is 
buildable
    (i.e. the edc file was builded sucessfuly, when this change happened)
    edc file will be recompiled. In case when change marked as unbilduable -
    nothing will happen.
    
    @T3051
---
 src/lib/edc_editor.c       |  2 +-
 src/lib/enventor_private.h |  3 ++-
 src/lib/enventor_smart.c   | 14 ++++++++++----
 src/lib/redoundo.c         | 34 ++++++++++++++++++++++++++++++++--
 4 files changed, 45 insertions(+), 8 deletions(-)

diff --git a/src/lib/edc_editor.c b/src/lib/edc_editor.c
index 3b04717..fece9e5 100644
--- a/src/lib/edc_editor.c
+++ b/src/lib/edc_editor.c
@@ -1491,7 +1491,7 @@ edit_init(Evas_Object *enventor)
    ed->select_pos = -1;
    ed->font_scale = 1;
 
-   ed->rd = redoundo_init(en_edit);
+   ed->rd = redoundo_init(en_edit, ed);
    evas_object_data_set(ed->en_edit, "redoundo", ed->rd);
 
    return ed;
diff --git a/src/lib/enventor_private.h b/src/lib/enventor_private.h
index 8febd4f..41c8acc 100644
--- a/src/lib/enventor_private.h
+++ b/src/lib/enventor_private.h
@@ -198,7 +198,7 @@ void edj_mgr_all_views_reload(void);
 
 
 /* redoundo */
-redoundo_data *redoundo_init(Evas_Object *entry);
+redoundo_data *redoundo_init(Evas_Object *entry, edit_data *ed);
 void redoundo_term(redoundo_data *rd);
 void redoundo_clear(redoundo_data *rd);
 void redoundo_text_push(redoundo_data *rd, const char *text, int pos, int 
length, Eina_Bool insert);
@@ -208,6 +208,7 @@ int redoundo_undo(redoundo_data *rd, Eina_Bool *changed);
 int redoundo_redo(redoundo_data *rd, Eina_Bool *changed);
 void redoundo_n_diff_cancel(redoundo_data *rd, unsigned int n);
 void redoundo_smart_set(redoundo_data *rd, Eina_Bool status);
+void redoundo_diff_buildable(redoundo_data *rd, Eina_Bool buildable);
 
 
 /* edj_viewer */
diff --git a/src/lib/enventor_smart.c b/src/lib/enventor_smart.c
index b580482..eb195e1 100644
--- a/src/lib/enventor_smart.c
+++ b/src/lib/enventor_smart.c
@@ -154,14 +154,20 @@ call_error:
    if (line_num || target)
      edit_syntax_color_full_apply(pd->ed, EINA_TRUE);
 
+   redoundo_data *rd = evas_object_data_get(edit_entry_get(pd->ed), 
"redoundo");
+
    // When msg == NULL it mean, that needed to reset error state
    if (msg)
      {
-       // Ctxpopup should be dismissed only in cases when error happens
-       edit_ctxpopup_dismiss(pd->ed);
-       evas_object_smart_callback_call(pd->obj, SIG_COMPILE_ERROR, (char 
*)msg);
+        // Ctxpopup should be dismissed only in cases when error happens
+        edit_ctxpopup_dismiss(pd->ed);
+        evas_object_smart_callback_call(pd->obj, SIG_COMPILE_ERROR, (char 
*)msg);
+        redoundo_diff_buildable(rd, EINA_FALSE);
+     }
+   else
+     {
+        redoundo_diff_buildable(rd, EINA_TRUE);
      }
-
 }
 
 static void
diff --git a/src/lib/redoundo.c b/src/lib/redoundo.c
index 01d7106..2dee312 100644
--- a/src/lib/redoundo.c
+++ b/src/lib/redoundo.c
@@ -15,6 +15,7 @@ typedef struct diff_s
    unsigned int cursor_pos;
    Eina_Bool action : 1;   //EINA_TRUE: insert, EINA_FALSE, delete
    Eina_Bool relative : 1; //If this change relative to prevision or next step
+   Eina_Bool buildable : 1;           //Is this change buildable?
 } diff_data;
 
 struct redoundo_s
@@ -27,6 +28,7 @@ struct redoundo_s
    diff_data *last_diff;
    unsigned int queue_max;        //Maximum queuing data count 0: unlimited
    Eina_Bool internal_change : 1; //Entry change by redoundo
+   edit_data *edit_data;
    struct {
       Eina_Bool enable;
       Ecore_Timer *timer;
@@ -188,7 +190,12 @@ redoundo_undo(redoundo_data *rd, Eina_Bool *changed)
 {
    if (changed) *changed = EINA_FALSE;
 
-   if (!rd->last_diff) return 0;
+   if (!rd->last_diff)
+     {
+        edit_save(rd->edit_data, build_edc_path_get());
+        build_edc();
+        return 0;
+     }
 
    rd->internal_change = EINA_TRUE;
 
@@ -246,6 +253,12 @@ redoundo_undo(redoundo_data *rd, Eina_Bool *changed)
         elm_entry_select_none(rd->entry);
      }
 
+   if (rd->last_diff && rd->last_diff->buildable)
+     {
+        edit_save(rd->edit_data, build_edc_path_get());
+        build_edc();
+     }
+
    return lines;
 }
 
@@ -325,6 +338,12 @@ redoundo_redo(redoundo_data *rd, Eina_Bool *changed)
         elm_entry_select_none(rd->entry);
      }
 
+   if (rd->last_diff && rd->last_diff->buildable)
+     {
+        edit_save(rd->edit_data, build_edc_path_get());
+        build_edc();
+     }
+
    return lines;
 }
 
@@ -366,7 +385,7 @@ redoundo_text_push(redoundo_data *rd, const char *text, int 
pos, int length,
 }
 
 redoundo_data *
-redoundo_init(Evas_Object *entry)
+redoundo_init(Evas_Object *entry, edit_data *ed)
 {
    if (!entry) return NULL;
 
@@ -383,6 +402,7 @@ redoundo_init(Evas_Object *entry)
    rd->queue_max = DEFAULT_QUEUE_SIZE;
    rd->smart.enable = EINA_FALSE;
    rd->smart.input_delay = INPUT_SPEED;
+   rd->edit_data = ed;
 
    //FIXME: Why signal callback? not smart callback?
    elm_object_signal_callback_add(entry, "entry,changed,user", "*",
@@ -467,3 +487,13 @@ redoundo_smart_set(redoundo_data *rd, Eina_Bool status)
    if (!rd) return;
    rd->smart.enable = status;
 }
+
+void
+redoundo_diff_buildable(redoundo_data *rd, Eina_Bool buildable)
+{
+   if (!rd || !rd->queue || !rd->last_diff)
+     return;
+
+   rd->last_diff->buildable = buildable;
+}
+

-- 


Reply via email to