cfg->wordness[j] = atoi(q);
}
}
- gpps(sesskey, "LineCodePage", "ISO-8859-1:1987", cfg->line_codepage,
+ /*
+ * The empty default for LineCodePage will be converted later
+ * into a plausible default for the locale.
+ */
+ gpps(sesskey, "LineCodePage", "", cfg->line_codepage,
sizeof(cfg->line_codepage));
gppi(sesskey, "ScrollBar", 1, &cfg->scrollbar);
gppi(sesskey, "ScrollOnKey", 0, &cfg->scroll_on_key);
{"Win1257 (Baltic)", 1257},
{"Win1258 (Vietnamese)", 1258},
- /* All below here are aliases - First the windows ones. */
- {"Central European (Win1250)", 1250},
- {"Cyrillic (Win1251)", 1251},
- {"Western (Win1252)", 1252},
- {"Greek (Win1253)", 1253},
- {"Turkish (Win1254)", 1254},
- {"Hebrew (Win1255)", 1255},
- {"Arabic (Win1256)", 1256},
- {"Baltic (Win1257)", 1257},
- {"Vietnamese (Win1258)", 1258},
-
- {"ROMAN8", 0, 96, roman8},
- {"R8", 0, 96, roman8},
-
- /* Note this is Latin ->> */
- {"LATIN0", 0, 96, iso_8859_15},
- {"L0", 0, 96, iso_8859_15},
+ {"Win1258 (Vietnamese)", 1258},
+ {"CP437", 437},
{"CP819", 28591},
{"CP878", 20866},
- {"L1", 28591},
- {"L2", 28592},
- {"L3", 28593},
- {"L4", 28594},
- {"L5", 28599},
- {"LATIN1", 28591},
- {"LATIN2", 28592},
- {"LATIN3", 28593},
- {"LATIN4", 28594},
- {"LATIN5", 28599},
+
+ {"Use font encoding", -1},
+
{0, 0}
};
int codepage = -1;
CPINFO cpinfo;
+ if (!*cp_name) {
+ /*
+ * Here we select a plausible default code page based on
+ * the locale the user is in. We wish to select an ISO code
+ * page or appropriate local default _rather_ than go with
+ * the Win125* series, because it's more important to have
+ * CSI and friends enabled by default than the ghastly
+ * Windows extra quote characters, and because it's more
+ * likely the user is connecting to a remote server that
+ * does something Unixy or VMSy and hence standards-
+ * compliant than that they're connecting back to a Windows
+ * box using horrible nonstandard charsets.
+ *
+ * Accordingly, Robert de Bath suggests a method for
+ * picking a default character set that runs as follows:
+ * first call GetACP to get the system's ANSI code page
+ * identifier, and translate as follows:
+ *
+ * 1250 -> ISO 8859-2
+ * 1251 -> KOI8-U
+ * 1252 -> ISO 8859-1
+ * 1253 -> ISO 8859-7
+ * 1254 -> ISO 8859-9
+ * 1255 -> ISO 8859-8
+ * 1256 -> ISO 8859-6
+ * 1257 -> ISO 8859-4
+ *
+ * and for anything else, choose direct-to-font.
+ */
+ int cp = GetACP();
+ switch (cp) {
+ case 1250: cp_name = "ISO-8859-2"; break;
+ case 1251: cp_name = "KOI8-U"; break;
+ case 1252: cp_name = "ISO-8859-1"; break;
+ case 1253: cp_name = "ISO-8859-7"; break;
+ case 1254: cp_name = "ISO-8859-9"; break;
+ case 1255: cp_name = "ISO-8859-8"; break;
+ case 1256: cp_name = "ISO-8859-6"; break;
+ case 1257: cp_name = "ISO-8859-4"; break;
+ /* default: leave it blank, which will select -1, direct->font */
+ }
+ }
+
if (cp_name && *cp_name)
for (cpi = cp_list; cpi->name; cpi++) {
s = cp_name;
{
struct cp_list_item *cpi, *cpno;
static char buf[32];
+
+ if (codepage == -1) {
+ sprintf(buf, "Use font encoding");
+ return buf;
+ }
+
if (codepage > 0 && codepage < 65536)
sprintf(buf, "CP%03d", codepage);
else
}
/*
- * A static line, followed by a full-width drop-down list (ie a
- * non-editing combo box).
+ * A static line, followed by a full-width combo box.
*/
-void dropdownlist(struct ctlpos *cp, char *text, int staticid, int listid)
+void combobox(struct ctlpos *cp, char *text, int staticid, int listid)
{
RECT r;
r.bottom = COMBOHEIGHT * 10;
doctl(cp, r, "COMBOBOX",
WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL |
- CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_CLIENTEDGE, "", listid);
+ CBS_DROPDOWN | CBS_HASSTRINGS, WS_EX_CLIENTEDGE, "", listid);
cp->ypos += STATICHEIGHT + GAPWITHIN + COMBOHEIGHT + GAPBETWEEN;
}
{
int i;
char *cp;
- int index = 0;
+ strcpy(cfg.line_codepage, cp_name(decode_codepage(cfg.line_codepage)));
SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_RESETCONTENT, 0, 0);
for (i = 0; (cp = cp_enumerate(i)) != NULL; i++) {
SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_ADDSTRING,
0, (LPARAM) cp);
- if (!strcmp(cp, cfg.line_codepage))
- index = i;
}
- SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_SETCURSEL, index, 0);
+ SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
}
CheckRadioButton(hwnd, IDC_VTXWINDOWS, IDC_VTUNICODE,
endbox(&cp);
beginbox(&cp, "Character set translation on received data",
IDC_BOX_TRANSLATION2);
- dropdownlist(&cp,
- "Received data assumed to be in which character set:",
- IDC_CODEPAGESTATIC, IDC_CODEPAGE);
+ combobox(&cp, "Received data assumed to be in which character set:",
+ IDC_CODEPAGESTATIC, IDC_CODEPAGE);
endbox(&cp);
}
CB_GETCURSEL, 0, 0);
SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_GETLBTEXT,
index, (LPARAM)cfg.line_codepage);
+ } else if (HIWORD(wParam) == CBN_EDITCHANGE) {
+ GetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage,
+ sizeof(cfg.line_codepage) - 1);
+ } else if (HIWORD(wParam) == CBN_KILLFOCUS) {
+ strcpy(cfg.line_codepage,
+ cp_name(decode_codepage(cfg.line_codepage)));
+ SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
}
break;
case IDC_VTXWINDOWS:
char *btext1, int bid1, char *btext2, int bid2);
void staticedit(struct ctlpos *cp, char *stext,
int sid, int eid, int percentedit);
-void dropdownlist(struct ctlpos *cp, char *text, int staticid, int listid);
+void combobox(struct ctlpos *cp, char *text, int staticid, int listid);
void staticpassedit(struct ctlpos *cp, char *stext,
int sid, int eid, int percentedit);
void bigeditctrl(struct ctlpos *cp, char *stext,