arregos y qol menores
This commit is contained in:
parent
c8739ce010
commit
ab03616559
1 changed files with 13 additions and 22 deletions
35
main.cpp
35
main.cpp
|
|
@ -20,8 +20,8 @@
|
||||||
#define MAX_ERRORSTR_LEN 512
|
#define MAX_ERRORSTR_LEN 512
|
||||||
|
|
||||||
//HISTORY HANDLING MACRO
|
//HISTORY HANDLING MACRO
|
||||||
#define MIN_HISTORY_POS history->historyTraversalPos <= 0
|
#define MIN_HISTORY_POS (history->historyTraversalPos <= 0)
|
||||||
#define MAX_HISTORY_POS history->historyTraversalPos >= history->historyDepth
|
#define MAX_HISTORY_POS (history->historyTraversalPos >= history->historyDepth)
|
||||||
|
|
||||||
#include "imgui/misc/single_file/imgui_single_file.h"
|
#include "imgui/misc/single_file/imgui_single_file.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
@ -66,10 +66,13 @@ typedef struct {
|
||||||
|
|
||||||
} directoriesInfo;
|
} directoriesInfo;
|
||||||
|
|
||||||
|
|
||||||
struct History{
|
struct History{
|
||||||
std::vector<char*> previousPaths;
|
std::vector<char*> previousPaths;
|
||||||
//TODO C++ david momento
|
//warnings e 1 cosa
|
||||||
//int historyDepth = -1;
|
//int historyDepth = -1;
|
||||||
|
//TODO Limitar historial
|
||||||
|
//const int maxHistoryDepth = 10000;
|
||||||
int historyDepth;
|
int historyDepth;
|
||||||
int historyTraversalPos;
|
int historyTraversalPos;
|
||||||
bool isAdditionTime;
|
bool isAdditionTime;
|
||||||
|
|
@ -94,13 +97,6 @@ enum agnosticDirError {
|
||||||
AGDIR_ERROR_ACCESS_DENIED = 1
|
AGDIR_ERROR_ACCESS_DENIED = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
// struct ErrorMessages{
|
|
||||||
// const std::string addrBarError = "Failed to open folder: invalid path";
|
|
||||||
// const std::string tableElementError = "Failed to open folder: access restricted to non-admin users";
|
|
||||||
// const std::string listDirectoryError = "Failed to open folder: access denied";
|
|
||||||
// const std::string moveUpError = "Failed to move up: reached volume root?";
|
|
||||||
// };
|
|
||||||
|
|
||||||
namespace ErrorMessages {
|
namespace ErrorMessages {
|
||||||
char addrBarError[] = "Failed to open folder: invalid path";
|
char addrBarError[] = "Failed to open folder: invalid path";
|
||||||
char tableElementError[] = "Failed to open folder: access restricted to non-admin users";
|
char tableElementError[] = "Failed to open folder: access restricted to non-admin users";
|
||||||
|
|
@ -270,7 +266,7 @@ int listVolumes(std::vector<char*> *onPresentPaths){
|
||||||
}else{
|
}else{
|
||||||
log_debugcpp("no volumes found wtf");
|
log_debugcpp("no volumes found wtf");
|
||||||
}
|
}
|
||||||
|
//TODO benchimarqui
|
||||||
std::fill(volumePaths, volumePaths + volumePathsBufferSize, '\0');
|
std::fill(volumePaths, volumePaths + volumePathsBufferSize, '\0');
|
||||||
} while (FindNextVolume(hFind, volumeName, volumeNameSize) != 0);
|
} while (FindNextVolume(hFind, volumeName, volumeNameSize) != 0);
|
||||||
log_debugcpp(std::to_string(onPresentPaths->size()) + " JUST BEFORE MAIN");
|
log_debugcpp(std::to_string(onPresentPaths->size()) + " JUST BEFORE MAIN");
|
||||||
|
|
@ -317,8 +313,8 @@ void handleFolderAccessResult(bool isListDirectoriesAdequate, char* currentPath,
|
||||||
|
|
||||||
void addPathToHistory(History *history, char* pathToAdd){
|
void addPathToHistory(History *history, char* pathToAdd){
|
||||||
char* path;
|
char* path;
|
||||||
int ajjj = history->previousPaths.size();
|
//int ajjj = history->previousPaths.size();
|
||||||
if (history->historyTraversalPos + 1 >= ajjj){
|
if (history->historyTraversalPos + 1 >= history->previousPaths.size()){
|
||||||
path = (char*)calloc(1, MAX_PATH);
|
path = (char*)calloc(1, MAX_PATH);
|
||||||
history->previousPaths.push_back(path);
|
history->previousPaths.push_back(path);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -330,23 +326,22 @@ void addPathToHistory(History *history, char* pathToAdd){
|
||||||
history->isAdditionTime = false;
|
history->isAdditionTime = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char** moveThroughHistory(History *history, HistoryMovement movement){
|
char** moveThroughHistory(History *history, HistoryMovement movement) {
|
||||||
|
int sign = (movement == HISTORY_BACKWARD ? -1 : 1);
|
||||||
switch(movement){
|
switch(movement){
|
||||||
case HISTORY_BACKWARD:
|
case HISTORY_BACKWARD:
|
||||||
if(MIN_HISTORY_POS)
|
if(MIN_HISTORY_POS)
|
||||||
return &history->previousPaths.at(history->historyTraversalPos);
|
return &history->previousPaths.at(history->historyTraversalPos);
|
||||||
history->historyTraversalPos--;
|
|
||||||
return &history->previousPaths.at(history->historyTraversalPos);
|
|
||||||
break;
|
break;
|
||||||
case HISTORY_FORWARD:
|
case HISTORY_FORWARD:
|
||||||
if(MAX_HISTORY_POS)
|
if(MAX_HISTORY_POS)
|
||||||
return &history->previousPaths.at(history->historyDepth);
|
return &history->previousPaths.at(history->historyDepth);
|
||||||
history->historyTraversalPos++;
|
|
||||||
return &history->previousPaths.at(history->historyTraversalPos);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return &history->previousPaths.at(history->historyDepth);
|
return &history->previousPaths.at(history->historyDepth);
|
||||||
}
|
}
|
||||||
|
history->historyTraversalPos += sign;
|
||||||
|
return &history->previousPaths.at(history->historyTraversalPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -469,7 +464,6 @@ int main(int, char**) {
|
||||||
{
|
{
|
||||||
ImGui::Begin("File Picker in 4K");
|
ImGui::Begin("File Picker in 4K");
|
||||||
|
|
||||||
//TODO is dis bector in hipp?
|
|
||||||
static History* history = new History();
|
static History* history = new History();
|
||||||
static bool showError = false;
|
static bool showError = false;
|
||||||
static char error[MAX_ERRORSTR_LEN];
|
static char error[MAX_ERRORSTR_LEN];
|
||||||
|
|
@ -487,7 +481,6 @@ int main(int, char**) {
|
||||||
log_debugcpp(std::to_string(numVolumes) + "<- depth MAIN size() ->" + std::to_string(onPresentPaths.size()));
|
log_debugcpp(std::to_string(numVolumes) + "<- depth MAIN size() ->" + std::to_string(onPresentPaths.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Listar UNA VEZ directorios
|
//Listar UNA VEZ directorios
|
||||||
//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];
|
||||||
|
|
@ -531,7 +524,6 @@ int main(int, char**) {
|
||||||
strcpy(error, ErrorMessages::listDirectoryError);
|
strcpy(error, ErrorMessages::listDirectoryError);
|
||||||
strcpy(currentPath, addrBarVal);
|
strcpy(currentPath, addrBarVal);
|
||||||
numFiles = listDirectory(std::string(currentPath), &directoryContents);
|
numFiles = listDirectory(std::string(currentPath), &directoryContents);
|
||||||
history->isAdditionTime = false;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
history->isAdditionTime = false;
|
history->isAdditionTime = false;
|
||||||
|
|
@ -597,7 +589,6 @@ int main(int, char**) {
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
//BARRA DE DIRECCIONES
|
//BARRA DE DIRECCIONES
|
||||||
//TODO a point
|
|
||||||
ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - (ImGui::CalcTextSize("Enter").x + ImGui::GetStyle().ItemSpacing.x * 2) );
|
ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - (ImGui::CalcTextSize("Enter").x + ImGui::GetStyle().ItemSpacing.x * 2) );
|
||||||
if(ImGui::InputText("##addrbar", addrBarVal, IM_ARRAYSIZE(addrBarVal), ImGuiInputTextFlags_EnterReturnsTrue )){
|
if(ImGui::InputText("##addrbar", addrBarVal, IM_ARRAYSIZE(addrBarVal), ImGuiInputTextFlags_EnterReturnsTrue )){
|
||||||
log_debugcpp(currentPath <<" ADDRBAR INTENTO");
|
log_debugcpp(currentPath <<" ADDRBAR INTENTO");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue