- @cursor[0].text.substr(@cursor[1])
- @cursor[0].el.nodeValue = @cursor[0].text
- @move_cursor [@cursor[0], @cursor[1] + 1]
+ @cursor.n.text.substr(@cursor.i)
+ @cursor.n.el.nodeValue = @cursor.n.text
+ new_cursor = new_cursor_position n: @cursor.n, i: @cursor.i + 1
+ unless new_cursor
+ # probably pressed space, and browser isn't displaying it
+ # FIXME insert instead, rip it out later if possible, etc.
+ # for now, remove it
+ @cursor.n.text =
+ @cursor.n.text.substr(0, @cursor.i) +
+ @cursor.n.text.substr(@cursor.i + 1)
+ @cursor.n.el.nodeValue = @cursor.n.text
+ return false
+ @move_cursor new_cursor