Mercurial > emacs
comparison src/keyboard.c @ 30212:f45d26144129
(show_help_echo): Add parameters OBJECT and POS.
if HELP is a function, call it with OBJECT and POS as parameters
to get the help to display.
(gen_help_event, kbd_buffer_store_help_event): New functions.
(kbd_buffer_get_event): Construct the Lisp help-event differently.
(read_char): Call show_help_echo with new parameters.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Fri, 14 Jul 2000 13:55:25 +0000 |
parents | ff33a5770282 |
children | 8b24b6f17856 |
comparison
equal
deleted
inserted
replaced
30211:8d8aa26c6884 | 30212:f45d26144129 |
---|---|
1900 return c; | 1900 return c; |
1901 } | 1901 } |
1902 | 1902 |
1903 /* Display help echo in the echo area. | 1903 /* Display help echo in the echo area. |
1904 | 1904 |
1905 MSG a string means display that string, MSG nil means clear the | 1905 HELP a string means display that string, HELP nil means clear the |
1906 help echo. If MSG is neither a string nor nil, it is evaluated | 1906 help echo. If HELP is a function, call it with OBJECT and POS as |
1907 to obtain a string. | 1907 arguments; the function should return a help string or nil for |
1908 none. For all other types of HELP evaluate it to obtain a string. | |
1909 | |
1910 OBJECT is the object where a `help-echo' property was found; POS | |
1911 is the position within OBJECT where it was found. OBJECT is nil | |
1912 if HELP isn't from a `help-echo' text property. | |
1908 | 1913 |
1909 OK_TO_IVERWRITE_KEYSTROKE_ECHO non-zero means it's okay if the help | 1914 OK_TO_IVERWRITE_KEYSTROKE_ECHO non-zero means it's okay if the help |
1910 echo overwrites a keystroke echo currently displayed in the echo | 1915 echo overwrites a keystroke echo currently displayed in the echo |
1911 area. | 1916 area. |
1912 | 1917 |
1913 Note: this function may only be called with MSG being nil or | 1918 Note: this function may only be called with HELP nil or a string |
1914 a string from X code running asynchronously. */ | 1919 from X code running asynchronously. */ |
1915 | 1920 |
1916 void | 1921 void |
1917 show_help_echo (msg, ok_to_overwrite_keystroke_echo) | 1922 show_help_echo (help, object, pos, ok_to_overwrite_keystroke_echo) |
1918 Lisp_Object msg; | 1923 Lisp_Object help, object, pos; |
1919 int ok_to_overwrite_keystroke_echo; | 1924 int ok_to_overwrite_keystroke_echo; |
1920 { | 1925 { |
1921 if (!NILP (msg) && !STRINGP (msg)) | 1926 if (!NILP (help) && !STRINGP (help)) |
1922 { | 1927 { |
1923 msg = eval_form (msg); | 1928 if (FUNCTIONP (help)) |
1924 if (!STRINGP (msg)) | 1929 { |
1930 Lisp_Object args[3]; | |
1931 args[0] = help; | |
1932 args[1] = object; | |
1933 args[2] = pos; | |
1934 help = call_function (3, args); | |
1935 } | |
1936 else | |
1937 help = eval_form (help); | |
1938 | |
1939 if (!STRINGP (help)) | |
1925 return; | 1940 return; |
1926 } | 1941 } |
1927 | 1942 |
1928 if (STRINGP (msg) || NILP (msg)) | 1943 if (STRINGP (help) || NILP (help)) |
1929 { | 1944 { |
1930 if (!NILP (Vshow_help_function)) | 1945 if (!NILP (Vshow_help_function)) |
1931 call1 (Vshow_help_function, msg); | 1946 call1 (Vshow_help_function, help); |
1932 else if (/* Don't overwrite minibuffer contents. */ | 1947 else if (/* Don't overwrite minibuffer contents. */ |
1933 !MINI_WINDOW_P (XWINDOW (selected_window)) | 1948 !MINI_WINDOW_P (XWINDOW (selected_window)) |
1934 /* Don't overwrite a keystroke echo. */ | 1949 /* Don't overwrite a keystroke echo. */ |
1935 && (NILP (echo_message_buffer) || ok_to_overwrite_keystroke_echo) | 1950 && (NILP (echo_message_buffer) |
1951 || ok_to_overwrite_keystroke_echo) | |
1936 /* Don't overwrite a prompt. */ | 1952 /* Don't overwrite a prompt. */ |
1937 && !cursor_in_echo_area) | 1953 && !cursor_in_echo_area) |
1938 { | 1954 { |
1939 if (STRINGP (msg)) | 1955 if (STRINGP (help)) |
1940 { | 1956 { |
1941 int count = specpdl_ptr - specpdl; | 1957 int count = specpdl_ptr - specpdl; |
1942 specbind (Qmessage_truncate_lines, Qt); | 1958 specbind (Qmessage_truncate_lines, Qt); |
1943 message3_nolog (msg, XSTRING (msg)->size, STRING_MULTIBYTE (msg)); | 1959 message3_nolog (help, XSTRING (help)->size, |
1960 STRING_MULTIBYTE (help)); | |
1944 unbind_to (count, Qnil); | 1961 unbind_to (count, Qnil); |
1945 } | 1962 } |
1946 else | 1963 else |
1947 message (0); | 1964 message (0); |
1948 } | 1965 } |
2691 reread_first: | 2708 reread_first: |
2692 | 2709 |
2693 /* Display help if not echoing. */ | 2710 /* Display help if not echoing. */ |
2694 if (CONSP (c) && EQ (XCAR (c), Qhelp_echo)) | 2711 if (CONSP (c) && EQ (XCAR (c), Qhelp_echo)) |
2695 { | 2712 { |
2696 show_help_echo (XCDR (XCDR (c)), 0); | 2713 /* (help-echo FRAME HELP OBJECT POS). */ |
2714 Lisp_Object help, object, position; | |
2715 help = Fnth (make_number (2), c); | |
2716 object = Fnth (make_number (3), c); | |
2717 position = Fnth (make_number (4), c); | |
2718 show_help_echo (help, object, position, 0); | |
2697 goto retry; | 2719 goto retry; |
2698 } | 2720 } |
2699 | 2721 |
2700 if (this_command_key_count == 0 || ! reread) | 2722 if (this_command_key_count == 0 || ! reread) |
2701 { | 2723 { |
3136 ASET (kbd_buffer_gcpro, idx, event->frame_or_window); | 3158 ASET (kbd_buffer_gcpro, idx, event->frame_or_window); |
3137 ASET (kbd_buffer_gcpro, idx + 1, event->arg); | 3159 ASET (kbd_buffer_gcpro, idx + 1, event->arg); |
3138 ++kbd_store_ptr; | 3160 ++kbd_store_ptr; |
3139 } | 3161 } |
3140 } | 3162 } |
3163 | |
3164 | |
3165 /* Generate HELP_EVENT input_events in BUFP. | |
3166 | |
3167 HELP is the help form. | |
3168 | |
3169 FRAME is the frame on which the help is generated. OBJECT is the | |
3170 Lisp object where the help was found (a buffer, a string, or nil if | |
3171 neither from a string nor from a buffer. POS is the position | |
3172 within OBJECT where the help was found. | |
3173 | |
3174 Value is the number of input_events generated. */ | |
3175 | |
3176 int | |
3177 gen_help_event (bufp, help, frame, object, pos) | |
3178 struct input_event *bufp; | |
3179 Lisp_Object help, frame, object; | |
3180 int pos; | |
3181 { | |
3182 bufp->kind = HELP_EVENT; | |
3183 bufp->frame_or_window = frame; | |
3184 bufp->arg = object; | |
3185 bufp->x = make_number (pos); | |
3186 bufp->code = 0; | |
3187 | |
3188 ++bufp; | |
3189 bufp->kind = HELP_EVENT; | |
3190 bufp->frame_or_window = frame; | |
3191 bufp->arg = help; | |
3192 bufp->code = 1; | |
3193 | |
3194 return 2; | |
3195 } | |
3196 | |
3197 | |
3198 /* Store HELP_EVENTs for HELP on FRAME in the input queue. */ | |
3199 | |
3200 void | |
3201 kbd_buffer_store_help_event (frame, help) | |
3202 Lisp_Object frame, help; | |
3203 { | |
3204 struct input_event event; | |
3205 | |
3206 event.kind = HELP_EVENT; | |
3207 event.frame_or_window = frame; | |
3208 event.arg = Qnil; | |
3209 event.x = make_number (0); | |
3210 event.code = 0; | |
3211 kbd_buffer_store_event (&event); | |
3212 | |
3213 event.kind = HELP_EVENT; | |
3214 event.frame_or_window = frame; | |
3215 event.arg = help; | |
3216 event.x = make_number (0); | |
3217 event.code = 1; | |
3218 kbd_buffer_store_event (&event); | |
3219 } | |
3220 | |
3141 | 3221 |
3142 /* Discard any mouse events in the event buffer by setting them to | 3222 /* Discard any mouse events in the event buffer by setting them to |
3143 no_event. */ | 3223 no_event. */ |
3144 void | 3224 void |
3145 discard_mouse_events () | 3225 discard_mouse_events () |
3356 mouse events during a popup-menu call. */ | 3436 mouse events during a popup-menu call. */ |
3357 else if (event->kind == no_event) | 3437 else if (event->kind == no_event) |
3358 kbd_fetch_ptr = event + 1; | 3438 kbd_fetch_ptr = event + 1; |
3359 else if (event->kind == HELP_EVENT) | 3439 else if (event->kind == HELP_EVENT) |
3360 { | 3440 { |
3441 /* There are always two consecutive HELP_EVENTs in the | |
3442 input queue. */ | |
3443 Lisp_Object object, position, help, frame; | |
3444 | |
3445 xassert (event->code == 0); | |
3446 frame = event->frame_or_window; | |
3447 object = event->arg; | |
3448 position = event->x; | |
3449 xassert ((event + 1)->code == 1); | |
3450 help = (event + 1)->arg; | |
3451 | |
3361 /* Event->frame_or_window is a frame, event->arg is the | 3452 /* Event->frame_or_window is a frame, event->arg is the |
3362 help to display. */ | 3453 help to display. */ |
3363 obj = Fcons (Qhelp_echo, | 3454 obj = list5 (Qhelp_echo, frame, help, object, position); |
3364 Fcons (event->frame_or_window, | 3455 kbd_fetch_ptr = event + 2; |
3365 event->arg)); | |
3366 kbd_fetch_ptr = event + 1; | |
3367 } | 3456 } |
3368 else if (event->kind == FOCUS_IN_EVENT) | 3457 else if (event->kind == FOCUS_IN_EVENT) |
3369 { | 3458 { |
3370 /* Notification of a FocusIn event. The frame receiving the | 3459 /* Notification of a FocusIn event. The frame receiving the |
3371 focus is in event->frame_or_window. Generate a | 3460 focus is in event->frame_or_window. Generate a |