Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
From: Rich Lane <rlane@club.cc.cmu.edu>
To: sup-devel@rubyforge.org
Subject: [sup-devel] [PATCH 3/3] add keybinding 'Oc' to reload colors
Date: Sun,  3 Jan 2010 07:24:20 -0800	[thread overview]
Message-ID: <1262532260-18353-3-git-send-email-rlane@club.cc.cmu.edu> (raw)
In-Reply-To: <1262532260-18353-2-git-send-email-rlane@club.cc.cmu.edu>

---
 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


  reply	other threads:[~2010-01-03 15:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-03 15:24 [sup-devel] [PATCHv2 1/3] support high colors in colors.yaml Rich Lane
2010-01-03 15:24 ` [sup-devel] [PATCH 2/3] send color errors to the log instead of flashing Rich Lane
2010-01-03 15:24   ` Rich Lane [this message]
2010-01-05 21:02     ` [sup-devel] [PATCH 3/3] add keybinding 'Oc' to reload colors William Morgan

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=1262532260-18353-3-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