luv

Workshop wiki

input.lisp

mcclim/input.lisp

system luv/mcclim · 7 definitions · on GitHub

in-package#:mcluv

A luv canvas reports portable physical keys, layout characters, and logical modifiers. McCLIM command tables call the same thing a gesture. Keeping this bridge beside the backend lets every canvas application be a CLIM application without borrowing another application's command package.

defparameter+canvas-lock-modifiers+'
:caps-lock:num-lock
"Modifiers a McCLIM keystroke never names and therefore need not match."
defuncanvas-key-event-gesture-modifiers
event

Return event's logical modifiers, less locks ignored by gestures.

set-difference
luv:canvas-key-event-modifiersevent
+canvas-lock-modifiers+
defuncanvas-key-event-matches-gesture-p
eventgesture

Whether portable luv key event is the McCLIM gesture.

A character gesture matches event's unshifted character, making it a place on the current keyboard layout. A symbol gesture matches the physical key name. The modifier :ANY means the key matches however it is modified.

let*
specification
if
listpgesture
gesture
listgesture
key
firstspecification
modifiers
restspecification
and
etypecasekey
character
eqlkey
luv:canvas-key-event-unshifted-characterevent
symbol
eqkey
luv:canvas-key-event-key-nameevent
or
member:anymodifiers
null
set-exclusive-ormodifiers
defunformat-gesture-key
key
etypecasekey
character
string-upcase
stringkey
symbol
casekey
:return"RET"
:escape"Esc"
:space"Space"
:tab"Tab"
:up"↑"
:down"↓"
:left"←"
:right"→"
:shift-left"Shift"
:shift-right"Shift"
t
string-capitalize
symbol-namekey
defunformat-gesture
gesture

Name gesture for a command legend without duplicating its binding.

let*
specification
if
listpgesture
gesture
listgesture
key
firstspecification
modifiers
remove:any
restspecification
formatnil"~{~A~}~A"
mapcar
lambda
modifier
casemodifier
:shift"Shift-"
:control"Ctrl-"
:meta"Alt-"
:super"Cmd-"
t
formatnil"~A-"modifier
modifiers
defuncanvas-key-event-command
frameevent&key
command-table
frame-command-tableframe

Return the command command-table binds to key event, or NIL.

McCLIM answers with the gesture itself on a miss and checks command enablement against *APPLICATION-FRAME*, so both details are established here.

let*
*application-frame*frame
command
lookup-keystroke-command-itemeventcommand-table:test#'canvas-key-event-matches-gesture-p
and
conspcommand
command
defunexecute-canvas-key-event-command
frameevent

Run frame's command for event inline; return true when one ran.

let
whencommand
execute-frame-commandframecommand
t