home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
me34src.zip
/
me3
/
mutt
/
package
/
mouse.mut
< prev
next >
Wrap
Text File
|
1995-01-14
|
9KB
|
306 lines
;; mouse.mut - mouse support.
;; WARNINGS
;; DO NOT bind any keys in this file! If it is autoloaded, binding keys
;; may be put in the wrong keymap (eg popup menus).
;; This code generates mouse events
;; Mouse driver (in ME) else handles motion compression
;; MouseInfo
;; button: 1, 2, 3, ... 5
;; r,c: row and column of the current (abs) location of the mouse
;; ??? deltas?
;; Motion is character resolution
;; Motion is compressed? Will this mess up D&D? Maybe don't care
;; if only generate motion while a button is down.
;; r == row, c == col
;; Origin?
;; state:
;; If button != 0, 0 is button is up, 1 if button is down, 2 is both
;; (ie button click, not a drag).
;; motion: 1 if mouse motion else 0
;; No MouseInfo generated without a button
;; Generated MouseInfo:
;; Button click:
;; Button 1 clicked: (1, -1,0, C)
;; Drag:
;; Move mouse while button 1 is down:
;; Button 1 pressed: nothing
;; Mouse moved: (1, <start r,c>, D), (1, r,c, D)
;; Get motion event when mouse moves more than 1 character.
;; Button 1 released: (1, r,c, U)
;; Double click:
;; ???
;; Generated mouse events:
;; Button Motion D/U/C Event
;; 1,2,3 no C S-<x> where x is 1,2 or 3
;; 1,2,3 yes D S-<x> where x is 3 + 1,2 or 3
;; Mouse keys:
;; S-m : what ME sends for all mouse events. Use (mouse-info) to find
;; out more about the event.
;; This code converts the mouse event into ME keys that can be bound.
;; They are:
;; S-1 ... S-5 : Mouse click on button 1 ... 5
;; S-! : Shift mouse click button 1
;; S-@ : Shift mouse click button 2
;; S-# : Shift mouse click button 3
;; S-$ : Shift mouse click button 4
;; S-% : Shift mouse click button 5
;; C-S-1 ... C-S-5 : Control Shift mouse click button 1 ... 5
;; M-S-1 ... M-S-5 : Meta Shift mouse click button 1 ... 5
;; M-C-S-1 ... M-C-S-5 : Meta Control Shift mouse click button 1 ... 5
;; For mouse motion (holding down a mouse button while moving the mouse),
;; S-6 ... S-0 (^&*() for shifted) keys are generated.
(include me.mh)
(defun
MAIN
{
(bind-key GLOBAL-KEYMAP
"do-mouse" "S-m"
"mouse-move-point" "S-1"
"mouse-1" "S-2"
"mouse-set-mark" "S-3" ;; button 3
"mouse-copy-region" "S-#" ;; shift button 3
"yank" "C-S-3" ;; control button 3
"mouse-drag" "S-a"
"previous-page" "S-!" ;; shift button 1
"next-page" "S-@" ;; shift button 2
"scroll-up" "C-S-1" ;; control button 1
"scroll-down" "C-S-2" ;; control button 2
)
}
mouse-move-point { (point-to-mouse) }
mouse-set-mark { (if (point-to-mouse) (set-the-mark)) }
mouse-copy-region
{
(if (copy-region) (msg "Region copied."))
}
mouse-1
{
(int where-is-mouse window row-in-window)
(small-int button row col state modifiers) ;; MouseInfo
(mouse-info (loc button))
(where-is-mouse (mouse-window row (loc window)(loc row-in-window)))
(cond
(== 0 where-is-mouse) ;; mouse in a window
{
(if (== col (screen-width))
{
(cond
(== 1 row-in-window) (previous-page)
(== (window-length) row-in-window) (next-page)
TRUE { (arg-prefix 1)(refresh-screen) }
)
}
(point-to-mouse))
}
(== 1 where-is-mouse) (free-window window) ;; mouse on a modeline
)
}
)
(bool mouse-drag-in-progress mouse-drag-no-good)
(defun
mouse-drag
{
(small-int button row col mouse-state modifiers) ;; MouseInfo
(mouse-info (loc button))
(if mouse-drag-no-good
{
(if (== mouse-state BUTTON-UP) ;; done dragging
{
(mouse-drag-no-good FALSE)
(mouse-drag-in-progress FALSE)
})
(done)
})
(if mouse-drag-in-progress
{
(floc "mouse-dragging"())
(if (== mouse-state BUTTON-UP) ;; done dragging
{
(floc "mouse-drag-done"())
(mouse-drag-in-progress FALSE)
})
}
{
(mouse-drag-no-good (not (floc "mouse-drag-start"())))
(mouse-drag-in-progress TRUE)
})
}
)
(defun
mouse-drag-start
{
(small-int button row col state modifiers) ;; MouseInfo
(mouse-info (loc button))
(msg "Mouse drag start: (" row "," col ")")
TRUE
}
mouse-dragging
{
(small-int button row col state modifiers) ;; MouseInfo
(mouse-info (loc button))
(msg "Mouse drag in progess: (" row "," col ")")
}
mouse-drag-done
{
(small-int button row col state modifiers) ;; MouseInfo
(mouse-info (loc button))
(msg "Done dragging: (" row "," col ")")
}
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;; ME Support Routines ;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; !!!!!!!!!!!!!???????????????
;; modify (window-row) to:
;; (window-row) : same
;; (window-row 0) : same as (window-row)
;; (window-row 1) : screen row
(defun screen-row
{
(int n row)
(row (window-row))
(n (- (current-window) 1))
(while (!= -1 n)
{
(+= row (window-length n) 1)
(-= n 1)
})
row
})
;; Find the window the mouse is in
;; Returns:
;; 0: Mouse is in a window
;; 1: Mouse is on a modeline
;; 2: Mouse is mini buffer
;; window: id of window mouse is in
;; mouse-row-in-window:
(defun mouse-window (int mouse-row)(pointer int window mouse-row-in-window)
{
(int n rows)
(n 0)(rows 0)
(while (!= n (windows))
{
(if (<= mouse-row (+= rows (window-length n) 1))
{
(window n)
(mouse-row-in-window
(+ (- mouse-row rows) 1 (window-length n)))
(if (== mouse-row rows) 1 0)
(done)
})
(+= n 1)
})
2
})
;; Move the point to where the mouse cursor is.
;; This only works right after a mouse event
(defun point-to-mouse
{
(int sr where-is-mouse window row-in-window)
(small-int button mouse-row mouse-col state modifiers) ;; MouseInfo
(mouse-info (loc button))
(where-is-mouse (mouse-window mouse-row (loc window)(loc row-in-window)))
(if (!= 0 where-is-mouse) { FALSE (done) }) ;; in minibuffer or on modeline
(current-window window)(update)
;(msg ">>" window " " row-in-window " " (window-row))
(forward-line (- row-in-window (window-row)))
(current-column mouse-col)
TRUE
})
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;; Gory Details ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This code converts the mouse key (from the driver) multiple mouse keys.
;; No MouseInfo generated without a button
;; Generated MouseInfo:
;; Button click:
;; Button 1 clicked: (1, -1,0, C)
;; Drag:
;; Move mouse while button 1 is down:
;; Button 1 pressed: nothing
;; Mouse moved: (1, <start r,c>, D), (1, r,c, D)
;; Get motion event when mouse moves more than 1 character.
;; Button 1 released: (1, r,c, U)
;; Double click:
;; ???
;; Generated mouse events:
;; Button Motion D/U/C Event
;; 1,2,3 no C S-<x> where x is 1,2 or 3
;; 1,2,3 yes D S-<x> where x is 3 + 1,2 or 3
;; Mouse keys:
;; S-m : what ME sends for all mouse events. Use (mouse-info) to find
;; out more about the event.
;; This code converts the mouse event into ME keys that can be bound.
;; They are:
;; S-1 ... S-5 : Mouse click on button 1 ... 5
;; S-! : Shift mouse click button 1
;; S-@ : Shift mouse click button 2
;; S-# : Shift mouse click button 3
;; S-$ : Shift mouse click button 4
;; S-% : Shift mouse click button 5
;; C-S-1 ... C-S-5 : Control Shift mouse click button 1 ... 5
;; M-S-1 ... M-S-5 : Meta Shift mouse click button 1 ... 5
;; M-C-S-1 ... M-C-S-5 : Meta Control Shift mouse click button 1 ... 5
;; For mouse motion (holding down a mouse button while moving the mouse),
;; S-6 ... S-0 (^&*() for shifted) keys are generated.
(defun
do-mouse
{
(small-int button r c state modifiers) ;; MouseInfo
(int b)
(mouse-info (loc button))
;(msg "do-mouse: " button " " r " " c " " state)(get-key)
(b button)
(if (== BUTTON-DOWN state) (+= b 5)) ;; mouse motion
(if (!= 0 (bit-and SHIFT modifiers)) (+= b 10)) ;; Shift modifier
(exe-key
(bit-or ;; "S-<modifiers><special key>
SHIFT
modifiers
(convert-to CHARACTER (extract-element " 1234567890!@#$%^&*()" b))))
}
)