2012-06-17 10:04:17 -07:00
|
|
|
#include "private.h"
|
2014-03-18 14:53:02 -07:00
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
#include <Elementary.h>
|
2020-11-29 06:27:34 -08:00
|
|
|
#include <Elementary_Cursor.h>
|
2012-06-28 01:21:51 -07:00
|
|
|
#include <Ecore_Input.h>
|
2014-03-18 14:53:02 -07:00
|
|
|
|
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"
|
2019-11-23 14:31:21 -08:00
|
|
|
#include "backlog.h"
|
2021-09-13 13:49:48 -07:00
|
|
|
#include "extns.h"
|
2017-06-29 14:45:05 -07:00
|
|
|
#include "termptyops.h"
|
2012-09-07 17:26:09 -07:00
|
|
|
#include "termcmd.h"
|
2015-01-07 05:35:49 -08:00
|
|
|
#include "termptydbl.h"
|
2012-06-12 03:10:01 -07:00
|
|
|
#include "utf8.h"
|
2020-08-19 10:16:11 -07:00
|
|
|
#include "colors.h"
|
2012-06-12 03:10:01 -07:00
|
|
|
#include "keyin.h"
|
|
|
|
#include "config.h"
|
2020-06-23 03:48:27 -07:00
|
|
|
#include "theme.h"
|
2012-07-04 07:44:43 -07:00
|
|
|
#include "media.h"
|
2014-05-01 15:08:58 -07:00
|
|
|
#include "miniview.h"
|
2014-10-05 12:00:14 -07:00
|
|
|
#include "gravatar.h"
|
2016-11-06 02:42:17 -08:00
|
|
|
#include "sb.h"
|
2020-06-23 04:11:09 -07:00
|
|
|
#include "utils.h"
|
2012-06-12 03:10:01 -07:00
|
|
|
|
2014-01-26 03:20:38 -08:00
|
|
|
#if defined (__MacOSX__) || (defined (__MACH__) && defined (__APPLE__))
|
|
|
|
# include <sys/proc_info.h>
|
|
|
|
# include <libproc.h>
|
|
|
|
#endif
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
|
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
|
|
|
|
2013-04-14 21:09:48 -07:00
|
|
|
static Eina_List *terms = NULL;
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static void _smart_apply(Evas_Object *obj);
|
|
|
|
static void _smart_size(Evas_Object *obj, int w, int h, Eina_Bool force);
|
2012-06-12 03:10:01 -07:00
|
|
|
static void _smart_calculate(Evas_Object *obj);
|
2015-04-05 03:13:04 -07:00
|
|
|
static Eina_Bool _mouse_in_selection(Termio *sd, int cx, int cy);
|
2012-06-12 03:10:01 -07:00
|
|
|
|
2012-08-23 08:47:24 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
/* {{{ Helpers */
|
2012-08-23 08:47:24 -07:00
|
|
|
|
2019-02-04 14:10:51 -08:00
|
|
|
Termio *
|
|
|
|
termio_get_from_obj(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
return evas_object_smart_data_get(obj);
|
|
|
|
}
|
|
|
|
|
2019-02-04 12:24:00 -08:00
|
|
|
void
|
|
|
|
termio_object_geometry_get(Termio *sd,
|
|
|
|
Evas_Coord *x, Evas_Coord *y,
|
|
|
|
Evas_Coord *w, Evas_Coord *h)
|
|
|
|
{
|
|
|
|
evas_object_geometry_get(sd->self, x, y, w, h);
|
|
|
|
}
|
|
|
|
|
2013-11-01 14:26:03 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_win_obj_del(void *data,
|
|
|
|
Evas *_e EINA_UNUSED,
|
|
|
|
Evas_Object *obj,
|
|
|
|
void *_event EINA_UNUSED)
|
2013-11-01 14:26:03 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
|
2013-12-01 09:22:17 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2014-08-19 13:38:02 -07:00
|
|
|
if (obj == sd->win)
|
|
|
|
{
|
|
|
|
evas_object_event_callback_del_full(sd->win, EVAS_CALLBACK_DEL,
|
|
|
|
_win_obj_del, data);
|
|
|
|
sd->win = NULL;
|
|
|
|
}
|
2013-11-01 14:26:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
void
|
|
|
|
termio_theme_set(Evas_Object *obj, Evas_Object *theme)
|
2013-11-01 14:26:03 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
2020-11-14 15:15:10 -08:00
|
|
|
Evas_Object *bg;
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2020-06-22 14:41:27 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd->grid.obj);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(theme);
|
|
|
|
|
|
|
|
sd->theme = theme;
|
2020-11-14 15:15:10 -08:00
|
|
|
bg = term_bg_get(sd->term);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(bg);
|
2020-06-22 14:41:27 -07:00
|
|
|
|
2020-11-14 15:15:10 -08:00
|
|
|
edje_object_color_class_get(bg, "BG",
|
2020-06-22 14:41:27 -07:00
|
|
|
&sd->saved_bg.r,
|
|
|
|
&sd->saved_bg.g,
|
|
|
|
&sd->saved_bg.b,
|
2020-11-14 15:15:10 -08:00
|
|
|
&sd->saved_bg.a,
|
|
|
|
NULL, NULL, NULL, NULL,
|
|
|
|
NULL, NULL, NULL, NULL);
|
|
|
|
edje_object_color_class_get(sd->cursor.obj, "CURSOR",
|
|
|
|
&sd->saved_cursor.r,
|
|
|
|
&sd->saved_cursor.g,
|
|
|
|
&sd->saved_cursor.b,
|
|
|
|
&sd->saved_cursor.a,
|
|
|
|
NULL, NULL, NULL, NULL,
|
|
|
|
NULL, NULL, NULL, NULL);
|
2020-06-22 14:41:27 -07:00
|
|
|
evas_object_textgrid_palette_get(
|
|
|
|
sd->grid.obj,
|
|
|
|
EVAS_TEXTGRID_PALETTE_STANDARD, 0,
|
|
|
|
&sd->saved_fg.r,
|
|
|
|
&sd->saved_fg.g,
|
|
|
|
&sd->saved_fg.b,
|
|
|
|
&sd->saved_fg.a);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
termio_reset_main_colors(Evas_Object *termio)
|
|
|
|
{
|
|
|
|
if (termio)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(termio);
|
2020-11-14 15:15:10 -08:00
|
|
|
Evas_Object *bg;
|
|
|
|
|
2020-06-22 14:41:27 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd->grid.obj);
|
|
|
|
|
2020-11-14 15:15:10 -08:00
|
|
|
bg = term_bg_get(sd->term);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(bg);
|
|
|
|
edje_object_color_class_set(bg, "BG",
|
|
|
|
sd->saved_bg.r,
|
|
|
|
sd->saved_bg.g,
|
|
|
|
sd->saved_bg.b,
|
|
|
|
sd->saved_bg.a,
|
|
|
|
sd->saved_bg.r,
|
|
|
|
sd->saved_bg.g,
|
|
|
|
sd->saved_bg.b,
|
|
|
|
sd->saved_bg.a,
|
2020-06-22 14:41:27 -07:00
|
|
|
sd->saved_bg.r,
|
|
|
|
sd->saved_bg.g,
|
|
|
|
sd->saved_bg.b,
|
|
|
|
sd->saved_bg.a);
|
2020-11-14 14:32:41 -08:00
|
|
|
edje_object_color_class_set(sd->cursor.obj, "CURSOR",
|
|
|
|
sd->saved_cursor.r,
|
|
|
|
sd->saved_cursor.g,
|
|
|
|
sd->saved_cursor.b,
|
|
|
|
sd->saved_cursor.a,
|
|
|
|
sd->saved_cursor.r,
|
|
|
|
sd->saved_cursor.g,
|
|
|
|
sd->saved_cursor.b,
|
|
|
|
sd->saved_cursor.a,
|
|
|
|
sd->saved_cursor.r,
|
|
|
|
sd->saved_cursor.g,
|
|
|
|
sd->saved_cursor.b,
|
|
|
|
sd->saved_cursor.a);
|
2020-06-22 14:41:27 -07:00
|
|
|
evas_object_textgrid_palette_set(
|
|
|
|
sd->grid.obj,
|
|
|
|
EVAS_TEXTGRID_PALETTE_STANDARD, 0,
|
|
|
|
sd->saved_fg.r,
|
|
|
|
sd->saved_fg.g,
|
|
|
|
sd->saved_fg.b,
|
|
|
|
sd->saved_fg.a);
|
|
|
|
}
|
2013-11-01 14:26:03 -07:00
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
void
|
|
|
|
termio_mouseover_suspend_pushpop(Evas_Object *obj, int dir)
|
2013-02-21 05:23:48 -08:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
2013-12-01 09:22:17 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2014-08-19 13:38:02 -07:00
|
|
|
sd->link.suspend += dir;
|
|
|
|
if (sd->link.suspend < 0) sd->link.suspend = 0;
|
|
|
|
if (sd->link.suspend)
|
2013-11-01 14:26:03 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
if (sd->anim) ecore_animator_del(sd->anim);
|
|
|
|
sd->anim = NULL;
|
2013-11-01 14:26:03 -07:00
|
|
|
}
|
2019-02-02 06:36:58 -08:00
|
|
|
termio_smart_update_queue(sd);
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
2013-11-01 14:26:03 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
void
|
2017-07-06 11:55:02 -07:00
|
|
|
termio_size_get(const Evas_Object *obj, int *w, int *h)
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
2020-11-03 14:05:49 -08:00
|
|
|
const Termio *sd = evas_object_smart_data_get(obj);
|
2014-08-19 13:38:02 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
if (w) *w = sd->grid.w;
|
|
|
|
if (h) *h = sd->grid.h;
|
2013-02-21 05:23:48 -08:00
|
|
|
}
|
|
|
|
|
2020-11-03 14:05:49 -08:00
|
|
|
void
|
|
|
|
termio_character_size_get(const Evas_Object *obj, int *w, int *h)
|
|
|
|
{
|
|
|
|
const Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
if (w) *w = sd->font.chw;
|
|
|
|
if (h) *h = sd->font.chh;
|
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
int
|
2017-07-06 11:55:02 -07:00
|
|
|
termio_scroll_get(const Evas_Object *obj)
|
2012-07-04 07:44:43 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, 0);
|
|
|
|
return sd->scroll;
|
2012-07-04 07:44:43 -07:00
|
|
|
}
|
|
|
|
|
2015-07-22 08:42:46 -07:00
|
|
|
void
|
|
|
|
termio_scroll_delta(Evas_Object *obj, int delta, int by_page)
|
2014-08-22 12:54:04 -07:00
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
|
|
|
|
if (by_page)
|
|
|
|
{
|
|
|
|
int by = sd->grid.h - 2;
|
|
|
|
if (by > 1)
|
|
|
|
delta *= by;
|
|
|
|
}
|
|
|
|
sd->scroll += delta;
|
2021-08-09 14:20:55 -07:00
|
|
|
if ((delta <= 0) && (sd->scroll < 0)) sd->scroll = 0;
|
2019-02-02 06:36:58 -08:00
|
|
|
termio_smart_update_queue(sd);
|
2014-09-23 13:10:12 -07:00
|
|
|
miniview_position_offset(term_miniview_get(sd->term), -delta, EINA_TRUE);
|
2014-08-22 12:54:04 -07:00
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
void
|
|
|
|
termio_scroll_set(Evas_Object *obj, int scroll)
|
2012-07-04 07:44:43 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
2013-12-01 09:50:45 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2014-08-19 13:38:02 -07:00
|
|
|
sd->scroll = scroll;
|
2020-04-16 14:43:21 -07:00
|
|
|
termio_remove_links(sd);
|
2014-08-19 13:38:02 -07:00
|
|
|
_smart_apply(obj);
|
|
|
|
}
|
2013-08-29 09:26:46 -07:00
|
|
|
|
2016-05-31 12:33:00 -07:00
|
|
|
void
|
|
|
|
termio_scroll_top_backlog(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
sd->scroll = INT32_MAX;
|
2020-04-16 14:43:21 -07:00
|
|
|
termio_remove_links(sd);
|
2016-05-31 12:33:00 -07:00
|
|
|
_smart_apply(obj);
|
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
const char *
|
2017-07-06 11:55:02 -07:00
|
|
|
termio_title_get(const Evas_Object *obj)
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, NULL);
|
2018-04-22 08:27:14 -07:00
|
|
|
if (sd->pty->prop.user_title)
|
|
|
|
return sd->pty->prop.user_title;
|
2014-08-19 13:38:02 -07:00
|
|
|
return sd->pty->prop.title;
|
|
|
|
}
|
2013-08-29 09:26:46 -07:00
|
|
|
|
2018-04-22 08:27:14 -07:00
|
|
|
const char *
|
|
|
|
termio_user_title_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, NULL);
|
|
|
|
return sd->pty->prop.user_title;
|
|
|
|
}
|
|
|
|
|
2016-03-02 06:37:02 -08:00
|
|
|
void
|
2018-04-22 08:27:14 -07:00
|
|
|
termio_user_title_set(Evas_Object *obj, const char *title)
|
2016-03-02 06:37:02 -08:00
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
2017-08-28 12:36:48 -07:00
|
|
|
size_t len = 0;
|
2016-03-02 06:37:02 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
|
2019-11-29 10:59:57 -08:00
|
|
|
eina_stringshare_del(sd->pty->prop.user_title);
|
|
|
|
sd->pty->prop.user_title = NULL;
|
2016-03-02 06:37:02 -08:00
|
|
|
|
2017-08-28 12:36:48 -07:00
|
|
|
if (title)
|
2017-08-26 10:27:14 -07:00
|
|
|
{
|
2018-04-22 08:27:14 -07:00
|
|
|
len = strlen(title);
|
2017-08-26 10:27:14 -07:00
|
|
|
}
|
2018-04-22 08:27:14 -07:00
|
|
|
if (len)
|
|
|
|
sd->pty->prop.user_title = eina_stringshare_add_length(title, len);
|
2016-03-02 06:37:02 -08:00
|
|
|
if (sd->pty->cb.set_title.func)
|
|
|
|
sd->pty->cb.set_title.func(sd->pty->cb.set_title.data);
|
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
const char *
|
2017-07-06 11:55:02 -07:00
|
|
|
termio_icon_name_get(const Evas_Object *obj)
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, NULL);
|
|
|
|
return sd->pty->prop.icon;
|
2013-02-21 05:23:48 -08:00
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
void
|
|
|
|
termio_media_mute_set(Evas_Object *obj, Eina_Bool mute)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
Eina_List *l;
|
|
|
|
Termblock *blk;
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
EINA_LIST_FOREACH(sd->pty->block.active, l, blk)
|
2013-02-22 00:49:21 -08:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
if (blk->obj && !blk->edje)
|
|
|
|
media_mute_set(blk->obj, mute);
|
2013-02-22 00:49:21 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-21 11:32:58 -07:00
|
|
|
void
|
|
|
|
termio_media_visualize_set(Evas_Object *obj, Eina_Bool visualize)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
Eina_List *l;
|
|
|
|
Termblock *blk;
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
EINA_LIST_FOREACH(sd->pty->block.active, l, blk)
|
|
|
|
{
|
|
|
|
if (blk->obj && !blk->edje)
|
|
|
|
media_visualize_set(blk->obj, visualize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
Eina_Bool
|
|
|
|
termio_selection_exists(const Evas_Object *obj)
|
2013-02-22 00:49:21 -08:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EINA_FALSE);
|
|
|
|
return sd->pty->selection.is_active;
|
2013-02-22 00:49:21 -08:00
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
Termpty *
|
2017-07-06 11:55:02 -07:00
|
|
|
termio_pty_get(const Evas_Object *obj)
|
2013-02-21 05:23:48 -08:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, NULL);
|
2013-12-01 09:50:45 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
return sd->pty;
|
2013-02-21 05:23:48 -08:00
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
Evas_Object *
|
2017-07-06 11:55:02 -07:00
|
|
|
termio_miniview_get(const Evas_Object *obj)
|
2013-02-21 05:23:48 -08:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
2013-12-01 09:50:45 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, NULL);
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
return term_miniview_get(sd->term);
|
2013-02-21 05:23:48 -08:00
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
Term*
|
2017-07-06 11:55:02 -07:00
|
|
|
termio_term_get(const Evas_Object *obj)
|
2013-02-21 05:23:48 -08:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, NULL);
|
2013-09-11 23:00:08 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
return sd->term;
|
2012-07-04 07:44:43 -07:00
|
|
|
}
|
|
|
|
|
2021-11-02 15:26:40 -07:00
|
|
|
Eina_Bool
|
|
|
|
termio_is_focused(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EINA_FALSE);
|
|
|
|
|
|
|
|
return term_is_focused(sd->term);
|
|
|
|
}
|
|
|
|
|
2020-11-14 15:15:10 -08:00
|
|
|
Evas_Object *
|
|
|
|
termio_bg_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, NULL);
|
|
|
|
|
|
|
|
return term_bg_get(sd->term);
|
|
|
|
}
|
|
|
|
|
2012-07-04 07:44:43 -07:00
|
|
|
static void
|
2014-08-19 13:38:02 -07:00
|
|
|
_font_size_set(Evas_Object *obj, int size)
|
2012-07-04 07:44:43 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
2014-10-08 14:45:21 -07:00
|
|
|
Config *config;
|
2013-12-01 09:50:45 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2021-08-09 14:20:55 -07:00
|
|
|
int font_size_scale;
|
2013-06-09 02:50:30 -07:00
|
|
|
|
2014-10-08 14:45:21 -07:00
|
|
|
config = sd->config;
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
if (size < 5) size = 5;
|
|
|
|
else if (size > 100) size = 100;
|
2021-08-09 14:20:55 -07:00
|
|
|
font_size_scale = ELM_SCALE_SIZE(size);
|
|
|
|
if (sd->font_size_scale == font_size_scale) return;
|
|
|
|
sd->font_size_scale = font_size_scale;
|
2022-02-01 11:16:51 -08:00
|
|
|
if (config)
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
|
|
|
config->font.size = size;
|
|
|
|
sd->noreqsize = 1;
|
|
|
|
termio_config_update(obj);
|
|
|
|
sd->noreqsize = 0;
|
|
|
|
evas_object_data_del(obj, "sizedone");
|
2012-07-04 07:44:43 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-14 13:10:54 -07:00
|
|
|
void
|
|
|
|
termio_font_update(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
Config *config;
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
|
|
|
|
config = sd->config;
|
|
|
|
|
|
|
|
if (config)
|
|
|
|
{
|
|
|
|
sd->noreqsize = 1;
|
|
|
|
termio_config_update(obj);
|
|
|
|
sd->noreqsize = 0;
|
|
|
|
evas_object_data_del(obj, "sizedone");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
void
|
|
|
|
termio_font_size_set(Evas_Object *obj, int size)
|
2013-08-26 07:16:21 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
_font_size_set(obj, size);
|
|
|
|
}
|
2013-08-26 07:16:21 -07:00
|
|
|
|
2014-08-19 13:38:02 -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;
|
2013-08-26 07:16:21 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2013-08-26 07:16:21 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
if (w < 1) w = 1;
|
|
|
|
if (h < 1) h = 1;
|
|
|
|
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);
|
2013-08-26 07:16:21 -07:00
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
pid_t
|
|
|
|
termio_pid_get(const Evas_Object *obj)
|
2012-07-04 07:44:43 -07:00
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
2014-08-19 13:38:02 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, 0);
|
|
|
|
return termpty_pid_get(sd->pty);
|
|
|
|
}
|
2013-06-09 02:50:30 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
Eina_Bool
|
|
|
|
termio_cwd_get(const Evas_Object *obj, char *buf, size_t size)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
pid_t pid;
|
2014-04-11 11:20:47 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EINA_FALSE);
|
|
|
|
|
|
|
|
pid = termpty_pid_get(sd->pty);
|
|
|
|
|
|
|
|
#if defined (__MacOSX__) || (defined (__MACH__) && defined (__APPLE__))
|
|
|
|
|
|
|
|
struct proc_vnodepathinfo vpi;
|
|
|
|
|
|
|
|
if (proc_pidinfo(pid, PROC_PIDVNODEPATHINFO, 0, &vpi, sizeof(vpi)) <= 0)
|
2013-10-08 13:22:20 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
ERR(_("Could not get working directory of pid %i: %s"),
|
|
|
|
pid, strerror(errno));
|
|
|
|
return EINA_FALSE;
|
2013-10-08 13:22:20 -07:00
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
memcpy(buf, vpi.pvi_cdir.vip_path, size);
|
2013-10-08 13:22:20 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
#else
|
|
|
|
|
|
|
|
char procpath[PATH_MAX];
|
|
|
|
ssize_t siz;
|
|
|
|
|
2015-02-23 12:51:28 -08:00
|
|
|
snprintf(procpath, sizeof(procpath), "/proc/%ld/cwd", (long) pid);
|
2019-07-08 13:12:13 -07:00
|
|
|
siz = readlink(procpath, buf, size);
|
|
|
|
if ((siz == -1) || (siz >= (ssize_t)size))
|
2012-07-04 07:44:43 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
ERR(_("Could not load working directory %s: %s"),
|
|
|
|
procpath, strerror(errno));
|
|
|
|
return EINA_FALSE;
|
2012-07-04 07:44:43 -07:00
|
|
|
}
|
2016-03-12 08:11:01 -08:00
|
|
|
buf[siz] = '\0';
|
2013-06-15 14:37:10 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
#endif
|
2013-06-15 14:37:10 -07:00
|
|
|
|
2016-03-12 08:11:01 -08:00
|
|
|
buf[size -1] = '\0';
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
return EINA_TRUE;
|
2012-07-03 08:25:19 -07:00
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
Evas_Object *
|
2017-07-06 11:55:02 -07:00
|
|
|
termio_textgrid_get(const Evas_Object *obj)
|
2013-01-30 21:23:25 -08:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, NULL);
|
2014-08-03 12:05:03 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
return sd->grid.obj;
|
2013-01-30 21:23:25 -08:00
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
Evas_Object *
|
2017-07-06 11:55:02 -07:00
|
|
|
termio_win_get(const Evas_Object *obj)
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, NULL);
|
2013-02-14 13:44:16 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
return sd->win;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* }}} */
|
|
|
|
/* {{{ Config */
|
|
|
|
|
|
|
|
void
|
|
|
|
termio_config_update(Evas_Object *obj)
|
2013-02-18 07:31:54 -08:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
Evas_Coord w, h, ow = 0, oh = 0;
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
|
2019-11-29 10:59:57 -08:00
|
|
|
eina_stringshare_del(sd->font.name);
|
2014-08-19 13:38:02 -07:00
|
|
|
sd->font.name = NULL;
|
|
|
|
|
|
|
|
if (sd->config->font.bitmap)
|
2013-03-11 04:44:27 -07:00
|
|
|
{
|
2020-04-17 14:09:07 -07:00
|
|
|
char buf[4096];
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/fonts/%s",
|
|
|
|
elm_app_data_dir_get(), sd->config->font.name);
|
|
|
|
sd->font.name = eina_stringshare_add(buf);
|
2013-03-11 04:44:27 -07:00
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
else
|
|
|
|
sd->font.name = eina_stringshare_add(sd->config->font.name);
|
|
|
|
sd->font.size = sd->config->font.size;
|
|
|
|
|
|
|
|
sd->jump_on_change = sd->config->jump_on_change;
|
|
|
|
sd->jump_on_keypress = sd->config->jump_on_keypress;
|
|
|
|
|
2019-06-23 10:00:10 -07:00
|
|
|
termpty_config_update(sd->pty, sd->config);
|
2014-08-19 13:38:02 -07:00
|
|
|
sd->scroll = 0;
|
|
|
|
|
2020-11-15 11:18:37 -08:00
|
|
|
colors_term_init(sd->grid.obj, sd->config->color_scheme);
|
2014-08-19 13:38:02 -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);
|
2020-12-05 07:14:18 -08:00
|
|
|
evas_object_scale_set(sd->grid.obj, elm_config_scale_get());
|
2014-08-19 13:38:02 -07:00
|
|
|
|
|
|
|
if (w < 1) w = 1;
|
|
|
|
if (h < 1) h = 1;
|
|
|
|
sd->font.chw = w;
|
|
|
|
sd->font.chh = h;
|
|
|
|
|
|
|
|
evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
|
2018-03-15 11:20:09 -07:00
|
|
|
termio_set_cursor_shape(obj, sd->config->cursor_shape);
|
2014-08-19 13:38:02 -07:00
|
|
|
_smart_size(obj, ow / w, oh / h, EINA_TRUE);
|
2013-02-18 07:31:54 -08:00
|
|
|
}
|
2013-02-14 13:44:16 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
Config *
|
|
|
|
termio_config_get(const Evas_Object *obj)
|
2013-03-11 00:56:07 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, NULL);
|
|
|
|
return sd->config;
|
2013-03-11 00:56:07 -07:00
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
void
|
|
|
|
termio_config_set(Evas_Object *obj, Config *config)
|
2013-04-20 00:54:11 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
Evas_Coord w = 2, h = 2;
|
2013-12-01 09:50:45 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
sd->config = config;
|
|
|
|
|
|
|
|
sd->jump_on_change = config->jump_on_change;
|
|
|
|
sd->jump_on_keypress = config->jump_on_keypress;
|
|
|
|
|
|
|
|
if (config->font.bitmap)
|
2013-04-20 00:54:11 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
char buf[PATH_MAX];
|
|
|
|
snprintf(buf, sizeof(buf), "%s/fonts/%s",
|
|
|
|
elm_app_data_dir_get(), config->font.name);
|
|
|
|
sd->font.name = eina_stringshare_add(buf);
|
2013-04-20 00:54:11 -07:00
|
|
|
}
|
|
|
|
else
|
2014-08-19 13:38:02 -07:00
|
|
|
sd->font.name = eina_stringshare_add(config->font.name);
|
|
|
|
sd->font.size = config->font.size;
|
|
|
|
|
|
|
|
evas_object_textgrid_font_set(sd->grid.obj, sd->font.name, sd->font.size);
|
|
|
|
evas_object_textgrid_size_get(sd->grid.obj, &w, &h);
|
2020-12-05 07:14:18 -08:00
|
|
|
evas_object_scale_set(sd->grid.obj, elm_config_scale_get());
|
2014-08-19 13:38:02 -07:00
|
|
|
if (w < 1) w = 1;
|
|
|
|
if (h < 1) h = 1;
|
|
|
|
evas_object_textgrid_size_set(sd->grid.obj, w, h);
|
|
|
|
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;
|
|
|
|
|
2018-03-15 11:20:09 -07:00
|
|
|
termio_set_cursor_shape(obj, sd->cursor.shape);
|
2014-08-19 13:38:02 -07:00
|
|
|
|
2020-10-18 13:32:20 -07:00
|
|
|
theme_apply(sd->sel.theme, config, "terminology/selection",
|
|
|
|
NULL, NULL, EINA_FALSE);
|
2014-08-19 13:38:02 -07:00
|
|
|
theme_auto_reload_enable(sd->sel.theme);
|
|
|
|
edje_object_part_swallow(sd->sel.theme, "terminology.top_left", sd->sel.top);
|
|
|
|
edje_object_part_swallow(sd->sel.theme, "terminology.bottom_right", sd->sel.bottom);
|
|
|
|
}
|
|
|
|
|
2018-03-15 11:20:09 -07:00
|
|
|
static const char *
|
|
|
|
_cursor_shape_to_group_name(Cursor_Shape shape)
|
|
|
|
{
|
|
|
|
switch (shape)
|
|
|
|
{
|
|
|
|
case CURSOR_SHAPE_BLOCK: return "terminology/cursor";
|
|
|
|
case CURSOR_SHAPE_BAR: return "terminology/cursor_bar";
|
|
|
|
case CURSOR_SHAPE_UNDERLINE: return "terminology/cursor_underline";
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-14 14:32:41 -08:00
|
|
|
Evas_Object *
|
|
|
|
termio_get_cursor(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, NULL);
|
|
|
|
return sd->cursor.obj;
|
|
|
|
}
|
|
|
|
|
2018-03-15 11:20:09 -07:00
|
|
|
void
|
|
|
|
termio_set_cursor_shape(Evas_Object *obj, Cursor_Shape shape)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
Config *config;
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
|
|
|
|
config = sd->config;
|
2020-10-18 13:32:20 -07:00
|
|
|
theme_apply(sd->cursor.obj, config, _cursor_shape_to_group_name(shape),
|
|
|
|
NULL, NULL, EINA_FALSE);
|
2018-03-15 11:20:09 -07:00
|
|
|
theme_auto_reload_enable(sd->cursor.obj);
|
|
|
|
evas_object_resize(sd->cursor.obj, sd->font.chw, sd->font.chh);
|
|
|
|
evas_object_show(sd->cursor.obj);
|
|
|
|
sd->cursor.shape = shape;
|
|
|
|
|
2019-09-02 14:44:34 -07:00
|
|
|
if (term_is_focused(sd->term))
|
2018-03-15 11:20:09 -07:00
|
|
|
{
|
|
|
|
edje_object_signal_emit(sd->cursor.obj, "focus,out", "terminology");
|
|
|
|
if (sd->config->disable_cursor_blink)
|
|
|
|
edje_object_signal_emit(sd->cursor.obj, "focus,in,noblink", "terminology");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(sd->cursor.obj, "focus,in", "terminology");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
/* }}} */
|
|
|
|
/* {{{ Links */
|
|
|
|
|
2015-04-05 03:13:04 -07:00
|
|
|
static Eina_Bool
|
2014-08-19 13:38:02 -07:00
|
|
|
_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;
|
|
|
|
}
|
|
|
|
|
2020-04-20 12:20:21 -07:00
|
|
|
/*
|
|
|
|
* Returned string needs to be freed.
|
|
|
|
* Does not handle colors */
|
2018-12-12 12:42:42 -08:00
|
|
|
const char *
|
2019-01-21 13:11:22 -08:00
|
|
|
termio_link_get(const Evas_Object *obj,
|
|
|
|
Eina_Bool *from_escape_code)
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, NULL);
|
2018-12-12 12:42:42 -08:00
|
|
|
const char *link;
|
|
|
|
|
|
|
|
if (!sd->link.string && !sd->link.id)
|
|
|
|
return NULL;
|
2019-01-21 13:11:22 -08:00
|
|
|
|
|
|
|
if (from_escape_code)
|
|
|
|
*from_escape_code = EINA_FALSE;
|
2018-12-12 12:42:42 -08:00
|
|
|
link = sd->link.string;
|
|
|
|
if (sd->link.id)
|
|
|
|
{
|
|
|
|
Term_Link *hl = &sd->pty->hl.links[sd->link.id];
|
|
|
|
if (!hl->url)
|
|
|
|
return NULL;
|
|
|
|
link = hl->url;
|
2019-01-21 13:11:22 -08:00
|
|
|
if (from_escape_code)
|
|
|
|
*from_escape_code = EINA_TRUE;
|
2018-12-12 12:42:42 -08:00
|
|
|
}
|
|
|
|
if (link_is_url(link))
|
|
|
|
{
|
|
|
|
if (casestartswith(link, "file://"))
|
|
|
|
{
|
|
|
|
// TODO: decode string: %XX -> char
|
|
|
|
link = link + sizeof("file://") - 1;
|
2020-07-05 11:19:59 -07:00
|
|
|
/* Handle cases where / is omitted: file://HOSTNAME/home/ */
|
2018-12-12 12:42:42 -08:00
|
|
|
if (link[0] != '/')
|
|
|
|
{
|
|
|
|
link = strchr(link, '/');
|
|
|
|
if (!link)
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return strdup(link);
|
2013-04-20 00:54:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-08-19 13:38:02 -07:00
|
|
|
_activate_link(Evas_Object *obj, Eina_Bool may_inline)
|
2013-04-20 00:54:11 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
2014-10-08 14:45:21 -07:00
|
|
|
Config *config;
|
2014-08-19 13:38:02 -07:00
|
|
|
char buf[PATH_MAX], *s, *escaped;
|
|
|
|
const char *path = NULL, *cmd = NULL;
|
2018-12-12 12:42:42 -08:00
|
|
|
const char *link = NULL;
|
2019-01-21 13:11:22 -08:00
|
|
|
Eina_Bool from_escape_code = EINA_FALSE;
|
2014-08-19 13:38:02 -07:00
|
|
|
Eina_Bool url = EINA_FALSE, email = EINA_FALSE, handled = EINA_FALSE;
|
2013-12-01 09:50:45 -08:00
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2014-10-08 14:45:21 -07:00
|
|
|
config = sd->config;
|
2019-01-21 13:11:22 -08:00
|
|
|
if (!config)
|
|
|
|
return;
|
2018-12-12 12:42:42 -08:00
|
|
|
|
2019-01-21 13:11:22 -08:00
|
|
|
link = termio_link_get(obj, &from_escape_code);
|
2018-12-12 12:42:42 -08:00
|
|
|
if (!link)
|
|
|
|
return;
|
|
|
|
|
2019-01-21 13:11:22 -08:00
|
|
|
if (from_escape_code && !config->active_links_escape)
|
2019-03-20 14:31:58 -07:00
|
|
|
goto end;
|
2019-01-21 13:11:22 -08:00
|
|
|
|
2018-12-12 12:42:42 -08:00
|
|
|
if (link_is_url(link))
|
2019-01-21 13:11:22 -08:00
|
|
|
{
|
|
|
|
if (casestartswith(link, "mailto:"))
|
|
|
|
{
|
|
|
|
email = EINA_TRUE;
|
|
|
|
if (!config->active_links_email)
|
2019-03-20 14:31:58 -07:00
|
|
|
goto end;
|
2019-01-21 13:11:22 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
url = EINA_TRUE;
|
|
|
|
if (!config->active_links_url)
|
2019-03-20 14:31:58 -07:00
|
|
|
goto end;
|
2019-01-21 13:11:22 -08:00
|
|
|
}
|
|
|
|
}
|
2018-12-12 12:42:42 -08:00
|
|
|
else if (link[0] == '/')
|
2019-01-21 13:11:22 -08:00
|
|
|
{
|
|
|
|
path = link;
|
|
|
|
if (!config->active_links_file)
|
2019-03-20 14:31:58 -07:00
|
|
|
goto end;
|
2019-01-21 13:11:22 -08:00
|
|
|
}
|
2018-12-12 12:42:42 -08:00
|
|
|
else if (link_is_email(link))
|
2013-04-20 00:54:11 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
email = EINA_TRUE;
|
2019-01-21 13:11:22 -08:00
|
|
|
if (!config->active_links_email)
|
2019-03-20 14:31:58 -07:00
|
|
|
goto end;
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
|
|
|
|
2018-12-12 12:42:42 -08:00
|
|
|
s = eina_str_escape(link);
|
2019-03-20 14:31:58 -07:00
|
|
|
if (!s)
|
|
|
|
goto end;
|
2014-08-19 13:38:02 -07:00
|
|
|
if (email)
|
|
|
|
{
|
|
|
|
const char *p = s;
|
|
|
|
|
|
|
|
// run mail client
|
|
|
|
cmd = "xdg-email";
|
|
|
|
|
|
|
|
if ((config->helper.email) &&
|
|
|
|
(config->helper.email[0]))
|
|
|
|
cmd = config->helper.email;
|
|
|
|
|
|
|
|
if (casestartswith(s, "mailto:"))
|
|
|
|
p += sizeof("mailto:") - 1;
|
|
|
|
|
|
|
|
escaped = ecore_file_escape_name(p);
|
|
|
|
if (escaped)
|
2013-04-20 00:54:11 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s %s", cmd, escaped);
|
|
|
|
free(escaped);
|
2013-04-20 00:54:11 -07:00
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
|
|
|
else if (path)
|
|
|
|
{
|
|
|
|
// locally accessible file
|
|
|
|
cmd = "xdg-open";
|
|
|
|
|
2018-12-12 12:42:42 -08:00
|
|
|
escaped = ecore_file_escape_name(path);
|
2014-08-19 13:38:02 -07:00
|
|
|
if (escaped)
|
2013-04-20 00:54:11 -07:00
|
|
|
{
|
2021-09-13 14:30:09 -07:00
|
|
|
size_t len = strlen(path);
|
|
|
|
Media_Type type = media_src_type_get(path, len);
|
2014-08-19 13:38:02 -07:00
|
|
|
if (may_inline && _should_inline(obj))
|
2013-04-21 09:11:08 -07:00
|
|
|
{
|
2014-10-08 15:12:34 -07:00
|
|
|
if ((type == MEDIA_TYPE_IMG) ||
|
|
|
|
(type == MEDIA_TYPE_SCALE) ||
|
|
|
|
(type == MEDIA_TYPE_EDJE))
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
|
|
|
evas_object_smart_callback_call(obj, "popup", NULL);
|
|
|
|
handled = EINA_TRUE;
|
|
|
|
}
|
2014-10-08 15:12:34 -07:00
|
|
|
else if (type == MEDIA_TYPE_MOV)
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
|
|
|
evas_object_smart_callback_call(obj, "popup", NULL);
|
|
|
|
handled = EINA_TRUE;
|
|
|
|
}
|
2013-04-21 09:11:08 -07:00
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
if (!handled)
|
2013-04-21 09:11:08 -07:00
|
|
|
{
|
2014-10-08 15:12:34 -07:00
|
|
|
if ((type == MEDIA_TYPE_IMG) ||
|
|
|
|
(type == MEDIA_TYPE_SCALE) ||
|
|
|
|
(type == MEDIA_TYPE_EDJE))
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
|
|
|
if ((config->helper.local.image) &&
|
|
|
|
(config->helper.local.image[0]))
|
|
|
|
cmd = config->helper.local.image;
|
|
|
|
}
|
2014-10-08 15:12:34 -07:00
|
|
|
else if (type == MEDIA_TYPE_MOV)
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
|
|
|
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, escaped);
|
|
|
|
free(escaped);
|
2013-04-21 09:11:08 -07:00
|
|
|
}
|
2013-04-20 00:54:11 -07:00
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
|
|
|
else if (url)
|
|
|
|
{
|
|
|
|
// remote file needs ecore-con-url
|
|
|
|
cmd = "xdg-open";
|
|
|
|
|
|
|
|
escaped = ecore_file_escape_name(s);
|
|
|
|
if (escaped)
|
2013-04-20 00:54:11 -07:00
|
|
|
{
|
2021-09-13 14:30:09 -07:00
|
|
|
size_t len = strlen(link);
|
|
|
|
Media_Type type = media_src_type_get(link, len);
|
2014-08-19 13:38:02 -07:00
|
|
|
if (may_inline && _should_inline(obj))
|
2013-04-21 09:11:08 -07:00
|
|
|
{
|
2015-02-15 11:32:16 -08:00
|
|
|
evas_object_smart_callback_call(obj, "popup", NULL);
|
|
|
|
handled = EINA_TRUE;
|
2013-04-21 09:11:08 -07:00
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
if (!handled)
|
2013-04-21 09:11:08 -07:00
|
|
|
{
|
2014-10-08 15:12:34 -07:00
|
|
|
if ((type == MEDIA_TYPE_IMG) ||
|
|
|
|
(type == MEDIA_TYPE_SCALE) ||
|
|
|
|
(type == MEDIA_TYPE_EDJE))
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
|
|
|
if ((config->helper.url.image) &&
|
|
|
|
(config->helper.url.image[0]))
|
|
|
|
cmd = config->helper.url.image;
|
|
|
|
}
|
2014-10-08 15:12:34 -07:00
|
|
|
else if (type == MEDIA_TYPE_MOV)
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
|
|
|
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, escaped);
|
|
|
|
free(escaped);
|
2013-04-21 09:11:08 -07:00
|
|
|
}
|
2013-04-20 00:54:11 -07:00
|
|
|
}
|
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
else
|
2013-04-19 18:37:05 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
free(s);
|
2019-03-20 14:31:58 -07:00
|
|
|
goto end;
|
2013-04-19 18:37:05 -07:00
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
free(s);
|
2019-03-20 14:31:58 -07:00
|
|
|
if (!handled)
|
|
|
|
ecore_exe_run(buf, NULL);
|
|
|
|
|
|
|
|
end:
|
|
|
|
free((char*)link);
|
2013-04-19 18:37:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_ctxp_del(void *data,
|
|
|
|
Evas *_e EINA_UNUSED,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
void *_event EINA_UNUSED)
|
2013-04-19 18:37:05 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Termio *sd = data;
|
2013-12-01 09:50:45 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2015-04-05 03:13:04 -07:00
|
|
|
sd->ctxpopup = NULL;
|
2018-03-19 14:12:08 -07:00
|
|
|
|
|
|
|
/* Force refocus */
|
|
|
|
term_unfocus(sd->term);
|
|
|
|
term_focus(sd->term);
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
2013-04-19 18:37:05 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_ctxp_dismissed(void *data,
|
|
|
|
Evas_Object *obj,
|
|
|
|
void *_event EINA_UNUSED)
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
2015-05-31 08:38:02 -07:00
|
|
|
Termio *sd = data;
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
sd->ctxpopup = NULL;
|
2014-08-19 13:38:02 -07:00
|
|
|
evas_object_del(obj);
|
2013-04-19 18:37:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_ctxp_link_preview(void *data,
|
|
|
|
Evas_Object *obj,
|
|
|
|
void *_event EINA_UNUSED)
|
2013-04-19 18:37:05 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Evas_Object *term = data;
|
2015-05-31 08:38:02 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(term);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
_activate_link(term, EINA_TRUE);
|
2015-05-31 08:38:02 -07:00
|
|
|
|
|
|
|
sd->ctxpopup = NULL;
|
2014-08-19 13:38:02 -07:00
|
|
|
evas_object_del(obj);
|
|
|
|
}
|
2013-12-01 09:50:45 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_ctxp_link_open(void *data,
|
|
|
|
Evas_Object *obj,
|
|
|
|
void *_event EINA_UNUSED)
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
|
|
|
Evas_Object *term = data;
|
2015-05-31 08:38:02 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(term);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2014-08-19 13:38:02 -07:00
|
|
|
_activate_link(term, EINA_FALSE);
|
2015-05-31 08:38:02 -07:00
|
|
|
|
|
|
|
sd->ctxpopup = NULL;
|
2014-08-19 13:38:02 -07:00
|
|
|
evas_object_del(obj);
|
|
|
|
}
|
|
|
|
|
2019-02-02 06:36:58 -08:00
|
|
|
static void _lost_selection(void *data, Elm_Sel_Type selection);
|
|
|
|
|
|
|
|
static void
|
|
|
|
_lost_selection_reset_job(void *data)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
|
|
|
|
sd->sel_reset_job = NULL;
|
|
|
|
if (sd->sel_str)
|
|
|
|
{
|
|
|
|
elm_cnp_selection_set(sd->win, sd->sel_type,
|
|
|
|
ELM_SEL_FORMAT_TEXT,
|
|
|
|
sd->sel_str, strlen(sd->sel_str));
|
|
|
|
elm_cnp_selection_loss_callback_set(sd->win, sd->sel_type,
|
|
|
|
_lost_selection, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_lost_selection(void *data, Elm_Sel_Type selection)
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Evas_Object *obj;
|
|
|
|
double t = ecore_time_get();
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(terms, l, obj)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) continue;
|
|
|
|
if ((t - sd->set_sel_at) < 0.2) /// hack
|
|
|
|
{
|
|
|
|
if ((sd->have_sel) && (sd->sel_str) && (!sd->reset_sel))
|
|
|
|
{
|
|
|
|
sd->reset_sel = EINA_TRUE;
|
|
|
|
if (sd->sel_reset_job) ecore_job_del(sd->sel_reset_job);
|
|
|
|
sd->sel_reset_job = ecore_job_add
|
|
|
|
(_lost_selection_reset_job, data);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (sd->have_sel)
|
|
|
|
{
|
2019-11-29 10:59:57 -08:00
|
|
|
eina_stringshare_del(sd->sel_str);
|
|
|
|
sd->sel_str = NULL;
|
2019-02-02 06:36:58 -08:00
|
|
|
termio_sel_set(sd, EINA_FALSE);
|
|
|
|
elm_object_cnp_selection_clear(sd->win, selection);
|
|
|
|
termio_smart_update_queue(sd);
|
|
|
|
sd->have_sel = EINA_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
termio_take_selection_text(Termio *sd, Elm_Sel_Type type, const char *text)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
|
|
|
|
text = eina_stringshare_add(text);
|
|
|
|
|
|
|
|
sd->have_sel = EINA_FALSE;
|
|
|
|
sd->reset_sel = EINA_FALSE;
|
|
|
|
sd->set_sel_at = ecore_time_get(); // hack
|
|
|
|
sd->sel_type = type;
|
|
|
|
|
|
|
|
elm_cnp_selection_set(sd->win, type,
|
|
|
|
ELM_SEL_FORMAT_TEXT,
|
|
|
|
text,
|
|
|
|
eina_stringshare_strlen(text));
|
|
|
|
elm_cnp_selection_loss_callback_set(sd->win, type,
|
|
|
|
_lost_selection, sd->self);
|
|
|
|
sd->have_sel = EINA_TRUE;
|
2019-11-29 10:59:57 -08:00
|
|
|
eina_stringshare_del(sd->sel_str);
|
2020-05-04 02:47:00 -07:00
|
|
|
sd->sel_str = eina_stringshare_add(text);
|
2019-02-02 06:36:58 -08:00
|
|
|
}
|
|
|
|
|
2019-02-10 11:09:20 -08:00
|
|
|
|
|
|
|
Eina_Bool
|
|
|
|
termio_take_selection(Evas_Object *obj, Elm_Sel_Type type)
|
|
|
|
{
|
|
|
|
Termio *sd = termio_get_from_obj(obj);
|
|
|
|
const char *s = NULL;
|
|
|
|
size_t len = 0;
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EINA_FALSE);
|
|
|
|
|
|
|
|
s = termio_internal_get_selection(sd, &len);
|
|
|
|
if (s)
|
|
|
|
{
|
|
|
|
if ((sd->win) && (len > 0))
|
|
|
|
termio_take_selection_text(sd, type, s);
|
|
|
|
eina_stringshare_del(s);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2016-11-17 11:04:50 -08:00
|
|
|
static void
|
|
|
|
_cb_ctxp_link_content_copy(void *data,
|
|
|
|
Evas_Object *obj,
|
|
|
|
void *event EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Evas_Object *term = data;
|
|
|
|
Termio *sd = evas_object_smart_data_get(term);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
|
2018-12-12 12:42:42 -08:00
|
|
|
if (sd->link.id)
|
|
|
|
{
|
|
|
|
Term_Link *hl = &sd->pty->hl.links[sd->link.id];
|
2016-11-17 11:04:50 -08:00
|
|
|
|
2018-12-12 12:42:42 -08:00
|
|
|
if (!hl->url)
|
|
|
|
return;
|
2019-02-02 06:36:58 -08:00
|
|
|
termio_take_selection_text(sd, ELM_SEL_TYPE_CLIPBOARD, hl->url);
|
2018-12-12 12:42:42 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-27 11:59:04 -08:00
|
|
|
struct ty_sb sb = {.buf = NULL, .len = 0, .alloc = 0};
|
2020-05-04 02:47:00 -07:00
|
|
|
char *raw_link;
|
2020-04-17 14:09:07 -07:00
|
|
|
|
2019-02-02 06:36:58 -08:00
|
|
|
termio_selection_get(sd,
|
|
|
|
sd->link.x1, sd->link.y1,
|
|
|
|
sd->link.x2, sd->link.y2,
|
|
|
|
&sb, EINA_FALSE);
|
2019-01-27 11:59:04 -08:00
|
|
|
raw_link = ty_sb_steal_buf(&sb);
|
2019-02-02 06:36:58 -08:00
|
|
|
termio_take_selection_text(sd, ELM_SEL_TYPE_CLIPBOARD, raw_link);
|
2020-05-04 02:47:00 -07:00
|
|
|
free(raw_link);
|
2018-12-12 12:42:42 -08:00
|
|
|
}
|
2016-11-17 11:04:50 -08:00
|
|
|
|
|
|
|
sd->ctxpopup = NULL;
|
|
|
|
evas_object_del(obj);
|
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_ctxp_link_copy(void *data,
|
|
|
|
Evas_Object *obj,
|
|
|
|
void *_event EINA_UNUSED)
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
|
|
|
Evas_Object *term = data;
|
|
|
|
Termio *sd = evas_object_smart_data_get(term);
|
2013-12-01 09:50:45 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2014-08-19 13:38:02 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd->link.string);
|
2019-02-02 06:36:58 -08:00
|
|
|
termio_take_selection_text(sd, ELM_SEL_TYPE_CLIPBOARD, sd->link.string);
|
2015-05-31 08:38:02 -07:00
|
|
|
|
|
|
|
sd->ctxpopup = NULL;
|
2014-08-19 13:38:02 -07:00
|
|
|
evas_object_del(obj);
|
|
|
|
}
|
|
|
|
|
2019-02-02 06:36:58 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_mouse_in_selection(Termio *sd, int cx, int cy)
|
|
|
|
{
|
|
|
|
int start_x = 0, start_y = 0, end_x = 0, end_y = 0;
|
|
|
|
|
|
|
|
if (!sd->pty->selection.is_active)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
start_x = sd->pty->selection.start.x;
|
|
|
|
start_y = sd->pty->selection.start.y;
|
|
|
|
end_x = sd->pty->selection.end.x;
|
|
|
|
end_y = sd->pty->selection.end.y;
|
|
|
|
|
|
|
|
if (!sd->pty->selection.is_top_to_bottom)
|
|
|
|
{
|
|
|
|
INT_SWAP(start_y, end_y);
|
|
|
|
INT_SWAP(start_x, end_x);
|
|
|
|
}
|
|
|
|
if (sd->pty->selection.is_box)
|
|
|
|
{
|
|
|
|
if ((start_y <= cy) && (cy <= end_y) &&
|
|
|
|
(start_x <= cx) && (cx <= end_x) )
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((cy < start_y) || (cy > end_y))
|
|
|
|
return EINA_FALSE;
|
|
|
|
if (((cy == start_y) && (cx < start_x)) ||
|
|
|
|
((cy == end_y) && (cx > end_x)))
|
|
|
|
return EINA_FALSE;
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_getsel_cb(void *data,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
Elm_Selection_Data *ev)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EINA_FALSE);
|
|
|
|
|
|
|
|
if (ev->format == ELM_SEL_FORMAT_TEXT)
|
|
|
|
{
|
2019-03-19 15:18:03 -07:00
|
|
|
char *buf;
|
2019-02-02 06:36:58 -08:00
|
|
|
|
|
|
|
if (ev->len <= 0) return EINA_TRUE;
|
|
|
|
|
2019-05-05 02:41:10 -07:00
|
|
|
buf = calloc(2, ev->len); /* twice in case the paste is only \n */
|
2019-03-19 15:18:03 -07:00
|
|
|
if (buf)
|
2019-02-02 06:36:58 -08:00
|
|
|
{
|
2019-05-05 02:41:10 -07:00
|
|
|
const char *s = ev->data;
|
|
|
|
int i, j, pos = 0;
|
2019-02-02 06:36:58 -08:00
|
|
|
|
2019-03-19 15:18:03 -07:00
|
|
|
/* apparently we have to convert \n into \r in terminal land. */
|
2019-05-03 14:26:11 -07:00
|
|
|
for (i = 0; i < (int)ev->len && s[i];)
|
2019-02-02 06:36:58 -08:00
|
|
|
{
|
2019-05-03 14:26:11 -07:00
|
|
|
Eina_Unicode g = 0;
|
2019-05-05 02:41:10 -07:00
|
|
|
int prev_i = i;
|
2019-05-03 14:26:11 -07:00
|
|
|
g = eina_unicode_utf8_next_get(s, &i);
|
2019-03-19 15:18:03 -07:00
|
|
|
/* Skip escape codes as a security measure */
|
2019-10-26 14:20:38 -07:00
|
|
|
if (! ((g == '\t') || (g == '\n') || (g >= ' ')))
|
2019-03-19 15:18:03 -07:00
|
|
|
{
|
2019-05-03 14:26:11 -07:00
|
|
|
continue;
|
2019-03-19 15:18:03 -07:00
|
|
|
}
|
2019-05-03 14:26:11 -07:00
|
|
|
if (g == '\n')
|
|
|
|
buf[pos++] = '\r';
|
2019-05-05 03:56:23 -07:00
|
|
|
else
|
|
|
|
for (j = prev_i; j < i; j++)
|
|
|
|
buf[pos++] = s[j];
|
2019-02-02 06:36:58 -08:00
|
|
|
}
|
2019-03-19 15:18:03 -07:00
|
|
|
if (pos)
|
2019-02-02 06:36:58 -08:00
|
|
|
{
|
2019-05-03 14:26:11 -07:00
|
|
|
if (sd->pty->bracketed_paste)
|
|
|
|
termpty_write(sd->pty, "\x1b[200~",
|
|
|
|
sizeof("\x1b[200~") - 1);
|
2019-02-02 06:36:58 -08:00
|
|
|
|
2019-05-03 14:26:11 -07:00
|
|
|
termpty_write(sd->pty, buf, pos);
|
2019-02-02 06:36:58 -08:00
|
|
|
|
2019-05-03 14:26:11 -07:00
|
|
|
if (sd->pty->bracketed_paste)
|
|
|
|
termpty_write(sd->pty, "\x1b[201~",
|
|
|
|
sizeof("\x1b[201~") - 1);
|
2019-02-02 06:36:58 -08:00
|
|
|
}
|
2019-03-19 15:18:03 -07:00
|
|
|
free(buf);
|
2019-02-02 06:36:58 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const char *fmt = "UNKNOWN";
|
|
|
|
switch (ev->format)
|
|
|
|
{
|
2019-10-28 01:56:03 -07:00
|
|
|
case ELM_SEL_FORMAT_TARGETS: fmt = "TARGETS"; break;
|
2019-02-02 06:36:58 -08:00
|
|
|
case ELM_SEL_FORMAT_NONE: fmt = "NONE"; break;
|
2019-10-28 01:56:03 -07:00
|
|
|
case ELM_SEL_FORMAT_TEXT: fmt = "TEXT"; break; /* shouldn't happen */
|
2019-02-02 06:36:58 -08:00
|
|
|
case ELM_SEL_FORMAT_MARKUP: fmt = "MARKUP"; break;
|
|
|
|
case ELM_SEL_FORMAT_IMAGE: fmt = "IMAGE"; break;
|
|
|
|
case ELM_SEL_FORMAT_VCARD: fmt = "VCARD"; break;
|
|
|
|
case ELM_SEL_FORMAT_HTML: fmt = "HTML"; break;
|
|
|
|
}
|
|
|
|
WRN(_("unsupported selection format '%s'"), fmt);
|
|
|
|
}
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
termio_paste_selection(Evas_Object *obj, Elm_Sel_Type type)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
if (!sd->win)
|
|
|
|
return;
|
|
|
|
elm_cnp_selection_get(sd->win, type, ELM_SEL_FORMAT_TEXT,
|
|
|
|
_getsel_cb, obj);
|
|
|
|
}
|
|
|
|
|
2020-05-21 14:49:28 -07:00
|
|
|
static const char *
|
|
|
|
_color_to_txt(const Termio *sd)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, NULL);
|
|
|
|
|
|
|
|
if (sd->link.color.a == 255)
|
|
|
|
return eina_stringshare_printf("#%.2x%.2x%.2x",
|
|
|
|
sd->link.color.r,
|
|
|
|
sd->link.color.g,
|
|
|
|
sd->link.color.b);
|
|
|
|
else
|
|
|
|
return eina_stringshare_printf("#%.2x%.2x%.2x%.2x",
|
|
|
|
sd->link.color.r,
|
|
|
|
sd->link.color.g,
|
|
|
|
sd->link.color.b,
|
|
|
|
sd->link.color.a);
|
|
|
|
}
|
|
|
|
|
2020-05-21 14:21:50 -07:00
|
|
|
static void
|
|
|
|
_cb_ctxp_color_copy(void *data,
|
|
|
|
Evas_Object *obj,
|
|
|
|
void *_event EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Termio *sd = data;
|
|
|
|
const char *txt;
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
|
2020-05-21 14:49:28 -07:00
|
|
|
txt = _color_to_txt(sd);
|
2020-06-15 14:08:52 -07:00
|
|
|
if (!txt) return;
|
2020-05-21 14:21:50 -07:00
|
|
|
|
|
|
|
termio_take_selection_text(sd, ELM_SEL_TYPE_CLIPBOARD, txt);
|
|
|
|
|
2020-05-21 14:49:28 -07:00
|
|
|
eina_stringshare_del(txt);
|
2020-05-21 14:21:50 -07:00
|
|
|
sd->ctxpopup = NULL;
|
|
|
|
evas_object_del(obj);
|
|
|
|
}
|
2019-02-02 06:36:58 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_link_down(void *data,
|
|
|
|
Evas *_e EINA_UNUSED,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
void *event)
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
|
|
|
Evas_Event_Mouse_Down *ev = event;
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2018-12-12 12:42:42 -08:00
|
|
|
Term_Link *hl = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
if (!sd->link.string && sd->link.id)
|
|
|
|
{
|
|
|
|
hl = &sd->pty->hl.links[sd->link.id];
|
|
|
|
if (!hl->url)
|
|
|
|
return;
|
|
|
|
sd->link.string = eina_stringshare_add(hl->url);
|
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
|
|
|
|
if (ev->button == 1)
|
2014-08-18 08:56:58 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
sd->link.down.down = EINA_TRUE;
|
|
|
|
sd->link.down.x = ev->canvas.x;
|
|
|
|
sd->link.down.y = ev->canvas.y;
|
2014-08-18 08:56:58 -07:00
|
|
|
}
|
2020-05-21 14:21:50 -07:00
|
|
|
else if (ev->button == 3) /* right click */
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
2015-04-05 03:13:04 -07:00
|
|
|
Evas_Object *ctxp;
|
|
|
|
|
|
|
|
ctxp = elm_ctxpopup_add(sd->win);
|
|
|
|
sd->ctxpopup = ctxp;
|
2014-08-19 13:38:02 -07:00
|
|
|
|
2020-05-21 14:21:50 -07:00
|
|
|
if (sd->link.is_color)
|
2018-12-12 12:42:42 -08:00
|
|
|
{
|
2020-05-21 14:21:50 -07:00
|
|
|
const char *fmt, *txt;
|
|
|
|
if (sd->link.color.a == 255)
|
|
|
|
{
|
|
|
|
fmt = eina_stringshare_printf(_("Copy '%s'"),
|
|
|
|
"#%.2x%.2x%.2x");
|
|
|
|
txt = eina_stringshare_printf(fmt,
|
|
|
|
sd->link.color.r,
|
|
|
|
sd->link.color.g,
|
|
|
|
sd->link.color.b);
|
|
|
|
}
|
2022-01-02 07:46:16 -08:00
|
|
|
else
|
2020-05-21 14:21:50 -07:00
|
|
|
{
|
|
|
|
fmt = eina_stringshare_printf(_("Copy '%s'"),
|
|
|
|
"#%.2x%.2x%.2x%.2x");
|
|
|
|
txt = eina_stringshare_printf(fmt,
|
|
|
|
sd->link.color.r,
|
|
|
|
sd->link.color.g,
|
|
|
|
sd->link.color.b,
|
|
|
|
sd->link.color.a);
|
|
|
|
}
|
|
|
|
elm_ctxpopup_item_append(ctxp, txt, NULL,
|
|
|
|
_cb_ctxp_color_copy, sd);
|
|
|
|
eina_stringshare_del(txt);
|
|
|
|
eina_stringshare_del(fmt);
|
2018-12-12 12:42:42 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-05-21 14:21:50 -07:00
|
|
|
Eina_Bool absolut = EINA_FALSE;
|
|
|
|
const char *raw_link;
|
|
|
|
size_t len;
|
2016-11-17 11:04:50 -08:00
|
|
|
|
2020-05-21 14:21:50 -07:00
|
|
|
if (sd->pty->selection.is_active)
|
|
|
|
{
|
|
|
|
int cx = 0, cy = 0;
|
2016-11-17 11:04:50 -08:00
|
|
|
|
2020-05-21 14:21:50 -07:00
|
|
|
termio_cursor_to_xy(sd, ev->canvas.x, ev->canvas.y, &cx, &cy);
|
|
|
|
if (_mouse_in_selection(sd, cx, cy))
|
|
|
|
return;
|
|
|
|
}
|
2018-12-23 01:20:50 -08:00
|
|
|
|
2020-05-21 14:21:50 -07:00
|
|
|
|
|
|
|
if (hl)
|
|
|
|
{
|
|
|
|
raw_link = hl->url;
|
|
|
|
len = strlen(hl->url);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct ty_sb sb = {.buf = NULL, .len = 0, .alloc = 0};
|
|
|
|
termio_selection_get(sd,
|
|
|
|
sd->link.x1,
|
|
|
|
sd->link.y1,
|
|
|
|
sd->link.x2,
|
|
|
|
sd->link.y2,
|
|
|
|
&sb,
|
|
|
|
EINA_FALSE);
|
|
|
|
len = sb.len;
|
|
|
|
raw_link = ty_sb_steal_buf(&sb);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (len > 0 && raw_link[0] == '/')
|
|
|
|
absolut = EINA_TRUE;
|
|
|
|
|
|
|
|
if (sd->config->helper.inline_please)
|
|
|
|
{
|
2021-09-13 14:30:09 -07:00
|
|
|
Media_Type type = media_src_type_get(raw_link, len);
|
2020-05-21 14:21:50 -07:00
|
|
|
|
|
|
|
if ((type == MEDIA_TYPE_IMG) ||
|
|
|
|
(type == MEDIA_TYPE_SCALE) ||
|
|
|
|
(type == MEDIA_TYPE_EDJE) ||
|
|
|
|
(type == MEDIA_TYPE_MOV))
|
|
|
|
elm_ctxpopup_item_append(ctxp, _("Preview"), NULL,
|
|
|
|
_cb_ctxp_link_preview, sd->self);
|
|
|
|
}
|
|
|
|
elm_ctxpopup_item_append(ctxp, _("Open"), NULL, _cb_ctxp_link_open,
|
2016-11-17 11:04:50 -08:00
|
|
|
sd->self);
|
2020-05-21 14:21:50 -07:00
|
|
|
|
|
|
|
if (!absolut &&
|
|
|
|
!link_is_url(raw_link) &&
|
|
|
|
!link_is_email(raw_link))
|
|
|
|
{
|
|
|
|
elm_ctxpopup_item_append(ctxp, _("Copy relative path"), NULL, _cb_ctxp_link_content_copy,
|
|
|
|
sd->self);
|
|
|
|
elm_ctxpopup_item_append(ctxp, _("Copy full path"), NULL, _cb_ctxp_link_copy,
|
|
|
|
sd->self);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
elm_ctxpopup_item_append(ctxp, _("Copy"), NULL, _cb_ctxp_link_copy, sd->self);
|
|
|
|
}
|
|
|
|
if (!hl)
|
|
|
|
free((void*)raw_link);
|
2016-11-17 11:04:50 -08:00
|
|
|
}
|
2020-05-21 14:21:50 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
evas_object_move(ctxp, ev->canvas.x, ev->canvas.y);
|
|
|
|
evas_object_show(ctxp);
|
|
|
|
evas_object_smart_callback_add(ctxp, "dismissed",
|
|
|
|
_cb_ctxp_dismissed, sd);
|
|
|
|
evas_object_event_callback_add(ctxp, EVAS_CALLBACK_DEL,
|
|
|
|
_cb_ctxp_del, sd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_cb_link_up_delay(void *data)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EINA_FALSE);
|
|
|
|
|
|
|
|
sd->link_do_timer = NULL;
|
|
|
|
if (!sd->didclick) _activate_link(data, EINA_TRUE);
|
|
|
|
sd->didclick = EINA_FALSE;
|
|
|
|
return EINA_FALSE;
|
2013-04-19 18:37:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_link_up(void *data,
|
|
|
|
Evas *_e EINA_UNUSED,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
void *event)
|
2013-04-19 18:37:05 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Evas_Event_Mouse_Up *ev = event;
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
|
2020-06-14 12:54:27 -07:00
|
|
|
if ((ev->button == 1) && (sd->link.down.down) && (!sd->link.is_color))
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
|
|
|
Evas_Coord dx, dy, finger_size;
|
|
|
|
|
|
|
|
dx = abs(ev->canvas.x - sd->link.down.x);
|
|
|
|
dy = abs(ev->canvas.y - sd->link.down.y);
|
|
|
|
finger_size = elm_config_finger_size_get();
|
|
|
|
|
|
|
|
if ((dx <= finger_size) && (dy <= finger_size))
|
|
|
|
{
|
|
|
|
if (sd->link_do_timer)
|
|
|
|
ecore_timer_reset(sd->link_do_timer);
|
|
|
|
else
|
|
|
|
sd->link_do_timer = ecore_timer_add(0.2, _cb_link_up_delay, data);
|
|
|
|
}
|
|
|
|
sd->link.down.down = EINA_FALSE;
|
|
|
|
}
|
|
|
|
}
|
2013-12-01 09:50:45 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static void
|
|
|
|
_cb_link_drag_move(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y, Elm_Xdnd_Action action)
|
|
|
|
{
|
|
|
|
const Evas_Modifier *em = NULL;
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
2013-12-01 09:50:45 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2014-08-19 13:38:02 -07:00
|
|
|
|
|
|
|
DBG("dnd %i %i act %i", x, y, action);
|
|
|
|
em = evas_key_modifier_get(evas_object_evas_get(sd->event));
|
|
|
|
if (em)
|
|
|
|
{
|
|
|
|
if (evas_key_modifier_is_set(em, "Control"))
|
|
|
|
elm_drag_action_set(obj, ELM_XDND_ACTION_COPY);
|
|
|
|
else
|
|
|
|
elm_drag_action_set(obj, ELM_XDND_ACTION_MOVE);
|
|
|
|
}
|
2013-04-19 18:37:05 -07:00
|
|
|
}
|
|
|
|
|
2014-04-24 02:10:28 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_link_drag_accept(void *data,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
Eina_Bool doaccept)
|
2014-04-24 02:10:28 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2014-04-24 02:10:28 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
DBG("dnd accept: %i", doaccept);
|
2014-04-24 02:10:28 -07:00
|
|
|
}
|
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_link_drag_done(void *data, Evas_Object *_obj EINA_UNUSED)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
|
|
|
|
DBG("dnd done");
|
|
|
|
sd->link.down.dnd = EINA_FALSE;
|
|
|
|
if ((sd->link.down.dndobjdel) && (sd->link.down.dndobj))
|
|
|
|
evas_object_del(sd->link.down.dndobj);
|
|
|
|
sd->link.down.dndobj = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, NULL);
|
|
|
|
|
|
|
|
icon = elm_button_add(par);
|
|
|
|
elm_object_text_set(icon, sd->link.string);
|
|
|
|
*xoff = 0;
|
|
|
|
*yoff = 0;
|
|
|
|
return icon;
|
|
|
|
}
|
2012-06-15 22:07:33 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_link_move(void *data,
|
|
|
|
Evas *_e EINA_UNUSED,
|
2018-03-13 10:58:41 -07:00
|
|
|
Evas_Object *obj,
|
|
|
|
void *event)
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
|
|
|
Evas_Event_Mouse_Move *ev = event;
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
Evas_Coord dx, dy;
|
2013-12-01 09:50:45 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2014-08-19 13:38:02 -07:00
|
|
|
|
2018-12-12 12:42:42 -08:00
|
|
|
if (!sd->link.down.down)
|
|
|
|
return;
|
2014-08-19 13:38:02 -07:00
|
|
|
dx = abs(ev->cur.canvas.x - sd->link.down.x);
|
|
|
|
dy = abs(ev->cur.canvas.y - sd->link.down.y);
|
|
|
|
if ((sd->config->drag_links) &&
|
|
|
|
(sd->link.string) &&
|
|
|
|
((dx > elm_config_finger_size_get()) ||
|
|
|
|
(dy > elm_config_finger_size_get())))
|
2013-01-28 08:06:26 -08:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
sd->link.down.down = EINA_FALSE;
|
|
|
|
sd->link.down.dnd = EINA_TRUE;
|
|
|
|
DBG("dnd start %s %i %i", sd->link.string,
|
|
|
|
evas_key_modifier_is_set(ev->modifiers, "Control"),
|
|
|
|
evas_key_modifier_is_set(ev->modifiers, "Shift"));
|
|
|
|
if (evas_key_modifier_is_set(ev->modifiers, "Control"))
|
|
|
|
elm_drag_start(obj, ELM_SEL_FORMAT_IMAGE, sd->link.string,
|
|
|
|
ELM_XDND_ACTION_COPY,
|
|
|
|
_cb_link_icon_new, data,
|
|
|
|
_cb_link_drag_move, data,
|
|
|
|
_cb_link_drag_accept, data,
|
|
|
|
_cb_link_drag_done, data);
|
|
|
|
else
|
|
|
|
elm_drag_start(obj, ELM_SEL_FORMAT_IMAGE, sd->link.string,
|
|
|
|
ELM_XDND_ACTION_MOVE,
|
|
|
|
_cb_link_icon_new, data,
|
|
|
|
_cb_link_drag_move, data,
|
|
|
|
_cb_link_drag_accept, data,
|
|
|
|
_cb_link_drag_done, data);
|
|
|
|
sd->link.down.dndobj = obj;
|
|
|
|
sd->link.down.dndobjdel = EINA_FALSE;
|
2013-01-28 08:06:26 -08:00
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
|
|
|
|
2020-04-20 12:20:21 -07:00
|
|
|
static Evas_Object *
|
|
|
|
_color_tooltip_content(void *data,
|
|
|
|
Evas_Object *obj,
|
|
|
|
Evas_Object *_tt EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Termio *sd = data;
|
|
|
|
Evas_Object *o;
|
2020-05-12 14:50:22 -07:00
|
|
|
Evas *canvas = evas_object_evas_get(obj);
|
2020-05-21 14:49:28 -07:00
|
|
|
const char *txt;
|
2020-04-20 12:20:21 -07:00
|
|
|
|
2020-05-12 14:50:22 -07:00
|
|
|
o = edje_object_add(canvas);
|
2020-10-18 13:32:20 -07:00
|
|
|
theme_apply(o, sd->config, "terminology/color_preview",
|
|
|
|
NULL, NULL, EINA_FALSE);
|
2020-04-20 12:20:21 -07:00
|
|
|
evas_object_size_hint_min_set(o, 80, 80);
|
2020-05-12 14:50:22 -07:00
|
|
|
edje_object_color_class_set(o, "color_preview",
|
|
|
|
sd->link.color.r, sd->link.color.g, sd->link.color.b, sd->link.color.a,
|
|
|
|
sd->link.color.r, sd->link.color.g, sd->link.color.b, sd->link.color.a,
|
|
|
|
sd->link.color.r, sd->link.color.g, sd->link.color.b, sd->link.color.a);
|
2020-05-21 14:49:28 -07:00
|
|
|
|
|
|
|
txt = _color_to_txt(sd);
|
|
|
|
edje_object_part_text_set(o, "name", txt);
|
|
|
|
eina_stringshare_del(txt);
|
2020-04-20 12:20:21 -07:00
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_color_tooltip(Evas_Object *obj,
|
|
|
|
Termio *sd)
|
|
|
|
{
|
|
|
|
elm_object_tooltip_content_cb_set(obj, _color_tooltip_content, sd, NULL);
|
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static void
|
2018-10-14 03:49:04 -07:00
|
|
|
_update_link(Termio *sd, Eina_Bool same_geom)
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
2014-10-05 11:59:19 -07:00
|
|
|
Evas_Coord ox, oy, ow, oh;
|
|
|
|
Evas_Object *o;
|
2018-10-14 02:32:21 -07:00
|
|
|
Evas_Object *obj;
|
2014-10-05 11:59:19 -07:00
|
|
|
Eina_Bool popup_exists;
|
|
|
|
int y;
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2018-10-14 02:32:21 -07:00
|
|
|
obj = sd->self;
|
2014-08-19 13:38:02 -07:00
|
|
|
|
2020-04-20 12:20:21 -07:00
|
|
|
if (sd->link.id || sd->link.is_color)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2018-10-14 02:32:21 -07:00
|
|
|
same_geom = EINA_FALSE;
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
2012-06-15 22:07:33 -07:00
|
|
|
|
2014-10-05 11:59:19 -07:00
|
|
|
if (same_geom)
|
|
|
|
return;
|
2014-08-19 13:38:02 -07:00
|
|
|
|
2018-10-14 02:32:21 -07:00
|
|
|
sd->link.id = 0;
|
|
|
|
|
2014-10-05 11:59:19 -07:00
|
|
|
if (sd->link.suspend)
|
|
|
|
return;
|
|
|
|
evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
|
|
|
|
EINA_LIST_FREE(sd->link.objs, o)
|
|
|
|
{
|
|
|
|
if (sd->link.down.dndobj == o)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2014-10-05 11:59:19 -07:00
|
|
|
sd->link.down.dndobjdel = EINA_TRUE;
|
|
|
|
evas_object_hide(o);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
evas_object_del(o);
|
|
|
|
}
|
2020-04-20 12:20:21 -07:00
|
|
|
if (!sd->link.string && !sd->link.is_color)
|
2014-10-05 11:59:19 -07:00
|
|
|
return;
|
|
|
|
|
|
|
|
popup_exists = main_term_popup_exists(sd->term);
|
|
|
|
for (y = sd->link.y1; y <= sd->link.y2; y++)
|
|
|
|
{
|
2016-11-15 11:29:17 -08:00
|
|
|
o = elm_layout_add(sd->win);
|
2014-10-05 11:59:19 -07:00
|
|
|
evas_object_smart_member_add(o, obj);
|
2020-10-18 13:32:20 -07:00
|
|
|
theme_apply(o, sd->config, "terminology/link",
|
|
|
|
NULL, NULL, EINA_TRUE);
|
2014-08-19 13:38:02 -07:00
|
|
|
|
2014-10-05 11:59:19 -07:00
|
|
|
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);
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
2014-10-05 11:59:19 -07:00
|
|
|
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);
|
2020-11-29 06:27:34 -08:00
|
|
|
elm_object_cursor_set(o, ELM_CURSOR_HAND2);
|
2014-10-05 11:59:19 -07:00
|
|
|
evas_object_show(o);
|
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
|
|
|
|
_cb_link_down, obj);
|
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP,
|
|
|
|
_cb_link_up, obj);
|
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_MOVE,
|
|
|
|
_cb_link_move, obj);
|
2020-04-20 12:20:21 -07:00
|
|
|
if (!popup_exists)
|
2014-10-06 14:15:44 -07:00
|
|
|
{
|
2020-04-20 12:20:21 -07:00
|
|
|
if (link_is_email(sd->link.string))
|
|
|
|
{
|
|
|
|
gravatar_tooltip(o, sd->config, sd->link.string);
|
|
|
|
}
|
|
|
|
if (sd->link.is_color)
|
|
|
|
{
|
|
|
|
_color_tooltip(o, sd);
|
|
|
|
}
|
2014-10-06 14:15:44 -07:00
|
|
|
}
|
2013-01-28 08:06:26 -08:00
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2020-04-16 14:43:21 -07:00
|
|
|
void
|
|
|
|
termio_remove_links(Termio *sd)
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
2018-10-14 03:49:04 -07:00
|
|
|
Eina_Bool same_geom = EINA_FALSE;
|
2012-07-12 17:41:43 -07:00
|
|
|
|
2019-11-29 10:59:57 -08:00
|
|
|
eina_stringshare_del(sd->link.string);
|
|
|
|
sd->link.string = NULL;
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
sd->link.x1 = -1;
|
|
|
|
sd->link.y1 = -1;
|
|
|
|
sd->link.x2 = -1;
|
|
|
|
sd->link.y2 = -1;
|
2020-04-19 14:22:57 -07:00
|
|
|
sd->link.suspend = 0;
|
2018-10-13 10:15:57 -07:00
|
|
|
sd->link.id = 0;
|
2020-04-20 12:20:21 -07:00
|
|
|
sd->link.is_color = EINA_FALSE;
|
|
|
|
sd->link.color.r = 0;
|
|
|
|
sd->link.color.g = 0;
|
|
|
|
sd->link.color.b = 0;
|
|
|
|
sd->link.color.a = 0;
|
2018-10-14 03:49:04 -07:00
|
|
|
_update_link(sd, same_geom);
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
|
2018-10-13 10:15:57 -07:00
|
|
|
static void
|
|
|
|
_hyperlink_end(Termio *sd,
|
|
|
|
Term_Link *hl,
|
|
|
|
Evas_Object *o,
|
|
|
|
Eina_Bool add_tooltip)
|
|
|
|
{
|
|
|
|
Eina_Bool popup_exists;
|
|
|
|
|
|
|
|
sd->link.objs = eina_list_append(sd->link.objs, o);
|
2020-11-29 06:27:34 -08:00
|
|
|
elm_object_cursor_set(o, ELM_CURSOR_HAND2);
|
2018-10-13 10:15:57 -07:00
|
|
|
evas_object_show(o);
|
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
|
|
|
|
_cb_link_down, sd->self);
|
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP,
|
|
|
|
_cb_link_up, sd->self);
|
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_MOVE,
|
|
|
|
_cb_link_move, sd->self);
|
|
|
|
popup_exists = main_term_popup_exists(sd->term);
|
|
|
|
if (!popup_exists && add_tooltip)
|
|
|
|
{
|
2018-10-14 02:57:11 -07:00
|
|
|
/* display tooltip */
|
|
|
|
elm_object_tooltip_text_set(o, hl->url);
|
|
|
|
|
2018-10-13 10:15:57 -07:00
|
|
|
if (link_is_email(hl->url))
|
|
|
|
{
|
|
|
|
gravatar_tooltip(o, sd->config, hl->url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-02-04 14:10:51 -08:00
|
|
|
_hyperlink_mouseover(Termio *sd,
|
2018-10-13 10:15:57 -07:00
|
|
|
uint16_t link_id)
|
|
|
|
{
|
|
|
|
Evas_Coord ox, oy, ow, oh;
|
|
|
|
int x, y;
|
|
|
|
Term_Link *hl;
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
|
|
|
|
/* If it's the same link, consider we already have the correct links
|
|
|
|
* displayed */
|
|
|
|
if (sd->link.id == link_id)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (sd->link.suspend)
|
|
|
|
return;
|
|
|
|
|
2020-04-16 14:43:21 -07:00
|
|
|
termio_remove_links(sd);
|
2018-10-14 02:32:21 -07:00
|
|
|
sd->link.id = link_id;
|
|
|
|
|
2018-10-13 10:15:57 -07:00
|
|
|
hl = &sd->pty->hl.links[link_id];
|
|
|
|
if (!hl->url)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Scan the whole screen and display links as needed */
|
2019-02-04 14:10:51 -08:00
|
|
|
termio_object_geometry_get(sd, &ox, &oy, &ow, &oh);
|
2018-10-13 10:15:57 -07:00
|
|
|
termpty_backlog_lock();
|
|
|
|
termpty_backscroll_adjust(sd->pty, &sd->scroll);
|
|
|
|
for (y = 0; y < sd->grid.h; y++)
|
|
|
|
{
|
|
|
|
Termcell *cells;
|
2020-04-17 14:09:07 -07:00
|
|
|
Evas_Object *o;
|
|
|
|
ssize_t w = 0;
|
2018-10-13 10:15:57 -07:00
|
|
|
int start_x = -1;
|
2020-04-16 14:43:21 -07:00
|
|
|
Eina_Bool add_tooltip = EINA_FALSE;
|
2018-10-13 10:15:57 -07:00
|
|
|
|
|
|
|
o = NULL;
|
|
|
|
|
|
|
|
cells = termpty_cellrow_get(sd->pty, y - sd->scroll, &w);
|
|
|
|
if (!cells)
|
|
|
|
continue;
|
|
|
|
for (x = 0; x < w; x++)
|
|
|
|
{
|
|
|
|
Termcell *c = cells + x;
|
|
|
|
if (term_link_eq(sd->pty, hl, c->att.link_id))
|
|
|
|
{
|
|
|
|
if (!o)
|
|
|
|
{
|
|
|
|
o = elm_layout_add(sd->win);
|
2019-02-04 14:10:51 -08:00
|
|
|
evas_object_smart_member_add(o, sd->self);
|
2020-10-18 13:32:20 -07:00
|
|
|
theme_apply(o, sd->config, "terminology/link",
|
|
|
|
NULL, NULL, EINA_TRUE);
|
2018-10-13 10:15:57 -07:00
|
|
|
evas_object_move(o,
|
|
|
|
ox + (x * sd->font.chw),
|
|
|
|
oy + (y * sd->font.chh));
|
|
|
|
start_x = x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (o)
|
|
|
|
{
|
|
|
|
evas_object_resize(o,
|
|
|
|
(x - start_x) * sd->font.chw,
|
|
|
|
sd->font.chh);
|
2020-04-16 14:43:21 -07:00
|
|
|
add_tooltip = ((y == sd->mouse.cy) &&
|
2018-10-13 10:15:57 -07:00
|
|
|
((start_x <= sd->mouse.cx) &&
|
2020-04-16 14:43:21 -07:00
|
|
|
(sd->mouse.cx <= x)));
|
|
|
|
_hyperlink_end(sd, hl, o, add_tooltip);
|
|
|
|
if (add_tooltip)
|
|
|
|
{
|
|
|
|
sd->link.y1 = sd->link.y2 = y;
|
|
|
|
sd->link.x1 = start_x;
|
|
|
|
sd->link.x2 = x;
|
|
|
|
}
|
2018-10-13 10:15:57 -07:00
|
|
|
o = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (o)
|
|
|
|
{
|
|
|
|
evas_object_resize(o,
|
|
|
|
(x - start_x + 1) * sd->font.chw,
|
|
|
|
sd->font.chh);
|
2020-04-16 14:43:21 -07:00
|
|
|
add_tooltip = ((y == sd->mouse.cy) &&
|
2018-10-13 10:15:57 -07:00
|
|
|
((start_x <= sd->mouse.cx) &&
|
|
|
|
(sd->mouse.cx <= x)));
|
2020-04-16 14:43:21 -07:00
|
|
|
_hyperlink_end(sd, hl, o, add_tooltip);
|
|
|
|
if (add_tooltip)
|
|
|
|
{
|
|
|
|
sd->link.y1 = sd->link.y2 = y;
|
|
|
|
sd->link.x1 = start_x;
|
|
|
|
sd->link.x2 = x;
|
|
|
|
}
|
2018-10-13 10:15:57 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
termpty_backlog_unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
/* }}} */
|
|
|
|
/* {{{ Blocks */
|
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_smart_media_clicked(void *data, Evas_Object *obj, void *_info EINA_UNUSED)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
// Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
Termblock *blk;
|
|
|
|
const char *file = media_get(obj);
|
|
|
|
if (!file) return;
|
|
|
|
blk = evas_object_data_get(obj, "blk");
|
|
|
|
if (blk)
|
2012-06-12 06:08:09 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
if (blk->link)
|
|
|
|
{
|
2021-09-13 14:30:09 -07:00
|
|
|
Media_Type type = media_src_type_get(blk->link, strlen(blk->link));
|
2014-08-19 13:38:02 -07:00
|
|
|
Config *config = termio_config_get(data);
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
if (config)
|
|
|
|
{
|
|
|
|
if ((!config->helper.inline_please) ||
|
2014-10-08 15:12:34 -07:00
|
|
|
(!((type == MEDIA_TYPE_IMG) || (type == MEDIA_TYPE_SCALE) ||
|
|
|
|
(type == MEDIA_TYPE_EDJE) || (type == MEDIA_TYPE_MOV))))
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
|
|
|
const char *cmd = NULL;
|
2012-06-12 03:10:01 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
file = blk->link;
|
|
|
|
if ((config->helper.local.general) &&
|
|
|
|
(config->helper.local.general[0]))
|
|
|
|
cmd = config->helper.local.general;
|
|
|
|
if (cmd)
|
|
|
|
{
|
2020-04-17 14:09:07 -07:00
|
|
|
char *escaped;
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
escaped = ecore_file_escape_name(file);
|
|
|
|
if (escaped)
|
|
|
|
{
|
2020-04-17 14:09:07 -07:00
|
|
|
char buf[PATH_MAX];
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s %s", cmd, escaped);
|
|
|
|
ecore_exe_run(buf, NULL);
|
|
|
|
free(escaped);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
file = blk->link;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
evas_object_smart_callback_call(data, "popup", (void *)file);
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_smart_media_del(void *data,
|
|
|
|
Evas *_e EINA_UNUSED,
|
|
|
|
Evas_Object *obj,
|
|
|
|
void *_info EINA_UNUSED)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Termblock *blk = data;
|
2013-12-01 09:50:45 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
if (blk->obj == obj) blk->obj = NULL;
|
2012-06-18 05:14:36 -07:00
|
|
|
}
|
|
|
|
|
2014-09-15 03:01:22 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_smart_media_play(void *data,
|
|
|
|
Evas_Object *obj,
|
|
|
|
void *_info EINA_UNUSED)
|
2014-09-15 03:01:22 -07:00
|
|
|
{
|
|
|
|
Termblock *blk = data;
|
|
|
|
|
|
|
|
if (blk->obj != obj) return;
|
|
|
|
|
|
|
|
blk->mov_state = MOVIE_STATE_PLAY;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_smart_media_pause(void *data,
|
|
|
|
Evas_Object *obj,
|
|
|
|
void *_info EINA_UNUSED)
|
2014-09-15 03:01:22 -07:00
|
|
|
{
|
|
|
|
Termblock *blk = data;
|
|
|
|
|
|
|
|
if (blk->obj != obj) return;
|
|
|
|
|
|
|
|
blk->mov_state = MOVIE_STATE_PAUSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_smart_media_stop(void *data,
|
|
|
|
Evas_Object *obj,
|
|
|
|
void *_info EINA_UNUSED)
|
2014-09-15 03:01:22 -07:00
|
|
|
{
|
|
|
|
Termblock *blk = data;
|
|
|
|
|
|
|
|
if (blk->obj != obj) return;
|
|
|
|
|
|
|
|
blk->mov_state = MOVIE_STATE_STOP;
|
|
|
|
}
|
|
|
|
|
2012-06-18 05:14:36 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_block_edje_signal_cb(void *data,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
const char *sig,
|
|
|
|
const char *src)
|
2012-06-18 05:14:36 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Termblock *blk = data;
|
|
|
|
Termio *sd = evas_object_smart_data_get(blk->pty->obj);
|
|
|
|
char *buf = NULL, *chid = NULL;
|
|
|
|
int buflen = 0;
|
|
|
|
Eina_List *l;
|
2012-06-12 03:10:01 -07:00
|
|
|
|
2013-12-01 09:50:45 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2014-08-19 13:38:02 -07:00
|
|
|
if ((!blk->chid) || (!sd->cur_chids)) return;
|
|
|
|
EINA_LIST_FOREACH(sd->cur_chids, l, chid)
|
|
|
|
{
|
|
|
|
if (!(!strcmp(blk->chid, chid))) break;
|
|
|
|
chid = NULL;
|
|
|
|
}
|
|
|
|
if (!chid) return;
|
|
|
|
if ((!strcmp(sig, "drag")) ||
|
|
|
|
(!strcmp(sig, "drag,start")) ||
|
|
|
|
(!strcmp(sig, "drag,stop")) ||
|
|
|
|
(!strcmp(sig, "drag,step")) ||
|
|
|
|
(!strcmp(sig, "drag,set")))
|
|
|
|
{
|
|
|
|
int v1, v2;
|
|
|
|
double f1 = 0.0, f2 = 0.0;
|
2013-12-01 09:50:45 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
edje_object_part_drag_value_get(blk->obj, src, &f1, &f2);
|
|
|
|
v1 = (int)(f1 * 1000.0);
|
|
|
|
v2 = (int)(f2 * 1000.0);
|
|
|
|
buf = alloca(strlen(src) + strlen(blk->chid) + 256);
|
|
|
|
buflen = sprintf(buf, "%c};%s\n%s\n%s\n%i\n%i", 0x1b,
|
|
|
|
blk->chid, sig, src, v1, v2);
|
|
|
|
termpty_write(sd->pty, buf, buflen + 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
buf = alloca(strlen(sig) + strlen(src) + strlen(blk->chid) + 128);
|
|
|
|
buflen = sprintf(buf, "%c}signal;%s\n%s\n%s", 0x1b,
|
|
|
|
blk->chid, sig, src);
|
|
|
|
termpty_write(sd->pty, buf, buflen + 1);
|
|
|
|
}
|
2013-04-14 21:09:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_block_edje_message_cb(void *data,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
Edje_Message_Type type, int id, void *msg)
|
2013-04-14 21:09:48 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Termblock *blk = data;
|
|
|
|
Termio *sd = evas_object_smart_data_get(blk->pty->obj);
|
|
|
|
char *chid = NULL, buf[4096];
|
2013-04-14 21:09:48 -07:00
|
|
|
Eina_List *l;
|
2014-08-19 13:38:02 -07:00
|
|
|
int buflen;
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
if ((!blk->chid) || (!sd->cur_chids)) return;
|
|
|
|
EINA_LIST_FOREACH(sd->cur_chids, l, chid)
|
2012-06-25 04:17:03 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
if (!(!strcmp(blk->chid, chid))) break;
|
|
|
|
chid = NULL;
|
|
|
|
}
|
|
|
|
if (!chid) return;
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case EDJE_MESSAGE_STRING:
|
2013-04-14 21:09:48 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Edje_Message_String *m = msg;
|
2013-11-01 14:26:03 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
buflen = sprintf(buf, "%c}message;%s\n%i\nstring\n%s", 0x1b,
|
|
|
|
blk->chid, id, m->str);
|
|
|
|
termpty_write(sd->pty, buf, buflen + 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EDJE_MESSAGE_INT:
|
|
|
|
{
|
|
|
|
Edje_Message_Int *m = msg;
|
2013-12-01 09:22:17 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
buflen = snprintf(buf, sizeof(buf),
|
|
|
|
"%c}message;%s\n%i\nint\n%i", 0x1b,
|
|
|
|
blk->chid, id, m->val);
|
|
|
|
termpty_write(sd->pty, buf, buflen + 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EDJE_MESSAGE_FLOAT:
|
|
|
|
{
|
|
|
|
Edje_Message_Float *m = msg;
|
2013-11-01 14:26:03 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
buflen = snprintf(buf, sizeof(buf),
|
|
|
|
"%c}message;%s\n%i\nfloat\n%i", 0x1b,
|
|
|
|
blk->chid, id, (int)(m->val * 1000.0));
|
|
|
|
termpty_write(sd->pty, buf, buflen + 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EDJE_MESSAGE_STRING_SET:
|
|
|
|
{
|
|
|
|
Edje_Message_String_Set *m = msg;
|
|
|
|
int i;
|
|
|
|
char zero[1] = { 0 };
|
2013-11-01 14:26:03 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
buflen = snprintf(buf, sizeof(buf),
|
|
|
|
"%c}message;%s\n%i\nstring_set\n%i", 0x1b,
|
|
|
|
blk->chid, id, m->count);
|
|
|
|
termpty_write(sd->pty, buf, buflen);
|
|
|
|
for (i = 0; i < m->count; i++)
|
|
|
|
{
|
|
|
|
termpty_write(sd->pty, "\n", 1);
|
|
|
|
termpty_write(sd->pty, m->str[i], strlen(m->str[i]));
|
|
|
|
}
|
|
|
|
termpty_write(sd->pty, zero, 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EDJE_MESSAGE_INT_SET:
|
|
|
|
{
|
|
|
|
Edje_Message_Int_Set *m = msg;
|
|
|
|
int i;
|
|
|
|
char zero[1] = { 0 };
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
buflen = snprintf(buf, sizeof(buf),
|
|
|
|
"%c}message;%s\n%i\nint_set\n%i", 0x1b,
|
|
|
|
blk->chid, id, m->count);
|
|
|
|
termpty_write(sd->pty, buf, buflen);
|
|
|
|
for (i = 0; i < m->count; i++)
|
|
|
|
{
|
|
|
|
termpty_write(sd->pty, "\n", 1);
|
|
|
|
buflen = snprintf(buf, sizeof(buf), "%i", m->val[i]);
|
|
|
|
termpty_write(sd->pty, buf, buflen);
|
|
|
|
}
|
|
|
|
termpty_write(sd->pty, zero, 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EDJE_MESSAGE_FLOAT_SET:
|
|
|
|
{
|
|
|
|
Edje_Message_Float_Set *m = msg;
|
|
|
|
int i;
|
|
|
|
char zero[1] = { 0 };
|
2013-02-14 13:44:16 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
buflen = snprintf(buf, sizeof(buf),
|
|
|
|
"%c}message;%s\n%i\nfloat_set\n%i", 0x1b,
|
|
|
|
blk->chid, id, m->count);
|
|
|
|
termpty_write(sd->pty, buf, buflen);
|
|
|
|
for (i = 0; i < m->count; i++)
|
|
|
|
{
|
|
|
|
termpty_write(sd->pty, "\n", 1);
|
|
|
|
buflen = snprintf(buf, sizeof(buf), "%i", (int)(m->val[i] * 1000.0));
|
|
|
|
termpty_write(sd->pty, buf, buflen);
|
|
|
|
}
|
|
|
|
termpty_write(sd->pty, zero, 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EDJE_MESSAGE_STRING_INT:
|
|
|
|
{
|
|
|
|
Edje_Message_String_Int *m = msg;
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
buflen = snprintf(buf, sizeof(buf),
|
|
|
|
"%c}message;%s\n%i\nstring_int\n%s\n%i", 0x1b,
|
|
|
|
blk->chid, id, m->str, m->val);
|
|
|
|
termpty_write(sd->pty, buf, buflen + 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EDJE_MESSAGE_STRING_FLOAT:
|
|
|
|
{
|
|
|
|
Edje_Message_String_Float *m = msg;
|
2013-02-14 13:44:16 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
buflen = snprintf(buf, sizeof(buf),
|
|
|
|
"%c}message;%s\n%i\nstring_float\n%s\n%i", 0x1b,
|
|
|
|
blk->chid, id, m->str, (int)(m->val * 1000.0));
|
|
|
|
termpty_write(sd->pty, buf, buflen + 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EDJE_MESSAGE_STRING_INT_SET:
|
2013-02-14 13:44:16 -08:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Edje_Message_String_Int_Set *m = msg;
|
|
|
|
int i;
|
|
|
|
char zero[1] = { 0 };
|
2013-02-14 13:44:16 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
buflen = snprintf(buf, sizeof(buf),
|
|
|
|
"%c}message;%s\n%i\nstring_int_set\n%i", 0x1b,
|
|
|
|
blk->chid, id, m->count);
|
|
|
|
termpty_write(sd->pty, buf, buflen);
|
|
|
|
termpty_write(sd->pty, "\n", 1);
|
|
|
|
termpty_write(sd->pty, m->str, strlen(m->str));
|
|
|
|
for (i = 0; i < m->count; i++)
|
2013-11-07 15:32:47 -08:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
termpty_write(sd->pty, "\n", 1);
|
|
|
|
buflen = snprintf(buf, sizeof(buf), "%i", m->val[i]);
|
|
|
|
termpty_write(sd->pty, buf, buflen);
|
2013-11-07 15:32:47 -08:00
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
termpty_write(sd->pty, zero, 1);
|
2013-02-14 13:44:16 -08:00
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
break;
|
|
|
|
case EDJE_MESSAGE_STRING_FLOAT_SET:
|
2013-02-14 13:44:16 -08:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Edje_Message_String_Float_Set *m = msg;
|
|
|
|
int i;
|
|
|
|
char zero[1] = { 0 };
|
2013-02-14 13:44:16 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
buflen = snprintf(buf, sizeof(buf),
|
|
|
|
"%c}message;%s\n%i\nstring_float_set\n%i", 0x1b,
|
|
|
|
blk->chid, id, m->count);
|
|
|
|
termpty_write(sd->pty, buf, buflen);
|
|
|
|
termpty_write(sd->pty, "\n", 1);
|
|
|
|
termpty_write(sd->pty, m->str, strlen(m->str));
|
|
|
|
for (i = 0; i < m->count; i++)
|
|
|
|
{
|
|
|
|
termpty_write(sd->pty, "\n", 1);
|
|
|
|
buflen = snprintf(buf, sizeof(buf), "%i", (int)(m->val[i] * 1000.0));
|
|
|
|
termpty_write(sd->pty, buf, buflen);
|
|
|
|
}
|
|
|
|
termpty_write(sd->pty, zero, 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static void
|
|
|
|
_block_edje_cmds(Termpty *ty, Termblock *blk, Eina_List *cmds, Eina_Bool created)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Eina_List *l;
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
#define ISCMD(cmd) !strcmp(s, cmd)
|
|
|
|
#define GETS(var) l = l->next; if (!l) return; var = l->data
|
|
|
|
#define GETI(var) l = l->next; if (!l) return; var = atoi(l->data)
|
|
|
|
#define GETF(var) l = l->next; if (!l) return; var = (double)atoi(l->data) / 1000.0
|
|
|
|
l = cmds;
|
|
|
|
while (l)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2020-04-17 14:09:07 -07:00
|
|
|
char *s = l->data;
|
2014-01-22 13:12:01 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
if (ISCMD("text")) // set text part
|
|
|
|
{
|
|
|
|
char *prt, *txt;
|
2014-01-22 13:12:01 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
GETS(prt);
|
|
|
|
GETS(txt);
|
|
|
|
edje_object_part_text_set(blk->obj, prt, txt);
|
|
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
else if (ISCMD("emit")) // emit signal
|
2012-07-06 03:08:51 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
char *sig, *src;
|
2012-07-06 03:08:51 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
GETS(sig);
|
|
|
|
GETS(src);
|
|
|
|
edje_object_signal_emit(blk->obj, sig, src);
|
|
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
else if (ISCMD("drag")) // set dragable
|
|
|
|
{
|
|
|
|
char *prt, *val;
|
|
|
|
double v1, v2;
|
|
|
|
|
|
|
|
GETS(prt);
|
|
|
|
GETS(val);
|
|
|
|
GETF(v1);
|
|
|
|
GETF(v2);
|
|
|
|
if (!strcmp(val, "value"))
|
|
|
|
edje_object_part_drag_value_set(blk->obj, prt, v1, v2);
|
|
|
|
else if (!strcmp(val, "size"))
|
|
|
|
edje_object_part_drag_size_set(blk->obj, prt, v1, v2);
|
|
|
|
else if (!strcmp(val, "step"))
|
|
|
|
edje_object_part_drag_step_set(blk->obj, prt, v1, v2);
|
|
|
|
else if (!strcmp(val, "page"))
|
|
|
|
edje_object_part_drag_page_set(blk->obj, prt, v1, v2);
|
|
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
else if (ISCMD("message")) // send message
|
|
|
|
{
|
|
|
|
int id;
|
|
|
|
char *typ;
|
|
|
|
|
|
|
|
GETI(id);
|
|
|
|
GETS(typ);
|
|
|
|
if (!strcmp(typ, "string"))
|
2014-01-22 13:12:01 -08:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Edje_Message_String *m;
|
|
|
|
|
|
|
|
m = alloca(sizeof(Edje_Message_String));
|
|
|
|
GETS(m->str);
|
|
|
|
edje_object_message_send(blk->obj, EDJE_MESSAGE_STRING,
|
|
|
|
id, m);
|
2014-01-22 13:12:01 -08:00
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
else if (!strcmp(typ, "int"))
|
2012-07-06 03:08:51 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Edje_Message_Int *m;
|
2014-01-06 12:51:23 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
m = alloca(sizeof(Edje_Message_Int));
|
|
|
|
GETI(m->val);
|
|
|
|
edje_object_message_send(blk->obj, EDJE_MESSAGE_INT,
|
|
|
|
id, m);
|
|
|
|
}
|
|
|
|
else if (!strcmp(typ, "float"))
|
|
|
|
{
|
|
|
|
Edje_Message_Float *m;
|
2014-01-06 12:51:23 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
m = alloca(sizeof(Edje_Message_Float));
|
|
|
|
GETF(m->val);
|
|
|
|
edje_object_message_send(blk->obj, EDJE_MESSAGE_FLOAT,
|
|
|
|
id, m);
|
|
|
|
}
|
|
|
|
else if (!strcmp(typ, "string_set"))
|
|
|
|
{
|
|
|
|
Edje_Message_String_Set *m;
|
|
|
|
int i, count;
|
2014-01-06 12:51:23 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
GETI(count);
|
|
|
|
m = alloca(sizeof(Edje_Message_String_Set) +
|
|
|
|
((count - 1) * sizeof(char *)));
|
|
|
|
m->count = count;
|
|
|
|
for (i = 0; i < m->count; i++)
|
|
|
|
{
|
|
|
|
GETS(m->str[i]);
|
|
|
|
}
|
|
|
|
edje_object_message_send(blk->obj,
|
|
|
|
EDJE_MESSAGE_STRING_SET,
|
|
|
|
id, m);
|
2012-07-06 03:08:51 -07:00
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
else if (!strcmp(typ, "int_set"))
|
|
|
|
{
|
|
|
|
Edje_Message_Int_Set *m;
|
|
|
|
int i, count;
|
2014-01-22 13:12:01 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
GETI(count);
|
|
|
|
m = alloca(sizeof(Edje_Message_Int_Set) +
|
|
|
|
((count - 1) * sizeof(int)));
|
|
|
|
m->count = count;
|
|
|
|
for (i = 0; i < m->count; i++)
|
|
|
|
{
|
|
|
|
GETI(m->val[i]);
|
|
|
|
}
|
|
|
|
edje_object_message_send(blk->obj,
|
|
|
|
EDJE_MESSAGE_INT_SET,
|
|
|
|
id, m);
|
|
|
|
}
|
|
|
|
else if (!strcmp(typ, "float_set"))
|
|
|
|
{
|
|
|
|
Edje_Message_Float_Set *m;
|
|
|
|
int i, count;
|
|
|
|
|
|
|
|
GETI(count);
|
|
|
|
m = alloca(sizeof(Edje_Message_Float_Set) +
|
|
|
|
((count - 1) * sizeof(double)));
|
|
|
|
m->count = count;
|
|
|
|
for (i = 0; i < m->count; i++)
|
|
|
|
{
|
|
|
|
GETF(m->val[i]);
|
|
|
|
}
|
|
|
|
edje_object_message_send(blk->obj,
|
|
|
|
EDJE_MESSAGE_FLOAT_SET,
|
|
|
|
id, m);
|
|
|
|
}
|
|
|
|
else if (!strcmp(typ, "string_int"))
|
|
|
|
{
|
|
|
|
Edje_Message_String_Int *m;
|
|
|
|
|
|
|
|
m = alloca(sizeof(Edje_Message_String_Int));
|
|
|
|
GETS(m->str);
|
|
|
|
GETI(m->val);
|
|
|
|
edje_object_message_send(blk->obj, EDJE_MESSAGE_STRING_INT,
|
|
|
|
id, m);
|
|
|
|
}
|
|
|
|
else if (!strcmp(typ, "string_float"))
|
|
|
|
{
|
|
|
|
Edje_Message_String_Float *m;
|
|
|
|
|
|
|
|
m = alloca(sizeof(Edje_Message_String_Float));
|
|
|
|
GETS(m->str);
|
|
|
|
GETF(m->val);
|
|
|
|
edje_object_message_send(blk->obj, EDJE_MESSAGE_STRING_FLOAT,
|
|
|
|
id, m);
|
|
|
|
}
|
|
|
|
else if (!strcmp(typ, "string_int_set"))
|
|
|
|
{
|
|
|
|
Edje_Message_String_Int_Set *m;
|
|
|
|
int i, count;
|
|
|
|
|
|
|
|
GETI(count);
|
|
|
|
m = alloca(sizeof(Edje_Message_String_Int_Set) +
|
|
|
|
((count - 1) * sizeof(int)));
|
|
|
|
GETS(m->str);
|
|
|
|
m->count = count;
|
|
|
|
for (i = 0; i < m->count; i++)
|
|
|
|
{
|
|
|
|
GETI(m->val[i]);
|
|
|
|
}
|
|
|
|
edje_object_message_send(blk->obj,
|
|
|
|
EDJE_MESSAGE_STRING_INT_SET,
|
|
|
|
id, m);
|
|
|
|
}
|
|
|
|
else if (!strcmp(typ, "string_float_set"))
|
|
|
|
{
|
|
|
|
Edje_Message_String_Float_Set *m;
|
|
|
|
int i, count;
|
|
|
|
|
|
|
|
GETI(count);
|
|
|
|
m = alloca(sizeof(Edje_Message_String_Float_Set) +
|
|
|
|
((count - 1) * sizeof(double)));
|
|
|
|
GETS(m->str);
|
|
|
|
m->count = count;
|
|
|
|
for (i = 0; i < m->count; i++)
|
|
|
|
{
|
|
|
|
GETF(m->val[i]);
|
|
|
|
}
|
|
|
|
edje_object_message_send(blk->obj,
|
|
|
|
EDJE_MESSAGE_STRING_FLOAT_SET,
|
|
|
|
id, m);
|
|
|
|
}
|
2012-07-06 03:08:51 -07:00
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
else if (ISCMD("chid")) // set callback channel id
|
2014-01-20 14:04:51 -08:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
char *chid;
|
|
|
|
|
|
|
|
GETS(chid);
|
|
|
|
if (!blk->chid)
|
|
|
|
{
|
|
|
|
blk->chid = eina_stringshare_add(chid);
|
|
|
|
termpty_block_chid_update(ty, blk);
|
|
|
|
}
|
|
|
|
if (created)
|
|
|
|
{
|
|
|
|
edje_object_signal_callback_add(blk->obj, "*", "*",
|
|
|
|
_block_edje_signal_cb,
|
|
|
|
blk);
|
|
|
|
edje_object_message_handler_set(blk->obj,
|
|
|
|
_block_edje_message_cb,
|
|
|
|
blk);
|
|
|
|
}
|
2014-01-20 14:04:51 -08:00
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
if (l) l = l->next;
|
2014-01-20 14:04:51 -08:00
|
|
|
}
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-08-19 13:38:02 -07:00
|
|
|
_block_edje_activate(Evas_Object *obj, Termblock *blk)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
2014-08-19 13:38:02 -07:00
|
|
|
Eina_Bool ok = EINA_FALSE;
|
|
|
|
|
2013-12-01 09:22:17 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2014-08-19 13:38:02 -07:00
|
|
|
if ((!blk->path) || (!blk->link)) return;
|
|
|
|
blk->obj = edje_object_add(evas_object_evas_get(obj));
|
|
|
|
if (blk->path[0] == '/')
|
2015-08-23 07:40:19 -07:00
|
|
|
{
|
|
|
|
ok = edje_object_file_set(blk->obj, blk->path, blk->link);
|
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
else if (!strcmp(blk->path, "THEME"))
|
2015-08-23 07:40:19 -07:00
|
|
|
{
|
|
|
|
ok = edje_object_file_set(blk->obj,
|
2020-10-17 14:33:04 -07:00
|
|
|
config_theme_path_get(sd->config),
|
2015-08-23 07:40:19 -07:00
|
|
|
blk->link);
|
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
char path[PATH_MAX], home[PATH_MAX];
|
|
|
|
|
|
|
|
if (homedir_get(home, sizeof(home)))
|
|
|
|
{
|
2018-11-16 04:47:16 -08:00
|
|
|
if ((size_t)snprintf(path, sizeof(path),
|
|
|
|
"%s/.terminology/objlib/%s",
|
|
|
|
home, blk->path) >= sizeof(path))
|
|
|
|
{
|
|
|
|
ERR("Not enough space in buffer for path to edje lib file");
|
|
|
|
goto skip;
|
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
ok = edje_object_file_set(blk->obj, path, blk->link);
|
|
|
|
}
|
|
|
|
if (!ok)
|
|
|
|
{
|
2018-11-16 04:47:16 -08:00
|
|
|
if ((size_t)snprintf(path, sizeof(path), "%s/objlib/%s",
|
|
|
|
elm_app_data_dir_get(), blk->path)
|
|
|
|
>= sizeof(path))
|
|
|
|
{
|
|
|
|
ERR("Not enough space in buffer for path to edje lib file");
|
|
|
|
goto skip;
|
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
ok = edje_object_file_set(blk->obj, path, blk->link);
|
|
|
|
}
|
|
|
|
}
|
2018-11-16 04:47:16 -08:00
|
|
|
skip:
|
2014-08-19 13:38:02 -07:00
|
|
|
evas_object_smart_member_add(blk->obj, obj);
|
|
|
|
evas_object_stack_above(blk->obj, sd->event);
|
|
|
|
evas_object_show(blk->obj);
|
|
|
|
evas_object_data_set(blk->obj, "blk", blk);
|
|
|
|
|
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
_block_edje_cmds(sd->pty, blk, blk->cmds, EINA_TRUE);
|
|
|
|
}
|
2015-08-23 07:40:19 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("failed to activate textblock of id %d", blk->id);
|
|
|
|
}
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
|
2012-06-18 17:37:27 -07:00
|
|
|
static void
|
2014-08-19 13:38:02 -07:00
|
|
|
_block_media_activate(Evas_Object *obj, Termblock *blk)
|
2012-06-18 17:37:27 -07:00
|
|
|
{
|
2012-07-01 20:47:02 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
2014-10-08 15:12:34 -07:00
|
|
|
Media_Type type;
|
2014-08-19 13:38:02 -07:00
|
|
|
int media = MEDIA_STRETCH;
|
|
|
|
Evas_Object *mctrl;
|
2014-01-01 07:52:03 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2015-08-23 07:40:19 -07:00
|
|
|
|
|
|
|
if (blk->scale_stretch)
|
|
|
|
media = MEDIA_STRETCH;
|
|
|
|
else if (blk->scale_center)
|
|
|
|
media = MEDIA_POP;
|
|
|
|
else if (blk->scale_fill)
|
|
|
|
media = MEDIA_BG;
|
|
|
|
else if (blk->thumb)
|
|
|
|
media = MEDIA_THUMB;
|
|
|
|
|
2014-09-15 03:01:22 -07:00
|
|
|
if (!blk->was_active_before || blk->mov_state == MOVIE_STATE_STOP)
|
|
|
|
media |= MEDIA_SAVE;
|
|
|
|
else
|
|
|
|
media |= MEDIA_RECOVER | MEDIA_SAVE;
|
2015-08-23 07:40:19 -07:00
|
|
|
|
2021-09-13 14:30:09 -07:00
|
|
|
type = media_src_type_get(blk->path, strlen(blk->path));
|
2014-10-08 15:12:34 -07:00
|
|
|
blk->obj = media_add(obj, blk->path, sd->config, media, type);
|
2015-08-23 07:40:19 -07:00
|
|
|
|
2014-10-08 15:12:34 -07:00
|
|
|
if (type == MEDIA_TYPE_MOV)
|
2014-09-15 03:01:22 -07:00
|
|
|
media_play_set(blk->obj, blk->mov_state == MOVIE_STATE_PLAY);
|
2015-08-23 07:40:19 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
evas_object_event_callback_add
|
|
|
|
(blk->obj, EVAS_CALLBACK_DEL, _smart_media_del, blk);
|
2014-09-15 03:01:22 -07:00
|
|
|
evas_object_smart_callback_add(blk->obj, "play", _smart_media_play, blk);
|
|
|
|
evas_object_smart_callback_add(blk->obj, "pause", _smart_media_pause, blk);
|
|
|
|
evas_object_smart_callback_add(blk->obj, "stop", _smart_media_stop, blk);
|
2015-08-23 07:40:19 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
blk->type = type;
|
|
|
|
evas_object_smart_member_add(blk->obj, obj);
|
2015-08-23 07:40:19 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
mctrl = media_control_get(blk->obj);
|
|
|
|
if (mctrl)
|
|
|
|
{
|
|
|
|
evas_object_smart_member_add(mctrl, obj);
|
|
|
|
evas_object_stack_above(mctrl, sd->event);
|
2012-07-01 20:47:02 -07:00
|
|
|
}
|
2015-08-23 07:40:19 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
evas_object_stack_above(blk->obj, sd->grid.obj);
|
|
|
|
evas_object_show(blk->obj);
|
|
|
|
evas_object_data_set(blk->obj, "blk", blk);
|
2015-08-23 07:40:19 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
if (blk->thumb)
|
2015-08-23 07:40:19 -07:00
|
|
|
{
|
|
|
|
evas_object_smart_callback_add(blk->obj, "clicked",
|
|
|
|
_smart_media_clicked, obj);
|
|
|
|
}
|
2012-07-01 20:47:02 -07:00
|
|
|
}
|
|
|
|
|
2019-02-09 14:48:15 -08:00
|
|
|
void
|
|
|
|
termio_block_activate(Evas_Object *obj, Termblock *blk)
|
2012-08-22 03:34:28 -07:00
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
2013-12-01 09:50:45 -08:00
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2015-08-23 07:40:19 -07:00
|
|
|
|
|
|
|
if (blk->active)
|
|
|
|
return;
|
2014-08-19 13:38:02 -07:00
|
|
|
blk->active = EINA_TRUE;
|
2015-08-23 07:40:19 -07:00
|
|
|
if (blk->obj)
|
|
|
|
return;
|
|
|
|
if (blk->edje)
|
|
|
|
_block_edje_activate(obj, blk);
|
|
|
|
else
|
|
|
|
_block_media_activate(obj, blk);
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
blk->was_active_before = EINA_TRUE;
|
|
|
|
if (!blk->was_active)
|
|
|
|
sd->pty->block.active = eina_list_append(sd->pty->block.active, blk);
|
|
|
|
}
|
2013-12-01 09:50:45 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static void
|
|
|
|
_block_obj_del(Termblock *blk)
|
|
|
|
{
|
|
|
|
if (!blk->obj) return;
|
|
|
|
|
|
|
|
evas_object_event_callback_del_full
|
|
|
|
(blk->obj, EVAS_CALLBACK_DEL,
|
|
|
|
_smart_media_del, blk);
|
|
|
|
evas_object_del(blk->obj);
|
|
|
|
blk->obj = NULL;
|
2012-08-22 03:34:28 -07:00
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
/* }}} */
|
2019-02-02 06:36:58 -08:00
|
|
|
/* {{{ Mouse */
|
2012-06-12 03:10:01 -07:00
|
|
|
|
2019-02-02 06:36:58 -08:00
|
|
|
void
|
|
|
|
termio_event_feed_mouse_in(Evas_Object *obj)
|
2015-04-05 03:13:04 -07:00
|
|
|
{
|
2019-02-02 06:36:58 -08:00
|
|
|
Evas *e;
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
2013-12-01 09:50:45 -08:00
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2014-08-19 13:38:02 -07:00
|
|
|
e = evas_object_evas_get(obj);
|
|
|
|
evas_event_feed_mouse_in(e, 0, NULL);
|
2012-07-03 08:25:19 -07:00
|
|
|
}
|
|
|
|
|
2018-02-04 15:07:47 -08:00
|
|
|
void
|
|
|
|
termio_imf_cursor_set(Evas_Object *obj, Ecore_IMF_Context *imf)
|
2012-07-18 01:36:28 -07:00
|
|
|
{
|
2018-02-04 15:07:47 -08:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
2014-08-19 13:38:02 -07:00
|
|
|
Evas_Coord cx, cy, cw, ch;
|
2018-02-04 15:07:47 -08:00
|
|
|
|
|
|
|
if (!imf)
|
|
|
|
return;
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2014-08-19 13:38:02 -07:00
|
|
|
evas_object_geometry_get(sd->cursor.obj, &cx, &cy, &cw, &ch);
|
2018-02-04 15:07:47 -08:00
|
|
|
ecore_imf_context_cursor_location_set(imf, cx, cy, cw, ch);
|
|
|
|
ecore_imf_context_cursor_position_set(imf, (sd->cursor.y * sd->grid.w) + sd->cursor.x);
|
2012-07-18 01:36:28 -07:00
|
|
|
}
|
|
|
|
|
2017-11-13 14:48:05 -08:00
|
|
|
void
|
|
|
|
termio_focus_in(Evas_Object *termio)
|
2012-07-18 01:36:28 -07:00
|
|
|
{
|
2017-11-13 14:48:05 -08:00
|
|
|
Termio *sd = evas_object_smart_data_get(termio);
|
2014-08-19 13:38:02 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2012-07-18 01:36:28 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
if (sd->config->disable_cursor_blink)
|
|
|
|
edje_object_signal_emit(sd->cursor.obj, "focus,in,noblink", "terminology");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(sd->cursor.obj, "focus,in", "terminology");
|
|
|
|
if (!sd->win) return;
|
2021-11-02 15:28:37 -07:00
|
|
|
termpty_focus_report(sd->pty, EINA_TRUE);
|
2012-07-18 01:36:28 -07:00
|
|
|
}
|
|
|
|
|
2017-11-13 14:48:05 -08:00
|
|
|
void
|
|
|
|
termio_focus_out(Evas_Object *termio)
|
2012-07-18 01:36:28 -07:00
|
|
|
{
|
2017-11-13 14:48:05 -08:00
|
|
|
Termio *sd = evas_object_smart_data_get(termio);
|
2014-08-19 13:38:02 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2012-07-18 01:36:28 -07:00
|
|
|
|
2017-03-13 09:02:52 -07:00
|
|
|
if (!sd->config->disable_focus_visuals)
|
|
|
|
edje_object_signal_emit(sd->cursor.obj, "focus,out", "terminology");
|
2014-08-19 13:38:02 -07:00
|
|
|
if (!sd->win) return;
|
2015-02-10 14:53:20 -08:00
|
|
|
sd->pty->selection.last_click = 0;
|
2015-06-03 14:03:07 -07:00
|
|
|
if (!sd->ctxpopup)
|
2020-04-16 14:43:21 -07:00
|
|
|
termio_remove_links(sd);
|
2021-11-02 15:28:37 -07:00
|
|
|
termpty_focus_report(sd->pty, EINA_FALSE);
|
2015-05-31 08:38:02 -07:00
|
|
|
term_unfocus(sd->term);
|
2012-07-18 01:36:28 -07:00
|
|
|
}
|
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
static void
|
2019-02-04 14:10:51 -08:00
|
|
|
_smart_mouseover_apply(Termio *sd)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
char *s;
|
|
|
|
int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
|
2018-10-14 03:49:04 -07:00
|
|
|
Eina_Bool same_geom = EINA_FALSE;
|
2014-10-08 14:45:21 -07:00
|
|
|
Config *config;
|
2018-10-13 10:15:57 -07:00
|
|
|
Termcell *cell = NULL;
|
2013-11-20 13:36:51 -08:00
|
|
|
|
2013-12-01 09:50:45 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2014-10-08 14:45:21 -07:00
|
|
|
config = sd->config;
|
2013-12-01 09:50:45 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
if ((sd->mouse.cx < 0) || (sd->mouse.cy < 0) ||
|
2019-06-17 13:13:39 -07:00
|
|
|
(sd->link.suspend) || (!term_is_focused(sd->term)))
|
2012-10-05 00:50:16 -07:00
|
|
|
{
|
2020-04-16 14:43:21 -07:00
|
|
|
termio_remove_links(sd);
|
2012-10-05 00:50:16 -07:00
|
|
|
return;
|
|
|
|
}
|
2018-10-13 10:15:57 -07:00
|
|
|
cell = termpty_cell_get(sd->pty, sd->mouse.cy - sd->scroll, sd->mouse.cx);
|
|
|
|
if (!cell)
|
2019-02-02 06:36:58 -08:00
|
|
|
{
|
2020-04-16 14:43:21 -07:00
|
|
|
termio_remove_links(sd);
|
2019-02-02 06:36:58 -08:00
|
|
|
return;
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
2013-12-01 09:50:45 -08:00
|
|
|
|
2019-02-02 06:36:58 -08:00
|
|
|
if (cell->att.link_id)
|
|
|
|
{
|
|
|
|
if (config->active_links_escape)
|
2019-02-04 14:10:51 -08:00
|
|
|
_hyperlink_mouseover(sd, cell->att.link_id);
|
2019-02-02 06:36:58 -08:00
|
|
|
return;
|
|
|
|
}
|
2012-10-25 12:36:46 -07:00
|
|
|
|
2019-02-04 14:10:51 -08:00
|
|
|
s = termio_link_find(sd->self, sd->mouse.cx, sd->mouse.cy,
|
2019-02-02 06:36:58 -08:00
|
|
|
&x1, &y1, &x2, &y2);
|
2020-06-14 13:00:25 -07:00
|
|
|
if (!s && config->active_links_color)
|
2012-10-25 12:36:46 -07:00
|
|
|
{
|
2020-04-20 12:20:21 -07:00
|
|
|
uint8_t r = 0, g = 0, b = 0, a = 0;
|
2020-06-14 13:00:25 -07:00
|
|
|
|
2020-04-20 12:20:21 -07:00
|
|
|
if (termio_color_find(sd->self, sd->mouse.cx, sd->mouse.cy,
|
|
|
|
&x1, &y1, &x2, &y2, &r, &g, &b, &a))
|
|
|
|
{
|
|
|
|
sd->link.is_color = EINA_TRUE;
|
|
|
|
sd->link.color.r = r;
|
|
|
|
sd->link.color.g = g;
|
|
|
|
sd->link.color.b = b;
|
|
|
|
sd->link.color.a = a;
|
|
|
|
goto found;
|
|
|
|
}
|
2020-04-16 14:43:21 -07:00
|
|
|
termio_remove_links(sd);
|
2019-02-02 06:36:58 -08:00
|
|
|
return;
|
|
|
|
}
|
2020-06-14 13:00:25 -07:00
|
|
|
if (!s)
|
|
|
|
return;
|
2014-08-19 13:38:02 -07:00
|
|
|
|
2019-02-02 06:36:58 -08:00
|
|
|
if (link_is_url(s))
|
|
|
|
{
|
|
|
|
if (casestartswith(s, "mailto:"))
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
2019-02-02 06:36:58 -08:00
|
|
|
if (!config->active_links_email)
|
2019-03-18 15:02:36 -07:00
|
|
|
goto end;
|
2013-12-01 14:40:58 -08:00
|
|
|
}
|
2019-02-02 06:36:58 -08:00
|
|
|
else
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
2019-02-02 06:36:58 -08:00
|
|
|
if (!config->active_links_url)
|
2019-03-18 15:02:36 -07:00
|
|
|
goto end;
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
2012-10-25 12:36:46 -07:00
|
|
|
}
|
2019-02-02 06:36:58 -08:00
|
|
|
else if (s[0] == '/')
|
|
|
|
{
|
|
|
|
if (!config->active_links_file)
|
2019-03-18 15:02:36 -07:00
|
|
|
goto end;
|
2019-02-02 06:36:58 -08:00
|
|
|
}
|
|
|
|
else if (link_is_email(s))
|
|
|
|
{
|
|
|
|
if (!config->active_links_email)
|
2019-03-18 15:02:36 -07:00
|
|
|
goto end;
|
2019-02-02 06:36:58 -08:00
|
|
|
}
|
|
|
|
|
2019-11-29 10:59:57 -08:00
|
|
|
eina_stringshare_del(sd->link.string);
|
2019-02-02 06:36:58 -08:00
|
|
|
sd->link.string = eina_stringshare_add(s);
|
|
|
|
|
2020-04-20 12:20:21 -07:00
|
|
|
found:
|
2019-02-02 06:36:58 -08:00
|
|
|
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(sd, same_geom);
|
2019-03-18 15:02:36 -07:00
|
|
|
|
|
|
|
end:
|
|
|
|
free(s);
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
2013-05-27 13:44:37 -07:00
|
|
|
|
2019-02-02 06:36:58 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_smart_mouseover_delay(void *data)
|
|
|
|
{
|
2019-02-04 14:10:51 -08:00
|
|
|
Termio *sd = data;
|
2012-10-25 12:36:46 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EINA_FALSE);
|
|
|
|
sd->mouseover_delay = NULL;
|
2019-02-04 14:10:51 -08:00
|
|
|
_smart_mouseover_apply(sd);
|
2014-08-19 13:38:02 -07:00
|
|
|
return EINA_FALSE;
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
|
2019-02-02 06:36:58 -08:00
|
|
|
void
|
|
|
|
termio_smart_cb_mouse_move_job(void *data)
|
2012-06-15 22:07:33 -07:00
|
|
|
{
|
2019-02-02 06:36:58 -08:00
|
|
|
Termio *sd = data;
|
2012-06-15 22:07:33 -07:00
|
|
|
|
2013-12-01 09:50:45 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2014-08-19 13:38:02 -07:00
|
|
|
sd->mouse_move_job = NULL;
|
|
|
|
if (sd->mouseover_delay)
|
|
|
|
ecore_timer_reset(sd->mouseover_delay);
|
|
|
|
else
|
2019-02-04 14:10:51 -08:00
|
|
|
sd->mouseover_delay = ecore_timer_add(0.05, _smart_mouseover_delay, sd);
|
2012-06-15 22:07:33 -07:00
|
|
|
}
|
|
|
|
|
2019-02-02 06:36:58 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_edje_cb_bottom_right_in(void *data,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
const char *_emission EINA_UNUSED,
|
|
|
|
const char *_source EINA_UNUSED)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Termio *sd = data;
|
2012-06-17 13:24:23 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
sd->bottom_right = EINA_TRUE;
|
|
|
|
}
|
2012-06-12 03:10:01 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_edje_cb_top_left_in(void *data,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
const char *_emission EINA_UNUSED,
|
|
|
|
const char *_source EINA_UNUSED)
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
|
|
|
Termio *sd = data;
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
sd->top_left = EINA_TRUE;
|
2012-06-17 13:24:23 -07:00
|
|
|
}
|
|
|
|
|
2012-06-18 21:16:36 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_edje_cb_bottom_right_out(void *data,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
const char *_emission EINA_UNUSED,
|
|
|
|
const char *_source EINA_UNUSED)
|
2012-06-18 21:16:36 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Termio *sd = data;
|
|
|
|
|
|
|
|
sd->bottom_right = EINA_FALSE;
|
2012-06-18 21:16:36 -07:00
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_edje_cb_top_left_out(void *data,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
const char *_emission EINA_UNUSED,
|
|
|
|
const char *_source EINA_UNUSED)
|
2012-07-01 20:47:02 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Termio *sd = data;
|
2013-12-01 09:50:45 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
sd->top_left = EINA_FALSE;
|
2012-07-01 20:47:02 -07:00
|
|
|
}
|
|
|
|
|
2015-01-21 13:56:16 -08:00
|
|
|
|
2015-04-05 03:13:04 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_ctxp_sel_copy(void *data,
|
|
|
|
Evas_Object *obj,
|
|
|
|
void *_event EINA_UNUSED)
|
2015-04-05 03:13:04 -07:00
|
|
|
{
|
2015-05-31 08:38:02 -07:00
|
|
|
Evas_Object *term = data;
|
|
|
|
Termio *sd = evas_object_smart_data_get(term);
|
|
|
|
|
2015-08-24 14:09:24 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
|
2015-04-05 03:13:04 -07:00
|
|
|
termio_take_selection(data, ELM_SEL_TYPE_CLIPBOARD);
|
2015-08-24 14:09:24 -07:00
|
|
|
|
|
|
|
sd->ctxpopup = NULL;
|
|
|
|
evas_object_del(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cb_ctxp_sel_open_as_url(void *data,
|
|
|
|
Evas_Object *obj,
|
|
|
|
void *_event EINA_UNUSED)
|
2015-08-24 14:09:24 -07:00
|
|
|
{
|
|
|
|
Evas_Object *term = data;
|
|
|
|
Termio *sd = evas_object_smart_data_get(term);
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
|
|
|
|
termio_take_selection(data, ELM_SEL_TYPE_PRIMARY);
|
|
|
|
|
|
|
|
if (!sd->have_sel || !sd->sel_str)
|
|
|
|
goto end;
|
|
|
|
|
2020-11-11 13:51:51 -08:00
|
|
|
open_url(sd->config, sd->sel_str);
|
2015-08-24 14:09:24 -07:00
|
|
|
|
|
|
|
end:
|
2015-05-31 08:38:02 -07:00
|
|
|
sd->ctxpopup = NULL;
|
2015-04-05 03:13:04 -07:00
|
|
|
evas_object_del(obj);
|
|
|
|
}
|
|
|
|
|
2015-08-24 14:09:24 -07:00
|
|
|
|
2019-02-02 06:36:58 -08:00
|
|
|
void
|
|
|
|
termio_handle_right_click(Evas_Event_Mouse_Down *ev, Termio *sd,
|
|
|
|
int cx, int cy)
|
2015-04-05 03:13:04 -07:00
|
|
|
{
|
|
|
|
if (_mouse_in_selection(sd, cx, cy))
|
|
|
|
{
|
|
|
|
Evas_Object *ctxp;
|
|
|
|
ctxp = elm_ctxpopup_add(sd->win);
|
|
|
|
sd->ctxpopup = ctxp;
|
|
|
|
|
2015-08-24 14:09:24 -07:00
|
|
|
elm_ctxpopup_item_append(ctxp, _("Copy"), NULL,
|
|
|
|
_cb_ctxp_sel_copy, sd->self);
|
|
|
|
elm_ctxpopup_item_append(ctxp, _("Open as URL"), NULL,
|
|
|
|
_cb_ctxp_sel_open_as_url, sd->self);
|
2015-04-05 03:13:04 -07:00
|
|
|
evas_object_move(ctxp, ev->canvas.x, ev->canvas.y);
|
|
|
|
evas_object_show(ctxp);
|
|
|
|
evas_object_smart_callback_add(ctxp, "dismissed",
|
|
|
|
_cb_ctxp_dismissed, sd);
|
|
|
|
evas_object_event_callback_add(ctxp, EVAS_CALLBACK_DEL,
|
|
|
|
_cb_ctxp_del, sd);
|
|
|
|
return;
|
|
|
|
}
|
2020-05-21 14:21:50 -07:00
|
|
|
if (!sd->link.string && !sd->link.is_color)
|
2019-02-02 06:36:58 -08:00
|
|
|
evas_object_smart_callback_call(sd->self, "options", NULL);
|
2015-04-05 03:13:04 -07:00
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_smart_cb_mouse_down(void *data,
|
|
|
|
Evas *_e EINA_UNUSED,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
void *event)
|
2012-07-01 20:47:02 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Evas_Event_Mouse_Down *ev = event;
|
2012-07-01 20:47:02 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
2019-02-06 10:25:02 -08:00
|
|
|
Termio_Modifiers modifiers = {};
|
2013-12-01 09:50:45 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2014-03-01 08:59:01 -08:00
|
|
|
|
2019-02-06 10:25:02 -08:00
|
|
|
modifiers.alt = evas_key_modifier_is_set(ev->modifiers, "Alt");
|
|
|
|
modifiers.shift = evas_key_modifier_is_set(ev->modifiers, "Shift");
|
|
|
|
modifiers.ctrl = evas_key_modifier_is_set(ev->modifiers, "Control");
|
|
|
|
modifiers.super = evas_key_modifier_is_set(ev->modifiers, "Super");
|
|
|
|
modifiers.meta = evas_key_modifier_is_set(ev->modifiers, "Meta");
|
|
|
|
modifiers.hyper = evas_key_modifier_is_set(ev->modifiers, "Hyper");
|
|
|
|
modifiers.iso_level3_shift = evas_key_modifier_is_set(ev->modifiers, "ISO_Level3_Shift");
|
|
|
|
modifiers.altgr= evas_key_modifier_is_set(ev->modifiers, "AltGr");
|
|
|
|
|
|
|
|
termio_internal_mouse_down(sd, ev, modifiers);
|
2012-07-01 20:47:02 -07:00
|
|
|
}
|
|
|
|
|
2012-06-18 17:37:27 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_smart_cb_mouse_up(void *data,
|
|
|
|
Evas *_e EINA_UNUSED,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
void *event)
|
2012-06-18 17:37:27 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Evas_Event_Mouse_Up *ev = event;
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
2019-02-06 10:25:02 -08:00
|
|
|
Termio_Modifiers modifiers = {};
|
2012-06-18 17:37:27 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2012-06-17 13:24:23 -07:00
|
|
|
|
2019-02-06 10:25:02 -08:00
|
|
|
modifiers.alt = evas_key_modifier_is_set(ev->modifiers, "Alt");
|
|
|
|
modifiers.shift = evas_key_modifier_is_set(ev->modifiers, "Shift");
|
|
|
|
modifiers.ctrl = evas_key_modifier_is_set(ev->modifiers, "Control");
|
|
|
|
modifiers.super = evas_key_modifier_is_set(ev->modifiers, "Super");
|
|
|
|
modifiers.meta = evas_key_modifier_is_set(ev->modifiers, "Meta");
|
|
|
|
modifiers.hyper = evas_key_modifier_is_set(ev->modifiers, "Hyper");
|
|
|
|
modifiers.iso_level3_shift = evas_key_modifier_is_set(ev->modifiers, "ISO_Level3_Shift");
|
|
|
|
modifiers.altgr= evas_key_modifier_is_set(ev->modifiers, "AltGr");
|
|
|
|
|
|
|
|
termio_internal_mouse_up(sd, ev, modifiers);
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_smart_cb_mouse_move(void *data,
|
|
|
|
Evas *_e EINA_UNUSED,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
void *event)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Evas_Event_Mouse_Move *ev = event;
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
2019-02-06 10:25:02 -08:00
|
|
|
Termio_Modifiers modifiers = {};
|
|
|
|
|
2013-12-01 09:50:45 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2012-06-12 03:10:01 -07:00
|
|
|
|
2019-02-06 10:25:02 -08:00
|
|
|
modifiers.alt = evas_key_modifier_is_set(ev->modifiers, "Alt");
|
|
|
|
modifiers.shift = evas_key_modifier_is_set(ev->modifiers, "Shift");
|
|
|
|
modifiers.ctrl = evas_key_modifier_is_set(ev->modifiers, "Control");
|
|
|
|
modifiers.super = evas_key_modifier_is_set(ev->modifiers, "Super");
|
|
|
|
modifiers.meta = evas_key_modifier_is_set(ev->modifiers, "Meta");
|
|
|
|
modifiers.hyper = evas_key_modifier_is_set(ev->modifiers, "Hyper");
|
|
|
|
modifiers.iso_level3_shift = evas_key_modifier_is_set(ev->modifiers, "ISO_Level3_Shift");
|
|
|
|
modifiers.altgr= evas_key_modifier_is_set(ev->modifiers, "AltGr");
|
|
|
|
|
|
|
|
termio_internal_mouse_move(sd, ev, modifiers);
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_smart_cb_mouse_in(void *data,
|
|
|
|
Evas *_e EINA_UNUSED,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
void *event)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
int cx = 0, cy = 0;
|
|
|
|
Evas_Event_Mouse_In *ev = event;
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
2013-12-01 09:50:45 -08:00
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2019-02-02 06:36:58 -08:00
|
|
|
termio_cursor_to_xy(sd, ev->canvas.x, ev->canvas.y, &cx, &cy);
|
2014-08-19 13:38:02 -07:00
|
|
|
sd->mouse.cx = cx;
|
|
|
|
sd->mouse.cy = cy;
|
|
|
|
termio_mouseover_suspend_pushpop(data, -1);
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_smart_cb_mouse_out(void *data,
|
|
|
|
Evas *_e EINA_UNUSED,
|
2018-10-15 12:34:15 -07:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
2014-08-19 13:38:02 -07:00
|
|
|
void *event)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
Evas_Event_Mouse_Out *ev = event;
|
2013-12-01 09:50:45 -08:00
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2012-06-12 03:10:01 -07:00
|
|
|
|
2015-04-05 03:13:04 -07:00
|
|
|
if (sd->ctxpopup) return; /* ctxp triggers mouse out we should ignore */
|
2013-12-01 09:50:45 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
termio_mouseover_suspend_pushpop(data, 1);
|
|
|
|
if ((ev->canvas.x == 0) || (ev->canvas.y == 0))
|
|
|
|
{
|
|
|
|
sd->mouse.cx = -1;
|
|
|
|
sd->mouse.cy = -1;
|
2020-04-19 14:22:57 -07:00
|
|
|
sd->link.suspend = 0;
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int cx = 0, cy = 0;
|
|
|
|
|
2019-02-02 06:36:58 -08:00
|
|
|
termio_cursor_to_xy(sd, ev->canvas.x, ev->canvas.y, &cx, &cy);
|
2014-08-19 13:38:02 -07:00
|
|
|
sd->mouse.cx = cx;
|
|
|
|
sd->mouse.cy = cy;
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
2020-04-16 14:43:21 -07:00
|
|
|
termio_remove_links(sd);
|
2014-08-19 13:38:02 -07:00
|
|
|
|
|
|
|
if (sd->mouseover_delay) ecore_timer_del(sd->mouseover_delay);
|
|
|
|
sd->mouseover_delay = NULL;
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
|
2012-06-20 07:12:26 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_smart_cb_mouse_wheel(void *data,
|
|
|
|
Evas *_e EINA_UNUSED,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
void *event)
|
2012-06-20 07:12:26 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Evas_Event_Mouse_Wheel *ev = event;
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
2019-02-19 11:03:14 -08:00
|
|
|
Termio_Modifiers modifiers = {};
|
2014-08-19 13:38:02 -07:00
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
|
2019-02-19 11:03:14 -08:00
|
|
|
modifiers.alt = evas_key_modifier_is_set(ev->modifiers, "Alt");
|
|
|
|
modifiers.shift = evas_key_modifier_is_set(ev->modifiers, "Shift");
|
|
|
|
modifiers.ctrl = evas_key_modifier_is_set(ev->modifiers, "Control");
|
|
|
|
modifiers.super = evas_key_modifier_is_set(ev->modifiers, "Super");
|
|
|
|
modifiers.meta = evas_key_modifier_is_set(ev->modifiers, "Meta");
|
|
|
|
modifiers.hyper = evas_key_modifier_is_set(ev->modifiers, "Hyper");
|
|
|
|
modifiers.iso_level3_shift = evas_key_modifier_is_set(ev->modifiers, "ISO_Level3_Shift");
|
|
|
|
modifiers.altgr= evas_key_modifier_is_set(ev->modifiers, "AltGr");
|
2015-02-13 13:58:41 -08:00
|
|
|
|
2019-02-19 11:03:14 -08:00
|
|
|
termio_internal_mouse_wheel(sd, ev, modifiers);
|
2012-06-20 07:12:26 -07:00
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
/* }}} */
|
|
|
|
/* {{{ Gestures */
|
|
|
|
|
|
|
|
static Evas_Event_Flags
|
2016-10-05 13:00:22 -07:00
|
|
|
_smart_cb_gest_long_move(void *data, void *_event EINA_UNUSED)
|
2012-06-23 02:25:01 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
// Elm_Gesture_Taps_Info *p = event;
|
2012-07-19 02:28:42 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
2013-12-01 09:50:45 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EVAS_EVENT_FLAG_ON_HOLD);
|
|
|
|
evas_object_smart_callback_call(data, "options", NULL);
|
|
|
|
sd->didclick = EINA_TRUE;
|
|
|
|
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);
|
2014-10-08 14:45:21 -07:00
|
|
|
Config *config;
|
2014-08-19 13:38:02 -07:00
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EVAS_EVENT_FLAG_ON_HOLD);
|
2014-10-08 14:45:21 -07:00
|
|
|
config = sd->config;
|
2014-08-19 13:38:02 -07:00
|
|
|
if (config)
|
|
|
|
{
|
2016-01-29 06:15:13 -08:00
|
|
|
sd->gesture_zoom_start_size = (double)config->font.size;
|
2015-08-06 12:26:43 -07:00
|
|
|
int sz = (double)config->font.size * p->zoom;
|
2014-08-19 13:38:02 -07:00
|
|
|
sd->zoom_fontsize_start = config->font.size;
|
2015-08-06 12:26:43 -07:00
|
|
|
if (sz != config->font.size)
|
|
|
|
win_font_size_set(term_win_get(sd->term), sz);
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
|
|
|
sd->didclick = EINA_TRUE;
|
|
|
|
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);
|
2014-10-08 14:45:21 -07:00
|
|
|
Config *config;
|
2014-08-19 13:38:02 -07:00
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EVAS_EVENT_FLAG_ON_HOLD);
|
2014-10-08 14:45:21 -07:00
|
|
|
config = sd->config;
|
2014-08-19 13:38:02 -07:00
|
|
|
if (config)
|
|
|
|
{
|
2016-01-29 06:15:13 -08:00
|
|
|
int sz = sd->gesture_zoom_start_size * p->zoom;
|
2015-08-06 12:26:43 -07:00
|
|
|
if (sz != config->font.size)
|
|
|
|
win_font_size_set(term_win_get(sd->term), sz);
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
|
|
|
sd->didclick = EINA_TRUE;
|
|
|
|
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);
|
2014-10-08 14:45:21 -07:00
|
|
|
Config *config;
|
2014-08-19 13:38:02 -07:00
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EVAS_EVENT_FLAG_ON_HOLD);
|
2014-10-08 14:45:21 -07:00
|
|
|
config = sd->config;
|
2014-08-19 13:38:02 -07:00
|
|
|
if (config)
|
|
|
|
{
|
2016-01-29 06:15:13 -08:00
|
|
|
int sz = sd->gesture_zoom_start_size * p->zoom;
|
|
|
|
sd->gesture_zoom_start_size = 0.0;
|
2015-08-06 12:26:43 -07:00
|
|
|
if (sz != config->font.size)
|
|
|
|
win_font_size_set(term_win_get(sd->term), sz);
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
|
|
|
sd->didclick = EINA_TRUE;
|
|
|
|
return EVAS_EVENT_FLAG_ON_HOLD;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Event_Flags
|
2016-10-05 13:00:22 -07:00
|
|
|
_smart_cb_gest_zoom_abort(void *data, void *_event EINA_UNUSED)
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
2014-10-08 14:45:21 -07:00
|
|
|
Config *config;
|
2014-08-19 13:38:02 -07:00
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EVAS_EVENT_FLAG_ON_HOLD);
|
2014-10-08 14:45:21 -07:00
|
|
|
config = sd->config;
|
2014-08-19 13:38:02 -07:00
|
|
|
if (config)
|
|
|
|
{
|
|
|
|
if (sd->zoom_fontsize_start != config->font.size)
|
2015-08-06 12:26:43 -07:00
|
|
|
win_font_size_set(term_win_get(sd->term), sd->zoom_fontsize_start);
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
|
|
|
sd->didclick = EINA_TRUE;
|
|
|
|
return EVAS_EVENT_FLAG_ON_HOLD;
|
2012-06-23 02:25:01 -07:00
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
/* }}} */
|
2017-12-17 06:36:51 -08:00
|
|
|
|
|
|
|
Eina_Bool
|
|
|
|
termio_file_send_ok(const Evas_Object *obj, const char *file)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
Termpty *ty;
|
|
|
|
|
|
|
|
if (!sd) return EINA_FALSE;
|
|
|
|
if (!file) return EINA_FALSE;
|
|
|
|
ty = sd->pty;
|
|
|
|
sd->sendfile.f = fopen(file, "w");
|
|
|
|
if (sd->sendfile.f)
|
|
|
|
{
|
2019-11-29 10:59:57 -08:00
|
|
|
eina_stringshare_del(sd->sendfile.file);
|
2017-12-17 06:36:51 -08:00
|
|
|
sd->sendfile.file = eina_stringshare_add(file);
|
|
|
|
sd->sendfile.active = EINA_TRUE;
|
|
|
|
termpty_write(ty, "k\n", 2);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2019-11-29 10:59:57 -08:00
|
|
|
eina_stringshare_del(sd->sendfile.file);
|
2017-12-17 06:36:51 -08:00
|
|
|
sd->sendfile.file = NULL;
|
|
|
|
sd->sendfile.active = EINA_FALSE;
|
|
|
|
termpty_write(ty, "n\n", 2);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
termio_file_send_cancel(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
Termpty *ty;
|
|
|
|
|
|
|
|
if (!sd) return;
|
|
|
|
ty = sd->pty;
|
|
|
|
if (!sd->sendfile.active) goto done;
|
|
|
|
sd->sendfile.progress = 0.0;
|
|
|
|
sd->sendfile.total = 0;
|
|
|
|
sd->sendfile.size = 0;
|
|
|
|
if (sd->sendfile.file)
|
|
|
|
{
|
|
|
|
ecore_file_unlink(sd->sendfile.file);
|
|
|
|
eina_stringshare_del(sd->sendfile.file);
|
|
|
|
sd->sendfile.file = NULL;
|
|
|
|
}
|
|
|
|
if (sd->sendfile.f)
|
|
|
|
{
|
|
|
|
fclose(sd->sendfile.f);
|
|
|
|
sd->sendfile.f = NULL;
|
|
|
|
}
|
|
|
|
sd->sendfile.active = EINA_FALSE;
|
|
|
|
done:
|
|
|
|
termpty_write(ty, "n\n", 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
double
|
|
|
|
termio_file_send_progress_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
|
|
|
|
if (!sd) return 0.0;
|
|
|
|
if (!sd->sendfile.active) return 0.0;
|
|
|
|
return sd->sendfile.progress;
|
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
/* {{{ Smart */
|
|
|
|
|
2012-06-30 17:24:30 -07:00
|
|
|
static void
|
2014-08-19 13:38:02 -07:00
|
|
|
_smart_apply(Evas_Object *obj)
|
2012-06-30 17:24:30 -07:00
|
|
|
{
|
2013-02-21 05:23:48 -08:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
2014-08-19 13:38:02 -07:00
|
|
|
Evas_Coord ox, oy, ow, oh;
|
2019-02-09 14:48:15 -08:00
|
|
|
int preedit_x = 0, preedit_y = 0;
|
2014-08-19 13:38:02 -07:00
|
|
|
Termblock *blk;
|
2019-02-09 14:48:15 -08:00
|
|
|
Eina_List *l, *ln;
|
2013-12-01 09:50:45 -08:00
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2019-01-30 13:48:55 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
|
|
|
|
|
2019-02-09 14:48:15 -08:00
|
|
|
termio_internal_render(sd,
|
|
|
|
ox, oy,
|
|
|
|
&preedit_x, &preedit_y);
|
2014-08-19 13:38:02 -07:00
|
|
|
|
|
|
|
EINA_LIST_FOREACH_SAFE(sd->pty->block.active, l, ln, blk)
|
|
|
|
{
|
|
|
|
if (!blk->active)
|
2013-04-21 08:37:11 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
blk->was_active = EINA_FALSE;
|
|
|
|
_block_obj_del(blk);
|
|
|
|
sd->pty->block.active = eina_list_remove_list
|
|
|
|
(sd->pty->block.active, l);
|
2013-01-28 19:34:50 -08:00
|
|
|
}
|
2013-01-28 08:06:26 -08:00
|
|
|
}
|
2015-04-19 10:59:29 -07:00
|
|
|
if ((sd->scroll != 0) || (sd->pty->termstate.hide_cursor))
|
2014-08-19 13:38:02 -07:00
|
|
|
evas_object_hide(sd->cursor.obj);
|
|
|
|
else
|
|
|
|
evas_object_show(sd->cursor.obj);
|
2015-04-19 10:59:29 -07:00
|
|
|
sd->cursor.x = sd->pty->cursor_state.cx;
|
|
|
|
sd->cursor.y = sd->pty->cursor_state.cy;
|
2014-08-19 13:38:02 -07:00
|
|
|
evas_object_move(sd->cursor.obj,
|
2015-01-07 05:35:49 -08:00
|
|
|
ox + ((sd->cursor.x + preedit_x) * sd->font.chw),
|
|
|
|
oy + ((sd->cursor.y + preedit_y) * sd->font.chh));
|
2014-08-19 13:38:02 -07:00
|
|
|
if (sd->pty->selection.is_active)
|
2013-01-28 08:06:26 -08:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
int start_x, start_y, end_x, end_y;
|
|
|
|
int size_top, size_bottom;
|
|
|
|
|
|
|
|
start_x = sd->pty->selection.start.x;
|
|
|
|
start_y = sd->pty->selection.start.y;
|
|
|
|
end_x = sd->pty->selection.end.x;
|
|
|
|
end_y = sd->pty->selection.end.y;
|
|
|
|
|
2015-01-21 13:56:16 -08:00
|
|
|
if (!sd->pty->selection.is_top_to_bottom)
|
2013-01-28 08:06:26 -08:00
|
|
|
{
|
2015-01-21 13:56:16 -08:00
|
|
|
INT_SWAP(start_y, end_y);
|
|
|
|
INT_SWAP(start_x, end_x);
|
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
size_top = start_x * sd->font.chw;
|
|
|
|
|
|
|
|
size_bottom = (sd->grid.w - end_x - 1) * sd->font.chw;
|
|
|
|
|
|
|
|
evas_object_size_hint_min_set(sd->sel.top,
|
|
|
|
size_top,
|
|
|
|
sd->font.chh);
|
|
|
|
evas_object_size_hint_max_set(sd->sel.top,
|
|
|
|
size_top,
|
|
|
|
sd->font.chh);
|
|
|
|
evas_object_size_hint_min_set(sd->sel.bottom,
|
|
|
|
size_bottom,
|
|
|
|
sd->font.chh);
|
|
|
|
evas_object_size_hint_max_set(sd->sel.bottom,
|
|
|
|
size_bottom,
|
|
|
|
sd->font.chh);
|
|
|
|
evas_object_move(sd->sel.theme,
|
|
|
|
ox,
|
|
|
|
oy + ((start_y + sd->scroll) * sd->font.chh));
|
|
|
|
evas_object_resize(sd->sel.theme,
|
|
|
|
sd->grid.w * sd->font.chw,
|
|
|
|
(end_y + 1 - start_y) * sd->font.chh);
|
|
|
|
|
|
|
|
if (sd->pty->selection.is_box)
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(sd->sel.theme,
|
|
|
|
"mode,oneline", "terminology");
|
2013-01-28 08:06:26 -08:00
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
else
|
2013-04-20 00:54:11 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
if ((start_y == end_y) ||
|
|
|
|
((start_x == 0) && (end_x == (sd->grid.w - 1))))
|
2013-04-20 00:54:11 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
edje_object_signal_emit(sd->sel.theme,
|
|
|
|
"mode,oneline", "terminology");
|
|
|
|
}
|
|
|
|
else if ((start_y == (end_y - 1)) &&
|
|
|
|
(start_x > end_x))
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(sd->sel.theme,
|
|
|
|
"mode,disjoint", "terminology");
|
|
|
|
}
|
|
|
|
else if (start_x == 0)
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(sd->sel.theme,
|
|
|
|
"mode,topfull", "terminology");
|
|
|
|
}
|
|
|
|
else if (end_x == (sd->grid.w - 1))
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(sd->sel.theme,
|
|
|
|
"mode,bottomfull", "terminology");
|
2013-04-20 00:54:11 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
edje_object_signal_emit(sd->sel.theme,
|
|
|
|
"mode,multiline", "terminology");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
evas_object_show(sd->sel.theme);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
evas_object_hide(sd->sel.theme);
|
|
|
|
if (sd->mouseover_delay)
|
|
|
|
{
|
|
|
|
ecore_timer_reset(sd->mouseover_delay);
|
|
|
|
}
|
|
|
|
miniview_redraw(term_miniview_get(sd->term));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_smart_size(Evas_Object *obj, int w, int h, Eina_Bool force)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
2019-05-17 18:41:16 -07:00
|
|
|
Evas_Coord mw = 0, mh = 0;
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
|
2019-06-23 07:39:17 -07:00
|
|
|
if ((w <= 1) || (h <= 1))
|
2017-03-05 07:40:10 -08:00
|
|
|
{
|
|
|
|
w = 80;
|
|
|
|
h = 24;
|
|
|
|
}
|
2016-12-06 14:42:10 -08:00
|
|
|
|
2019-05-17 18:41:16 -07:00
|
|
|
evas_object_size_hint_min_get(obj, &mw, &mh);
|
|
|
|
if ((mw != sd->font.chw) || (mh != sd->font.chh))
|
|
|
|
evas_object_size_hint_min_set(obj, sd->font.chw, sd->font.chh);
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
if (!force)
|
|
|
|
{
|
|
|
|
if ((w == sd->grid.w) && (h == sd->grid.h)) return;
|
|
|
|
}
|
|
|
|
sd->grid.w = w;
|
|
|
|
sd->grid.h = h;
|
2019-01-05 09:25:11 -08:00
|
|
|
evas_event_freeze(evas_object_evas_get(obj));
|
|
|
|
evas_object_textgrid_size_set(sd->grid.obj, w, h);
|
2014-08-19 13:38:02 -07:00
|
|
|
evas_object_resize(sd->cursor.obj, sd->font.chw, sd->font.chh);
|
|
|
|
if (!sd->noreqsize)
|
|
|
|
evas_object_size_hint_request_set(obj,
|
|
|
|
sd->font.chw * sd->grid.w,
|
|
|
|
sd->font.chh * sd->grid.h);
|
2019-02-02 06:36:58 -08:00
|
|
|
termio_sel_set(sd, EINA_FALSE);
|
2014-08-19 13:38:02 -07:00
|
|
|
termpty_resize(sd->pty, w, h);
|
|
|
|
|
|
|
|
_smart_calculate(obj);
|
|
|
|
_smart_apply(obj);
|
|
|
|
evas_event_thaw(evas_object_evas_get(obj));
|
2018-03-11 00:59:58 -08:00
|
|
|
evas_event_thaw_eval(evas_object_evas_get(obj));
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EINA_FALSE);
|
|
|
|
sd->delayed_size_timer = NULL;
|
|
|
|
|
|
|
|
evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
|
|
|
|
|
|
|
|
w = ow / sd->font.chw;
|
|
|
|
h = oh / sd->font.chh;
|
|
|
|
_smart_size(obj, w, h, EINA_FALSE);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_smart_cb_change(void *data)
|
|
|
|
{
|
|
|
|
Evas_Object *obj = data;
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EINA_FALSE);
|
|
|
|
sd->anim = NULL;
|
|
|
|
_smart_apply(obj);
|
|
|
|
evas_object_smart_callback_call(obj, "changed", NULL);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2019-02-02 06:36:58 -08:00
|
|
|
void
|
|
|
|
termio_smart_update_queue(Termio *sd)
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
2019-02-01 11:06:28 -08:00
|
|
|
if (sd->anim)
|
|
|
|
return;
|
|
|
|
sd->anim = ecore_animator_add(_smart_cb_change, sd->self);
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
|
|
|
|
2019-02-02 06:36:58 -08:00
|
|
|
void
|
|
|
|
termio_sel_set(Termio *sd, Eina_Bool enable)
|
|
|
|
{
|
|
|
|
if (sd->pty->selection.is_active == enable)
|
|
|
|
return;
|
|
|
|
sd->pty->selection.is_active = enable;
|
|
|
|
if (enable)
|
|
|
|
evas_object_smart_callback_call(sd->win, "selection,on", NULL);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
evas_object_smart_callback_call(sd->win, "selection,off", NULL);
|
|
|
|
sd->pty->selection.by_word = EINA_FALSE;
|
|
|
|
sd->pty->selection.by_line = EINA_FALSE;
|
|
|
|
free(sd->pty->selection.codepoints);
|
|
|
|
sd->pty->selection.codepoints = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_cursor_cb_move(void *data,
|
|
|
|
Evas *_e EINA_UNUSED,
|
|
|
|
Evas_Object *_obj EINA_UNUSED,
|
|
|
|
void *_event EINA_UNUSED)
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
2018-02-09 14:18:03 -08:00
|
|
|
Ecore_IMF_Context *imf;
|
2014-08-19 13:38:02 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2018-02-09 14:18:03 -08:00
|
|
|
|
|
|
|
imf = term_imf_context_get(sd->term);
|
|
|
|
if (imf)
|
|
|
|
termio_imf_cursor_set(sd->self, imf);
|
2015-01-07 05:35:49 -08:00
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
|
|
|
|
static void
|
|
|
|
_smart_add(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Termio *sd;
|
|
|
|
Evas_Object *o;
|
|
|
|
|
|
|
|
sd = calloc(1, sizeof(Termio));
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
evas_object_smart_data_set(obj, sd);
|
|
|
|
|
|
|
|
_parent_sc.add(obj);
|
|
|
|
sd->self = obj;
|
|
|
|
|
|
|
|
/* Terminal output widget */
|
|
|
|
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;
|
|
|
|
|
|
|
|
/* 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->cursor.obj = o;
|
|
|
|
|
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOVE, _cursor_cb_move, obj);
|
|
|
|
|
|
|
|
/* Setup the selection widget */
|
|
|
|
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);
|
|
|
|
sd->sel.top = o;
|
|
|
|
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);
|
|
|
|
sd->sel.bottom = o;
|
|
|
|
o = edje_object_add(evas_object_evas_get(obj));
|
|
|
|
evas_object_smart_member_add(o, obj);
|
|
|
|
sd->sel.theme = o;
|
|
|
|
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);
|
|
|
|
|
|
|
|
/* Setup event catcher */
|
|
|
|
o = evas_object_rectangle_add(evas_object_evas_get(obj));
|
|
|
|
evas_object_repeat_events_set(o, EINA_TRUE);
|
|
|
|
evas_object_smart_member_add(o, obj);
|
|
|
|
sd->event = o;
|
|
|
|
evas_object_color_set(o, 0, 0, 0, 0);
|
|
|
|
evas_object_show(o);
|
|
|
|
|
|
|
|
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);
|
|
|
|
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);
|
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_WHEEL,
|
|
|
|
_smart_cb_mouse_wheel, obj);
|
|
|
|
|
|
|
|
sd->link.suspend = 1;
|
|
|
|
|
|
|
|
terms = eina_list_append(terms, obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_smart_del(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object *o;
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
char *chid;
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
terms = eina_list_remove(terms, obj);
|
|
|
|
if (sd->cursor.obj) evas_object_del(sd->cursor.obj);
|
2015-06-02 14:23:56 -07:00
|
|
|
if (sd->event)
|
|
|
|
{
|
|
|
|
evas_object_event_callback_del(sd->event, EVAS_CALLBACK_MOUSE_DOWN,
|
|
|
|
_smart_cb_mouse_down);
|
|
|
|
evas_object_event_callback_del(sd->event, EVAS_CALLBACK_MOUSE_UP,
|
|
|
|
_smart_cb_mouse_up);
|
|
|
|
evas_object_event_callback_del(sd->event, EVAS_CALLBACK_MOUSE_MOVE,
|
|
|
|
_smart_cb_mouse_move);
|
|
|
|
evas_object_event_callback_del(sd->event, EVAS_CALLBACK_MOUSE_IN,
|
|
|
|
_smart_cb_mouse_in);
|
|
|
|
evas_object_event_callback_del(sd->event, EVAS_CALLBACK_MOUSE_OUT,
|
|
|
|
_smart_cb_mouse_out);
|
|
|
|
evas_object_event_callback_del(sd->event, EVAS_CALLBACK_MOUSE_WHEEL,
|
|
|
|
_smart_cb_mouse_wheel);
|
|
|
|
|
|
|
|
evas_object_del(sd->event);
|
2016-02-02 14:34:54 -08:00
|
|
|
sd->event = NULL;
|
2015-06-02 14:23:56 -07:00
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
if (sd->sel.top) evas_object_del(sd->sel.top);
|
|
|
|
if (sd->sel.bottom) evas_object_del(sd->sel.bottom);
|
|
|
|
if (sd->sel.theme) evas_object_del(sd->sel.theme);
|
|
|
|
if (sd->anim) ecore_animator_del(sd->anim);
|
|
|
|
if (sd->delayed_size_timer) ecore_timer_del(sd->delayed_size_timer);
|
|
|
|
if (sd->link_do_timer) ecore_timer_del(sd->link_do_timer);
|
|
|
|
if (sd->mouse_move_job) ecore_job_del(sd->mouse_move_job);
|
|
|
|
if (sd->mouseover_delay) ecore_timer_del(sd->mouseover_delay);
|
2019-11-29 10:59:57 -08:00
|
|
|
eina_stringshare_del(sd->font.name);
|
2014-08-19 13:38:02 -07:00
|
|
|
if (sd->pty) termpty_free(sd->pty);
|
2019-11-29 10:59:57 -08:00
|
|
|
eina_stringshare_del(sd->link.string);
|
2014-08-19 13:38:02 -07: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);
|
|
|
|
EINA_LIST_FREE(sd->link.objs, o)
|
|
|
|
{
|
2020-04-16 14:43:21 -07:00
|
|
|
if (o == sd->link.down.dndobj)
|
|
|
|
sd->link.down.dndobj = NULL;
|
2014-08-19 13:38:02 -07:00
|
|
|
evas_object_del(o);
|
|
|
|
}
|
|
|
|
if (sd->link.down.dndobj) evas_object_del(sd->link.down.dndobj);
|
2017-12-17 06:36:51 -08:00
|
|
|
if (sd->sendfile.active)
|
|
|
|
{
|
|
|
|
if (sd->sendfile.file)
|
|
|
|
{
|
|
|
|
ecore_file_unlink(sd->sendfile.file);
|
|
|
|
eina_stringshare_del(sd->sendfile.file);
|
|
|
|
sd->sendfile.file = NULL;
|
|
|
|
}
|
|
|
|
if (sd->sendfile.f)
|
|
|
|
{
|
|
|
|
fclose(sd->sendfile.f);
|
|
|
|
sd->sendfile.f = NULL;
|
|
|
|
}
|
|
|
|
sd->sendfile.active = EINA_FALSE;
|
|
|
|
}
|
2019-11-29 10:59:57 -08:00
|
|
|
eina_stringshare_del(sd->sel_str);
|
2014-08-19 13:38:02 -07:00
|
|
|
if (sd->sel_reset_job) ecore_job_del(sd->sel_reset_job);
|
|
|
|
EINA_LIST_FREE(sd->cur_chids, chid) eina_stringshare_del(chid);
|
|
|
|
sd->sel_str = NULL;
|
|
|
|
sd->sel_reset_job = NULL;
|
|
|
|
sd->link.down.dndobj = NULL;
|
|
|
|
sd->cursor.obj = NULL;
|
|
|
|
sd->event = NULL;
|
|
|
|
sd->sel.top = NULL;
|
|
|
|
sd->sel.bottom = NULL;
|
|
|
|
sd->sel.theme = NULL;
|
|
|
|
sd->anim = NULL;
|
|
|
|
sd->delayed_size_timer = NULL;
|
|
|
|
sd->font.name = NULL;
|
|
|
|
sd->pty = NULL;
|
|
|
|
sd->win = NULL;
|
|
|
|
sd->glayer = NULL;
|
2012-06-30 17:24:30 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
_parent_sc.del(obj);
|
2021-03-18 04:21:38 -07:00
|
|
|
free(sd);
|
2013-02-21 05:23:48 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-08-19 13:38:02 -07:00
|
|
|
_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
|
2013-02-21 05:23:48 -08:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
Evas_Coord ow, oh;
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
|
2019-01-05 09:25:11 -08:00
|
|
|
/* Do not resize if same size */
|
|
|
|
if ((ow == w) && (oh == h))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
evas_object_smart_changed(obj);
|
|
|
|
if (!sd->delayed_size_timer)
|
|
|
|
sd->delayed_size_timer = ecore_timer_add(0.0, _smart_cb_delayed_size, obj);
|
|
|
|
else ecore_timer_reset(sd->delayed_size_timer);
|
|
|
|
evas_object_resize(sd->event, ow, oh);
|
2013-02-21 05:23:48 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-08-19 13:38:02 -07:00
|
|
|
_smart_calculate(Evas_Object *obj)
|
2013-02-21 05:23:48 -08:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
|
|
|
Evas_Coord ox, oy, ow, oh;
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
|
|
|
|
evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
|
|
|
|
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);
|
|
|
|
evas_object_move(sd->cursor.obj,
|
|
|
|
ox + (sd->cursor.x * sd->font.chw),
|
|
|
|
oy + (sd->cursor.y * sd->font.chh));
|
|
|
|
|
|
|
|
evas_object_move(sd->event, ox, oy);
|
|
|
|
evas_object_resize(sd->event, ow, oh);
|
2013-02-21 05:23:48 -08:00
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_smart_move(Evas_Object *obj,
|
|
|
|
Evas_Coord _x EINA_UNUSED,
|
|
|
|
Evas_Coord _y EINA_UNUSED)
|
2013-02-21 05:23:48 -08:00
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
2013-12-01 09:50:45 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
evas_object_smart_changed(obj);
|
2013-02-21 05:23:48 -08:00
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static void
|
|
|
|
_smart_init(void)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
static Evas_Smart_Class sc;
|
2014-01-22 03:31:37 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
evas_object_smart_clipped_smart_set(&_parent_sc);
|
|
|
|
sc = _parent_sc;
|
|
|
|
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);
|
|
|
|
}
|
2012-06-17 13:24:23 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static void
|
|
|
|
_smart_pty_change(void *data)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2012-07-01 20:47:02 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
// if scroll to bottom on updates
|
2021-08-09 14:20:55 -07:00
|
|
|
if (sd->jump_on_change) sd->scroll = 0;
|
2019-02-02 06:36:58 -08:00
|
|
|
termio_smart_update_queue(sd);
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
2014-03-01 08:59:01 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static void
|
|
|
|
_smart_pty_title(void *data)
|
|
|
|
{
|
|
|
|
Evas_Object *obj = data;
|
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
2014-01-22 03:31:37 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
if (!sd->win) return;
|
|
|
|
evas_object_smart_callback_call(obj, "title,change", NULL);
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static void
|
|
|
|
_smart_pty_icon(void *data)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Evas_Object *obj = data;
|
2012-06-12 06:08:09 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
2014-08-19 13:38:02 -07:00
|
|
|
|
2013-12-01 09:50:45 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2014-08-19 13:38:02 -07:00
|
|
|
if (!sd->win) return;
|
|
|
|
evas_object_smart_callback_call(obj, "icon,change", NULL);
|
2014-12-02 15:42:46 -08:00
|
|
|
// elm_win_icon_name_set(sd->win, sd->pty->prop.icon);
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static void
|
|
|
|
_smart_pty_cancel_sel(void *data)
|
2012-10-02 13:24:13 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Evas_Object *obj = data;
|
2012-10-02 13:24:13 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
2014-08-19 13:38:02 -07:00
|
|
|
|
2013-12-01 09:50:45 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2014-08-19 13:38:02 -07:00
|
|
|
if (sd->pty->selection.is_active)
|
|
|
|
{
|
2019-02-02 06:36:58 -08:00
|
|
|
termio_sel_set(sd, EINA_FALSE);
|
2014-08-19 13:38:02 -07:00
|
|
|
sd->pty->selection.makesel = EINA_FALSE;
|
2019-02-02 06:36:58 -08:00
|
|
|
termio_smart_update_queue(sd);
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
2012-10-02 13:24:13 -07:00
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static void
|
|
|
|
_smart_pty_exited(void *data)
|
2012-10-02 13:24:13 -07:00
|
|
|
{
|
2015-06-11 14:55:35 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
|
2016-02-02 14:15:50 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2016-02-02 14:34:54 -08:00
|
|
|
|
|
|
|
if (sd->event)
|
|
|
|
{
|
|
|
|
evas_object_event_callback_del(sd->event, EVAS_CALLBACK_MOUSE_DOWN,
|
|
|
|
_smart_cb_mouse_down);
|
|
|
|
evas_object_event_callback_del(sd->event, EVAS_CALLBACK_MOUSE_UP,
|
|
|
|
_smart_cb_mouse_up);
|
|
|
|
evas_object_event_callback_del(sd->event, EVAS_CALLBACK_MOUSE_MOVE,
|
|
|
|
_smart_cb_mouse_move);
|
|
|
|
evas_object_event_callback_del(sd->event, EVAS_CALLBACK_MOUSE_IN,
|
|
|
|
_smart_cb_mouse_in);
|
|
|
|
evas_object_event_callback_del(sd->event, EVAS_CALLBACK_MOUSE_OUT,
|
|
|
|
_smart_cb_mouse_out);
|
|
|
|
evas_object_event_callback_del(sd->event, EVAS_CALLBACK_MOUSE_WHEEL,
|
|
|
|
_smart_cb_mouse_wheel);
|
|
|
|
|
|
|
|
evas_object_del(sd->event);
|
|
|
|
sd->event = NULL;
|
|
|
|
}
|
|
|
|
|
2016-02-02 14:15:50 -08:00
|
|
|
term_close(sd->win, sd->self, EINA_TRUE);
|
2012-10-02 13:24:13 -07:00
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static void
|
|
|
|
_smart_pty_bell(void *data)
|
|
|
|
{
|
|
|
|
Termio *sd = evas_object_smart_data_get(data);
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
|
|
|
evas_object_smart_callback_call(data, "bell", NULL);
|
|
|
|
edje_object_signal_emit(sd->cursor.obj, "bell", "terminology");
|
|
|
|
if (sd->config->bell_rings)
|
|
|
|
edje_object_signal_emit(sd->cursor.obj, "bell,ring", "terminology");
|
|
|
|
}
|
|
|
|
|
2018-09-23 13:49:31 -07:00
|
|
|
static void
|
2018-10-13 09:10:54 -07:00
|
|
|
_handle_query_esc(Termio *sd)
|
2018-09-23 13:49:31 -07:00
|
|
|
{
|
2018-10-13 09:10:54 -07:00
|
|
|
Termpty *ty = sd->pty;
|
2018-09-23 13:49:31 -07:00
|
|
|
if (ty->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(ty, buf, strlen(buf));
|
|
|
|
}
|
|
|
|
else if (ty->cur_cmd[1] == 'j')
|
|
|
|
{
|
|
|
|
const char *chid = &(ty->cur_cmd[3]);
|
|
|
|
|
|
|
|
if (ty->cur_cmd[2])
|
|
|
|
{
|
|
|
|
if (ty->cur_cmd[2] == '+')
|
|
|
|
{
|
|
|
|
sd->cur_chids = eina_list_append
|
|
|
|
(sd->cur_chids, eina_stringshare_add(chid));
|
|
|
|
}
|
|
|
|
else if (ty->cur_cmd[2] == '-')
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
char *chid2;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(sd->cur_chids, l, chid2)
|
|
|
|
{
|
|
|
|
if (!(!strcmp(chid, chid2)))
|
|
|
|
{
|
|
|
|
sd->cur_chids =
|
|
|
|
eina_list_remove_list(sd->cur_chids, l);
|
|
|
|
eina_stringshare_del(chid2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EINA_LIST_FREE(sd->cur_chids, chid)
|
|
|
|
eina_stringshare_del(chid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static void
|
|
|
|
_smart_pty_command(void *data)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Evas_Object *obj = data;
|
2012-06-12 06:08:09 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
2015-08-23 11:57:49 -07:00
|
|
|
Config *config;
|
|
|
|
Termpty *ty;
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2015-08-23 11:57:49 -07:00
|
|
|
|
|
|
|
config = sd->config;
|
|
|
|
ty = sd->pty;
|
|
|
|
if (!ty->cur_cmd)
|
|
|
|
return;
|
|
|
|
if (ty->cur_cmd[0] == 'q')
|
|
|
|
{
|
2018-10-13 09:10:54 -07:00
|
|
|
_handle_query_esc(sd);
|
2015-08-23 11:57:49 -07:00
|
|
|
return;
|
|
|
|
}
|
2018-09-23 13:49:31 -07:00
|
|
|
|
2015-08-23 11:57:49 -07:00
|
|
|
if (!config->ty_escapes)
|
|
|
|
return;
|
2018-09-23 13:49:31 -07:00
|
|
|
|
2015-08-23 11:57:49 -07:00
|
|
|
if (ty->cur_cmd[0] == 'i')
|
|
|
|
{
|
|
|
|
if ((ty->cur_cmd[1] == 's') ||
|
|
|
|
(ty->cur_cmd[1] == 'c') ||
|
|
|
|
(ty->cur_cmd[1] == 'f') ||
|
|
|
|
(ty->cur_cmd[1] == 't') ||
|
|
|
|
(ty->cur_cmd[1] == 'j'))
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
const char *p, *p0, *p1, *path = NULL;
|
|
|
|
char *pp;
|
|
|
|
int ww = 0, hh = 0, repch;
|
|
|
|
Eina_List *strs = NULL;
|
2020-04-17 14:09:07 -07:00
|
|
|
char *link = NULL;
|
2014-08-19 13:38:02 -07:00
|
|
|
|
|
|
|
// exact size in CHAR CELLS - WW (decimal) width CELLS,
|
|
|
|
// HH (decimal) in CELLS.
|
|
|
|
//
|
|
|
|
// isCWW;HH;PATH
|
|
|
|
// OR
|
|
|
|
// isCWW;HH;LINK\nPATH
|
|
|
|
// OR specific to 'j' (edje)
|
|
|
|
// ijCWW;HH;PATH\nGROUP[commands]
|
|
|
|
// WHERE [commands] is an optional string set of:
|
|
|
|
// \nCMD\nP1[\nP2][\nP3][[\nCMD2\nP21[\nP22]]...
|
|
|
|
// CMD is the command, P1, P2, P3 etc. are parameters (P2 and
|
|
|
|
// on are optional depending on CMD)
|
2015-08-23 11:57:49 -07:00
|
|
|
repch = ty->cur_cmd[2];
|
2020-04-17 14:09:07 -07:00
|
|
|
if (!repch)
|
|
|
|
return;
|
2014-08-19 13:38:02 -07:00
|
|
|
|
2020-04-17 14:09:07 -07:00
|
|
|
for (p0 = p = &(ty->cur_cmd[3]); *p; p++)
|
|
|
|
{
|
|
|
|
if (*p == ';')
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
2020-04-17 14:09:07 -07:00
|
|
|
ww = strtol(p0, NULL, 10);
|
|
|
|
p++;
|
|
|
|
break;
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
2020-04-17 14:09:07 -07:00
|
|
|
}
|
|
|
|
for (p0 = p; *p; p++)
|
|
|
|
{
|
|
|
|
if (*p == ';')
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
2020-04-17 14:09:07 -07:00
|
|
|
hh = strtol(p0, NULL, 10);
|
|
|
|
p++;
|
|
|
|
break;
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
2020-04-17 14:09:07 -07:00
|
|
|
}
|
|
|
|
if (ty->cur_cmd[1] == 'j')
|
|
|
|
{
|
|
|
|
// parse from p until end of string - one newline
|
|
|
|
// per list item in strs
|
|
|
|
p0 = p1 = p;
|
|
|
|
for (;;)
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
2020-04-17 14:09:07 -07:00
|
|
|
// end of str param
|
|
|
|
if ((*p1 == '\n') || (*p1 == '\r') || (!*p1))
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
2020-04-17 14:09:07 -07:00
|
|
|
// if string is non-empty...
|
|
|
|
if ((p1 - p0) >= 1)
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
2020-04-17 14:09:07 -07:00
|
|
|
// allocate, fill and add to list
|
|
|
|
pp = malloc(p1 - p0 + 1);
|
|
|
|
if (pp)
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
2020-04-17 14:09:07 -07:00
|
|
|
strncpy(pp, p0, p1 - p0);
|
|
|
|
pp[p1 - p0] = 0;
|
|
|
|
strs = eina_list_append(strs, pp);
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
|
|
|
}
|
2020-04-17 14:09:07 -07:00
|
|
|
// end of string buffer
|
|
|
|
if (!*p1) break;
|
|
|
|
p1++; // skip \n or \r
|
|
|
|
p0 = p1;
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
2020-04-17 14:09:07 -07:00
|
|
|
else
|
|
|
|
p1++;
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
2020-04-17 14:09:07 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
path = p;
|
|
|
|
p = strchr(path, '\n');
|
|
|
|
if (p)
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
2020-04-17 14:09:07 -07:00
|
|
|
link = strdup(path);
|
|
|
|
path = p + 1;
|
|
|
|
if (isspace(path[0])) path++;
|
|
|
|
pp = strchr(link, '\n');
|
|
|
|
if (pp) *pp = 0;
|
|
|
|
pp = strchr(link, '\r');
|
|
|
|
if (pp) *pp = 0;
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
2020-04-17 14:09:07 -07:00
|
|
|
}
|
|
|
|
if ((ww < 512) && (hh < 512))
|
|
|
|
{
|
|
|
|
Termblock *blk = NULL;
|
2014-08-19 13:38:02 -07:00
|
|
|
|
2020-04-17 14:09:07 -07:00
|
|
|
if (strs)
|
|
|
|
{
|
|
|
|
const char *file, *group;
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
file = eina_list_nth(strs, 0);
|
|
|
|
group = eina_list_nth(strs, 1);
|
|
|
|
l = eina_list_nth_list(strs, 2);
|
|
|
|
blk = termpty_block_new(ty, ww, hh, file, group);
|
|
|
|
for (;l; l = l->next)
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
2020-04-17 14:09:07 -07:00
|
|
|
pp = l->data;
|
|
|
|
if (pp)
|
|
|
|
blk->cmds = eina_list_append(blk->cmds, pp);
|
|
|
|
l->data = NULL;
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
|
|
|
}
|
2020-04-17 14:09:07 -07:00
|
|
|
else
|
|
|
|
blk = termpty_block_new(ty, ww, hh, path, link);
|
|
|
|
if (blk)
|
|
|
|
{
|
|
|
|
if (ty->cur_cmd[1] == 's')
|
|
|
|
blk->scale_stretch = EINA_TRUE;
|
|
|
|
else if (ty->cur_cmd[1] == 'c')
|
|
|
|
blk->scale_center = EINA_TRUE;
|
|
|
|
else if (ty->cur_cmd[1] == 'f')
|
|
|
|
blk->scale_fill = EINA_TRUE;
|
|
|
|
else if (ty->cur_cmd[1] == 't')
|
|
|
|
blk->thumb = EINA_TRUE;
|
|
|
|
else if (ty->cur_cmd[1] == 'j')
|
|
|
|
blk->edje = EINA_TRUE;
|
|
|
|
termpty_block_insert(ty, repch, blk);
|
|
|
|
}
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
2020-04-17 14:09:07 -07:00
|
|
|
free(link);
|
|
|
|
EINA_LIST_FREE(strs, pp) free(pp);
|
2014-08-19 13:38:02 -07:00
|
|
|
return;
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
2015-08-23 11:57:49 -07:00
|
|
|
else if (ty->cur_cmd[1] == 'C')
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Termblock *blk = NULL;
|
|
|
|
const char *p, *p0, *p1;
|
|
|
|
char *pp;
|
|
|
|
Eina_List *strs = NULL;
|
2012-06-19 12:59:35 -07:00
|
|
|
|
2015-08-23 11:57:49 -07:00
|
|
|
p = &(ty->cur_cmd[2]);
|
2014-08-19 13:38:02 -07:00
|
|
|
// parse from p until end of string - one newline
|
|
|
|
// per list item in strs
|
|
|
|
p0 = p1 = p;
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
// end of str param
|
|
|
|
if ((*p1 == '\n') || (*p1 == '\r') || (!*p1))
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
// if string is non-empty...
|
|
|
|
if ((p1 - p0) >= 1)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
// allocate, fill and add to list
|
|
|
|
pp = malloc(p1 - p0 + 1);
|
|
|
|
if (pp)
|
|
|
|
{
|
|
|
|
strncpy(pp, p0, p1 - p0);
|
|
|
|
pp[p1 - p0] = 0;
|
|
|
|
strs = eina_list_append(strs, pp);
|
|
|
|
}
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
// end of string buffer
|
|
|
|
if (!*p1) break;
|
|
|
|
p1++; // skip \n or \r
|
|
|
|
p0 = p1;
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
else
|
|
|
|
p1++;
|
|
|
|
}
|
|
|
|
if (strs)
|
|
|
|
{
|
|
|
|
char *chid = strs->data;
|
2015-08-23 11:57:49 -07:00
|
|
|
blk = termpty_block_chid_get(ty, chid);
|
2014-08-19 13:38:02 -07:00
|
|
|
if (blk)
|
2012-06-24 03:01:53 -07:00
|
|
|
{
|
2015-08-23 11:57:49 -07:00
|
|
|
_block_edje_cmds(ty, blk, strs->next, EINA_FALSE);
|
2012-06-24 03:01:53 -07:00
|
|
|
}
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
EINA_LIST_FREE(strs, pp) free(pp);
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
2015-08-23 11:57:49 -07:00
|
|
|
else if (ty->cur_cmd[1] == 'b')
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2015-08-23 11:57:49 -07:00
|
|
|
ty->block.on = EINA_TRUE;
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
2015-08-23 11:57:49 -07:00
|
|
|
else if (ty->cur_cmd[1] == 'e')
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
2015-08-23 11:57:49 -07:00
|
|
|
ty->block.on = EINA_FALSE;
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
|
|
|
}
|
2017-12-17 06:36:51 -08:00
|
|
|
else if (ty->cur_cmd[0] == 'f') // file...
|
|
|
|
{
|
|
|
|
if (ty->cur_cmd[1] == 'r') // receive
|
|
|
|
{
|
|
|
|
sd->sendfile.progress = 0.0;
|
|
|
|
sd->sendfile.total = 0;
|
|
|
|
sd->sendfile.size = 0;
|
|
|
|
}
|
|
|
|
else if (ty->cur_cmd[1] == 's') // file size
|
|
|
|
{
|
|
|
|
sd->sendfile.total = 0;
|
|
|
|
sd->sendfile.size = atoll(&(ty->cur_cmd[2]));
|
|
|
|
}
|
|
|
|
else if (ty->cur_cmd[1] == 'd') // data packet
|
|
|
|
{
|
|
|
|
char *p = strchr(ty->cur_cmd, ' ');
|
|
|
|
Eina_Bool valid = EINA_TRUE;
|
|
|
|
|
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
Eina_Binbuf *bb = eina_binbuf_new();
|
|
|
|
|
|
|
|
if (bb)
|
|
|
|
{
|
2017-12-17 22:16:54 -08:00
|
|
|
unsigned char localbuf[128];
|
|
|
|
unsigned char localbufpos = 0;
|
2020-04-17 14:09:07 -07:00
|
|
|
int pksum = atoi(&(ty->cur_cmd[2]));
|
|
|
|
int sum;
|
2017-12-17 22:16:54 -08:00
|
|
|
|
|
|
|
eina_binbuf_expand(bb, 32 * 1024);
|
|
|
|
for (sum = 0, p++; *p; p++)
|
2017-12-17 06:36:51 -08:00
|
|
|
{
|
2017-12-17 22:16:54 -08:00
|
|
|
// high nibble
|
2020-04-17 14:09:07 -07:00
|
|
|
unsigned char v = (unsigned char)(*p);
|
2017-12-17 06:36:51 -08:00
|
|
|
sum += v;
|
2017-12-17 07:51:52 -08:00
|
|
|
v = ((v - '@') & 0xf) << 4;
|
2017-12-17 22:16:54 -08:00
|
|
|
// low nibble
|
2017-12-17 07:51:52 -08:00
|
|
|
p++;
|
|
|
|
sum += *p;
|
|
|
|
v |= ((*p - '@') & 0xf);
|
2017-12-17 22:16:54 -08:00
|
|
|
localbuf[localbufpos++] = v;
|
|
|
|
if (localbufpos >= sizeof(localbuf))
|
|
|
|
{
|
|
|
|
eina_binbuf_append_length(bb, localbuf, localbufpos);
|
|
|
|
localbufpos = 0;
|
|
|
|
}
|
2017-12-17 07:51:52 -08:00
|
|
|
if (!*p) valid = EINA_FALSE;
|
2017-12-17 06:36:51 -08:00
|
|
|
}
|
2017-12-17 22:16:54 -08:00
|
|
|
if (localbufpos > 0)
|
|
|
|
eina_binbuf_append_length(bb, localbuf, localbufpos);
|
|
|
|
|
2017-12-17 06:36:51 -08:00
|
|
|
if ((valid) && (sum == pksum) && (sd->sendfile.active))
|
|
|
|
{
|
|
|
|
// write "ok" (k) to term
|
|
|
|
size_t size = eina_binbuf_length_get(bb);
|
|
|
|
|
|
|
|
sd->sendfile.total += size;
|
|
|
|
if (sd->sendfile.size > 0.0)
|
|
|
|
{
|
|
|
|
sd->sendfile.progress =
|
|
|
|
(double)sd->sendfile.total /
|
|
|
|
(double)sd->sendfile.size;
|
|
|
|
evas_object_smart_callback_call
|
|
|
|
(obj, "send,progress", NULL);
|
|
|
|
}
|
|
|
|
fwrite(eina_binbuf_string_get(bb), size, 1,
|
|
|
|
sd->sendfile.f);
|
|
|
|
termpty_write(ty, "k\n", 2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// write "not valid" (n) to term
|
|
|
|
if (sd->sendfile.file)
|
|
|
|
{
|
|
|
|
ecore_file_unlink(sd->sendfile.file);
|
|
|
|
eina_stringshare_del(sd->sendfile.file);
|
|
|
|
sd->sendfile.file = NULL;
|
|
|
|
}
|
|
|
|
if (sd->sendfile.f)
|
|
|
|
{
|
|
|
|
fclose(sd->sendfile.f);
|
|
|
|
sd->sendfile.f = NULL;
|
|
|
|
}
|
|
|
|
sd->sendfile.active = EINA_FALSE;
|
|
|
|
termpty_write(ty, "n\n", 2);
|
|
|
|
evas_object_smart_callback_call
|
|
|
|
(obj, "send,end", NULL);
|
|
|
|
}
|
|
|
|
eina_binbuf_free(bb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ty->cur_cmd[1] == 'x') // exit data stream
|
|
|
|
{
|
|
|
|
if (sd->sendfile.active)
|
|
|
|
{
|
|
|
|
sd->sendfile.progress = 0.0;
|
|
|
|
sd->sendfile.size = 0;
|
2019-11-29 10:59:57 -08:00
|
|
|
eina_stringshare_del(sd->sendfile.file);
|
|
|
|
sd->sendfile.file = NULL;
|
2017-12-17 06:36:51 -08:00
|
|
|
if (sd->sendfile.f)
|
|
|
|
{
|
|
|
|
fclose(sd->sendfile.f);
|
|
|
|
sd->sendfile.f = NULL;
|
|
|
|
}
|
|
|
|
sd->sendfile.active = EINA_FALSE;
|
|
|
|
evas_object_smart_callback_call
|
|
|
|
(obj, "send,end", NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-08-23 11:57:49 -07:00
|
|
|
evas_object_smart_callback_call(obj, "command", (void *)ty->cur_cmd);
|
2012-07-13 02:12:01 -07:00
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_smart_cb_drag_enter(void *_data EINA_UNUSED, Evas_Object *_o EINA_UNUSED)
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
|
|
|
DBG("dnd enter");
|
2012-07-13 02:12:01 -07:00
|
|
|
}
|
2012-10-09 10:09:26 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_smart_cb_drag_leave(void *_data EINA_UNUSED, Evas_Object *_o EINA_UNUSED)
|
2013-06-22 17:07:27 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
DBG("dnd leave");
|
2013-06-22 17:07:27 -07:00
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static void
|
2016-10-05 13:00:22 -07:00
|
|
|
_smart_cb_drag_pos(void *_data EINA_UNUSED,
|
|
|
|
Evas_Object *_o EINA_UNUSED,
|
|
|
|
Evas_Coord x, Evas_Coord y, Elm_Xdnd_Action action)
|
2012-10-09 10:09:26 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
DBG("dnd at %i %i act:%i", x, y, action);
|
2012-10-09 10:09:26 -07:00
|
|
|
}
|
2012-10-09 10:32:29 -07:00
|
|
|
|
2021-09-13 13:49:48 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
static Eina_Bool
|
2016-10-05 13:00:22 -07:00
|
|
|
_smart_cb_drop(void *data,
|
|
|
|
Evas_Object *_o EINA_UNUSED,
|
|
|
|
Elm_Selection_Data *ev)
|
2012-10-09 10:32:29 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Evas_Object *obj = data;
|
2012-10-09 10:32:29 -07:00
|
|
|
Termio *sd = evas_object_smart_data_get(obj);
|
2021-09-13 13:49:48 -07:00
|
|
|
size_t len;
|
2014-01-26 03:20:38 -08:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EINA_TRUE);
|
2021-09-13 13:49:48 -07:00
|
|
|
if (ev->action != ELM_XDND_ACTION_COPY)
|
|
|
|
return EINA_TRUE;
|
|
|
|
|
|
|
|
if (strchr(ev->data, '\n'))
|
2014-01-26 03:20:38 -08:00
|
|
|
{
|
2021-09-13 13:49:48 -07:00
|
|
|
char *buf = alloca(strlen(ev->data) + 1);
|
|
|
|
const char *p = ev->data;
|
|
|
|
while (p)
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
2021-09-13 13:49:48 -07:00
|
|
|
char *new_line = strchr(p, '\n');
|
|
|
|
char *carriage_return = strchr(p, '\r');
|
|
|
|
if (new_line && carriage_return)
|
|
|
|
{
|
|
|
|
if (carriage_return < new_line)
|
|
|
|
new_line = carriage_return;
|
|
|
|
}
|
|
|
|
else if (!new_line)
|
|
|
|
new_line = carriage_return;
|
|
|
|
if (new_line)
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
2021-09-13 13:49:48 -07:00
|
|
|
strncpy(buf, p, new_line - p);
|
|
|
|
len = new_line - p;
|
|
|
|
buf[len] = '\0';
|
|
|
|
p = new_line;
|
|
|
|
while ((*p) && (isspace(*p)))
|
|
|
|
p++;
|
|
|
|
if (buf[0])
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
2021-09-13 13:49:48 -07:00
|
|
|
if (extn_is_media(buf, len))
|
|
|
|
evas_object_smart_callback_call(obj, "popup,queue", buf);
|
|
|
|
else
|
2014-08-19 13:38:02 -07:00
|
|
|
{
|
2021-09-13 13:49:48 -07:00
|
|
|
if (sd->pty->bracketed_paste)
|
|
|
|
termpty_write(sd->pty, "\x1b[200~", sizeof("\x1b[200~") - 1);
|
|
|
|
|
|
|
|
termpty_write(sd->pty, buf, len);
|
|
|
|
|
|
|
|
if (sd->pty->bracketed_paste)
|
|
|
|
termpty_write(sd->pty, "\x1b[201~", sizeof("\x1b[201~") - 1);
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
2021-09-13 13:49:48 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (*p)
|
|
|
|
{
|
|
|
|
len = strlen(p);
|
2022-04-30 06:53:47 -07:00
|
|
|
memcpy(buf, p, len);
|
2021-09-13 13:49:48 -07:00
|
|
|
buf[len] = '\0';
|
|
|
|
if (extn_is_media(buf, len))
|
|
|
|
evas_object_smart_callback_call(obj, "popup,queue", buf);
|
2014-08-19 13:38:02 -07:00
|
|
|
else
|
|
|
|
{
|
2021-09-13 13:49:48 -07:00
|
|
|
if (sd->pty->bracketed_paste)
|
|
|
|
termpty_write(sd->pty, "\x1b[200~", sizeof("\x1b[200~") - 1);
|
|
|
|
|
|
|
|
termpty_write(sd->pty, buf, len);
|
|
|
|
|
|
|
|
if (sd->pty->bracketed_paste)
|
|
|
|
termpty_write(sd->pty, "\x1b[201~", sizeof("\x1b[201~") - 1);
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
|
|
|
}
|
2021-09-13 13:49:48 -07:00
|
|
|
break;
|
2014-08-19 13:38:02 -07:00
|
|
|
}
|
|
|
|
}
|
2012-10-09 10:32:29 -07:00
|
|
|
}
|
2014-08-19 13:38:02 -07:00
|
|
|
else
|
2021-09-13 13:49:48 -07:00
|
|
|
{
|
|
|
|
len = strlen(ev->data);
|
|
|
|
if (extn_is_media(ev->data, len))
|
|
|
|
evas_object_smart_callback_call(obj, "popup", ev->data);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (sd->pty->bracketed_paste)
|
|
|
|
termpty_write(sd->pty, "\x1b[200~", sizeof("\x1b[200~") - 1);
|
|
|
|
|
|
|
|
termpty_write(sd->pty, ev->data, len);
|
|
|
|
|
|
|
|
if (sd->pty->bracketed_paste)
|
|
|
|
termpty_write(sd->pty, "\x1b[201~", sizeof("\x1b[201~") - 1);
|
|
|
|
}
|
|
|
|
}
|
2012-10-09 10:32:29 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2013-01-20 08:48:18 -08:00
|
|
|
|
2018-05-28 10:31:23 -07:00
|
|
|
// As we do not control the lifecycle of the Evas_Object *win,
|
|
|
|
// the death of the gesture layer can happen before the termio
|
|
|
|
// is destroyed. So by NULLing the structure field on gesture
|
|
|
|
// death, we make sure to not manipulate dead pointer
|
|
|
|
static void
|
|
|
|
_gesture_layer_death(void *data,
|
|
|
|
Evas *e EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Termio *sd = data;
|
|
|
|
|
|
|
|
sd->glayer = NULL;
|
|
|
|
}
|
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
/* }}} */
|
2013-01-20 08:48:18 -08:00
|
|
|
|
2013-03-17 07:52:13 -07:00
|
|
|
|
2013-04-21 14:07:14 -07:00
|
|
|
Evas_Object *
|
2016-02-02 14:15:50 -08:00
|
|
|
termio_add(Evas_Object *win, Config *config,
|
2014-08-19 13:38:02 -07:00
|
|
|
const char *cmd, Eina_Bool login_shell, const char *cd,
|
2017-08-28 12:36:48 -07:00
|
|
|
int w, int h, Term *term, const char *title)
|
2013-05-03 19:44:20 -07:00
|
|
|
{
|
2014-08-19 13:38:02 -07:00
|
|
|
Evas *e;
|
|
|
|
Evas_Object *obj, *g;
|
|
|
|
Termio *sd;
|
2018-12-24 02:10:01 -08:00
|
|
|
Ecore_Window window_id;
|
2013-11-01 11:43:30 -07:00
|
|
|
|
2016-02-02 14:15:50 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(win, NULL);
|
|
|
|
e = evas_object_evas_get(win);
|
2014-08-19 13:38:02 -07:00
|
|
|
if (!e) return NULL;
|
2014-07-28 19:00:51 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
if (!_smart) _smart_init();
|
|
|
|
obj = evas_object_smart_add(e, _smart);
|
|
|
|
sd = evas_object_smart_data_get(obj);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, obj);
|
2014-07-28 19:00:51 -07:00
|
|
|
|
2018-03-15 11:20:09 -07:00
|
|
|
sd->cursor.shape = config->cursor_shape;
|
2014-08-19 13:38:02 -07:00
|
|
|
termio_config_set(obj, config);
|
|
|
|
sd->term = term;
|
2016-02-02 14:15:50 -08:00
|
|
|
sd->win = win;
|
2014-03-30 09:22:22 -07:00
|
|
|
|
2016-02-02 14:15:50 -08:00
|
|
|
sd->glayer = g = elm_gesture_layer_add(win);
|
2018-05-28 10:35:17 -07:00
|
|
|
evas_object_event_callback_add(g, EVAS_CALLBACK_FREE,
|
|
|
|
_gesture_layer_death, sd);
|
2014-08-19 13:38:02 -07:00
|
|
|
elm_gesture_layer_attach(g, sd->event);
|
2014-05-03 13:16:27 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
elm_gesture_layer_cb_set(g, ELM_GESTURE_N_LONG_TAPS,
|
|
|
|
ELM_GESTURE_STATE_MOVE, _smart_cb_gest_long_move,
|
|
|
|
obj);
|
2014-05-03 13:16:27 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
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);
|
2014-05-12 14:11:49 -07:00
|
|
|
|
2014-08-19 13:38:02 -07:00
|
|
|
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);
|
2014-05-12 14:11:49 -07:00
|
|
|
|
2018-12-24 02:10:01 -08:00
|
|
|
window_id = elm_win_window_id_get(win);
|
2020-04-12 07:59:43 -07:00
|
|
|
sd->pty = termpty_new(cmd, login_shell, cd, w, h, config, title,
|
2019-06-23 10:00:10 -07:00
|
|
|
window_id);
|
2014-08-19 13:38:02 -07:00
|
|
|
if (!sd->pty)
|
|
|
|
{
|
|
|
|
ERR(_("Could not allocate termpty"));
|
|
|
|
evas_object_del(obj);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
sd->pty->obj = obj;
|
|
|
|
sd->pty->cb.change.func = _smart_pty_change;
|
|
|
|
sd->pty->cb.change.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;
|
|
|
|
sd->pty->cb.exited.func = _smart_pty_exited;
|
|
|
|
sd->pty->cb.exited.data = obj;
|
|
|
|
sd->pty->cb.bell.func = _smart_pty_bell;
|
|
|
|
sd->pty->cb.bell.data = obj;
|
|
|
|
sd->pty->cb.command.func = _smart_pty_command;
|
|
|
|
sd->pty->cb.command.data = obj;
|
2019-01-05 09:25:11 -08:00
|
|
|
_smart_size(obj, w, h, EINA_TRUE);
|
2014-08-19 13:38:02 -07:00
|
|
|
return obj;
|
2014-05-12 14:11:49 -07:00
|
|
|
}
|
2017-11-13 14:48:05 -08:00
|
|
|
|
|
|
|
void
|
2018-02-04 15:07:47 -08:00
|
|
|
termio_key_down(Evas_Object *termio,
|
2019-06-18 13:06:44 -07:00
|
|
|
Evas_Event_Key_Down *ev,
|
2018-02-12 13:03:02 -08:00
|
|
|
Eina_Bool action_handled)
|
2017-11-13 14:48:05 -08:00
|
|
|
{
|
2018-02-04 15:07:47 -08:00
|
|
|
Termio *sd = evas_object_smart_data_get(termio);
|
2017-11-13 14:48:05 -08:00
|
|
|
|
2018-02-04 15:07:47 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
2018-02-12 13:03:02 -08:00
|
|
|
if (sd->jump_on_keypress && !action_handled)
|
2018-02-04 15:07:47 -08:00
|
|
|
{
|
|
|
|
if (!key_is_modifier(ev->key))
|
|
|
|
{
|
|
|
|
sd->scroll = 0;
|
2019-02-02 06:36:58 -08:00
|
|
|
termio_smart_update_queue(sd);
|
2018-02-04 15:07:47 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (sd->config->flicker_on_key)
|
|
|
|
edje_object_signal_emit(sd->cursor.obj, "key,down", "terminology");
|
2019-06-18 13:06:44 -07:00
|
|
|
ev->event_flags = EVAS_EVENT_FLAG_ON_HOLD;
|
2017-11-13 14:48:05 -08:00
|
|
|
}
|