Package: pterm
Version: 0.60+2010-02-20-1
Severity: wishlist
Tags: patch

Hi,

 Here's the latest version of my patch to support xterm escape sequences OSC
10 and OSC 11 (to set forground and background colour).  The patch should 
apply cleanly to both 0.60 and 0.61.

J.

diff -r -u putty-0.61-orig/terminal.c putty-0.61/terminal.c
--- putty-0.61-orig/terminal.c     2011-05-07 11:57:19.000000000 +0100
+++ putty-0.61/terminal.c          2011-09-23 16:19:14.000000000 +0100
@@ -2442,6 +2442,35 @@

 /*
  * Process an OSC sequence: set window title or icon name.
+ *
+ * type  source      sup? action
+ *
+ *   0   xterm          y Set window title and icon name
+ *   1   xterm          y Set icon name
+ *   2   xterm          y Set window title
+ *   3   gnome-terminal n Set X text property for window
+ *  10   rxvt           n `menu'
+ *  10   xterm          y Set foreground  colour
+ *  11   xterm          y Set background  colour
+ *  12   xterm          y Set cursor      colour (pterm cursor background)
+ *  13   xterm          n Set mouse fg    colour
+ *  14   xterm          n Set mouse bg    colour
+ *  15   xterm          n Set tek fg      colour
+ *  16   xterm          n Set tek bg      colour
+ *  17   xterm          n Set highlighted colour (background)
+ *  20   rxvt           n Set background pixmap
+ *  21   DEC            y Set window title
+ *  39   rxvt           n Set default fg colour
+ *  46   xterm          n Change log file (security implications!)
+ *  49   rxvt           n Set default bg colour
+ *  50   xterm          n Set font
+ *  51   xterm          n (unimplemented, reserved for the Emacs Shell)
+ *  90-97 NCD           n VT320 emulation `colour pair selection'
+ *               (see http://ist.uwaterloo.ca/~swball/ncd/term_em8.htm)
+ *
+ * Note that there is no code for `set <thing> bold colour' or for
+ * `set cursor foreground colour', however this is implemented in OSC P
+ * The NCD codes 90-97 are unlikely to be useful for putty.
  */
 static void do_osc(Terminal *term)
 {
@@ -2464,6 +2493,58 @@
            if (!term->cfg.no_remote_wintitle)
                set_title(term->frontend, term->osc_string);
            break;
+            /* Some very simple xterm palette changing handling */
+          case 10:                     /* Set foreground */
+          case 11:                     /* Set background */
+            {
+              char * p;
+              int n;
+              int ii;
+              int col = (((term->esc_args[0] - 10) * 2) + 16);
+              const int max=16;
+              char c;
+
+              /* We don't want to deal with the faff of named colours */
+              if (term->osc_string[0] != '#') break;
+              /* We also don't want to deal with redefining
+                 more than one colour at once */
+              if ((p = strchr(term->osc_string, ';'))) {
+                p='\0';
+              }
+              n = strlen(term->osc_string) - 1;
+              /* There should be three sets of digits, all the same length */
+              if (((n % 3) != 0) || (n < 3)) break;
+
+              for ( ii = 0; ii < n; ii++ ) {
+                c=term->osc_string[ii+1];
+                if (c >= '0' && c <= '9')
+                  c = c - '0';
+                else if (c >= 'A' && c <= 'A' + max - 10)
+                  c = c - 'A' + 10;
+                else if (c >= 'a' && c <= 'a' + max - 10)
+                  c = c - 'a' + 10;
+                else {
+                  break;
+                }
+                term->osc_string[ii+1]=c;
+              }
+
+              n /= 3;
+
+              if (n == 1) {
+                palette_set(term->frontend, col,
+                            term->osc_string[1]*17,
+                            term->osc_string[2]*17,
+                            term->osc_string[3]*17);
+              }
+              else {
+                palette_set(term->frontend, col,
+                            term->osc_string[    1]*16+term->osc_string[    2],
+                            term->osc_string[  n+1]*16+term->osc_string[  n+2],
+                            
term->osc_string[2*n+1]*16+term->osc_string[2*n+2]);
+              }
+              term_invalidate(term);
+            }
        }
     }
 }



-- System Information:
Debian Release: 6.0.1
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.32-5-686 (SMP w/2 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages pterm depends on:
ii  libatk1.0-0            1.30.0-1          The ATK accessibility toolkit
ii  libc6                  2.11.2-10         Embedded GNU C Library: Shared lib
ii  libcairo2              1.8.10-6          The Cairo 2D vector graphics libra
ii  libfontconfig1         2.8.0-2.1         generic font configuration library
ii  libfreetype6           2.4.2-2.1         FreeType 2 font engine, shared lib
ii  libglib2.0-0           2.24.2-1          The GLib library of C routines
ii  libgtk2.0-0            2.20.1-2          The GTK+ graphical user interface 
ii  libpango1.0-0          1.28.3-1+squeeze2 Layout and rendering of internatio
ii  libx11-6               2:1.3.3-4         X11 client-side library

pterm recommends no packages.

Versions of packages pterm suggests:
pn  putty-doc                     <none>     (no description available)

-- debconf-show failed



-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to