x-mouse.elc 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. (provide (quote x-mouse))
  2. (defconst x-button-right (char-to-string 0))
  3. (defconst x-button-middle (char-to-string 1))
  4. (defconst x-button-left (char-to-string 2))
  5. (defconst x-button-right-up (char-to-string 4))
  6. (defconst x-button-middle-up (char-to-string 5))
  7. (defconst x-button-left-up (char-to-string 6))
  8. (defconst x-button-s-right (char-to-string 16))
  9. (defconst x-button-s-middle (char-to-string 17))
  10. (defconst x-button-s-left (char-to-string 18))
  11. (defconst x-button-s-right-up (char-to-string 20))
  12. (defconst x-button-s-middle-up (char-to-string 21))
  13. (defconst x-button-s-left-up (char-to-string 22))
  14. (defconst x-button-m-right (char-to-string 32))
  15. (defconst x-button-m-middle (char-to-string 33))
  16. (defconst x-button-m-left (char-to-string 34))
  17. (defconst x-button-m-right-up (char-to-string 36))
  18. (defconst x-button-m-middle-up (char-to-string 37))
  19. (defconst x-button-m-left-up (char-to-string 38))
  20. (defconst x-button-c-right (char-to-string 64))
  21. (defconst x-button-c-middle (char-to-string 65))
  22. (defconst x-button-c-left (char-to-string 66))
  23. (defconst x-button-c-right-up (char-to-string 68))
  24. (defconst x-button-c-middle-up (char-to-string 69))
  25. (defconst x-button-c-left-up (char-to-string 70))
  26. (defconst x-button-m-s-right (char-to-string 48))
  27. (defconst x-button-m-s-middle (char-to-string 49))
  28. (defconst x-button-m-s-left (char-to-string 50))
  29. (defconst x-button-m-s-right-up (char-to-string 52))
  30. (defconst x-button-m-s-middle-up (char-to-string 53))
  31. (defconst x-button-m-s-left-up (char-to-string 54))
  32. (defconst x-button-c-s-right (char-to-string 80))
  33. (defconst x-button-c-s-middle (char-to-string 81))
  34. (defconst x-button-c-s-left (char-to-string 82))
  35. (defconst x-button-c-s-right-up (char-to-string 84))
  36. (defconst x-button-c-s-middle-up (char-to-string 85))
  37. (defconst x-button-c-s-left-up (char-to-string 86))
  38. (defconst x-button-c-m-right (char-to-string 96))
  39. (defconst x-button-c-m-middle (char-to-string 97))
  40. (defconst x-button-c-m-left (char-to-string 98))
  41. (defconst x-button-c-m-right-up (char-to-string 100))
  42. (defconst x-button-c-m-middle-up (char-to-string 101))
  43. (defconst x-button-c-m-left-up (char-to-string 102))
  44. (defconst x-button-c-m-s-right (char-to-string 112))
  45. (defconst x-button-c-m-s-middle (char-to-string 113))
  46. (defconst x-button-c-m-s-left (char-to-string 114))
  47. (defconst x-button-c-m-s-right-up (char-to-string 116))
  48. (defconst x-button-c-m-s-middle-up (char-to-string 117))
  49. (defconst x-button-c-m-s-left-up (char-to-string 118))
  50. (defvar x-process-mouse-hook nil "\
  51. Hook to run after each mouse event is processed. Should take two
  52. arguments; the first being a list (XPOS YPOS) corresponding to character
  53. offset from top left of screen and the second being a specifier for the
  54. buttons/keys.
  55. This will normally be set on a per-buffer basis.")
  56. (defun x-flush-mouse-queue nil "\
  57. Process all queued mouse events." (interactive) (byte-code "ÃˆÄ ÅV… Æ ˆÇÀ!…ÀJ…È
  58. #ˆ‚‡" [x-process-mouse-hook x-mouse-pos x-mouse-item nil x-mouse-events 0 x-proc-mouse-event boundp funcall] 8))
  59. (define-key global-map " " (quote x-flush-mouse-queue))
  60. (define-key global-map "" (quote x-flush-mouse-queue))
  61. (defun x-mouse-select (arg) "\
  62. Select Emacs window the mouse is on." (byte-code "Ç ÂÇ Â ?…È \"‰?…,É !‰ˆ =…(Ɖˆ‚
  63. ˆÊ !ˆ ,‡" [start-w done nil w rel-coordinate arg t selected-window coordinates-in-window-p next-window select-window] 7))
  64. (defun x-mouse-keep-one-window (arg) "\
  65. Select Emacs window mouse is on, then kill all other Emacs windows." (byte-code "Á!…Â ‡" [arg x-mouse-select delete-other-windows] 3))
  66. (defun x-mouse-select-and-split (arg) "\
  67. Select Emacs window mouse is on, then split it vertically in half." (byte-code "Â!… ÃÁ!‡" [arg nil x-mouse-select split-window-vertically] 3))
  68. (defun x-mouse-set-point (arg) "\
  69. Select Emacs window mouse is on, and move point to mouse position." (byte-code "Ä !@A@…Å !ˆÆ
  70. i\\!+‡" [relative-coordinate arg rel-x rel-y x-mouse-select move-to-window-line move-to-column] 5))
  71. (defun x-mouse-set-mark (arg) "\
  72. Select Emacs window mouse is on, and set mark at mouse position.
  73. Display cursor at that position for a second." (byte-code "Ä!…`ÅŽÆ!ˆÇÂÃ\"ˆÈÉ!))‡" [arg point-save nil t x-mouse-select ((byte-code "b‡" [point-save] 1)) x-mouse-set-point push-mark sit-for 1] 5))
  74. (defun x-cut-text (arg &optional kill) "\
  75. Copy text between point and mouse position into window system cut buffer.
  76. Save in Emacs kill ring also." (byte-code "ÅÆ \"ƒ6Š`ÇÇÈ!ˆ `^ `]‰ˆÉÊ
  77. \"!ˆË
  78. \"ˆ …1Ì
  79. \"+)‚9ÍÎ!‡" [arg opoint beg end kill coordinates-in-window-p selected-window nil x-mouse-set-point x-store-cut-buffer buffer-substring copy-region-as-kill delete-region message "Mouse not in selected window"] 9))
  80. (defun x-paste-text (arg) "\
  81. Move point to mouse position and insert window system cut buffer contents." (byte-code "Á!ˆÂ c‡" [arg x-mouse-set-point x-get-cut-buffer] 3))
  82. (defun x-cut-and-wipe-text (arg) "\
  83. Kill text between point and mouse; also copy to window system cut buffer." (byte-code "ÂÁ\"‡" [arg t x-cut-text] 3))
  84. (defun x-mouse-ignore (arg) "\
  85. Don't do anything." (byte-code "À‡" [nil] 1))
  86. (defun x-buffer-menu (arg) "\
  87. Pop up a menu of buffers for selection with the mouse." (byte-code "ÅÆÇ È …5 @ÉÊË !\"?…+ÌÍË !Î !†$Ï# B
  88. B‰)ˆ A‰ˆ‚ˆÐ
  89. !*BDÑÒ \"†Fp!)‡" [menu tail head elt arg "Buffer Menu" "Select Buffer" buffer-list nil string-match "^ " buffer-name format "%14s %s" buffer-file-name "" reverse switch-to-buffer x-popup-menu] 12))
  90. (defun x-help (arg) "\
  91. Enter a menu-based help system." (byte-code "Â Ã\"… Ä!)‡" [selection arg x-popup-menu ("Help" ("Is there a command that..." ("Command apropos" . command-apropos) ("Apropos" . apropos)) ("Key Commands <==> Functions" ("List all keystroke commands" . describe-bindings) ("Describe key briefly" . describe-key-briefly) ("Describe key verbose" . describe-key) ("Describe Lisp function" . describe-function) ("Where is this command" . where-is)) ("Manual and tutorial" ("Info system" . info) ("Invoke Emacs tutorial" . help-with-tutorial)) ("Odds and ends" ("Last 100 Keystrokes" . view-lossage) ("Describe syntax table" . describe-syntax)) ("Modes" ("Describe current major mode" . describe-mode) ("List all keystroke commands" . describe-bindings)) ("Administrivia" ("View Emacs news" . view-emacs-news) ("View the GNU Emacs license" . describe-copying) ("Describe distribution" . describe-distribution) ("Describe (non)warranty" . describe-no-warranty))) call-interactively] 3))
  92. (define-key mouse-map x-button-c-s-middle (quote x-help))
  93. (define-key mouse-map x-button-c-s-left (quote x-buffer-menu))
  94. (define-key mouse-map x-button-right (quote x-mouse-select))
  95. (define-key mouse-map x-button-left (quote x-mouse-set-mark))
  96. (define-key mouse-map x-button-c-s-right (quote x-mouse-keep-one-window))
  97. (define-key mouse-map x-button-c-right (quote x-mouse-select-and-split))
  98. (define-key mouse-map x-button-middle (quote x-mouse-set-point))
  99. (define-key mouse-map x-button-s-middle (quote x-cut-text))
  100. (define-key mouse-map x-button-s-right (quote x-paste-text))
  101. (define-key mouse-map x-button-c-middle (quote x-cut-and-wipe-text))