diff options
Diffstat (limited to 'state.lua')
| -rw-r--r-- | state.lua | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -195,6 +195,42 @@ function menu_mt:set_options(options) self:set_cursor(1) end +function menu_mt:get_title() + if self.type == 'search' then + local str = self.search_active and 'Searching: ' or + 'Search results: ' + if self.title then + str = '(' .. self.title .. ') ' .. str + end + + local start = #self.search_text - #self.search_term + local prefix = self.search_text:sub(1, start) + local term = self.search_text:sub(start + 1) + if self.search_active then + local idx = self.search_cursor + if idx <= start then + prefix = prefix:sub(1, idx - 1) .. + '<reset_colour><cursor>' .. + '<colour.search_prefix>' .. + prefix:sub(idx) + else + idx = idx - start + term = term:sub(1, idx - 1) .. '<cursor>' .. + term:sub(idx) + end + end + str = str .. '<colour.search_prefix>' .. prefix .. + '<reset_colour>' .. term + + str = str .. ' <colour.info>(' .. #self.options .. '/' .. + #self.search_options .. ')' + + return str, true + end + + return self.title +end + function menu_mt:set_search_cursor(pos) local pos = math.max(1, math.min(#self.search_text + 1, pos)) if pos == self.search_cursor then |
