Permalink
Browse files

Adds support for the Dvorak layout to LustyJuggler.

Remaps the alphabetic keys for LustyJuggler navigation to match the home
row keys for the Dvorak layout. This takes place by subclassing the
"LustyJuggler" class in juggler.rb, given as LustyJugglerDvorak.

The user can designate the desire to use the Dvorak layout for
LustyJuggler by placing the following line in his/her .vimrc:

    let g:LustyJugglerKeyboardLayout = "dvorak"

LustyJuggler will read this configuration variable and set the mapping
to Dvorak if the variable exists and is set to "dvorak".
  • Loading branch information...
1 parent a4ce28c commit 8ae0a50f21ac063cdc6aaa1f1bb63c0eea22e990 @gotgenes gotgenes committed Feb 23, 2012
Showing with 46 additions and 3 deletions.
  1. +20 −2 src/juggler.vim
  2. +26 −1 src/lusty/juggler.rb
View
@@ -32,7 +32,8 @@
" new bar showing the names of currently-opened buffers in
" most-recently-used order.
"
-" The buffers are mapped to these keys:
+" By default, LustyJuggler follows the QWERTY layout, and
+" buffers are mapped to these keys:
"
" 1st|2nd|3rd|4th|5th|6th|7th|8th|9th|10th
" ----------------------------------------
@@ -57,6 +58,19 @@
" To cancel the juggler, press any of "q", "<ESC>", "<C-c",
" "<BS>", "<Del>", or "<C-h>".
"
+" LustyJuggler also supports the Dvorak keyboard layout. To
+" enable this feature, place the following in your .vimrc:
+"
+" let g:LustyJugglerKeyboardLayout = "dvorak"
+"
+" With the layout set to "dvorak", the buffer mapping is as
+" follows:
+"
+" 1st|2nd|3rd|4th|5th|6th|7th|8th|9th|10th
+" ----------------------------------------
+" a o e u i d h t n s
+" 1 2 3 4 5 6 7 8 9 0
+"
" LustyJuggler can act very much like <A-Tab> window switching.
" To enable this mode, add the following line to your .vimrc:
"
@@ -266,7 +280,11 @@ end
{{RUBY_CODE_INSERTION_POINT}}
-$lusty_juggler = LustyJ::LustyJuggler.new
+if VIM::exists?('g:LustyJugglerKeyboardLayout') and VIM::evaluate_bool('g:LustyJugglerKeyboardLayout == "dvorak"')
+ $lusty_juggler = LustyJ::LustyJugglerDvorak.new
+else
+ $lusty_juggler = LustyJ::LustyJuggler.new
+end
$lj_buffer_stack = LustyJ::BufferStack.new
EOF
View
@@ -230,5 +230,30 @@ def unmap_key(key)
end
end
end
-end
+class LustyJugglerDvorak < LustyJuggler
+ public
+ def initialize
+ super
+ alpha_buffer_keys = [
+ "a",
+ "o",
+ "e",
+ "u",
+ "i",
+ "d",
+ "h",
+ "t",
+ "n",
+ "s",
+ ]
+ @name_bar = NameBar.new(alpha_buffer_keys)
+ @ALPHA_BUFFER_KEYS = Hash.new
+ alpha_buffer_keys.each_with_index {|x, i| @ALPHA_BUFFER_KEYS[x] = i + 1}
+ @BUFFER_KEYS = @ALPHA_BUFFER_KEYS.merge(@NUMERIC_BUFFER_KEYS)
+ @KEYPRESS_MAPPINGS = @BUFFER_KEYS.merge(@KEYPRESS_KEYS)
+ @CANCEL_MAPPINGS.delete("i")
+ @CANCEL_MAPPINGS.push("c")
+ end
+end
+end

0 comments on commit 8ae0a50

Please sign in to comment.