2001-07-15 19:53:53 +00:00
|
|
|
;;; levents.el --- emulate the Lucid event data type and associated functions
|
1993-03-17 16:56:02 +00:00
|
|
|
|
2019-01-01 00:59:58 +00:00
|
|
|
;; Copyright (C) 1993, 2001-2019 Free Software Foundation, Inc.
|
1993-03-07 04:10:02 +00:00
|
|
|
|
2019-05-25 13:43:06 -07:00
|
|
|
;; Maintainer: emacs-devel@gnu.org
|
2001-09-04 12:54:14 +00:00
|
|
|
;; Keywords: emulations
|
2009-11-05 21:17:21 +00:00
|
|
|
;; Obsolete-since: 23.2
|
2001-08-26 16:44:22 +00:00
|
|
|
|
1993-03-07 04:10:02 +00:00
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
2008-05-06 03:21:21 +00:00
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1993-03-07 04:10:02 +00:00
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 03:21:21 +00:00
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
1993-03-07 04:10:02 +00:00
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 15:52:52 -07:00
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
1993-03-07 04:10:02 +00:00
|
|
|
|
1993-03-17 16:56:02 +00:00
|
|
|
;;; Commentary:
|
1993-03-07 04:10:02 +00:00
|
|
|
|
|
|
|
;; Things we cannot emulate in Lisp:
|
|
|
|
;; It is not possible to emulate current-mouse-event as a variable,
|
|
|
|
;; though it is not hard to obtain the data from (this-command-keys).
|
|
|
|
|
|
|
|
;; We do not have a variable unread-command-event;
|
|
|
|
;; instead, we have the more general unread-command-events.
|
|
|
|
|
1993-03-07 07:32:47 +00:00
|
|
|
;; Our read-key-sequence and read-char are not precisely
|
|
|
|
;; compatible with those in Lucid Emacs, but they should work ok.
|
1993-03-07 04:10:02 +00:00
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
1993-03-07 20:57:30 +00:00
|
|
|
(defun next-command-event (event)
|
|
|
|
(error "You must rewrite to use `read-command-event' instead of `next-command-event'"))
|
|
|
|
|
|
|
|
(defun next-event (event)
|
|
|
|
(error "You must rewrite to use `read-event' instead of `next-event'"))
|
|
|
|
|
|
|
|
(defun dispatch-event (event)
|
|
|
|
(error "`dispatch-event' not supported"))
|
|
|
|
|
1993-03-07 04:10:02 +00:00
|
|
|
;; Make events of type eval, menu and timeout
|
|
|
|
;; execute properly.
|
|
|
|
|
|
|
|
(define-key global-map [menu] 'execute-eval-event)
|
|
|
|
(define-key global-map [timeout] 'execute-eval-event)
|
|
|
|
(define-key global-map [eval] 'execute-eval-event)
|
|
|
|
|
|
|
|
(defun execute-eval-event (event)
|
|
|
|
(interactive "e")
|
|
|
|
(funcall (nth 1 event) (nth 2 event)))
|
|
|
|
|
|
|
|
(put 'eval 'event-symbol-elements '(eval))
|
|
|
|
(put 'menu 'event-symbol-elements '(eval))
|
|
|
|
(put 'timeout 'event-symbol-elements '(eval))
|
|
|
|
|
|
|
|
(defun allocate-event ()
|
Fix typos in docstrings.
* image-dired.el (image-dired-display-thumbs): Fix typo in docstring.
(image-dired-read-comment): Doc fix.
* json.el (json-object-type, json-array-type, json-key-type, json-false)
(json-null, json-read-number):
* minibuffer.el (completion-in-region-functions):
* calendar/cal-tex.el (cal-tex-daily-end, cal-tex-number-weeks)
(cal-tex-cursor-week):
* emacs-lisp/trace.el (trace-function):
* eshell/em-basic.el (eshell/printnl):
* eshell/em-dirs.el (eshell-last-dir-ring, eshell-parse-drive-letter)
(eshell-read-last-dir-ring, eshell-write-last-dir-ring):
* obsolete/levents.el (allocate-event, event-key, event-object)
(event-point, event-process, event-timestamp, event-to-character)
(event-window, event-x, event-x-pixel, event-y, event-y-pixel):
* textmodes/reftex-vars.el (reftex-index-macros-builtin)
(reftex-section-levels, reftex-auto-recenter-toc, reftex-toc-mode-hook)
(reftex-cite-punctuation, reftex-search-unrecursed-path-first)
(reftex-highlight-selection): Fix typos in docstrings.
2010-03-22 17:50:29 +01:00
|
|
|
"Return an empty event structure.
|
1993-03-07 04:10:02 +00:00
|
|
|
In this emulation, it returns nil."
|
|
|
|
nil)
|
|
|
|
|
|
|
|
(defun button-press-event-p (obj)
|
|
|
|
"True if the argument is a mouse-button-press event object."
|
|
|
|
(and (consp obj) (symbolp (car obj))
|
|
|
|
(memq 'down (get (car obj) 'event-symbol-elements))))
|
|
|
|
|
|
|
|
(defun button-release-event-p (obj)
|
|
|
|
"True if the argument is a mouse-button-release event object."
|
|
|
|
(and (consp obj) (symbolp (car obj))
|
|
|
|
(or (memq 'click (get (car obj) 'event-symbol-elements))
|
|
|
|
(memq 'drag (get (car obj) 'event-symbol-elements)))))
|
|
|
|
|
1997-05-17 18:38:17 +00:00
|
|
|
(defun button-event-p (obj)
|
|
|
|
"True if the argument is a mouse-button press or release event object."
|
|
|
|
(and (consp obj) (symbolp (car obj))
|
|
|
|
(or (memq 'click (get (car obj) 'event-symbol-elements))
|
|
|
|
(memq 'down (get (car obj) 'event-symbol-elements))
|
|
|
|
(memq 'drag (get (car obj) 'event-symbol-elements)))))
|
|
|
|
|
|
|
|
(defun mouse-event-p (obj)
|
|
|
|
"True if the argument is a mouse-button press or release event object."
|
|
|
|
(and (consp obj) (symbolp (car obj))
|
|
|
|
(or (eq (car obj) 'mouse-movement)
|
|
|
|
(memq 'click (get (car obj) 'event-symbol-elements))
|
|
|
|
(memq 'down (get (car obj) 'event-symbol-elements))
|
|
|
|
(memq 'drag (get (car obj) 'event-symbol-elements)))))
|
|
|
|
|
1993-03-07 04:10:02 +00:00
|
|
|
(defun character-to-event (ch &optional event)
|
|
|
|
"Converts a numeric ASCII value to an event structure, replete with
|
|
|
|
bucky bits. The character is the first argument, and the event to fill
|
|
|
|
in is the second. This function contains knowledge about what the codes
|
|
|
|
mean -- for example, the number 9 is converted to the character Tab,
|
|
|
|
not the distinct character Control-I.
|
|
|
|
|
2003-02-04 13:24:35 +00:00
|
|
|
Beware that character-to-event and event-to-character are not strictly
|
|
|
|
inverse functions, since events contain much more information than the
|
1993-03-07 04:10:02 +00:00
|
|
|
ASCII character set can encode."
|
|
|
|
ch)
|
|
|
|
|
|
|
|
(defun copy-event (event1 &optional event2)
|
|
|
|
"Make a copy of the given event object.
|
|
|
|
In this emulation, `copy-event' just returns its argument."
|
|
|
|
event1)
|
|
|
|
|
|
|
|
(defun deallocate-event (event)
|
|
|
|
"Allow the given event structure to be reused.
|
|
|
|
In actual Lucid Emacs, you MUST NOT use this event object after
|
|
|
|
calling this function with it. You will lose. It is not necessary to
|
|
|
|
call this function, as event objects are garbage- collected like all
|
|
|
|
other objects; however, it may be more efficient to explicitly
|
2017-10-09 22:53:19 -07:00
|
|
|
deallocate events when you are sure that this is safe.
|
1993-03-07 04:10:02 +00:00
|
|
|
|
|
|
|
This emulation does not actually deallocate or reuse events
|
|
|
|
except via garbage collection and `cons'."
|
|
|
|
nil)
|
|
|
|
|
|
|
|
(defun enqueue-eval-event: (function object)
|
|
|
|
"Add an eval event to the back of the queue.
|
|
|
|
It will be the next event read after all pending events."
|
|
|
|
(setq unread-command-events
|
|
|
|
(nconc unread-command-events
|
|
|
|
(list (list 'eval function object)))))
|
|
|
|
|
|
|
|
(defun eval-event-p (obj)
|
|
|
|
"True if the argument is an eval or menu event object."
|
|
|
|
(eq (car-safe obj) 'eval))
|
|
|
|
|
|
|
|
(defun event-button (event)
|
|
|
|
"Return the button-number of the given mouse-button-press event."
|
|
|
|
(let ((sym (car (get (car event) 'event-symbol-elements))))
|
|
|
|
(cdr (assq sym '((mouse-1 . 1) (mouse-2 . 2) (mouse-3 . 3)
|
|
|
|
(mouse-4 . 4) (mouse-5 . 5))))))
|
|
|
|
|
|
|
|
(defun event-function (event)
|
|
|
|
"Return the callback function of the given timeout, menu, or eval event."
|
|
|
|
(nth 1 event))
|
|
|
|
|
|
|
|
(defun event-key (event)
|
Fix typos in docstrings.
* image-dired.el (image-dired-display-thumbs): Fix typo in docstring.
(image-dired-read-comment): Doc fix.
* json.el (json-object-type, json-array-type, json-key-type, json-false)
(json-null, json-read-number):
* minibuffer.el (completion-in-region-functions):
* calendar/cal-tex.el (cal-tex-daily-end, cal-tex-number-weeks)
(cal-tex-cursor-week):
* emacs-lisp/trace.el (trace-function):
* eshell/em-basic.el (eshell/printnl):
* eshell/em-dirs.el (eshell-last-dir-ring, eshell-parse-drive-letter)
(eshell-read-last-dir-ring, eshell-write-last-dir-ring):
* obsolete/levents.el (allocate-event, event-key, event-object)
(event-point, event-process, event-timestamp, event-to-character)
(event-window, event-x, event-x-pixel, event-y, event-y-pixel):
* textmodes/reftex-vars.el (reftex-index-macros-builtin)
(reftex-section-levels, reftex-auto-recenter-toc, reftex-toc-mode-hook)
(reftex-cite-punctuation, reftex-search-unrecursed-path-first)
(reftex-highlight-selection): Fix typos in docstrings.
2010-03-22 17:50:29 +01:00
|
|
|
"Return the KeySym of the given key-press event.
|
1993-03-07 04:10:02 +00:00
|
|
|
The value is an ASCII printing character (not upper case) or a symbol."
|
|
|
|
(if (symbolp event)
|
|
|
|
(car (get event 'event-symbol-elements))
|
Audit use of lsh and fix glitches
I audited use of lsh in the Lisp source code, and fixed the
glitches that I found. While I was at it, I replaced uses of lsh
with ash when either will do. Replacement is OK when either
argument is known to be nonnegative, or when only the low-order
bits of the result matter, and is a (minor) win since ash is a bit
more solid than lsh nowadays, and is a bit faster.
* lisp/calc/calc-ext.el (math-check-fixnum):
Prefer most-positive-fixnum to (lsh -1 -1).
* lisp/vc/vc-hg.el (vc-hg-state-fast): When testing fixnum width,
prefer (zerop (ash most-positive-fixnum -32)) to (zerop (lsh -1
32)) (Bug#32485#11).
* lisp/emacs-lisp/bytecomp.el (byte-compile-lapcode):
Tighten sanity-check for bytecode overflow, by checking that the
result of (ash pc -8) is nonnegative. Formerly this check was not
needed since lsh was used and the number overflowed differently.
* lisp/net/dns.el (dns-write): Fix some obvious sign typos in
shift counts. Evidently this part of the code has never been
exercised.
* lisp/progmodes/hideif.el (hif-shiftleft, hif-shiftright):
* lisp/term/common-win.el (x-setup-function-keys):
Simplify.
* admin/unidata/unidata-gen.el, admin/unidata/uvs.el:
* doc/lispref/keymaps.texi, doc/lispref/syntax.texi:
* doc/misc/calc.texi, doc/misc/cl.texi, etc/NEWS.19:
* lisp/arc-mode.el, lisp/calc/calc-bin.el, lisp/calc/calc-comb.el:
* lisp/calc/calc-ext.el, lisp/calc/calc-math.el:
* lisp/cedet/semantic/wisent/comp.el, lisp/composite.el:
* lisp/disp-table.el, lisp/dos-fns.el, lisp/edmacro.el:
* lisp/emacs-lisp/bindat.el, lisp/emacs-lisp/byte-opt.el:
* lisp/emacs-lisp/bytecomp.el, lisp/emacs-lisp/cl-extra.el:
* lisp/erc/erc-dcc.el, lisp/facemenu.el, lisp/gnus/message.el:
* lisp/gnus/nndoc.el, lisp/gnus/nnmaildir.el, lisp/image.el:
* lisp/international/ccl.el, lisp/international/fontset.el:
* lisp/international/mule-cmds.el, lisp/international/mule.el:
* lisp/json.el, lisp/mail/binhex.el, lisp/mail/rmail.el:
* lisp/mail/uudecode.el, lisp/md4.el, lisp/net/dns.el:
* lisp/net/ntlm.el, lisp/net/sasl.el, lisp/net/socks.el:
* lisp/net/tramp.el, lisp/obsolete/levents.el:
* lisp/obsolete/pgg-parse.el, lisp/org/org.el:
* lisp/org/ox-publish.el, lisp/progmodes/cc-defs.el:
* lisp/progmodes/ebnf2ps.el, lisp/progmodes/hideif.el:
* lisp/ps-bdf.el, lisp/ps-print.el, lisp/simple.el:
* lisp/tar-mode.el, lisp/term/common-win.el:
* lisp/term/tty-colors.el, lisp/term/xterm.el, lisp/vc/vc-git.el:
* lisp/vc/vc-hg.el, lisp/x-dnd.el, test/src/data-tests.el:
Prefer ash to lsh when either will do.
2018-08-21 13:44:03 -07:00
|
|
|
(let ((base (logand event (1- (ash 1 18)))))
|
1993-03-07 04:10:02 +00:00
|
|
|
(downcase (if (< base 32) (logior base 64) base)))))
|
|
|
|
|
|
|
|
(defun event-object (event)
|
Fix typos in docstrings.
* image-dired.el (image-dired-display-thumbs): Fix typo in docstring.
(image-dired-read-comment): Doc fix.
* json.el (json-object-type, json-array-type, json-key-type, json-false)
(json-null, json-read-number):
* minibuffer.el (completion-in-region-functions):
* calendar/cal-tex.el (cal-tex-daily-end, cal-tex-number-weeks)
(cal-tex-cursor-week):
* emacs-lisp/trace.el (trace-function):
* eshell/em-basic.el (eshell/printnl):
* eshell/em-dirs.el (eshell-last-dir-ring, eshell-parse-drive-letter)
(eshell-read-last-dir-ring, eshell-write-last-dir-ring):
* obsolete/levents.el (allocate-event, event-key, event-object)
(event-point, event-process, event-timestamp, event-to-character)
(event-window, event-x, event-x-pixel, event-y, event-y-pixel):
* textmodes/reftex-vars.el (reftex-index-macros-builtin)
(reftex-section-levels, reftex-auto-recenter-toc, reftex-toc-mode-hook)
(reftex-cite-punctuation, reftex-search-unrecursed-path-first)
(reftex-highlight-selection): Fix typos in docstrings.
2010-03-22 17:50:29 +01:00
|
|
|
"Return the function argument of the given timeout, menu, or eval event."
|
1993-03-07 04:10:02 +00:00
|
|
|
(nth 2 event))
|
|
|
|
|
|
|
|
(defun event-point (event)
|
Fix typos in docstrings.
* image-dired.el (image-dired-display-thumbs): Fix typo in docstring.
(image-dired-read-comment): Doc fix.
* json.el (json-object-type, json-array-type, json-key-type, json-false)
(json-null, json-read-number):
* minibuffer.el (completion-in-region-functions):
* calendar/cal-tex.el (cal-tex-daily-end, cal-tex-number-weeks)
(cal-tex-cursor-week):
* emacs-lisp/trace.el (trace-function):
* eshell/em-basic.el (eshell/printnl):
* eshell/em-dirs.el (eshell-last-dir-ring, eshell-parse-drive-letter)
(eshell-read-last-dir-ring, eshell-write-last-dir-ring):
* obsolete/levents.el (allocate-event, event-key, event-object)
(event-point, event-process, event-timestamp, event-to-character)
(event-window, event-x, event-x-pixel, event-y, event-y-pixel):
* textmodes/reftex-vars.el (reftex-index-macros-builtin)
(reftex-section-levels, reftex-auto-recenter-toc, reftex-toc-mode-hook)
(reftex-cite-punctuation, reftex-search-unrecursed-path-first)
(reftex-highlight-selection): Fix typos in docstrings.
2010-03-22 17:50:29 +01:00
|
|
|
"Return the character position of the given mouse-related event.
|
1993-03-07 04:10:02 +00:00
|
|
|
If the event did not occur over a window, or did
|
|
|
|
not occur over text, then this returns nil. Otherwise, it returns an index
|
|
|
|
into the buffer visible in the event's window."
|
|
|
|
(posn-point (event-end event)))
|
|
|
|
|
1997-05-17 18:38:17 +00:00
|
|
|
;; Return position of start of line LINE in WINDOW.
|
|
|
|
;; If LINE is nil, return the last position
|
|
|
|
;; visible in WINDOW.
|
|
|
|
(defun event-closest-point-1 (window &optional line)
|
|
|
|
(let* ((total (- (window-height window)
|
|
|
|
(if (window-minibuffer-p window)
|
|
|
|
0 1)))
|
|
|
|
(distance (or line total)))
|
|
|
|
(save-excursion
|
|
|
|
(goto-char (window-start window))
|
|
|
|
(if (= (vertical-motion distance) distance)
|
|
|
|
(if (not line)
|
|
|
|
(forward-char -1)))
|
|
|
|
(point))))
|
|
|
|
|
|
|
|
(defun event-closest-point (event &optional start-window)
|
|
|
|
"Return the nearest position to where EVENT ended its motion.
|
|
|
|
This is computed for the window where EVENT's motion started,
|
|
|
|
or for window WINDOW if that is specified."
|
|
|
|
(or start-window (setq start-window (posn-window (event-start event))))
|
|
|
|
(if (eq start-window (posn-window (event-end event)))
|
|
|
|
(if (eq (event-point event) 'vertical-line)
|
|
|
|
(event-closest-point-1 start-window
|
|
|
|
(cdr (posn-col-row (event-end event))))
|
|
|
|
(if (eq (event-point event) 'mode-line)
|
|
|
|
(event-closest-point-1 start-window)
|
|
|
|
(event-point event)))
|
|
|
|
;; EVENT ended in some other window.
|
|
|
|
(let* ((end-w (posn-window (event-end event)))
|
|
|
|
(end-w-top)
|
|
|
|
(w-top (nth 1 (window-edges start-window))))
|
|
|
|
(setq end-w-top
|
|
|
|
(if (windowp end-w)
|
|
|
|
(nth 1 (window-edges end-w))
|
|
|
|
(/ (cdr (posn-x-y (event-end event)))
|
1997-05-20 17:17:39 +00:00
|
|
|
(frame-char-height end-w))))
|
1997-05-17 18:38:17 +00:00
|
|
|
(if (>= end-w-top w-top)
|
|
|
|
(event-closest-point-1 start-window)
|
|
|
|
(window-start start-window)))))
|
|
|
|
|
1993-03-07 04:10:02 +00:00
|
|
|
(defun event-process (event)
|
Fix typos in docstrings.
* image-dired.el (image-dired-display-thumbs): Fix typo in docstring.
(image-dired-read-comment): Doc fix.
* json.el (json-object-type, json-array-type, json-key-type, json-false)
(json-null, json-read-number):
* minibuffer.el (completion-in-region-functions):
* calendar/cal-tex.el (cal-tex-daily-end, cal-tex-number-weeks)
(cal-tex-cursor-week):
* emacs-lisp/trace.el (trace-function):
* eshell/em-basic.el (eshell/printnl):
* eshell/em-dirs.el (eshell-last-dir-ring, eshell-parse-drive-letter)
(eshell-read-last-dir-ring, eshell-write-last-dir-ring):
* obsolete/levents.el (allocate-event, event-key, event-object)
(event-point, event-process, event-timestamp, event-to-character)
(event-window, event-x, event-x-pixel, event-y, event-y-pixel):
* textmodes/reftex-vars.el (reftex-index-macros-builtin)
(reftex-section-levels, reftex-auto-recenter-toc, reftex-toc-mode-hook)
(reftex-cite-punctuation, reftex-search-unrecursed-path-first)
(reftex-highlight-selection): Fix typos in docstrings.
2010-03-22 17:50:29 +01:00
|
|
|
"Return the process of the given process-output event."
|
1993-03-07 04:10:02 +00:00
|
|
|
(nth 1 event))
|
|
|
|
|
|
|
|
(defun event-timestamp (event)
|
Fix typos in docstrings.
* image-dired.el (image-dired-display-thumbs): Fix typo in docstring.
(image-dired-read-comment): Doc fix.
* json.el (json-object-type, json-array-type, json-key-type, json-false)
(json-null, json-read-number):
* minibuffer.el (completion-in-region-functions):
* calendar/cal-tex.el (cal-tex-daily-end, cal-tex-number-weeks)
(cal-tex-cursor-week):
* emacs-lisp/trace.el (trace-function):
* eshell/em-basic.el (eshell/printnl):
* eshell/em-dirs.el (eshell-last-dir-ring, eshell-parse-drive-letter)
(eshell-read-last-dir-ring, eshell-write-last-dir-ring):
* obsolete/levents.el (allocate-event, event-key, event-object)
(event-point, event-process, event-timestamp, event-to-character)
(event-window, event-x, event-x-pixel, event-y, event-y-pixel):
* textmodes/reftex-vars.el (reftex-index-macros-builtin)
(reftex-section-levels, reftex-auto-recenter-toc, reftex-toc-mode-hook)
(reftex-cite-punctuation, reftex-search-unrecursed-path-first)
(reftex-highlight-selection): Fix typos in docstrings.
2010-03-22 17:50:29 +01:00
|
|
|
"Return the timestamp of the given event object.
|
1993-03-07 04:10:02 +00:00
|
|
|
In Lucid Emacs, this works for any kind of event.
|
|
|
|
In this emulation, it returns nil for non-mouse-related events."
|
|
|
|
(and (listp event)
|
|
|
|
(posn-timestamp (event-end event))))
|
|
|
|
|
|
|
|
(defun event-to-character (event &optional lenient)
|
Fix typos in docstrings.
* image-dired.el (image-dired-display-thumbs): Fix typo in docstring.
(image-dired-read-comment): Doc fix.
* json.el (json-object-type, json-array-type, json-key-type, json-false)
(json-null, json-read-number):
* minibuffer.el (completion-in-region-functions):
* calendar/cal-tex.el (cal-tex-daily-end, cal-tex-number-weeks)
(cal-tex-cursor-week):
* emacs-lisp/trace.el (trace-function):
* eshell/em-basic.el (eshell/printnl):
* eshell/em-dirs.el (eshell-last-dir-ring, eshell-parse-drive-letter)
(eshell-read-last-dir-ring, eshell-write-last-dir-ring):
* obsolete/levents.el (allocate-event, event-key, event-object)
(event-point, event-process, event-timestamp, event-to-character)
(event-window, event-x, event-x-pixel, event-y, event-y-pixel):
* textmodes/reftex-vars.el (reftex-index-macros-builtin)
(reftex-section-levels, reftex-auto-recenter-toc, reftex-toc-mode-hook)
(reftex-cite-punctuation, reftex-search-unrecursed-path-first)
(reftex-highlight-selection): Fix typos in docstrings.
2010-03-22 17:50:29 +01:00
|
|
|
"Return the closest ASCII approximation to the given event object.
|
1993-03-07 04:10:02 +00:00
|
|
|
If the event isn't a keypress, this returns nil.
|
2003-02-04 13:24:35 +00:00
|
|
|
If the second argument is non-nil, then this is lenient in its
|
1993-03-07 04:10:02 +00:00
|
|
|
translation; it will ignore modifier keys other than control and meta,
|
2003-02-04 13:24:35 +00:00
|
|
|
and will ignore the shift modifier on those characters which have no
|
|
|
|
shifted ASCII equivalent (Control-Shift-A for example, will be mapped to
|
|
|
|
the same ASCII code as Control-A.) If the second arg is nil, then nil
|
1993-03-07 04:10:02 +00:00
|
|
|
will be returned for events which have no direct ASCII equivalent."
|
|
|
|
(if (symbolp event)
|
|
|
|
(and lenient
|
|
|
|
(cdr (assq event '((backspace . 8) (delete . 127) (tab . 9)
|
|
|
|
(return . 10) (enter . 10)))))
|
|
|
|
;; Our interpretation is, ASCII means anything a number can represent.
|
|
|
|
(if (integerp event)
|
|
|
|
event nil)))
|
|
|
|
|
|
|
|
(defun event-window (event)
|
Fix typos in docstrings.
* image-dired.el (image-dired-display-thumbs): Fix typo in docstring.
(image-dired-read-comment): Doc fix.
* json.el (json-object-type, json-array-type, json-key-type, json-false)
(json-null, json-read-number):
* minibuffer.el (completion-in-region-functions):
* calendar/cal-tex.el (cal-tex-daily-end, cal-tex-number-weeks)
(cal-tex-cursor-week):
* emacs-lisp/trace.el (trace-function):
* eshell/em-basic.el (eshell/printnl):
* eshell/em-dirs.el (eshell-last-dir-ring, eshell-parse-drive-letter)
(eshell-read-last-dir-ring, eshell-write-last-dir-ring):
* obsolete/levents.el (allocate-event, event-key, event-object)
(event-point, event-process, event-timestamp, event-to-character)
(event-window, event-x, event-x-pixel, event-y, event-y-pixel):
* textmodes/reftex-vars.el (reftex-index-macros-builtin)
(reftex-section-levels, reftex-auto-recenter-toc, reftex-toc-mode-hook)
(reftex-cite-punctuation, reftex-search-unrecursed-path-first)
(reftex-highlight-selection): Fix typos in docstrings.
2010-03-22 17:50:29 +01:00
|
|
|
"Return the window of the given mouse-related event object."
|
1993-03-07 04:10:02 +00:00
|
|
|
(posn-window (event-end event)))
|
|
|
|
|
|
|
|
(defun event-x (event)
|
Fix typos in docstrings.
* image-dired.el (image-dired-display-thumbs): Fix typo in docstring.
(image-dired-read-comment): Doc fix.
* json.el (json-object-type, json-array-type, json-key-type, json-false)
(json-null, json-read-number):
* minibuffer.el (completion-in-region-functions):
* calendar/cal-tex.el (cal-tex-daily-end, cal-tex-number-weeks)
(cal-tex-cursor-week):
* emacs-lisp/trace.el (trace-function):
* eshell/em-basic.el (eshell/printnl):
* eshell/em-dirs.el (eshell-last-dir-ring, eshell-parse-drive-letter)
(eshell-read-last-dir-ring, eshell-write-last-dir-ring):
* obsolete/levents.el (allocate-event, event-key, event-object)
(event-point, event-process, event-timestamp, event-to-character)
(event-window, event-x, event-x-pixel, event-y, event-y-pixel):
* textmodes/reftex-vars.el (reftex-index-macros-builtin)
(reftex-section-levels, reftex-auto-recenter-toc, reftex-toc-mode-hook)
(reftex-cite-punctuation, reftex-search-unrecursed-path-first)
(reftex-highlight-selection): Fix typos in docstrings.
2010-03-22 17:50:29 +01:00
|
|
|
"Return the X position in characters of the given mouse-related event."
|
1993-03-07 04:10:02 +00:00
|
|
|
(/ (car (posn-col-row (event-end event)))
|
1993-03-08 07:44:39 +00:00
|
|
|
(frame-char-width (window-frame (event-window event)))))
|
1993-03-07 04:10:02 +00:00
|
|
|
|
|
|
|
(defun event-x-pixel (event)
|
Fix typos in docstrings.
* image-dired.el (image-dired-display-thumbs): Fix typo in docstring.
(image-dired-read-comment): Doc fix.
* json.el (json-object-type, json-array-type, json-key-type, json-false)
(json-null, json-read-number):
* minibuffer.el (completion-in-region-functions):
* calendar/cal-tex.el (cal-tex-daily-end, cal-tex-number-weeks)
(cal-tex-cursor-week):
* emacs-lisp/trace.el (trace-function):
* eshell/em-basic.el (eshell/printnl):
* eshell/em-dirs.el (eshell-last-dir-ring, eshell-parse-drive-letter)
(eshell-read-last-dir-ring, eshell-write-last-dir-ring):
* obsolete/levents.el (allocate-event, event-key, event-object)
(event-point, event-process, event-timestamp, event-to-character)
(event-window, event-x, event-x-pixel, event-y, event-y-pixel):
* textmodes/reftex-vars.el (reftex-index-macros-builtin)
(reftex-section-levels, reftex-auto-recenter-toc, reftex-toc-mode-hook)
(reftex-cite-punctuation, reftex-search-unrecursed-path-first)
(reftex-highlight-selection): Fix typos in docstrings.
2010-03-22 17:50:29 +01:00
|
|
|
"Return the X position in pixels of the given mouse-related event."
|
1993-03-07 04:10:02 +00:00
|
|
|
(car (posn-col-row (event-end event))))
|
|
|
|
|
|
|
|
(defun event-y (event)
|
Fix typos in docstrings.
* image-dired.el (image-dired-display-thumbs): Fix typo in docstring.
(image-dired-read-comment): Doc fix.
* json.el (json-object-type, json-array-type, json-key-type, json-false)
(json-null, json-read-number):
* minibuffer.el (completion-in-region-functions):
* calendar/cal-tex.el (cal-tex-daily-end, cal-tex-number-weeks)
(cal-tex-cursor-week):
* emacs-lisp/trace.el (trace-function):
* eshell/em-basic.el (eshell/printnl):
* eshell/em-dirs.el (eshell-last-dir-ring, eshell-parse-drive-letter)
(eshell-read-last-dir-ring, eshell-write-last-dir-ring):
* obsolete/levents.el (allocate-event, event-key, event-object)
(event-point, event-process, event-timestamp, event-to-character)
(event-window, event-x, event-x-pixel, event-y, event-y-pixel):
* textmodes/reftex-vars.el (reftex-index-macros-builtin)
(reftex-section-levels, reftex-auto-recenter-toc, reftex-toc-mode-hook)
(reftex-cite-punctuation, reftex-search-unrecursed-path-first)
(reftex-highlight-selection): Fix typos in docstrings.
2010-03-22 17:50:29 +01:00
|
|
|
"Return the Y position in characters of the given mouse-related event."
|
1993-03-07 04:10:02 +00:00
|
|
|
(/ (cdr (posn-col-row (event-end event)))
|
1993-03-08 07:44:39 +00:00
|
|
|
(frame-char-height (window-frame (event-window event)))))
|
1993-03-07 04:10:02 +00:00
|
|
|
|
|
|
|
(defun event-y-pixel (event)
|
Fix typos in docstrings.
* image-dired.el (image-dired-display-thumbs): Fix typo in docstring.
(image-dired-read-comment): Doc fix.
* json.el (json-object-type, json-array-type, json-key-type, json-false)
(json-null, json-read-number):
* minibuffer.el (completion-in-region-functions):
* calendar/cal-tex.el (cal-tex-daily-end, cal-tex-number-weeks)
(cal-tex-cursor-week):
* emacs-lisp/trace.el (trace-function):
* eshell/em-basic.el (eshell/printnl):
* eshell/em-dirs.el (eshell-last-dir-ring, eshell-parse-drive-letter)
(eshell-read-last-dir-ring, eshell-write-last-dir-ring):
* obsolete/levents.el (allocate-event, event-key, event-object)
(event-point, event-process, event-timestamp, event-to-character)
(event-window, event-x, event-x-pixel, event-y, event-y-pixel):
* textmodes/reftex-vars.el (reftex-index-macros-builtin)
(reftex-section-levels, reftex-auto-recenter-toc, reftex-toc-mode-hook)
(reftex-cite-punctuation, reftex-search-unrecursed-path-first)
(reftex-highlight-selection): Fix typos in docstrings.
2010-03-22 17:50:29 +01:00
|
|
|
"Return the Y position in pixels of the given mouse-related event."
|
1993-03-07 04:10:02 +00:00
|
|
|
(cdr (posn-col-row (event-end event))))
|
|
|
|
|
|
|
|
(defun key-press-event-p (obj)
|
|
|
|
"True if the argument is a keyboard event object."
|
|
|
|
(or (integerp obj)
|
|
|
|
(and (symbolp obj)
|
|
|
|
(get obj 'event-symbol-elements))))
|
|
|
|
|
|
|
|
(defun menu-event-p (obj)
|
|
|
|
"True if the argument is a menu event object."
|
|
|
|
(eq (car-safe obj) 'menu))
|
|
|
|
|
|
|
|
(defun motion-event-p (obj)
|
|
|
|
"True if the argument is a mouse-motion event object."
|
|
|
|
(eq (car-safe obj) 'mouse-movement))
|
|
|
|
|
1993-03-07 20:57:30 +00:00
|
|
|
(defun read-command-event ()
|
|
|
|
"Return the next keyboard or mouse event; execute other events.
|
|
|
|
This is similar to the function `next-command-event' of Lucid Emacs,
|
|
|
|
but different in that it returns the event rather than filling in
|
|
|
|
an existing event object."
|
|
|
|
(let (event)
|
|
|
|
(while (progn
|
|
|
|
(setq event (read-event))
|
|
|
|
(not (or (key-press-event-p event)
|
|
|
|
(button-press-event-p event)
|
|
|
|
(button-release-event-p event)
|
|
|
|
(menu-event-p event))))
|
|
|
|
(let ((type (car-safe event)))
|
|
|
|
(cond ((eq type 'eval)
|
|
|
|
(funcall (nth 1 event) (nth 2 event)))
|
|
|
|
((eq type 'switch-frame)
|
1993-05-22 20:25:08 +00:00
|
|
|
(select-frame (nth 1 event))))))
|
1993-03-07 20:57:30 +00:00
|
|
|
event))
|
1993-03-07 04:10:02 +00:00
|
|
|
|
|
|
|
(defun process-event-p (obj)
|
|
|
|
"True if the argument is a process-output event object.
|
|
|
|
GNU Emacs 19 does not currently generate process-output events."
|
|
|
|
(eq (car-safe obj) 'process))
|
|
|
|
|
1997-06-22 18:57:55 +00:00
|
|
|
(provide 'levents)
|
|
|
|
|
1993-03-07 04:10:02 +00:00
|
|
|
;;; levents.el ends here
|