aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjames <>2008-03-07 12:00:58 +0000
committerjames <>2008-03-07 12:00:58 +0000
commitd61d603fbfc1f9c5bc03d26fee8ffdf18e2c0faf (patch)
treece08de6c15232aba57f9c3c60053c44695705092
parentb3b7dcdcf17fcfc152e05c385288335d9e3729d3 (diff)
downloadsympathy-d61d603fbfc1f9c5bc03d26fee8ffdf18e2c0faf.tar.gz
sympathy-d61d603fbfc1f9c5bc03d26fee8ffdf18e2c0faf.tar.bz2
sympathy-d61d603fbfc1f9c5bc03d26fee8ffdf18e2c0faf.zip
*** empty log message ***
-rw-r--r--src/vt102.c279
1 files changed, 147 insertions, 132 deletions
diff --git a/src/vt102.c b/src/vt102.c
index 7ab2d90..604a41e 100644
--- a/src/vt102.c
+++ b/src/vt102.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.63 2008/03/07 12:00:58 james
+ * *** empty log message ***
+ *
* Revision 1.62 2008/03/06 21:34:09 james
* *** empty log message ***
*
@@ -616,11 +619,6 @@ vt102_do_pending_wrap (Context * c)
if (!v->pending_wrap)
return;
-#if 0
- fprintf (stderr, "ca: (%d,%d) autowrap %d couldscroll %d\n", v->pos.x,
- v->pos.y, autowrap, couldscroll);
-#endif
-
/*End of line but no autowrap, nothing to do*/
if (!autowrap)
return;
@@ -815,10 +813,6 @@ vt102_change_mode (Context * c, int private, char *ns, int set)
case VT102_PRIVATE_MODE_CURSOR_MODE:
if (v->application_keypad_mode)
v->private_modes[m] = 0;
-#if 0
- fprintf (stderr, "APPLICATION CURSOR MODE %d wanted %d\n",
- v->private_modes[m], set);
-#endif
break;
case VT102_PRIVATE_MODE_ORIGIN_MODE:
vt102_cursor_home (v);
@@ -838,10 +832,6 @@ vt102_change_mode (Context * c, int private, char *ns, int set)
}
else
v->modes[m] = set;
-
-#if 0
- fprintf (stderr, "mode set=%d private=%d num=%d\n", set, private, m);
-#endif
}
void
@@ -1002,12 +992,6 @@ vt102_change_attr (VT102 * v, char *na)
v->color |=
(CRT_BGCOLOR_NORMAL << CRT_COLOR_BG_SHIFT) & CRT_COLOR_BG_MASK;
break;
-
- default:
- ;
-#if 0
- fprintf (stderr, "unhandled SGR %d\n", a);
-#endif
}
}
@@ -1163,9 +1147,6 @@ vt102_parse_csi (Context * c, char *buf, int len)
buf[len] = 0;
last = buf[len - 1];
-#if 0
- buf[len - 1] = 0;
-#endif
if (len > 2)
{
@@ -1178,40 +1159,40 @@ vt102_parse_csi (Context * c, char *buf, int len)
switch (buf[0])
{
- case '[':
+ case '[': /*CSI*/
switch (last)
{
- case '@':
+ case '@': /*ICH*/
while (narg--)
vt102_insert_into_line (v, v->pos);
break;
- case 'A':
+ case 'A': /*CUU*/
vt102_cursor_relative (v, 0, -narg);
break;
- case 'e':
- case 'B':
+ case 'e': /*VPR*/
+ case 'B': /*CUD*/
vt102_cursor_relative (v, 0, narg);
break;
- case 'a':
- case 'C':
+ case 'a': /*HPR*/
+ case 'C': /*CUF*/
vt102_cursor_relative (v, narg, 0);
break;
- case 'D':
+ case 'D': /*CUB*/
vt102_cursor_relative (v, -narg, 0);
break;
- case 'E':
+ case 'E': /*CNL*/
vt102_cursor_relative (v, 0, narg);
vt102_cursor_carriage_return (v);
break;
- case 'F':
+ case 'F': /*CPL*/
vt102_cursor_relative (v, 0, -narg);
vt102_cursor_carriage_return (v);
break;
- case 'G':
+ case 'G': /*CHG*/
vt102_cursor_absolute (v, narg - 1, v->pos.y);
break;
- case 'H':
- case 'f':
+ case 'H': /*CUP*/
+ case 'f': /*HVP*/
{
int x, y;
@@ -1226,11 +1207,11 @@ vt102_parse_csi (Context * c, char *buf, int len)
vt102_cursor_absolute (v, x, y);
}
break;
- case 'I':
+ case 'I': /*CHT*/
while (narg--)
vt102_cursor_advance_tab (c->v);
break;
- case 'J':
+ case 'J': /*ED*/
if (len == 2)
narg = 0; /*Different default */
switch (narg)
@@ -1247,7 +1228,7 @@ vt102_parse_csi (Context * c, char *buf, int len)
break;
}
break;
- case 'K':
+ case 'K': /*EL*/
{
CRT_Pos ls = { 0, v->pos.y };
CRT_Pos le = { v->current_size.x - 1, v->pos.y };
@@ -1269,7 +1250,7 @@ vt102_parse_csi (Context * c, char *buf, int len)
}
break;
- case 'L':
+ case 'L': /*IL*/
if ((v->pos.y >= v->top_margin.y)
&& (v->pos.y <= v->bottom_margin.y))
{
@@ -1279,7 +1260,7 @@ vt102_parse_csi (Context * c, char *buf, int len)
}
break;
- case 'M':
+ case 'M': /*DL*/
if ((v->pos.y >= v->top_margin.y)
&& (v->pos.y <= v->bottom_margin.y))
{
@@ -1291,11 +1272,11 @@ vt102_parse_csi (Context * c, char *buf, int len)
}
}
break;
- case 'P':
+ case 'P': /*DCH*/
while (narg--)
vt102_delete_from_line (v, v->pos);
break;
- case 'S':
+ case 'S': /*SU*/
while (narg--)
{
vt102_history (c, v->top_margin, v->bottom_margin);
@@ -1303,12 +1284,12 @@ vt102_parse_csi (Context * c, char *buf, int len)
v->color);
}
break;
- case 'T':
+ case 'T': /*SD*/
while (narg--)
crt_scroll_down (&v->crt, v->top_margin, v->bottom_margin, 1,
v->color);
break;
- case 'X':
+ case 'X': /*ECH*/
{
CRT_Pos end = v->pos;
if (!narg)
@@ -1321,30 +1302,30 @@ vt102_parse_csi (Context * c, char *buf, int len)
crt_erase (&v->crt, v->pos, end, 1, v->color);
}
break;
- case 'Z':
+ case 'Z': /*CBT*/
while (narg--)
vt102_cursor_retreat_tab (c->v);
break;
- case '`':
+ case '`': /*HPA*/
vt102_cursor_absolute (v, narg - 1, v->pos.y);
break;
- case 'b':
+ case 'b': /*REP*/
while (narg--)
{
vt102_regular_char (c, v, v->last_reg_char);
err += vt102_rx_hook (c, v->last_reg_char);
}
break;
- case 'c':
+ case 'c': /*DA*/
/* For some obscure reason some programs seem to send */
/* CSI [ ? .. c, which we ignore */
if (buf[1] != '?')
vt102_send_id (c, "\033[?2c");
break;
- case 'd':
+ case 'd': /*VPA*/
vt102_cursor_absolute (v, v->pos.x, narg - 1);
break;
- case 'g':
+ case 'g': /*TBC*/
if (len == 2)
narg = 0; /*Different default */
@@ -1360,25 +1341,23 @@ vt102_parse_csi (Context * c, char *buf, int len)
}
break;
- case 'i': //Printer commands
+ case 'i': /*MC*/ //Printer commands
//FIXME
break;
- case 'h':
- case 'l':
+ case 'h': /*SM*/
+ case 'l': /*RM*/
vt102_parse_mode_string (c, &buf[1], len - 1);
break;
-
-
- case 'm':
+ case 'm': /*SGR*/
vt102_parse_attr_string (v, &buf[1], len - 1);
break;
- case 'n': //Device status report
+ case 'n': /*DSR*/ //Device status report
switch (buf[1])
{
- case '5':
+ case '5':
vt102_send_id (c, "\033[0n");
break;
- case '6':
+ case '6': /*CPR*/
if (c->t)
{
char buf[16];
@@ -1394,9 +1373,9 @@ vt102_parse_csi (Context * c, char *buf, int len)
__LINE__, buf);
}
break;
- case 'q': //Load LED on off
+ case 'q': /*DECLL*/ //Load LED on off
break;
- case 'r':
+ case 'r': /*DECSTBM*/
v->top_margin = v->screen_start;
v->bottom_margin = v->screen_end;
@@ -1418,17 +1397,17 @@ vt102_parse_csi (Context * c, char *buf, int len)
vt102_cursor_home (v);
break;
- case 's':
+ case 's': /*SCP*/
v->saved.pos = v->pos;
break;
- case 'u':
+ case 'u': /*RCP*/
v->pos = v->saved.pos;
vt102_cursor_normalize (v);
v->pending_wrap = 0;
break;
- case 'y': //Invoke confidence test
+ case 'y': /*DECTST*/ //Invoke confidence test
break;
- case 'z': //request terminal parameters
+ case 'z': /*DECVERP*/ //request terminal parameters
break;
default:
@@ -1469,51 +1448,51 @@ vt102_parse_esc (Context * c)
switch (p->cmd_buf[0])
{
- case 'A':
+ case 'A': /*CURSOR UP*/
vt102_cursor_relative (v, 0, -1);
break;
- case 'B':
+ case 'B': /*CURSOR DOWN*/
vt102_cursor_relative (v, 0, 1);
break;
- case 'C':
+ case 'C': /*CURSOR RIGHT*/
vt102_cursor_relative (v, 1, 0);
break;
- case 'D':
+ case 'D': /*CURSOR LEFT*/
vt102_cursor_relative (v, -1, 0);
break;
- case 'F':
+ case 'F': /*ENTER GRAPHICS MODE*/
v->cs = 1;
v->g[1] = VT102_CSID_VT52;
break;
- case 'G':
+ case 'G': /*EXIT GRAPHICS MODE*/
v->cs = 0;
v->g[0] = VT102_CSID_US;
break;
- case 'H':
+ case 'H': /*CURSOR HOME*/
vt102_cursor_absolute (v, 0, 0);
break;
- case 'I':
+ case 'I': /*REVERSE LINE FEED*/
vt102_cursor_retreat_line (c);
break;
- case 'J':
+ case 'J': /*ERASE TO END OF SCREEN*/
crt_erase (&v->crt, v->pos, v->screen_end, 1, v->color);
break;
- case 'K':
+ case 'K': /*ERASE TO END OF LINE*/
{
CRT_Pos le = { v->current_size.x - 1, v->pos.y };
crt_erase (&v->crt, v->pos, le, 1, v->color);
}
break;
- case 'Y':
+ case 'Y': /*DIRECT CURSOR ADDRESS*/
vt102_cursor_absolute (v, p->cmd_buf[2] - 040, p->cmd_buf[1] - 040);
break;
- case 'V': //Print current line
+ case 'V': /*PRINT CURSOR LINE*/ //Print current line
break;
- case 'W': //Printer on
+ case 'W': //Printer on
break;
case 'X': //printer off
break;
- case ']': //print screen
+ case ']': /*PRINT SCREEN */ //print screen
break;
case 'Z': //ID
vt102_send_id (c, "\033/K");
@@ -1522,10 +1501,10 @@ vt102_parse_esc (Context * c)
break;
case '_': //Autoprint off
break;
- case '=':
+ case '=': /*ENTER ALTERNATE KEYPAD MODE*/
v->application_keypad_mode = 1;
break;
- case '>':
+ case '>': /*EXIT ALTERNATE KEYPAD MODE*/
v->application_keypad_mode = 0;
break;
default:
@@ -1539,46 +1518,62 @@ vt102_parse_esc (Context * c)
/*If you edit this switch don't forget to edit the length and termination tables*/
switch (p->cmd_buf[0])
{
- case 'D':
+ case 'D': /*IND*/
vt102_cursor_advance_line (c);
break;
- case 'E':
+ case 'E': /*NEL*/
vt102_cursor_advance_line (c);
v->pos.x = v->top_margin.x;
vt102_cursor_normalize (v);
v->pending_wrap = 0;
break;
- case 'H':
+/*F SSA*/
+/*G ESA*/
+ case 'H': /*HTS*/
v->tabs[v->pos.x]++;
break;
- case 'M':
+/*I HTJ*/
+/*J VTS*/
+/*K PLD*/
+/*L PLU*/
+ case 'M': /*RI*/
vt102_cursor_retreat_line (c);
break;
- case 'N': //select G2 for one char
+ case 'N': /*SS2*/ //select G2 for one char
break;
- case 'O': //select G3 for one char
+ case 'O': /*SS3*/ //select G3 for one char
break;
- case 'Z':
+/*P DCS*/
+/*Q PU1*/
+/*R PU2*/
+/*S STS*/
+/*T CCH*/
+/*U MW*/
+/*V SPA*/
+/*W EPA*/
+/*X SOS*/
+/*Y SGCI*/
+ case 'Z': /*DECID*/
vt102_send_id (c, terminal_id);
break;
- case 'c':
+ case 'c': /*RIS*/
vt102_reset (c);
break;
- case '=':
+ case '=': /*DECKPAM*/
v->application_keypad_mode = 1;
break;
- case '>':
+ case '>': /*DECKPNM*/
v->application_keypad_mode = 0;
break;
case '#':
switch (p->cmd_buf[1])
{
- case '3': //top of double height line
- case '4': //bottom of double height line
- case '5': //single width line
- case '6': //double width line
+ case '3': /*DECDHL*/ //top of double height line
+ case '4': /*DECDHL*/ //bottom of double height line
+ case '5': /*DECSWL*/ //single width line
+ case '6': /*DECDWL*/ //double width line
break;
case '8':
/*DECALN*/
@@ -1598,27 +1593,26 @@ vt102_parse_esc (Context * c)
}
break;
- case '<':
+ case '<': /*DECANM*/
/*Set ansi mode - ignored */
break;
- case '7':
+ case '7': /*DECSC*/
vt102_save_state (v);
break;
- case '8':
+ case '8': /*DECRC*/
vt102_restore_state (v);
break;
- case ']': /*Set various titles */
- //FIXME:
+ case ']': /*Set various titles in xterm - ignored*/
break;
- case '[':
+ case '[': /*CSI*/
err += vt102_parse_csi (c, p->cmd_buf, p->cmd_ptr);
break;
- case '(': /*Charsets */
- case ')':
- case '+':
- case '*':
- case '%':
+ case '(': /*SCS*/ /*Charsets */
+ case ')': /*SCS*/
+ case '+': /*SCS*/
+ case '*': /*SCS*/
+ case '%': /*SCS*/
vt102_scs (c, p->cmd_buf[0], p->cmd_buf[1]);
break;
default:
@@ -1747,27 +1741,12 @@ vt102_parse_char (Context * c, int ch)
VT102 *v = c->v;
VT102_parser *p = &v->parser;
-#if 0
+#ifdef DEBUG
log_f (c->l, "char %3d %c ie=%d ic=%d cmb=%d ct=%3d %2d %2d %d", ch,
safe_ch (ch), p->in_escape, p->in_cmd, p->cmd_more_bytes,
p->cmd_termination, v->pos.x, v->pos.y, v->pending_wrap);
#endif
-/* Turn anything non-ascii into '?' */
-#if 0
- if ((ch != SYM_CHAR_RESET) && (ch != 0xb9) && (ch > 127))
- {
- ch = '?';
- }
-#endif
-
-
-#if 0
- if (p->dca_ptr == 2)
- {
- p->in_dca = 0;
- }
-#endif
if (ch == SYM_CHAR_RESET)
{
vt102_reset_state (c);
@@ -1818,12 +1797,51 @@ vt102_parse_char (Context * c, int ch)
if (!p->in_cmd)
err += vt102_parse_esc (c);
}
- else if (ch == 0x9b)
- { /*One byte CSI */
+ else if ((ch>=0x80) && (ch<0xa0))
+ { /*C1 characters*/
+switch (ch) {
+case 0x80: /*@ PAD*/
+case 0x81: /*A HOP*/
+case 0x82: /*B BPH*/
+case 0x83: /*C NBH*/
+case 0x84: /*D IND*/
+case 0x85: /*E NEL*/
+case 0x86: /*F SSA*/
+case 0x87: /*G ESA*/
+case 0x88: /*H HTS*/
+case 0x89: /*I HTJ*/
+case 0x8a: /*J VTS*/
+case 0x8b: /*K PLD*/
+case 0x8c: /*L PLU*/
+case 0x8d: /*M RI*/
+case 0x8e: /*N SS2*/
+case 0x8f: /*O SS3*/
+case 0x90: /*P DCS*/
+case 0x91: /*Q PU1*/
+case 0x92: /*R PU2*/
+case 0x93: /*S STS*/
+case 0x94: /*T CCH*/
+case 0x95: /*U MW*/
+case 0x96: /*V SPA*/
+case 0x97: /*W EPA*/
+case 0x98: /*X SOS*/
+case 0x99: /*Y SGCI*/
+case 0x9a: /*Z DECID*/
+case 0x9b: /*[ CSI*/
+case 0x9c: /*\ ST*/
+case 0x9d: /*] OSC*/
+case 0x9e: /*^ PM*/
+case 0x9f: /*_ APC*/
p->cmd_ptr = 0;
- p->cmd_buf[p->cmd_ptr++] = '[';
+ p->cmd_buf[p->cmd_ptr++] = ch;
+ p->in_escape = 0;
pre_parse_cmd (ch, p);
+
+ if (!p->in_cmd)
+ err += vt102_parse_esc (c);
+ break;
+}
}
else
{
@@ -1839,7 +1857,7 @@ vt102_parse_char (Context * c, int ch)
{
/*NUL*/ case 0:
break;
-#if 0
+#ifdef HIDE_NON_PRINTABLES
/*SOH*/ case 1:
/*STX*/ case 2:
/*ETX*/ case 3:
@@ -1849,7 +1867,7 @@ vt102_parse_char (Context * c, int ch)
/*ENQ*/ case 5:
vt102_send_id (c, terminal_id);
break;
-#if 0
+#ifdef HIDE_NON_PRINTABLES
/*ACK*/ case 6:
break;
#endif
@@ -1883,7 +1901,7 @@ vt102_parse_char (Context * c, int ch)
/*select G0 */
v->cs = 0;
break;
-#if 0
+#ifdef HIDE_NON_PRINTABLES
/*DLE*/ case 16:
/*DC1 */ case 17:
/*DC2 */ case 18:
@@ -1900,7 +1918,7 @@ vt102_parse_char (Context * c, int ch)
/*ESC*/ case 27:
p->in_escape++;
break;
-#if 0
+#ifdef HIDE_NON_PRINTABLES
/*FS*/ case 28:
/*GS*/ case 29:
/*RS*/ case 30:
@@ -1934,9 +1952,6 @@ vt102_send (Context * c, uint8_t key)
if (!c->t)
return;
-#if 0
- fprintf (stderr, "vts: %d(%c)\n", key, (key > 31) ? key : ' ');
-#endif
if ((key > 31) && (key < 127))
{
c->t->xmit (c->t, &key, 1);