Oleg Panashchenko's Cyrillic support patch

[originally from svn r277]
This commit is contained in:
Simon Tatham 1999-11-08 11:08:09 +00:00
Родитель 97994b235d
Коммит e913e99b40
9 изменённых файлов: 192 добавлений и 25 удалений

Просмотреть файл

@ -13,7 +13,7 @@ CFLAGS = /nologo /W3 /YX /O2 /Yd /D_WINDOWS /DDEBUG /ML /Fd
.c.obj:
cl $(COMPAT) $(FWHACK) $(CFLAGS) /c $*.c
PUTTYOBJS = window.obj windlg.obj terminal.obj telnet.obj raw.obj
PUTTYOBJS = window.obj windlg.obj terminal.obj telnet.obj raw.obj xlat.obj
OBJS1 = misc.obj noise.obj
OBJS2 = ssh.obj sshcrc.obj sshdes.obj sshmd5.obj sshrsa.obj sshrand.obj
OBJS3 = sshsha.obj sshblowf.obj version.obj sizetip.obj
@ -48,6 +48,7 @@ terminal.obj: terminal.c putty.h
sizetip.obj: sizetip.c putty.h
telnet.obj: telnet.c putty.h
raw.obj: raw.c putty.h
xlat.obj: xlat.c putty.h
misc.obj: misc.c putty.h
noise.obj: noise.c putty.h ssh.h
ssh.obj: ssh.c ssh.h putty.h

11
putty.h
Просмотреть файл

