Compare commits

52 Commits
main ... v1.0.0

Author SHA1 Message Date
Zvonimir Rudinski
9414db11e1 add ncurses to requirements 2024-08-15 02:43:30 +02:00
Zvonimir Rudinski
6513a73ce4 change package name 2024-08-15 02:42:52 +02:00
Zvonimir Rudinski
5d32c49557 add msystem 2024-08-15 02:42:47 +02:00
Zvonimir Rudinski
1e1d6b9115 try out different command name 2024-08-15 02:38:06 +02:00
Zvonimir Rudinski
ec8d491e6f change to correct package name 2024-08-15 02:37:59 +02:00
Zvonimir Rudinski
278b11f1c1 add windows build again 2024-08-15 02:37:52 +02:00
Zvonimir Rudinski
677bd89362 add dirty check 2024-06-02 16:35:08 +02:00
Zvonimir Rudinski
537f57a3b2 remove windows build step 2024-06-02 07:13:36 +02:00
Zvonimir Rudinski
49c403cf63 add windows build step 2024-06-02 07:12:49 +02:00
Zvonimir Rudinski
31831d29d7 add mac build step 2024-06-02 07:12:08 +02:00
Zvonimir Rudinski
e35ba14b19 upload artifact 2024-06-02 07:11:32 +02:00
Zvonimir Rudinski
1c1ab9d29b fix mvwprintw string literal error 2024-06-02 07:09:39 +02:00
Zvonimir Rudinski
8a114acc71 remove setup gcc 2024-06-02 07:06:27 +02:00
Zvonimir Rudinski
aa25ef9a6a remove cache apt pkgs 2024-06-02 07:05:15 +02:00
Zvonimir Rudinski
6ec4aebf2a set version to string 2024-06-02 07:05:00 +02:00
Zvonimir Rudinski
481d853ebc add other steps 2024-06-02 07:04:39 +02:00
Zvonimir Rudinski
895abb1f0b generate workflow file 2024-06-02 07:02:12 +02:00
Zvonimir Rudinski
0ef406e59c start debugging workflow file 2024-06-02 07:01:12 +02:00
Zvonimir Rudinski
3e02cfe363 copy workflow into correct directory 2024-06-02 06:58:17 +02:00
Zvonimir Rudinski
05adbf5d33 add github build action 2024-06-02 06:57:46 +02:00
Zvonimir Rudinski
705f989737 take height into account 2024-06-02 06:50:19 +02:00
Zvonimir Rudinski
90991e7401 add view command 2024-06-02 06:49:24 +02:00
Zvonimir Rudinski
694a71362d add licenses 2024-06-02 06:40:15 +02:00
Zvonimir Rudinski
60f5e2af3e add proper scroll 2024-06-02 06:33:54 +02:00
Zvonimir Rudinski
ec9a455a49 load file on startup if it exists 2024-06-02 06:10:38 +02:00
Zvonimir Rudinski
40f2155a34 remove unused command 2024-06-02 06:05:31 +02:00
Zvonimir Rudinski
668dd69ac0 add install makefile command 2024-06-02 06:02:57 +02:00
Zvonimir Rudinski
758300b704 print key bindings on the footer 2024-06-02 05:59:43 +02:00
Zvonimir Rudinski
b73e47e590 add save file path to the header 2024-06-02 05:57:35 +02:00
Zvonimir Rudinski
c5ba5e8bfa store the default file in the home directory dotfile 2024-06-02 05:55:54 +02:00
Zvonimir Rudinski
0e709a08e2 add todo count in the bottom bar 2024-01-07 12:16:42 +01:00
Zvonimir Rudinski
1914119412 add space key for marking todos 2024-01-07 12:13:45 +01:00
Zvonimir Rudinski
2dd52012a7 allow arrow input 2024-01-07 12:11:30 +01:00
Zvonimir Rudinski
4c1d6a3f79 add a semi-functional TUI 2024-01-06 17:53:01 +01:00
Zvonimir Rudinski
691045186f fix build errors 2023-12-22 04:24:04 +01:00
Zvonimir Rudinski
87d220912e add cflags 2023-12-22 04:22:35 +01:00
Zvonimir Rudinski
4049d732bb update makefile 2023-12-22 04:20:16 +01:00
Zvonimir Rudinski
0efd48dd6f update readme 2023-12-22 04:17:47 +01:00
Zvonimir Rudinski
5fbf6bed11 format the code 2023-12-22 04:11:26 +01:00
Zvonimir Rudinski
8a649463c5 free todos after quit 2023-12-21 21:02:34 +01:00
Zvonimir Rudinski
aa3502dc7b update readme 2023-12-21 19:55:18 +01:00
Zvonimir Rudinski
44a7c3aacc implement loading from file 2023-12-21 19:49:34 +01:00
Zvonimir Rudinski
f0aa6758dc use stb like a normal person (totally didnt waste an hour) 2023-12-21 19:42:50 +01:00
Zvonimir Rudinski
13ebbcd049 remove llist 2023-12-21 19:25:34 +01:00
Zvonimir Rudinski
1a45b1e219 steal a linked list implementation 2023-12-21 18:26:44 +01:00
Zvonimir Rudinski
aa851fad3a add todo serialization 2023-12-21 18:06:50 +01:00
Zvonimir Rudinski
a89a330ede add makefile 2023-12-21 17:35:09 +01:00
Zvonimir Rudinski
38ca5234ca add ideas 2023-12-16 17:24:37 +01:00
Zvonimir Rudinski
a4319c5b38 add readme 2023-12-16 17:23:31 +01:00
Zvonimir Rudinski
f152a85d8a add remove command 2023-12-16 17:22:03 +01:00
Zvonimir Rudinski
dd7c5d0a1c separate files and fix newline bug 2023-12-16 17:12:25 +01:00
Zvonimir Rudinski
9e0ff21192 make stuff work 2023-12-16 17:03:00 +01:00
7 changed files with 83 additions and 77 deletions

