This commit is contained in:
whiteline 2022-10-11 23:18:30 +02:00
parent 0ccdb42173
commit 4baee01dc6
4 changed files with 137 additions and 2 deletions

117
format.scm Normal file
View File

@ -0,0 +1,117 @@
(module format (terminal-code-reset terminal-code-bold terminal-code-fg-red)
(import scheme)
(import (chicken base))
(import matchable)
(define (terminal-code str)
(string-append "\u001b[" str "m"))
(define terminal-code-reset
(terminal-code "0"))
(define terminal-code-bold
(terminal-code "1"))
(define terminal-code-fg-black
(terminal-code "30"))
(define terminal-code-fg-red
(terminal-code "31"))
(define terminal-code-fg-green
(terminal-code "32"))
(define terminal-code-fg-yellow
(terminal-code "33"))
(define terminal-code-fg-blue
(terminal-code "34"))
(define terminal-code-fg-magenta
(terminal-code "35"))
(define terminal-code-fg-cyan
(terminal-code "36"))
(define terminal-code-fg-white
(terminal-code "37"))
(define terminal-code-fg-bright-black
(terminal-code "30;1"))
(define terminal-code-fg-bright-red
(terminal-code "31;1"))
(define terminal-code-fg-bright-green
(terminal-code "32;1"))
(define terminal-code-fg-bright-yellow
(terminal-code "33;1"))
(define terminal-code-fg-bright-blue
(terminal-code "34;1"))
(define terminal-code-fg-bright-magenta
(terminal-code "35;1"))
(define terminal-code-fg-bright-cyan
(terminal-code "36;1"))
(define terminal-code-fg-bright-white
(terminal-code "37;1"))
(define terminal-code-bg-black
(terminal-code "40"))
(define terminal-code-bg-red
(terminal-code "41"))
(define terminal-code-bg-green
(terminal-code "42"))
(define terminal-code-bg-yellow
(terminal-code "43"))
(define terminal-code-bg-blue
(terminal-code "44"))
(define terminal-code-bg-magenta
(terminal-code "45"))
(define terminal-code-bg-cyan
(terminal-code "46"))
(define terminal-code-bg-white
(terminal-code "47"))
(define terminal-code-bg-bright-black
(terminal-code "40;1"))
(define terminal-code-bg-bright-red
(terminal-code "41;1"))
(define terminal-code-bg-bright-green
(terminal-code "42;1"))
(define terminal-code-bg-bright-yellow
(terminal-code "43;1"))
(define terminal-code-bg-bright-blue
(terminal-code "44;1"))
(define terminal-code-bg-bright-magenta
(terminal-code "45;1"))
(define terminal-code-bg-bright-cyan
(terminal-code "46;1"))
(define terminal-code-bg-bright-white
(terminal-code "47;1"))
(define (format str)
(let loop (input result state)
(if (null? input)
(list->string (reverse result))
(match (cons (car input) state)
((#\< . 'text) (loop (cdr input) result 'enter-tag))
((#\b . 'enter-tag) (loop (cdr input)

13
test-breadline.scm Normal file
View File

@ -0,0 +1,13 @@
(import breadline)
(import fmt)
(import fmt-color)
(let loop ()
(let ((input (readline (fmt #f (fmt-bold (fmt-magenta "> "))))))
(if input
(begin
(display input)
(newline)
(add-history! input)
(loop))
(newline))))

5
test-fmt.scm Normal file
View File

@ -0,0 +1,5 @@
(import fmt)
(import fmt-color)
(fmt #t (dsp (wrap-lines "The fairy soldiers wore uniforms patterned in " (fmt-bold (fmt-green "green")) " and " (fmt-bold (fmt-red "red")) " checkerboard patterns and carried large halberds inlaid with " (fmt-bold "silver") " and " (fmt-yellow "gold") ".")))

View File

@ -6,8 +6,8 @@
(module world (adventure create-object move-object add-alias set-hidden toggle-fixed set-enter-message set-destination get-container print-room-description)
(import scheme)
(import chicken.base)
(import chicken.file)
(import (chicken base))
(import (chicken file))
(import srfi-1)
(import matchable)
(import fmt)