commit 109ed4ae2a8cdeb7415f54478ed8107c8968eeba
parent 7bef236860784171c43b186dfd5d3af466a9d416
Author: Rich Lane <rlane@club.cc.cmu.edu>
Date: Sun, 3 Jan 2010 07:24:20 -0800
add keybinding 'Oc' to reload colors
Diffstat:
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/bin/sup b/bin/sup
@@ -96,6 +96,11 @@ global_keymap = Keymap.new do |k|
k.add :recall_draft, "Edit most recent draft message", 'R'
k.add :show_inbox, "Show the Inbox buffer", 'I'
k.add :show_console, "Show the Console buffer", '~'
+
+ ## Submap for less often used keybindings
+ k.add_multi "reload (c)olors", 'O' do |kk|
+ kk.add :reload_colors, "Reload colors", 'c'
+ end
end
## the following magic enables wide characters when used with a ruby
@@ -324,6 +329,11 @@ begin
when :show_console
b, new = bm.spawn_unless_exists("Console", :system => true) { ConsoleMode.new }
b.mode.run
+ when :reload_colors
+ Colormap.reset
+ Colormap.populate_colormap
+ bm.completely_redraw_screen
+ bm.flash "reloaded colors"
when :nothing, InputSequenceAborted
when :redraw
bm.completely_redraw_screen
diff --git a/lib/sup/colormap.rb b/lib/sup/colormap.rb
@@ -68,11 +68,15 @@ class Colormap
def initialize
raise "only one instance can be created" if @@instance
@@instance = self
- @entries = {}
@color_pairs = {[Curses::COLOR_WHITE, Curses::COLOR_BLACK] => 0}
@users = []
@next_id = 0
+ reset
yield self if block_given?
+ end
+
+ def reset
+ @entries = {}
@entries[highlight_sym(:none)] = highlight_for(Curses::COLOR_WHITE,
Curses::COLOR_BLACK,
[]) + [nil]