duskos

dusk os fork
git clone git://git.alexwennerberg.com/duskos
Log | Files | Refs | README | LICENSE

commit 44224c32798a03762592f7d21edde7f4cf45ac33
parent 8791863df2db483942897cca9a71f299936c172b
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Wed, 30 Nov 2022 08:50:02 -0500

sys/io: add .f" shortcut to IO :printf

Diffstat:
Mfs/doc/io.txt | 7+++++++
Mfs/lib/fmt.fs | 3+++
2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/fs/doc/io.txt b/fs/doc/io.txt @@ -175,3 +175,10 @@ these letters are supported (others produce an error): w - 2b hexadecimal b - 1b hexadecimal s - string + c - char + +When you want to quickly printf to the console, there's the .f" shortcut, which +behaves like ." with formatting capabilities: + + : foo .f" foo %d bar" ; + 42 foo --> prints "foo 42 bar" diff --git a/fs/lib/fmt.fs b/fs/lib/fmt.fs @@ -28,11 +28,14 @@ struct+[ IO 'x' of = V1 :.x endof 'd' of = V1 :. endof 's' of = V1 :puts endof + 'c' of = V1 :putc endof abort" unsupported fmt argument" endcase else V1 :putc then next rfree ; ]struct +: _ ConsoleOut IO :printf ; +: .f" [compile] S" compiling if compile _ else _ then ; immediate : .x1 StdOut IO :.x1 ; : .x2 StdOut IO :.x2 ; : .x StdOut IO :.x ;