From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by 10.213.28.69 with SMTP id l5cs51430ebc; Sun, 24 Jan 2010 19:10:53 -0800 (PST) Received: by 10.224.10.30 with SMTP id n30mr3775881qan.250.1264389051163; Sun, 24 Jan 2010 19:10:51 -0800 (PST) Return-Path: Received: from rubyforge.org (rubyforge.org [205.234.109.19]) by mx.google.com with ESMTP id 7si16327487qwb.42.2010.01.24.19.10.50; Sun, 24 Jan 2010 19:10:51 -0800 (PST) Received-SPF: pass (google.com: domain of sup-devel-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) client-ip=205.234.109.19; Authentication-Results: mx.google.com; spf=pass (google.com: domain of sup-devel-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) smtp.mail=sup-devel-bounces@rubyforge.org Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id 34F9C167830F; Sun, 24 Jan 2010 22:10:50 -0500 (EST) Received: from magnesium.club.cc.cmu.edu (MAGNESIUM.CLUB.CC.cmu.edu [128.237.157.15]) by rubyforge.org (Postfix) with ESMTP id 2D1A8185830B for ; Sun, 24 Jan 2010 22:10:48 -0500 (EST) Received: (qmail 10555 invoked from network); 25 Jan 2010 03:10:47 -0000 Received: from pion.club.cc.cmu.edu (HELO localhost.localdomain) (128.237.157.88) by magnesium.club.cc.cmu.edu with SMTP; 25 Jan 2010 03:10:47 -0000 From: Rich Lane To: sup-devel@rubyforge.org Date: Sun, 24 Jan 2010 19:09:33 -0800 Message-Id: <1264388973-5804-3-git-send-email-rlane@club.cc.cmu.edu> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1264388973-5804-2-git-send-email-rlane@club.cc.cmu.edu> References: <1264388973-5804-1-git-send-email-rlane@club.cc.cmu.edu> <1264388973-5804-2-git-send-email-rlane@club.cc.cmu.edu> Subject: [sup-devel] [PATCH 3/3] keybindings hook X-BeenThere: sup-devel@rubyforge.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: Sup developer discussion List-Id: Sup developer discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: sup-devel-bounces@rubyforge.org Errors-To: sup-devel-bounces@rubyforge.org Add a hook specifically for custom keybindings. The advantage of this over the startup hook is that we can assume it's safe to reload this one while Sup is running. The "modes" variable provides a debatably-useful mapping between user-visible mode names and the actual classes, for use with class_eval. --- bin/sup | 9 +++++++++ lib/sup/hook.rb | 1 + lib/sup/keymap.rb | 17 +++++++++++++++++ lib/sup/mode.rb | 4 ++++ 4 files changed, 31 insertions(+), 0 deletions(-) diff --git a/bin/sup b/bin/sup index 7824aca..ad1271f 100755 --- a/bin/sup +++ b/bin/sup @@ -83,8 +83,13 @@ 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", '~' + k.add_multi "Rerun (k)eybindings hook:", 'O' do |kk| + kk.add :run_keybindings_hook, "Rerun keybindings hook", 'k' + end end +Redwood::Keymap.run_hook global_keymap + ## the following magic enables wide characters when used with a ruby ## ncurses.so that's been compiled against libncursesw. (note the w.) why ## this works, i have no idea. much like pretty much every aspect of @@ -339,6 +344,10 @@ begin when :show_console b, new = bm.spawn_unless_exists("Console", :system => true) { ConsoleMode.new } b.mode.run + when :run_keybindings_hook + HookManager.clear_one 'keybindings' + Keymap.run_hook global_keymap + bm.flash "keybindings hook run" when :nothing, InputSequenceAborted when :redraw bm.completely_redraw_screen diff --git a/lib/sup/hook.rb b/lib/sup/hook.rb index 3bf9823..08738cd 100644 --- a/lib/sup/hook.rb +++ b/lib/sup/hook.rb @@ -113,6 +113,7 @@ EOS def enabled? name; !hook_for(name).nil? end def clear; @hooks.clear; end + def clear_one k; @hooks.delete k; end private diff --git a/lib/sup/keymap.rb b/lib/sup/keymap.rb index 4cdeeed..93060b8 100644 --- a/lib/sup/keymap.rb +++ b/lib/sup/keymap.rb @@ -1,6 +1,14 @@ module Redwood class Keymap + + HookManager.register "keybindings", < modes, + :global_keymap => global_keymap, + } + HookManager.run 'keybindings', locals + end end end diff --git a/lib/sup/mode.rb b/lib/sup/mode.rb index b9e0698..f5aee1c 100644 --- a/lib/sup/mode.rb +++ b/lib/sup/mode.rb @@ -14,6 +14,10 @@ class Mode @@keymaps[self] || register_keymap end + def self.keymaps + @@keymaps + end + def initialize @buffer = nil end -- 1.6.3.3 _______________________________________________ Sup-devel mailing list Sup-devel@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-devel