MenuOpen mode, deffered read on start, cleanup todos
This commit is contained in:
@@ -1,14 +1,8 @@
|
||||
/*
|
||||
@todo: popup when error
|
||||
@todo: read recursive
|
||||
@todo: add option for user to control what files are read
|
||||
@todo: pdf files
|
||||
@todo: plumbing for custom commands - pdf: {tools_path}/vlc {filename} --start-at {hour}:{second}:{minute}
|
||||
@todo: config with preload_files, initial_query, style
|
||||
@todo: help menu and config menu
|
||||
|
||||
@todo: help menu
|
||||
@todo: check for number of cores before creating threads
|
||||
@todo:
|
||||
*/
|
||||
|
||||
#define BASIC_IMPL
|
||||
@@ -149,23 +143,6 @@ int main(int, char **) {
|
||||
InitOS();
|
||||
InitScratch();
|
||||
InitArena(&Perm);
|
||||
|
||||
// {
|
||||
// Scratch scratch;
|
||||
// for (FileIter it = IterateFiles(scratch, "D:/pdfs"); IsValid(it); Advance(&it)) {
|
||||
// if (it.is_directory || !EndsWith(it.absolute_path, ".pdf", true)) continue;
|
||||
// PDF pdf = pdfioReadPDF(scratch, it.absolute_path);
|
||||
// Array<String> strings = {scratch};
|
||||
// For(pdf.pages) {
|
||||
// strings.add(it.string);
|
||||
// }
|
||||
// String s = Merge(scratch, strings, "\n");
|
||||
// WriteFile(Format(scratch, "%.*s.txt", FmtString(it.absolute_path)), s);
|
||||
|
||||
// String pdf_content = ReadFile(scratch, it.absolute_path);
|
||||
// }
|
||||
// }
|
||||
|
||||
XInitLoading();
|
||||
InitSearch();
|
||||
LoadConfig();
|
||||
@@ -222,17 +199,20 @@ int main(int, char **) {
|
||||
ImGui_ImplOpenGL3_Init(glsl_version);
|
||||
io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf", 18.0f);
|
||||
|
||||
bool deffered_read_on_start = false;
|
||||
{
|
||||
String read_on_start = ReadOnStart;
|
||||
if (read_on_start != "-") {
|
||||
Scratch scratch;
|
||||
Array<String> strings = Split(scratch, read_on_start, ";");
|
||||
For(strings) XAddFolder(it, &filenames);
|
||||
}
|
||||
String read_on_start = ReadOnStart;
|
||||
deffered_read_on_start = (read_on_start != "-");
|
||||
}
|
||||
|
||||
bool command_menu_open = false;
|
||||
bool show_loaded_files = false;
|
||||
enum MenuOpen {
|
||||
MenuOpen_Query,
|
||||
MenuOpen_LoadedFiles,
|
||||
MenuOpen_Config,
|
||||
MenuOpen_Count,
|
||||
};
|
||||
MenuOpen menu_open = MenuOpen_Query;
|
||||
|
||||
bool set_focus_to_input = true;
|
||||
int64_t frame = -1;
|
||||
|
||||
@@ -305,29 +285,29 @@ int main(int, char **) {
|
||||
|
||||
ImGui::Begin("input", NULL, window_flags);
|
||||
|
||||
if (show_loaded_files) {
|
||||
if (ImGui::Button("Show files (F1)") || f1_press) {
|
||||
show_loaded_files = !show_loaded_files;
|
||||
if (menu_open == MenuOpen_LoadedFiles) {
|
||||
if (ImGui::Button("Hide files (F1)") || f1_press) {
|
||||
menu_open = MenuOpen_Query;
|
||||
}
|
||||
} else {
|
||||
if (ImGui::Button("Hide files (F1)") || f1_press) {
|
||||
show_loaded_files = !show_loaded_files;
|
||||
if (ImGui::Button("Show files (F1)") || f1_press) {
|
||||
menu_open = MenuOpen_LoadedFiles;
|
||||
}
|
||||
}
|
||||
ImGui::SameLine();
|
||||
|
||||
if (command_menu_open) {
|
||||
if (menu_open == MenuOpen_Config) {
|
||||
if (ImGui::Button("Hide config (F2)") || f2_press) {
|
||||
command_menu_open = !command_menu_open;
|
||||
menu_open = MenuOpen_Query;
|
||||
}
|
||||
} else {
|
||||
if (ImGui::Button("Show config (F2)") || f2_press) {
|
||||
command_menu_open = !command_menu_open;
|
||||
menu_open = MenuOpen_Config;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
if (!command_menu_open && set_focus_to_input) ImGui::SetKeyboardFocusHere(0);
|
||||
if (menu_open != MenuOpen_Query && set_focus_to_input) ImGui::SetKeyboardFocusHere(0);
|
||||
if (tab_press && ImGui::IsWindowFocused()) set_focus_to_list = true;
|
||||
if (ImGui::InputText("Input your query", Prompt, sizeof(Prompt))) {
|
||||
StartSearchingForMatches();
|
||||
@@ -342,6 +322,13 @@ int main(int, char **) {
|
||||
memset(Prompt, 0, sizeof(Prompt));
|
||||
}
|
||||
}
|
||||
if (frame > 2 && deffered_read_on_start) {
|
||||
deffered_read_on_start = false;
|
||||
Scratch scratch;
|
||||
String read_on_start = ReadOnStart;
|
||||
Array<String> strings = Split(scratch, read_on_start, ";");
|
||||
For(strings) XAddFolder(it, &filenames);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
@@ -353,7 +340,7 @@ int main(int, char **) {
|
||||
ImGui::Begin("result", NULL, window_flags);
|
||||
if (!ImGui::IsWindowFocused() && set_focus_to_list) ImGui::SetKeyboardFocusHere(0);
|
||||
|
||||
if (command_menu_open) {
|
||||
if (menu_open == MenuOpen_Config) {
|
||||
ImGui::InputText(".srt", SRTCommand, sizeof(SRTCommand));
|
||||
ImGui::InputText(".pdf", PDFCommand, sizeof(PDFCommand));
|
||||
ImGui::InputText(".txt", TXTCommand, sizeof(TXTCommand));
|
||||
@@ -362,12 +349,10 @@ int main(int, char **) {
|
||||
SaveConfig();
|
||||
LoadConfig();
|
||||
}
|
||||
} else if (menu_open == MenuOpen_LoadedFiles) {
|
||||
UILoadedFiles();
|
||||
} else {
|
||||
if (show_loaded_files) {
|
||||
UILoadedFiles();
|
||||
} else {
|
||||
UISearchResults(filenames);
|
||||
}
|
||||
UISearchResults(filenames);
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
|
||||
Reference in New Issue
Block a user