We have a framework for performing the search but don't actually do any searching yet.
Current plan: searching is expensive, so make searches persistent. Put each search's results in a file as we construct them. They don't reload until you repeat the search.
D7D6T2F3FRMONF627F2NV227T5KTZ4FOHZKROEIIA236U7FVASTQC
IYW5AHK7E2YFDWTX6OBBLYKNMWFANSPALKGVYXGIBRIRCACVQZEQC
3EQZGRICHPHDMY2THLKGTS63G2L3CDED2HILRAY425Z55A26YQXAC
46WQF4LQNK54PSZNQLZNYVSDRZU4STNLIGCB4Y7SDWTWQ7ZY7LBQC
GHJKEJZUVPHDP27CYJQ2RYDUJBF2MM3NHVIALFZGJPHT4PUIOMAQC
OTIBCAUJ3KDQJLVDN3A536DLZGNRYMGJLORZVR3WLCGXGO6UGO6AC
CZY3IDERLI6MTKKKMX6QLLERSPM2ZJ57NGQRKILJBM7S5PYPQ3XAC
W5D22DQ5HRM3SGVEDY3E57Q6UPXGYLPQUJEVYMP2SU5KKG4J5K2AC
3JDTNKUEWV3V2ABWCOAR4I5LHY3R4MARCFAAQ3KEYGKYHQOXCC2QC
DIVBY22FIFTEVZ3TMPJZFTC55G3GU6SBXQ6ILPGNSFPBWKXWGLPQC
L2Z26UKWMGFSOB6NM4BRH4533D5A7CDYEKHKOSWA3Q5BGJWK2QGAC
VCX4UWKU3LYXW4LQDJPSHAZ6AJRGS3V27DMRH35IZMMV6FQW4DQAC
6H7WAQUD2RDKO5PM2GCHRPNUE76UIT37NQ52ZWVDW46VQGIKHLBQC
2S7DYJ57LKAZHZ4CZCCAFWDMOUPUXPJNTDYD4FJQA32SFVUCDOJQC
GQBUV2XOMEPMTXMPCBQWGGIUXGQDX77VTGPFIG6YT7G64ASOYHXQC
KWPSFOB3BZAJLQZRULNJW7AQK355ZOGN7AREZMMIEBEMY7R5JQMAC
AUE2Y6HE5AIZVFO6EGLYNXKBDXGXJKDURTA4CFAEX6ZWRZKUCMUQC
DFO5SFDTU6GR5XQ4X5U6I2BENQNQP3M4EUUQ2E2DQEB3YQYS2WIAC
ZUVS2754WHE4L3SMNFKGY5ZVBTIXUCYD3OVPDJBQM3AKPHSPMC3QC
ZPIIIN2B4EENXZAANI23O2IBKAMFNPLGZYFFMJIZ6ENYVPH5ECDQC
YKRUNSPXQMYUZM2HC2BWRL3OLVF5X3Y3XASG7JCT4TW4VUHZD6ZAC
7JAODGVLU6GEMEJTJL34QMYOCKWPFX22A4UH5SLSDGSIVIRETO7QC
function keychord_pressed_in_search_all_mode(chord, key)
if chord == 'escape' then
Display_settings.mode = 'normal'
-- don't forget search text
elseif chord == 'return' then
finalize_search_all_pane()
add_search_all_pane_to_right_of_cursor()
Display_settings.mode = 'searching_all'
elseif chord == 'backspace' then
local len = utf8.len(Display_settings.search_all_term)
local byte_offset = Text.offset(Display_settings.search_all_term, len)
Display_settings.search_all_term = string.sub(Display_settings.search_all_term, 1, byte_offset-1)
Display_settings.search_all_text = nil
--? print('backspace; search_all term is now', Display_settings.search_all_term)
elseif chord == 'C-v' then
Display_settings.search_all_term = Display_settings.search_all_term..App.getClipboardText()
Display_settings.search_all_text = nil
--? print('paste; search_all term is now', Display_settings.search_all_term)
end
end
end
end
function draw_command_palette_for_search_all()
-- background
App.color(Command_palette_background_color)
love.graphics.rectangle('fill', 0,0, App.screen.width, Menu_status_bar_height)
App.color(Command_palette_border_color)
love.graphics.rectangle('line', 0,0, App.screen.width, Menu_status_bar_height)
-- input box
App.color(Command_palette_command_color)
if Display_settings.search_all_text == nil then
Display_settings.search_all_text = App.newText(love.graphics.getFont(), Display_settings.search_all_term)
end
local x = 5
local y = 5
love.graphics.draw(Display_settings.search_all_text, x,y)
if Display_settings.mode == 'search_all' then
x = x+App.width(Display_settings.search_all_text)
draw_cursor(x, y)
end
-- show progress
if Display_settings.mode == 'searching_all' then
App.color(Command_palette_alternatives_background_color)
love.graphics.rectangle('fill', 0, Menu_status_bar_height, App.screen.width, 5+Line_height+5)
App.color(Command_palette_border_color)
love.graphics.rectangle('line', 0, Menu_status_bar_height, App.screen.width, 5+Line_height+5)
App.screen.print(Display_settings.search_all_most_recent_file, --[[x]] 5, --[[y]] Menu_status_bar_height+5)
end
function command.commence_search_in_disk()
Display_settings.mode = 'search_all'
Display_settings.search_all_pane = initialize_search_all_pane()
Display_settings.search_all_term = ''
Display_settings.search_all_text = nil
Display_settings.search_all_most_recent_file = ''
end
-- search panes are opposites of regular panes
-- regular pane: pass in id, load from disk, may be edited
-- search pane: create without id, initialize id after search term is typed in, create empty file, slowly append to disk, may not be edited
function initialize_search_all_pane()
local result = edit.initialize_state(0, 0, math.min(Display_settings.column_width, App.screen.width-Margin_right), Font_height, Line_height)
result.font_height = Font_height
result.line_height = Line_height
result.em = Em
result.editable = false
return result
end
function finalize_search_all_pane()
local id = Display_settings.search_all_term:gsub('%W', '_')
--? print(id)
initialize_cache_if_necessary(id)
Display_settings.search_all_pane.id = id
Display_settings.search_all_pane.filename = Directory..id
Display_settings.editable = false