Merge pull request #2435 from myk002/myk_default_search_key

supply default search key for tokenized text
develop
Myk 2022-11-29 15:07:23 -08:00 committed by GitHub
commit 04bdce0d40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

@ -115,9 +115,10 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
- ``dfhack.constructions.findAtTile()``: exposed preexisting function to Lua.
- ``dfhack.constructions.insert()``: exposed new function to Lua.
- ``widgets.Panel``: new ``frame_style`` and ``frame_title`` attributes for drawing frames around groups of widgets
- ``widgets.EditField``: now allows other widgets to process characters that the ``on_char`` callback rejects.
- ``widgets.FilteredList``: now provides a useful default search key for list items made up of text tokens instead of plain text
- ``widgets.ResizingPanel``: now accounts for frame inset when calculating frame size
- ``widgets.HotkeyLabel``: now ignores mouse clicks when ``on_activate`` is not defined
- ``widgets.EditField`` now allows other widgets to process characters that the ``on_char`` callback rejects.
- ``gui.Screen.show()`` now returns ``self`` as a convenience
- ``gui.View.getMousePos()`` now takes an optional ``ViewRect`` parameter in case the caller wants to get the mouse pos relative to a rect that is not the frame_body (such as the frame_rect)
- Lua mouse events now conform to documented behavior in `lua-api` -- ``_MOUSE_L_DOWN`` will be sent exactly once per mouse click and ``_MOUSE_L`` will be sent repeatedly as long as the button is held down. Similarly for right mouse button events.

@ -1456,7 +1456,20 @@ function FilteredList:setFilter(filter, pos)
for i,v in ipairs(self.choices) do
local ok = true
local search_key = v.search_key or v.text
local search_key = v.search_key
if not search_key then
if type(v.text) ~= 'table' then
search_key = v.text
else
local texts = {}
for _,token in ipairs(v.text) do
table.insert(texts,
type(token) == 'string' and token
or getval(token.text) or '')
end
search_key = table.concat(texts, ' ')
end
end
for _,key in ipairs(tokens) do
key = key:escape_pattern()
-- start matches at non-space or non-punctuation. this allows