diff --git a/format.scm b/format.scm new file mode 100644 index 0000000..bcafeb2 --- /dev/null +++ b/format.scm @@ -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) diff --git a/test-breadline.scm b/test-breadline.scm new file mode 100644 index 0000000..a0179b4 --- /dev/null +++ b/test-breadline.scm @@ -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)))) diff --git a/test-fmt.scm b/test-fmt.scm new file mode 100644 index 0000000..065ab5b --- /dev/null +++ b/test-fmt.scm @@ -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") "."))) + diff --git a/world.scm b/world.scm index 84148ea..7bd7fb9 100644 --- a/world.scm +++ b/world.scm @@ -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)