1 USING: accessors ui.gadgets ui.gadgets.labels namespaces make
2 sequences kernel math arrays tools.test io ui.gadgets.panes
3 ui.traverse definitions compiler.units ;
8 GENERIC: (flatten-tree) ( node -- )
10 M: node (flatten-tree)
11 children>> [ (flatten-tree) ] each ;
13 M: object (flatten-tree) , ;
15 : flatten-tree ( seq -- newseq )
16 [ [ (flatten-tree) ] each ] { } make ;
18 : gadgets-in-range ( frompath topath gadget -- seq )
19 gadget-subtree flatten-tree ;
21 [ { "a" "b" "c" "d" } ] [
22 { 0 } { } { "a" "b" "c" "d" } gadgets-in-range
26 { } { 1 } { "a" "b" "c" "d" } gadgets-in-range
30 { 0 } { 0 } { "a" "b" "c" "d" } gadgets-in-range
34 { 0 } { 2 } { "a" "b" "c" "d" } gadgets-in-range
37 [ { "a" "b" "c" "d" } ] [
38 { 0 } { 3 } { "a" "b" "c" "d" } gadgets-in-range
41 [ { "a" "b" "c" "d" } ] [
42 { 0 0 } { 0 3 } { { "a" "b" "c" "d" } } gadgets-in-range
45 [ { "b" "c" "d" "e" } ] [
46 { 0 1 } { 1 } { { "a" "b" "c" "d" } "e" } gadgets-in-range
49 [ { "b" "c" "d" "e" "f" } ] [
50 { 0 1 } { 1 1 } { { "a" "b" "c" "d" } { "e" "f" "g" } } gadgets-in-range
53 [ { "b" "c" "d" { "e" "f" "g" } "h" "i" } ] [
54 { 0 1 } { 2 1 } { { "a" "b" "c" "d" } { "e" "f" "g" } { "h" "i" } } gadgets-in-range
57 [ { "b" "c" "d" { "e" "f" "g" } "h" } ] [
58 { 0 1 } { 2 0 0 } { { "a" "b" "c" "d" } { "e" "f" "g" } { { "h" "i" } "j" } } gadgets-in-range
61 [ { "b" "c" "d" { "e" "f" "g" } "h" "i" } ] [
62 { 0 1 } { 2 0 1 } { { "a" "b" "c" "d" } { "e" "f" "g" } { { "h" "i" } "j" } } gadgets-in-range
65 [ { array children>> } forget ] with-compilation-unit