forked from enlightenment/enventor
edc_edit: code refactoring.
font set for editor should be global. so, take care of this in enventor object data. This is a partial change for multiple edc editor.
This commit is contained in:
parent
11f5ebfd49
commit
f36abe3d3c
|
@ -55,8 +55,6 @@ struct editor_s
|
|||
Eina_Stringshare *part_name, Eina_Stringshare *group_name);
|
||||
void *view_sync_cb_data;
|
||||
int select_pos;
|
||||
const char *font_name;
|
||||
const char *font_style;
|
||||
const char *error_target;
|
||||
|
||||
Eina_Bool edit_changed : 1;
|
||||
|
@ -72,8 +70,6 @@ struct editor_s
|
|||
static Eina_Bool
|
||||
image_preview_show(edit_data *ed, char *cur, Evas_Coord x, Evas_Coord y);
|
||||
static void
|
||||
edit_font_apply(edit_data *ed, const char *font_name, const char *font_style);
|
||||
static void
|
||||
error_line_num_highlight(edit_data *ed);
|
||||
|
||||
static void
|
||||
|
@ -153,20 +149,13 @@ entry_recover(edit_data *ed, int cursor_pos, int sel_cur_begin, int sel_cur_end)
|
|||
ed->on_select_recover = EINA_FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
edit_font_apply(edit_data *ed, const char *font_name, const char *font_style)
|
||||
void
|
||||
edit_font_update(edit_data *ed)
|
||||
{
|
||||
char *font = NULL;
|
||||
if (font_name)
|
||||
font = elm_font_fontconfig_name_get(font_name, font_style);
|
||||
edje_text_class_set("enventor_entry", font, -100);
|
||||
elm_font_fontconfig_name_free(font);
|
||||
if (!ed) return;
|
||||
|
||||
elm_entry_calc_force(ed->en_line);
|
||||
|
||||
int cursor_pos;
|
||||
entry_recover_param_get(ed, &cursor_pos, NULL, NULL);
|
||||
entry_recover(ed, cursor_pos, -1, -1);
|
||||
elm_entry_calc_force(ed->en_edit);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1450,9 +1439,6 @@ edit_term(edit_data *ed)
|
|||
{
|
||||
if (!ed) return;
|
||||
|
||||
if (ed->font_name) eina_stringshare_del(ed->font_name);
|
||||
if (ed->font_style) eina_stringshare_del(ed->font_style);
|
||||
|
||||
syntax_helper *sh = ed->sh;
|
||||
parser_data *pd = ed->pd;
|
||||
|
||||
|
@ -1497,23 +1483,6 @@ edit_font_scale_set(edit_data *ed, double font_scale)
|
|||
syntax_color_partial_update(ed, 0);
|
||||
}
|
||||
|
||||
void
|
||||
edit_font_set(edit_data *ed, const char *font_name, const char *font_style)
|
||||
{
|
||||
if (!ed) return;
|
||||
|
||||
eina_stringshare_replace(&ed->font_name, font_name);
|
||||
eina_stringshare_replace(&ed->font_style, font_style);
|
||||
edit_font_apply(ed, font_name, font_style);
|
||||
}
|
||||
|
||||
void
|
||||
edit_font_get(edit_data *ed, const char **font_name, const char **font_style)
|
||||
{
|
||||
if (font_name) *font_name = ed->font_name;
|
||||
if (font_style) *font_style = ed->font_style;
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
edit_load(edit_data *ed, const char *edc_path)
|
||||
{
|
||||
|
|
|
@ -229,6 +229,7 @@ Evas_Object *ctxpopup_img_preview_create(edit_data*ed, const char *imgpath, Evas
|
|||
void ctxpopup_img_preview_reload(Evas_Object *ctxpopup, const char *imgpath);
|
||||
|
||||
/* edc_editor */
|
||||
void edit_font_update(edit_data *ed);
|
||||
Eina_Bool edit_key_down_event_dispatch(edit_data *ed, const char *key);
|
||||
Eina_Bool edit_key_up_event_dispatch(edit_data *ed, const char *key);
|
||||
edit_data *edit_init(Enventor_Object *enventor);
|
||||
|
@ -244,8 +245,6 @@ void edit_new(edit_data* ed);
|
|||
void edit_view_sync_cb_set(edit_data *ed, void (*cb)(void *data, Eina_Stringshare *state_name, double state_value, Eina_Stringshare *part_name, Eina_Stringshare *group_name), void *data);
|
||||
void edit_view_sync(edit_data *ed);
|
||||
void edit_font_scale_set(edit_data *ed, double font_scale);
|
||||
void edit_font_set(edit_data *ed, const char *font_name, const char *font_style);
|
||||
void edit_font_get(edit_data *ed, const char **font_name, const char **font_style);
|
||||
void edit_line_delete(edit_data *ed);
|
||||
Eina_Stringshare *edit_cur_prog_name_get(edit_data *ed);
|
||||
Eina_Stringshare *edit_cur_part_name_get(edit_data *ed);
|
||||
|
|
|
@ -44,6 +44,8 @@ struct _Enventor_Object_Data
|
|||
Ecore_Event_Handler *key_up_handler;
|
||||
|
||||
double font_scale;
|
||||
Eina_Stringshare *font_name;
|
||||
Eina_Stringshare *font_style;
|
||||
|
||||
Eina_Bool dummy_parts : 1;
|
||||
Eina_Bool disabled : 1;
|
||||
|
@ -255,6 +257,8 @@ EOLIAN static void
|
|||
_enventor_object_evas_object_smart_del(Evas_Object *obj EINA_UNUSED,
|
||||
Enventor_Object_Data *pd)
|
||||
{
|
||||
eina_stringshare_del(pd->font_name);
|
||||
eina_stringshare_del(pd->font_style);
|
||||
eina_stringshare_del(pd->group_name);
|
||||
autocomp_term();
|
||||
ecore_event_handler_del(pd->key_down_handler);
|
||||
|
@ -717,18 +721,29 @@ EOLIAN static void
|
|||
_enventor_object_font_set(Eo *obj EINA_UNUSED, Enventor_Object_Data *pd,
|
||||
const char *font_name, const char *font_style)
|
||||
{
|
||||
//Main Item
|
||||
edit_font_set(pd->main_it.ed, font_name, font_style);
|
||||
if (!font_name) return;
|
||||
|
||||
//FIXME: store font_name, font_style...
|
||||
eina_stringshare_replace(&pd->font_name, font_name);
|
||||
eina_stringshare_replace(&pd->font_style, font_style);
|
||||
|
||||
char *font = NULL;
|
||||
if (font_name) font = elm_font_fontconfig_name_get(font_name, font_style);
|
||||
elm_config_font_overlay_set("enventor_entry", font, -100);
|
||||
elm_config_font_overlay_apply();
|
||||
elm_config_save();
|
||||
|
||||
elm_font_fontconfig_name_free(font);
|
||||
|
||||
//Main Item
|
||||
edit_font_update(pd->main_it.ed);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_enventor_object_font_get(Eo *obj EINA_UNUSED, Enventor_Object_Data *pd,
|
||||
const char **font_name, const char **font_style)
|
||||
{
|
||||
//FIXME: ...
|
||||
edit_font_get(pd->main_it.ed, font_name, font_style);
|
||||
if (font_name) *font_name = pd->font_name;
|
||||
if (font_style) *font_style = pd->font_style;
|
||||
}
|
||||
|
||||
//TODO: Itemize
|
||||
|
@ -940,8 +955,6 @@ enventor_object_main_file_set(Enventor_Object *obj, const char *file)
|
|||
edit_disabled_set(pd->main_it.ed, EINA_TRUE);
|
||||
|
||||
//FIXME: ...
|
||||
// edit_smart_undo_redo_set(pd->main_it.ed, smart_undo_redo);
|
||||
// edit_ctxpopup_enabled_set(pd->main_it.ed, ctxpopup);
|
||||
// edit_font_set(pd->main_it.ed, font_name, font_style);
|
||||
// edit_syntax_color_set(pd->main_it.ed, color_type, val);
|
||||
|
||||
|
|
Loading…
Reference in New Issue