Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(text area): fix syntax highlighting in examples #4099

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/examples/widgets/text_area_custom_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class HelloWorld {

class TextAreaCustomLanguage(App):
def compose(self) -> ComposeResult:
text_area = TextArea(text=java_code)
text_area = TextArea.code_editor(text=java_code)
text_area.cursor_blink = False

# Register the Java language and highlight query
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/widgets/text_area_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def goodbye(name):

class TextAreaExample(App):
def compose(self) -> ComposeResult:
yield TextArea(TEXT, language="python")
yield TextArea.code_editor(TEXT, language="python")


app = TextAreaExample()
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/widgets/text_area_extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def _on_key(self, event: events.Key) -> None:

class TextAreaKeyPressHook(App):
def compose(self) -> ComposeResult:
yield ExtendedTextArea(language="python")
yield ExtendedTextArea.code_editor(language="python")


app = TextAreaKeyPressHook()
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/widgets/text_area_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def goodbye(name):

class TextAreaSelection(App):
def compose(self) -> ComposeResult:
text_area = TextArea(TEXT, language="python")
text_area = TextArea.code_editor(TEXT, language="python")
text_area.selection = Selection(start=(0, 0), end=(2, 0)) # (1)!
yield text_area

Expand Down
2 changes: 1 addition & 1 deletion src/textual/widgets/_text_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ def code_editor(
classes: One or more Textual CSS compatible class names separated by spaces.
disabled: True if the widget is disabled.
"""
return TextArea(
return cls(
text,
language=language,
theme=theme,
Expand Down
Loading