From: dag.odenhall@gmail.com (Dag Odenhall)
Subject: [sup-talk] [PATCH] use any custom colors configured in config.yaml
Date: Fri, 25 Apr 2008 21:12:16 +0200 [thread overview]
Message-ID: <1209150616-sup-8211@psilocybic> (raw)
* bin/sup: (start_cursing) Initialize use of default
colors (transparency).
* lib/sup/colormap.rb: Add a COLOR_DEFAULT constant to the
Curses module.
(CURSES_COLOR) Add the new COLOR_DEFAULT constant.
(color_for) Use colors from config if available.
Signed-off-by: Dag Odenhall <dag.odenhall at gmail.com>
---
bin/sup | 1 +
lib/sup/colormap.rb | 11 ++++++++++-
2 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/bin/sup b/bin/sup
index 6360cde..e791fe5 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
--
1.5.5.1
next reply other threads:[~2008-04-25 19:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-25 19:12 Dag Odenhall [this message]
2008-04-28 22:28 ` William Morgan
2008-04-28 23:01 ` Dag Odenhall
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=1209150616-sup-8211@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