@ -123,6 +123,7 @@ typedef struct {
char font[64];
int fontisbold;
int fontheight;
int fontcharset;
VT_Mode vtmode;
/* Colour options */
int try_palette;
@ -131,6 +132,9 @@ typedef struct {
/* Selection options */
int mouse_is_xterm;
short wordness[256];
/* russian language translation */
int xlat_enablekoiwin;
int xlat_capslockcyr;
} Config;
/*
@ -258,6 +262,13 @@ void safefree(void *);
*/
extern char ver[];
/*
* Exports from xlat.c.
*/
unsigned char xlat_kbd2tty(unsigned char c);
unsigned char xlat_tty2scr(unsigned char c);
unsigned char xlat_latkbd2win(unsigned char c);
/*
* A debug system.
*/

Просмотреть файл

@ -1,3 +1,2 @@
void UpdateSizeTip(HWND src, int cx, int cy);
void EnableSizeTip(int bEnable);

Просмотреть файл

@ -665,7 +665,7 @@ void term_out(void) {
if (insert)
insch (1);
check_selection (cpos, cpos+1);
*cpos++ = c | curr_attr |
*cpos++ = xlat_tty2scr((unsigned char)c) | curr_attr |
(c <= 0x7F ? cset_attr[cset] : ATTR_ASCII);
curs_x++;
if (curs_x == cols) {
@ -1436,7 +1436,17 @@ void term_mouse (Mouse_Button b, Mouse_Action a, int x, int y) {
!(p <= data+len-sizeof(sel_nl) &&
!memcmp(p, sel_nl, sizeof(sel_nl))))
p++;
back->send (q, p-q);
{
int i;
unsigned char c;
for(i=0;i<p-q;i++)
{
c=xlat_kbd2tty(q[i]);
back->send(&c,1);
}
}
if (p <= data+len-sizeof(sel_nl) &&
!memcmp(p, sel_nl, sizeof(sel_nl))) {
back->send ("\r", 1);

Просмотреть файл

@ -11,6 +11,7 @@
#define IDD_PANEL35 107
#define IDD_PANEL4 108
#define IDD_PANEL5 109
#define IDD_PANEL6 114
#define IDD_LOGBOX 110
#define IDD_ABOUTBOX 111
#define IDD_RECONF 112
@ -124,4 +125,7 @@
#define IDC5_BVALUE 1010
#define IDC5_CHANGE 1011
#define IDC6_ENABLEKOIWINXLAT 1001
#define IDC6_CAPSLOCKCYR 1002
#endif

Просмотреть файл

@ -204,6 +204,16 @@ BEGIN
PUSHBUTTON "C&hange...", IDC5_CHANGE, 109, 140, 56, 14
END
IDD_PANEL6 DIALOG DISCARDABLE 6, 30, 168, 163
STYLE WS_CHILD | WS_VISIBLE
FONT 8, "MS Sans Serif"
BEGIN
AUTOCHECKBOX "Enable &KOI8-Win1251 translation",
IDC6_ENABLEKOIWINXLAT, 13, 14, 135, 10
AUTOCHECKBOX "&CAPS LOCK acts as cyrillic switch",
IDC6_CAPSLOCKCYR, 13, 30, 136, 10
END
IDD_LOGBOX DIALOG DISCARDABLE 100, 20, 160, 119
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "PuTTY Negotiation Log"

Просмотреть файл

@ -9,9 +9,9 @@
#include "putty.h"
#include "win_res.h"
#define NPANELS 7
#define MAIN_NPANELS 7
#define RECONF_NPANELS 4
#define NPANELS 8
#define MAIN_NPANELS 8
#define RECONF_NPANELS 5
static const char *const puttystr = PUTTY_REG_POS "\\Sessions";
@ -161,6 +161,7 @@ static void save_settings (char *section, int do_host) {
wppi (sesskey, "TermHeight", cfg.height);
wpps (sesskey, "Font", cfg.font);
wppi (sesskey, "FontIsBold", cfg.fontisbold);
wppi (sesskey, "FontCharSet", cfg.fontcharset);
wppi (sesskey, "FontHeight", cfg.fontheight);
wppi (sesskey, "FontVTMode", cfg.vtmode);
wppi (sesskey, "TryPalette", cfg.try_palette);
@ -184,6 +185,8 @@ static void save_settings (char *section, int do_host) {
}
wpps (sesskey, buf, buf2);
}
wppi (sesskey, "KoiWinXlat", cfg.xlat_enablekoiwin);
wppi (sesskey, "CapsLockCyr", cfg.xlat_capslockcyr);
RegCloseKey(sesskey);
}
@ -287,6 +290,7 @@ static void load_settings (char *section, int do_host) {
gppi (sesskey, "TermHeight", 24, &cfg.height);
gpps (sesskey, "Font", "Courier", cfg.font, sizeof(cfg.font));
gppi (sesskey, "FontIsBold", 0, &cfg.fontisbold);
gppi (sesskey, "FontCharSet", ANSI_CHARSET, &cfg.fontcharset);
gppi (sesskey, "FontHeight", 10, &cfg.fontheight);
gppi (sesskey, "FontVTMode", VT_POORMAN, &cfg.vtmode);
gppi (sesskey, "TryPalette", 0, &cfg.try_palette);
@ -329,6 +333,9 @@ static void load_settings (char *section, int do_host) {
cfg.wordness[j] = atoi(q);
}
}
gppi (sesskey, "KoiWinXlat", 0, &cfg.xlat_enablekoiwin);
gppi (sesskey, "CapsLockCyr", 0, &cfg.xlat_capslockcyr);
RegCloseKey(sesskey);
}
@ -721,7 +728,7 @@ static int CALLBACK TerminalProc (HWND hwnd, UINT msg,
lf.lfWidth = lf.lfEscapement = lf.lfOrientation = 0;
lf.lfItalic = lf.lfUnderline = lf.lfStrikeOut = 0;
lf.lfWeight = (cfg.fontisbold ? FW_BOLD : 0);
lf.lfCharSet = ANSI_CHARSET;
lf.lfCharSet = cfg.fontcharset;
lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
lf.lfQuality = DEFAULT_QUALITY;
@ -739,6 +746,7 @@ static int CALLBACK TerminalProc (HWND hwnd, UINT msg,
strncpy (cfg.font, lf.lfFaceName, sizeof(cfg.font)-1);
cfg.font[sizeof(cfg.font)-1] = '\0';
cfg.fontisbold = (lf.lfWeight == FW_BOLD);
cfg.fontcharset = lf.lfCharSet;
cfg.fontheight = lf.lfHeight;
fmtfont (fontstatic);
SetDlgItemText (hwnd, IDC2_FONTSTATIC, fontstatic);
@ -1098,9 +1106,36 @@ static int CALLBACK ColourProc (HWND hwnd, UINT msg,
return GeneralPanelProc (hwnd, msg, wParam, lParam);
}
static int CALLBACK LanguageProc (HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam) {
switch (msg) {
case WM_INITDIALOG:
CheckDlgButton (hwnd, IDC6_ENABLEKOIWINXLAT, cfg.xlat_enablekoiwin);
CheckDlgButton (hwnd, IDC6_CAPSLOCKCYR, cfg.xlat_capslockcyr);
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC6_ENABLEKOIWINXLAT:
if (HIWORD(wParam) == BN_CLICKED ||
HIWORD(wParam) == BN_DOUBLECLICKED) {
cfg.xlat_enablekoiwin =
IsDlgButtonChecked (hwnd, IDC6_ENABLEKOIWINXLAT);
}
break;
case IDC6_CAPSLOCKCYR:
if (HIWORD(wParam) == BN_CLICKED ||
HIWORD(wParam) == BN_DOUBLECLICKED) {
cfg.xlat_capslockcyr =
IsDlgButtonChecked (hwnd, IDC6_CAPSLOCKCYR);
}
break;
}
}
return GeneralPanelProc (hwnd, msg, wParam, lParam);
}
static DLGPROC panelproc[NPANELS] = {
ConnectionProc, KeyboardProc, TerminalProc,
TelnetProc, SshProc, SelectionProc, ColourProc
TelnetProc, SshProc, SelectionProc, ColourProc, LanguageProc
};
static char *panelids[NPANELS] = {
MAKEINTRESOURCE(IDD_PANEL0),
@ -1109,14 +1144,17 @@ static char *panelids[NPANELS] = {
MAKEINTRESOURCE(IDD_PANEL3),
MAKEINTRESOURCE(IDD_PANEL35),
MAKEINTRESOURCE(IDD_PANEL4),
MAKEINTRESOURCE(IDD_PANEL5)
};
static char *names[NPANELS] = {
"Connection", "Keyboard", "Terminal", "Telnet", "SSH", "Selection", "Colours"
MAKEINTRESOURCE(IDD_PANEL5),
MAKEINTRESOURCE(IDD_PANEL6)
};
static int mainp[MAIN_NPANELS] = { 0, 1, 2, 3, 4, 5, 6 };
static int reconfp[RECONF_NPANELS] = { 1, 2, 5, 6 };
static char *names[NPANELS] = {
"Connection", "Keyboard", "Terminal", "Telnet",
"SSH", "Selection", "Colours", "Language"
};
static int mainp[MAIN_NPANELS] = { 0, 1, 2, 3, 4, 5, 6, 7};
static int reconfp[RECONF_NPANELS] = { 1, 2, 5, 6, 7};
static int GenericMainDlgProc (HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam,

Просмотреть файл

@ -507,8 +507,8 @@ static void init_fonts(void) {
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, \
FIXED_PITCH | FF_DONTCARE, cfg.font)
if (cfg.vtmode != VT_OEMONLY) {
f(FONT_NORMAL, ANSI_CHARSET, fw_dontcare, FALSE);
f(FONT_UNDERLINE, ANSI_CHARSET, fw_dontcare, TRUE);
f(FONT_NORMAL, cfg.fontcharset, fw_dontcare, FALSE);
f(FONT_UNDERLINE, cfg.fontcharset, fw_dontcare, TRUE);
}
if (cfg.vtmode == VT_OEMANSI || cfg.vtmode == VT_OEMONLY) {
f(FONT_OEM, OEM_CHARSET, fw_dontcare, FALSE);
@ -516,8 +516,8 @@ static void init_fonts(void) {
}
if (bold_mode == BOLD_FONT) {
if (cfg.vtmode != VT_OEMONLY) {
f(FONT_BOLD, ANSI_CHARSET, fw_bold, FALSE);
f(FONT_BOLDUND, ANSI_CHARSET, fw_bold, TRUE);
f(FONT_BOLD, cfg.fontcharset, fw_bold, FALSE);
f(FONT_BOLDUND, cfg.fontcharset, fw_bold, TRUE);
}
if (cfg.vtmode == VT_OEMANSI || cfg.vtmode == VT_OEMONLY) {
f(FONT_OEMBOLD, OEM_CHARSET, fw_bold, FALSE);
@ -1053,7 +1053,7 @@ static int WINAPI WndProc (HWND hwnd, UINT message,
* we're ready to cope.
*/
{
char c = wParam;
char c = xlat_kbd2tty((unsigned char)wParam);
back->send (&c, 1);
}
return 0;
@ -1341,10 +1341,20 @@ static int TranslateKey(WPARAM wParam, LPARAM lParam, unsigned char *output) {
*/
if (ret) {
WORD chr;
int r = ToAscii (wParam, (lParam >> 16) & 0xFF,
int r;
BOOL capsOn=keystate[VK_CAPITAL] !=0;
/* helg: clear CAPS LOCK state if caps lock switches to cyrillic */
if(cfg.xlat_capslockcyr)
keystate[VK_CAPITAL] = 0;
r = ToAscii (wParam, (lParam >> 16) & 0xFF,
keystate, &chr, 0);
if(capsOn)
chr = xlat_latkbd2win((unsigned char)(chr & 0xFF));
if (r == 1) {
*p++ = chr & 0xFF;
*p++ = xlat_kbd2tty((unsigned char)(chr & 0xFF));
return p - output;
}
}

84
xlat.c Normal file
Просмотреть файл

@ -0,0 +1,84 @@
#include <windows.h>
#include "putty.h"
static unsigned char win2koi[] =
{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111,
112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
160,161,162,163,164,189,166,167,179,169,180,171,172,173,174,183,
176,177,182,166,173,181,182,183,163,185,164,187,188,189,190,167,
225,226,247,231,228,229,246,250,233,234,235,236,237,238,239,240,
242,243,244,245,230,232,227,254,251,253,255,249,248,252,224,241,
193,194,215,199,196,197,214,218,201,202,203,204,205,206,207,208,
210,211,212,213,198,200,195,222,219,221,223,217,216,220,192,209
};
static unsigned char koi2win[] =
{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111,
112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
160,161,162,184,186,165,179,191,168,169,170,171,172,180,174,175,
176,177,178,168,170,181,178,175,184,185,186,187,188,165,190,191,
254,224,225,246,228,229,244,227,245,232,233,234,235,236,237,238,
239,255,240,241,242,243,230,226,252,251,231,248,253,249,247,250,
222,192,193,214,196,197,212,195,213,200,201,202,203,204,205,206,
207,223,208,209,210,211,198,194,220,219,199,216,221,217,215,218
};
unsigned char xlat_kbd2tty(unsigned char c)
{
if(cfg.xlat_enablekoiwin)
return win2koi[c];
return c;
}
unsigned char xlat_tty2scr(unsigned char c)
{
if(cfg.xlat_enablekoiwin)
return koi2win[c];
return c;
}
static unsigned char latkbd2_win[]=
{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33,221, 35, 36, 37, 38,253, 40, 41, 42,178,225,186,254, 46,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57,198,230,193,179,222, 44,
64,212,200,209,194,211,192,207,208,216,206,203,196,220,210,217,
199,201,202,219,197,195,204,214,215,205,223,245,191,250, 94,170,
96,244,232,241,226,243,224,239,240,248,238,235,228,252,242,249,
231,233,234,251,229,227,236,246,247,237,255,213,175,218,126,127,
128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
};
unsigned char xlat_latkbd2win(unsigned char c)
{
if(cfg.xlat_capslockcyr)
return latkbd2_win[c];
return c;
}