aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjames <>2008-02-22 17:07:00 +0000
committerjames <>2008-02-22 17:07:00 +0000
commita7a1526ef4fed8460a87713fac159cc714bfde77 (patch)
treee198c9785f1d883a5a1804204bd7d8ac834f499f
parent980bd369ac8759c8a1df6fea7cbb5bfc8fee7afc (diff)
downloadsympathy-a7a1526ef4fed8460a87713fac159cc714bfde77.tar.gz
sympathy-a7a1526ef4fed8460a87713fac159cc714bfde77.tar.bz2
sympathy-a7a1526ef4fed8460a87713fac159cc714bfde77.zip
*** empty log message ***
-rw-r--r--apps/clients.c6
-rw-r--r--src/ansi.c8
-rw-r--r--src/cmd.c7
-rw-r--r--src/crt.c17
-rw-r--r--src/ipc.c14
-rw-r--r--src/ipc.h19
-rw-r--r--src/keydis.c28
-rw-r--r--src/keydis.h4
-rw-r--r--src/prototypes.h10
-rw-r--r--src/ptty.c5
-rw-r--r--src/vt102.c70
-rw-r--r--src/vt102.h6
12 files changed, 158 insertions, 36 deletions
diff --git a/apps/clients.c b/apps/clients.c
index 80b7750..069ae40 100644
--- a/apps/clients.c
+++ b/apps/clients.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.10 2008/02/22 17:06:59 james
+ * *** empty log message ***
+ *
* Revision 1.9 2008/02/20 18:49:11 staffcvs
* *** empty log message ***
*
@@ -70,6 +73,9 @@ client_msg (IPC_Msg * m, Context * c)
case IPC_MSG_TYPE_SETFLOW:
tty_set_flow (c->t, m->setflow.flow);
break;
+ case IPC_MSG_TYPE_SETANSI:
+ vt102_set_ansi (c->v, m->setansi.ansi);
+ break;
case IPC_MSG_TYPE_HANGUP:
tty_hangup (c->t);
break;
diff --git a/src/ansi.c b/src/ansi.c
index d2efc46..66c70f1 100644
--- a/src/ansi.c
+++ b/src/ansi.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.28 2008/02/22 17:07:00 james
+ * *** empty log message ***
+ *
* Revision 1.27 2008/02/20 22:54:22 staffcvs
* *** empty log message ***
*
@@ -528,6 +531,9 @@ ansi_history (ANSI * a, History * h)
/*Roll HISTORY_GUESS_SCROLL lines up putting the top line into the xterm's history */
+ /*Make extra lines a predictable colour*/
+ ansi_set_color (a, CRT_COLOR_NORMAL);
+
ansi_showhide_cursor (a, 1);
i = sprintf (buf, "\033[%d;%dH", HISTORY_GUESS_SCROLL, 1);
a->terminal->xmit (a->terminal, buf, i);
@@ -553,7 +559,7 @@ ansi_history (ANSI * a, History * h)
/* erase new line */
s.y = e.y;
e.x = CRT_COLS - 1;
- crt_erase (&a->crt, s, e, 1);
+ crt_erase (&a->crt, s, e, 1,CRT_COLOR_NORMAL);
}
}
diff --git a/src/cmd.c b/src/cmd.c
index bf5be83..7105c5b 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.3 2008/02/22 17:07:00 james
+ * *** empty log message ***
+ *
* Revision 1.2 2008/02/15 23:52:12 james
* *** empty log message ***
*
@@ -31,6 +34,10 @@ cmd_parse (Cmd * c, Context * ctx, char *buf)
ctx->k->set_flow (ctx->k, ctx, 1);
if (!strcmp (buf, "noflow"))
ctx->k->set_flow (ctx->k, ctx, 0);
+ if (!strcmp (buf, "ansi"))
+ ctx->k->set_ansi (ctx->k, ctx, 0);
+ if (!strcmp (buf, "noansi"))
+ ctx->k->set_ansi (ctx->k, ctx, 1);
if (!strncmp (buf, "baud", 4))
ctx->k->set_baud (ctx->k, ctx, atoi (buf + 4));
if (!strncmp (buf, "break", 4))
diff --git a/src/crt.c b/src/crt.c
index a9e6e86..5f5656b 100644
--- a/src/crt.c
+++ b/src/crt.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.10 2008/02/22 17:07:00 james
+ * *** empty log message ***
+ *
* Revision 1.9 2008/02/07 13:22:51 james
* *** empty log message ***
*
@@ -42,7 +45,7 @@ static char rcsid[] = "$Id$";
#include "project.h"
void
-crt_erase (CRT * c, CRT_Pos s, CRT_Pos e, int ea)
+crt_erase (CRT * c, CRT_Pos s, CRT_Pos e, int ea,int color)
{
CRT_CA *ps = &c->screen[CRT_ADDR_POS (&s)];
CRT_CA *pe = &c->screen[CRT_ADDR_POS (&e)];
@@ -53,7 +56,7 @@ crt_erase (CRT * c, CRT_Pos s, CRT_Pos e, int ea)
if (ea)
{
ps->attr = CRT_ATTR_NORMAL;
- ps->color = CRT_COLOR_NORMAL;
+ ps->color = color;
}
ps++;
}
@@ -67,12 +70,12 @@ crt_cls (CRT * c)
CRT_Pos e = { CRT_COLS - 1, CRT_ROWS - 1 };
int i;
- crt_erase (c, s, e, 1);
+ crt_erase (c, s, e, 1, CRT_COLOR_NORMAL);
c->sh.dir = 0;
}
void
-crt_scroll_up (CRT * c, CRT_Pos s, CRT_Pos e, int ea)
+crt_scroll_up (CRT * c, CRT_Pos s, CRT_Pos e, int ea,int color)
{
int l, n;
int p;
@@ -101,12 +104,12 @@ crt_scroll_up (CRT * c, CRT_Pos s, CRT_Pos e, int ea)
}
s.y = e.y;
- crt_erase (c, s, e, ea);
+ crt_erase (c, s, e, ea,color);
}
void
-crt_scroll_down (CRT * c, CRT_Pos s, CRT_Pos e, int ea)
+crt_scroll_down (CRT * c, CRT_Pos s, CRT_Pos e, int ea,int color)
{
int l, n;
int p;
@@ -134,7 +137,7 @@ crt_scroll_down (CRT * c, CRT_Pos s, CRT_Pos e, int ea)
}
e.y = s.y;
- crt_erase (c, s, e, ea);
+ crt_erase (c, s, e, ea,color);
}
diff --git a/src/ipc.c b/src/ipc.c
index b30bef0..8809f36 100644
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.4 2008/02/22 17:07:00 james
+ * *** empty log message ***
+ *
* Revision 1.3 2008/02/15 23:52:12 james
* *** empty log message ***
*
@@ -193,6 +196,17 @@ ipc_msg_send_setflow (Socket * s, int flow)
}
int
+ipc_msg_send_setansi (Socket * s, int ansi)
+{
+ IPC_Msg_setansi m;
+
+ m.size = sizeof (m);
+ m.type = IPC_MSG_TYPE_SETANSI;
+ m.ansi = ansi;
+ return ipc_msg_send (s, (IPC_Msg *) & m);
+}
+
+int
ipc_msg_send_hangup (Socket * s)
{
IPC_Msg_hangup m;
diff --git a/src/ipc.h b/src/ipc.h
index 2713de7..1820511 100644
--- a/src/ipc.h
+++ b/src/ipc.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.4 2008/02/22 17:07:00 james
+ * *** empty log message ***
+ *
* Revision 1.3 2008/02/15 23:52:12 james
* *** empty log message ***
*
@@ -30,15 +33,16 @@
#define IPC_MSG_TYPE_NOOP 0
#define IPC_MSG_TYPE_DEBUG 1
-#define IPC_MSG_TYPE_HISTORY 2
-#define IPC_MSG_TYPE_VT102 3
+#define IPC_MSG_TYPE_VT102 2
+#define IPC_MSG_TYPE_HISTORY 3
#define IPC_MSG_TYPE_KEY 4
#define IPC_MSG_TYPE_TERM 5
#define IPC_MSG_TYPE_STATUS 6
#define IPC_MSG_TYPE_SETBAUD 7
#define IPC_MSG_TYPE_SENDBREAK 8
#define IPC_MSG_TYPE_SETFLOW 9
-#define IPC_MSG_TYPE_HANGUP 10
+#define IPC_MSG_TYPE_SETANSI 10
+#define IPC_MSG_TYPE_HANGUP 11
typedef struct
{
@@ -128,6 +132,14 @@ typedef struct
{
int32_t size;
int32_t type;
+ int32_t ansi;
+} IPC_Msg_setansi;
+
+
+typedef struct
+{
+ int32_t size;
+ int32_t type;
} IPC_Msg_hangup;
@@ -145,6 +157,7 @@ IPC_Msg_status status;
IPC_Msg_setbaud setbaud;
IPC_Msg_sendbreak sendbreak;
IPC_Msg_setflow setflow;
+IPC_Msg_setansi setansi;
IPC_Msg_hangup hangup;
} IPC_Msg;
diff --git a/src/keydis.c b/src/keydis.c
index c8883a7..73f6306 100644
--- a/src/keydis.c
+++ b/src/keydis.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.4 2008/02/22 17:07:00 james
+ * *** empty log message ***
+ *
* Revision 1.3 2008/02/15 23:52:12 james
* *** empty log message ***
*
@@ -88,6 +91,19 @@ keydis_ipc_set_flow (KeyDis * _t, Context * c, int flow)
static int
+keydis_ipc_set_ansi (KeyDis * _t, Context * c, int ansi)
+{
+ KeyDis_IPC *t = (KeyDis_IPC *) _t;
+
+ vt102_set_ansi (c->v, ansi);
+
+ ipc_msg_send_setansi (t->s, ansi);
+
+ return 0;
+}
+
+
+static int
keydis_ipc_hangup (KeyDis * _t, Context * c)
{
KeyDis_IPC *t = (KeyDis_IPC *) _t;
@@ -136,6 +152,16 @@ keydis_vt102_set_flow (KeyDis * _t, Context * c, int flow)
return 0;
}
+static int
+keydis_vt102_set_ansi (KeyDis * _t, Context * c, int ansi)
+{
+ KeyDis_VT102 *t = (KeyDis_VT102 *) _t;
+
+ if (c->v)
+ c->v->xn_glitch=ansi ? 0:1;
+ return 0;
+}
+
static int
keydis_vt102_hangup (KeyDis * _t, Context * c)
@@ -158,6 +184,7 @@ keydis_vt102_new (void)
t->set_baud = keydis_vt102_set_baud;
t->send_break = keydis_vt102_send_break;
t->set_flow = keydis_vt102_set_flow;
+ t->set_ansi = keydis_vt102_set_ansi;
t->hangup = keydis_vt102_hangup;
return (KeyDis *) t;
}
@@ -172,6 +199,7 @@ keydis_ipc_new (Socket * s)
t->set_baud = keydis_ipc_set_baud;
t->send_break = keydis_ipc_send_break;
t->set_flow = keydis_ipc_set_flow;
+ t->set_ansi = keydis_ipc_set_ansi;
t->hangup = keydis_ipc_hangup;
t->s = s;
return (KeyDis *) t;
diff --git a/src/keydis.h b/src/keydis.h
index 4ccfb7d..89bf9e2 100644
--- a/src/keydis.h
+++ b/src/keydis.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.4 2008/02/22 17:07:00 james
+ * *** empty log message ***
+ *
* Revision 1.3 2008/02/15 23:52:12 james
* *** empty log message ***
*
@@ -38,6 +41,7 @@ struct Context_struct;
int (*set_baud)(struct KeyDis_struct *,struct Context_struct *,int rate); \
int (*send_break)(struct KeyDis_struct *,struct Context_struct *); \
int (*set_flow)(struct KeyDis_struct *,struct Context_struct *,int flow); \
+ int (*set_ansi)(struct KeyDis_struct *,struct Context_struct *,int ansi); \
int (*hangup)(struct KeyDis_struct *,struct Context_struct *)
diff --git a/src/prototypes.h b/src/prototypes.h
index 89ada5d..f0aaa8a 100644
--- a/src/prototypes.h
+++ b/src/prototypes.h
@@ -2,10 +2,10 @@
extern int ansi_dispatch(ANSI *a, Context *c);
extern ANSI *ansi_new_from_terminal(TTY *t);
/* crt.c */
-extern void crt_erase(CRT *c, CRT_Pos s, CRT_Pos e, int ea);
+extern void crt_erase(CRT *c, CRT_Pos s, CRT_Pos e, int ea, int color);
extern void crt_cls(CRT *c);
-extern void crt_scroll_up(CRT *c, CRT_Pos s, CRT_Pos e, int ea);
-extern void crt_scroll_down(CRT *c, CRT_Pos s, CRT_Pos e, int ea);
+extern void crt_scroll_up(CRT *c, CRT_Pos s, CRT_Pos e, int ea, int color);
+extern void crt_scroll_down(CRT *c, CRT_Pos s, CRT_Pos e, int ea, int color);
extern void crt_reset(CRT *c);
extern void crt_insert(CRT *c, CRT_CA ca);
/* html.c */
@@ -20,8 +20,8 @@ extern void vt102_clip_cursor(VT102 *v, CRT_Pos tl, CRT_Pos br);
extern void vt102_cursor_normalize(VT102 *v);
extern void vt102_cursor_carriage_return(VT102 *v);
extern void vt102_cursor_advance_line(Context *c);
-extern void vt102_cursor_advance(Context *c);
extern void vt102_do_pending_wrap(Context *c);
+extern void vt102_cursor_advance(Context *c);
extern void vt102_cursor_retard(VT102 *v);
extern void vt102_reset_tabs(VT102 *v);
extern void vt102_cursor_advance_tab(VT102 *v);
@@ -50,6 +50,7 @@ extern void vt102_reset(VT102 *v);
extern int vt102_dispatch(Context *c);
extern int vt102_dispatch_one(Context *c);
extern VT102 *vt102_new(void);
+extern void vt102_set_ansi(VT102 *v, int ansi);
extern void vt102_free(VT102 *v);
/* tty.c */
extern void tty_pre_select(TTY *t, fd_set *rfds, fd_set *wfds);
@@ -104,6 +105,7 @@ extern int ipc_msg_send_status(Socket *s, char *buf);
extern int ipc_msg_send_setbaud(Socket *s, int baud);
extern int ipc_msg_send_sendbreak(Socket *s);
extern int ipc_msg_send_setflow(Socket *s, int flow);
+extern int ipc_msg_send_setansi(Socket *s, int ansi);
extern int ipc_msg_send_hangup(Socket *s);
/* slide.c */
extern void slide_free(Slide *s);
diff --git a/src/ptty.c b/src/ptty.c
index 0c69a2b..860928e 100644
--- a/src/ptty.c
+++ b/src/ptty.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.7 2008/02/22 17:07:00 james
+ * *** empty log message ***
+ *
* Revision 1.6 2008/02/22 14:51:54 james
* *** empty log message ***
*
@@ -145,7 +148,7 @@ ptty_open (char *path, char *argv[])
case -1: /*boo hiss */
return NULL;
case 0: /*waaah */
- setenv ("TERM", "ansi", 1);
+ setenv ("TERM", "xterm", 1);
setenv ("LANG", "C", 1);
if (!path)
path = "/bin/sh";
diff --git a/src/vt102.c b/src/vt102.c
index d74437f..292e15c 100644
--- a/src/vt102.c
+++ b/src/vt102.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.31 2008/02/22 17:07:00 james
+ * *** empty log message ***
+ *
* Revision 1.30 2008/02/22 14:51:54 james
* *** empty log message ***
*
@@ -416,7 +419,7 @@ vt102_cursor_advance_line (Context * c)
vt102_history (c, v->top_margin, v->bottom_margin);
- crt_scroll_up (&v->crt, v->top_margin, v->bottom_margin, 1);
+ crt_scroll_up (&v->crt, v->top_margin, v->bottom_margin, 1, v->color);
return;
}
@@ -473,7 +476,7 @@ vt102_cursor_advance (Context * c)
return;
}
v->pending_wrap++;
- if (c->v->xn_glitch)
+ if (!c->v->xn_glitch)
vt102_do_pending_wrap(c);
}
@@ -911,7 +914,7 @@ vt102_parse_esc (Context * c, int ch)
{
vt102_log_line (c, v->pos.y);
vt102_history (c, v->top_margin, v->bottom_margin);
- crt_scroll_up (&v->crt, v->top_margin, v->bottom_margin, 1);
+ crt_scroll_up (&v->crt, v->top_margin, v->bottom_margin, 1,v->color);
}
else
{
@@ -924,7 +927,7 @@ vt102_parse_esc (Context * c, int ch)
case 'M':
if (v->pos.y == v->top_margin.y)
{
- crt_scroll_down (&v->crt, v->top_margin, v->bottom_margin, 1);
+ crt_scroll_down (&v->crt, v->top_margin, v->bottom_margin, 1,v->color);
}
else
{
@@ -1035,13 +1038,13 @@ vt102_parse_csi (Context * c, char *buf, int len)
switch (narg)
{
case 0:
- crt_erase (&v->crt, v->pos, v->screen_end, 1);
+ crt_erase (&v->crt, v->pos, v->screen_end, 1,v->color);
break;
case 1:
- crt_erase (&v->crt, v->screen_start, v->pos, 1);
+ crt_erase (&v->crt, v->screen_start, v->pos, 1,v->color);
break;
case 2:
- crt_erase (&v->crt, v->screen_start, v->screen_end, 1);
+ crt_erase (&v->crt, v->screen_start, v->screen_end, 1,v->color);
break;
}
break;
@@ -1055,13 +1058,13 @@ vt102_parse_csi (Context * c, char *buf, int len)
switch (narg)
{
case 0:
- crt_erase (&v->crt, v->pos, le, 1);
+ crt_erase (&v->crt, v->pos, le, 1,v->color);
break;
case 1:
- crt_erase (&v->crt, ls, v->pos, 1);
+ crt_erase (&v->crt, ls, v->pos, 1,v->color);
break;
case 2:
- crt_erase (&v->crt, ls, le, 1);
+ crt_erase (&v->crt, ls, le, 1,v->color);
break;
}
}
@@ -1072,7 +1075,7 @@ vt102_parse_csi (Context * c, char *buf, int len)
&& (v->pos.y <= v->bottom_margin.y))
{
while (narg--)
- crt_scroll_down (&v->crt, v->pos, v->bottom_margin, 1);
+ crt_scroll_down (&v->crt, v->pos, v->bottom_margin, 1,v->color);
}
break;
@@ -1083,7 +1086,7 @@ vt102_parse_csi (Context * c, char *buf, int len)
while (narg--)
{
vt102_history (c, v->pos, v->bottom_margin);
- crt_scroll_up (&v->crt, v->pos, v->bottom_margin, 1);
+ crt_scroll_up (&v->crt, v->pos, v->bottom_margin, 1,v->color);
}
}
break;
@@ -1098,12 +1101,12 @@ vt102_parse_csi (Context * c, char *buf, int len)
while (narg--)
{
vt102_history (c, v->top_margin, v->bottom_margin);
- crt_scroll_up (&v->crt, v->top_margin, v->bottom_margin, 1);
+ crt_scroll_up (&v->crt, v->top_margin, v->bottom_margin, 1,v->color);
}
break;
case 'T':
while (narg--)
- crt_scroll_down (&v->crt, v->top_margin, v->bottom_margin, 1);
+ crt_scroll_down (&v->crt, v->top_margin, v->bottom_margin, 1,v->color);
break;
case 'X':
{
@@ -1114,7 +1117,7 @@ vt102_parse_csi (Context * c, char *buf, int len)
if (end.x > v->bottom_margin.x)
end.x = v->bottom_margin.x;
- crt_erase (&v->crt, v->pos, end, 1);
+ crt_erase (&v->crt, v->pos, end, 1,v->color);
}
break;
case 'Z':
@@ -1237,10 +1240,28 @@ vt102_parse_char (Context * c, int ch)
VT102_parser *p = &v->parser;
#if 1
- log_f (c->l, "char %3d %c pc %d %d %2d %2d %d",ch,safe_ch(ch),
- p->in_csi, p->in_escape, v->pos.x, v->pos.y,v->pending_wrap);
+ log_f (c->l, "char %3d %c pc %d %d %d %2d %2d %d",ch,safe_ch(ch),
+ p->in_utf8,p->in_escape, p->in_csi, v->pos.x, v->pos.y,v->pending_wrap);
#endif
- if (p->in_csi)
+
+ if ((ch>=0xc0) && (ch<0xe0)) /*Start of two byte unicode sequence*/
+ {
+ p->in_utf8=2;
+ } else if ((ch>=0xe0) && (ch<0xf0)) /*Start of three byte unicode sequence*/
+ {
+ p->in_utf8=3;
+ } else if ((ch>=0xf0) && (ch<0xf7)) /*Start of four byte unicode sequence*/
+ p->in_utf8=4;
+ }
+
+ if (p->utf_8) {
+ p->in_utf8--;
+ ch='?';
+ }
+
+ if (p->utf_8) {
+ /*Not first or last byte in sequence*/
+ }else if (p->in_csi)
{
p->csi_buf[p->csi_ptr++] = ch;
if (csi_ender (ch) || (p->csi_ptr == VT102_CSI_LEN))
@@ -1275,6 +1296,12 @@ vt102_parse_char (Context * c, int ch)
vt102_parse_esc (c, ch);
}
}
+ else if (ch==0x9b) /*One byte CSI*/
+ {
+ p->csi_ptr = 0;
+ p->csi_buf[p->csi_ptr++] = '[';
+ p->in_csi++;
+ }
else
{
@@ -1582,7 +1609,6 @@ vt102_reset (VT102 * v)
v->last_reg_char = ' ';
- v->xn_glitch=0;
}
@@ -1630,6 +1656,7 @@ vt102_new (void)
VT102 *v;
v = (VT102 *) malloc (sizeof (VT102));
+ v->xn_glitch=1;
vt102_reset (v);
@@ -1637,6 +1664,11 @@ vt102_new (void)
return v;
}
+void vt102_set_ansi(VT102 *v,int ansi)
+{
+v->xn_glitch=ansi ? 0:1;
+}
+
void
vt102_free (VT102 * v)
{
diff --git a/src/vt102.h b/src/vt102.h
index 7537969..9d7f9d6 100644
--- a/src/vt102.h
+++ b/src/vt102.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.13 2008/02/22 17:07:00 james
+ * *** empty log message ***
+ *
* Revision 1.12 2008/02/22 14:51:54 james
* *** empty log message ***
*
@@ -61,10 +64,12 @@
#define VT102_NMODES 32
+
typedef struct
{
int in_escape;
int in_csi;
+ int in_utf8;
int csi_ptr;
char csi_buf[VT102_CSI_LEN];
} VT102_parser;
@@ -100,7 +105,6 @@ typedef struct
int application_keypad_mode;
char last_reg_char;
-
int xn_glitch;
} VT102;