comparison src/keyboard.c @ 42337:aed4f1043eb8

(record_char): Ignore duplicate help-echo events only separated by mouse-movement. When tracking mouse, only record first and last mouse-movement event in same window. Don't record mouse-movement events in keyboard macros.
author Kim F. Storm <storm@cua.dk>
date Tue, 25 Dec 2001 23:38:23 +0000
parents 3069e9eb44de
children 488ddda9d397
comparison
equal deleted inserted replaced
42336:ee21403198b5 42337:aed4f1043eb8
2980 2980
2981 static void 2981 static void
2982 record_char (c) 2982 record_char (c)
2983 Lisp_Object c; 2983 Lisp_Object c;
2984 { 2984 {
2985 /* Don't record `help-echo' in recent_keys unless it shows some help 2985 int recorded = 0;
2986 message, and a different help than the previoiusly recorded 2986
2987 event. */ 2987 if (CONSP (c) && (EQ (XCAR (c), Qhelp_echo) || EQ (XCAR (c), Qmouse_movement)))
2988 if (CONSP (c) && EQ (XCAR (c), Qhelp_echo)) 2988 {
2989 { 2989 /* To avoid filling recent_keys with help-echo and mouse-movement
2990 Lisp_Object help; 2990 events, we filter out repeated help-echo events, only store the
2991 2991 first and last in a series of mouse-movement events, and don't
2992 help = Fcar (Fcdr (XCDR (c))); 2992 store repeated help-echo events which are only separated by
2993 if (STRINGP (help)) 2993 mouse-movement events. */
2994 { 2994
2995 int last_idx; 2995 Lisp_Object ev1, ev2, ev3;
2996 Lisp_Object last_c, last_help; 2996 int ix1, ix2, ix3;
2997 2997
2998 last_idx = recent_keys_index - 1; 2998 if ((ix1 = recent_keys_index - 1) < 0)
2999 if (last_idx < 0) 2999 ix1 = NUM_RECENT_KEYS - 1;
3000 last_idx = NUM_RECENT_KEYS - 1; 3000 ev1 = AREF (recent_keys, ix1);
3001 last_c = AREF (recent_keys, last_idx); 3001
3002 3002 if ((ix2 = ix1 - 1) < 0)
3003 if (!CONSP (last_c) 3003 ix2 = NUM_RECENT_KEYS - 1;
3004 || !EQ (XCAR (last_c), Qhelp_echo) 3004 ev2 = AREF (recent_keys, ix2);
3005 || (last_help = Fcar (Fcdr (XCDR (last_c))), 3005
3006 !EQ (last_help, help))) 3006 if ((ix3 = ix2 - 1) < 0)
3007 ix3 = NUM_RECENT_KEYS - 1;
3008 ev3 = AREF (recent_keys, ix3);
3009
3010 if (EQ (XCAR (c), Qhelp_echo))
3011 {
3012 /* Don't record `help-echo' in recent_keys unless it shows some help
3013 message, and a different help than the previoiusly recorded
3014 event. */
3015 Lisp_Object help, last_help;
3016
3017 help = Fcar_safe (Fcdr_safe (XCDR (c)));
3018 if (!STRINGP (help))
3019 recorded = 1;
3020 else if (CONSP (ev1) && EQ (XCAR (ev1), Qhelp_echo)
3021 && (last_help = Fcar_safe (Fcdr_safe (XCDR (ev1))), EQ (last_help, help)))
3022 recorded = 1;
3023 else if (CONSP (ev1) && EQ (XCAR (ev1), Qmouse_movement)
3024 && CONSP (ev2) && EQ (XCAR (ev2), Qhelp_echo)
3025 && (last_help = Fcar_safe (Fcdr_safe (XCDR (ev2))), EQ (last_help, help)))
3026 recorded = -1;
3027 else if (CONSP (ev1) && EQ (XCAR (ev1), Qmouse_movement)
3028 && CONSP (ev2) && EQ (XCAR (ev2), Qmouse_movement)
3029 && CONSP (ev3) && EQ (XCAR (ev3), Qhelp_echo)
3030 && (last_help = Fcar_safe (Fcdr_safe (XCDR (ev3))), EQ (last_help, help)))
3031 recorded = -2;
3032 }
3033 else if (EQ (XCAR (c), Qmouse_movement))
3034 {
3035 /* Only record one pair of `mouse-movement' on a window in recent_keys.
3036 So additional mouse movement events replace the last element. */
3037 Lisp_Object last_window, window;
3038
3039 window = Fcar_safe (Fcar_safe (XCDR (c)));
3040 if (CONSP (ev1) && EQ (XCAR (ev1), Qmouse_movement)
3041 && (last_window = Fcar_safe (Fcar_safe (XCDR (ev1))), EQ (last_window, window))
3042 && CONSP (ev2) && EQ (XCAR (ev2), Qmouse_movement)
3043 && (last_window = Fcar_safe (Fcar_safe (XCDR (ev2))), EQ (last_window, window)))
3007 { 3044 {
3008 total_keys++; 3045 ASET (recent_keys, ix1, c);
3009 ASET (recent_keys, recent_keys_index, c); 3046 recorded = 1;
3010 if (++recent_keys_index >= NUM_RECENT_KEYS)
3011 recent_keys_index = 0;
3012 } 3047 }
3013 } 3048 }
3014 } 3049 }
3015 else 3050 else
3051 store_kbd_macro_char (c);
3052
3053 if (!recorded)
3016 { 3054 {
3017 total_keys++; 3055 total_keys++;
3018 ASET (recent_keys, recent_keys_index, c); 3056 ASET (recent_keys, recent_keys_index, c);
3019 if (++recent_keys_index >= NUM_RECENT_KEYS) 3057 if (++recent_keys_index >= NUM_RECENT_KEYS)
3020 recent_keys_index = 0; 3058 recent_keys_index = 0;
3021 } 3059 }
3060 else if (recorded < 0)
3061 {
3062 /* We need to remove one or two events from recent_keys.
3063 To do this, we simply put nil at those events and move the
3064 recent_keys_index backwards over those events. Usually,
3065 users will never see those nil events, as they will be
3066 overwritten by the command keys entered to see recent_keys
3067 (e.g. C-h l). */
3068
3069 while (recorded++ < 0 && total_keys > 0)
3070 {
3071 if (total_keys < NUM_RECENT_KEYS)
3072 total_keys--;
3073 if (--recent_keys_index < 0)
3074 recent_keys_index = NUM_RECENT_KEYS - 1;
3075 ASET (recent_keys, recent_keys_index, Qnil);
3076 }
3077 }
3078
3079 num_nonmacro_input_events++;
3022 3080
3023 /* Write c to the dribble file. If c is a lispy event, write 3081 /* Write c to the dribble file. If c is a lispy event, write
3024 the event's symbol to the dribble file, in <brackets>. Bleaugh. 3082 the event's symbol to the dribble file, in <brackets>. Bleaugh.
3025 If you, dear reader, have a better idea, you've got the source. :-) */ 3083 If you, dear reader, have a better idea, you've got the source. :-) */
3026 if (dribble) 3084 if (dribble)
3049 } 3107 }
3050 } 3108 }
3051 3109
3052 fflush (dribble); 3110 fflush (dribble);
3053 } 3111 }
3054
3055 if (!CONSP (c) || !EQ (Qhelp_echo, XCAR (c)))
3056 store_kbd_macro_char (c);
3057
3058 num_nonmacro_input_events++;
3059 } 3112 }
3060 3113
3061 Lisp_Object 3114 Lisp_Object
3062 print_help (object) 3115 print_help (object)
3063 Lisp_Object object; 3116 Lisp_Object object;