2012-06-17 10:04:17 -07:00
|
|
|
#include "private.h"
|
2012-06-19 00:19:31 -07:00
|
|
|
#include <Ecore_IMF.h>
|
|
|
|
#include <Ecore_IMF_Evas.h>
|
2012-06-12 03:10:01 -07:00
|
|
|
#include <Elementary.h>
|
2012-06-28 01:21:51 -07:00
|
|
|
#include <Ecore_Input.h>
|
2012-06-12 03:10:01 -07:00
|
|
|
#include "termio.h"
|
2012-07-13 02:12:01 -07:00
|
|
|
#include "termiolink.h"
|
2012-06-12 03:10:01 -07:00
|
|
|
#include "termpty.h"
|
2012-09-07 17:26:09 -07:00
|
|
|
#include "termcmd.h"
|
2012-06-12 03:10:01 -07:00
|
|
|
#include "utf8.h"
|
|
|
|
#include "col.h"
|
|
|
|
#include "keyin.h"
|
|
|
|
#include "config.h"
|
2012-06-19 08:59:49 -07:00
|
|
|
#include "utils.h"
|
2012-07-04 07:44:43 -07:00
|
|
|
#include "media.h"
|
2012-06-12 03:10:01 -07:00
|
|
|
|
|
|
|
typedef struct _Termio Termio;
|
|
|
|
|
|
|
|
struct _Termio
|
|
|
|
{
|
|
|
|
Evas_Object_Smart_Clipped_Data __clipped_data;
|
|
|
|
struct {
|
|
|
|
int size;
|
|
|
|
const char *name;
|
|
|
|
int chw, chh;
|
|
|
|
} font;
|
|
|
|
struct {
|
|
|
|
int w, h;
|
2012-06-15 22:07:33 -07:00
|
|
|
Evas_Object *obj;
|
2012-06-12 03:10:01 -07:00
|
|
|
} grid;
|
|
|
|
struct {
|
2012-07-11 05:09:00 -07:00
|
|
|
Evas_Object *obj, *selo_top, *selo_bottom, *selo_theme;
|
2012-06-12 03:10:01 -07:00
|
|
|
int x, y;
|
|
|
|
struct {
|
|
|
|
int x, y;
|
|
|
|
} sel1, sel2;
|
|
|
|
Eina_Bool sel : 1;
|
|
|
|
Eina_Bool makesel : 1;
|
|
|
|
} cur;
|
2012-07-03 08:25:19 -07:00
|
|
|
struct {
|
|
|
|
int cx, cy;
|
2012-10-04 16:19:17 -07:00
|
|
|
int button;
|
2012-07-03 08:25:19 -07:00
|
|
|
} mouse;
|
2012-06-18 01:56:27 -07:00
|
|
|
struct {
|
|
|
|
struct {
|
|
|
|
int x, y;
|
|
|
|
} sel1, sel2;
|
|
|
|
Eina_Bool sel : 1;
|
|
|
|
} backup;
|
2012-07-04 07:44:43 -07:00
|
|
|
struct {
|
|
|
|
char *string;
|
|
|
|
int x1, y1, x2, y2;
|
|
|
|
int suspend;
|
|
|
|
Eina_List *objs;
|
2013-02-21 05:23:48 -08:00
|
|
|
struct {
|
|
|
|
Evas_Coord x, y;
|
|
|
|
Eina_Bool down : 1;
|
|
|
|
Eina_Bool dnd : 1;
|
|
|
|
} down;
|
2012-07-04 07:44:43 -07:00
|
|
|
} link;
|
2012-07-01 20:47:02 -07:00
|
|
|
int zoom_fontsize_start;
|
2012-06-12 03:10:01 -07:00
|
|
|
int scroll;
|
2012-06-22 23:43:02 -07:00
|
|
|
unsigned int last_keyup;
|
2012-06-28 01:21:51 -07:00
|
|
|
Eina_List *seq;
|
2012-06-12 03:10:01 -07:00
|
|
|
Evas_Object *event;
|
|
|
|
Termpty *pty;
|
2012-06-18 05:14:36 -07:00
|
|
|
Ecore_Animator *anim;
|
2012-06-12 03:10:01 -07:00
|
|
|
Ecore_Timer *delayed_size_timer;
|
2012-07-04 07:44:43 -07:00
|
|
|
Ecore_Timer *link_do_timer;
|
2012-07-03 08:25:19 -07:00
|
|
|
Ecore_Job *mouse_move_job;
|
2013-01-30 21:23:25 -08:00
|
|
|
Ecore_Timer *mouseover_delay;
|
2013-01-22 07:01:53 -08:00
|
|
|
Evas_Object *win, *theme, *glayer;
|
2012-06-17 13:24:23 -07:00
|
|
|
Config *config;
|
2012-06-18 17:37:27 -07:00
|
|
|
Ecore_IMF_Context *imf;
|
2012-06-12 03:10:01 -07:00
|
|
|
Eina_Bool jump_on_change : 1;
|
2012-07-04 21:36:47 -07:00
|
|
|
Eina_Bool jump_on_keypress : 1;
|
2012-06-25 04:17:03 -07:00
|
|
|
Eina_Bool have_sel : 1;
|
2012-06-26 03:30:41 -07:00
|
|
|
Eina_Bool noreqsize : 1;
|
2012-06-26 20:26:34 -07:00
|
|
|
Eina_Bool composing : 1;
|
2012-07-04 07:44:43 -07:00
|
|
|
Eina_Bool didclick : 1;
|
2012-07-18 01:36:28 -07:00
|
|
|
Eina_Bool bottom_right : 1;
|
|
|
|
Eina_Bool top_left : 1;
|
2013-02-14 13:44:16 -08:00
|
|
|
Eina_Bool boxsel : 1;
|
2012-06-12 03:10:01 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static Evas_Smart *_smart = NULL;
|
2012-06-17 13:24:23 -07:00
|
|
|
static Evas_Smart_Class _parent_sc = EVAS_SMART_CLASS_INIT_NULL;
|
2012-06-12 03:10:01 -07:00
|
|
|
|
|
|
|
static void _smart_calculate(Evas_Object *obj);
|
|
|
|
|
2012-08-23 08:47:24 -07:00
|
|
|
static inline Eina_Bool
|
|
|
|
_should_inline(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
const Config *config = termio_config_get(obj);
|
|
|
|
const Evas *e;
|
|
|
|
const Evas_Modifier *mods;
|
|
|
|
|
|
|
|
if (!config->helper.inline_please) return EINA_FALSE;
|
|
|
|
|
|
|
|
e = evas_object_evas_get(obj);
|
|
|
|
mods = evas_key_modifier_get(e);
|
|
|
|
|
|
|
|
if (evas_key_modifier_is_set(mods, "Control")) return EINA_FALSE;
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2012-07-04 07:44:43 -07:00
|
|
|
static void
|
|
|
|
_activate_link(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
Config *config = termio_config_get(obj);
|
|
|
|
char buf[PATH_MAX], *s;
|
|
|
|
const char *path = NULL, *cmd = NULL;
|
|
|
|
Eina_Bool url = EINA_FALSE, email = EINA_FALSE, handled = EINA_FALSE;
|
|
|
|
int type;
|
|
|
|
|
|
|
|
if (!sd) return;
|
|
|
|
if (!config) return;
|
|
|
|
if (!sd->link.string) return;
|
2012-08-08 06:15:54 -07:00
|
|
|
if (link_is_url(sd->link.string))
|
2012-07-04 07:44:43 -07:00
|
|
|
{
|
2012-10-09 09:16:19 -07:00
|
|
|
if (casestartswith(sd->link.string, "file://"))
|
2012-10-09 08:11:09 -07:00
|
|
|
// TODO: decode string: %XX -> char
|
|
|
|
path = sd->link.string + sizeof("file://") - 1;
|
|
|
|
else
|
|
|
|
url = EINA_TRUE;
|
2012-10-09 07:50:01 -07:00
|
|
|
}
|
2012-10-09 08:11:09 -07:00
|
|
|
else if (sd->link.string[0] == '/')
|
|
|
|
path = sd->link.string;
|
|
|
|
else if (link_is_email(sd->link.string))
|
|
|
|
email = EINA_TRUE;
|
2012-10-09 07:50:01 -07:00
|
|
|
|
2012-10-09 09:16:19 -07:00
|
|
|
if (url && casestartswith(sd->link.string, "mailto:"))
|
|
|
|
{
|
|
|
|
email = EINA_TRUE;
|
|
|
|
url = EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2012-07-04 07:44:43 -07:00
|
|
|
s = eina_str_escape(sd->link.string);
|
|
|
|
if (!s) return;
|
|
|
|
if (email)
|
|
|
|
{
|
2012-10-09 09:16:19 -07:00
|
|
|
const char *p = s;
|
|
|
|
|
2012-07-04 07:44:43 -07:00
|
|
|
// run mail client
|
|
|
|
cmd = "xdg-email";
|
|
|
|
|
|
|
|
if ((config->helper.email) &&
|
|
|
|
(config->helper.email[0]))
|
|
|
|
cmd = config->helper.email;
|
2012-10-09 09:16:19 -07:00
|
|
|
|
|
|
|
if (casestartswith(s, "mailto:"))
|
|
|
|
p += sizeof("mailto:") - 1;
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%s %s", cmd, p);
|
2012-07-04 07:44:43 -07:00
|
|
|
}
|
|
|
|
else if (path)
|
|
|
|
{
|
|
|
|
// locally accessible file
|
|
|
|
cmd = "xdg-open";
|
|
|
|
|
|
|
|
type = media_src_type_get(sd->link.string);
|
2012-08-23 08:47:24 -07:00
|
|
|
if (_should_inline(obj))
|
2012-07-04 07:44:43 -07:00
|
|
|
{
|
|
|
|
if ((type == TYPE_IMG) ||
|
|
|
|
(type == TYPE_SCALE) ||
|
|
|
|
(type == TYPE_EDJE))
|
|
|
|
{
|
|
|
|
evas_object_smart_callback_call(obj, "popup", NULL);
|
|
|
|
handled = EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (type == TYPE_MOV)
|
|
|
|
{
|
|
|
|
evas_object_smart_callback_call(obj, "popup", NULL);
|
|
|
|
handled = EINA_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!handled)
|
|
|
|
{
|
|
|
|
if ((type == TYPE_IMG) ||
|
|
|
|
(type == TYPE_SCALE) ||
|
|
|
|
(type == TYPE_EDJE))
|
|
|
|
{
|
|
|
|
if ((config->helper.local.image) &&
|
|
|
|
(config->helper.local.image[0]))
|
|
|
|
cmd = config->helper.local.image;
|
|
|
|
}
|
|
|
|
else if (type == TYPE_MOV)
|
|
|
|
{
|
|
|
|
if ((config->helper.local.video) &&
|
|
|
|
(config->helper.local.video[0]))
|
|
|
|
cmd = config->helper.local.video;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((config->helper.local.general) &&
|
|
|
|
(config->helper.local.general[0]))
|
|
|
|
cmd = config->helper.local.general;
|
|
|
|
}
|
|
|
|
snprintf(buf, sizeof(buf), "%s %s", cmd, s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (url)
|
|
|
|
{
|
|
|
|
// remote file needs ecore-con-url
|
|
|
|
cmd = "xdg-open";
|
|
|
|
|
|
|
|
type = media_src_type_get(sd->link.string);
|
2012-08-23 08:47:24 -07:00
|
|
|
if (_should_inline(obj))
|
2012-07-04 07:44:43 -07:00
|
|
|
{
|
|
|
|
if ((type == TYPE_IMG) ||
|
|
|
|
(type == TYPE_SCALE) ||
|
|
|
|
(type == TYPE_EDJE))
|
|
|
|
{
|
|
|
|
// XXX: begin fetch of url, once done, show
|
|
|
|
evas_object_smart_callback_call(obj, "popup", NULL);
|
|
|
|
handled = EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (type == TYPE_MOV)
|
|
|
|
{
|
|
|
|
// XXX: if no http:// add
|
|
|
|
evas_object_smart_callback_call(obj, "popup", NULL);
|
|
|
|
handled = EINA_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!handled)
|
|
|
|
{
|
|
|
|
if ((type == TYPE_IMG) ||
|
|
|
|
(type == TYPE_SCALE) ||
|
|
|
|
(type == TYPE_EDJE))
|
2012-07-03 08:25:19 -07:00
|
|
|
{
|
2012-07-04 07:44:43 -07:00
|
|
|
if ((config->helper.url.image) &&
|
|
|
|
(config->helper.url.image[0]))
|
|
|
|
cmd = config->helper.url.image;
|
2012-07-03 08:25:19 -07:00
|
|
|
}
|
2012-07-04 07:44:43 -07:00
|
|
|
else if (type == TYPE_MOV)
|
|
|
|
{
|
|
|
|
if ((config->helper.url.video) &&
|
|
|
|
(config->helper.url.video[0]))
|
|
|
|
cmd = config->helper.url.video;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((config->helper.url.general) &&
|
|
|
|
(config->helper.url.general[0]))
|
|
|
|
cmd = config->helper.url.general;
|
|
|
|
}
|
|
|
|
snprintf(buf, sizeof(buf), "%s %s", cmd, s);
|
2012-07-03 08:25:19 -07:00
|
|
|
}
|
2012-07-04 07:44:43 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-07-03 08:25:19 -07:00
|
|
|
free(s);
|
2012-07-04 07:44:43 -07:00
|
|
|
return;
|
2012-07-03 08:25:19 -07:00
|
|
|
}
|
2012-07-04 07:44:43 -07:00
|
|
|
free(s);
|
|
|
|
if (!handled) ecore_exe_run(buf, NULL);
|
|
|
|
}
|
|
|
|
|
2013-02-21 05:23:48 -08:00
|
|
|
static void
|
|
|
|
_cb_link_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event)
|
|
|
|
{
|
|
|
|
Evas_Event_Mouse_Down *ev = event;
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return;
|
|
|
|
|
|
|
|
if (ev->button != 1) return;
|
|
|
|
sd->link.down.down = EINA_TRUE;
|
|
|
|
sd->link.down.x = ev->canvas.x;
|
|
|
|
sd->link.down.y = ev->canvas.y;
|
|
|
|
}
|
|
|
|
|
2012-07-04 07:44:43 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_cb_link_up_delay(void *data)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return EINA_FALSE;
|
2013-02-21 05:23:48 -08:00
|
|
|
|
2012-07-04 07:44:43 -07:00
|
|
|
sd->link_do_timer = NULL;
|
|
|
|
if (!sd->didclick) _activate_link(data);
|
|
|
|
sd->didclick = EINA_FALSE;
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_cb_link_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event)
|
|
|
|
{
|
|
|
|
Evas_Event_Mouse_Up *ev = event;
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
2013-02-21 05:23:48 -08:00
|
|
|
Evas_Coord dx, dy;
|
2012-07-04 07:44:43 -07:00
|
|
|
|
|
|
|
if (!sd) return;
|
2013-02-21 05:23:48 -08:00
|
|
|
dx = abs(ev->canvas.x - sd->link.down.x);
|
|
|
|
dy = abs(ev->canvas.y - sd->link.down.y);
|
|
|
|
if ((ev->button == 1) && (sd->link.down.down) &&
|
|
|
|
((dx <= elm_config_finger_size_get()) &&
|
|
|
|
(dy <= elm_config_finger_size_get())))
|
2012-07-04 07:44:43 -07:00
|
|
|
{
|
|
|
|
if (sd->link_do_timer) ecore_timer_del(sd->link_do_timer);
|
|
|
|
sd->link_do_timer = ecore_timer_add(0.2, _cb_link_up_delay, data);
|
|
|
|
}
|
2013-02-21 05:23:48 -08:00
|
|
|
if ((ev->button == 1) && (sd->link.down.down))
|
|
|
|
{
|
|
|
|
sd->link.down.down = EINA_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if (ECORE_VERSION_MAJOR > 1) || (ECORE_VERSION_MINOR >= 8)
|
|
|
|
static void
|
|
|
|
_cb_link_drag_done(void *data, Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return;
|
|
|
|
|
|
|
|
printf("dnd done\n");
|
|
|
|
sd->link.down.dnd = EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
|
|
|
_cb_link_icon_new(void *data, Evas_Object *par, Evas_Coord *xoff, Evas_Coord *yoff)
|
|
|
|
{
|
|
|
|
Evas_Object *icon;
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return NULL;
|
|
|
|
|
|
|
|
icon = elm_button_add(par);
|
|
|
|
elm_object_text_set(icon, sd->link.string);
|
|
|
|
*xoff = 0;
|
|
|
|
*yoff = 0;
|
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void
|
|
|
|
_cb_link_move(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event)
|
|
|
|
{
|
|
|
|
Evas_Event_Mouse_Move *ev = event;
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
Evas_Coord dx, dy;
|
|
|
|
if (!sd) return;
|
|
|
|
|
|
|
|
if (!sd->link.down.down) return;
|
|
|
|
dx = abs(ev->cur.canvas.x - sd->link.down.x);
|
|
|
|
dy = abs(ev->cur.canvas.y - sd->link.down.y);
|
|
|
|
if ((sd->link.string) &&
|
|
|
|
((dx > elm_config_finger_size_get()) ||
|
|
|
|
(dy > elm_config_finger_size_get())))
|
|
|
|
{
|
|
|
|
sd->link.down.down = EINA_FALSE;
|
|
|
|
sd->link.down.dnd = EINA_TRUE;
|
|
|
|
#if (ECORE_VERSION_MAJOR > 1) || (ECORE_VERSION_MINOR >= 8)
|
|
|
|
printf("dnd start %s\n", sd->link.string);
|
|
|
|
elm_drag_start(obj, ELM_SEL_FORMAT_IMAGE,
|
|
|
|
sd->link.string,
|
|
|
|
_cb_link_icon_new, data,
|
|
|
|
_cb_link_drag_done, data);
|
|
|
|
#endif
|
|
|
|
}
|
2012-07-04 07:44:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_update_link(Evas_Object *obj, Eina_Bool same_link, Eina_Bool same_geom)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
|
|
|
|
if (!sd) return;
|
|
|
|
|
|
|
|
if (!same_link)
|
|
|
|
{
|
|
|
|
// check link and re-probe/fetch create popup preview
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!same_geom)
|
|
|
|
{
|
|
|
|
Evas_Coord ox, oy, ow, oh;
|
|
|
|
Evas_Object *o;
|
|
|
|
// fix up edje objects "underlining" the link
|
|
|
|
int y;
|
|
|
|
|
|
|
|
evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
|
|
|
|
EINA_LIST_FREE(sd->link.objs, o) evas_object_del(o);
|
|
|
|
if ((sd->link.string) && (sd->link.suspend == 0))
|
|
|
|
{
|
|
|
|
for (y = sd->link.y1; y <= sd->link.y2; y++)
|
|
|
|
{
|
|
|
|
o = edje_object_add(evas_object_evas_get(obj));
|
|
|
|
evas_object_smart_member_add(o, obj);
|
|
|
|
theme_apply(o, sd->config, "terminology/link");
|
|
|
|
|
|
|
|
if (y == sd->link.y1)
|
|
|
|
{
|
|
|
|
evas_object_move(o, ox + (sd->link.x1 * sd->font.chw),
|
|
|
|
oy + (y * sd->font.chh));
|
|
|
|
if (sd->link.y1 == sd->link.y2)
|
|
|
|
evas_object_resize(o,
|
|
|
|
((sd->link.x2 - sd->link.x1 + 1) * sd->font.chw),
|
|
|
|
sd->font.chh);
|
|
|
|
else
|
|
|
|
evas_object_resize(o,
|
|
|
|
((sd->grid.w - sd->link.x1) * sd->font.chw),
|
|
|
|
sd->font.chh);
|
|
|
|
}
|
|
|
|
else if (y == sd->link.y2)
|
|
|
|
{
|
|
|
|
evas_object_move(o, ox, oy + (y * sd->font.chh));
|
|
|
|
evas_object_resize(o,
|
|
|
|
((sd->link.x2 + 1) * sd->font.chw),
|
|
|
|
sd->font.chh);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
evas_object_move(o, ox, oy + (y * sd->font.chh));
|
|
|
|
evas_object_resize(o, (sd->grid.w * sd->font.chw),
|
|
|
|
sd->font.chh);
|
|
|
|
}
|
|
|
|
|
|
|
|
sd->link.objs = eina_list_append(sd->link.objs, o);
|
|
|
|
evas_object_show(o);
|
2013-02-21 05:23:48 -08:00
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
|
|
|
|
_cb_link_down, obj);
|
2012-07-04 07:44:43 -07:00
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP,
|
|
|
|
_cb_link_up, obj);
|
2013-02-21 05:23:48 -08:00
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_MOVE,
|
|
|
|
_cb_link_move, obj);
|
2012-07-04 07:44:43 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_smart_mouseover_apply(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
char *s;
|
|
|
|
int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
|
|
|
|
Eina_Bool same_link = EINA_FALSE, same_geom = EINA_FALSE;
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
|
|
|
|
if (!sd) return;
|
|
|
|
|
2012-07-13 02:12:01 -07:00
|
|
|
s = _termio_link_find(obj, sd->mouse.cx, sd->mouse.cy,
|
2012-07-04 07:44:43 -07:00
|
|
|
&x1, &y1, &x2, &y2);
|
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
if (sd->link.string) free(sd->link.string);
|
|
|
|
sd->link.string = NULL;
|
|
|
|
sd->link.x1 = -1;
|
|
|
|
sd->link.y1 = -1;
|
|
|
|
sd->link.x2 = -1;
|
|
|
|
sd->link.y2 = -1;
|
|
|
|
_update_link(obj, same_link, same_geom);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((sd->link.string) && (!strcmp(sd->link.string, s)))
|
|
|
|
same_link = EINA_TRUE;
|
|
|
|
if (sd->link.string) free(sd->link.string);
|
|
|
|
sd->link.string = s;
|
|
|
|
if ((x1 == sd->link.x1) && (y1 == sd->link.y1) &&
|
|
|
|
(x2 == sd->link.x2) && (y2 == sd->link.y2))
|
|
|
|
same_geom = EINA_TRUE;
|
|
|
|
if (((sd->link.suspend != 0) && (sd->link.objs)) ||
|
|
|
|
((sd->link.suspend == 0) && (!sd->link.objs)))
|
|
|
|
same_geom = EINA_FALSE;
|
|
|
|
sd->link.x1 = x1;
|
|
|
|
sd->link.y1 = y1;
|
|
|
|
sd->link.x2 = x2;
|
|
|
|
sd->link.y2 = y2;
|
|
|
|
_update_link(obj, same_link, same_geom);
|
2012-07-03 08:25:19 -07:00
|
|
|
}
|
|
|
|
|
2013-01-30 21:23:25 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_smart_mouseover_delay(void *data)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
|
|
|
|
if (!sd) return EINA_FALSE;
|
|
|
|
sd->mouseover_delay = NULL;
|
|
|
|
_smart_mouseover_apply(data);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2013-02-14 13:44:16 -08:00
|
|
|
#define INT_SWAP(_a, _b) do { \
|
|
|
|
int _swap = _a; _a = _b; _b = _swap; \
|
|
|
|
} while (0)
|
|
|
|
|
2013-02-18 07:31:54 -08:00
|
|
|
static void
|
|
|
|
_smart_media_clicked(void *data, Evas_Object *obj, void *info __UNUSED__)
|
|
|
|
{
|
|
|
|
// Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
const char *file = media_get(obj);
|
|
|
|
if (!file) return;
|
|
|
|
evas_object_smart_callback_call(data, "popup", (void *)file);
|
|
|
|
}
|
2013-02-14 13:44:16 -08:00
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
static void
|
|
|
|
_smart_apply(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
Evas_Coord ox, oy, ow, oh;
|
2013-01-28 08:06:26 -08:00
|
|
|
Eina_List *l, *ln;
|
|
|
|
Termblock *blk;
|
2012-06-22 23:43:02 -07:00
|
|
|
int j, x, y, w, ch1 = 0, ch2 = 0, inv = 0;
|
2012-06-15 22:07:33 -07:00
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
if (!sd) return;
|
|
|
|
evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
|
2013-01-28 08:06:26 -08:00
|
|
|
|
|
|
|
EINA_LIST_FOREACH(sd->pty->block.active, l, blk)
|
|
|
|
{
|
|
|
|
blk->was_active = blk->active;
|
|
|
|
blk->active = EINA_FALSE;
|
|
|
|
}
|
2012-06-22 23:43:02 -07:00
|
|
|
inv = sd->pty->state.reverse;
|
2012-06-15 22:07:33 -07:00
|
|
|
for (y = 0; y < sd->grid.h; y++)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2012-06-15 22:07:33 -07:00
|
|
|
Termcell *cells;
|
|
|
|
Evas_Textgrid_Cell *tc;
|
|
|
|
|
|
|
|
w = 0; j = 0;
|
|
|
|
cells = termpty_cellrow_get(sd->pty, y - sd->scroll, &w);
|
|
|
|
tc = evas_object_textgrid_cellrow_get(sd->grid.obj, y);
|
2012-06-15 22:27:03 -07:00
|
|
|
if (!tc) continue;
|
2012-06-15 22:07:33 -07:00
|
|
|
ch1 = -1;
|
|
|
|
for (x = 0; x < sd->grid.w; x++)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2012-06-15 22:07:33 -07:00
|
|
|
if ((!cells) || (x >= w))
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2012-06-15 22:07:33 -07:00
|
|
|
if ((tc[x].codepoint != 0) ||
|
|
|
|
(tc[x].bg != COL_INVIS) ||
|
|
|
|
(tc[x].bg_extended))
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2012-06-15 22:07:33 -07:00
|
|
|
if (ch1 < 0) ch1 = x;
|
|
|
|
ch2 = x;
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
2012-06-15 22:07:33 -07:00
|
|
|
tc[x].codepoint = 0;
|
2012-06-22 23:43:02 -07:00
|
|
|
if (inv) tc[x].bg = COL_INVERSEBG;
|
|
|
|
else tc[x].bg = COL_INVIS;
|
2012-06-15 22:07:33 -07:00
|
|
|
tc[x].bg_extended = 0;
|
2012-11-20 13:18:42 -08:00
|
|
|
#if defined(SUPPORT_DBLWIDTH)
|
2012-06-25 18:38:13 -07:00
|
|
|
tc[x].double_width = cells[j].att.dblwidth;
|
2012-11-20 13:18:42 -08:00
|
|
|
#endif
|
2012-06-25 18:38:13 -07:00
|
|
|
if ((tc[x].double_width) && (tc[x].codepoint == 0) &&
|
|
|
|
(ch2 == x - 1))
|
|
|
|
ch2 = x;
|
2012-06-15 22:07:33 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-01-28 08:06:26 -08:00
|
|
|
int bid, bx = 0, by = 0;
|
|
|
|
|
|
|
|
bid = termpty_block_id_get(&(cells[j]), &bx, &by);
|
|
|
|
if (bid >= 0)
|
|
|
|
{
|
|
|
|
if (ch1 < 0) ch1 = x;
|
|
|
|
ch2 = x;
|
|
|
|
tc[x].codepoint = 0;
|
|
|
|
tc[x].fg_extended = 0;
|
|
|
|
tc[x].bg_extended = 0;
|
|
|
|
tc[x].underline = 0;
|
|
|
|
tc[x].strikethrough = 0;
|
|
|
|
tc[x].fg = COL_INVIS;
|
|
|
|
tc[x].bg = COL_INVIS;
|
|
|
|
#if defined(SUPPORT_DBLWIDTH)
|
|
|
|
tc[x].double_width = 0;
|
|
|
|
#endif
|
|
|
|
blk = termpty_block_get(sd->pty, bid);
|
|
|
|
if (blk)
|
|
|
|
{
|
|
|
|
if (!blk->active)
|
|
|
|
{
|
|
|
|
blk->active = EINA_TRUE;
|
|
|
|
if (!blk->obj)
|
|
|
|
{
|
|
|
|
int type = 0;
|
|
|
|
int media = MEDIA_STRETCH;
|
|
|
|
|
|
|
|
if (blk->scale_stretch)
|
|
|
|
media = MEDIA_STRETCH;
|
|
|
|
else if (blk->scale_center)
|
|
|
|
media = MEDIA_POP;
|
|
|
|
else if (blk->scale_fill)
|
|
|
|
media = MEDIA_BG;
|
2013-02-01 06:10:51 -08:00
|
|
|
else if (blk->thumb)
|
|
|
|
media = MEDIA_THUMB;
|
|
|
|
// media = MEDIA_POP;
|
2013-01-28 08:06:26 -08:00
|
|
|
if (!blk->was_active_before)
|
|
|
|
media |= MEDIA_SAVE;
|
|
|
|
else
|
|
|
|
media |= MEDIA_RECOVER | MEDIA_SAVE;
|
|
|
|
blk->obj = media_add(obj, blk->path,
|
|
|
|
sd->config,
|
|
|
|
media, &type);
|
|
|
|
blk->type = type;
|
|
|
|
evas_object_smart_member_add(blk->obj, obj);
|
|
|
|
evas_object_stack_above(blk->obj, sd->grid.obj);
|
|
|
|
evas_object_show(blk->obj);
|
2013-02-18 07:31:54 -08:00
|
|
|
if (blk->thumb)
|
|
|
|
evas_object_smart_callback_add
|
|
|
|
(blk->obj, "clicked",
|
|
|
|
_smart_media_clicked, obj);
|
2013-01-28 08:06:26 -08:00
|
|
|
}
|
|
|
|
blk->was_active_before = EINA_TRUE;
|
|
|
|
if (!blk->was_active)
|
|
|
|
sd->pty->block.active = eina_list_append(sd->pty->block.active, blk);
|
|
|
|
}
|
|
|
|
blk->x = (x - bx);
|
|
|
|
blk->y = (y - by);
|
|
|
|
evas_object_move(blk->obj,
|
|
|
|
ox + (blk->x * sd->font.chw),
|
|
|
|
oy + (blk->y * sd->font.chh));
|
|
|
|
evas_object_resize(blk->obj,
|
|
|
|
blk->w * sd->font.chw,
|
|
|
|
blk->h * sd->font.chh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (cells[j].att.invisible)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2012-06-15 22:07:33 -07:00
|
|
|
if ((tc[x].codepoint != 0) ||
|
|
|
|
(tc[x].bg != COL_INVIS) ||
|
|
|
|
(tc[x].bg_extended))
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2012-06-15 22:07:33 -07:00
|
|
|
if (ch1 < 0) ch1 = x;
|
|
|
|
ch2 = x;
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
2012-06-15 22:07:33 -07:00
|
|
|
tc[x].codepoint = 0;
|
2012-06-22 23:43:02 -07:00
|
|
|
if (inv) tc[x].bg = COL_INVERSEBG;
|
|
|
|
else tc[x].bg = COL_INVIS;
|
2012-06-15 22:07:33 -07:00
|
|
|
tc[x].bg_extended = 0;
|
2012-11-20 13:18:42 -08:00
|
|
|
#if defined(SUPPORT_DBLWIDTH)
|
2012-06-25 18:38:13 -07:00
|
|
|
tc[x].double_width = cells[j].att.dblwidth;
|
2012-11-20 13:18:42 -08:00
|
|
|
#endif
|
2012-06-25 18:38:13 -07:00
|
|
|
if ((tc[x].double_width) && (tc[x].codepoint == 0) &&
|
|
|
|
(ch2 == x - 1))
|
|
|
|
ch2 = x;
|
2012-06-15 22:07:33 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-06-25 18:38:13 -07:00
|
|
|
int bold, fg, bg, fgext, bgext, codepoint;
|
2012-06-15 22:07:33 -07:00
|
|
|
|
|
|
|
// colors
|
|
|
|
bold = cells[j].att.bold;
|
|
|
|
fgext = cells[j].att.fg256;
|
|
|
|
bgext = cells[j].att.bg256;
|
2012-06-25 18:38:13 -07:00
|
|
|
codepoint = cells[j].codepoint;
|
2012-06-15 22:07:33 -07:00
|
|
|
|
2012-06-22 23:43:02 -07:00
|
|
|
if (cells[j].att.inverse ^ inv)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2012-06-15 22:07:33 -07:00
|
|
|
fgext = 0;
|
|
|
|
bgext = 0;
|
2012-06-18 06:59:09 -07:00
|
|
|
fg = cells[j].att.fg;
|
|
|
|
bg = cells[j].att.bg;
|
|
|
|
if (fg == COL_DEF) fg = COL_INVERSEBG;
|
|
|
|
if (bg == COL_DEF) bg = COL_INVERSE;
|
2013-02-14 13:44:16 -08:00
|
|
|
INT_SWAP(bg, fg);
|
2012-06-15 22:07:33 -07:00
|
|
|
if (bold)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2012-06-15 22:07:33 -07:00
|
|
|
fg += 12;
|
|
|
|
bg += 12;
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
2012-06-15 22:07:33 -07:00
|
|
|
if (cells[j].att.faint)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2012-06-15 22:07:33 -07:00
|
|
|
fg += 24;
|
|
|
|
bg += 24;
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
2012-06-18 06:59:09 -07:00
|
|
|
if (cells[j].att.fgintense) fg += 48;
|
|
|
|
if (cells[j].att.bgintense) bg += 48;
|
2012-06-15 22:07:33 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fg = cells[j].att.fg;
|
|
|
|
bg = cells[j].att.bg;
|
|
|
|
|
|
|
|
if (!fgext)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2012-06-15 22:07:33 -07:00
|
|
|
if (bold) fg += 12;
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
2012-06-15 22:07:33 -07:00
|
|
|
if (!bgext)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2012-06-15 22:07:33 -07:00
|
|
|
if (bg == COL_DEF) bg = COL_INVIS;
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
2012-06-15 22:07:33 -07:00
|
|
|
if (cells[j].att.faint)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2012-06-15 22:07:33 -07:00
|
|
|
if (!fgext) fg += 24;
|
|
|
|
if (!bgext) bg += 24;
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
2012-06-18 06:59:09 -07:00
|
|
|
if (cells[j].att.fgintense) fg += 48;
|
|
|
|
if (cells[j].att.bgintense) bg += 48;
|
2012-12-10 13:52:39 -08:00
|
|
|
if (((codepoint == ' ') || (codepoint == 0)) &&
|
|
|
|
(!cells[j].att.strike) &&
|
|
|
|
(!cells[j].att.underline))
|
2012-06-15 22:07:33 -07:00
|
|
|
fg = COL_INVIS;
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
2012-06-25 18:38:13 -07:00
|
|
|
if ((tc[x].codepoint != codepoint) ||
|
2012-06-15 22:07:33 -07:00
|
|
|
(tc[x].fg != fg) ||
|
|
|
|
(tc[x].bg != bg) ||
|
|
|
|
(tc[x].fg_extended != fgext) ||
|
|
|
|
(tc[x].bg_extended != bgext) ||
|
|
|
|
(tc[x].underline != cells[j].att.underline) ||
|
|
|
|
(tc[x].strikethrough != cells[j].att.strike))
|
|
|
|
{
|
|
|
|
if (ch1 < 0) ch1 = x;
|
|
|
|
ch2 = x;
|
|
|
|
}
|
|
|
|
tc[x].fg_extended = fgext;
|
|
|
|
tc[x].bg_extended = bgext;
|
|
|
|
tc[x].underline = cells[j].att.underline;
|
|
|
|
tc[x].strikethrough = cells[j].att.strike;
|
|
|
|
tc[x].fg = fg;
|
|
|
|
tc[x].bg = bg;
|
2012-06-25 18:38:13 -07:00
|
|
|
tc[x].codepoint = codepoint;
|
2012-11-20 13:18:42 -08:00
|
|
|
#if defined(SUPPORT_DBLWIDTH)
|
2012-06-25 18:38:13 -07:00
|
|
|
tc[x].double_width = cells[j].att.dblwidth;
|
2012-11-20 13:18:42 -08:00
|
|
|
#endif
|
2012-06-25 18:38:13 -07:00
|
|
|
if ((tc[x].double_width) && (tc[x].codepoint == 0) &&
|
|
|
|
(ch2 == x - 1))
|
|
|
|
ch2 = x;
|
2012-06-15 22:07:33 -07:00
|
|
|
// cells[j].att.italic // never going 2 support
|
|
|
|
// cells[j].att.blink
|
|
|
|
// cells[j].att.blink2
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
}
|
2012-06-15 22:07:33 -07:00
|
|
|
j++;
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
2012-06-15 22:07:33 -07:00
|
|
|
evas_object_textgrid_cellrow_set(sd->grid.obj, y, tc);
|
|
|
|
/* only bothering to keep 1 change span per row - not worth doing
|
|
|
|
* more really */
|
|
|
|
if (ch1 >= 0)
|
|
|
|
evas_object_textgrid_update_add(sd->grid.obj, ch1, y,
|
|
|
|
ch2 - ch1 + 1, 1);
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
2012-06-15 22:07:33 -07:00
|
|
|
|
2013-01-28 08:06:26 -08:00
|
|
|
EINA_LIST_FOREACH_SAFE(sd->pty->block.active, l, ln, blk)
|
|
|
|
{
|
|
|
|
if (!blk->active)
|
|
|
|
{
|
|
|
|
blk->was_active = EINA_FALSE;
|
|
|
|
if (blk->obj)
|
|
|
|
{
|
|
|
|
evas_object_del(blk->obj);
|
|
|
|
blk->obj = NULL;
|
|
|
|
}
|
|
|
|
sd->pty->block.active = eina_list_remove_list
|
|
|
|
(sd->pty->block.active, l);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
if ((sd->scroll != 0) || (sd->pty->state.hidecursor))
|
|
|
|
evas_object_hide(sd->cur.obj);
|
|
|
|
else
|
|
|
|
evas_object_show(sd->cur.obj);
|
|
|
|
sd->cur.x = sd->pty->state.cx;
|
|
|
|
sd->cur.y = sd->pty->state.cy;
|
2012-06-12 17:26:00 -07:00
|
|
|
evas_object_move(sd->cur.obj,
|
2012-06-12 03:10:01 -07:00
|
|
|
ox + (sd->cur.x * sd->font.chw),
|
|
|
|
oy + (sd->cur.y * sd->font.chh));
|
|
|
|
if (sd->cur.sel)
|
|
|
|
{
|
2012-06-17 10:13:50 -07:00
|
|
|
int start_x, start_y, end_x, end_y;
|
2013-02-14 13:44:16 -08:00
|
|
|
int size_top, size_bottom;
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2012-06-17 10:13:50 -07:00
|
|
|
start_x = sd->cur.sel1.x;
|
|
|
|
start_y = sd->cur.sel1.y;
|
|
|
|
end_x = sd->cur.sel2.x;
|
|
|
|
end_y = sd->cur.sel2.y;
|
2012-07-12 17:41:43 -07:00
|
|
|
|
2013-02-14 13:44:16 -08:00
|
|
|
if (sd->boxsel)
|
|
|
|
{
|
|
|
|
if (start_y > end_y)
|
|
|
|
INT_SWAP(start_y, end_y);
|
|
|
|
if (start_x > end_x)
|
|
|
|
INT_SWAP(start_x, end_x);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((start_y > end_y) ||
|
|
|
|
((start_y == end_y) && (end_x < start_x)))
|
|
|
|
{
|
|
|
|
INT_SWAP(start_y, end_y);
|
|
|
|
INT_SWAP(start_x, end_x);
|
|
|
|
|
|
|
|
if (sd->top_left)
|
|
|
|
{
|
|
|
|
sd->top_left = EINA_FALSE;
|
|
|
|
sd->bottom_right = EINA_TRUE;
|
|
|
|
edje_object_signal_emit(sd->cur.selo_theme,
|
|
|
|
"mouse,out",
|
|
|
|
"zone.top_left");
|
|
|
|
edje_object_signal_emit(sd->cur.selo_theme,
|
|
|
|
"mouse,in",
|
|
|
|
"zone.bottom_right");
|
|
|
|
}
|
|
|
|
else if (sd->bottom_right)
|
|
|
|
{
|
|
|
|
sd->top_left = EINA_TRUE;
|
|
|
|
sd->bottom_right = EINA_FALSE;
|
|
|
|
edje_object_signal_emit(sd->cur.selo_theme,
|
|
|
|
"mouse,out",
|
|
|
|
"zone.bottom_right");
|
|
|
|
edje_object_signal_emit(sd->cur.selo_theme,
|
|
|
|
"mouse,in",
|
|
|
|
"zone.top_left");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
size_top = start_x * sd->font.chw;
|
|
|
|
|
|
|
|
size_bottom = (sd->grid.w - end_x - 1) * sd->font.chw;
|
2012-07-12 17:41:43 -07:00
|
|
|
|
2012-07-11 05:09:00 -07:00
|
|
|
evas_object_size_hint_min_set(sd->cur.selo_top,
|
2012-07-12 17:41:43 -07:00
|
|
|
size_top,
|
2012-07-11 05:09:00 -07:00
|
|
|
sd->font.chh);
|
|
|
|
evas_object_size_hint_max_set(sd->cur.selo_top,
|
2012-07-12 17:41:43 -07:00
|
|
|
size_top,
|
2012-07-11 05:09:00 -07:00
|
|
|
sd->font.chh);
|
|
|
|
evas_object_size_hint_min_set(sd->cur.selo_bottom,
|
2012-07-12 17:41:43 -07:00
|
|
|
size_bottom,
|
2012-07-11 05:09:00 -07:00
|
|
|
sd->font.chh);
|
|
|
|
evas_object_size_hint_max_set(sd->cur.selo_bottom,
|
2012-07-12 17:41:43 -07:00
|
|
|
size_bottom,
|
2012-07-11 05:09:00 -07:00
|
|
|
sd->font.chh);
|
|
|
|
evas_object_move(sd->cur.selo_theme,
|
|
|
|
ox,
|
|
|
|
oy + ((start_y + sd->scroll) * sd->font.chh));
|
|
|
|
evas_object_resize(sd->cur.selo_theme,
|
2012-07-14 21:49:20 -07:00
|
|
|
sd->grid.w * sd->font.chw,
|
2012-07-13 02:20:07 -07:00
|
|
|
(end_y + 1 - start_y) * sd->font.chh);
|
2013-02-14 13:44:16 -08:00
|
|
|
|
|
|
|
if (sd->boxsel)
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(sd->cur.selo_theme,
|
2012-10-21 19:12:55 -07:00
|
|
|
"mode,oneline", "terminology");
|
2013-02-14 13:44:16 -08:00
|
|
|
}
|
2012-07-14 21:49:20 -07:00
|
|
|
else
|
2013-02-14 13:44:16 -08:00
|
|
|
{
|
|
|
|
if ((start_y == end_y) ||
|
|
|
|
((start_x == 0) && (end_x == (sd->grid.w - 1))))
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(sd->cur.selo_theme,
|
|
|
|
"mode,oneline", "terminology");
|
|
|
|
}
|
|
|
|
else if ((start_y == (end_y - 1)) &&
|
|
|
|
(start_x > end_x))
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(sd->cur.selo_theme,
|
|
|
|
"mode,disjoint", "terminology");
|
|
|
|
}
|
|
|
|
else if (start_x == 0)
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(sd->cur.selo_theme,
|
|
|
|
"mode,topfull", "terminology");
|
|
|
|
}
|
|
|
|
else if (end_x == (sd->grid.w - 1))
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(sd->cur.selo_theme,
|
|
|
|
"mode,bottomfull", "terminology");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(sd->cur.selo_theme,
|
|
|
|
"mode,multiline", "terminology");
|
|
|
|
}
|
|
|
|
}
|
2012-07-11 05:09:00 -07:00
|
|
|
evas_object_show(sd->cur.selo_theme);
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
else
|
2012-07-14 21:49:20 -07:00
|
|
|
evas_object_hide(sd->cur.selo_theme);
|
2013-01-30 21:23:25 -08:00
|
|
|
if (sd->mouseover_delay) ecore_timer_del(sd->mouseover_delay);
|
|
|
|
sd->mouseover_delay = ecore_timer_add(0.05, _smart_mouseover_delay, obj);
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-12 06:08:09 -07:00
|
|
|
_smart_size(Evas_Object *obj, int w, int h, Eina_Bool force)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
|
|
|
|
|
|
|
if (w < 1) w = 1;
|
|
|
|
if (h < 1) h = 1;
|
2012-06-12 06:08:09 -07:00
|
|
|
if (!force)
|
|
|
|
{
|
|
|
|
if ((w == sd->grid.w) && (h == sd->grid.h)) return;
|
|
|
|
}
|
2012-06-12 03:10:01 -07:00
|
|
|
|
|
|
|
evas_event_freeze(evas_object_evas_get(obj));
|
2012-06-15 22:07:33 -07:00
|
|
|
evas_object_textgrid_size_set(sd->grid.obj, w, h);
|
2012-06-12 03:10:01 -07:00
|
|
|
sd->grid.w = w;
|
|
|
|
sd->grid.h = h;
|
|
|
|
evas_object_resize(sd->cur.obj, sd->font.chw, sd->font.chh);
|
|
|
|
evas_object_size_hint_min_set(obj, sd->font.chw, sd->font.chh);
|
2012-06-26 03:30:41 -07:00
|
|
|
if (!sd->noreqsize)
|
|
|
|
evas_object_size_hint_request_set(obj,
|
|
|
|
sd->font.chw * sd->grid.w,
|
|
|
|
sd->font.chh * sd->grid.h);
|
2012-06-12 03:10:01 -07:00
|
|
|
termpty_resize(sd->pty, w, h);
|
|
|
|
_smart_calculate(obj);
|
|
|
|
_smart_apply(obj);
|
|
|
|
evas_event_thaw(evas_object_evas_get(obj));
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_smart_cb_delayed_size(void *data)
|
|
|
|
{
|
|
|
|
Evas_Object *obj = data;
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
Evas_Coord ow = 0, oh = 0;
|
|
|
|
int w, h;
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
if (!sd) return EINA_FALSE;
|
|
|
|
sd->delayed_size_timer = NULL;
|
|
|
|
|
|
|
|
evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
w = ow / sd->font.chw;
|
|
|
|
h = oh / sd->font.chh;
|
2012-06-12 06:08:09 -07:00
|
|
|
_smart_size(obj, w, h, EINA_FALSE);
|
2012-06-12 03:10:01 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2012-06-18 05:14:36 -07:00
|
|
|
static Eina_Bool
|
2012-06-12 03:10:01 -07:00
|
|
|
_smart_cb_change(void *data)
|
|
|
|
{
|
|
|
|
Evas_Object *obj = data;
|
|
|
|
Termio *sd;
|
|
|
|
sd = evas_object_smart_data_get(obj);
|
2012-06-18 07:22:15 -07:00
|
|
|
if (!sd) return EINA_FALSE;
|
2012-06-18 05:14:36 -07:00
|
|
|
sd->anim = NULL;
|
2012-06-12 03:10:01 -07:00
|
|
|
_smart_apply(obj);
|
2012-06-16 19:35:07 -07:00
|
|
|
evas_object_smart_callback_call(obj, "changed", NULL);
|
2012-06-18 05:14:36 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_smart_update_queue(Evas_Object *obj, Termio *sd)
|
|
|
|
{
|
|
|
|
if (sd->anim) return;
|
|
|
|
sd->anim = ecore_animator_add(_smart_cb_change, obj);
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
|
2012-06-25 04:17:03 -07:00
|
|
|
static void
|
|
|
|
_lost_selection(void *data, Elm_Sel_Type selection)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return;
|
|
|
|
if (sd->have_sel)
|
|
|
|
{
|
|
|
|
sd->cur.sel = 0;
|
|
|
|
elm_object_cnp_selection_clear(sd->win, selection);
|
|
|
|
_smart_update_queue(data, sd);
|
|
|
|
sd->have_sel = EINA_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
static void
|
2012-06-23 23:39:54 -07:00
|
|
|
_take_selection(Evas_Object *obj, Elm_Sel_Type type)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
2012-06-17 10:13:50 -07:00
|
|
|
int start_x, start_y, end_x, end_y;
|
2012-06-12 03:10:01 -07:00
|
|
|
char *s;
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
if (!sd) return;
|
2012-06-17 10:13:50 -07:00
|
|
|
start_x = sd->cur.sel1.x;
|
|
|
|
start_y = sd->cur.sel1.y;
|
|
|
|
end_x = sd->cur.sel2.x;
|
|
|
|
end_y = sd->cur.sel2.y;
|
2013-02-14 13:44:16 -08:00
|
|
|
|
|
|
|
|
|
|
|
if (sd->boxsel)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2013-02-14 13:44:16 -08:00
|
|
|
int i;
|
|
|
|
Eina_Strbuf *sb;
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2013-02-14 13:44:16 -08:00
|
|
|
if (start_y > end_y)
|
|
|
|
INT_SWAP(start_y, end_y);
|
|
|
|
if (start_x > end_x)
|
|
|
|
INT_SWAP(start_x, end_x);
|
|
|
|
|
|
|
|
sb = eina_strbuf_new();
|
|
|
|
for (i = start_y; i <= end_y; i++)
|
|
|
|
{
|
|
|
|
char *tmp = termio_selection_get(obj, start_x, i, end_x, i);
|
|
|
|
size_t len = strlen(tmp);
|
|
|
|
|
|
|
|
eina_strbuf_append_length(sb, tmp, len);
|
|
|
|
if (len && tmp[len - 1] != '\n')
|
|
|
|
eina_strbuf_append_char(sb, '\n');
|
|
|
|
free(tmp);
|
|
|
|
}
|
|
|
|
s = eina_strbuf_string_steal(sb);
|
|
|
|
eina_strbuf_free(sb);
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
2013-02-14 13:44:16 -08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((start_y > end_y) || ((start_y == end_y) && (end_x < start_x)))
|
|
|
|
{
|
|
|
|
INT_SWAP(start_y, end_y);
|
|
|
|
INT_SWAP(start_x, end_x);
|
|
|
|
}
|
|
|
|
s = termio_selection_get(obj, start_x, start_y, end_x, end_y);
|
|
|
|
}
|
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
if (s)
|
|
|
|
{
|
|
|
|
if (sd->win)
|
2012-06-25 04:17:03 -07:00
|
|
|
{
|
|
|
|
sd->have_sel = EINA_FALSE;
|
|
|
|
elm_cnp_selection_set(sd->win, type,
|
|
|
|
ELM_SEL_FORMAT_TEXT, s, strlen(s));
|
2012-08-22 01:34:06 -07:00
|
|
|
elm_cnp_selection_loss_callback_set(sd->win, type,
|
|
|
|
_lost_selection, obj);
|
2012-06-25 04:17:03 -07:00
|
|
|
sd->have_sel = EINA_TRUE;
|
|
|
|
}
|
2012-06-12 03:10:01 -07:00
|
|
|
free(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2012-06-17 10:04:17 -07:00
|
|
|
_getsel_cb(void *data, Evas_Object *obj __UNUSED__, Elm_Selection_Data *ev)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return EINA_FALSE;
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
if (ev->format == ELM_SEL_FORMAT_TEXT)
|
|
|
|
{
|
|
|
|
if (ev->len > 0)
|
2012-07-06 03:08:51 -07:00
|
|
|
{
|
|
|
|
char *tmp, *s;
|
2012-07-12 16:09:40 -07:00
|
|
|
size_t i;
|
2012-07-06 03:08:51 -07:00
|
|
|
|
|
|
|
// apparently we have to convert \n into \r in terminal land.
|
|
|
|
tmp = malloc(ev->len);
|
|
|
|
if (tmp)
|
|
|
|
{
|
|
|
|
s = ev->data;
|
|
|
|
for (i = 0; i < ev->len; i++)
|
|
|
|
{
|
|
|
|
tmp[i] = s[i];
|
2012-12-23 04:19:40 -08:00
|
|
|
if (tmp[i] == '\n') tmp[i] = '\r';
|
2012-07-06 03:08:51 -07:00
|
|
|
}
|
|
|
|
termpty_write(sd->pty, tmp, ev->len - 1);
|
|
|
|
free(tmp);
|
|
|
|
}
|
|
|
|
}
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-23 23:39:54 -07:00
|
|
|
_paste_selection(Evas_Object *obj, Elm_Sel_Type type)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
|
|
|
if (!sd->win) return;
|
2012-06-23 23:39:54 -07:00
|
|
|
elm_cnp_selection_get(sd->win, type, ELM_SEL_FORMAT_TEXT,
|
2012-06-12 03:10:01 -07:00
|
|
|
_getsel_cb, obj);
|
|
|
|
}
|
|
|
|
|
2012-06-18 17:37:27 -07:00
|
|
|
static void
|
2012-07-01 20:47:02 -07:00
|
|
|
_font_size_set(Evas_Object *obj, int size)
|
2012-06-18 17:37:27 -07:00
|
|
|
{
|
2012-07-01 20:47:02 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
Config *config = termio_config_get(obj);
|
|
|
|
if (!sd) return;
|
|
|
|
|
|
|
|
if (size < 5) size = 5;
|
|
|
|
else if (size > 100) size = 100;
|
|
|
|
if (config)
|
|
|
|
{
|
|
|
|
Evas_Coord mw = 1, mh = 1;
|
|
|
|
int gw, gh;
|
|
|
|
|
|
|
|
config->temporary = EINA_TRUE;
|
|
|
|
config->font.size = size;
|
|
|
|
gw = sd->grid.w;
|
|
|
|
gh = sd->grid.h;
|
|
|
|
sd->noreqsize = 1;
|
|
|
|
termio_config_update(obj);
|
|
|
|
sd->noreqsize = 0;
|
|
|
|
evas_object_size_hint_min_get(obj, &mw, &mh);
|
|
|
|
evas_object_data_del(obj, "sizedone");
|
|
|
|
evas_object_size_hint_request_set(obj, mw * gw, mh * gh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-14 05:30:55 -07:00
|
|
|
void
|
|
|
|
termio_font_size_set(Evas_Object *obj, int size)
|
|
|
|
{
|
|
|
|
_font_size_set(obj, size);
|
|
|
|
}
|
|
|
|
|
2012-08-22 03:34:28 -07:00
|
|
|
void
|
|
|
|
termio_grid_size_set(Evas_Object *obj, int w, int h)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
Evas_Coord mw = 1, mh = 1;
|
|
|
|
|
|
|
|
if (w < 1) w = 1;
|
|
|
|
if (h < 1) h = 1;
|
|
|
|
if (!sd) return;
|
|
|
|
evas_object_size_hint_min_get(obj, &mw, &mh);
|
|
|
|
evas_object_data_del(obj, "sizedone");
|
|
|
|
evas_object_size_hint_request_set(obj, mw * w, mh * h);
|
|
|
|
}
|
|
|
|
|
2012-07-01 20:47:02 -07:00
|
|
|
static void
|
|
|
|
_smart_cb_key_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event)
|
|
|
|
{
|
|
|
|
Evas_Event_Key_Up *ev = event;
|
2012-06-18 17:37:27 -07:00
|
|
|
Termio *sd;
|
|
|
|
|
|
|
|
sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return;
|
2012-06-22 23:43:02 -07:00
|
|
|
sd->last_keyup = ev->timestamp;
|
2012-06-18 17:37:27 -07:00
|
|
|
if (sd->imf)
|
|
|
|
{
|
|
|
|
Ecore_IMF_Event_Key_Up imf_ev;
|
|
|
|
ecore_imf_evas_event_key_up_wrap(ev, &imf_ev);
|
|
|
|
if (ecore_imf_context_filter_event
|
|
|
|
(sd->imf, ECORE_IMF_EVENT_KEY_UP, (Ecore_IMF_Event *)&imf_ev))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-27 17:22:08 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_is_modifier(const char *key)
|
|
|
|
{
|
|
|
|
if ((!strncmp(key, "Shift", 5)) ||
|
|
|
|
(!strncmp(key, "Control", 7)) ||
|
|
|
|
(!strncmp(key, "Alt", 3)) ||
|
|
|
|
(!strncmp(key, "Meta", 4)) ||
|
|
|
|
(!strncmp(key, "Super", 5)) ||
|
|
|
|
(!strncmp(key, "Hyper", 5)) ||
|
|
|
|
(!strcmp(key, "Scroll_Lock")) ||
|
|
|
|
(!strcmp(key, "Num_Lock")) ||
|
|
|
|
(!strcmp(key, "Caps_Lock")))
|
|
|
|
return EINA_TRUE;
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2012-08-17 18:30:05 -07:00
|
|
|
static void
|
|
|
|
_compose_seq_reset(Termio *sd)
|
|
|
|
{
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str);
|
|
|
|
sd->composing = EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2012-08-23 02:44:31 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_handle_alt_ctrl(const char *keyname, Evas_Object *term)
|
|
|
|
{
|
|
|
|
if (!strcmp(keyname, "equal"))
|
|
|
|
termcmd_do(term, NULL, NULL, "f+");
|
|
|
|
else if (!strcmp(keyname, "minus"))
|
|
|
|
termcmd_do(term, NULL, NULL, "f-");
|
|
|
|
else if (!strcmp(keyname, "0"))
|
|
|
|
termcmd_do(term, NULL, NULL, "f");
|
|
|
|
else if (!strcmp(keyname, "9"))
|
|
|
|
termcmd_do(term, NULL, NULL, "fb");
|
|
|
|
else
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_handle_shift(Evas_Event_Key_Down *ev, int by, Evas_Object *term, Termio *sd)
|
|
|
|
{
|
|
|
|
if (!strcmp(ev->keyname, "Prior"))
|
|
|
|
{
|
|
|
|
sd->scroll += by;
|
|
|
|
if (sd->scroll > sd->pty->backscroll_num)
|
|
|
|
sd->scroll = sd->pty->backscroll_num;
|
|
|
|
_smart_update_queue(term, sd);
|
|
|
|
}
|
|
|
|
else if (!strcmp(ev->keyname, "Next"))
|
|
|
|
{
|
|
|
|
sd->scroll -= by;
|
|
|
|
if (sd->scroll < 0) sd->scroll = 0;
|
|
|
|
_smart_update_queue(term, sd);
|
|
|
|
}
|
|
|
|
else if (!strcmp(ev->keyname, "Insert"))
|
|
|
|
{
|
|
|
|
if (evas_key_modifier_is_set(ev->modifiers, "Control"))
|
|
|
|
_paste_selection(term, ELM_SEL_TYPE_PRIMARY);
|
|
|
|
else
|
|
|
|
_paste_selection(term, ELM_SEL_TYPE_CLIPBOARD);
|
|
|
|
}
|
|
|
|
else if (!strcmp(ev->keyname, "KP_Add"))
|
|
|
|
{
|
|
|
|
Config *config = termio_config_get(term);
|
|
|
|
|
|
|
|
if (config) _font_size_set(term, config->font.size + 1);
|
|
|
|
}
|
|
|
|
else if (!strcmp(ev->keyname, "KP_Subtract"))
|
|
|
|
{
|
|
|
|
Config *config = termio_config_get(term);
|
|
|
|
|
|
|
|
if (config) _font_size_set(term, config->font.size - 1);
|
|
|
|
}
|
|
|
|
else if (!strcmp(ev->keyname, "KP_Multiply"))
|
|
|
|
{
|
|
|
|
Config *config = termio_config_get(term);
|
|
|
|
|
|
|
|
if (config) _font_size_set(term, 10);
|
|
|
|
}
|
|
|
|
else if (!strcmp(ev->keyname, "KP_Divide"))
|
|
|
|
_take_selection(term, ELM_SEL_TYPE_CLIPBOARD);
|
|
|
|
else
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
void
|
2012-06-19 02:59:30 -07:00
|
|
|
_smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
|
|
|
Evas_Event_Key_Down *ev = event;
|
|
|
|
Termio *sd;
|
2012-06-28 01:21:51 -07:00
|
|
|
Ecore_Compose_State state;
|
2012-08-17 18:30:05 -07:00
|
|
|
char *compres = NULL;
|
2012-06-12 03:10:01 -07:00
|
|
|
|
|
|
|
sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return;
|
2012-06-18 17:37:27 -07:00
|
|
|
if (sd->imf)
|
|
|
|
{
|
2012-06-23 00:18:47 -07:00
|
|
|
// EXCEPTION. Don't filter modifiers alt+shift -> breaks emacs
|
|
|
|
// and jed (alt+shift+5 for search/replace for example)
|
2012-06-27 13:54:17 -07:00
|
|
|
// Don't filter modifiers alt, is used by shells
|
|
|
|
if (!evas_key_modifier_is_set(ev->modifiers, "Alt"))
|
2012-06-23 00:18:47 -07:00
|
|
|
{
|
2012-08-18 20:32:39 -07:00
|
|
|
Ecore_IMF_Event_Key_Down imf_ev;
|
|
|
|
|
|
|
|
ecore_imf_evas_event_key_down_wrap(ev, &imf_ev);
|
2012-06-27 08:27:59 -07:00
|
|
|
if (!sd->composing)
|
|
|
|
{
|
|
|
|
if (ecore_imf_context_filter_event
|
|
|
|
(sd->imf, ECORE_IMF_EVENT_KEY_DOWN, (Ecore_IMF_Event *)&imf_ev))
|
|
|
|
goto end;
|
|
|
|
}
|
2012-06-23 00:18:47 -07:00
|
|
|
}
|
2012-06-18 17:37:27 -07:00
|
|
|
}
|
2013-01-26 05:06:58 -08:00
|
|
|
if ((!evas_key_modifier_is_set(ev->modifiers, "Alt")) &&
|
|
|
|
(evas_key_modifier_is_set(ev->modifiers, "Control")) &&
|
|
|
|
(!evas_key_modifier_is_set(ev->modifiers, "Shift")))
|
|
|
|
{
|
|
|
|
if (!strcmp(ev->keyname, "Prior"))
|
|
|
|
{
|
|
|
|
evas_object_smart_callback_call(data, "prev", NULL);
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
else if (!strcmp(ev->keyname, "Next"))
|
|
|
|
{
|
|
|
|
evas_object_smart_callback_call(data, "next", NULL);
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((!evas_key_modifier_is_set(ev->modifiers, "Alt")) &&
|
|
|
|
(evas_key_modifier_is_set(ev->modifiers, "Control")) &&
|
|
|
|
(evas_key_modifier_is_set(ev->modifiers, "Shift")))
|
|
|
|
{
|
|
|
|
if (!strcmp(ev->keyname, "Prior"))
|
|
|
|
{
|
|
|
|
evas_object_smart_callback_call(data, "split,h", NULL);
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
else if (!strcmp(ev->keyname, "Next"))
|
|
|
|
{
|
|
|
|
evas_object_smart_callback_call(data, "split,v", NULL);
|
|
|
|
goto end;
|
|
|
|
}
|
2013-01-28 08:06:26 -08:00
|
|
|
else if (!strcmp(ev->keyname, "t"))
|
|
|
|
{
|
|
|
|
evas_object_smart_callback_call(data, "new", NULL);
|
|
|
|
goto end;
|
|
|
|
}
|
2013-01-26 05:06:58 -08:00
|
|
|
}
|
2012-08-14 05:30:55 -07:00
|
|
|
if ((evas_key_modifier_is_set(ev->modifiers, "Alt")) &&
|
|
|
|
(!evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
|
|
|
|
(!evas_key_modifier_is_set(ev->modifiers, "Control")) &&
|
2012-08-15 20:50:01 -07:00
|
|
|
(!strcmp(ev->keyname, "Home")))
|
2012-08-14 05:30:55 -07:00
|
|
|
{
|
2012-08-17 18:30:05 -07:00
|
|
|
_compose_seq_reset(sd);
|
2012-08-14 05:30:55 -07:00
|
|
|
evas_object_smart_callback_call(data, "cmdbox", NULL);
|
|
|
|
goto end;
|
|
|
|
}
|
2012-08-22 23:21:30 -07:00
|
|
|
if ((evas_key_modifier_is_set(ev->modifiers, "Alt")) &&
|
|
|
|
(evas_key_modifier_is_set(ev->modifiers, "Control")) &&
|
|
|
|
(!evas_key_modifier_is_set(ev->modifiers, "Shift")))
|
|
|
|
{
|
2012-08-23 02:44:31 -07:00
|
|
|
if (_handle_alt_ctrl(ev->keyname, data))
|
2012-08-22 23:21:30 -07:00
|
|
|
{
|
2012-08-23 02:44:31 -07:00
|
|
|
_compose_seq_reset(sd);
|
2012-08-22 23:21:30 -07:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
}
|
2012-08-23 02:44:31 -07:00
|
|
|
if ((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
|
|
|
|
(ev->keyname))
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2012-08-23 02:44:31 -07:00
|
|
|
int by = sd->grid.h - 2;
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2012-08-23 02:44:31 -07:00
|
|
|
if (by < 1) by = 1;
|
|
|
|
|
|
|
|
if (_handle_shift(ev, by, data, sd))
|
|
|
|
{
|
|
|
|
_compose_seq_reset(sd);
|
|
|
|
goto end;
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
}
|
2012-07-27 17:22:08 -07:00
|
|
|
if (sd->jump_on_keypress)
|
2012-07-04 21:36:47 -07:00
|
|
|
{
|
2012-07-27 17:22:08 -07:00
|
|
|
if (!_is_modifier(ev->key))
|
|
|
|
{
|
|
|
|
sd->scroll = 0;
|
|
|
|
_smart_update_queue(data, sd);
|
|
|
|
}
|
2012-07-04 21:36:47 -07:00
|
|
|
}
|
2012-06-22 23:43:02 -07:00
|
|
|
// if term app asked fro kbd lock - dont handle here
|
|
|
|
if (sd->pty->state.kbd_lock) return;
|
|
|
|
// if app asked us to not do autorepeat - ignore pree is it is the same
|
|
|
|
// timestamp as last one
|
|
|
|
if ((sd->pty->state.no_autorepeat) &&
|
|
|
|
(ev->timestamp == sd->last_keyup)) return;
|
2012-06-27 08:27:59 -07:00
|
|
|
if (!sd->composing)
|
2012-06-26 20:26:34 -07:00
|
|
|
{
|
2012-08-17 18:30:05 -07:00
|
|
|
_compose_seq_reset(sd);
|
2012-06-28 01:21:51 -07:00
|
|
|
sd->seq = eina_list_append(sd->seq, eina_stringshare_add(ev->key));
|
|
|
|
state = ecore_compose_get(sd->seq, &compres);
|
|
|
|
if (state == ECORE_COMPOSE_MIDDLE) sd->composing = EINA_TRUE;
|
|
|
|
else sd->composing = EINA_FALSE;
|
2012-08-17 18:30:05 -07:00
|
|
|
if (!sd->composing) _compose_seq_reset(sd);
|
2012-06-28 01:21:51 -07:00
|
|
|
else goto end;
|
2012-06-26 20:26:34 -07:00
|
|
|
}
|
2012-06-27 08:27:59 -07:00
|
|
|
else
|
2012-06-26 20:26:34 -07:00
|
|
|
{
|
2012-07-27 17:22:08 -07:00
|
|
|
if (_is_modifier(ev->key)) goto end;
|
2012-06-28 01:21:51 -07:00
|
|
|
sd->seq = eina_list_append(sd->seq, eina_stringshare_add(ev->key));
|
|
|
|
state = ecore_compose_get(sd->seq, &compres);
|
2012-08-17 18:30:05 -07:00
|
|
|
if (state == ECORE_COMPOSE_NONE) _compose_seq_reset(sd);
|
2012-06-28 01:21:51 -07:00
|
|
|
else if (state == ECORE_COMPOSE_DONE)
|
2012-06-26 20:26:34 -07:00
|
|
|
{
|
2012-08-17 18:30:05 -07:00
|
|
|
_compose_seq_reset(sd);
|
2012-06-28 01:21:51 -07:00
|
|
|
if (compres)
|
2012-06-26 20:26:34 -07:00
|
|
|
{
|
2012-06-28 01:21:51 -07:00
|
|
|
termpty_write(sd->pty, compres, strlen(compres));
|
|
|
|
free(compres);
|
|
|
|
compres = NULL;
|
2012-06-26 20:26:34 -07:00
|
|
|
}
|
2012-06-27 08:27:59 -07:00
|
|
|
goto end;
|
2012-06-26 20:26:34 -07:00
|
|
|
}
|
2012-06-28 01:21:51 -07:00
|
|
|
else goto end;
|
2012-06-26 20:26:34 -07:00
|
|
|
}
|
2012-06-12 03:10:01 -07:00
|
|
|
keyin_handle(sd->pty, ev);
|
2012-06-19 08:35:37 -07:00
|
|
|
end:
|
2012-06-20 01:29:08 -07:00
|
|
|
if (sd->config->flicker_on_key)
|
2012-10-21 19:12:55 -07:00
|
|
|
edje_object_signal_emit(sd->cur.obj, "key,down", "terminology");
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
|
2012-06-18 17:37:27 -07:00
|
|
|
static void
|
|
|
|
_imf_cursor_set(Termio *sd)
|
|
|
|
{
|
|
|
|
/* TODO */
|
|
|
|
Evas_Coord cx, cy, cw, ch;
|
|
|
|
evas_object_geometry_get(sd->cur.obj, &cx, &cy, &cw, &ch);
|
2012-06-19 00:14:59 -07:00
|
|
|
if (sd->imf)
|
|
|
|
ecore_imf_context_cursor_location_set(sd->imf, cx, cy, cw, ch);
|
2012-06-18 17:37:27 -07:00
|
|
|
/*
|
2012-06-19 00:19:31 -07:00
|
|
|
ecore_imf_context_cursor_position_set(sd->imf, 0); // how to get it?
|
|
|
|
*/
|
2012-06-18 17:37:27 -07:00
|
|
|
}
|
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
void
|
2012-06-17 10:04:17 -07:00
|
|
|
_smart_cb_focus_in(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
|
|
|
Termio *sd;
|
|
|
|
|
|
|
|
sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return;
|
2012-06-26 01:05:43 -07:00
|
|
|
if (sd->config->disable_cursor_blink)
|
2012-10-21 19:12:55 -07:00
|
|
|
edje_object_signal_emit(sd->cur.obj, "focus,in,noblink", "terminology");
|
2012-06-26 01:05:43 -07:00
|
|
|
else
|
2012-10-21 19:12:55 -07:00
|
|
|
edje_object_signal_emit(sd->cur.obj, "focus,in", "terminology");
|
2012-06-12 03:10:01 -07:00
|
|
|
if (!sd->win) return;
|
|
|
|
elm_win_keyboard_mode_set(sd->win, ELM_WIN_KEYBOARD_TERMINAL);
|
2012-06-18 17:37:27 -07:00
|
|
|
if (sd->imf)
|
|
|
|
{
|
2012-07-01 19:52:48 -07:00
|
|
|
ecore_imf_context_input_panel_show(sd->imf);
|
2012-06-18 17:37:27 -07:00
|
|
|
ecore_imf_context_reset(sd->imf);
|
|
|
|
ecore_imf_context_focus_in(sd->imf);
|
|
|
|
_imf_cursor_set(sd);
|
|
|
|
}
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-06-17 10:04:17 -07:00
|
|
|
_smart_cb_focus_out(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
|
|
|
Termio *sd;
|
|
|
|
|
|
|
|
sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return;
|
2012-10-21 19:12:55 -07:00
|
|
|
edje_object_signal_emit(sd->cur.obj, "focus,out", "terminology");
|
2012-06-12 03:10:01 -07:00
|
|
|
if (!sd->win) return;
|
|
|
|
elm_win_keyboard_mode_set(sd->win, ELM_WIN_KEYBOARD_OFF);
|
2012-06-18 17:37:27 -07:00
|
|
|
if (sd->imf)
|
|
|
|
{
|
|
|
|
ecore_imf_context_reset(sd->imf);
|
|
|
|
_imf_cursor_set(sd);
|
|
|
|
ecore_imf_context_focus_out(sd->imf);
|
2012-07-01 19:52:48 -07:00
|
|
|
ecore_imf_context_input_panel_hide(sd->imf);
|
2012-06-18 17:37:27 -07:00
|
|
|
}
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_smart_xy_to_cursor(Evas_Object *obj, Evas_Coord x, Evas_Coord y, int *cx, int *cy)
|
|
|
|
{
|
|
|
|
Termio *sd;
|
|
|
|
Evas_Coord ox, oy;
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd)
|
|
|
|
{
|
|
|
|
*cx = 0;
|
|
|
|
*cy = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
|
|
|
|
*cx = (x - ox) / sd->font.chw;
|
|
|
|
*cy = (y - oy) / sd->font.chh;
|
|
|
|
if (*cx < 0) *cx = 0;
|
|
|
|
else if (*cx >= sd->grid.w) *cx = sd->grid.w - 1;
|
|
|
|
if (*cy < 0) *cy = 0;
|
|
|
|
else if (*cy >= sd->grid.h) *cy = sd->grid.h - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-19 02:59:30 -07:00
|
|
|
_sel_line(Evas_Object *obj, int cx __UNUSED__, int cy)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
|
|
|
|
|
|
|
sd->cur.sel = 1;
|
|
|
|
sd->cur.makesel = 0;
|
|
|
|
sd->cur.sel1.x = 0;
|
|
|
|
sd->cur.sel1.y = cy;
|
|
|
|
sd->cur.sel2.x = sd->grid.w - 1;
|
|
|
|
sd->cur.sel2.y = cy;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2012-06-25 18:38:13 -07:00
|
|
|
_codepoint_is_wordsep(const Config *config, int g)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (g == 0) return EINA_TRUE;
|
|
|
|
if (!config->wordsep) return EINA_FALSE;
|
|
|
|
for (i = 0;;)
|
|
|
|
{
|
|
|
|
int g2 = 0;
|
|
|
|
|
|
|
|
if (!config->wordsep[i]) break;
|
|
|
|
i = evas_string_char_next_get(config->wordsep, i, &g2);
|
|
|
|
if (i < 0) break;
|
|
|
|
if (g == g2) return EINA_TRUE;
|
|
|
|
}
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_sel_word(Evas_Object *obj, int cx, int cy)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
Termcell *cells;
|
|
|
|
int x, w = 0;
|
|
|
|
if (!sd) return;
|
|
|
|
|
2012-06-24 01:45:10 -07:00
|
|
|
cells = termpty_cellrow_get(sd->pty, cy, &w);
|
2012-06-12 03:10:01 -07:00
|
|
|
if (!cells) return;
|
|
|
|
sd->cur.sel = 1;
|
|
|
|
sd->cur.makesel = 0;
|
|
|
|
sd->cur.sel1.x = cx;
|
|
|
|
sd->cur.sel1.y = cy;
|
|
|
|
for (x = sd->cur.sel1.x; x >= 0; x--)
|
|
|
|
{
|
2012-11-20 13:18:42 -08:00
|
|
|
#if defined(SUPPORT_DBLWIDTH)
|
2012-06-25 18:38:13 -07:00
|
|
|
if ((cells[x].codepoint == 0) && (cells[x].att.dblwidth) &&
|
|
|
|
(x > 0))
|
|
|
|
x--;
|
2012-11-20 13:18:42 -08:00
|
|
|
#endif
|
2012-06-12 03:10:01 -07:00
|
|
|
if (x >= w) break;
|
2012-06-25 18:38:13 -07:00
|
|
|
if (_codepoint_is_wordsep(sd->config, cells[x].codepoint)) break;
|
2012-06-12 03:10:01 -07:00
|
|
|
sd->cur.sel1.x = x;
|
|
|
|
}
|
|
|
|
sd->cur.sel2.x = cx;
|
|
|
|
sd->cur.sel2.y = cy;
|
|
|
|
for (x = sd->cur.sel2.x; x < sd->grid.w; x++)
|
|
|
|
{
|
2012-11-20 13:18:42 -08:00
|
|
|
#if defined(SUPPORT_DBLWIDTH)
|
2012-06-25 18:38:13 -07:00
|
|
|
if ((cells[x].codepoint == 0) && (cells[x].att.dblwidth) &&
|
|
|
|
(x < (sd->grid.w - 1)))
|
|
|
|
{
|
|
|
|
sd->cur.sel2.x = x;
|
|
|
|
x++;
|
|
|
|
}
|
2012-11-20 13:18:42 -08:00
|
|
|
#endif
|
2012-06-12 03:10:01 -07:00
|
|
|
if (x >= w) break;
|
2012-06-25 18:38:13 -07:00
|
|
|
if (_codepoint_is_wordsep(sd->config, cells[x].codepoint)) break;
|
2012-06-12 03:10:01 -07:00
|
|
|
sd->cur.sel2.x = x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-18 01:56:27 -07:00
|
|
|
static void
|
|
|
|
_sel_word_to(Evas_Object *obj, int cx, int cy)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
Termcell *cells;
|
|
|
|
int x, w = 0;
|
|
|
|
if (!sd) return;
|
|
|
|
|
2012-06-24 01:45:10 -07:00
|
|
|
cells = termpty_cellrow_get(sd->pty, cy, &w);
|
2012-06-18 01:56:27 -07:00
|
|
|
if (!cells) return;
|
|
|
|
if (sd->cur.sel1.x > cx || sd->cur.sel1.y > cy)
|
|
|
|
{
|
|
|
|
sd->cur.sel1.x = cx;
|
|
|
|
sd->cur.sel1.y = cy;
|
|
|
|
for (x = sd->cur.sel1.x; x >= 0; x--)
|
|
|
|
{
|
2012-11-20 13:18:42 -08:00
|
|
|
#if defined(SUPPORT_DBLWIDTH)
|
2012-06-25 18:38:13 -07:00
|
|
|
if ((cells[x].codepoint == 0) && (cells[x].att.dblwidth) &&
|
|
|
|
(x > 0))
|
|
|
|
x--;
|
2012-11-20 13:18:42 -08:00
|
|
|
#endif
|
2012-06-18 01:56:27 -07:00
|
|
|
if (x >= w) break;
|
2012-06-25 18:38:13 -07:00
|
|
|
if (_codepoint_is_wordsep(sd->config, cells[x].codepoint)) break;
|
2012-06-18 01:56:27 -07:00
|
|
|
sd->cur.sel1.x = x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (sd->cur.sel2.x < cx || sd->cur.sel2.y < cy)
|
|
|
|
{
|
|
|
|
sd->cur.sel2.x = cx;
|
|
|
|
sd->cur.sel2.y = cy;
|
|
|
|
for (x = sd->cur.sel2.x; x < sd->grid.w; x++)
|
|
|
|
{
|
2012-11-20 13:18:42 -08:00
|
|
|
#if defined(SUPPORT_DBLWIDTH)
|
2012-06-25 18:38:13 -07:00
|
|
|
if ((cells[x].codepoint == 0) && (cells[x].att.dblwidth) &&
|
|
|
|
(x < (sd->grid.w - 1)))
|
|
|
|
{
|
|
|
|
sd->cur.sel2.x = x;
|
|
|
|
x++;
|
|
|
|
}
|
2012-11-20 13:18:42 -08:00
|
|
|
#endif
|
2012-06-18 01:56:27 -07:00
|
|
|
if (x >= w) break;
|
2012-06-25 18:38:13 -07:00
|
|
|
if (_codepoint_is_wordsep(sd->config, cells[x].codepoint)) break;
|
2012-06-18 01:56:27 -07:00
|
|
|
sd->cur.sel2.x = x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-03 05:23:06 -07:00
|
|
|
static Eina_Bool
|
2012-10-04 16:19:13 -07:00
|
|
|
_rep_mouse_down(Termio *sd, Evas_Event_Mouse_Down *ev, int cx, int cy)
|
2012-06-22 23:43:02 -07:00
|
|
|
{
|
|
|
|
char buf[64];
|
2012-10-03 05:23:06 -07:00
|
|
|
Eina_Bool ret = EINA_FALSE;
|
2012-10-25 12:36:46 -07:00
|
|
|
int btn;
|
2012-10-24 14:34:36 -07:00
|
|
|
|
|
|
|
if (sd->pty->mouse_mode == MOUSE_OFF) return EINA_FALSE;
|
2012-10-04 16:19:17 -07:00
|
|
|
if (!sd->mouse.button)
|
|
|
|
{
|
|
|
|
/* Need to remember the first button pressed for terminal handling */
|
|
|
|
sd->mouse.button = ev->button;
|
|
|
|
}
|
2012-10-25 12:36:46 -07:00
|
|
|
|
|
|
|
btn = ev->button - 1;
|
2012-10-24 14:34:36 -07:00
|
|
|
switch (sd->pty->mouse_ext)
|
2012-06-22 23:43:02 -07:00
|
|
|
{
|
2012-10-24 14:34:36 -07:00
|
|
|
case MOUSE_EXT_NONE:
|
2012-06-22 23:43:02 -07:00
|
|
|
if ((cx < (0xff - ' ')) && (cy < (0xff - ' ')))
|
|
|
|
{
|
2012-10-24 14:34:36 -07:00
|
|
|
if (sd->pty->mouse_mode == MOUSE_X10)
|
|
|
|
{
|
|
|
|
if (btn <= 2)
|
|
|
|
{
|
|
|
|
buf[0] = 0x1b;
|
|
|
|
buf[1] = '[';
|
|
|
|
buf[2] = 'M';
|
|
|
|
buf[3] = btn + ' ';
|
|
|
|
buf[4] = cx + 1 + ' ';
|
|
|
|
buf[5] = cy + 1 + ' ';
|
|
|
|
buf[6] = 0;
|
|
|
|
termpty_write(sd->pty, buf, strlen(buf));
|
|
|
|
ret = EINA_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2012-06-22 23:43:02 -07:00
|
|
|
{
|
2012-10-24 14:34:36 -07:00
|
|
|
int shift = evas_key_modifier_is_set(ev->modifiers, "Shift") ? 4 : 0;
|
|
|
|
int meta = evas_key_modifier_is_set(ev->modifiers, "Alt") ? 8 : 0;
|
|
|
|
int ctrl = evas_key_modifier_is_set(ev->modifiers, "Control") ? 16 : 0;
|
|
|
|
|
|
|
|
if (btn > 2) btn = 0;
|
2012-06-22 23:43:02 -07:00
|
|
|
buf[0] = 0x1b;
|
|
|
|
buf[1] = '[';
|
|
|
|
buf[2] = 'M';
|
2012-10-24 14:34:36 -07:00
|
|
|
buf[3] = (btn | shift | meta | ctrl) + ' ';
|
2012-06-22 23:43:02 -07:00
|
|
|
buf[4] = cx + 1 + ' ';
|
|
|
|
buf[5] = cy + 1 + ' ';
|
|
|
|
buf[6] = 0;
|
|
|
|
termpty_write(sd->pty, buf, strlen(buf));
|
2012-10-03 05:23:06 -07:00
|
|
|
ret = EINA_TRUE;
|
2012-06-22 23:43:02 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2012-10-24 14:34:36 -07:00
|
|
|
case MOUSE_EXT_UTF8: // ESC.[.M.BTN/FLGS.XUTF8.YUTF8
|
2012-06-22 23:43:02 -07:00
|
|
|
{
|
|
|
|
int shift = evas_key_modifier_is_set(ev->modifiers, "Shift") ? 4 : 0;
|
|
|
|
int meta = evas_key_modifier_is_set(ev->modifiers, "Alt") ? 8 : 0;
|
|
|
|
int ctrl = evas_key_modifier_is_set(ev->modifiers, "Control") ? 16 : 0;
|
|
|
|
int v, i;
|
2012-10-24 14:34:36 -07:00
|
|
|
|
2012-06-22 23:43:02 -07:00
|
|
|
if (btn > 2) btn = 0;
|
|
|
|
buf[0] = 0x1b;
|
|
|
|
buf[1] = '[';
|
|
|
|
buf[2] = 'M';
|
2012-10-04 16:18:35 -07:00
|
|
|
buf[3] = (btn | shift | meta | ctrl) + ' ';
|
2012-06-22 23:43:02 -07:00
|
|
|
i = 4;
|
|
|
|
v = cx + 1 + ' ';
|
|
|
|
if (v <= 127) buf[i++] = v;
|
|
|
|
else
|
|
|
|
{ // 14 bits for cx/cy - enough i think
|
|
|
|
buf[i++] = 0xc0 + (v >> 6);
|
|
|
|
buf[i++] = 0x80 + (v & 0x3f);
|
|
|
|
}
|
|
|
|
v = cy + 1 + ' ';
|
|
|
|
if (v <= 127) buf[i++] = v;
|
|
|
|
else
|
|
|
|
{ // 14 bits for cx/cy - enough i think
|
|
|
|
buf[i++] = 0xc0 + (v >> 6);
|
|
|
|
buf[i++] = 0x80 + (v & 0x3f);
|
|
|
|
}
|
|
|
|
buf[i] = 0;
|
|
|
|
termpty_write(sd->pty, buf, strlen(buf));
|
2012-10-03 05:23:06 -07:00
|
|
|
ret = EINA_TRUE;
|
2012-06-22 23:43:02 -07:00
|
|
|
}
|
|
|
|
break;
|
2012-10-24 14:34:36 -07:00
|
|
|
case MOUSE_EXT_SGR: // ESC.[.<.NUM.;.NUM.;.NUM.M
|
2012-06-22 23:43:02 -07:00
|
|
|
{
|
|
|
|
int shift = evas_key_modifier_is_set(ev->modifiers, "Shift") ? 4 : 0;
|
|
|
|
int meta = evas_key_modifier_is_set(ev->modifiers, "Alt") ? 8 : 0;
|
|
|
|
int ctrl = evas_key_modifier_is_set(ev->modifiers, "Control") ? 16 : 0;
|
2012-10-24 14:34:36 -07:00
|
|
|
|
2012-06-22 23:43:02 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%c[<%i;%i;%iM", 0x1b,
|
2012-10-04 16:18:35 -07:00
|
|
|
(btn | shift | meta | ctrl), cx + 1, cy + 1);
|
2012-06-22 23:43:02 -07:00
|
|
|
termpty_write(sd->pty, buf, strlen(buf));
|
2012-10-03 05:23:06 -07:00
|
|
|
ret = EINA_TRUE;
|
2012-06-22 23:43:02 -07:00
|
|
|
}
|
|
|
|
break;
|
2012-10-24 14:34:36 -07:00
|
|
|
case MOUSE_EXT_URXVT: // ESC.[.NUM.;.NUM.;.NUM.M
|
2012-06-22 23:43:02 -07:00
|
|
|
{
|
|
|
|
int shift = evas_key_modifier_is_set(ev->modifiers, "Shift") ? 4 : 0;
|
|
|
|
int meta = evas_key_modifier_is_set(ev->modifiers, "Alt") ? 8 : 0;
|
|
|
|
int ctrl = evas_key_modifier_is_set(ev->modifiers, "Control") ? 16 : 0;
|
2012-10-24 14:34:36 -07:00
|
|
|
|
2012-06-22 23:43:02 -07:00
|
|
|
if (btn > 2) btn = 0;
|
2012-10-24 14:34:36 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%c[%i;%i;%iM", 0x1b,
|
|
|
|
(btn | shift | meta | ctrl) + ' ',
|
|
|
|
cx + 1 + ' ', cy + 1 + ' ');
|
2012-06-22 23:43:02 -07:00
|
|
|
termpty_write(sd->pty, buf, strlen(buf));
|
2012-10-03 05:23:06 -07:00
|
|
|
ret = EINA_TRUE;
|
2012-06-22 23:43:02 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2012-10-03 05:23:06 -07:00
|
|
|
return ret;
|
2012-06-22 23:43:02 -07:00
|
|
|
}
|
|
|
|
|
2012-10-04 16:19:09 -07:00
|
|
|
static Eina_Bool
|
2012-10-04 16:19:13 -07:00
|
|
|
_rep_mouse_up(Termio *sd, Evas_Event_Mouse_Up *ev, int cx, int cy)
|
2012-06-22 23:43:02 -07:00
|
|
|
{
|
|
|
|
char buf[64];
|
2012-10-04 16:19:09 -07:00
|
|
|
Eina_Bool ret = EINA_FALSE;
|
2012-10-25 13:27:11 -07:00
|
|
|
int shift, meta, ctrl;
|
2012-10-24 14:34:36 -07:00
|
|
|
|
|
|
|
if ((sd->pty->mouse_mode == MOUSE_OFF) ||
|
|
|
|
(sd->pty->mouse_mode == MOUSE_X10))
|
|
|
|
return EINA_FALSE;
|
2012-10-04 16:19:17 -07:00
|
|
|
if (sd->mouse.button == ev->button)
|
|
|
|
sd->mouse.button = 0;
|
2012-10-24 14:34:36 -07:00
|
|
|
|
|
|
|
shift = evas_key_modifier_is_set(ev->modifiers, "Shift") ? 4 : 0;
|
|
|
|
meta = evas_key_modifier_is_set(ev->modifiers, "Alt") ? 8 : 0;
|
|
|
|
ctrl = evas_key_modifier_is_set(ev->modifiers, "Control") ? 16 : 0;
|
|
|
|
|
|
|
|
switch (sd->pty->mouse_ext)
|
2012-06-22 23:43:02 -07:00
|
|
|
{
|
2012-10-24 14:34:36 -07:00
|
|
|
case MOUSE_EXT_NONE:
|
|
|
|
if ((cx < (0xff - ' ')) && (cy < (0xff - ' ')))
|
|
|
|
{
|
|
|
|
buf[0] = 0x1b;
|
|
|
|
buf[1] = '[';
|
|
|
|
buf[2] = 'M';
|
2012-10-25 13:27:11 -07:00
|
|
|
buf[3] = (3 | shift | meta | ctrl) + ' ';
|
2012-10-24 14:34:36 -07:00
|
|
|
buf[4] = cx + 1 + ' ';
|
|
|
|
buf[5] = cy + 1 + ' ';
|
|
|
|
buf[6] = 0;
|
|
|
|
termpty_write(sd->pty, buf, strlen(buf));
|
|
|
|
ret = EINA_TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MOUSE_EXT_UTF8: // ESC.[.M.BTN/FLGS.XUTF8.YUTF8
|
2012-06-22 23:43:02 -07:00
|
|
|
{
|
|
|
|
int v, i;
|
2012-10-24 14:34:36 -07:00
|
|
|
|
2012-06-22 23:43:02 -07:00
|
|
|
buf[0] = 0x1b;
|
|
|
|
buf[1] = '[';
|
|
|
|
buf[2] = 'M';
|
2012-10-25 13:27:11 -07:00
|
|
|
buf[3] = (3 | shift | meta | ctrl) + ' ';
|
2012-06-22 23:43:02 -07:00
|
|
|
i = 4;
|
|
|
|
v = cx + 1 + ' ';
|
|
|
|
if (v <= 127) buf[i++] = v;
|
|
|
|
else
|
|
|
|
{ // 14 bits for cx/cy - enough i think
|
|
|
|
buf[i++] = 0xc0 + (v >> 6);
|
|
|
|
buf[i++] = 0x80 + (v & 0x3f);
|
|
|
|
}
|
|
|
|
v = cy + 1 + ' ';
|
|
|
|
if (v <= 127) buf[i++] = v;
|
|
|
|
else
|
|
|
|
{ // 14 bits for cx/cy - enough i think
|
|
|
|
buf[i++] = 0xc0 + (v >> 6);
|
|
|
|
buf[i++] = 0x80 + (v & 0x3f);
|
|
|
|
}
|
|
|
|
buf[i] = 0;
|
|
|
|
termpty_write(sd->pty, buf, strlen(buf));
|
2012-10-04 16:19:09 -07:00
|
|
|
ret = EINA_TRUE;
|
2012-06-22 23:43:02 -07:00
|
|
|
}
|
|
|
|
break;
|
2012-10-24 14:34:36 -07:00
|
|
|
case MOUSE_EXT_SGR: // ESC.[.<.NUM.;.NUM.;.NUM.m
|
2012-06-22 23:43:02 -07:00
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "%c[<%i;%i;%im", 0x1b,
|
2012-10-25 13:27:11 -07:00
|
|
|
(3 | shift | meta | ctrl), cx + 1, cy + 1);
|
2012-06-22 23:43:02 -07:00
|
|
|
termpty_write(sd->pty, buf, strlen(buf));
|
2012-10-04 16:19:09 -07:00
|
|
|
ret = EINA_TRUE;
|
2012-06-22 23:43:02 -07:00
|
|
|
}
|
|
|
|
break;
|
2012-10-24 14:34:36 -07:00
|
|
|
case MOUSE_EXT_URXVT: // ESC.[.NUM.;.NUM.;.NUM.M
|
2012-06-22 23:43:02 -07:00
|
|
|
{
|
2012-10-24 14:34:36 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%c[%i;%i;%iM", 0x1b,
|
2012-10-25 13:27:11 -07:00
|
|
|
(3 | shift | meta | ctrl) + ' ',
|
2012-10-24 14:34:36 -07:00
|
|
|
cx + 1 + ' ', cy + 1 + ' ');
|
2012-06-22 23:43:02 -07:00
|
|
|
termpty_write(sd->pty, buf, strlen(buf));
|
2012-10-04 16:19:09 -07:00
|
|
|
ret = EINA_TRUE;
|
2012-06-22 23:43:02 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2012-10-04 16:19:09 -07:00
|
|
|
return ret;
|
2012-06-22 23:43:02 -07:00
|
|
|
}
|
|
|
|
|
2012-10-04 16:19:09 -07:00
|
|
|
static Eina_Bool
|
2012-10-04 16:19:17 -07:00
|
|
|
_rep_mouse_move(Termio *sd, Evas_Event_Mouse_Move *ev, int cx __UNUSED__, int cy __UNUSED__, Eina_Bool change)
|
2012-06-22 23:43:02 -07:00
|
|
|
{
|
2012-10-04 16:19:17 -07:00
|
|
|
char buf[64];
|
2012-10-04 16:19:09 -07:00
|
|
|
Eina_Bool ret = EINA_FALSE;
|
2012-10-24 14:34:36 -07:00
|
|
|
int btn, shift, meta, ctrl;
|
|
|
|
|
|
|
|
if ((sd->pty->mouse_mode == MOUSE_OFF) ||
|
|
|
|
(sd->pty->mouse_mode == MOUSE_X10) ||
|
|
|
|
(sd->pty->mouse_mode == MOUSE_NORMAL))
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
if ((!sd->mouse.button) && (sd->pty->mouse_mode == MOUSE_NORMAL_BTN_MOVE))
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
if (!change) return EINA_TRUE;
|
|
|
|
|
|
|
|
btn = sd->mouse.button - 1;
|
|
|
|
shift = evas_key_modifier_is_set(ev->modifiers, "Shift") ? 4 : 0;
|
|
|
|
meta = evas_key_modifier_is_set(ev->modifiers, "Alt") ? 8 : 0;
|
|
|
|
ctrl = evas_key_modifier_is_set(ev->modifiers, "Control") ? 16 : 0;
|
|
|
|
|
|
|
|
switch (sd->pty->mouse_ext)
|
2012-10-04 16:19:17 -07:00
|
|
|
{
|
2012-10-24 14:34:36 -07:00
|
|
|
case MOUSE_EXT_NONE:
|
|
|
|
if ((cx < (0xff - ' ')) && (cy < (0xff - ' ')))
|
|
|
|
{
|
|
|
|
if (btn > 2) btn = 0;
|
|
|
|
buf[0] = 0x1b;
|
|
|
|
buf[1] = '[';
|
|
|
|
buf[2] = 'M';
|
2012-11-24 11:55:37 -08:00
|
|
|
buf[3] = (btn | shift | meta | ctrl | 32) + ' ';
|
2012-10-24 14:34:36 -07:00
|
|
|
buf[4] = cx + 1 + ' ';
|
|
|
|
buf[5] = cy + 1 + ' ';
|
|
|
|
buf[6] = 0;
|
|
|
|
termpty_write(sd->pty, buf, strlen(buf));
|
|
|
|
ret = EINA_TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MOUSE_EXT_UTF8: // ESC.[.M.BTN/FLGS.XUTF8.YUTF8
|
2012-10-04 16:19:17 -07:00
|
|
|
{
|
|
|
|
int v, i;
|
2012-10-24 14:34:36 -07:00
|
|
|
|
2012-10-04 16:19:17 -07:00
|
|
|
if (btn > 2) btn = 0;
|
|
|
|
buf[0] = 0x1b;
|
|
|
|
buf[1] = '[';
|
|
|
|
buf[2] = 'M';
|
2012-11-24 12:27:40 -08:00
|
|
|
buf[3] = (btn | shift | meta | ctrl | 32) + ' ';
|
2012-10-04 16:19:17 -07:00
|
|
|
i = 4;
|
|
|
|
v = cx + 1 + ' ';
|
|
|
|
if (v <= 127) buf[i++] = v;
|
|
|
|
else
|
|
|
|
{ // 14 bits for cx/cy - enough i think
|
|
|
|
buf[i++] = 0xc0 + (v >> 6);
|
|
|
|
buf[i++] = 0x80 + (v & 0x3f);
|
|
|
|
}
|
|
|
|
v = cy + 1 + ' ';
|
|
|
|
if (v <= 127) buf[i++] = v;
|
|
|
|
else
|
|
|
|
{ // 14 bits for cx/cy - enough i think
|
|
|
|
buf[i++] = 0xc0 + (v >> 6);
|
|
|
|
buf[i++] = 0x80 + (v & 0x3f);
|
|
|
|
}
|
|
|
|
buf[i] = 0;
|
|
|
|
termpty_write(sd->pty, buf, strlen(buf));
|
2012-10-24 14:34:36 -07:00
|
|
|
ret = EINA_TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MOUSE_EXT_SGR: // ESC.[.<.NUM.;.NUM.;.NUM.M
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "%c[<%i;%i;%iM", 0x1b,
|
2012-11-24 12:27:40 -08:00
|
|
|
(btn | shift | meta | ctrl | 32), cx + 1, cy + 1);
|
2012-10-24 14:34:36 -07:00
|
|
|
termpty_write(sd->pty, buf, strlen(buf));
|
|
|
|
ret = EINA_TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MOUSE_EXT_URXVT: // ESC.[.NUM.;.NUM.;.NUM.M
|
|
|
|
{
|
|
|
|
if (btn > 2) btn = 0;
|
|
|
|
snprintf(buf, sizeof(buf), "%c[%i;%i;%iM", 0x1b,
|
2012-11-24 12:27:40 -08:00
|
|
|
(btn | shift | meta | ctrl | 32) + ' ',
|
2012-10-24 14:34:36 -07:00
|
|
|
cx + 1 + ' ', cy + 1 + ' ');
|
|
|
|
termpty_write(sd->pty, buf, strlen(buf));
|
|
|
|
ret = EINA_TRUE;
|
2012-10-04 16:19:17 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2012-10-04 16:19:09 -07:00
|
|
|
return ret;
|
2012-06-22 23:43:02 -07:00
|
|
|
}
|
|
|
|
|
2012-11-20 13:18:42 -08:00
|
|
|
#if defined(SUPPORT_DBLWIDTH)
|
2012-06-26 03:30:41 -07:00
|
|
|
static void
|
|
|
|
_selection_dbl_fix(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Termio *sd;
|
|
|
|
int w = 0;
|
|
|
|
Termcell *cells;
|
|
|
|
|
|
|
|
sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
|
|
|
cells = termpty_cellrow_get(sd->pty, sd->cur.sel2.y - sd->scroll, &w);
|
|
|
|
if (cells)
|
|
|
|
{
|
|
|
|
// if sel2 after sel1
|
|
|
|
if ((sd->cur.sel2.y > sd->cur.sel1.y) ||
|
|
|
|
((sd->cur.sel2.y == sd->cur.sel1.y) &&
|
|
|
|
(sd->cur.sel2.x >= sd->cur.sel1.x)))
|
|
|
|
{
|
|
|
|
if (sd->cur.sel2.x < (w - 1))
|
|
|
|
{
|
|
|
|
if ((cells[sd->cur.sel2.x].codepoint != 0) &&
|
|
|
|
(cells[sd->cur.sel2.x].att.dblwidth))
|
|
|
|
sd->cur.sel2.x++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// else sel1 after sel 2
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (sd->cur.sel2.x > 0)
|
|
|
|
{
|
|
|
|
if ((cells[sd->cur.sel2.x].codepoint == 0) &&
|
|
|
|
(cells[sd->cur.sel2.x].att.dblwidth))
|
|
|
|
sd->cur.sel2.x--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cells = termpty_cellrow_get(sd->pty, sd->cur.sel1.y - sd->scroll, &w);
|
|
|
|
if (cells)
|
|
|
|
{
|
|
|
|
// if sel2 after sel1
|
|
|
|
if ((sd->cur.sel2.y > sd->cur.sel1.y) ||
|
|
|
|
((sd->cur.sel2.y == sd->cur.sel1.y) &&
|
|
|
|
(sd->cur.sel2.x >= sd->cur.sel1.x)))
|
|
|
|
{
|
|
|
|
if (sd->cur.sel1.x > 0)
|
|
|
|
{
|
|
|
|
if ((cells[sd->cur.sel1.x].codepoint == 0) &&
|
|
|
|
(cells[sd->cur.sel1.x].att.dblwidth))
|
|
|
|
sd->cur.sel1.x--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// else sel1 after sel 2
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (sd->cur.sel1.x < (w - 1))
|
|
|
|
{
|
|
|
|
if ((cells[sd->cur.sel1.x].codepoint != 0) &&
|
|
|
|
(cells[sd->cur.sel1.x].att.dblwidth))
|
|
|
|
sd->cur.sel1.x++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-11-20 13:18:42 -08:00
|
|
|
#endif
|
2012-06-26 03:30:41 -07:00
|
|
|
|
2012-12-27 18:28:39 -08:00
|
|
|
static void
|
|
|
|
_selection_newline_extend_fix(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Termio *sd;
|
|
|
|
|
|
|
|
sd = evas_object_smart_data_get(obj);
|
|
|
|
if ((!sd->top_left) && (sd->cur.sel2.y >= sd->cur.sel1.y))
|
|
|
|
{
|
|
|
|
if (((sd->cur.sel1.y == sd->cur.sel2.y) &&
|
|
|
|
(sd->cur.sel1.x <= sd->cur.sel2.x)) ||
|
|
|
|
(sd->cur.sel1.y < sd->cur.sel2.y))
|
|
|
|
{
|
|
|
|
char *lastline;
|
|
|
|
int x1, y1, x2, y2;
|
|
|
|
|
|
|
|
if (sd->cur.sel1.y == sd->cur.sel2.y) x1 = sd->cur.sel1.x;
|
|
|
|
else x1 = 0;
|
|
|
|
x2 = sd->cur.sel2.x;
|
|
|
|
y1 = y2 = sd->cur.sel2.y;
|
|
|
|
lastline = termio_selection_get(obj, x1, y1, x2, y2);
|
|
|
|
if (lastline)
|
|
|
|
{
|
|
|
|
int len = strlen(lastline);
|
|
|
|
|
|
|
|
if ((len > 0) && (lastline[len - 1] == '\n'))
|
|
|
|
{
|
|
|
|
sd->cur.sel2.x = sd->grid.w - 1;
|
|
|
|
#if defined(SUPPORT_DBLWIDTH)
|
|
|
|
_selection_dbl_fix(obj);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
free(lastline);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-03 08:25:19 -07:00
|
|
|
static void
|
|
|
|
_smart_cb_mouse_move_job(void *data)
|
|
|
|
{
|
|
|
|
Termio *sd;
|
|
|
|
|
|
|
|
sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return;
|
|
|
|
sd->mouse_move_job = NULL;
|
2013-01-30 21:23:25 -08:00
|
|
|
if (sd->mouseover_delay) ecore_timer_del(sd->mouseover_delay);
|
|
|
|
sd->mouseover_delay = ecore_timer_add(0.05, _smart_mouseover_delay, data);
|
2012-07-03 08:25:19 -07:00
|
|
|
}
|
|
|
|
|
2012-07-18 01:36:28 -07:00
|
|
|
static void
|
|
|
|
_edje_cb_bottom_right_in(void *data, Evas_Object *obj __UNUSED__,
|
|
|
|
const char *emission __UNUSED__, const char *source __UNUSED__)
|
|
|
|
{
|
|
|
|
Termio *sd = data;
|
|
|
|
|
|
|
|
sd->bottom_right = EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_edje_cb_top_left_in(void *data, Evas_Object *obj __UNUSED__,
|
|
|
|
const char *emission __UNUSED__, const char *source __UNUSED__)
|
|
|
|
{
|
|
|
|
Termio *sd = data;
|
|
|
|
|
|
|
|
sd->top_left = EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_edje_cb_bottom_right_out(void *data, Evas_Object *obj __UNUSED__,
|
|
|
|
const char *emission __UNUSED__, const char *source __UNUSED__)
|
|
|
|
{
|
|
|
|
Termio *sd = data;
|
|
|
|
|
|
|
|
sd->bottom_right = EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_edje_cb_top_left_out(void *data, Evas_Object *obj __UNUSED__,
|
|
|
|
const char *emission __UNUSED__, const char *source __UNUSED__)
|
|
|
|
{
|
|
|
|
Termio *sd = data;
|
|
|
|
|
|
|
|
sd->top_left = EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
static void
|
2012-06-17 10:04:17 -07:00
|
|
|
_smart_cb_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
|
|
|
Evas_Event_Mouse_Down *ev = event;
|
|
|
|
Termio *sd;
|
|
|
|
int cx, cy;
|
|
|
|
|
|
|
|
sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return;
|
|
|
|
_smart_xy_to_cursor(data, ev->canvas.x, ev->canvas.y, &cx, &cy);
|
2012-07-04 07:44:43 -07:00
|
|
|
sd->didclick = EINA_FALSE;
|
2013-02-14 13:44:16 -08:00
|
|
|
sd->boxsel = EINA_FALSE;
|
2012-10-05 00:50:16 -07:00
|
|
|
if ((ev->button == 3) && evas_key_modifier_is_set(ev->modifiers, "Control"))
|
|
|
|
{
|
|
|
|
evas_object_smart_callback_call(data, "options", NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (_rep_mouse_down(sd, ev, cx, cy)) return;
|
2012-06-12 03:10:01 -07:00
|
|
|
if (ev->button == 1)
|
|
|
|
{
|
|
|
|
if (ev->flags & EVAS_BUTTON_TRIPLE_CLICK)
|
|
|
|
{
|
|
|
|
_sel_line(data, cx, cy - sd->scroll);
|
2012-06-23 23:39:54 -07:00
|
|
|
if (sd->cur.sel) _take_selection(data, ELM_SEL_TYPE_PRIMARY);
|
2012-07-04 07:44:43 -07:00
|
|
|
sd->didclick = EINA_TRUE;
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
else if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
|
|
|
|
{
|
2012-06-18 01:56:27 -07:00
|
|
|
if (evas_key_modifier_is_set(ev->modifiers, "Shift") && sd->backup.sel)
|
|
|
|
{
|
|
|
|
sd->cur.sel = 1;
|
|
|
|
sd->cur.sel1.x = sd->backup.sel1.x;
|
|
|
|
sd->cur.sel1.y = sd->backup.sel1.y;
|
|
|
|
sd->cur.sel2.x = sd->backup.sel2.x;
|
|
|
|
sd->cur.sel2.y = sd->backup.sel2.y;
|
2012-11-20 13:18:42 -08:00
|
|
|
#if defined(SUPPORT_DBLWIDTH)
|
2012-06-26 03:30:41 -07:00
|
|
|
_selection_dbl_fix(data);
|
2012-11-20 13:18:42 -08:00
|
|
|
#endif
|
2012-06-18 01:56:27 -07:00
|
|
|
_sel_word_to(data, cx, cy - sd->scroll);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_sel_word(data, cx, cy - sd->scroll);
|
|
|
|
}
|
2012-06-23 23:39:54 -07:00
|
|
|
if (sd->cur.sel) _take_selection(data, ELM_SEL_TYPE_PRIMARY);
|
2012-07-04 07:44:43 -07:00
|
|
|
sd->didclick = EINA_TRUE;
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-02-16 06:44:45 -08:00
|
|
|
if (evas_key_modifier_is_set(ev->modifiers, "Shift") ||
|
|
|
|
evas_key_modifier_is_set(ev->modifiers, "Control") ||
|
|
|
|
evas_key_modifier_is_set(ev->modifiers, "Alt"))
|
2013-02-14 13:44:16 -08:00
|
|
|
{
|
|
|
|
sd->cur.sel1.x = cx;
|
|
|
|
sd->cur.sel1.y = cy - sd->scroll;
|
|
|
|
sd->cur.sel2.x = cx;
|
|
|
|
sd->cur.sel2.y = cy - sd->scroll;
|
|
|
|
sd->cur.sel = EINA_TRUE;
|
|
|
|
sd->cur.makesel = EINA_TRUE;
|
|
|
|
sd->boxsel = EINA_TRUE;
|
|
|
|
#if defined(SUPPORT_DBLWIDTH)
|
|
|
|
_selection_dbl_fix(data);
|
|
|
|
#endif
|
|
|
|
}
|
2012-07-18 01:36:28 -07:00
|
|
|
if (sd->top_left || sd->bottom_right)
|
2012-07-04 07:44:43 -07:00
|
|
|
{
|
2012-07-18 01:36:28 -07:00
|
|
|
sd->cur.makesel = 1;
|
|
|
|
sd->cur.sel = 1;
|
|
|
|
if (sd->top_left)
|
|
|
|
{
|
|
|
|
sd->cur.sel1.x = cx;
|
|
|
|
sd->cur.sel1.y = cy - sd->scroll;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sd->cur.sel2.x = cx;
|
|
|
|
sd->cur.sel2.y = cy - sd->scroll;
|
|
|
|
}
|
2012-11-20 13:18:42 -08:00
|
|
|
#if defined(SUPPORT_DBLWIDTH)
|
2012-07-18 01:36:28 -07:00
|
|
|
_selection_dbl_fix(data);
|
2012-11-20 13:18:42 -08:00
|
|
|
#endif
|
2012-07-18 01:36:28 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sd->backup.sel = sd->cur.sel;
|
|
|
|
sd->backup.sel1.x = sd->cur.sel1.x;
|
|
|
|
sd->backup.sel1.y = sd->cur.sel1.y;
|
|
|
|
sd->backup.sel2.x = sd->cur.sel2.x;
|
|
|
|
sd->backup.sel2.y = sd->cur.sel2.y;
|
|
|
|
if (sd->cur.sel)
|
|
|
|
{
|
|
|
|
sd->cur.sel = 0;
|
|
|
|
sd->didclick = EINA_TRUE;
|
|
|
|
}
|
|
|
|
sd->cur.makesel = 1;
|
|
|
|
sd->cur.sel1.x = cx;
|
|
|
|
sd->cur.sel1.y = cy - sd->scroll;
|
|
|
|
sd->cur.sel2.x = cx;
|
|
|
|
sd->cur.sel2.y = cy - sd->scroll;
|
2012-11-20 13:18:42 -08:00
|
|
|
#if defined(SUPPORT_DBLWIDTH)
|
2012-07-18 01:36:28 -07:00
|
|
|
_selection_dbl_fix(data);
|
2012-11-20 13:18:42 -08:00
|
|
|
#endif
|
2012-07-04 07:44:43 -07:00
|
|
|
}
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
2012-06-18 05:14:36 -07:00
|
|
|
_smart_update_queue(data, sd);
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
else if (ev->button == 2)
|
2012-10-03 05:23:06 -07:00
|
|
|
{
|
2012-10-04 16:19:09 -07:00
|
|
|
_paste_selection(data, ELM_SEL_TYPE_PRIMARY);
|
2012-10-03 05:23:06 -07:00
|
|
|
}
|
2012-06-12 03:10:01 -07:00
|
|
|
else if (ev->button == 3)
|
2012-10-04 16:19:09 -07:00
|
|
|
{
|
2013-01-22 07:01:53 -08:00
|
|
|
elm_object_focus_set(data, EINA_TRUE);
|
2012-10-04 16:19:09 -07:00
|
|
|
evas_object_smart_callback_call(data, "options", NULL);
|
|
|
|
}
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-17 10:04:17 -07:00
|
|
|
_smart_cb_mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
|
|
|
Evas_Event_Mouse_Up *ev = event;
|
|
|
|
Termio *sd;
|
2013-01-28 16:43:13 -08:00
|
|
|
int cx, cy;
|
2012-06-12 03:10:01 -07:00
|
|
|
|
|
|
|
sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return;
|
|
|
|
_smart_xy_to_cursor(data, ev->canvas.x, ev->canvas.y, &cx, &cy);
|
2012-10-04 16:19:13 -07:00
|
|
|
if (_rep_mouse_up(sd, ev, cx, cy)) return;
|
2013-02-21 05:23:48 -08:00
|
|
|
if (sd->link.down.dnd) return;
|
2012-06-12 03:10:01 -07:00
|
|
|
if (sd->cur.makesel)
|
|
|
|
{
|
|
|
|
sd->cur.makesel = 0;
|
|
|
|
if (sd->cur.sel)
|
|
|
|
{
|
2012-07-04 07:44:43 -07:00
|
|
|
sd->didclick = EINA_TRUE;
|
2012-07-18 01:36:28 -07:00
|
|
|
if (sd->top_left)
|
|
|
|
{
|
|
|
|
sd->cur.sel1.x = cx;
|
|
|
|
sd->cur.sel1.y = cy - sd->scroll;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sd->cur.sel2.x = cx;
|
|
|
|
sd->cur.sel2.y = cy - sd->scroll;
|
|
|
|
}
|
2012-11-20 13:18:42 -08:00
|
|
|
#if defined(SUPPORT_DBLWIDTH)
|
2012-06-26 03:30:41 -07:00
|
|
|
_selection_dbl_fix(data);
|
2012-11-20 13:18:42 -08:00
|
|
|
#endif
|
2013-02-14 13:44:16 -08:00
|
|
|
if (sd->boxsel)
|
|
|
|
{
|
|
|
|
sd->cur.sel2.x = cx;
|
|
|
|
sd->cur.sel2.y = cy - sd->scroll;
|
|
|
|
_smart_update_queue(data, sd);
|
|
|
|
_take_selection(data, ELM_SEL_TYPE_PRIMARY);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_selection_newline_extend_fix(data);
|
|
|
|
_smart_update_queue(data, sd);
|
|
|
|
_take_selection(data, ELM_SEL_TYPE_PRIMARY);
|
|
|
|
}
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static void
|
2012-06-17 10:04:17 -07:00
|
|
|
_smart_cb_mouse_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
|
|
|
Evas_Event_Mouse_Move *ev = event;
|
|
|
|
Termio *sd;
|
|
|
|
int cx, cy;
|
2012-07-03 08:25:19 -07:00
|
|
|
Eina_Bool mc_change = EINA_FALSE;
|
2012-06-12 03:10:01 -07:00
|
|
|
|
|
|
|
sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return;
|
|
|
|
_smart_xy_to_cursor(data, ev->cur.canvas.x, ev->cur.canvas.y, &cx, &cy);
|
2012-07-03 08:25:19 -07:00
|
|
|
if ((sd->mouse.cx != cx) || (sd->mouse.cy != cy)) mc_change = EINA_TRUE;
|
|
|
|
sd->mouse.cx = cx;
|
|
|
|
sd->mouse.cy = cy;
|
2012-10-04 16:19:17 -07:00
|
|
|
if (_rep_mouse_move(sd, ev, cx, cy, mc_change)) return;
|
2013-02-21 05:23:48 -08:00
|
|
|
if (sd->link.down.dnd)
|
|
|
|
{
|
|
|
|
sd->cur.makesel = 0;
|
|
|
|
sd->cur.sel = 0;
|
|
|
|
_smart_update_queue(data, sd);
|
|
|
|
return;
|
|
|
|
}
|
2012-06-12 03:10:01 -07:00
|
|
|
if (sd->cur.makesel)
|
|
|
|
{
|
|
|
|
if (!sd->cur.sel)
|
|
|
|
{
|
|
|
|
if ((cx != sd->cur.sel1.x) ||
|
|
|
|
((cy - sd->scroll) != sd->cur.sel1.y))
|
|
|
|
sd->cur.sel = 1;
|
|
|
|
}
|
2012-07-18 01:36:28 -07:00
|
|
|
if (sd->top_left)
|
|
|
|
{
|
|
|
|
sd->cur.sel1.x = cx;
|
|
|
|
sd->cur.sel1.y = cy - sd->scroll;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sd->cur.sel2.x = cx;
|
|
|
|
sd->cur.sel2.y = cy - sd->scroll;
|
|
|
|
}
|
2012-11-20 13:18:42 -08:00
|
|
|
#if defined(SUPPORT_DBLWIDTH)
|
2012-06-26 03:30:41 -07:00
|
|
|
_selection_dbl_fix(data);
|
2012-11-20 13:18:42 -08:00
|
|
|
#endif
|
2013-02-14 13:44:16 -08:00
|
|
|
if (!sd->boxsel)
|
|
|
|
_selection_newline_extend_fix(data);
|
|
|
|
_smart_update_queue(data, sd);
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
2012-07-03 08:25:19 -07:00
|
|
|
if (mc_change)
|
|
|
|
{
|
|
|
|
if (sd->mouse_move_job) ecore_job_del(sd->mouse_move_job);
|
|
|
|
sd->mouse_move_job = ecore_job_add(_smart_cb_mouse_move_job, data);
|
|
|
|
}
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
|
2012-07-04 07:44:43 -07:00
|
|
|
static void
|
|
|
|
_smart_cb_mouse_in(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
|
|
|
|
{
|
|
|
|
termio_mouseover_suspend_pushpop(data, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_smart_cb_mouse_out(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
|
|
|
|
{
|
|
|
|
termio_mouseover_suspend_pushpop(data, 1);
|
|
|
|
}
|
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
static void
|
2012-06-17 10:04:17 -07:00
|
|
|
_smart_cb_mouse_wheel(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
|
|
|
Evas_Event_Mouse_Wheel *ev = event;
|
|
|
|
Termio *sd;
|
|
|
|
|
|
|
|
sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return;
|
2012-07-01 20:47:02 -07:00
|
|
|
if (evas_key_modifier_is_set(ev->modifiers, "Control")) return;
|
|
|
|
if (evas_key_modifier_is_set(ev->modifiers, "Alt")) return;
|
|
|
|
if (evas_key_modifier_is_set(ev->modifiers, "Shift")) return;
|
2012-10-25 12:36:46 -07:00
|
|
|
|
|
|
|
if (sd->pty->mouse_mode == MOUSE_OFF)
|
|
|
|
{
|
|
|
|
|
|
|
|
sd->scroll -= (ev->z * 4);
|
|
|
|
if (sd->scroll > sd->pty->backscroll_num)
|
|
|
|
sd->scroll = sd->pty->backscroll_num;
|
|
|
|
else if (sd->scroll < 0) sd->scroll = 0;
|
|
|
|
_smart_update_queue(data, sd);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char buf[64];
|
|
|
|
int btn = (ev->z >= 0) ? 1 + 64 : 2 + 64;
|
|
|
|
int cx, cy;
|
|
|
|
|
|
|
|
_smart_xy_to_cursor(data, ev->canvas.x, ev->canvas.y, &cx, &cy);
|
|
|
|
|
|
|
|
switch (sd->pty->mouse_ext)
|
|
|
|
{
|
|
|
|
case MOUSE_EXT_NONE:
|
|
|
|
if ((cx < (0xff - ' ')) && (cy < (0xff - ' ')))
|
|
|
|
{
|
|
|
|
buf[0] = 0x1b;
|
|
|
|
buf[1] = '[';
|
|
|
|
buf[2] = 'M';
|
|
|
|
buf[3] = btn + ' ';
|
|
|
|
buf[4] = cx + 1 + ' ';
|
|
|
|
buf[5] = cy + 1 + ' ';
|
|
|
|
buf[6] = 0;
|
|
|
|
termpty_write(sd->pty, buf, strlen(buf));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MOUSE_EXT_UTF8: // ESC.[.M.BTN/FLGS.XUTF8.YUTF8
|
|
|
|
{
|
|
|
|
int v, i;
|
|
|
|
|
|
|
|
buf[0] = 0x1b;
|
|
|
|
buf[1] = '[';
|
|
|
|
buf[2] = 'M';
|
|
|
|
buf[3] = btn + ' ';
|
|
|
|
i = 4;
|
|
|
|
v = cx + 1 + ' ';
|
|
|
|
if (v <= 127) buf[i++] = v;
|
|
|
|
else
|
|
|
|
{ // 14 bits for cx/cy - enough i think
|
|
|
|
buf[i++] = 0xc0 + (v >> 6);
|
|
|
|
buf[i++] = 0x80 + (v & 0x3f);
|
|
|
|
}
|
|
|
|
v = cy + 1 + ' ';
|
|
|
|
if (v <= 127) buf[i++] = v;
|
|
|
|
else
|
|
|
|
{ // 14 bits for cx/cy - enough i think
|
|
|
|
buf[i++] = 0xc0 + (v >> 6);
|
|
|
|
buf[i++] = 0x80 + (v & 0x3f);
|
|
|
|
}
|
|
|
|
buf[i] = 0;
|
|
|
|
termpty_write(sd->pty, buf, strlen(buf));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MOUSE_EXT_SGR: // ESC.[.<.NUM.;.NUM.;.NUM.M
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "%c[<%i;%i;%iM", 0x1b,
|
|
|
|
btn, cx + 1, cy + 1);
|
|
|
|
termpty_write(sd->pty, buf, strlen(buf));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MOUSE_EXT_URXVT: // ESC.[.NUM.;.NUM.;.NUM.M
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "%c[%i;%i;%iM", 0x1b,
|
|
|
|
btn + ' ',
|
|
|
|
cx + 1 + ' ', cy + 1 + ' ');
|
|
|
|
termpty_write(sd->pty, buf, strlen(buf));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
|
2012-06-15 22:07:33 -07:00
|
|
|
static void
|
2012-06-17 10:04:17 -07:00
|
|
|
_win_obj_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event __UNUSED__)
|
2012-06-15 22:07:33 -07:00
|
|
|
{
|
|
|
|
Termio *sd;
|
|
|
|
|
|
|
|
sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return;
|
|
|
|
if (obj == sd->win)
|
|
|
|
{
|
|
|
|
evas_object_event_callback_del_full(sd->win, EVAS_CALLBACK_DEL,
|
|
|
|
_win_obj_del, data);
|
|
|
|
sd->win = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
static void
|
2012-06-17 13:24:23 -07:00
|
|
|
_termio_config_set(Evas_Object *obj, Config *config)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2012-06-17 13:24:23 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
2012-06-15 22:07:33 -07:00
|
|
|
Evas_Coord w = 2, h = 2;
|
2012-06-17 13:24:23 -07:00
|
|
|
|
|
|
|
sd->config = config;
|
2012-06-12 03:10:01 -07:00
|
|
|
|
|
|
|
sd->jump_on_change = config->jump_on_change;
|
2012-07-04 21:36:47 -07:00
|
|
|
sd->jump_on_keypress = config->jump_on_keypress;
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2012-06-15 22:07:33 -07:00
|
|
|
if (config->font.bitmap)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2012-06-17 13:24:23 -07:00
|
|
|
char buf[PATH_MAX];
|
2012-06-15 22:07:33 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/fonts/%s",
|
|
|
|
elm_app_data_dir_get(), config->font.name);
|
|
|
|
sd->font.name = eina_stringshare_add(buf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
sd->font.name = eina_stringshare_add(config->font.name);
|
|
|
|
sd->font.size = config->font.size;
|
2012-06-17 13:24:23 -07:00
|
|
|
|
2012-06-18 00:54:40 -07:00
|
|
|
evas_object_scale_set(sd->grid.obj, elm_config_scale_get());
|
2012-06-17 13:24:23 -07:00
|
|
|
evas_object_textgrid_font_set(sd->grid.obj, sd->font.name, sd->font.size);
|
|
|
|
evas_object_textgrid_size_set(sd->grid.obj, 1, 1);
|
|
|
|
evas_object_textgrid_cell_size_get(sd->grid.obj, &w, &h);
|
|
|
|
if (w < 1) w = 1;
|
|
|
|
if (h < 1) h = 1;
|
|
|
|
sd->font.chw = w;
|
|
|
|
sd->font.chh = h;
|
|
|
|
|
2012-06-19 08:59:49 -07:00
|
|
|
theme_apply(sd->cur.obj, config, "terminology/cursor");
|
|
|
|
theme_auto_reload_enable(sd->cur.obj);
|
2012-06-17 13:24:23 -07:00
|
|
|
evas_object_resize(sd->cur.obj, sd->font.chw, sd->font.chh);
|
|
|
|
evas_object_show(sd->cur.obj);
|
2012-07-11 05:09:00 -07:00
|
|
|
|
|
|
|
theme_apply(sd->cur.selo_theme, config, "terminology/selection");
|
|
|
|
theme_auto_reload_enable(sd->cur.selo_theme);
|
2012-10-21 19:12:55 -07:00
|
|
|
edje_object_part_swallow(sd->cur.selo_theme, "terminology.top_left", sd->cur.selo_top);
|
|
|
|
edje_object_part_swallow(sd->cur.selo_theme, "terminology.bottom_right", sd->cur.selo_bottom);
|
2012-06-17 13:24:23 -07:00
|
|
|
}
|
|
|
|
|
2012-06-18 21:16:36 -07:00
|
|
|
static void
|
2012-06-19 02:59:30 -07:00
|
|
|
_cursor_cb_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
|
2012-06-18 21:16:36 -07:00
|
|
|
{
|
|
|
|
Termio *sd;
|
|
|
|
|
|
|
|
sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return;
|
|
|
|
_imf_cursor_set(sd);
|
|
|
|
}
|
|
|
|
|
2012-07-01 20:47:02 -07:00
|
|
|
static Evas_Event_Flags
|
2012-07-02 22:28:31 -07:00
|
|
|
_smart_cb_gest_long_move(void *data, void *event __UNUSED__)
|
2012-07-01 20:47:02 -07:00
|
|
|
{
|
|
|
|
// Elm_Gesture_Taps_Info *p = event;
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
|
|
|
|
if (!sd) return EVAS_EVENT_FLAG_ON_HOLD;
|
|
|
|
evas_object_smart_callback_call(data, "options", NULL);
|
2012-07-04 07:44:43 -07:00
|
|
|
sd->didclick = EINA_TRUE;
|
2012-07-01 20:47:02 -07:00
|
|
|
return EVAS_EVENT_FLAG_ON_HOLD;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Event_Flags
|
|
|
|
_smart_cb_gest_zoom_start(void *data, void *event)
|
|
|
|
{
|
|
|
|
Elm_Gesture_Zoom_Info *p = event;
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
Config *config = termio_config_get(data);
|
|
|
|
|
|
|
|
if (!sd) return EVAS_EVENT_FLAG_ON_HOLD;
|
|
|
|
if (config)
|
|
|
|
{
|
2013-02-18 08:07:30 -08:00
|
|
|
int sz;
|
|
|
|
|
2012-07-01 20:47:02 -07:00
|
|
|
sd->zoom_fontsize_start = config->font.size;
|
2013-02-18 08:07:30 -08:00
|
|
|
sz = (double)sd->zoom_fontsize_start * p->zoom;
|
|
|
|
if (sz != config->font.size) _font_size_set(data, sz);
|
2012-07-01 20:47:02 -07:00
|
|
|
}
|
2012-07-04 07:44:43 -07:00
|
|
|
sd->didclick = EINA_TRUE;
|
2012-07-01 20:47:02 -07:00
|
|
|
return EVAS_EVENT_FLAG_ON_HOLD;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Event_Flags
|
|
|
|
_smart_cb_gest_zoom_move(void *data, void *event)
|
|
|
|
{
|
|
|
|
Elm_Gesture_Zoom_Info *p = event;
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
Config *config = termio_config_get(data);
|
|
|
|
|
|
|
|
if (!sd) return EVAS_EVENT_FLAG_ON_HOLD;
|
|
|
|
if (config)
|
|
|
|
{
|
2013-02-18 08:07:30 -08:00
|
|
|
int sz = (double)sd->zoom_fontsize_start *
|
|
|
|
(1.0 + ((p->zoom - 1.0) / 30.0));
|
|
|
|
if (sz != config->font.size) _font_size_set(data, sz);
|
2012-07-01 20:47:02 -07:00
|
|
|
}
|
2012-07-04 07:44:43 -07:00
|
|
|
sd->didclick = EINA_TRUE;
|
2012-07-01 20:47:02 -07:00
|
|
|
return EVAS_EVENT_FLAG_ON_HOLD;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Event_Flags
|
|
|
|
_smart_cb_gest_zoom_end(void *data, void *event)
|
|
|
|
{
|
|
|
|
Elm_Gesture_Zoom_Info *p = event;
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
Config *config = termio_config_get(data);
|
|
|
|
|
|
|
|
if (!sd) return EVAS_EVENT_FLAG_ON_HOLD;
|
|
|
|
if (config)
|
|
|
|
{
|
2013-02-18 08:07:30 -08:00
|
|
|
int sz = (double)sd->zoom_fontsize_start *
|
|
|
|
(1.0 + ((p->zoom - 1.0) / 30.0));
|
|
|
|
if (sz != config->font.size) _font_size_set(data, sz);
|
2012-07-01 20:47:02 -07:00
|
|
|
}
|
2012-07-04 07:44:43 -07:00
|
|
|
sd->didclick = EINA_TRUE;
|
2012-07-01 20:47:02 -07:00
|
|
|
return EVAS_EVENT_FLAG_ON_HOLD;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Event_Flags
|
|
|
|
_smart_cb_gest_zoom_abort(void *data, void *event __UNUSED__)
|
|
|
|
{
|
|
|
|
// Elm_Gesture_Zoom_Info *p = event;
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
Config *config = termio_config_get(data);
|
|
|
|
|
|
|
|
if (!sd) return EVAS_EVENT_FLAG_ON_HOLD;
|
|
|
|
if (config)
|
|
|
|
{
|
2013-02-18 08:07:30 -08:00
|
|
|
if (sd->zoom_fontsize_start != config->font.size)
|
|
|
|
_font_size_set(data, sd->zoom_fontsize_start);
|
2012-07-01 20:47:02 -07:00
|
|
|
}
|
2012-07-04 07:44:43 -07:00
|
|
|
sd->didclick = EINA_TRUE;
|
2012-07-01 20:47:02 -07:00
|
|
|
return EVAS_EVENT_FLAG_ON_HOLD;
|
|
|
|
}
|
|
|
|
|
2012-06-18 17:37:27 -07:00
|
|
|
static void
|
2012-07-01 20:47:02 -07:00
|
|
|
_imf_event_commit_cb(void *data, Ecore_IMF_Context *ctx __UNUSED__, void *event)
|
2012-06-18 17:37:27 -07:00
|
|
|
{
|
|
|
|
Termio *sd = data;
|
2012-07-01 20:47:02 -07:00
|
|
|
char *str = event;
|
2012-06-18 17:37:27 -07:00
|
|
|
DBG("IMF committed '%s'", str);
|
|
|
|
if (!str) return;
|
|
|
|
termpty_write(sd->pty, str, strlen(str));
|
|
|
|
}
|
|
|
|
|
2012-06-17 13:24:23 -07:00
|
|
|
static void
|
|
|
|
_smart_add(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Termio *sd;
|
2012-07-03 05:57:32 -07:00
|
|
|
Evas_Object *o;
|
2012-06-17 13:24:23 -07:00
|
|
|
|
|
|
|
sd = calloc(1, sizeof(Termio));
|
2012-12-29 05:45:38 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2012-06-17 13:24:23 -07:00
|
|
|
evas_object_smart_data_set(obj, sd);
|
|
|
|
|
2012-12-29 05:45:38 -08:00
|
|
|
_parent_sc.add(obj);
|
|
|
|
|
2012-07-18 01:36:28 -07:00
|
|
|
/* Terminal output widget */
|
2012-06-15 22:07:33 -07:00
|
|
|
o = evas_object_textgrid_add(evas_object_evas_get(obj));
|
|
|
|
evas_object_pass_events_set(o, EINA_TRUE);
|
|
|
|
evas_object_propagate_events_set(o, EINA_FALSE);
|
|
|
|
evas_object_smart_member_add(o, obj);
|
|
|
|
evas_object_show(o);
|
|
|
|
sd->grid.obj = o;
|
2012-06-17 13:24:23 -07:00
|
|
|
|
2012-07-18 01:36:28 -07:00
|
|
|
/* Setup cursor */
|
|
|
|
o = edje_object_add(evas_object_evas_get(obj));
|
|
|
|
evas_object_pass_events_set(o, EINA_TRUE);
|
|
|
|
evas_object_propagate_events_set(o, EINA_FALSE);
|
|
|
|
evas_object_smart_member_add(o, obj);
|
|
|
|
sd->cur.obj = o;
|
|
|
|
|
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOVE, _cursor_cb_move, obj);
|
|
|
|
|
|
|
|
/* Setup the selection widget */
|
2012-06-15 22:07:33 -07:00
|
|
|
o = evas_object_rectangle_add(evas_object_evas_get(obj));
|
|
|
|
evas_object_pass_events_set(o, EINA_TRUE);
|
|
|
|
evas_object_propagate_events_set(o, EINA_FALSE);
|
2012-07-11 05:09:00 -07:00
|
|
|
sd->cur.selo_top = o;
|
2012-06-15 22:07:33 -07:00
|
|
|
o = evas_object_rectangle_add(evas_object_evas_get(obj));
|
|
|
|
evas_object_pass_events_set(o, EINA_TRUE);
|
|
|
|
evas_object_propagate_events_set(o, EINA_FALSE);
|
2012-07-11 05:09:00 -07:00
|
|
|
sd->cur.selo_bottom = o;
|
|
|
|
o = edje_object_add(evas_object_evas_get(obj));
|
2012-06-15 22:07:33 -07:00
|
|
|
evas_object_smart_member_add(o, obj);
|
2012-07-11 05:09:00 -07:00
|
|
|
sd->cur.selo_theme = o;
|
2012-07-18 01:36:28 -07:00
|
|
|
edje_object_signal_callback_add(o, "mouse,in", "zone.bottom_right", _edje_cb_bottom_right_in, sd);
|
|
|
|
edje_object_signal_callback_add(o, "mouse,in", "zone.top_left", _edje_cb_top_left_in, sd);
|
|
|
|
edje_object_signal_callback_add(o, "mouse,out", "zone.bottom_right", _edje_cb_bottom_right_out, sd);
|
|
|
|
edje_object_signal_callback_add(o, "mouse,out", "zone.top_left", _edje_cb_top_left_out, sd);
|
2012-06-18 21:16:36 -07:00
|
|
|
|
2012-07-18 01:36:28 -07:00
|
|
|
/* Setup event catcher */
|
2012-06-15 22:07:33 -07:00
|
|
|
o = evas_object_rectangle_add(evas_object_evas_get(obj));
|
2012-07-11 05:09:00 -07:00
|
|
|
evas_object_repeat_events_set(o, EINA_TRUE);
|
2012-06-15 22:07:33 -07:00
|
|
|
evas_object_smart_member_add(o, obj);
|
|
|
|
sd->event = o;
|
|
|
|
evas_object_color_set(o, 0, 0, 0, 0);
|
|
|
|
evas_object_show(o);
|
2012-07-01 20:47:02 -07:00
|
|
|
|
2012-06-15 22:07:33 -07:00
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
|
|
|
|
_smart_cb_mouse_down, obj);
|
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP,
|
|
|
|
_smart_cb_mouse_up, obj);
|
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_MOVE,
|
|
|
|
_smart_cb_mouse_move, obj);
|
2012-07-04 07:44:43 -07:00
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_IN,
|
|
|
|
_smart_cb_mouse_in, obj);
|
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_OUT,
|
|
|
|
_smart_cb_mouse_out, obj);
|
2012-06-15 22:07:33 -07:00
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_WHEEL,
|
|
|
|
_smart_cb_mouse_wheel, obj);
|
2012-06-12 03:10:01 -07:00
|
|
|
|
|
|
|
evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN,
|
|
|
|
_smart_cb_key_down, obj);
|
2012-06-18 17:37:27 -07:00
|
|
|
evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_UP,
|
|
|
|
_smart_cb_key_up, obj);
|
2012-06-12 03:10:01 -07:00
|
|
|
evas_object_event_callback_add(obj, EVAS_CALLBACK_FOCUS_IN,
|
|
|
|
_smart_cb_focus_in, obj);
|
|
|
|
evas_object_event_callback_add(obj, EVAS_CALLBACK_FOCUS_OUT,
|
|
|
|
_smart_cb_focus_out, obj);
|
2012-06-18 17:37:27 -07:00
|
|
|
|
2012-07-04 07:44:43 -07:00
|
|
|
sd->link.suspend = 1;
|
|
|
|
|
2012-06-18 17:37:27 -07:00
|
|
|
if (ecore_imf_init())
|
|
|
|
{
|
|
|
|
const char *imf_id = ecore_imf_context_default_id_get();
|
|
|
|
Evas *e;
|
|
|
|
|
|
|
|
if (!imf_id) sd->imf = NULL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const Ecore_IMF_Context_Info *imf_info;
|
|
|
|
|
|
|
|
imf_info = ecore_imf_context_info_by_id_get(imf_id);
|
|
|
|
if ((!imf_info->canvas_type) ||
|
|
|
|
(strcmp(imf_info->canvas_type, "evas") == 0))
|
|
|
|
sd->imf = ecore_imf_context_add(imf_id);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
imf_id = ecore_imf_context_default_id_by_canvas_type_get("evas");
|
2012-06-19 00:19:31 -07:00
|
|
|
if (imf_id) sd->imf = ecore_imf_context_add(imf_id);
|
2012-06-18 17:37:27 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!sd->imf) goto imf_done;
|
|
|
|
|
|
|
|
e = evas_object_evas_get(o);
|
|
|
|
ecore_imf_context_client_window_set
|
|
|
|
(sd->imf, (void *)ecore_evas_window_get(ecore_evas_ecore_evas_get(e)));
|
|
|
|
ecore_imf_context_client_canvas_set(sd->imf, e);
|
|
|
|
|
|
|
|
ecore_imf_context_event_callback_add
|
|
|
|
(sd->imf, ECORE_IMF_CALLBACK_COMMIT, _imf_event_commit_cb, sd);
|
|
|
|
|
|
|
|
/* make IMF usable by a terminal - no preedit, prediction... */
|
2012-07-01 19:52:48 -07:00
|
|
|
ecore_imf_context_use_preedit_set
|
|
|
|
(sd->imf, EINA_FALSE);
|
|
|
|
ecore_imf_context_prediction_allow_set
|
|
|
|
(sd->imf, EINA_FALSE);
|
|
|
|
ecore_imf_context_autocapital_type_set
|
|
|
|
(sd->imf, ECORE_IMF_AUTOCAPITAL_TYPE_NONE);
|
|
|
|
ecore_imf_context_input_panel_layout_set
|
|
|
|
(sd->imf, ECORE_IMF_INPUT_PANEL_LAYOUT_TERMINAL);
|
|
|
|
ecore_imf_context_input_mode_set
|
|
|
|
(sd->imf, ECORE_IMF_INPUT_MODE_FULL);
|
|
|
|
ecore_imf_context_input_panel_language_set
|
|
|
|
(sd->imf, ECORE_IMF_INPUT_PANEL_LANG_ALPHABET);
|
|
|
|
ecore_imf_context_input_panel_return_key_type_set
|
|
|
|
(sd->imf, ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT);
|
2012-06-19 00:19:31 -07:00
|
|
|
imf_done:
|
2012-06-18 17:37:27 -07:00
|
|
|
if (sd->imf) DBG("Ecore IMF Setup");
|
|
|
|
else WRN("Ecore IMF failed");
|
|
|
|
}
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_smart_del(Evas_Object *obj)
|
|
|
|
{
|
2012-07-04 07:44:43 -07:00
|
|
|
Evas_Object *o;
|
2012-06-12 03:10:01 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
2012-07-04 07:44:43 -07:00
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
if (!sd) return;
|
2012-06-19 00:19:31 -07:00
|
|
|
if (sd->imf)
|
|
|
|
{
|
|
|
|
ecore_imf_context_event_callback_del
|
|
|
|
(sd->imf, ECORE_IMF_CALLBACK_COMMIT, _imf_event_commit_cb);
|
|
|
|
ecore_imf_context_del(sd->imf);
|
|
|
|
}
|
2012-06-12 03:10:01 -07:00
|
|
|
if (sd->cur.obj) evas_object_del(sd->cur.obj);
|
|
|
|
if (sd->event) evas_object_del(sd->event);
|
2012-07-11 05:09:00 -07:00
|
|
|
if (sd->cur.selo_top) evas_object_del(sd->cur.selo_top);
|
|
|
|
if (sd->cur.selo_bottom) evas_object_del(sd->cur.selo_bottom);
|
|
|
|
if (sd->cur.selo_theme) evas_object_del(sd->cur.selo_theme);
|
2012-06-18 05:14:36 -07:00
|
|
|
if (sd->anim) ecore_animator_del(sd->anim);
|
2012-06-12 03:10:01 -07:00
|
|
|
if (sd->delayed_size_timer) ecore_timer_del(sd->delayed_size_timer);
|
2012-07-04 07:44:43 -07:00
|
|
|
if (sd->link_do_timer) ecore_timer_del(sd->link_do_timer);
|
2012-07-03 08:25:19 -07:00
|
|
|
if (sd->mouse_move_job) ecore_job_del(sd->mouse_move_job);
|
2013-01-30 21:23:25 -08:00
|
|
|
if (sd->mouseover_delay) ecore_timer_del(sd->mouseover_delay);
|
2012-06-12 03:10:01 -07:00
|
|
|
if (sd->font.name) eina_stringshare_del(sd->font.name);
|
|
|
|
if (sd->pty) termpty_free(sd->pty);
|
2012-07-04 07:44:43 -07:00
|
|
|
if (sd->link.string) free(sd->link.string);
|
2013-01-22 07:01:53 -08:00
|
|
|
if (sd->glayer) evas_object_del(sd->glayer);
|
|
|
|
if (sd->win)
|
|
|
|
evas_object_event_callback_del_full(sd->win, EVAS_CALLBACK_DEL,
|
|
|
|
_win_obj_del, obj);
|
2012-07-04 07:44:43 -07:00
|
|
|
EINA_LIST_FREE(sd->link.objs, o) evas_object_del(o);
|
2012-08-17 18:30:05 -07:00
|
|
|
_compose_seq_reset(sd);
|
2012-06-12 03:10:01 -07:00
|
|
|
sd->cur.obj = NULL;
|
|
|
|
sd->event = NULL;
|
2012-07-11 05:09:00 -07:00
|
|
|
sd->cur.selo_top = NULL;
|
|
|
|
sd->cur.selo_bottom = NULL;
|
|
|
|
sd->cur.selo_theme = NULL;
|
2012-06-18 05:14:36 -07:00
|
|
|
sd->anim = NULL;
|
2012-06-12 03:10:01 -07:00
|
|
|
sd->delayed_size_timer = NULL;
|
|
|
|
sd->font.name = NULL;
|
|
|
|
sd->pty = NULL;
|
2012-06-19 00:19:31 -07:00
|
|
|
sd->imf = NULL;
|
2013-01-22 07:01:53 -08:00
|
|
|
sd->win = NULL;
|
|
|
|
sd->glayer = NULL;
|
2012-06-18 17:37:27 -07:00
|
|
|
ecore_imf_shutdown();
|
|
|
|
|
2012-12-28 18:52:48 -08:00
|
|
|
_parent_sc.del(obj);
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
Evas_Coord ow, oh;
|
|
|
|
if (!sd) return;
|
|
|
|
evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
|
|
|
|
if ((ow == w) && (oh == h)) return;
|
|
|
|
evas_object_smart_changed(obj);
|
2012-06-16 19:35:07 -07:00
|
|
|
if (!sd->delayed_size_timer) sd->delayed_size_timer =
|
|
|
|
ecore_timer_add(0.0, _smart_cb_delayed_size, obj);
|
|
|
|
else ecore_timer_delay(sd->delayed_size_timer, 0.0);
|
2012-06-12 03:10:01 -07:00
|
|
|
evas_object_resize(sd->event, ow, oh);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_smart_calculate(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
Evas_Coord ox, oy, ow, oh;
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
if (!sd) return;
|
|
|
|
|
|
|
|
evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
|
2012-06-15 22:07:33 -07:00
|
|
|
evas_object_move(sd->grid.obj, ox, oy);
|
|
|
|
evas_object_resize(sd->grid.obj,
|
|
|
|
sd->grid.w * sd->font.chw,
|
|
|
|
sd->grid.h * sd->font.chh);
|
2012-06-12 17:26:00 -07:00
|
|
|
evas_object_move(sd->cur.obj,
|
2012-06-12 03:10:01 -07:00
|
|
|
ox + (sd->cur.x * sd->font.chw),
|
|
|
|
oy + (sd->cur.y * sd->font.chh));
|
|
|
|
evas_object_move(sd->event, ox, oy);
|
|
|
|
evas_object_resize(sd->event, ow, oh);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-17 10:04:17 -07:00
|
|
|
_smart_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
|
2012-06-12 17:26:00 -07:00
|
|
|
{
|
2012-06-12 03:10:01 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
|
|
|
evas_object_smart_changed(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_smart_init(void)
|
|
|
|
{
|
|
|
|
static Evas_Smart_Class sc;
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2012-06-17 13:24:23 -07:00
|
|
|
evas_object_smart_clipped_smart_set(&_parent_sc);
|
|
|
|
sc = _parent_sc;
|
2012-06-12 03:10:01 -07:00
|
|
|
sc.name = "termio";
|
|
|
|
sc.version = EVAS_SMART_CLASS_VERSION;
|
|
|
|
sc.add = _smart_add;
|
|
|
|
sc.del = _smart_del;
|
|
|
|
sc.resize = _smart_resize;
|
|
|
|
sc.move = _smart_move;
|
|
|
|
sc.calculate = _smart_calculate;
|
|
|
|
_smart = evas_smart_class_new(&sc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_smart_pty_change(void *data)
|
|
|
|
{
|
|
|
|
Evas_Object *obj = data;
|
|
|
|
Termio *sd;
|
|
|
|
sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
|
|
|
|
2012-06-18 05:14:36 -07:00
|
|
|
// if scroll to bottom on updates
|
|
|
|
if (sd->jump_on_change) sd->scroll = 0;
|
|
|
|
_smart_update_queue(data, sd);
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_smart_pty_scroll(void *data)
|
|
|
|
{
|
|
|
|
Evas_Object *obj = data;
|
|
|
|
Termio *sd;
|
|
|
|
int changed = 0;
|
|
|
|
sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
|
|
|
|
|
|
|
if ((!sd->jump_on_change) && // if NOT scroll to bottom on updates
|
2012-06-12 17:26:00 -07:00
|
|
|
(sd->scroll > 0))
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
|
|
|
// adjust scroll position for added scrollback
|
|
|
|
sd->scroll++;
|
|
|
|
if (sd->scroll > sd->pty->backscroll_num)
|
|
|
|
sd->scroll = sd->pty->backscroll_num;
|
|
|
|
changed = 1;
|
|
|
|
}
|
|
|
|
if (sd->cur.sel)
|
|
|
|
{
|
|
|
|
sd->cur.sel1.y--;
|
|
|
|
sd->cur.sel2.y--;
|
|
|
|
changed = 1;
|
|
|
|
}
|
2012-06-18 05:14:36 -07:00
|
|
|
if (changed) _smart_update_queue(data, sd);
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_smart_pty_title(void *data)
|
|
|
|
{
|
|
|
|
Evas_Object *obj = data;
|
|
|
|
Termio *sd;
|
|
|
|
sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
|
|
|
if (!sd->win) return;
|
|
|
|
elm_win_title_set(sd->win, sd->pty->prop.title);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_smart_pty_icon(void *data)
|
|
|
|
{
|
|
|
|
Evas_Object *obj = data;
|
|
|
|
Termio *sd;
|
|
|
|
sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
|
|
|
if (!sd->win) return;
|
|
|
|
elm_win_icon_name_set(sd->win, sd->pty->prop.icon);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_smart_pty_cancel_sel(void *data)
|
|
|
|
{
|
|
|
|
Evas_Object *obj = data;
|
|
|
|
Termio *sd;
|
|
|
|
sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
|
|
|
if (sd->cur.sel)
|
|
|
|
{
|
|
|
|
sd->cur.sel = 0;
|
|
|
|
sd->cur.makesel = 0;
|
2012-06-18 05:14:36 -07:00
|
|
|
_smart_update_queue(data, sd);
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-20 07:12:26 -07:00
|
|
|
static void
|
|
|
|
_smart_pty_exited(void *data)
|
|
|
|
{
|
|
|
|
evas_object_smart_callback_call(data, "exited", NULL);
|
|
|
|
}
|
|
|
|
|
2012-06-23 02:25:01 -07:00
|
|
|
static void
|
|
|
|
_smart_pty_bell(void *data)
|
|
|
|
{
|
2012-07-19 02:28:42 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
if (!sd) return;
|
2012-06-23 02:25:01 -07:00
|
|
|
evas_object_smart_callback_call(data, "bell", NULL);
|
2012-10-21 19:12:55 -07:00
|
|
|
edje_object_signal_emit(sd->cur.obj, "bell", "terminology");
|
2012-06-23 02:25:01 -07:00
|
|
|
}
|
|
|
|
|
2012-06-30 17:24:30 -07:00
|
|
|
static void
|
|
|
|
_smart_pty_command(void *data)
|
|
|
|
{
|
|
|
|
Evas_Object *obj = data;
|
2013-02-21 05:23:48 -08:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
2012-06-30 17:24:30 -07:00
|
|
|
if (!sd) return;
|
2012-12-24 17:53:41 -08:00
|
|
|
if (!sd->pty->cur_cmd) return;
|
2013-01-28 08:06:26 -08:00
|
|
|
if (sd->pty->cur_cmd[0] == 'i')
|
|
|
|
{
|
|
|
|
if ((sd->pty->cur_cmd[1] == 's') ||
|
|
|
|
(sd->pty->cur_cmd[1] == 'c') ||
|
2013-02-01 06:10:51 -08:00
|
|
|
(sd->pty->cur_cmd[1] == 'f') ||
|
|
|
|
(sd->pty->cur_cmd[1] == 't'))
|
2013-01-28 08:06:26 -08:00
|
|
|
{
|
|
|
|
const char *p, *p0, *path;
|
2013-01-28 16:43:13 -08:00
|
|
|
int ww = 0, hh = 0, repch;
|
2013-01-28 08:06:26 -08:00
|
|
|
|
|
|
|
// exact size in CHAR CELLS - WW (decimal) width CELLS,
|
|
|
|
// HH (decimal) in CELLS.
|
|
|
|
//
|
2013-01-28 16:43:13 -08:00
|
|
|
// isCWW;HH;PATH
|
|
|
|
repch = sd->pty->cur_cmd[2];
|
|
|
|
if (repch)
|
2013-01-28 08:06:26 -08:00
|
|
|
{
|
2013-01-28 16:43:13 -08:00
|
|
|
for (p0 = p = &(sd->pty->cur_cmd[3]); *p; p++)
|
2013-01-28 08:06:26 -08:00
|
|
|
{
|
2013-01-28 16:43:13 -08:00
|
|
|
if (*p == ';')
|
|
|
|
{
|
|
|
|
ww = strtol(p0, NULL, 10);
|
|
|
|
p++;
|
|
|
|
break;
|
|
|
|
}
|
2013-01-28 08:06:26 -08:00
|
|
|
}
|
2013-01-28 16:43:13 -08:00
|
|
|
for (p0 = p; *p; p++)
|
2013-01-28 08:06:26 -08:00
|
|
|
{
|
2013-01-28 16:43:13 -08:00
|
|
|
if (*p == ';')
|
|
|
|
{
|
|
|
|
hh = strtol(p0, NULL, 10);
|
|
|
|
p++;
|
|
|
|
break;
|
|
|
|
}
|
2013-01-28 08:06:26 -08:00
|
|
|
}
|
2013-01-28 16:43:13 -08:00
|
|
|
path = p;
|
|
|
|
if ((ww < 512) && (hh < 512))
|
2013-01-28 08:06:26 -08:00
|
|
|
{
|
2013-01-28 16:43:13 -08:00
|
|
|
Termblock *blk = termpty_block_new(sd->pty, ww, hh, path);
|
|
|
|
if (blk)
|
|
|
|
{
|
|
|
|
if (sd->pty->cur_cmd[1] == 's')
|
|
|
|
blk->scale_stretch = EINA_TRUE;
|
|
|
|
else if (sd->pty->cur_cmd[1] == 'c')
|
|
|
|
blk->scale_center = EINA_TRUE;
|
|
|
|
else if (sd->pty->cur_cmd[1] == 'f')
|
|
|
|
blk->scale_fill = EINA_TRUE;
|
2013-02-01 06:10:51 -08:00
|
|
|
else if (sd->pty->cur_cmd[1] == 't')
|
|
|
|
blk->thumb = EINA_TRUE;
|
2013-01-28 16:43:13 -08:00
|
|
|
termpty_block_insert(sd->pty, repch, blk);
|
|
|
|
}
|
2013-01-28 08:06:26 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2013-01-28 19:34:50 -08:00
|
|
|
else if (sd->pty->cur_cmd[1] == 'b')
|
|
|
|
{
|
|
|
|
sd->pty->block.on = EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (sd->pty->cur_cmd[1] == 'e')
|
|
|
|
{
|
|
|
|
sd->pty->block.on = EINA_FALSE;
|
|
|
|
}
|
2013-01-28 08:06:26 -08:00
|
|
|
}
|
|
|
|
else if (sd->pty->cur_cmd[0] == 'q')
|
|
|
|
{
|
|
|
|
if (sd->pty->cur_cmd[1] == 's')
|
|
|
|
{
|
|
|
|
char buf[256];
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%i;%i;%i;%i\n",
|
|
|
|
sd->grid.w, sd->grid.h, sd->font.chw, sd->font.chh);
|
|
|
|
termpty_write(sd->pty, buf, strlen(buf));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2012-12-24 17:53:41 -08:00
|
|
|
evas_object_smart_callback_call(obj, "command", (void *)sd->pty->cur_cmd);
|
2012-06-30 17:24:30 -07:00
|
|
|
}
|
|
|
|
|
2013-02-21 05:23:48 -08:00
|
|
|
#if (ECORE_VERSION_MAJOR > 1) || (ECORE_VERSION_MINOR >= 8)
|
|
|
|
static void
|
|
|
|
_smart_cb_drag_enter(void *data, Evas_Object *o)
|
|
|
|
{
|
|
|
|
printf("dnd enter\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_smart_cb_drag_leave(void *data, Evas_Object *o)
|
|
|
|
{
|
|
|
|
printf("dnd leave\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_smart_cb_drag_pos(void *data, Evas_Object *o, Evas_Coord x, Evas_Coord y)
|
|
|
|
{
|
|
|
|
printf("dnd at %i %i\n", x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_smart_cb_drop(void *data, Evas_Object *o, Elm_Selection_Data *ev)
|
|
|
|
{
|
|
|
|
Evas_Object *obj = data;
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return EINA_TRUE;
|
|
|
|
printf("drop: '%s'\n", ev->data);
|
|
|
|
termpty_write(sd->pty, ev->data, strlen(ev->data));
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
Evas_Object *
|
2012-09-27 02:33:33 -07:00
|
|
|
termio_add(Evas_Object *parent, Config *config, const char *cmd, Eina_Bool login_shell, const char *cd, int w, int h)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
|
|
|
Evas *e;
|
2012-07-01 20:47:02 -07:00
|
|
|
Evas_Object *obj, *g;
|
2012-06-12 03:10:01 -07:00
|
|
|
Termio *sd;
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
|
|
|
|
e = evas_object_evas_get(parent);
|
|
|
|
if (!e) return NULL;
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
if (!_smart) _smart_init();
|
|
|
|
obj = evas_object_smart_add(e, _smart);
|
|
|
|
sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return obj;
|
2012-06-17 13:24:23 -07:00
|
|
|
|
|
|
|
_termio_config_set(obj, config);
|
|
|
|
|
2013-01-22 07:01:53 -08:00
|
|
|
sd->glayer = g = elm_gesture_layer_add(parent);
|
2012-07-01 20:47:02 -07:00
|
|
|
elm_gesture_layer_attach(g, sd->event);
|
|
|
|
|
|
|
|
elm_gesture_layer_cb_set(g, ELM_GESTURE_N_LONG_TAPS,
|
2012-07-02 22:28:31 -07:00
|
|
|
ELM_GESTURE_STATE_MOVE, _smart_cb_gest_long_move,
|
2012-07-01 20:47:02 -07:00
|
|
|
obj);
|
|
|
|
|
|
|
|
elm_gesture_layer_cb_set(g, ELM_GESTURE_ZOOM,
|
|
|
|
ELM_GESTURE_STATE_START, _smart_cb_gest_zoom_start,
|
|
|
|
obj);
|
|
|
|
elm_gesture_layer_cb_set(g, ELM_GESTURE_ZOOM,
|
|
|
|
ELM_GESTURE_STATE_MOVE, _smart_cb_gest_zoom_move,
|
|
|
|
obj);
|
|
|
|
elm_gesture_layer_cb_set(g, ELM_GESTURE_ZOOM,
|
|
|
|
ELM_GESTURE_STATE_END, _smart_cb_gest_zoom_end,
|
|
|
|
obj);
|
|
|
|
elm_gesture_layer_cb_set(g, ELM_GESTURE_ZOOM,
|
|
|
|
ELM_GESTURE_STATE_ABORT, _smart_cb_gest_zoom_abort,
|
|
|
|
obj);
|
|
|
|
|
2013-02-21 05:23:48 -08:00
|
|
|
#if (ECORE_VERSION_MAJOR > 1) || (ECORE_VERSION_MINOR >= 8)
|
|
|
|
elm_drop_target_add(sd->event,
|
|
|
|
ELM_SEL_FORMAT_TEXT | ELM_SEL_FORMAT_IMAGE,
|
|
|
|
_smart_cb_drag_enter, obj,
|
|
|
|
_smart_cb_drag_leave, obj,
|
|
|
|
_smart_cb_drag_pos, obj,
|
|
|
|
_smart_cb_drop, obj);
|
|
|
|
#endif
|
|
|
|
|
2012-09-27 02:33:33 -07:00
|
|
|
sd->pty = termpty_new(cmd, login_shell, cd, w, h, config->scrollback);
|
2012-06-12 03:10:01 -07:00
|
|
|
sd->pty->cb.change.func = _smart_pty_change;
|
|
|
|
sd->pty->cb.change.data = obj;
|
|
|
|
sd->pty->cb.scroll.func = _smart_pty_scroll;
|
|
|
|
sd->pty->cb.scroll.data = obj;
|
|
|
|
sd->pty->cb.set_title.func = _smart_pty_title;
|
|
|
|
sd->pty->cb.set_title.data = obj;
|
|
|
|
sd->pty->cb.set_icon.func = _smart_pty_icon;
|
|
|
|
sd->pty->cb.set_icon.data = obj;
|
|
|
|
sd->pty->cb.cancel_sel.func = _smart_pty_cancel_sel;
|
|
|
|
sd->pty->cb.cancel_sel.data = obj;
|
2012-06-20 07:12:26 -07:00
|
|
|
sd->pty->cb.exited.func = _smart_pty_exited;
|
|
|
|
sd->pty->cb.exited.data = obj;
|
2012-06-23 02:25:01 -07:00
|
|
|
sd->pty->cb.bell.func = _smart_pty_bell;
|
|
|
|
sd->pty->cb.bell.data = obj;
|
2012-06-30 17:24:30 -07:00
|
|
|
sd->pty->cb.command.func = _smart_pty_command;
|
|
|
|
sd->pty->cb.command.data = obj;
|
2012-06-12 06:08:09 -07:00
|
|
|
_smart_size(obj, w, h, EINA_FALSE);
|
2012-06-12 03:10:01 -07:00
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
termio_win_set(Evas_Object *obj, Evas_Object *win)
|
|
|
|
{
|
2012-06-12 06:08:09 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
2012-06-12 03:10:01 -07:00
|
|
|
if (!sd) return;
|
2012-06-15 22:07:33 -07:00
|
|
|
if (sd->win)
|
|
|
|
{
|
|
|
|
evas_object_event_callback_del_full(sd->win, EVAS_CALLBACK_DEL,
|
|
|
|
_win_obj_del, obj);
|
|
|
|
sd->win = NULL;
|
|
|
|
}
|
2012-06-17 03:56:21 -07:00
|
|
|
if (win)
|
2012-06-15 22:07:33 -07:00
|
|
|
{
|
|
|
|
sd->win = win;
|
|
|
|
evas_object_event_callback_add(sd->win, EVAS_CALLBACK_DEL,
|
|
|
|
_win_obj_del, obj);
|
|
|
|
}
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
|
2012-10-02 13:24:13 -07:00
|
|
|
void
|
|
|
|
termio_theme_set(Evas_Object *obj, Evas_Object *theme)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
2013-01-22 07:01:53 -08:00
|
|
|
if (theme) sd->theme = theme;
|
2012-10-02 13:24:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Evas_Object *
|
|
|
|
termio_theme_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
2012-10-03 05:23:06 -07:00
|
|
|
if (!sd) return NULL;
|
2012-10-02 13:24:13 -07:00
|
|
|
return sd->theme;
|
|
|
|
}
|
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
char *
|
|
|
|
termio_selection_get(Evas_Object *obj, int c1x, int c1y, int c2x, int c2y)
|
|
|
|
{
|
2012-06-12 06:08:09 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
2012-06-12 03:10:01 -07:00
|
|
|
Eina_Strbuf *sb;
|
2012-06-19 12:59:35 -07:00
|
|
|
char *s;
|
2012-06-12 03:10:01 -07:00
|
|
|
int x, y;
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
if (!sd) return NULL;
|
|
|
|
sb = eina_strbuf_new();
|
|
|
|
for (y = c1y; y <= c2y; y++)
|
|
|
|
{
|
|
|
|
Termcell *cells;
|
2012-06-17 10:13:50 -07:00
|
|
|
int w, last0, v, start_x, end_x;
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
w = 0;
|
|
|
|
last0 = -1;
|
2012-06-13 01:23:18 -07:00
|
|
|
cells = termpty_cellrow_get(sd->pty, y, &w);
|
2012-07-04 07:44:43 -07:00
|
|
|
if (!cells) continue;
|
2012-06-12 03:10:01 -07:00
|
|
|
if (w > sd->grid.w) w = sd->grid.w;
|
2013-01-22 07:01:53 -08:00
|
|
|
if (c1x >= w) continue;
|
|
|
|
if (c2x >= w) c2x = w - 1;
|
2012-06-17 10:13:50 -07:00
|
|
|
start_x = c1x;
|
|
|
|
end_x = c2x;
|
2012-06-12 03:10:01 -07:00
|
|
|
if (c1y != c2y)
|
|
|
|
{
|
2012-06-17 10:13:50 -07:00
|
|
|
if (y == c1y) end_x = w - 1;
|
|
|
|
else if (y == c2y) start_x = 0;
|
2012-06-12 03:10:01 -07:00
|
|
|
else
|
|
|
|
{
|
2012-06-17 10:13:50 -07:00
|
|
|
start_x = 0;
|
|
|
|
end_x = w - 1;
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
}
|
2012-06-17 10:13:50 -07:00
|
|
|
for (x = start_x; x <= end_x; x++)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2012-11-20 13:18:42 -08:00
|
|
|
#if defined(SUPPORT_DBLWIDTH)
|
2012-06-26 03:30:41 -07:00
|
|
|
if ((cells[x].codepoint == 0) && (cells[x].att.dblwidth))
|
|
|
|
{
|
|
|
|
if (x < end_x) x++;
|
|
|
|
else break;
|
|
|
|
}
|
2012-11-20 13:18:42 -08:00
|
|
|
#endif
|
2012-06-12 03:10:01 -07:00
|
|
|
if (x >= w) break;
|
2012-07-03 05:57:32 -07:00
|
|
|
if ((cells[x].codepoint == 0) || (cells[x].codepoint == ' '))
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
|
|
|
if (last0 < 0) last0 = x;
|
|
|
|
}
|
|
|
|
else if (cells[x].att.newline)
|
|
|
|
{
|
|
|
|
last0 = -1;
|
2012-06-19 12:59:35 -07:00
|
|
|
eina_strbuf_append_char(sb, '\n');
|
2012-06-12 03:10:01 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (cells[x].att.tab)
|
|
|
|
{
|
2012-06-19 12:59:35 -07:00
|
|
|
eina_strbuf_append_char(sb, '\t');
|
2012-06-12 03:10:01 -07:00
|
|
|
x = ((x + 8) / 8) * 8;
|
|
|
|
x--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-06-19 12:59:35 -07:00
|
|
|
char txt[8];
|
|
|
|
int txtlen;
|
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
if (last0 >= 0)
|
|
|
|
{
|
|
|
|
v = x - last0 - 1;
|
|
|
|
last0 = -1;
|
|
|
|
while (v >= 0)
|
|
|
|
{
|
2012-06-19 12:59:35 -07:00
|
|
|
eina_strbuf_append_char(sb, ' ');
|
2012-06-12 03:10:01 -07:00
|
|
|
v--;
|
|
|
|
}
|
|
|
|
}
|
2012-06-25 18:38:13 -07:00
|
|
|
txtlen = codepoint_to_utf8(cells[x].codepoint, txt);
|
2012-06-19 12:59:35 -07:00
|
|
|
if (txtlen > 0)
|
|
|
|
eina_strbuf_append_length(sb, txt, txtlen);
|
2012-06-24 03:01:53 -07:00
|
|
|
if (x == (w - 1))
|
|
|
|
{
|
|
|
|
if (!cells[x].att.autowrapped)
|
|
|
|
eina_strbuf_append_char(sb, '\n');
|
|
|
|
}
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (last0 >= 0)
|
|
|
|
{
|
2012-07-03 05:57:32 -07:00
|
|
|
if (y == c2y)
|
|
|
|
{
|
|
|
|
Eina_Bool have_more = EINA_FALSE;
|
|
|
|
|
|
|
|
for (x = end_x + 1; x < w; x++)
|
|
|
|
{
|
2012-11-20 13:18:42 -08:00
|
|
|
#if defined(SUPPORT_DBLWIDTH)
|
2012-07-03 05:57:32 -07:00
|
|
|
if ((cells[x].codepoint == 0) &&
|
|
|
|
(cells[x].att.dblwidth))
|
|
|
|
{
|
|
|
|
if (x < (w - 1)) x++;
|
|
|
|
else break;
|
|
|
|
}
|
2012-11-20 13:18:42 -08:00
|
|
|
#endif
|
2012-07-03 05:57:32 -07:00
|
|
|
if (((cells[x].codepoint != 0) &&
|
|
|
|
(cells[x].codepoint != ' ')) ||
|
|
|
|
(cells[x].att.newline) ||
|
|
|
|
(cells[x].att.tab))
|
|
|
|
{
|
|
|
|
have_more = EINA_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!have_more) eina_strbuf_append_char(sb, '\n');
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (x = last0; x <= end_x; x++)
|
|
|
|
{
|
2012-11-20 13:18:42 -08:00
|
|
|
#if defined(SUPPORT_DBLWIDTH)
|
2012-07-03 05:57:32 -07:00
|
|
|
if ((cells[x].codepoint == 0) &&
|
|
|
|
(cells[x].att.dblwidth))
|
|
|
|
{
|
|
|
|
if (x < (w - 1)) x++;
|
|
|
|
else break;
|
|
|
|
}
|
2012-11-20 13:18:42 -08:00
|
|
|
#endif
|
2012-07-03 05:57:32 -07:00
|
|
|
if (x >= w) break;
|
|
|
|
eina_strbuf_append_char(sb, ' ');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else eina_strbuf_append_char(sb, '\n');
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
}
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
s = eina_strbuf_string_steal(sb);
|
|
|
|
eina_strbuf_free(sb);
|
|
|
|
return s;
|
|
|
|
}
|
2012-06-12 06:08:09 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
termio_config_update(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
Evas_Coord w, h;
|
|
|
|
char buf[4096];
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2012-06-12 06:08:09 -07:00
|
|
|
if (!sd) return;
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2012-06-12 06:08:09 -07:00
|
|
|
if (sd->font.name) eina_stringshare_del(sd->font.name);
|
|
|
|
sd->font.name = NULL;
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2012-06-17 13:24:23 -07:00
|
|
|
if (sd->config->font.bitmap)
|
2012-06-12 06:08:09 -07:00
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "%s/fonts/%s",
|
2012-06-17 13:24:23 -07:00
|
|
|
elm_app_data_dir_get(), sd->config->font.name);
|
2012-06-12 06:08:09 -07:00
|
|
|
sd->font.name = eina_stringshare_add(buf);
|
|
|
|
}
|
|
|
|
else
|
2012-06-17 13:24:23 -07:00
|
|
|
sd->font.name = eina_stringshare_add(sd->config->font.name);
|
|
|
|
sd->font.size = sd->config->font.size;
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2012-06-17 13:24:23 -07:00
|
|
|
sd->jump_on_change = sd->config->jump_on_change;
|
2012-07-04 21:36:47 -07:00
|
|
|
sd->jump_on_keypress = sd->config->jump_on_keypress;
|
2012-06-16 10:31:54 -07:00
|
|
|
|
2012-06-17 13:24:23 -07:00
|
|
|
termpty_backscroll_set(sd->pty, sd->config->scrollback);
|
2012-06-16 10:31:54 -07:00
|
|
|
sd->scroll = 0;
|
2012-06-26 01:05:43 -07:00
|
|
|
|
2013-01-22 07:01:53 -08:00
|
|
|
if (evas_object_focus_get(obj))
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(sd->cur.obj, "focus,out", "terminology");
|
|
|
|
if (sd->config->disable_cursor_blink)
|
|
|
|
edje_object_signal_emit(sd->cur.obj, "focus,in,noblink", "terminology");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(sd->cur.obj, "focus,in", "terminology");
|
|
|
|
}
|
2012-06-16 10:31:54 -07:00
|
|
|
|
2012-06-18 00:54:40 -07:00
|
|
|
evas_object_scale_set(sd->grid.obj, elm_config_scale_get());
|
2012-06-15 23:28:39 -07:00
|
|
|
evas_object_textgrid_font_set(sd->grid.obj, sd->font.name, sd->font.size);
|
|
|
|
evas_object_textgrid_cell_size_get(sd->grid.obj, &w, &h);
|
2012-06-12 06:08:09 -07:00
|
|
|
if (w < 1) w = 1;
|
|
|
|
if (h < 1) h = 1;
|
|
|
|
sd->font.chw = w;
|
|
|
|
sd->font.chh = h;
|
|
|
|
_smart_size(obj, sd->grid.w, sd->grid.h, EINA_TRUE);
|
|
|
|
}
|
2012-06-17 13:24:23 -07:00
|
|
|
|
|
|
|
Config *
|
|
|
|
termio_config_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, NULL);
|
|
|
|
return sd->config;
|
|
|
|
}
|
2012-06-23 23:39:54 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
termio_copy_clipboard(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
_take_selection(obj, ELM_SEL_TYPE_CLIPBOARD);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
termio_paste_clipboard(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
_paste_selection(obj, ELM_SEL_TYPE_CLIPBOARD);
|
|
|
|
}
|
2012-07-04 07:44:43 -07:00
|
|
|
|
|
|
|
const char *
|
|
|
|
termio_link_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, NULL);
|
|
|
|
return sd->link.string;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
termio_mouseover_suspend_pushpop(Evas_Object *obj, int dir)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
|
|
|
sd->link.suspend += dir;
|
|
|
|
if (sd->link.suspend < 0) sd->link.suspend = 0;
|
|
|
|
_smart_update_queue(obj, sd);
|
|
|
|
}
|
2012-07-13 02:12:01 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
termio_size_get(Evas_Object *obj, int *w, int *h)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd)
|
|
|
|
{
|
|
|
|
if (w) *w = 0;
|
|
|
|
if (h) *h = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (w) *w = sd->grid.w;
|
|
|
|
if (h) *h = sd->grid.h;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
termio_scroll_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return 0;
|
|
|
|
return sd->scroll;
|
|
|
|
}
|
2012-10-09 10:09:26 -07:00
|
|
|
|
|
|
|
pid_t
|
|
|
|
termio_pid_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return 0;
|
|
|
|
return termpty_pid_get(sd->pty);
|
|
|
|
}
|
2012-10-09 10:32:29 -07:00
|
|
|
|
|
|
|
Eina_Bool
|
|
|
|
termio_cwd_get(const Evas_Object *obj, char *buf, size_t size)
|
|
|
|
{
|
|
|
|
char procpath[PATH_MAX];
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
pid_t pid;
|
|
|
|
|
|
|
|
if (!sd) return EINA_FALSE;
|
|
|
|
|
|
|
|
pid = termpty_pid_get(sd->pty);
|
|
|
|
snprintf(procpath, sizeof(procpath), "/proc/%d/cwd", pid);
|
|
|
|
if (readlink(procpath, buf, size) < 1)
|
|
|
|
{
|
|
|
|
ERR("Could not load working directory %s: %s",
|
|
|
|
procpath, strerror(errno));
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2013-01-20 08:48:18 -08:00
|
|
|
|
|
|
|
Evas_Object *
|
|
|
|
termio_textgrid_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return NULL;
|
|
|
|
|
|
|
|
return sd->grid.obj;
|
|
|
|
}
|