1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-24 16:52:24 +00:00

Support for non-ISO-8859-1 X keysyms. So in particular, pterm in a

Euro-supporting font with a Euro-enabled X key map will now actually
generate a Euro character rather than shrugging and doing nothing.

[originally from svn r3151]
This commit is contained in:
Simon Tatham 2003-04-27 11:10:48 +00:00
parent 95159b8283
commit 082cf832c5
4 changed files with 1078 additions and 28 deletions

20
Recipe
View File

@ -97,8 +97,9 @@
GUITERM = window windlg winctrls terminal sizetip wcwidth unicode ldiscucs GUITERM = window windlg winctrls terminal sizetip wcwidth unicode ldiscucs
+ logging printing winutils dialog config wincfg tree234 + logging printing winutils dialog config wincfg tree234
# Config box on Unix. # Same thing on Unix.
UXCFG = config uxcfg dialog gtkdlg gtkcols gtkpanel UXTERM = pterm config uxcfg dialog gtkdlg gtkcols gtkpanel tree234
+ terminal wcwidth uxucs ldiscucs logging uxprint xkeysym
# Non-SSH back ends (putty, puttytel, plink). # Non-SSH back ends (putty, puttytel, plink).
NONSSH = telnet raw rlogin ldisc NONSSH = telnet raw rlogin ldisc
@ -152,15 +153,12 @@ puttygen : [G] puttygen sshrsag sshdssg sshprime sshdes sshbn sshmd5 version
+ sshrand noise sshsha winstore misc winctrls sshrsa sshdss winmisc + sshrand noise sshsha winstore misc winctrls sshrsa sshdss winmisc
+ sshpubk sshaes sshsh512 import winutils puttygen.res tree234 LIBS + sshpubk sshaes sshsh512 import winutils puttygen.res tree234 LIBS
pterm : [X] pterm terminal wcwidth uxucs uxmisc tree234 misc ldisc ldiscucs pterm : [X] UXTERM uxmisc misc ldisc settings pty uxsel be_none uxstore
+ logging uxprint settings pty uxsel be_none uxstore signal CHARSET + signal CHARSET cmdline ptermm version
+ cmdline ptermm UXCFG version putty : [X] UXTERM uxmisc misc ldisc settings pty uxsel be_all uxstore
putty : [X] pterm terminal wcwidth uxucs uxmisc tree234 misc ldisc ldiscucs + signal CHARSET uxputty NONSSH UXSSH UXMISC ux_x11
+ logging uxprint settings pty uxsel be_all uxstore signal CHARSET puttytel : [X] UXTERM uxmisc misc ldisc settings pty uxsel be_nossh uxstore
+ uxputty NONSSH UXSSH UXMISC logging ux_x11 UXCFG + signal CHARSET uxputty NONSSH UXMISC
puttytel : [X] pterm terminal wcwidth uxucs uxmisc tree234 misc ldisc ldiscucs
+ logging uxprint settings pty uxsel be_nossh uxstore signal CHARSET
+ uxputty NONSSH UXMISC logging UXCFG
plink : [U] uxplink uxcons NONSSH UXSSH be_all logging UXMISC signal ux_x11 plink : [U] uxplink uxcons NONSSH UXSSH be_all logging UXMISC signal ux_x11

View File

