summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2013-01-29 00:43:13 +0000
committerCarsten Haitzler <raster@rasterman.com>2013-01-29 00:43:13 +0000
commit3b9b38b86c7b553b67e7626486686dd29b752bc3 (patch)
treea72745222bd037491341161666d85f44148993ab /src/bin
parentc4ad6c9c942be93e2a9b3bf98201c36da482c54e (diff)
make block insert allow the inserter to specify a character to replace
on insert. this allows multiple insertions to be "active simultaneously". until all the inset chars are used up. need to wrap these insert chars with begin/end escapes still for efficiency and so you can use insert chars elsewhere in the same text output area. also clean up warnings. SVN revision: 83394
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/col.c2
-rw-r--r--src/bin/config.c1
-rw-r--r--src/bin/controls.c2
-rw-r--r--src/bin/main.c9
-rw-r--r--src/bin/termio.c61
-rw-r--r--src/bin/termpty.c24
-rw-r--r--src/bin/termpty.h14
-rw-r--r--src/bin/termptyesc.c54
-rw-r--r--src/bin/tycat.c31
9 files changed, 117 insertions, 81 deletions
diff --git a/src/bin/col.c b/src/bin/col.c
index e13e04c..8f16b8f 100644
--- a/src/bin/col.c
+++ b/src/bin/col.c
@@ -396,7 +396,7 @@ static const Color colors256[256] =
396 396
397void colors_term_init(Evas_Object *textgrid, Evas_Object *bg) 397void colors_term_init(Evas_Object *textgrid, Evas_Object *bg)
398{ 398{
399 int c, n, l, k, j, i; 399 int c, n;
400 int r, g, b, a; 400 int r, g, b, a;
401 char buf[32]; 401 char buf[32];
402 402
diff --git a/src/bin/config.c b/src/bin/config.c
index 0fabead..f415162 100644
--- a/src/bin/config.c
+++ b/src/bin/config.c
@@ -3,6 +3,7 @@
3#include <Elementary.h> 3#include <Elementary.h>
4#include <Efreet.h> 4#include <Efreet.h>
5#include "config.h" 5#include "config.h"
6#include "main.h"
6 7
7#define CONF_VER 1 8#define CONF_VER 1
8 9
diff --git a/src/bin/controls.c b/src/bin/controls.c
index edf2674..73b30a4 100644
--- a/src/bin/controls.c
+++ b/src/bin/controls.c
@@ -75,7 +75,7 @@ _cb_ct_about(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __U
75} 75}
76 76
77static void 77static void
78_cb_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *ev __UNUSED__) 78_cb_mouse_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *ev __UNUSED__)
79{ 79{
80 controls_toggle(ct_win, ct_bg, ct_term); 80 controls_toggle(ct_win, ct_bg, ct_term);
81} 81}
diff --git a/src/bin/main.c b/src/bin/main.c
index 7b33a9b..7b11919 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -5,6 +5,7 @@
5#include "main.h" 5#include "main.h"
6#include "win.h" 6#include "win.h"
7#include "termio.h" 7#include "termio.h"
8#include "termpty.h"
8#include "termcmd.h" 9#include "termcmd.h"
9#include "config.h" 10#include "config.h"
10#include "controls.h" 11#include "controls.h"
@@ -859,9 +860,9 @@ _cb_next(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
859} 860}
860 861
861static void 862static void
862_cb_new(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__) 863_cb_new(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
863{ 864{
864 Term *term = data; 865// Term *term = data;
865} 866}
866 867
867static void 868static void
@@ -963,13 +964,15 @@ _cb_cmd_changed(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
963 char *cmd; 964 char *cmd;
964 Term *term; 965 Term *term;
965 966
967 term = main_win_focused_term_get(wn);
968 if (!term) return;
966 cmd = (char *)elm_entry_entry_get(wn->cmdbox); 969 cmd = (char *)elm_entry_entry_get(wn->cmdbox);
967 if (cmd) 970 if (cmd)
968 { 971 {
969 cmd = elm_entry_markup_to_utf8(cmd); 972 cmd = elm_entry_markup_to_utf8(cmd);
970 if (cmd) 973 if (cmd)
971 { 974 {
972 if (term) termcmd_watch(term->term, term->wn->win, term->bg, cmd); 975 termcmd_watch(term->term, term->wn->win, term->bg, cmd);
973 free(cmd); 976 free(cmd);
974 } 977 }
975 } 978 }
diff --git a/src/bin/termio.c b/src/bin/termio.c
index 585fc15..64bf3a9 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -1924,7 +1924,7 @@ _smart_cb_mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
1924{ 1924{
1925 Evas_Event_Mouse_Up *ev = event; 1925 Evas_Event_Mouse_Up *ev = event;
1926 Termio *sd; 1926 Termio *sd;
1927 int cx, cy, dx, dy, f; 1927 int cx, cy;
1928 1928
1929 sd = evas_object_smart_data_get(data); 1929 sd = evas_object_smart_data_get(data);
1930 if (!sd) return; 1930 if (!sd) return;
@@ -2269,7 +2269,6 @@ _smart_add(Evas_Object *obj)
2269{ 2269{
2270 Termio *sd; 2270 Termio *sd;
2271 Evas_Object *o; 2271 Evas_Object *o;
2272 int i, j, k, l, n;
2273 2272
2274 sd = calloc(1, sizeof(Termio)); 2273 sd = calloc(1, sizeof(Termio));
2275 EINA_SAFETY_ON_NULL_RETURN(sd); 2274 EINA_SAFETY_ON_NULL_RETURN(sd);
@@ -2610,43 +2609,47 @@ _smart_pty_command(void *data)
2610 (sd->pty->cur_cmd[1] == 'f')) 2609 (sd->pty->cur_cmd[1] == 'f'))
2611 { 2610 {
2612 const char *p, *p0, *path; 2611 const char *p, *p0, *path;
2613 int ww = 0, hh = 0; 2612 int ww = 0, hh = 0, repch;
2614 2613
2615 // exact size in CHAR CELLS - WW (decimal) width CELLS, 2614 // exact size in CHAR CELLS - WW (decimal) width CELLS,
2616 // HH (decimal) in CELLS. 2615 // HH (decimal) in CELLS.
2617 // 2616 //
2618 // isWW;HH;PATH 2617 // isCWW;HH;PATH
2619 for (p0 = p = &(sd->pty->cur_cmd[2]); *p; p++) 2618 repch = sd->pty->cur_cmd[2];
2619 if (repch)
2620 { 2620 {
2621 if (*p == ';') 2621 for (p0 = p = &(sd->pty->cur_cmd[3]); *p; p++)
2622 { 2622 {
2623 ww = strtol(p0, NULL, 10); 2623 if (*p == ';')
2624 p++; 2624 {
2625 break; 2625 ww = strtol(p0, NULL, 10);
2626 p++;
2627 break;
2628 }
2626 } 2629 }
2627 } 2630 for (p0 = p; *p; p++)
2628 for (p0 = p; *p; p++)
2629 {
2630 if (*p == ';')
2631 { 2631 {
2632 hh = strtol(p0, NULL, 10); 2632 if (*p == ';')
2633 p++; 2633 {
2634 break; 2634 hh = strtol(p0, NULL, 10);
2635 p++;
2636 break;
2637 }
2635 } 2638 }
2636 } 2639 path = p;
2637 path = p; 2640 if ((ww < 512) && (hh < 512))
2638 if ((ww < 512) && (hh < 512))
2639 {
2640 Termblock *blk = termpty_block_new(sd->pty, ww, hh, path);
2641 if (blk)
2642 { 2641 {
2643 if (sd->pty->cur_cmd[1] == 's') 2642 Termblock *blk = termpty_block_new(sd->pty, ww, hh, path);
2644 blk->scale_stretch = EINA_TRUE; 2643 if (blk)
2645 else if (sd->pty->cur_cmd[1] == 'c') 2644 {
2646 blk->scale_center = EINA_TRUE; 2645 if (sd->pty->cur_cmd[1] == 's')
2647 else if (sd->pty->cur_cmd[1] == 'f') 2646 blk->scale_stretch = EINA_TRUE;
2648 blk->scale_fill = EINA_TRUE; 2647 else if (sd->pty->cur_cmd[1] == 'c')
2649 termpty_block_insert(sd->pty, blk); 2648 blk->scale_center = EINA_TRUE;
2649 else if (sd->pty->cur_cmd[1] == 'f')
2650 blk->scale_fill = EINA_TRUE;
2651 termpty_block_insert(sd->pty, repch, blk);
2652 }
2650 } 2653 }
2651 } 2654 }
2652 return; 2655 return;
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index 77402d6..3d97c3c 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -377,6 +377,9 @@ err:
377void 377void
378termpty_free(Termpty *ty) 378termpty_free(Termpty *ty)
379{ 379{
380 Termexp *ex;
381
382 EINA_LIST_FREE(ty->block.expecting, ex) free(ex);
380 if (ty->block.blocks) eina_hash_free(ty->block.blocks); 383 if (ty->block.blocks) eina_hash_free(ty->block.blocks);
381 if (ty->block.active) eina_list_free(ty->block.active); 384 if (ty->block.active) eina_list_free(ty->block.active);
382 if (ty->fd >= 0) close(ty->fd); 385 if (ty->fd >= 0) close(ty->fd);
@@ -589,7 +592,7 @@ termpty_block_new(Termpty *ty, int w, int h, const char *path)
589} 592}
590 593
591void 594void
592termpty_block_insert(Termpty *ty, Termblock *blk) 595termpty_block_insert(Termpty *ty, int ch, Termblock *blk)
593{ 596{
594 // bit 0-8 = y (9b 0->511) 597 // bit 0-8 = y (9b 0->511)
595 // bit 9-17 = x (9b 0->511) 598 // bit 9-17 = x (9b 0->511)
@@ -599,13 +602,18 @@ termpty_block_insert(Termpty *ty, Termblock *blk)
599 // fg/bg = 8+8bit unused. (use for extra id bits? so 16 + 13 == 29bit?) 602 // fg/bg = 8+8bit unused. (use for extra id bits? so 16 + 13 == 29bit?)
600 // 603 //
601 // cp = (1 << 31) | ((id 0x1fff) << 18) | ((x & 0x1ff) << 9) | (y & 0x1ff); 604 // cp = (1 << 31) | ((id 0x1fff) << 18) | ((x & 0x1ff) << 9) | (y & 0x1ff);
602 605 Termexp *ex;
603 ty->block.expecting.left = blk->w * blk->h; 606
604 ty->block.expecting.x = 0; 607 ex = calloc(1, sizeof(Termexp));
605 ty->block.expecting.y = 0; 608 if (!ex) return;
606 ty->block.expecting.id = blk->id; 609 ex->ch = ch;
607 ty->block.expecting.w = blk->w; 610 ex->left = blk->w * blk->h;
608 ty->block.expecting.h = blk->h; 611 ex->x = 0;
612 ex->y = 0;
613 ex->id = blk->id;
614 ex->w = blk->w;
615 ex->h = blk->h;
616 ty->block.expecting = eina_list_append(ty->block.expecting, ex);
609} 617}
610 618
611int 619int
diff --git a/src/bin/termpty.h b/src/bin/termpty.h
index 54f93ad..e5a7049 100644
--- a/src/bin/termpty.h
+++ b/src/bin/termpty.h
@@ -4,6 +4,7 @@ typedef struct _Termatt Termatt;
4typedef struct _Termstate Termstate; 4typedef struct _Termstate Termstate;
5typedef struct _Termsave Termsave; 5typedef struct _Termsave Termsave;
6typedef struct _Termblock Termblock; 6typedef struct _Termblock Termblock;
7typedef struct _Termexp Termexp;
7 8
8#define COL_DEF 0 9#define COL_DEF 0
9#define COL_BLACK 1 10#define COL_BLACK 1
@@ -113,10 +114,7 @@ struct _Termpty
113 int curid; 114 int curid;
114 Eina_Hash *blocks; 115 Eina_Hash *blocks;
115 Eina_List *active; 116 Eina_List *active;
116 struct { 117 Eina_List *expecting;
117 int left, id;
118 int x, y, w, h;
119 } expecting;
120 } block; 118 } block;
121 Termstate state, save, swap; 119 Termstate state, save, swap;
122 int exit_code; 120 int exit_code;
@@ -155,6 +153,12 @@ struct _Termblock
155 Eina_Bool was_active_before : 1; 153 Eina_Bool was_active_before : 1;
156}; 154};
157 155
156struct _Termexp
157{
158 int ch, left, id;
159 int x, y, w, h;
160};
161
158void termpty_init(void); 162void termpty_init(void);
159void termpty_shutdown(void); 163void termpty_shutdown(void);
160 164
@@ -168,7 +172,7 @@ void termpty_backscroll_set(Termpty *ty, int size);
168pid_t termpty_pid_get(const Termpty *ty); 172pid_t termpty_pid_get(const Termpty *ty);
169void termpty_block_free(Termblock *tb); 173void termpty_block_free(Termblock *tb);
170Termblock *termpty_block_new(Termpty *ty, int w, int h, const char *path); 174Termblock *termpty_block_new(Termpty *ty, int w, int h, const char *path);
171void termpty_block_insert(Termpty *ty, Termblock *blk); 175void termpty_block_insert(Termpty *ty, int ch, Termblock *blk);
172int termpty_block_id_get(Termcell *cell, int *x, int *y); 176int termpty_block_id_get(Termcell *cell, int *x, int *y);
173Termblock *termpty_block_get(Termpty *ty, int id); 177Termblock *termpty_block_get(Termpty *ty, int id);
174 178
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index ce0d5b3..c0620ed 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -1304,38 +1304,48 @@ _termpty_handle_seq(Termpty *ty, Eina_Unicode *c, Eina_Unicode *ce)
1304 } 1304 }
1305 else if (c[0] == 0x9b) // ANSI ESC!!! 1305 else if (c[0] == 0x9b) // ANSI ESC!!!
1306 { 1306 {
1307 printf("ANSI CSI!!!!!\n"); 1307 DBG("ANSI CSI!!!!!");
1308 ty->state.had_cr = 0; 1308 ty->state.had_cr = 0;
1309 len = _handle_esc_csi(ty, c + 1, ce); 1309 len = _handle_esc_csi(ty, c + 1, ce);
1310 if (len == 0) return 0; 1310 if (len == 0) return 0;
1311 return 1 + len; 1311 return 1 + len;
1312 } 1312 }
1313 else if (ty->block.expecting.left > 0) 1313 else if (ty->block.expecting)
1314 { 1314 {
1315 if (c[0] == '#') 1315 Termexp *ex;
1316 Eina_List *l;
1317
1318 EINA_LIST_FOREACH(ty->block.expecting, l, ex)
1316 { 1319 {
1317 Eina_Unicode cp; 1320 if (c[0] == ex->ch)
1318
1319 cp = (1 << 31) |
1320 ((ty->block.expecting.id & 0x1fff) << 18) |
1321 ((ty->block.expecting.x & 0x1ff) << 9) |
1322 (ty->block.expecting.y & 0x1ff);
1323 ty->block.expecting.x++;
1324 if (ty->block.expecting.x >= ty->block.expecting.w)
1325 { 1321 {
1326 ty->block.expecting.x = 0; 1322 Eina_Unicode cp;
1327 ty->block.expecting.y++; 1323
1324 cp = (1 << 31) | ((ex->id & 0x1fff) << 18) |
1325 ((ex->x & 0x1ff) << 9) | (ex->y & 0x1ff);
1326 ex->x++;
1327 if (ex->x >= ex->w)
1328 {
1329 ex->x = 0;
1330 ex->y++;
1331 }
1332 ex->left--;
1333 _termpty_text_append(ty, &cp, 1);
1334 if (ex->left <= 0)
1335 {
1336 ty->block.expecting =
1337 eina_list_remove_list(ty->block.expecting, l);
1338 free(ex);
1339 }
1340 else
1341 ty->block.expecting =
1342 eina_list_promote_list(ty->block.expecting, l);
1343 return 1;
1328 } 1344 }
1329 ty->block.expecting.left--;
1330 _termpty_text_append(ty, &cp, 1);
1331 return 1;
1332 }
1333 else
1334 {
1335 _termpty_text_append(ty, c, 1);
1336 ty->state.had_cr = 0;
1337 return 1;
1338 } 1345 }
1346 _termpty_text_append(ty, c, 1);
1347 ty->state.had_cr = 0;
1348 return 1;
1339 } 1349 }
1340 cc = (int *)c; 1350 cc = (int *)c;
1341 DBG("txt: ["); 1351 DBG("txt: [");
diff --git a/src/bin/tycat.c b/src/bin/tycat.c
index 68deb27..ba0627f 100644
--- a/src/bin/tycat.c
+++ b/src/bin/tycat.c
@@ -71,7 +71,7 @@ main(int argc, char **argv)
71 o = evas_object_image_add(evas); 71 o = evas_object_image_add(evas);
72 echo_off(); 72 echo_off();
73 snprintf(buf, sizeof(buf), "%c}qs", 0x1b); 73 snprintf(buf, sizeof(buf), "%c}qs", 0x1b);
74 write(0, buf, strlen(buf) + 1); 74 if (write(0, buf, strlen(buf) + 1) < 0) perror("write");
75 if (scanf("%i;%i;%i;%i", &tw, &th, &cw, &ch) != 4) 75 if (scanf("%i;%i;%i;%i", &tw, &th, &cw, &ch) != 4)
76 { 76 {
77 echo_on(); 77 echo_on();
@@ -110,8 +110,9 @@ main(int argc, char **argv)
110 if ((w >= 0) && (h > 0)) 110 if ((w >= 0) && (h > 0))
111 { 111 {
112 int x, y; 112 int x, y;
113 char *line;
113 114
114 if ((tw <= 0) || (th <= 0) || (cw <= 1) || (ch <= 1)) 115 if ((tw <= 0) || (th <= 0) || (cw <= 1) || (ch <= 1))
115 { 116 {
116 free(rp); 117 free(rp);
117 continue; 118 continue;
@@ -126,24 +127,30 @@ main(int argc, char **argv)
126 iw = (w + (cw - 1)) / cw; 127 iw = (w + (cw - 1)) / cw;
127 ih = (h + (ch - 1)) / ch; 128 ih = (h + (ch - 1)) / ch;
128 } 129 }
129 if (mode == CENTER) 130 line = malloc(iw + 2);
130 snprintf(buf, sizeof(buf), "%c}ic%i;%i;%s", 131 if (!line)
132 {
133 free(rp);
134 continue;
135 }
136 if (mode == CENTER)
137 snprintf(buf, sizeof(buf), "%c}ic#%i;%i;%s",
131 0x1b, iw, ih, rp); 138 0x1b, iw, ih, rp);
132 else if (mode == FILL) 139 else if (mode == FILL)
133 snprintf(buf, sizeof(buf), "%c}if%i;%i;%s", 140 snprintf(buf, sizeof(buf), "%c}if#%i;%i;%s",
134 0x1b, iw, ih, rp); 141 0x1b, iw, ih, rp);
135 else 142 else
136 snprintf(buf, sizeof(buf), "%c}is%i;%i;%s", 143 snprintf(buf, sizeof(buf), "%c}is#%i;%i;%s",
137 0x1b, iw, ih, rp); 144 0x1b, iw, ih, rp);
138 write(0, buf, strlen(buf) + 1); 145 if (write(0, buf, strlen(buf) + 1) < 0) perror("write");
146 for (x = 0; x < iw; x++) line[x] = '#';
147 line[x++] = '\n';
148 line[x++] = 0;
139 for (y = 0; y < ih; y++) 149 for (y = 0; y < ih; y++)
140 { 150 {
141 for (x = 0; x < iw; x++) 151 if (write(0, line, iw + 1) < 0) perror("write");
142 {
143 write(0, "#", 1);
144 }
145 write(0, "\n", 1);
146 } 152 }
153 free(line);
147 } 154 }
148 free(rp); 155 free(rp);
149 } 156 }