Permalink
Browse files

Update goLineStart + keybindings

  • Loading branch information...
icebeat committed May 28, 2012
1 parent 5f6ab4a commit b64a6dc881ad54594f2b216c1d56a9397847e716
Showing with 8 additions and 5 deletions.
  1. +2 −2 js/commands.js
  2. +1 −1 js/editor.js
  3. +2 −0 js/events.js
  4. +3 −2 js/layout.js
View
@@ -98,7 +98,7 @@ Extend(Editor.prototype, {
getPositionFromPoint: function (x, y) {
var element = this.element, wrapper = element.wrapper, view = element.view;
- x += wrapper.getBoundingClientRect().left + this.padding_width / 2;
+ x += wrapper.getBoundingClientRect().left + this.padding;
y += view.getBoundingClientRect().top + 8;
y -= view.scrollTop - parseInt(wrapper.style.paddingTop);
return this.getPosition(x, y);
@@ -350,7 +350,7 @@ Extend(Editor.prototype, {
},
goLineStart: function () {
var start = this.selectionStart(), position;
- position = this.getPositionFromPoint(0, start.y);
+ position = this.getPositionFromPoint(-this.padding, start.y);
this.updateView(this.shiftSelecting ? this.from : position, position);
},
goLineEnd: function () {
View
@@ -13,7 +13,7 @@ var Editor = function (lines, options) {
this.line_height = 32;
this.em_width = 13;
this.width = 832; // max_line * em_width
- this.padding_width = 156; // padding_length * em_width
+ this.padding = 156; // padding_length * em_width
this.tab_width = 64;
this.focused = null;
View
@@ -240,6 +240,8 @@ var keyBindings = {
"alt+right": "goWordRight",
"super+left": "goLineStart",
"super+right": "goLineEnd",
+ "alt+up": "goLineStart",
+ "alt+down": "goLineEnd",
"alt+backspace": "delWordLeft",
"ctrl+alt+backspace": "delWordRight",
"super+backspace": "deleteLine",
View
@@ -75,11 +75,12 @@ Extend(Editor.prototype, {
this.width = text.offsetWidth * max_line;
this.line_height = text.offsetHeight;
this.em_width = text.offsetWidth;
- this.padding_width = option.padding_length * this.em_width * 2;
+ this.padding = option.padding_length * this.em_width;
+ this.padding_width = this.padding * 2;
wrapper.style.width = this.width + this.padding_width + "px";
wrapper.style.padding = this.line_height + "px 0";
- content.style.padding = "0 " + (this.padding_width/2) + "px";
+ content.style.padding = "0 " + this.padding + "px";
},

0 comments on commit b64a6dc

Please sign in to comment.