add selection.moveTo
This commit is contained in:
parent
4a80bd7b3d
commit
42a368ed02
11 changed files with 46 additions and 44 deletions
|
|
@ -86,8 +86,7 @@ var AcePopup = function(parentNode) {
|
|||
|
||||
popup.on("mousedown", function(e) {
|
||||
var pos = e.getDocumentPosition();
|
||||
popup.moveCursorToPosition(pos);
|
||||
popup.selection.clearSelection();
|
||||
popup.selection.moveToPosition(pos);
|
||||
selectionMarker.start.row = selectionMarker.end.row = pos.row;
|
||||
e.stop();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -281,13 +281,13 @@ var EditSession = function(text, mode) {
|
|||
**/
|
||||
this.setValue = function(text) {
|
||||
this.doc.setValue(text);
|
||||
this.selection.moveCursorTo(0, 0);
|
||||
this.selection.clearSelection();
|
||||
this.selection.moveTo(0, 0);
|
||||
|
||||
this.$resetRowCache(0);
|
||||
this.$deltas = [];
|
||||
this.$deltasDoc = [];
|
||||
this.$deltasFold = [];
|
||||
this.setUndoManager(this.$undoManager);
|
||||
this.getUndoManager().reset();
|
||||
};
|
||||
|
||||
|
|
@ -412,7 +412,7 @@ var EditSession = function(text, mode) {
|
|||
}
|
||||
self.mergeUndoDeltas = false;
|
||||
self.$deltas = [];
|
||||
}
|
||||
};
|
||||
this.$informUndoManager = lang.delayedCall(this.$syncInformUndoManager);
|
||||
}
|
||||
};
|
||||
|
|
@ -696,7 +696,7 @@ var EditSession = function(text, mode) {
|
|||
this.$searchHighlight = this.addDynamicMarker(highlight);
|
||||
}
|
||||
this.$searchHighlight.setRegexp(re);
|
||||
}
|
||||
};
|
||||
|
||||
// experimental
|
||||
this.highlightLines = function(startRow, endRow, clazz, inFront) {
|
||||
|
|
|
|||
|
|
@ -1941,8 +1941,7 @@ var Editor = function(renderer, session) {
|
|||
else
|
||||
this.selection.selectTo(pos.row, pos.column);
|
||||
} else {
|
||||
this.clearSelection();
|
||||
this.moveCursorTo(pos.row, pos.column);
|
||||
this.selection.moveTo(pos.row, pos.column);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -1977,8 +1976,7 @@ var Editor = function(renderer, session) {
|
|||
* @related Editor.moveCursorTo
|
||||
**/
|
||||
this.navigateTo = function(row, column) {
|
||||
this.clearSelection();
|
||||
this.moveCursorTo(row, column);
|
||||
this.selection.moveTo(row, column);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -1993,8 +1991,7 @@ var Editor = function(renderer, session) {
|
|||
return this.moveCursorToPosition(selectionStart);
|
||||
}
|
||||
this.selection.clearSelection();
|
||||
times = times || 1;
|
||||
this.selection.moveCursorBy(-times, 0);
|
||||
this.selection.moveCursorBy(-times || -1, 0);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -2009,8 +2006,7 @@ var Editor = function(renderer, session) {
|
|||
return this.moveCursorToPosition(selectionEnd);
|
||||
}
|
||||
this.selection.clearSelection();
|
||||
times = times || 1;
|
||||
this.selection.moveCursorBy(times, 0);
|
||||
this.selection.moveCursorBy(times || 1, 0);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -2154,8 +2150,7 @@ var Editor = function(renderer, session) {
|
|||
this.$blockScrolling += 1;
|
||||
|
||||
var selection = this.getSelectionRange();
|
||||
this.clearSelection();
|
||||
this.selection.moveCursorTo(0, 0);
|
||||
this.selection.moveTo(0, 0);
|
||||
|
||||
for (var i = ranges.length - 1; i >= 0; --i) {
|
||||
if(this.$tryReplace(ranges[i], replacement)) {
|
||||
|
|
|
|||
|
|
@ -130,8 +130,7 @@ AceEmmetEditor.prototype = {
|
|||
*/
|
||||
setCaretPos: function(index){
|
||||
var pos = this.ace.indexToPosition(index);
|
||||
this.ace.clearSelection();
|
||||
this.ace.selection.moveCursorToPosition(pos);
|
||||
this.ace.selection.moveToPosition(pos);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -122,8 +122,7 @@ exports.showErrorMarker = function(editor, dir) {
|
|||
};
|
||||
}
|
||||
editor.session.unfold(pos.row);
|
||||
editor.selection.moveCursorToPosition(pos);
|
||||
editor.selection.clearSelection();
|
||||
editor.selection.moveToPosition(pos);
|
||||
|
||||
var w = {
|
||||
row: pos.row,
|
||||
|
|
|
|||
|
|
@ -201,8 +201,7 @@ var actions = exports.actions = {
|
|||
//editor.selection.selectLine();
|
||||
//editor.selection.selectLeft();
|
||||
var row = editor.getCursorPosition().row;
|
||||
editor.selection.clearSelection();
|
||||
editor.selection.moveCursorTo(row, 0);
|
||||
editor.selection.moveTo(row, 0);
|
||||
editor.selection.selectLineEnd();
|
||||
editor.selection.visualLineStart = row;
|
||||
|
||||
|
|
@ -582,13 +581,11 @@ var handleCursorMove = exports.onCursorMove = function(editor, e) {
|
|||
var cursorRow = editor.getCursorPosition().row;
|
||||
if(originRow <= cursorRow) {
|
||||
var endLine = editor.session.getLine(cursorRow);
|
||||
editor.selection.clearSelection();
|
||||
editor.selection.moveCursorTo(originRow, 0);
|
||||
editor.selection.moveTo(originRow, 0);
|
||||
editor.selection.selectTo(cursorRow, endLine.length);
|
||||
} else {
|
||||
var endLine = editor.session.getLine(originRow);
|
||||
editor.selection.clearSelection();
|
||||
editor.selection.moveCursorTo(originRow, endLine.length);
|
||||
editor.selection.moveTo(originRow, endLine.length);
|
||||
editor.selection.selectTo(cursorRow, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,8 +53,7 @@ function Motion(m) {
|
|||
var a = getPos(editor, range, count, param, false);
|
||||
if (!a)
|
||||
return;
|
||||
editor.clearSelection();
|
||||
editor.moveCursorTo(a.row, a.column);
|
||||
editor.selection.moveTo(a.row, a.column);
|
||||
};
|
||||
m.sel = function(editor, range, count, param) {
|
||||
var a = getPos(editor, range, count, param, true);
|
||||
|
|
|
|||
|
|
@ -122,13 +122,11 @@ module.exports = {
|
|||
},
|
||||
copyLine: function(editor) {
|
||||
var pos = editor.getCursorPosition();
|
||||
editor.selection.clearSelection();
|
||||
editor.moveCursorTo(pos.row, pos.column);
|
||||
editor.selection.moveTo(pos.row, pos.column);
|
||||
editor.selection.selectLine();
|
||||
registers._default.isLine = true;
|
||||
registers._default.text = editor.getCopyText().replace(/\n$/, "");
|
||||
editor.selection.clearSelection();
|
||||
editor.moveCursorTo(pos.row, pos.column);
|
||||
editor.selection.moveTo(pos.row, pos.column);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -72,8 +72,7 @@ function DefaultHandlers(mouseHandler) {
|
|||
var selectionEmpty = selectionRange.isEmpty();
|
||||
|
||||
if (selectionEmpty) {
|
||||
editor.moveCursorToPosition(pos);
|
||||
editor.selection.clearSelection();
|
||||
editor.selection.moveToPosition(pos);
|
||||
}
|
||||
|
||||
// 2: contextmenu, 1: linux paste
|
||||
|
|
@ -93,6 +92,7 @@ function DefaultHandlers(mouseHandler) {
|
|||
}
|
||||
}
|
||||
|
||||
this.captureMouse(ev);
|
||||
if (!inSelection || this.$clickSelection || ev.getShiftKey() || editor.inMultiSelectMode) {
|
||||
// Directly pick STATE_SELECT, since the user is not clicking inside
|
||||
// a selection.
|
||||
|
|
@ -101,7 +101,6 @@ function DefaultHandlers(mouseHandler) {
|
|||
this.mousedownEvent.time = Date.now();
|
||||
this.startSelect(pos);
|
||||
}
|
||||
this.captureMouse(ev);
|
||||
return ev.preventDefault();
|
||||
};
|
||||
|
||||
|
|
@ -114,8 +113,7 @@ function DefaultHandlers(mouseHandler) {
|
|||
editor.selection.selectToPosition(pos);
|
||||
}
|
||||
else if (!this.$clickSelection) {
|
||||
editor.moveCursorToPosition(pos);
|
||||
editor.selection.clearSelection();
|
||||
editor.selection.moveToPosition(pos);
|
||||
}
|
||||
if (editor.renderer.scroller.setCapture) {
|
||||
editor.renderer.scroller.setCapture();
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ define(function(require, exports, module) {
|
|||
|
||||
var event = require("../lib/event");
|
||||
|
||||
|
||||
// mouse
|
||||
function isSamePoint(p1, p2) {
|
||||
return p1.row == p2.row && p1.column == p2.column;
|
||||
|
|
@ -79,8 +78,7 @@ function onMouseDown(e) {
|
|||
return;
|
||||
screenCursor = newCursor;
|
||||
|
||||
editor.selection.moveCursorToPosition(cursor);
|
||||
editor.selection.clearSelection();
|
||||
editor.selection.moveToPosition(cursor);
|
||||
editor.renderer.scrollCursorIntoView();
|
||||
|
||||
editor.removeSelectionMarkers(rectSel);
|
||||
|
|
@ -95,7 +93,7 @@ function onMouseDown(e) {
|
|||
|
||||
|
||||
|
||||
if (ctrl && !shift && !alt && button == 0) {
|
||||
if (ctrl && !alt && !shift && button === 0) {
|
||||
if (!isMultiSelect && inSelection)
|
||||
return; // dragging
|
||||
|
||||
|
|
@ -122,7 +120,7 @@ function onMouseDown(e) {
|
|||
editor.$blockScrolling--;
|
||||
});
|
||||
|
||||
} else if (alt && button == 0) {
|
||||
} else if (alt && button === 0) {
|
||||
e.stop();
|
||||
|
||||
if (isMultiSelect && !ctrl)
|
||||
|
|
@ -135,8 +133,7 @@ function onMouseDown(e) {
|
|||
screenAnchor = session.documentToScreenPosition(selection.lead);
|
||||
blockSelect();
|
||||
} else {
|
||||
selection.moveCursorToPosition(pos);
|
||||
selection.clearSelection();
|
||||
selection.moveToPosition(pos);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -298,6 +298,27 @@ var Selection = function(session) {
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Moves the selection cursor to the indicated row and column.
|
||||
* @param {Number} row The row to select to
|
||||
* @param {Number} column The column to select to
|
||||
*
|
||||
**/
|
||||
this.moveTo = function(row, column) {
|
||||
this.clearSelection();
|
||||
this.moveCursorTo(row, column);
|
||||
};
|
||||
|
||||
/**
|
||||
* Moves the selection cursor to the row and column indicated by `pos`.
|
||||
* @param {Object} pos An object containing the row and column
|
||||
**/
|
||||
this.moveToPosition = function(pos) {
|
||||
this.clearSelection();
|
||||
this.moveCursorToPosition(pos);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Moves the selection up one row.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue