summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Geier <geier@lostpackets.de>2017-05-31 00:41:26 +0200
committerChristian Geier <geier@lostpackets.de>2018-01-02 22:28:20 +0100
commit6933bedd953cdaa2ffafa800cccb23eff8177393 (patch)
tree454a4482cda2d6aefcc313d2ce1cfed417043deb
parentab6bfbcaf0ff2326e3392d7895fb1aaee5bbb167 (diff)
downloadurwid-6933bedd953cdaa2ffafa800cccb23eff8177393.tar.gz
Support for new foreground setting "strikethrough"
If you are unsure if your terminal supports this, try the following: echo -e "\e[9mstrikethrough\e[0m"
-rw-r--r--docs/manual/displayattributes.rst8
-rwxr-xr-xurwid/display_common.py12
-rw-r--r--urwid/raw_display.py2
3 files changed, 16 insertions, 6 deletions
diff --git a/docs/manual/displayattributes.rst b/docs/manual/displayattributes.rst
index f68c0c2..4f800f6 100644
--- a/docs/manual/displayattributes.rst
+++ b/docs/manual/displayattributes.rst
@@ -169,6 +169,11 @@ Foreground and Background Settings
- NO
- NO
- some support
+ * - :ref:`strikethrough <bold-underline-standout>`
+ - YES
+ - NO
+ - NO
+ - some supported
* - :ref:`"bright" background colors <bright-background>`
- YES
- urxvt
@@ -251,9 +256,10 @@ Bold, Underline, Standout
* ``'standout'``
* ``'blink'``
* ``'italics'``
+* ``'strikethrough'``
These settings may be tagged on to foreground colors using commas, eg: ``'light
-gray,underline,bold'``
+gray,underline,bold,strikethrough'``
For monochrome mode combinations of these are the only values that may be used.
diff --git a/urwid/display_common.py b/urwid/display_common.py
index 867691d..26f3a5a 100755
--- a/urwid/display_common.py
+++ b/urwid/display_common.py
@@ -91,8 +91,9 @@ _UNDERLINE = 0x04000000
_BOLD = 0x08000000
_BLINK = 0x10000000
_ITALICS = 0x20000000
+_STRIKETHROUGH = 0x40000000
_FG_MASK = (_FG_COLOR_MASK | _FG_BASIC_COLOR | _FG_HIGH_COLOR |
- _STANDOUT | _UNDERLINE | _BLINK | _BOLD | _ITALICS)
+ _STANDOUT | _UNDERLINE | _BLINK | _BOLD | _ITALICS | _STRIKETHROUGH)
_BG_MASK = _BG_COLOR_MASK | _BG_BASIC_COLOR | _BG_HIGH_COLOR
DEFAULT = 'default'
@@ -138,6 +139,7 @@ _ATTRIBUTES = {
'underline': _UNDERLINE,
'blink': _BLINK,
'standout': _STANDOUT,
+ 'strikethrough': _STRIKETHROUGH,
}
def _value_lookup_table(values, size):
@@ -452,7 +454,8 @@ class AttrSpec(object):
'h8' (color number 8), 'h255' (color number 255)
Setting:
- 'bold', 'italics', 'underline', 'blink', 'standout'
+ 'bold', 'italics', 'underline', 'blink', 'standout',
+ 'strikethrough'
Some terminals use 'bold' for bright colors. Most terminals
ignore the 'blink' setting. If the color is not given then
@@ -507,6 +510,7 @@ class AttrSpec(object):
underline = property(lambda s: s._value & _UNDERLINE != 0)
blink = property(lambda s: s._value & _BLINK != 0)
standout = property(lambda s: s._value & _STANDOUT != 0)
+ strikethrough = property(lambda s: s._value & _STRIKETHROUGH != 0)
def _colors(self):
"""
@@ -548,7 +552,7 @@ class AttrSpec(object):
return (self._foreground_color() +
',bold' * self.bold + ',italics' * self.italics +
',standout' * self.standout + ',blink' * self.blink +
- ',underline' * self.underline)
+ ',underline' * self.underline + ',strikethrough' * self.strikethrough)
def _set_foreground(self, foreground):
color = None
@@ -814,7 +818,7 @@ class BaseScreen(object):
'light magenta', 'light cyan', 'white'
Settings:
- 'bold', 'underline', 'blink', 'standout'
+ 'bold', 'underline', 'blink', 'standout', 'strikethrough'
Some terminals use 'bold' for bright colors. Most terminals
ignore the 'blink' setting. If the color is not given then
diff --git a/urwid/raw_display.py b/urwid/raw_display.py
index f88d0b4..b619d82 100644
--- a/urwid/raw_display.py
+++ b/urwid/raw_display.py
@@ -933,7 +933,7 @@ class Screen(BaseScreen, RealTerminal):
fg = "39"
st = ("1;" * a.bold + "3;" * a.italics +
"4;" * a.underline + "5;" * a.blink +
- "7;" * a.standout)
+ "7;" * a.standout + "9;" * a.strikethrough)
if a.background_high:
bg = "48;5;%d" % a.background_number
elif a.background_basic: