src.elv.sh@v0.21.0-dev.0.20240515223629-06979efb9a2a/pkg/edit/listing_custom.d.elv (about) 1 # Starts custom listing mode. 2 # 3 # The `$items` argument can be as a list of maps, each map representing one item 4 # and having the following keys: 5 # 6 # - The value of the `to-show` key must be a string or a styled text. It is used 7 # in the listing UI. 8 # 9 # - The value of the `to-filter` key must be a string. It is used when filtering 10 # the item. 11 # 12 # - The value of the `to-accept` key must be a string. It is passed to the 13 # accept callback (see below). 14 # 15 # Alternatively, the `$items` argument can be a function taking one argument. It 16 # will be called with the value of the filter (initially an empty string), and 17 # can output any number of maps containing the `to-show` and `to-accept` keys, 18 # with the same semantics as above. Any other key is ignored. 19 # 20 # The `&binding` option, if specified, should be a binding map to use in the 21 # custom listing mode. Bindings from [`$edit:listing:binding`]() are also used, 22 # after this map if it is specified. 23 # 24 # The `&caption` option changes the caption of the mode. If empty, the caption 25 # defaults to `' LISTING '`. 26 # 27 # The `&keep-bottom` option, if true, makes the last item to get selected 28 # initially or when the filter changes. 29 # 30 # The `&accept` option specifies a function to call when an item is accepted. It 31 # is passed the value of the `to-accept` key of the item. 32 # 33 # The `&auto-accept` option, if true, accepts an item automatically when there 34 # is only one item being shown. 35 fn listing:start-custom {|items &binding=$nil &caption='' &keep-bottom=$false &accept=$nil &auto-accept=$false| }