Mercurial > hg > xemacs
diff jde-hax.el @ 78:0abfe9bf83a0
merge
| author | Henry S. Thompson <ht@inf.ed.ac.uk> |
|---|---|
| date | Thu, 25 Sep 2025 17:57:05 +0100 |
| parents | 5f3a215f12eb |
| children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jde-hax.el Thu Sep 25 17:57:05 2025 +0100 @@ -0,0 +1,27 @@ +(defun jde-cursor-posn-as-event(&optional forceText) + "Returns the text cursor position as an EVENT on Emacs and the mouse +cursor position on XEmacs." + (if (and jde-xemacsp (not forceText)) + (let* ((mouse-pos (mouse-pixel-position)) + (x (car (cdr mouse-pos))) + (y (cdr (cdr mouse-pos)))) + (if x + (make-event 'button-press `(button 1 modifiers nil x ,x y ,y)) + (let ((fake (jde-cursor-posn-as-event t))) + (make-event 'button-press `(button 1 modifiers nil + x ,(caar fake) + y ,(cadar fake)))))) + (let ((x (* (if jde-xemacsp (/(window-pixel-width)(window-width)) + (frame-char-width)) + (if (and + (boundp 'hscroll-mode) + (fboundp 'hscroll-window-column)) + (hscroll-window-column) + (mod (current-column) (window-width))))) + (y (* (if jde-xemacsp (/ (window-pixel-height) + (window-height)) + (frame-char-height)) + (- (count-lines (point-min) (point)) + (count-lines (point-min) (window-start))))) + (window (get-buffer-window (current-buffer)))) + (list (list x y) window))))
