diff options
| author | Kim F. Storm | 2004-04-20 22:16:46 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2004-04-20 22:16:46 +0000 |
| commit | ec026e7a3eeb0e4b8322fe8bddb3962e10dba966 (patch) | |
| tree | 34cf4a97e678f0ebea7faa5616e75352af28cbc8 | |
| parent | 1938bc365db9cdcddbd4261740d9ce27c51700d1 (diff) | |
| download | emacs-ec026e7a3eeb0e4b8322fe8bddb3962e10dba966.tar.gz emacs-ec026e7a3eeb0e4b8322fe8bddb3962e10dba966.zip | |
(Fposn_at_x_y, Fposn_at_point): New defuns.
(syms_of_keyboard): Defsubr them.
| -rw-r--r-- | src/keyboard.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index c158ea2fced..9ce832ea42c 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -10489,6 +10489,61 @@ The elements of this list correspond to the arguments of | |||
| 10489 | return Flist (sizeof (val) / sizeof (val[0]), val); | 10489 | return Flist (sizeof (val) / sizeof (val[0]), val); |
| 10490 | } | 10490 | } |
| 10491 | 10491 | ||
| 10492 | DEFUN ("posn-at-x-y", Fposn_at_x_y, Sposn_at_x_y, 2, 3, 0, | ||
| 10493 | doc: /* Return position information for pixel coordinates X and Y. | ||
| 10494 | By default, X and Y are relative to text area of the selected window. | ||
| 10495 | Optional third arg FRAME_OR_WINDOW non-nil specifies frame or window. | ||
| 10496 | |||
| 10497 | The return value is similar to a mouse click position: | ||
| 10498 | (WINDOW AREA-OR-POS (X . Y) TIMESTAMP OBJECT POS (COL . ROW) | ||
| 10499 | IMAGE (DX . DY) (WIDTH . HEIGHT)) | ||
| 10500 | The `posn-' functions access elements of such lists. */) | ||
| 10501 | (x, y, frame_or_window) | ||
| 10502 | Lisp_Object x, y, frame_or_window; | ||
| 10503 | { | ||
| 10504 | if (NILP (frame_or_window)) | ||
| 10505 | frame_or_window = selected_window; | ||
| 10506 | |||
| 10507 | if (WINDOWP (frame_or_window)) | ||
| 10508 | { | ||
| 10509 | struct window *w; | ||
| 10510 | |||
| 10511 | CHECK_LIVE_WINDOW (frame_or_window); | ||
| 10512 | |||
| 10513 | w = XWINDOW (frame_or_window); | ||
| 10514 | XSETINT (x, (WINDOW_TO_FRAME_PIXEL_X (w, XINT (x)) | ||
| 10515 | + window_box_left_offset (w, TEXT_AREA))); | ||
| 10516 | XSETINT (y, WINDOW_TO_FRAME_PIXEL_Y (w, XINT (y))); | ||
| 10517 | frame_or_window = w->frame; | ||
| 10518 | } | ||
| 10519 | |||
| 10520 | CHECK_LIVE_FRAME (frame_or_window); | ||
| 10521 | |||
| 10522 | return make_lispy_position (XFRAME (frame_or_window), &x, &y, 0); | ||
| 10523 | } | ||
| 10524 | |||
| 10525 | DEFUN ("posn-at-point", Fposn_at_point, Sposn_at_point, 0, 2, 0, | ||
| 10526 | doc: /* Return position information for buffer POS in WINDOW. | ||
| 10527 | POS defaults to point in WINDOW; WINDOW defaults to the selected window. | ||
| 10528 | |||
| 10529 | Return nil if position is not visible in window. Otherwise, | ||
| 10530 | the return value is similar to that returned by event-start for | ||
| 10531 | a mouse click at the upper left corner of the glyph corresponding | ||
| 10532 | to the given buffer position: | ||
| 10533 | (WINDOW AREA-OR-POS (X . Y) TIMESTAMP OBJECT POS (COL . ROW) | ||
| 10534 | IMAGE (DX . DY) (WIDTH . HEIGHT)) | ||
| 10535 | The `posn-' functions access elements of such lists. */*/) | ||
| 10536 | (pos, window) | ||
| 10537 | Lisp_Object pos, window; | ||
| 10538 | { | ||
| 10539 | Lisp_Object tem; | ||
| 10540 | |||
| 10541 | tem = Fpos_visible_in_window_p (pos, window, Qt); | ||
| 10542 | if (!NILP (tem)) | ||
| 10543 | tem = Fposn_at_x_y (XCAR (tem), XCAR (XCDR (tem)), window); | ||
| 10544 | return tem; | ||
| 10545 | } | ||
| 10546 | |||
| 10492 | 10547 | ||
| 10493 | /* | 10548 | /* |
| 10494 | * Set up a new kboard object with reasonable initial values. | 10549 | * Set up a new kboard object with reasonable initial values. |
| @@ -10912,6 +10967,8 @@ syms_of_keyboard () | |||
| 10912 | defsubr (&Sset_input_mode); | 10967 | defsubr (&Sset_input_mode); |
| 10913 | defsubr (&Scurrent_input_mode); | 10968 | defsubr (&Scurrent_input_mode); |
| 10914 | defsubr (&Sexecute_extended_command); | 10969 | defsubr (&Sexecute_extended_command); |
| 10970 | defsubr (&Sposn_at_point); | ||
| 10971 | defsubr (&Sposn_at_x_y); | ||
| 10915 | 10972 | ||
| 10916 | DEFVAR_LISP ("last-command-char", &last_command_char, | 10973 | DEFVAR_LISP ("last-command-char", &last_command_char, |
| 10917 | doc: /* Last input event that was part of a command. */); | 10974 | doc: /* Last input event that was part of a command. */); |