From 6eeea2f1f38152a4fe651e60f60818e22b64f478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Pant=C5=AF=C4=8Dek?= Date: Wed, 22 Mar 2023 17:00:14 +0100 Subject: [PATCH] Work on table rendering and integrate it. --- Makefile | 22 ++++++++++++++-------- table.scm | 20 +++++++++++++++++++- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 6df01f2..8a13d33 100644 --- a/Makefile +++ b/Makefile @@ -37,27 +37,27 @@ all: imports shared static CSC=csc -BBSTOOL-DEPS=bbstool.scm testing.import.scm listing.import.scm \ +BBSTOOL-DEPS=bbstool.scm testing.import.scm listing.import.scm \ dictionary.import.scm month.import.scm period.import.scm \ ansi.import.scm member-file.import.scm \ command-line.import.scm members-base.import.scm \ utils.import.scm primes.import.scm member-record.import.scm \ - configuration.import.scm progress.import.scm + configuration.import.scm progress.import.scm table.import.scm -BBSTOOL-SOURCES=bbstool.scm testing.scm listing.scm \ - dictionary.scm month.scm period.scm ansi.scm member-file.scm \ +BBSTOOL-SOURCES=bbstool.scm testing.scm listing.scm dictionary.scm \ + month.scm period.scm ansi.scm member-file.scm \ command-line.scm members-base.scm utils.scm primes.scm \ - member-record.scm configuration.scm progress.scm + member-record.scm configuration.scm progress.scm table.scm BBSTOOL-OBJS=testing.o listing.o month.o period.o ansi.o \ member-file.o dictionary.o command-line.o \ members-base.o utils.o primes.o member-record.o \ - configuration.o progress.o + configuration.o progress.o table.o -BBSTOOL-SHARED=testing.so listing.so month.so period.so ansi.so \ +BBSTOOL-SHARED=testing.so listing.so month.so period.so ansi.so \ member-file.so dictionary.so command-line.so \ members-base.so utils.so primes.so member-record.so \ - configuration.so progress.so + configuration.so progress.so table.so .PHONY: imports imports: $(BBSTOOL-DEPS) @@ -181,3 +181,9 @@ PROGRESS-SOURCES=progress.scm progress.so: progress.o progress.o: progress.import.scm progress.import.scm: $(PROGRESS-SOURCES) + +TABLE-SOURCES=table.scm ansi.import.scm testing.import.scm + +table.so: table.o +table.o: table.import.scm +table.import.scm: $(TABLE-SOURCES) diff --git a/table.scm b/table.scm index 91eea23..89caad6 100644 --- a/table.scm +++ b/table.scm @@ -35,6 +35,7 @@ (chicken base) (chicken string) (chicken format) + (chicken keyword) ansi testing) @@ -153,8 +154,25 @@ (table-stringify (table-rectangularize tbl)))))) + ;; Table border styles in visual form + (define table-borders-lookup-source + '((ascii "/~,\\" + "| ||" + ">-+<" + "'~^`"))) + + ;; Compiled table borders for rendering + (define table-borders-lookup + (map (lambda (src) + (cons (car src) (apply string-join (cdr src)))) + table-borders-lookup-source)) + (define (table->string tbl . args) - "") + (let ((table-border (get-keyword #:table-border args (lambda () #f))) + (cell-border (get-keyword #:cell-border args (lambda () #f))) + (border-style (get-keyword #:border-style args (lambda () 'ascii))) + (table (table-prepare tbl))) + "")) ;; Performs module self-tests (define (table-tests!)