Support for transparent terminals (and other colour schemes).

Joss Wright joss-offlineimap at pseudonymity.net
Mon Aug 13 22:24:52 BST 2012


Hello All,

Apologies if this email is out of place, or is doing something that has
been rejected for other reasons.

I've been using OfflineImap in a transparent terminal, and noticed that
the curses UI uses a hardcoded black as its default background.
(Actually, I run OfflineImap in one tmux window, and mutt in another.) I
had a play around, and found that enabling support for transparency in
curses is fairly simple, so patched my version of OfflineImap to support
it. 

As far as I can tell, it works fine, and it certainly makes the ui more
usable for me, as it stops certain colours from disappearing when they
conflict with my terminal's colour settings. I imagine that this use of
default colours would be helpful for other terminal colour schemes that
interact badly with a hardcoded black background.

I had a look at the mailing list archives, and only found one post from
about two years ago requesting this feature. (I'm not a list
subscriber.)

Again, sorry if this is something that has been tried and rejected, or
if I'm missing something obvious, but it seems a nice improvement for a
very small code change.

Joss

My (git diff) patch against the latest version I have from git:

diff --git a/offlineimap/ui/Curses.py b/offlineimap/ui/Curses.py
index 1c378ab..9d644f3 100644
--- a/offlineimap/ui/Curses.py
+++ b/offlineimap/ui/Curses.py
@@ -44,12 +44,17 @@ class CursesUtil:
 
     def init_colorpairs(self):
         """initialize the curses color pairs available"""
+
+        # allow the use of default colors, particularly transparency for those terminals that support it
+        curses.use_default_colors()
+
         # set special colors 'gray' and 'banner'
         self.colormap['white'] = 0 #hardcoded by curses
         curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE)
         self.colormap['banner'] = 1 # color 'banner' for bannerwin
 
-        bcol = curses.COLOR_BLACK
+        # use the default color for the background (possibly transparent)
+        bcol = -1
         colors = ( # name, color, bold?
                 ('black', curses.COLOR_BLACK, False),
                 ('blue', curses.COLOR_BLUE,False),




More information about the OfflineIMAP-project mailing list