Support for more SCO ANSI escape sequences:
authorben <ben@cda61777-01e9-0310-a592-d414129be87e>
Sun, 15 Jun 2003 22:05:05 +0000 (22:05 +0000)
committerben <ben@cda61777-01e9-0310-a592-d414129be87e>
Sun, 15 Jun 2003 22:05:05 +0000 (22:05 +0000)
CSI = Ps c
CSI = Pn1 ; Pn2 C
CSI = Ps D
CSI = Ps F
CSI = Ps G
SGR 6

Patch derived from one supplied by Leonid Lisoskiy, with several fixes from me.

git-svn-id: svn://svn.tartarus.org/sgt/putty@3263 cda61777-01e9-0310-a592-d414129be87e

terminal.c

index 05a6233..68363c0 100644 (file)
@@ -56,6 +56,8 @@
 
 #define has_compat(x) ( ((CL_##x)&term->compatibility_level) != 0 )
 
+const char sco2ansicolour[] = { 0, 4, 2, 6, 1, 5, 3, 7 };
+
 #define sel_nl_sz  (sizeof(sel_nl)/sizeof(wchar_t))
 const wchar_t sel_nl[] = SEL_NL;
 
@@ -2390,6 +2392,11 @@ void term_out(Terminal *term)
                                    compatibility(VT100AVO);
                                    term->curr_attr |= ATTR_BLINK;
                                    break;
+                                 case 6:       /* SCO light bkgrd */
+                                   compatibility(SCOANSI);
+                                   term->blink_is_real = FALSE;
+                                   term->curr_attr |= ATTR_BLINK;
+                                   break;
                                  case 7:       /* enable reverse video */
                                    term->curr_attr |= ATTR_REVERSE;
                                    break;
@@ -2726,8 +2733,71 @@ void term_out(Terminal *term)
                            check_selection(term, old_curs, term->curs);
                        }
                        break;
+                     case ANSI('c', '='):      /* Hide or Show Cursor */
+                       compatibility(SCOANSI);
+                       switch(term->esc_args[0]) {
+                         case 0:  /* hide cursor */
+                           term->cursor_on = FALSE;
+                           break;
+                         case 1:  /* restore cursor */
+                           term->big_cursor = FALSE;
+                           term->cursor_on = TRUE;
+                           break;
+                         case 2:  /* block cursor */
+                           term->big_cursor = TRUE;
+                           term->cursor_on = TRUE;
+                           break;
+                       }
+                       break;
+                     case ANSI('C', '='):
+                       /*
+                        * set cursor start on scanline esc_args[0] and
+                        * end on scanline esc_args[1].If you set
+                        * the bottom scan line to a value less than
+                        * the top scan line, the cursor will disappear.
+                        */
+                       compatibility(SCOANSI);
+                       if (term->esc_nargs >= 2) {
+                           if (term->esc_args[0] > term->esc_args[1])
+                               term->cursor_on = FALSE;
+                           else
+                               term->cursor_on = TRUE;
+                       }
+                       break;
+                     case ANSI('D', '='):
+                       compatibility(SCOANSI);
+                       term->blink_is_real = FALSE;
+                       if (term->esc_args[0]>=1)
+                           term->curr_attr |= ATTR_BLINK;
+                       else
+                           term->curr_attr &= ~ATTR_BLINK;
+                       break;
+                     case ANSI('E', '='):
+                       compatibility(SCOANSI);
+                       term->blink_is_real = (term->esc_args[0] >= 1);
+                       break;
+                     case ANSI('F', '='):      /* set normal foreground */
+                       compatibility(SCOANSI);
+                       if (term->esc_args[0] >= 0 && term->esc_args[0] < 16) {
+                           term->curr_attr &= ~ATTR_FGMASK;
+                           term->curr_attr |=
+                               (sco2ansicolour[term->esc_args[0] & 0x7] |
+                                ((term->esc_args[0] & 0x8) << 1)) <<
+                               ATTR_FGSHIFT;
+                       }
+                       break;
+                     case ANSI('G', '='):      /* set normal background */
+                       compatibility(SCOANSI);
+                       if (term->esc_args[0] >= 0 && term->esc_args[0] < 16) {
+                           term->curr_attr &= ~ATTR_BGMASK;
+                           term->curr_attr |=
+                               (sco2ansicolour[term->esc_args[0] & 0x7] |
+                                ((term->esc_args[0] & 0x8) << 1)) <<
+                               ATTR_BGSHIFT;
+                       }
+                       break;
                      case ANSI('L', '='):
-                       compatibility(OTHER);
+                       compatibility(SCOANSI);
                        term->use_bce = (term->esc_args[0] <= 0);
                        term->erase_char = ERASE_CHAR;
                        if (term->use_bce)
@@ -2735,10 +2805,6 @@ void term_out(Terminal *term)
                                                (term->curr_attr & 
                                                 (ATTR_FGMASK | ATTR_BGMASK)));
                        break;
-                     case ANSI('E', '='):
-                       compatibility(OTHER);
-                       term->blink_is_real = (term->esc_args[0] >= 1);
-                       break;
                      case ANSI('p', '"'):
                        /*
                         * Allow the host to make this emulator a