diff options
author | nyamatongwe <unknown> | 2003-08-07 09:21:01 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2003-08-07 09:21:01 +0000 |
commit | 7d2d6a0620eeecd553842d532922bb993779872c (patch) | |
tree | e047cd37c34046b03ff036eac9e871202d247a89 | |
parent | c49f0b23baf7dcc7ad5c60872828f35715e01d81 (diff) | |
download | scintilla-mirror-7d2d6a0620eeecd553842d532922bb993779872c.tar.gz |
Patch from João Paulo F Farias to make keyboard input of accents
work for languages such as Brazilian Portuguese.
-rw-r--r-- | gtk/ScintillaGTK.cxx | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index 11506abb0..b28bb6b38 100644 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -83,6 +83,7 @@ class ScintillaGTK : public ScintillaBase { GdkEventButton evbtn; bool capturedMouse; bool dragWasDropped; + int lastKey; GtkWidgetClass *parentClass; @@ -245,7 +246,7 @@ ScintillaGTK::ScintillaGTK(_ScintillaObject *sci_) : adjustmentv(0), adjustmenth(0), scrollBarWidth(30), scrollBarHeight(30), capturedMouse(false), dragWasDropped(false), - parentClass(0), + lastKey(0), parentClass(0), #ifdef INTERNATIONAL_INPUT ic(NULL), ic_attr(NULL), @@ -858,11 +859,57 @@ void ScintillaGTK::NotifyURIDropped(const char *list) { } const char *CharacterSetID(int characterSet); +#define IS_ACC(x) \ + ((x) >= 65103 && (x) <= 65111) +#define IS_CHAR(x) \ + ((x) >= 0 && (x) <= 128) + +#define IS_ACC_OR_CHAR(x) \ + (IS_CHAR(x)) || (IS_ACC(x)) + +static int MakeAccent(int key, int acc) { + const char *conv[] = { + "aeioun AEIOUN", + "ãeiõuñ~ÃEIÕUÑ", + "áéíóún'ÁÉÍÓÚN", + "àèìòùn`ÀÈÌÒÙN", + "âêîôûn^ÂÊÎÔÛN", + "äëïöün¨ÄËÏÖÜN" + }; + int idx; + for (idx = 0; idx < 13; ++idx) { + if (char(key) == conv[0][idx]) { + break; + } + } + if (idx == 13) { + return key; + } + if (acc == 65107) { // ~ + return int((unsigned char)(conv[1][idx])); + } else if (acc == 65105) { // ' + return int((unsigned char)(conv[2][idx])); + } else if (acc == 65104) { // ` + return int((unsigned char)(conv[3][idx])); + } else if (acc == 65106) { // ^ + return int((unsigned char)(conv[4][idx])); + } else if (acc == 65111) { // " + return int((unsigned char)(conv[5][idx])); + } + return key; +} + int ScintillaGTK::KeyDefault(int key, int modifiers) { if (!(modifiers & SCI_CTRL) && !(modifiers & SCI_ALT)) { #if GTK_MAJOR_VERSION >= 2 char utfVal[4]="\0\0\0"; wchar_t wcs[2]; + if (IS_CHAR(key) && IS_ACC(lastKey)) { + key = MakeAccent(key, lastKey); + } + if (IS_ACC_OR_CHAR(key)) { + lastKey = key; + } wcs[0] = gdk_keyval_to_unicode(key); wcs[1] = 0; UTF8FromUCS2(wcs, 1, utfVal, 3); |