Merge pull request #1822 from rbanffy/overline-italic
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Overline and italic support
authored by David Lord · committed by GitHub · parents d334d82, 1e02000 · Browse files · 3 files·+19 added−4 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+19 added−4 removed
- tests:+7 added−2 removed
- other:+12 added−2 removed
Provenance
- Commit
c0f9c06- Tree
c930f9a- Author
David Lord <davidism@gmail.com>- Committer
GitHub <noreply@github.com>- Parent 1
d334d82- Parent 2
1e02000
3 files changed+19 added−4 removed
modified:src/click/termui.py+10 added-1 removed
462 unmodified lines463 bg=None,464 bold=None,465 dim=None,466 underline=None,467+ overline=None,468+ italic=None,469 blink=None,470 reverse=None,471 strikethrough=None,472 reset=True,46 unmodified lines519 :param bold: if provided this will enable or disable bold mode.520 :param dim: if provided this will enable or disable dim mode. This is521 badly supported.522 :param underline: if provided this will enable or disable underline.523+ :param overline: if provided this will enable or disable overline.524+ :param italic: if provided this will enable or disable italic.525 :param blink: if provided this will enable or disable blinking.526 :param reverse: if provided this will enable or disable inverse527 rendering (foreground becomes background and the528 other way round).9 unmodified lines538 .. versionchanged:: 8.0539 Added support for 256 and RGB color codes.540 541 .. versionchanged:: 8.0538- Added the ``strikethrough`` parameter.542+ Added the ``strikethrough``, ``italic``, and ``overline``543+ parameters.544 545 .. versionchanged:: 7.0546 Added support for bright colors.547 21 unmodified lines569 if dim is not None:570 bits.append(f"\033[{2 if dim else 22}m")571 if underline is not None:572 bits.append(f"\033[{4 if underline else 24}m")573+ if overline is not None:574+ bits.append(f"\033[{53 if underline else 55}m")575+ if italic is not None:576+ bits.append(f"\033[{5 if underline else 23}m")577 if blink is not None:578 bits.append(f"\033[{5 if blink else 25}m")579 if reverse is not None:580 bits.append(f"\033[{7 if reverse else 27}m")180 unmodified linesmodified:tests/test_utils.py+7 added-2 removed
62 unmodified lines63 ({"bg": "cyan"}, "\x1b[46mx y\x1b[0m"),64 ({"bg": "white"}, "\x1b[47mx y\x1b[0m"),65 ({"bg": 91}, "\x1b[48;5;91mx y\x1b[0m"),66 ({"bg": (135, 0, 175)}, "\x1b[48;2;135;0;175mx y\x1b[0m"),67- ({"blink": True}, "\x1b[5mx y\x1b[0m"),68- ({"underline": True}, "\x1b[4mx y\x1b[0m"),67 ({"bold": True}, "\x1b[1mx y\x1b[0m"),68 ({"dim": True}, "\x1b[2mx y\x1b[0m"),69+ ({"underline": True}, "\x1b[4mx y\x1b[0m"),70+ ({"overline": True}, "\x1b[55mx y\x1b[0m"),71+ ({"italic": True}, "\x1b[23mx y\x1b[0m"),72+ ({"blink": True}, "\x1b[5mx y\x1b[0m"),73+ ({"reverse": True}, "\x1b[7mx y\x1b[0m"),74+ ({"strikethrough": True}, "\x1b[9mx y\x1b[0m"),75+ ({"fg": "black", "reset": False}, "\x1b[30mx y"),76 ],77 )78 def test_styling(styles, ref):79 assert click.style("x y", **styles) == ref367 unmodified linesmodified:CHANGES.rst+2 added-1 removed
172 unmodified lines173 - Option prompts validate the value with the option's callback in174 addition to its type. :issue:`457`175 - ``confirmation_prompt`` can be set to a custom string. :issue:`723`176 - Allow styled output in Jupyter on Windows. :issue:`1271`177-- ``style()`` supports the ``strikethrough`` style. :issue:`805`177+- ``style()`` supports the ``strikethrough``, ``italic``, and178+ ``overline`` styles. :issue:`805, 1821`179 - Multiline marker is removed from short help text. :issue:`1597`180 - Restore progress bar behavior of echoing only the label if the file181 is not a TTY. :issue:`1138`182 - Progress bar output is shown even if execution time is less than 0.5656 unmodified lines