diff options
| author | Gerd Moellmann | 2000-07-14 13:55:25 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-07-14 13:55:25 +0000 |
| commit | 8dfd92c9a616f3c0184e764dac3985301ad7836c (patch) | |
| tree | b585a94f4bd2ccb41c3f5374bf1fefd3280a32a5 /src | |
| parent | fc8c47972e9760f487a50dffb2fbef03f05aaa8c (diff) | |
| download | emacs-8dfd92c9a616f3c0184e764dac3985301ad7836c.tar.gz emacs-8dfd92c9a616f3c0184e764dac3985301ad7836c.zip | |
(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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keyboard.c | 129 |
1 files changed, 109 insertions, 20 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index 2442b8823c1..05e2e50e11d 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -1902,45 +1902,62 @@ make_ctrl_char (c) | |||
| 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 |
| @@ -2693,7 +2710,12 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | |||
| 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 | ||
| @@ -3138,6 +3160,64 @@ kbd_buffer_store_event (event) | |||
| 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. */ |
| @@ -3358,12 +3438,21 @@ kbd_buffer_get_event (kbp, used_mouse_menu) | |||
| 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 | { |