aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-02-13 21:16:12 +0100
committerbptato <nincsnevem662@gmail.com>2024-02-25 02:46:21 +0100
commit6e98894199442e2213dc89e0c5fe970029f05b65 (patch)
tree57bf69a6fa825d72be1654482e8865b5e9b82829 /Makefile
parentd41d4803b5ed15b7e8461394ee07ce5ab1de143a (diff)
downloadchawan-6e98894199442e2213dc89e0c5fe970029f05b65.tar.gz
Separate ANSI text decoding from main binary
Handling text/plain as ANSI colored text was problematic for two reasons: * You couldn't actually look at the real source of HTML pages or text files that used ANSI colors in the source. In general, I only want ANSI colors when piping something into my pager, not when viewing any random file. * More importantly, it introduced a separate rendering mode for plaintext documents, which resulted in the problem that only some buffers had DOMs. This made it impossible to add functionality that would operate on the buffer's DOM, to e.g. implement w3m's MARK_URL. Also, it locked us into the horribly inefficient line-based rendering model of entire documents. Now we solve the problem in two separate parts: * text/x-ansi is used automatically for documents received through stdin. A text/x-ansi handler ansi2html converts ANSI formatting to HTML. text/x-ansi is also used for .ans, .asc file extensions. * text/plain is a separate input mode in buffer, which places all text in a single <plaintext> tag. Crucially, this does not invoke the HTML parser; that would eat NUL characters, which we should avoid. One blind spot still remains: copiousoutput used to display ANSI colors, and now it doesn't. To solve this, users can put the x-ansioutput extension field to their mailcap entries, which behaves like x-htmloutput except it first pipes the output into ansi2html.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile10
1 files changed, 9 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 1f4c0f97..2add0049 100644
--- a/Makefile
+++ b/Makefile
@@ -46,7 +46,7 @@ all: $(OUTDIR_BIN)/cha $(OUTDIR_BIN)/mancha $(OUTDIR_CGI_BIN)/http \
$(OUTDIR_CGI_BIN)/data $(OUTDIR_CGI_BIN)/file $(OUTDIR_CGI_BIN)/ftp \
$(OUTDIR_CGI_BIN)/man $(OUTDIR_CGI_BIN)/spartan \
$(OUTDIR_LIBEXEC)/urldec $(OUTDIR_LIBEXEC)/urlenc \
- $(OUTDIR_LIBEXEC)/md2html
+ $(OUTDIR_LIBEXEC)/md2html $(OUTDIR_LIBEXEC)/ansi2html
$(OUTDIR_BIN)/cha: lib/libquickjs.a src/*.nim src/**/*.nim src/**/*.c res/* \
res/**/* res/map/idna_gen.nim nim.cfg
@@ -87,6 +87,12 @@ $(OUTDIR_LIBEXEC)/md2html: adapter/format/md2html.nim
$(NIMC) $(FLAGS) --nimcache:"$(OBJDIR)/$(TARGET)/md2html" \
-o:"$(OUTDIR_LIBEXEC)/md2html" adapter/format/md2html.nim
+$(OUTDIR_LIBEXEC)/ansi2html: adapter/format/ansi2html.nim src/io/posixstream.nim \
+ src/types/color.nim src/utils/twtstr.nim
+ @mkdir -p "$(OUTDIR_LIBEXEC)"
+ $(NIMC) $(FLAGS) --nimcache:"$(OBJDIR)/$(TARGET)/ansi2html" \
+ -o:"$(OUTDIR_LIBEXEC)/ansi2html" adapter/format/ansi2html.nim
+
GMIFETCH_CFLAGS = -Wall -Wextra -std=c89 -pedantic -lcrypto -lssl -g -O3
$(OUTDIR_CGI_BIN)/gmifetch: adapter/protocol/gmifetch.c
@mkdir -p "$(OUTDIR_CGI_BIN)"
@@ -224,6 +230,7 @@ install:
install -m755 "$(OUTDIR_CGI_BIN)/gopher" $(LIBEXECDIR_CHAWAN)/cgi-bin
install -m755 "$(OUTDIR_LIBEXEC)/gopher2html" $(LIBEXECDIR_CHAWAN)
install -m755 "$(OUTDIR_LIBEXEC)/md2html" $(LIBEXECDIR_CHAWAN)
+ install -m755 "$(OUTDIR_LIBEXEC)/ansi2html" $(LIBEXECDIR_CHAWAN)
install -m755 "$(OUTDIR_LIBEXEC)/gmi2html" $(LIBEXECDIR_CHAWAN)
install -m755 "$(OUTDIR_CGI_BIN)/gmifetch" $(LIBEXECDIR_CHAWAN)/cgi-bin
install -m755 "$(OUTDIR_CGI_BIN)/cha-finger" $(LIBEXECDIR_CHAWAN)/cgi-bin
@@ -262,6 +269,7 @@ uninstall:
rmdir $(LIBEXECDIR_CHAWAN)/cgi-bin || true
rm -f $(LIBEXECDIR_CHAWAN)/gopher2html
rm -f $(LIBEXECDIR_CHAWAN)/md2html
+ rm -f $(LIBEXECDIR_CHAWAN)/ansi2html
rm -f $(LIBEXECDIR_CHAWAN)/gmi2html
rm -f $(LIBEXECDIR_CHAWAN)/urldec
rm -f $(LIBEXECDIR_CHAWAN)/urlenc