From: Rich Lane <rlane@club.cc.cmu.edu>
To: sup-devel@rubyforge.org
Subject: [sup-devel] [PATCH] configurable color highlights
Date: Fri, 22 Jan 2010 18:47:14 -0500 [thread overview]
Message-ID: <1264204034-7088-1-git-send-email-rlane@club.cc.cmu.edu> (raw)
Adds a :highlight key to the color entries in colors.yaml that names another
color to be used for highlighting.
---
lib/sup/colormap.rb | 18 ++++++++++++++----
1 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/lib/sup/colormap.rb b/lib/sup/colormap.rb
index 6f21f9a..aeb3818 100644
--- a/lib/sup/colormap.rb
+++ b/lib/sup/colormap.rb
@@ -77,19 +77,26 @@ class Colormap
def reset
@entries = {}
+ @highlights = { :none => highlight_sym(:none)}
@entries[highlight_sym(:none)] = highlight_for(Curses::COLOR_WHITE,
Curses::COLOR_BLACK,
[]) + [nil]
end
- def add sym, fg, bg, attr=nil, opts={}
+ def add sym, fg, bg, attr=nil, highlight=nil
raise ArgumentError, "color for #{sym} already defined" if @entries.member? sym
raise ArgumentError, "color '#{fg}' unknown" unless (-1...Curses::NUM_COLORS).include? fg
raise ArgumentError, "color '#{bg}' unknown" unless (-1...Curses::NUM_COLORS).include? bg
attrs = [attr].flatten.compact
@entries[sym] = [fg, bg, attrs, nil]
- @entries[highlight_sym(sym)] = opts[:highlight] ? @entries[opts[:highlight]] : highlight_for(fg, bg, attrs) + [nil]
+
+ if not highlight
+ highlight = highlight_sym(sym)
+ @entries[highlight] = highlight_for(fg, bg, attrs) + [nil]
+ end
+
+ @highlights[sym] = highlight
end
def highlight_sym sym
@@ -132,7 +139,7 @@ class Colormap
end
def color_for sym, highlight=false
- sym = highlight_sym(sym) if highlight
+ sym = @highlights[sym] if highlight
return Curses::COLOR_BLACK if sym == :none
raise ArgumentError, "undefined color #{sym}" unless @entries.member? sym
@@ -213,8 +220,11 @@ class Colormap
end
end
+ highlight = ucolor[:highlight] || v[:highlight]
+ highlight_symbol = highlight ? :"#{highlight}_color" : nil
+
symbol = (k.to_s + "_color").to_sym
- add symbol, fg, bg, attrs
+ add symbol, fg, bg, attrs, highlight_symbol
end
warn error if error
--
1.5.6.5
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel
next reply other threads:[~2010-01-22 23:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-22 23:47 Rich Lane [this message]
2010-01-24 19:37 ` [sup-devel] [PATCH] dont restrict colors to those in Colormap::DEFAULT_COLORS Rich Lane
2010-02-27 7:56 ` Rich Lane
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=1264204034-7088-1-git-send-email-rlane@club.cc.cmu.edu \
--to=rlane@club.cc.cmu.edu \
--cc=sup-devel@rubyforge.org \
/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