@@ -396,7 +396,7 @@ def get_height(self, rules: RulesMap, width: int) -> int:
396
396
lines = self .without_spans ._wrap_and_format (
397
397
width ,
398
398
overflow = rules .get ("text_overflow" , "fold" ),
399
- no_wrap = rules .get ("text_wrap" ) == "nowrap" ,
399
+ no_wrap = rules .get ("text_wrap" , "wrap" ) == "nowrap" ,
400
400
)
401
401
return len (lines )
402
402
@@ -442,17 +442,17 @@ def get_span(y: int) -> tuple[int, int] | None:
442
442
443
443
line = line .expand_tabs (tab_size )
444
444
445
- if no_wrap and overflow == "fold" :
446
- cuts = list ( range ( 0 , line . cell_length , width ))[ 1 :]
447
- new_lines = [
448
- _FormattedLine ( line , width , y = y , align = align )
449
- for line in line . divide ( cuts )
450
- ]
451
- elif no_wrap :
452
- if overflow == "ellipsis" and no_wrap :
453
- line = line .truncate (width , ellipsis = True )
454
- content_line = _FormattedLine (line , width , y = y , align = align )
455
- new_lines = [content_line ]
445
+ if no_wrap :
446
+ if overflow == "fold" :
447
+ cuts = list ( range ( 0 , line . cell_length , width ))[ 1 :]
448
+ new_lines = [
449
+ _FormattedLine ( line , width , y = y , align = align )
450
+ for line in line . divide ( cuts )
451
+ ]
452
+ else :
453
+ line = line .truncate (width , ellipsis = overflow == "ellipsis" )
454
+ content_line = _FormattedLine (line , width , y = y , align = align )
455
+ new_lines = [content_line ]
456
456
else :
457
457
content_line = _FormattedLine (line , width , y = y , align = align )
458
458
offsets = divide_line (line .plain , width , fold = overflow == "fold" )
@@ -495,6 +495,7 @@ def render_strips(
495
495
Returns:
496
496
An list of Strips.
497
497
"""
498
+
498
499
if not width :
499
500
return []
500
501
@@ -948,7 +949,7 @@ def render(
948
949
self ,
949
950
base_style : Style = Style .null (),
950
951
end : str = "\n " ,
951
- parse_style : Callable [[str ], Style ] | None = None ,
952
+ parse_style : Callable [[str | Style ], Style ] | None = None ,
952
953
) -> Iterable [tuple [str , Style ]]:
953
954
"""Render Content in to an iterable of strings and styles.
954
955
@@ -971,11 +972,13 @@ def render(
971
972
yield end , base_style
972
973
return
973
974
974
- get_style : Callable [[str ], Style ]
975
+ get_style : Callable [[str | Style ], Style ]
975
976
if parse_style is None :
976
977
977
- def get_style (style : str , / ) -> Style :
978
+ def get_style (style : str | Style ) -> Style :
978
979
"""The default get_style method."""
980
+ if isinstance (style , Style ):
981
+ return style
979
982
try :
980
983
visual_style = Style .parse (style )
981
984
except Exception :
0 commit comments