const char *cmd = NULL;
static Evas_Object *win, *bg, *term;
-static Evas_Object
- *op_frame, *op_box, *op_toolbar, *op_opbox,
+static Evas_Object
+ *op_frame, *op_box, *op_toolbar, *op_opbox,
*op_fontslider, *op_fontlist;
static Eina_Bool op_out = EINA_FALSE;
_cb_size_hint(void *data, Evas *e, Evas_Object *obj, void *event)
{
Evas_Coord mw, mh, rw, rh, w = 0, h = 0;
-
+
evas_object_size_hint_min_get(obj, &mw, &mh);
evas_object_size_hint_request_get(obj, &rw, &rh);
-
+
edje_object_size_min_calc(bg, &w, &h);
evas_object_size_hint_min_set(bg, w, h);
elm_win_size_base_set(win, w - mw, h - mh);
_update_sizing(void)
{
Evas_Coord ow = 0, oh = 0, mw = 1, mh = 1, w, h;
-
+
evas_object_data_del(term, "sizedone");
termio_config_update(term);
evas_object_geometry_get(term, NULL, NULL, &ow, &oh);
char buf[4096], *file, *fname, *s;
Eina_List *files, *fontlist, *l;
Font *f;
-
+
EINA_LIST_FREE(fonts, f)
{
eina_stringshare_del(f->name);
fonthash = NULL;
}
elm_box_clear(op_opbox);
-
+
op_fontslider = o = elm_slider_add(win);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
elm_slider_value_set(o, config->font.size);
elm_box_pack_end(op_opbox, o);
evas_object_show(o);
-
+
evas_object_smart_callback_add(o, "delay,changed",
_cb_op_fontsize_sel, NULL);
-
+
op_fontlist = o = elm_list_add(win);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
-
+
evas_event_freeze(evas_object_evas_get(win));
edje_freeze();
elm_list_item_append(o, f->name, NULL, NULL, _cb_op_font_sel, f);
free(file);
}
-
+
fontlist = evas_font_available_list(evas_object_evas_get(win));
fonthash = eina_hash_string_superfast_new(NULL);
}
if (fontlist)
evas_font_available_list_free(evas_object_evas_get(win), fontlist);
-
+
elm_list_go(o);
-
+
edje_thaw();
evas_event_thaw(evas_object_evas_get(win));
if (!op_frame)
{
Elm_Object_Item *it_fn, *it_th, *it_bh;
-
+
op_frame = o = elm_frame_add(win);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_text_set(o, "Options");
-
+
op_box = o = elm_box_add(win);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
elm_object_content_set(op_frame, o);
evas_object_show(o);
-
+
op_toolbar = o = elm_toolbar_add(win);
elm_object_style_set(o, "item_horizontal");
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
elm_toolbar_select_mode_set(o, ELM_OBJECT_SELECT_MODE_DEFAULT);
elm_toolbar_menu_parent_set(o, win);
elm_toolbar_homogeneous_set(o, EINA_FALSE);
-
+
it_fn = elm_toolbar_item_append(o, "preferences-desktop-font", "Font",
_cb_op_font, NULL);
it_th = elm_toolbar_item_append(o, "preferences-desktop-theme", "Theme",
_cb_op_theme, NULL);
it_bh = elm_toolbar_item_append(o, "system-run", "Behavior",
_cb_op_behavior, NULL);
-
+
elm_box_pack_end(op_box, o);
evas_object_show(o);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(op_box, o);
evas_object_show(o);
-
+
elm_toolbar_item_selected_set(it_fn, EINA_TRUE);
-
+
evas_smart_objects_calculate(evas_object_evas_get(win));
edje_object_part_swallow(bg, "terminology.options", op_frame);
evas_object_show(o);
cmd = argv[i];
}
}
-
+
win = tg_win_add();
bg = o = edje_object_add(evas_object_evas_get(win));
edje_object_file_set(o, buf, "terminology/background");
elm_win_resize_object_add(win, o);
evas_object_show(o);
-
+
term = o = termio_add(win, cmd, 80, 24);
termio_win_set(o, win);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_smart_callback_add(win, "focus,in", _cb_focus_in, term);
evas_object_smart_callback_add(win, "focus,out", _cb_focus_out, term);
_cb_size_hint(win, evas_object_evas_get(win), term, NULL);
-
+
evas_object_show(win);
-
+
elm_run();
elm_shutdown();
config_shutdown();
char txt[8];
if (!sd) return;
evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
-
+
if (sd->grid.array)
{
int i, j, x, y, w;
-
+
i = 0;
for (y = 0; y < sd->grid.h; y++)
{
Termcell *cells;
-
+
w = 0;
cells = termpty_cellrow_get(sd->pty, y - sd->scroll, &w);
j = 0;
{
Evas_Object *bg = sd->grid.array[i].bg;
Evas_Object *tx = sd->grid.array[i].tx;
-
+
if ((!cells) || (x >= w))
{
evas_object_hide(bg);
else
{
Color c1, c2;
-
+
if (cells[j].att.invisible)
{
evas_object_hide(tx);
else
{
int cbd, cbdbg, cfg, cbg;
-
+
// colors
cbd = cells[j].att.bold;
cbdbg = 0;
cfg = cells[j].att.fg;
cbg = cells[j].att.bg;
-
+
if (cells[j].att.inverse)
{
cfg = COL_INVERSE;
// if (cells[j].att.blink2) {}
evas_object_color_set(tx, c1.r, c1.g, c1.b, c1.a);
evas_object_color_set(bg, c2.r, c2.g, c2.b, c2.a);
-
+
// text - convert glyph back to utf8 str seq
if (cells[j].glyph > 0)
{
int g = cells[j].glyph;
-
+
glyph_to_utf8(g, txt);
// special case for whitespace :)
if (cells[j].glyph == ' ')
evas_object_show(sd->cur.obj);
sd->cur.x = sd->pty->state.cx;
sd->cur.y = sd->pty->state.cy;
- evas_object_move(sd->cur.obj,
+ evas_object_move(sd->cur.obj,
ox + (sd->cur.x * sd->font.chw),
oy + (sd->cur.y * sd->font.chh));
if (sd->cur.sel)
{
int x1, y1, x2, y2;
-
+
x1 = sd->cur.sel1.x;
y1 = sd->cur.sel1.y;
x2 = sd->cur.sel2.x;
if ((y1 > y2) || ((y1 == y2) && (x2 < x1)))
{
int t;
-
+
t = x1; x1 = x2; x2 = t;
t = y1; y1 = y2; y2 = t;
}
-
+
if (y2 > y1)
{
evas_object_move(sd->cur.selo1,
(sd->grid.w - x1) * sd->font.chw,
sd->font.chh);
evas_object_show(sd->cur.selo1);
-
+
evas_object_move(sd->cur.selo3,
ox, oy + ((y2 + sd->scroll) * sd->font.chh));
evas_object_resize(sd->cur.selo3,
if (sd->grid.array)
{
int i, x, y;
-
+
i = 0;
for (y = 0; y < sd->grid.h; y++)
{
for (x = 0; x < sd->grid.w; x++)
{
Evas_Object *bg, *tx;
-
+
bg = evas_object_rectangle_add(evas_object_evas_get(obj));
tx = evas_object_text_add(evas_object_evas_get(obj));
evas_object_pass_events_set(bg, EINA_TRUE);
evas_object_resize(sd->cur.obj, sd->font.chw, sd->font.chh);
evas_object_size_hint_min_set(obj, sd->font.chw, sd->font.chh);
printf("req grid %ix%i\n", sd->grid.w, sd->grid.h);
- evas_object_size_hint_request_set(obj,
+ evas_object_size_hint_request_set(obj,
sd->font.chw * sd->grid.w,
sd->font.chh * sd->grid.h);
evas_object_raise(sd->event);
Termio *sd = evas_object_smart_data_get(obj);
Evas_Coord ow = 0, oh = 0;
int w, h;
-
+
if (!sd) return EINA_FALSE;
sd->delayed_size_timer = NULL;
evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
-
+
w = ow / sd->font.chw;
h = oh / sd->font.chh;
_smart_size(obj, w, h, EINA_FALSE);
Termio *sd = evas_object_smart_data_get(obj);
int x1, y1, x2, y2;
char *s;
-
+
if (!sd) return;
x1 = sd->cur.sel1.x;
y1 = sd->cur.sel1.y;
if ((y1 > y2) || ((y1 == y2) && (x2 < x1)))
{
int t;
-
+
t = x1; x1 = x2; x2 = t;
t = y1; y1 = y2; y2 = t;
}
{
Termio *sd = evas_object_smart_data_get(data);
if (!sd) return EINA_FALSE;
-
+
if (ev->format == ELM_SEL_FORMAT_TEXT)
{
if (ev->len > 0)
if (ev->keyname)
{
int by = sd->grid.h - 2;
-
+
if (by < 1) by = 1;
if (!strcmp(ev->keyname, "Prior"))
{
{
Termio *sd;
Evas_Coord ox, oy;
-
+
sd = evas_object_smart_data_get(obj);
if (!sd)
{
evas_object_smart_data_set(obj, sd);
sd->jump_on_change = config->jump_on_change;
-
+
{
Evas_Object *o;
Evas_Coord w = 2, h = 2;
if (h < 1) h = 1;
sd->font.chw = w;
sd->font.chh = h;
-
+
o = evas_object_rectangle_add(evas_object_evas_get(obj));
evas_object_pass_events_set(o, EINA_TRUE);
evas_object_propagate_events_set(o, EINA_FALSE);
evas_object_smart_member_add(o, obj);
sd->cur.selo3 = o;
evas_object_color_set(o, 64, 64, 64, 64);
-
+
o = edje_object_add(evas_object_evas_get(obj));
evas_object_pass_events_set(o, EINA_TRUE);
evas_object_propagate_events_set(o, EINA_FALSE);
sd->event = o;
evas_object_color_set(o, 0, 0, 0, 0);
evas_object_show(o);
-
+
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
_smart_cb_mouse_down, obj);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP,
{
Termio *sd = evas_object_smart_data_get(obj);
Evas_Coord ox, oy, ow, oh;
-
+
if (!sd) return;
evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
if (sd->grid.array)
{
int i, x, y;
-
+
i = 0;
for (y = 0; y < sd->grid.h; y++)
{
}
}
}
- evas_object_move(sd->cur.obj,
+ evas_object_move(sd->cur.obj,
ox + (sd->cur.x * sd->font.chw),
oy + (sd->cur.y * sd->font.chh));
evas_object_move(sd->event, ox, oy);
static void
_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
-{
+{
Termio *sd = evas_object_smart_data_get(obj);
if (!sd) return;
evas_object_smart_changed(obj);
_smart_init(void)
{
static Evas_Smart_Class sc;
-
+
evas_object_smart_clipped_smart_set(&_termio_sc);
sc = _termio_sc;
sc.name = "termio";
if (!sd) return;
if ((!sd->jump_on_change) && // if NOT scroll to bottom on updates
- (sd->scroll > 0))
+ (sd->scroll > 0))
{
// adjust scroll position for added scrollback
sd->scroll++;
EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
e = evas_object_evas_get(parent);
if (!e) return NULL;
-
+
if (!_smart) _smart_init();
obj = evas_object_smart_add(e, _smart);
sd = evas_object_smart_data_get(obj);
Eina_Strbuf *sb;
char *s, txt[8];
int x, y;
-
+
if (!sd) return NULL;
sb = eina_strbuf_new();
for (y = c1y; y <= c2y; y++)
{
Termcell *cells;
int w, last0, v, x1, x2;
-
+
w = 0;
last0 = -1;
cells = termpty_cellrow_get(sd->pty, y - sd->scroll, &w);
eina_strbuf_append(sb, "\n");
}
}
-
+
s = eina_strbuf_string_steal(sb);
eina_strbuf_free(sb);
return s;
Evas_Object *o;
Evas_Coord w, h;
char buf[4096];
-
+
if (!sd) return;
-
+
if (sd->font.name) eina_stringshare_del(sd->font.name);
sd->font.name = NULL;
-
+
if (config->font.bitmap)
{
snprintf(buf, sizeof(buf), "%s/fonts/%s",
else
sd->font.name = eina_stringshare_add(config->font.name);
sd->font.size = config->font.size;
-
+
o = evas_object_text_add(evas_object_evas_get(obj));
evas_object_text_font_set(o, sd->font.name, sd->font.size);
evas_object_text_text_set(o, "X");
{
int i;
Termatt clear;
-
+
memset(&clear, 0, sizeof(clear));
if (inherit_att)
{
_text_save_top(Termpty *ty)
{
Termsave *ts;
-
+
ts = malloc(sizeof(Termsave) + ((ty->w - 1) * sizeof(Termcell)));
ts->w = ty->w;
_text_copy(ty, ty->screen, ts->cell, ty->w);
_text_scroll_test(Termpty *ty)
{
int e = ty->h;
-
+
if (ty->state.scroll_y2 != 0) e = ty->state.scroll_y2;
if (ty->state.cy >= e)
{
_text_scroll_rev_test(Termpty *ty)
{
int b = 0;
-
+
if (ty->state.scroll_y2 != 0) b = ty->state.scroll_y1;
if (ty->state.cy < b)
{
_clear_screen(Termpty *ty, int mode)
{
Termcell *cells;
-
+
cells = ty->screen;
switch (mode)
{
char *b = *ptr;
int octal = 0;
int sum = 0;
-
+
while ((*b) && (!isdigit(*b))) b++;
if (!*b)
{
{
int *cc, arg, first = 1, i;
char buf[4096], *b;
-
+
cc = (int *)c;
b = buf;
while ((cc < ce) && (*cc >= '0') && (*cc <= '?'))
{
int pi = ty->state.insert;
int blank[1] = { ' ' };
-
+
ty->state.wrapnext = 0;
ty->state.insert = 1;
for (i = 0; i < arg; i++)
arg = _csi_arg_get(&b);
{
int sy1, sy2;
-
+
sy1 = ty->state.scroll_y1;
sy2 = ty->state.scroll_y2;
if (ty->state.scroll_y2 == 0)
{
Termcell *cells;
int x, lim;
-
+
if (arg < 1) arg = 1;
cells = &(ty->screen[ty->state.cy * ty->w]);
lim = ty->w - arg;
{
int mode = 0, priv = 0;
int handled = 0;
-
+
if (*cc == 'h') mode = 1;
if (*b == '?')
{
if (b)
{
int i, size;
-
+
switch (arg)
{
case 1:
for (i = 0; i < size; i++)
{
Termcell t;
-
+
t = ty->screen[i];
ty->screen[i] = ty->screen2[i];
ty->screen2[i] = t;
else
{
int arg2;
-
+
arg2 = _csi_arg_get(&b);
if (!b)
{
case 'u': // restore cursor pos
_cursor_copy(&(ty->save), &(ty->state));
break;
-/*
+/*
case 'R': // report cursor
break;
case 'n': // "6n" queires cursor pos, 0n, 3n, 5n too
{
int *cc;
char buf[4096], *b;
-
+
cc = (int *)c;
b = buf;
while ((cc < ce) && (*cc >= ' ') && (*cc < 0x7f))
{
int i, size;
Termcell *cells;
-
+
DBG("reset to init mode and clear then fill with E\n");
_reset_state(ty);
ty->save = ty->state;
case '8': // restore cursor pos
_cursor_copy(&(ty->save), &(ty->state));
return 2;
-/*
+/*
case 'G': // query gfx mode
return 3;
case 'H': // set tab at current column
_handle_seq(Termpty *ty, const int *c, int *ce)
{
int *cc, len = 0;
-
+
if (c[0] < 0x20)
{
switch (c[0])
{
-/*
+/*
case 0x00: // NUL
return 1;
case 0x01: // SOH (start of heading)
_term_txt_write(ty, "ABC\r\n");
ty->state.had_cr = 0;
return 1;
-/*
+/*
case 0x06: // ACK (acknowledge)
return 1;
*/
ty->state.cx = ty->w - 1;
ty->state.had_cr = 0;
return 1;
- case 0x0a: // LF '\n' (new line)
+ case 0x0a: // LF '\n' (new line)
case 0x0b: // VT '\v' (vertical tab)
case 0x0c: // FF '\f' (form feed)
DBG("->LF\n");
ty->state.cx = 0;
ty->state.had_cr = 1;
return 1;
-/*
+/*
case 0x0e: // SO (shift out) // Maps G1 character set into GL.
return 1;
case 0x0f: // SI (shift in) // Maps G0 character set into GL.
case 0x1b: // ESC (escape)
ty->state.had_cr = 0;
return _handle_esc(ty, c, ce);
-/*
+/*
case 0x1c: // FS (file separator)
return 1;
case 0x1d: // GS (group separator)
ty->state.had_cr = 0;
return 1;
}
-
+
cc = (int *)c;
DBG("txt: [");
while ((cc < ce) && (*cc >= 0x20) && (*cc != 0xf7))
_handle_buf(Termpty *ty, const int *glyphs, int len)
{
int *c, *ce, n, *b, bytes;
-
+
c = (int *)glyphs;
ce = &(c[len]);
_pty_size(Termpty *ty)
{
struct winsize sz;
-
+
sz.ws_col = ty->w;
sz.ws_row = ty->h;
sz.ws_xpixel = 0;
{
Ecore_Exe_Event_Del *ev = event;
Termpty *ty = data;
-
+
if (ev->pid != ty->pid) return ECORE_CALLBACK_PASS_ON;
// XXX: report via cb
exit(ev->exit_code);
for (i = 0; i < len;)
{
int g = 0;
-
+
if (buf[i])
{
i = evas_string_char_next_get(buf, i, &g);
{
Termpty *ty;
const char *pty;
-
+
ty = calloc(1, sizeof(Termpty));
if (!ty) return NULL;
ty->w = w;
_reset_state(ty);
ty->save = ty->state;
ty->swap = ty->state;
-
+
ty->screen = calloc(1, sizeof(Termcell) * ty->w * ty->h);
if (!ty->screen) goto err;
ty->screen2 = calloc(1, sizeof(Termcell) * ty->w * ty->h);
if (!ty->screen2) goto err;
-
+
ty->fd = posix_openpt(O_RDWR | O_NOCTTY);
if (ty->fd < 0) goto err;
if (grantpt(ty->fd) != 0) goto err;
}
ty->fd = ty->slavefd;
setsid();
-
+
dup2(ty->fd, 0);
dup2(ty->fd, 1);
dup2(ty->fd, 2);
-
+
if (ioctl(ty->fd, TIOCSCTTY, NULL) < 0) exit(1);
-
+
uid = getuid();
pw = getpwuid(uid);
if (!pw) shell = "/bin/sh";
if (ty->back)
{
int i;
-
+
for (i = 0; i < ty->backmax; i++)
{
if (ty->back[i]) free(ty->back[i]);
termpty_cellrow_get(Termpty *ty, int y, int *wret)
{
Termsave *ts;
-
+
if (y >= 0)
{
if (y >= ty->h) return NULL;
{
Termcell *olds, *olds2;
int y, ww, hh, oldw, oldh;
-
+
if ((ty->w == w) && (ty->h == h)) return;
olds = ty->screen;
olds2 = ty->screen2;
oldw = ty->w;
oldh = ty->h;
-
+
ty->w = w;
ty->h = h;
ty->state.had_cr = 0;
_limit_coord(ty, &(ty->state));
_limit_coord(ty, &(ty->swap));
_limit_coord(ty, &(ty->save));
-
+
ty->screen = calloc(1, sizeof(Termcell) * ty->w * ty->h);
if (!ty->screen)
{
{
ERR("memerr");
}
-
+
ww = ty->w;
hh = ty->h;
if (ww > oldw) ww = oldw;
for (y = 0; y < hh; y++)
{
Termcell *c1, *c2;
-
+
c1 = &(olds[y * oldw]);
c2 = &(ty->screen[y * ty->w]);
_text_copy(ty, c1, c2, ww);
-
+
c1 = &(olds2[y * oldw]);
c2 = &(ty->screen2[y * ty->w]);
_text_copy(ty, c1, c2, ww);
{
Evas_Object *win, *o;
char buf[4096];
-
+
win = elm_win_add(NULL, "main", ELM_WIN_BASIC);
elm_win_autodel_set(win, EINA_TRUE);
-
+
elm_win_title_set(win, "Terminology");
elm_win_icon_name_set(win, "Terminology");
-
+
o = evas_object_image_add(evas_object_evas_get(win));
snprintf(buf, sizeof(buf), "%s/images/terminology.png",
elm_app_data_dir_get());
evas_object_image_file_set(o, buf, NULL);
elm_win_icon_object_set(win, o);
-
+
return win;
}