diff options
-rw-r--r-- | docs/manual/mainloop.rst | 2 | ||||
-rwxr-xr-x | urwid/monitored_list.py | 67 | ||||
-rw-r--r-- | urwid/raw_display.py | 20 | ||||
-rw-r--r-- | urwid/version.py | 2 |
4 files changed, 36 insertions, 55 deletions
diff --git a/docs/manual/mainloop.rst b/docs/manual/mainloop.rst index ee3f62a..1228724 100644 --- a/docs/manual/mainloop.rst +++ b/docs/manual/mainloop.rst @@ -132,7 +132,7 @@ This event loop integrates with Tornado. :: from tornado.ioloop import IOLoop - evl = urwid.TornadoEventLoop(IOLoop() + evl = urwid.TornadoEventLoop(IOLoop()) loop = urwid.MainLoop(widget, event_loop=evl) .. seealso:: diff --git a/urwid/monitored_list.py b/urwid/monitored_list.py index a1a6326..f9170ca 100755 --- a/urwid/monitored_list.py +++ b/urwid/monitored_list.py @@ -265,8 +265,10 @@ class MonitoredFocusList(MonitoredList): def __delitem__(self, y): """ - >>> ml = MonitoredFocusList([0,1,2,3], focus=2) + >>> ml = MonitoredFocusList([0,1,2,3,4], focus=2) >>> del ml[3]; ml + MonitoredFocusList([0, 1, 2, 4], focus=2) + >>> del ml[-1]; ml MonitoredFocusList([0, 1, 2], focus=2) >>> del ml[0]; ml MonitoredFocusList([1, 2], focus=1) @@ -279,11 +281,19 @@ class MonitoredFocusList(MonitoredList): MonitoredFocusList([5, 6, 5, 6, 5], focus=2) >>> del ml[::2]; ml MonitoredFocusList([6, 6], focus=1) + >>> ml = MonitoredFocusList([0,1,2,3,4,6,7], focus=2) + >>> del ml[-2:]; ml + MonitoredFocusList([0, 1, 2, 3, 4], focus=2) + >>> del ml[-4:-2]; ml + MonitoredFocusList([0, 3, 4], focus=1) + >>> del ml[:]; ml + MonitoredFocusList([], focus=None) """ if isinstance(y, slice): focus = self._adjust_focus_on_contents_modified(y) else: - focus = self._adjust_focus_on_contents_modified(slice(y, y+1)) + focus = self._adjust_focus_on_contents_modified(slice(y, + y+1 or None)) rval = super(MonitoredFocusList, self).__delitem__(y) self._set_focus(focus) return rval @@ -308,6 +318,14 @@ class MonitoredFocusList(MonitoredList): range(1, 4, 2) <- [12, 13] >>> ml[::2] = [10, 11] range(0, 4, 2) <- [10, 11] + >>> ml[-3:-1] = [21, 22, 23] + range(1, 3, 1) <- [21, 22, 23] + >>> ml + MonitoredFocusList([10, 21, 22, 23, 13], focus=2) + >>> ml[:] = [] + range(0, 5, 1) <- [] + >>> ml + MonitoredFocusList([], focus=None) """ if isinstance(i, slice): focus = self._adjust_focus_on_contents_modified(i, y) @@ -319,51 +337,10 @@ class MonitoredFocusList(MonitoredList): if not PYTHON3: def __delslice__(self, i, j): - """ - >>> def modified(indices, new_items): - ... print "range%r <- %r" % (indices, list(new_items)) - >>> ml = MonitoredFocusList([0,1,2,3,4], focus=2) - >>> ml.set_validate_contents_modified(modified) - >>> del ml[3:5] - range(3, 5, 1) <- [] - >>> ml - MonitoredFocusList([0, 1, 2], focus=2) - >>> del ml[:1] - range(0, 1, 1) <- [] - >>> ml - MonitoredFocusList([1, 2], focus=1) - >>> del ml[1:]; ml - range(1, 2, 1) <- [] - MonitoredFocusList([1], focus=0) - >>> del ml[:]; ml - range(0, 1, 1) <- [] - MonitoredFocusList([], focus=None) - """ - focus = self._adjust_focus_on_contents_modified(slice(i, j)) - rval = super(MonitoredFocusList, self).__delslice__(i, j) - self._set_focus(focus) - return rval + return self.__delitem__(slice(i,j)) def __setslice__(self, i, j, y): - """ - >>> ml = MonitoredFocusList([0,1,2,3,4], focus=2) - >>> ml[3:5] = [-1]; ml - MonitoredFocusList([0, 1, 2, -1], focus=2) - >>> ml[0:1] = []; ml - MonitoredFocusList([1, 2, -1], focus=1) - >>> ml[1:] = [3, 4]; ml - MonitoredFocusList([1, 3, 4], focus=1) - >>> ml[1:] = [2]; ml - MonitoredFocusList([1, 2], focus=1) - >>> ml[0:1] = [9,9,9]; ml - MonitoredFocusList([9, 9, 9, 2], focus=3) - >>> ml[:] = []; ml - MonitoredFocusList([], focus=None) - """ - focus = self._adjust_focus_on_contents_modified(slice(i, j), y) - rval = super(MonitoredFocusList, self).__setslice__(i, j, y) - self._set_focus(focus) - return rval + return self.__setitem__(slice(i, j), y) def __imul__(self, n): """ diff --git a/urwid/raw_display.py b/urwid/raw_display.py index a3d14a0..86ac654 100644 --- a/urwid/raw_display.py +++ b/urwid/raw_display.py @@ -75,7 +75,8 @@ class Screen(BaseScreen, RealTerminal): self._rows_used = None self._cy = 0 term = os.environ.get('TERM', '') - self.bright_is_bold = not term.startswith("xterm") + self.fg_bright_is_bold = not term.startswith("xterm") + self.bg_bright_is_blink = (term == "linux") self.back_color_erase = not term.startswith("screen") self._next_timeout = None @@ -745,7 +746,7 @@ class Screen(BaseScreen, RealTerminal): cy = 0 for row in r.content(): y += 1 - if False and osb and osb[y] == row: + if osb and osb[y] == row: # this row of the screen buffer matches what is # currently displayed, so we can skip this line sb.append( osb[y] ) @@ -916,7 +917,7 @@ class Screen(BaseScreen, RealTerminal): fg = "38;5;%d" % a.foreground_number elif a.foreground_basic: if a.foreground_number > 7: - if self.bright_is_bold: + if self.fg_bright_is_bold: fg = "1;%d" % (a.foreground_number - 8 + 30) else: fg = "%d" % (a.foreground_number - 8 + 90) @@ -930,8 +931,11 @@ class Screen(BaseScreen, RealTerminal): bg = "48;5;%d" % a.background_number elif a.background_basic: if a.background_number > 7: - # this doesn't work on most terminals - bg = "%d" % (a.background_number - 8 + 100) + if self.bg_bright_is_blink: + bg = "5;%d" % (a.background_number - 8 + 40) + else: + # this doesn't work on most terminals + bg = "%d" % (a.background_number + 100) else: bg = "%d" % (a.background_number + 40) else: @@ -955,16 +959,16 @@ class Screen(BaseScreen, RealTerminal): if colors is None: colors = self.colors if bright_is_bold is None: - bright_is_bold = self.bright_is_bold + bright_is_bold = self.fg_bright_is_bold if has_underline is None: has_underline = self.has_underline - if colors == self.colors and bright_is_bold == self.bright_is_bold \ + if colors == self.colors and bright_is_bold == self.fg_bright_is_bold \ and has_underline == self.has_underline: return self.colors = colors - self.bright_is_bold = bright_is_bold + self.fg_bright_is_bold = bright_is_bold self.has_underline = has_underline self.clear() diff --git a/urwid/version.py b/urwid/version.py index 0cfb892..d4a87bb 100644 --- a/urwid/version.py +++ b/urwid/version.py @@ -1,5 +1,5 @@ -VERSION = (1, 2, 2, 'dev') +VERSION = (1, 3, 0, 'dev') __version__ = ''.join(['-.'[type(x) == int]+str(x) for x in VERSION])[1:] |