refactor: rename window state to state

This commit is contained in:
2026-10-04 12:03:48 -07:00
parent d14436bb38
commit 190b220391
4 changed files with 18 additions and 16 deletions
+7 -7
View File
@@ -1,11 +1,11 @@
CC = cc CC = cc
CFLAGS = -g -Wall -Iinclude -I/opt/homebrew/include CFLAGS = -g -Wall -Iinclude -I/opt/homebrew/include
SOURCES = src/main.c src/window_state.c SOURCES = src/main.c src/state.c
OBJECTS = src/main.o src/window_state.o OBJECTS = src/main.o src/state.o
LDFLAGS = -L/opt/homebrew/lib LDFLAGS = -L/opt/homebrew/lib
LDLIBS = -lraylib -lm -lsqlite3 LDLIBS = -lraylib -lm -lsqlite3
HEADERS = \ HEADERS = \
include/raygui.h include/common.h include/window_state.h include/raygui.h include/common.h include/state.h
PREFIX ?= /usr/local PREFIX ?= /usr/local
BINDIR := $(PREFIX)/bin BINDIR := $(PREFIX)/bin
@@ -16,14 +16,14 @@ BINDIR := $(PREFIX)/bin
# %.o: %.c $(HEADERS) # %.o: %.c $(HEADERS)
# $(CC) $(CFLAGS) -c $< -o $@ # $(CC) $(CFLAGS) -c $< -o $@
adhd: src/main.o src/window_state.o adhd: src/main.o src/state.o
$(CC) $(CFLAGS) src/main.o src/window_state.o -o $@ $(LDFLAGS) $(LDLIBS) $(CC) $(CFLAGS) src/main.o src/state.o -o $@ $(LDFLAGS) $(LDLIBS)
src/main.o: src/main.c $(HEADERS) src/main.o: src/main.c $(HEADERS)
$(CC) -c $(CFLAGS) src/main.c -o $@ $(CC) -c $(CFLAGS) src/main.c -o $@
src/window_state.o: src/window_state.c $(HEADERS) src/state.o: src/state.c $(HEADERS)
$(CC) -c $(CFLAGS) src/window_state.c -o $@ $(CC) -c $(CFLAGS) src/state.c -o $@
clean: clean:
rm -rf $(OBJECTS) adhd rm -rf $(OBJECTS) adhd
+4 -4
View File
@@ -1,5 +1,5 @@
#ifndef WINDOWSTATE_H #ifndef STATE_H
#define WINDOWSTATE_H #define STATE_H
#include "common.h" #include "common.h"
#include <stddef.h> #include <stddef.h>
@@ -11,8 +11,8 @@ enum mode_t {
}; };
typedef enum mode_t Mode; typedef enum mode_t Mode;
void init_window_state(); void init_state();
void cleanup_window_state(); void cleanup_state();
void set_intention(char *intention); void set_intention(char *intention);
char *get_intention(); char *get_intention();
+4 -2
View File
@@ -6,7 +6,7 @@
#define RAYGUI_IMPLEMENTATION #define RAYGUI_IMPLEMENTATION
#include <raygui.h> #include <raygui.h>
#include <raylib.h> #include <raylib.h>
#include "window_state.h" #include "state.h"
#include "common.h" #include "common.h"
#define WINDOW_HEIGHT 700 #define WINDOW_HEIGHT 700
@@ -170,7 +170,7 @@ int main(int argc, char *argv[]) {
localtime_r(&now, &local_time); localtime_r(&now, &local_time);
mktime(&local_time); mktime(&local_time);
init_window_state(); init_state();
printf("Welcome to Flowy.adhd\n"); printf("Welcome to Flowy.adhd\n");
@@ -190,5 +190,7 @@ int main(int argc, char *argv[]) {
CloseWindow(); CloseWindow();
cleanup_state();
return 0; return 0;
} }
+3 -3
View File
@@ -1,4 +1,4 @@
#include "window_state.h" #include "state.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@@ -101,7 +101,7 @@ static void db_get_all_records() {
assert(rc == SQLITE_OK); assert(rc == SQLITE_OK);
} }
void init_window_state() { void init_state() {
s = malloc(sizeof(struct state)); s = malloc(sizeof(struct state));
s->mode = WINDOW; s->mode = WINDOW;
@@ -170,7 +170,7 @@ static void generate_key(struct tm *time, char *buffer, size_t buffer_size) {
snprintf(buffer, buffer_size, "%d", time->tm_yday); snprintf(buffer, buffer_size, "%d", time->tm_yday);
} }
void cleanup_window_state() { void cleanup_state() {
if (!s) { if (!s) {
return; return;
} }