fix map-function in keymap% to handle non-ASCII characters in the mapping
svn: r5952
This commit is contained in:
parent
0b8a403f6f
commit
fdee9e7af9
|
@ -446,11 +446,23 @@ wxKeycode *wxKeymap::MapFunction(long code, int shift, int ctrl,
|
|||
return newkey;
|
||||
}
|
||||
|
||||
static long GetCode(unsigned char *keyseq, int *_kp, int *fullset)
|
||||
static int wx_c_strcmp(wxchar *keyseq, char *s)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
while (keyseq[i] && s[i]) {
|
||||
if ((int)keyseq[i] != (int)s[i])
|
||||
return 1;
|
||||
i++;
|
||||
}
|
||||
return keyseq[i] || s[i];
|
||||
}
|
||||
|
||||
static long GetCode(wxchar *keyseq, int *_kp, int *fullset)
|
||||
{
|
||||
long i, code, kp;
|
||||
#define MAX_BUF 256
|
||||
unsigned char buffer[MAX_BUF], first;
|
||||
wxchar buffer[MAX_BUF], first;
|
||||
|
||||
kp = *_kp;
|
||||
|
||||
|
@ -468,11 +480,11 @@ static long GetCode(unsigned char *keyseq, int *_kp, int *fullset)
|
|||
if (buffer[0] < 128)
|
||||
buffer[0] = tolower(buffer[0]);
|
||||
for (i = 0; keylist[i].str; i++) {
|
||||
if (!strcmp((char *)buffer, keylist[i].str)) {
|
||||
if (!wx_c_strcmp(buffer, keylist[i].str)) {
|
||||
code = keylist[i].code;
|
||||
if (!strcmp((char *)buffer, "leftbuttonseq")
|
||||
|| !strcmp((char *)buffer, "middlebuttonseq")
|
||||
|| !strcmp((char *)buffer, "rightbuttonseq"))
|
||||
if (!wx_c_strcmp(buffer, "leftbuttonseq")
|
||||
|| !wx_c_strcmp(buffer, "middlebuttonseq")
|
||||
|| !wx_c_strcmp(buffer, "rightbuttonseq"))
|
||||
*fullset = 1;
|
||||
break;
|
||||
}
|
||||
|
@ -485,9 +497,9 @@ static long GetCode(unsigned char *keyseq, int *_kp, int *fullset)
|
|||
return code;
|
||||
}
|
||||
|
||||
void wxKeymap::MapFunction(char *keys, char *fname)
|
||||
void wxKeymap::MapFunction(wxchar *keys, char *fname)
|
||||
{
|
||||
char *keyseq = keys;
|
||||
wxchar *keyseq = keys;
|
||||
int num_keys, num_new_keys, kp, start_keys;
|
||||
wxKeycode **key, **new_key;
|
||||
int shift, ctrl, alt, meta, mod, checkOther;
|
||||
|
@ -522,11 +534,11 @@ void wxKeymap::MapFunction(char *keys, char *fname)
|
|||
kp++;
|
||||
goto do_mod;
|
||||
}
|
||||
} else if (isspace(keyseq[kp])) {
|
||||
} else if (keyseq[kp] < 128 && isspace(keyseq[kp])) {
|
||||
kp++;
|
||||
} else if (keyseq[kp + 1] == ':') {
|
||||
do_mod:
|
||||
unsigned char mch;
|
||||
wxchar mch;
|
||||
mch = keyseq[kp];
|
||||
if (mch < 128)
|
||||
mch = tolower(mch);
|
||||
|
@ -572,7 +584,7 @@ void wxKeymap::MapFunction(char *keys, char *fname)
|
|||
kp += 2;
|
||||
} else {
|
||||
do_char:
|
||||
code = GetCode((unsigned char *)keyseq, &kp, &fullset);
|
||||
code = GetCode(keyseq, &kp, &fullset);
|
||||
if (!code) {
|
||||
errstr = "bad keyname";
|
||||
goto key_error;
|
||||
|
@ -625,9 +637,24 @@ void wxKeymap::MapFunction(char *keys, char *fname)
|
|||
return;
|
||||
|
||||
key_error:
|
||||
sprintf(buffer, "keymap: %s in keystring: \"%.100s\", part %d",
|
||||
errstr, keys, part);
|
||||
wxsKeymapError(buffer);
|
||||
{
|
||||
long l;
|
||||
char *r = NULL;
|
||||
|
||||
wxme_utf8_encode(keys, wxstrlen(keys), &r, &l);
|
||||
sprintf(buffer, "keymap: %s in keystring: \"%.100s\", part %d",
|
||||
errstr, r, part);
|
||||
wxsKeymapError(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
void wxKeymap::MapFunction(char *keys, char *fname)
|
||||
{
|
||||
wxchar *us;
|
||||
long ulen;
|
||||
|
||||
wxme_utf8_decode(keys, strlen(keys), &us, &ulen);
|
||||
MapFunction(us, fname);
|
||||
}
|
||||
|
||||
int wxKeymap::HandleEvent(long code, long other_code, long alt_code, long other_alt_code,
|
||||
|
|
|
@ -5,6 +5,11 @@
|
|||
#include "wx_stdev.h"
|
||||
#include "wx_hash.h"
|
||||
|
||||
typedef unsigned int wxchar;
|
||||
extern int wxstrlen(wxchar *s);
|
||||
void wxme_utf8_decode(char *str, long len, wxchar **us, long *ulen);
|
||||
void wxme_utf8_encode(wxchar *us, long ulen, char **s, long *len);
|
||||
|
||||
#define UNKNOWN_OBJ void*
|
||||
|
||||
typedef Bool (*wxKMFunction)(UNKNOWN_OBJ media, wxEvent *event, void *data);
|
||||
|
@ -108,6 +113,7 @@ class wxKeymap : public wxObject
|
|||
int alt, int meta, int check_alt,
|
||||
char *fname, class wxKeycode *prevkey=NULL,
|
||||
int keytype = wxKEY_FINAL);
|
||||
void MapFunction(wxchar *keyname, char *fname);
|
||||
void MapFunction(char *keyname, char *fname);
|
||||
|
||||
void AddFunction(char *name, wxKMFunction func, void *data);
|
||||
|
|
|
@ -18,13 +18,8 @@ class wxMediaEdit;
|
|||
class wxClickback;
|
||||
class wxClipboard;
|
||||
|
||||
typedef unsigned int wxchar;
|
||||
extern int wxstrlen(wxchar *s);
|
||||
extern wxchar wx_empty_wxstr[1];
|
||||
|
||||
void wxme_utf8_decode(char *str, long len, wxchar **us, long *ulen);
|
||||
void wxme_utf8_encode(wxchar *us, long ulen, char **s, long *len);
|
||||
|
||||
#define wxFOCUS_IMMEDIATE 0
|
||||
#define wxFOCUS_DISPLAY 1
|
||||
#define wxFOCUS_GLOBAL 2
|
||||
|
|
|
@ -4870,7 +4870,7 @@ static Scheme_Object *os_wxKeymapMapFunction(int n, Scheme_Object *p[])
|
|||
WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
|
||||
REMEMBER_VAR_STACK();
|
||||
objscheme_check_valid(os_wxKeymap_class, "map-function in keymap%", n, p);
|
||||
string x0 INIT_NULLED_OUT;
|
||||
mzstring x0 INIT_NULLED_OUT;
|
||||
string x1 INIT_NULLED_OUT;
|
||||
|
||||
SETUP_VAR_STACK_REMEMBERED(3);
|
||||
|
@ -4879,7 +4879,7 @@ static Scheme_Object *os_wxKeymapMapFunction(int n, Scheme_Object *p[])
|
|||
VAR_STACK_PUSH(2, x1);
|
||||
|
||||
|
||||
x0 = (string)WITH_VAR_STACK(objscheme_unbundle_string(p[POFFSET+0], "map-function in keymap%"));
|
||||
x0 = (mzstring)WITH_VAR_STACK(objscheme_unbundle_mzstring(p[POFFSET+0], "map-function in keymap%"));
|
||||
x1 = (string)WITH_VAR_STACK(objscheme_unbundle_string(p[POFFSET+1], "map-function in keymap%"));
|
||||
|
||||
|
||||
|
|
|
@ -226,7 +226,7 @@ static void BreakSequenceCallbackToScheme(KeymapCallbackToSchemeRec *data);
|
|||
@ v "handle-key-event" : bool HandleKeyEvent(UNKNOWN_OBJ/bAnythingFromVoid/ubAnythingToVoid/cAnything///push,wxKeyEvent!);
|
||||
@ v "handle-mouse-event" : bool HandleMouseEvent(UNKNOWN_OBJ/bAnythingFromVoid/ubAnythingToVoid/cAnything///push,wxMouseEvent!);
|
||||
@ "break-sequence" : void BreakSequence();
|
||||
@ "map-function" : void MapFunction(string,string);
|
||||
@ "map-function" : void MapFunction(mzstring,string);
|
||||
@ "add-function" : void AddFunction(string,wxKMFunction/bCallback/ubCallbackKM/cCallback//spCallbackKM/nopush,-unknown#void*=NULL); : : ubSetup / ubSetData[1.2]
|
||||
@ "set-grab-key-function" : void SetGrabKeyFunction(wxGrabKeyFunction/bCallback/ubCallbackGrabKey/cCallback//spCallbackGrabKey/nopush,-unknown#void*=NULL); : : ubSetup / ubSetData[0.1]
|
||||
@ "remove-grab-key-function" : void RemoveGrabKeyFunction()
|
||||
|
|
|
@ -904,7 +904,7 @@ static Scheme_Object *wxSchemeGetFontFromUser(int argc, Scheme_Object **argv)
|
|||
lf->lfPitchAndFamily |= FF_DECORATIVE;
|
||||
break;
|
||||
case wxMODERN:
|
||||
lf->lfPitchAndFamily = FIXED_PITCH | FF_MODERN;
|
||||
Lf->lfPitchAndFamily = FIXED_PITCH | FF_MODERN;
|
||||
break;
|
||||
case wxROMAN:
|
||||
lf->lfPitchAndFamily |= FF_ROMAN;
|
||||
|
|
Loading…
Reference in New Issue
Block a user