summaryrefslogtreecommitdiff
path: root/src/main/smp/sys/text.smp
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-08-10 11:11:18 -0700
committerCliff Click <cliffc@acm.org>2026-11-13 16:17:13 -0800
commit236a9b50ffe5c13f33027dbf5fef38f9fc58a8f9 (patch)
tree9fe5d79a2d0c7b12e1317b737857065fff5093a5 /src/main/smp/sys/text.smp
parent2cb35c65bde63f90d7afc3d7a8a985b0c6ea15d7 (diff)
downloadSimple-236a9b50ffe5c13f33027dbf5fef38f9fc58a8f9.tar.gz
Simple-236a9b50ffe5c13f33027dbf5fef38f9fc58a8f9.zip
Chapter 31: Software Drawing, Time, and Graphical Games
Co-authored-by: Hsiang-Ying Fu <66062782+fuhsnn@users.noreply.github.com> Co-authored-by: fuhsnn <66062782+fuhsnn@users.noreply.github.com> Co-authored-by: Symious <14933944+symious@users.noreply.github.com> Co-authored-by: Jun Kawasaki <jun784@gmail.com> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'src/main/smp/sys/text.smp')
-rw-r--r--src/main/smp/sys/text.smp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/main/smp/sys/text.smp b/src/main/smp/sys/text.smp
index a414ff45..2c4b44ff 100644
--- a/src/main/smp/sys/text.smp
+++ b/src/main/smp/sys/text.smp
@@ -5,10 +5,7 @@
val begin = { -> new aryu8(); };
val end = { aryu8 b ->
- val bytes = new u8[b.len];
- ary.copy(bytes,0,b.buf,0,b.len);
- u8[~] result = bytes;
- result;
+ new u8[~b.len]{ i64 i -> b.buf[i]; };
};
val _pad = { !aryu8 b, i64 n, u8 c ->
@@ -96,3 +93,8 @@ val f64 = { f64 x -> end(floating(begin(),x, 0 ,0,-1)); };
val char = { i64 x -> end(integer (begin(),x,'c',0,-1)); };
val bool = { bool x -> end(integer (begin(),x,'b',0,-1)); };
val hex = { i64 x -> end(integer (begin(),x,'x',0,-1)); };
+
+// Time selectors occupy spec bits 16..23; padding shares string formatting.
+val time = { !aryu8 b, i64 value, i64 spec, i64 width, i64 precision ->
+ string(b,sys.time.format(value,(spec>>>16)&255),spec,width,-1);
+};