mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +02:00
rename (chibi show) update! to with! as in srfi 159
This commit is contained in:
parent
309c591d66
commit
03544833dc
7 changed files with 21 additions and 19 deletions
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
(define-library (chibi show)
|
(define-library (chibi show)
|
||||||
(export
|
(export
|
||||||
show fn fn-fork with update! each each-in-list call-with-output
|
show fn fn-fork with with! each each-in-list call-with-output
|
||||||
displayed written written-shared written-simply
|
displayed written written-shared written-simply
|
||||||
numeric numeric/comma numeric/si numeric/fitted
|
numeric numeric/comma numeric/si numeric/fitted
|
||||||
nothing nl fl space-to tab-to escaped maybe-escaped
|
nothing nl fl space-to tab-to escaped maybe-escaped
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
(bind: %fn)
|
(bind: %fn)
|
||||||
(bind-fork: fn-fork)
|
(bind-fork: fn-fork)
|
||||||
(local: %with)
|
(local: %with)
|
||||||
(local!: update!)
|
(local!: with!)
|
||||||
(return: return)
|
(return: return)
|
||||||
(run: run)
|
(run: run)
|
||||||
(fields:
|
(fields:
|
||||||
|
@ -75,14 +75,14 @@
|
||||||
|
|
||||||
;; Run with an output port with initial default values.
|
;; Run with an output port with initial default values.
|
||||||
(define (show-run out proc)
|
(define (show-run out proc)
|
||||||
(run (sequence (update! (port out)
|
(run (sequence (with! (port out)
|
||||||
(col 0)
|
(col 0)
|
||||||
(row 0)
|
(row 0)
|
||||||
(width 78)
|
(width 78)
|
||||||
(radix 10)
|
(radix 10)
|
||||||
(pad-char #\space)
|
(pad-char #\space)
|
||||||
(output output-default)
|
(output output-default)
|
||||||
(string-width substring-length))
|
(string-width substring-length))
|
||||||
proc)))
|
proc)))
|
||||||
|
|
||||||
;;> Temporarily bind the parameters in the body \var{x}.
|
;;> Temporarily bind the parameters in the body \var{x}.
|
||||||
|
@ -94,7 +94,7 @@
|
||||||
|
|
||||||
;;> The noop formatter. Generates no output and leaves the state
|
;;> The noop formatter. Generates no output and leaves the state
|
||||||
;;> unmodified.
|
;;> unmodified.
|
||||||
(define nothing (fn () (update!)))
|
(define nothing (fn () (with!)))
|
||||||
|
|
||||||
;;> Formats a displayed version of x - if a string or char, outputs the
|
;;> Formats a displayed version of x - if a string or char, outputs the
|
||||||
;;> raw characters (as with `display'), if x is already a formatter
|
;;> raw characters (as with `display'), if x is already a formatter
|
||||||
|
@ -131,9 +131,9 @@
|
||||||
(display str port)
|
(display str port)
|
||||||
(let ((nl-index (string-find-right str #\newline)))
|
(let ((nl-index (string-find-right str #\newline)))
|
||||||
(if (string-cursor>? nl-index (string-cursor-start str))
|
(if (string-cursor>? nl-index (string-cursor-start str))
|
||||||
(update! (row (+ row (string-count str #\newline)))
|
(with! (row (+ row (string-count str #\newline)))
|
||||||
(col (string-width str (string-cursor->index str nl-index))))
|
(col (string-width str (string-cursor->index str nl-index))))
|
||||||
(update! (col (+ col (string-width str))))))))
|
(with! (col (+ col (string-width str))))))))
|
||||||
|
|
||||||
;;> Captures the output of \var{producer} and formats the result with
|
;;> Captures the output of \var{producer} and formats the result with
|
||||||
;;> \var{consumer}.
|
;;> \var{consumer}.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
(define-library (chibi show base)
|
(define-library (chibi show base)
|
||||||
(export
|
(export
|
||||||
show fn fn-fork with update! each each-in-list call-with-output
|
show fn fn-fork with with! each each-in-list call-with-output
|
||||||
displayed written written-shared written-simply numeric nothing
|
displayed written written-shared written-simply numeric nothing
|
||||||
escaped maybe-escaped numeric/si numeric/fitted numeric/comma
|
escaped maybe-escaped numeric/si numeric/fitted numeric/comma
|
||||||
;; internal
|
;; internal
|
||||||
|
|
|
@ -30,10 +30,10 @@
|
||||||
(let ((nl-index
|
(let ((nl-index
|
||||||
(string-index-right str (lambda (ch) (eqv? ch #\newline)))))
|
(string-index-right str (lambda (ch) (eqv? ch #\newline)))))
|
||||||
(if (string-cursor>? nl-index (string-cursor-start str))
|
(if (string-cursor>? nl-index (string-cursor-start str))
|
||||||
(update!
|
(with!
|
||||||
(row (+ row (string-count str (lambda (ch) (eqv? ch #\newline)))))
|
(row (+ row (string-count str (lambda (ch) (eqv? ch #\newline)))))
|
||||||
(col (string-width str (string-cursor->index str nl-index))))
|
(col (string-width str (string-cursor->index str nl-index))))
|
||||||
(update! (col (+ col (string-width str))))))
|
(with! (col (+ col (string-width str))))))
|
||||||
(call-with-current-continuation
|
(call-with-current-continuation
|
||||||
(lambda (cc)
|
(lambda (cc)
|
||||||
(set! resume cc)
|
(set! resume cc)
|
||||||
|
|
|
@ -223,7 +223,7 @@
|
||||||
(let* ((end (max 0 (- len (- chars-written width))))
|
(let* ((end (max 0 (- len (- chars-written width))))
|
||||||
(s (substring str 0 end)))
|
(s (substring str 0 end)))
|
||||||
(each (output s)
|
(each (output s)
|
||||||
(update! (output orig-output))
|
(with! (output orig-output))
|
||||||
(fn () (return nothing))))
|
(fn () (return nothing))))
|
||||||
(output str))))
|
(output str))))
|
||||||
(with ((output output*))
|
(with ((output output*))
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
(srfi 159 unicode) (srfi 159 color))
|
(srfi 159 unicode) (srfi 159 color))
|
||||||
(export
|
(export
|
||||||
;; base
|
;; base
|
||||||
show fn fn-fork with update! each each-in-list call-with-output
|
show fn fn-fork with with! each each-in-list call-with-output
|
||||||
displayed written written-shared written-simply
|
displayed written written-shared written-simply
|
||||||
numeric numeric/comma numeric/si numeric/fitted
|
numeric numeric/comma numeric/si numeric/fitted
|
||||||
nothing nl fl space-to tab-to escaped maybe-escaped
|
nothing nl fl space-to tab-to escaped maybe-escaped
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
(rename (chibi regexp-test) (run-tests run-regexp-tests))
|
(rename (chibi regexp-test) (run-tests run-regexp-tests))
|
||||||
(rename (chibi scribble-test) (run-tests run-scribble-tests))
|
(rename (chibi scribble-test) (run-tests run-scribble-tests))
|
||||||
(rename (chibi show-test) (run-tests run-show-tests))
|
(rename (chibi show-test) (run-tests run-show-tests))
|
||||||
|
(rename (chibi show c-test) (run-tests run-show-c-tests))
|
||||||
(rename (chibi string-test) (run-tests run-string-tests))
|
(rename (chibi string-test) (run-tests run-string-tests))
|
||||||
(rename (chibi system-test) (run-tests run-system-tests))
|
(rename (chibi system-test) (run-tests run-system-tests))
|
||||||
(rename (chibi tar-test) (run-tests run-tar-tests))
|
(rename (chibi tar-test) (run-tests run-tar-tests))
|
||||||
|
@ -106,6 +107,7 @@
|
||||||
(run-string-tests)
|
(run-string-tests)
|
||||||
(run-sha2-tests)
|
(run-sha2-tests)
|
||||||
(run-show-tests)
|
(run-show-tests)
|
||||||
|
(run-show-c-tests)
|
||||||
(run-system-tests)
|
(run-system-tests)
|
||||||
(run-tar-tests)
|
(run-tar-tests)
|
||||||
(run-uri-tests)
|
(run-uri-tests)
|
||||||
|
|
Loading…
Add table
Reference in a new issue