summaryrefslogtreecommitdiff
path: root/stickers.scm
diff options
context:
space:
mode:
authorEkaitz Zarraga <ekaitz@elenq.tech>2024-10-09 16:47:48 +0200
committerEkaitz Zarraga <ekaitz@elenq.tech>2024-10-09 16:47:48 +0200
commita687bf48be1f3b0447dedb0fb7861b9e51644b2a (patch)
treef7dc21b30ff2eb9cb1cefc9d4ac738bf2c0e4795 /stickers.scm
parentffdcc34a9e7680aad1f46ab0bfb9472aa2d2e36b (diff)
Simplify config as `load`HEADmaster
Diffstat (limited to 'stickers.scm')
-rw-r--r--stickers.scm67
1 files changed, 55 insertions, 12 deletions
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 <config>
+ (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>
- (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>
- (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)