view jde-hax.el @ 65:104736399f86

move some local (maritain) stuff into .xemacs/gnus.el
author Henry S Thompson <ht@inf.ed.ac.uk>
date Mon, 16 Dec 2024 18:21:41 +0000
parents 5f3a215f12eb
children
line wrap: on
line source

(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))))