mirror of
https://github.com/tomasriveral/NoteWrapper.git
synced 2026-08-12 10:20:46 +02:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e666ca32de | ||
|
|
2a8392ac2e | ||
|
|
a32f97d229 | ||
|
|
6555b7247e | ||
|
|
2b2a3455d2 |
@@ -13,7 +13,7 @@
|
||||
in {
|
||||
packages.default = pkgs.stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "notewrapper";
|
||||
version = "v2.2";
|
||||
version = "v2.2.1";
|
||||
|
||||
src = ./.;
|
||||
|
||||
|
||||
+9
-1
@@ -695,12 +695,18 @@ backup_config_end:
|
||||
|
||||
int *journalWasUpdated = malloc(sizeof(int));
|
||||
*journalWasUpdated = 0;
|
||||
|
||||
// used to go back to note selection
|
||||
int *returnNoteSelection = malloc(sizeof(int));
|
||||
*returnNoteSelection = 0;
|
||||
|
||||
if (!regexReturn) { // if the regex matches -> it's a journal
|
||||
debug("%s is a journal. Updating it...", noteSelected);
|
||||
fullPath = updateJournal(fullPath, noteSelected, timeFormat, journalWasUpdated,
|
||||
fullPath = updateJournal(fullPath, noteSelected, timeFormat, journalWasUpdated, returnNoteSelection,
|
||||
shouldDebug); // we return the path. As if it is a divided journal we
|
||||
// must point to the correct entry
|
||||
}
|
||||
if (!*returnNoteSelection) { // if we don't need to return to the note selection
|
||||
if (newLineOnOpening) {
|
||||
if (*journalWasUpdated) {
|
||||
appendToFile(fullPath, " \n",
|
||||
@@ -713,6 +719,8 @@ backup_config_end:
|
||||
}
|
||||
openEditor(fullPath, editorToOpen, shouldRender, shouldJumpToEnd, shouldDebug);
|
||||
free(fullPath);
|
||||
}
|
||||
free(returnNoteSelection);
|
||||
} else if (strcmp(noteSelected, "Create new note") == 0) {
|
||||
note_creation:
|
||||
noteSelected = createNewNote(notesDirectoryString, vaultSelected, bypassSelectionNote, bypassSelectionNoteValue, journalRegex, shouldDebug);
|
||||
|
||||
+5
-2
@@ -188,7 +188,7 @@ char **getVaultsFromDirectories(char **directoryStringArray, int directoryNumber
|
||||
return vaultsArray;
|
||||
}
|
||||
|
||||
char *updateJournal(char *path, char *journal, char *timeFormat, int *journalWasUpdated, int shouldDebug) {
|
||||
char *updateJournal(char *path, char *journal, char *timeFormat, int *journalWasUpdated, int *returnNoteSelection, int shouldDebug) {
|
||||
path[PATH_MAX] = '\0'; // it assures it is a string (Most cases this does nothing). But rewriting at least
|
||||
// one bytes make the compile happy. He doesn't want to return an unchanged input.
|
||||
debug("Handling the journal %s", path);
|
||||
@@ -221,13 +221,14 @@ char *updateJournal(char *path, char *journal, char *timeFormat, int *journalWas
|
||||
that the Create new entry in journal is on top entryArray = realloc(entryArray,
|
||||
sizeof(char*));*/
|
||||
// simpler to just malloc 2 and later realloc
|
||||
const int extraOptions = 3;
|
||||
const int extraOptions = 4;
|
||||
char **entryArray = malloc(extraOptions * sizeof(char *));
|
||||
char *createEntryMessage = malloc(PATH_MAX);
|
||||
snprintf(createEntryMessage, PATH_MAX, "Create new entry for the journal %s", journal);
|
||||
entryArray[0] = createEntryMessage;
|
||||
entryArray[1] = "Open random entry";
|
||||
entryArray[2] = "Search inside entries";
|
||||
entryArray[3] = "Return to the note selection";
|
||||
int entryCount = extraOptions; // we need to count how many dirs there is to always readjust
|
||||
// how many memory we alloc
|
||||
// Refer https://pubs.opengroup.org/onlinepubs/7990989775/xsh/readdir.html
|
||||
@@ -301,6 +302,8 @@ char *updateJournal(char *path, char *journal, char *timeFormat, int *journalWas
|
||||
snprintf(selectedOption, PATH_MAX, "%s/%s", path, temp);
|
||||
path = strdup(selectedOption);
|
||||
free(selectedOption);
|
||||
} else if (strcmp(selectedOption, "Return to the note selection") == 0) {
|
||||
*returnNoteSelection = 1;
|
||||
} else { // we just recreate the path to the selected entry
|
||||
// snprintf does not like to have the same variable as input and output so we use a
|
||||
// buffer
|
||||
|
||||
+2
-1
@@ -25,6 +25,7 @@ char **getVaultsFromDirectories(char **directoryStringArray, int directoryNumber
|
||||
// handles both type of journal (divided and unified).
|
||||
// creates new entry with date.
|
||||
// for divided select if we want to acces to a new entry or a old one.
|
||||
// returnNoteSelection tells us if the user wants to go back to the note selection.
|
||||
// returns the path to the file that needs to be opened.
|
||||
char *updateJournal(char *path, char *journal, char *timeFormat, int *journalWasUpdated, int shouldDebug);
|
||||
char *updateJournal(char *path, char *journal, char *timeFormat, int *journalWasUpdated, int *returnNoteSelection, int shouldDebug);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user