summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2012-07-01 00:24:30 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-07-01 00:24:30 +0000
commit689e2c2dd70cd48b11658ac1f1ee9732bd8379b9 (patch)
tree51b74ad05e3b930fd8de426b75b18ac919f0204b /src/bin
parent5afd73501ff673a5735c662058ddd2cfa6e304e2 (diff)
begin on custom command infra, fix home/end for emacs, and fix about
dialog to restart properly and dismiss layer to be above about. SVN revision: 73085
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/about.c1
-rw-r--r--src/bin/keyin.c8
-rw-r--r--src/bin/termio.c12
-rw-r--r--src/bin/termpty.c132
-rw-r--r--src/bin/termpty.h3
5 files changed, 117 insertions, 39 deletions
diff --git a/src/bin/about.c b/src/bin/about.c
index 3c413a6..411934e 100644
--- a/src/bin/about.c
+++ b/src/bin/about.c
@@ -97,6 +97,7 @@ about_toggle(Evas_Object *win, Evas_Object *bg, Evas_Object *term)
97 _cb_mouse_down, term); 97 _cb_mouse_down, term);
98 98
99 edje_object_signal_emit(bg, "about,show", "terminology"); 99 edje_object_signal_emit(bg, "about,show", "terminology");
100 elm_object_signal_emit(ab_layout, "begin" ,"terminology");
100 ab_out = EINA_TRUE; 101 ab_out = EINA_TRUE;
101 elm_object_focus_set(ab_layout, EINA_TRUE); 102 elm_object_focus_set(ab_layout, EINA_TRUE);
102 if (ab_del_timer) 103 if (ab_del_timer)
diff --git a/src/bin/keyin.c b/src/bin/keyin.c
index 46d24a7..ae0961e 100644
--- a/src/bin/keyin.c
+++ b/src/bin/keyin.c
@@ -34,8 +34,11 @@ static const Keyout appcur_keyout[] =
34 KEY("Right", "\033OC"), 34 KEY("Right", "\033OC"),
35 KEY("Up", "\033OA"), 35 KEY("Up", "\033OA"),
36 KEY("Down", "\033OB"), 36 KEY("Down", "\033OB"),
37 KEY("Home", "\033[7~"), 37 KEY("Home", "\033OH"),
38 KEY("End", "\033[8~"), 38 KEY("End", "\033OF"),
39//// why did i change these?
40// KEY("Home", "\033[7~"),
41// KEY("End", "\033[8~"),
39 KEY("F1", "\033OP"), 42 KEY("F1", "\033OP"),
40 KEY("F2", "\033OQ"), 43 KEY("F2", "\033OQ"),
41 KEY("F3", "\033OR"), 44 KEY("F3", "\033OR"),
@@ -266,6 +269,7 @@ keyin_handle(Termpty *ty, Evas_Event_Key_Down *ev)
266 269
267 if (ty->state.appcursor) 270 if (ty->state.appcursor)
268 { 271 {
272 printf("appcur...\n");
269 if (_key_try(ty, appcur_keyout, ev)) return; 273 if (_key_try(ty, appcur_keyout, ev)) return;
270 } 274 }
271 275
diff --git a/src/bin/termio.c b/src/bin/termio.c
index d529097..17309b8 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -1614,6 +1614,16 @@ _smart_pty_bell(void *data)
1614 evas_object_smart_callback_call(data, "bell", NULL); 1614 evas_object_smart_callback_call(data, "bell", NULL);
1615} 1615}
1616 1616
1617static void
1618_smart_pty_command(void *data)
1619{
1620 Evas_Object *obj = data;
1621 Termio *sd;
1622 sd = evas_object_smart_data_get(obj);
1623 if (!sd) return;
1624 printf("COMMAND: '%s'\n", sd->pty->cur_cmd);
1625}
1626
1617Evas_Object * 1627Evas_Object *
1618termio_add(Evas_Object *parent, Config *config, const char *cmd, int w, int h) 1628termio_add(Evas_Object *parent, Config *config, const char *cmd, int w, int h)
1619{ 1629{
@@ -1649,6 +1659,8 @@ termio_add(Evas_Object *parent, Config *config, const char *cmd, int w, int h)
1649 sd->pty->cb.exited.data = obj; 1659 sd->pty->cb.exited.data = obj;
1650 sd->pty->cb.bell.func = _smart_pty_bell; 1660 sd->pty->cb.bell.func = _smart_pty_bell;
1651 sd->pty->cb.bell.data = obj; 1661 sd->pty->cb.bell.data = obj;
1662 sd->pty->cb.command.func = _smart_pty_command;
1663 sd->pty->cb.command.data = obj;
1652 _smart_size(obj, w, h, EINA_FALSE); 1664 _smart_size(obj, w, h, EINA_FALSE);
1653 return obj; 1665 return obj;
1654} 1666}
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index 445c4d0..561b77f 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -649,9 +649,9 @@ _cursor_copy(Termstate *state, Termstate *dest)
649} 649}
650 650
651static int 651static int
652_csi_arg_get(char **ptr) 652_csi_arg_get(Eina_Unicode **ptr)
653{ 653{
654 char *b = *ptr; 654 Eina_Unicode *b = *ptr;
655 int octal = 0; 655 int octal = 0;
656 int sum = 0; 656 int sum = 0;
657 657
@@ -674,12 +674,13 @@ _csi_arg_get(char **ptr)
674} 674}
675 675
676static int 676static int
677_handle_esc_csi(Termpty *ty, const int *c, int *ce) 677_handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
678{ 678{
679 int *cc, arg, first = 1, i; 679 Eina_Unicode *cc;
680 char buf[4096], *b; 680 int arg, first = 1, i;
681 Eina_Unicode buf[4096], *b;
681 682
682 cc = (int *)c; 683 cc = (Eina_Unicode *)c;
683 b = buf; 684 b = buf;
684 while ((cc < ce) && (*cc >= '0') && (*cc <= '?')) 685 while ((cc < ce) && (*cc >= '0') && (*cc <= '?'))
685 { 686 {
@@ -693,7 +694,7 @@ _handle_esc_csi(Termpty *ty, const int *c, int *ce)
693 if (cc == ce) return -2; 694 if (cc == ce) return -2;
694 *b = 0; 695 *b = 0;
695 b = buf; 696 b = buf;
696 DBG(" CSI: '%c' args '%s'", *cc, buf); 697// DBG(" CSI: '%c' args '%s'", *cc, buf);
697 switch (*cc) 698 switch (*cc)
698 { 699 {
699 case 'm': // color set 700 case 'm': // color set
@@ -1383,7 +1384,7 @@ _handle_esc_csi(Termpty *ty, const int *c, int *ce)
1383 } 1384 }
1384 } 1385 }
1385 } 1386 }
1386 if (!handled) ERR("unhandled '%c' : '%s'", *cc, buf); 1387 if (!handled) ERR("unhandled '%c'", *cc);
1387 } 1388 }
1388 break; 1389 break;
1389 case 'r': 1390 case 'r':
@@ -1454,7 +1455,7 @@ _handle_esc_csi(Termpty *ty, const int *c, int *ce)
1454 break; 1455 break;
1455 */ 1456 */
1456 default: 1457 default:
1457 ERR("unhandled CSI '%c' (0x%02x), buf='%s'", *cc, *cc, buf); 1458 ERR("unhandled CSI '%c' (0x%02x)", *cc, *cc);
1458 break; 1459 break;
1459 } 1460 }
1460 cc++; 1461 cc++;
@@ -1462,12 +1463,14 @@ _handle_esc_csi(Termpty *ty, const int *c, int *ce)
1462} 1463}
1463 1464
1464static int 1465static int
1465_handle_esc_xterm(Termpty *ty, const int *c, int *ce) 1466_handle_esc_xterm(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
1466{ 1467{
1467 int *cc; 1468 Eina_Unicode *cc;
1468 char buf[4096], *b; 1469 Eina_Unicode buf[4096], *b;
1469 1470 char *s;
1470 cc = (int *)c; 1471 int len = 0;
1472
1473 cc = (Eina_Unicode *)c;
1471 b = buf; 1474 b = buf;
1472 while ((cc < ce) && (*cc >= ' ') && (*cc < 0x7f)) 1475 while ((cc < ce) && (*cc >= ' ') && (*cc < 0x7f))
1473 { 1476 {
@@ -1482,26 +1485,51 @@ _handle_esc_xterm(Termpty *ty, const int *c, int *ce)
1482 { 1485 {
1483 case '0': 1486 case '0':
1484 // XXX: title + name - callback 1487 // XXX: title + name - callback
1485 b = &(buf[2]); 1488 s = eina_unicode_unicode_to_utf8(&(buf[2]), &len);
1486 if (ty->prop.title) eina_stringshare_del(ty->prop.title); 1489 if (ty->prop.title) eina_stringshare_del(ty->prop.title);
1487 if (ty->prop.icon) eina_stringshare_del(ty->prop.icon); 1490 if (ty->prop.icon) eina_stringshare_del(ty->prop.icon);
1488 ty->prop.title = eina_stringshare_add(b); 1491 if (b)
1489 ty->prop.icon = eina_stringshare_add(b); 1492 {
1493 ty->prop.title = eina_stringshare_add(s);
1494 ty->prop.icon = eina_stringshare_add(s);
1495 free(s);
1496 }
1497 else
1498 {
1499 ty->prop.title = NULL;
1500 ty->prop.icon = NULL;
1501 }
1490 if (ty->cb.set_title.func) ty->cb.set_title.func(ty->cb.set_title.data); 1502 if (ty->cb.set_title.func) ty->cb.set_title.func(ty->cb.set_title.data);
1491 if (ty->cb.set_icon.func) ty->cb.set_title.func(ty->cb.set_icon.data); 1503 if (ty->cb.set_icon.func) ty->cb.set_title.func(ty->cb.set_icon.data);
1492 break; 1504 break;
1493 case '1': 1505 case '1':
1494 // XXX: icon name - callback 1506 // XXX: icon name - callback
1495 b = &(buf[2]); 1507 s = eina_unicode_unicode_to_utf8(&(buf[2]), &len);
1496 if (ty->prop.icon) eina_stringshare_del(ty->prop.icon); 1508 if (ty->prop.icon) eina_stringshare_del(ty->prop.icon);
1497 ty->prop.icon = eina_stringshare_add(b); 1509 if (s)
1510 {
1511 ty->prop.icon = eina_stringshare_add(s);
1512 free(s);
1513 }
1514 else
1515 {
1516 ty->prop.icon = NULL;
1517 }
1498 if (ty->cb.set_icon.func) ty->cb.set_title.func(ty->cb.set_icon.data); 1518 if (ty->cb.set_icon.func) ty->cb.set_title.func(ty->cb.set_icon.data);
1499 break; 1519 break;
1500 case '2': 1520 case '2':
1501 // XXX: title - callback 1521 // XXX: title - callback
1502 b = &(buf[2]); 1522 s = eina_unicode_unicode_to_utf8(&(buf[2]), &len);
1503 if (ty->prop.title) eina_stringshare_del(ty->prop.title); 1523 if (ty->prop.title) eina_stringshare_del(ty->prop.title);
1504 ty->prop.title = eina_stringshare_add(b); 1524 if (s)
1525 {
1526 ty->prop.title = eina_stringshare_add(s);
1527 free(s);
1528 }
1529 else
1530 {
1531 ty->prop.title = NULL;
1532 }
1505 if (ty->cb.set_title.func) ty->cb.set_title.func(ty->cb.set_title.data); 1533 if (ty->cb.set_title.func) ty->cb.set_title.func(ty->cb.set_title.data);
1506 break; 1534 break;
1507 case '4': 1535 case '4':
@@ -1510,14 +1538,42 @@ _handle_esc_xterm(Termpty *ty, const int *c, int *ce)
1510 break; 1538 break;
1511 default: 1539 default:
1512 // many others 1540 // many others
1513 ERR("unhandled xterm esc '%c' -> '%s'", buf[0], buf); 1541 ERR("unhandled xterm esc '%c'", buf[0]);
1514 break; 1542 break;
1515 } 1543 }
1516 return cc - c; 1544 return cc - c;
1517} 1545}
1518 1546
1519static int 1547static int
1520_handle_esc(Termpty *ty, const int *c, int *ce) 1548_handle_esc_terminology(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
1549{
1550 Eina_Unicode *cc;
1551 Eina_Unicode buf[4096], *b;
1552 char *s;
1553 int slen = 0;
1554
1555 cc = (Eina_Unicode *)c;
1556 b = buf;
1557 while ((cc < ce) && (*cc != 0x0))
1558 {
1559 *b = *cc;
1560 b++;
1561 cc++;
1562 }
1563 *b = 0;
1564 if (*cc == 0x0) cc++;
1565 else return -2;
1566 // commands are stored in the buffer, 0 bytes not allowd (end marker)
1567 s = eina_unicode_unicode_to_utf8(buf, &slen);
1568 ty->cur_cmd = s;
1569 if (ty->cb.command.func) ty->cb.command.func(ty->cb.command.data);
1570 ty->cur_cmd = NULL;
1571 if (s) free(s);
1572 return cc - c;
1573}
1574
1575static int
1576_handle_esc(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
1521{ 1577{
1522 if ((ce - c) < 2) return 0; 1578 if ((ce - c) < 2) return 0;
1523 DBG("ESC: '%c'", c[1]); 1579 DBG("ESC: '%c'", c[1]);
@@ -1527,6 +1583,8 @@ _handle_esc(Termpty *ty, const int *c, int *ce)
1527 return 2 + _handle_esc_csi(ty, c + 2, ce); 1583 return 2 + _handle_esc_csi(ty, c + 2, ce);
1528 case ']': 1584 case ']':
1529 return 2 + _handle_esc_xterm(ty, c + 2, ce); 1585 return 2 + _handle_esc_xterm(ty, c + 2, ce);
1586 case '}':
1587 return 2 + _handle_esc_terminology(ty, c + 2, ce);
1530 case '=': // set alternate keypad mode 1588 case '=': // set alternate keypad mode
1531 ty->state.alt_kp = 1; 1589 ty->state.alt_kp = 1;
1532 return 2; 1590 return 2;
@@ -1626,9 +1684,10 @@ _handle_esc(Termpty *ty, const int *c, int *ce)
1626} 1684}
1627 1685
1628static int 1686static int
1629_handle_seq(Termpty *ty, const int *c, int *ce) 1687_handle_seq(Termpty *ty, Eina_Unicode *c, Eina_Unicode *ce)
1630{ 1688{
1631 int *cc, len = 0; 1689 Eina_Unicode *cc;
1690 int len = 0;
1632 1691
1633/* 1692/*
1634 printf(" B: "); 1693 printf(" B: ");
@@ -1794,9 +1853,10 @@ _handle_seq(Termpty *ty, const int *c, int *ce)
1794} 1853}
1795 1854
1796static void 1855static void
1797_handle_buf(Termpty *ty, const int *codepoints, int len) 1856_handle_buf(Termpty *ty, const Eina_Unicode *codepoints, int len)
1798{ 1857{
1799 int *c, *ce, n, *b, bytes; 1858 Eina_Unicode *c, *ce, *b;
1859 int n, bytes;
1800 1860
1801 c = (int *)codepoints; 1861 c = (int *)codepoints;
1802 ce = &(c[len]); 1862 ce = &(c[len]);
@@ -1810,7 +1870,7 @@ _handle_buf(Termpty *ty, const int *codepoints, int len)
1810 ERR("memerr"); 1870 ERR("memerr");
1811 } 1871 }
1812 INF("realloc add %i + %i", (int)(ty->buflen * sizeof(int)), (int)(len * sizeof(int))); 1872 INF("realloc add %i + %i", (int)(ty->buflen * sizeof(int)), (int)(len * sizeof(int)));
1813 bytes = len * sizeof(int); 1873 bytes = len * sizeof(Eina_Unicode);
1814 memcpy(&(b[ty->buflen]), codepoints, bytes); 1874 memcpy(&(b[ty->buflen]), codepoints, bytes);
1815 ty->buf = b; 1875 ty->buf = b;
1816 ty->buflen += len; 1876 ty->buflen += len;
@@ -1822,11 +1882,11 @@ _handle_buf(Termpty *ty, const int *codepoints, int len)
1822 n = _handle_seq(ty, c, ce); 1882 n = _handle_seq(ty, c, ce);
1823 if (n == 0) 1883 if (n == 0)
1824 { 1884 {
1825 int *tmp = ty->buf; 1885 Eina_Unicode *tmp = ty->buf;
1826 ty->buf = NULL; 1886 ty->buf = NULL;
1827 ty->buflen = 0; 1887 ty->buflen = 0;
1828 bytes = ((char *)ce - (char *)c) + sizeof(int); 1888 bytes = ((char *)ce - (char *)c) + sizeof(Eina_Unicode);
1829 INF("malloc til %i", (int)(bytes - sizeof(int))); 1889 INF("malloc til %i", (int)(bytes - sizeof(Eina_Unicode)));
1830 ty->buf = malloc(bytes); 1890 ty->buf = malloc(bytes);
1831 if (!ty->buf) 1891 if (!ty->buf)
1832 { 1892 {
@@ -1834,7 +1894,7 @@ _handle_buf(Termpty *ty, const int *codepoints, int len)
1834 } 1894 }
1835 bytes = (char *)ce - (char *)c; 1895 bytes = (char *)ce - (char *)c;
1836 memcpy(ty->buf, c, bytes); 1896 memcpy(ty->buf, c, bytes);
1837 ty->buflen = bytes / sizeof(int); 1897 ty->buflen = bytes / sizeof(Eina_Unicode);
1838 ty->buf[ty->buflen] = 0; 1898 ty->buf[ty->buflen] = 0;
1839 free(tmp); 1899 free(tmp);
1840 break; 1900 break;
@@ -1858,16 +1918,16 @@ _handle_buf(Termpty *ty, const int *codepoints, int len)
1858 n = _handle_seq(ty, c, ce); 1918 n = _handle_seq(ty, c, ce);
1859 if (n == 0) 1919 if (n == 0)
1860 { 1920 {
1861 bytes = ((char *)ce - (char *)c) + sizeof(int); 1921 bytes = ((char *)ce - (char *)c) + sizeof(Eina_Unicode);
1862 ty->buf = malloc(bytes); 1922 ty->buf = malloc(bytes);
1863 INF("malloc %i", (int)(bytes - sizeof(int))); 1923 INF("malloc %i", (int)(bytes - sizeof(Eina_Unicode)));
1864 if (!ty->buf) 1924 if (!ty->buf)
1865 { 1925 {
1866 ERR("memerr"); 1926 ERR("memerr");
1867 } 1927 }
1868 bytes = (char *)ce - (char *)c; 1928 bytes = (char *)ce - (char *)c;
1869 memcpy(ty->buf, c, bytes); 1929 memcpy(ty->buf, c, bytes);
1870 ty->buflen = bytes / sizeof(int); 1930 ty->buflen = bytes / sizeof(Eina_Unicode);
1871 ty->buf[ty->buflen] = 0; 1931 ty->buf[ty->buflen] = 0;
1872 break; 1932 break;
1873 } 1933 }
@@ -1906,7 +1966,7 @@ _cb_fd_read(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__)
1906{ 1966{
1907 Termpty *ty = data; 1967 Termpty *ty = data;
1908 char buf[4097]; 1968 char buf[4097];
1909 int codepoint[4097]; 1969 Eina_Unicode codepoint[4097];
1910 int len, i, j, reads; 1970 int len, i, j, reads;
1911 1971
1912 // read up to 64 * 4096 bytes 1972 // read up to 64 * 4096 bytes
diff --git a/src/bin/termpty.h b/src/bin/termpty.h
index 05f4995..e531dcc 100644
--- a/src/bin/termpty.h
+++ b/src/bin/termpty.h
@@ -90,7 +90,7 @@ struct _Termpty
90 struct { 90 struct {
91 void (*func) (void *data); 91 void (*func) (void *data);
92 void *data; 92 void *data;
93 } change, scroll, set_title, set_icon, cancel_sel, exited, bell; 93 } change, scroll, set_title, set_icon, cancel_sel, exited, bell, command;
94 } cb; 94 } cb;
95 struct { 95 struct {
96 const char *title; 96 const char *title;
@@ -99,6 +99,7 @@ struct _Termpty
99 int w, h; 99 int w, h;
100 int fd, slavefd; 100 int fd, slavefd;
101 pid_t pid; 101 pid_t pid;
102 const char *cur_cmd;
102 Termcell *screen, *screen2; 103 Termcell *screen, *screen2;
103 Termsave **back; 104 Termsave **back;
104 int backmax, backpos; 105 int backmax, backpos;