hermet pushed a commit to branch master. http://git.enlightenment.org/tools/enventor.git/commit/?id=dd135280f625988997500510d67582e45ad9c1d1
commit dd135280f625988997500510d67582e45ad9c1d1 Author: ChunEon Park <[email protected]> Date: Fri Feb 28 02:45:49 2014 +0900 search - implementing the gui --- src/bin/edc_editor.c | 10 ++--- src/bin/search.c | 113 +++++++++++++++++++++++++++++++++++++++++++-------- src/include/common.h | 1 - src/include/search.h | 5 ++- 4 files changed, 102 insertions(+), 27 deletions(-) diff --git a/src/bin/edc_editor.c b/src/bin/edc_editor.c index aeebfcc..2d3f5af 100644 --- a/src/bin/edc_editor.c +++ b/src/bin/edc_editor.c @@ -867,10 +867,8 @@ void edit_search(edit_data *ed, const char *word) { Eina_Bool found; - static search_data *sd = NULL; - - sd = search_word(sd, ed->en_edit, word, &found); -// search_stop(sd); - printf("word(%s) found(%d)\n", word, found); - fflush(stdout); + search_open(); +// sd = search_word(sd, ed->en_edit, word, &found); +// printf("word(%s) found(%d)\n", word, found); +// fflush(stdout); } diff --git a/src/bin/search.c b/src/bin/search.c index 345961f..d5c3a6f 100644 --- a/src/bin/search.c +++ b/src/bin/search.c @@ -1,42 +1,125 @@ #include <Elementary.h> #include "common.h" -struct search_s +typedef struct search_s { + Evas_Object *win; int order; -}; +} search_data; -search_data * -search_word(search_data *sd, Evas_Object *entry, const char *word, - Eina_Bool *found) +static search_data *g_sd = NULL; +static Evas_Coord win_x = -1; +static Evas_Coord win_y = -1; +static Evas_Coord win_w = 300; +static Evas_Coord win_h = 100; + +static void +win_delete_request_cb(void *data, Evas_Object *obj, void *event_info) { + search_data *sd = data; + search_close(); +} + +void +search_open() +{ + search_data *sd = calloc(1, sizeof(search_data)); + g_sd = sd; + + //Win + Evas_Object *win = elm_win_add(base_win_get(), "Enventor Search", + ELM_WIN_DIALOG_BASIC); + elm_win_focus_highlight_enabled_set(win, EINA_TRUE); + elm_win_title_set(win, "Find/Replace"); + //FIXME: doesn't moved + if ((win_x == -1) && (win_y == -1)) evas_object_move(win, win_x, win_y); + evas_object_resize(win, win_w, win_h); + evas_object_smart_callback_add(win, "delete,request", win_delete_request_cb, + sd); + evas_object_show(win); + + //BG + Evas_Object *bg = elm_bg_add(win); + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_show(bg); + + elm_win_resize_object_add(win, bg); + + //Box + Evas_Object *box = elm_box_add(win); + evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_show(box); + elm_win_resize_object_add(win, box); + + //Box 2 + Evas_Object *box2 = elm_box_add(box); + evas_object_size_hint_align_set(box2, 0, 0); + evas_object_show(box2); + elm_box_pack_end(box, box2); + + //Label (find) + Evas_Object *label_find; + label_find = elm_label_add(box2); + evas_object_size_hint_align_set(label_find, 0, 0); + elm_object_text_set(label_find, "Find:"); + evas_object_show(label_find); + elm_box_pack_end(box2, label_find); + + //Label (find) + Evas_Object *label_replace; + label_replace = elm_label_add(box2); + evas_object_size_hint_align_set(label_replace, 0, 0); + elm_object_text_set(label_replace, "Replace with:"); + evas_object_show(label_replace); + elm_box_pack_end(box2, label_replace); + + sd->win = win; +} + +void +search_close() +{ + search_data *sd = g_sd; + if (!sd) return; + //Save last state + evas_object_geometry_get(sd->win, NULL, NULL, &win_w, &win_h); + elm_win_screen_position_get(sd->win, &win_x, &win_y); + printf("%d %d\n", win_x, win_y); + evas_object_del(sd->win); + free(sd); + g_sd = NULL; +} + +void +search_word(Evas_Object *entry, const char *word, Eina_Bool *found) +{ + search_data *sd = g_sd; + *found = EINA_FALSE; - if (!word) return NULL; + if (!word) return; const char *text = elm_entry_entry_get(entry); const char *utf8 = elm_entry_markup_to_utf8(text); - if (!sd) sd = calloc(1, sizeof(search_data)); - //There is no word in the text char *s = strstr(utf8, word); if (!s) { free(sd); - return sd; + return; } int order = sd->order; //No more next word found - if ((order > 0) && (strlen(s) <= 1)) return sd; + if ((order > 0) && (strlen(s) <= 1)) return; while (order > 0) { s++; s = strstr(s, word); - if (!s) return sd; + if (!s) return; order--; } @@ -46,11 +129,5 @@ search_word(search_data *sd, Evas_Object *entry, const char *word, sd->order++; *found = EINA_TRUE; - return sd; -} - -void -search_stop(search_data *sd) -{ - if (sd) free(sd); + return; } diff --git a/src/include/common.h b/src/include/common.h index 4627b04..a530df2 100644 --- a/src/include/common.h +++ b/src/include/common.h @@ -9,7 +9,6 @@ typedef struct parser_s parser_data; typedef struct attr_value_s attr_value; typedef struct syntax_helper_s syntax_helper; typedef struct indent_s indent_data; -typedef struct search_s search_data; #include "edc_editor.h" #include "menu.h" diff --git a/src/include/search.h b/src/include/search.h index a1aba51..9713fbc 100644 --- a/src/include/search.h +++ b/src/include/search.h @@ -1,2 +1,3 @@ -search_data * -search_word(search_data *sd, Evas_Object *entry, const char *word, Eina_Bool *found); +void search_word(Evas_Object *entry, const char *word, Eina_Bool *found); +void search_open(); +void search_close(); --
