From: dag.odenhall@gmail.com (Dag Odenhall)
Subject: [sup-talk] [PATCH] Configurable coloring
Date: Fri, 25 Apr 2008 01:53:51 +0200 [thread overview]
Message-ID: <1209080103-sup-8620@psilocybic> (raw)
Hello good folks
This lil patch allows you to override these color symbols:
:status
:index_old
:index_new
:index_starred
:index_draft
:labellist_old
:labellist_new
:twiddle
:label
:message_patina
:alternate_patina
:missing_message
:attachment
:cryptosig_valid
:cryptosig_unknown
:cryptosig_invalid
:generic_notice_patina
:quote_patina
:sig_patina
:quote
:sig
:to_me
:starred
:starred_patina
:alternate_starred_patina
:snippet
:option
:tagged
:draft_notification
:completion_character
:horizontal_selector_selected
:horizontal_selector_unselected
:search_highlight
in your config.yaml. You can set :fg or :bg to any of:
default (transparent)
black
blue
cyan
green
magenta
red
white
yellow
You can also set :attrs to a list of any of:
horizontal
reverse
left
blink
low
dim
right
bold
top
protect
attributes
vertical
invis
normal
color
altcharset
standout
chartext
underline
This all goes under :colors, so an example would be:
:colors:
:status:
:fg: black
:bg: red
:attrs:
- reverse
- underline
This is all a quick hack that can probably be improved upon, but it
works fine.
Thanks Marc Hartstein for help with getting the transparency working.
Dag.
diff --git a/bin/sup b/bin/sup
index 078a134..0c5e70d 100644
--- a/bin/sup
+++ b/bin/sup
@@ -78,6 +78,7 @@ def start_cursing
Ncurses.stdscr.keypad 1
Ncurses.curs_set 0
Ncurses.start_color
+ Ncurses.use_default_colors
$cursing = true
end
diff --git a/lib/sup/colormap.rb b/lib/sup/colormap.rb
index 9c6869a..4c48604 100644
--- a/lib/sup/colormap.rb
+++ b/lib/sup/colormap.rb
@@ -1,3 +1,7 @@
+module Curses
+ COLOR_DEFAULT = -1
+end
+
module Redwood
class Colormap
@@ -6,7 +10,7 @@ class Colormap
CURSES_COLORS = [Curses::COLOR_BLACK, Curses::COLOR_RED, Curses::COLOR_GREEN,
Curses::COLOR_YELLOW, Curses::COLOR_BLUE,
Curses::COLOR_MAGENTA, Curses::COLOR_CYAN,
- Curses::COLOR_WHITE]
+ Curses::COLOR_WHITE, Curses::COLOR_DEFAULT]
NUM_COLORS = 15
def initialize
@@ -80,6 +84,11 @@ class Colormap
fg, bg, attrs, color = @entries[sym]
return color if color
+ confcolor = $config[:colors][sym.to_s[0..-7].to_sym] rescue nil
+ fg = Curses.const_get "COLOR_#{confcolor[:fg].upcase}" rescue fg
+ bg = Curses.const_get "COLOR_#{confcolor[:bg].upcase}" rescue bg
+ attrs = confcolor[:attrs].map {|a| Curses.const_get "A_#{a.upcase}" } rescue attrs
+
if(cp = @color_pairs[[fg, bg]])
## nothing
else ## need to get a new colorpair
reply other threads:[~2008-04-24 23:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1209080103-sup-8620@psilocybic \
--to=dag.odenhall@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox