2014-09-30 07:56:16 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define ENVENTOR_BETA_API_SUPPORT 1
|
|
|
|
|
|
|
|
#include <Enventor.h>
|
|
|
|
#include <Eio.h>
|
|
|
|
#include "enventor_private.h"
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
//FIXME: Make flexible
|
|
|
|
const int MAX_LINE_DIGIT_CNT = 10;
|
2014-05-27 00:30:09 -07:00
|
|
|
const int SYNTAX_COLOR_SPARE_LINES = 42;
|
2014-05-26 07:35:57 -07:00
|
|
|
const double SYNTAX_COLOR_DEFAULT_TIME = 0.25;
|
|
|
|
const double SYNTAX_COLOR_SHORT_TIME = 0.025;
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2014-05-27 01:17:15 -07:00
|
|
|
typedef struct syntax_color_thread_data_s
|
|
|
|
{
|
|
|
|
edit_data *ed;
|
|
|
|
char *text;
|
|
|
|
const char *translated;
|
|
|
|
} syntax_color_td;
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
struct editor_s
|
|
|
|
{
|
|
|
|
Evas_Object *en_edit;
|
|
|
|
Evas_Object *en_line;
|
|
|
|
Evas_Object *scroller;
|
|
|
|
Evas_Object *layout;
|
2014-09-30 07:56:16 -07:00
|
|
|
Evas_Object *enventor;
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2013-08-15 08:47:31 -07:00
|
|
|
syntax_helper *sh;
|
2013-07-20 01:51:56 -07:00
|
|
|
parser_data *pd;
|
2014-08-02 00:41:24 -07:00
|
|
|
redoundo_data *rd;
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2013-09-15 01:07:43 -07:00
|
|
|
int cur_line;
|
2013-07-20 01:51:56 -07:00
|
|
|
int line_max;
|
2014-06-04 08:50:41 -07:00
|
|
|
int syntax_color_lock;
|
2014-05-26 07:35:57 -07:00
|
|
|
Evas_Coord scroller_h;
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2014-04-01 00:05:08 -07:00
|
|
|
Ecore_Timer *syntax_color_timer;
|
2014-05-27 01:17:15 -07:00
|
|
|
Ecore_Thread *syntax_color_thread;
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2013-09-18 10:05:46 -07:00
|
|
|
void (*view_sync_cb)(void *data, Eina_Stringshare *part_name,
|
|
|
|
Eina_Stringshare *group_name);
|
|
|
|
void *view_sync_cb_data;
|
2014-06-07 21:17:06 -07:00
|
|
|
int select_pos;
|
2014-09-30 07:56:16 -07:00
|
|
|
double font_scale;
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
Eina_Bool edit_changed : 1;
|
|
|
|
Eina_Bool linenumber : 1;
|
|
|
|
Eina_Bool ctrl_pressed : 1;
|
2014-06-07 21:17:06 -07:00
|
|
|
Eina_Bool on_select_recover : 1;
|
2014-09-30 07:56:16 -07:00
|
|
|
Eina_Bool auto_indent : 1;
|
|
|
|
Eina_Bool part_highlight : 1;
|
|
|
|
Eina_Bool ctxpopup: 1;
|
2014-10-23 00:39:31 -07:00
|
|
|
Eina_Bool on_save : 1;
|
2013-07-20 01:51:56 -07:00
|
|
|
};
|
|
|
|
|
2014-09-30 07:56:16 -07:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* Internal method implementation */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
2014-03-15 00:08:04 -07:00
|
|
|
static Eina_Bool
|
|
|
|
image_preview_show(edit_data *ed, char *cur, Evas_Coord x, Evas_Coord y);
|
2013-09-09 08:58:33 -07:00
|
|
|
|
2014-05-13 23:59:49 -07:00
|
|
|
static void
|
|
|
|
line_init(edit_data *ed)
|
|
|
|
{
|
|
|
|
char buf[MAX_LINE_DIGIT_CNT];
|
|
|
|
|
|
|
|
ed->line_max = 1;
|
|
|
|
snprintf(buf, sizeof(buf), "%d", ed->line_max);
|
|
|
|
elm_entry_entry_set(ed->en_line, buf);
|
|
|
|
}
|
|
|
|
|
2014-05-26 07:35:57 -07:00
|
|
|
static void
|
2014-05-27 01:17:15 -07:00
|
|
|
visible_text_region_get(edit_data *ed, int *from_line, int *to_line)
|
2014-05-26 07:35:57 -07:00
|
|
|
{
|
|
|
|
Evas_Coord region_y, region_h;
|
|
|
|
Evas_Coord cursor_h;
|
|
|
|
|
|
|
|
elm_scroller_region_get(ed->scroller, NULL, ®ion_y, NULL, ®ion_h);
|
|
|
|
elm_entry_cursor_geometry_get(ed->en_edit, NULL, NULL, NULL, &cursor_h);
|
|
|
|
|
2014-05-27 00:30:09 -07:00
|
|
|
int from = (region_y / cursor_h);
|
|
|
|
int to = from + (region_h / cursor_h);
|
2014-05-26 07:35:57 -07:00
|
|
|
from -= SYNTAX_COLOR_SPARE_LINES;
|
|
|
|
to += SYNTAX_COLOR_SPARE_LINES;
|
|
|
|
|
|
|
|
if (from < 1) from = 1;
|
|
|
|
if (to > ed->line_max) to = ed->line_max;
|
|
|
|
|
|
|
|
*from_line = from;
|
|
|
|
*to_line = to;
|
|
|
|
}
|
|
|
|
|
2014-06-07 21:17:06 -07:00
|
|
|
static void
|
|
|
|
entry_recover(edit_data *ed, int cursor_pos)
|
|
|
|
{
|
|
|
|
elm_entry_calc_force(ed->en_edit);
|
|
|
|
|
|
|
|
//recover cursor position??
|
|
|
|
elm_entry_cursor_pos_set(ed->en_edit, 0);
|
|
|
|
elm_entry_cursor_pos_set(ed->en_edit, cursor_pos);
|
|
|
|
|
|
|
|
//not on selection mode
|
|
|
|
if (ed->select_pos == -1) return;
|
|
|
|
|
|
|
|
//recover selection region
|
2014-08-06 02:02:54 -07:00
|
|
|
const char *selected = elm_entry_selection_get(ed->en_edit);
|
|
|
|
if (!selected) return;
|
|
|
|
char *utf8 = evas_textblock_text_markup_to_utf8(NULL, selected);
|
2014-06-07 21:17:06 -07:00
|
|
|
ed->on_select_recover = EINA_TRUE;
|
|
|
|
elm_entry_select_region_set(ed->en_edit, ed->select_pos, cursor_pos);
|
|
|
|
ed->on_select_recover = EINA_FALSE;
|
|
|
|
free(utf8);
|
|
|
|
}
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
static void
|
2014-06-04 08:50:41 -07:00
|
|
|
syntax_color_apply(edit_data *ed, Eina_Bool partial)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-05-26 07:35:57 -07:00
|
|
|
Evas_Object *tb = elm_entry_textblock_get(ed->en_edit);
|
|
|
|
char *text = (char *) evas_object_textblock_text_markup_get(tb);
|
2013-07-20 01:51:56 -07:00
|
|
|
int pos = elm_entry_cursor_pos_get(ed->en_edit);
|
2014-05-26 07:35:57 -07:00
|
|
|
|
2014-06-04 08:50:41 -07:00
|
|
|
int from_line = 1;
|
|
|
|
int to_line = -1;
|
|
|
|
if (partial) visible_text_region_get(ed, &from_line, &to_line);
|
2014-05-26 07:35:57 -07:00
|
|
|
|
2014-06-04 08:50:41 -07:00
|
|
|
char *from = NULL;
|
|
|
|
char *to = NULL;
|
2013-08-15 08:47:31 -07:00
|
|
|
char *utf8 = (char *) color_cancel(syntax_color_data_get(ed->sh), text,
|
2014-05-26 07:35:57 -07:00
|
|
|
strlen(text), from_line, to_line, &from,
|
|
|
|
&to);
|
2013-07-20 01:51:56 -07:00
|
|
|
if (!utf8) return;
|
2014-05-26 07:35:57 -07:00
|
|
|
|
2013-08-15 08:47:31 -07:00
|
|
|
const char *translated = color_apply(syntax_color_data_get(ed->sh), utf8,
|
2014-05-26 07:35:57 -07:00
|
|
|
strlen(utf8), from, to);
|
|
|
|
if (!translated) return;
|
2014-05-22 06:17:12 -07:00
|
|
|
|
|
|
|
/* I'm not sure this will be problem.
|
|
|
|
But it can avoid entry_object_text_escaped_set() in Edje.
|
|
|
|
Logically that's unnecessary in this case. */
|
|
|
|
evas_object_textblock_text_markup_set(tb, translated);
|
2014-05-26 21:52:15 -07:00
|
|
|
|
2014-06-07 21:17:06 -07:00
|
|
|
entry_recover(ed, pos);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
syntax_color_timer_cb(void *data)
|
|
|
|
{
|
|
|
|
edit_data *ed = data;
|
2014-05-20 00:54:41 -07:00
|
|
|
if (!color_ready(syntax_color_data_get(ed->sh))) return ECORE_CALLBACK_RENEW;
|
2014-06-04 08:50:41 -07:00
|
|
|
syntax_color_apply(ed, EINA_TRUE);
|
2013-10-03 10:24:29 -07:00
|
|
|
ed->syntax_color_timer = NULL;
|
2013-07-20 01:51:56 -07:00
|
|
|
return ECORE_CALLBACK_CANCEL;
|
|
|
|
}
|
|
|
|
|
2013-10-03 10:24:29 -07:00
|
|
|
static void
|
2014-08-06 02:02:54 -07:00
|
|
|
syntax_color_partial_update(edit_data *ed, double interval)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-06-04 08:50:41 -07:00
|
|
|
/* If the syntax_color_full_update is requested forcely, lock would be -1
|
|
|
|
in this case, it should avoid partial updation by entry changed. */
|
|
|
|
if (ed->syntax_color_lock != 0) return;
|
2014-05-27 01:17:15 -07:00
|
|
|
ecore_thread_cancel(ed->syntax_color_thread);
|
|
|
|
ed->syntax_color_thread = NULL;
|
2014-03-15 21:28:11 -07:00
|
|
|
ecore_timer_del(ed->syntax_color_timer);
|
2014-08-06 02:02:54 -07:00
|
|
|
ed->syntax_color_timer = ecore_timer_add(interval, syntax_color_timer_cb, ed);
|
2013-10-03 10:24:29 -07:00
|
|
|
}
|
|
|
|
|
2014-05-27 01:17:15 -07:00
|
|
|
static void
|
|
|
|
syntax_color_thread_cb(void *data, Ecore_Thread *thread EINA_UNUSED)
|
|
|
|
{
|
|
|
|
syntax_color_td *td = data;
|
|
|
|
char *utf8 = (char *) color_cancel(syntax_color_data_get(td->ed->sh),
|
|
|
|
td->text, strlen(td->text), -1, -1, NULL,
|
|
|
|
NULL);
|
|
|
|
if (!utf8) return;
|
|
|
|
td->translated = color_apply(syntax_color_data_get(td->ed->sh), utf8,
|
|
|
|
strlen(utf8), NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
syntax_color_thread_end_cb(void *data, Ecore_Thread *thread EINA_UNUSED)
|
|
|
|
{
|
|
|
|
syntax_color_td *td = data;
|
|
|
|
if (!td->translated) return;
|
|
|
|
|
|
|
|
int pos = elm_entry_cursor_pos_get(td->ed->en_edit);
|
|
|
|
Evas_Object *tb = elm_entry_textblock_get(td->ed->en_edit);
|
|
|
|
|
|
|
|
/* I'm not sure this will be problem.
|
|
|
|
But it can avoid entry_object_text_escaped_set() in Edje.
|
|
|
|
Logically that's unnecessary in this case. */
|
|
|
|
evas_object_textblock_text_markup_set(tb, td->translated);
|
|
|
|
|
2014-06-07 21:17:06 -07:00
|
|
|
entry_recover(td->ed, pos);
|
2014-05-27 01:17:15 -07:00
|
|
|
|
|
|
|
td->ed->syntax_color_thread = NULL;
|
|
|
|
free(td);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
syntax_color_thread_cancel_cb(void *data, Ecore_Thread *thread EINA_UNUSED)
|
|
|
|
{
|
|
|
|
syntax_color_td *td = data;
|
|
|
|
td->ed->syntax_color_thread = NULL;
|
|
|
|
free(td);
|
|
|
|
}
|
|
|
|
|
2013-08-19 07:29:43 -07:00
|
|
|
static void
|
2013-09-12 06:14:16 -07:00
|
|
|
edit_changed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
|
|
|
Elm_Entry_Change_Info *info = event_info;
|
|
|
|
edit_data *ed = data;
|
2014-05-28 23:23:10 -07:00
|
|
|
edit_changed_set(ed, EINA_TRUE);
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2013-08-19 10:46:37 -07:00
|
|
|
Eina_Bool syntax_color = EINA_TRUE;
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
if (info->insert)
|
|
|
|
{
|
2014-02-27 08:07:06 -08:00
|
|
|
if ((info->change.insert.plain_length == 1)&&
|
|
|
|
(info->change.insert.content[0] == ' ')) return;
|
2013-09-15 06:44:04 -07:00
|
|
|
|
2014-03-16 02:01:47 -07:00
|
|
|
if (!strcmp(info->change.insert.content, EOL))
|
2013-08-19 07:29:43 -07:00
|
|
|
{
|
2014-07-18 21:31:08 -07:00
|
|
|
edit_line_increase(ed, 1);
|
2013-08-19 10:46:37 -07:00
|
|
|
syntax_color = EINA_FALSE;
|
2013-08-19 07:29:43 -07:00
|
|
|
}
|
2014-06-04 06:37:00 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
int increase =
|
|
|
|
parser_line_cnt_get(ed->pd, info->change.insert.content);
|
2014-07-18 21:31:08 -07:00
|
|
|
edit_line_increase(ed, increase);
|
2014-06-04 06:37:00 -07:00
|
|
|
}
|
2013-09-15 01:07:43 -07:00
|
|
|
|
2014-09-30 07:56:16 -07:00
|
|
|
if (ed->auto_indent)
|
2013-09-15 01:20:13 -07:00
|
|
|
indent_insert_apply(syntax_indent_data_get(ed->sh), ed->en_edit,
|
|
|
|
info->change.insert.content, ed->cur_line);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-19 06:29:19 -07:00
|
|
|
int decrease = parser_line_cnt_get(ed->pd, info->change.del.content);
|
2013-09-15 06:44:04 -07:00
|
|
|
|
2014-09-30 07:56:16 -07:00
|
|
|
if (ed->auto_indent)
|
2013-09-15 08:22:15 -07:00
|
|
|
{
|
|
|
|
if (indent_delete_apply(syntax_indent_data_get(ed->sh),
|
|
|
|
ed->en_edit, info->change.del.content,
|
|
|
|
ed->cur_line))
|
|
|
|
decrease++;
|
|
|
|
}
|
2013-09-15 06:44:04 -07:00
|
|
|
|
2014-07-18 21:31:08 -07:00
|
|
|
edit_line_decrease(ed, decrease);
|
2013-09-15 06:44:04 -07:00
|
|
|
if (info->change.del.content[0] == ' ') return;
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
2013-08-19 10:46:37 -07:00
|
|
|
if (!syntax_color) return;
|
2014-05-26 21:52:15 -07:00
|
|
|
syntax_color_partial_update(ed, SYNTAX_COLOR_DEFAULT_TIME);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-09-12 06:14:16 -07:00
|
|
|
ctxpopup_candidate_dismiss_cb(void *data, Evas_Object *obj,
|
|
|
|
void *event_info EINA_UNUSED)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
|
|
|
edit_data *ed = data;
|
|
|
|
evas_object_del(obj);
|
|
|
|
elm_object_disabled_set(ed->layout, EINA_FALSE);
|
|
|
|
elm_object_focus_set(ed->en_edit, EINA_TRUE);
|
2014-09-30 07:56:16 -07:00
|
|
|
evas_object_smart_callback_call(ed->enventor, SIG_CTXPOPUP_DISMISSED, NULL);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-09-08 01:04:56 -07:00
|
|
|
ctxpopup_candidate_selected_cb(void *data, Evas_Object *obj, void *event_info)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
|
|
|
edit_data *ed = data;
|
2013-08-08 10:22:56 -07:00
|
|
|
const char *text = event_info;
|
2014-08-02 00:41:24 -07:00
|
|
|
redoundo_text_relative_push(ed->rd, text);
|
2013-08-08 10:22:56 -07:00
|
|
|
elm_entry_entry_insert(ed->en_edit, text);
|
2013-07-20 01:51:56 -07:00
|
|
|
elm_ctxpopup_dismiss(obj);
|
2014-05-28 23:23:10 -07:00
|
|
|
edit_changed_set(ed, EINA_TRUE);
|
2014-09-30 07:56:16 -07:00
|
|
|
evas_object_smart_callback_call(ed->enventor, SIG_CTXPOPUP_SELECTED,
|
|
|
|
(void *)text);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
2013-09-08 01:04:56 -07:00
|
|
|
static void
|
2013-09-12 06:14:16 -07:00
|
|
|
ctxpopup_preview_dismiss_cb(void *data, Evas_Object *obj,
|
|
|
|
void *event_info EINA_UNUSED)
|
2013-09-08 01:04:56 -07:00
|
|
|
{
|
|
|
|
edit_data *ed = data;
|
2014-08-22 09:03:51 -07:00
|
|
|
int skip_focus = (int)(uintptr_t) evas_object_data_get(obj, "continue");
|
2013-09-08 01:04:56 -07:00
|
|
|
evas_object_del(obj);
|
2013-09-09 08:58:33 -07:00
|
|
|
|
|
|
|
//Since the ctxpopup will be shown again, Don't revert the focus.
|
|
|
|
if (skip_focus) return;
|
2013-09-08 01:04:56 -07:00
|
|
|
elm_object_disabled_set(ed->layout, EINA_FALSE);
|
|
|
|
elm_object_focus_set(ed->en_edit, EINA_TRUE);
|
|
|
|
}
|
|
|
|
|
2013-09-09 08:58:33 -07:00
|
|
|
//This function is called when user press up/down key or mouse wheel up/down
|
|
|
|
static void
|
|
|
|
preview_img_relay_show(edit_data *ed, Evas_Object *ctxpopup, Eina_Bool next)
|
|
|
|
{
|
|
|
|
if (next) elm_entry_cursor_down(ed->en_edit);
|
|
|
|
else elm_entry_cursor_up(ed->en_edit);
|
|
|
|
|
|
|
|
Evas_Object *textblock = elm_entry_textblock_get(ed->en_edit);
|
|
|
|
Evas_Textblock_Cursor *cursor = evas_object_textblock_cursor_get(textblock);
|
|
|
|
const char *str = evas_textblock_cursor_paragraph_text_get(cursor);
|
|
|
|
char *text = elm_entry_markup_to_utf8(str);
|
|
|
|
|
|
|
|
//Compute current ctxpopup position.
|
|
|
|
Evas_Coord x, y, h;
|
|
|
|
evas_object_geometry_get(ctxpopup, &x, &y, NULL, NULL);
|
|
|
|
elm_entry_cursor_geometry_get(ed->en_edit, NULL, NULL, NULL, &h);
|
|
|
|
|
|
|
|
if (next) y += h;
|
|
|
|
else y -= h;
|
|
|
|
|
|
|
|
//Limit the ctxpopup position in the scroller vertical zone.
|
|
|
|
Evas_Coord scrl_y, scrl_h;
|
|
|
|
evas_object_geometry_get(ed->scroller, NULL, &scrl_y, NULL, &scrl_h);
|
|
|
|
|
|
|
|
if (y > (scrl_y + scrl_h)) y = (scrl_y + scrl_h);
|
|
|
|
else if (y < scrl_y) y = scrl_y;
|
|
|
|
|
|
|
|
if (image_preview_show(ed, text, x, y))
|
|
|
|
{
|
|
|
|
/* Since the ctxpopup will be shown again,
|
|
|
|
Don't revert the focus in the dismiss cb. */
|
|
|
|
evas_object_data_set(ctxpopup, "continue", (void *) 1);
|
|
|
|
|
2014-08-15 01:54:03 -07:00
|
|
|
//Set the entry selection region to next image.
|
|
|
|
const char *colon = parser_colon_pos_get(NULL, text);
|
|
|
|
if (!colon) goto end;
|
|
|
|
|
2014-10-31 09:15:58 -07:00
|
|
|
const char *selection = elm_entry_selection_get(ed->en_edit);
|
|
|
|
if (!selection) goto end;
|
2014-08-15 01:54:03 -07:00
|
|
|
|
2014-10-31 09:15:58 -07:00
|
|
|
char *select_utf8 = elm_entry_markup_to_utf8(selection);
|
2014-08-15 01:54:03 -07:00
|
|
|
if (!select_utf8) goto end;
|
|
|
|
int select_len = strlen(select_utf8);
|
|
|
|
free(select_utf8);
|
|
|
|
const char *p = (colon - select_len);
|
|
|
|
if (p < text) goto end;
|
|
|
|
|
|
|
|
int cursor_pos = elm_entry_cursor_pos_get(ed->en_edit);
|
|
|
|
elm_entry_select_region_set(ed->en_edit, (cursor_pos - select_len),
|
|
|
|
cursor_pos);
|
|
|
|
}
|
|
|
|
end:
|
2014-09-30 07:56:16 -07:00
|
|
|
#if 0
|
2013-09-09 08:58:33 -07:00
|
|
|
menu_ctxpopup_unregister(ctxpopup);
|
2014-09-30 07:56:16 -07:00
|
|
|
#endif
|
2013-09-09 08:58:33 -07:00
|
|
|
elm_ctxpopup_dismiss(ctxpopup);
|
|
|
|
}
|
|
|
|
|
2013-09-08 00:26:11 -07:00
|
|
|
static void
|
2013-09-09 08:58:33 -07:00
|
|
|
ctxpopup_preview_relay_cb(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
edit_data *ed = data;
|
2014-08-22 09:03:51 -07:00
|
|
|
int next = (int)(uintptr_t) event_info;
|
2013-09-09 08:58:33 -07:00
|
|
|
preview_img_relay_show(ed, obj, (Eina_Bool) next);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
image_preview_show(edit_data *ed, char *cur, Evas_Coord x, Evas_Coord y)
|
2013-09-08 00:26:11 -07:00
|
|
|
{
|
2013-09-08 01:04:56 -07:00
|
|
|
char *filename = parser_name_get(ed->pd, cur);
|
2013-09-09 08:58:33 -07:00
|
|
|
if (!filename) return EINA_FALSE;
|
2013-09-08 01:04:56 -07:00
|
|
|
|
|
|
|
char fullpath[PATH_MAX];
|
|
|
|
|
|
|
|
//1.Find the image path.
|
2014-09-30 07:56:16 -07:00
|
|
|
Eina_List *list = build_path_get(ENVENTOR_RES_IMAGE);
|
2013-09-08 01:04:56 -07:00
|
|
|
Eina_List *l;
|
|
|
|
char *path;
|
|
|
|
Eina_Bool found = EINA_FALSE;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(list, l, path)
|
|
|
|
{
|
|
|
|
snprintf(fullpath, sizeof(fullpath), "%s/%s", path, filename);
|
|
|
|
if (!ecore_file_exists(fullpath)) continue;
|
|
|
|
found = EINA_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-03-15 21:21:09 -07:00
|
|
|
//2. Find in the default fault.
|
|
|
|
if (!found)
|
|
|
|
{
|
|
|
|
snprintf(fullpath, sizeof(fullpath), "%s/images/%s",
|
|
|
|
elm_app_data_dir_get(), filename);
|
|
|
|
if (ecore_file_exists(fullpath)) found = EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2013-09-09 08:58:33 -07:00
|
|
|
Eina_Bool succeed;
|
|
|
|
|
2013-10-07 08:02:05 -07:00
|
|
|
//Create Ctxpopup with the image pathes.
|
2013-09-08 01:04:56 -07:00
|
|
|
if (found)
|
2013-09-08 00:26:11 -07:00
|
|
|
{
|
2013-09-08 01:04:56 -07:00
|
|
|
Evas_Object *ctxpopup =
|
2014-03-16 01:55:34 -07:00
|
|
|
ctxpopup_img_preview_create(ed, fullpath,
|
2013-09-08 01:04:56 -07:00
|
|
|
ctxpopup_preview_dismiss_cb,
|
2014-03-16 01:55:34 -07:00
|
|
|
ctxpopup_preview_relay_cb);
|
2014-08-22 09:01:37 -07:00
|
|
|
if (!ctxpopup)
|
|
|
|
{
|
|
|
|
free(filename);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
2013-09-08 01:04:56 -07:00
|
|
|
|
|
|
|
evas_object_move(ctxpopup, x, y);
|
|
|
|
evas_object_show(ctxpopup);
|
2014-09-30 07:56:16 -07:00
|
|
|
#if 0
|
2013-09-08 01:04:56 -07:00
|
|
|
menu_ctxpopup_register(ctxpopup);
|
2014-09-30 07:56:16 -07:00
|
|
|
#endif
|
2013-09-08 01:04:56 -07:00
|
|
|
elm_object_disabled_set(ed->layout, EINA_TRUE);
|
2013-09-09 08:58:33 -07:00
|
|
|
succeed = EINA_TRUE;
|
2013-09-08 00:26:11 -07:00
|
|
|
}
|
2013-09-09 07:03:02 -07:00
|
|
|
else
|
|
|
|
{
|
2013-09-09 08:58:33 -07:00
|
|
|
succeed = EINA_FALSE;
|
2013-09-09 07:03:02 -07:00
|
|
|
}
|
2013-09-09 08:58:33 -07:00
|
|
|
|
2013-09-08 01:04:56 -07:00
|
|
|
free(filename);
|
2013-09-09 08:58:33 -07:00
|
|
|
|
|
|
|
return succeed;
|
2013-09-08 00:26:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
candidate_list_show(edit_data *ed, char *text, char *cur, char *selected)
|
|
|
|
{
|
|
|
|
attr_value * attr = parser_attribute_get(ed->pd, text, cur);
|
|
|
|
if (!attr) return;
|
|
|
|
|
2013-09-08 00:31:46 -07:00
|
|
|
//Show up the list of the types
|
|
|
|
Evas_Object *ctxpopup =
|
2014-03-16 01:55:34 -07:00
|
|
|
ctxpopup_candidate_list_create(ed, attr, atof(selected),
|
2013-09-08 01:04:56 -07:00
|
|
|
ctxpopup_candidate_dismiss_cb,
|
2014-03-16 01:55:34 -07:00
|
|
|
ctxpopup_candidate_selected_cb);
|
2013-09-08 00:31:46 -07:00
|
|
|
if (!ctxpopup) return;
|
|
|
|
|
2013-09-08 00:26:11 -07:00
|
|
|
int x, y;
|
|
|
|
evas_pointer_output_xy_get(evas_object_evas_get(ed->en_edit), &x, &y);
|
2013-09-08 00:31:46 -07:00
|
|
|
evas_object_move(ctxpopup, x, y);
|
|
|
|
evas_object_show(ctxpopup);
|
2014-09-30 07:56:16 -07:00
|
|
|
#if 0
|
2013-09-08 00:31:46 -07:00
|
|
|
menu_ctxpopup_register(ctxpopup);
|
2014-09-30 07:56:16 -07:00
|
|
|
#endif
|
2013-09-08 00:31:46 -07:00
|
|
|
elm_object_disabled_set(ed->layout, EINA_TRUE);
|
2013-09-08 00:26:11 -07:00
|
|
|
}
|
|
|
|
|
2014-09-30 07:56:16 -07:00
|
|
|
static void
|
|
|
|
program_run(edit_data *ed, char *cur)
|
|
|
|
{
|
|
|
|
char *program = parser_name_get(ed->pd, cur);
|
|
|
|
if (program)
|
|
|
|
{
|
|
|
|
view_data *vd = edj_mgr_view_get(NULL);
|
|
|
|
view_program_run(vd, program);
|
|
|
|
free(program);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
static void
|
|
|
|
edit_cursor_double_clicked_cb(void *data, Evas_Object *obj,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
edit_data *ed = data;
|
|
|
|
|
|
|
|
if (ed->ctrl_pressed) return;
|
2014-09-30 07:56:16 -07:00
|
|
|
if (!ed->ctxpopup) return;
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2013-09-08 00:26:11 -07:00
|
|
|
char *selected = (char *) elm_entry_selection_get(obj);
|
2013-07-20 01:51:56 -07:00
|
|
|
if (!selected) return;
|
2014-09-30 07:56:16 -07:00
|
|
|
|
2013-09-08 00:26:11 -07:00
|
|
|
selected = elm_entry_markup_to_utf8(selected);
|
2014-03-15 21:52:30 -07:00
|
|
|
if (selected[0] == '\"')
|
|
|
|
{
|
|
|
|
free(selected);
|
|
|
|
return;
|
|
|
|
}
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
Evas_Object *textblock = elm_entry_textblock_get(obj);
|
|
|
|
Evas_Textblock_Cursor *cursor = evas_object_textblock_cursor_get(textblock);
|
|
|
|
const char *str = evas_textblock_cursor_paragraph_text_get(cursor);
|
|
|
|
char *text = elm_entry_markup_to_utf8(str);
|
|
|
|
char *cur = strstr(text, selected);
|
|
|
|
|
2013-09-07 23:27:23 -07:00
|
|
|
if (!strcmp(selected, "program"))
|
|
|
|
{
|
2013-09-08 00:26:11 -07:00
|
|
|
program_run(ed, cur);
|
|
|
|
}
|
2013-09-08 01:25:27 -07:00
|
|
|
else if ((!strncmp(selected, "image", 5)) || //5: sizeof("image")
|
2013-09-09 01:42:46 -07:00
|
|
|
(!strcmp(selected, "normal")) ||
|
|
|
|
(!strcmp(selected, "tween")))
|
2013-09-08 00:26:11 -07:00
|
|
|
{
|
2013-09-09 08:58:33 -07:00
|
|
|
int x, y;
|
|
|
|
evas_pointer_output_xy_get(evas_object_evas_get(ed->en_edit), &x, &y);
|
|
|
|
image_preview_show(ed, cur, x, y);
|
2013-09-07 23:27:23 -07:00
|
|
|
}
|
|
|
|
else
|
2013-09-12 06:14:16 -07:00
|
|
|
candidate_list_show(ed, text, cur, selected);
|
|
|
|
|
2014-03-15 19:51:02 -07:00
|
|
|
free(selected);
|
|
|
|
free(text);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-09-18 08:14:34 -07:00
|
|
|
cur_name_get_cb(void *data, Eina_Stringshare *part_name,
|
2014-09-30 07:56:16 -07:00
|
|
|
Eina_Stringshare *group_name)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
|
|
|
edit_data *ed = data;
|
2013-09-18 10:05:46 -07:00
|
|
|
|
|
|
|
if (ed->view_sync_cb)
|
|
|
|
ed->view_sync_cb(ed->view_sync_cb_data, part_name, group_name);
|
2013-09-18 00:48:05 -07:00
|
|
|
}
|
|
|
|
|
2014-09-30 07:56:16 -07:00
|
|
|
static void
|
|
|
|
cur_line_pos_set(edit_data *ed, Eina_Bool force)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-09-30 07:56:16 -07:00
|
|
|
Evas_Coord y, h;
|
|
|
|
elm_entry_cursor_geometry_get(ed->en_edit, NULL, &y, NULL, &h);
|
|
|
|
int line = (y / h) + 1;
|
|
|
|
|
|
|
|
if (line < 0) line = 1;
|
|
|
|
if (!force && (ed->cur_line == line)) return;
|
|
|
|
ed->cur_line = line;
|
|
|
|
|
|
|
|
evas_object_smart_callback_call(ed->enventor, SIG_CURSOR_LINE_CHANGED,
|
|
|
|
(void *)line);
|
2013-09-18 00:48:05 -07:00
|
|
|
}
|
|
|
|
|
2014-10-27 09:23:24 -07:00
|
|
|
void
|
|
|
|
edit_selection_clear(edit_data *ed)
|
|
|
|
{
|
|
|
|
if (ed->on_select_recover) return;
|
|
|
|
cur_line_pos_set(ed, EINA_TRUE);
|
|
|
|
ed->select_pos = -1;
|
|
|
|
}
|
|
|
|
|
2014-05-17 02:19:18 -07:00
|
|
|
static void
|
|
|
|
edit_selection_cleared_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
edit_data *ed = data;
|
2014-10-27 09:23:24 -07:00
|
|
|
edit_selection_clear(ed);
|
2014-06-07 21:17:06 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
edit_selection_start_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
edit_data *ed = data;
|
|
|
|
if (ed->select_pos != -1) return;
|
|
|
|
ed->select_pos = elm_entry_cursor_pos_get(ed->en_edit);
|
2014-05-17 02:19:18 -07:00
|
|
|
}
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
static void
|
2013-10-14 10:30:36 -07:00
|
|
|
edit_cursor_changed_manual_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
|
|
|
edit_data *ed = data;
|
2013-09-18 08:14:34 -07:00
|
|
|
edit_view_sync(ed);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
2013-10-17 22:58:40 -07:00
|
|
|
static void
|
|
|
|
edit_cursor_changed_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
edit_data *ed = data;
|
2014-05-17 02:19:18 -07:00
|
|
|
cur_line_pos_set(ed, EINA_FALSE);
|
2013-10-17 22:58:40 -07:00
|
|
|
}
|
|
|
|
|
2014-09-30 07:56:16 -07:00
|
|
|
static void
|
|
|
|
syntax_color_full_update(edit_data *ed, Eina_Bool thread)
|
2014-03-09 10:15:31 -07:00
|
|
|
{
|
2014-09-30 07:56:16 -07:00
|
|
|
if (ed->syntax_color_lock > 0) return;
|
2014-03-09 10:15:31 -07:00
|
|
|
|
2014-09-30 07:56:16 -07:00
|
|
|
ecore_timer_del(ed->syntax_color_timer);
|
|
|
|
ed->syntax_color_timer = NULL;
|
2014-03-10 08:01:23 -07:00
|
|
|
|
2014-09-30 07:56:16 -07:00
|
|
|
if (thread)
|
2014-03-10 08:01:23 -07:00
|
|
|
{
|
2014-09-30 07:56:16 -07:00
|
|
|
syntax_color_td *td = calloc(1, sizeof(syntax_color_td));
|
|
|
|
if (!td)
|
|
|
|
{
|
|
|
|
EINA_LOG_ERR("Failed to allocate Memory!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
td->ed = ed;
|
|
|
|
Evas_Object *tb = elm_entry_textblock_get(ed->en_edit);
|
|
|
|
td->text = (char *) evas_object_textblock_text_markup_get(tb);
|
|
|
|
ed->syntax_color_thread =
|
|
|
|
ecore_thread_run(syntax_color_thread_cb,
|
|
|
|
syntax_color_thread_end_cb,
|
|
|
|
syntax_color_thread_cancel_cb,
|
|
|
|
td);
|
2014-03-10 08:01:23 -07:00
|
|
|
}
|
2014-09-30 07:56:16 -07:00
|
|
|
else
|
2014-03-10 08:01:23 -07:00
|
|
|
{
|
2014-09-30 07:56:16 -07:00
|
|
|
syntax_color_apply(ed, EINA_FALSE);
|
2014-03-09 10:15:31 -07:00
|
|
|
}
|
2014-08-08 22:29:51 -07:00
|
|
|
}
|
|
|
|
|
2014-08-02 00:41:24 -07:00
|
|
|
static void
|
|
|
|
edit_redoundo(edit_data *ed, Eina_Bool undo)
|
|
|
|
{
|
|
|
|
int lines;
|
|
|
|
Eina_Bool changed;
|
2014-08-01 21:45:47 -07:00
|
|
|
|
2014-08-02 00:41:24 -07:00
|
|
|
if (undo) lines = redoundo_undo(ed->rd, &changed);
|
|
|
|
else lines = redoundo_redo(ed->rd, &changed);
|
2014-08-02 01:18:21 -07:00
|
|
|
if (!changed)
|
|
|
|
{
|
2014-09-30 07:56:16 -07:00
|
|
|
#if 0
|
2014-08-02 01:18:21 -07:00
|
|
|
if (undo) stats_info_msg_update("No text to be undo.");
|
|
|
|
else stats_info_msg_update("No text to be redo.");
|
2014-09-30 07:56:16 -07:00
|
|
|
#endif
|
2014-08-02 01:18:21 -07:00
|
|
|
return;
|
|
|
|
}
|
2014-08-02 00:41:24 -07:00
|
|
|
|
2014-09-30 07:56:16 -07:00
|
|
|
#if 0
|
2014-08-02 00:59:37 -07:00
|
|
|
if (undo) stats_info_msg_update("Undo text.");
|
|
|
|
else stats_info_msg_update("Redo text.");
|
2014-09-30 07:56:16 -07:00
|
|
|
#endif
|
2014-08-02 00:59:37 -07:00
|
|
|
|
2014-08-02 00:41:24 -07:00
|
|
|
if (lines > 0) edit_line_increase(ed, lines);
|
|
|
|
else edit_line_decrease(ed, abs(lines));
|
|
|
|
|
|
|
|
edit_changed_set(ed, EINA_TRUE);
|
|
|
|
syntax_color_full_update(ed, EINA_TRUE);
|
2014-03-09 10:15:31 -07:00
|
|
|
}
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
static Eina_Bool
|
|
|
|
key_down_cb(void *data, int type EINA_UNUSED, void *ev)
|
|
|
|
{
|
|
|
|
Ecore_Event_Key *event = ev;
|
|
|
|
edit_data *ed = data;
|
|
|
|
|
|
|
|
//Control Key
|
2014-01-31 23:22:00 -08:00
|
|
|
if (!strcmp("Control_L", event->key))
|
2014-08-02 00:41:24 -07:00
|
|
|
{
|
|
|
|
ed->ctrl_pressed = EINA_TRUE;
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ed->ctrl_pressed)
|
|
|
|
{
|
|
|
|
//Undo
|
|
|
|
if (!strcmp(event->key, "z") || !strcmp(event->key, "Z"))
|
|
|
|
{
|
|
|
|
edit_redoundo(ed, EINA_TRUE);
|
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
|
|
|
//Redo
|
|
|
|
if (!strcmp(event->key, "r") || !strcmp(event->key, "R"))
|
|
|
|
{
|
|
|
|
edit_redoundo(ed, EINA_FALSE);
|
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
|
|
|
}
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
key_up_cb(void *data, int type EINA_UNUSED, void *ev)
|
|
|
|
{
|
|
|
|
Ecore_Event_Key *event = ev;
|
|
|
|
edit_data *ed = data;
|
|
|
|
|
|
|
|
//Control Key
|
2014-01-31 23:22:00 -08:00
|
|
|
if (!strcmp("Control_L", event->key))
|
2013-07-20 01:51:56 -07:00
|
|
|
ed->ctrl_pressed = EINA_FALSE;
|
|
|
|
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
|
|
|
|
2014-05-26 07:35:57 -07:00
|
|
|
static void
|
2014-05-26 21:52:15 -07:00
|
|
|
scroller_scroll_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2014-05-26 07:35:57 -07:00
|
|
|
{
|
|
|
|
edit_data *ed = data;
|
2014-05-26 21:56:22 -07:00
|
|
|
syntax_color_partial_update(ed, SYNTAX_COLOR_SHORT_TIME);
|
2014-05-26 07:35:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-08-06 02:02:54 -07:00
|
|
|
scroller_resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj,
|
|
|
|
void *event_info EINA_UNUSED)
|
2014-05-26 07:35:57 -07:00
|
|
|
{
|
|
|
|
edit_data *ed = data;
|
|
|
|
Evas_Coord h;
|
|
|
|
evas_object_geometry_get(obj, NULL, NULL, NULL, &h);
|
|
|
|
|
|
|
|
if (h == ed->scroller_h) return;
|
2014-05-31 00:20:01 -07:00
|
|
|
syntax_color_partial_update(ed, SYNTAX_COLOR_DEFAULT_TIME);
|
2014-05-26 07:35:57 -07:00
|
|
|
ed->scroller_h = h;
|
|
|
|
}
|
|
|
|
|
2014-05-26 21:52:15 -07:00
|
|
|
static void
|
|
|
|
scroller_vbar_press_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
edit_data *ed = data;
|
2014-06-04 08:50:41 -07:00
|
|
|
syntax_color_full_update(ed, EINA_TRUE);
|
|
|
|
ed->syntax_color_lock++;
|
2014-05-26 21:52:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
scroller_vbar_unpress_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
edit_data *ed = data;
|
2014-06-04 08:50:41 -07:00
|
|
|
ed->syntax_color_lock--;
|
2014-05-26 21:52:15 -07:00
|
|
|
syntax_color_partial_update(ed, SYNTAX_COLOR_SHORT_TIME);
|
|
|
|
}
|
|
|
|
|
2014-09-30 07:56:16 -07:00
|
|
|
static Eina_Bool
|
|
|
|
edit_edc_load(edit_data *ed, const char *file_path)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-09-30 07:56:16 -07:00
|
|
|
char buf[MAX_LINE_DIGIT_CNT];
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2014-09-30 07:56:16 -07:00
|
|
|
Eina_File *file = NULL;
|
|
|
|
Eina_Strbuf *strbuf_line = NULL;
|
2014-10-31 04:48:39 -07:00
|
|
|
Eina_Stringshare *group_name = NULL;
|
2014-09-30 07:56:16 -07:00
|
|
|
char *utf8_edit = NULL;
|
|
|
|
char *markup_edit = NULL;
|
|
|
|
char *markup_line = NULL;
|
|
|
|
int line_num = 1;
|
|
|
|
Eina_Bool ret = EINA_FALSE;
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2014-09-30 07:56:16 -07:00
|
|
|
ed->line_max = 0;
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2014-09-30 07:56:16 -07:00
|
|
|
file = eina_file_open(file_path, EINA_FALSE);
|
|
|
|
if (!file) goto err;
|
|
|
|
|
|
|
|
strbuf_line = eina_strbuf_new();
|
|
|
|
if (!strbuf_line) goto err;
|
|
|
|
|
|
|
|
utf8_edit = eina_file_map_all(file, EINA_FILE_POPULATE);
|
|
|
|
if (!utf8_edit) goto err;
|
|
|
|
|
|
|
|
//Append line numbers
|
|
|
|
if (!eina_strbuf_append_char(strbuf_line, '1')) goto err;
|
|
|
|
char *p = utf8_edit;
|
|
|
|
int len = strlen(p);
|
|
|
|
while ((p = strchr(p, '\n')) && p < (utf8_edit + len))
|
|
|
|
{
|
|
|
|
line_num++;
|
|
|
|
++p;
|
|
|
|
sprintf(buf, "\n%d", line_num);
|
|
|
|
if (!eina_strbuf_append(strbuf_line, buf)) goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
markup_line = elm_entry_utf8_to_markup(eina_strbuf_string_get(strbuf_line));
|
|
|
|
if (!markup_line) goto err;
|
|
|
|
elm_entry_entry_append(ed->en_line, markup_line);
|
|
|
|
free(markup_line);
|
|
|
|
|
|
|
|
markup_edit = elm_entry_utf8_to_markup(utf8_edit);
|
|
|
|
if (!markup_edit) goto err;
|
|
|
|
elm_entry_entry_set(ed->en_edit, markup_edit);
|
|
|
|
free(markup_edit);
|
|
|
|
|
|
|
|
ed->line_max = line_num;
|
|
|
|
|
2014-10-31 04:48:39 -07:00
|
|
|
group_name = parser_first_group_name_get(ed->pd, ed->en_edit);
|
2014-09-30 07:56:16 -07:00
|
|
|
|
|
|
|
ecore_animator_add(syntax_color_timer_cb, ed);
|
|
|
|
|
|
|
|
ret = EINA_TRUE;
|
|
|
|
|
|
|
|
err:
|
|
|
|
//Even any text is not inserted, line number should start with 1
|
|
|
|
if (ed->line_max == 0) line_init(ed);
|
|
|
|
if (strbuf_line) eina_strbuf_free(strbuf_line);
|
|
|
|
if (utf8_edit) eina_file_map_free(file, utf8_edit);
|
|
|
|
if (file) eina_file_close(file);
|
|
|
|
|
|
|
|
evas_object_smart_callback_call(ed->enventor, SIG_MAX_LINE_CHANGED,
|
|
|
|
(void *)ed->line_max);
|
|
|
|
|
|
|
|
if (ed->view_sync_cb)
|
|
|
|
ed->view_sync_cb(ed->view_sync_cb_data, NULL, group_name);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/* Externally accessible calls */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
void
|
|
|
|
edit_view_sync_cb_set(edit_data *ed,
|
|
|
|
void (*cb)(void *data, Eina_Stringshare *part_name,
|
|
|
|
Eina_Stringshare *group_name), void *data)
|
|
|
|
{
|
|
|
|
ed->view_sync_cb = cb;
|
|
|
|
ed->view_sync_cb_data = data;
|
|
|
|
}
|
|
|
|
|
2014-10-23 00:39:31 -07:00
|
|
|
Eina_Bool
|
|
|
|
edit_saved_get(edit_data *ed)
|
|
|
|
{
|
|
|
|
return ed->on_save;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
edit_saved_set(edit_data *ed, Eina_Bool saved)
|
|
|
|
{
|
|
|
|
ed->on_save = saved;
|
|
|
|
}
|
|
|
|
|
2014-09-30 07:56:16 -07:00
|
|
|
Eina_Bool
|
|
|
|
edit_save(edit_data *ed, const char *file)
|
|
|
|
{
|
|
|
|
if (!ed->edit_changed) return EINA_FALSE;
|
|
|
|
|
|
|
|
const char *text = elm_entry_entry_get(ed->en_edit);
|
|
|
|
char *utf8 = elm_entry_markup_to_utf8(text);
|
|
|
|
FILE *fp = fopen(file, "w");
|
|
|
|
if (!fp)
|
|
|
|
{
|
|
|
|
EINA_LOG_ERR("Failed to open file \"%s\"", file);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
fputs(utf8, fp);
|
|
|
|
fclose(fp);
|
|
|
|
free(utf8);
|
|
|
|
|
|
|
|
edit_view_sync(ed);
|
|
|
|
|
2014-10-23 00:39:31 -07:00
|
|
|
ed->on_save = EINA_TRUE;
|
|
|
|
|
2014-09-30 07:56:16 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
edit_syntax_color_full_apply(edit_data *ed, Eina_Bool force)
|
|
|
|
{
|
|
|
|
int lock;
|
|
|
|
|
|
|
|
if (force)
|
|
|
|
{
|
|
|
|
lock = ed->syntax_color_lock;
|
|
|
|
ed->syntax_color_lock = -1;
|
|
|
|
}
|
|
|
|
syntax_color_full_update(ed, EINA_FALSE);
|
|
|
|
|
|
|
|
if (force) ed->syntax_color_lock = lock;
|
|
|
|
else ed->syntax_color_lock++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
edit_syntax_color_partial_apply(edit_data *ed, double interval)
|
|
|
|
{
|
|
|
|
if (ed->syntax_color_lock > 0) ed->syntax_color_lock = 0;
|
|
|
|
if (interval < 0) syntax_color_partial_update(ed, SYNTAX_COLOR_DEFAULT_TIME);
|
|
|
|
else syntax_color_partial_update(ed, interval);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
edit_view_sync(edit_data *ed)
|
|
|
|
{
|
|
|
|
if (!ed->part_highlight)
|
|
|
|
parser_cur_group_name_get(ed->pd, ed->en_edit, cur_name_get_cb, ed);
|
|
|
|
else
|
|
|
|
parser_cur_name_get(ed->pd, ed->en_edit, cur_name_get_cb, ed);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
edit_line_delete(edit_data *ed)
|
|
|
|
{
|
|
|
|
if (!elm_object_focus_get(ed->en_edit)) return;
|
|
|
|
|
|
|
|
Evas_Object *textblock = elm_entry_textblock_get(ed->en_edit);
|
|
|
|
|
|
|
|
int line1 = ed->cur_line - 1;
|
|
|
|
int line2 = ed->cur_line;
|
|
|
|
|
|
|
|
//min position case
|
|
|
|
if (line1 < 0)
|
|
|
|
{
|
|
|
|
line1 = 0;
|
|
|
|
line2 = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Max position case
|
|
|
|
Eina_Bool max = EINA_FALSE;
|
|
|
|
if (line2 >= ed->line_max)
|
|
|
|
{
|
|
|
|
line1 = (ed->line_max - 2);
|
|
|
|
line2 = (ed->line_max - 1);
|
|
|
|
max = EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//only one line remain. clear it.
|
|
|
|
if (ed->line_max == 1)
|
|
|
|
{
|
|
|
|
redoundo_text_push(ed->rd, elm_entry_entry_get(ed->en_edit), 0, 0,
|
|
|
|
EINA_FALSE);
|
|
|
|
elm_entry_entry_set(ed->en_edit, "");
|
|
|
|
line_init(ed);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Evas_Textblock_Cursor *cur1 = evas_object_textblock_cursor_new(textblock);
|
|
|
|
evas_textblock_cursor_line_set(cur1, line1);
|
|
|
|
if (max) evas_textblock_cursor_line_char_last(cur1);
|
|
|
|
|
|
|
|
Evas_Textblock_Cursor *cur2 = evas_object_textblock_cursor_new(textblock);
|
|
|
|
evas_textblock_cursor_line_set(cur2, line2);
|
|
|
|
if (max) evas_textblock_cursor_line_char_last(cur2);
|
|
|
|
int cur1_pos, cur2_pos;
|
|
|
|
|
|
|
|
cur1_pos = evas_textblock_cursor_pos_get(cur1);
|
|
|
|
cur2_pos = evas_textblock_cursor_pos_get(cur2);
|
|
|
|
const char *content = evas_textblock_cursor_range_text_get(cur1, cur2,
|
|
|
|
EVAS_TEXTBLOCK_TEXT_MARKUP);
|
|
|
|
|
|
|
|
evas_textblock_cursor_range_delete(cur1, cur2);
|
|
|
|
evas_textblock_cursor_free(cur1);
|
|
|
|
evas_textblock_cursor_free(cur2);
|
|
|
|
redoundo_text_push(ed->rd, content, cur1_pos, abs(cur2_pos - cur1_pos),
|
|
|
|
EINA_FALSE);
|
|
|
|
elm_entry_calc_force(ed->en_edit);
|
|
|
|
|
|
|
|
edit_line_decrease(ed, 1);
|
|
|
|
|
|
|
|
cur_line_pos_set(ed, EINA_TRUE);
|
|
|
|
edit_changed_set(ed, EINA_TRUE);
|
|
|
|
|
|
|
|
syntax_color_partial_update(ed, SYNTAX_COLOR_DEFAULT_TIME);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
edit_cur_indent_depth_get(edit_data *ed)
|
|
|
|
{
|
|
|
|
return indent_space_get(syntax_indent_data_get(ed->sh), ed->en_edit);
|
|
|
|
}
|
|
|
|
|
|
|
|
edit_data *
|
|
|
|
edit_init(Evas_Object *enventor)
|
|
|
|
{
|
|
|
|
srand(time(NULL));
|
|
|
|
parser_data *pd = parser_init();
|
|
|
|
syntax_helper *sh = syntax_init();
|
|
|
|
|
|
|
|
edit_data *ed = calloc(1, sizeof(edit_data));
|
|
|
|
if (!ed)
|
|
|
|
{
|
|
|
|
EINA_LOG_ERR("Failed to allocate Memory!");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
ed->pd = pd;
|
|
|
|
ed->sh = sh;
|
|
|
|
|
|
|
|
ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, key_down_cb, ed);
|
|
|
|
ecore_event_handler_add(ECORE_EVENT_KEY_UP, key_up_cb, ed);
|
|
|
|
|
|
|
|
//Scroller
|
|
|
|
Evas_Object *scroller = elm_scroller_add(enventor);
|
|
|
|
elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_AUTO,
|
|
|
|
ELM_SCROLLER_POLICY_AUTO);
|
2013-07-20 01:51:56 -07:00
|
|
|
elm_object_focus_allow_set(scroller, EINA_FALSE);
|
2014-05-26 07:35:57 -07:00
|
|
|
evas_object_smart_callback_add(scroller, "scroll,up", scroller_scroll_cb,
|
|
|
|
ed);
|
|
|
|
evas_object_smart_callback_add(scroller, "scroll,down", scroller_scroll_cb,
|
|
|
|
ed);
|
2014-05-26 21:52:15 -07:00
|
|
|
evas_object_smart_callback_add(scroller, "vbar,press",
|
|
|
|
scroller_vbar_press_cb, ed);
|
|
|
|
evas_object_smart_callback_add(scroller, "vbar,unpress",
|
|
|
|
scroller_vbar_unpress_cb, ed);
|
2014-05-26 07:35:57 -07:00
|
|
|
evas_object_event_callback_add(scroller, EVAS_CALLBACK_RESIZE,
|
|
|
|
scroller_resize_cb, ed);
|
2013-07-20 01:51:56 -07:00
|
|
|
evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND,
|
|
|
|
EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
|
2014-09-30 07:56:16 -07:00
|
|
|
//This is hackish call to not change scroller color by widget.
|
|
|
|
evas_object_data_set(scroller, "_elm_leaveme", (void *)1);
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
//Layout
|
|
|
|
Evas_Object *layout = elm_layout_add(scroller);
|
|
|
|
elm_layout_file_set(layout, EDJE_PATH, "edit_layout");
|
|
|
|
evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_object_content_set(scroller, layout);
|
|
|
|
|
|
|
|
//Line Number Entry
|
|
|
|
Evas_Object *en_line = elm_entry_add(layout);
|
2014-08-28 08:19:51 -07:00
|
|
|
evas_object_color_set(en_line, 101, 101, 101, 255);
|
2013-07-20 01:51:56 -07:00
|
|
|
elm_entry_editable_set(en_line, EINA_FALSE);
|
2014-03-14 10:53:56 -07:00
|
|
|
elm_entry_line_wrap_set(en_line, ELM_WRAP_NONE);
|
2014-07-29 00:33:22 -07:00
|
|
|
elm_object_focus_allow_set(en_line, EINA_FALSE);
|
2013-07-20 01:51:56 -07:00
|
|
|
evas_object_size_hint_weight_set(en_line, 0, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(en_line, 0, EVAS_HINT_FILL);
|
|
|
|
elm_object_part_content_set(layout, "elm.swallow.linenumber", en_line);
|
|
|
|
|
|
|
|
//EDC Editor Entry
|
|
|
|
Evas_Object *en_edit = elm_entry_add(layout);
|
|
|
|
elm_entry_context_menu_disabled_set(en_edit, EINA_TRUE);
|
2014-03-14 23:33:45 -07:00
|
|
|
elm_entry_line_wrap_set(en_edit, ELM_WRAP_NONE);
|
2013-07-20 01:51:56 -07:00
|
|
|
evas_object_smart_callback_add(en_edit, "changed,user", edit_changed_cb, ed);
|
2013-10-14 10:30:36 -07:00
|
|
|
evas_object_smart_callback_add(en_edit, "cursor,changed,manual",
|
|
|
|
edit_cursor_changed_manual_cb, ed);
|
2013-10-17 22:58:40 -07:00
|
|
|
evas_object_smart_callback_add(en_edit, "cursor,changed",
|
|
|
|
edit_cursor_changed_cb, ed);
|
2013-07-20 01:51:56 -07:00
|
|
|
evas_object_smart_callback_add(en_edit, "clicked,double",
|
|
|
|
edit_cursor_double_clicked_cb, ed);
|
2014-05-17 02:19:18 -07:00
|
|
|
evas_object_smart_callback_add(en_edit, "selection,cleared",
|
|
|
|
edit_selection_cleared_cb, ed);
|
2014-06-07 21:17:06 -07:00
|
|
|
evas_object_smart_callback_add(en_edit, "selection,start",
|
|
|
|
edit_selection_start_cb, ed);
|
2013-07-20 01:51:56 -07:00
|
|
|
evas_object_size_hint_weight_set(en_edit, EVAS_HINT_EXPAND,
|
|
|
|
EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(en_edit, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_object_focus_set(en_edit, EINA_TRUE);
|
|
|
|
elm_object_part_content_set(layout, "elm.swallow.edit", en_edit);
|
|
|
|
|
|
|
|
ed->scroller = scroller;
|
|
|
|
ed->en_line = en_line;
|
|
|
|
ed->en_edit = en_edit;
|
|
|
|
ed->layout = layout;
|
2014-09-30 07:56:16 -07:00
|
|
|
ed->enventor = enventor;
|
2013-07-20 01:51:56 -07:00
|
|
|
ed->linenumber = EINA_TRUE;
|
2014-09-30 07:56:16 -07:00
|
|
|
ed->auto_indent = EINA_TRUE;
|
|
|
|
ed->part_highlight = EINA_TRUE;
|
|
|
|
ed->ctxpopup = EINA_TRUE;
|
2013-10-17 22:58:40 -07:00
|
|
|
ed->cur_line = -1;
|
2014-06-07 21:17:06 -07:00
|
|
|
ed->select_pos = -1;
|
2014-09-30 07:56:16 -07:00
|
|
|
ed->font_scale = 1;
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2014-08-02 00:41:24 -07:00
|
|
|
ed->rd = redoundo_init(en_edit);
|
|
|
|
evas_object_data_set(ed->en_edit, "redoundo", ed->rd);
|
2014-08-01 21:45:47 -07:00
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
return ed;
|
|
|
|
}
|
|
|
|
|
|
|
|
Evas_Object *
|
|
|
|
edit_obj_get(edit_data *ed)
|
|
|
|
{
|
|
|
|
return ed->scroller;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
edit_term(edit_data *ed)
|
|
|
|
{
|
2013-07-25 09:31:49 -07:00
|
|
|
if (!ed) return;
|
|
|
|
|
2013-08-15 08:47:31 -07:00
|
|
|
syntax_helper *sh = ed->sh;
|
2013-07-20 01:51:56 -07:00
|
|
|
parser_data *pd = ed->pd;
|
|
|
|
|
2014-08-02 00:41:24 -07:00
|
|
|
redoundo_term(ed->rd);
|
2014-05-27 01:17:15 -07:00
|
|
|
ecore_thread_cancel(ed->syntax_color_thread);
|
2014-03-15 19:51:02 -07:00
|
|
|
ecore_timer_del(ed->syntax_color_timer);
|
2013-07-20 01:51:56 -07:00
|
|
|
free(ed);
|
|
|
|
|
2013-08-15 08:47:31 -07:00
|
|
|
syntax_term(sh);
|
2013-07-20 01:51:56 -07:00
|
|
|
parser_term(pd);
|
|
|
|
}
|
|
|
|
|
|
|
|
Eina_Bool
|
|
|
|
edit_changed_get(edit_data *ed)
|
|
|
|
{
|
|
|
|
return ed->edit_changed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-08-04 09:28:47 -07:00
|
|
|
edit_changed_set(edit_data *ed, Eina_Bool changed)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2013-08-04 09:28:47 -07:00
|
|
|
ed->edit_changed = changed;
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
2014-09-30 07:56:16 -07:00
|
|
|
Eina_Bool
|
|
|
|
edit_linenumber_get(edit_data *ed)
|
|
|
|
{
|
|
|
|
return ed->linenumber;
|
|
|
|
}
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
void
|
2014-09-30 07:56:16 -07:00
|
|
|
edit_linenumber_set(edit_data *ed, Eina_Bool linenumber)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
|
|
|
if (ed->linenumber == linenumber) return;
|
2014-09-30 07:56:16 -07:00
|
|
|
ed->linenumber = !!linenumber;
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
if (linenumber)
|
|
|
|
elm_object_signal_emit(ed->layout, "elm,state,linenumber,show", "");
|
|
|
|
else
|
|
|
|
elm_object_signal_emit(ed->layout, "elm,state,linenumber,hide", "");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-09-30 07:56:16 -07:00
|
|
|
edit_font_scale_set(edit_data *ed, double font_scale)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-09-30 07:56:16 -07:00
|
|
|
if (ed->font_scale == font_scale) return;
|
|
|
|
elm_object_scale_set(ed->layout, font_scale);
|
|
|
|
syntax_color_partial_update(ed, 0);
|
|
|
|
ed->font_scale = font_scale;
|
|
|
|
}
|
2013-08-24 11:39:39 -07:00
|
|
|
|
2014-09-30 07:56:16 -07:00
|
|
|
double
|
|
|
|
edit_font_scale_get(edit_data *ed)
|
|
|
|
{
|
|
|
|
return ed->font_scale;
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
2013-08-22 05:47:23 -07:00
|
|
|
void
|
2014-09-30 07:56:16 -07:00
|
|
|
edit_part_highlight_set(edit_data *ed, Eina_Bool part_highlight)
|
2013-08-22 05:47:23 -07:00
|
|
|
{
|
2014-09-30 07:56:16 -07:00
|
|
|
part_highlight = !!part_highlight;
|
2013-08-24 09:46:56 -07:00
|
|
|
|
2014-09-30 07:56:16 -07:00
|
|
|
if (ed->part_highlight == part_highlight) return;
|
2013-08-24 11:39:39 -07:00
|
|
|
|
2014-09-30 07:56:16 -07:00
|
|
|
ed->part_highlight = part_highlight;
|
2014-05-26 07:35:57 -07:00
|
|
|
|
2014-09-30 07:56:16 -07:00
|
|
|
if (part_highlight) edit_view_sync(ed);
|
|
|
|
else view_part_highlight_set(VIEW_DATA, NULL);
|
2013-08-22 05:47:23 -07:00
|
|
|
}
|
2014-03-08 05:55:48 -08:00
|
|
|
|
2014-09-30 07:56:16 -07:00
|
|
|
Eina_Bool
|
|
|
|
edit_part_highlight_get(edit_data *ed)
|
2014-03-08 05:55:48 -08:00
|
|
|
{
|
2014-09-30 07:56:16 -07:00
|
|
|
return ed->part_highlight;
|
2014-03-08 05:55:48 -08:00
|
|
|
}
|
2014-03-12 11:54:03 -07:00
|
|
|
|
2014-09-30 07:56:16 -07:00
|
|
|
Eina_Bool
|
|
|
|
edit_load(edit_data *ed, const char *edc_path)
|
2014-03-12 11:54:03 -07:00
|
|
|
{
|
2014-09-30 07:56:16 -07:00
|
|
|
#if 0
|
2014-08-15 04:08:01 -07:00
|
|
|
live_edit_cancel();
|
2014-09-30 07:56:16 -07:00
|
|
|
#endif
|
|
|
|
parser_cancel(ed->pd);
|
|
|
|
elm_entry_entry_set(ed->en_edit, "");
|
|
|
|
elm_entry_entry_set(ed->en_line, "");
|
|
|
|
Eina_Bool ret = edit_edc_load(ed, edc_path);
|
|
|
|
edit_changed_set(ed, EINA_TRUE);
|
2014-03-12 11:54:03 -07:00
|
|
|
edj_mgr_reload_need_set(EINA_TRUE);
|
2014-08-02 00:41:24 -07:00
|
|
|
redoundo_clear(ed->rd);
|
2014-09-30 07:56:16 -07:00
|
|
|
|
|
|
|
return ret;
|
2014-03-12 11:54:03 -07:00
|
|
|
}
|
2014-03-16 01:55:34 -07:00
|
|
|
|
2014-08-08 22:29:51 -07:00
|
|
|
Eina_Stringshare *
|
|
|
|
edit_cur_paragh_get(edit_data *ed)
|
|
|
|
{
|
|
|
|
return parser_paragh_name_get(ed->pd, ed->en_edit);
|
|
|
|
}
|
|
|
|
|
2014-03-16 01:55:34 -07:00
|
|
|
Eina_Stringshare *
|
|
|
|
edit_cur_prog_name_get(edit_data *ed)
|
|
|
|
{
|
|
|
|
return parser_cur_name_fast_get(ed->en_edit, "program");
|
|
|
|
}
|
|
|
|
|
|
|
|
Eina_Stringshare *
|
|
|
|
edit_cur_part_name_get(edit_data *ed)
|
|
|
|
{
|
|
|
|
return parser_cur_name_fast_get(ed->en_edit, "part");
|
|
|
|
}
|
2014-05-31 23:35:54 -07:00
|
|
|
|
|
|
|
int
|
|
|
|
edit_max_line_get(edit_data *ed)
|
|
|
|
{
|
|
|
|
return ed->line_max;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
edit_goto(edit_data *ed, int line)
|
|
|
|
{
|
2014-06-07 21:25:47 -07:00
|
|
|
elm_entry_select_none(ed->en_edit);
|
2014-05-31 23:35:54 -07:00
|
|
|
Evas_Object *tb = elm_entry_textblock_get(ed->en_edit);
|
|
|
|
Evas_Textblock_Cursor *cur = evas_object_textblock_cursor_get(tb);
|
|
|
|
evas_textblock_cursor_line_set(cur, (line - 1));
|
|
|
|
elm_entry_calc_force(ed->en_edit);
|
|
|
|
elm_object_focus_set(ed->en_edit, EINA_TRUE);
|
|
|
|
}
|
2014-06-04 08:50:41 -07:00
|
|
|
|
|
|
|
Evas_Object *
|
|
|
|
edit_entry_get(edit_data *ed)
|
|
|
|
{
|
|
|
|
return ed->en_edit;
|
|
|
|
}
|
2014-07-18 21:31:08 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
edit_line_increase(edit_data *ed, int cnt)
|
|
|
|
{
|
|
|
|
char buf[MAX_LINE_DIGIT_CNT];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < cnt; i++)
|
|
|
|
{
|
|
|
|
ed->line_max++;
|
|
|
|
snprintf(buf, sizeof(buf), "<br/>%d", ed->line_max);
|
|
|
|
elm_entry_entry_append(ed->en_line, buf);
|
|
|
|
}
|
2014-07-25 22:10:14 -07:00
|
|
|
elm_entry_calc_force(ed->en_line);
|
2014-08-02 02:15:22 -07:00
|
|
|
|
2014-09-30 07:56:16 -07:00
|
|
|
evas_object_smart_callback_call(ed->enventor, SIG_MAX_LINE_CHANGED,
|
|
|
|
(void *)ed->line_max);
|
2014-07-18 21:31:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
edit_line_decrease(edit_data *ed, int cnt)
|
|
|
|
{
|
|
|
|
if (cnt < 1) return;
|
|
|
|
|
|
|
|
Evas_Object *textblock = elm_entry_textblock_get(ed->en_line);
|
|
|
|
Evas_Textblock_Cursor *cur1 = evas_object_textblock_cursor_new(textblock);
|
|
|
|
Evas_Textblock_Cursor *cur2 = evas_object_textblock_cursor_new(textblock);
|
|
|
|
|
2014-07-25 22:05:18 -07:00
|
|
|
int i = cnt;
|
|
|
|
while (i)
|
|
|
|
{
|
|
|
|
evas_textblock_cursor_paragraph_last(cur1);
|
|
|
|
evas_textblock_cursor_paragraph_prev(cur1);
|
|
|
|
evas_textblock_cursor_paragraph_last(cur2);
|
|
|
|
evas_textblock_cursor_range_delete(cur1, cur2);
|
|
|
|
i--;
|
|
|
|
}
|
2014-07-18 21:31:08 -07:00
|
|
|
|
|
|
|
evas_textblock_cursor_free(cur1);
|
|
|
|
evas_textblock_cursor_free(cur2);
|
|
|
|
|
|
|
|
elm_entry_calc_force(ed->en_line);
|
|
|
|
|
|
|
|
ed->line_max -= cnt;
|
|
|
|
|
|
|
|
if (ed->line_max < 1) line_init(ed);
|
2014-09-30 07:56:16 -07:00
|
|
|
|
|
|
|
evas_object_smart_callback_call(ed->enventor, SIG_MAX_LINE_CHANGED,
|
|
|
|
(void *)ed->line_max);
|
2014-07-18 21:31:08 -07:00
|
|
|
}
|
2014-08-08 22:29:51 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
edit_redoundo_region_push(edit_data *ed, int cursor_pos1, int cursor_pos2)
|
|
|
|
{
|
|
|
|
redoundo_entry_region_push(ed->rd, cursor_pos1, cursor_pos2);
|
|
|
|
}
|
|
|
|
|
2014-08-10 21:48:01 -07:00
|
|
|
void
|
2014-08-11 00:32:35 -07:00
|
|
|
edit_disabled_set(edit_data *ed, Eina_Bool disabled)
|
2014-08-10 21:48:01 -07:00
|
|
|
{
|
2014-08-11 00:32:35 -07:00
|
|
|
elm_object_disabled_set(ed->layout, disabled);
|
|
|
|
elm_object_focus_allow_set(ed->layout, disabled);
|
2014-08-10 21:48:01 -07:00
|
|
|
|
2014-08-11 00:32:35 -07:00
|
|
|
if (disabled)
|
2014-08-13 03:09:11 -07:00
|
|
|
{
|
|
|
|
elm_object_signal_emit(ed->layout, "elm,state,disabled", "");
|
|
|
|
elm_entry_select_none(ed->en_edit);
|
|
|
|
}
|
2014-08-10 21:48:01 -07:00
|
|
|
else
|
2014-08-11 00:32:35 -07:00
|
|
|
elm_object_signal_emit(ed->layout, "elm,state,enabled", "");
|
2014-08-10 21:48:01 -07:00
|
|
|
}
|
2014-09-30 07:56:16 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
edit_auto_indent_set(edit_data *ed, Eina_Bool auto_indent)
|
|
|
|
{
|
|
|
|
auto_indent = !!auto_indent;
|
|
|
|
ed->auto_indent = auto_indent;
|
|
|
|
}
|
|
|
|
|
|
|
|
Eina_Bool
|
|
|
|
edit_auto_indent_get(edit_data *ed)
|
|
|
|
{
|
|
|
|
return ed->auto_indent;
|
|
|
|
}
|
|
|
|
|
|
|
|
Eina_Bool
|
|
|
|
edit_ctxpopup_get(edit_data *ed)
|
|
|
|
{
|
|
|
|
return ed->ctxpopup;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
edit_ctxpopup_set(edit_data *ed, Eina_Bool ctxpopup)
|
|
|
|
{
|
|
|
|
ctxpopup = !!ctxpopup;
|
|
|
|
ed->ctxpopup = ctxpopup;
|
|
|
|
}
|