Reworked ncurseSelect text

This commit is contained in:
Tomas Rivera
2026-04-04 10:39:47 +02:00
parent 44100c49d1
commit 0a3e30196e
3 changed files with 5 additions and 5 deletions
+3 -3
View File
@@ -210,7 +210,7 @@ int main(int argc, char *argv[]) {
vaultSelected = bypassVaultSelection; vaultSelected = bypassVaultSelection;
goto note_selection; goto note_selection;
} }
vaultSelected = ncursesSelect(vaultsArray, "vault", vaultsCount, extraOptions, " ", "Or select an option below", "", shouldDebug); vaultSelected = ncursesSelect(vaultsArray, "Select vault to open (Use arrows or WASD, Enter to select):", vaultsCount, extraOptions, " ", "Or select an option below", "", shouldDebug);
// now that we won't use vaultsArray in this iteration of the loop, we should free it and all its elements. (As this is memory in the heap and not the stack and thus is our responsability to manage) // now that we won't use vaultsArray in this iteration of the loop, we should free it and all its elements. (As this is memory in the heap and not the stack and thus is our responsability to manage)
for (int i = 0; i < vaultsCount; i++) { for (int i = 0; i < vaultsCount; i++) {
@@ -264,7 +264,7 @@ note_selection:
goto note_creation; goto note_creation;
} }
} }
noteSelected = ncursesSelect(filesArray, "note or journal", filesCount, extraNotesOptions, " ", "Or select an option below", "", shouldDebug); noteSelected = ncursesSelect(filesArray, "Select note or journal to open (Use arrows or WASD, Enter to select):", filesCount, extraNotesOptions, " ", "Or select an option below", "", shouldDebug);
// now that we won't use filesArray in this iteration of the loop, we should free it and all its elements. (As this is memory in the heap and not the stack and thus is our responsability to manage) // now that we won't use filesArray in this iteration of the loop, we should free it and all its elements. (As this is memory in the heap and not the stack and thus is our responsability to manage)
for (int i = 0; i < filesCount; i++) { for (int i = 0; i < filesCount; i++) {
if (noteSelected != filesArray[i]) { // we must prevent noteSelected to be freed. It will cause a lot of problems if (noteSelected != filesArray[i]) { // we must prevent noteSelected to be freed. It will cause a lot of problems
@@ -306,7 +306,7 @@ note_creation:
shouldChangeVault = 1; shouldChangeVault = 1;
} else if (strcmp(noteSelected, "Delete vault") == 0) { } else if (strcmp(noteSelected, "Delete vault") == 0) {
const char *yesNo[] = {"No, go back to note selection.", "Yes."}; const char *yesNo[] = {"No, go back to note selection.", "Yes."};
char *answer = ncursesSelect((char **)yesNo, "Are you sure you want to delete the entire vault? This can not be undone.", 1, 1, " ", "", "", shouldDebug); // (TODO LATER) This is ugly with Select Are you sure[...] char *answer = ncursesSelect((char **)yesNo, "Are you sure you want to delete the entire vault? This can not be undone (Use arrows or WASD, Enter to select):", 1, 1, " ", "", "", shouldDebug); // (TODO LATER) This is ugly with Select Are you sure[...]
debug("You answered: %s for deleting the vault %s", answer, vaultSelected); debug("You answered: %s for deleting the vault %s", answer, vaultSelected);
if (strcmp(answer, "Yes.") == 0) { if (strcmp(answer, "Yes.") == 0) {
// delete the vault after confirmation by the user // delete the vault after confirmation by the user
+1 -1
View File
@@ -185,7 +185,7 @@ char *updateJournal(char *path, char *journal, char *timeFormat, int shouldDebug
// free's some used memory // free's some used memory
closedir(dividedJournalDirectory); closedir(dividedJournalDirectory);
// we must now select to create new entry or to enter in old one // we must now select to create new entry or to enter in old one
char *selectedOption = ncursesSelect(entryArray, "Create new entry or acces old entry:", 1, entryCount -1, " ", " ", "", shouldDebug); // the "Create new entry for the journal %s" will be the only options. All other will be extraOptions. This is made so that "Create [...] %s" will always be on top char *selectedOption = ncursesSelect(entryArray, "Create new entry or acces old entry (Use arrows or WASD, Enter to select):", 1, entryCount -1, " ", " ", "", shouldDebug); // the "Create new entry for the journal %s" will be the only options. All other will be extraOptions. This is made so that "Create [...] %s" will always be on top
debug("Selected option from journal entry selection: %s", selectedOption); debug("Selected option from journal entry selection: %s", selectedOption);
if (strcmp(selectedOption, createEntryMessage) == 0) { // create new entry if (strcmp(selectedOption, createEntryMessage) == 0) { // create new entry
char temp[PATH_MAX]; char temp[PATH_MAX];
+1 -1
View File
@@ -103,7 +103,7 @@ char* ncursesSelect(char **options, char *optionsText, size_t optionsNumber, siz
while (1) { while (1) {
clear(); clear();
attron(COLOR_PAIR(1)); attron(COLOR_PAIR(1));
mvprintw(0,0, "Select %s (Use arrows or WASD, Enter to select):", optionsText); mvprintw(0,0, "%s", optionsText);
int offset = 1; int offset = 1;
if (strcmp(bottomText, "") != 0) { if (strcmp(bottomText, "") != 0) {
mvprintw(offset, 1, "%s", bottomText); mvprintw(offset, 1, "%s", bottomText);