@ -440,11 +440,12 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
{ {
struct gui_data *inst = (struct gui_data *)data; struct gui_data *inst = (struct gui_data *)data;
char output[32]; char output[32];
int start, end, special; wchar_t ucsoutput[2];
int ucsval, start, end, special, use_ucsoutput;
/* By default, nothing is generated. */ /* By default, nothing is generated. */
end = start = 0; end = start = 0;
special = FALSE; special = use_ucsoutput = FALSE;
/* /*
* If Alt is being released after typing an Alt+numberpad * If Alt is being released after typing an Alt+numberpad
@ -566,12 +567,21 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
} }
special = FALSE; special = FALSE;
use_ucsoutput = FALSE;
/* ALT+things gives leading Escape. */ /* ALT+things gives leading Escape. */
output[0] = '\033'; output[0] = '\033';
strncpy(output+1, event->string, 31); strncpy(output+1, event->string, 31);
output[31] = '\0'; if (!*event->string &&
end = strlen(output); (ucsval = keysym_to_unicode(event->keyval)) >= 0) {
ucsoutput[0] = '\033';
ucsoutput[1] = ucsval;
use_ucsoutput = TRUE;
end = 2;
} else {
output[31] = '\0';
end = strlen(output);
}
if (event->state & GDK_MOD1_MASK) { if (event->state & GDK_MOD1_MASK) {
start = 0; start = 0;
if (end == 1) end = 0; if (end == 1) end = 0;
@ -582,6 +592,7 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
if (!event->string[0] && event->keyval == '`' && if (!event->string[0] && event->keyval == '`' &&
(event->state & GDK_CONTROL_MASK)) { (event->state & GDK_CONTROL_MASK)) {
output[1] = '\x1C'; output[1] = '\x1C';
use_ucsoutput = FALSE;
end = 2; end = 2;
} }
@ -589,6 +600,7 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
if (event->keyval == GDK_Break && if (event->keyval == GDK_Break &&
(event->state & GDK_CONTROL_MASK)) { (event->state & GDK_CONTROL_MASK)) {
output[1] = '\003'; output[1] = '\003';
use_ucsoutput = FALSE;
end = 2; end = 2;
special = TRUE; special = TRUE;
} }
@ -597,6 +609,7 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
* special to ldisc. */ * special to ldisc. */
if (event->keyval == GDK_Return) { if (event->keyval == GDK_Return) {
output[1] = '\015'; output[1] = '\015';
use_ucsoutput = FALSE;
end = 2; end = 2;
special = TRUE; special = TRUE;
} }
@ -608,6 +621,7 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
(event->state & (GDK_SHIFT_MASK | (event->state & (GDK_SHIFT_MASK |
GDK_CONTROL_MASK)) == GDK_CONTROL_MASK) { GDK_CONTROL_MASK)) == GDK_CONTROL_MASK) {
output[1] = '\0'; output[1] = '\0';
use_ucsoutput = FALSE;
end = 2; end = 2;
} }
@ -616,6 +630,7 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
(event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) == (event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) ==
(GDK_SHIFT_MASK | GDK_CONTROL_MASK)) { (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) {
output[1] = '\240'; output[1] = '\240';
use_ucsoutput = FALSE;
end = 2; end = 2;
} }
@ -623,6 +638,7 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
if (event->keyval == GDK_BackSpace && if (event->keyval == GDK_BackSpace &&
!(event->state & GDK_SHIFT_MASK)) { !(event->state & GDK_SHIFT_MASK)) {
output[1] = inst->cfg.bksp_is_delete ? '\x7F' : '\x08'; output[1] = inst->cfg.bksp_is_delete ? '\x7F' : '\x08';
use_ucsoutput = FALSE;
end = 2; end = 2;
special = TRUE; special = TRUE;
} }
@ -630,6 +646,7 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
if (event->keyval == GDK_BackSpace && if (event->keyval == GDK_BackSpace &&
(event->state & GDK_SHIFT_MASK)) { (event->state & GDK_SHIFT_MASK)) {
output[1] = inst->cfg.bksp_is_delete ? '\x08' : '\x7F'; output[1] = inst->cfg.bksp_is_delete ? '\x08' : '\x7F';
use_ucsoutput = FALSE;
end = 2; end = 2;
special = TRUE; special = TRUE;
} }
@ -638,6 +655,7 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
if (event->keyval == GDK_ISO_Left_Tab || if (event->keyval == GDK_ISO_Left_Tab ||
(event->keyval == GDK_Tab && (event->state & GDK_SHIFT_MASK))) { (event->keyval == GDK_Tab && (event->state & GDK_SHIFT_MASK))) {
end = 1 + sprintf(output+1, "\033[Z"); end = 1 + sprintf(output+1, "\033[Z");
use_ucsoutput = FALSE;
} }
/* /*
@ -662,6 +680,7 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
output[1] = keys[1]; output[1] = keys[1];
else else
output[1] = keys[0]; output[1] = keys[0];
use_ucsoutput = FALSE;
goto done; goto done;
} }
} }
@ -714,6 +733,7 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
end = 1 + sprintf(output+1, "\033?%c", xkey); end = 1 + sprintf(output+1, "\033?%c", xkey);
} else } else
end = 1 + sprintf(output+1, "\033O%c", xkey); end = 1 + sprintf(output+1, "\033O%c", xkey);
use_ucsoutput = FALSE;
goto done; goto done;
} }
} }
@ -817,6 +837,7 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
if (inst->term->vt52_mode && code > 0 && code <= 6) { if (inst->term->vt52_mode && code > 0 && code <= 6) {
end = 1 + sprintf(output+1, "\x1B%c", " HLMEIG"[code]); end = 1 + sprintf(output+1, "\x1B%c", " HLMEIG"[code]);
use_ucsoutput = FALSE;
goto done; goto done;
} }
@ -841,6 +862,7 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
if (event->state & GDK_SHIFT_MASK) index += 12; if (event->state & GDK_SHIFT_MASK) index += 12;
if (event->state & GDK_CONTROL_MASK) index += 24; if (event->state & GDK_CONTROL_MASK) index += 24;
end = 1 + sprintf(output+1, "\x1B[%c", codes[index]); end = 1 + sprintf(output+1, "\x1B[%c", codes[index]);
use_ucsoutput = FALSE;
goto done; goto done;
} }
if (inst->cfg.funky_type == 5 && /* SCO small keypad */ if (inst->cfg.funky_type == 5 && /* SCO small keypad */
@ -852,6 +874,7 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
} else { } else {
end = 1 + sprintf(output+1, "\x1B[%c", codes[code-1]); end = 1 + sprintf(output+1, "\x1B[%c", codes[code-1]);
} }
use_ucsoutput = FALSE;
goto done; goto done;
} }
if ((inst->term->vt52_mode || inst->cfg.funky_type == 4) && if ((inst->term->vt52_mode || inst->cfg.funky_type == 4) &&
@ -867,10 +890,12 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
else else
end = 1 + sprintf(output+1, end = 1 + sprintf(output+1,
"\x1BO%c", code + 'P' - 11 - offt); "\x1BO%c", code + 'P' - 11 - offt);
use_ucsoutput = FALSE;
goto done; goto done;
} }
if (inst->cfg.funky_type == 1 && code >= 11 && code <= 15) { if (inst->cfg.funky_type == 1 && code >= 11 && code <= 15) {
end = 1 + sprintf(output+1, "\x1B[[%c", code + 'A' - 11); end = 1 + sprintf(output+1, "\x1B[[%c", code + 'A' - 11);
use_ucsoutput = FALSE;
goto done; goto done;
} }
if (inst->cfg.funky_type == 2 && code >= 11 && code <= 14) { if (inst->cfg.funky_type == 2 && code >= 11 && code <= 14) {
@ -878,14 +903,17 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
end = 1 + sprintf(output+1, "\x1B%c", code + 'P' - 11); end = 1 + sprintf(output+1, "\x1B%c", code + 'P' - 11);
else else
end = 1 + sprintf(output+1, "\x1BO%c", code + 'P' - 11); end = 1 + sprintf(output+1, "\x1BO%c", code + 'P' - 11);
use_ucsoutput = FALSE;
goto done; goto done;
} }
if (inst->cfg.rxvt_homeend && (code == 1 || code == 4)) { if (inst->cfg.rxvt_homeend && (code == 1 || code == 4)) {
end = 1 + sprintf(output+1, code == 1 ? "\x1B[H" : "\x1BOw"); end = 1 + sprintf(output+1, code == 1 ? "\x1B[H" : "\x1BOw");
use_ucsoutput = FALSE;
goto done; goto done;
} }
if (code) { if (code) {
end = 1 + sprintf(output+1, "\x1B[%d~", code); end = 1 + sprintf(output+1, "\x1B[%d~", code);
use_ucsoutput = FALSE;
goto done; goto done;
} }
} }
@ -920,6 +948,7 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
} else { } else {
end = 1 + sprintf(output+1, "\033[%c", xkey); end = 1 + sprintf(output+1, "\033[%c", xkey);
} }
use_ucsoutput = FALSE;
goto done; goto done;
} }
} }
@ -945,19 +974,28 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
output[end] = '\0'; /* NUL-terminate */ output[end] = '\0'; /* NUL-terminate */
ldisc_send(inst->ldisc, output+start, -2, 1); ldisc_send(inst->ldisc, output+start, -2, 1);
} else if (!inst->direct_to_font) { } else if (!inst->direct_to_font) {
/* if (!use_ucsoutput) {
* The stuff we've just generated is assumed to be /*
* ISO-8859-1! This sounds insane, but `man * The stuff we've just generated is assumed to be
* XLookupString' agrees: strings of this type returned * ISO-8859-1! This sounds insane, but `man
* from the X server are hardcoded to 8859-1. Strictly * XLookupString' agrees: strings of this type
* speaking we should be doing this using some sort of * returned from the X server are hardcoded to
* GtkIMContext, which (if we're lucky) would give us * 8859-1. Strictly speaking we should be doing
* our data directly in Unicode; but that's not * this using some sort of GtkIMContext, which (if
* supported in GTK 1.2 as far as I can tell, and it's * we're lucky) would give us our data directly in
* poorly documented even in 2.0, so it'll have to * Unicode; but that's not supported in GTK 1.2 as
* wait. * far as I can tell, and it's poorly documented
*/ * even in 2.0, so it'll have to wait.
lpage_send(inst->ldisc, CS_ISO8859_1, output+start, end-start, 1); */
lpage_send(inst->ldisc, CS_ISO8859_1, output+start,
end-start, 1);
} else {
/*
* We generated our own Unicode key data from the
* keysym, so use that instead.
*/
luni_send(inst->ldisc, ucsoutput+start, end-start, 1);
}
} else { } else {
/* /*
* In direct-to-font mode, we just send the string * In direct-to-font mode, we just send the string

View File

@ -71,6 +71,9 @@ int reallyclose(void *frontend);
char *make_default_wintitle(char *hostname); char *make_default_wintitle(char *hostname);
int process_nonoption_arg(char *arg, Config *cfg); int process_nonoption_arg(char *arg, Config *cfg);
/* pterm.c needs this special function in xkeysym.c */
int keysym_to_unicode(int keysym);
/* Things uxstore.c needs from pterm.c */ /* Things uxstore.c needs from pterm.c */
char *x_get_default(const char *key); char *x_get_default(const char *key);

1011
unix/xkeysym.c Normal file

File diff suppressed because it is too large Load Diff