Skip to content

Commit

Permalink
Added more to vim.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Eliot Alter authored and Eliot Alter committed Apr 14, 2012
1 parent baae140 commit 97e0b8b
Showing 1 changed file with 40 additions and 3 deletions.
43 changes: 40 additions & 3 deletions evervim/static/js/vim.js
@@ -1,18 +1,55 @@
//Global variables
var mode = MODE.NORMAL;
var row = 0;
var col = 0;

$(document).ready(function() {
var textField = $("#vimText");
textField.text("hello world");
//var textField = $("#vimText");
//textField.text("hello world");
$(document).keypress(function (event) {
event.preventDefault();
keyPress(String.fromCharCode(event.which))
});
console.log(textToLineList(textField.text(), 3));
$(document).keyup(function (event) {
if(event.which == KEYCODE.ESCAPE)
vim_escape();
});
//console.log(textToLineList(textField.text(), 3));
});

var KEYCODE = {
ESCAPE: 33
};

var MODE = {
NORMAL: 0,
INSERT: 1
};


function keyPress(c)
{
if(mode == MODE.INSERT) {
console.log("In insert mode with key " + c);
}
else if(mode == MODE.NORMAL) {
if(c == 'i') {
mode = MODE.INSERT;
}
}
console.log("Key " + c);
}

function vim_escape()
{
mode = MODE.NORMAL;
}

function insertCharacter(c)
{
//TODO: work here
}

function textToLineList(text, lineLength)
{
var textLength = text.length;
Expand Down

0 comments on commit 97e0b8b

Please sign in to comment.