diff --git a/README.md b/README.md index 2e3d15f..7fb245b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ config file in json -requierements neovim, nvim-tree, vivify, vivify.vim +requierements neovim vivify, vivify.vim, ncurses, cjson, pkg-config, 1. launches a TUI - asks if you want to open an already existing directory (by default in ~/Documents/Notes but can be changed in the config file) or create a new directory diff --git a/makefile b/makefile index 6629a9f..d3d6018 100644 --- a/makefile +++ b/makefile @@ -1,35 +1,17 @@ -# Makefile for the Notes Vault project - -# Compiler CC = gcc - -# Source files SRC = startup.c - -# Output binary TARGET = nvimnotes - -# Compiler flags CFLAGS = -Wall -O2 `pkg-config --cflags libcjson ncurses` - -# Linker flags LDFLAGS = `pkg-config --libs libcjson ncurses` - -# Debug mode DEBUG ?= 0 ifeq ($(DEBUG),1) - CFLAGS += -g +CFLAGS += -g endif - .PHONY: all clean run - all: $(TARGET) - $(TARGET): $(SRC) $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) - run: $(TARGET) ./$(TARGET) - clean: rm -f $(TARGET) diff --git a/shell.nix b/shell.nix index 0982f3d..6f05f7b 100644 --- a/shell.nix +++ b/shell.nix @@ -2,7 +2,6 @@ pkgs.mkShell { buildInputs = [ - pkgs.vivify pkgs.cjson pkgs.ncurses pkgs.pkg-config diff --git a/startup.c b/startup.c index 3fe1946..098f62e 100644 --- a/startup.c +++ b/startup.c @@ -256,7 +256,7 @@ int main(int argc, char *argv[]) { char *vaultSelected = ncursesSelect(vaultsArray, "vault", vaultsCount + extraOptions, debug); if (debug) {printf("\e[0;32m[DEBUG]\e[0m Selected vault:%s\n", vaultSelected);} - if (vaultSelected != "Create a new vault" && vaultSelected != "Settings" && vaultSelected != "Quit (Ctrl+C)") { + if (strcmp(vaultSelected,"Create a new vault") != 0 && strcmp(vaultSelected,"Settings") != 0 && strcmp(vaultSelected,"Quit (Ctrl+C)") != 0) { int shouldChangeVault = 0; while (!shouldExit && !shouldChangeVault) { // this loop is the note selector @@ -280,25 +280,25 @@ int main(int argc, char *argv[]) { char *noteSelected = ncursesSelect(filesArray, "note", filesCount + extraNotesOptions, debug); if (debug) {printf("\e[0;32m[DEBUG]\e[0m Selected note: %s\n", noteSelected);} - if (noteSelected != "Create new note" && noteSelected != "Back to vault selection" && noteSelected != "Quit (Ctrl+C)") { + if (strcmp(noteSelected, "Create new note") != 0 && strcmp(noteSelected,"Back to vault selection") != 0 && strcmp(noteSelected,"Quit (Ctrl+C)") != 0) { char fullPath[PATH_MAX]; sprintf(fullPath, "%s/%s/%s", notesDirectoryString, vaultSelected, noteSelected); openNvim(fullPath, debug); - } else if (noteSelected == "Create new note") { + } else if (strcmp(noteSelected,"Create new note") == 0) { - } else if (noteSelected == "Back to vault selection") { + } else if (strcmp(noteSelected,"Back to vault selection") == 0) { shouldChangeVault = 1; - } else if (noteSelected == "Quit (Ctrl+C)") { + } else if (strcmp(noteSelected,"Quit (Ctrl+C)") == 0) { if (debug) {printf("\e[0;32m[DEBUG]\e[0m The program was exited,\n");} shouldExit = 1; } } - } else if (vaultSelected == "Create a new vault") { + } else if (strcmp(vaultSelected,"Create a new vault") == 0) { - } else if (vaultSelected == "Settings") { + } else if (strcmp(vaultSelected,"Settings") == 0) { //(TODO LATER) add a way to change the config.json from the app or at least show all the options - } else if (vaultSelected == "Quit (Ctrl+C)") { + } else if (strcmp(vaultSelected,"Quit (Ctrl+C)") == 0) { if (debug) {printf("\e[0;32m[DEBUG]\e[0m The program was exited.\n");} shouldExit = 1; }