From d338f6d46af0d6b5e746203748ba7cc9242020cb Mon Sep 17 00:00:00 2001 From: james <> Date: Sun, 24 Feb 2008 00:47:14 +0000 Subject: *** empty log message *** --- src/serial.c | 6 ++++-- src/utf8.c | 46 +++++++++++++++++++++++++++++++++++++++++++--- src/utf8.h | 5 ++++- src/util.c | 46 ++++++++++++++++++++++++++++++++-------------- src/vt102.c | 7 ++++++- src/vt102.h | 5 ++++- 6 files changed, 93 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/serial.c b/src/serial.c index 1044bb2..ab06e60 100644 --- a/src/serial.c +++ b/src/serial.c @@ -6,11 +6,13 @@ * */ -static char rcsid[] = - "$Id$"; +static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.10 2008/02/24 00:47:14 james + * *** empty log message *** + * * Revision 1.9 2008/02/24 00:42:53 james * *** empty log message *** * diff --git a/src/utf8.c b/src/utf8.c index 52ba398..ff8a2ec 100644 --- a/src/utf8.c +++ b/src/utf8.c @@ -10,6 +10,9 @@ static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.5 2008/02/24 00:42:53 james + * *** empty log message *** + * * Revision 1.4 2008/02/23 13:05:58 staffcvs * *** empty log message *** * @@ -61,7 +64,7 @@ utf8_flush (Context * c) } void -utf8_parse (Context * c, int ch) +utf8_parse (Context * c, uint32_t ch) { UTF8 *u = c->u; @@ -74,7 +77,8 @@ utf8_parse (Context * c, int ch) if (!u->in_utf8) { - /*FIXME: for the moment we bodge utf8 support */ + /*FIXME: for the moment we bodge utf8 support - need to do */ + /* L->R and R->L and double width characters */ if (ch == 0xb9) { /*CSI, not a valid utf8 start char */ vt102_parse_char (c, ch); @@ -123,7 +127,7 @@ utf8_parse (Context * c, int ch) u->in_utf8--; if (!u->in_utf8) - vt102_parse_char (c, ch); + vt102_parse_char (c, u->ch); } } } @@ -140,3 +144,39 @@ utf8_new (void) ret->in_utf8 = 0; } + + + +void +utf8_emit (TTY * t, int ch) +{ + uint8_t buf[4]; + + if (ch < 0x80) + { + buf[0] = ch; + t->xmit (t, buf, 1); + } + else if (ch < 0x800) + { + buf[0] = 0xc0 | (ch >> 6); + buf[1] = 0x80 | (ch & 0x3f); + + t->xmit (t, buf, 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); + } + 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); + } +} diff --git a/src/utf8.h b/src/utf8.h index 4fbf378..22ee915 100644 --- a/src/utf8.h +++ b/src/utf8.h @@ -12,6 +12,9 @@ /* * $Log$ + * Revision 1.4 2008/02/24 00:42:53 james + * *** empty log message *** + * * Revision 1.3 2008/02/23 11:48:37 james * *** empty log message *** * @@ -35,7 +38,7 @@ typedef struct uint8_t utf_buf[4]; int utf_ptr; - int ch; + uint32_t ch; int sh; } UTF8; diff --git a/src/util.c b/src/util.c index ba1e309..e8b221a 100644 --- a/src/util.c +++ b/src/util.c @@ -10,6 +10,9 @@ static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.5 2008/02/24 00:42:53 james + * *** empty log message *** + * * Revision 1.4 2008/02/23 13:05:58 staffcvs * *** empty log message *** * @@ -78,17 +81,15 @@ set_blocking (int fd) fcntl (fd, F_SETFL, arg); } + + void -raw_termios (struct termios *termios) +default_termios (struct termios *termios) { - - termios->c_iflag = 0; -/*ICRNL | IXON;*/ + termios->c_iflag = PARMRK | INPCK; termios->c_oflag = NL0 | CR0 | TAB0 | BS0 | VT0 | FF0; termios->c_lflag = 0; -/* - ISIG | ICANON | IEXTEN | ECHO | ECHOE | ECHOK | ECHOCTL | ECHOKE; -*/ + termios->c_cflag = CS8 | CREAD | CLOCAL; termios->c_cc[VINTR] = 003; termios->c_cc[VQUIT] = 034; @@ -105,19 +106,36 @@ raw_termios (struct termios *termios) termios->c_cc[VREPRINT] = 022; termios->c_cc[VDISCARD] = 017; + } void -default_termios (struct termios *termios) +client_termios (struct termios *termios) { + memset (termios, 0, sizeof (termios)); -// memset (termios, 0, sizeof (termios)); + termios->c_iflag = ICRNL | IXON | PARMRK | INPCK; + termios->c_oflag = OPOST | ONLCR | NL0 | CR0 | TAB0 | BS0 | VT0 | FF0; + termios->c_lflag = + ISIG | ICANON | IEXTEN | ECHO | ECHOE | ECHOK | ECHOCTL | ECHOKE; + termios->c_cflag = CS8 | CREAD | CLOCAL; - raw_termios (termios); + termios->c_cc[VINTR] = 003; + termios->c_cc[VQUIT] = 034; + termios->c_cc[VERASE] = 0177; + termios->c_cc[VKILL] = 025; + termios->c_cc[VEOF] = 004; + termios->c_cc[VEOL] = 0; + termios->c_cc[VEOL2] = 0; + termios->c_cc[VSTART] = 021; + termios->c_cc[VSTOP] = 023; + termios->c_cc[VSUSP] = 032; + termios->c_cc[VLNEXT] = 026; + termios->c_cc[VWERASE] = 027; + termios->c_cc[VREPRINT] = 022; + termios->c_cc[VDISCARD] = 017; - termios->c_cflag = CS8 | CREAD | CLOCAL; - termios->c_iflag |= PARMRK | INPCK; - //cfsetispeed (termios, B9600); - //cfsetospeed (termios, B9600); + cfsetispeed (termios, B9600); + cfsetospeed (termios, B9600); } diff --git a/src/vt102.c b/src/vt102.c index 9b316ce..5a2ab37 100644 --- a/src/vt102.c +++ b/src/vt102.c @@ -10,6 +10,9 @@ static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.35 2008/02/24 00:42:53 james + * *** empty log message *** + * * Revision 1.34 2008/02/23 11:48:37 james * *** empty log message *** * @@ -894,7 +897,7 @@ vt102_restore_state (VT102 * v) } void -vt102_regular_char (Context * c, VT102 * v, char ch) +vt102_regular_char (Context * c, VT102 * v, int ch) { vt102_do_pending_wrap (c); @@ -1307,10 +1310,12 @@ vt102_parse_char (Context * c, int ch) #endif /* Turn anything non-ascii into '?' */ +#if 0 if ((ch != SYM_CHAR_RESET) && (ch != 0xb9) && (ch > 127)) { ch = '?'; } +#endif if (ch == SYM_CHAR_RESET) diff --git a/src/vt102.h b/src/vt102.h index 6343e6d..d12182a 100644 --- a/src/vt102.h +++ b/src/vt102.h @@ -12,6 +12,9 @@ /* * $Log$ + * Revision 1.15 2008/02/24 00:42:53 james + * *** empty log message *** + * * Revision 1.14 2008/02/23 11:48:37 james * *** empty log message *** * @@ -107,7 +110,7 @@ typedef struct int application_keypad_mode; - char last_reg_char; + int last_reg_char; int xn_glitch; } VT102; -- cgit v1.2.3