@@ -374,6 +374,9 @@ class TextArea(ScrollView):
374374 compact : reactive [bool ] = reactive (False , toggle_class = "-textual-compact" )
375375 """Enable compact display?"""
376376
377+ highlight_cursor_line : reactive [bool ] = reactive (True )
378+ """Highlight the line under the cursor?"""
379+
377380 _cursor_visible : Reactive [bool ] = reactive (False , repaint = False , init = False )
378381 """Indicates where the cursor is in the blink cycle. If it's currently
379382 not visible due to blinking, this is False."""
@@ -427,6 +430,7 @@ def __init__(
427430 disabled : bool = False ,
428431 tooltip : RenderableType | None = None ,
429432 compact : bool = False ,
433+ highlight_cursor_line : bool = True ,
430434 ) -> None :
431435 """Construct a new `TextArea`.
432436
@@ -446,6 +450,7 @@ def __init__(
446450 disabled: True if the widget is disabled.
447451 tooltip: Optional tooltip.
448452 compact: Enable compact style (without borders).
453+ highlight_cursor_line: Highlight the line under the cursor.
449454 """
450455 super ().__init__ (name = name , id = id , classes = classes , disabled = disabled )
451456
@@ -504,6 +509,7 @@ def __init__(
504509 self .set_reactive (TextArea .read_only , read_only )
505510 self .set_reactive (TextArea .show_line_numbers , show_line_numbers )
506511 self .set_reactive (TextArea .line_number_start , line_number_start )
512+ self .set_reactive (TextArea .highlight_cursor_line , highlight_cursor_line )
507513
508514 self ._set_document (text , language )
509515
@@ -541,6 +547,7 @@ def code_editor(
541547 disabled : bool = False ,
542548 tooltip : RenderableType | None = None ,
543549 compact : bool = False ,
550+ highlight_cursor_line : bool = True ,
544551 ) -> TextArea :
545552 """Construct a new `TextArea` with sensible defaults for editing code.
546553
@@ -561,6 +568,7 @@ def code_editor(
561568 disabled: True if the widget is disabled.
562569 tooltip: Optional tooltip
563570 compact: Enable compact style (without borders).
571+ highlight_cursor_line: Highlight the line under the cursor.
564572 """
565573 return cls (
566574 text ,
@@ -578,6 +586,7 @@ def code_editor(
578586 disabled = disabled ,
579587 tooltip = tooltip ,
580588 compact = compact ,
589+ highlight_cursor_line = highlight_cursor_line ,
581590 )
582591
583592 @staticmethod
@@ -1149,7 +1158,11 @@ def render_line(self, y: int) -> Strip:
11491158 selection_bottom_row , selection_bottom_column = selection_bottom
11501159
11511160 cursor_line_style = theme .cursor_line_style if theme else None
1152- if cursor_line_style and cursor_row == line_index :
1161+ if (
1162+ cursor_line_style
1163+ and cursor_row == line_index
1164+ and self .highlight_cursor_line
1165+ ):
11531166 line .stylize (cursor_line_style )
11541167
11551168 # Selection styling
@@ -1241,7 +1254,7 @@ def render_line(self, y: int) -> Strip:
12411254 # Build the gutter text for this line
12421255 gutter_width = self .gutter_width
12431256 if self .show_line_numbers :
1244- if cursor_row == line_index :
1257+ if cursor_row == line_index and self . highlight_cursor_line :
12451258 gutter_style = theme .cursor_line_gutter_style
12461259 else :
12471260 gutter_style = theme .gutter_style
@@ -1306,7 +1319,7 @@ def render_line(self, y: int) -> Strip:
13061319 text_strip = text_strip .crop (scroll_x , scroll_x + virtual_width )
13071320
13081321 # Stylize the line the cursor is currently on.
1309- if cursor_row == line_index :
1322+ if cursor_row == line_index and self . highlight_cursor_line :
13101323 line_style = cursor_line_style
13111324 else :
13121325 line_style = theme .base_style if theme else None
0 commit comments