aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-02-23 05:08:28 +0000
committerRichard M. Stallman1994-02-23 05:08:28 +0000
commite55c21bea72663cd74018be0aebbf019b8f8ace5 (patch)
tree169ab266ff395998fd3847e1476eaff0e068d68f
parent6e2f6f4518fb490338ed6e392c699508fc111461 (diff)
downloademacs-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.el28
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
356of the event. 356of the event.
357If EVENT is a drag, this returns the drag's starting position. 357If EVENT is a drag, this returns the drag's starting position.
358The return value is of the form 358The return value is of the form
359 (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP) 359 (WINDOW BUFFER-POSITION (X . Y) TIMESTAMP)
360The `posn-' functions access elements of such lists." 360The `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.
365If EVENT is a click event, this function is the same as `event-start'. 365If EVENT is a click event, this function is the same as `event-start'.
366The return value is of the form 366The return value is of the form
367 (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP) 367 (WINDOW BUFFER-POSITION (X . Y) TIMESTAMP)
368The `posn-' functions access elements of such lists." 368The `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.
378POSITION should be a list of the form 378POSITION should be a list of the form
379 (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP) 379 (WINDOW BUFFER-POSITION (X . Y) TIMESTAMP)
380as returned by the `event-start' and `event-end' functions." 380as 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.
385POSITION should be a list of the form 385POSITION should be a list of the form
386 (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP) 386 (WINDOW BUFFER-POSITION (X . Y) TIMESTAMP)
387as returned by the `event-start' and `event-end' functions." 387as 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.
394POSITION should be a list of the form 394POSITION should be a list of the form
395 (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP) 395 (WINDOW BUFFER-POSITION (X . Y) TIMESTAMP)
396as returned by the `event-start' and `event-end' functions." 396as 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.
401POSITION should be a list of the form
402 (WINDOW BUFFER-POSITION (X . Y) TIMESTAMP)
403as 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.
401POSITION should be a list of the form 413POSITION should be a list of the form
402 (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP) 414 (WINDOW BUFFER-POSITION (X . Y) TIMESTAMP)
403as returned by the `event-start' and `event-end' functions." 415as returned by the `event-start' and `event-end' functions."
404 (nth 3 position)) 416 (nth 3 position))
405 417