]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve and document the language-change event on MS-Windows.
authorEli Zaretskii <eliz@gnu.org>
Sat, 23 Jun 2012 12:39:23 +0000 (15:39 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sat, 23 Jun 2012 12:39:23 +0000 (15:39 +0300)
 src/keyboard.c (kbd_buffer_get_event): Include the codepage and the
 language ID in the event parameters.
 src/w32term.c (w32_read_socket): Put the new keyboard codepage into
 event.code, not the obscure "character set ID".
 doc/lispref/commands.texi (Misc Events): Document the language-change event.

doc/lispref/ChangeLog
doc/lispref/commands.texi
src/ChangeLog
src/keyboard.c
src/w32term.c

index 838617cf8669c86749a0e7e55eaa94f7ecf47b42..154b4487d5e41bbeca1ca0ecb13cba7e039f7678 100644 (file)
@@ -1,3 +1,7 @@
+2012-06-23  Eli Zaretskii  <eliz@gnu.org>
+
+       * commands.texi (Misc Events): Document the language-change event.
+
 2012-06-22  Paul Eggert  <eggert@cs.ucla.edu>
 
        Support higher-resolution time stamps (Bug#9000).
index 59ad2927411ff687e4a1c88d884db83c3454a4f3..a5fb4638c9d6debac5d37792cfb81a18b83636c3 100644 (file)
@@ -1716,6 +1716,38 @@ To test the signal handler, you can make Emacs send a signal to itself:
 @smallexample
 (signal-process (emacs-pid) 'sigusr1)
 @end smallexample
+
+@cindex @code{language-change} event
+@item language-change
+This kind of event is generated on MS-Windows when the input language
+has changed.  This typically means that the keyboard keys will send to
+Emacs characters from a different language.  The generated event has
+this form:
+
+@smallexample
+(language-change @var{frame} @var{codepage} @var{language-id})
+@end smallexample
+
+@noindent
+Here @var{frame} is the frame which was current when the input
+language changed; @var{codepage} is the new codepage number; and
+@var{language-id} is the numerical ID of the new input language.  The
+coding-system (@pxref{Coding Systems}) that corresponds to
+@var{codepage} is @code{cp@var{codepage}} or
+@code{windows-@var{codepage}}.  To convert @var{language-id} to a
+string (e.g., to use it for various language-dependent features, such
+as @code{set-language-environment}), use the
+@code{w32-get-locale-info} function, like this:
+
+@smallexample
+;; Get the abbreviated language name, such as "ENU" for English
+(w32-get-locale-info language-id)
+;; Get the full English name of the language,
+;; such as "English (United States)"
+(w32-get-locale-info language-id 4097)
+;; Get the full localized name of the language
+(w32-get-locale-info language-id t)
+@end smallexample
 @end table
 
   If one of these events arrives in the middle of a key sequence---that
index 2266ccc49ef7eec435ce247c40c74c2413d13dea..a01a93f86e9e3c970854fd083b29c4ce57e531f9 100644 (file)
@@ -1,3 +1,11 @@
+2012-06-23  Eli Zaretskii  <eliz@gnu.org>
+
+       * keyboard.c (kbd_buffer_get_event): Include the codepage and the
+       language ID in the event parameters.
+
+       * w32term.c (w32_read_socket): Put the new keyboard codepage into
+       event.code, not the obscure "character set ID".
+
 2012-06-23  Chong Yidong  <cyd@gnu.org>
 
        * xmenu.c (x_menu_wait_for_event): Adapt GTK3 to new xg_select.
index 9b80c5c7019d5c725b48ef0c82884d9b7838e07f..0e8d22c2b1cdb7020ca13fc20d3619f12c382dfb 100644 (file)
@@ -3982,9 +3982,11 @@ kbd_buffer_get_event (KBOARD **kbp,
 #if defined (WINDOWSNT)
       else if (event->kind == LANGUAGE_CHANGE_EVENT)
        {
-         /* Make an event (language-change (FRAME CHARSET LCID)).  */
-         obj = Fcons (event->frame_or_window, Qnil);
-         obj = Fcons (Qlanguage_change, Fcons (obj, Qnil));
+         /* Make an event (language-change (FRAME CODEPAGE LANGUAGE-ID)).  */
+         obj = Fcons (Qlanguage_change,
+                      list3 (event->frame_or_window,
+                             make_number (event->code),
+                             make_number (event->modifiers)));
          kbd_fetch_ptr = event + 1;
        }
 #endif
index 6a4b3ca4afbf957e6fe618d65ce562fd3af7fbce..4f4fa220a7bd584a2b621132ab5a92ea73559c2e 100644 (file)
@@ -4234,8 +4234,8 @@ w32_read_socket (struct terminal *terminal, int expected,
          /* Generate a language change event.  */
          f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
 
-         /* lParam contains the input lang ID.  Use it to update our
-            record of the keyboard codepage.  */
+         /* lParam contains the input language ID in its low 16 bits.
+            Use it to update our record of the keyboard codepage.  */
          keyboard_codepage = codepage_for_locale ((LCID)(msg.msg.lParam
                                                          & 0xffff));
 
@@ -4243,7 +4243,7 @@ w32_read_socket (struct terminal *terminal, int expected,
            {
              inev.kind = LANGUAGE_CHANGE_EVENT;
              XSETFRAME (inev.frame_or_window, f);
-             inev.code = msg.msg.wParam;
+             inev.code = keyboard_codepage;
              inev.modifiers = msg.msg.lParam & 0xffff;
            }
          break;