Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Very basic insert mode

  • Loading branch information...
commit 0a3ea48d142291b4d496ed99f6254eff31abf99e 1 parent b66bf8f
@holizz authored
Showing with 25 additions and 3 deletions.
  1. +1 −1  index.html
  2. +24 −2 js/script.coffee
View
2  index.html
@@ -17,7 +17,7 @@
</header>
<div id="main" role="main">
- <textarea cols="80" rows="24" id="vim"></textarea>
+ <textarea autofocus cols="80" rows="24" id="vim"></textarea>
</div>
<footer>
View
26 js/script.coffee
@@ -1,2 +1,24 @@
-jQuery ->
- $('#vim').css('background','red')
+jQuery.fn.vimify = ->
+ this.mode = 'normal'
+ this.normalCommands =
+ i: =>
+ this.mode = 'insert'
+
+ this.keypress (e) =>
+ c = String.fromCharCode(e.charCode)
+ window.log(c)
+ false
+ switch this.mode
+ when 'normal'
+ if c of this.normalCommands
+ this.normalCommands[c]()
+ else
+ window.log('Error: unknown normal mode command: '+c)
+ when 'insert'
+ return true
+ else
+ window.log('Error: WTF error: '+c)
+
+ false
+
+jQuery('#vim').vimify()
Please sign in to comment.
Something went wrong with that request. Please try again.