Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Dvorak and alternative keyboard layouts in LustyJuggler #63

Merged
merged 4 commits into from
Feb 25, 2012
Merged

Support for Dvorak and alternative keyboard layouts in LustyJuggler #63

merged 4 commits into from
Feb 25, 2012

Conversation

gotgenes
Copy link
Contributor

I have added fairly robust support for the Dvorak keyboard layout to LustyJuggler by refactoring the LustyJuggler and NameBar Ruby classes. In particular, the refactoring of the LustyJuggler class makes it extensible by subclassing, which was difficult previously due to use of class variables (which are affected in parent classes upon reassignment by subclasses) and hard-coding of mapping and unmappings.

This series of commits will add support for Dvorak and lays the way for further extension of other keyboard layouts through subclassing the LustyJuggler class.

Previously, the key labels were hard-coded to the buffers displayed by
NameBar. Now NameBar requires these labels on initialization, passed in
as an array. This allows for NameBar greater flexibility and to
correctly display the correct alphabetic keys for other keyboard
layouts, such as Dvorak.
The LustyJuggler class in juggler.rb required refactoring to make it
possible to subclass the class for the purpose of allowing alternative
layouts. A central challenge was the reliance on a class variable
("@@keys"). Class variables can not be overridden for only subclasses;
setting "@@keys" to a different value in any subclass caused the mapping
to change also for the LustyJuggler parent class. See the following
webpages for further explanation on the complications of inheritance
with class variables

* http://rubysource.com/class-variables-a-ruby-gotcha/
* http://sporkmonger.com/2007/2/19/instance-variables-class-variables-and-inheritance-in-ruby
* http://ghouston.blogspot.com/2006/06/ruby-class-variables-attributes-and.html

This necessitated moving the variable to an instance variable, where it
is still private, but can be overridden easily by subclasses.

Further refactoring involved breaking apart the "@@keys" variable into
alphabetic and numeric components, and storing the cancels keys in an
instance variable, too, then looping through these data structures to
map and unmap keys, rather than have a dozen hard-coded mappings and
unmappings.

Overall the result is a LustyJuggler class that can be subclassed
somewhat easily to change the mappings.
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".
@gotgenes gotgenes mentioned this pull request Feb 23, 2012
@sjbach sjbach merged commit ca4d97e into sjbach:master Feb 25, 2012
@sjbach
Copy link
Owner

sjbach commented Feb 25, 2012

Merged - thanks!

@sjbach
Copy link
Owner

sjbach commented Feb 25, 2012

p.s. Excellent patch.

@gotgenes
Copy link
Contributor Author

Thanks so much! =-D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants