(provide (quote sun-mouse)) (defvar extra-click-wait 150 "\ *Number of milliseconds to wait for an extra click. Set this to zero if you don't want chords or double clicks.") (defvar scrollbar-width 5 "\ *The character width of the scrollbar. The cursor is deemed to be in the right edge scrollbar if it is this near the right edge, and more than two chars past the end of the indicated line. Setting to nil limits the scrollbar to the edge or vertical dividing bar.") (defun make-mousemap nil "\ Returns a new mousemap." (byte-code "AAB+" [nil mousemap] 2)) (defun copy-mousemap (mousemap) "\ Return a copy of mousemap." (byte-code "A!+" [mousemap copy-alist] 2)) (defun define-mouse (mousemap mouse-list def) "\ Args MOUSEMAP, MOUSE-LIST, DEF. Define MOUSE-LIST in MOUSEMAP as DEF. MOUSE-LIST is a list of atoms specifing a mouse hit according to these rules: * One of these atoms specifies the active region of the definition. text, scrollbar, modeline, minibuffer * One or two or these atoms specify the button or button combination. left, middle, right, double * Any combination of these atoms specify the active shift keys. control, shift, meta * With a single unshifted button, you can add up to indicate an up-click. The atom `double' is used with a button designator to denote a double click. Two button chords are denoted by listing the two buttons. See sun-mouse-handler for the treatment of the form DEF." (byte-code "AA! #+" [mouse-list mousemap def mousemap-set mouse-list-to-mouse-code] 5)) (defun global-set-mouse (mouse-list def) "\ Give MOUSE-EVENT-LIST a local definition of DEF. See define-mouse for a description of MOUSE-EVENT-LIST and DEF. Note that if MOUSE-EVENT-LIST has a local definition in the current buffer, that local definition will continue to shadow any global definition." (interactive "xMouse event: xDefinition: ") (byte-code "EA #+" [current-global-mousemap mouse-list def nil define-mouse] 4)) (defun local-set-mouse (mouse-list def) "\ Give MOUSE-EVENT-LIST a local definition of DEF. See define-mouse for a description of the arguments. The definition goes in the current buffer's local mousemap. Normally buffers in the same major mode share a local mousemap." (interactive "xMouse event: xDefinition: ") (byte-code "E?. #+" [current-local-mousemap mouse-list def nil make-mousemap define-mouse] 5)) (defun use-global-mousemap (mousemap) "\ Selects MOUSEMAP as the global mousemap." (byte-code " %+" [current-global-mousemap mousemap] 2)) (defun use-local-mousemap (mousemap) "\ Selects MOUSEMAP as the local mousemap. nil for MOUSEMAP means no local mousemap." (byte-code " %+" [current-local-mousemap mousemap] 2)) (defun logtest (x y) "\ True if any bits set in X are also set in Y. Just like the Common Lisp function of the same name." (byte-code "AA \"!?+" [x y zerop logand] 4)) (defconst sm::ButtonBits 7) (defconst sm::ShiftmaskBits 56) (defconst sm::DoubleBits 64) (defconst sm::UpBits 128) (defmacro sm::hit-code (hit) (byte-code "AAE+" [hit nth 0] 3)) (defmacro sm::hit-button (hit) (byte-code "AAAAEE+" [hit logand sm::ButtonBits nth 0] 5)) (defmacro sm::hit-shiftmask (hit) (byte-code "AAAAEE+" [hit logand sm::ShiftmaskBits nth 0] 5)) (defmacro sm::hit-double (hit) (byte-code "AAAAEE+" [hit logand sm::DoubleBits nth 0] 5)) (defmacro sm::hit-up (hit) (byte-code "AAAAEE+" [hit logand sm::UpBits nth 0] 5)) (defmacro sm::hit-x (hit) (byte-code "AAE+" [hit nth 1] 3)) (defmacro sm::hit-y (hit) (byte-code "AAE+" [hit nth 2] 3)) (defmacro sm::hit-delta (hit) (byte-code "AAE+" [hit nth 3] 3)) (defmacro sm::hit-up-p (hit) (byte-code "AAADDD+" [hit not zerop sm::hit-up] 4)) (defmacro sm::loc-w (loc) (byte-code "AAE+" [loc nth 0] 3)) (defmacro sm::loc-x (loc) (byte-code "AAE+" [loc nth 1] 3)) (defmacro sm::loc-y (loc) (byte-code "AAE+" [loc nth 2] 3)) (defmacro eval-in-buffer (buffer &rest forms) "Macro to switches to BUFFER, evaluates FORMS, returns to original buffer." (byte-code "AAAAACDD \"EEE+" [buffer forms let ((StartBuffer (current-buffer))) unwind-protect append progn set-buffer (set-buffer StartBuffer)] 7)) (put (quote eval-in-buffer) (quote lisp-indent-hook) 1) (defmacro eval-in-window (window &rest forms) "Switch to WINDOW, evaluate FORMS, return to original window." (byte-code "AAAAACDD \"EEE+" [window forms let ((OriginallySelectedWindow (selected-window))) unwind-protect append progn select-window (if (window-point OriginallySelectedWindow) (select-window OriginallySelectedWindow))] 7)) (put (quote eval-in-window) (quote lisp-indent-hook) 1) (defmacro eval-in-windows (form &optional yesmini) "Switches to each window and evaluates FORM. Optional argument YESMINI says to include the minibuffer as a window. This is a macro, and does not evaluate its arguments." (byte-code "AAAAACEEEEI EDEDEDIEE+" [form yesmini let ((OriginallySelectedWindow (selected-window))) unwind-protect while progn not eq OriginallySelectedWindow select-window next-window nil (select-window OriginallySelectedWindow)] 13)) (put (quote eval-in-window) (quote lisp-indent-hook) 0) (defun move-to-loc (x y) "\ Move cursor to window location X, Y. Handles wrapped and horizontally scrolled lines correctly." (byte-code "A!^iAAC !f Z*+" [y cc nc x move-to-window-line move-to-column zerop window-hscroll window-width 2 + -1] 13)) (defun minibuffer-window-p (window) "\ True iff this WINDOW is minibuffer." (byte-code "A AA!8U+" [window screen-height 3 window-edges] 5)) (setq *mouse-help* nil) (defun sun-mouse-handler (&optional hit) "\ Evaluates the function or list associated with a mouse hit. Expecting to read a hit, which is a list: (button x y delta). A form bound to button by define-mouse is found by mouse-lookup. The variables: *mouse-window*, *mouse-x*, *mouse-y* are bound. If the form is a symbol (symbolp), it is funcall'ed with *mouse-window*, *mouse-x*, and *mouse-y* as arguments; if the form is a list (listp), the form is eval'ed; if the form is neither of these, it is an error. Returns nil." (interactive) (byte-code "??. !q^O fu F!^T ,| $,$ f> (defun mouse-help nil (interactive) (byte-code "^AA )+" [*mouse-help* t nil recursive-edit] 2)) (defun sm::combined-hits nil "\ Read and return next mouse-hit, include possible double click" (byte-code "A CE E8\"!??.9 .8 8E E8\"E E 8\"Uf5 (defun mouse-hit-read nil "\ Read mouse-hit list from keyboard. Like (read 'read-char), but that uses minibuffer, and mucks up last-command." (byte-code "AAAAr% B%^\"?. (defvar mouse-prefix1 24 "\ First char of mouse-prefix. Used to detect double clicks and chords.") (defvar mouse-prefix2 0 "\ Second char of mouse-prefix. Used to detect double clicks and chords.") (defun mouse-second-hit (hit-wait) "\ Returns the next mouse hit occurring within HIT-WAIT milliseconds." (byte-code "E!f \"?+ %^?Y %^I ^?X (defun sm::window-xy (x y) "\ Find window containing screen coordinates X and Y. Returns list (window x y) where x and y are relative to window." (byte-code "A?+ E+" [nil x y found (byte-code "E ?IE !I 8I 8I 8D 8 N U.% Y.K Z ZE\",)^OOEE\"!=?.p (defun sm::window-region (loc) "\ Parse LOC into a region symbol. Returns one of (text scrollbar modeline minibuffer)" (byte-code "E 8E 8E 8E!SI!SI!f Yf4 ZY.K EN #\\YfR (defun window-line-end (w x y) "\ Return WINDOW column (ignore X) containing end of line Y" (byte-code "A ?A !^SAC \")))+" [OriginallySelectedWindow w y selected-window ((byte-code "A!. (defconst sm::keyword-alist (quote ((left . 1) (middle . 2) (right . 4) (shift . 8) (control . 16) (meta . 32) (double . 64) (up . 128) (text . 256) (scrollbar . 512) (modeline . 1024) (minibuffer . 2048)))) (defun mouse-event-code (hit loc) "\ Maps MOUSE-HIT and LOC into a mouse-code." (byte-code "AA8AA !!\"+" [hit loc logior 0 mouse-region-to-code sm::window-region] 5)) (defun mouse-region-to-code (region) "\ Returns partial mouse-code for specified REGION." (byte-code "A \"A+" [region sm::keyword-alist assq] 3)) (defun mouse-list-to-mouse-code (mouse-list) "\ Map a MOUSE-LIST to a mouse-code." (byte-code "AAAA\"\"+" [mouse-list apply logior mapcar (lambda (x) (byte-code "A \"A+" [x sm::keyword-alist assq] 3))] 5)) (defun mouse-code-to-mouse-list (mouse-code) "\ Map a MOUSE-CODE to a mouse-list." (byte-code "AAAA\"\"+" [sm::keyword-alist apply nconc mapcar (lambda (x) (byte-code "A A\". (defun mousemap-set (code mousemap value) (byte-code " AA \" f \", (defun mousemap-get (code mousemap) (byte-code "A A\"A+" [code mousemap assq] 3)) (defun mouse-lookup (mouse-code) "\ Look up MOUSE-EVENT and return the definition. nil means undefined." (byte-code "A \"+ \"+" [mouse-code current-local-mousemap current-global-mousemap mousemap-get] 4)) (defun mouse-mask-lookup (mask list) "\ Args MASK (a bit mask) and LIST (a list of (code . form) pairs). Returns a list of elements of LIST whose code or'ed with MASK is non-zero." (byte-code "A . @@\". @B%^ A%^, (defun mouse-union (l l-unique) "\ Return the union of list of mouse (code . form) pairs L and L-UNIQUE, where L-UNIQUE is considered to be union'ized already." (byte-code "  .! @A @\"?. A%^, (defun mouse-union-first-prefered (l1 l2) "\ Return the union of lists of mouse (code . form) pairs L1 and L2, based on the code's, with preference going to elements in L1." (byte-code "AA A\"\"+" [l2 l1 nil mouse-union] 5)) (defun mouse-code-function-pairs-of-region (region) "\ Return a list of (code . function) pairs, where each code is currently set in the REGION." (byte-code "A !AA A\"A A\"\")+" [mask region current-local-mousemap current-global-mousemap mouse-region-to-code mouse-union-first-prefered mouse-mask-lookup] 7)) (defun one-line-doc-string (function) "\ Returns first line of documentation string for FUNCTION. If there is no documentation string, then the string \"No documentation\" is returned." (byte-code ":. (defun print-mouse-format (binding) (byte-code "A@!^AA!^AAA\"^A ^AA!^AC@!!^A +" [binding princ ": " mapcar (lambda (mouse-list) (byte-code "A!^AA!+" [mouse-list princ " "] 3)) terpri " " one-line-doc-string] 9)) (defun print-mouse-bindings (region) "\ Prints mouse-event bindings for REGION." (byte-code "AAA!\"+" [region mapcar print-mouse-format sm::event-bindings] 4)) (defun sm::event-bindings (region) "\ Returns an alist of (function . (mouse-list1 ... mouse-listN)) for REGION, where each mouse-list is bound to the function in REGION." (byte-code "A !A.: \" B%*^A%^, *+" [mouse-bindings region result nil code-function-pair current-entry mouse-code-function-pairs-of-region assoc setcdr mouse-code-to-mouse-list] 8)) (defun describe-mouse-bindings nil "\ Lists all current mouse-event bindings." (interactive) (byte-code "??AA!^A ^AA!^A ^AC!^A ^AE!^A ^AE!^A ^AE!^A ^AE!^A ^AI!^A ^AI!'+" [nil "*Help*" princ "Text Region" terpri "---- ------" print-mouse-bindings text "Modeline Region" "-------- ------" modeline "Scrollbar Region" "--------- ------" scrollbar] 19)) (defun describe-mouse-briefly (mouse-list) "\ Print a short description of the function bound to MOUSE-LIST." (interactive "xDescibe mouse list briefly: ") (byte-code "^AA !!f (defun mouse-help-menu (function-and-binding) (byte-code "A@!AA@!CAA!CD!B+" [function-and-binding prin1-to-string menu-create one-line-doc-string] 7)) (defun mouse-help-region (w x y &optional region) "\ Displays a menu of mouse functions callable in this region." (byte-code "+ E!EEKE!\"EI!C B!I I (defun menu-create (items) "\ Functional form for defmenu, given a list of ITEMS returns a menu. Each ITEM is a (STRING . VALUE) pair." (byte-code "AA\"+" [items apply vector] 3)) (defmacro defmenu (menu &rest itemlist) "Defines MENU to be a menu, the ITEMS are (STRING . VALUE) pairs. See sun-menu-evaluate for interpretation of ITEMS." (byte-code "AAA \"E+" [menu itemlist defconst funcall menu-create] 5)) (defun sun-menu-evaluate (*menu-window* *menu-x* *menu-y* menu) "\ Display a pop-up menu in WINDOW at X Y and evaluate selected item of MENU. MENU (or its symbol-value) should be a menu defined by defmenu. A menu ITEM is a (STRING . FORM) pair; the FORM associated with the selected STRING is evaluated, and the resulting value is returned. Generally these FORMs are evaluated for their side-effects rather than their values. If the selected form is a menu or a symbol whose value is a menu, then it is displayed and evaluated as a pullright menu item. If the the FORM of the first ITEM is nil, the STRING of the item is used as a label for the menu, i.e. it's inverted and not selectible." (byte-code "9. A%!+" [menu *menu-window* *menu-x* *menu-y* eval sun-menu-internal 4] 7)) (defun sun-get-frame-data (code) "\ Sends the tty-sub-window escape sequence CODE to terminal, and returns a cons of the two numbers in returned escape sequence. That is it returns (cons ) from \"\\E[n;;t\". CODE values: 13 = Tool-Position, 14 = Size-in-Pixels, 18 = Size-in-Chars." (byte-code "AAC!EQ!^EEEEEEr%\"?.$ B%^, !I#%^DN \"^ OO!TOO!O%^ OO!EO%^DN \"^ OO!TOO!O%^O !O !B,+" [code char str x y send-string-to-terminal "[" int-to-string "t" nil equal 116 mapconcat char-to-string nreverse "" string-match ";[0-9]*" match-beginning 0 match-end string-to-int] 16)) (defun sm::font-size nil "\ Returns font size in pixels: (cons Ysize Xsize)" (byte-code "AA!AA!A@ @\"AA A\"B*+" [pix chr sun-get-frame-data 14 18 /] 7)) (defvar sm::menu-kludge-x nil "\ Cached frame-to-window X-Offset for sm::menu-kludge") (defvar sm::menu-kludge-y nil "\ Cached frame-to-window Y-Offset for sm::menu-kludge") (defun sm::menu-kludge nil "\ If sunfns.c uses this function must be here!" (byte-code "+ \\B)+" [sm::menu-kludge-y fs sm::menu-kludge-x wl sm::font-size 8 4 sun-get-frame-data 13] 5)) (defun sunview-yank-stuff nil "\ Set mark and yank the contents of the current TTYSW `STUFF' selection into the current buffer at point. The STUFF selection contains the currently or previously highlighted text from a TTYSW." (interactive "*") (byte-code "?AA!^AA !+" [nil set-mark-command insert-string sun-get-selection] 4)) (defun display-host nil "\ Extract from DISPLAY environment variable, or return nil if not specified." (byte-code "AA!. (defun sunview-yank-clipboard nil "\ Set mark and yank the contents of the SunView Clipboard into the current buffer at point." (interactive "*") (byte-code "?AA!^A  f (defun sunview-yank-current-selection nil "\ Set mark and yank the contents of the current SunView selection into current buffer at point. The current selection is the currently highlighted text in either a textsw or a ttysw." (interactive "*") (byte-code "?AA!^A  f (defun sunview-yank-any-selection (arg) "\ Yank one of the sunview selections: with no arg, the current selection; with minus-only prefix, the clipboard; with any other arg, the ttysw STUFF." (interactive "*P") (byte-code "^?f (defvar owselectionfilex nil "\ Cache path to ttysw selection file (a kludge!).") (defun owselectionfile nil (byte-code "+& !f %,% (defun xv-yank-selection nil "\ Set mark and yank the contents of the current Xview selection into the current buffer at point. The STUFF selection contains the currently or previously highlighted text from a TTYSW." (interactive "*") (byte-code "?A . (defun xv-select-region (beg end) "\ Set the TTYSW selection to the region in the current buffer." (interactive "r") (byte-code "^A . (defun sun-yank-selection nil "\ Set mark and yank the contents of the current TTYSW `STUFF' or Xview selection into the current buffer at point." (interactive "*") (byte-code "?AA!f (defun sun-select-region (beg end) "\ Set the TTYSW 'STUFF' or Xview selection to the region in the current buffer." (interactive "r") (byte-code "^AA!f (defun suspend-emacstool (&optional stuffstring) "\ If running under as a detached process emacstool, you don't want to suspend (there is no way to resume), just close the window, and wait for reopening." (interactive) (byte-code "EAA!. .) !+" [suspend-hook stuffstring suspend-resume-hook nil boundp funcall send-string-to-terminal ""] 7)) (make-variable-buffer-local (quote current-local-mousemap)) (setq-default current-local-mousemap nil) (defvar current-global-mousemap (make-mousemap)) .