commit
f25b14a328
19 changed files with 590 additions and 308 deletions
|
|
@ -306,13 +306,7 @@ var Autocomplete = function() {
|
|||
};
|
||||
|
||||
this.cancelContextMenu = function() {
|
||||
var stop = function(e) {
|
||||
this.editor.off("nativecontextmenu", stop);
|
||||
if (e && e.domEvent)
|
||||
event.stopEvent(e.domEvent);
|
||||
}.bind(this);
|
||||
setTimeout(stop, 10);
|
||||
this.editor.on("nativecontextmenu", stop);
|
||||
this.editor.$mouseHandler.cancelContextMenu();
|
||||
};
|
||||
|
||||
}).call(Autocomplete.prototype);
|
||||
|
|
|
|||
|
|
@ -485,15 +485,15 @@ function Folding() {
|
|||
};
|
||||
|
||||
this.getFoldDisplayLine = function(foldLine, endRow, endColumn, startRow, startColumn) {
|
||||
if (startRow == null) {
|
||||
if (startRow == null)
|
||||
startRow = foldLine.start.row;
|
||||
if (startColumn == null)
|
||||
startColumn = 0;
|
||||
}
|
||||
|
||||
if (endRow == null) {
|
||||
if (endRow == null)
|
||||
endRow = foldLine.end.row;
|
||||
if (endColumn == null)
|
||||
endColumn = this.getLine(endRow).length;
|
||||
}
|
||||
|
||||
|
||||
// Build the textline using the FoldLine walker.
|
||||
var doc = this.doc;
|
||||
|
|
|
|||
|
|
@ -121,40 +121,45 @@ var loadSnippetFile = function(id) {
|
|||
});
|
||||
};
|
||||
|
||||
var doLiveAutocomplete = function(e) {
|
||||
var editor = e.editor;
|
||||
var text = e.args || "";
|
||||
function getCompletionPrefix(editor) {
|
||||
var pos = editor.getCursorPosition();
|
||||
var line = editor.session.getLine(pos.row);
|
||||
var hasCompleter = editor.completer && editor.completer.activated;
|
||||
var prefix = util.retrievePrecedingIdentifier(line, pos.column);
|
||||
|
||||
//Try to find custom prefixes on the completers
|
||||
completers.forEach(function(completer) {
|
||||
// Try to find custom prefixes on the completers
|
||||
editor.completers.forEach(function(completer) {
|
||||
if (completer.identifierRegexps) {
|
||||
completer.identifierRegexps.forEach(function(identifierRegex) {
|
||||
if (!prefix) {
|
||||
if (!prefix && identifierRegex)
|
||||
prefix = util.retrievePrecedingIdentifier(line, pos.column, identifierRegex);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return prefix;
|
||||
}
|
||||
|
||||
var doLiveAutocomplete = function(e) {
|
||||
var editor = e.editor;
|
||||
var text = e.args || "";
|
||||
var hasCompleter = editor.completer && editor.completer.activated;
|
||||
|
||||
|
||||
|
||||
// We don't want to autocomplete with no prefix
|
||||
if (e.command.name === "backspace" && !prefix) {
|
||||
if (hasCompleter)
|
||||
if (e.command.name === "backspace") {
|
||||
if (hasCompleter && !getCompletionPrefix(editor))
|
||||
editor.completer.detach();
|
||||
}
|
||||
else if (e.command.name === "insertstring") {
|
||||
var prefix = getCompletionPrefix(editor);
|
||||
// Only autocomplete if there's a prefix that can be matched
|
||||
if (prefix && !hasCompleter) {
|
||||
if (!editor.completer) {
|
||||
// Create new autocompleter
|
||||
editor.completer = new Autocomplete();
|
||||
// Disable autoInsert
|
||||
editor.completer.autoSelect = false;
|
||||
editor.completer.autoInsert = false;
|
||||
}
|
||||
// Disable autoInsert
|
||||
editor.completer.autoSelect = false;
|
||||
editor.completer.autoInsert = false;
|
||||
editor.completer.showPopup(editor);
|
||||
} else if (!prefix && hasCompleter) {
|
||||
// When the prefix is empty
|
||||
|
|
@ -169,7 +174,8 @@ require("../config").defineOptions(Editor.prototype, "editor", {
|
|||
enableBasicAutocompletion: {
|
||||
set: function(val) {
|
||||
if (val) {
|
||||
this.completers = Array.isArray(val)? val: completers;
|
||||
if (!this.completers)
|
||||
this.completers = Array.isArray(val)? val: completers;
|
||||
this.commands.addCommand(Autocomplete.startCommand);
|
||||
} else {
|
||||
this.commands.removeCommand(Autocomplete.startCommand);
|
||||
|
|
@ -184,7 +190,8 @@ require("../config").defineOptions(Editor.prototype, "editor", {
|
|||
enableLiveAutocompletion: {
|
||||
set: function(val) {
|
||||
if (val) {
|
||||
this.completers = Array.isArray(val)? val: completers;
|
||||
if (!this.completers)
|
||||
this.completers = Array.isArray(val)? val: completers;
|
||||
// On each change automatically trigger the autocomplete
|
||||
this.commands.on('afterExec', doLiveAutocomplete);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ var supportedModes = {
|
|||
C9Search: ["c9search_results"],
|
||||
C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp"],
|
||||
Cirru: ["cirru|cr"],
|
||||
Clojure: ["clj"],
|
||||
Clojure: ["clj|cljs"],
|
||||
Cobol: ["CBL|COB"],
|
||||
coffee: ["coffee|cf|cson|^Cakefile"],
|
||||
ColdFusion: ["cfm"],
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ exports.$detectIndentation = function(lines, fallback) {
|
|||
if (!/^\s*[^*+\-\s]/.test(line))
|
||||
continue;
|
||||
|
||||
var tabs = line.match(/^\t*/)[0].length;
|
||||
if (line[0] == "\t")
|
||||
tabIndents++;
|
||||
|
||||
|
|
@ -65,9 +64,6 @@ exports.$detectIndentation = function(lines, fallback) {
|
|||
line = lines[i++];
|
||||
}
|
||||
|
||||
if (!stats.length)
|
||||
return;
|
||||
|
||||
function getScore(indent) {
|
||||
var score = 0;
|
||||
for (var i = indent; i < stats.length; i += indent)
|
||||
|
|
@ -82,7 +78,7 @@ exports.$detectIndentation = function(lines, fallback) {
|
|||
for (var i = 1; i < 12; i++) {
|
||||
if (i == 1) {
|
||||
spaceIndents = getScore(i);
|
||||
var score = 1;
|
||||
var score = stats.length && 1;
|
||||
} else
|
||||
var score = getScore(i) / spaceIndents;
|
||||
|
||||
|
|
@ -99,7 +95,7 @@ exports.$detectIndentation = function(lines, fallback) {
|
|||
if (tabIndents > spaceIndents + 1)
|
||||
return {ch: "\t", length: tabLength};
|
||||
|
||||
if (spaceIndents + 1 > tabIndents)
|
||||
if (spaceIndents > tabIndents + 1)
|
||||
return {ch: " ", length: tabLength};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ define(function(require, exports, module) {
|
|||
|
||||
var util = require("./util");
|
||||
var registers = require("../registers");
|
||||
var Range = require("../../../range").Range;
|
||||
|
||||
module.exports = {
|
||||
"d": {
|
||||
|
|
@ -90,15 +91,18 @@ module.exports = {
|
|||
count = count || 1;
|
||||
switch (param) {
|
||||
case "c":
|
||||
for (var i = 0; i < count; i++) {
|
||||
editor.removeLines();
|
||||
util.insertMode(editor);
|
||||
}
|
||||
|
||||
editor.$blockScrolling++;
|
||||
editor.selection.$moveSelection(function() {
|
||||
editor.selection.moveCursorBy(count - 1, 0);
|
||||
});
|
||||
var rows = editor.$getSelectedRows();
|
||||
range = new Range(rows.first, 0, rows.last, Infinity);
|
||||
editor.session.remove(range);
|
||||
editor.$blockScrolling--;
|
||||
util.insertMode(editor);
|
||||
break;
|
||||
default:
|
||||
if (range) {
|
||||
|
||||
// range.end.column ++;
|
||||
editor.session.remove(range);
|
||||
util.insertMode(editor);
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ exports.preventDefault = function(e) {
|
|||
exports.getButton = function(e) {
|
||||
if (e.type == "dblclick")
|
||||
return 0;
|
||||
if (e.type == "contextmenu" || (e.ctrlKey && useragent.isMac))
|
||||
if (e.type == "contextmenu" || (useragent.isMac && (e.ctrlKey && !e.altKey && !e.shiftKey)))
|
||||
return 2;
|
||||
|
||||
// DOM Event
|
||||
|
|
@ -183,7 +183,7 @@ exports.addMultiMouseDownListener = function(el, timeouts, eventHandler, callbac
|
|||
if (!timer || isNewClick)
|
||||
clicks = 1;
|
||||
if (timer)
|
||||
clearTimeout(timer)
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(function() {timer = null}, timeouts[clicks - 1] || 600);
|
||||
|
||||
if (clicks == 1) {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -74,14 +74,21 @@ oop.inherits(Mode, TextMode);
|
|||
};
|
||||
|
||||
this.checkOutdent = function(state, line, input) {
|
||||
return /^\s+end$/.test(line + input) || /^\s+}$/.test(line + input) || /^\s+else$/.test(line + input);
|
||||
return /^\s+(end|else)$/.test(line + input) || this.$outdent.checkOutdent(line, input);
|
||||
};
|
||||
|
||||
this.autoOutdent = function(state, doc, row) {
|
||||
var indent = this.$getIndent(doc.getLine(row));
|
||||
var tab = doc.getTabString();
|
||||
if (indent.slice(-tab.length) == tab)
|
||||
doc.remove(new Range(row, indent.length-tab.length, row, indent.length));
|
||||
this.autoOutdent = function(state, session, row) {
|
||||
var line = session.getLine(row);
|
||||
if (/}/.test(line))
|
||||
return this.$outdent.autoOutdent(session, row);
|
||||
var indent = this.$getIndent(line);
|
||||
var prevLine = session.getLine(row - 1);
|
||||
var prevIndent = this.$getIndent(prevLine);
|
||||
var tab = session.getTabString();
|
||||
if (prevIndent.length <= indent.length) {
|
||||
if (indent.slice(-tab.length) == tab)
|
||||
session.remove(new Range(row, indent.length-tab.length, row, indent.length));
|
||||
}
|
||||
};
|
||||
|
||||
this.$id = "ace/mode/ruby";
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ var Mode = function() {
|
|||
|
||||
this.getTokenizer = function() {
|
||||
if (!this.$tokenizer) {
|
||||
this.$highlightRules = new this.HighlightRules();
|
||||
this.$highlightRules = this.$highlightRules || new this.HighlightRules();
|
||||
this.$tokenizer = new Tokenizer(this.$highlightRules.getRules());
|
||||
}
|
||||
return this.$tokenizer;
|
||||
|
|
|
|||
|
|
@ -109,12 +109,15 @@ function DefaultHandlers(mouseHandler) {
|
|||
var editor = this.editor;
|
||||
// allow double/triple click handlers to change selection
|
||||
var shiftPressed = this.mousedownEvent.getShiftKey();
|
||||
if (shiftPressed) {
|
||||
editor.selection.selectToPosition(pos);
|
||||
}
|
||||
else if (!this.$clickSelection) {
|
||||
editor.selection.moveToPosition(pos);
|
||||
}
|
||||
setTimeout(function(){
|
||||
if (shiftPressed) {
|
||||
editor.selection.selectToPosition(pos);
|
||||
}
|
||||
else if (!this.$clickSelection) {
|
||||
editor.selection.moveToPosition(pos);
|
||||
}
|
||||
this.select();
|
||||
}.bind(this), 0);
|
||||
if (editor.renderer.scroller.setCapture) {
|
||||
editor.renderer.scroller.setCapture();
|
||||
}
|
||||
|
|
@ -213,7 +216,6 @@ function DefaultHandlers(mouseHandler) {
|
|||
this.setState("selectByWords");
|
||||
}
|
||||
this.$clickSelection = range;
|
||||
this[this.state] && this[this.state](ev);
|
||||
};
|
||||
|
||||
this.onTripleClick = function(ev) {
|
||||
|
|
@ -221,8 +223,13 @@ function DefaultHandlers(mouseHandler) {
|
|||
var editor = this.editor;
|
||||
|
||||
this.setState("selectByLines");
|
||||
this.$clickSelection = editor.selection.getLineRange(pos.row);
|
||||
this[this.state] && this[this.state](ev);
|
||||
var range = editor.getSelectionRange();
|
||||
if (range.isMultiLine() && range.contains(pos.row, pos.column)) {
|
||||
this.$clickSelection = editor.selection.getLineRange(range.start.row);
|
||||
this.$clickSelection.end = editor.selection.getLineRange(range.end.row).end;
|
||||
} else {
|
||||
this.$clickSelection = editor.selection.getLineRange(pos.row);
|
||||
}
|
||||
};
|
||||
|
||||
this.onQuadClick = function(ev) {
|
||||
|
|
|
|||
|
|
@ -173,6 +173,17 @@ var MouseHandler = function(editor) {
|
|||
var timerId = setInterval(onCaptureInterval, 20);
|
||||
};
|
||||
this.releaseMouse = null;
|
||||
this.cancelContextMenu = function() {
|
||||
var stop = function(e) {
|
||||
if (e && e.domEvent && e.domEvent.type != "contextmenu")
|
||||
return;
|
||||
this.editor.off("nativecontextmenu", stop);
|
||||
if (e && e.domEvent)
|
||||
event.stopEvent(e.domEvent);
|
||||
}.bind(this);
|
||||
setTimeout(stop, 10);
|
||||
this.editor.on("nativecontextmenu", stop);
|
||||
};
|
||||
}).call(MouseHandler.prototype);
|
||||
|
||||
config.defineOptions(MouseHandler.prototype, "mouseHandler", {
|
||||
|
|
|
|||
|
|
@ -58,15 +58,17 @@ module.exports = {
|
|||
next();
|
||||
},
|
||||
|
||||
"test: double tap. issue #956" : function() {
|
||||
"test: double tap. issue #956" : function(done) {
|
||||
// mouse up fired immediately after mouse down
|
||||
var target = this.editor.renderer.getMouseEventTarget();
|
||||
target.dispatchEvent(MouseEvent("down", {x: 1, y: 1}));
|
||||
target.dispatchEvent(MouseEvent("up", {x: 1, y: 1}));
|
||||
target.dispatchEvent(MouseEvent("down", {x: 1, y: 1, detail: 2}));
|
||||
target.dispatchEvent(MouseEvent("up", {x: 1, y: 1, detail: 2}));
|
||||
|
||||
assert.equal(this.editor.getSelectedText(), "Juhu");
|
||||
setTimeout(function() {
|
||||
assert.equal(this.editor.getSelectedText(), "Juhu");
|
||||
done();
|
||||
}.bind(this));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
define(function(require, exports, module) {
|
||||
|
||||
var event = require("../lib/event");
|
||||
var useragent = require("../lib/useragent");
|
||||
|
||||
// mouse
|
||||
function isSamePoint(p1, p2) {
|
||||
|
|
@ -41,19 +42,26 @@ function onMouseDown(e) {
|
|||
var ev = e.domEvent;
|
||||
var alt = ev.altKey;
|
||||
var shift = ev.shiftKey;
|
||||
var ctrl = e.getAccelKey();
|
||||
var ctrl = ev.ctrlKey;
|
||||
var accel = e.getAccelKey();
|
||||
var button = e.getButton();
|
||||
|
||||
if (ctrl && useragent.isMac)
|
||||
button = ev.button;
|
||||
|
||||
if (e.editor.inMultiSelectMode && button == 2) {
|
||||
e.editor.textInput.onContextMenu(e.domEvent);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ctrl && !alt) {
|
||||
if (!ctrl && !alt && !accel) {
|
||||
if (button === 0 && e.editor.inMultiSelectMode)
|
||||
e.editor.exitMultiSelectMode();
|
||||
return;
|
||||
}
|
||||
|
||||
if (button !== 0)
|
||||
return;
|
||||
|
||||
var editor = e.editor;
|
||||
var selection = editor.selection;
|
||||
|
|
@ -62,38 +70,37 @@ function onMouseDown(e) {
|
|||
var cursor = selection.getCursor();
|
||||
var inSelection = e.inSelection() || (selection.isEmpty() && isSamePoint(pos, cursor));
|
||||
|
||||
|
||||
var mouseX = e.x, mouseY = e.y;
|
||||
var onMouseSelection = function(e) {
|
||||
mouseX = e.clientX;
|
||||
mouseY = e.clientY;
|
||||
};
|
||||
|
||||
var blockSelect = function() {
|
||||
var newCursor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
|
||||
var cursor = session.screenToDocumentPosition(newCursor.row, newCursor.column);
|
||||
|
||||
if (isSamePoint(screenCursor, newCursor)
|
||||
&& isSamePoint(cursor, selection.selectionLead))
|
||||
return;
|
||||
screenCursor = newCursor;
|
||||
|
||||
editor.selection.moveToPosition(cursor);
|
||||
editor.renderer.scrollCursorIntoView();
|
||||
|
||||
editor.removeSelectionMarkers(rectSel);
|
||||
rectSel = selection.rectangularRangeBlock(screenCursor, screenAnchor);
|
||||
rectSel.forEach(editor.addSelectionMarker, editor);
|
||||
editor.updateSelectionMarkers();
|
||||
};
|
||||
|
||||
var session = editor.session;
|
||||
var screenAnchor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
|
||||
var screenCursor = screenAnchor;
|
||||
|
||||
|
||||
var selectionMode;
|
||||
if (editor.$mouseHandler.$enableJumpToDef) {
|
||||
if (ctrl && alt || accel && alt)
|
||||
selectionMode = "add";
|
||||
else if (alt)
|
||||
selectionMode = "block";
|
||||
} else {
|
||||
if (accel && !alt) {
|
||||
selectionMode = "add";
|
||||
if (!isMultiSelect && shift)
|
||||
return;
|
||||
} else if (alt) {
|
||||
selectionMode = "block";
|
||||
}
|
||||
}
|
||||
|
||||
if (selectionMode && useragent.isMac && ev.ctrlKey) {
|
||||
editor.$mouseHandler.cancelContextMenu();
|
||||
}
|
||||
|
||||
if (ctrl && !alt && !shift && button === 0) {
|
||||
if (selectionMode == "add") {
|
||||
if (!isMultiSelect && inSelection)
|
||||
return; // dragging
|
||||
|
||||
|
|
@ -104,44 +111,86 @@ function onMouseDown(e) {
|
|||
|
||||
var oldRange = selection.rangeList.rangeAtPoint(pos);
|
||||
|
||||
|
||||
editor.$blockScrolling++;
|
||||
editor.inVirtualSelectionMode = true;
|
||||
|
||||
if (shift) {
|
||||
oldRange = null;
|
||||
range = selection.ranges[0];
|
||||
editor.removeSelectionMarker(range);
|
||||
}
|
||||
editor.once("mouseup", function() {
|
||||
var tmpSel = selection.toOrientedRange();
|
||||
|
||||
if (oldRange && tmpSel.isEmpty() && isSamePoint(oldRange.cursor, tmpSel.cursor))
|
||||
selection.substractPoint(tmpSel.cursor);
|
||||
else {
|
||||
if (range) {
|
||||
if (shift) {
|
||||
selection.substractPoint(range.cursor);
|
||||
} else if (range) {
|
||||
editor.removeSelectionMarker(range);
|
||||
selection.addRange(range);
|
||||
}
|
||||
selection.addRange(tmpSel);
|
||||
}
|
||||
editor.$blockScrolling--;
|
||||
editor.inVirtualSelectionMode = false;
|
||||
});
|
||||
|
||||
} else if (alt && button === 0) {
|
||||
} else if (selectionMode == "block") {
|
||||
e.stop();
|
||||
|
||||
if (isMultiSelect && !ctrl)
|
||||
selection.toSingleRange();
|
||||
else if (!isMultiSelect && ctrl)
|
||||
selection.addRange();
|
||||
|
||||
editor.inVirtualSelectionMode = true;
|
||||
var initialRange;
|
||||
var rectSel = [];
|
||||
if (shift) {
|
||||
screenAnchor = session.documentToScreenPosition(selection.lead);
|
||||
blockSelect();
|
||||
} else {
|
||||
selection.moveToPosition(pos);
|
||||
}
|
||||
var blockSelect = function() {
|
||||
var newCursor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
|
||||
var cursor = session.screenToDocumentPosition(newCursor.row, newCursor.column);
|
||||
|
||||
if (isSamePoint(screenCursor, newCursor) && isSamePoint(cursor, selection.lead))
|
||||
return;
|
||||
screenCursor = newCursor;
|
||||
|
||||
editor.selection.moveToPosition(cursor);
|
||||
editor.renderer.scrollCursorIntoView();
|
||||
|
||||
editor.removeSelectionMarkers(rectSel);
|
||||
rectSel = selection.rectangularRangeBlock(screenCursor, screenAnchor);
|
||||
if (editor.$mouseHandler.$clickSelection && rectSel.length == 1 && rectSel[0].isEmpty())
|
||||
rectSel[0] = editor.$mouseHandler.$clickSelection.clone();
|
||||
rectSel.forEach(editor.addSelectionMarker, editor);
|
||||
editor.updateSelectionMarkers();
|
||||
};
|
||||
|
||||
if (isMultiSelect && !accel) {
|
||||
selection.toSingleRange();
|
||||
} else if (!isMultiSelect && accel) {
|
||||
initialRange = selection.toOrientedRange();
|
||||
editor.addSelectionMarker(initialRange);
|
||||
}
|
||||
|
||||
if (shift)
|
||||
screenAnchor = session.documentToScreenPosition(selection.lead);
|
||||
else
|
||||
selection.moveToPosition(pos);
|
||||
|
||||
screenCursor = {row: -1, column: -1};
|
||||
|
||||
var onMouseSelectionEnd = function(e) {
|
||||
clearInterval(timerId);
|
||||
editor.removeSelectionMarkers(rectSel);
|
||||
if (!rectSel.length)
|
||||
rectSel = [selection.toOrientedRange()];
|
||||
editor.$blockScrolling++;
|
||||
if (initialRange) {
|
||||
editor.removeSelectionMarker(initialRange);
|
||||
selection.toSingleRange(initialRange);
|
||||
}
|
||||
for (var i = 0; i < rectSel.length; i++)
|
||||
selection.addRange(rectSel[i]);
|
||||
editor.inVirtualSelectionMode = false;
|
||||
editor.$mouseHandler.$clickSelection = null;
|
||||
editor.$blockScrolling--;
|
||||
};
|
||||
|
||||
var onSelectionInterval = blockSelect;
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ var EditSession = require("./edit_session").EditSession;
|
|||
if (!range)
|
||||
return;
|
||||
|
||||
if (!this.inMultiSelectMode && this.rangeCount == 0) {
|
||||
if (!this.inMultiSelectMode && this.rangeCount === 0) {
|
||||
var oldRange = this.toOrientedRange();
|
||||
this.rangeList.add(oldRange);
|
||||
this.rangeList.add(range);
|
||||
|
|
@ -168,7 +168,7 @@ var EditSession = require("./edit_session").EditSession;
|
|||
|
||||
this._signal("removeRange", {ranges: removed});
|
||||
|
||||
if (this.rangeCount == 0 && this.inMultiSelectMode) {
|
||||
if (this.rangeCount === 0 && this.inMultiSelectMode) {
|
||||
this.inMultiSelectMode = false;
|
||||
this._signal("singleSelect");
|
||||
this.session.$undoSelect = true;
|
||||
|
|
@ -543,6 +543,19 @@ var Editor = require("./editor").Editor;
|
|||
}
|
||||
return text;
|
||||
};
|
||||
|
||||
this.$checkMultiselectChange = function(e, anchor) {
|
||||
if (this.inMultiSelectMode && !this.inVirtualSelectionMode) {
|
||||
var range = this.multiSelect.ranges[0];
|
||||
if (this.multiSelect.isEmpty() && anchor == this.multiSelect.anchor)
|
||||
return;
|
||||
var pos = anchor == this.multiSelect.anchor
|
||||
? range.cursor == range.start ? range.end : range.start
|
||||
: range.cursor;
|
||||
if (!isSamePoint(pos, anchor))
|
||||
this.multiSelect.toSingleRange(this.multiSelect.toOrientedRange());
|
||||
}
|
||||
};
|
||||
|
||||
// todo this should change when paste becomes a command
|
||||
this.onPaste = function(text) {
|
||||
|
|
@ -742,8 +755,15 @@ var Editor = require("./editor").Editor;
|
|||
var session = this.session;
|
||||
var sel = session.multiSelect;
|
||||
var ranges = sel.ranges;
|
||||
|
||||
if (!ranges.length) {
|
||||
// filter out ranges on same row
|
||||
var row = -1;
|
||||
var sameRowRanges = ranges.filter(function(r) {
|
||||
if (r.cursor.row == row)
|
||||
return true;
|
||||
row = r.cursor.row;
|
||||
});
|
||||
|
||||
if (!ranges.length || sameRowRanges.length == ranges.length - 1) {
|
||||
var range = this.selection.getRange();
|
||||
var fr = range.start.row, lr = range.end.row;
|
||||
var guessRange = fr == lr;
|
||||
|
|
@ -769,14 +789,9 @@ var Editor = require("./editor").Editor;
|
|||
}
|
||||
this.selection.setRange(range);
|
||||
} else {
|
||||
// filter out ranges on same row
|
||||
var row = -1;
|
||||
var sameRowRanges = ranges.filter(function(r) {
|
||||
if (r.cursor.row == row)
|
||||
return true;
|
||||
row = r.cursor.row;
|
||||
sameRowRanges.forEach(function(r) {
|
||||
sel.substractPoint(r.cursor);
|
||||
});
|
||||
sel.$onRemoveRange(sameRowRanges);
|
||||
|
||||
var maxCol = 0;
|
||||
var minSpace = Infinity;
|
||||
|
|
@ -851,19 +866,19 @@ var Editor = require("./editor").Editor;
|
|||
function alignLeft(m) {
|
||||
return !m[2] ? m[0] : spaces(startW) + m[2]
|
||||
+ spaces(textW - m[2].length + endW)
|
||||
+ m[4].replace(/^([=:])\s+/, "$1 ")
|
||||
+ m[4].replace(/^([=:])\s+/, "$1 ");
|
||||
}
|
||||
function alignRight(m) {
|
||||
return !m[2] ? m[0] : spaces(startW + textW - m[2].length) + m[2]
|
||||
+ spaces(endW, " ")
|
||||
+ m[4].replace(/^([=:])\s+/, "$1 ")
|
||||
+ m[4].replace(/^([=:])\s+/, "$1 ");
|
||||
}
|
||||
function unAlign(m) {
|
||||
return !m[2] ? m[0] : spaces(startW) + m[2]
|
||||
+ spaces(endW)
|
||||
+ m[4].replace(/^([=:])\s+/, "$1 ")
|
||||
+ m[4].replace(/^([=:])\s+/, "$1 ");
|
||||
}
|
||||
}
|
||||
};
|
||||
}).call(Editor.prototype);
|
||||
|
||||
|
||||
|
|
@ -884,17 +899,21 @@ exports.onSessionChange = function(e) {
|
|||
|
||||
var oldSession = e.oldSession;
|
||||
if (oldSession) {
|
||||
oldSession.multiSelect.removeEventListener("addRange", this.$onAddRange);
|
||||
oldSession.multiSelect.removeEventListener("removeRange", this.$onRemoveRange);
|
||||
oldSession.multiSelect.removeEventListener("multiSelect", this.$onMultiSelect);
|
||||
oldSession.multiSelect.removeEventListener("singleSelect", this.$onSingleSelect);
|
||||
oldSession.multiSelect.off("addRange", this.$onAddRange);
|
||||
oldSession.multiSelect.off("removeRange", this.$onRemoveRange);
|
||||
oldSession.multiSelect.off("multiSelect", this.$onMultiSelect);
|
||||
oldSession.multiSelect.off("singleSelect", this.$onSingleSelect);
|
||||
oldSession.multiSelect.lead.off("change", this.$checkMultiselectChange);
|
||||
oldSession.multiSelect.anchor.off("change", this.$checkMultiselectChange);
|
||||
}
|
||||
|
||||
session.multiSelect.on("addRange", this.$onAddRange);
|
||||
session.multiSelect.on("removeRange", this.$onRemoveRange);
|
||||
session.multiSelect.on("multiSelect", this.$onMultiSelect);
|
||||
session.multiSelect.on("singleSelect", this.$onSingleSelect);
|
||||
|
||||
session.multiSelect.lead.on("change", this.$checkMultiselectChange);
|
||||
session.multiSelect.anchor.on("change", this.$checkMultiselectChange);
|
||||
|
||||
// this.$onSelectionChange = this.onSelectionChange.bind(this);
|
||||
|
||||
if (this.inMultiSelectMode != session.selection.inMultiSelectMode) {
|
||||
|
|
@ -916,6 +935,7 @@ function MultiSelect(editor) {
|
|||
editor.$onMultiSelect = editor.$onMultiSelect.bind(editor);
|
||||
editor.$onSingleSelect = editor.$onSingleSelect.bind(editor);
|
||||
editor.$multiselectOnSessionChange = exports.onSessionChange.bind(editor);
|
||||
editor.$checkMultiselectChange = editor.$checkMultiselectChange.bind(editor);
|
||||
|
||||
editor.$multiselectOnSessionChange(editor);
|
||||
editor.on("changeSession", editor.$multiselectOnSessionChange);
|
||||
|
|
@ -969,7 +989,7 @@ require("./config").defineOptions(Editor.prototype, "editor", {
|
|||
},
|
||||
value: true
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ var EventEmitter = require("./lib/event_emitter").EventEmitter;
|
|||
var Range = require("./range").Range;
|
||||
|
||||
/**
|
||||
*
|
||||
* Contains the cursor position and the text selection of an edit session.
|
||||
*
|
||||
* The row/columns used in the selection are in document coordinates representing ths coordinates as thez appear in the document before applying soft wrap and folding.
|
||||
|
|
@ -49,22 +48,16 @@ var Range = require("./range").Range;
|
|||
* Emitted when the cursor position changes.
|
||||
* @event changeCursor
|
||||
*
|
||||
*
|
||||
*
|
||||
**/
|
||||
/**
|
||||
* Emitted when the cursor selection changes.
|
||||
*
|
||||
* @event changeSelection
|
||||
*
|
||||
*
|
||||
*
|
||||
**/
|
||||
/**
|
||||
* Creates a new `Selection` object.
|
||||
* @param {EditSession} session The session to use
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* @constructor
|
||||
**/
|
||||
var Selection = function(session) {
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ var testNames = [
|
|||
"ace/mode/folding/xml_test",
|
||||
"ace/mode/folding/coffee_test",
|
||||
"ace/multi_select_test",
|
||||
"ace/mouse/mouse_handler_test",
|
||||
"ace/occur_test",
|
||||
"ace/range_test",
|
||||
"ace/range_list_test",
|
||||
|
|
|
|||
|
|
@ -116,6 +116,11 @@ var Tokenizer = function(rules) {
|
|||
rule.onMatch = null;
|
||||
}
|
||||
|
||||
if (!ruleRegExps.length) {
|
||||
mapping[0] = 0;
|
||||
ruleRegExps.push("$");
|
||||
}
|
||||
|
||||
splitterRurles.forEach(function(rule) {
|
||||
rule.splitRegex = this.createSplitterRegexp(rule.regex, flag);
|
||||
}, this);
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ var deps = {
|
|||
jshint: {
|
||||
path: "mode/javascript/jshint.js",
|
||||
browserify: {
|
||||
npmModule: "git+https://github.com/nightwing/jshint.git#master",
|
||||
npmModule: "git+https://github.com/ajaxorg/jshint.git#master",
|
||||
path: "jshint/src/jshint.js",
|
||||
exports: "jshint"
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue