summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2026-04-24 18:12:37 -0400
committerJonathan Bradley <jcb@pikum.xyz>2026-04-24 18:12:37 -0400
commit8b222c9e59a41220ef69d2244544c13ca7f88c60 (patch)
tree5e95cfd3b454f7c9b0dbfcca4afe9b9899266158
parenta4f4ee9420857e385c6aca00526ae881afcca640 (diff)
convert build to Makefile, bump versionHEADmaster
-rw-r--r--.gitignore3
-rw-r--r--LICENSE21
-rw-r--r--Makefile45
-rw-r--r--README.md67
-rw-r--r--config.def.h4
-rw-r--r--config.mk20
-rw-r--r--[-rwxr-xr-x]spreed.c12
7 files changed, 162 insertions, 10 deletions
diff --git a/.gitignore b/.gitignore
index 5dee528..f08441c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,4 @@
/spreed
+config.h
+*.tar
+*.zst
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..2bfa808
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+© 2026 Jonathan Bradley <jcb@pikum.xyz>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..f81e596
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,45 @@
+# spreed - speed reader
+
+include config.mk
+
+SRC = spreed.c
+OBJ = $(SRC:.c=.o)
+
+all: options spreed
+
+options:
+ @echo spreed build options:
+ @echo "CFLAGS = $(CFLAGS)"
+ @echo "LDFLAGS = $(LDFLAGS)"
+ @echo "CC = $(CC)"
+
+.c.o:
+ $(CC) -c $(CFLAGS) $<
+
+config.h:
+ cp config.def.h $@
+
+$(OBJ): config.h config.mk
+
+spreed: spreed.o
+ $(CC) -o $@ spreed.o $(LDFLAGS)
+
+clean:
+ rm -f spreed $(OBJ)
+
+dist: clean
+ mkdir -p spreed-$(VERSION)
+ cp LICENSE Makefile config.def.h config.mk $(SRC)\
+ spreed-$(VERSION)
+ tar --zstd -cf spreed-$(VERSION).tar.zst spreed-$(VERSION)
+ rm -rf spreed-$(VERSION)
+
+install: spreed
+ mkdir -p $(DESTDIR)$(PREFIX)/$(BIN)
+ cp -f spreed $(DESTDIR)$(PREFIX)/$(BIN)
+ chmod 755 $(DESTDIR)$(PREFIX)/$(BIN)/spreed
+
+uninstall:
+ rm -f $(DESTDIR)$(PREFIX)/bin/spreed
+
+.PHONY: all options clean install uninstall
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..f5da090
--- /dev/null
+++ b/README.md
@@ -0,0 +1,67 @@
+# spreed - speed reader
+
+`spreed` is a simple speed reader.
+
+# Usage
+
+`spreed` reads plain text from stdin with a default speed of 250 WPM.
+
+## Calling
+
+```sh
+echo "this is some test text." | spreed
+```
+
+```sh
+spreed < text.txt
+```
+
+## Options
+
+WPM may be set in one of two ways:
+
+env:
+```sh
+env SPREED_WPM=400 spreed < text.txt
+```
+
+argument:
+```sh
+spreed 400 < text.txt
+```
+
+Note: Argument takes precedence over environment variable.
+
+## Quirks
+
+`spreed` attempts to pause at the end of a sentence.
+This word should stay visible for twice as long as normal words.
+
+# Limitations
+
+- WPM is hard-coded to not exceed 1800.
+ - This was chosen arbitrarily.
+ - The program could certainly handle faster, however 1800 WPM is 30fps.
+ - If you have a use-case requiring >1800 WPM, please submit a patch with an explanation and I will review.
+- Does __*not*__ handle anything other than plain text (no pdf, epub, etc).
+- Writes 48 columns wide
+ - There are ~10 columns of padding at the start of the line.
+ - Words longer than the remaining ~37 characters will be split between multiple lines.
+- Preliminary support for languages other than English
+ - May not behave as expected, especially in regards to punctuation.
+- May not behave as expected on 32-bit systems (untested).
+
+# Installation
+
+Generate and edit config.h to customize program settings.
+
+```sh
+make config.h
+```
+
+Default installation is to `/usr/local/bin/spreed`
+
+To install to a custom location (e.g. $HOME/.bin), do:
+```sh
+make clean install BIN=.bin DESTDIR=$HOME PREFIX=
+```
diff --git a/config.def.h b/config.def.h
new file mode 100644
index 0000000..8e50baa
--- /dev/null
+++ b/config.def.h
@@ -0,0 +1,4 @@
+
+#define CLR_FG L"\033[31m"
+#define CLR_RESET L"\033[0m"
+#define SPRD_CLOCK CLOCK_MONOTONIC
diff --git a/config.mk b/config.mk
new file mode 100644
index 0000000..9a21e69
--- /dev/null
+++ b/config.mk
@@ -0,0 +1,20 @@
+# spreed version
+VERSION = 0.2
+
+# paths
+BIN = bin
+PREFIX = /usr/local
+MANPREFIX = $(PREFIX)/share/man
+
+# includes and libs
+INCS =
+LIBS =
+
+# flags
+CFLAGS = -std=c99 -pedantic -Wall -O2 $(INCS)\
+ -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION)\"\
+ -DLVERSION=L\"$(VERSION)\"
+LDFLAGS = -s $(LIBS)
+
+# compiler and linker
+CC ?= /usr/bin/gcc
diff --git a/spreed.c b/spreed.c
index a646e4f..b06090e 100755..100644
--- a/spreed.c
+++ b/spreed.c
@@ -1,9 +1,5 @@
-#if 0
-${CC:-gcc} -s -O2 -std=c99 -Wall -o ${SPREED_INSTALL_DIR:-.}/spreed spreed.c
-exit
-#endif
-#define _POSIX_C_SOURCE 200809L
+#include "config.h"
#include <locale.h> // setlocale
#include <stdio.h> // getchar, stdin/out/err
@@ -13,10 +9,6 @@ exit
#include <wchar.h> // fwide, mbrtowc, putwchar
#include <wctype.h> // iswprint, iswspace, iswalnum
-#define SPRD_VER L"0.1"
-#define CLR_FG L"\033[31m"
-#define CLR_RESET L"\033[0m"
-#define SPRD_CLOCK CLOCK_MONOTONIC
#define MS_PER_MIN (60ll * 1000000000ll)
#define SPRD_CLOCK_DIFF(t1, t2) ((((long int)t1.tv_sec * 1000000000ll) + (long int)t1.tv_nsec) - (((long int)t2.tv_sec * 1000000000ll) + (long int)t2.tv_nsec))
@@ -53,7 +45,7 @@ int main(int argc, char *argv[])
if (argc > 1) {
if (strstr(argv[1], "-v") || strstr(argv[1], "--v") || strstr(argv[1], "-V") || strstr(argv[1], "--V")) {
- c = fputws(L"spreed version " SPRD_VER L"\n", stdout);
+ c = fputws(L"spreed version " LVERSION L"\n", stdout);
if (c == EOF) {
perror("fputws()");
}