Compare commits
54 Commits
main
...
14cc20f6c3
| Author | SHA1 | Date | |
|---|---|---|---|
|
14cc20f6c3
|
|||
|
|
25ef59e7f3 | ||
|
|
9414db11e1
|
||
|
|
6513a73ce4
|
||
|
|
5d32c49557
|
||
|
|
1e1d6b9115
|
||
|
|
ec8d491e6f
|
||
|
|
278b11f1c1
|
||
|
|
677bd89362 | ||
|
|
537f57a3b2 | ||
|
|
49c403cf63 | ||
|
|
31831d29d7 | ||
|
|
e35ba14b19 | ||
|
|
1c1ab9d29b | ||
|
|
8a114acc71 | ||
|
|
aa25ef9a6a | ||
|
|
6ec4aebf2a | ||
|
|
481d853ebc | ||
|
|
895abb1f0b | ||
|
|
0ef406e59c | ||
|
|
3e02cfe363 | ||
|
|
05adbf5d33 | ||
|
|
705f989737 | ||
|
|
90991e7401 | ||
|
|
694a71362d | ||
|
|
60f5e2af3e | ||
|
|
ec9a455a49 | ||
|
|
40f2155a34 | ||
|
|
668dd69ac0 | ||
|
|
758300b704 | ||
|
|
b73e47e590 | ||
|
|
c5ba5e8bfa | ||
|
|
0e709a08e2 | ||
|
|
1914119412 | ||
|
|
2dd52012a7 | ||
|
|
4c1d6a3f79 | ||
|
|
691045186f | ||
|
|
87d220912e | ||
|
|
4049d732bb | ||
|
|
0efd48dd6f | ||
|
|
5fbf6bed11 | ||
|
|
8a649463c5 | ||
|
|
aa3502dc7b | ||
|
|
44a7c3aacc | ||
|
|
f0aa6758dc | ||
|
|
13ebbcd049 | ||
|
|
1a45b1e219 | ||
|
|
aa851fad3a | ||
|
|
a89a330ede | ||
|
|
38ca5234ca | ||
|
|
a4319c5b38 | ||
|
|
f152a85d8a | ||
|
|
dd7c5d0a1c | ||
|
|
9e0ff21192 |
74
.github/workflows/build.yml
vendored
Normal file
74
.github/workflows/build.yml
vendored
Normal 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
|
||||
6
Makefile
6
Makefile
@@ -1,7 +1,7 @@
|
||||
.DEFAULT_GOAL := all
|
||||
|
||||
CC=gcc
|
||||
CFLAGS=-Wall -Wextra -Werror -pedantic -std=c99 -O3
|
||||
CFLAGS=-Wall -Wextra -Werror -pedantic -std=c99 -g
|
||||
|
||||
todo.o:
|
||||
$(CC) $(CFLAGS) -c engine/todo.c -o todo.o
|
||||
@@ -12,6 +12,7 @@ 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
|
||||
@@ -20,6 +21,3 @@ all: todd
|
||||
|
||||
install: todd
|
||||
cp todd /usr/local/bin/todd
|
||||
|
||||
uninstall:
|
||||
rm /usr/local/bin/todd || true
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "todo.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
// Memory management
|
||||
@@ -55,20 +54,3 @@ 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);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#define TODO_H
|
||||
#define TODO_MAX_TITLE_LENGTH 255
|
||||
|
||||
#define true 1
|
||||
#define false 0
|
||||
typedef unsigned char bool_t;
|
||||
|
||||
typedef struct {
|
||||
@@ -20,7 +22,4 @@ 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
|
||||
|
||||
30
main.c
30
main.c
@@ -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 [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;
|
||||
char SAVE_FILE[MAX_PATH_LENGTH] = "";
|
||||
@@ -32,7 +32,6 @@ enum Command {
|
||||
|
||||
WRITE_TO_FILE = 'w',
|
||||
LOAD_FROM_FILE = 'l',
|
||||
EXPORT_AS_CSV = 'e',
|
||||
|
||||
UP = 'k',
|
||||
DOWN = 'j',
|
||||
@@ -236,22 +235,12 @@ 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);
|
||||
@@ -263,11 +252,6 @@ 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
|
||||
@@ -347,14 +331,6 @@ 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;
|
||||
@@ -399,10 +375,6 @@ 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;
|
||||
|
||||
Reference in New Issue
Block a user