Preserve editor line breaks in the teleprompter (opt-out setting)#69
Open
mama-samba-braima wants to merge 1 commit into
Open
Preserve editor line breaks in the teleprompter (opt-out setting)#69mama-samba-braima wants to merge 1 commit into
mama-samba-braima wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:What this PR does
tokenizeText(), which tokenizes exactly as before but also records how many newlines preceded each word.lineBreaks) throughOverlayContent → SpeechScrollView → WordFlowLayout, which now forces a line break at each hard newline and inserts blank lines for paragraph gaps.splitTextIntoWordsis 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
A\nBA B(one line)A/B(two lines)A\n\nBA B(one line)A/ (blank) /B(paragraph gap)Testing
xcodebuild, Debug/macOS).