Implement gesture>string for actions
parent
11f509b0c7
commit
dcbb5bc692
|
@ -71,7 +71,7 @@ M: word command-description ( word -- str )
|
|||
[ props>> ] [ default-flags swap assoc-union ] bi* update ;
|
||||
|
||||
: command-quot ( target command -- quot )
|
||||
dup 1quotation swap +nullary+ word-prop
|
||||
[ 1quotation ] [ +nullary+ word-prop ] bi
|
||||
[ nip ] [ curry ] if ;
|
||||
|
||||
M: word invoke-command ( target command -- )
|
||||
|
@ -85,4 +85,4 @@ M: f invoke-command ( target command -- ) 2drop ;
|
|||
[
|
||||
command-name %
|
||||
gesture>string [ " (" % % ")" % ] when*
|
||||
] "" make ;
|
||||
] "" make ;
|
|
@ -90,6 +90,7 @@ ARTICLE: "gadgets-editors-commands" "Editor gadget commands"
|
|||
{ $command-map editor "editing" }
|
||||
{ $command-map editor "caret-motion" }
|
||||
{ $command-map editor "selection" }
|
||||
{ $command-map editor "clipboard" }
|
||||
{ $command-map multiline-editor "multiline" } ;
|
||||
|
||||
ARTICLE: "ui.gadgets.editors" "Editor gadgets"
|
||||
|
|
|
@ -369,11 +369,11 @@ editor "editing" f {
|
|||
: com-cut ( editor -- ) clipboard get editor-cut ;
|
||||
|
||||
editor "clipboard" f {
|
||||
{ paste-action com-paste }
|
||||
{ copy-action com-copy }
|
||||
{ cut-action com-cut }
|
||||
{ T{ button-up f f 2 } paste-selection }
|
||||
{ copy-action com-copy }
|
||||
{ paste-action com-paste }
|
||||
{ T{ button-up } com-copy-selection }
|
||||
{ T{ button-up f f 2 } paste-selection }
|
||||
} define-command-map
|
||||
|
||||
: previous-character ( editor -- )
|
||||
|
|
|
@ -4,7 +4,7 @@ USING: accessors arrays assocs continuations kernel math models
|
|||
call namespaces opengl sequences io combinators
|
||||
combinators.short-circuit fry math.vectors math.rectangles cache
|
||||
ui.gadgets ui.gestures ui.render ui.text ui.text.private
|
||||
ui.backend ui.gadgets.tracks ;
|
||||
ui.backend ui.gadgets.tracks ui.commands ;
|
||||
IN: ui.gadgets.worlds
|
||||
|
||||
TUPLE: world < track
|
||||
|
@ -110,20 +110,20 @@ ui-error-hook [ [ rethrow ] ] initialize
|
|||
] with-variable
|
||||
] [ drop ] if ;
|
||||
|
||||
world H{
|
||||
{ T{ key-down f { C+ } "z" } [ undo-action send-action ] }
|
||||
{ T{ key-down f { C+ } "Z" } [ redo-action send-action ] }
|
||||
{ T{ key-down f { C+ } "x" } [ cut-action send-action ] }
|
||||
{ T{ key-down f { C+ } "c" } [ copy-action send-action ] }
|
||||
{ T{ key-down f { C+ } "v" } [ paste-action send-action ] }
|
||||
{ T{ key-down f { C+ } "a" } [ select-all-action send-action ] }
|
||||
world
|
||||
action-gestures [
|
||||
[ [ { C+ } ] dip f <key-down> ]
|
||||
[ '[ _ send-action ] ]
|
||||
bi*
|
||||
] H{ } assoc-map-as
|
||||
H{
|
||||
{ T{ button-down f { C+ } 1 } [ drop T{ button-down f f 3 } button-gesture ] }
|
||||
{ T{ button-down f { A+ } 1 } [ drop T{ button-down f f 2 } button-gesture ] }
|
||||
{ T{ button-down f { M+ } 1 } [ drop T{ button-down f f 2 } button-gesture ] }
|
||||
{ T{ button-up f { C+ } 1 } [ drop T{ button-up f f 3 } button-gesture ] }
|
||||
{ T{ button-up f { A+ } 1 } [ drop T{ button-up f f 2 } button-gesture ] }
|
||||
{ T{ button-up f { M+ } 1 } [ drop T{ button-up f f 2 } button-gesture ] }
|
||||
} set-gestures
|
||||
} assoc-union set-gestures
|
||||
|
||||
PREDICATE: specific-button-up < button-up #>> ;
|
||||
PREDICATE: specific-button-down < button-down #>> ;
|
||||
|
|
|
@ -84,6 +84,23 @@ delete-action select-all-action
|
|||
left-action right-action up-action down-action
|
||||
zoom-in-action zoom-out-action ;
|
||||
|
||||
UNION: action
|
||||
undo-action redo-action
|
||||
cut-action copy-action paste-action
|
||||
delete-action select-all-action
|
||||
left-action right-action up-action down-action
|
||||
zoom-in-action zoom-out-action ;
|
||||
|
||||
CONSTANT: action-gestures
|
||||
{
|
||||
{ "z" undo-action }
|
||||
{ "Z" redo-action }
|
||||
{ "x" cut-action }
|
||||
{ "c" copy-action }
|
||||
{ "v" paste-action }
|
||||
{ "a" select-all-action }
|
||||
}
|
||||
|
||||
! Modifiers
|
||||
SYMBOLS: C+ A+ M+ S+ ;
|
||||
|
||||
|
@ -323,4 +340,14 @@ M: zoom-in-action gesture>string drop "Zoom in" ;
|
|||
|
||||
M: zoom-out-action gesture>string drop "Zoom out (pinch)" ;
|
||||
|
||||
HOOK: action-modifier os ( -- mod )
|
||||
|
||||
M: object action-modifier C+ ;
|
||||
M: macosx action-modifier A+ ;
|
||||
|
||||
M: action gesture>string
|
||||
action-gestures value-at
|
||||
action-modifier 1array
|
||||
swap f <key-down> gesture>string ;
|
||||
|
||||
M: object gesture>string drop f ;
|
||||
|
|
Loading…
Reference in New Issue