Skip to content

TextArea: make sure to use \n as line separator #4560

Answered by TomJGooding
UlrichGoebel asked this question in Q&A
Discussion options

You must be logged in to vote

It sounds like you already have a pretty good understanding of the TextArea widget from the docs.

When content is loaded into the TextArea, the lines of the document are stored separate from the newline character, which is based on the "first occurrence of a line separator". Here's the underlying code (though note only intended for internal use from the leading underscore) :

class Document(DocumentBase):
"""A document which can be opened in a TextArea."""
def __init__(self, text: str) -> None:
self._newline = _detect_newline_style(text)
"""The type of newline used in the text."""

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@UlrichGoebel
Comment options

Answer selected by UlrichGoebel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants