handle message working, mutation of self working, draw not working
This commit is contained in:
50
utils.scm
50
utils.scm
@@ -2,8 +2,12 @@
|
||||
|
||||
;s-string->theme-info
|
||||
(define s-string->theme-info (lambda (str)
|
||||
;split by : and then \x1F
|
||||
(display "placeholder")
|
||||
;split by : then \x1F
|
||||
(apply make-theme-info (map (lambda (s)
|
||||
(map string->number (split-string s #\x1F -1))
|
||||
)
|
||||
(split-string str #\: -1)
|
||||
))
|
||||
))
|
||||
|
||||
(define s-bool->string (lambda (b)
|
||||
@@ -21,14 +25,20 @@
|
||||
)
|
||||
))
|
||||
|
||||
;todo: generalise to more types
|
||||
(define s-list->string (lambda (li)
|
||||
(join-string (map number->string li) "\x1F;")
|
||||
(join-string (map (lambda (t)
|
||||
(if (string? t)
|
||||
t
|
||||
(number->string t)
|
||||
)
|
||||
) li) "\x1F;")
|
||||
))
|
||||
|
||||
;max should be 0 if no max is desired
|
||||
;max should be -1 if no max is desired
|
||||
(define split-string (lambda (str split-char max)
|
||||
(define split-string-tail (lambda (chars current splitted)
|
||||
(if (or (= (length chars) 0) (= (+ (length splitted) 1) max))
|
||||
(if (or (= (length chars) 0) (= (length splitted) max))
|
||||
(reverse (cons current splitted))
|
||||
(let (
|
||||
[c (car chars)]
|
||||
@@ -42,5 +52,31 @@
|
||||
))
|
||||
|
||||
(define s-string->list (lambda (str)
|
||||
(split-string str #\x1F 0)
|
||||
))
|
||||
(split-string str #\x1F -1)
|
||||
))
|
||||
|
||||
(define s-option->string (lambda (opt)
|
||||
(if (not opt)
|
||||
;None
|
||||
"N"
|
||||
;Some
|
||||
(string-append "S" (number->string opt))
|
||||
)
|
||||
))
|
||||
|
||||
(define draw-instructions-text (lambda (point fonts text colour bg-colour option-horiz-spacing option-mono-width)
|
||||
;Text(Point, Vec<String>, String, RGBColor, RGBColor, Option<usize>, Option<u8>), //font and text
|
||||
(string-append "Text/\x1E;" (s-list->string point) (s-list->string fonts) text (s-list->string colour) (s-list->string bg-colour) (s-option->string option-horiz-spacing) (s-option->string option-mono-width))
|
||||
))
|
||||
|
||||
(define is-escape (lambda (c)
|
||||
(string=? c "𐘃")
|
||||
))
|
||||
|
||||
(define is-enter (lambda (c)
|
||||
(string=? c "𐘂")
|
||||
))
|
||||
|
||||
(define is-backspace (lambda (c)
|
||||
(string=? c "𐘁")
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user