Formated comments in headers

This commit is contained in:
Tomas Rivera
2026-04-05 15:51:42 +02:00
parent 514046dadc
commit 8da1a430d7
4 changed files with 58 additions and 59 deletions
-2
View File
@@ -14,7 +14,6 @@
#include <ncurses.h> #include <ncurses.h>
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
int shouldDebug = 0; int shouldDebug = 0;
int overwriteConfigPath = 0; int overwriteConfigPath = 0;
// (TODO LATER) we really should change all the HASH_MACRO to an int that checks if it is overwritten and a char* that stores to the string // (TODO LATER) we really should change all the HASH_MACRO to an int that checks if it is overwritten and a char* that stores to the string
@@ -34,7 +33,6 @@ int main(int argc, char *argv[]) {
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
// this part handles the config.json file // this part handles the config.json file
// gets the home directory // gets the home directory
char *configPath = malloc(PATH_MAX); char *configPath = malloc(PATH_MAX);
+12 -13
View File
@@ -2,21 +2,20 @@
#define NOTES_H #define NOTES_H
#include "utils.h" #include "utils.h"
#include "ui.h" #include "ui.h"
// gets the journals from the vault.
//to distinguish journals from note we use regex.
//Note: we must handle them separatly as journals can either be a single file (which will treat specially) or a directory.
char **getJournalsFromVault(char *pathToVault, char *vault, char *journalRegex, int *count, int shouldDebug); char **getJournalsFromVault(char *pathToVault, char *vault, char *journalRegex, int *count, int shouldDebug);
// gets the journals from the vault // this function is inputed a path to a vault (which was selected before) and outpus all the suitable notes (so not the hidden ones).
// to distinguish journals from note we use regex.
// Note: we must handle them separatly as journals can either be a single file (which will treat specially) or a directory
char **getNotesFromVault(char *pathToVault, char *vault, char *journalRegex, int *count, int shouldDebug);
// this function is inputed a path to a vault (which was selected before) and outpus all the suitable notes (so not the hidden ones)
// journalRegex is the regex code for the journals. If a note matches this code, it is treated as a journal and it is not outputed from this function. // journalRegex is the regex code for the journals. If a note matches this code, it is treated as a journal and it is not outputed from this function.
char **getNotesFromVault(char *pathToVault, char *vault, char *journalRegex, int *count, int shouldDebug);
// this function is inputed a path to a directory (which comes usually from the config file) and outpus all the suitable directories (so not the hidden ones) which will serve as separate vaults for notes.
char **getVaultsFromDirectory(char *dirString, size_t *count, int shouldDebug); char **getVaultsFromDirectory(char *dirString, size_t *count, int shouldDebug);
// this function is inputed a path to a directory (which comes usually from the config file) and outpus all the suitable directories (so not the hidden ones) which will serve as separate vaults for notes // path is the path to the file.
// journal is the name of the file.
// 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.
// returns the path to the file that needs to be opened.
char *updateJournal(char *path, char *journal, char *timeFormat, int shouldDebug); char *updateJournal(char *path, char *journal, char *timeFormat, int shouldDebug);
// path is the path to the file
// journal is the name of the file
// 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
// returns the path to the file that needs to be opened
#endif #endif
+20 -20
View File
@@ -12,27 +12,27 @@
#include <limits.h> #include <limits.h>
#include <regex.h> #include <regex.h>
#include "utils.h" #include "utils.h"
/*Uses ncurses to get an input from the user.
Creates a new note with this input.
also can create a journal if the name matches with journalRegex.
returns the path to the note. */
char *createNewNote(char dirToVault[PATH_MAX], char *vaultFromDir, char *bypass, char *journalRegex, int debug); char *createNewNote(char dirToVault[PATH_MAX], char *vaultFromDir, char *bypass, char *journalRegex, int debug);
// Uses ncurses to get an input from the user /*Uses ncurses to get an input from the user.
// Creates a new note with this input Creates a new vault with this input.
// also can create a journal if the name matches with journalRegex If vault already exists, prints a warning.
// returns the name of the note returns nothing. */
void createNewVault(char *dirToVault, int debug); void createNewVault(char *dirToVault, int debug);
// Uses ncurses to get an input from the user /*this function is used multiple times let the user select one options from many with ncurses in a TUI.
// Creates a new vault with this input options is the array of strings with all the options.
// If vault already exists, prints a warning optionsText is the text that will be printed at the top (For example: "Please select ...").
// returns nothing we distinguish options from extraOptions.
options could be the list of all notes or all vaults.
extraOptions are options that are special and have a special color (for ex: "Delete vault", "Settings", etc.).
note: extraOptions should be at the end of options.
topText is printed between options text and the start of options.
middleText (usally \n) is printed between options and extraOptions.
bottomText is printed bellow.
topText and middle must be exactly one line. If you want empty lines use " " and not "".
returns the selected option. */
char* ncursesSelect(char **options, char *optionsText, size_t optionsNumber, size_t extraOptionsNumber, char *bottomText, char *middleText, char *topText, int debug); char* ncursesSelect(char **options, char *optionsText, size_t optionsNumber, size_t extraOptionsNumber, char *bottomText, char *middleText, char *topText, int debug);
// this function is used multiple times let the user select one options from many with ncurses in a TUI.
// options is the array of strings with all the options.
// optionsText is the text that will be printed at the top (For example: "Please select ...")
// we distinguish options from extraOptions
// options could be the list of all notes or all vaults
// extraOptions are options that are special and have a special color (for ex: "Delete vault", "Settings", etc.)
// note: extraOptions should be at the end of options
// topText is printed between options text and the start of options
// middleText (usally \n) is printed between options and extraOptions
// bottomText is printed bellow
// topText and middle must be exactly one line. If you want empty lines use " " and not ""
// returns the selected option
#endif #endif
+24 -22
View File
@@ -30,39 +30,41 @@ extern const char *supportedEditor[]; // array of supported editors
extern const int numEditors; // number of supported editors extern const int numEditors; // number of supported editors
//(TODO LATER) organise this mess //(TODO LATER) organise this mess
int compareString(const void *a, const void *b);
//compares two strings alphabetically. //compares two strings alphabetically.
//this function is used for qsort //this function is used for qsort
int doesEditorExist(char *editorToCheck, int debug); int compareString(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);
// please use the macro debug instead of _debug.
//formated debugging.
void _debug(const int d, const char *file, const int line, const char *function, const char *message, ...); void _debug(const int d, const char *file, const int line, const char *function, const char *message, ...);
//formated debugging //use for less formal debuggin. (usefull if enumerating or making a list).
void _altDebug(const int d, const char *message, ...); void _altDebug(const int d, const char *message, ...);
//use for less formal debuggin. (usefull if enumerating or making a list) // formated error.
void _error(const int shouldDebug, const int condition, const char *type, const char *file, const int line, const char *function, const char *message, ...); void _error(const int shouldDebug, const int condition, const char *type, const char *file, const int line, const char *function, const char *message, ...);
// formated error // Returns 1 if the string is in the array.
// if the error is not a critical one (for ex: file not found) System error message will be Succesfull // Returns 0 if the string is not in the array.
// If you want to only check the first n elements of the array, pass n as len.
int isStringInArray(const char *string, const char **array, const int len); int isStringInArray(const char *string, const char **array, const int len);
// Returns 1 if the string is in the array // returns 1 if the string is in the file.
// Returns 0 if the string is not in the array // returns 0 if the string is not in the file.
// If you want to only check the first n elements of the array, pass n as len
int isStringInFile(const char *path, const char *string, const int shouldDebug); int isStringInFile(const char *path, const char *string, const int shouldDebug);
// returns 1 if the string is in the file
// returns 0 if the string is not in the file
void appendToFile(const char *path, const char *string, const int shouldDebug); void appendToFile(const char *path, const char *string, const int shouldDebug);
// replace unwanted chars by '_'.
// '.' is replaced if it is only the first two chars
void sanitize(char *string); void sanitize(char *string);
// replace unwanted chars by '_'. '.' is replaced if it is only the first two chars //from https://stackoverflow.com/a/5467788.
//deletes an entire directory. Use with parsimony and carefullness.
int rmrf(char *path); int rmrf(char *path);
//from https://stackoverflow.com/a/5467788 // Inputs are the path to the file, the editor to open and some rendering option.
//deletes an entire directory. Use with parsimony and carefullness // render: if we render the .md file with Vivify.
// shouldJumpToEndOfFile: if we put the cursor at the end of the file when opening.
// The program resumes when the editor is closed.
int openEditor(char *path, char *editor, int render, int shouldJumpToEndOfFile, int debug); int openEditor(char *path, char *editor, int render, int shouldJumpToEndOfFile, int debug);
// Inputs are the path to the file, the editor to open and some rendering option // see https://pubs.opengroup.org/onlinepubs/7908799/xsh/strftime.html? for formats.
// render: if we render the .md file with Vivify // returns a string (buffered at 256 chars).
// shouldJumpToEndOfFile: if we put the cursor at the end of the file when opening // you should not forgot to free this string as it is in the heap.
// The program resumes when the editor is closed
char *getFormatedTime(char *format, int shouldDebug); char *getFormatedTime(char *format, int shouldDebug);
// see https://pubs.opengroup.org/onlinepubs/7908799/xsh/strftime.html? for formats
// returns a string (buffered at 256 chars)
// you should not forgot to free this string as it is in the heap
#endif #endif