Last commit did not work

This commit is contained in:
Tomas Rivera
2026-04-09 18:27:02 +02:00
parent 27b0a35dd0
commit 2835de027c
4 changed files with 16 additions and 1 deletions
+5 -1
View File
@@ -289,6 +289,8 @@ int main(int argc, char *argv[]) {
goto vault_creation; goto vault_creation;
} else { } else {
goto note_selection; goto note_selection;
debug("[BYPASS] %s does exist. Going to note selection");
} }
} }
@@ -356,11 +358,13 @@ note_selection:
char *noteSelected; char *noteSelected;
// if we set to bypass the note selector // if we set to bypass the note selector
if (bypassSelectionNote) { if (bypassSelectionNote) {
// (TODO LATER) Add shouldDebug info debug("We are bypassing note selection.");
noteSelected = bypassSelectionNoteValue; noteSelected = bypassSelectionNoteValue;
if (isStringInArray(noteSelected, (const char **)filesArray, filesCount)) {// we just give filesCount and not filesCount + extraOptions to avoid matching with an extra options. if (isStringInArray(noteSelected, (const char **)filesArray, filesCount)) {// we just give filesCount and not filesCount + extraOptions to avoid matching with an extra options.
debug("The note specified with -n or --note does exist. Opening it.");
goto open_note; goto open_note;
} else { // if the specified note doesn't exist. We creat it } else { // if the specified note doesn't exist. We creat it
debug("The note specified with -n or --note doesn't exist. Creating it.");
goto note_creation; goto note_creation;
} }
} }
+3
View File
@@ -1,5 +1,6 @@
#include "notes.h" #include "notes.h"
// (TODO LATER) Check if it isn't a know media file like .jpg, etc. more generally only text, code or markdown file should be accepted. maybe se if it is in utf8?
char **getJournalsFromVault(char *pathToVault, char *vault, char *journalRegex, int *count, int shouldDebug) { char **getJournalsFromVault(char *pathToVault, char *vault, char *journalRegex, int *count, int shouldDebug) {
debug("Searching %s for journals", vault); debug("Searching %s for journals", vault);
// originally from https://www.geeksforgeeks.org/c/c-program-list-files-sub-directories-directory/ // originally from https://www.geeksforgeeks.org/c/c-program-list-files-sub-directories-directory/
@@ -184,6 +185,8 @@ char *updateJournal(char *path, char *journal, char *timeFormat, int shouldDebug
altDebug("└------------------------------\n"); altDebug("└------------------------------\n");
// free's some used memory // free's some used memory
closedir(dividedJournalDirectory); closedir(dividedJournalDirectory);
qsort(entryArray + 1, entryCount - 1, sizeof(const char *), reverseCompareString); // sorts the journals entries alphabetically. // the + 1 - 1 is to not sort "Create new entry for the journal" which is the first 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):", 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);
+5
View File
@@ -8,6 +8,11 @@ int compareString(const void *a, const void *b) {
const char *str2 = *(const char **)b; const char *str2 = *(const char **)b;
return strcmp(str1, str2); // strcmp returns <0, 0, >0 return strcmp(str1, str2); // strcmp returns <0, 0, >0
} }
int reverseCompareString(const void *a, const void *b) {
const char *str1 = *(const char **)a;
const char *str2 = *(const char **)b;
return -1*strcmp(str1, str2);
}
void getCurrentTime(int *hour, int *minute, int *second) { void getCurrentTime(int *hour, int *minute, int *second) {
time_t now = time(NULL); // Get current time in seconds since epoch time_t now = time(NULL); // Get current time in seconds since epoch
+3
View File
@@ -37,6 +37,9 @@ extern const int numEditors; // number of supported editors
//compares two strings alphabetically. //compares two strings alphabetically.
//this function is used for qsort //this function is used for qsort
int compareString(const void *a, const void *b); int compareString(const void *a, const void *b);
// compares two strings in reversed alphabetical order
// this function is used for qsort
int reverseCompareString(const void *a, const void *b);
// this basically checks all the dirs from your path for the editor. This is a safety check. // this basically checks all the dirs from your path for the editor. This is a safety check.
// If the executable from an editor is not the editor name (for example neovim and nvim), you must handle at the start of the function. // If the executable from an editor is not the editor name (for example neovim and nvim), you must handle at the start of the function.
int doesEditorExist(char *editorToCheck, int debug); int doesEditorExist(char *editorToCheck, int debug);