We still need to actually look inside the contents of date-based directories.
FJQM2HAOV7J5263GOEBH4Y55Q2WGKU6ZE5AQ7MMLFHWYAYUP7INQC
D7D6T2F3FRMONF627F2NV227T5KTZ4FOHZKROEIIA236U7FVASTQC
B22JHH4W75CLJTHZWAHJZWYL3L7IN4MSIJSR5CCCCXYWYA27TRNQC
OTIBCAUJ3KDQJLVDN3A536DLZGNRYMGJLORZVR3WLCGXGO6UGO6AC
HCLCAFHPRUDGNFOYXKNHME2ELQKSXUTN3E4NV3PT4DGG2VJV7KOAC
3JDTNKUEWV3V2ABWCOAR4I5LHY3R4MARCFAAQ3KEYGKYHQOXCC2QC
GQBUV2XOMEPMTXMPCBQWGGIUXGQDX77VTGPFIG6YT7G64ASOYHXQC
YKRUNSPXQMYUZM2HC2BWRL3OLVF5X3Y3XASG7JCT4TW4VUHZD6ZAC
7JAODGVLU6GEMEJTJL34QMYOCKWPFX22A4UH5SLSDGSIVIRETO7QC
46WQF4LQNK54PSZNQLZNYVSDRZU4STNLIGCB4Y7SDWTWQ7ZY7LBQC
KWPSFOB3BZAJLQZRULNJW7AQK355ZOGN7AREZMMIEBEMY7R5JQMAC
local search_term = string.match(column.name, 'search: (.+)')
-- TODO
--? print('column name', column.name)
local search_all_term = string.match(column.name, 'search: (.+)')
--? print('search term', search_all_term)
populate_search_all_column(column, search_all_term)
function resume_search_all()
-- make a little more progress towards searching the whole disk
if Display_settings.search_all_state == nil then
Display_settings.search_all_progress_indicator = 'initialized top-level files'
Display_settings.search_all_state = {
top_level_files = love.filesystem.getDirectoryItems(Directory),
top_level_file_index = 1,
}
elseif Display_settings.search_all_state.top_level_file_index then
local current_filename = Display_settings.search_all_state.top_level_files[Display_settings.search_all_state.top_level_file_index]
Display_settings.search_all_progress_indicator = current_filename
local info = love.filesystem.getInfo(Directory..current_filename)
if info.type == 'file' then
--? print('searching '..current_filename..' for '..Display_settings.search_all_term)
local contents = love.filesystem.read(Directory..current_filename)
local index = contents:find(Display_settings.search_all_term)
if index then
local id = id_for_search_all_pane(Display_settings.search_all_term)
local snippet = contents:sub(math.max(1, index-100), math.min(#contents, index+100))
local outfilename = Directory..id
local success, errmsg = love.filesystem.append(outfilename, '[['..current_filename..']]\t')
if not success then error(errmsg) end
local success, errmsg = love.filesystem.append(outfilename, '...'..snippet..'...\n\n')
if not success then error(errmsg) end
load_from_disk(Cache[id])
Display_settings.search_all_pane.lines = Cache[id].lines
Text.redraw_all(Display_settings.search_all_pane)
end
end
Display_settings.search_all_state.top_level_file_index = Display_settings.search_all_state.top_level_file_index+1
if Display_settings.search_all_state.top_level_file_index > #Display_settings.search_all_state.top_level_files then
Display_settings.search_all_state.top_level_file_index = nil
Display_settings.search_all_state.top_level_files = nil
Display_settings.search_all_state.time = os.time()
Display_settings.search_all_state.year = os.date('%Y', Display_settings.search_all_state.time)
Display_settings.search_all_state.date = os.date('%Y/%m/%d/', Display_settings.search_all_state.time)
end
elseif Display_settings.search_all_state.date then
-- search one day's directory per frame
-- stop when a whole year is missing
Display_settings.search_all_progress_indicator = Display_settings.search_all_state.date
local old_year = Display_settings.search_all_state.year
local date_dir = Directory..Display_settings.search_all_state.date
local info = love.filesystem.getInfo(date_dir)
if info then
if info.type == 'directory' then
local files = love.filesystem.getDirectoryItems(date_dir)
for _,file in ipairs(files) do
print(date_dir..file)
end
end
end
Display_settings.search_all_state.time = Display_settings.search_all_state.time - 24*60*60
Display_settings.search_all_state.year = os.date('%Y', Display_settings.search_all_state.time)
Display_settings.search_all_state.date = os.date('%Y/%m/%d/', Display_settings.search_all_state.time)
if old_year ~= Display_settings.search_all_state.year then
local previous_year_info = love.filesystem.getInfo(Directory..Display_settings.search_all_state.year)
if previous_year_info == nil then
Display_settings.search_all_state = nil
Display_settings.mode = 'normal'
end
end
else
assert(false, 'error in search state machine')
end
end
function interrupt_search_all()
if Display_settings.search_all_state then
local id = id_for_search_all_pane(Display_settings.search_all_term)
local outfilename = Directory..id
local success, errmsg = love.filesystem.append(outfilename, 'interrupted at '..Display_settings.search_all_state.date..'\n')
if not success then error(errmsg) end
load_from_disk(Cache[id])
Display_settings.search_all_pane.lines = Cache[id].lines
Text.redraw_all(Display_settings.search_all_pane)
end
Display_settings.search_all_state = nil
Display_settings.mode = 'normal'
end
function populate_search_all_column(column, search_all_term)
local id = id_for_search_all_pane(search_all_term)
table.insert(column, load_pane(id))
end