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 "->"

Reviewers: ajwillia.ms

Reviewed By: ajwillia.ms

Tags: #edi

Differential Revision: https://phab.enlightenment.org/D4976
This commit is contained in:
Al Poole 2017-06-18 22:55:58 +01:00 committed by Andy Williams
parent 197c3dee2b
commit 9677bb4b86
3 changed files with 32 additions and 14 deletions

View File

@ -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) _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; Evas_Event_Key_Down *event;
const char *text; const char *text_markup;
char *command; char *command, *text;
Eina_Bool res; Eina_Bool res;
event = event_info; 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; if (!_debug_exe) return;
text = elm_object_part_text_get(_entry_widget, NULL); text_markup = elm_object_part_text_get(_entry_widget, NULL);
if (strlen(text)) text = elm_entry_markup_to_utf8(text_markup);
if (text)
{ {
command = malloc(strlen(text) + 2); command = malloc(strlen(text) + 2);
snprintf(command, strlen(text) + 2, "%s\n", text); 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); elm_code_file_line_append(_debug_output->file, command, strlen(command) - 1, NULL);
free(command); free(command);
free(text);
} }
elm_object_part_text_set(_entry_widget, NULL, ""); elm_object_part_text_set(_entry_widget, NULL, "");
} }

View File

@ -87,7 +87,7 @@ _edi_search_term_changed(Edi_Editor_Search *search, const char *text)
} }
static void 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; *text = search->first_result.text;
*line = search->first_result.line; *line = search->first_result.line;
@ -103,18 +103,21 @@ _edi_search_in_entry(Evas_Object *entry, Edi_Editor_Search *search)
Eina_List *item; Eina_List *item;
Elm_Code *code; Elm_Code *code;
Elm_Code_Line *line; Elm_Code_Line *line;
const char *text; const char *text_markup;
char *text;
unsigned int offset, pos_line, pos_col; unsigned int offset, pos_line, pos_col;
int found; int found;
search->wrap = elm_check_state_get(search->checkbox); search->wrap = elm_check_state_get(search->checkbox);
text = elm_object_text_get(search->entry); text_markup = elm_object_text_get(search->entry);
if (!text || !*text) if (!text_markup || !text_markup[0])
{ {
search->term_found = EINA_FALSE; search->term_found = EINA_FALSE;
return EINA_FALSE; return EINA_FALSE;
} }
text = elm_entry_markup_to_utf8(text_markup);
code = elm_code_widget_code_get(entry); code = elm_code_widget_code_get(entry);
elm_code_widget_cursor_position_get(entry, &pos_line, &pos_col); elm_code_widget_cursor_position_get(entry, &pos_line, &pos_col);
if (search->current_search_line == pos_line && 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_selection_end(entry, search->current_search_line,
elm_code_widget_line_text_column_width_to_position(entry, line, found + strlen(text)) - 1); elm_code_widget_line_text_column_width_to_position(entry, line, found + strlen(text)) - 1);
free(text);
return EINA_TRUE; return EINA_TRUE;
} }
@ -215,7 +220,8 @@ static void
_edi_replace_in_entry(void *data, Edi_Editor_Search *search) _edi_replace_in_entry(void *data, Edi_Editor_Search *search)
{ {
Edi_Editor *editor; Edi_Editor *editor;
const char *replace; const char *replace_markup;
char *replace = NULL;
editor = (Edi_Editor *)data; editor = (Edi_Editor *)data;
// If there is no search term found to replace, then do a new search first. // 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) if (search->current_search_line)
{ {
elm_code_widget_selection_delete(editor->entry); elm_code_widget_selection_delete(editor->entry);
replace = elm_object_text_get(search->replace_entry); replace_markup = elm_object_text_get(search->replace_entry);
elm_code_widget_text_at_cursor_insert(editor->entry, replace); 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; 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); _edi_search_in_entry(editor->entry, search);
} }
if (replace)
free(replace);
return; return;
} }

View File

@ -849,13 +849,18 @@ _edi_mainview_project_search_cb(void *data,
Evas_Object *obj EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED) void *event_info EINA_UNUSED)
{ {
const char *text; const char *text_markup;
char *text;
text = elm_entry_entry_get((Evas_Object *) data); text_markup = elm_object_text_get((Evas_Object *) data);
if (!text || strlen(text) == 0) return; if (!text_markup || !text_markup[0]) return;
text = elm_entry_markup_to_utf8(text_markup);
edi_searchpanel_show(); edi_searchpanel_show();
edi_searchpanel_find(text); edi_searchpanel_find(text);
free(text);
evas_object_del(_edi_mainview_search_project_popup); evas_object_del(_edi_mainview_search_project_popup);
} }