Wrap outgoing TUI messages
ober
d87094a7bffaccfe4246fb3dc384e6096cb3752b
--- a/signal/tui/main.ss +++ b/signal/tui/main.ss @@ -612,21 +612,33 @@ (get-output-string out))) (def (chat-message->display-lines msg width) - (if (and (> width 0) (eq? (chat-message-direction msg) 'in)) - (incoming-message-lines (chat-message-sender msg) - (chat-message-text msg) - width) - (list (chat-message->line msg)))) + (let ([dir (chat-message-direction msg)]) + (cond + [(and (> width 0) (eq? dir 'in)) + (incoming-message-lines (chat-message-sender msg) + (chat-message-text msg) + width)] + [(and (> width 0) (eq? dir 'out)) + (prefixed-message-lines + "You: " + (string-append (safe-display (chat-message-text msg)) + (receipt-suffix (chat-message-status msg))) + width)] + [else (list (chat-message->line msg))]))) (def (incoming-message-lines sender text width) (let* ([sender (one-line-text sender)] [prefix (if (non-empty-string? sender) (string-append sender ": ") - "")] + "")]) + (prefixed-message-lines prefix (safe-display text) width))) + + (def (prefixed-message-lines prefix text width) + (let* ([prefix (one-line-text prefix)] [rest-prefix (make-string (min (string-length prefix) (max 0 (- width 1))) #\space)] - [parts (message-text-lines (safe-display text))]) + [parts (message-text-lines text)]) (let loop ([xs parts] [first? #t] [acc '()]) (if (null? xs) (if (null? acc) (list prefix) (reverse acc))