Statusline showencoding patch

Yi-Jheng Lin <[email protected]> Wed, 28 May 2008 15:34:15 +0800
Newsgroups gmane.comp.gnu.screen
Message-ID <20080528073415.GA31918__29085.2551385344$1238088992$gmane$org@stucgi.cs.nctu.edu.tw>
Dear,
    I'm so glad that screen supports the encoding transformation. That's really a great function for me to switch between Big5 & UTF-8 environment! But sometimes I may be confused "What encoding am I using?". Although, I can use "Ctrl-a i" to get the information of current window (including the encoding info).  I was wondering if the statusline could show the encoding of current window, so I patch it!

    With this patch, I could add a new parameter "%e" to statusline for showing the encoding of current window. This might not be a good solution, but it does work!

    The following is the patch.

--- screen.c.orig	2008-05-08 02:37:22.000000000 +0800
+++ screen.c	2008-05-20 20:34:37.000000000 +0800
@@ -2584,6 +2584,18 @@
 	    }
 	  p += strlen(p) - 1;
 	  break;
+#ifdef ENCODINGS
+	case 'e':
+	  *p = 0;
+	  D_encoding = nwin_options.encoding > 0 ? nwin_options.encoding : 0;
+	  if (win && win->w_encoding)
+	    {
+	      *p++ = ' ';
+	      strcpy(p, EncodingName(win->w_encoding));
+	    }
+	  p += strlen(p) - 1;
+	  break;
+#endif
 	case '{':
           {
 	    char rbuf[128];
    
--- process.c.orig	2008-05-08 02:37:33.000000000 +0800
+++ process.c	2008-05-08 02:37:49.000000000 +0800
@@ -3422,6 +3422,7 @@
 	    {
 	      WinSwitchEncoding(fore, n);
 	      ResetCharsets(fore);
+	      RedisplayDisplays(0);
 	    }
 	  else if (i && display)
 	    D_encoding  = n;

    I would like to see this function in future version. :)

    BRs,
    yzlin


-- 
__   ________     ___ _   _     Name:   林宜政 Yi-Jheng, Lin
\ \ / /__  / |   |_ _| \ | |    E-Mail: [email protected], [email protected]
 \ V /  / /| |    | ||  \| |    MSN:    [email protected]
  | |  / /_| |___ | || |\  |    Web:    http://blog.yzlin.org
  |_| /____|_____|___|_| \_|    Flickr: http://www.flickr.com/photos/yzlin1985/