Reading multiple directories in transcript browser
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
#include <semaphore>
|
||||
#include <mutex>
|
||||
|
||||
Arena Perm;
|
||||
|
||||
struct TimeString {
|
||||
uint16_t hour;
|
||||
uint16_t minute;
|
||||
@@ -87,21 +89,17 @@ struct XToTimeString {
|
||||
uint16_t second;
|
||||
String filepath;
|
||||
};
|
||||
Arena XArena;
|
||||
|
||||
Arena Perm;
|
||||
Array<XToTimeString> XToTimeStringArray = {Perm};
|
||||
bool AppInitializedWithFolder;
|
||||
Arena XArena;
|
||||
|
||||
Array<String> InitForFolder(String folder) {
|
||||
void AddFolder(String folder, Array<String> *filenames, Array<XToTimeString> *x_to_time_string) {
|
||||
Scratch scratch;
|
||||
|
||||
Array<String> filenames = {Perm};
|
||||
Array<String> srt_files = {scratch};
|
||||
for (FileIter iter = IterateFiles(scratch, folder); IsValid(iter); Advance(&iter)) {
|
||||
filenames.add(Copy(Perm, iter.absolute_path));
|
||||
String file = Copy(Perm, iter.absolute_path);
|
||||
filenames->add(file);
|
||||
if (EndsWith(iter.filename, ".srt")) {
|
||||
srt_files.add(Copy(scratch, iter.absolute_path));
|
||||
srt_files.add(file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,14 +133,11 @@ Array<String> InitForFolder(String folder) {
|
||||
For(it_time_file.time_strings) {
|
||||
String s = Copy(XArena, it.string);
|
||||
s.data[s.len] = ' ';
|
||||
XToTimeStringArray.add({s, it.hour, it.minute, it.second, it_time_file.file});
|
||||
x_to_time_string->add({s, it.hour, it.minute, it.second, it_time_file.file});
|
||||
}
|
||||
}
|
||||
Release(it_io.arena);
|
||||
}
|
||||
|
||||
AppInitializedWithFolder = true;
|
||||
return filenames;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -204,13 +199,14 @@ int main() {
|
||||
Arena *frame_arena = AllocArena();
|
||||
XArena.align = 0;
|
||||
|
||||
String start_string = "C:/video";
|
||||
String start_string = "read=D:/zizek";
|
||||
For(start_string) Prompt.add(it);
|
||||
|
||||
std::thread search_thread(SearchThreadEntry);
|
||||
int64_t chosen_text = 0;
|
||||
int64_t match_search_offset = 0;
|
||||
Array<String> filenames = {};
|
||||
std::thread search_thread(SearchThreadEntry);
|
||||
int64_t chosen_text = 0;
|
||||
int64_t match_search_offset = 0;
|
||||
Array<String> filenames = {};
|
||||
Array<XToTimeString> x_to_time_string = {};
|
||||
|
||||
InitWindow(1920, 1080, "Transcript Browser");
|
||||
SetWindowState(FLAG_WINDOW_RESIZABLE);
|
||||
@@ -261,9 +257,10 @@ int main() {
|
||||
match_search_offset = Clamp(match_search_offset, (int64_t)0, Max(Matches.len - 1 - 10, (int64_t)0));
|
||||
|
||||
if (IsKeyPressed(KEY_ENTER)) {
|
||||
if (!AppInitializedWithFolder) {
|
||||
String prompt = {Prompt.data, Prompt.len};
|
||||
if (StartsWith(prompt, "read=")) {
|
||||
Prompt.add('\0');
|
||||
filenames = InitForFolder(Prompt.data);
|
||||
AddFolder(prompt.skip(5), &filenames, &x_to_time_string);
|
||||
Prompt.clear();
|
||||
} else if (ItemFound) {
|
||||
String base = ChopLastPeriod(ItemFound->filepath); // .srt
|
||||
@@ -284,7 +281,7 @@ int main() {
|
||||
}
|
||||
} else if (Matches.len) {
|
||||
String string = Matches[chosen_text];
|
||||
For(XToTimeStringArray) {
|
||||
For(x_to_time_string) {
|
||||
uintptr_t begin = (uintptr_t)(it.string.data);
|
||||
uintptr_t end = (uintptr_t)(it.string.data + it.string.len);
|
||||
uintptr_t needle = (uintptr_t)string.data;
|
||||
@@ -303,12 +300,7 @@ int main() {
|
||||
float y = 0;
|
||||
int xwidth = MeasureTextEx(font, "_", font_size, 1).x;
|
||||
|
||||
if (!AppInitializedWithFolder) {
|
||||
Prompt.add('\0');
|
||||
DrawTextEx(font, "> ", {0, y}, font_size, 1, BLACK);
|
||||
DrawTextEx(font, Prompt.data, {(float)xwidth * 3, y}, font_size, 1, BLACK);
|
||||
Prompt.len -= 1;
|
||||
} else if (ItemFound) {
|
||||
if (ItemFound) {
|
||||
uintptr_t begin_region = (uintptr_t)XArena.data;
|
||||
uintptr_t end_region = (uintptr_t)XArena.data + XArena.len;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user