From a687bf48be1f3b0447dedb0fb7861b9e51644b2a Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Wed, 9 Oct 2024 16:47:48 +0200 Subject: Simplify config as `load` --- stickers.scm | 67 +++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 55 insertions(+), 12 deletions(-) (limited to 'stickers.scm') diff --git a/stickers.scm b/stickers.scm index 31c63af..f818ec2 100644 --- a/stickers.scm +++ b/stickers.scm @@ -1,5 +1,6 @@ ; Generate keys (import (scheme char) + (scheme eval) (chibi) (chibi string) (chibi sxml) @@ -7,8 +8,38 @@ (srfi 9) (srfi 41)) +(define a4-size '(297 . 210)) +(define a5-size '(210 . 148)) +(define a6-size '(148 . 105)) +(define a7-size '(105 . 74)) +;https://unicode-table.com/en/2B7E/ +(define es-chars (string->list "ABCDEFGHIJKLMNÑOPQRSTUVWXYZ")) +(define en-chars (string->list "ABCDEFGHIJKLMNOPQRSTUVWXYZ")) +(define uk-chars (string->list "АБВГҐДЕЄЖЗИІЇЙКЛМНОПРСТУФХЦЧШЩЬЮЯ")) +(define ru-chars (string->list "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ" )) +(define numbers (string->list "1234567890")) +(define brackets (string->list "()[]{}<>")) +(define punct (string->list ",.:;_")) +(define symbols (string->list "\\|@#~$%&^`´\"'")) +(define math (string->list "+-*/=")) +(define tab (list "⇥")) +(define backspace (list "⟵")) +(define arrows (string->list "←↑→↓")) +(define upcase (string->list "⇧⇧⇪")) +(define enter (list "⏎")) +(define modifiers (list "Ctrl" "Ctrl" "Alt" "AltGr" "Esc" "Del" "Fn")) +(define pagers (list "PgUp" "PgDn")) +(define media (string->list "")) + +(define-record-type + (make-config page-size sticker-radius stickers) + config? + (page-size config-page-size set-config-page-size!) + (sticker-radius config-sticker-radius set-config-sticker-radius!) + (stickers config-stickers set-config-stickers!)) + (define-record-type - (glyph char font size color style) + (make-glyph char font size color style) glyph? (char glyph-char glyph-set-char!) (font glyph-font glyph-set-font!) @@ -17,28 +48,40 @@ (style glyph-style glyph-set-style!)) (define-record-type - (path contents size color) + (make-path contents size color) path? (contents path-contents path-contents!) (size path-size path-set-size!) (color path-color path-set-color!)) - (define args (cdr (command-line))) (define INFILE (first args)) (define OUTFILE (second args)) -(define a4-size '(297 . 210)) -(define a5-size '(210 . 148)) -(define a6-size '(148 . 105)) -(define a7-size '(105 . 74)) - -;; INFILE HAS TO DEFINE THESE TWO VALUES -;; (define sticker-radius 3.82); mm -;; (define page-size a7-size) ;; 96 Stickers at this size -(load INFILE) +(define (load* file) + "Eval the file in current environment" + (let ((code (call-with-input-file file + (lambda (p) + (let loop ((x (read p))) + (if (eof-object? x) + '() + (cons x (loop (read p))))))))) + (let loop ((l code)) + (let* ((cur (car l)) + (next (cdr l)) + (x (eval cur))) + (if (null? next) + x + (loop next)))))) + +;; Needs to return a config file +(define config (load* INFILE)) + +(define sticker-radius (config-sticker-radius config)) +(define page-size (config-page-size config)) +(define glyphs (config-stickers config)) (define x car) (define y cdr) -- cgit v1.2.3