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