#include <Elementary.h>
typedef struct
{
} App_Data;
typedef struct
{
int size;
int vsize;
int width, height;
const char *emo;
App_Data *ad;
} App_Inwin_Data;
static void
{
elm_entry_entry_insert(e, text);
}
static void
{
App_Inwin_Data *aid = data;
elm_naviframe_item_simple_promote(aid->naviframe, aid->settings);
}
static char *
{
return strdup(data);
}
_emo_content_get(
void *data,
Evas_Object *obj,
const char *part)
{
if (strcmp(part, "elm.swallow.icon"))
return NULL;
{
fprintf(stderr, "Failed to set layout");
return NULL;
}
return o;
}
static void
{
free(data);
}
_page_grid_add(
Evas_Object *parent, App_Inwin_Data *aid)
{
char *theme, *emo;
if (!theme) return NULL;
free(theme);
if (!emos) return NULL;
elm_gengrid_item_size_set(grid, 64, 80);
{
char name[512];
if (strncmp(emo, "elm/entry/emoticon/", 19))
continue;
sscanf(emo, "elm/entry/emoticon/%[^/]/default", name);
elm_gengrid_item_append(grid, it_class, strdup(name), _it_sel_cb, aid);
}
return grid;
}
static void
{
App_Inwin_Data *aid = data;
const char *size[] = {
"size",
"absize",
"relsize"
};
const char *vsize[] = {
"full",
"ascent"
};
char buf[512];
snprintf(buf, sizeof(buf), "<item %s=%dx%d vsize=%s href=emoticon/%s>"
"</item>", size[aid->size], aid->width, aid->height,
vsize[aid->vsize], aid->emo);
_edit_buffer_insert(aid->ad->edit_buffer, buf);
}
static void
{
App_Inwin_Data *aid = data;
aid->width = atoi(elm_object_text_get(obj));
}
static void
{
App_Inwin_Data *aid = data;
aid->height = atoi(elm_object_text_get(obj));
}
_page_settings_add(
Evas_Object *parent, App_Inwin_Data *aid)
{
Evas_Object *box, *sizeopts, *box2, *sizebox, *vsizebox,
*rsize, *rabsize, *rrelsize, *rvfull, *rvascent,
*fwidth, *ewidth, *fheight, *eheight,
*binsert;
char buf[100];
.rejected = NULL
};
.max_byte_count = 0
};
elm_object_text_set(sizeopts, "Size");
elm_box_pack_end(box, sizeopts);
elm_object_content_set(sizeopts, box2);
elm_box_pack_end(box2, sizebox);
elm_object_text_set(rsize, "Scale adjusted (size)");
elm_radio_state_value_set(rsize, 0);
elm_radio_value_pointer_set(rsize, &aid->size);
elm_box_pack_end(sizebox, rsize);
elm_object_text_set(rabsize, "Absolute size (absize)");
elm_radio_state_value_set(rabsize, 1);
elm_radio_value_pointer_set(rabsize, &aid->size);
elm_radio_group_add(rabsize, rsize);
elm_box_pack_end(sizebox, rabsize);
elm_object_text_set(rrelsize, "Relative to line (relsize)");
elm_radio_state_value_set(rrelsize, 2);
elm_radio_value_pointer_set(rrelsize, &aid->size);
elm_radio_group_add(rrelsize, rsize);
elm_box_pack_end(sizebox, rrelsize);
elm_box_pack_end(box2, vsizebox);
elm_object_text_set(rvfull, "Full height (vsize=full)");
elm_radio_state_value_set(rvfull, 0);
elm_radio_value_pointer_set(rvfull, &aid->vsize);
elm_box_pack_end(vsizebox, rvfull);
elm_object_text_set(rvascent, "Ascent only (vsize=ascent)");
elm_radio_state_value_set(rvascent, 1);
elm_radio_value_pointer_set(rvascent, &aid->vsize);
elm_radio_group_add(rvascent, rvfull);
elm_box_pack_end(vsizebox, rvascent);
elm_object_text_set(fwidth, "Width");
elm_box_pack_end(box2, fwidth);
snprintf(buf, sizeof(buf), "%d", aid->width);
elm_entry_single_line_set(ewidth,
EINA_TRUE);
&accept_set);
&limit_size);
elm_object_text_set(ewidth, buf);
elm_object_content_set(fwidth, ewidth);
elm_object_text_set(fheight, "Height");
elm_box_pack_end(box2, fheight);
snprintf(buf, sizeof(buf), "%d", aid->height);
elm_entry_single_line_set(eheight,
EINA_TRUE);
&accept_set);
&limit_size);
elm_object_text_set(eheight, buf);
elm_object_content_set(fheight, eheight);
elm_object_text_set(binsert, "Insert");
elm_box_pack_end(box, binsert);
return box;
}
static void
{
App_Inwin_Data *aid = data;
}
static void
{
free(data);
}
static void
{
App_Data *ad = data;
App_Inwin_Data *aid;
aid = calloc(1, sizeof(App_Inwin_Data));
if (!aid) return;
aid->ad = ad;
aid->size = 1;
aid->vsize = 1;
aid->width = 64;
aid->height = 64;
aid);
elm_box_pack_end(box, naviframe);
o = _page_grid_add(ad->win, aid);
elm_naviframe_item_simple_push(naviframe, o);
aid->grid = o;
o = _page_settings_add(ad->win, aid);
elm_naviframe_item_simple_push(naviframe, o);
aid->settings = o;
elm_naviframe_item_simple_promote(naviframe, aid->grid);
elm_box_pack_end(box, box2);
elm_object_text_set(o, "Cancel");
elm_box_pack_end(box2, o);
aid->inwin = inwin;
aid->naviframe = naviframe;
}
static void
{
App_Data *ad = data;
char fmt_open[5], fmt_close[6];
const char *sel;
int cursor;
char *s;
const char *ptr, *what;
sel = elm_object_text_get(obj);
snprintf(fmt_open, sizeof(fmt_open), "<%s>", sel);
snprintf(fmt_close, sizeof(fmt_close), "</%s>", sel);
cursor = elm_entry_cursor_pos_get(ad->edit_buffer);
elm_entry_cursor_begin_set(ad->edit_buffer);
elm_entry_cursor_selection_begin(ad->edit_buffer);
elm_entry_cursor_pos_set(ad->edit_buffer, cursor);
elm_entry_cursor_selection_end(ad->edit_buffer);
sel = elm_entry_selection_get(ad->edit_buffer);
if (!sel || !sel[0])
{
goto all_done;
}
what = fmt_open;
ptr = sel;
while ((s = strstr(ptr, what)))
{
ptr = s + strlen(what);
if (what == fmt_open) what = fmt_close;
else what = fmt_open;
}
if (what == fmt_close)
{
elm_entry_cursor_selection_begin(ad->edit_buffer);
elm_entry_cursor_end_set(ad->edit_buffer);
elm_entry_cursor_selection_end(ad->edit_buffer);
sel = elm_entry_selection_get(ad->edit_buffer);
if (sel)
{
elm_entry_entry_insert(ad->edit_buffer,
}
}
elm_entry_select_none(ad->edit_buffer);
elm_entry_cursor_pos_set(ad->edit_buffer, cursor);
all_done:
}
static void
{
App_Data *ad = data;
elm_entry_autosave_set(ad->edit_buffer, state);
if (state) elm_entry_file_save(ad->edit_buffer);
}
static void
{
int current_cursor;
current_cursor = elm_entry_cursor_pos_get(obj);
while (elm_entry_cursor_prev(obj))
{
const char *content;
if (elm_entry_cursor_is_visible_format_get(obj))
break;
content = elm_entry_cursor_content_get(obj);
if (content && (content[0] == ' '))
break;
}
if (current_cursor == elm_entry_cursor_pos_get(obj))
return;
elm_entry_cursor_next(obj);
elm_entry_cursor_selection_begin(obj);
elm_entry_cursor_pos_set(obj, current_cursor);
while (elm_entry_cursor_next(obj))
{
const char *content;
if (elm_entry_cursor_is_visible_format_get(obj))
break;
content = elm_entry_cursor_content_get(obj);
if (content && (content[0] == ' '))
break;
}
elm_entry_cursor_selection_end(obj);
}
static void
{
elm_entry_cursor_line_begin_set(obj);
elm_entry_cursor_selection_begin(obj);
elm_entry_cursor_line_end_set(obj);
elm_entry_cursor_selection_end(obj);
}
EAPI_MAIN int
{
App_Data app;
memset(&app, 0, sizeof(app));
elm_box_pack_end(box, tb);
elm_object_text_set(o, "Autosave");
elm_box_pack_end(tb, o);
elm_object_text_set(o, "b");
elm_box_pack_end(tb, o);
elm_object_text_set(o, "em");
elm_box_pack_end(tb, o);
elm_box_pack_end(tb, o);
icon, "entry", "emoticon/haha", "default"))
fprintf(stderr, "Failed to set layout");
elm_box_pack_end(box, en);
app.win = win;
app.edit_buffer = en;
NULL);
NULL);
evas_object_resize(win, 300, 780);
return 0;
}