[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sup-devel] [PATCH 3/3] add keybinding 'Oc' to reload colors



---
 bin/sup             |   10 ++++++++++
 lib/sup/colormap.rb |    6 +++++-
 2 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/bin/sup b/bin/sup
index 5571598..0716e55 100755
--- 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
@@ -326,6 +331,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
index d28c550..6f21f9a 100644
--- 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]
-- 
1.6.3.3

_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel