Compare commits

60 Commits
v1.0.0 ... main

Author SHA1 Message Date
e97e106001 add csv export 2025-12-22 04:03:26 +01:00
6862af407e add uninstall task 2025-09-18 01:59:12 +02:00
6a8bb3f5d4 use stdbool for true/false 2025-09-18 01:59:04 +02:00
557a4affa6 add -O3 to cflags 2025-09-18 01:55:12 +02:00
3b99b87c22 fix index oob segfaults 2025-04-28 02:36:14 +02:00
f40b4001c7 remove github workflows 2024-11-10 01:22:58 +01:00
143feaac83 make ui color configurable through a header file
Some checks failed
Build Todd / build-linux (push) Has been cancelled
Build Todd / build-mac (push) Has been cancelled
Build Todd / build-windows (push) Has been cancelled
2024-11-10 01:21:00 +01:00
972bd28b6f add usage 2024-11-10 01:20:57 +01:00
8421e3ee01 add ncurses to requirements 2024-11-10 01:20:55 +01:00
bda1c18a52 change package name 2024-11-10 01:20:54 +01:00
37cd828c21 add msystem 2024-11-10 01:20:51 +01:00
c746cad281 try out different command name 2024-11-10 01:20:49 +01:00
0abfa4af0f change to correct package name 2024-11-10 01:20:46 +01:00
ceede3001a add windows build again 2024-11-10 01:20:44 +01:00
29eeef56b8 add dirty check 2024-11-10 01:20:42 +01:00
e6203f70a9 remove windows build step 2024-11-10 01:20:41 +01:00
d8a3fe0d7a add windows build step 2024-11-10 01:20:39 +01:00
7c060419f4 add mac build step 2024-11-10 01:20:38 +01:00
c3b1797bd9 upload artifact 2024-11-10 01:20:37 +01:00
e9d8988ef2 fix mvwprintw string literal error 2024-11-10 01:20:35 +01:00
476428b7de remove setup gcc 2024-11-10 01:20:34 +01:00
58eda93cbb remove cache apt pkgs 2024-11-10 01:20:32 +01:00
21a6c077fd set version to string 2024-11-10 01:20:31 +01:00
2e0f7501d7 add other steps 2024-11-10 01:20:29 +01:00
3809b5b96a generate workflow file 2024-11-10 01:20:28 +01:00
79a313a03e start debugging workflow file 2024-11-10 01:20:26 +01:00
c3dee6a8ef copy workflow into correct directory 2024-11-10 01:20:25 +01:00
20d6e4a8b1 add github build action 2024-11-10 01:20:23 +01:00
65d591a455 take height into account 2024-11-10 01:20:22 +01:00
65b5e45cba add view command 2024-11-10 01:20:21 +01:00
e3f807bd7f add licenses 2024-11-10 01:20:19 +01:00
9bd8817797 add proper scroll 2024-11-10 01:20:18 +01:00
e8e0babfaa load file on startup if it exists 2024-11-10 01:20:17 +01:00
3159a34c9a remove unused command 2024-11-10 01:20:15 +01:00
1267fc54bb add install makefile command 2024-11-10 01:20:14 +01:00
613071c8f5 print key bindings on the footer 2024-11-10 01:20:12 +01:00
0cf3febd2b add save file path to the header 2024-11-10 01:20:11 +01:00
76396a3022 store the default file in the home directory dotfile 2024-11-10 01:20:09 +01:00
e900ffc0d7 add todo count in the bottom bar 2024-11-10 01:20:08 +01:00
dd148396f1 add space key for marking todos 2024-11-10 01:20:06 +01:00
71939366c7 allow arrow input 2024-11-10 01:20:05 +01:00
a5734d1323 add a semi-functional TUI 2024-11-10 01:20:03 +01:00
14f177e3f9 fix build errors 2024-11-10 01:20:02 +01:00
881d13b546 add cflags 2024-11-10 01:20:00 +01:00
a852107b62 update makefile 2024-11-10 01:19:59 +01:00
3acbe3eb33 update readme 2024-11-10 01:19:57 +01:00
672998b17b format the code 2024-11-10 01:19:56 +01:00
01e6a6064d free todos after quit 2024-11-10 01:19:54 +01:00
d0ec4b758b update readme 2024-11-10 01:19:52 +01:00
b27047e7d1 implement loading from file 2024-11-10 01:19:51 +01:00
71e935c8ad use stb like a normal person (totally didnt waste an hour) 2024-11-10 01:19:49 +01:00
44a4374fd1 remove llist 2024-11-10 01:19:48 +01:00
76c620c142 steal a linked list implementation 2024-11-10 01:19:46 +01:00
b49b728a4c add todo serialization 2024-11-10 01:19:44 +01:00
bb0c5c173a add makefile 2024-11-10 01:19:43 +01:00
b476873ede add ideas 2024-11-10 01:19:41 +01:00
78a190b28f add readme 2024-11-10 01:19:39 +01:00
21dd4c988e add remove command 2024-11-10 01:19:38 +01:00
e875f6fab3 separate files and fix newline bug 2024-11-10 01:19:36 +01:00
06a0b782cf make stuff work 2024-11-10 01:19:34 +01:00
7 changed files with 77 additions and 83 deletions

View File

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

View File

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

15
color.h Normal file
View File

@@ -0,0 +1,15 @@
#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,6 +1,7 @@
#include "todo.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
// Memory management
@@ -54,3 +55,20 @@ char *todo_item_serialize(TodoItem *item, int *buffer_size_out) {
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,8 +2,6 @@
#define TODO_H
#define TODO_MAX_TITLE_LENGTH 255
#define true 1
#define false 0
typedef unsigned char bool_t;
typedef struct {
@@ -22,4 +20,7 @@ void todo_print_item(TodoItem *item);
// Serialization
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

38
main.c
View File

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