aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Rumney2007-12-14 12:26:31 +0000
committerJason Rumney2007-12-14 12:26:31 +0000
commit2e3566d8b733b5ba810508e5507a131b1bf255b9 (patch)
tree6e06d4ff7441555c6e6c1121058db8380e424787 /src
parentbf2540370278fcfbe6ac2423650db8fb4e357be7 (diff)
downloademacs-2e3566d8b733b5ba810508e5507a131b1bf255b9.tar.gz
emacs-2e3566d8b733b5ba810508e5507a131b1bf255b9.zip
(w32_read_socket): Use MULTIBYTE_CHAR_KEYSTROKE_EVENT for characters above 127.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/w32term.c94
2 files changed, 97 insertions, 2 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 7d2240f7829..2bf4e0ed15f 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
12007-12-14 Jason Rumney <jasonr@gnu.org>
2
3 * w32term.c (w32_read_socket): Use MULTIBYTE_CHAR_KEYSTROKE_EVENT
4 for characters above 127.
5
12007-12-13 Jason Rumney <jasonr@gnu.org> 62007-12-13 Jason Rumney <jasonr@gnu.org>
2 7
3 * w32fns.c (w32_wnd_proc, Fw32_reconstruct_hot_key): Range check 8 * w32fns.c (w32_wnd_proc, Fw32_reconstruct_hot_key): Range check
diff --git a/src/w32term.c b/src/w32term.c
index a2d64ba581f..1a76d6bfcca 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -4128,6 +4128,8 @@ x_scroll_bar_clear (f)
4128static int temp_index; 4128static int temp_index;
4129static short temp_buffer[100]; 4129static short temp_buffer[100];
4130 4130
4131/* Temporarily store lead byte of DBCS input sequences. */
4132static char dbcs_lead = 0;
4131 4133
4132/* Read events coming from the W32 shell. 4134/* Read events coming from the W32 shell.
4133 This routine is called by the SIGIO handler. 4135 This routine is called by the SIGIO handler.
@@ -4287,8 +4289,96 @@ w32_read_socket (sd, expected, hold_quit)
4287 if (temp_index == sizeof temp_buffer / sizeof (short)) 4289 if (temp_index == sizeof temp_buffer / sizeof (short))
4288 temp_index = 0; 4290 temp_index = 0;
4289 temp_buffer[temp_index++] = msg.msg.wParam; 4291 temp_buffer[temp_index++] = msg.msg.wParam;
4290 inev.kind = ASCII_KEYSTROKE_EVENT; 4292
4291 inev.code = msg.msg.wParam; 4293 if (msg.msg.wParam < 128 && !dbcs_lead)
4294 {
4295 inev.kind = ASCII_KEYSTROKE_EVENT;
4296 inev.code = msg.msg.wParam;
4297 }
4298 else if (msg.msg.wParam < 256)
4299 {
4300 wchar_t code;
4301
4302 inev.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
4303
4304 if (IsDBCSLeadByteEx(CP_ACP, (BYTE) msg.msg.wParam))
4305 {
4306 dbcs_lead = (char) msg.msg.wParam;
4307 inev.kind = NO_EVENT;
4308 break;
4309 }
4310 else if (dbcs_lead)
4311 {
4312 char dbcs[2];
4313 dbcs[0] = dbcs_lead;
4314 dbcs[1] = (char) msg.msg.wParam;
4315 dbcs_lead = 0;
4316 if (!MultiByteToWideChar(CP_ACP, 0, dbcs, 2, &code, 1))
4317 {
4318 /* Garbage */
4319 DebPrint (("Invalid DBCS sequence: %d %d\n",
4320 dbcs[0], dbcs[1]));
4321 inev.kind = NO_EVENT;
4322 break;
4323 }
4324 }
4325 else
4326 {
4327 char single_byte = (char) msg.msg.wParam;
4328 if (!MultiByteToWideChar(CP_ACP, 0, &single_byte, 1,
4329 &code, 1))
4330 {
4331 /* What to do with garbage? */
4332 DebPrint (("Invalid character: %d\n", single_byte));
4333 inev.kind = NO_EVENT;
4334 break;
4335 }
4336 }
4337
4338 /* Now process unicode input as per xterm.c */
4339 if (code < 0x80)
4340 {
4341 inev.kind = ASCII_KEYSTROKE_EVENT;
4342 inev.code = code;
4343 }
4344 else if (code < 0xA0)
4345 inev.code = MAKE_CHAR (CHARSET_8_BIT_CONTROL, code, 0);
4346 else if (code < 0x100)
4347 inev.code = MAKE_CHAR (charset_latin_iso8859_1, code, 0);
4348 else
4349 {
4350 int c1, c2;
4351 int charset_id;
4352
4353 if (code < 0x2500)
4354 {
4355 charset_id = charset_mule_unicode_0100_24ff;
4356 code -= 0x100;
4357 }
4358 else if (code < 0xE000)
4359 {
4360 charset_id = charset_mule_unicode_2500_33ff;
4361 code -= 0x2500;
4362 }
4363 else
4364 {
4365 charset_id = charset_mule_unicode_e000_ffff;
4366 code -= 0xE000;
4367 }
4368
4369 c1 = (code / 96) + 32;
4370 c2 = (code % 96) + 32;
4371 inev.code = MAKE_CHAR (charset_id, c1, c2);
4372 }
4373 }
4374 else
4375 {
4376 /* Windows shouldn't generate WM_CHAR events above 0xFF
4377 in non-Unicode message handlers. */
4378 DebPrint (("Non-byte WM_CHAR: %d\n", msg.msg.wParam));
4379 inev.kind = NO_EVENT;
4380 break;
4381 }
4292 inev.modifiers = msg.dwModifiers; 4382 inev.modifiers = msg.dwModifiers;
4293 XSETFRAME (inev.frame_or_window, f); 4383 XSETFRAME (inev.frame_or_window, f);
4294 inev.timestamp = msg.msg.time; 4384 inev.timestamp = msg.msg.time;