1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 09:27:59 +00:00

Fixed the printing and charset combo boxes in Unix PuTTY. (The

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.

[originally from svn r3064]
This commit is contained in:
Simon Tatham 2003-04-05 16:36:11 +00:00
parent 09c9f31289
commit cf08c5a64a
8 changed files with 41 additions and 57 deletions

2
Recipe
View File

@ -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

View File

@ -136,6 +136,14 @@ int charset_from_xenc(const char *name);
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.
*/

View File

@ -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)));

View File

@ -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);
/*

View File

@ -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;

View 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;

View File

@ -14,12 +14,6 @@
/*
* 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)

View 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);
}