From 2fd234ac62948e26c47b566b8801a4b78851f3ee Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 8 Jan 2009 18:56:39 -0600 Subject: [PATCH] Add common tool commands: F2, A+l, A+L, A+b, A+B --- basis/ui/tools/browser/browser.factor | 21 +++++++++++++++------ basis/ui/tools/common/common.factor | 10 +++------- basis/ui/tools/inspector/inspector.factor | 4 ++-- basis/ui/tools/listener/listener.factor | 20 ++++++++++++-------- basis/ui/tools/operations/operations.factor | 14 +++++++------- basis/ui/tools/profiler/profiler.factor | 4 ++-- basis/ui/tools/tools.factor | 15 +++++++++++++-- basis/ui/tools/walker/walker.factor | 4 ++-- 8 files changed, 56 insertions(+), 36 deletions(-) diff --git a/basis/ui/tools/browser/browser.factor b/basis/ui/tools/browser/browser.factor index e4b3168bd4..211e522c1b 100644 --- a/basis/ui/tools/browser/browser.factor +++ b/basis/ui/tools/browser/browser.factor @@ -9,9 +9,9 @@ ui.gadgets.editors ui.gadgets.labels ui.gadgets.status-bar ui.tools.common ui ; IN: ui.tools.browser -TUPLE: browser-gadget < track pane scroller search-field ; +TUPLE: browser-gadget < tool pane scroller search-field ; -TOOL: browser-gadget { 550 400 } +{ 550 400 } browser-gadget set-tool-dim : show-help ( link browser-gadget -- ) model>> dup add-history @@ -63,10 +63,22 @@ M: browser-gadget definitions-changed ( assoc browser -- ) M: browser-gadget focusable-child* search-field>> ; +: (browser-window) ( topic -- ) + "Browser" open-status-window ; + +: browser-window ( -- ) + "handbook" (browser-window) ; + +\ browser-window H{ { +nullary+ t } } define-command + : com-follow ( link -- ) [ browser-gadget? ] find-window [ [ raise-window ] [ gadget-child show-help ] bi ] - [ "Browser" open-status-window ] if* ; + [ (browser-window) ] if* ; + +: show-browser ( -- ) "handbook" com-follow ; + +\ show-browser H{ { +nullary+ t } } define-command : com-back ( browser -- ) model>> go-back ; @@ -99,7 +111,4 @@ browser-gadget "scrolling" { T{ key-down f f "PAGE_DOWN" } com-page-down } } define-command-map -: browser-window ( -- ) - [ "handbook" com-follow ] with-ui ; - MAIN: browser-window \ No newline at end of file diff --git a/basis/ui/tools/common/common.factor b/basis/ui/tools/common/common.factor index b14d5bc7bb..6d40acbdd3 100644 --- a/basis/ui/tools/common/common.factor +++ b/basis/ui/tools/common/common.factor @@ -1,14 +1,14 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs classes classes.mixin kernel namespaces -parser ui.gadgets ui.gadgets.scrollers ; +parser ui.gadgets ui.gadgets.scrollers ui.gadgets.tracks ; IN: ui.tools.common SYMBOL: tool-dims tool-dims global [ H{ } clone or ] change-at -MIXIN: tool +TUPLE: tool < track ; M: tool pref-dim* class tool-dims get at ; @@ -18,11 +18,7 @@ M: tool layout* [ [ dim>> ] [ class ] bi tool-dims get set-at ] bi ; -: TOOL: - scan-word - [ tool add-mixin-instance ] - [ scan-object swap tool-dims get set-at ] - bi ; parsing +: set-tool-dim ( dim class -- ) tool-dims get set-at ; SLOT: scroller diff --git a/basis/ui/tools/inspector/inspector.factor b/basis/ui/tools/inspector/inspector.factor index 37df73664e..9191110fcd 100644 --- a/basis/ui/tools/inspector/inspector.factor +++ b/basis/ui/tools/inspector/inspector.factor @@ -10,9 +10,9 @@ ui.gadgets.status-bar ui.gadgets.theme ui.gadgets.labelled ui.tools.common ui ; IN: ui.tools.inspector -TUPLE: inspector-gadget < track table ; +TUPLE: inspector-gadget < tool table ; -TOOL: inspector-gadget { 500 300 } +{ 500 300 } inspector-gadget set-tool-dim TUPLE: slot-description key key-string value value-string ; diff --git a/basis/ui/tools/listener/listener.factor b/basis/ui/tools/listener/listener.factor index 147916eab1..0f169faf47 100644 --- a/basis/ui/tools/listener/listener.factor +++ b/basis/ui/tools/listener/listener.factor @@ -149,9 +149,9 @@ M: interactor dispose drop ; over set-caret mark>caret ; -TUPLE: listener-gadget < track input output scroller popup ; +TUPLE: listener-gadget < tool input output scroller popup ; -TOOL: listener-gadget { 550 700 } +{ 550 700 } listener-gadget set-tool-dim : find-listener ( gadget -- listener ) [ listener-gadget? ] find-parent ; @@ -196,13 +196,21 @@ M: listener-gadget focusable-child* : listener-window ( -- ) [ listener-window* drop ] with-ui ; +\ listener-window H{ { +nullary+ t } } define-command + : (get-listener) ( quot -- listener ) find-window - [ gadget-child ] [ listener-window* ] if* ; inline + [ [ raise-window ] [ gadget-child ] bi ] + [ listener-window* ] if* ; inline : get-listener ( -- listener ) [ listener-gadget? ] (get-listener) ; +: show-listener ( -- ) + get-listener drop ; + +\ show-listener H{ { +nullary+ t } } define-command + : get-ready-listener ( -- listener ) [ { @@ -398,16 +406,12 @@ listener-gadget "scrolling" { T{ key-down f { A+ } "PAGE_DOWN" } com-page-down } } define-command-map -\ refresh-all -H{ { +nullary+ t } { +listener+ t } } define-command - listener-gadget "multi-touch" f { { T{ up-action } refresh-all } } define-command-map -listener-gadget "workflow" f { +listener-gadget "other" f { { T{ key-down f f "ESC" } hide-popup } - { T{ key-down f f "F2" } refresh-all } } define-command-map M: listener-gadget graft* diff --git a/basis/ui/tools/operations/operations.factor b/basis/ui/tools/operations/operations.factor index cd9df9aff3..43de1a2f61 100644 --- a/basis/ui/tools/operations/operations.factor +++ b/basis/ui/tools/operations/operations.factor @@ -62,7 +62,7 @@ V{ } clone operations set-global : edit-file ( pathname -- ) edit ; [ pathname? ] \ edit-file H{ - { +keyboard+ T{ key-down f { C+ } "E" } } + { +keyboard+ T{ key-down f { C+ } "e" } } { +primary+ t } { +secondary+ t } { +listener+ t } @@ -71,7 +71,7 @@ V{ } clone operations set-global UNION: definition word method-spec link vocab vocab-link ; [ definition? ] \ edit H{ - { +keyboard+ T{ key-down f { C+ } "E" } } + { +keyboard+ T{ key-down f { C+ } "e" } } { +listener+ t } } define-operation @@ -86,7 +86,7 @@ UNION: definition word method-spec link vocab vocab-link ; } define-operation [ topic? ] \ com-follow H{ - { +keyboard+ T{ key-down f { C+ } "H" } } + { +keyboard+ T{ key-down f { C+ } "h" } } { +primary+ t } } define-operation @@ -98,7 +98,7 @@ UNION: definition word method-spec link vocab vocab-link ; ! } define-operation [ word? ] \ fix H{ - { +keyboard+ T{ key-down f { C+ } "F" } } + { +keyboard+ T{ key-down f { C+ } "f" } } { +listener+ t } } define-operation @@ -128,7 +128,7 @@ M: word com-stack-effect def>> com-stack-effect ; : com-enter-in ( vocab -- ) vocab-name set-in ; [ vocab? ] \ com-enter-in H{ - { +keyboard+ T{ key-down f { C+ } "I" } } + { +keyboard+ T{ key-down f { C+ } "i" } } { +listener+ t } } define-operation @@ -140,12 +140,12 @@ M: word com-stack-effect def>> com-stack-effect ; } define-operation [ vocab-spec? ] \ run H{ - { +keyboard+ T{ key-down f { C+ } "R" } } + { +keyboard+ T{ key-down f { C+ } "r" } } { +listener+ t } } define-operation [ vocab? ] \ test H{ - { +keyboard+ T{ key-down f { C+ } "T" } } + { +keyboard+ T{ key-down f { C+ } "t" } } { +listener+ t } } define-operation diff --git a/basis/ui/tools/profiler/profiler.factor b/basis/ui/tools/profiler/profiler.factor index 37a0ed1081..867afbb65f 100644 --- a/basis/ui/tools/profiler/profiler.factor +++ b/basis/ui/tools/profiler/profiler.factor @@ -13,14 +13,14 @@ FROM: models.filter => ; FROM: models.compose => ; IN: ui.tools.profiler -TUPLE: profiler-gadget < track +TUPLE: profiler-gadget < tool sort vocabs vocab words methods generic class ; -TOOL: profiler-gadget { 700 400 } +{ 700 400 } profiler-gadget set-tool-dim SINGLETON: word-renderer diff --git a/basis/ui/tools/tools.factor b/basis/ui/tools/tools.factor index 81ef87a16b..9e20a686cc 100644 --- a/basis/ui/tools/tools.factor +++ b/basis/ui/tools/tools.factor @@ -1,9 +1,20 @@ ! Copyright (C) 2006, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: ui.tools.operations ui.tools.listener ui kernel ; +USING: ui.tools.operations ui.tools.listener ui.tools.browser +ui.tools.common ui.commands ui.gestures ui kernel tools.vocabs ; IN: ui.tools : main ( -- ) restore-windows? [ restore-windows ] [ listener-window ] if ; -MAIN: main \ No newline at end of file +MAIN: main + +\ refresh-all H{ { +nullary+ t } { +listener+ t } } define-command + +tool "common" "Common commands available in all UI tools" { + { T{ key-down f { A+ } "l" } show-listener } + { T{ key-down f { A+ } "L" } listener-window } + { T{ key-down f { A+ } "b" } show-browser } + { T{ key-down f { A+ } "B" } browser-window } + { T{ key-down f f "F2" } refresh-all } +} define-command-map \ No newline at end of file diff --git a/basis/ui/tools/walker/walker.factor b/basis/ui/tools/walker/walker.factor index eeaa8a1f5b..c5d6dd7cdc 100644 --- a/basis/ui/tools/walker/walker.factor +++ b/basis/ui/tools/walker/walker.factor @@ -8,12 +8,12 @@ ui.gadgets.labels ui threads namespaces make tools.walker assocs combinators fry ; IN: ui.tools.walker -TUPLE: walker-gadget < track +TUPLE: walker-gadget < tool status continuation thread traceback closing? ; -TOOL: walker-gadget { 620 620 } +{ 620 620 } walker-gadget set-tool-dim : walker-command ( walker msg -- ) swap