Skip to content

Preserve editor line breaks in the teleprompter (opt-out setting)#69

Open
mama-samba-braima wants to merge 1 commit into
f:masterfrom
mama-samba-braima:preserve-line-breaks
Open

Preserve editor line breaks in the teleprompter (opt-out setting)#69
mama-samba-braima wants to merge 1 commit into
f:masterfrom
mama-samba-braima:preserve-line-breaks

Conversation

@mama-samba-braima

Copy link
Copy Markdown

What & why

The teleprompter flattens every line break in your script into a single space and then reflows the words purely by the container width. So no matter how you lay your script out in the editor, the on-screen prompter collapses it into one continuous block. Line breaks and paragraph gaps you deliberately typed are lost, which makes scripts with short lines, stanzas, or beats hard to follow while presenting.

The root cause is in splitTextIntoWords:

let tokens = text.replacingOccurrences(of: "\n", with: " ")  // every line break destroyed here

What this PR does

  • Adds tokenizeText(), which tokenizes exactly as before but also records how many newlines preceded each word.
  • Threads that metadata (lineBreaks) through OverlayContent → SpeechScrollView → WordFlowLayout, which now forces a line break at each hard newline and inserts blank lines for paragraph gaps.
  • Exposes it as a new Appearance → Text Layout → "Preserve Line Breaks" toggle (on by default). When off, the prompter falls back to the previous width-only reflow, so existing behaviour is one click away.

splitTextIntoWords is unchanged for the callers that only need words (speech matching, character offsets, highlighting), so word tracking and highlighting behave identically. The change is purely additive to layout.

Applies to all four prompter surfaces: notch, floating, fullscreen, and the external-display mirror.

Behaviour

Script Before After (toggle on)
A\nB A B (one line) A / B (two lines)
A\n\nB A B (one line) A / (blank) / B (paragraph gap)
leading/trailing newlines n/a trimmed
multiple spaces / soft wrap collapsed & width-wrapped unchanged

Testing

  • Builds clean (xcodebuild, Debug/macOS).
  • Verified the tokenizer + line-break layout against 8 cases (single line, single newline, paragraph gap, leading/trailing newline trimming, multi-space collapse, triple newline → two blank lines).
  • Manually tested on macOS across the notch, floating, fullscreen and external-display prompters, and toggling the setting on/off live.

The teleprompter flattened every newline into a space (splitTextIntoWords
did replacingOccurrences(of: "\n", with: " ")) and reflowed the words
purely by container width, so the on-screen text never matched the line
breaks and paragraph gaps the author typed in the editor.

Add tokenizeText(), which tokenizes exactly as before but also records how
many newlines preceded each word. That metadata (lineBreaks) is threaded
through OverlayContent -> SpeechScrollView -> WordFlowLayout, which forces a
line break at each hard newline and inserts blank lines for paragraph gaps.

Expose it as a new Appearance setting, "Preserve Line Breaks" (on by
default). When off, the prompter falls back to the previous width-only
reflow. splitTextIntoWords is unchanged for callers that only need words
(speech matching, char offsets), so tracking/highlighting is identical.

Covers the notch, floating, fullscreen and external-display prompters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant