aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjames <>2008-02-22 19:12:05 +0000
committerjames <>2008-02-22 19:12:05 +0000
commit22301df1f4af5937bf96cb85091d5220d206d9bc (patch)
tree71020082ddea0c28f6b754778f6b0133b3a0daff
parenta7a1526ef4fed8460a87713fac159cc714bfde77 (diff)
downloadsympathy-22301df1f4af5937bf96cb85091d5220d206d9bc.tar.gz
sympathy-22301df1f4af5937bf96cb85091d5220d206d9bc.tar.bz2
sympathy-22301df1f4af5937bf96cb85091d5220d206d9bc.zip
*** empty log message ***
-rw-r--r--src/tty.h6
-rw-r--r--src/utf8.c38
-rw-r--r--src/utf8.h34
-rw-r--r--src/vt102.c138
4 files changed, 122 insertions, 94 deletions
diff --git a/src/tty.h b/src/tty.h
index 2ad1003..5585a02 100644
--- a/src/tty.h
+++ b/src/tty.h
@@ -12,6 +12,9 @@
/*
* $Log$
+ * Revision 1.9 2008/02/22 19:12:05 james
+ * *** empty log message ***
+ *
* Revision 1.8 2008/02/15 23:52:12 james
* *** empty log message ***
*
@@ -41,6 +44,9 @@
#ifndef __TTY_H__
#define __TTY_H__
+
+#define SYM_CHAR_RESET (-1)
+
#define TTY_SIGNATURE \
char name[1024]; \
int blocked; \
diff --git a/src/utf8.c b/src/utf8.c
new file mode 100644
index 0000000..18ca3eb
--- /dev/null
+++ b/src/utf8.c
@@ -0,0 +1,38 @@
+/*
+ * utf8.c:
+ *
+ * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
+ * All rights reserved.
+ *
+ */
+
+static char rcsid[] = "$Id$";
+
+/*
+ * $Log$
+ * Revision 1.1 2008/02/22 19:12:05 james
+ * *** empty log message ***
+ *
+ */
+
+#include "project.h"
+
+
+ /*FIXME: for the moment we bodge utf8 support*/
+ 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*/
diff --git a/src/utf8.h b/src/utf8.h
new file mode 100644
index 0000000..faa8d7a
--- /dev/null
+++ b/src/utf8.h
@@ -0,0 +1,34 @@
+/*
+ * utf8.h:
+ *
+ * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
+ * All rights reserved.
+ *
+ */
+
+/*
+ * $Id$
+ */
+
+/*
+ * $Log$
+ * Revision 1.1 2008/02/22 19:12:05 james
+ * *** empty log message ***
+ *
+ *
+ */
+
+#ifndef __UTF8_H__
+#define __UTF8_H__
+
+
+typedef struct
+{
+ int in_escape;
+ int in_csi;
+ int in_utf8;
+ int csi_ptr;
+ char csi_buf[VT102_CSI_LEN];
+} UTF8_Parser;
+
+#endif /* __UTF8_H__ */
diff --git a/src/vt102.c b/src/vt102.c
index 292e15c..e136637 100644
--- a/src/vt102.c
+++ b/src/vt102.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.32 2008/02/22 19:12:05 james
+ * *** empty log message ***
+ *
* Revision 1.31 2008/02/22 17:07:00 james
* *** empty log message ***
*
@@ -1234,6 +1237,39 @@ vt102_status_line (VT102 * v, char *str)
void
+vt102_parser_reset (VT102_parser * p)
+{
+ p->in_csi = 0;
+ p->in_escape = 0;
+}
+
+
+void
+vt102_reset_state(VT102 *v)
+{
+ vt102_parser_reset(&v->parser);
+
+ v->attr = CRT_ATTR_NORMAL;
+ v->color = CRT_COLOR_NORMAL;
+
+ v->application_keypad_mode = 0;
+
+ v->top_margin = v->screen_start;
+ v->bottom_margin = v->screen_end;
+
+ memset (v->modes, 0, VT102_NMODES);
+ memset (v->private_modes, 0, VT102_NMODES);
+
+ v->private_modes[VT102_PRIVATE_MODE_AUTO_WRAP] = 1;
+ v->private_modes[VT102_PRIVATE_MODE_AUTO_REPEAT] = 1;
+ v->private_modes[VT102_PRIVATE_MODE_SHOW_CURSOR] = 1;
+ v->modes[VT102_MODE_LOCAL_ECHO_OFF] = 1;
+
+ vt102_reset_tabs (v);
+}
+
+
+void
vt102_parse_char (Context * c, int ch)
{
VT102 *v = c->v;
@@ -1244,24 +1280,9 @@ vt102_parse_char (Context * c, int ch)
p->in_utf8,p->in_escape, p->in_csi, v->pos.x, v->pos.y,v->pending_wrap);
#endif
- 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)
+ if (ch==SYM_CHAR_RESET) {
+ vt102_reset_state(v);
+ } else if (p->in_csi)
{
p->csi_buf[p->csi_ptr++] = ch;
if (csi_ender (ch) || (p->csi_ptr == VT102_CSI_LEN))
@@ -1383,22 +1404,6 @@ vt102_parse_char (Context * c, int ch)
cmd_show_status (c->d, c);
}
-vt102_parse (Context * c, char *buf, int len)
-{
- while (len--)
- vt102_parse_char (c, *(buf++));
-}
-
-
-void
-vt102_parser_reset (VT102_parser * p)
-{
- p->in_csi = 0;
- p->in_escape = 0;
- p->csi_ptr = 0;
-}
-
-
void
vt102_send (Context * c, uint8_t key)
{
@@ -1573,13 +1578,9 @@ vt102_reset (VT102 * v)
VT102_parser *p = &v->parser;
vt102_parser_reset (p);
- crt_cls (&v->crt);
-
- v->attr = CRT_ATTR_NORMAL;
- v->color = CRT_COLOR_NORMAL;
-
- v->application_keypad_mode = 0;
+ vt102_reset_state(p);
+ crt_cls (&v->crt);
v->current_line = v->pos;
v->pending_wrap = 0;
@@ -1588,74 +1589,23 @@ vt102_reset (VT102 * v)
v->screen_end.x = VT102_COLS - 1;
v->screen_end.y = VT102_ROWS - 1;
- v->top_margin = v->screen_start;
- v->bottom_margin = v->screen_end;
-
- memset (v->modes, 0, VT102_NMODES);
- memset (v->private_modes, 0, VT102_NMODES);
-
- v->private_modes[VT102_PRIVATE_MODE_AUTO_WRAP] = 1;
- v->private_modes[VT102_PRIVATE_MODE_AUTO_REPEAT] = 1;
- v->private_modes[VT102_PRIVATE_MODE_SHOW_CURSOR] = 1;
- v->modes[VT102_MODE_LOCAL_ECHO_OFF] = 1;
-
vt102_cursor_home (v);
+ vt102_status_line (v, "");
+
vt102_reset_tabs (v);
v->current_line = v->pos;
vt102_save_state (v);
- vt102_status_line (v, "");
-
v->last_reg_char = ' ';
-
-
-}
-
-int
-vt102_dispatch (Context * c)
-{
- char buf[1024];
- int red;
-
- red = c->t->recv (c->t, buf, sizeof (buf));
-
- if (red < 0)
- return -1;
- if (!red)
- return 0;
-
-
- vt102_parse (c, buf, red);
-
- return 0;
}
-
-
-int
-vt102_dispatch_one (Context * c)
-{
- char buf;
- int red;
-
- red = c->t->recv (c->t, &buf, sizeof (buf));
-
- if (red < 0)
- return -1;
- if (!red)
- return 0;
-
- vt102_parse_char (c, buf);
-
- return 0;
-}
-
VT102 *
vt102_new (void)
{
VT102 *v;
v = (VT102 *) malloc (sizeof (VT102));
+
v->xn_glitch=1;
vt102_reset (v);