casi addrbar lista, ai bug
This commit is contained in:
parent
395159763c
commit
a50f53dcc1
1 changed files with 75 additions and 37 deletions
108
main.cpp
108
main.cpp
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
|
|
||||||
#define MAX_LISTDIR_PATH_LENGTH (MAX_PATH - 3)
|
#define MAX_LISTDIR_PATH_LENGTH (MAX_PATH - 3)
|
||||||
|
#define MAX_ERRORSTR_LEN 512
|
||||||
|
|
||||||
#include "imgui/misc/single_file/imgui_single_file.h"
|
#include "imgui/misc/single_file/imgui_single_file.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
@ -63,27 +64,6 @@ typedef struct {
|
||||||
//TODO UNICORDEO
|
//TODO UNICORDEO
|
||||||
/* FILE PICKER MOMENTO */
|
/* FILE PICKER MOMENTO */
|
||||||
|
|
||||||
/* PROPOSITO GENERAL */
|
|
||||||
|
|
||||||
bool compareLastChar(std::vector<std::string> *lastCharCandidates, char* string){
|
|
||||||
bool matchingExtension = false;
|
|
||||||
for (int i = 0; i < lastCharCandidates->size(); i++){
|
|
||||||
log_debugcpp(lastCharCandidates->at(i) + " <- FILTERING EXTENSION");
|
|
||||||
|
|
||||||
if(strlen(string) < lastCharCandidates->at(i).length()) continue;
|
|
||||||
char* potentialExtension = &string[strlen(string) - lastCharCandidates->at(i).length()];
|
|
||||||
|
|
||||||
log_debugcpp(potentialExtension);
|
|
||||||
log_debugcpp(" LEN " + std::to_string(strlen(potentialExtension)) + " <- VS -> " + lastCharCandidates->at(i) + " LEN " + std::to_string(lastCharCandidates->at(i).length()));
|
|
||||||
//+ strlen(potentialExtension) + std::to_string(lastCharCandidates->at(i).length())
|
|
||||||
if(!strcmp(potentialExtension, lastCharCandidates->at(i).c_str())) {
|
|
||||||
log_debugcpp("VALID EXTENSION");
|
|
||||||
matchingExtension = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return matchingExtension;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* DIRECTORIES */
|
/* DIRECTORIES */
|
||||||
|
|
||||||
|
|
@ -241,6 +221,36 @@ int listVolumes(std::vector<char*> *onPresentPaths){
|
||||||
return numVolumes;
|
return numVolumes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* DISPLAY */
|
||||||
|
|
||||||
|
|
||||||
|
bool compareLastChar(std::vector<std::string> *lastCharCandidates, char* string){
|
||||||
|
bool matchingExtension = false;
|
||||||
|
for (int i = 0; i < lastCharCandidates->size(); i++){
|
||||||
|
log_debugcpp(lastCharCandidates->at(i) + " <- FILTERING EXTENSION");
|
||||||
|
|
||||||
|
if(strlen(string) < lastCharCandidates->at(i).length()) continue;
|
||||||
|
char* potentialExtension = &string[strlen(string) - lastCharCandidates->at(i).length()];
|
||||||
|
|
||||||
|
log_debugcpp(potentialExtension);
|
||||||
|
log_debugcpp(" LEN " + std::to_string(strlen(potentialExtension)) + " <- VS -> " + lastCharCandidates->at(i) + " LEN " + std::to_string(lastCharCandidates->at(i).length()));
|
||||||
|
//+ strlen(potentialExtension) + std::to_string(lastCharCandidates->at(i).length())
|
||||||
|
if(!strcmp(potentialExtension, lastCharCandidates->at(i).c_str())) {
|
||||||
|
log_debugcpp("VALID EXTENSION");
|
||||||
|
matchingExtension = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return matchingExtension;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool inputMove(bool* error, char** str){
|
||||||
|
*error = false;
|
||||||
|
if(!moveDirectory(str)) { *error = true; return false; }
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* FIN FILE PICKER MOMENTO */
|
/* FIN FILE PICKER MOMENTO */
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -361,9 +371,10 @@ int main(int, char**)
|
||||||
{
|
{
|
||||||
ImGui::Begin("File Picker in 4K");
|
ImGui::Begin("File Picker in 4K");
|
||||||
|
|
||||||
static bool isInvalidPath = false;
|
static bool showError = false;
|
||||||
static bool isListVolumesAdequate = true;
|
static bool isListVolumesAdequate = true;
|
||||||
static bool isListDirectoriesAdequate = true;
|
static bool isListDirectoriesAdequate = true;
|
||||||
|
static char error[MAX_ERRORSTR_LEN];
|
||||||
|
|
||||||
//Listar UNA VEZ volumenes
|
//Listar UNA VEZ volumenes
|
||||||
static int numVolumes;
|
static int numVolumes;
|
||||||
|
|
@ -381,13 +392,15 @@ int main(int, char**)
|
||||||
//cursed C momento: necesario ptr en otra var para mandar a char** de firma
|
//cursed C momento: necesario ptr en otra var para mandar a char** de firma
|
||||||
static char currentPath[MAX_PATH];
|
static char currentPath[MAX_PATH];
|
||||||
static char* currentPathPtr = ¤tPath[0];
|
static char* currentPathPtr = ¤tPath[0];
|
||||||
|
static char addrBarVal[MAX_LISTDIR_PATH_LENGTH];
|
||||||
|
static char* addrBarValPtr = &addrBarVal[0];
|
||||||
|
|
||||||
//static int currentItemIdx = -1;
|
//static int currentItemIdx = -1;
|
||||||
//static std::vector<char*> directoryContents;
|
//static std::vector<char*> directoryContents;
|
||||||
static std::vector<directoriesInfo*> directoryContents;
|
static std::vector<directoriesInfo*> directoryContents;
|
||||||
static int numFiles = 0;
|
static int numFiles = 0;
|
||||||
|
|
||||||
ImGui::Text("%s PRE DIRECTORY TREATMENTO", currentPath);
|
//ImGui::Text("%s PRE DIRECTORY TREATMENTO", currentPath);
|
||||||
|
|
||||||
if(isListDirectoriesAdequate) {
|
if(isListDirectoriesAdequate) {
|
||||||
log_debugcpp("ADECUADO LISTAR DIRECTORIOS");
|
log_debugcpp("ADECUADO LISTAR DIRECTORIOS");
|
||||||
|
|
@ -403,7 +416,13 @@ int main(int, char**)
|
||||||
//std::cout << numFiles;
|
//std::cout << numFiles;
|
||||||
if (numFiles < 0) {
|
if (numFiles < 0) {
|
||||||
log_debugcpp("FALLO LA FUNCION, VALOR NEGATIVO " + std::to_string(numFiles));
|
log_debugcpp("FALLO LA FUNCION, VALOR NEGATIVO " + std::to_string(numFiles));
|
||||||
isInvalidPath = true;
|
showError = true;
|
||||||
|
strcpy(error, "Failed to open folder: permission denied?");
|
||||||
|
strcpy(currentPath, addrBarVal);
|
||||||
|
numFiles = listDirectory(std::string(currentPath), &directoryContents);
|
||||||
|
} else {
|
||||||
|
showError = false;
|
||||||
|
strcpy(addrBarVal, currentPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -411,6 +430,11 @@ int main(int, char**)
|
||||||
static bool showHidden = false;
|
static bool showHidden = false;
|
||||||
static bool filterByExtension = false;
|
static bool filterByExtension = false;
|
||||||
static std::vector<std::string> extensions;
|
static std::vector<std::string> extensions;
|
||||||
|
|
||||||
|
if(showError){
|
||||||
|
ImGui::Text(error);
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::Text("Select a file:");
|
ImGui::Text("Select a file:");
|
||||||
|
|
||||||
//Permanentes e increiblemente utilitarios botones en Cuatro K: MOVE UP
|
//Permanentes e increiblemente utilitarios botones en Cuatro K: MOVE UP
|
||||||
|
|
@ -418,14 +442,31 @@ int main(int, char**)
|
||||||
static char moveUp[] = "..";
|
static char moveUp[] = "..";
|
||||||
static char* moveUpPtr = &moveUp[0];
|
static char* moveUpPtr = &moveUp[0];
|
||||||
if(ImGui::Button("Move Up")) {
|
if(ImGui::Button("Move Up")) {
|
||||||
moveDirectory(&moveUpPtr);
|
isListDirectoriesAdequate = inputMove(&showError, (&moveUpPtr));
|
||||||
isInvalidPath = false;
|
strcpy(error, "Failed to move up: reached volume root?");
|
||||||
isListDirectoriesAdequate = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
//BARRA DE DIRECCIONES
|
//BARRA DE DIRECCIONES
|
||||||
ImGui::Text("%s TEMPADDRBAR", currentPath);
|
if(ImGui::InputText("##addrbar", addrBarVal, IM_ARRAYSIZE(addrBarVal), ImGuiInputTextFlags_EnterReturnsTrue )){
|
||||||
|
log_debugcpp(currentPath);
|
||||||
|
log_debugcpp(" ADDRBAR INTENTO");
|
||||||
|
isListDirectoriesAdequate = inputMove(&showError, &addrBarValPtr);
|
||||||
|
if (isListDirectoriesAdequate) strcpy(currentPath, addrBarVal);
|
||||||
|
else strcpy(addrBarVal, currentPath);
|
||||||
|
strcpy(error, "Failed to open folder: invalid path");
|
||||||
|
};
|
||||||
|
ImGui::SameLine();
|
||||||
|
if(ImGui::Button("Enter")){
|
||||||
|
log_debugcpp(currentPath);
|
||||||
|
log_debugcpp(" ADDRBAR INTENTO");
|
||||||
|
isListDirectoriesAdequate = inputMove(&showError, &addrBarValPtr);
|
||||||
|
if (isListDirectoriesAdequate) strcpy(currentPath, addrBarVal);
|
||||||
|
else strcpy(addrBarVal, currentPath);
|
||||||
|
strcpy(error, "Failed to open folder: invalid path");
|
||||||
|
}
|
||||||
|
|
||||||
|
//ImGui::Text("%s TEMPADDRBAR", currentPath);
|
||||||
|
|
||||||
//LA GRAN TABLACIÓN: ACTOR EN LAS SOMBRAS
|
//LA GRAN TABLACIÓN: ACTOR EN LAS SOMBRAS
|
||||||
static ImGuiTableFlags splitterTableFlags = ImGuiTableFlags_Resizable | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV;
|
static ImGuiTableFlags splitterTableFlags = ImGuiTableFlags_Resizable | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV;
|
||||||
|
|
@ -450,8 +491,7 @@ int main(int, char**)
|
||||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(i / 7.0f, 0.7f, 0.7f));
|
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(i / 7.0f, 0.7f, 0.7f));
|
||||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV(i / 7.0f, 0.8f, 0.8f));
|
ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV(i / 7.0f, 0.8f, 0.8f));
|
||||||
if(ImGui::Button(onPresentPaths.at(i))){
|
if(ImGui::Button(onPresentPaths.at(i))){
|
||||||
moveDirectory(&onPresentPaths.at(i));
|
isListDirectoriesAdequate = inputMove(&showError, &onPresentPaths.at(i));
|
||||||
isListDirectoriesAdequate = true;
|
|
||||||
}
|
}
|
||||||
ImGui::PopStyleColor(3);
|
ImGui::PopStyleColor(3);
|
||||||
if (i != onPresentPaths.size() - 1) ImGui::TableNextRow();
|
if (i != onPresentPaths.size() - 1) ImGui::TableNextRow();
|
||||||
|
|
@ -493,9 +533,9 @@ int main(int, char**)
|
||||||
//currentItemIdx = i;
|
//currentItemIdx = i;
|
||||||
strcat(currentPath, "\\");
|
strcat(currentPath, "\\");
|
||||||
strcat(currentPath, directoryContents.at(idx)->name);
|
strcat(currentPath, directoryContents.at(idx)->name);
|
||||||
moveDirectory(¤tPathPtr);
|
isListDirectoriesAdequate = inputMove(&showError, ¤tPathPtr);
|
||||||
|
strcpy(error, "Failed to open folder: invalid option");
|
||||||
//currentItemIdx = -1;
|
//currentItemIdx = -1;
|
||||||
isListDirectoriesAdequate = true;
|
|
||||||
}
|
}
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
|
|
||||||
|
|
@ -512,9 +552,7 @@ int main(int, char**)
|
||||||
}
|
}
|
||||||
//DISPLAYING ALTERNATIVE INFO
|
//DISPLAYING ALTERNATIVE INFO
|
||||||
if (!idx) {
|
if (!idx) {
|
||||||
ImGui::TableNextRow(); ImGui::TableNextColumn();
|
ImGui::TableNextRow(); ImGui::TableNextColumn(); ImGui::Text("Folder is empty");
|
||||||
if (isInvalidPath) ImGui::Text("Failed to access: Path not valid");
|
|
||||||
else ImGui::Text("Folder is empty");
|
|
||||||
}
|
}
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue