Fixed the printing and charset combo boxes in Unix PuTTY. (The
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sat, 5 Apr 2003 16:36:11 +0000 (16:36 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sat, 5 Apr 2003 16:36:11 +0000 (16:36 +0000)
former by simply removing it; the latter by adding an enumeration
function to libcharset.) This has had slight `const' repercussions
on cp_name() and cp_enumerate() which might break the Mac build.

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

Recipe
charset/charset.h
config.c
putty.h
unicode.c
unix/ptermm.c
unix/uxputty.c
unix/uxucs.c

diff --git a/Recipe b/Recipe
index 6bb4fa1..71eeb15 100644 (file)
--- a/Recipe
+++ b/Recipe
@@ -124,7 +124,7 @@ MACMISC  = misc version macstore settings tree234 macnet mtcpnet otnet proxy
          + macmisc macabout
 
 # Character set library, for use in pterm.
-CHARSET  = sbcsdat slookup sbcs utf8 toucs fromucs xenc mimeenc macenc
+CHARSET  = sbcsdat slookup sbcs utf8 toucs fromucs xenc mimeenc macenc localenc
 
 # Standard libraries, and the same with WinSocks 1 and 2.
 LIBS     = advapi32.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib
index 7dd038b..0a2e919 100644 (file)
@@ -137,6 +137,14 @@ const char *charset_to_mimeenc(int charset);
 int charset_from_mimeenc(const char *name);
 
 /*
+ * Convert our own encoding names to and from our charset
+ * identifiers.
+ */
+const char *charset_to_localenc(int charset);
+int charset_from_localenc(const char *name);
+int charset_localenc_nth(int n);
+
+/*
  * Convert Mac OS script/region/font to our charset identifiers.
  */
 int charset_from_macenc(int script, int region, int sysvers,
index 5488031..239247d 100644 (file)
--- a/config.c
+++ b/config.c
@@ -162,7 +162,7 @@ static void codepage_handler(union control *ctrl, void *dlg,
     Config *cfg = (Config *)data;
     if (event == EVENT_REFRESH) {
        int i;
-       char *cp;
+       const char *cp;
        dlg_update_start(ctrl, dlg);
        strcpy(cfg->line_codepage,
               cp_name(decode_codepage(cfg->line_codepage)));
diff --git a/putty.h b/putty.h
index 76bfe00..f985ad2 100644 (file)
--- a/putty.h
+++ b/putty.h
@@ -728,8 +728,8 @@ int wc_to_mb(int codepage, int flags, wchar_t *wcstr, int wclen,
 wchar_t xlat_uskbd2cyrllic(int ch);
 int check_compose(int first, int second);
 int decode_codepage(char *cp_name);
-char *cp_enumerate (int index);
-char *cp_name(int codepage);
+const char *cp_enumerate (int index);
+const char *cp_name(int codepage);
 void get_unitab(int codepage, wchar_t * unitab, int ftype);
 
 /*
index 0242733..c68017a 100644 (file)
--- a/unicode.c
+++ b/unicode.c
@@ -1094,7 +1094,7 @@ int decode_codepage(char *cp_name)
     return codepage;
 }
 
-char *cp_name(int codepage)
+const char *cp_name(int codepage)
 {
     const struct cp_list_item *cpi, *cpno;
     static char buf[32];
@@ -1134,7 +1134,7 @@ char *cp_name(int codepage)
  * Return the nth code page in the list, for use in the GUI
  * configurer.
  */
-char *cp_enumerate(int index)
+const char *cp_enumerate(int index)
 {
     if (index < 0 || index >= lenof(cp_list))
        return NULL;
index 58b42b6..6cdeffc 100644 (file)
@@ -9,27 +9,6 @@
 
 const char *const appname = "pterm";
 
-/*
- * Another bunch of temporary stub functions. These ones will want
- * removing by means of implementing them properly: libcharset
- * should invent its own sensible format for codepage names and a
- * means of enumerating them, and printer_enum needs to be dealt
- * with somehow or other too.
- */
-
-char *cp_name(int codepage)
-{
-    return "";
-}
-char *cp_enumerate(int index)
-{
-    return NULL;
-}
-int decode_codepage(char *cp_name)
-{
-    return -2;
-}
-
 Backend *select_backend(Config *cfg)
 {
     return &pty_backend;
index 18f1b6b..53ee0d8 100644 (file)
 /*
  * TODO:
  * 
- *  - libcharset enumeration.
- * 
- *  - fix the printer enum (I think the sensible thing is simply to
- *    have uxcfg.c remove the drop-down list completely, since you
- *    can't sensibly provide an enumerated list of lpr commands!).
- * 
  *  - Remainder of the context menu:
  * 
  *     - Event Log (this means we must implement the Event Log; not
@@ -73,27 +67,6 @@ void cleanup_exit(int code)
     exit(code);
 }
 
-/*
- * Another bunch of temporary stub functions. These ones will want
- * removing by means of implementing them properly: libcharset
- * should invent its own sensible format for codepage names and a
- * means of enumerating them, and printer_enum needs to be dealt
- * with somehow or other too.
- */
-
-char *cp_name(int codepage)
-{
-    return "";
-}
-char *cp_enumerate(int index)
-{
-    return NULL;
-}
-int decode_codepage(char *cp_name)
-{
-    return -2;
-}
-
 const char *const appname = "PuTTY";
 
 Backend *select_backend(Config *cfg)
index 8731239..f3d6a89 100644 (file)
@@ -8,6 +8,7 @@
 #include <time.h>
 
 #include "putty.h"
+#include "charset.h"
 #include "terminal.h"
 #include "misc.h"
 
@@ -122,9 +123,7 @@ int init_ucs(struct unicode_data *ucsdata,
      * line_codepage should be decoded from the specification in
      * cfg.
      */
-    ucsdata->line_codepage = charset_from_mimeenc(linecharset);
-    if (ucsdata->line_codepage == CS_NONE)
-       ucsdata->line_codepage = charset_from_xenc(linecharset);
+    ucsdata->line_codepage = decode_codepage(linecharset);
 
     /*
      * If line_codepage is _still_ CS_NONE, we assume we're using
@@ -218,3 +217,28 @@ int init_ucs(struct unicode_data *ucsdata,
 
     return ret;
 }
+
+const char *cp_name(int codepage)
+{
+    if (codepage == CS_NONE)
+       return "Use font encoding";
+    return charset_to_localenc(codepage);
+}
+
+const char *cp_enumerate(int index)
+{
+    int charset;
+    if (index == 0)
+       return "Use font encoding";
+    charset = charset_localenc_nth(index-1);
+    if (charset == CS_NONE)
+       return NULL;
+    return charset_to_localenc(charset);
+}
+
+int decode_codepage(char *cp_name)
+{
+    if (!*cp_name)
+       return CS_NONE;                /* use font encoding */
+    return charset_from_localenc(cp_name);
+}