some cleanups

This commit is contained in:
Fabian Jakobs 2010-04-15 16:19:42 +02:00
commit 6a11af1a44
2 changed files with 14 additions and 12 deletions

View file

@ -10,13 +10,10 @@ ace.Editor = function(renderer, doc, mode) {
this.textInput = new ace.TextInput(container, this); this.textInput = new ace.TextInput(container, this);
new ace.KeyBinding(container, this); new ace.KeyBinding(container, this);
ace.addListener(container, "mousedown", ace ace.addListener(container, "mousedown", ace.bind(this.onMouseDown, this));
.bind(this.onMouseDown, this)); ace.addListener(container, "dblclick", ace.bind(this.onMouseDoubleClick, this));
ace.addListener(container, "dblclick", ace ace.addTripleClickListener(container, ace.bind(this.onMouseTripleClick, this));
.bind(this.onMouseDoubleClick, this));
ace.addMouseWheelListener(container, ace.bind(this.onMouseWheel, this)); ace.addMouseWheelListener(container, ace.bind(this.onMouseWheel, this));
ace.addTripleClickListener(container, ace.bind(this.selection.selectLine,
this.selection));
this.selectionMarker = null; this.selectionMarker = null;
this._blockScrolling = false; this._blockScrolling = false;
@ -176,9 +173,7 @@ ace.Editor.prototype.onMouseDown = function(e) {
selectionLead = _self.renderer.screenToTextCoordinates(mousePageX, selectionLead = _self.renderer.screenToTextCoordinates(mousePageX,
mousePageY); mousePageY);
_self.selection._moveSelection(function() { _self.selection.selectToPosition(selectionLead);
_self.moveCursorToPosition(selectionLead);
});
_self.renderer.scrollCursorIntoView(); _self.renderer.scrollCursorIntoView();
}; };
@ -188,13 +183,14 @@ ace.Editor.prototype.onMouseDown = function(e) {
return ace.preventDefault(e); return ace.preventDefault(e);
}; };
ace.Editor.prototype.tokenRe = /^[\w\d]+/g;
ace.Editor.prototype.nonTokenRe = /^[^\w\d]+/g;
ace.Editor.prototype.onMouseDoubleClick = function(e) { ace.Editor.prototype.onMouseDoubleClick = function(e) {
this.selection.selectWord(); this.selection.selectWord();
}; };
ace.Editor.prototype.onMouseTripleClick = function(e) {
this.selection.selectLine();
};
ace.Editor.prototype.onMouseWheel = function(e) { ace.Editor.prototype.onMouseWheel = function(e) {
var delta = e.wheel; var delta = e.wheel;
this.renderer.scrollToY(this.renderer.getScrollTop() - (delta * 15)); this.renderer.scrollToY(this.renderer.getScrollTop() - (delta * 15));

View file

@ -114,6 +114,12 @@ ace.Selection.prototype._moveSelection = function(mover) {
this.updateSelection(); this.updateSelection();
}; };
ace.Selection.prototype.selectToPosition = function(pos) {
this._moveSelection(function() {
this.moveCursorToPosition(pos);
});
};
ace.Selection.prototype.selectUp = function() { ace.Selection.prototype.selectUp = function() {
this._moveSelection(this.moveCursorUp); this._moveSelection(this.moveCursorUp);
}; };