aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2009-07-01 11:37:45 +0000
committerKenichi Handa2009-07-01 11:37:45 +0000
commitfd503d99b25a653ba5b300e31d8b3c6a86520ecd (patch)
tree8d4c4bbbc8288c69c9e796616b2f19c69c6ffe49 /src
parent624bda0987593f3e3933fa9d9db6ebad98db81c7 (diff)
downloademacs-fd503d99b25a653ba5b300e31d8b3c6a86520ecd.tar.gz
emacs-fd503d99b25a653ba5b300e31d8b3c6a86520ecd.zip
(decode_keyboard_code): New function.
(tty_read_avail_input): Decode the input bytes if necessary.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog10
-rw-r--r--src/keyboard.c71
2 files changed, 81 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 5ca300dd833..61d2d1b7eba 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,13 @@
12009-07-01 Kenichi Handa <handa@m17n.org>
2
3 * keyboard.c (decode_keyboard_code): New function.
4 (tty_read_avail_input): Decode the input bytes if necessary.
5
6 * coding.c (setup_coding_system): Initialize
7 coding->carryover_bytes to 0.
8 (Fset_keyboard_coding_system_internal): If CODING-SYSTEM is nil,
9 use Qno_conversion.
10
12009-07-01 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> 112009-07-01 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
2 12
3 * Makefile.in (SOME_MACHINE_LISP): Add ../lisp/term/common-win.elc. 13 * Makefile.in (SOME_MACHINE_LISP): Add ../lisp/term/common-win.elc.
diff --git a/src/keyboard.c b/src/keyboard.c
index 8ed335a12bb..55862e1da33 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -7137,6 +7137,47 @@ read_avail_input (expected)
7137 return nread; 7137 return nread;
7138} 7138}
7139 7139
7140static void
7141decode_keyboard_code (struct tty_display_info *tty,
7142 struct coding_system *coding,
7143 unsigned char *buf, int nbytes)
7144{
7145 unsigned char *src = buf;
7146 const unsigned char *p;
7147 int i;
7148
7149 if (nbytes == 0)
7150 return;
7151 if (tty->meta_key != 2)
7152 for (i = 0; i < nbytes; i++)
7153 buf[i] &= ~0x80;
7154 if (coding->carryover_bytes > 0)
7155 {
7156 src = alloca (coding->carryover_bytes + nbytes);
7157 memcpy (src, coding->carryover, coding->carryover_bytes);
7158 memcpy (src + coding->carryover_bytes, buf, nbytes);
7159 nbytes += coding->carryover_bytes;
7160 }
7161 coding->destination = alloca (nbytes * 4);
7162 coding->dst_bytes = nbytes * 4;
7163 decode_coding_c_string (coding, src, nbytes, Qnil);
7164 if (coding->produced_char == 0)
7165 return;
7166 for (i = 0, p = coding->destination; i < coding->produced_char; i++)
7167 {
7168 struct input_event buf;
7169
7170 EVENT_INIT (buf);
7171 buf.code = STRING_CHAR_ADVANCE (p);
7172 buf.kind = (ASCII_CHAR_P (buf.code)
7173 ? ASCII_KEYSTROKE_EVENT : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
7174 /* See the comment in tty_read_avail_input. */
7175 buf.frame_or_window = tty->top_frame;
7176 buf.arg = Qnil;
7177 kbd_buffer_store_event (&buf);
7178 }
7179}
7180
7140/* This is the tty way of reading available input. 7181/* This is the tty way of reading available input.
7141 7182
7142 Note that each terminal device has its own `struct terminal' object, 7183 Note that each terminal device has its own `struct terminal' object,
@@ -7288,6 +7329,36 @@ tty_read_avail_input (struct terminal *terminal,
7288#endif /* not MSDOS */ 7329#endif /* not MSDOS */
7289#endif /* not WINDOWSNT */ 7330#endif /* not WINDOWSNT */
7290 7331
7332 if (TERMINAL_KEYBOARD_CODING (terminal)->common_flags
7333 & CODING_REQUIRE_DECODING_MASK)
7334 {
7335 struct coding_system *coding = TERMINAL_KEYBOARD_CODING (terminal);
7336 int from;
7337
7338 /* Decode the key sequence except for those with meta
7339 modifiers. */
7340 for (i = from = 0; ; i++)
7341 if (i == nread || (tty->meta_key == 1 && (cbuf[i] & 0x80)))
7342 {
7343 struct input_event buf;
7344
7345 decode_keyboard_code (tty, coding, cbuf + from, i - from);
7346 if (i == nread)
7347 break;
7348
7349 EVENT_INIT (buf);
7350 buf.kind = ASCII_KEYSTROKE_EVENT;
7351 buf.modifiers = meta_modifier;
7352 buf.code = cbuf[i] & ~0x80;
7353 /* See the comment below. */
7354 buf.frame_or_window = tty->top_frame;
7355 buf.arg = Qnil;
7356 kbd_buffer_store_event (&buf);
7357 from = i + 1;
7358 }
7359 return nread;
7360 }
7361
7291 for (i = 0; i < nread; i++) 7362 for (i = 0; i < nread; i++)
7292 { 7363 {
7293 struct input_event buf; 7364 struct input_event buf;