Limited number of iterations in rote_vt_update to avoid infinite loop with ever-avail...
[apps/madtty.git] / inject_csi.c
index 2d3ba65..e7652aa 100644 (file)
@@ -1,3 +1,24 @@
+/*
+LICENSE INFORMATION:
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License (LGPL) as published by the Free Software Foundation.
+
+Please refer to the COPYING file for more information.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+
+Copyright (c) 2004 Bruno T. C. de Oliveira
+*/
+
+
 #include "inject_csi.h"
 #include "roteprivate.h"
 #include <stdlib.h>
@@ -27,11 +48,43 @@ static void interpret_csi_SGR(RoteTerm *rt, int param[], int pcount) {
    }
 
    for (i = 0; i < pcount; i++) {
+
+// From http://vt100.net/docs/vt510-rm/SGR table 5-16
+// 0   All attributes off
+// 1   Bold
+// 4   Underline
+// 5   Blinking
+// 7   Negative image
+// 8   Invisible image
+// 10  The ASCII character set is the current 7-bit
+//     display character set (default) - SCO Console only.
+// 11  Map Hex 00-7F of the PC character set codes
+//     to the current 7-bit display character set
+//     - SCO Console only.
+// 12  Map Hex 80-FF of the current character set to
+//     the current 7-bit display character set - SCO
+//     Console only.
+// 22  Bold off
+// 24  Underline off
+// 25  Blinking off
+// 27  Negative image off
+// 28  Invisible image off
+
       if (param[i] == 0) rt->curattr = 0x70;
       else if (param[i] == 1 || param[i] == 2 || param[i] == 4)  /* set bold */
-         rt->curattr |= 0x80;
-      else if (param[i] == 5) rt->curattr |= 0x08;  /* set blink */
+         ROTE_ATTR_MOD_BOLD(rt->curattr,1);
+      else if (param[i] == 5)  /* set blink */
+         ROTE_ATTR_MOD_BLINK(rt->curattr,1);
       else if (param[i] == 7) rt->curattr = 0x07;   /* reverse video */
+      else if (param[i] == 8) rt->curattr = 0x0;    /* invisible */
+      else if (param[i] == 22 || param[i] == 24) /* bold off */
+        ROTE_ATTR_MOD_BOLD(rt->curattr,0);
+      else if (param[i] == 25) /* blink off */
+        ROTE_ATTR_MOD_BLINK(rt->curattr,0);
+      else if (param[i] == 27) /* negative off */
+        rt->curattr = 0x70;
+      else if (param[i] == 28) /* invisible off */
+        rt->curattr = 0x70;
       else if (param[i] >= 30 && param[i] <= 37)    /* set fg */
          ROTE_ATTR_MOD_FG(rt->curattr, param[i] - 30);
       else if (param[i] >= 40 && param[i] <= 47)    /* set bg */