/offlineimap/head: changeset 351
Fixed color on FreeBSD, and exceptions for non-color terminals
This commit is contained in:
parent
9f76bac96f
commit
897e93700d
@ -1,3 +1,12 @@
|
|||||||
|
offlineimap (3.99.8) unstable; urgency=low
|
||||||
|
|
||||||
|
* This is a 4.0 TRACK release, and may be unstable or in flux!
|
||||||
|
* Fixed several problems with the Curses interface: colors showing
|
||||||
|
up very weird on FreeBSD and exceptions when running on non-color
|
||||||
|
terminals.
|
||||||
|
|
||||||
|
-- John Goerzen <jgoerzen@complete.org> Fri, 10 Jan 2003 11:46:24 -0600
|
||||||
|
|
||||||
offlineimap (3.99.7) unstable; urgency=low
|
offlineimap (3.99.7) unstable; urgency=low
|
||||||
|
|
||||||
* This is a 4.0 TRACK release, and may be unstable or in flux!
|
* This is a 4.0 TRACK release, and may be unstable or in flux!
|
||||||
|
@ -29,12 +29,18 @@ acctkeys = '1234567890abcdefghijklmnoprstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-=;/.,'
|
|||||||
|
|
||||||
class CursesUtil:
|
class CursesUtil:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.pairs = {self._getpairindex(curses.COLOR_WHITE,
|
|
||||||
curses.COLOR_BLACK): 0}
|
|
||||||
self.start()
|
|
||||||
self.nextpair = 1
|
|
||||||
self.pairlock = Lock()
|
self.pairlock = Lock()
|
||||||
self.iolock = MultiLock()
|
self.iolock = MultiLock()
|
||||||
|
self.start()
|
||||||
|
|
||||||
|
def initpairs(self):
|
||||||
|
self.pairlock.acquire()
|
||||||
|
try:
|
||||||
|
self.pairs = {self._getpairindex(curses.COLOR_WHITE,
|
||||||
|
curses.COLOR_BLACK): 0}
|
||||||
|
self.nextpair = 1
|
||||||
|
finally:
|
||||||
|
self.pairlock.release()
|
||||||
|
|
||||||
def lock(self):
|
def lock(self):
|
||||||
self.iolock.acquire()
|
self.iolock.acquire()
|
||||||
@ -63,6 +69,8 @@ class CursesUtil:
|
|||||||
return '%d/%d' % (fg,bg)
|
return '%d/%d' % (fg,bg)
|
||||||
|
|
||||||
def getpair(self, fg, bg):
|
def getpair(self, fg, bg):
|
||||||
|
if not self.has_color:
|
||||||
|
return 0
|
||||||
pindex = self._getpairindex(fg, bg)
|
pindex = self._getpairindex(fg, bg)
|
||||||
self.pairlock.acquire()
|
self.pairlock.acquire()
|
||||||
try:
|
try:
|
||||||
@ -96,6 +104,7 @@ class CursesUtil:
|
|||||||
self.stdscr.clear()
|
self.stdscr.clear()
|
||||||
self.stdscr.refresh()
|
self.stdscr.refresh()
|
||||||
(self.height, self.width) = self.stdscr.getmaxyx()
|
(self.height, self.width) = self.stdscr.getmaxyx()
|
||||||
|
self.initpairs()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
if not hasattr(self, 'stdscr'):
|
if not hasattr(self, 'stdscr'):
|
||||||
@ -200,6 +209,9 @@ class CursesThreadFrame:
|
|||||||
|
|
||||||
def display(self):
|
def display(self):
|
||||||
def lockedstuff():
|
def lockedstuff():
|
||||||
|
if self.getcolor() == 'black':
|
||||||
|
self.window.addstr(self.y, self.x, ' ', self.color)
|
||||||
|
else:
|
||||||
self.window.addstr(self.y, self.x, '.', self.color)
|
self.window.addstr(self.y, self.x, '.', self.color)
|
||||||
self.c.stdscr.move(self.c.height - 1, self.c.width - 1)
|
self.c.stdscr.move(self.c.height - 1, self.c.width - 1)
|
||||||
self.window.refresh()
|
self.window.refresh()
|
||||||
@ -406,9 +418,12 @@ class Blinkenlights(BlinkenBase, UIBase):
|
|||||||
s.c.unlock()
|
s.c.unlock()
|
||||||
|
|
||||||
def setupwindow_drawbanner(s):
|
def setupwindow_drawbanner(s):
|
||||||
s.bannerwindow.bkgd(' ', curses.A_BOLD | \
|
if s.c.has_color:
|
||||||
s.c.getpair(curses.COLOR_WHITE,
|
color = s.c.getpair(curses.COLOR_WHITE, curses.COLOR_BLUE) | \
|
||||||
curses.COLOR_BLUE))
|
curses.A_BOLD
|
||||||
|
else:
|
||||||
|
color = curses.A_REVERSE
|
||||||
|
s.bannerwindow.bkgd(' ', color) # Fill background with that color
|
||||||
s.bannerwindow.addstr("%s %s" % (version.productname,
|
s.bannerwindow.addstr("%s %s" % (version.productname,
|
||||||
version.versionstr))
|
version.versionstr))
|
||||||
s.bannerwindow.addstr(0, s.bannerwindow.getmaxyx()[1] - len(version.copyright) - 1,
|
s.bannerwindow.addstr(0, s.bannerwindow.getmaxyx()[1] - len(version.copyright) - 1,
|
||||||
@ -417,7 +432,11 @@ class Blinkenlights(BlinkenBase, UIBase):
|
|||||||
s.bannerwindow.noutrefresh()
|
s.bannerwindow.noutrefresh()
|
||||||
|
|
||||||
def setupwindow_drawlog(s):
|
def setupwindow_drawlog(s):
|
||||||
s.logwindow.bkgd(' ', s.c.getpair(curses.COLOR_WHITE, curses.COLOR_BLACK))
|
if s.c.has_color:
|
||||||
|
color = s.c.getpair(curses.COLOR_WHITE, curses.COLOR_BLACK)
|
||||||
|
else:
|
||||||
|
color = curses.A_NORMAL
|
||||||
|
s.logwindow.bkgd(' ', color)
|
||||||
for line, color in s.text:
|
for line, color in s.text:
|
||||||
s.logwindow.addstr("\n" + line, color)
|
s.logwindow.addstr("\n" + line, color)
|
||||||
s.logwindow.noutrefresh()
|
s.logwindow.noutrefresh()
|
||||||
@ -501,7 +520,7 @@ if __name__ == '__main__':
|
|||||||
x = Blinkenlights(None)
|
x = Blinkenlights(None)
|
||||||
x.init_banner()
|
x.init_banner()
|
||||||
import time
|
import time
|
||||||
time.sleep(10)
|
time.sleep(5)
|
||||||
x.c.stop()
|
x.c.stop()
|
||||||
fgs = {'black': curses.COLOR_BLACK, 'red': curses.COLOR_RED,
|
fgs = {'black': curses.COLOR_BLACK, 'red': curses.COLOR_RED,
|
||||||
'green': curses.COLOR_GREEN, 'yellow': curses.COLOR_YELLOW,
|
'green': curses.COLOR_GREEN, 'yellow': curses.COLOR_YELLOW,
|
||||||
@ -536,7 +555,7 @@ if __name__ == '__main__':
|
|||||||
win4.refresh()
|
win4.refresh()
|
||||||
x.stdscr.refresh()
|
x.stdscr.refresh()
|
||||||
import time
|
import time
|
||||||
time.sleep(40)
|
time.sleep(5)
|
||||||
x.stop()
|
x.stop()
|
||||||
print x.has_color
|
print x.has_color
|
||||||
print x.height
|
print x.height
|
||||||
|
Loading…
Reference in New Issue
Block a user