aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2020-09-06 11:05:40 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2020-09-06 11:05:40 -0400
commitb4365e3d457d7f5179fed57c9f828bbce4994476 (patch)
tree1e697e03dcbd2bbbcd925b4292f15c551a5d5e75 /src
parent4fa91c4a662c8cb1f1efe631610b944381e12457 (diff)
Clean up control picture substitution a little
Diffstat (limited to 'src')
-rw-r--r--src/fmt.bqn8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/fmt.bqn b/src/fmt.bqn
index 18969fb9..9344042d 100644
--- a/src/fmt.bqn
+++ b/src/fmt.bqn
@@ -1,11 +1,6 @@
# Format an array to a character matrix
{
F0←𝔽 # Function to format a scalar
- # Substitute control codes for character arrays
- CSub ← {
- del ← @+127
- 𝕩 + (('␑'-del)×𝕩=del) + ('␀'-@)×𝕩<@+32
- }
# Vertical padding for arrays of rank greater than 2
PadV ← {
# Leading shape
@@ -52,6 +47,9 @@
# All characters
k ← ∞⍟(0⊸=) -β‰  c ← Β―1↓≒𝕩
q ← '"'
+ # Escape quotes in strings (rank 1) and substitute control chars
+ # with control pictures for other ranks.
+ CSub ← { 𝕩 + (𝕩(=Γ—'␑'-⊒)@+127) + ('␀'-@)×𝕩<@+32 }
𝕩 ↩ (1β‰ =)β—ΆβŸ¨(1+q=⊒)⊸/,Csub⟩ 𝕩
(r Enframe 1 PadH PadV)⍟(1β‰ r) ≍ (c↑q) βˆΎβŽ‰k 𝕩 βˆΎβŽ‰k ⌽⌾β₯Šc↑q
}β€Ώ{