]> gitweb.factorcode.org Git - factor.git/commitdiff
Adds keyboard driven link following for the browser
authorinivekin <inivekin@gmail.com>
Sat, 27 Mar 2021 06:54:31 +0000 (14:54 +0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 25 Jan 2022 19:07:19 +0000 (11:07 -0800)
basis/ui/gadgets/buttons/buttons.factor
basis/ui/tools/browser/browser.factor
basis/ui/tools/browser/popups/popups.factor

index c7609dbe06da538cee7120a2953cacf17679b1f5..4ced17e86c29e3f597ef982227e8512b0393dd7b 100644 (file)
@@ -11,6 +11,16 @@ IN: ui.gadgets.buttons
 
 TUPLE: button < border pressed? selected? quot tooltip ;
 
+SYMBOL: active-buttons
+active-buttons [ H{ } ] initialize
+
+: label-from-button ( button -- str )
+    children>> [ label? ] find swap [ text>> ] [ drop "unknown" ] if ;
+
+M: button graft* dup label-from-button active-buttons get set-at ;
+
+M: button ungraft* label-from-button active-buttons get delete-at ;
+
 <PRIVATE
 
 : find-button ( gadget -- button )
index 65d567afeef7ddbc9316a4d2c65cdb7eb24d7c1e..461ee21b5c7feb8bf8955aef960e0bb4977138cc 100644 (file)
@@ -217,6 +217,7 @@ browser-gadget "navigation" "Commands for navigating in the article hierarchy" {
     { T{ key-down f ${ os macosx? M+ A+ ? } "k" } com-show-outgoing-links }
     { T{ key-down f ${ os macosx? M+ A+ ? } "K" } com-show-incoming-links }
     { T{ key-down f ${ os macosx? M+ A+ ? } "f" } browser-focus-search }
+    { T{ key-down f ${ os macosx? C+ A+ ? } "t" } com-show-active-buttons }
 } os macosx? [ {
     { T{ key-down f { M+ } "[" } com-back }
     { T{ key-down f { M+ } "]" } com-forward }
index 81f5099440c499dbe1d06da091260299f4027473..25114b7f5cf945bb12d88b6cd624a63c0026d56b 100644 (file)
@@ -49,3 +49,26 @@ SLOT: model
 
 : com-show-incoming-links ( browser-gadget -- )
     [ usage ] "Incoming links" show-links-popup ;
+
+: <active-buttons-table> ( model -- table )
+    [ keys [ ">" swap 2array ] map ] <arrow> trivial-renderer [ second ] <search-table> 
+        dup table>>
+        active-buttons get '[ second _ at invoke-secondary ] >>action
+        [ hide-glass ] >>hook
+        t >>selection-required?
+        10 >>min-rows
+        10 >>max-rows
+        30 >>min-cols
+        30 >>max-cols drop
+    ;
+
+: <active-buttons-popup> ( model title -- gadget )
+    [ <active-buttons-table> white-interior ] dip
+    popup-color <framed-labeled-gadget> links-popup new-wrapper ;
+
+: show-active-buttons-popup ( browser-gadget model title -- )
+    <active-buttons-popup>
+    [ hand-loc get-global point>rect show-glass ] [ request-focus ] bi ; inline
+
+: com-show-active-buttons ( browser-gadget -- )
+    active-buttons get <model> "Active buttons" show-active-buttons-popup ;