74
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,74 @@
name: Build Todd
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libncurses5-dev
version: "1.0"
- name: make
run: make
- name: copy to build folder
run: |
mkdir -p build
cp ./todd build/
- uses: actions/upload-artifact@v4
with:
name: todd-linux
path: build
build-mac:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: make
run: make
- name: copy to build folder
run: |
mkdir -p build
cp ./todd build/
- uses: actions/upload-artifact@v4
with:
name: todd-mac
path: build
build-windows:
defaults:
run:
shell: msys2 {0}
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: msys2/setup-msys2@v2
with:
msystem: mingw64
update: true
install: >-
gcc
make
ncurses-devel
- name: make
run: make
- name: copy to build folder
run: |
mkdir -p build
cp ./todd.exe build/
- uses: actions/upload-artifact@v4
with:
name: todd-windows
path: build

View File

@@ -1,7 +1,7 @@
.DEFAULT_GOAL := all .DEFAULT_GOAL := all
CC=gcc CC=gcc
CFLAGS=-Wall -Wextra -Werror -pedantic -std=c99 -O3 CFLAGS=-Wall -Wextra -Werror -pedantic -std=c99 -g
todo.o: todo.o:
$(CC) $(CFLAGS) -c engine/todo.c -o todo.o $(CC) $(CFLAGS) -c engine/todo.c -o todo.o
@@ -12,6 +12,7 @@ main.o:
clean: clean:
rm -f *.o rm -f *.o
rm -f todd rm -f todd
rm /usr/local/bin/todd || true
todd: todo.o main.o todd: todo.o main.o
$(CC) $(CFLAGS) todo.o main.o -lncurses -o todd $(CC) $(CFLAGS) todo.o main.o -lncurses -o todd
@@ -20,6 +21,3 @@ all: todd
install: todd install: todd
cp todd /usr/local/bin/todd cp todd /usr/local/bin/todd
uninstall:
rm /usr/local/bin/todd || true

View File

@@ -6,10 +6,6 @@
- ncurses development libraries - ncurses development libraries
## Building ## Building
To build `todd` all you need to do is run `make`. To build `todd` all you need to do is run `make`.
## Usage
```sh
./todd <file.todd>
```
## 3rd Party ## 3rd Party
Todd uses the following dependencies: Todd uses the following dependencies:
- stb_ds - https://github.com/nothings/stb - stb_ds - https://github.com/nothings/stb

15
color.h
View File

@@ -1,15 +0,0 @@
#ifndef COLOR_H
#define COLOR_H
#include <ncurses.h>
#define BORDERS_PRIMARY COLOR_BLACK
#define BORDERS_SECONDARY COLOR_WHITE
#define DEFAULT_PRIMARY COLOR_WHITE
#define DEFAULT_SECONDARY COLOR_BLACK
#define COMPLETED_PRIMARY COLOR_BLACK
#define COMPLETED_SECONDARY COLOR_YELLOW
#endif

View File

@@ -1,7 +1,6 @@
#include "todo.h" #include "todo.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h>
#include <string.h> #include <string.h>
// Memory management // Memory management
@@ -55,20 +54,3 @@ char *todo_item_serialize(TodoItem *item, int *buffer_size_out) {
return buffer; return buffer;
} }
// Exports
void todo_export_as_csv(TodoItem *items, int item_count, const char *filename) {
FILE *file = fopen(filename, "w");
if (file == NULL) {
perror("Failed to open file for writing");
return;
}
// Write CSV header
fprintf(file, "Title,Completed\n");
for (int i = 0; i < item_count; i++) {
fprintf(file, "\"%s\",%s\n", items[i].title,
items[i].completed ? "Yes" : "No");
}
fclose(file);
}

View File

