/*
* $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 ***
*
l->fp = f;
l->do_close = dc;
+ fput_cp(f,0xffef);
+
return (Log *) l;
}
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, ...);
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];
/*
* $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 ***
*
}
-
-
-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);
}
/*
* $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 ***
*
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);
+}
/*
* $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 ***
*
{
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;
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);
}
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)
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);
/*select G0 */
v->cs = 0;
break;
+#if 0
/*DLE*/ case 16:
/*DC1 */ case 17:
/*DC2 */ case 18:
/*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);
}
/*
* $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 ***
*
[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,