aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/keyboard.c191
1 files changed, 175 insertions, 16 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index f46a7b24f6c..8c782b65e20 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -56,6 +56,10 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
56#include "xterm.h" 56#include "xterm.h"
57#endif 57#endif
58 58
59#ifdef HAVE_NTGUI
60#include "w32term.h"
61#endif /* HAVE_NTGUI */
62
59/* Include systime.h after xterm.h to avoid double inclusion of time.h. */ 63/* Include systime.h after xterm.h to avoid double inclusion of time.h. */
60#include "systime.h" 64#include "systime.h"
61 65
@@ -74,7 +78,7 @@ int interrupt_input_pending;
74/* File descriptor to use for input. */ 78/* File descriptor to use for input. */
75extern int input_fd; 79extern int input_fd;
76 80
77#ifdef HAVE_X_WINDOWS 81#ifdef HAVE_WINDOW_SYSTEM
78/* Make all keyboard buffers much bigger when using X windows. */ 82/* Make all keyboard buffers much bigger when using X windows. */
79#define KBD_BUFFER_SIZE 4096 83#define KBD_BUFFER_SIZE 4096
80#else /* No X-windows, character input */ 84#else /* No X-windows, character input */
@@ -496,9 +500,9 @@ int flow_control;
496#endif 500#endif
497#endif 501#endif
498 502
499/* If we support X Windows, turn on the code to poll periodically 503/* If we support a window system, turn on the code to poll periodically
500 to detect C-g. It isn't actually used when doing interrupt input. */ 504 to detect C-g. It isn't actually used when doing interrupt input. */
501#ifdef HAVE_X_WINDOWS 505#ifdef HAVE_WINDOW_SYSTEM
502#define POLL_FOR_INPUT 506#define POLL_FOR_INPUT
503#endif 507#endif
504 508
@@ -1102,13 +1106,13 @@ command_loop_1 ()
1102 throw to top level. */ 1106 throw to top level. */
1103 /* Note that the value cell will never directly contain nil 1107 /* Note that the value cell will never directly contain nil
1104 if the symbol is a local variable. */ 1108 if the symbol is a local variable. */
1105 if (!NILP (XSYMBOL (Qpost_command_hook)->value) && !NILP (Vrun_hooks)) 1109 if (!NILP (Vpost_command_hook) && !NILP (Vrun_hooks))
1106 safe_run_hooks (Qpost_command_hook); 1110 safe_run_hooks (Qpost_command_hook);
1107 1111
1108 if (!NILP (Vdeferred_action_list)) 1112 if (!NILP (Vdeferred_action_list))
1109 call0 (Vdeferred_action_function); 1113 call0 (Vdeferred_action_function);
1110 1114
1111 if (!NILP (XSYMBOL (Qpost_command_idle_hook)->value) && !NILP (Vrun_hooks)) 1115 if (!NILP (Vpost_command_idle_hook) && !NILP (Vrun_hooks))
1112 { 1116 {
1113 if (NILP (Vunread_command_events) 1117 if (NILP (Vunread_command_events)
1114 && NILP (Vexecuting_macro) 1118 && NILP (Vexecuting_macro)
@@ -1245,7 +1249,7 @@ command_loop_1 ()
1245 this_command = cmd; 1249 this_command = cmd;
1246 /* Note that the value cell will never directly contain nil 1250 /* Note that the value cell will never directly contain nil
1247 if the symbol is a local variable. */ 1251 if the symbol is a local variable. */
1248 if (!NILP (XSYMBOL (Qpre_command_hook)->value) && !NILP (Vrun_hooks)) 1252 if (!NILP (Vpre_command_hook) && !NILP (Vrun_hooks))
1249 safe_run_hooks (Qpre_command_hook); 1253 safe_run_hooks (Qpre_command_hook);
1250 1254
1251 if (NILP (this_command)) 1255 if (NILP (this_command))
@@ -1393,14 +1397,13 @@ command_loop_1 ()
1393 1397
1394 /* Note that the value cell will never directly contain nil 1398 /* Note that the value cell will never directly contain nil
1395 if the symbol is a local variable. */ 1399 if the symbol is a local variable. */
1396 if (!NILP (XSYMBOL (Qpost_command_hook)->value) && !NILP (Vrun_hooks)) 1400 if (!NILP (Vpost_command_hook) && !NILP (Vrun_hooks))
1397 safe_run_hooks (Qpost_command_hook); 1401 safe_run_hooks (Qpost_command_hook);
1398 1402
1399 if (!NILP (Vdeferred_action_list)) 1403 if (!NILP (Vdeferred_action_list))
1400 safe_run_hooks (Qdeferred_action_function); 1404 safe_run_hooks (Qdeferred_action_function);
1401 1405
1402 if (!NILP (XSYMBOL (Qpost_command_idle_hook)->value) 1406 if (!NILP (Vpost_command_idle_hook) && !NILP (Vrun_hooks))
1403 && !NILP (Vrun_hooks))
1404 { 1407 {
1405 if (NILP (Vunread_command_events) 1408 if (NILP (Vunread_command_events)
1406 && NILP (Vexecuting_macro) 1409 && NILP (Vexecuting_macro)
@@ -2649,7 +2652,7 @@ kbd_buffer_get_event (kbp, used_mouse_menu)
2649 abort (); 2652 abort ();
2650#endif 2653#endif
2651 } 2654 }
2652#ifdef HAVE_X11 2655#if defined (HAVE_X11) || defined (HAVE_NTGUI)
2653 else if (event->kind == delete_window_event) 2656 else if (event->kind == delete_window_event)
2654 { 2657 {
2655 /* Make an event (delete-frame (FRAME)). */ 2658 /* Make an event (delete-frame (FRAME)). */
@@ -2725,7 +2728,7 @@ kbd_buffer_get_event (kbp, used_mouse_menu)
2725 if (NILP (obj)) 2728 if (NILP (obj))
2726 { 2729 {
2727 obj = make_lispy_event (event); 2730 obj = make_lispy_event (event);
2728#ifdef USE_X_TOOLKIT 2731#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
2729 /* If this was a menu selection, then set the flag to inhibit 2732 /* If this was a menu selection, then set the flag to inhibit
2730 writing to last_nonmenu_event. Don't do this if the event 2733 writing to last_nonmenu_event. Don't do this if the event
2731 we're returning is (menu-bar), though; that indicates the 2734 we're returning is (menu-bar), though; that indicates the
@@ -2961,6 +2964,160 @@ static char *lispy_accent_keys[] =
2961 "dead-abovedot", 2964 "dead-abovedot",
2962}; 2965};
2963 2966
2967#ifdef HAVE_NTGUI
2968#define FUNCTION_KEY_OFFSET 0x0
2969
2970char *lispy_function_keys[] =
2971 {
2972 0, /* 0 */
2973
2974 0, /* VK_LBUTTON 0x01 */
2975 0, /* VK_RBUTTON 0x02 */
2976 "cancel", /* VK_CANCEL 0x03 */
2977 0, /* VK_MBUTTON 0x04 */
2978
2979 0, 0, 0, /* 0x05 .. 0x07 */
2980
2981 "backspace", /* VK_BACK 0x08 */
2982 "tab", /* VK_TAB 0x09 */
2983
2984 0, 0, /* 0x0A .. 0x0B */
2985
2986 "clear", /* VK_CLEAR 0x0C */
2987 "return", /* VK_RETURN 0x0D */
2988
2989 0, 0, /* 0x0E .. 0x0F */
2990
2991 "shift", /* VK_SHIFT 0x10 */
2992 "control", /* VK_CONTROL 0x11 */
2993 "menu", /* VK_MENU 0x12 */
2994 "pause", /* VK_PAUSE 0x13 */
2995 "capital", /* VK_CAPITAL 0x14 */
2996
2997 0, 0, 0, 0, 0, 0, /* 0x15 .. 0x1A */
2998
2999 0, /* VK_ESCAPE 0x1B */
3000
3001 0, 0, 0, 0, /* 0x1C .. 0x1F */
3002
3003 0, /* VK_SPACE 0x20 */
3004 "prior", /* VK_PRIOR 0x21 */
3005 "next", /* VK_NEXT 0x22 */
3006 "end", /* VK_END 0x23 */
3007 "home", /* VK_HOME 0x24 */
3008 "left", /* VK_LEFT 0x25 */
3009 "up", /* VK_UP 0x26 */
3010 "right", /* VK_RIGHT 0x27 */
3011 "down", /* VK_DOWN 0x28 */
3012 "select", /* VK_SELECT 0x29 */
3013 "print", /* VK_PRINT 0x2A */
3014 "execute", /* VK_EXECUTE 0x2B */
3015 "snapshot", /* VK_SNAPSHOT 0x2C */
3016 "insert", /* VK_INSERT 0x2D */
3017 "delete", /* VK_DELETE 0x2E */
3018 "help", /* VK_HELP 0x2F */
3019
3020 /* VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */
3021
3022 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3023
3024 0, 0, 0, 0, 0, 0, 0, /* 0x3A .. 0x40 */
3025
3026 /* VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */
3027
3028 0, 0, 0, 0, 0, 0, 0, 0, 0,
3029 0, 0, 0, 0, 0, 0, 0, 0, 0,
3030 0, 0, 0, 0, 0, 0, 0, 0,
3031
3032 0, /* VK_LWIN 0x5B */
3033 0, /* VK_RWIN 0x5C */
3034 0, /* VK_APPS 0x5D */
3035
3036 0, 0, /* 0x5E .. 0x5F */
3037
3038 "kp-0", /* VK_NUMPAD0 0x60 */
3039 "kp-1", /* VK_NUMPAD1 0x61 */
3040 "kp-2", /* VK_NUMPAD2 0x62 */
3041 "kp-3", /* VK_NUMPAD3 0x63 */
3042 "kp-4", /* VK_NUMPAD4 0x64 */
3043 "kp-5", /* VK_NUMPAD5 0x65 */
3044 "kp-6", /* VK_NUMPAD6 0x66 */
3045 "kp-7", /* VK_NUMPAD7 0x67 */
3046 "kp-8", /* VK_NUMPAD8 0x68 */
3047 "kp-9", /* VK_NUMPAD9 0x69 */
3048 "kp-multiply", /* VK_MULTIPLY 0x6A */
3049 "kp-add", /* VK_ADD 0x6B */
3050 "kp-separator", /* VK_SEPARATOR 0x6C */
3051 "kp-subtract", /* VK_SUBTRACT 0x6D */
3052 "kp-decimal", /* VK_DECIMAL 0x6E */
3053 "kp-divide", /* VK_DIVIDE 0x6F */
3054 "f1", /* VK_F1 0x70 */
3055 "f2", /* VK_F2 0x71 */
3056 "f3", /* VK_F3 0x72 */
3057 "f4", /* VK_F4 0x73 */
3058 "f5", /* VK_F5 0x74 */
3059 "f6", /* VK_F6 0x75 */
3060 "f7", /* VK_F7 0x76 */
3061 "f8", /* VK_F8 0x77 */
3062 "f9", /* VK_F9 0x78 */
3063 "f10", /* VK_F10 0x79 */
3064 "f11", /* VK_F11 0x7A */
3065 "f12", /* VK_F12 0x7B */
3066 "f13", /* VK_F13 0x7C */
3067 "f14", /* VK_F14 0x7D */
3068 "f15", /* VK_F15 0x7E */
3069 "f16", /* VK_F16 0x7F */
3070 "f17", /* VK_F17 0x80 */
3071 "f18", /* VK_F18 0x81 */
3072 "f19", /* VK_F19 0x82 */
3073 "f20", /* VK_F20 0x83 */
3074 "f21", /* VK_F21 0x84 */
3075 "f22", /* VK_F22 0x85 */
3076 "f23", /* VK_F23 0x86 */
3077 "f24", /* VK_F24 0x87 */
3078
3079 0, 0, 0, 0, /* 0x88 .. 0x8B */
3080 0, 0, 0, 0, /* 0x8C .. 0x8F */
3081
3082 "kp-numlock", /* VK_NUMLOCK 0x90 */
3083 "scroll", /* VK_SCROLL 0x91 */
3084
3085 0, 0, 0, 0, 0, /* 0x92 .. 0x96 */
3086 0, 0, 0, 0, 0, /* 0x97 .. 0x9B */
3087 0, 0, 0, 0, /* 0x9C .. 0x9F */
3088
3089 /*
3090 * VK_L* & VK_R* - left and right Alt, Ctrl and Shift virtual keys.
3091 * Used only as parameters to GetAsyncKeyState() and GetKeyState().
3092 * No other API or message will distinguish left and right keys this way.
3093 */
3094 /* 0xA0 .. 0xEF */
3095
3096 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3097 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3098 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3099 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3100 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3101
3102 /* 0xF0 .. 0xF5 */
3103
3104 0, 0, 0, 0, 0, 0,
3105
3106 "attn", /* VK_ATTN 0xF6 */
3107 "crsel", /* VK_CRSEL 0xF7 */
3108 "exsel", /* VK_EXSEL 0xF8 */
3109 "ereof", /* VK_EREOF 0xF9 */
3110 "play", /* VK_PLAY 0xFA */
3111 "zoom", /* VK_ZOOM 0xFB */
3112 "noname", /* VK_NONAME 0xFC */
3113 "pa1", /* VK_PA1 0xFD */
3114 "oem_clear", /* VK_OEM_CLEAR 0xFE */
3115 };
3116
3117#else
3118
3119#define FUNCTION_KEY_OFFSET 0xff00
3120
2964/* You'll notice that this table is arranged to be conveniently 3121/* You'll notice that this table is arranged to be conveniently
2965 indexed by X Windows keysym values. */ 3122 indexed by X Windows keysym values. */
2966static char *lispy_function_keys[] = 3123static char *lispy_function_keys[] =
@@ -3057,6 +3214,8 @@ static char *lispy_function_keys[] =
3057 0, 0, 0, 0, 0, 0, 0, "delete" 3214 0, 0, 0, 0, 0, 0, 0, "delete"
3058 }; 3215 };
3059 3216
3217#endif /* HAVE_NTGUI */
3218
3060static char *lispy_mouse_names[] = 3219static char *lispy_mouse_names[] =
3061{ 3220{
3062 "mouse-1", "mouse-2", "mouse-3", "mouse-4", "mouse-5" 3221 "mouse-1", "mouse-2", "mouse-3", "mouse-4", "mouse-5"
@@ -3167,7 +3326,7 @@ make_lispy_event (event)
3167 (unsigned)-1); 3326 (unsigned)-1);
3168 } 3327 }
3169 3328
3170 return modify_event_symbol (event->code - 0xff00, 3329 return modify_event_symbol (event->code - FUNCTION_KEY_OFFSET,
3171 event->modifiers, 3330 event->modifiers,
3172 Qfunction_key, Qnil, 3331 Qfunction_key, Qnil,
3173 lispy_function_keys, &func_key_syms, 3332 lispy_function_keys, &func_key_syms,
@@ -3420,7 +3579,7 @@ make_lispy_event (event)
3420 } 3579 }
3421#endif /* HAVE_MOUSE */ 3580#endif /* HAVE_MOUSE */
3422 3581
3423#ifdef USE_X_TOOLKIT 3582#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
3424 case menu_bar_event: 3583 case menu_bar_event:
3425 /* The event value is in the cdr of the frame_or_window slot. */ 3584 /* The event value is in the cdr of the frame_or_window slot. */
3426 if (!CONSP (event->frame_or_window)) 3585 if (!CONSP (event->frame_or_window))
@@ -3924,7 +4083,7 @@ modify_event_symbol (symbol_num, modifiers, symbol_kind, name_alist,
3924 else if (name_table[symbol_num]) 4083 else if (name_table[symbol_num])
3925 value = intern (name_table[symbol_num]); 4084 value = intern (name_table[symbol_num]);
3926 4085
3927#ifdef HAVE_X_WINDOWS 4086#ifdef HAVE_WINDOW_SYSTEM
3928 if (NILP (value)) 4087 if (NILP (value))
3929 { 4088 {
3930 char *name = x_get_keysym_name (symbol_num); 4089 char *name = x_get_keysym_name (symbol_num);
@@ -4804,7 +4963,7 @@ read_char_x_menu_prompt (nmaps, maps, prev_event, used_mouse_menu)
4804 if (mapno >= nmaps) 4963 if (mapno >= nmaps)
4805 return Qnil; 4964 return Qnil;
4806 4965
4807#if (defined (HAVE_X_WINDOWS) && defined (HAVE_X_MENU)) || defined (MSDOS) 4966#if (defined (HAVE_X_WINDOWS) && defined (HAVE_X_MENU)) || defined (MSDOS) || defined (HAVE_NTGUI)
4808 /* If we got to this point via a mouse click, 4967 /* If we got to this point via a mouse click,
4809 use a real menu for mouse selection. */ 4968 use a real menu for mouse selection. */
4810 if (EVENT_HAS_PARAMETERS (prev_event) 4969 if (EVENT_HAS_PARAMETERS (prev_event)
@@ -4854,7 +5013,7 @@ read_char_x_menu_prompt (nmaps, maps, prev_event, used_mouse_menu)
4854 *used_mouse_menu = 1; 5013 *used_mouse_menu = 1;
4855 return value; 5014 return value;
4856 } 5015 }
4857#endif /* (HAVE_X_WINDOWS && HAVE_X_MENU) || MSDOS */ 5016#endif /* (HAVE_X_WINDOWS && HAVE_X_MENU) || MSDOS || HAVE_NTGUI */
4858 return Qnil ; 5017 return Qnil ;
4859} 5018}
4860 5019