Skip to content

Commit

Permalink
docs(text area): fix syntax highlighting in examples (Textualize#4099)
Browse files Browse the repository at this point in the history
* docs(text area): fix syntax highlighting in examples

* revert text_area_extended.py

* fix class method

* fix extended text area example
  • Loading branch information
TomJGooding authored Feb 5, 2024
1 parent 6459878 commit ca2c11b
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
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

0 comments on commit ca2c11b

Please sign in to comment.