2013-07-20 01:51:56 -07:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include "common.h"
|
2013-08-31 05:03:11 -07:00
|
|
|
#include "template_code.h"
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
//FIXME: Make flexible
|
|
|
|
const int MAX_LINE_DIGIT_CNT = 10;
|
2013-08-31 10:50:17 -07:00
|
|
|
const double SYNTAX_COLOR_TIME = 0.25;
|
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;
|
|
|
|
Evas_Object *parent;
|
|
|
|
|
2013-08-15 08:47:31 -07:00
|
|
|
syntax_helper *sh;
|
2013-07-20 01:51:56 -07:00
|
|
|
stats_data *sd;
|
2013-08-24 10:41:53 -07:00
|
|
|
config_data *cd;
|
2013-07-20 01:51:56 -07:00
|
|
|
parser_data *pd;
|
|
|
|
|
2013-09-15 01:07:43 -07:00
|
|
|
int cur_line;
|
2013-07-20 01:51:56 -07:00
|
|
|
int line_max;
|
|
|
|
|
|
|
|
Ecore_Idler *syntax_color_timer;
|
|
|
|
|
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;
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
Eina_Bool edit_changed : 1;
|
|
|
|
Eina_Bool linenumber : 1;
|
|
|
|
Eina_Bool ctrl_pressed : 1;
|
|
|
|
};
|
|
|
|
|
2013-09-09 08:58:33 -07:00
|
|
|
static Eina_Bool image_preview_show(edit_data *ed, char *cur, Evas_Coord x, Evas_Coord y);
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
static void
|
2013-09-15 01:07:43 -07:00
|
|
|
line_increase(edit_data *ed)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
|
|
|
char buf[MAX_LINE_DIGIT_CNT];
|
|
|
|
|
|
|
|
ed->line_max++;
|
|
|
|
snprintf(buf, sizeof(buf), "%d<br/>", ed->line_max);
|
|
|
|
elm_entry_entry_append(ed->en_line, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
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_line_set(cur1, (ed->line_max - cnt));
|
|
|
|
evas_textblock_cursor_word_start(cur1);
|
|
|
|
|
|
|
|
Evas_Textblock_Cursor *cur2 = evas_object_textblock_cursor_new(textblock);
|
|
|
|
evas_textblock_cursor_line_set(cur2, ed->line_max);
|
|
|
|
evas_textblock_cursor_paragraph_last(cur2);
|
|
|
|
|
|
|
|
evas_textblock_cursor_range_delete(cur1, cur2);
|
|
|
|
|
|
|
|
evas_textblock_cursor_free(cur1);
|
|
|
|
evas_textblock_cursor_free(cur2);
|
|
|
|
|
|
|
|
elm_entry_calc_force(ed->en_line);
|
|
|
|
|
|
|
|
ed->line_max -= cnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
syntax_color_apply(edit_data *ed)
|
|
|
|
{
|
|
|
|
//FIXME: Optimize here by applying color syntax for only changed lines
|
2013-10-03 07:10:47 -07:00
|
|
|
char *text = (char *) elm_entry_entry_get(ed->en_edit);
|
2013-07-20 01:51:56 -07:00
|
|
|
int pos = elm_entry_cursor_pos_get(ed->en_edit);
|
2013-08-15 08:47:31 -07:00
|
|
|
char *utf8 = (char *) color_cancel(syntax_color_data_get(ed->sh), text,
|
|
|
|
strlen(text));
|
2013-07-20 01:51:56 -07:00
|
|
|
if (!utf8) return;
|
|
|
|
utf8 = strdup(utf8);
|
2013-08-15 08:47:31 -07:00
|
|
|
const char *translated = color_apply(syntax_color_data_get(ed->sh), utf8,
|
2013-09-11 08:57:08 -07:00
|
|
|
strlen(utf8));
|
2013-08-30 10:06:57 -07:00
|
|
|
elm_entry_entry_set(ed->en_edit, NULL);
|
|
|
|
elm_entry_entry_append(ed->en_edit, translated);
|
2013-07-20 01:51:56 -07:00
|
|
|
elm_entry_cursor_pos_set(ed->en_edit, pos);
|
|
|
|
free(utf8);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
syntax_color_timer_cb(void *data)
|
|
|
|
{
|
|
|
|
edit_data *ed = data;
|
|
|
|
syntax_color_apply(ed);
|
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
|
|
|
|
syntax_color_timer_update(edit_data *ed)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2013-10-03 10:24:29 -07:00
|
|
|
if (ed->syntax_color_timer) ecore_timer_del(ed->syntax_color_timer);
|
|
|
|
ed->syntax_color_timer = ecore_timer_add(SYNTAX_COLOR_TIME,
|
|
|
|
syntax_color_timer_cb, ed);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
ed->edit_changed = EINA_TRUE;
|
|
|
|
|
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)
|
|
|
|
{
|
2013-09-15 05:45:03 -07:00
|
|
|
if (info->change.insert.content[0] == ' ') return;
|
2013-09-15 06:44:04 -07:00
|
|
|
|
2013-08-19 07:29:43 -07:00
|
|
|
if (!strcmp(info->change.insert.content, "<br/>"))
|
|
|
|
{
|
2013-09-15 01:07:43 -07:00
|
|
|
line_increase(ed);
|
2013-08-19 10:46:37 -07:00
|
|
|
syntax_color = EINA_FALSE;
|
2013-08-19 07:29:43 -07:00
|
|
|
}
|
2013-09-15 01:07:43 -07:00
|
|
|
|
|
|
|
if (config_auto_indent_get(ed->cd))
|
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
|
|
|
|
|
|
|
if (config_auto_indent_get(ed->cd))
|
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
|
|
|
|
2013-09-15 08:22:15 -07:00
|
|
|
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;
|
2013-10-03 10:24:29 -07:00
|
|
|
syntax_color_timer_update(ed);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
save_msg_show(edit_data *ed)
|
|
|
|
{
|
2013-08-24 10:41:53 -07:00
|
|
|
if (!config_stats_bar_get(ed->cd)) return;
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
|
|
|
|
if (ed->edit_changed)
|
2013-08-04 09:28:47 -07:00
|
|
|
snprintf(buf, sizeof(buf), "File saved. \"%s\"",
|
2013-08-24 10:41:53 -07:00
|
|
|
config_edc_path_get(ed->cd));
|
2013-07-20 01:51:56 -07:00
|
|
|
else
|
2013-08-04 09:28:47 -07:00
|
|
|
snprintf(buf, sizeof(buf), "Already saved. \"%s\"",
|
2013-08-24 10:41:53 -07:00
|
|
|
config_edc_path_get(ed->cd));
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
stats_info_msg_update(ed->sd, buf);
|
|
|
|
}
|
|
|
|
|
2013-08-04 09:28:47 -07:00
|
|
|
Eina_Bool
|
2013-07-20 01:51:56 -07:00
|
|
|
edit_save(edit_data *ed)
|
|
|
|
{
|
|
|
|
if (!ed->edit_changed)
|
|
|
|
{
|
|
|
|
save_msg_show(ed);
|
2013-08-04 09:28:47 -07:00
|
|
|
return EINA_TRUE;
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *text = elm_entry_entry_get(ed->en_edit);
|
2013-09-15 01:07:43 -07:00
|
|
|
char *utf8 = elm_entry_markup_to_utf8(text);
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2013-08-24 10:41:53 -07:00
|
|
|
FILE *fp = fopen(config_edc_path_get(ed->cd), "w");
|
2013-08-04 09:28:47 -07:00
|
|
|
if (!fp) return EINA_FALSE;
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2013-09-15 01:07:43 -07:00
|
|
|
fputs(utf8, fp);
|
2013-07-20 01:51:56 -07:00
|
|
|
fclose(fp);
|
|
|
|
|
2013-09-15 01:07:43 -07:00
|
|
|
free(utf8);
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
save_msg_show(ed);
|
|
|
|
//FIXME: If compile edc here? we can edit_changed FALSE;
|
|
|
|
//ed->edit_changed = EINA_FALSE;
|
2013-08-04 09:28:47 -07:00
|
|
|
|
2013-10-14 10:30:36 -07:00
|
|
|
edit_view_sync(ed);
|
|
|
|
|
2013-08-04 09:28:47 -07:00
|
|
|
return EINA_TRUE;
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
elm_entry_entry_insert(ed->en_edit, text);
|
2013-07-20 01:51:56 -07:00
|
|
|
elm_ctxpopup_dismiss(obj);
|
|
|
|
ed->edit_changed = EINA_TRUE;
|
|
|
|
edit_save(ed);
|
|
|
|
}
|
|
|
|
|
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;
|
2013-09-09 08:58:33 -07:00
|
|
|
int skip_focus = (int) 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-08-31 11:49:17 -07:00
|
|
|
void
|
|
|
|
edit_template_insert(edit_data *ed)
|
|
|
|
{
|
2013-09-01 11:52:31 -07:00
|
|
|
const char *paragh = parser_paragh_name_get(ed->pd, ed->en_edit);
|
|
|
|
if (!paragh) return;
|
|
|
|
|
|
|
|
if (!strcmp(paragh, "parts"))
|
|
|
|
{
|
|
|
|
edit_template_part_insert(ed, EDJE_PART_TYPE_IMAGE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int line_cnt;
|
|
|
|
char **t = NULL;
|
2013-09-05 07:09:51 -07:00
|
|
|
char buf[64];
|
|
|
|
char buf2[12];
|
2013-09-01 11:52:31 -07:00
|
|
|
|
|
|
|
if (!strcmp(paragh, "part"))
|
|
|
|
{
|
|
|
|
line_cnt = TEMPLATE_DESC_LINE_CNT;
|
|
|
|
t = (char **) &TEMPLATE_DESC;
|
2013-09-05 07:09:51 -07:00
|
|
|
strcpy(buf2, "Description");
|
2013-09-01 11:52:31 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(paragh, "programs"))
|
|
|
|
{
|
|
|
|
line_cnt = TEMPLATE_PROG_LINE_CNT;
|
|
|
|
t = (char **) &TEMPLATE_PROG;
|
2013-09-05 07:09:51 -07:00
|
|
|
strcpy(buf2, "Program");
|
2013-09-01 11:52:31 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(paragh, "images"))
|
|
|
|
{
|
|
|
|
line_cnt = TEMPLATE_IMG_LINE_CNT;
|
|
|
|
t = (char **) &TEMPLATE_IMG;
|
2013-09-05 07:09:51 -07:00
|
|
|
strcpy(buf2, "Image File");
|
2013-09-01 11:52:31 -07:00
|
|
|
}
|
2013-09-19 06:51:19 -07:00
|
|
|
else if (!strcmp(paragh, "collections"))
|
|
|
|
{
|
|
|
|
line_cnt = TEMPLATE_GROUP_LINE_CNT;
|
|
|
|
t = (char **) &TEMPLATE_GROUP;
|
|
|
|
strcpy(buf2, "Group");
|
|
|
|
}
|
2013-09-01 11:52:31 -07:00
|
|
|
|
2013-09-05 07:09:51 -07:00
|
|
|
if (!t)
|
|
|
|
{
|
|
|
|
stats_info_msg_update(ed->sd,
|
|
|
|
"Can't insert template code here. Move the cursor inside the \"Images|Parts|Part\" scope.");
|
|
|
|
return;
|
|
|
|
}
|
2013-09-01 11:52:31 -07:00
|
|
|
|
|
|
|
int cursor_pos = elm_entry_cursor_pos_get(ed->en_edit);
|
|
|
|
elm_entry_cursor_line_begin_set(ed->en_edit);
|
2013-09-15 01:20:13 -07:00
|
|
|
int space = indent_space_get(syntax_indent_data_get(ed->sh), ed->en_edit);
|
2013-09-01 11:52:31 -07:00
|
|
|
|
|
|
|
//Alloc Empty spaces
|
2013-09-12 06:14:16 -07:00
|
|
|
char *p = alloca(space + 1);
|
2013-09-01 11:52:31 -07:00
|
|
|
memset(p, ' ', space);
|
|
|
|
p[space] = '\0';
|
|
|
|
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < line_cnt; i++)
|
|
|
|
{
|
|
|
|
elm_entry_entry_insert(ed->en_edit, p);
|
|
|
|
elm_entry_entry_insert(ed->en_edit, t[i]);
|
2013-09-15 01:07:43 -07:00
|
|
|
line_increase(ed);
|
2013-09-01 11:52:31 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
elm_entry_cursor_pos_set(ed->en_edit, cursor_pos);
|
|
|
|
|
2013-10-03 10:24:29 -07:00
|
|
|
syntax_color_timer_update(ed);
|
|
|
|
snprintf(buf, sizeof(buf), "Template code inserted. (%s)", buf2);
|
|
|
|
stats_info_msg_update(ed->sd, buf);
|
2013-08-31 11:49:17 -07:00
|
|
|
}
|
|
|
|
|
2013-08-31 05:03:11 -07:00
|
|
|
void
|
2013-08-31 11:49:17 -07:00
|
|
|
edit_template_part_insert(edit_data *ed, Edje_Part_Type type)
|
2013-08-31 05:03:11 -07:00
|
|
|
{
|
2013-08-31 10:50:17 -07:00
|
|
|
if (type == EDJE_PART_TYPE_NONE) return;
|
|
|
|
|
2013-08-31 05:03:11 -07:00
|
|
|
int cursor_pos = elm_entry_cursor_pos_get(ed->en_edit);
|
|
|
|
elm_entry_cursor_line_begin_set(ed->en_edit);
|
2013-09-15 01:20:13 -07:00
|
|
|
int space = indent_space_get(syntax_indent_data_get(ed->sh), ed->en_edit);
|
2013-08-31 05:03:11 -07:00
|
|
|
|
|
|
|
//Alloc Empty spaces
|
2013-09-12 06:14:16 -07:00
|
|
|
char *p = alloca(space + 1);
|
2013-08-31 05:03:11 -07:00
|
|
|
memset(p, ' ', space);
|
|
|
|
p[space] = '\0';
|
|
|
|
|
2013-08-31 10:50:17 -07:00
|
|
|
int line_cnt;
|
|
|
|
char **t;
|
2013-09-05 07:09:51 -07:00
|
|
|
char buf[64];
|
|
|
|
char part[20];
|
2013-08-31 10:50:17 -07:00
|
|
|
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case EDJE_PART_TYPE_RECTANGLE:
|
|
|
|
line_cnt = TEMPLATE_PART_RECT_LINE_CNT;
|
|
|
|
t = (char **) &TEMPLATE_PART_RECT;
|
2013-09-05 07:09:51 -07:00
|
|
|
strcpy(part, "Rect");
|
2013-08-31 10:50:17 -07:00
|
|
|
break;
|
|
|
|
case EDJE_PART_TYPE_TEXT:
|
|
|
|
line_cnt = TEMPLATE_PART_TEXT_LINE_CNT;
|
|
|
|
t = (char **) &TEMPLATE_PART_TEXT;
|
2013-09-05 07:09:51 -07:00
|
|
|
strcpy(part, "Text");
|
2013-08-31 10:50:17 -07:00
|
|
|
break;
|
|
|
|
case EDJE_PART_TYPE_SWALLOW:
|
|
|
|
line_cnt = TEMPLATE_PART_SWALLOW_LINE_CNT;
|
|
|
|
t = (char **) &TEMPLATE_PART_SWALLOW;
|
2013-09-05 07:09:51 -07:00
|
|
|
strcpy(part, "Swallow");
|
2013-08-31 10:50:17 -07:00
|
|
|
break;
|
|
|
|
case EDJE_PART_TYPE_TEXTBLOCK:
|
|
|
|
line_cnt = TEMPLATE_PART_TEXTBLOCK_LINE_CNT;
|
|
|
|
t = (char **) &TEMPLATE_PART_TEXTBLOCK;
|
2013-09-05 07:09:51 -07:00
|
|
|
strcpy(part, "Textblock");
|
2013-08-31 10:50:17 -07:00
|
|
|
break;
|
|
|
|
case EDJE_PART_TYPE_SPACER:
|
|
|
|
line_cnt = TEMPLATE_PART_SPACER_LINE_CNT;
|
|
|
|
t = (char **) &TEMPLATE_PART_SPACER;
|
2013-09-05 07:09:51 -07:00
|
|
|
strcpy(part, "Spacer");
|
2013-08-31 10:50:17 -07:00
|
|
|
break;
|
|
|
|
case EDJE_PART_TYPE_IMAGE:
|
2013-09-12 06:14:16 -07:00
|
|
|
case EDJE_PART_TYPE_NONE:
|
|
|
|
case EDJE_PART_TYPE_GRADIENT:
|
|
|
|
case EDJE_PART_TYPE_GROUP:
|
|
|
|
case EDJE_PART_TYPE_BOX:
|
|
|
|
case EDJE_PART_TYPE_TABLE:
|
|
|
|
case EDJE_PART_TYPE_EXTERNAL:
|
|
|
|
case EDJE_PART_TYPE_PROXY:
|
|
|
|
case EDJE_PART_TYPE_LAST:
|
2013-08-31 10:50:17 -07:00
|
|
|
line_cnt = TEMPLATE_PART_IMAGE_LINE_CNT;
|
|
|
|
t = (char **) &TEMPLATE_PART_IMAGE;
|
2013-09-05 07:09:51 -07:00
|
|
|
strcpy(part, "Image");
|
2013-08-31 10:50:17 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-08-31 05:03:11 -07:00
|
|
|
int i;
|
|
|
|
for (i = 0; i < line_cnt; i++)
|
|
|
|
{
|
|
|
|
elm_entry_entry_insert(ed->en_edit, p);
|
2013-08-31 10:50:17 -07:00
|
|
|
elm_entry_entry_insert(ed->en_edit, t[i]);
|
2013-09-15 01:07:43 -07:00
|
|
|
line_increase(ed);
|
2013-08-31 05:03:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
elm_entry_cursor_pos_set(ed->en_edit, cursor_pos);
|
|
|
|
|
2013-10-03 10:24:29 -07:00
|
|
|
syntax_color_timer_update(ed);
|
|
|
|
snprintf(buf, sizeof(buf), "Template code inserted. (%s Part)", part);
|
|
|
|
stats_info_msg_update(ed->sd, buf);
|
2013-08-31 05:03:11 -07:00
|
|
|
}
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
static void
|
|
|
|
edit_mouse_down_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED,
|
|
|
|
Evas_Object *obj, void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Evas_Event_Mouse_Down *ev = event_info;
|
|
|
|
if (ev->button == 1)
|
|
|
|
{
|
|
|
|
elm_entry_select_none(obj);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cur_line_pos_set(edit_data *ed)
|
|
|
|
{
|
2013-08-24 10:41:53 -07:00
|
|
|
if (!config_stats_bar_get(ed->cd)) return;
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
Evas_Coord y, h;
|
|
|
|
elm_entry_cursor_geometry_get(ed->en_edit, NULL, &y, NULL, &h);
|
2013-10-13 21:23:57 -07:00
|
|
|
int line = (y / h) + 1;
|
|
|
|
if (ed->cur_line == line) return;
|
|
|
|
ed->cur_line = line;
|
2013-09-15 01:07:43 -07:00
|
|
|
stats_line_num_update(ed->sd, ed->cur_line, ed->line_max);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
2013-09-08 00:26:11 -07:00
|
|
|
static void
|
|
|
|
program_run(edit_data *ed, char *cur)
|
|
|
|
{
|
|
|
|
char *program = parser_name_get(ed->pd, cur);
|
|
|
|
if (program)
|
|
|
|
{
|
2013-09-18 21:42:34 -07:00
|
|
|
edj_mgr *em = edj_mgr_get();
|
|
|
|
view_data *vd = edj_mgr_view_get(em, NULL);
|
|
|
|
view_program_run(vd, program);
|
2013-09-08 00:26:11 -07:00
|
|
|
free(program);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
menu_ctxpopup_unregister(ctxpopup);
|
|
|
|
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;
|
|
|
|
int next = (int) event_info;
|
|
|
|
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.
|
|
|
|
Eina_List *list = config_edc_img_path_list_get(ed->cd);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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 =
|
|
|
|
ctxpopup_img_preview_create(ed->parent,
|
|
|
|
fullpath,
|
|
|
|
ctxpopup_preview_dismiss_cb,
|
2013-09-09 08:58:33 -07:00
|
|
|
ctxpopup_preview_relay_cb,
|
2013-09-08 01:04:56 -07:00
|
|
|
ed);
|
2013-09-09 08:58:33 -07:00
|
|
|
if (!ctxpopup) return EINA_FALSE;
|
2013-09-08 01:04:56 -07:00
|
|
|
|
|
|
|
evas_object_move(ctxpopup, x, y);
|
|
|
|
evas_object_show(ctxpopup);
|
|
|
|
menu_ctxpopup_register(ctxpopup);
|
|
|
|
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
|
|
|
|
{
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
snprintf(buf, sizeof(buf), "Failed to load the image. \"%s\"",
|
|
|
|
filename);
|
|
|
|
stats_info_msg_update(ed->sd, buf);
|
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 =
|
|
|
|
ctxpopup_candidate_list_create(ed->parent, attr,
|
|
|
|
atof(selected),
|
2013-09-08 01:04:56 -07:00
|
|
|
ctxpopup_candidate_dismiss_cb,
|
|
|
|
ctxpopup_candidate_selected_cb, ed);
|
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);
|
|
|
|
menu_ctxpopup_register(ctxpopup);
|
|
|
|
elm_object_disabled_set(ed->layout, EINA_TRUE);
|
2013-09-08 00:26:11 -07:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
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;
|
2013-09-08 00:26:11 -07:00
|
|
|
selected = elm_entry_markup_to_utf8(selected);
|
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);
|
|
|
|
|
2013-09-08 00:26:11 -07:00
|
|
|
if (selected) free(selected);
|
|
|
|
if (text) 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,
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
void
|
2013-09-18 08:14:34 -07:00
|
|
|
edit_view_sync(edit_data *ed)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2013-08-24 10:41:53 -07:00
|
|
|
if (!config_part_highlight_get(ed->cd)) return;
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2013-09-18 08:14:34 -07:00
|
|
|
parser_cur_name_get(ed->pd, ed->en_edit, cur_name_get_cb, ed);
|
2013-09-18 00:48:05 -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;
|
|
|
|
cur_line_pos_set(ed);
|
2013-09-18 08:14:34 -07:00
|
|
|
edit_view_sync(ed);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-09-18 10:05:46 -07:00
|
|
|
edit_view_sync_cb_set(edit_data *ed,
|
|
|
|
void (*cb)(void *data, Eina_Stringshare *part_name,
|
|
|
|
Eina_Stringshare *group_name), void *data)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2013-09-18 10:05:46 -07:00
|
|
|
ed->view_sync_cb = cb;
|
|
|
|
ed->view_sync_cb_data = data;
|
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
|
|
|
|
if (!strcmp("Control_L", event->keyname))
|
|
|
|
ed->ctrl_pressed = EINA_TRUE;
|
|
|
|
|
|
|
|
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
|
|
|
|
if (!strcmp("Control_L", event->keyname))
|
|
|
|
ed->ctrl_pressed = EINA_FALSE;
|
|
|
|
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
|
|
|
|
|
|
|
edit_data *
|
2013-08-24 10:41:53 -07:00
|
|
|
edit_init(Evas_Object *parent, stats_data *sd, config_data *cd)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
|
|
|
parser_data *pd = parser_init();
|
2013-08-15 08:47:31 -07:00
|
|
|
syntax_helper *sh = syntax_init();
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
edit_data *ed = calloc(1, sizeof(edit_data));
|
|
|
|
ed->sd = sd;
|
|
|
|
ed->pd = pd;
|
2013-08-15 08:47:31 -07:00
|
|
|
ed->sh = sh;
|
2013-08-24 10:41:53 -07:00
|
|
|
ed->cd = cd;
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
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(parent);
|
|
|
|
elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_AUTO,
|
|
|
|
ELM_SCROLLER_POLICY_AUTO);
|
|
|
|
elm_object_focus_allow_set(scroller, EINA_FALSE);
|
|
|
|
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);
|
|
|
|
evas_object_show(scroller);
|
|
|
|
|
|
|
|
//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);
|
|
|
|
evas_object_show(layout);
|
|
|
|
|
|
|
|
elm_object_content_set(scroller, layout);
|
|
|
|
|
|
|
|
//Line Number Entry
|
|
|
|
Evas_Object *en_line = elm_entry_add(layout);
|
|
|
|
elm_object_style_set(en_line, "linenumber");
|
|
|
|
elm_entry_editable_set(en_line, EINA_FALSE);
|
|
|
|
elm_entry_line_wrap_set(en_line, EINA_FALSE);
|
|
|
|
evas_object_size_hint_weight_set(en_line, 0, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(en_line, 0, EVAS_HINT_FILL);
|
|
|
|
evas_object_show(en_line);
|
|
|
|
|
|
|
|
elm_object_part_content_set(layout, "elm.swallow.linenumber", en_line);
|
|
|
|
|
|
|
|
//EDC Editor Entry
|
|
|
|
Evas_Object *en_edit = elm_entry_add(layout);
|
|
|
|
elm_object_style_set(en_edit, elm_app_name_get());
|
|
|
|
elm_entry_context_menu_disabled_set(en_edit, EINA_TRUE);
|
|
|
|
elm_entry_line_wrap_set(en_edit, EINA_FALSE);
|
|
|
|
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-07-20 01:51:56 -07:00
|
|
|
evas_object_smart_callback_add(en_edit, "clicked,double",
|
|
|
|
edit_cursor_double_clicked_cb, ed);
|
|
|
|
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);
|
|
|
|
evas_object_event_callback_add(en_edit, EVAS_CALLBACK_MOUSE_DOWN,
|
|
|
|
edit_mouse_down_cb, ed);
|
|
|
|
evas_object_show(en_edit);
|
|
|
|
|
|
|
|
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;
|
|
|
|
ed->parent = parent;
|
|
|
|
ed->linenumber = EINA_TRUE;
|
|
|
|
|
|
|
|
edit_line_number_toggle(ed);
|
|
|
|
|
|
|
|
return ed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
edit_editable_set(edit_data *ed, Eina_Bool editable)
|
|
|
|
{
|
|
|
|
elm_entry_editable_set(ed->en_edit, editable);
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
if (ed->syntax_color_timer) ecore_timer_del(ed->syntax_color_timer);
|
|
|
|
free(ed);
|
|
|
|
|
2013-08-15 08:47:31 -07:00
|
|
|
syntax_term(sh);
|
2013-07-20 01:51:56 -07:00
|
|
|
parser_term(pd);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
edit_edc_read(edit_data *ed, const char *file_path)
|
|
|
|
{
|
|
|
|
char buf[MAX_LINE_DIGIT_CNT];
|
|
|
|
|
|
|
|
Eina_File *file = eina_file_open(file_path, EINA_FALSE);
|
|
|
|
if (!file) goto err;
|
|
|
|
|
|
|
|
Eina_Iterator *itr = eina_file_map_lines(file);
|
|
|
|
if (!itr) goto err;
|
|
|
|
|
|
|
|
Eina_Strbuf *strbuf = eina_strbuf_new();
|
|
|
|
if (!strbuf) goto err;
|
|
|
|
|
|
|
|
Eina_File_Line *line;
|
|
|
|
int line_num = 0;
|
|
|
|
EINA_ITERATOR_FOREACH(itr, line)
|
|
|
|
{
|
2013-08-24 10:41:53 -07:00
|
|
|
//Append edc ccde
|
2013-07-20 01:51:56 -07:00
|
|
|
if (line_num > 0)
|
|
|
|
{
|
|
|
|
if (!eina_strbuf_append(strbuf, "<br/>")) goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!eina_strbuf_append_length(strbuf, line->start, line->length))
|
|
|
|
goto err;
|
|
|
|
line_num++;
|
|
|
|
|
|
|
|
//Append line number
|
|
|
|
sprintf(buf, "%d<br/>", line_num);
|
|
|
|
elm_entry_entry_append(ed->en_line, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
elm_entry_entry_append(ed->en_edit, eina_strbuf_string_get(strbuf));
|
|
|
|
|
|
|
|
ed->line_max = line_num;
|
2013-09-18 09:43:10 -07:00
|
|
|
Eina_Stringshare *group_name =
|
|
|
|
parser_first_group_name_get(ed->pd, ed->en_edit);
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2013-09-18 09:43:10 -07:00
|
|
|
stats_edc_file_set(ed->sd, group_name);
|
2013-10-03 05:38:51 -07:00
|
|
|
|
2013-10-03 10:24:29 -07:00
|
|
|
ecore_animator_add(syntax_color_timer_cb, ed);
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
err:
|
|
|
|
if (strbuf) eina_strbuf_free(strbuf);
|
|
|
|
if (itr) eina_iterator_free(itr);
|
|
|
|
if (file) eina_file_close(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
edit_focus_set(edit_data *ed)
|
|
|
|
{
|
|
|
|
elm_object_focus_set(ed->en_edit, EINA_TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
edit_line_number_toggle(edit_data *ed)
|
|
|
|
{
|
2013-08-24 10:41:53 -07:00
|
|
|
Eina_Bool linenumber = config_linenumber_get(ed->cd);
|
2013-07-20 01:51:56 -07:00
|
|
|
if (ed->linenumber == linenumber) return;
|
|
|
|
ed->linenumber = linenumber;
|
|
|
|
|
|
|
|
if (linenumber)
|
|
|
|
elm_object_signal_emit(ed->layout, "elm,state,linenumber,show", "");
|
|
|
|
else
|
|
|
|
elm_object_signal_emit(ed->layout, "elm,state,linenumber,hide", "");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
edit_new(edit_data *ed)
|
|
|
|
{
|
2013-09-19 03:16:54 -07:00
|
|
|
parser_cancel(ed->pd);
|
2013-07-20 01:51:56 -07:00
|
|
|
elm_entry_entry_set(ed->en_edit, "");
|
|
|
|
elm_entry_entry_set(ed->en_line, "");
|
2013-08-24 10:41:53 -07:00
|
|
|
edit_edc_read(ed, config_edc_path_get(ed->cd));
|
2013-07-20 01:51:56 -07:00
|
|
|
ed->edit_changed = EINA_TRUE;
|
2013-08-24 11:39:39 -07:00
|
|
|
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
snprintf(buf, sizeof(buf), "File Path: \"%s\"",
|
|
|
|
config_edc_path_get(ed->cd));
|
|
|
|
stats_info_msg_update(ed->sd, buf);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
2013-08-22 05:47:23 -07:00
|
|
|
void
|
2013-08-24 11:39:39 -07:00
|
|
|
edit_font_size_update(edit_data *ed, Eina_Bool msg)
|
2013-08-22 05:47:23 -07:00
|
|
|
{
|
2013-08-24 10:41:53 -07:00
|
|
|
elm_object_scale_set(ed->en_edit, config_font_size_get(ed->cd));
|
|
|
|
elm_object_scale_set(ed->en_line, config_font_size_get(ed->cd));
|
2013-08-24 09:46:56 -07:00
|
|
|
|
2013-08-24 11:39:39 -07:00
|
|
|
if (!msg) return;
|
|
|
|
|
2013-08-24 09:46:56 -07:00
|
|
|
char buf[128];
|
|
|
|
snprintf(buf, sizeof(buf), "Font Size: %1.1fx",
|
2013-08-24 10:41:53 -07:00
|
|
|
config_font_size_get(ed->cd));
|
2013-08-24 09:46:56 -07:00
|
|
|
stats_info_msg_update(ed->sd, buf);
|
2013-08-22 05:47:23 -07:00
|
|
|
}
|