Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BasedOnStyle: LLVM
IndentWidth: 4
ColumnLimit: 100
10 changes: 9 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@ jobs:

steps:
- uses: actions/checkout@v4

- name: Install clang
run: |
sudo apt-get update
sudo apt-get install -y clang-format
- name: Check format
run: |
clang-format --version
find src -name "*.c" -o -name "*.h" | xargs clang-format --dry-run --Werror

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
gcc \
make \
Expand Down
9 changes: 9 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,12 @@ Before submitting a pull request, ensure that:
* `make`, or
* `nix-build` (on NixOS)
* There are **no warnings or errors**

---

## Continuous integration

All PR will need to pass these checks:
1. `clang-format`. Running `find src -name "*.c" -o -name "*.h" | xargs clang-format -i` will automatically apply those rules.
2. The program must build without warning or error.
3. The program must run for five seconds without crashing.
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ CC := gcc

VERSION := $(shell git describe --tags --always --dirty)

CFLAGS := -Wall -Wextra -O2 \
CFLAGS := -Wall -Wextra -Werror -O2 \
-DVERSION=\"$(VERSION)\" \
$(shell pkg-config --cflags libcjson ncurses)

Expand Down
1 change: 1 addition & 0 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ pkgs.mkShell {
pkgs.gdb
pkgs.valgrind
pkgs.kdePackages.kcachegrind
pkgs.clang-tools
];
}
1,030 changes: 584 additions & 446 deletions src/main.c

Large diffs are not rendered by default.

525 changes: 301 additions & 224 deletions src/notes.c

Large diffs are not rendered by default.

37 changes: 22 additions & 15 deletions src/notes.h
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
#ifndef NOTES_H
#define NOTES_H
#include "utils.h"
#include "ui.h"
#include "utils.h"
// find which directory contains targetVault
char *getDirectoryFromVault(char *targetVault, char **vaultsArray, int vaultTotalNumber, int *vaultNumberPerDirectory, char **directoryArray, int directoryNumber, int shouldDebug);
char *getDirectoryFromVault(char *targetVault, char **vaultsArray, int vaultTotalNumber,
int *vaultNumberPerDirectory, char **directoryArray,
int directoryNumber, 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 **getJournalsFromVault(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.
char **getNotesFromVault(char *pathToVault, char *vault, char *journalRegex, int *count, int shouldDebug);
// function gets as input an array of directoryNumber strings. Which are the directories the function will search for vaults.
// it returns an array of vaults.
// the vaults are organized in order per directory.
// vaultsPerDirectoryNumber and count should be initiallized before calling the function and the address be inputed.
// count is the total number of vaults.
// 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);
// 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);
// function gets as input an array of directoryNumber strings. Which are the directories the
// function will search for vaults. it returns an array of vaults. the vaults are organized in order
// per directory. vaultsPerDirectoryNumber and count should be initiallized before calling the
// function and the address be inputed. count is the total number of vaults.
// vaultsPerDirectoryNumber gives how many vaults each directory has.
char **getVaultsFromDirectories(char **directoryStringArray, int directoryNumber, int *vaultsPerDirectoryNumber, int *count, int shouldDebug);
char **getVaultsFromDirectories(char **directoryStringArray, int directoryNumber,
int *vaultsPerDirectoryNumber, int *count, int shouldDebug);
// path is the path to the file.
// journal is the name of the file.
// journalWasUpdated will be set to 1 if a new entry was created
// 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 *journalWasUpdated, int shouldDebug);
char *updateJournal(char *path, char *journal, char *timeFormat, int *journalWasUpdated,
int shouldDebug);
#endif
Loading
Loading