forked from enlightenment/terminology
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
This commit is contained in:
parent
c4ad6c9c94
commit
3b9b38b86c
|
@ -396,7 +396,7 @@ static const Color colors256[256] =
|
|||
|
||||
void colors_term_init(Evas_Object *textgrid, Evas_Object *bg)
|
||||
{
|
||||
int c, n, l, k, j, i;
|
||||
int c, n;
|
||||
int r, g, b, a;
|
||||
char buf[32];
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <Elementary.h>
|
||||
#include <Efreet.h>
|
||||
#include "config.h"
|
||||
#include "main.h"
|
||||
|
||||
#define CONF_VER 1
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ _cb_ct_about(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __U
|
|||
}
|
||||
|
||||
static void
|
||||
_cb_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *ev __UNUSED__)
|
||||
_cb_mouse_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *ev __UNUSED__)
|
||||
{
|
||||
controls_toggle(ct_win, ct_bg, ct_term);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "main.h"
|
||||
#include "win.h"
|
||||
#include "termio.h"
|
||||
#include "termpty.h"
|
||||
#include "termcmd.h"
|
||||
#include "config.h"
|
||||
#include "controls.h"
|
||||
|
@ -859,9 +860,9 @@ _cb_next(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
|
|||
}
|
||||
|
||||
static void
|
||||
_cb_new(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
|
||||
_cb_new(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
|
||||
{
|
||||
Term *term = data;
|
||||
// Term *term = data;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -963,13 +964,15 @@ _cb_cmd_changed(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
|
|||
char *cmd;
|
||||
Term *term;
|
||||
|
||||
term = main_win_focused_term_get(wn);
|
||||
if (!term) return;
|
||||
cmd = (char *)elm_entry_entry_get(wn->cmdbox);
|
||||
if (cmd)
|
||||
{
|
||||
cmd = elm_entry_markup_to_utf8(cmd);
|
||||
if (cmd)
|
||||
{
|
||||
if (term) termcmd_watch(term->term, term->wn->win, term->bg, cmd);
|
||||
termcmd_watch(term->term, term->wn->win, term->bg, cmd);
|
||||
free(cmd);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1924,7 +1924,7 @@ _smart_cb_mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
|
|||
{
|
||||
Evas_Event_Mouse_Up *ev = event;
|
||||
Termio *sd;
|
||||
int cx, cy, dx, dy, f;
|
||||
int cx, cy;
|
||||
|
||||
sd = evas_object_smart_data_get(data);
|
||||
if (!sd) return;
|
||||
|
@ -2269,7 +2269,6 @@ _smart_add(Evas_Object *obj)
|
|||
{
|
||||
Termio *sd;
|
||||
Evas_Object *o;
|
||||
int i, j, k, l, n;
|
||||
|
||||
sd = calloc(1, sizeof(Termio));
|
||||
EINA_SAFETY_ON_NULL_RETURN(sd);
|
||||
|
@ -2610,43 +2609,47 @@ _smart_pty_command(void *data)
|
|||
(sd->pty->cur_cmd[1] == 'f'))
|
||||
{
|
||||
const char *p, *p0, *path;
|
||||
int ww = 0, hh = 0;
|
||||
int ww = 0, hh = 0, repch;
|
||||
|
||||
// exact size in CHAR CELLS - WW (decimal) width CELLS,
|
||||
// HH (decimal) in CELLS.
|
||||
//
|
||||
// isWW;HH;PATH
|
||||
for (p0 = p = &(sd->pty->cur_cmd[2]); *p; p++)
|
||||
// isCWW;HH;PATH
|
||||
repch = sd->pty->cur_cmd[2];
|
||||
if (repch)
|
||||
{
|
||||
if (*p == ';')
|
||||
for (p0 = p = &(sd->pty->cur_cmd[3]); *p; p++)
|
||||
{
|
||||
ww = strtol(p0, NULL, 10);
|
||||
p++;
|
||||
break;
|
||||
if (*p == ';')
|
||||
{
|
||||
ww = strtol(p0, NULL, 10);
|
||||
p++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (p0 = p; *p; p++)
|
||||
{
|
||||
if (*p == ';')
|
||||
for (p0 = p; *p; p++)
|
||||
{
|
||||
hh = strtol(p0, NULL, 10);
|
||||
p++;
|
||||
break;
|
||||
if (*p == ';')
|
||||
{
|
||||
hh = strtol(p0, NULL, 10);
|
||||
p++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
path = p;
|
||||
if ((ww < 512) && (hh < 512))
|
||||
{
|
||||
Termblock *blk = termpty_block_new(sd->pty, ww, hh, path);
|
||||
if (blk)
|
||||
path = p;
|
||||
if ((ww < 512) && (hh < 512))
|
||||
{
|
||||
if (sd->pty->cur_cmd[1] == 's')
|
||||
blk->scale_stretch = EINA_TRUE;
|
||||
else if (sd->pty->cur_cmd[1] == 'c')
|
||||
blk->scale_center = EINA_TRUE;
|
||||
else if (sd->pty->cur_cmd[1] == 'f')
|
||||
blk->scale_fill = EINA_TRUE;
|
||||
termpty_block_insert(sd->pty, blk);
|
||||
Termblock *blk = termpty_block_new(sd->pty, ww, hh, path);
|
||||
if (blk)
|
||||
{
|
||||
if (sd->pty->cur_cmd[1] == 's')
|
||||
blk->scale_stretch = EINA_TRUE;
|
||||
else if (sd->pty->cur_cmd[1] == 'c')
|
||||
blk->scale_center = EINA_TRUE;
|
||||
else if (sd->pty->cur_cmd[1] == 'f')
|
||||
blk->scale_fill = EINA_TRUE;
|
||||
termpty_block_insert(sd->pty, repch, blk);
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -377,6 +377,9 @@ err:
|
|||
void
|
||||
termpty_free(Termpty *ty)
|
||||
{
|
||||
Termexp *ex;
|
||||
|
||||
EINA_LIST_FREE(ty->block.expecting, ex) free(ex);
|
||||
if (ty->block.blocks) eina_hash_free(ty->block.blocks);
|
||||
if (ty->block.active) eina_list_free(ty->block.active);
|
||||
if (ty->fd >= 0) close(ty->fd);
|
||||
|
@ -589,7 +592,7 @@ termpty_block_new(Termpty *ty, int w, int h, const char *path)
|
|||
}
|
||||
|
||||
void
|
||||
termpty_block_insert(Termpty *ty, Termblock *blk)
|
||||
termpty_block_insert(Termpty *ty, int ch, Termblock *blk)
|
||||
{
|
||||
// bit 0-8 = y (9b 0->511)
|
||||
// bit 9-17 = x (9b 0->511)
|
||||
|
@ -599,13 +602,18 @@ termpty_block_insert(Termpty *ty, Termblock *blk)
|
|||
// fg/bg = 8+8bit unused. (use for extra id bits? so 16 + 13 == 29bit?)
|
||||
//
|
||||
// cp = (1 << 31) | ((id 0x1fff) << 18) | ((x & 0x1ff) << 9) | (y & 0x1ff);
|
||||
|
||||
ty->block.expecting.left = blk->w * blk->h;
|
||||
ty->block.expecting.x = 0;
|
||||
ty->block.expecting.y = 0;
|
||||
ty->block.expecting.id = blk->id;
|
||||
ty->block.expecting.w = blk->w;
|
||||
ty->block.expecting.h = blk->h;
|
||||
Termexp *ex;
|
||||
|
||||
ex = calloc(1, sizeof(Termexp));
|
||||
if (!ex) return;
|
||||
ex->ch = ch;
|
||||
ex->left = blk->w * blk->h;
|
||||
ex->x = 0;
|
||||
ex->y = 0;
|
||||
ex->id = blk->id;
|
||||
ex->w = blk->w;
|
||||
ex->h = blk->h;
|
||||
ty->block.expecting = eina_list_append(ty->block.expecting, ex);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -4,6 +4,7 @@ typedef struct _Termatt Termatt;
|
|||
typedef struct _Termstate Termstate;
|
||||
typedef struct _Termsave Termsave;
|
||||
typedef struct _Termblock Termblock;
|
||||
typedef struct _Termexp Termexp;
|
||||
|
||||
#define COL_DEF 0
|
||||
#define COL_BLACK 1
|
||||
|
@ -113,10 +114,7 @@ struct _Termpty
|
|||
int curid;
|
||||
Eina_Hash *blocks;
|
||||
Eina_List *active;
|
||||
struct {
|
||||
int left, id;
|
||||
int x, y, w, h;
|
||||
} expecting;
|
||||
Eina_List *expecting;
|
||||
} block;
|
||||
Termstate state, save, swap;
|
||||
int exit_code;
|
||||
|
@ -155,6 +153,12 @@ struct _Termblock
|
|||
Eina_Bool was_active_before : 1;
|
||||
};
|
||||
|
||||
struct _Termexp
|
||||
{
|
||||
int ch, left, id;
|
||||
int x, y, w, h;
|
||||
};
|
||||
|
||||
void termpty_init(void);
|
||||
void termpty_shutdown(void);
|
||||
|
||||
|
@ -168,7 +172,7 @@ void termpty_backscroll_set(Termpty *ty, int size);
|
|||
pid_t termpty_pid_get(const Termpty *ty);
|
||||
void termpty_block_free(Termblock *tb);
|
||||
Termblock *termpty_block_new(Termpty *ty, int w, int h, const char *path);
|
||||
void termpty_block_insert(Termpty *ty, Termblock *blk);
|
||||
void termpty_block_insert(Termpty *ty, int ch, Termblock *blk);
|
||||
int termpty_block_id_get(Termcell *cell, int *x, int *y);
|
||||
Termblock *termpty_block_get(Termpty *ty, int id);
|
||||
|
||||
|
|
|
@ -1304,38 +1304,48 @@ _termpty_handle_seq(Termpty *ty, Eina_Unicode *c, Eina_Unicode *ce)
|
|||
}
|
||||
else if (c[0] == 0x9b) // ANSI ESC!!!
|
||||
{
|
||||
printf("ANSI CSI!!!!!\n");
|
||||
DBG("ANSI CSI!!!!!");
|
||||
ty->state.had_cr = 0;
|
||||
len = _handle_esc_csi(ty, c + 1, ce);
|
||||
if (len == 0) return 0;
|
||||
return 1 + len;
|
||||
}
|
||||
else if (ty->block.expecting.left > 0)
|
||||
else if (ty->block.expecting)
|
||||
{
|
||||
if (c[0] == '#')
|
||||
Termexp *ex;
|
||||
Eina_List *l;
|
||||
|
||||
EINA_LIST_FOREACH(ty->block.expecting, l, ex)
|
||||
{
|
||||
Eina_Unicode cp;
|
||||
|
||||
cp = (1 << 31) |
|
||||
((ty->block.expecting.id & 0x1fff) << 18) |
|
||||
((ty->block.expecting.x & 0x1ff) << 9) |
|
||||
(ty->block.expecting.y & 0x1ff);
|
||||
ty->block.expecting.x++;
|
||||
if (ty->block.expecting.x >= ty->block.expecting.w)
|
||||
if (c[0] == ex->ch)
|
||||
{
|
||||
ty->block.expecting.x = 0;
|
||||
ty->block.expecting.y++;
|
||||
Eina_Unicode cp;
|
||||
|
||||
cp = (1 << 31) | ((ex->id & 0x1fff) << 18) |
|
||||
((ex->x & 0x1ff) << 9) | (ex->y & 0x1ff);
|
||||
ex->x++;
|
||||
if (ex->x >= ex->w)
|
||||
{
|
||||
ex->x = 0;
|
||||
ex->y++;
|
||||
}
|
||||
ex->left--;
|
||||
_termpty_text_append(ty, &cp, 1);
|
||||
if (ex->left <= 0)
|
||||
{
|
||||
ty->block.expecting =
|
||||
eina_list_remove_list(ty->block.expecting, l);
|
||||
free(ex);
|
||||
}
|
||||
else
|
||||
ty->block.expecting =
|
||||
eina_list_promote_list(ty->block.expecting, l);
|
||||
return 1;
|
||||
}
|
||||
ty->block.expecting.left--;
|
||||
_termpty_text_append(ty, &cp, 1);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_termpty_text_append(ty, c, 1);
|
||||
ty->state.had_cr = 0;
|
||||
return 1;
|
||||
}
|
||||
_termpty_text_append(ty, c, 1);
|
||||
ty->state.had_cr = 0;
|
||||
return 1;
|
||||
}
|
||||
cc = (int *)c;
|
||||
DBG("txt: [");
|
||||
|
|
|
@ -71,7 +71,7 @@ main(int argc, char **argv)
|
|||
o = evas_object_image_add(evas);
|
||||
echo_off();
|
||||
snprintf(buf, sizeof(buf), "%c}qs", 0x1b);
|
||||
write(0, buf, strlen(buf) + 1);
|
||||
if (write(0, buf, strlen(buf) + 1) < 0) perror("write");
|
||||
if (scanf("%i;%i;%i;%i", &tw, &th, &cw, &ch) != 4)
|
||||
{
|
||||
echo_on();
|
||||
|
@ -110,8 +110,9 @@ main(int argc, char **argv)
|
|||
if ((w >= 0) && (h > 0))
|
||||
{
|
||||
int x, y;
|
||||
char *line;
|
||||
|
||||
if ((tw <= 0) || (th <= 0) || (cw <= 1) || (ch <= 1))
|
||||
if ((tw <= 0) || (th <= 0) || (cw <= 1) || (ch <= 1))
|
||||
{
|
||||
free(rp);
|
||||
continue;
|
||||
|
@ -126,24 +127,30 @@ main(int argc, char **argv)
|
|||
iw = (w + (cw - 1)) / cw;
|
||||
ih = (h + (ch - 1)) / ch;
|
||||
}
|
||||
if (mode == CENTER)
|
||||
snprintf(buf, sizeof(buf), "%c}ic%i;%i;%s",
|
||||
line = malloc(iw + 2);
|
||||
if (!line)
|
||||
{
|
||||
free(rp);
|
||||
continue;
|
||||
}
|
||||
if (mode == CENTER)
|
||||
snprintf(buf, sizeof(buf), "%c}ic#%i;%i;%s",
|
||||
0x1b, iw, ih, rp);
|
||||
else if (mode == FILL)
|
||||
snprintf(buf, sizeof(buf), "%c}if%i;%i;%s",
|
||||
snprintf(buf, sizeof(buf), "%c}if#%i;%i;%s",
|
||||
0x1b, iw, ih, rp);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "%c}is%i;%i;%s",
|
||||
snprintf(buf, sizeof(buf), "%c}is#%i;%i;%s",
|
||||
0x1b, iw, ih, rp);
|
||||
write(0, buf, strlen(buf) + 1);
|
||||
if (write(0, buf, strlen(buf) + 1) < 0) perror("write");
|
||||
for (x = 0; x < iw; x++) line[x] = '#';
|
||||
line[x++] = '\n';
|
||||
line[x++] = 0;
|
||||
for (y = 0; y < ih; y++)
|
||||
{
|
||||
for (x = 0; x < iw; x++)
|
||||
{
|
||||
write(0, "#", 1);
|
||||
}
|
||||
write(0, "\n", 1);
|
||||
if (write(0, line, iw + 1) < 0) perror("write");
|
||||
}
|
||||
free(line);
|
||||
}
|
||||
free(rp);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue