Merge remote-tracking branch 'origin/master' into indent_guides
Conflicts: lib/ace/theme/textmate.css
This commit is contained in:
commit
768bfbb1f2
19 changed files with 155 additions and 153 deletions
|
|
@ -117,11 +117,13 @@ exports.commands = [{
|
||||||
name: "selecttostart",
|
name: "selecttostart",
|
||||||
bindKey: bindKey("Ctrl-Shift-Home", "Command-Shift-Up"),
|
bindKey: bindKey("Ctrl-Shift-Home", "Command-Shift-Up"),
|
||||||
exec: function(editor) { editor.getSelection().selectFileStart(); },
|
exec: function(editor) { editor.getSelection().selectFileStart(); },
|
||||||
|
multiSelectAction: "forEach",
|
||||||
readOnly: true
|
readOnly: true
|
||||||
}, {
|
}, {
|
||||||
name: "gotostart",
|
name: "gotostart",
|
||||||
bindKey: bindKey("Ctrl-Home", "Command-Home|Command-Up"),
|
bindKey: bindKey("Ctrl-Home", "Command-Home|Command-Up"),
|
||||||
exec: function(editor) { editor.navigateFileStart(); },
|
exec: function(editor) { editor.navigateFileStart(); },
|
||||||
|
multiSelectAction: "forEach",
|
||||||
readOnly: true
|
readOnly: true
|
||||||
}, {
|
}, {
|
||||||
name: "selectup",
|
name: "selectup",
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,12 @@
|
||||||
z-index: 4;
|
z-index: 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ace_gutter_active_line {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.ace_scroller.horscroll {
|
.ace_scroller.horscroll {
|
||||||
box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;
|
box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2029,7 +2029,7 @@ var EditSession = function(text, mode) {
|
||||||
* - row (Number): The row number to check
|
* - row (Number): The row number to check
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Returns the length of the indicated row.
|
* Returns number of screenrows in a wrapped line.
|
||||||
**/
|
**/
|
||||||
this.getRowLength = function(row) {
|
this.getRowLength = function(row) {
|
||||||
if (!this.$useWrapMode || !this.$wrapData[row]) {
|
if (!this.$useWrapMode || !this.$wrapData[row]) {
|
||||||
|
|
@ -2039,18 +2039,6 @@ var EditSession = function(text, mode) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* EditSession.getRowHeight(config, row) -> Number
|
|
||||||
* - config (Object): An object containing a parameter indicating the `lineHeight`.
|
|
||||||
* - row (Number): The row number to check
|
|
||||||
*
|
|
||||||
* Returns the height of the indicated row. This is mostly relevant for situations where wrapping occurs, and a single line spans across multiple rows.
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
this.getRowHeight = function(config, row) {
|
|
||||||
return this.getRowLength(row) * config.lineHeight;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** internal, hide, related to: EditSession.documentToScreenColumn
|
/** internal, hide, related to: EditSession.documentToScreenColumn
|
||||||
* EditSession.getScreenLastRowColumn(screenRow) -> Number
|
* EditSession.getScreenLastRowColumn(screenRow) -> Number
|
||||||
* - screenRow (Number): The screen row to check
|
* - screenRow (Number): The screen row to check
|
||||||
|
|
|
||||||
|
|
@ -694,6 +694,9 @@ var Editor = function(renderer, session) {
|
||||||
* called whenever a text "paste" happens.
|
* called whenever a text "paste" happens.
|
||||||
**/
|
**/
|
||||||
this.onPaste = function(text) {
|
this.onPaste = function(text) {
|
||||||
|
// todo this should change when paste becomes a command
|
||||||
|
if (this.$readOnly)
|
||||||
|
return;
|
||||||
this._emit("paste", text);
|
this._emit("paste", text);
|
||||||
this.insert(text);
|
this.insert(text);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,9 @@ var TextInput = function(parentNode, host) {
|
||||||
var onPropertyChange = function(e) {
|
var onPropertyChange = function(e) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
if (!inCompostion)
|
if (!inCompostion)
|
||||||
|
if(text.value != "") {
|
||||||
sendText();
|
sendText();
|
||||||
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ var Gutter = function(parentEl) {
|
||||||
breakpoints[i] ? " ace_breakpoint " : " ",
|
breakpoints[i] ? " ace_breakpoint " : " ",
|
||||||
annotation.className,
|
annotation.className,
|
||||||
"' title='", annotation.text.join("\n"),
|
"' title='", annotation.text.join("\n"),
|
||||||
"' style='height:", this.session.getRowLength(i) * config.lineHeight, "px;'>", (i+1));
|
"' style='height:", this.session.getRowLength(i) * config.lineHeight, "px;'>", (i));
|
||||||
|
|
||||||
if (foldWidgets) {
|
if (foldWidgets) {
|
||||||
var c = foldWidgets[i];
|
var c = foldWidgets[i];
|
||||||
|
|
|
||||||
|
|
@ -108,11 +108,6 @@ exports.getButton = function(e) {
|
||||||
|
|
||||||
if (document.documentElement.setCapture) {
|
if (document.documentElement.setCapture) {
|
||||||
exports.capture = function(el, eventHandler, releaseCaptureHandler) {
|
exports.capture = function(el, eventHandler, releaseCaptureHandler) {
|
||||||
function onMouseMove(e) {
|
|
||||||
eventHandler(e);
|
|
||||||
return exports.stopPropagation(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
var called = false;
|
var called = false;
|
||||||
function onReleaseCapture(e) {
|
function onReleaseCapture(e) {
|
||||||
eventHandler(e);
|
eventHandler(e);
|
||||||
|
|
@ -137,22 +132,17 @@ if (document.documentElement.setCapture) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
exports.capture = function(el, eventHandler, releaseCaptureHandler) {
|
exports.capture = function(el, eventHandler, releaseCaptureHandler) {
|
||||||
function onMouseMove(e) {
|
|
||||||
eventHandler(e);
|
|
||||||
e.stopPropagation();
|
|
||||||
}
|
|
||||||
|
|
||||||
function onMouseUp(e) {
|
function onMouseUp(e) {
|
||||||
eventHandler && eventHandler(e);
|
eventHandler && eventHandler(e);
|
||||||
releaseCaptureHandler && releaseCaptureHandler(e);
|
releaseCaptureHandler && releaseCaptureHandler(e);
|
||||||
|
|
||||||
document.removeEventListener("mousemove", onMouseMove, true);
|
document.removeEventListener("mousemove", eventHandler, true);
|
||||||
document.removeEventListener("mouseup", onMouseUp, true);
|
document.removeEventListener("mouseup", onMouseUp, true);
|
||||||
|
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener("mousemove", onMouseMove, true);
|
document.addEventListener("mousemove", eventHandler, true);
|
||||||
document.addEventListener("mouseup", onMouseUp, true);
|
document.addEventListener("mouseup", onMouseUp, true);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var useragent = require("ace/lib/useragent");
|
var useragent = require("./useragent");
|
||||||
|
|
||||||
exports.get = function (url, callback) {
|
exports.get = function (url, callback) {
|
||||||
var xhr = exports.createXhr();
|
var xhr = exports.createXhr();
|
||||||
|
|
|
||||||
|
|
@ -28,39 +28,39 @@ define(function(require, exports, module) {
|
||||||
this.inherit(CstyleBehaviour, ["braces", "parens", "string_dquotes"]); // Get string behaviour
|
this.inherit(CstyleBehaviour, ["braces", "parens", "string_dquotes"]); // Get string behaviour
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
|
|
||||||
this.add("brackets", "insertion", function (state, action, editor, session, text) {
|
// this.add("brackets", "insertion", function (state, action, editor, session, text) {
|
||||||
if (text == "\n") {
|
// if (text == "\n") {
|
||||||
var cursor = editor.getCursorPosition();
|
// var cursor = editor.getCursorPosition();
|
||||||
var line = session.doc.getLine(cursor.row);
|
// var line = session.doc.getLine(cursor.row);
|
||||||
var rightChars = line.substring(cursor.column, cursor.column + 2);
|
// var rightChars = line.substring(cursor.column, cursor.column + 2);
|
||||||
if (rightChars == '</') {
|
// if (rightChars == '</') {
|
||||||
var indent = this.$getIndent(session.doc.getLine(cursor.row)) + session.getTabString();
|
// var indent = this.$getIndent(session.doc.getLine(cursor.row)) + session.getTabString();
|
||||||
var next_indent = this.$getIndent(session.doc.getLine(cursor.row));
|
// var next_indent = this.$getIndent(session.doc.getLine(cursor.row));
|
||||||
|
//
|
||||||
return {
|
// return {
|
||||||
text: '\n' + indent + '\n' + next_indent,
|
// text: '\n' + indent + '\n' + next_indent,
|
||||||
selection: [1, indent.length, 1, indent.length]
|
// selection: [1, indent.length, 1, indent.length]
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return false;
|
// return false;
|
||||||
});
|
// });
|
||||||
|
|
||||||
// Check for open tag if user enters / and auto-close it.
|
// Check for open tag if user enters / and auto-close it.
|
||||||
this.add("slash", "insertion", function (state, action, editor, session, text) {
|
// this.add("slash", "insertion", function (state, action, editor, session, text) {
|
||||||
if (text == "/") {
|
// if (text == "/") {
|
||||||
var cursor = editor.getCursorPosition();
|
// var cursor = editor.getCursorPosition();
|
||||||
var line = session.doc.getLine(cursor.row);
|
// var line = session.doc.getLine(cursor.row);
|
||||||
if (cursor.column > 0 && line.charAt(cursor.column - 1) == "<") {
|
// if (cursor.column > 0 && line.charAt(cursor.column - 1) == "<") {
|
||||||
line = line.substring(0, cursor.column) + "/" + line.substring(cursor.column);
|
// line = line.substring(0, cursor.column) + "/" + line.substring(cursor.column);
|
||||||
var lines = session.doc.getAllLines();
|
// var lines = session.doc.getAllLines();
|
||||||
lines[cursor.row] = line;
|
// lines[cursor.row] = line;
|
||||||
// call mode helper to close the tag if possible
|
// // call mode helper to close the tag if possible
|
||||||
parent.exec("closeTag", lines.join(session.doc.getNewLineCharacter()), cursor.row);
|
// parent.exec("closeTag", lines.join(session.doc.getNewLineCharacter()), cursor.row);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return false;
|
// return false;
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
oop.inherits(XQueryBehaviour, Behaviour);
|
oop.inherits(XQueryBehaviour, Behaviour);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -190,10 +190,7 @@ var ClojureHighlightRules = function() {
|
||||||
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
||||||
}, {
|
}, {
|
||||||
token : "string", // single line
|
token : "string", // single line
|
||||||
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
|
regex : '"',
|
||||||
}, {
|
|
||||||
token : "string", // multi line
|
|
||||||
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?$',
|
|
||||||
next: "string"
|
next: "string"
|
||||||
}, {
|
}, {
|
||||||
token : "string", // symbol
|
token : "string", // symbol
|
||||||
|
|
@ -217,12 +214,16 @@ var ClojureHighlightRules = function() {
|
||||||
],
|
],
|
||||||
"string" : [
|
"string" : [
|
||||||
{
|
{
|
||||||
token : "string",
|
token : "constant.language.escape",
|
||||||
merge : true,
|
merge : true,
|
||||||
regex : "\\\\."
|
regex : "\\\\.|\\\\$"
|
||||||
}, {
|
}, {
|
||||||
token : "string",
|
token : "string",
|
||||||
regex : '[^"\\\\]*?"',
|
merge : true,
|
||||||
|
regex : '[^"\\\\]+'
|
||||||
|
}, {
|
||||||
|
token : "string",
|
||||||
|
regex : '"',
|
||||||
next : "start"
|
next : "start"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -48,18 +48,19 @@ oop.inherits(FoldMode, BaseFoldMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
this.foldingStartMarker = /^(\w.*\:|Searching for.*)$/;
|
this.foldingStartMarker = /^(\S.*\:|Searching for.*)$/;
|
||||||
this.foldingStopMarker = /^(\s+|Found.*)$/;
|
this.foldingStopMarker = /^(\s+|Found.*)$/;
|
||||||
|
|
||||||
this.getFoldWidgetRange = function(session, foldStyle, row) {
|
this.getFoldWidgetRange = function(session, foldStyle, row) {
|
||||||
var line = session.getLine(row);
|
var lines = session.doc.getAllLines(row);
|
||||||
|
var line = lines[row];
|
||||||
var level1 = /^(Found.*|Searching for.*)$/;
|
var level1 = /^(Found.*|Searching for.*)$/;
|
||||||
var level2 = /^(\w.*\:|\s*)$/;
|
var level2 = /^(\S.*\:|\s*)$/;
|
||||||
var re = level1.test(line) ? level1 : level2;
|
var re = level1.test(line) ? level1 : level2;
|
||||||
|
|
||||||
if (this.foldingStartMarker.test(line)) {
|
if (this.foldingStartMarker.test(line)) {
|
||||||
for (var i = row + 1, l = session.getLength(); i < l; i++) {
|
for (var i = row + 1, l = session.getLength(); i < l; i++) {
|
||||||
if (re.test(session.getLine(i)))
|
if (re.test(lines[i]))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,7 +69,7 @@ oop.inherits(FoldMode, BaseFoldMode);
|
||||||
|
|
||||||
if (this.foldingStopMarker.test(line)) {
|
if (this.foldingStopMarker.test(line)) {
|
||||||
for (var i = row - 1; i >= 0; i--) {
|
for (var i = row - 1; i >= 0; i--) {
|
||||||
line = session.getLine(i);
|
line = lines[i];
|
||||||
if (re.test(line))
|
if (re.test(line))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -225,7 +225,7 @@ function DefaultHandlers(mouseHandler) {
|
||||||
var editor = this.editor;
|
var editor = this.editor;
|
||||||
|
|
||||||
if (distance > DRAG_OFFSET) {
|
if (distance > DRAG_OFFSET) {
|
||||||
this.startSelect();
|
this.startSelect(this.mousedownEvent.getDocumentPosition());
|
||||||
} else if (time - this.mousedownEvent.time > editor.getDragDelay()) {
|
} else if (time - this.mousedownEvent.time > editor.getDragDelay()) {
|
||||||
this.startDrag();
|
this.startDrag();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,8 @@ function FoldHandler(editor) {
|
||||||
|
|
||||||
if (gutterRegion == "foldWidgets") {
|
if (gutterRegion == "foldWidgets") {
|
||||||
var row = e.getDocumentPosition().row;
|
var row = e.getDocumentPosition().row;
|
||||||
if (editor.session.foldWidgets[row])
|
var session = editor.session;
|
||||||
|
if (session.foldWidgets && session.foldWidgets[row])
|
||||||
editor.session.onFoldWidgetClick(row, e);
|
editor.session.onFoldWidgetClick(row, e);
|
||||||
e.stop();
|
e.stop();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -502,7 +502,11 @@ var Editor = require("./editor").Editor;
|
||||||
return text;
|
return text;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// todo this should change when paste becomes a command
|
||||||
this.onPaste = function(text) {
|
this.onPaste = function(text) {
|
||||||
|
if (this.$readOnly)
|
||||||
|
return;
|
||||||
|
|
||||||
this._emit("paste", text);
|
this._emit("paste", text);
|
||||||
if (!this.inMultiSelectMode)
|
if (!this.inMultiSelectMode)
|
||||||
return this.insert(text);
|
return this.insert(text);
|
||||||
|
|
|
||||||
|
|
@ -137,23 +137,24 @@ var Search = function() {
|
||||||
return [];
|
return [];
|
||||||
this.$assembleRegExp(options);
|
this.$assembleRegExp(options);
|
||||||
|
|
||||||
if (options.range) {
|
|
||||||
var range = options.range;
|
var range = options.range;
|
||||||
var lines = session.getLines(range.start.row, range.end.row);
|
var lines = range
|
||||||
} else
|
? session.getLines(range.start.row, range.end.row)
|
||||||
var lines = session.doc.getAllLines();
|
: session.doc.getAllLines();
|
||||||
|
|
||||||
var ranges = [];
|
var ranges = [];
|
||||||
var re = options.re;
|
var re = options.re;
|
||||||
if (options.$isMultiLine) {
|
if (options.$isMultiLine) {
|
||||||
var len = re.length;
|
var len = re.length;
|
||||||
var maxRow = lines.length - len;
|
var maxRow = lines.length - len;
|
||||||
for (var row = re.offset || 0; row < maxRow; row++) {
|
for (var row = re.offset || 0; row <= maxRow; row++) {
|
||||||
for (var j = 0; j < re.length; j++)
|
for (var j = 0; j < len; j++)
|
||||||
if (lines[row + j].search(re[j]) == -1)
|
if (lines[row + j].search(re[j]) == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
var startIndex = lines[row + j].match(re[0])[0].length;
|
var startLine = lines[row];
|
||||||
|
var line = lines[row + len - 1];
|
||||||
|
var startIndex = startLine.match(re[0])[0].length;
|
||||||
var endIndex = line.match(re[len - 1])[0].length;
|
var endIndex = line.match(re[len - 1])[0].length;
|
||||||
|
|
||||||
ranges.push(new Range(
|
ranges.push(new Range(
|
||||||
|
|
@ -167,11 +168,11 @@ var Search = function() {
|
||||||
for (var j = 0; j < matches.length; j++) {
|
for (var j = 0; j < matches.length; j++) {
|
||||||
var match = matches[j];
|
var match = matches[j];
|
||||||
ranges.push(new Range(i, match.offset, i, match.offset + match.length));
|
ranges.push(new Range(i, match.offset, i, match.offset + match.length));
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.range) {
|
if (range) {
|
||||||
var startColumn = range.start.column;
|
var startColumn = range.start.column;
|
||||||
var endColumn = range.start.column;
|
var endColumn = range.start.column;
|
||||||
var i = 0, j = ranges.length - 1;
|
var i = 0, j = ranges.length - 1;
|
||||||
|
|
@ -210,7 +211,7 @@ var Search = function() {
|
||||||
if (!match || match[0].length != input.length)
|
if (!match || match[0].length != input.length)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
replacement = input.replace(re, replacement)
|
replacement = input.replace(re, replacement);
|
||||||
if (options.preserveCase) {
|
if (options.preserveCase) {
|
||||||
replacement = replacement.split("");
|
replacement = replacement.split("");
|
||||||
for (var i = Math.min(input.length, input.length); i--; ) {
|
for (var i = Math.min(input.length, input.length); i--; ) {
|
||||||
|
|
@ -261,21 +262,21 @@ var Search = function() {
|
||||||
|
|
||||||
if (callback(range))
|
if (callback(range))
|
||||||
return true;
|
return true;
|
||||||
}
|
};
|
||||||
} else if (backwards) {
|
} else if (backwards) {
|
||||||
var matchIterator = function(line, row, startIndex) {
|
var matchIterator = function(line, row, startIndex) {
|
||||||
var matches = lang.getMatchOffsets(line, re);
|
var matches = lang.getMatchOffsets(line, re);
|
||||||
for (var i = matches.length-1; i >= 0; i--)
|
for (var i = matches.length-1; i >= 0; i--)
|
||||||
if (callback(matches[i], row, startIndex))
|
if (callback(matches[i], row, startIndex))
|
||||||
return true;
|
return true;
|
||||||
}
|
};
|
||||||
} else {
|
} else {
|
||||||
var matchIterator = function(line, row, startIndex) {
|
var matchIterator = function(line, row, startIndex) {
|
||||||
var matches = lang.getMatchOffsets(line, re);
|
var matches = lang.getMatchOffsets(line, re);
|
||||||
for (var i = 0; i < matches.length; i++)
|
for (var i = 0; i < matches.length; i++)
|
||||||
if (callback(matches[i], row, startIndex))
|
if (callback(matches[i], row, startIndex))
|
||||||
return true;
|
return true;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
@ -310,7 +311,7 @@ var Search = function() {
|
||||||
try {
|
try {
|
||||||
var re = new RegExp(needle, modifier);
|
var re = new RegExp(needle, modifier);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
var re = false;
|
re = false;
|
||||||
}
|
}
|
||||||
return options.re = re;
|
return options.re = re;
|
||||||
};
|
};
|
||||||
|
|
@ -333,7 +334,6 @@ var Search = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$lineIterator = function(session, options) {
|
this.$lineIterator = function(session, options) {
|
||||||
var range = options.range;
|
|
||||||
var backwards = options.backwards == true;
|
var backwards = options.backwards == true;
|
||||||
var skipCurrent = options.skipCurrent != false;
|
var skipCurrent = options.skipCurrent != false;
|
||||||
|
|
||||||
|
|
@ -346,30 +346,9 @@ var Search = function() {
|
||||||
start = start[skipCurrent != backwards ? "end" : "start"];
|
start = start[skipCurrent != backwards ? "end" : "start"];
|
||||||
|
|
||||||
var firstRow = range ? range.start.row : 0;
|
var firstRow = range ? range.start.row : 0;
|
||||||
var firstColumn = range ? range.start.column : 0;
|
|
||||||
var lastRow = range ? range.end.row : session.getLength() - 1;
|
var lastRow = range ? range.end.row : session.getLength() - 1;
|
||||||
|
|
||||||
if (!backwards) {
|
var forEach = backwards ? function(callback) {
|
||||||
var forEach = function(callback) {
|
|
||||||
var row = start.row;
|
|
||||||
|
|
||||||
var line = session.getLine(row).substr(start.column);
|
|
||||||
if (callback(line, row, start.column))
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (row = row+1; row <= lastRow; row++)
|
|
||||||
if (callback(session.getLine(row), row))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (options.wrap == false)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (row = firstRow, lastRow = start.row; row <= lastRow; row++)
|
|
||||||
if (callback(session.getLine(row), row))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
var forEach = function(callback) {
|
|
||||||
var row = start.row;
|
var row = start.row;
|
||||||
|
|
||||||
var line = session.getLine(row).substring(0, start.column);
|
var line = session.getLine(row).substring(0, start.column);
|
||||||
|
|
@ -386,8 +365,24 @@ var Search = function() {
|
||||||
for (row = lastRow, firstRow = start.row; row >= firstRow; row--)
|
for (row = lastRow, firstRow = start.row; row >= firstRow; row--)
|
||||||
if (callback(session.getLine(row), row))
|
if (callback(session.getLine(row), row))
|
||||||
return;
|
return;
|
||||||
}
|
} : function(callback) {
|
||||||
}
|
var row = start.row;
|
||||||
|
|
||||||
|
var line = session.getLine(row).substr(start.column);
|
||||||
|
if (callback(line, row, start.column))
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (row = row+1; row <= lastRow; row++)
|
||||||
|
if (callback(session.getLine(row), row))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (options.wrap == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (row = firstRow, lastRow = start.row; row <= lastRow; row++)
|
||||||
|
if (callback(session.getLine(row), row))
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
return {forEach: forEach};
|
return {forEach: forEach};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -340,6 +340,24 @@ module.exports = {
|
||||||
assert.position(ranges[1].end, 2, 3);
|
assert.position(ranges[1].end, 2, 3);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"test: find all multiline matches" : function() {
|
||||||
|
var session = new EditSession(["juhu", "juhu", "juhu", "juhu"]);
|
||||||
|
|
||||||
|
var search = new Search().set({
|
||||||
|
needle: "hu\nju",
|
||||||
|
wrap: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var ranges = search.findAll(session);
|
||||||
|
|
||||||
|
assert.equal(ranges.length, 3);
|
||||||
|
assert.position(ranges[0].start, 0, 2);
|
||||||
|
assert.position(ranges[0].end, 1, 2);
|
||||||
|
assert.position(ranges[1].start, 1, 2);
|
||||||
|
assert.position(ranges[1].end, 2, 2);
|
||||||
|
},
|
||||||
|
|
||||||
"test: replace() should return the replacement if the input matches the needle" : function() {
|
"test: replace() should return the replacement if the input matches the needle" : function() {
|
||||||
var search = new Search().set({
|
var search = new Search().set({
|
||||||
needle: "juhu"
|
needle: "juhu"
|
||||||
|
|
|
||||||
|
|
@ -115,10 +115,10 @@ MockRenderer.prototype.scrollToX = function(scrollTop) {};
|
||||||
MockRenderer.prototype.scrollToY = function(scrollLeft) {};
|
MockRenderer.prototype.scrollToY = function(scrollLeft) {};
|
||||||
|
|
||||||
MockRenderer.prototype.scrollToLine = function(line, center) {
|
MockRenderer.prototype.scrollToLine = function(line, center) {
|
||||||
var lineHeight = { lineHeight: 16 };
|
var lineHeight = 16;
|
||||||
var row = 0;
|
var row = 0;
|
||||||
for (var l = 1; l < line; l++) {
|
for (var l = 1; l < line; l++) {
|
||||||
row += this.session.getRowHeight(lineHeight, l-1) / lineHeight.lineHeight;
|
row += this.session.getRowLength(l-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (center) {
|
if (center) {
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace-tm .ace_meta.ace_tag {
|
.ace-tm .ace_meta.ace_tag {
|
||||||
color:rgb(0, 50, 198);
|
color:rgb(0, 22, 142);
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace-tm .ace_string.ace_regex {
|
.ace-tm .ace_string.ace_regex {
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
this.content.className = "ace_content";
|
this.content.className = "ace_content";
|
||||||
this.scroller.appendChild(this.content);
|
this.scroller.appendChild(this.content);
|
||||||
|
|
||||||
|
this.setHighlightGutterLine(true);
|
||||||
this.$gutterLayer = new GutterLayer(this.$gutter);
|
this.$gutterLayer = new GutterLayer(this.$gutter);
|
||||||
this.$gutterLayer.on("changeGutterWidth", this.onResize.bind(this, true));
|
this.$gutterLayer.on("changeGutterWidth", this.onResize.bind(this, true));
|
||||||
|
|
||||||
|
|
@ -481,38 +482,32 @@ var VirtualRenderer = function(container, theme) {
|
||||||
dom.removeCssClass(this.$gutter, "ace_fade-fold-widgets");
|
dom.removeCssClass(this.$gutter, "ace_fade-fold-widgets");
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$highlightGutterLine = true;
|
this.$highlightGutterLine = false;
|
||||||
this.setHighlightGutterLine = function(shouldHighlight) {
|
this.setHighlightGutterLine = function(shouldHighlight) {
|
||||||
if (this.$highlightGutterLine == shouldHighlight)
|
if (this.$highlightGutterLine == shouldHighlight)
|
||||||
return;
|
return;
|
||||||
this.$highlightGutterLine = shouldHighlight;
|
this.$highlightGutterLine = shouldHighlight;
|
||||||
|
|
||||||
this.$loop.schedule(this.CHANGE_GUTTER);
|
if (!this.$gutterLineHighlight) {
|
||||||
|
this.$gutterLineHighlight = dom.createElement("div");
|
||||||
|
this.$gutterLineHighlight.className = "ace_gutter_active_line";
|
||||||
|
this.$gutter.appendChild(this.$gutterLineHighlight);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$gutterLineHighlight.style.display = shouldHighlight ? "" : "none";
|
||||||
|
// if cursorlayer have never been updated there's nothing on screen to update
|
||||||
|
if (this.$cursorLayer.$pixelPos)
|
||||||
|
this.$updateGutterLineHighlight();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getHighlightGutterLine = function() {
|
this.getHighlightGutterLine = function() {
|
||||||
return this.$highlightGutterLine;
|
return this.$highlightGutterLine;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$updateGutterLineHighlight = function(gutterReady) {
|
this.$updateGutterLineHighlight = function() {
|
||||||
var i = this.session.selection.lead.row;
|
this.$gutterLineHighlight.style.top = this.$cursorLayer.$pixelPos.top - this.layerConfig.offset + "px";
|
||||||
if (i == this.$gutterLineHighlight)
|
this.$gutterLineHighlight.style.height = this.layerConfig.lineHeight + "px";
|
||||||
return;
|
|
||||||
|
|
||||||
if (!gutterReady) {
|
|
||||||
var lineEl, ch = this.$gutterLayer.element.children;
|
|
||||||
var index = this.$gutterLineHighlight - this.layerConfig.firstRow;
|
|
||||||
if (index >= 0 && (lineEl = ch[index]))
|
|
||||||
dom.removeCssClass(lineEl, "ace_gutter_active_line");
|
|
||||||
|
|
||||||
index = i - this.layerConfig.firstRow;
|
|
||||||
if (index >= 0 && (lineEl = ch[index]))
|
|
||||||
dom.addCssClass(lineEl, "ace_gutter_active_line");
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$gutterLayer.removeGutterDecoration(this.$gutterLineHighlight, "ace_gutter_active_line");
|
|
||||||
this.$gutterLayer.addGutterDecoration(i, "ace_gutter_active_line");
|
|
||||||
this.$gutterLineHighlight = i;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$updatePrintMargin = function() {
|
this.$updatePrintMargin = function() {
|
||||||
|
|
@ -706,15 +701,13 @@ var VirtualRenderer = function(container, theme) {
|
||||||
// update scrollbar first to not lose scroll position when gutter calls resize
|
// update scrollbar first to not lose scroll position when gutter calls resize
|
||||||
this.$updateScrollBar();
|
this.$updateScrollBar();
|
||||||
this.$textLayer.update(this.layerConfig);
|
this.$textLayer.update(this.layerConfig);
|
||||||
if (this.showGutter) {
|
if (this.showGutter)
|
||||||
if (this.$highlightGutterLine)
|
|
||||||
this.$updateGutterLineHighlight(true);
|
|
||||||
this.$gutterLayer.update(this.layerConfig);
|
this.$gutterLayer.update(this.layerConfig);
|
||||||
}
|
|
||||||
this.$markerBack.update(this.layerConfig);
|
this.$markerBack.update(this.layerConfig);
|
||||||
this.$markerFront.update(this.layerConfig);
|
this.$markerFront.update(this.layerConfig);
|
||||||
this.$cursorLayer.update(this.layerConfig);
|
this.$cursorLayer.update(this.layerConfig);
|
||||||
this.$moveTextAreaToCursor();
|
this.$moveTextAreaToCursor();
|
||||||
|
this.$highlightGutterLine && this.$updateGutterLineHighlight();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -726,15 +719,13 @@ var VirtualRenderer = function(container, theme) {
|
||||||
else
|
else
|
||||||
this.$textLayer.scrollLines(this.layerConfig);
|
this.$textLayer.scrollLines(this.layerConfig);
|
||||||
|
|
||||||
if (this.showGutter) {
|
if (this.showGutter)
|
||||||
if (this.$highlightGutterLine)
|
|
||||||
this.$updateGutterLineHighlight(true);
|
|
||||||
this.$gutterLayer.update(this.layerConfig);
|
this.$gutterLayer.update(this.layerConfig);
|
||||||
}
|
|
||||||
this.$markerBack.update(this.layerConfig);
|
this.$markerBack.update(this.layerConfig);
|
||||||
this.$markerFront.update(this.layerConfig);
|
this.$markerFront.update(this.layerConfig);
|
||||||
this.$cursorLayer.update(this.layerConfig);
|
this.$cursorLayer.update(this.layerConfig);
|
||||||
this.$moveTextAreaToCursor();
|
this.$moveTextAreaToCursor();
|
||||||
|
this.$highlightGutterLine && this.$updateGutterLineHighlight();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -757,7 +748,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
if (changes & this.CHANGE_CURSOR) {
|
if (changes & this.CHANGE_CURSOR) {
|
||||||
this.$cursorLayer.update(this.layerConfig);
|
this.$cursorLayer.update(this.layerConfig);
|
||||||
this.$moveTextAreaToCursor();
|
this.$moveTextAreaToCursor();
|
||||||
this.$highlightGutterLine && this.$updateGutterLineHighlight(false);
|
this.$highlightGutterLine && this.$updateGutterLineHighlight();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_FRONT)) {
|
if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_FRONT)) {
|
||||||
|
|
@ -799,7 +790,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
|
|
||||||
// Map lines on the screen to lines in the document.
|
// Map lines on the screen to lines in the document.
|
||||||
var firstRowScreen, firstRowHeight;
|
var firstRowScreen, firstRowHeight;
|
||||||
var lineHeight = { lineHeight: this.lineHeight };
|
var lineHeight = this.lineHeight;
|
||||||
firstRow = session.screenToDocumentRow(firstRow, 0);
|
firstRow = session.screenToDocumentRow(firstRow, 0);
|
||||||
|
|
||||||
// Check if firstRow is inside of a foldLine. If true, then use the first
|
// Check if firstRow is inside of a foldLine. If true, then use the first
|
||||||
|
|
@ -810,13 +801,13 @@ var VirtualRenderer = function(container, theme) {
|
||||||
}
|
}
|
||||||
|
|
||||||
firstRowScreen = session.documentToScreenRow(firstRow, 0);
|
firstRowScreen = session.documentToScreenRow(firstRow, 0);
|
||||||
firstRowHeight = session.getRowHeight(lineHeight, firstRow);
|
firstRowHeight = session.getRowLength(firstRow) * lineHeight;
|
||||||
|
|
||||||
lastRow = Math.min(session.screenToDocumentRow(lastRow, 0), session.getLength() - 1);
|
lastRow = Math.min(session.screenToDocumentRow(lastRow, 0), session.getLength() - 1);
|
||||||
minHeight = this.$size.scrollerHeight + session.getRowHeight(lineHeight, lastRow)+
|
minHeight = this.$size.scrollerHeight + session.getRowLength(lastRow) * lineHeight +
|
||||||
firstRowHeight;
|
firstRowHeight;
|
||||||
|
|
||||||
offset = this.scrollTop - firstRowScreen * this.lineHeight;
|
offset = this.scrollTop - firstRowScreen * lineHeight;
|
||||||
|
|
||||||
this.layerConfig = {
|
this.layerConfig = {
|
||||||
width : longestLine,
|
width : longestLine,
|
||||||
|
|
@ -824,7 +815,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
firstRow : firstRow,
|
firstRow : firstRow,
|
||||||
firstRowScreen: firstRowScreen,
|
firstRowScreen: firstRowScreen,
|
||||||
lastRow : lastRow,
|
lastRow : lastRow,
|
||||||
lineHeight : this.lineHeight,
|
lineHeight : lineHeight,
|
||||||
characterWidth : this.characterWidth,
|
characterWidth : this.characterWidth,
|
||||||
minHeight : minHeight,
|
minHeight : minHeight,
|
||||||
maxHeight : maxHeight,
|
maxHeight : maxHeight,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue