mirror of
https://github.com/tomasriveral/NoteWrapper.git
synced 2026-08-11 18:18:36 +02:00
Merge (#47) from tomasriveral/ncurse-quick-selection
feat: ncurses quick select
This commit is contained in:
+5
-4
@@ -598,7 +598,8 @@ backup_config_end:
|
|||||||
|
|
||||||
*backupMessage = 0; // we reset it to show the message only once
|
*backupMessage = 0; // we reset it to show the message only once
|
||||||
|
|
||||||
vaultSelected = ncursesSelect(vaultsArray, "Select vault to open (Use arrows or WASD, Enter to select):", vaultsCount, extraOptions, " ", "Or select an option below", "", shouldDebug);
|
vaultSelected = ncursesSelect(vaultsArray, "Select vault to open (Use arrows or WASD, Enter to select or use 1-9 to quick select or use 1-9 to quick 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
|
// 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
|
// all its elements. (As this is memory in the heap and not the stack and thus is our
|
||||||
@@ -666,8 +667,8 @@ backup_config_end:
|
|||||||
goto note_creation;
|
goto note_creation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
noteSelected =
|
noteSelected = ncursesSelect(filesArray, "Select note or journal to open (Use arrows or WASD, Enter to select or use 1-9 to quick select):", filesCount, extraNotesOptions, " ",
|
||||||
ncursesSelect(filesArray, "Select note or journal to open (Use arrows or WASD, Enter to select):", filesCount, extraNotesOptions, " ", "Or select an option below", "", shouldDebug);
|
"Or select an option below", "", shouldDebug);
|
||||||
// now that we won't use filesArray in this iteration of the loop, we should free it
|
// 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
|
// and all its elements. (As this is memory in the heap and not the stack and thus
|
||||||
// is our responsability to manage)
|
// is our responsability to manage)
|
||||||
@@ -741,7 +742,7 @@ backup_config_end:
|
|||||||
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,
|
char *answer = ncursesSelect((char **)yesNo,
|
||||||
"Are you sure you want to delete the entire vault? This can "
|
"Are you sure you want to delete the entire vault? This can "
|
||||||
"not be undone (Use arrows or WASD, Enter to select):",
|
"not be undone (Use arrows or WASD, Enter to select or use 1-9 to quick select):",
|
||||||
1, 1, " ", "", "", shouldDebug);
|
1, 1, " ", "", "", shouldDebug);
|
||||||
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) {
|
||||||
|
|||||||
+5
-4
@@ -260,10 +260,11 @@ char *updateJournal(char *path, char *journal, char *timeFormat, int *journalWas
|
|||||||
// element
|
// element
|
||||||
|
|
||||||
// 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 (Use arrows or WASD, Enter to select):", extraOptions, entryCount - extraOptions, " ", " ", "",
|
char *selectedOption =
|
||||||
shouldDebug); // the "Create new entry for the journal %s" will be the only options. All
|
ncursesSelect(entryArray, "Create new entry or acces old entry (Use arrows or WASD, Enter to select or use 1-9 to quick select):", extraOptions, entryCount - extraOptions, " ", " ", "",
|
||||||
// other will be extraOptions. This is made so that "Create [...] %s" will
|
shouldDebug); // the "Create new entry for the journal %s" will be the only options. All
|
||||||
// always be on top
|
// 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];
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ void createNewVault(char **directoriesArray, int directoryCount, char **vaultsAr
|
|||||||
int emptyWarning = 0; // set to 1 later if inpted empty name
|
int emptyWarning = 0; // set to 1 later if inpted empty name
|
||||||
input_screen:
|
input_screen:
|
||||||
// choose in which directory the vault will be created
|
// choose in which directory the vault will be created
|
||||||
char *dirToVault = ncursesSelect(directoriesArray, "Select a directory, in which the vault will remain (Use arrows or WASD, Enter to select)", directoryCount, 0, "", "", " ", shouldDebug);
|
char *dirToVault =
|
||||||
|
ncursesSelect(directoriesArray, "Select a directory, in which the vault will remain (Use arrows or WASD, Enter to select or use 1-9 to quick select)", directoryCount, 0, "", "", " ", shouldDebug);
|
||||||
char *vaultName = malloc(PATH_MAX);
|
char *vaultName = malloc(PATH_MAX);
|
||||||
if (!bypass) { // if won't bypass (if -v or --vault weren't set)
|
if (!bypass) { // if won't bypass (if -v or --vault weren't set)
|
||||||
echo();
|
echo();
|
||||||
@@ -309,6 +310,69 @@ char *ncursesSelect(char **options, char *optionsText, int optionsNumber, int ex
|
|||||||
highlight = 0;
|
highlight = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case '1':
|
||||||
|
if (optionsNumber + extraOptionsNumber >= 1) {
|
||||||
|
debug("Quickselected option 1.");
|
||||||
|
highlight = 0;
|
||||||
|
goto end_loop;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '2':
|
||||||
|
if (optionsNumber + extraOptionsNumber >= 1) {
|
||||||
|
debug("Quickselected option 2.");
|
||||||
|
highlight = 1;
|
||||||
|
goto end_loop;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '3':
|
||||||
|
if (optionsNumber + extraOptionsNumber >= 1) {
|
||||||
|
debug("Quickselected option 3.");
|
||||||
|
highlight = 2;
|
||||||
|
goto end_loop;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '4':
|
||||||
|
if (optionsNumber + extraOptionsNumber >= 1) {
|
||||||
|
debug("Quickselected option 4.");
|
||||||
|
highlight = 3;
|
||||||
|
goto end_loop;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '5':
|
||||||
|
if (optionsNumber + extraOptionsNumber >= 1) {
|
||||||
|
debug("Quickselected option 5.");
|
||||||
|
highlight = 4;
|
||||||
|
goto end_loop;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '6':
|
||||||
|
if (optionsNumber + extraOptionsNumber >= 1) {
|
||||||
|
debug("Quickselected option 6.");
|
||||||
|
highlight = 5;
|
||||||
|
goto end_loop;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '7':
|
||||||
|
if (optionsNumber + extraOptionsNumber >= 1) {
|
||||||
|
debug("Quickselected option 7.");
|
||||||
|
highlight = 6;
|
||||||
|
goto end_loop;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '8':
|
||||||
|
if (optionsNumber + extraOptionsNumber >= 1) {
|
||||||
|
debug("Quickselected option 8.");
|
||||||
|
highlight = 7;
|
||||||
|
goto end_loop;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '9':
|
||||||
|
if (optionsNumber + extraOptionsNumber >= 1) {
|
||||||
|
debug("Quickselected option 9.");
|
||||||
|
highlight = 8;
|
||||||
|
goto end_loop;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 10: //\n
|
case 10: //\n
|
||||||
goto end_loop;
|
goto end_loop;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user