Searches a list-panel.
list-panel-search-with-function list-panel function arg &key start-index wrap-around reset-time
A list-panel.
A function taking two arguments. The first is arg , the second is an item in list-panel .
Any Lisp object.
An integer, default 0.
A real number. The default is an internal value which can be set by set-list-panel-keyboard-search-reset-time.
A boolean, default t
.
The function list-panel-search-with-function
searches
list-panel
using
function
. list-panel-search-with-function
is intended to simplify the implementation of the
keyboard-search-callback
of list-panel.
list-panel-search-with-function
searches
list-panel
for a match. It applies
function
to each item and
arg
, until
function
returns non-nil.
When function returns non-nil, list-panel-search-with-function returns three values: the index of the item, arg , and reset-time .
The search starts at
start-index
if supplied, and at 0 otherwise. When the search reaches the end of the list panel and it did not start from 0, it wraps around to the beginning, unless
wrap-around
is supplied as nil
. The default value of
wrap-around
is t
.
(defun string-equal-prefix (string item)
(let* ((start 0)
(len (length item))
(end (+ start (length string))))
(and (>= len end )
(string-equal string item
:start2 start
:end2 end))))
(capi:contain
(make-instance
'capi:list-panel
:items '("ae" "af" "bb" "cc")
:keyboard-search-callback
#'(lambda (pane string position)
(capi:list-panel-search-with-function
pane
'string-equal-prefix ; or 'string-not-greaterp
string
:start position
:reset-time 1
:wrap-around t))))
Pressing "a" slowly cycles between "ae" and "af". Running the same example with string-not-greaterp
instead causes "a" to cycle around all of the items.
CAPI User Guide and Reference Manual (Unix version) - 25 Feb 2015