summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2012-07-04 14:44:43 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-07-04 14:44:43 +0000
commitf5bef8a0ed6beb23e81dec5be1a5ee240eb4687f (patch)
treebf406da3f12976b01481623514b9338f90a2930b /src/bin
parent2f57d0c7a9d3fb84faaabe8c551ae72fb9ca0c85 (diff)
incoming sexiness... links, file paths, email addresses found in text
on mousover. highlight with a subtley animated underline and on click.. do something sensible. the inline handler is the sexiest of all. try local file pahts for now (full paths). as they work best. remote urls for video files SHOULd work if they have http:// etc. before them - no adjusting of loose ones. u may want to look at the helpers config panel. internal handling of remote urls for media doesnt download currently. still needs to be done. anyway. enjoy! SVN revision: 73288
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/Makefile.am1
-rw-r--r--src/bin/config.c24
-rw-r--r--src/bin/config.h9
-rw-r--r--src/bin/main.c44
-rw-r--r--src/bin/media.c97
-rw-r--r--src/bin/media.h11
-rw-r--r--src/bin/options.c10
-rw-r--r--src/bin/options_helpers.c373
-rw-r--r--src/bin/options_helpers.h1
-rw-r--r--src/bin/termio.c387
-rw-r--r--src/bin/termio.h3
11 files changed, 920 insertions, 40 deletions
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index 8aedb06..2bb6c90 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -19,6 +19,7 @@ main.c main.h \
19media.c media.h \ 19media.c media.h \
20options.c options.h \ 20options.c options.h \
21options_behavior.c options_behavior.h \ 21options_behavior.c options_behavior.h \
22options_helpers.c options_helpers.h \
22options_font.c options_font.h \ 23options_font.c options_font.h \
23options_video.c options_video.h \ 24options_video.c options_video.h \
24options_theme.c options_theme.h \ 25options_theme.c options_theme.h \
diff --git a/src/bin/config.c b/src/bin/config.c
index 8a51b18..ef8dc5b 100644
--- a/src/bin/config.c
+++ b/src/bin/config.c
@@ -49,6 +49,22 @@ config_init(void)
49 EET_DATA_DESCRIPTOR_ADD_BASIC 49 EET_DATA_DESCRIPTOR_ADD_BASIC
50 (edd_base, Config, "font.bitmap", font.bitmap, EET_T_UCHAR); 50 (edd_base, Config, "font.bitmap", font.bitmap, EET_T_UCHAR);
51 EET_DATA_DESCRIPTOR_ADD_BASIC 51 EET_DATA_DESCRIPTOR_ADD_BASIC
52 (edd_base, Config, "helper.email", helper.email, EET_T_STRING);
53 EET_DATA_DESCRIPTOR_ADD_BASIC
54 (edd_base, Config, "helper.url.general", helper.url.general, EET_T_STRING);
55 EET_DATA_DESCRIPTOR_ADD_BASIC
56 (edd_base, Config, "helper.url.video", helper.url.video, EET_T_STRING);
57 EET_DATA_DESCRIPTOR_ADD_BASIC
58 (edd_base, Config, "helper.url.image", helper.url.image, EET_T_STRING);
59 EET_DATA_DESCRIPTOR_ADD_BASIC
60 (edd_base, Config, "helper.local.general", helper.local.general, EET_T_STRING);
61 EET_DATA_DESCRIPTOR_ADD_BASIC
62 (edd_base, Config, "helper.local.video", helper.local.video, EET_T_STRING);
63 EET_DATA_DESCRIPTOR_ADD_BASIC
64 (edd_base, Config, "helper.local.image", helper.local.image, EET_T_STRING);
65 EET_DATA_DESCRIPTOR_ADD_BASIC
66 (edd_base, Config, "helper.inline_please", helper.inline_please, EET_T_UCHAR);
67 EET_DATA_DESCRIPTOR_ADD_BASIC
52 (edd_base, Config, "theme", theme, EET_T_STRING); 68 (edd_base, Config, "theme", theme, EET_T_STRING);
53 EET_DATA_DESCRIPTOR_ADD_BASIC 69 EET_DATA_DESCRIPTOR_ADD_BASIC
54 (edd_base, Config, "background", background, EET_T_STRING); 70 (edd_base, Config, "background", background, EET_T_STRING);
@@ -192,6 +208,14 @@ config_load(const char *key)
192 config->font.bitmap = EINA_TRUE; 208 config->font.bitmap = EINA_TRUE;
193 config->font.name = eina_stringshare_add("nexus.pcf"); 209 config->font.name = eina_stringshare_add("nexus.pcf");
194 config->font.size = 10; 210 config->font.size = 10;
211 config->helper.email = eina_stringshare_add("xdg-email");;
212 config->helper.url.general = eina_stringshare_add("xdg-open");
213 config->helper.url.video = eina_stringshare_add("xdg-open");
214 config->helper.url.image = eina_stringshare_add("xdg-open");
215 config->helper.local.general = eina_stringshare_add("xdg-open");
216 config->helper.local.video = eina_stringshare_add("xdg-open");
217 config->helper.local.image = eina_stringshare_add("xdg-open");
218 config->helper.inline_please = EINA_TRUE;
195 config->scrollback = 2000; 219 config->scrollback = 2000;
196 config->theme = eina_stringshare_add("default.edj"); 220 config->theme = eina_stringshare_add("default.edj");
197 config->background = NULL; 221 config->background = NULL;
diff --git a/src/bin/config.h b/src/bin/config.h
index e54f1f4..9bb2068 100644
--- a/src/bin/config.h
+++ b/src/bin/config.h
@@ -12,6 +12,15 @@ struct _Config
12 int size; 12 int size;
13 unsigned char bitmap; 13 unsigned char bitmap;
14 } font; 14 } font;
15 struct {
16 const char *email;
17 struct {
18 const char *general;
19 const char *video;
20 const char *image;
21 } url, local;
22 Eina_Bool inline_please;
23 } helper;
15 const char *theme; 24 const char *theme;
16 const char *background; 25 const char *background;
17 const char *wordsep; 26 const char *wordsep;
diff --git a/src/bin/main.c b/src/bin/main.c
index c7ce5db..92a79c9 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -13,6 +13,7 @@
13int _log_domain = -1; 13int _log_domain = -1;
14 14
15static Evas_Object *win = NULL, *bg = NULL, *term = NULL, *media = NULL; 15static Evas_Object *win = NULL, *bg = NULL, *term = NULL, *media = NULL;
16static Evas_Object *popmedia = NULL;
16static Evas_Object *conform = NULL; 17static Evas_Object *conform = NULL;
17static Ecore_Timer *flush_timer = NULL; 18static Ecore_Timer *flush_timer = NULL;
18static Eina_Bool focused = EINA_FALSE; 19static Eina_Bool focused = EINA_FALSE;
@@ -94,6 +95,43 @@ _cb_bell(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSE
94 } 95 }
95} 96}
96 97
98static void
99_cb_popmedia_done(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *src __UNUSED__)
100{
101 if (popmedia)
102 {
103 evas_object_del(popmedia);
104 popmedia = NULL;
105 termio_mouseover_suspend_pushpop(term, -1);
106 }
107}
108
109static void
110_cb_popup(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
111{
112 Evas_Object *o;
113 Config *config = termio_config_get(term);
114 const char *src;
115 int type = 0;
116
117 if (!config) return;
118 src = termio_link_get(term);
119 if (!src) return;
120 if (popmedia) evas_object_del(popmedia);
121 if (!popmedia) termio_mouseover_suspend_pushpop(term, 1);
122 popmedia = o = media_add(win, src, config, MEDIA_POP, &type);
123 edje_object_part_swallow(bg, "terminology.popmedia", o);
124 evas_object_show(o);
125 if (type == TYPE_IMG)
126 edje_object_signal_emit(bg, "popmedia,image", "terminology");
127 else if (type == TYPE_SCALE)
128 edje_object_signal_emit(bg, "popmedia,scale", "terminology");
129 else if (type == TYPE_EDJE)
130 edje_object_signal_emit(bg, "popmedia,edje", "terminology");
131 else if (type == TYPE_MOV)
132 edje_object_signal_emit(bg, "popmedia,movie", "terminology");
133}
134
97void 135void
98main_trans_update(const Config *config) 136main_trans_update(const Config *config)
99{ 137{
@@ -120,6 +158,7 @@ main_media_update(const Config *config)
120 if (media) evas_object_del(media); 158 if (media) evas_object_del(media);
121 o = media = media_add(win, config->background, config, MEDIA_BG, &type); 159 o = media = media_add(win, config->background, config, MEDIA_BG, &type);
122 edje_object_part_swallow(bg, "terminology.background", o); 160 edje_object_part_swallow(bg, "terminology.background", o);
161 evas_object_show(o);
123 if (type == TYPE_IMG) 162 if (type == TYPE_IMG)
124 edje_object_signal_emit(bg, "media,image", "terminology"); 163 edje_object_signal_emit(bg, "media,image", "terminology");
125 else if (type == TYPE_SCALE) 164 else if (type == TYPE_SCALE)
@@ -128,7 +167,6 @@ main_media_update(const Config *config)
128 edje_object_signal_emit(bg, "media,edje", "terminology"); 167 edje_object_signal_emit(bg, "media,edje", "terminology");
129 else if (type == TYPE_MOV) 168 else if (type == TYPE_MOV)
130 edje_object_signal_emit(bg, "media,movie", "terminology"); 169 edje_object_signal_emit(bg, "media,movie", "terminology");
131 evas_object_show(o);
132 } 170 }
133 else 171 else
134 { 172 {
@@ -378,6 +416,9 @@ elm_main(int argc, char **argv)
378 theme_auto_reload_enable(o); 416 theme_auto_reload_enable(o);
379 elm_object_content_set(conform, o); 417 elm_object_content_set(conform, o);
380 evas_object_show(o); 418 evas_object_show(o);
419
420 edje_object_signal_callback_add(o, "popmedia,done", "terminology",
421 _cb_popmedia_done, NULL);
381 422
382 if (pos_set) 423 if (pos_set)
383 { 424 {
@@ -399,6 +440,7 @@ elm_main(int argc, char **argv)
399 evas_object_smart_callback_add(o, "change", _cb_change, NULL); 440 evas_object_smart_callback_add(o, "change", _cb_change, NULL);
400 evas_object_smart_callback_add(o, "exited", _cb_exited, NULL); 441 evas_object_smart_callback_add(o, "exited", _cb_exited, NULL);
401 evas_object_smart_callback_add(o, "bell", _cb_bell, NULL); 442 evas_object_smart_callback_add(o, "bell", _cb_bell, NULL);
443 evas_object_smart_callback_add(o, "popup", _cb_popup, NULL);
402 evas_object_show(o); 444 evas_object_show(o);
403 445
404 main_trans_update(config); 446 main_trans_update(config);
diff --git a/src/bin/media.c b/src/bin/media.c
index d9e8750..30277dd 100644
--- a/src/bin/media.c
+++ b/src/bin/media.c
@@ -143,13 +143,32 @@ _type_img_calc(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_
143 { 143 {
144 int iw, ih; 144 int iw, ih;
145 145
146 iw = w; 146 if (sd->mode == MEDIA_BG)
147 ih = (sd->ih * w) / sd->iw;
148 if (ih < h)
149 { 147 {
150 ih = h; 148 iw = w;
151 iw = (sd->iw * h) / sd->ih; 149 ih = (sd->ih * w) / sd->iw;
152 if (iw < w) iw = w; 150 if (ih < h)
151 {
152 ih = h;
153 iw = (sd->iw * h) / sd->ih;
154 if (iw < w) iw = w;
155 }
156 }
157 else if (sd->mode == MEDIA_POP)
158 {
159 iw = w;
160 ih = (sd->ih * w) / sd->iw;
161 if (ih > h)
162 {
163 ih = h;
164 iw = (sd->iw * h) / sd->ih;
165 if (iw > w) iw = w;
166 }
167 if ((iw > sd->iw) || (ih > sd->ih))
168 {
169 iw = sd->iw;
170 ih = sd->ih;
171 }
153 } 172 }
154 x += ((w - iw) / 2); 173 x += ((w - iw) / 2);
155 y += ((h - ih) / 2); 174 y += ((h - ih) / 2);
@@ -208,13 +227,27 @@ _type_scale_calc(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Eva
208 { 227 {
209 int iw, ih; 228 int iw, ih;
210 229
211 iw = w; 230 if (sd->mode == MEDIA_BG)
212 ih = (sd->ih * w) / sd->iw; 231 {
213 if (ih < h) 232 iw = w;
233 ih = (sd->ih * w) / sd->iw;
234 if (ih < h)
235 {
236 ih = h;
237 iw = (sd->iw * h) / sd->ih;
238 if (iw < w) iw = w;
239 }
240 }
241 else if (sd->mode == MEDIA_POP)
214 { 242 {
215 ih = h; 243 iw = w;
216 iw = (sd->iw * h) / sd->ih; 244 ih = (sd->ih * w) / sd->iw;
217 if (iw < w) iw = w; 245 if (ih > h)
246 {
247 ih = h;
248 iw = (sd->iw * h) / sd->ih;
249 if (iw > w) iw = w;
250 }
218 } 251 }
219 x += ((w - iw) / 2); 252 x += ((w - iw) / 2);
220 y += ((h - ih) / 2); 253 y += ((h - ih) / 2);
@@ -502,14 +535,28 @@ _type_mov_calc(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_
502 ratio = emotion_object_ratio_get(sd->o_img); 535 ratio = emotion_object_ratio_get(sd->o_img);
503 if (ratio > 0.0) sd->iw = (sd->ih * ratio) + 0.5; 536 if (ratio > 0.0) sd->iw = (sd->ih * ratio) + 0.5;
504 else ratio = (double)sd->iw / (double)sd->ih; 537 else ratio = (double)sd->iw / (double)sd->ih;
505 538
506 iw = w; 539 if (sd->mode == MEDIA_BG)
507 ih = w / ratio;
508 if (ih < h)
509 { 540 {
510 ih = h; 541 iw = w;
511 iw = h * ratio; 542 ih = w / ratio;
512 if (iw < w) iw = w; 543 if (ih < h)
544 {
545 ih = h;
546 iw = h * ratio;
547 if (iw < w) iw = w;
548 }
549 }
550 else if (sd->mode == MEDIA_POP)
551 {
552 iw = w;
553 ih = w / ratio;
554 if (ih > h)
555 {
556 ih = h;
557 iw = h * ratio;
558 if (iw > w) iw = w;
559 }
513 } 560 }
514 x += ((w - iw) / 2); 561 x += ((w - iw) / 2);
515 y += ((h - ih) / 2); 562 y += ((h - ih) / 2);
@@ -706,3 +753,15 @@ media_volume_set(Evas_Object *obj, double vol)
706 emotion_object_audio_volume_set(sd->o_img, vol); 753 emotion_object_audio_volume_set(sd->o_img, vol);
707 edje_object_part_drag_value_set(sd->o_ctrl, "terminology.voldrag", vol, vol); 754 edje_object_part_drag_value_set(sd->o_ctrl, "terminology.voldrag", vol, vol);
708} 755}
756
757int
758media_src_type_get(const char *src)
759{
760 int type = TYPE_UNKNOWN;
761
762 if (_is_fmt(src, extn_img)) type = TYPE_IMG;
763 else if (_is_fmt(src, extn_scale)) type = TYPE_SCALE;
764 else if (_is_fmt(src, extn_edj)) type = TYPE_EDJE;
765 else if (_is_fmt(src, extn_mov)) type = TYPE_MOV;
766 return type;
767}
diff --git a/src/bin/media.h b/src/bin/media.h
index 1aa8779..8d99e93 100644
--- a/src/bin/media.h
+++ b/src/bin/media.h
@@ -2,11 +2,13 @@
2#define _MEDIA_H__ 1 2#define _MEDIA_H__ 1
3 3
4#define MEDIA_BG 0 4#define MEDIA_BG 0
5#define MEDIA_POP 1
5 6
6#define TYPE_IMG 0 7#define TYPE_UNKNOWN -1
7#define TYPE_SCALE 1 8#define TYPE_IMG 0
8#define TYPE_EDJE 2 9#define TYPE_SCALE 1
9#define TYPE_MOV 3 10#define TYPE_EDJE 2
11#define TYPE_MOV 3
10 12
11#include "config.h" 13#include "config.h"
12 14
@@ -16,5 +18,6 @@ void media_play_set(Evas_Object *obj, Eina_Bool play);
16void media_position_set(Evas_Object *obj, double pos); 18void media_position_set(Evas_Object *obj, double pos);
17void media_volume_set(Evas_Object *obj, double vol); 19void media_volume_set(Evas_Object *obj, double vol);
18void media_stop(Evas_Object *obj); 20void media_stop(Evas_Object *obj);
21int media_src_type_get(const char *src);
19 22
20#endif 23#endif
diff --git a/src/bin/options.c b/src/bin/options.c
index 6733266..c58bdec 100644
--- a/src/bin/options.c
+++ b/src/bin/options.c
@@ -3,6 +3,7 @@
3#include <Elementary.h> 3#include <Elementary.h>
4#include "options.h" 4#include "options.h"
5#include "options_font.h" 5#include "options_font.h"
6#include "options_helpers.h"
6#include "options_behavior.h" 7#include "options_behavior.h"
7#include "options_video.h" 8#include "options_video.h"
8#include "options_theme.h" 9#include "options_theme.h"
@@ -56,6 +57,13 @@ _cb_op_behavior(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
56} 57}
57 58
58static void 59static void
60_cb_op_helpers(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
61{
62 elm_box_clear(op_opbox);
63 options_helpers(op_opbox, data);
64}
65
66static void
59_cb_op_tmp_chg(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__) 67_cb_op_tmp_chg(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
60{ 68{
61 Config *config = data; 69 Config *config = data;
@@ -136,6 +144,8 @@ options_toggle(Evas_Object *win, Evas_Object *bg, Evas_Object *term)
136 "Video", _cb_op_video, term); 144 "Video", _cb_op_video, term);
137 elm_toolbar_item_append(o, "system-run", 145 elm_toolbar_item_append(o, "system-run",
138 "Behavior", _cb_op_behavior, term); 146 "Behavior", _cb_op_behavior, term);
147 elm_toolbar_item_append(o, "document-open",
148 "Helpers", _cb_op_helpers, term);
139 149
140 elm_box_pack_end(op_tbox, o); 150 elm_box_pack_end(op_tbox, o);
141 evas_object_show(o); 151 evas_object_show(o);
diff --git a/src/bin/options_helpers.c b/src/bin/options_helpers.c
new file mode 100644
index 0000000..7f300f5
--- /dev/null
+++ b/src/bin/options_helpers.c
@@ -0,0 +1,373 @@
1#include "private.h"
2
3#include <Elementary.h>
4#include "config.h"
5#include "termio.h"
6#include "options.h"
7#include "options_helpers.h"
8#include "main.h"
9
10static void
11_cb_op_helper_inline_chg(void *data, Evas_Object *obj, void *event __UNUSED__)
12{
13 Evas_Object *term = data;
14 Config *config = termio_config_get(term);
15 config->helper.inline_please = elm_check_state_get(obj);
16 config_save(config, NULL);
17}
18
19static void
20_cb_op_helper_email_chg(void *data, Evas_Object *obj, void *event __UNUSED__)
21{
22 Evas_Object *term = data;
23 Config *config = termio_config_get(term);
24 char *txt;
25
26 if (config->helper.email)
27 {
28 eina_stringshare_del(config->helper.email);
29 config->helper.email = NULL;
30 }
31 txt = elm_entry_markup_to_utf8(elm_object_text_get(obj));
32 if (txt)
33 {
34 config->helper.email = eina_stringshare_add(txt);
35 free(txt);
36 }
37 config_save(config, NULL);
38}
39
40static void
41_cb_op_helper_url_image_chg(void *data, Evas_Object *obj, void *event __UNUSED__)
42{
43 Evas_Object *term = data;
44 Config *config = termio_config_get(term);
45 char *txt;
46
47 if (config->helper.url.image)
48 {
49 eina_stringshare_del(config->helper.url.image);
50 config->helper.email = NULL;
51 }
52 txt = elm_entry_markup_to_utf8(elm_object_text_get(obj));
53 if (txt)
54 {
55 config->helper.url.image = eina_stringshare_add(txt);
56 free(txt);
57 }
58 config_save(config, NULL);
59}
60
61static void
62_cb_op_helper_url_video_chg(void *data, Evas_Object *obj, void *event __UNUSED__)
63{
64 Evas_Object *term = data;
65 Config *config = termio_config_get(term);
66 char *txt;
67
68 if (config->helper.url.video)
69 {
70 eina_stringshare_del(config->helper.url.video);
71 config->helper.email = NULL;
72 }
73 txt = elm_entry_markup_to_utf8(elm_object_text_get(obj));
74 if (txt)
75 {
76 config->helper.url.video = eina_stringshare_add(txt);
77 free(txt);
78 }
79 config_save(config, NULL);
80}
81
82static void
83_cb_op_helper_url_general_chg(void *data, Evas_Object *obj, void *event __UNUSED__)
84{
85 Evas_Object *term = data;
86 Config *config = termio_config_get(term);
87 char *txt;
88
89 if (config->helper.url.general)
90 {
91 eina_stringshare_del(config->helper.url.general);
92 config->helper.email = NULL;
93 }
94 txt = elm_entry_markup_to_utf8(elm_object_text_get(obj));
95 if (txt)
96 {
97 config->helper.url.general = eina_stringshare_add(txt);
98 free(txt);
99 }
100 config_save(config, NULL);
101}
102
103static void
104_cb_op_helper_local_image_chg(void *data, Evas_Object *obj, void *event __UNUSED__)
105{
106 Evas_Object *term = data;
107 Config *config = termio_config_get(term);
108 char *txt;
109
110 if (config->helper.local.image)
111 {
112 eina_stringshare_del(config->helper.local.image);
113 config->helper.email = NULL;
114 }
115 txt = elm_entry_markup_to_utf8(elm_object_text_get(obj));
116 if (txt)
117 {
118 config->helper.local.image = eina_stringshare_add(txt);
119 free(txt);
120 }
121 config_save(config, NULL);
122}
123
124static void
125_cb_op_helper_local_video_chg(void *data, Evas_Object *obj, void *event __UNUSED__)
126{
127 Evas_Object *term = data;
128 Config *config = termio_config_get(term);
129 char *txt;
130
131 if (config->helper.local.video)
132 {
133 eina_stringshare_del(config->helper.local.video);
134 config->helper.email = NULL;
135 }
136 txt = elm_entry_markup_to_utf8(elm_object_text_get(obj));
137 if (txt)
138 {
139 config->helper.local.video = eina_stringshare_add(txt);
140 free(txt);
141 }
142 config_save(config, NULL);
143}
144
145static void
146_cb_op_helper_local_general_chg(void *data, Evas_Object *obj, void *event __UNUSED__)
147{
148 Evas_Object *term = data;
149 Config *config = termio_config_get(term);
150 char *txt;
151
152 if (config->helper.local.general)
153 {
154 eina_stringshare_del(config->helper.local.general);
155 config->helper.email = NULL;
156 }
157 txt = elm_entry_markup_to_utf8(elm_object_text_get(obj));
158 if (txt)
159 {
160 config->helper.local.general = eina_stringshare_add(txt);
161 free(txt);
162 }
163 config_save(config, NULL);
164}
165
166void
167options_helpers(Evas_Object *opbox, Evas_Object *term)
168{
169 Config *config = termio_config_get(term);
170 Evas_Object *o, *bx, *sc;
171 char *txt;
172
173 o = elm_check_add(opbox);
174 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
175 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
176 elm_object_text_set(o, "Inline if possible");
177 elm_check_state_set(o, config->helper.inline_please);
178 elm_box_pack_end(opbox, o);
179 evas_object_show(o);
180 evas_object_smart_callback_add(o, "changed",
181 _cb_op_helper_inline_chg, term);
182
183 o = elm_separator_add(opbox);
184 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
185 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
186 elm_separator_horizontal_set(o, EINA_TRUE);
187 elm_box_pack_end(opbox, o);
188 evas_object_show(o);
189
190 sc = o = elm_scroller_add(opbox);
191 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
192 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
193 elm_box_pack_end(opbox, o);
194 evas_object_show(o);
195
196 bx = o = elm_box_add(opbox);
197 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
198 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0);
199 elm_object_content_set(sc, o);
200 evas_object_show(o);
201
202 o = elm_label_add(bx);
203 evas_object_size_hint_weight_set(o, 0.0, 0.0);
204 evas_object_size_hint_align_set(o, 0.0, 0.5);
205 elm_object_text_set(o, "E-mail:");
206 elm_box_pack_end(bx, o);
207 evas_object_show(o);
208
209 o = elm_entry_add(bx);
210 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
211 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
212 elm_entry_single_line_set(o, EINA_TRUE);
213 elm_entry_scrollable_set(o, EINA_TRUE);
214 elm_entry_scrollbar_policy_set(o, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
215 txt = elm_entry_utf8_to_markup(config->helper.email);
216 if (txt)
217 {
218 elm_object_text_set(o, txt);
219 free(txt);
220 }
221 elm_box_pack_end(bx, o);
222 evas_object_show(o);
223 evas_object_smart_callback_add(o, "changed",
224 _cb_op_helper_email_chg, term);
225
226 o = elm_label_add(bx);
227 evas_object_size_hint_weight_set(o, 0.0, 0.0);
228 evas_object_size_hint_align_set(o, 0.0, 0.5);
229 elm_object_text_set(o, "URL (Images):");
230 elm_box_pack_end(bx, o);
231 evas_object_show(o);
232
233 o = elm_entry_add(bx);
234 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
235 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
236 elm_entry_single_line_set(o, EINA_TRUE);
237 elm_entry_scrollable_set(o, EINA_TRUE);
238 elm_entry_scrollbar_policy_set(o, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
239 txt = elm_entry_utf8_to_markup(config->helper.url.image);
240 if (txt)
241 {
242 elm_object_text_set(o, txt);
243 free(txt);
244 }
245 elm_box_pack_end(bx, o);
246 evas_object_show(o);
247 evas_object_smart_callback_add(o, "changed",
248 _cb_op_helper_url_image_chg, term);
249
250 o = elm_label_add(bx);
251 evas_object_size_hint_weight_set(o, 0.0, 0.0);
252 evas_object_size_hint_align_set(o, 0.0, 0.5);
253 elm_object_text_set(o, "URL (Video):");
254 elm_box_pack_end(bx, o);
255 evas_object_show(o);
256
257 o = elm_entry_add(bx);
258 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
259 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
260 elm_entry_single_line_set(o, EINA_TRUE);
261 elm_entry_scrollable_set(o, EINA_TRUE);
262 elm_entry_scrollbar_policy_set(o, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
263 txt = elm_entry_utf8_to_markup(config->helper.url.video);
264 if (txt)
265 {
266 elm_object_text_set(o, txt);
267 free(txt);
268 }
269 elm_box_pack_end(bx, o);
270 evas_object_show(o);
271 evas_object_smart_callback_add(o, "changed",
272 _cb_op_helper_url_video_chg, term);
273
274 o = elm_label_add(bx);
275 evas_object_size_hint_weight_set(o, 0.0, 0.0);
276 evas_object_size_hint_align_set(o, 0.0, 0.5);
277 elm_object_text_set(o, "URL (All):");
278 elm_box_pack_end(bx, o);
279 evas_object_show(o);
280
281 o = elm_entry_add(bx);
282 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
283 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
284 elm_entry_single_line_set(o, EINA_TRUE);
285 elm_entry_scrollable_set(o, EINA_TRUE);
286 elm_entry_scrollbar_policy_set(o, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
287 txt = elm_entry_utf8_to_markup(config->helper.url.general);
288 if (txt)
289 {
290 elm_object_text_set(o, txt);
291 free(txt);
292 }
293 elm_box_pack_end(bx, o);
294 evas_object_show(o);
295 evas_object_smart_callback_add(o, "changed",
296 _cb_op_helper_url_general_chg, term);
297
298 o = elm_label_add(bx);
299 evas_object_size_hint_weight_set(o, 0.0, 0.0);
300 evas_object_size_hint_align_set(o, 0.0, 0.5);
301 elm_object_text_set(o, "Local (Images):");
302 elm_box_pack_end(bx, o);
303 evas_object_show(o);
304
305 o = elm_entry_add(bx);
306 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
307 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
308 elm_entry_single_line_set(o, EINA_TRUE);
309 elm_entry_scrollable_set(o, EINA_TRUE);
310 elm_entry_scrollbar_policy_set(o, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
311 txt = elm_entry_utf8_to_markup(config->helper.local.image);
312 if (txt)
313 {
314 elm_object_text_set(o, txt);
315 free(txt);
316 }
317 elm_box_pack_end(bx, o);
318 evas_object_show(o);
319 evas_object_smart_callback_add(o, "changed",
320 _cb_op_helper_local_image_chg, term);
321
322 o = elm_label_add(bx);
323 evas_object_size_hint_weight_set(o, 0.0, 0.0);
324 evas_object_size_hint_align_set(o, 0.0, 0.5);
325 elm_object_text_set(o, "Local (Video):");
326 elm_box_pack_end(bx, o);
327 evas_object_show(o);
328
329 o = elm_entry_add(bx);
330 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
331 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
332 elm_entry_single_line_set(o, EINA_TRUE);
333 elm_entry_scrollable_set(o, EINA_TRUE);
334 elm_entry_scrollbar_policy_set(o, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
335 txt = elm_entry_utf8_to_markup(config->helper.local.video);
336 if (txt)
337 {
338 elm_object_text_set(o, txt);
339 free(txt);
340 }
341 elm_box_pack_end(bx, o);
342 evas_object_show(o);
343 evas_object_smart_callback_add(o, "changed",
344 _cb_op_helper_local_video_chg, term);
345
346 o = elm_label_add(bx);
347 evas_object_size_hint_weight_set(o, 0.0, 0.0);
348 evas_object_size_hint_align_set(o, 0.0, 0.5);
349 elm_object_text_set(o, "Local (All):");
350 elm_box_pack_end(bx, o);
351 evas_object_show(o);
352
353 o = elm_entry_add(bx);
354 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
355 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
356 elm_entry_single_line_set(o, EINA_TRUE);
357 elm_entry_scrollable_set(o, EINA_TRUE);
358 elm_entry_scrollbar_policy_set(o, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
359 txt = elm_entry_utf8_to_markup(config->helper.local.general);
360 if (txt)
361 {
362 elm_object_text_set(o, txt);
363 free(txt);
364 }
365 elm_box_pack_end(bx, o);
366 evas_object_show(o);
367 evas_object_smart_callback_add(o, "changed",
368 _cb_op_helper_local_general_chg, term);
369
370 evas_object_size_hint_weight_set(opbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
371 evas_object_size_hint_align_set(opbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
372 evas_object_show(o);
373}
diff --git a/src/bin/options_helpers.h b/src/bin/options_helpers.h
new file mode 100644
index 0000000..da422e4
--- /dev/null
+++ b/src/bin/options_helpers.h
@@ -0,0 +1 @@
void options_helpers(Evas_Object *opbox, Evas_Object *term);
diff --git a/src/bin/termio.c b/src/bin/termio.c
index 3813b69..9bf7437 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -10,6 +10,7 @@
10#include "keyin.h" 10#include "keyin.h"
11#include "config.h" 11#include "config.h"
12#include "utils.h" 12#include "utils.h"
13#include "media.h"
13 14
14typedef struct _Termio Termio; 15typedef struct _Termio Termio;
15 16
@@ -43,6 +44,12 @@ struct _Termio
43 } sel1, sel2; 44 } sel1, sel2;
44 Eina_Bool sel : 1; 45 Eina_Bool sel : 1;
45 } backup; 46 } backup;
47 struct {
48 char *string;
49 int x1, y1, x2, y2;
50 int suspend;
51 Eina_List *objs;
52 } link;
46 int zoom_fontsize_start; 53 int zoom_fontsize_start;
47 int scroll; 54 int scroll;
48 unsigned int last_keyup; 55 unsigned int last_keyup;
@@ -51,6 +58,7 @@ struct _Termio
51 Termpty *pty; 58 Termpty *pty;
52 Ecore_Animator *anim; 59 Ecore_Animator *anim;
53 Ecore_Timer *delayed_size_timer; 60 Ecore_Timer *delayed_size_timer;
61 Ecore_Timer *link_do_timer;
54 Ecore_Job *mouse_move_job; 62 Ecore_Job *mouse_move_job;
55 Evas_Object *win; 63 Evas_Object *win;
56 Config *config; 64 Config *config;
@@ -59,6 +67,7 @@ struct _Termio
59 Eina_Bool have_sel : 1; 67 Eina_Bool have_sel : 1;
60 Eina_Bool noreqsize : 1; 68 Eina_Bool noreqsize : 1;
61 Eina_Bool composing : 1; 69 Eina_Bool composing : 1;
70 Eina_Bool didclick : 1;
62}; 71};
63 72
64static Evas_Smart *_smart = NULL; 73static Evas_Smart *_smart = NULL;
@@ -100,8 +109,8 @@ coord_forward(Termio *sd, int *x, int *y)
100 return EINA_TRUE; 109 return EINA_TRUE;
101} 110}
102 111
103static void 112static char *
104_smart_mouseover_apply(Evas_Object *obj) 113_magic_string_find(Evas_Object *obj, int cx, int cy, int *x1r, int *y1r, int *x2r, int *y2r)
105{ 114{
106 Termio *sd = evas_object_smart_data_get(obj); 115 Termio *sd = evas_object_smart_data_get(obj);
107 char *s; 116 char *s;
@@ -109,11 +118,11 @@ _smart_mouseover_apply(Evas_Object *obj)
109 int x1, x2, y1, y2, len; 118 int x1, x2, y1, y2, len;
110 Eina_Bool goback = EINA_TRUE, goforward = EINA_FALSE, extend = EINA_FALSE; 119 Eina_Bool goback = EINA_TRUE, goforward = EINA_FALSE, extend = EINA_FALSE;
111 120
112 if (!sd) return; 121 if (!sd) return NULL;
113 x1 = sd->mouse.cx; 122 x1 = cx;
114 y1 = sd->mouse.cy; 123 y1 = cy;
115 x2 = sd->mouse.cx; 124 x2 = cx;
116 y2 = sd->mouse.cy; 125 y2 = cy;
117 if (!coord_back(sd, &x1, &y1)) goback = EINA_FALSE; 126 if (!coord_back(sd, &x1, &y1)) goback = EINA_FALSE;
118 for (;;) 127 for (;;)
119 { 128 {
@@ -125,6 +134,7 @@ _smart_mouseover_apply(Evas_Object *obj)
125 { 134 {
126 if ((!strncasecmp(s, "http://", 7))|| 135 if ((!strncasecmp(s, "http://", 7))||
127 (!strncasecmp(s, "https://", 8)) || 136 (!strncasecmp(s, "https://", 8)) ||
137 (!strncasecmp(s, "file://", 7)) ||
128 (!strncasecmp(s, "ftp://", 6))) 138 (!strncasecmp(s, "ftp://", 6)))
129 { 139 {
130 goback = EINA_FALSE; 140 goback = EINA_FALSE;
@@ -154,7 +164,8 @@ _smart_mouseover_apply(Evas_Object *obj)
154 else if (s[0] == '\'') endmatch = '\''; 164 else if (s[0] == '\'') endmatch = '\'';
155 else if (s[0] == '<') endmatch = '>'; 165 else if (s[0] == '<') endmatch = '>';
156 if ((!strncasecmp((s + 1), "www.", 4)) || 166 if ((!strncasecmp((s + 1), "www.", 4)) ||
157 (!strncasecmp((s + 1), "ftp.", 4))) 167 (!strncasecmp((s + 1), "ftp.", 4)) ||
168 (!strncasecmp((s + 1), "/", 1)))
158 { 169 {
159 goback = EINA_FALSE; 170 goback = EINA_FALSE;
160 coord_forward(sd, &x1, &y1); 171 coord_forward(sd, &x1, &y1);
@@ -164,6 +175,9 @@ _smart_mouseover_apply(Evas_Object *obj)
164 goback = EINA_FALSE; 175 goback = EINA_FALSE;
165 coord_forward(sd, &x1, &y1); 176 coord_forward(sd, &x1, &y1);
166 } 177 }
178 else if (s[0] == '=')
179 {
180 }
167 else 181 else
168 { 182 {
169 free(s); 183 free(s);
@@ -178,7 +192,9 @@ _smart_mouseover_apply(Evas_Object *obj)
178 if (len > 1) 192 if (len > 1)
179 { 193 {
180 if (((endmatch) && (s[len - 1] == endmatch)) || 194 if (((endmatch) && (s[len - 1] == endmatch)) ||
181 ((!endmatch) && (isspace(s[len - 1])))) 195 ((!endmatch) &&
196 ((isspace(s[len - 1])) || (s[len - 1] == '>'))
197 ))
182 { 198 {
183 goforward = EINA_FALSE; 199 goforward = EINA_FALSE;
184 coord_back(sd, &x2, &y2); 200 coord_back(sd, &x2, &y2);
@@ -194,7 +210,7 @@ _smart_mouseover_apply(Evas_Object *obj)
194 { 210 {
195 if (!coord_back(sd, &x1, &y1)) goback = EINA_FALSE; 211 if (!coord_back(sd, &x1, &y1)) goback = EINA_FALSE;
196 } 212 }
197 else if (!extend) 213 if ((!extend) && (!goback))
198 { 214 {
199 goforward = EINA_TRUE; 215 goforward = EINA_TRUE;
200 extend = EINA_TRUE; 216 extend = EINA_TRUE;
@@ -222,21 +238,307 @@ _smart_mouseover_apply(Evas_Object *obj)
222 } 238 }
223 else break; 239 else break;
224 } 240 }
225 if (!isspace(s[0])) 241 if ((!isspace(s[0])) && (len > 1))
226 { 242 {
227 if ((strchr(s, '@')) || 243 if ((strchr(s, '@')) ||
228 (!strncasecmp(s, "http://", 7))|| 244 (!strncasecmp(s, "http://", 7))||
229 (!strncasecmp(s, "https://", 8)) || 245 (!strncasecmp(s, "https://", 8)) ||
230 (!strncasecmp(s, "ftp://", 6)) || 246 (!strncasecmp(s, "ftp://", 6)) ||
247 (!strncasecmp(s, "file://", 7)) ||
231 (!strncasecmp(s, "www.", 4)) || 248 (!strncasecmp(s, "www.", 4)) ||
232 (!strncasecmp(s, "ftp.", 4))) 249 (!strncasecmp(s, "ftp.", 4)) ||
250 (!strncasecmp(s, "/", 1))
251 )
252 {
253 if (x1r) *x1r = x1;
254 if (y1r) *y1r = y1;
255 if (x2r) *x2r = x2;
256 if (y2r) *y2r = y2;
257 return s;
258 }
259 }
260 free(s);
261 }
262 return NULL;
263}
264
265static void
266_activate_link(Evas_Object *obj)
267{
268 Termio *sd = evas_object_smart_data_get(obj);
269 Config *config = termio_config_get(obj);
270 char buf[PATH_MAX], *s;
271 const char *path = NULL, *cmd = NULL;
272 Eina_Bool url = EINA_FALSE, email = EINA_FALSE, handled = EINA_FALSE;
273 int type;
274
275 if (!sd) return;
276 if (!config) return;
277 if (!sd->link.string) return;
278 if ((!strncasecmp(sd->link.string, "http://", 7))||
279 (!strncasecmp(sd->link.string, "https://", 8)) ||
280 (!strncasecmp(sd->link.string, "ftp://", 6)) ||
281 (!strncasecmp(sd->link.string, "www.", 4)) ||
282 (!strncasecmp(sd->link.string, "ftp.", 4)))
283 {
284 url = EINA_TRUE;
285 }
286 else if ((!strncasecmp(sd->link.string, "file://", 7)) ||
287 (!strncasecmp(sd->link.string, "/", 1)))
288 {
289 path = sd->link.string;
290 if (!strncasecmp(sd->link.string, "file://", 7)) path = path + 7;
291 }
292 else if (strchr(sd->link.string, '@'))
293 {
294 email = EINA_TRUE;
295 }
296
297 s = eina_str_escape(sd->link.string);
298 if (!s) return;
299 if (email)
300 {
301 // run mail client
302 cmd = "xdg-email";
303
304 if ((config->helper.email) &&
305 (config->helper.email[0]))
306 cmd = config->helper.email;
307 snprintf(buf, sizeof(buf), "%s %s", cmd, s);
308 }
309 else if (path)
310 {
311 // locally accessible file
312 cmd = "xdg-open";
313
314 type = media_src_type_get(sd->link.string);
315 if (config->helper.inline_please)
316 {
317 if ((type == TYPE_IMG) ||
318 (type == TYPE_SCALE) ||
319 (type == TYPE_EDJE))
320 {
321 evas_object_smart_callback_call(obj, "popup", NULL);
322 handled = EINA_TRUE;
323 }
324 else if (type == TYPE_MOV)
325 {
326 evas_object_smart_callback_call(obj, "popup", NULL);
327 handled = EINA_TRUE;
328 }
329 }
330 if (!handled)
331 {
332 if ((type == TYPE_IMG) ||
333 (type == TYPE_SCALE) ||
334 (type == TYPE_EDJE))
335 {
336 if ((config->helper.local.image) &&
337 (config->helper.local.image[0]))
338 cmd = config->helper.local.image;
339 }
340 else if (type == TYPE_MOV)
341 {
342 if ((config->helper.local.video) &&
343 (config->helper.local.video[0]))
344 cmd = config->helper.local.video;
345 }
346 else
347 {
348 if ((config->helper.local.general) &&
349 (config->helper.local.general[0]))
350 cmd = config->helper.local.general;
351 }
352 snprintf(buf, sizeof(buf), "%s %s", cmd, s);
353 }
354 }
355 else if (url)
356 {
357 // remote file needs ecore-con-url
358 cmd = "xdg-open";
359
360 type = media_src_type_get(sd->link.string);
361 if (config->helper.inline_please)
362 {
363 if ((type == TYPE_IMG) ||
364 (type == TYPE_SCALE) ||
365 (type == TYPE_EDJE))
366 {
367 // XXX: begin fetch of url, once done, show
368 evas_object_smart_callback_call(obj, "popup", NULL);
369 handled = EINA_TRUE;
370 }
371 else if (type == TYPE_MOV)
372 {
373 // XXX: if no http:// add
374 evas_object_smart_callback_call(obj, "popup", NULL);
375 handled = EINA_TRUE;
376 }
377 }
378 if (!handled)
379 {
380 if ((type == TYPE_IMG) ||
381 (type == TYPE_SCALE) ||
382 (type == TYPE_EDJE))
233 { 383 {
234 printf("FOUND: '%s' @ %i,%i -> %i,%i\n", s, x1, y1, x2, y2); 384 if ((config->helper.url.image) &&
235 // XXX: record coords and url string 385 (config->helper.url.image[0]))
386 cmd = config->helper.url.image;
236 } 387 }
388 else if (type == TYPE_MOV)
389 {
390 if ((config->helper.url.video) &&
391 (config->helper.url.video[0]))
392 cmd = config->helper.url.video;
393 }
394 else
395 {
396 if ((config->helper.url.general) &&
397 (config->helper.url.general[0]))
398 cmd = config->helper.url.general;
399 }
400 snprintf(buf, sizeof(buf), "%s %s", cmd, s);
237 } 401 }
402 }
403 else
404 {
238 free(s); 405 free(s);
406 return;
239 } 407 }
408 free(s);
409 if (!handled) ecore_exe_run(buf, NULL);
410}
411
412static Eina_Bool
413_cb_link_up_delay(void *data)
414{
415 Termio *sd = evas_object_smart_data_get(data);
416
417 if (!sd) return EINA_FALSE;
418 sd->link_do_timer = NULL;
419 if (!sd->didclick) _activate_link(data);
420 sd->didclick = EINA_FALSE;
421 return EINA_FALSE;
422}
423
424static void
425_cb_link_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event)
426{
427 Evas_Event_Mouse_Up *ev = event;
428 Termio *sd = evas_object_smart_data_get(data);
429
430 if (!sd) return;
431 if (ev->button == 1)
432 {
433 if (sd->link_do_timer) ecore_timer_del(sd->link_do_timer);
434 sd->link_do_timer = ecore_timer_add(0.2, _cb_link_up_delay, data);
435 }
436}
437
438static void
439_update_link(Evas_Object *obj, Eina_Bool same_link, Eina_Bool same_geom)
440{
441 Termio *sd = evas_object_smart_data_get(obj);
442
443 if (!sd) return;
444
445 if (!same_link)
446 {
447 // check link and re-probe/fetch create popup preview
448 }
449
450 if (!same_geom)
451 {
452 Evas_Coord ox, oy, ow, oh;
453 Evas_Object *o;
454 // fix up edje objects "underlining" the link
455 int y;
456
457 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
458 EINA_LIST_FREE(sd->link.objs, o) evas_object_del(o);
459 if ((sd->link.string) && (sd->link.suspend == 0))
460 {
461 for (y = sd->link.y1; y <= sd->link.y2; y++)
462 {
463 o = edje_object_add(evas_object_evas_get(obj));
464 evas_object_smart_member_add(o, obj);
465 theme_apply(o, sd->config, "terminology/link");
466
467 if (y == sd->link.y1)
468 {
469 evas_object_move(o, ox + (sd->link.x1 * sd->font.chw),
470 oy + (y * sd->font.chh));
471 if (sd->link.y1 == sd->link.y2)
472 evas_object_resize(o,
473 ((sd->link.x2 - sd->link.x1 + 1) * sd->font.chw),
474 sd->font.chh);
475 else
476 evas_object_resize(o,
477 ((sd->grid.w - sd->link.x1) * sd->font.chw),
478 sd->font.chh);
479 }
480 else if (y == sd->link.y2)
481 {
482 evas_object_move(o, ox, oy + (y * sd->font.chh));
483 evas_object_resize(o,
484 ((sd->link.x2 + 1) * sd->font.chw),
485 sd->font.chh);
486 }
487 else
488 {
489 evas_object_move(o, ox, oy + (y * sd->font.chh));
490 evas_object_resize(o, (sd->grid.w * sd->font.chw),
491 sd->font.chh);
492 }
493
494 sd->link.objs = eina_list_append(sd->link.objs, o);
495 evas_object_show(o);
496 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP,
497 _cb_link_up, obj);
498 }
499 }
500 }
501}
502
503static void
504_smart_mouseover_apply(Evas_Object *obj)
505{
506 char *s;
507 int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
508 Eina_Bool same_link = EINA_FALSE, same_geom = EINA_FALSE;
509 Termio *sd = evas_object_smart_data_get(obj);
510
511 if (!sd) return;
512
513 s = _magic_string_find(obj, sd->mouse.cx, sd->mouse.cy,
514 &x1, &y1, &x2, &y2);
515 if (!s)
516 {
517 if (sd->link.string) free(sd->link.string);
518 sd->link.string = NULL;
519 sd->link.x1 = -1;
520 sd->link.y1 = -1;
521 sd->link.x2 = -1;
522 sd->link.y2 = -1;
523 _update_link(obj, same_link, same_geom);
524 return;
525 }
526
527 if ((sd->link.string) && (!strcmp(sd->link.string, s)))
528 same_link = EINA_TRUE;
529 if (sd->link.string) free(sd->link.string);
530 sd->link.string = s;
531 if ((x1 == sd->link.x1) && (y1 == sd->link.y1) &&
532 (x2 == sd->link.x2) && (y2 == sd->link.y2))
533 same_geom = EINA_TRUE;
534 if (((sd->link.suspend != 0) && (sd->link.objs)) ||
535 ((sd->link.suspend == 0) && (!sd->link.objs)))
536 same_geom = EINA_FALSE;
537 sd->link.x1 = x1;
538 sd->link.y1 = y1;
539 sd->link.x2 = x2;
540 sd->link.y2 = y2;
541 _update_link(obj, same_link, same_geom);
240} 542}
241 543
242static void 544static void
@@ -1272,12 +1574,14 @@ _smart_cb_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__
1272 if (!sd) return; 1574 if (!sd) return;
1273 _smart_xy_to_cursor(data, ev->canvas.x, ev->canvas.y, &cx, &cy); 1575 _smart_xy_to_cursor(data, ev->canvas.x, ev->canvas.y, &cx, &cy);
1274 _rep_mouse_down(data, ev, cx, cy); 1576 _rep_mouse_down(data, ev, cx, cy);
1577 sd->didclick = EINA_FALSE;
1275 if (ev->button == 1) 1578 if (ev->button == 1)
1276 { 1579 {
1277 if (ev->flags & EVAS_BUTTON_TRIPLE_CLICK) 1580 if (ev->flags & EVAS_BUTTON_TRIPLE_CLICK)
1278 { 1581 {
1279 _sel_line(data, cx, cy - sd->scroll); 1582 _sel_line(data, cx, cy - sd->scroll);
1280 if (sd->cur.sel) _take_selection(data, ELM_SEL_TYPE_PRIMARY); 1583 if (sd->cur.sel) _take_selection(data, ELM_SEL_TYPE_PRIMARY);
1584 sd->didclick = EINA_TRUE;
1281 } 1585 }
1282 else if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK) 1586 else if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1283 { 1587 {
@@ -1296,6 +1600,7 @@ _smart_cb_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__
1296 _sel_word(data, cx, cy - sd->scroll); 1600 _sel_word(data, cx, cy - sd->scroll);
1297 } 1601 }
1298 if (sd->cur.sel) _take_selection(data, ELM_SEL_TYPE_PRIMARY); 1602 if (sd->cur.sel) _take_selection(data, ELM_SEL_TYPE_PRIMARY);
1603 sd->didclick = EINA_TRUE;
1299 } 1604 }
1300 else 1605 else
1301 { 1606 {
@@ -1304,7 +1609,11 @@ _smart_cb_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__
1304 sd->backup.sel1.y = sd->cur.sel1.y; 1609 sd->backup.sel1.y = sd->cur.sel1.y;
1305 sd->backup.sel2.x = sd->cur.sel2.x; 1610 sd->backup.sel2.x = sd->cur.sel2.x;
1306 sd->backup.sel2.y = sd->cur.sel2.y; 1611 sd->backup.sel2.y = sd->cur.sel2.y;
1307 if (sd->cur.sel) sd->cur.sel = 0; 1612 if (sd->cur.sel)
1613 {
1614 sd->cur.sel = 0;
1615 sd->didclick = EINA_TRUE;
1616 }
1308 sd->cur.makesel = 1; 1617 sd->cur.makesel = 1;
1309 sd->cur.sel1.x = cx; 1618 sd->cur.sel1.x = cx;
1310 sd->cur.sel1.y = cy - sd->scroll; 1619 sd->cur.sel1.y = cy - sd->scroll;
@@ -1336,6 +1645,7 @@ _smart_cb_mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
1336 sd->cur.makesel = 0; 1645 sd->cur.makesel = 0;
1337 if (sd->cur.sel) 1646 if (sd->cur.sel)
1338 { 1647 {
1648 sd->didclick = EINA_TRUE;
1339 sd->cur.sel2.x = cx; 1649 sd->cur.sel2.x = cx;
1340 sd->cur.sel2.y = cy - sd->scroll; 1650 sd->cur.sel2.y = cy - sd->scroll;
1341 _selection_dbl_fix(data); 1651 _selection_dbl_fix(data);
@@ -1381,6 +1691,18 @@ _smart_cb_mouse_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__
1381} 1691}
1382 1692
1383static void 1693static void
1694_smart_cb_mouse_in(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
1695{
1696 termio_mouseover_suspend_pushpop(data, -1);
1697}
1698
1699static void
1700_smart_cb_mouse_out(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
1701{
1702 termio_mouseover_suspend_pushpop(data, 1);
1703}
1704
1705static void
1384_smart_cb_mouse_wheel(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event) 1706_smart_cb_mouse_wheel(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event)
1385{ 1707{
1386 Evas_Event_Mouse_Wheel *ev = event; 1708 Evas_Event_Mouse_Wheel *ev = event;
@@ -1468,6 +1790,7 @@ _smart_cb_gest_long_move(void *data, void *event __UNUSED__)
1468 1790
1469 if (!sd) return EVAS_EVENT_FLAG_ON_HOLD; 1791 if (!sd) return EVAS_EVENT_FLAG_ON_HOLD;
1470 evas_object_smart_callback_call(data, "options", NULL); 1792 evas_object_smart_callback_call(data, "options", NULL);
1793 sd->didclick = EINA_TRUE;
1471 return EVAS_EVENT_FLAG_ON_HOLD; 1794 return EVAS_EVENT_FLAG_ON_HOLD;
1472} 1795}
1473 1796
@@ -1484,6 +1807,7 @@ _smart_cb_gest_zoom_start(void *data, void *event)
1484 sd->zoom_fontsize_start = config->font.size; 1807 sd->zoom_fontsize_start = config->font.size;
1485 _font_size_set(data, (double)sd->zoom_fontsize_start * p->zoom); 1808 _font_size_set(data, (double)sd->zoom_fontsize_start * p->zoom);
1486 } 1809 }
1810 sd->didclick = EINA_TRUE;
1487 return EVAS_EVENT_FLAG_ON_HOLD; 1811 return EVAS_EVENT_FLAG_ON_HOLD;
1488} 1812}
1489 1813
@@ -1500,6 +1824,7 @@ _smart_cb_gest_zoom_move(void *data, void *event)
1500 sd->zoom_fontsize_start = config->font.size; 1824 sd->zoom_fontsize_start = config->font.size;
1501 _font_size_set(data, (double)sd->zoom_fontsize_start * p->zoom); 1825 _font_size_set(data, (double)sd->zoom_fontsize_start * p->zoom);
1502 } 1826 }
1827 sd->didclick = EINA_TRUE;
1503 return EVAS_EVENT_FLAG_ON_HOLD; 1828 return EVAS_EVENT_FLAG_ON_HOLD;
1504} 1829}
1505 1830
@@ -1516,6 +1841,7 @@ _smart_cb_gest_zoom_end(void *data, void *event)
1516 sd->zoom_fontsize_start = config->font.size; 1841 sd->zoom_fontsize_start = config->font.size;
1517 _font_size_set(data, (double)sd->zoom_fontsize_start * p->zoom); 1842 _font_size_set(data, (double)sd->zoom_fontsize_start * p->zoom);
1518 } 1843 }
1844 sd->didclick = EINA_TRUE;
1519 return EVAS_EVENT_FLAG_ON_HOLD; 1845 return EVAS_EVENT_FLAG_ON_HOLD;
1520} 1846}
1521 1847
@@ -1532,6 +1858,7 @@ _smart_cb_gest_zoom_abort(void *data, void *event __UNUSED__)
1532 sd->zoom_fontsize_start = config->font.size; 1858 sd->zoom_fontsize_start = config->font.size;
1533 _font_size_set(data, sd->zoom_fontsize_start); 1859 _font_size_set(data, sd->zoom_fontsize_start);
1534 } 1860 }
1861 sd->didclick = EINA_TRUE;
1535 return EVAS_EVENT_FLAG_ON_HOLD; 1862 return EVAS_EVENT_FLAG_ON_HOLD;
1536} 1863}
1537 1864
@@ -1631,6 +1958,10 @@ _smart_add(Evas_Object *obj)
1631 _smart_cb_mouse_up, obj); 1958 _smart_cb_mouse_up, obj);
1632 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_MOVE, 1959 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_MOVE,
1633 _smart_cb_mouse_move, obj); 1960 _smart_cb_mouse_move, obj);
1961 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_IN,
1962 _smart_cb_mouse_in, obj);
1963 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_OUT,
1964 _smart_cb_mouse_out, obj);
1634 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_WHEEL, 1965 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_WHEEL,
1635 _smart_cb_mouse_wheel, obj); 1966 _smart_cb_mouse_wheel, obj);
1636 1967
@@ -1643,6 +1974,8 @@ _smart_add(Evas_Object *obj)
1643 evas_object_event_callback_add(obj, EVAS_CALLBACK_FOCUS_OUT, 1974 evas_object_event_callback_add(obj, EVAS_CALLBACK_FOCUS_OUT,
1644 _smart_cb_focus_out, obj); 1975 _smart_cb_focus_out, obj);
1645 1976
1977 sd->link.suspend = 1;
1978
1646 if (ecore_imf_init()) 1979 if (ecore_imf_init())
1647 { 1980 {
1648 const char *imf_id = ecore_imf_context_default_id_get(); 1981 const char *imf_id = ecore_imf_context_default_id_get();
@@ -1699,7 +2032,9 @@ static void
1699_smart_del(Evas_Object *obj) 2032_smart_del(Evas_Object *obj)
1700{ 2033{
1701 char *str; 2034 char *str;
2035 Evas_Object *o;
1702 Termio *sd = evas_object_smart_data_get(obj); 2036 Termio *sd = evas_object_smart_data_get(obj);
2037
1703 if (!sd) return; 2038 if (!sd) return;
1704 if (sd->imf) 2039 if (sd->imf)
1705 { 2040 {
@@ -1714,9 +2049,12 @@ _smart_del(Evas_Object *obj)
1714 if (sd->cur.selo3) evas_object_del(sd->cur.selo3); 2049 if (sd->cur.selo3) evas_object_del(sd->cur.selo3);
1715 if (sd->anim) ecore_animator_del(sd->anim); 2050 if (sd->anim) ecore_animator_del(sd->anim);
1716 if (sd->delayed_size_timer) ecore_timer_del(sd->delayed_size_timer); 2051 if (sd->delayed_size_timer) ecore_timer_del(sd->delayed_size_timer);
2052 if (sd->link_do_timer) ecore_timer_del(sd->link_do_timer);
1717 if (sd->mouse_move_job) ecore_job_del(sd->mouse_move_job); 2053 if (sd->mouse_move_job) ecore_job_del(sd->mouse_move_job);
1718 if (sd->font.name) eina_stringshare_del(sd->font.name); 2054 if (sd->font.name) eina_stringshare_del(sd->font.name);
1719 if (sd->pty) termpty_free(sd->pty); 2055 if (sd->pty) termpty_free(sd->pty);
2056 if (sd->link.string) free(sd->link.string);
2057 EINA_LIST_FREE(sd->link.objs, o) evas_object_del(o);
1720 EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str); 2058 EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str);
1721 sd->cur.obj = NULL; 2059 sd->cur.obj = NULL;
1722 sd->event = NULL; 2060 sd->event = NULL;
@@ -1993,6 +2331,7 @@ termio_selection_get(Evas_Object *obj, int c1x, int c1y, int c2x, int c2y)
1993 w = 0; 2331 w = 0;
1994 last0 = -1; 2332 last0 = -1;
1995 cells = termpty_cellrow_get(sd->pty, y, &w); 2333 cells = termpty_cellrow_get(sd->pty, y, &w);
2334 if (!cells) continue;
1996 if (w > sd->grid.w) w = sd->grid.w; 2335 if (w > sd->grid.w) w = sd->grid.w;
1997 start_x = c1x; 2336 start_x = c1x;
1998 end_x = c2x; 2337 end_x = c2x;
@@ -2165,3 +2504,21 @@ termio_paste_clipboard(Evas_Object *obj)
2165{ 2504{
2166 _paste_selection(obj, ELM_SEL_TYPE_CLIPBOARD); 2505 _paste_selection(obj, ELM_SEL_TYPE_CLIPBOARD);
2167} 2506}
2507
2508const char *
2509termio_link_get(const Evas_Object *obj)
2510{
2511 Termio *sd = evas_object_smart_data_get(obj);
2512 EINA_SAFETY_ON_NULL_RETURN_VAL(sd, NULL);
2513 return sd->link.string;
2514}
2515
2516void
2517termio_mouseover_suspend_pushpop(Evas_Object *obj, int dir)
2518{
2519 Termio *sd = evas_object_smart_data_get(obj);
2520 if (!sd) return;
2521 sd->link.suspend += dir;
2522 if (sd->link.suspend < 0) sd->link.suspend = 0;
2523 _smart_update_queue(obj, sd);
2524}
diff --git a/src/bin/termio.h b/src/bin/termio.h
index d727468..108d535 100644
--- a/src/bin/termio.h
+++ b/src/bin/termio.h
@@ -10,5 +10,6 @@ void termio_config_update(Evas_Object *obj);
10Config *termio_config_get(const Evas_Object *obj); 10Config *termio_config_get(const Evas_Object *obj);
11void termio_copy_clipboard(Evas_Object *obj); 11void termio_copy_clipboard(Evas_Object *obj);
12void termio_paste_clipboard(Evas_Object *obj); 12void termio_paste_clipboard(Evas_Object *obj);
13 13const char *termio_link_get(const Evas_Object *obj);
14void termio_mouseover_suspend_pushpop(Evas_Object *obj, int dir);
14#endif 15#endif