diff options
| author | Richard M. Stallman | 1994-02-23 05:08:28 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-02-23 05:08:28 +0000 |
| commit | e55c21bea72663cd74018be0aebbf019b8f8ace5 (patch) | |
| tree | 169ab266ff395998fd3847e1476eaff0e068d68f | |
| parent | 6e2f6f4518fb490338ed6e392c699508fc111461 (diff) | |
| download | emacs-e55c21bea72663cd74018be0aebbf019b8f8ace5.tar.gz emacs-e55c21bea72663cd74018be0aebbf019b8f8ace5.zip | |
(posn-x-y): New function.
(posn-col-row): Convert coords from pixels to glyph units.
| -rw-r--r-- | lisp/subr.el | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index ad5b50ccadf..119e7c2159f 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -356,7 +356,7 @@ If EVENT is a mouse press or a mouse click, this returns the location | |||
| 356 | of the event. | 356 | of the event. |
| 357 | If EVENT is a drag, this returns the drag's starting position. | 357 | If EVENT is a drag, this returns the drag's starting position. |
| 358 | The return value is of the form | 358 | The return value is of the form |
| 359 | (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP) | 359 | (WINDOW BUFFER-POSITION (X . Y) TIMESTAMP) |
| 360 | The `posn-' functions access elements of such lists." | 360 | The `posn-' functions access elements of such lists." |
| 361 | (nth 1 event)) | 361 | (nth 1 event)) |
| 362 | 362 | ||
| @@ -364,7 +364,7 @@ The `posn-' functions access elements of such lists." | |||
| 364 | "Return the ending location of EVENT. EVENT should be a click or drag event. | 364 | "Return the ending location of EVENT. EVENT should be a click or drag event. |
| 365 | If EVENT is a click event, this function is the same as `event-start'. | 365 | If EVENT is a click event, this function is the same as `event-start'. |
| 366 | The return value is of the form | 366 | The return value is of the form |
| 367 | (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP) | 367 | (WINDOW BUFFER-POSITION (X . Y) TIMESTAMP) |
| 368 | The `posn-' functions access elements of such lists." | 368 | The `posn-' functions access elements of such lists." |
| 369 | (nth (if (consp (nth 2 event)) 2 1) event)) | 369 | (nth (if (consp (nth 2 event)) 2 1) event)) |
| 370 | 370 | ||
| @@ -376,30 +376,42 @@ The return value is a positive integer." | |||
| 376 | (defsubst posn-window (position) | 376 | (defsubst posn-window (position) |
| 377 | "Return the window in POSITION. | 377 | "Return the window in POSITION. |
| 378 | POSITION should be a list of the form | 378 | POSITION should be a list of the form |
| 379 | (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP) | 379 | (WINDOW BUFFER-POSITION (X . Y) TIMESTAMP) |
| 380 | as returned by the `event-start' and `event-end' functions." | 380 | as returned by the `event-start' and `event-end' functions." |
| 381 | (nth 0 position)) | 381 | (nth 0 position)) |
| 382 | 382 | ||
| 383 | (defsubst posn-point (position) | 383 | (defsubst posn-point (position) |
| 384 | "Return the buffer location in POSITION. | 384 | "Return the buffer location in POSITION. |
| 385 | POSITION should be a list of the form | 385 | POSITION should be a list of the form |
| 386 | (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP) | 386 | (WINDOW BUFFER-POSITION (X . Y) TIMESTAMP) |
| 387 | as returned by the `event-start' and `event-end' functions." | 387 | as returned by the `event-start' and `event-end' functions." |
| 388 | (if (consp (nth 1 position)) | 388 | (if (consp (nth 1 position)) |
| 389 | (car (nth 1 position)) | 389 | (car (nth 1 position)) |
| 390 | (nth 1 position))) | 390 | (nth 1 position))) |
| 391 | 391 | ||
| 392 | (defsubst posn-col-row (position) | 392 | (defsubst posn-x-y (position) |
| 393 | "Return the row and column in POSITION. | 393 | "Return the x and y coordinates in POSITION. |
| 394 | POSITION should be a list of the form | 394 | POSITION should be a list of the form |
| 395 | (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP) | 395 | (WINDOW BUFFER-POSITION (X . Y) TIMESTAMP) |
| 396 | as returned by the `event-start' and `event-end' functions." | 396 | as returned by the `event-start' and `event-end' functions." |
| 397 | (nth 2 position)) | 397 | (nth 2 position)) |
| 398 | 398 | ||
| 399 | (defsubst posn-col-row (position) | ||
| 400 | "Return the row and column in POSITION, measured in characters. | ||
| 401 | POSITION should be a list of the form | ||
| 402 | (WINDOW BUFFER-POSITION (X . Y) TIMESTAMP) | ||
| 403 | as returned by the `event-start' and `event-end' functions." | ||
| 404 | (let* ((pair (nth 2 position)) | ||
| 405 | (window (posn-window position)) | ||
| 406 | (frame (if (framep window) window (window-frame window))) | ||
| 407 | (x (/ (car pair) (frame-char-width frame))) | ||
| 408 | (y (/ (cdr pair) (frame-char-height frame)))) | ||
| 409 | (cons x y))) | ||
| 410 | |||
| 399 | (defsubst posn-timestamp (position) | 411 | (defsubst posn-timestamp (position) |
| 400 | "Return the timestamp of POSITION. | 412 | "Return the timestamp of POSITION. |
| 401 | POSITION should be a list of the form | 413 | POSITION should be a list of the form |
| 402 | (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP) | 414 | (WINDOW BUFFER-POSITION (X . Y) TIMESTAMP) |
| 403 | as returned by the `event-start' and `event-end' functions." | 415 | as returned by the `event-start' and `event-end' functions." |
| 404 | (nth 3 position)) | 416 | (nth 3 position)) |
| 405 | 417 | ||