mirror of
https://github.com/rvtr/GodMode9i.git
synced 2025-11-02 00:11:07 -04:00
Bug fix: Position cursor, depending on how long the full file path is
This commit is contained in:
parent
4b536e50d9
commit
44076238de
@ -156,6 +156,7 @@ int fileBrowse_A(DirEntry* entry) {
|
|||||||
int pressed = 0;
|
int pressed = 0;
|
||||||
int assignedOp[3] = {0};
|
int assignedOp[3] = {0};
|
||||||
int optionOffset = 0;
|
int optionOffset = 0;
|
||||||
|
int cursorScreenPos = 0;
|
||||||
int maxCursors = -1;
|
int maxCursors = -1;
|
||||||
|
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
@ -163,8 +164,19 @@ int fileBrowse_A(DirEntry* entry) {
|
|||||||
printf ("\x1b[0;27H");
|
printf ("\x1b[0;27H");
|
||||||
printf (" "); // Clear time
|
printf (" "); // Clear time
|
||||||
consoleInit(NULL, 1, BgType_Text4bpp, BgSize_T_256x256, 15, 0, false, true);
|
consoleInit(NULL, 1, BgType_Text4bpp, BgSize_T_256x256, 15, 0, false, true);
|
||||||
iprintf("%s%s", path, entry->name.c_str());
|
char fullPath[256];
|
||||||
printf("\n\n");
|
snprintf(fullPath, sizeof(fullPath), "%s%s", path, entry->name.c_str());
|
||||||
|
printf(fullPath);
|
||||||
|
// Position cursor, depending on how long the full file path is
|
||||||
|
for (int i = 0; i < 256; i++) {
|
||||||
|
if (i == 33 || i == 65 || i == 97 || i == 129 || i == 161 || i == 193 || i == 225) {
|
||||||
|
cursorScreenPos++;
|
||||||
|
}
|
||||||
|
if (fullPath[i] == '\0') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
iprintf ("\x1b[%d;0H", cursorScreenPos + ENTRIES_START_ROW);
|
||||||
if (entry->isApp) {
|
if (entry->isApp) {
|
||||||
maxCursors++;
|
maxCursors++;
|
||||||
assignedOp[maxCursors] = 0;
|
assignedOp[maxCursors] = 0;
|
||||||
@ -184,11 +196,11 @@ int fileBrowse_A(DirEntry* entry) {
|
|||||||
printf("(<A> select, <B> cancel)");
|
printf("(<A> select, <B> cancel)");
|
||||||
while (true) {
|
while (true) {
|
||||||
// Clear old cursors
|
// Clear old cursors
|
||||||
for (int i = ENTRIES_START_ROW; i < (maxCursors+1) + ENTRIES_START_ROW; i++) {
|
for (int i = ENTRIES_START_ROW+cursorScreenPos; i < (maxCursors+1) + ENTRIES_START_ROW+cursorScreenPos; i++) {
|
||||||
iprintf ("\x1b[%d;0H ", i);
|
iprintf ("\x1b[%d;0H ", i);
|
||||||
}
|
}
|
||||||
// Show cursor
|
// Show cursor
|
||||||
iprintf ("\x1b[%d;0H->", optionOffset + ENTRIES_START_ROW);
|
iprintf ("\x1b[%d;0H->", optionOffset + ENTRIES_START_ROW+cursorScreenPos);
|
||||||
|
|
||||||
// Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do
|
// Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do
|
||||||
do {
|
do {
|
||||||
@ -207,38 +219,38 @@ int fileBrowse_A(DirEntry* entry) {
|
|||||||
if (pressed & KEY_A) {
|
if (pressed & KEY_A) {
|
||||||
if (assignedOp[optionOffset] == 0) {
|
if (assignedOp[optionOffset] == 0) {
|
||||||
applaunch = true;
|
applaunch = true;
|
||||||
iprintf ("\x1b[%d;3H", optionOffset + ENTRIES_START_ROW);
|
iprintf ("\x1b[%d;3H", optionOffset + ENTRIES_START_ROW+cursorScreenPos);
|
||||||
printf("Now loading...");
|
printf("Now loading...");
|
||||||
} else if (assignedOp[optionOffset] == 1) {
|
} else if (assignedOp[optionOffset] == 1) {
|
||||||
if (access("sd:/gm9i", F_OK) != 0) {
|
if (access("sd:/gm9i", F_OK) != 0) {
|
||||||
iprintf ("\x1b[%d;3H", optionOffset + ENTRIES_START_ROW);
|
iprintf ("\x1b[%d;3H", optionOffset + ENTRIES_START_ROW+cursorScreenPos);
|
||||||
printf("Creating directory...");
|
printf("Creating directory...");
|
||||||
mkdir("sd:/gm9i", 0777);
|
mkdir("sd:/gm9i", 0777);
|
||||||
}
|
}
|
||||||
if (access("sd:/gm9i/out", F_OK) != 0) {
|
if (access("sd:/gm9i/out", F_OK) != 0) {
|
||||||
iprintf ("\x1b[%d;3H", optionOffset + ENTRIES_START_ROW);
|
iprintf ("\x1b[%d;3H", optionOffset + ENTRIES_START_ROW+cursorScreenPos);
|
||||||
printf("Creating directory...");
|
printf("Creating directory...");
|
||||||
mkdir("sd:/gm9i/out", 0777);
|
mkdir("sd:/gm9i/out", 0777);
|
||||||
}
|
}
|
||||||
char destPath[256];
|
char destPath[256];
|
||||||
snprintf(destPath, sizeof(destPath), "sd:/gm9i/out/%s", entry->name.c_str());
|
snprintf(destPath, sizeof(destPath), "sd:/gm9i/out/%s", entry->name.c_str());
|
||||||
iprintf ("\x1b[%d;3H", optionOffset + ENTRIES_START_ROW);
|
iprintf ("\x1b[%d;3H", optionOffset + ENTRIES_START_ROW+cursorScreenPos);
|
||||||
printf("Copying... ");
|
printf("Copying... ");
|
||||||
fcopy(entry->name.c_str(), destPath);
|
fcopy(entry->name.c_str(), destPath);
|
||||||
} else if (assignedOp[optionOffset] == 2) {
|
} else if (assignedOp[optionOffset] == 2) {
|
||||||
if (access("fat:/gm9i", F_OK) != 0) {
|
if (access("fat:/gm9i", F_OK) != 0) {
|
||||||
iprintf ("\x1b[%d;3H", optionOffset + ENTRIES_START_ROW);
|
iprintf ("\x1b[%d;3H", optionOffset + ENTRIES_START_ROW+cursorScreenPos);
|
||||||
printf("Creating directory...");
|
printf("Creating directory...");
|
||||||
mkdir("fat:/gm9i", 0777);
|
mkdir("fat:/gm9i", 0777);
|
||||||
}
|
}
|
||||||
if (access("fat:/gm9i/out", F_OK) != 0) {
|
if (access("fat:/gm9i/out", F_OK) != 0) {
|
||||||
iprintf ("\x1b[%d;3H", optionOffset + ENTRIES_START_ROW);
|
iprintf ("\x1b[%d;3H", optionOffset + ENTRIES_START_ROW+cursorScreenPos);
|
||||||
printf("Creating directory...");
|
printf("Creating directory...");
|
||||||
mkdir("fat:/gm9i/out", 0777);
|
mkdir("fat:/gm9i/out", 0777);
|
||||||
}
|
}
|
||||||
char destPath[256];
|
char destPath[256];
|
||||||
snprintf(destPath, sizeof(destPath), "fat:/gm9i/out/%s", entry->name.c_str());
|
snprintf(destPath, sizeof(destPath), "fat:/gm9i/out/%s", entry->name.c_str());
|
||||||
iprintf ("\x1b[%d;3H", optionOffset + ENTRIES_START_ROW);
|
iprintf ("\x1b[%d;3H", optionOffset + ENTRIES_START_ROW+cursorScreenPos);
|
||||||
printf("Copying... ");
|
printf("Copying... ");
|
||||||
fcopy(entry->name.c_str(), destPath);
|
fcopy(entry->name.c_str(), destPath);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user