File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
prompt_toolkit/formatted_text Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 2727 fragment_list_to_text ,
2828 fragment_list_width ,
2929 split_lines ,
30+ to_plain_text ,
3031)
3132
3233__all__ = [
4950 "fragment_list_width" ,
5051 "fragment_list_to_text" ,
5152 "split_lines" ,
53+ "to_plain_text" ,
5254]
Original file line number Diff line number Diff line change 88
99from prompt_toolkit .utils import get_cwidth
1010
11- from .base import OneStyleAndTextTuple , StyleAndTextTuples
11+ from .base import (
12+ AnyFormattedText ,
13+ OneStyleAndTextTuple ,
14+ StyleAndTextTuples ,
15+ to_formatted_text ,
16+ )
1217
1318__all__ = [
19+ "to_plain_text" ,
1420 "fragment_list_len" ,
1521 "fragment_list_width" ,
1622 "fragment_list_to_text" ,
1723 "split_lines" ,
1824]
1925
2026
27+ def to_plain_text (value : AnyFormattedText ) -> str :
28+ """
29+ Turn any kind of formatted text back into plain text.
30+ """
31+ return fragment_list_to_text (to_formatted_text (value ))
32+
33+
2134def fragment_list_len (fragments : StyleAndTextTuples ) -> int :
2235 """
2336 Return the amount of characters in this text fragment list.
You can’t perform that action at this time.
0 commit comments