]> gitweb.factorcode.org Git - factor.git/commitdiff
ui: add find-windows to find multiple worlds matching a predicate
authorAlexander Iljin <ajsoft@yandex.ru>
Sat, 26 Aug 2017 07:23:18 +0000 (10:23 +0300)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 22 Jan 2018 15:58:17 +0000 (07:58 -0800)
basis/ui/ui-docs.factor
basis/ui/ui.factor

index 29078d5206dd192b62ef160959cccb7d502fa090..4b78687345f9b18213bc1afd4e39c5f0803ce805 100644 (file)
@@ -53,6 +53,10 @@ HELP: fullscreen?
 
 { fullscreen? set-fullscreen } related-words
 
+HELP: find-windows
+{ $values { "quot" { $quotation ( world -- ? ) } } { "seq" sequence } }
+{ $description "Finds all native windows such that the gadget passed to " { $link open-window } " satisfies the quotation, outputting an empty sequence if no such gadget could be found. The front-most native window is the last in the " { $snippet "seq" } "." } ;
+
 HELP: find-window
 { $values { "quot" { $quotation ( world -- ? ) } } { "world/f" { $maybe world } } }
 { $description "Finds a native window such that the gadget passed to " { $link open-window } " satisfies the quotation, outputting " { $link f } " if no such gadget could be found. The front-most native window is checked first." } ;
index 6d2739970f843dcbd0a3d52343608970979eaf2f..1f1d052a9433b23d31885a3c9eaa48722c5e59b7 100644 (file)
@@ -140,10 +140,13 @@ SYMBOL: ui-running
 
 PRIVATE>
 
-: find-window ( quot: ( world -- ? ) -- world/f )
+: find-windows ( quot: ( world -- ? ) -- seq )
     [ ui-windows get-global values ] dip
     '[ dup children>> [ ] [ nip first ] if-empty @ ]
-    find-last nip ; inline
+    filter ; inline
+
+: find-window ( quot: ( world -- ? ) -- world/f )
+    find-windows ?last ; inline
 
 : ui-running? ( -- ? )
     ui-running get-global ;