@@ -137,13 +137,21 @@ users can modify to control whether these escape codes are passed through to
137137the terminal or not.
138138
139139
140- Centering Text
140+ Aligning Text
141141--------------
142142
143- If you would like to generate output which is centered in the user's terminal,
144- the :meth: `cmd2.utils.align_center ` method can help. Pass it a string and it
145- will figure out the width of the terminal and return you a new string,
146- appropriately padded so it will be centered.
143+ If you would like to generate output which is left, center, or right aligned within a
144+ specified width or the terminal width, the following functions can help:
145+
146+ - :meth: `cmd2.utils.align_left `
147+ - :meth: `cmd2.utils.align_center `
148+ - :meth: `cmd2.utils.align_right `
149+
150+ These functions differ from Python's string justifying functions in that they support
151+ characters with display widths greater than 1. Additionally, ANSI style sequences are safely
152+ ignored and do not count toward the display width. This means colored text is supported. If
153+ text has line breaks, then each line is aligned independently.
154+
147155
148156
149157Columnar Output
@@ -157,5 +165,5 @@ in the output to generate colors on the terminal.
157165
158166The :meth: `cmd2.ansi.style_aware_wcswidth ` function solves both of these
159167problems. Pass it a string, and regardless of which Unicode characters and ANSI
160- escape sequences it contains, it will tell you how many characters on the
168+ text style escape sequences it contains, it will tell you how many characters on the
161169screen that string will consume when printed.
0 commit comments