ajwillia-ms pushed a commit to branch master.

http://git.enlightenment.org/tools/edi.git/commit/?id=9677bb4b866d20549036b92a4679fa3aa178a487

commit 9677bb4b866d20549036b92a4679fa3aa178a487
Author: Al Poole <[email protected]>
Date:   Sun Jun 18 22:55:58 2017 +0100

    general input: work around elm_entry assuming markup in input.
    
    Test Plan: Run Edi, start a debug session. Print prt to struct member e.g. 
"print m->file", stops conversion to "-&gt;"
    
    Reviewers: ajwillia.ms
    
    Reviewed By: ajwillia.ms
    
    Tags: #edi
    
    Differential Revision: https://phab.enlightenment.org/D4976
---
 src/bin/edi_debugpanel.c           | 10 ++++++----
 src/bin/editor/edi_editor_search.c | 25 ++++++++++++++++++-------
 src/bin/mainview/edi_mainview.c    | 11 ++++++++---
 3 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/src/bin/edi_debugpanel.c b/src/bin/edi_debugpanel.c
index 5b491ca..0b4deb6 100644
--- a/src/bin/edi_debugpanel.c
+++ b/src/bin/edi_debugpanel.c
@@ -81,8 +81,8 @@ static void
 _edi_debugpanel_keypress_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, 
Evas_Object *obj EINA_UNUSED, void *event_info)
 {
    Evas_Event_Key_Down *event;
-   const char *text; 
-   char *command;
+   const char *text_markup;
+   char *command, *text;
    Eina_Bool res;
 
    event = event_info;
@@ -95,8 +95,9 @@ _edi_debugpanel_keypress_cb(void *data EINA_UNUSED, Evas *e 
EINA_UNUSED, Evas_Ob
      {
         if (!_debug_exe) return;
 
-        text = elm_object_part_text_get(_entry_widget, NULL);
-        if (strlen(text))
+        text_markup = elm_object_part_text_get(_entry_widget, NULL);
+        text = elm_entry_markup_to_utf8(text_markup);
+        if (text)
           {
              command = malloc(strlen(text) + 2);
              snprintf(command, strlen(text) + 2, "%s\n", text);
@@ -105,6 +106,7 @@ _edi_debugpanel_keypress_cb(void *data EINA_UNUSED, Evas *e 
EINA_UNUSED, Evas_Ob
                elm_code_file_line_append(_debug_output->file, command, 
strlen(command) - 1, NULL);
 
              free(command);
+             free(text);
           }
         elm_object_part_text_set(_entry_widget, NULL, "");
      }
diff --git a/src/bin/editor/edi_editor_search.c 
b/src/bin/editor/edi_editor_search.c
index b4b6792..3152fc1 100644
--- a/src/bin/editor/edi_editor_search.c
+++ b/src/bin/editor/edi_editor_search.c
@@ -87,7 +87,7 @@ _edi_search_term_changed(Edi_Editor_Search *search, const 
char *text)
 }
 
 static void
-_edi_search_cache_use(Edi_Editor_Search *search, const char **text 
EINA_UNUSED, Elm_Code_Line **line EINA_UNUSED, int *found)
+_edi_search_cache_use(Edi_Editor_Search *search, char **text, Elm_Code_Line 
**line, int *found)
 {
    *text = search->first_result.text;
    *line = search->first_result.line;
@@ -103,18 +103,21 @@ _edi_search_in_entry(Evas_Object *entry, 
Edi_Editor_Search *search)
    Eina_List *item;
    Elm_Code *code;
    Elm_Code_Line *line;
-   const char *text;
+   const char *text_markup;
+   char *text;
    unsigned int offset, pos_line, pos_col;
    int found;
    search->wrap = elm_check_state_get(search->checkbox);
 
-   text = elm_object_text_get(search->entry);
-   if (!text || !*text)
+   text_markup = elm_object_text_get(search->entry);
+   if (!text_markup || !text_markup[0])
      {
         search->term_found = EINA_FALSE;
         return EINA_FALSE;
      }
 
+   text = elm_entry_markup_to_utf8(text_markup);
+
    code = elm_code_widget_code_get(entry);
    elm_code_widget_cursor_position_get(entry, &pos_line, &pos_col);
    if (search->current_search_line == pos_line &&
@@ -190,6 +193,8 @@ _edi_search_in_entry(Evas_Object *entry, Edi_Editor_Search 
*search)
    elm_code_widget_selection_end(entry, search->current_search_line,
                                  
elm_code_widget_line_text_column_width_to_position(entry, line, found + 
strlen(text)) - 1);
 
+   free(text);
+
    return EINA_TRUE;
 }
 
@@ -215,7 +220,8 @@ static void
 _edi_replace_in_entry(void *data, Edi_Editor_Search *search)
 {
    Edi_Editor *editor;
-   const char *replace;
+   const char *replace_markup;
+   char *replace = NULL;
 
    editor = (Edi_Editor *)data;
    // If there is no search term found to replace, then do a new search first.
@@ -228,8 +234,10 @@ _edi_replace_in_entry(void *data, Edi_Editor_Search 
*search)
         if (search->current_search_line)
           {
              elm_code_widget_selection_delete(editor->entry);
-             replace = elm_object_text_get(search->replace_entry);
-             elm_code_widget_text_at_cursor_insert(editor->entry, replace);
+             replace_markup = elm_object_text_get(search->replace_entry);
+             replace = elm_entry_markup_to_utf8(replace_markup);
+             if (strlen(replace))
+               elm_code_widget_text_at_cursor_insert(editor->entry, replace);
 
              search->current_search_line = 0;
           }
@@ -240,6 +248,9 @@ _edi_replace_in_entry(void *data, Edi_Editor_Search *search)
         _edi_search_in_entry(editor->entry, search);
      }
 
+  if (replace)
+     free(replace);
+
    return;
 }
 
diff --git a/src/bin/mainview/edi_mainview.c b/src/bin/mainview/edi_mainview.c
index 1bf8236..eed3364 100644
--- a/src/bin/mainview/edi_mainview.c
+++ b/src/bin/mainview/edi_mainview.c
@@ -849,13 +849,18 @@ _edi_mainview_project_search_cb(void *data,
                              Evas_Object *obj EINA_UNUSED,
                              void *event_info EINA_UNUSED)
 {
-   const char *text;
+   const char *text_markup;
+   char *text;
 
-   text = elm_entry_entry_get((Evas_Object *) data);
-   if (!text || strlen(text) == 0) return;
+   text_markup = elm_object_text_get((Evas_Object *) data);
+   if (!text_markup || !text_markup[0]) return;
+
+   text = elm_entry_markup_to_utf8(text_markup);
 
    edi_searchpanel_show();
    edi_searchpanel_find(text);
+
+   free(text);
    evas_object_del(_edi_mainview_search_project_popup);
 }
 

-- 


Reply via email to