summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2012-07-02 03:47:02 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-07-02 03:47:02 +0000
commit654e76003373370b2d0266d24ec761dcf3cea9fb (patch)
tree6cdf1c0d6bab8d25b247662bde1add6b838f0e11 /src/bin
parentf9474527a92365f0d497a7ea3d1a9f39887fac24 (diff)
and now also use gesture layer for long-press for control panel and
zoom controls too for font size change (happens to make ctrl+mouse wheel zoom too) SVN revision: 73122
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/termio.c195
1 files changed, 137 insertions, 58 deletions
diff --git a/src/bin/termio.c b/src/bin/termio.c
index e4db2d4..6b7bb87 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -40,6 +40,7 @@ struct _Termio
40 } sel1, sel2; 40 } sel1, sel2;
41 Eina_Bool sel : 1; 41 Eina_Bool sel : 1;
42 } backup; 42 } backup;
43 int zoom_fontsize_start;
43 int scroll; 44 int scroll;
44 unsigned int last_keyup; 45 unsigned int last_keyup;
45 Eina_List *seq; 46 Eina_List *seq;
@@ -430,9 +431,37 @@ _paste_selection(Evas_Object *obj, Elm_Sel_Type type)
430} 431}
431 432
432static void 433static void
433_smart_cb_key_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) 434_font_size_set(Evas_Object *obj, int size)
434{ 435{
435 Evas_Event_Key_Up *ev = event_info; 436 Termio *sd = evas_object_smart_data_get(obj);
437 Config *config = termio_config_get(obj);
438 if (!sd) return;
439
440 if (size < 5) size = 5;
441 else if (size > 100) size = 100;
442 if (config)
443 {
444 Evas_Coord mw = 1, mh = 1;
445 int gw, gh;
446
447 config->temporary = EINA_TRUE;
448 config->font.size = size;
449 gw = sd->grid.w;
450 gh = sd->grid.h;
451 evas_object_size_hint_min_get(obj, &mw, &mh);
452 sd->noreqsize = 1;
453 termio_config_update(obj);
454 sd->noreqsize = 0;
455 evas_object_size_hint_min_get(obj, &mw, &mh);
456 evas_object_data_del(obj, "sizedone");
457 evas_object_size_hint_request_set(obj, mw * gw, mh * gh);
458 }
459}
460
461static void
462_smart_cb_key_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event)
463{
464 Evas_Event_Key_Up *ev = event;
436 Termio *sd; 465 Termio *sd;
437 466
438 sd = evas_object_smart_data_get(data); 467 sd = evas_object_smart_data_get(data);
@@ -517,23 +546,7 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
517 546
518 EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str); 547 EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str);
519 sd->composing = EINA_FALSE; 548 sd->composing = EINA_FALSE;
520 if (config) 549 if (config) _font_size_set(data, config->font.size + 1);
521 {
522 Evas_Coord mw = 1, mh = 1;
523 int gw, gh;
524
525 config->temporary = EINA_TRUE;
526 config->font.size += 1;
527 gw = sd->grid.w;
528 gh = sd->grid.h;
529 evas_object_size_hint_min_get(obj, &mw, &mh);
530 sd->noreqsize = 1;
531 termio_config_update(data);
532 sd->noreqsize = 0;
533 evas_object_size_hint_min_get(data, &mw, &mh);
534 evas_object_data_del(data, "sizedone");
535 evas_object_size_hint_request_set(data, mw * gw, mh * gh);
536 }
537 goto end; 550 goto end;
538 } 551 }
539 else if (!strcmp(ev->keyname, "KP_Subtract")) 552 else if (!strcmp(ev->keyname, "KP_Subtract"))
@@ -542,23 +555,7 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
542 555
543 EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str); 556 EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str);
544 sd->composing = EINA_FALSE; 557 sd->composing = EINA_FALSE;
545 if (config) 558 if (config) _font_size_set(data, config->font.size - 1);
546 {
547 Evas_Coord mw = 1, mh = 1;
548 int gw, gh;
549
550 config->temporary = EINA_TRUE;
551 config->font.size -= 1;
552 gw = sd->grid.w;
553 gh = sd->grid.h;
554 evas_object_size_hint_min_get(obj, &mw, &mh);
555 sd->noreqsize = 1;
556 termio_config_update(data);
557 sd->noreqsize = 0;
558 evas_object_size_hint_min_get(data, &mw, &mh);
559 evas_object_data_del(data, "sizedone");
560 evas_object_size_hint_request_set(data, mw * gw, mh * gh);
561 }
562 goto end; 559 goto end;
563 } 560 }
564 else if (!strcmp(ev->keyname, "KP_Multiply")) 561 else if (!strcmp(ev->keyname, "KP_Multiply"))
@@ -567,23 +564,7 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
567 564
568 EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str); 565 EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str);
569 sd->composing = EINA_FALSE; 566 sd->composing = EINA_FALSE;
570 if (config) 567 if (config) _font_size_set(data, 10);
571 {
572 Evas_Coord mw = 1, mh = 1;
573 int gw, gh;
574
575 config->temporary = EINA_TRUE;
576 config->font.size = 10;
577 gw = sd->grid.w;
578 gh = sd->grid.h;
579 evas_object_size_hint_min_get(obj, &mw, &mh);
580 sd->noreqsize = 1;
581 termio_config_update(data);
582 sd->noreqsize = 0;
583 evas_object_size_hint_min_get(data, &mw, &mh);
584 evas_object_data_del(data, "sizedone");
585 evas_object_size_hint_request_set(data, mw * gw, mh * gh);
586 }
587 goto end; 568 goto end;
588 } 569 }
589 else if (!strcmp(ev->keyname, "KP_Divide")) 570 else if (!strcmp(ev->keyname, "KP_Divide"))
@@ -1210,6 +1191,9 @@ _smart_cb_mouse_wheel(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED_
1210 sd = evas_object_smart_data_get(data); 1191 sd = evas_object_smart_data_get(data);
1211 if (!sd) return; 1192 if (!sd) return;
1212 if (sd->pty->altbuf) return; 1193 if (sd->pty->altbuf) return;
1194 if (evas_key_modifier_is_set(ev->modifiers, "Control")) return;
1195 if (evas_key_modifier_is_set(ev->modifiers, "Alt")) return;
1196 if (evas_key_modifier_is_set(ev->modifiers, "Shift")) return;
1213 sd->scroll -= (ev->z * 4); 1197 sd->scroll -= (ev->z * 4);
1214 if (sd->scroll > sd->pty->backscroll_num) 1198 if (sd->scroll > sd->pty->backscroll_num)
1215 sd->scroll = sd->pty->backscroll_num; 1199 sd->scroll = sd->pty->backscroll_num;
@@ -1278,11 +1262,86 @@ _cursor_cb_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, voi
1278 _imf_cursor_set(sd); 1262 _imf_cursor_set(sd);
1279} 1263}
1280 1264
1265static Evas_Event_Flags
1266_smart_cb_gest_long_start(void *data, void *event __UNUSED__)
1267{
1268// Elm_Gesture_Taps_Info *p = event;
1269 Termio *sd = evas_object_smart_data_get(data);
1270
1271 if (!sd) return EVAS_EVENT_FLAG_ON_HOLD;
1272 evas_object_smart_callback_call(data, "options", NULL);
1273 return EVAS_EVENT_FLAG_ON_HOLD;
1274}
1275
1276static Evas_Event_Flags
1277_smart_cb_gest_zoom_start(void *data, void *event)
1278{
1279 Elm_Gesture_Zoom_Info *p = event;
1280 Termio *sd = evas_object_smart_data_get(data);
1281 Config *config = termio_config_get(data);
1282
1283 if (!sd) return EVAS_EVENT_FLAG_ON_HOLD;
1284 if (config)
1285 {
1286 sd->zoom_fontsize_start = config->font.size;
1287 _font_size_set(data, (double)sd->zoom_fontsize_start * p->zoom);
1288 }
1289 return EVAS_EVENT_FLAG_ON_HOLD;
1290}
1291
1292static Evas_Event_Flags
1293_smart_cb_gest_zoom_move(void *data, void *event)
1294{
1295 Elm_Gesture_Zoom_Info *p = event;
1296 Termio *sd = evas_object_smart_data_get(data);
1297 Config *config = termio_config_get(data);
1298
1299 if (!sd) return EVAS_EVENT_FLAG_ON_HOLD;
1300 if (config)
1301 {
1302 sd->zoom_fontsize_start = config->font.size;
1303 _font_size_set(data, (double)sd->zoom_fontsize_start * p->zoom);
1304 }
1305 return EVAS_EVENT_FLAG_ON_HOLD;
1306}
1307
1308static Evas_Event_Flags
1309_smart_cb_gest_zoom_end(void *data, void *event)
1310{
1311 Elm_Gesture_Zoom_Info *p = event;
1312 Termio *sd = evas_object_smart_data_get(data);
1313 Config *config = termio_config_get(data);
1314
1315 if (!sd) return EVAS_EVENT_FLAG_ON_HOLD;
1316 if (config)
1317 {
1318 sd->zoom_fontsize_start = config->font.size;
1319 _font_size_set(data, (double)sd->zoom_fontsize_start * p->zoom);
1320 }
1321 return EVAS_EVENT_FLAG_ON_HOLD;
1322}
1323
1324static Evas_Event_Flags
1325_smart_cb_gest_zoom_abort(void *data, void *event __UNUSED__)
1326{
1327// Elm_Gesture_Zoom_Info *p = event;
1328 Termio *sd = evas_object_smart_data_get(data);
1329 Config *config = termio_config_get(data);
1330
1331 if (!sd) return EVAS_EVENT_FLAG_ON_HOLD;
1332 if (config)
1333 {
1334 sd->zoom_fontsize_start = config->font.size;
1335 _font_size_set(data, sd->zoom_fontsize_start);
1336 }
1337 return EVAS_EVENT_FLAG_ON_HOLD;
1338}
1339
1281static void 1340static void
1282_imf_event_commit_cb(void *data, Ecore_IMF_Context *ctx __UNUSED__, void *event_info) 1341_imf_event_commit_cb(void *data, Ecore_IMF_Context *ctx __UNUSED__, void *event)
1283{ 1342{
1284 Termio *sd = data; 1343 Termio *sd = data;
1285 char *str = event_info; 1344 char *str = event;
1286 DBG("IMF committed '%s'", str); 1345 DBG("IMF committed '%s'", str);
1287 if (!str) return; 1346 if (!str) return;
1288 termpty_write(sd->pty, str, strlen(str)); 1347 termpty_write(sd->pty, str, strlen(str));
@@ -1293,7 +1352,7 @@ _smart_add(Evas_Object *obj)
1293{ 1352{
1294 Termio *sd; 1353 Termio *sd;
1295 Evas_Object_Smart_Clipped_Data *cd; 1354 Evas_Object_Smart_Clipped_Data *cd;
1296 Evas_Object *o; 1355 Evas_Object *o, *g;
1297 int i, j, k, l, n; 1356 int i, j, k, l, n;
1298 1357
1299 _parent_sc.add(obj); 1358 _parent_sc.add(obj);
@@ -1367,7 +1426,7 @@ _smart_add(Evas_Object *obj)
1367 sd->event = o; 1426 sd->event = o;
1368 evas_object_color_set(o, 0, 0, 0, 0); 1427 evas_object_color_set(o, 0, 0, 0, 0);
1369 evas_object_show(o); 1428 evas_object_show(o);
1370 1429
1371 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, 1430 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
1372 _smart_cb_mouse_down, obj); 1431 _smart_cb_mouse_down, obj);
1373 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, 1432 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP,
@@ -1641,7 +1700,7 @@ Evas_Object *
1641termio_add(Evas_Object *parent, Config *config, const char *cmd, int w, int h) 1700termio_add(Evas_Object *parent, Config *config, const char *cmd, int w, int h)
1642{ 1701{
1643 Evas *e; 1702 Evas *e;
1644 Evas_Object *obj; 1703 Evas_Object *obj, *g;
1645 Termio *sd; 1704 Termio *sd;
1646 1705
1647 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); 1706 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
@@ -1655,6 +1714,26 @@ termio_add(Evas_Object *parent, Config *config, const char *cmd, int w, int h)
1655 1714
1656 _termio_config_set(obj, config); 1715 _termio_config_set(obj, config);
1657 1716
1717 g = elm_gesture_layer_add(parent);
1718 elm_gesture_layer_attach(g, sd->event);
1719
1720 elm_gesture_layer_cb_set(g, ELM_GESTURE_N_LONG_TAPS,
1721 ELM_GESTURE_STATE_START, _smart_cb_gest_long_start,
1722 obj);
1723
1724 elm_gesture_layer_cb_set(g, ELM_GESTURE_ZOOM,
1725 ELM_GESTURE_STATE_START, _smart_cb_gest_zoom_start,
1726 obj);
1727 elm_gesture_layer_cb_set(g, ELM_GESTURE_ZOOM,
1728 ELM_GESTURE_STATE_MOVE, _smart_cb_gest_zoom_move,
1729 obj);
1730 elm_gesture_layer_cb_set(g, ELM_GESTURE_ZOOM,
1731 ELM_GESTURE_STATE_END, _smart_cb_gest_zoom_end,
1732 obj);
1733 elm_gesture_layer_cb_set(g, ELM_GESTURE_ZOOM,
1734 ELM_GESTURE_STATE_ABORT, _smart_cb_gest_zoom_abort,
1735 obj);
1736
1658 termpty_init(); 1737 termpty_init();
1659 1738
1660 sd->pty = termpty_new(cmd, w, h, config->scrollback); 1739 sd->pty = termpty_new(cmd, w, h, config->scrollback);