mirror of
https://github.com/tomasriveral/NoteWrapper.git
synced 2026-08-12 02:18:38 +02:00
Formated comments in headers
This commit is contained in:
+2
-4
@@ -14,7 +14,6 @@
|
||||
#include <ncurses.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
int shouldDebug = 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
|
||||
@@ -33,8 +32,7 @@ int main(int argc, char *argv[]) {
|
||||
const char *homedir = pw->pw_dir;
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// this part handles the config.json file
|
||||
// gets the home directory
|
||||
char *configPath = malloc(PATH_MAX);
|
||||
@@ -90,7 +88,7 @@ int main(int argc, char *argv[]) {
|
||||
snprintf(notesDirectoryString, PATH_MAX, "%s/Documents/Notes/", homedir);
|
||||
debug("the vault's directory is not set in the config file. Using default %s", notesDirectoryString);
|
||||
}
|
||||
|
||||
|
||||
// fetch the render and jumpToEnfOfFileOnLaunch bools
|
||||
int shouldRender = 1;
|
||||
cJSON *shouldRenderJSON = cJSON_GetObjectItem(json, "render");
|
||||
|
||||
+12
-13
@@ -2,21 +2,20 @@
|
||||
#define NOTES_H
|
||||
#include "utils.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);
|
||||
// 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 **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)
|
||||
// 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.
|
||||
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);
|
||||
// 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);
|
||||
// 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
|
||||
|
||||
@@ -12,27 +12,27 @@
|
||||
#include <limits.h>
|
||||
#include <regex.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);
|
||||
// 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 name of the note
|
||||
/*Uses ncurses to get an input from the user.
|
||||
Creates a new vault with this input.
|
||||
If vault already exists, prints a warning.
|
||||
returns nothing. */
|
||||
void createNewVault(char *dirToVault, int debug);
|
||||
// Uses ncurses to get an input from the user
|
||||
// Creates a new vault with this input
|
||||
// If vault already exists, prints a warning
|
||||
// returns nothing
|
||||
/*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. */
|
||||
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
|
||||
|
||||
+24
-22
@@ -30,39 +30,41 @@ extern const char *supportedEditor[]; // array of supported editors
|
||||
extern const int numEditors; // number of supported editors
|
||||
|
||||
//(TODO LATER) organise this mess
|
||||
int compareString(const void *a, const void *b);
|
||||
|
||||
//compares two strings alphabetically.
|
||||
//this function is used for qsort
|
||||
int doesEditorExist(char *editorToCheck, int debug);
|
||||
// this basically checks all the dirs from your path for the editor. This is a safety check
|
||||
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.
|
||||
// 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, ...);
|
||||
//formated debugging
|
||||
//use for less formal debuggin. (usefull if enumerating or making a list).
|
||||
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, ...);
|
||||
// formated error
|
||||
// if the error is not a critical one (for ex: file not found) System error message will be Succesfull
|
||||
// Returns 1 if the string is in the array.
|
||||
// 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);
|
||||
// Returns 1 if the string is in the array
|
||||
// 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
|
||||
// returns 1 if the string is in the file.
|
||||
// returns 0 if the string is not in the file.
|
||||
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);
|
||||
// replace unwanted chars by '_'.
|
||||
// '.' is replaced if it is only the first two chars
|
||||
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);
|
||||
//from https://stackoverflow.com/a/5467788
|
||||
//deletes an entire directory. Use with parsimony and carefullness
|
||||
// Inputs are the path to the file, the editor to open and some rendering option.
|
||||
// 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);
|
||||
// Inputs are the path to the file, the editor to open and some rendering option
|
||||
// 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
|
||||
// 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.
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user