diff options
| author | Cristobal Sciutto <cristobal.sciutto@gmail.com> | 2023-06-02 21:17:09 +0000 |
|---|---|---|
| committer | Cristobal Sciutto <cristobal.sciutto@gmail.com> | 2023-06-02 21:17:09 +0000 |
| commit | 5662d5847bc4da8ff9b6f0bdc6b7c66a8d50b58d (patch) | |
| tree | c2f3409384d3cde5858b0159a99a7b8d19456085 /virtual-programs | |
| parent | better API + display API (diff) | |
| parent | Fix linebreaks in labels (diff) | |
| download | folk-5662d5847bc4da8ff9b6f0bdc6b7c66a8d50b58d.tar.gz folk-5662d5847bc4da8ff9b6f0bdc6b7c66a8d50b58d.zip | |
:wqMerge branch 'cs/camera-slice' of github.com:FolkComputer/folk into cs/camera-slice
Diffstat (limited to 'virtual-programs')
| -rw-r--r-- | virtual-programs/label.folk | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/virtual-programs/label.folk b/virtual-programs/label.folk index 002eeca5..3a5f7f38 100644 --- a/virtual-programs/label.folk +++ b/virtual-programs/label.folk @@ -13,18 +13,19 @@ When /thing/ has region /region/ { if {$::isLaptop} {set upsidedown false} When the collected matches for [list /someone/ wishes $thing is labelled /text/] are /matches/ { - set lines [lmap match $matches {dict get $match text}] - if {[llength lines] eq 0} { return } - - set lines [expr {$upsidedown ? [lreverse $lines] : $lines}] - set scale 1 - set fontSize [expr {18 * $scale}] - - for {set lineNum 0} {$lineNum < [llength $lines]} {incr lineNum} { - set line [lindex $lines $lineNum] - set ly [expr {$y + $lineNum * $fontSize}] - Display::text device $x $ly $scale $line $radians - } + set text [join [lmap match $matches {dict get $match text}] "\n"] + if {$text eq ""} { return } + set lines [split $text "\n"] + + set lines [expr {$upsidedown ? [lreverse $lines] : $lines}] + set scale 1 + set fontSize [expr {18 * $scale}] + + for {set lineNum 0} {$lineNum < [llength $lines]} {incr lineNum} { + set line [lindex $lines $lineNum] + set ly [expr {$y + $lineNum * $fontSize}] + Display::text device $x $ly $scale $line $radians + } } } @@ -33,8 +34,8 @@ fn text {coords text angle} { } When /anyone/ wishes /p/ has halo message /message/ & /p/ has region /r/ { - lassign [lindex $r 0] a b c d - lassign $a x y - text $a $message 0 - text $d $message 180 + lassign [lindex $r 0] a b c d + lassign $a x y + text $a $message 0 + text $d $message 180 } |