@@ -2,6 +2,8 @@
#define TODO_H #define TODO_H
#define TODO_MAX_TITLE_LENGTH 255 #define TODO_MAX_TITLE_LENGTH 255
#define true 1
#define false 0
typedef unsigned char bool_t; typedef unsigned char bool_t;
typedef struct { typedef struct {
@@ -20,7 +22,4 @@ void todo_print_item(TodoItem *item);
// Serialization // Serialization
char *todo_item_serialize(TodoItem *item, int *buffer_size_out); char *todo_item_serialize(TodoItem *item, int *buffer_size_out);
// Exports
void todo_export_as_csv(TodoItem *items, int item_count, const char *filename);
#endif #endif

38
main.c
View File

@@ -1,9 +1,9 @@
#include "engine/todo.h" #include "engine/todo.h"
#include "color.h"
#include <limits.h> #include <limits.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ncurses.h>
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#include <pwd.h> #include <pwd.h>
@@ -17,7 +17,7 @@
#define COMPLETED_PAIR 3 #define COMPLETED_PAIR 3
#include "3rd-party/stb-ds.h" #include "3rd-party/stb-ds.h"
#define KEY_BINDINGS " [a]dd [v]view [m]ark [d]elete [e]xport csv [w]rite [l]oad [q]uit" #define KEY_BINDINGS " [a]dd [v]view [m]ark [d]elete [w]rite [l]oad [q]uit"
bool dirty = false; bool dirty = false;
char SAVE_FILE[MAX_PATH_LENGTH] = ""; char SAVE_FILE[MAX_PATH_LENGTH] = "";
@@ -32,7 +32,6 @@ enum Command {
WRITE_TO_FILE = 'w', WRITE_TO_FILE = 'w',
LOAD_FROM_FILE = 'l', LOAD_FROM_FILE = 'l',
EXPORT_AS_CSV = 'e',
UP = 'k', UP = 'k',
DOWN = 'j', DOWN = 'j',
@@ -60,9 +59,9 @@ void initialize_curses(int *width, int *height) {
*height = th; *height = th;
start_color(); start_color();
init_pair(BORDERS_PAIR, BORDERS_PRIMARY, BORDERS_SECONDARY); init_pair(BORDERS_PAIR, COLOR_BLACK, COLOR_WHITE);
init_pair(DEFAULT_PAIR, DEFAULT_PRIMARY, DEFAULT_SECONDARY); init_pair(DEFAULT_PAIR, COLOR_WHITE, COLOR_BLACK);
init_pair(COMPLETED_PAIR, COMPLETED_PRIMARY, COMPLETED_SECONDARY); init_pair(COMPLETED_PAIR, COLOR_BLACK, COLOR_GREEN);
// turn off echoing of keys, and enter cbreak mode, // turn off echoing of keys, and enter cbreak mode,
// where no buffering is performed on keyboard input // where no buffering is performed on keyboard input
cbreak(); cbreak();
@@ -236,22 +235,12 @@ void add_command_handler(int width, int height) {
} }
void view_command_handler(int width, int height, int index) { void view_command_handler(int width, int height, int index) {
// check if the index is out of bounds
if (index < 0 || index >= arrlen(todos)) {
return;
}
TodoItem item = todos[index]; TodoItem item = todos[index];
// create an alert in the middle of the screen // create an alert in the middle of the screen
alert(item.title, width, height); alert(item.title, width, height);
} }
void mark_command_handler(int index) { void mark_command_handler(int index) {
// check if the index is out of bounds
if (index < 0 || index >= arrlen(todos)) {
return;
}
TodoItem item = todos[index]; TodoItem item = todos[index];
todo_mark_item(&item, !item.completed); todo_mark_item(&item, !item.completed);
@@ -263,11 +252,6 @@ void mark_command_handler(int index) {
} }
void remove_command_handler(int index) { void remove_command_handler(int index) {
// check if the index is out of bounds
if (index < 0 || index >= arrlen(todos)) {
return;
}
arrdel(todos, index); arrdel(todos, index);
// set the dirty flag // set the dirty flag
@@ -347,14 +331,6 @@ void load_from_file_handler(void) {
dirty = false; dirty = false;
} }
void export_as_csv_handler(void) {
// create the csv file path
char csv_file_path[MAX_PATH_LENGTH + 5]; // +5 for .csv extension
snprintf(csv_file_path, sizeof(csv_file_path), "%s.csv", SAVE_FILE);
todo_export_as_csv(todos, arrlen(todos), csv_file_path);
}
int main(int argc, char **argv) { int main(int argc, char **argv) {
int terminal_width = 0; int terminal_width = 0;
int terminal_height = 0; int terminal_height = 0;
@@ -399,10 +375,6 @@ int main(int argc, char **argv) {
write_to_file_handler(); write_to_file_handler();
alert("Saved!", terminal_width, terminal_height); alert("Saved!", terminal_width, terminal_height);
break; break;
case EXPORT_AS_CSV:
export_as_csv_handler();
alert("Exported as CSV!", terminal_width, terminal_height);
break;
case ADD: case ADD:
add_command_handler(terminal_width, terminal_height); add_command_handler(terminal_width, terminal_height);
break; break;