aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjames <>2008-02-27 00:54:16 +0000
committerjames <>2008-02-27 00:54:16 +0000
commit74feb0db53bf6ed2d53ca59e3aed001f1160e62a (patch)
tree5344087602e010d1677a647656121b3713470410
parentdd068f2faaa044fbcef7a430650a221f210cba40 (diff)
downloadsympathy-74feb0db53bf6ed2d53ca59e3aed001f1160e62a.tar.gz
sympathy-74feb0db53bf6ed2d53ca59e3aed001f1160e62a.tar.bz2
sympathy-74feb0db53bf6ed2d53ca59e3aed001f1160e62a.zip
*** empty log message ***
-rw-r--r--src/log.c5
-rw-r--r--src/prototypes.h2
-rw-r--r--src/utf8.c50
-rw-r--r--src/util.c14
-rw-r--r--src/vt102.c40
-rw-r--r--src/vt102_charset.c15
6 files changed, 88 insertions, 38 deletions
diff --git a/src/log.c b/src/log.c
index 0f96964..ef0dfb5 100644
--- a/src/log.c
+++ b/src/log.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.4 2008/02/27 00:54:16 james
+ * *** empty log message ***
+ *
* Revision 1.3 2008/02/23 11:48:37 james
* *** empty log message ***
*
@@ -98,6 +101,8 @@ file_log_new (char *fn)
l->fp = f;
l->do_close = dc;
+ fput_cp(f,0xffef);
+
return (Log *) l;
}
diff --git a/src/prototypes.h b/src/prototypes.h
index 735617b..a115592 100644
--- a/src/prototypes.h
+++ b/src/prototypes.h
@@ -96,6 +96,7 @@ extern void set_nonblocking(int fd);
extern void set_blocking(int fd);
extern void default_termios(struct termios *termios);
extern void client_termios(struct termios *termios);
+extern int fput_cp(FILE *f, uint32_t ch);
/* log.c */
extern Log *file_log_new(char *fn);
extern void log_f(Log *log, char *fmt, ...);
@@ -164,6 +165,7 @@ extern Serial_lock *serial_lock_new(char *dev, int mode);
extern void utf8_flush(Context *c);
extern void utf8_parse(Context *c, uint32_t ch);
extern UTF8 *utf8_new(void);
+extern int utf8_encode(char *ptr, int ch);
extern void utf8_emit(TTY *t, int ch);
/* vt102_charset.c */
extern uint32_t vt102_charset_c0[128];
diff --git a/src/utf8.c b/src/utf8.c
index bffc9e4..7512c43 100644
--- a/src/utf8.c
+++ b/src/utf8.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.8 2008/02/27 00:54:16 james
+ * *** empty log message ***
+ *
* Revision 1.7 2008/02/26 23:56:12 james
* *** empty log message ***
*
@@ -151,38 +154,45 @@ utf8_new (void)
}
-
-
-void
-utf8_emit (TTY * t, int ch)
+int utf8_encode (char *ptr, int ch)
{
- uint8_t buf[4];
if (ch < 0x80)
{
- buf[0] = ch;
- t->xmit (t, buf, 1);
+ ptr[0] = ch;
+ return 1;
}
else if (ch < 0x800)
{
- buf[0] = 0xc0 | (ch >> 6);
- buf[1] = 0x80 | (ch & 0x3f);
-
- t->xmit (t, buf, 2);
+ ptr[0] = 0xc0 | (ch >> 6);
+ ptr[1] = 0x80 | (ch & 0x3f);
+ return 2;
}
else if (ch < 0x10000)
{
- buf[0] = 0xe0 | (ch >> 12);
- buf[1] = 0x80 | ((ch >> 6) & 0x3f);
- buf[2] = 0x80 | (ch & 0x3f);
- t->xmit (t, buf, 3);
+ ptr[0] = 0xe0 | (ch >> 12);
+ ptr[1] = 0x80 | ((ch >> 6) & 0x3f);
+ ptr[2] = 0x80 | (ch & 0x3f);
+ return 3;
}
else if (ch < 0x1fffff)
{
- buf[0] = 0xf0 | (ch >> 18);
- buf[1] = 0x80 | ((ch >> 12) & 0x3f);
- buf[2] = 0x80 | ((ch >> 6) & 0x3f);
- buf[3] = 0x80 | (ch & 0x3f);
- t->xmit (t, buf, 4);
+ ptr[0] = 0xf0 | (ch >> 18);
+ ptr[1] = 0x80 | ((ch >> 12) & 0x3f);
+ ptr[2] = 0x80 | ((ch >> 6) & 0x3f);
+ ptr[3] = 0x80 | (ch & 0x3f);
+ return 4;
}
+ return 0;
+}
+
+void
+utf8_emit (TTY * t, int ch)
+{
+ uint8_t buf[4];
+int i;
+ i=utf8_encode(buf,ch);
+ if (!i) return;
+
+ t->xmit (t, buf, i);
}
diff --git a/src/util.c b/src/util.c
index e8b221a..ea46e77 100644
--- a/src/util.c
+++ b/src/util.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.6 2008/02/27 00:54:16 james
+ * *** empty log message ***
+ *
* Revision 1.5 2008/02/24 00:42:53 james
* *** empty log message ***
*
@@ -139,3 +142,14 @@ client_termios (struct termios *termios)
cfsetispeed (termios, B9600);
cfsetospeed (termios, B9600);
}
+
+int fput_cp(FILE *f,uint32_t ch)
+{
+char buf[4];
+int i;
+i=utf8_encode(buf,ch);
+
+if (!i) return 0;
+
+return fwrite(buf,i,1,f);
+}
diff --git a/src/vt102.c b/src/vt102.c
index 8821087..7c211c5 100644
--- a/src/vt102.c
+++ b/src/vt102.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.44 2008/02/27 00:54:16 james
+ * *** empty log message ***
+ *
* Revision 1.43 2008/02/27 00:27:22 james
* *** empty log message ***
*
@@ -384,7 +387,7 @@ vt102_log_line (Context * c, int line)
{
CRT_Pos e = { c->v->current_width - 1, line };
CRT_Pos p = { 0, line };
- char logbuf[VT102_MAX_COLS + 1];
+ char logbuf[4*(VT102_MAX_COLS + 1)],*logptr=logbuf;
if (!c->l)
return;
@@ -401,11 +404,9 @@ vt102_log_line (Context * c, int line)
int ch = c->v->crt.screen[CRT_ADDR_POS (&p)].chr;
if (ch < 32)
ch = ' ';
- if (ch > 126)
- ch = ' ';
- logbuf[p.x] = ch;
+ logptr+=utf8_encode(logptr,ch);
}
- logbuf[p.x] = 0;
+ *logptr=0;
c->l->log (c->l, logbuf);
}
@@ -983,25 +984,30 @@ void
vt102_regular_char (Context * c, VT102 * v, uint32_t ch)
{
+
vt102_do_pending_wrap (c);
+
if (v->modes[VT102_MODE_INSERT])
vt102_insert_into_line (v, v->pos);
+ v->last_reg_char = ch;
+
+
if (ch < VT102_CHARSET_SIZE)
{
- int cs = charset_from_csid[v->g[v->cs]][ch];
- v->crt.screen[CRT_ADDR_POS (&v->pos)].chr = cs ? cs : ch;
- }
- else
- {
- v->crt.screen[CRT_ADDR_POS (&v->pos)].chr = ch;
+ int cs;
+ if ((cs=vt102_charset_c0[ch])) {
+ ch=cs;
+ } else if ((cs=charset_from_csid[v->g[v->cs]][ch])) {
+ ch=cs;
+ }
}
+ v->crt.screen[CRT_ADDR_POS (&v->pos)].chr = ch;
v->crt.screen[CRT_ADDR_POS (&v->pos)].attr = v->attr;
v->crt.screen[CRT_ADDR_POS (&v->pos)].color = v->color;
vt102_cursor_advance (c);
- v->last_reg_char = ch;
}
vt102_send_id (Context * c, char *buf)
@@ -1719,17 +1725,23 @@ vt102_parse_char (Context * c, int ch)
switch (ch)
{
+#if 0
/*NUL*/ case 0:
/*SOH*/ case 1:
/*STX*/ case 2:
/*ETX*/ case 3:
/*EOT*/ case 4:
break;
+#endif
/*ENQ*/ case 5:
vt102_send_id (c, terminal_id);
break;
+#if 0
/*ACK*/ case 6:
+ break;
+#endif
/*BEL*/ case 7:
+ //FIXME beep
break;
/*BS*/ case 8:
vt102_cursor_retreat (c->v);
@@ -1754,6 +1766,7 @@ vt102_parse_char (Context * c, int ch)
/*select G0 */
v->cs = 0;
break;
+#if 0
/*DLE*/ case 16:
/*DC1 */ case 17:
/*DC2 */ case 18:
@@ -1766,15 +1779,18 @@ vt102_parse_char (Context * c, int ch)
/*EM*/ case 25:
/*SUB*/ case 26:
break;
+#endif
/*ESC*/ case 27:
p->in_escape++;
return;
+#if 0
/*FS*/ case 28:
/*GS*/ case 29:
/*RS*/ case 30:
/*US*/ case 31:
/*DEL*/ case 127:
break;
+#endif
/*regular character */ default:
vt102_regular_char (c, v, ch);
}
diff --git a/src/vt102_charset.c b/src/vt102_charset.c
index 49abe8f..43e6012 100644
--- a/src/vt102_charset.c
+++ b/src/vt102_charset.c
@@ -11,6 +11,9 @@ static char rcsid[] =
/*
* $Log$
+ * Revision 1.4 2008/02/27 00:54:16 james
+ * *** empty log message ***
+ *
* Revision 1.3 2008/02/27 00:27:22 james
* *** empty log message ***
*
@@ -80,14 +83,14 @@ uint32_t vt102_charset_vt52[VT102_CHARSET_SIZE] = {
[0x69] = 0x2026,
[0x6a] = 0x00f7,
[0x6b] = 0x2193,
- [0x6c] = 0x25ba, //bar scan 0
+ [0x6c] = 0x23ba, //bar scan 0
[0x6d] = 0x23ba,
- [0x6e] = 0x25ba, //bar scan 2
+ [0x6e] = 0x23bb, //bar scan 2
[0x6f] = 0x23bb,
- [0x70] = 0x23bb, //bar scan 4
- [0x71] = 0x2500,
- [0x72] = 0x23bc, //bar scan 6
- [0x73] = 0x23bc,
+ [0x70] = 0x2500, //bar scan 4
+ [0x71] = 0x23bc,
+ [0x72] = 0x23bd, //bar scan 6
+ [0x73] = 0x23bd,
[0x74] = 0x2080,
[0x75] = 0x2081,
[0x76] = 0x2082,