Merge remote-tracking branch 'remotes/origin/master' into v-1.2

Conflicts:
	build
	lib/ace/document.js
	lib/ace/editor.js
This commit is contained in:
nightwing 2014-10-05 23:04:57 +04:00
commit 29023787e5
125 changed files with 89027 additions and 86666 deletions

View file

@ -79,11 +79,21 @@ exports.edit = function(el) {
throw new Error("ace.edit can't find div #" + _id);
}
if (el.env && el.env.editor instanceof Editor)
if (el && el.env && el.env.editor instanceof Editor)
return el.env.editor;
var doc = exports.createEditSession(dom.getInnerText(el));
el.innerHTML = '';
var value = "";
if (el && /input|textarea/i.test(el.tagName)) {
var oldNode = el;
value = oldNode.value;
el = dom.createElement("pre");
oldNode.parentNode.replaceChild(el, oldNode);
} else {
value = dom.getInnerText(el);
el.innerHTML = '';
}
var doc = exports.createEditSession(value);
var editor = new Editor(new Renderer(el));
editor.setSession(doc);
@ -93,11 +103,13 @@ exports.edit = function(el) {
editor: editor,
onResize: editor.resize.bind(editor, null)
};
if (oldNode) env.textarea = oldNode;
event.addListener(window, "resize", env.onResize);
editor.on("destroy", function() {
event.removeListener(window, "resize", env.onResize);
env.editor.container.env = null; // prevent memory leak on old ie
});
el.env = editor.env = env;
editor.container.env = editor.env = env;
return editor;
};

View file

@ -89,6 +89,8 @@ var Autocomplete = function() {
pos.left += renderer.$gutterLayer.gutterWidth;
this.popup.show(pos, lineHeight);
} else if (keepPopupPosition && !prefix) {
this.detach();
}
};
@ -101,12 +103,12 @@ var Autocomplete = function() {
this.changeTimer.cancel();
if (this.popup && this.popup.isOpen) {
this.gatherCompletionsId = this.gatherCompletionsId + 1;
}
if (this.popup)
this.gatherCompletionsId += 1;
this.popup.hide();
}
if (this.base)
this.base.detach();
this.activated = false;
this.completions = this.base = null;
};
@ -205,9 +207,9 @@ var Autocomplete = function() {
var line = session.getLine(pos.row);
var prefix = util.retrievePrecedingIdentifier(line, pos.column);
this.base = editor.getCursorPosition();
this.base.column -= prefix.length;
this.base = session.doc.createAnchor(pos.row, pos.column - prefix.length);
this.base.$insertRight = true;
var matches = [];
var total = editor.completers.length;
editor.completers.forEach(function(completer, i) {
@ -298,7 +300,7 @@ var Autocomplete = function() {
return detachIfFinished();
// Autoinsert if one result
if (this.autoInsert && filtered.length == 1)
if (this.autoInsert && filtered.length == 1 && results.finished)
return this.insertMatch(filtered[0]);
this.openPopup(this.editor, prefix, keepPopupPosition);
@ -346,7 +348,7 @@ var FilteredList = function(array, filterText, mutateData) {
// make unique
var prev = null;
matches = matches.filter(function(item){
var caption = item.value || item.caption || item.snippet;
var caption = item.snippet || item.caption || item.value;
if (caption === prev) return false;
prev = caption;
return true;

View file

@ -52,6 +52,7 @@ var $singleLineEditor = function(el) {
editor.renderer.setHighlightGutterLine(false);
editor.$mouseHandler.$focusWaitTimout = 0;
editor.$highlightTagPending = true;
return editor;
};
@ -67,6 +68,7 @@ var AcePopup = function(parentNode) {
popup.renderer.setStyle("ace_autocomplete");
popup.setOption("displayIndentGuides", false);
popup.setOption("dragDelay", 150);
var noop = function(){};
@ -102,7 +104,7 @@ var AcePopup = function(parentNode) {
popup.session.removeMarker(hoverMarker.id);
hoverMarker.id = null;
}
}
};
popup.setSelectOnHover(false);
popup.on("mousemove", function(e) {
if (!lastMouseEvent) {
@ -170,15 +172,15 @@ var AcePopup = function(parentNode) {
};
var bgTokenizer = popup.session.bgTokenizer;
bgTokenizer.$tokenizeRow = function(i) {
var data = popup.data[i];
bgTokenizer.$tokenizeRow = function(row) {
var data = popup.data[row];
var tokens = [];
if (!data)
return tokens;
if (typeof data == "string")
data = {value: data};
if (!data.caption)
data.caption = data.value;
data.caption = data.value || data.name;
var last = -1;
var flag, c;
@ -205,7 +207,7 @@ var AcePopup = function(parentNode) {
popup.session.$computeWidth = function() {
return this.screenWidth = 0;
}
};
// public
popup.isOpen = false;

View file

@ -68,7 +68,7 @@ define(function(require, exports, module) {
var wordList = Object.keys(wordScore);
callback(null, wordList.map(function(word) {
return {
name: word,
caption: word,
value: word,
score: wordScore[word],
meta: "local"

View file

@ -36,8 +36,6 @@ var EventEmitter = require("./lib/event_emitter").EventEmitter;
/**
*
*
* Tokenizes the current [[Document `Document`]] in the background, and caches the tokenized rows for future use.
*
* If a certain row is changed, everything below that row is re-tokenized.
@ -50,8 +48,6 @@ var EventEmitter = require("./lib/event_emitter").EventEmitter;
* @param {Tokenizer} tokenizer The tokenizer to use
* @param {Editor} editor The editor to associate with
*
*
*
* @constructor
**/
@ -89,10 +85,9 @@ var BackgroundTokenizer = function(tokenizer, editor) {
// only check every 5 lines
processedLines ++;
if ((processedLines % 5 == 0) && (new Date() - workerStart) > 20) {
if ((processedLines % 5 === 0) && (new Date() - workerStart) > 20) {
self.running = setTimeout(self.$worker, 20);
self.currentLine = currentLine;
return;
break;
}
}
self.currentLine = currentLine;

View file

@ -80,8 +80,8 @@ exports.moduleUrl = function(name, component) {
// todo make this configurable or get rid of '-'
var sep = component == "snippets" ? "/" : "-";
var base = parts[parts.length - 1];
if (sep == "-") {
var base = parts[parts.length - 1];
if (component == "worker" && sep == "-") {
var re = new RegExp("^" + component + "[\\-_]|[\\-_]" + component + "$", "g");
base = base.replace(re, "");
}

View file

@ -43,7 +43,7 @@ module.exports = {
"test: path resolution" : function() {
config.set("packaged", "true");
var url = config.moduleUrl("kr_theme", "theme");
assert.equal(url, "theme-kr.js");
assert.equal(url, "theme-kr_theme.js");
config.set("basePath", "a/b");
url = config.moduleUrl("m/theme", "theme");

View file

@ -1,9 +1,7 @@
.ace_editor {
position: relative;
overflow: hidden;
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
font-size: 12px;
line-height: normal;
font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
direction: ltr;
}
@ -17,6 +15,7 @@
-moz-user-select: none;
-webkit-user-select: none;
user-select: none;
cursor: text;
}
.ace_content {
@ -24,14 +23,9 @@
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
cursor: text;
min-width: 100%;
}
.ace_dragging, .ace_dragging * {
cursor: move !important;
}
.ace_dragging .ace_scroller:before{
position: absolute;
top: 0;
@ -155,8 +149,8 @@
}
.ace_text-input.ace_composition {
background: #f8f8f8;
color: #111;
background: inherit;
color: inherit;
z-index: 1000;
opacity: 1;
text-indent: 0;
@ -211,7 +205,7 @@
}
.ace_overwrite-cursors .ace_cursor {
border-left-width: 0px;
border-left-width: 0;
border-bottom: 1px solid;
}
@ -220,10 +214,7 @@
}
.ace_smooth-blinking .ace_cursor {
-moz-transition: opacity 0.18s;
-webkit-transition: opacity 0.18s;
-o-transition: opacity 0.18s;
-ms-transition: opacity 0.18s;
transition: opacity 0.18s;
}
@ -277,8 +268,6 @@
color: transparent;
border: 1px solid black;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px;
cursor: pointer;
@ -302,7 +291,6 @@
border-radius: 1px;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
color: black;
display: block;
max-width: 100%;
padding: 3px 4px;
position: fixed;
@ -359,16 +347,12 @@
.ace_fold-widget:hover {
border: 1px solid rgba(0, 0, 0, 0.3);
background-color: rgba(255, 255, 255, 0.2);
-moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);
-webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);
box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);
}
.ace_fold-widget:active {
border: 1px solid rgba(0, 0, 0, 0.4);
background-color: rgba(0, 0, 0, 0.05);
-moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
-webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
}
/**
@ -388,8 +372,6 @@
background-color: rgba(255, 255, 255, 0.1);
}
.ace_dark .ace_fold-widget:active {
-moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);
-webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);
box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);
}
@ -399,19 +381,13 @@
}
.ace_fade-fold-widgets .ace_fold-widget {
-moz-transition: opacity 0.4s ease 0.05s;
-webkit-transition: opacity 0.4s ease 0.05s;
-o-transition: opacity 0.4s ease 0.05s;
-ms-transition: opacity 0.4s ease 0.05s;
transition: opacity 0.4s ease 0.05s;
opacity: 0;
}
.ace_fade-fold-widgets:hover .ace_fold-widget {
-moz-transition: opacity 0.05s ease 0.05s;
-webkit-transition: opacity 0.05s ease 0.05s;
-o-transition: opacity 0.05s ease 0.05s;
-ms-transition: opacity 0.05s ease 0.05s;
transition: opacity 0.05s ease 0.05s;
opacity:1;
}

View file

@ -268,7 +268,7 @@ var EditSession = function(text, mode) {
this.$informUndoManager.schedule();
}
this.bgTokenizer.$updateOnChange(delta);
this.bgTokenizer && this.bgTokenizer.$updateOnChange(delta);
this._signal("change", e);
};
@ -276,8 +276,6 @@ var EditSession = function(text, mode) {
* Sets the session text.
* @param {String} text The new text to place
*
*
*
**/
this.setValue = function(text) {
this.doc.setValue(text);
@ -950,6 +948,9 @@ var EditSession = function(text, mode) {
if (!$isPlaceholder) {
// experimental method, used by c9 findiniles
if (mode.attachToSession)
mode.attachToSession(this);
this.$options.wrapMethod.set.call(this, this.$wrapMethod);
this.$setFolding(mode.foldingRules);
this.bgTokenizer.start(0);
@ -957,26 +958,23 @@ var EditSession = function(text, mode) {
}
};
this.$stopWorker = function() {
if (this.$worker)
if (this.$worker) {
this.$worker.terminate();
this.$worker = null;
this.$worker = null;
}
};
this.$startWorker = function() {
if (typeof Worker !== "undefined" && !require.noWorker) {
try {
this.$worker = this.$mode.createWorker(this);
} catch (e) {
try {
this.$worker = this.$mode.createWorker(this);
} catch (e) {
if (typeof console == "object") {
console.log("Could not load worker");
console.log(e);
this.$worker = null;
}
}
else
}
this.$worker = null;
}
};
/**
@ -1726,9 +1724,10 @@ var EditSession = function(text, mode) {
// Inside of the foldLine range. Need to split stuff up.
if (cmp == 0) {
foldLine = foldLine.split(start.row, start.column);
foldLine.shiftRow(len);
foldLine.addRemoveChars(
lastRow, 0, end.column - start.column);
if (foldLine) {
foldLine.shiftRow(len);
foldLine.addRemoveChars(lastRow, 0, end.column - start.column);
}
} else
// Infront of the foldLine but same row. Need to shift column.
if (cmp == -1) {
@ -1956,6 +1955,8 @@ var EditSession = function(text, mode) {
split = lastSplit + wrapLimit;
// The split is inside of a CHAR or CHAR_EXT token and no space
// around -> force a split.
if (tokens[split] == CHAR_EXT)
split--;
addSplit(split);
}
return splits;
@ -2395,7 +2396,15 @@ var EditSession = function(text, mode) {
*/
this.$setFontMetrics = function(fm) {
// todo
}
};
this.destroy = function() {
if (this.bgTokenizer) {
this.bgTokenizer.setDocument(null);
this.bgTokenizer = null;
}
this.$stopWorker();
};
// For every keystroke this gets called once per char in the whole doc!!
// Wouldn't hurt to make it a bit faster for c >= 0x1100

View file

@ -117,6 +117,7 @@ function BracketMatch() {
typeRe = new RegExp(
"(\\.?" +
token.type.replace(".", "\\.").replace("rparen", ".paren")
.replace(/\b(?:end|start|begin)\b/, "")
+ ")+"
);
}
@ -173,6 +174,7 @@ function BracketMatch() {
typeRe = new RegExp(
"(\\.?" +
token.type.replace(".", "\\.").replace("lparen", ".paren")
.replace(/\b(?:end|start|begin)\b/, "")
+ ")+"
);
}

View file

@ -44,7 +44,7 @@ function FoldLine(foldData, folds) {
folds = this.folds = [ folds ];
}
var last = folds[folds.length - 1]
var last = folds[folds.length - 1];
this.range = new Range(folds[0].start.row, folds[0].start.column,
last.end.row, last.end.column);
this.start = this.range.start;
@ -66,7 +66,7 @@ function FoldLine(foldData, folds) {
fold.start.row += shift;
fold.end.row += shift;
});
}
};
this.addFold = function(fold) {
if (fold.sameRow) {
@ -96,17 +96,17 @@ function FoldLine(foldData, folds) {
throw new Error("Trying to add fold to FoldRow that doesn't have a matching row");
}
fold.foldLine = this;
}
};
this.containsRow = function(row) {
return row >= this.start.row && row <= this.end.row;
}
};
this.walk = function(callback, endRow, endColumn) {
var lastEnd = 0,
folds = this.folds,
fold,
comp, stop, isNewRow = true;
cmp, stop, isNewRow = true;
if (endRow == null) {
endRow = this.end.row;
@ -116,9 +116,9 @@ function FoldLine(foldData, folds) {
for (var i = 0; i < folds.length; i++) {
fold = folds[i];
comp = fold.range.compareStart(endRow, endColumn);
cmp = fold.range.compareStart(endRow, endColumn);
// This fold is after the endRow/Column.
if (comp == -1) {
if (cmp == -1) {
callback(null, endRow, endColumn, lastEnd, isNewRow);
return;
}
@ -127,8 +127,8 @@ function FoldLine(foldData, folds) {
stop = !stop && callback(fold.placeholder, fold.start.row, fold.start.column, lastEnd);
// If the user requested to stop the walk or endRow/endColumn is
// inside of this fold (comp == 0), then end here.
if (stop || comp == 0) {
// inside of this fold (cmp == 0), then end here.
if (stop || cmp === 0) {
return;
}
@ -138,7 +138,7 @@ function FoldLine(foldData, folds) {
lastEnd = fold.end.column;
}
callback(null, endRow, endColumn, lastEnd, isNewRow);
}
};
this.getNextFoldTo = function(row, column) {
var fold, cmp;
@ -150,15 +150,15 @@ function FoldLine(foldData, folds) {
fold: fold,
kind: "after"
};
} else if (cmp == 0) {
} else if (cmp === 0) {
return {
fold: fold,
kind: "inside"
}
};
}
}
return null;
}
};
this.addRemoveChars = function(row, column, len) {
var ret = this.getNextFoldTo(row, column),
@ -175,7 +175,7 @@ function FoldLine(foldData, folds) {
} else if (fold.start.row == row) {
folds = this.folds;
var i = folds.indexOf(fold);
if (i == 0) {
if (i === 0) {
this.start.column += len;
}
for (i; i < folds.length; i++) {
@ -189,16 +189,18 @@ function FoldLine(foldData, folds) {
this.end.column += len;
}
}
}
};
this.split = function(row, column) {
var fold = this.getNextFoldTo(row, column).fold;
var pos = this.getNextFoldTo(row, column);
if (!pos || pos.kind == "inside")
return null;
var fold = pos.fold;
var folds = this.folds;
var foldData = this.foldData;
if (!fold)
return null;
var i = folds.indexOf(fold);
var foldBefore = folds[i - 1];
this.end.row = foldBefore.end.row;
@ -211,7 +213,7 @@ function FoldLine(foldData, folds) {
var newFoldLine = new FoldLine(foldData, folds);
foldData.splice(foldData.indexOf(this) + 1, 0, newFoldLine);
return newFoldLine;
}
};
this.merge = function(foldLineNext) {
var folds = foldLineNext.folds;
@ -222,7 +224,7 @@ function FoldLine(foldData, folds) {
// it's merged now with foldLineNext.
var foldData = this.foldData;
foldData.splice(foldData.indexOf(foldLineNext), 1);
}
};
this.toString = function() {
var ret = [this.range.toString() + ": [" ];
@ -230,13 +232,12 @@ function FoldLine(foldData, folds) {
this.folds.forEach(function(fold) {
ret.push(" " + fold.toString());
});
ret.push("]")
ret.push("]");
return ret.join("\n");
}
};
this.idxToPosition = function(idx) {
var lastFoldEndColumn = 0;
var fold;
for (var i = 0; i < this.folds.length; i++) {
var fold = this.folds[i];
@ -261,7 +262,7 @@ function FoldLine(foldData, folds) {
row: this.end.row,
column: this.end.column + idx
};
}
};
}).call(FoldLine.prototype);
exports.FoldLine = FoldLine;

View file

@ -94,7 +94,8 @@ var Editor = function(renderer, session) {
this._$emitInputEvent = lang.delayedCall(function() {
this._signal("input", {});
this.session.bgTokenizer && this.session.bgTokenizer.scheduleStart();
if (this.session && this.session.bgTokenizer)
this.session.bgTokenizer.scheduleStart();
}.bind(this));
this.on("change", function(_, _self) {
@ -384,6 +385,9 @@ var Editor = function(renderer, session) {
this.onChangeAnnotation();
this.session.getUseWrapMode() && this.renderer.adjustWrapLimit();
this.renderer.updateFull();
} else {
this.selection = null;
this.renderer.setSession(session);
}
this._signal("changeSession", {
@ -525,25 +529,23 @@ var Editor = function(renderer, session) {
this.$highlightPending = true;
setTimeout(function() {
self.$highlightPending = false;
var pos = self.session.findMatchingBracket(self.getCursorPosition());
var session = self.session;
if (!session || !session.bgTokenizer) return;
var pos = session.findMatchingBracket(self.getCursorPosition());
if (pos) {
var range = new Range(pos.row, pos.column, pos.row, pos.column+1);
} else if (self.session.$mode.getMatching) {
var range = self.session.$mode.getMatching(self.session);
var range = new Range(pos.row, pos.column, pos.row, pos.column + 1);
} else if (session.$mode.getMatching) {
var range = session.$mode.getMatching(self.session);
}
if (range)
self.session.$bracketHighlight = self.session.addMarker(range, "ace_bracket", "text");
session.$bracketHighlight = session.addMarker(range, "ace_bracket", "text");
}, 50);
};
// todo: move to mode.getMatching
this.$highlightTags = function() {
var session = this.session;
if (this.$highlightTagPending) {
if (this.$highlightTagPending)
return;
}
// perform highlight async to not block the browser during navigation
var self = this;
@ -551,6 +553,9 @@ var Editor = function(renderer, session) {
setTimeout(function() {
self.$highlightTagPending = false;
var session = self.session;
if (!session || !session.bgTokenizer) return;
var pos = self.getCursorPosition();
var iterator = new TokenIterator(self.session, pos.row, pos.column);
var token = iterator.getCurrentToken();
@ -572,28 +577,28 @@ var Editor = function(renderer, session) {
token = iterator.stepForward();
if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
if (prevToken.value==='<'){
if (prevToken.value === '<'){
depth++;
} else if (prevToken.value==='</'){
} else if (prevToken.value === '</'){
depth--;
}
}
} while (token && depth>=0);
}else{
} while (token && depth >= 0);
} else {
//find opening tag
do {
token = prevToken;
prevToken = iterator.stepBackward();
if(token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
if (prevToken.value==='<') {
if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
if (prevToken.value === '<') {
depth++;
} else if( prevToken.value==='</') {
} else if (prevToken.value === '</') {
depth--;
}
}
} while (prevToken && depth<=0);
} while (prevToken && depth <= 0);
//select tag again
iterator.stepForward();
@ -696,12 +701,15 @@ var Editor = function(renderer, session) {
this.onDocumentChange = function(e) {
// Rerender and emit "change" event.
var delta = e.data;
var wrap = this.session.$useWrapMode;
var lastRow = (delta.start.row == delta.end.row ? delta.end.row : Infinity);
this.renderer.updateLines(delta.start.row, lastRow);
this.renderer.updateLines(delta.start.row, lastRow, wrap);
this._signal("change", e);
// Update cursor because tab characters can influence the cursor position.
this.$cursorChange();
this.$updateHighlightActiveLine();
};
this.onTokenizerUpdate = function(e) {
@ -1990,17 +1998,13 @@ var Editor = function(renderer, session) {
* Moves the cursor's row and column to the next matching bracket or HTML tag.
*
**/
this.jumpToMatching = function(select) {
this.jumpToMatching = function(select, expand) {
var cursor = this.getCursorPosition();
var iterator = new TokenIterator(this.session, cursor.row, cursor.column);
var prevToken = iterator.getCurrentToken();
var token = prevToken;
var token = prevToken || iterator.stepForward();
if (!token)
token = iterator.stepForward();
if (!token)
return;
if (!token) return;
//get next closing tag or bracket
var matchType;
@ -2019,12 +2023,12 @@ var Editor = function(renderer, session) {
do {
if (token.value.match(/[{}()\[\]]/g)) {
for (; i<token.value.length && !found; i++) {
for (; i < token.value.length && !found; i++) {
if (!brackets[token.value[i]]) {
continue;
}
bracketType = brackets[token.value[i]]+'.'+token.type.replace("rparen", "lparen");
bracketType = brackets[token.value[i]] + '.' + token.type.replace("rparen", "lparen");
if (isNaN(depth[bracketType])) {
depth[bracketType] = 0;
@ -2035,27 +2039,29 @@ var Editor = function(renderer, session) {
case '[':
case '{':
depth[bracketType]++;
break;
break;
case ')':
case ']':
case '}':
depth[bracketType]--;
if (depth[bracketType]===-1) {
if (depth[bracketType] === -1) {
matchType = 'bracket';
found = true;
}
break;
}
}
} else if (token && token.type.indexOf('tag-name') !== -1) {
}
else if (token && token.type.indexOf('tag-name') !== -1) {
if (isNaN(depth[token.value])) {
depth[token.value] = 0;
}
if (prevToken.value === '<') {
depth[token.value]++;
} else if (prevToken.value === '</') {
}
else if (prevToken.value === '</') {
depth[token.value]--;
}
@ -2073,37 +2079,35 @@ var Editor = function(renderer, session) {
} while (token && !found);
//no match found
if (!matchType) {
if (!matchType)
return;
}
var range;
if (matchType==='bracket') {
var range, pos;
if (matchType === 'bracket') {
range = this.session.getBracketRange(cursor);
if (!range) {
range = new Range(
iterator.getCurrentTokenRow(),
iterator.getCurrentTokenColumn()+i-1,
iterator.getCurrentTokenRow(),
iterator.getCurrentTokenColumn()+i-1
iterator.getCurrentTokenRow(),
iterator.getCurrentTokenColumn() + i - 1,
iterator.getCurrentTokenRow(),
iterator.getCurrentTokenColumn() + i - 1
);
if (!range)
return;
var pos = range.start;
if (pos.row === cursor.row && Math.abs(pos.column - cursor.column) < 2)
pos = range.start;
if (expand || pos.row === cursor.row && Math.abs(pos.column - cursor.column) < 2)
range = this.session.getBracketRange(pos);
}
} else if(matchType==='tag') {
if (token && token.type.indexOf('tag-name') !== -1)
}
else if (matchType === 'tag') {
if (token && token.type.indexOf('tag-name') !== -1)
var tag = token.value;
else
return;
var range = new Range(
iterator.getCurrentTokenRow(),
iterator.getCurrentTokenColumn()-2,
iterator.getCurrentTokenRow(),
iterator.getCurrentTokenColumn()-2
range = new Range(
iterator.getCurrentTokenRow(),
iterator.getCurrentTokenColumn() - 2,
iterator.getCurrentTokenRow(),
iterator.getCurrentTokenColumn() - 2
);
//find matching tag
@ -2115,17 +2119,18 @@ var Editor = function(renderer, session) {
if (prevToken) {
if (prevToken.type.indexOf('tag-close') !== -1) {
range.setEnd(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn()+1);
range.setEnd(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() + 1);
}
if (token.value === tag && token.type.indexOf('tag-name') !== -1) {
if (prevToken.value === '<') {
depth[tag]++;
} else if ( prevToken.value === '</') {
}
else if (prevToken.value === '</') {
depth[tag]--;
}
if (depth[tag]===0)
if (depth[tag] === 0)
found = true;
}
}
@ -2134,7 +2139,7 @@ var Editor = function(renderer, session) {
//we found it
if (token && token.type.indexOf('tag-name')) {
var pos = range.start;
pos = range.start;
if (pos.row == cursor.row && Math.abs(pos.column - cursor.column) < 2)
pos = range.end;
}
@ -2143,10 +2148,13 @@ var Editor = function(renderer, session) {
pos = range && range.cursor || pos;
if (pos) {
if (select) {
if (range && range.isEqual(this.getSelectionRange()))
if (range && expand) {
this.selection.setRange(range);
} else if (range && range.isEqual(this.getSelectionRange())) {
this.clearSelection();
else
} else {
this.selection.selectTo(pos.row, pos.column);
}
} else {
this.selection.moveTo(pos.row, pos.column);
}
@ -2504,6 +2512,9 @@ var Editor = function(renderer, session) {
this.destroy = function() {
this.renderer.destroy();
this._signal("destroy", this);
if (this.session) {
this.session.destroy();
}
};
/**

View file

@ -30,9 +30,9 @@
define(function(require, exports, module) {
"use strict";
var LineWidgets = require("ace/line_widgets").LineWidgets;
var dom = require("ace/lib/dom");
var Range = require("ace/range").Range;
var LineWidgets = require("../line_widgets").LineWidgets;
var dom = require("../lib/dom");
var Range = require("../range").Range;
function binarySearch(array, needle, comparator) {
var first = 0;

View file

@ -161,10 +161,6 @@ var doLiveAutocomplete = function(e) {
editor.completer.autoSelect = false;
editor.completer.autoInsert = false;
editor.completer.showPopup(editor);
} else if (!prefix && hasCompleter) {
// When the prefix is empty
// close the autocomplete dialog
editor.completer.detach();
}
}
};

View file

@ -65,11 +65,14 @@ var supportedModes = {
Diff: ["diff|patch"],
Dockerfile: ["^Dockerfile"],
Dot: ["dot"],
Erlang: ["erl|hrl"],
Eiffel: ["e"],
EJS: ["ejs"],
Erlang: ["erl|hrl"],
Forth: ["frt|fs|ldr"],
FTL: ["ftl"],
Gcode: ["gcode"],
Gherkin: ["feature"],
Gitignore: ["^.gitignore"],
Glsl: ["glsl|frag|vert"],
golang: ["go"],
Groovy: ["groovy"],
@ -80,6 +83,7 @@ var supportedModes = {
HTML: ["html|htm|xhtml"],
HTML_Ruby: ["erb|rhtml|html.erb"],
INI: ["ini|conf|cfg|prefs"],
Io: ["io"],
Jack: ["jack"],
Jade: ["jade"],
Java: ["java"],
@ -100,11 +104,11 @@ var supportedModes = {
LuaPage: ["lp"],
Lucene: ["lucene"],
Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"],
MATLAB: ["matlab"],
Markdown: ["md|markdown"],
MATLAB: ["matlab"],
MEL: ["mel"],
MySQL: ["mysql"],
MUSHCode: ["mc|mush"],
MySQL: ["mysql"],
Nix: ["nix"],
ObjectiveC: ["m|mm"],
OCaml: ["ml|mli"],
@ -113,6 +117,7 @@ var supportedModes = {
pgSQL: ["pgsql"],
PHP: ["php|phtml"],
Powershell: ["ps1"],
Praat: ["praat|praatscript|psc|proc"],
Prolog: ["plg|prolog"],
Properties: ["properties"],
Protobuf: ["proto"],
@ -125,14 +130,14 @@ var supportedModes = {
SASS: ["sass"],
SCAD: ["scad"],
Scala: ["scala"],
Smarty: ["smarty|tpl"],
Scheme: ["scm|rkt"],
SCSS: ["scss"],
SH: ["sh|bash|^.bashrc"],
SJS: ["sjs"],
Space: ["space"],
Smarty: ["smarty|tpl"],
snippets: ["snippets"],
Soy_Template:["soy"],
Space: ["space"],
SQL: ["sql"],
Stylus: ["styl|stylus"],
SVG: ["svg"],
@ -144,9 +149,10 @@ var supportedModes = {
Twig: ["twig"],
Typescript: ["ts|typescript|str"],
Vala: ["vala"],
VBScript: ["vbs"],
VBScript: ["vbs|vb"],
Velocity: ["vm"],
Verilog: ["v|vh|sv|svh"],
VHDL: ["vhd|vhdl"],
XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl"],
XQuery: ["xq"],
YAML: ["yaml|yml"]
@ -156,7 +162,7 @@ var nameOverrides = {
ObjectiveC: "Objective-C",
CSharp: "C#",
golang: "Go",
C_Cpp: "C/C++",
C_Cpp: "C and C++",
coffee: "CoffeeScript",
HTML_Ruby: "HTML (Ruby)",
FTL: "FreeMarker"

View file

@ -7,7 +7,7 @@
background-color: #ddd;
border: 1px solid #cbcbcb;
border-top: 0 none;
max-width: 297px;
max-width: 325px;
overflow: hidden;
margin: 0;
padding: 4px;
@ -47,7 +47,6 @@
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
display: block;
float: left;
height: 22px;
outline: 0;
@ -61,7 +60,6 @@
border: 0 none;
border-left: 1px solid #dcdcdc;
cursor: pointer;
display: block;
float: left;
height: 22px;
margin: 0;
@ -94,12 +92,9 @@
border: 0 none;
color: #656565;
cursor: pointer;
display: block;
float: right;
font-family: Arial;
font-size: 16px;
font: 16px/16px Arial;
height: 14px;
line-height: 16px;
margin: 5px 1px 9px 5px;
padding: 0;
text-align: center;

View file

@ -46,6 +46,7 @@ var html = '<div class="ace_search right">\
<input class="ace_search_field" placeholder="Search for" spellcheck="false"></input>\
<button type="button" action="findNext" class="ace_searchbtn next"></button>\
<button type="button" action="findPrev" class="ace_searchbtn prev"></button>\
<button type="button" action="findAll" class="ace_searchbtn" title="Alt-Enter">All</button>\
</div>\
<div class="ace_replace_form">\
<input class="ace_search_field" placeholder="Replace with" spellcheck="false"></input>\
@ -170,6 +171,11 @@ var SearchBox = function(editor, range, showReplaceForm) {
sb.replace();
sb.findPrev();
},
"Alt-Return": function(sb) {
if (sb.activeInput == sb.replaceInput)
sb.replaceAll();
sb.findAll();
},
"Tab": function(sb) {
(sb.activeInput == sb.replaceInput ? sb.searchInput : sb.replaceInput).focus();
}
@ -229,6 +235,18 @@ var SearchBox = function(editor, range, showReplaceForm) {
this.findPrev = function() {
this.find(true, true);
};
this.findAll = function(){
var range = this.editor.findAll(this.searchInput.value, {
regExp: this.regExpOption.checked,
caseSensitive: this.caseSensitiveOption.checked,
wholeWord: this.wholeWordOption.checked
});
var noMatch = !range && this.searchInput.value;
dom.setCssClass(this.searchBox, "ace_nomatch", noMatch);
this.editor._emit("findSearchBox", { match: !noMatch });
this.highlight();
this.hide();
};
this.replace = function() {
if (!this.editor.getReadOnly())
this.editor.replace(this.replaceInput.value);

View file

@ -5,7 +5,6 @@
.ace_static_highlight .ace_gutter {
width: 25px !important;
display: block;
float: left;
text-align: right;
padding: 0 3px 0 0;

View file

@ -98,7 +98,6 @@ var highlight = function(el, opts, callback) {
* and `css`.
* @returns {object} An object containing the properties `html` and `css`.
*/
highlight.render = function(input, mode, theme, lineStart, disableGutter, callback) {
var waiting = 1;
var modeCache = EditSession.prototype.$modes;
@ -112,11 +111,17 @@ highlight.render = function(input, mode, theme, lineStart, disableGutter, callba
--waiting || done();
});
}
// allow setting mode options e.h {path: "ace/mode/php", inline:true}
var modeOptions;
if (mode && typeof mode === "object" && !mode.getTokenizer) {
modeOptions = mode;
mode = modeOptions.path;
}
if (typeof mode == "string") {
waiting++;
config.loadModule(['mode', mode], function(m) {
if (!modeCache[mode]) modeCache[mode] = new m.Mode();
if (!modeCache[mode] || modeOptions)
modeCache[mode] = new m.Mode(modeOptions);
mode = modeCache[mode];
--waiting || done();
});
@ -130,14 +135,13 @@ highlight.render = function(input, mode, theme, lineStart, disableGutter, callba
return --waiting || done();
};
/*
/**
* Transforms a given input code snippet into HTML using the given mode
* @param {string} input Code snippet
* @param {mode} mode Mode loaded from /ace/mode (use 'ServerSideHiglighter.getMode')
* @param {string} r Code snippet
* @returns {object} An object containing: html, css
*/
highlight.renderSync = function(input, mode, theme, lineStart, disableGutter) {
lineStart = parseInt(lineStart || 1, 10);

View file

@ -76,11 +76,14 @@ exports.$detectIndentation = function(lines, fallback) {
var first = {score: 0, length: 0};
var spaceIndents = 0;
for (var i = 1; i < 12; i++) {
var score = getScore(i);
if (i == 1) {
spaceIndents = getScore(i);
var score = stats.length && 1;
spaceIndents = score;
score = stats[1] ? 0.9 : 0.8;
if (!stats.length)
score = 0
} else
var score = getScore(i) / spaceIndents;
score /= spaceIndents;
if (changes[i])
score += changes[i] / changesTotal;

View file

@ -300,9 +300,12 @@ exports.handler.handleKeyboard = function(data, hashId, key, keyCode) {
if (!command) return undefined;
}
if (!command.readonly && !command.isYank)
if (!command.readOnly && !command.isYank)
data.lastCommand = null;
if (!command.readOnly && editor.emacsMark())
editor.setEmacsMark(null)
if (data.count) {
var count = data.count;
data.count = 0;
@ -384,7 +387,7 @@ exports.emacsKeys = {
"M-y": "yankRotate",
"C-g": "keyboardQuit",
"C-w": "killRegion",
"C-w|C-S-W": "killRegion",
"M-w": "killRingSave",
"C-Space": "setMark",
"C-x C-x": "exchangePointAndMark",
@ -466,7 +469,7 @@ exports.handler.addCommands({
editor.setEmacsMark(mark);
editor.selection.setSelectionAnchor(mark.row, mark.column);
},
readonly: true,
readOnly: true,
handlesCount: true,
multiSelectAction: "forEach"
},
@ -488,7 +491,7 @@ exports.handler.addCommands({
}
sel.setSelectionRange(range, !sel.isBackwards());
},
readonly: true,
readOnly: true,
handlesCount: true,
multiSelectAction: "forEach"
},
@ -547,7 +550,7 @@ exports.handler.addCommands({
exports.killRing.add(editor.getCopyText());
editor.commands.byName.cut.exec(editor);
},
readonly: true,
readOnly: true,
multiSelectAction: "forEach"
},
killRingSave: {
@ -560,7 +563,7 @@ exports.handler.addCommands({
sel.clearSelection();
}, 0);
},
readonly: true
readOnly: true
},
keyboardQuit: function(editor) {
editor.selection.clearSelection();

View file

@ -51,6 +51,7 @@ var TextInput = function(parentNode, host) {
text.spellcheck = false;
text.style.opacity = "0";
if (useragent.isOldIE) text.style.top = "-100px";
parentNode.insertBefore(text, parentNode.firstChild);
var PLACEHOLDER = "\x01\x01";
@ -255,7 +256,7 @@ var TextInput = function(parentNode, host) {
} else {
return clipboardData.getData(mime);
}
}
};
var doCopy = function(e, isCut) {
var data = host.getCopyText();
@ -280,11 +281,11 @@ var TextInput = function(parentNode, host) {
var onCut = function(e) {
doCopy(e, true);
}
};
var onCopy = function(e) {
doCopy(e, false);
}
};
var onPaste = function(e) {
var data = handleClipboardData(e);
@ -335,7 +336,8 @@ var TextInput = function(parentNode, host) {
// COMPOSITION
var onCompositionStart = function(e) {
if (inComposition || !host.onCompositionStart) return;
if (inComposition || !host.onCompositionStart || host.$readOnly)
return;
// console.log("onCompositionStart", inComposition)
inComposition = {};
host.onCompositionStart();
@ -351,7 +353,8 @@ var TextInput = function(parentNode, host) {
var onCompositionUpdate = function() {
// console.log("onCompositionUpdate", inComposition && JSON.stringify(text.value))
if (!inComposition || !host.onCompositionUpdate) return;
if (!inComposition || !host.onCompositionUpdate || host.$readOnly)
return;
var val = text.value.replace(/\x01/g, "");
if (inComposition.lastValue === val) return;
@ -370,7 +373,7 @@ var TextInput = function(parentNode, host) {
};
var onCompositionEnd = function(e) {
if (!host.onCompositionEnd) return;
if (!host.onCompositionEnd || host.$readOnly) return;
// console.log("onCompositionEnd", inComposition &&inComposition.lastValue)
var c = inComposition;
inComposition = false;
@ -379,7 +382,7 @@ var TextInput = function(parentNode, host) {
var str = text.value.replace(/\x01/g, "");
// console.log(str, c.lastValue)
if (inComposition)
return
return;
else if (str == c.lastValue)
resetValue();
else if (!c.lastValue && str) {
@ -428,18 +431,25 @@ var TextInput = function(parentNode, host) {
this.onContextMenu = function(e) {
afterContextMenu = true;
if (!tempStyle)
tempStyle = text.style.cssText;
text.style.cssText = "z-index:100000;" + (useragent.isIE ? "opacity:0.1;" : "");
resetSelection(host.selection.isEmpty());
host._emit("nativecontextmenu", {target: host, domEvent: e});
this.moveToMouse(e, true);
};
this.moveToMouse = function(e, bringToFront) {
if (!bringToFront && useragent.isOldIE)
return;
if (!tempStyle)
tempStyle = text.style.cssText;
text.style.cssText = (bringToFront ? "z-index:100000;" : "")
+ "height:" + text.style.height + ";"
+ (useragent.isIE ? "opacity:0.1;" : "");
var rect = host.container.getBoundingClientRect();
var style = dom.computedStyle(host.container);
var top = rect.top + (parseInt(style.borderTopWidth) || 0);
var left = rect.left + (parseInt(rect.borderLeftWidth) || 0);
var maxTop = rect.bottom - top - text.clientHeight;
var maxTop = rect.bottom - top - text.clientHeight -2;
var move = function(e) {
text.style.left = e.clientX - left - 2 + "px";
text.style.top = Math.min(e.clientY - top - 2, maxTop) + "px";
@ -453,13 +463,15 @@ var TextInput = function(parentNode, host) {
host.renderer.$keepTextAreaAtCursor = null;
// on windows context menu is opened after mouseup
if (useragent.isWin)
if (useragent.isWin && !useragent.isOldIE)
event.capture(host.container, move, onContextMenuClose);
};
this.onContextMenuClose = onContextMenuClose;
var closeTimeout;
function onContextMenuClose() {
setTimeout(function () {
clearTimeout(closeTimeout)
closeTimeout = setTimeout(function () {
if (tempStyle) {
text.style.cssText = tempStyle;
tempStyle = '';
@ -468,18 +480,15 @@ var TextInput = function(parentNode, host) {
host.renderer.$keepTextAreaAtCursor = true;
host.renderer.$moveTextAreaToCursor();
}
}, 0);
}, useragent.isOldIE ? 200 : 0);
}
// firefox fires contextmenu event after opening it
if (!useragent.isGecko || useragent.isMac) {
var onContextMenu = function(e) {
host.textInput.onContextMenu(e);
onContextMenuClose();
};
event.addListener(host.renderer.scroller, "contextmenu", onContextMenu);
event.addListener(text, "contextmenu", onContextMenu);
}
var onContextMenu = function(e) {
host.textInput.onContextMenu(e);
onContextMenuClose();
};
event.addListener(host.renderer.scroller, "contextmenu", onContextMenu);
event.addListener(text, "contextmenu", onContextMenu);
};
exports.TextInput = TextInput;

View file

@ -426,7 +426,7 @@ module.exports = {
var column = util.getRightNthChar(editor, cursor, param, count || 1);
if (isRepeat && column == 0 && !(count > 1))
var column = util.getRightNthChar(editor, cursor, param, 2);
column = util.getRightNthChar(editor, cursor, param, 2);
if (typeof column === "number") {
cursor.column += column + (isSel ? 1 : 0);
@ -444,8 +444,8 @@ module.exports = {
var cursor = editor.getCursorPosition();
var column = util.getLeftNthChar(editor, cursor, param, count || 1);
if (isRepeat && column == 0 && !(count > 1))
var column = util.getLeftNthChar(editor, cursor, param, 2);
if (isRepeat && column === 0 && !(count > 1))
column = util.getLeftNthChar(editor, cursor, param, 2);
if (typeof column === "number") {
cursor.column -= column;
@ -558,7 +558,7 @@ module.exports = {
content += "\n";
if (content.length) {
editor.navigateLineEnd()
editor.navigateLineEnd();
editor.insert(content);
util.insertMode(editor);
}
@ -575,7 +575,7 @@ module.exports = {
if (content.length) {
if(row > 0) {
editor.navigateUp();
editor.navigateLineEnd()
editor.navigateLineEnd();
editor.insert(content);
} else {
editor.session.insert({row: 0, column: 0}, content);

View file

@ -74,7 +74,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
document.documentElement.appendChild(el);
var w = el.getBoundingClientRect().width;
if (w > 0 && w < 1)
CHAR_COUNT = 1;
CHAR_COUNT = 50;
else
CHAR_COUNT = 100;
el.parentNode.removeChild(el);
@ -127,11 +127,16 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
};
this.$measureSizes = function() {
if (CHAR_COUNT === 1) {
var rect = this.$measureNode.getBoundingClientRect();
if (CHAR_COUNT === 50) {
var rect = null;
try {
rect = this.$measureNode.getBoundingClientRect();
} catch(e) {
rect = {width: 0, height:0 };
};
var size = {
height: rect.height,
width: rect.width
width: rect.width / CHAR_COUNT
};
} else {
var size = {

View file

@ -58,7 +58,8 @@ var Gutter = function(parentEl) {
if (this.session)
this.session.removeEventListener("change", this.$updateAnnotations);
this.session = session;
session.on("change", this.$updateAnnotations);
if (session)
session.on("change", this.$updateAnnotations);
};
this.addGutterDecoration = function(row, className){

View file

@ -93,7 +93,7 @@ var Marker = function(parentEl) {
this.drawSingleLineMarker(html, range, marker.clazz + " ace_start", config);
}
}
this.element = dom.setInnerHtml(this.element, html.join(""));
this.element.innerHTML = html.join("");
};
this.$getTop = function(row, layerConfig) {

View file

@ -95,7 +95,8 @@ var Text = function(parentEl) {
};
this.setSession = function(session) {
this.session = session;
this.$computeTabString();
if (session)
this.$computeTabString();
};
this.showInvisibles = false;
@ -203,7 +204,7 @@ var Text = function(parentEl) {
html, row, !this.$useLineGroups(), row == foldStart ? foldLine : false
);
lineElement.style.height = config.lineHeight * this.session.getRowLength(row) + "px";
dom.setInnerHtml(lineElement, html.join(""));
lineElement.innerHTML = html.join("");
}
row++;
}
@ -310,7 +311,7 @@ var Text = function(parentEl) {
row++;
}
this.element = dom.setInnerHtml(this.element, html.join(""));
this.element.innerHTML = html.join("");
};
this.$textToken = {
@ -321,7 +322,7 @@ var Text = function(parentEl) {
this.$renderToken = function(stringBuilder, screenColumn, token, value) {
var self = this;
var replaceReg = /\t|&|<|( +)|([\x00-\x1f\x80-\xa0\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g;
var replaceReg = /\t|&|<|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g;
var replaceFunc = function(c, a, b, tabIdx, idx4) {
if (a) {
return self.showInvisibles ?

View file

@ -49,7 +49,7 @@ exports.createElement = function(tag, ns) {
};
exports.hasCssClass = function(el, name) {
var classes = el.className.split(/\s+/g);
var classes = (el.className || "").split(/\s+/g);
return classes.indexOf(name) !== -1;
};

View file

@ -191,6 +191,8 @@ exports.addMultiMouseDownListener = function(el, timeouts, eventHandler, callbac
startY = e.clientY;
}
}
e._clicks = clicks;
eventHandler[callbackName]("mousedown", e);
@ -237,7 +239,7 @@ function normalizeCommandKeys(callback, e, keyCode) {
return;
}
if (keyCode === 18 || keyCode === 17) {
var location = e.location || e.keyLocation;
var location = "location" in e ? e.location : e.keyLocation;
if (keyCode === 17 && location === 1) {
ts = e.timeStamp;
} else if (keyCode === 18 && hashId === 3 && location === 2) {
@ -273,7 +275,8 @@ function normalizeCommandKeys(callback, e, keyCode) {
}
if (!hashId && keyCode === 13) {
if (e.location || e.keyLocation === 3) {
var location = "location" in e ? e.location : e.keyLocation;
if (location === 3) {
callback(e, hashId, -keyCode);
if (e.defaultPrevented)
return;

View file

@ -34,6 +34,8 @@ For more information about SproutCore, visit http://www.sproutcore.com
define(function(require, exports, module) {
"use strict";
require("./fixoldbrowsers");
var oop = require("./oop");
/*
@ -136,7 +138,7 @@ var Keys = (function() {
(function() {
var mods = ["cmd", "ctrl", "alt", "shift"];
for (var i = Math.pow(2, mods.length); i--;) {
for (var i = Math.pow(2, mods.length); i--;) {
ret.KEY_MODS[i] = mods.filter(function(x) {
return i & ret.KEY_MODS[x];
}).join("-") + "-";

View file

@ -42,6 +42,7 @@ class Foo extends Bar
foo.static.function
#!test tokenize string with interpolation
a = "#{ 22 / 7 + {x: "#{a + b}"} + 2}"
" #{ "" + {} } )"
"""heredoc
"""
do ->

View file

@ -0,0 +1,24 @@
<?php
function nfact($n) {
if ($n == 0) {
return 1;
}
else {
return $n * nfact($n - 1);
}
}
echo "\n\nPlease enter a whole number ... ";
$num = trim(fgets(STDIN));
// ===== PROCESS - Determing the factorial of the input number =====
$output = "\n\nFactorial " . $num . " = " . nfact($num) . "\n\n";
echo $output;
?> <script> <?php
echo '
';
?>
/*this is js <?php echo ':)'; ?>
</script> not &js;

View file

@ -466,6 +466,23 @@
["constant.numeric","2"],
["paren.string","}"],
["string.end","\""]
],[
"start",
["string.start","\""],
["string"," "],
["paren.string","#{"],
["text"," "],
["string.start","\""],
["string.end","\""],
["text"," "],
["keyword.operator","+"],
["text"," "],
["paren","{}"],
["text"," "],
["paren.string","}"],
["string"," )"],
["string.end","\""],
["text"," "]
],[
"qqdoc",
["string","\"\"\"heredoc"]

View file

@ -0,0 +1,33 @@
[[
"start",
["comment","# A sample .gitignore file."]
],[
"start"
],[
"start",
["text",".buildlog"]
],[
"start",
["text",".DS_Store"]
],[
"start",
["text",".svn"]
],[
"start"
],[
"start",
["comment","# Negated patterns:"]
],[
"start",
["keyword","!foo.bar"]
],[
"start"
],[
"start",
["comment","# Also ignore user settings..."]
],[
"start",
["text","/.settings"]
],[
"start"
]]

View file

@ -288,9 +288,9 @@
["string.regexp.charachterclass","r"],
["constant.language.escape","-"],
["string.regexp.charachterclass","o"],
["regexp.keyword.operator","\\f\\f"],
["regexp.charclass.keyword.operator","\\f\\f"],
["string.regexp.charachterclass","["],
["regexp.keyword.operator","\\f"],
["regexp.charclass.keyword.operator","\\f"],
["constant.language.escape","]?"],
["string.regexp","r"],
["invalid","{7}+"],
@ -379,7 +379,7 @@
["constant.numeric","1."],
["text","00"],
["identifier","E"],
["text","^"],
["keyword.operator","^"],
["constant.numeric","1"],
["punctuation.operator",","],
["text"," "],

View file

@ -2,37 +2,37 @@
"start",
["keyword","\\usepackage"],
["lparen","{"],
["text","amsmath"],
["storage.type","amsmath"],
["rparen","}"]
],[
"start",
["keyword","\\title"],
["storage.type","\\title"],
["lparen","{"],
["keyword","\\LaTeX"],
["storage.type","\\LaTeX"],
["rparen","}"]
],[
"start",
["keyword","\\date"],
["storage.type","\\date"],
["lparen","{"],
["rparen","}"]
],[
"start",
["keyword","\\begin"],
["storage.type","\\begin"],
["lparen","{"],
["text","document"],
["variable.parameter","document"],
["rparen","}"]
],[
"start",
["text"," "],
["keyword","\\maketitle"]
["storage.type","\\maketitle"]
],[
"start",
["text"," "],
["keyword","\\LaTeX"],
["storage.type","\\LaTeX"],
["lparen","{"],
["rparen","}"],
["text"," is a document preparation system for the "],
["keyword","\\TeX"],
["storage.type","\\TeX"],
["lparen","{"],
["rparen","}"]
],[
@ -50,26 +50,26 @@
],[
"start",
["text"," and much more. "],
["keyword","\\LaTeX"],
["storage.type","\\LaTeX"],
["lparen","{"],
["rparen","}"],
["text"," was originally written in 1984 by Leslie"]
],[
"start",
["text"," Lamport and has become the dominant method for using "],
["keyword","\\TeX"],
["storage.type","\\TeX"],
["text","; few"]
],[
"start",
["text"," people write in plain "],
["keyword","\\TeX"],
["storage.type","\\TeX"],
["lparen","{"],
["rparen","}"],
["text"," anymore. The current version is"]
],[
"start",
["text"," "],
["keyword","\\LaTeXe"],
["storage.type","\\LaTeXe"],
["text","."]
],[
"start",
@ -85,26 +85,26 @@
],[
"start",
["text"," "],
["keyword","\\begin"],
["storage.type","\\begin"],
["lparen","{"],
["text","align"],
["variable.parameter","align"],
["rparen","}"]
],[
"start",
["text"," E &= mc^2 "],
["keyword","\\\\"]
["constant.character.escape","\\\\"]
],[
"start",
["text"," m &= "],
["keyword","\\frac"],
["storage.type","\\frac"],
["lparen","{"],
["text","m_0"],
["rparen","}"],
["lparen","{"],
["keyword","\\sqrt"],
["storage.type","\\sqrt"],
["lparen","{"],
["text","1-"],
["keyword","\\frac"],
["storage.type","\\frac"],
["lparen","{"],
["text","v^2"],
["rparen","}"],
@ -114,14 +114,14 @@
],[
"start",
["text"," "],
["keyword","\\end"],
["storage.type","\\end"],
["lparen","{"],
["text","align"],
["variable.parameter","align"],
["rparen","}"]
],[
"start",
["keyword","\\end"],
["storage.type","\\end"],
["lparen","{"],
["text","document"],
["variable.parameter","document"],
["rparen","}"]
]]

View file

@ -500,4 +500,4 @@
["paren.rparen.lsl","}"]
],[
"start"
]]
]]

View file

@ -345,4 +345,4 @@
["text"," "],
["comment","--[[ blah ]]"],
["paren.rparen",")"]
]]
]]

View file

@ -129,6 +129,43 @@
],[
"php-start"
],[
"start",
["php-start","js-start"],
["support.php_tag","?>"],
["text.xml"," "],
["meta.tag.punctuation.tag-open.xml","<"],
["meta.tag.script.tag-name.xml","script"],
["meta.tag.punctuation.tag-close.xml",">"],
["text"," "],
["support.php_tag","<?php"]
],[
["#tmp","php-qstring","php-start","js-start"],
["support.function","echo"],
["text"," "],
["string","'"]
],[
["php-start","js-start"],
["string","'"],
["text",";"]
],[
"js-start",
["support.php_tag","?>"]
],[
"js-comment_regex_allowed",
["comment","/*this is js "],
["support.php_tag","<?php"],
["text"," "],
["support.function","echo"],
["text"," "],
["string","':)'"],
["text","; "],
["support.php_tag","?>"]
],[
"start",
["meta.tag.punctuation.end-tag-open.xml","</"],
["meta.tag.script.tag-name.xml","script"],
["meta.tag.punctuation.tag-close.xml",">"],
["text.xml"," not "],
["constant.language.escape.reference.xml","&js;"]
],[
"start"
]]

View file

@ -0,0 +1,158 @@
[[
"start",
["meta.using.vala",""],
["keyword.other.using.vala","using"],
["meta.using.vala"," "],
["storage.modifier.using.vala","Gtk"],
["punctuation.terminator.vala",";"]
],[
"start",
["text"," "]
],[
"text0",
["storage.type.primitive.array.vala","int"],
["text"," main ("],
["storage.type.primitive.array.vala","string"],
["text","[] args) {"]
],[
"text0",
["text"," "],
["storage.type.vala","Gtk"],
["keyword.operator.dereference.vala","."],
["text","init ("],
["storage.modifier.vala","ref"],
["text"," args)"],
["punctuation.terminator.vala",";"]
],[
"text0",
["text"," "],
["storage.type.primitive.vala","var"],
["text"," foo "],
["keyword.operator.assignment.vala","="],
["text"," "],
["keyword.control.new.vala","new"],
["text"," "],
["storage.type.generic.vala","MyFoo<string[](), MyBar<string, int>>"],
["text","()"],
["punctuation.terminator.vala",";"]
],[
"text0"
],[
"text0",
["text"," "],
["storage.type.primitive.vala","var"],
["text"," window "],
["keyword.operator.assignment.vala","="],
["text"," "],
["keyword.control.new.vala","new"],
["text"," "],
["storage.type.vala","Window"],
["text","()"],
["punctuation.terminator.vala",";"]
],[
"text0",
["text"," window"],
["keyword.operator.dereference.vala","."],
["text","title "],
["keyword.operator.assignment.vala","="],
["text"," "],
["punctuation.definition.string.begin.vala","\""],
["string.quoted.double.vala","Hello, World!"],
["punctuation.definition.string.end.vala","\""],
["punctuation.terminator.vala",";"]
],[
"text0",
["text"," window"],
["keyword.operator.dereference.vala","."],
["text","border_width "],
["keyword.operator.assignment.vala","="],
["text"," "],
["constant.numeric.vala","10"],
["punctuation.terminator.vala",";"]
],[
"text0",
["text"," window"],
["keyword.operator.dereference.vala","."],
["text","window_position "],
["keyword.operator.assignment.vala","="],
["text"," "],
["storage.type.vala","WindowPosition"],
["keyword.operator.dereference.vala","."],
["constant.other.vala","CENTER"],
["punctuation.terminator.vala",";"]
],[
"text0",
["text"," window"],
["keyword.operator.dereference.vala","."],
["text","set_default_size("],
["constant.numeric.vala","350"],
["text",", "],
["constant.numeric.vala","70"],
["text",")"],
["punctuation.terminator.vala",";"]
],[
"text0",
["text"," window"],
["keyword.operator.dereference.vala","."],
["text","destroy"],
["keyword.operator.dereference.vala","."],
["text","connect("],
["storage.type.vala","Gtk"],
["keyword.operator.dereference.vala","."],
["text","main_quit)"],
["punctuation.terminator.vala",";"]
],[
"text0",
["text"," "]
],[
"text0",
["text"," "],
["storage.type.primitive.vala","var"],
["text"," label "],
["keyword.operator.assignment.vala","="],
["text"," "],
["keyword.control.new.vala","new"],
["text"," "],
["storage.type.vala","Label"],
["text","("],
["punctuation.definition.string.begin.vala","\""],
["string.quoted.double.vala","Hello, World!"],
["punctuation.definition.string.end.vala","\""],
["text",")"],
["punctuation.terminator.vala",";"]
],[
"text0",
["text"," "]
],[
"text0",
["text"," window"],
["keyword.operator.dereference.vala","."],
["text","add(label)"],
["punctuation.terminator.vala",";"]
],[
"text0",
["text"," window"],
["keyword.operator.dereference.vala","."],
["text","show_all()"],
["punctuation.terminator.vala",";"]
],[
"text0",
["text"," "]
],[
"text0",
["text"," "],
["storage.type.vala","Gtk"],
["keyword.operator.dereference.vala","."],
["text","main()"],
["punctuation.terminator.vala",";"]
],[
"text0",
["text"," "],
["keyword.control.vala","return"],
["text"," "],
["constant.numeric.vala","0"],
["punctuation.terminator.vala",";"]
],[
"start",
["text","}"]
]]

View file

@ -1,44 +0,0 @@
[[
"[\"start\"]",
["keyword","xquery"],
["text"," "],
["keyword","version"],
["text"," "],
["string","\""],
["string","1.0"],
["string","\""],
["text",";"]
],[
"[\"start\"]"
],[
"[\"start\"]",
["keyword","let"],
["text"," "],
["variable","$message"],
["text"," "],
["keyword.operator",":="],
["text"," "],
["string","\""],
["string","Hello World!"],
["string","\""]
],[
"[\"start\",\"StartTag\",\"TagContent\"]",
["keyword","return"],
["text"," "],
["meta.tag","<results"],
["meta.tag",">"]
],[
"[\"start\",\"StartTag\",\"TagContent\"]",
["text"," "],
["meta.tag","<message"],
["meta.tag",">"],
["text","{"],
["variable","$message"],
["text","}"],
["meta.tag","</message>"]
],[
"[\"start\"]",
["meta.tag","</results>"]
],[
"[\"start\"]"
]]

View file

@ -22,8 +22,9 @@ var c_cppHighlightRules = function() {
);
var storageModifiers = (
"const|extern|register|restrict|static|volatile|inline|private:|" +
"protected:|public:|friend|explicit|virtual|export|mutable|typename"
"const|extern|register|restrict|static|volatile|inline|private|" +
"protected|public|friend|explicit|virtual|export|mutable|typename|" +
"constexpr|new|delete"
);
var keywordOperators = (

File diff suppressed because it is too large Load diff

View file

@ -40,8 +40,11 @@ var Worker = exports.Worker = function(sender) {
Mirror.call(this, sender);
this.setTimeout(400);
this.ruleset = null;
this.setDisabledRules("ids");
this.setInfoRules("adjoining-classes|qualified-headings|zero-units|gradients|import|outline-none");
this.setDisabledRules("ids|order-alphabetical");
this.setInfoRules(
"adjoining-classes|qualified-headings|zero-units|gradients|" +
"import|outline-none|vendor-prefix"
);
};
oop.inherits(Worker, Mirror);

View file

@ -54,7 +54,7 @@ var DartHighlightRules = function() {
},
{
token: "keyword.other.import.dart",
regex: "(?:\\b)(?:library|import|export|part|of)(?:\\b)"
regex: "(?:\\b)(?:library|import|export|part|of|show|hide)(?:\\b)"
},
{
token : ["keyword.other.import.dart", "text"],

View file

@ -41,7 +41,7 @@ var DockerfileHighlightRules = function() {
for (var i = 0; i < startRules.length; i++) {
if (startRules[i].token == "variable.language") {
startRules.splice(i, 0, {
token: "variable.language",
token: "constant.language",
regex: "(?:^(?:FROM|MAINTAINER|RUN|CMD|EXPOSE|ENV|ADD|ENTRYPOINT|VOLUME|USER|WORKDIR|ONBUILD)\\b)",
caseInsensitive: true
});

52
lib/ace/mode/eiffel.js Normal file
View file

@ -0,0 +1,52 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2014, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
var EiffelHighlightRules = require("./eiffel_highlight_rules").EiffelHighlightRules;
var Range = require("../range").Range;
var Mode = function() {
this.HighlightRules = EiffelHighlightRules;
};
oop.inherits(Mode, TextMode);
(function() {
this.lineCommentStart = "--";
this.$id = "ace/mode/eiffel";
}).call(Mode.prototype);
exports.Mode = Mode;
});

View file

@ -0,0 +1,143 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2014, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var EiffelHighlightRules = function() {
var keywords = "across|agent|alias|all|attached|as|assign|attribute|check|" +
"class|convert|create|debug|deferred|detachable|do|else|elseif|end|" +
"ensure|expanded|export|external|feature|from|frozen|if|inherit|" +
"inspect|invariant|like|local|loop|not|note|obsolete|old|once|" +
"Precursor|redefine|rename|require|rescue|retry|select|separate|" +
"some|then|undefine|until|variant|when";
var operatorKeywords = "and|implies|or|xor";
var languageConstants = "Void";
var booleanConstants = "True|False";
var languageVariables = "Current|Result";
var keywordMapper = this.createKeywordMapper({
"constant.language": languageConstants,
"constant.language.boolean": booleanConstants,
"variable.language": languageVariables,
"keyword.operator": operatorKeywords,
"keyword": keywords
}, "identifier", true);
this.$rules = {
"start": [{
token : "comment.line.double-dash",
regex : /--.*$/
}, {
token : "string.quoted.double",
regex : /"(?:%"|[^%])*?"/
}, {
token : "string.quoted.other", // "[ ]" aligned verbatim string
regex : /"\[/,
next: "aligned_verbatim_string"
}, {
token : "string.quoted.other", // "{ }" non-aligned verbatim string
regex : /"\{/,
next: "non-aligned_verbatim_string"
}, {
token : "constant.character",
regex : /'(?:%%|%T|%R|%N|%F|%'|[^%])'/
}, {
token : "constant.numeric", // real
regex : /(?:\d(?:_?\d)*\.|\.\d)(?:\d*[eE][+-]?\d+)?\b/
}, {
token : "constant.numeric", // integer
regex : /\d(?:_?\d)*\b/
}, {
token : "constant.numeric", // hex
regex : /0[xX][a-fA-F\d](?:_?[a-fA-F\d])*\b/
}, {
token : "constant.numeric", // octal
regex : /0[cC][0-7](?:_?[0-7])*\b/
},{
token : "constant.numeric", // bin
regex : /0[bB][01](?:_?[01])*\b/
}, {
token : "keyword.operator",
regex : /\+|\-|\*|\/|\\\\|\/\/|\^|~|\/~|<|>|<=|>=|\/=|=|:=|\|\.\.\||\.\./
}, {
token : "keyword.operator", // punctuation
regex : /\.|:|,|;\b/
}, {
token : function (v) {
var result = keywordMapper (v);
if (result === "identifier" && v === v.toUpperCase ()) {
result = "entity.name.type";
}
return result;
},
regex : /[a-zA-Z][a-zA-Z\d_]*\b/
}, {
token : "paren.lparen",
regex : /[\[({]/
}, {
token : "paren.rparen",
regex : /[\])}]/
}, {
token : "text",
regex : /\s+/
}
],
"aligned_verbatim_string" : [{
token : "string", // closing multi-line comment
regex : /]"/,
next : "start"
}, {
token : "string", // comment spanning whole line
regex : /[^(?:\]")]+/
}
],
"non-aligned_verbatim_string" : [{
token : "string.quoted.other", // closing multi-line comment
regex : /}"/,
next : "start"
}, {
token : "string.quoted.other", // comment spanning whole line
regex : /[^(?:\}")]+/
}
]};
};
oop.inherits(EiffelHighlightRules, TextHighlightRules);
exports.EiffelHighlightRules = EiffelHighlightRules;
});

View file

@ -145,9 +145,9 @@ module.exports = {
session.setFoldStyle("markbeginend");
assert.equal(session.getFoldWidget(0), "start");
assert.equal(session.getFoldWidget(1), "");
assert.equal(session.getFoldWidget(1), "start");
assert.equal(session.getFoldWidget(2), "");
assert.equal(session.getFoldWidget(3), "");
assert.equal(session.getFoldWidget(3), "start");
assert.equal(session.getFoldWidget(4), "");
assert.equal(session.getFoldWidget(5), "end");

View file

@ -42,7 +42,7 @@ oop.inherits(FoldMode, BaseFoldMode);
(function() {
this.foldingStartMarker = /^\s*\\(begin)|(section|subsection)\b|{\s*$/;
this.foldingStartMarker = /^\s*\\(begin)|(section|subsection|paragraph)\b|{\s*$/;
this.foldingStopMarker = /^\s*\\(end)\b|^\s*}/;
this.getFoldWidgetRange = function(session, foldStyle, row) {
@ -74,7 +74,7 @@ oop.inherits(FoldMode, BaseFoldMode);
var stream = new TokenIterator(session, row, column);
var token = stream.getCurrentToken();
if (!token || token.type !== "keyword")
if (!token || !(token.type == "storage.type" || token.type == "constant.character.escape"))
return;
var val = token.value;
@ -96,7 +96,7 @@ oop.inherits(FoldMode, BaseFoldMode);
stream.step = dir === -1 ? stream.stepBackward : stream.stepForward;
while(token = stream.step()) {
if (token.type !== "keyword")
if (!token || !(token.type == "storage.type" || token.type == "constant.character.escape"))
continue;
var level = keywords[token.value];
if (!level)
@ -119,11 +119,11 @@ oop.inherits(FoldMode, BaseFoldMode);
};
this.latexSection = function(session, row, column) {
var keywords = ["\\subsection", "\\section", "\\begin", "\\end"];
var keywords = ["\\subsection", "\\section", "\\begin", "\\end", "\\paragraph"];
var stream = new TokenIterator(session, row, column);
var token = stream.getCurrentToken();
if (!token || token.type != "keyword")
if (!token || token.type != "storage.type")
return;
var startLevel = keywords.indexOf(token.value);
@ -131,7 +131,7 @@ oop.inherits(FoldMode, BaseFoldMode);
var endRow = row;
while(token = stream.stepForward()) {
if (token.type !== "keyword")
if (token.type !== "storage.type")
continue;
var level = keywords.indexOf(token.value);

View file

@ -39,8 +39,11 @@ var TokenIterator = require("../../token_iterator").TokenIterator;
var FoldMode = exports.FoldMode = function(voidElements, optionalEndTags) {
BaseFoldMode.call(this);
// TODO folding support for optional end tags
this.voidElements = oop.mixin(voidElements || {}, optionalEndTags || {});
this.voidElements = voidElements || {};
this.optionalEndTags = oop.mixin({}, this.voidElements);
if (optionalEndTags)
oop.mixin(this.optionalEndTags, optionalEndTags);
};
oop.inherits(FoldMode, BaseFoldMode);
@ -189,10 +192,10 @@ function is(token, type) {
if (!tag || top.tagName == tag.tagName) {
return stack.pop();
}
else if (this.voidElements.hasOwnProperty(tag.tagName)) {
else if (this.optionalEndTags.hasOwnProperty(tag.tagName)) {
return;
}
else if (this.voidElements.hasOwnProperty(top.tagName)) {
else if (this.optionalEndTags.hasOwnProperty(top.tagName)) {
stack.pop();
continue;
} else {

51
lib/ace/mode/gcode.js Normal file
View file

@ -0,0 +1,51 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
var GcodeHighlightRules = require("./gcode_highlight_rules").GcodeHighlightRules;
var Range = require("../range").Range;
var Mode = function() {
this.HighlightRules = GcodeHighlightRules;
};
oop.inherits(Mode, TextMode);
(function() {
this.$id = "ace/mode/gcode";
}).call(Mode.prototype);
exports.Mode = Mode;
});

View file

@ -0,0 +1,94 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2012, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var GcodeHighlightRules = function() {
var keywords = (
"IF|DO|WHILE|ENDWHILE|CALL|ENDIF|SUB|ENDSUB|GOTO|REPEAT|ENDREPEAT|CALL"
);
var builtinConstants = (
"PI"
);
var builtinFunctions = (
"ATAN|ABS|ACOS|ASIN|SIN|COS|EXP|FIX|FUP|ROUND|LN|TAN"
);
var keywordMapper = this.createKeywordMapper({
"support.function": builtinFunctions,
"keyword": keywords,
"constant.language": builtinConstants
}, "identifier", true);
this.$rules = {
"start" : [ {
token : "comment",
regex : "\\(.*\\)"
}, {
token : "comment", // block number
regex : "([N])([0-9]+)"
}, {
token : "string", // " string
regex : "([G])([0-9]+\\.?[0-9]?)"
}, {
token : "string", // ' string
regex : "([M])([0-9]+\\.?[0-9]?)"
}, {
token : "constant.numeric", // float
regex : "([-+]?([0-9]*\\.?[0-9]+\\.?))|(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)"
}, {
token : keywordMapper,
regex : "[A-Z]"
}, {
token : "keyword.operator",
regex : "EQ|LT|GT|NE|GE|LE|OR|XOR"
}, {
token : "paren.lparen",
regex : "[\\[]"
}, {
token : "paren.rparen",
regex : "[\\]]"
}, {
token : "text",
regex : "\\s+"
} ]
};
};
oop.inherits(GcodeHighlightRules, TextHighlightRules);
exports.GcodeHighlightRules = GcodeHighlightRules;
});

19
lib/ace/mode/gitignore.js Normal file
View file

@ -0,0 +1,19 @@
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
var GitignoreHighlightRules = require("./gitignore_highlight_rules").GitignoreHighlightRules;
var Mode = function() {
this.HighlightRules = GitignoreHighlightRules;
};
oop.inherits(Mode, TextMode);
(function() {
this.$id = "ace/mode/gitignore";
}).call(Mode.prototype);
exports.Mode = Mode;
});

View file

@ -0,0 +1,31 @@
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var GitignoreHighlightRules = function() {
this.$rules = {
"start" : [
{
token : "comment",
regex : /^\s*#.*$/
}, {
token : "keyword", // negated patterns
regex : /^\s*!.*$/
}
]
};
this.normalizeRules();
};
GitignoreHighlightRules.metaData = {
fileTypes: ['gitignore'],
name: 'Gitignore'
};
oop.inherits(GitignoreHighlightRules, TextHighlightRules);
exports.GitignoreHighlightRules = GitignoreHighlightRules;
});

View file

@ -43,7 +43,7 @@ var HtmlCompletions = require("./html_completions").HtmlCompletions;
var WorkerClient = require("../worker/worker_client").WorkerClient;
// http://www.w3.org/TR/html5/syntax.html#void-elements
var voidElements = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
var voidElements = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "menuitem", "param", "source", "track", "wbr"];
var optionalEndTags = ["li", "dt", "dd", "p", "rt", "rp", "optgroup", "option", "colgroup", "td", "th"];
var Mode = function(options) {

58
lib/ace/mode/io.js Normal file
View file

@ -0,0 +1,58 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2012, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
/*
THIS FILE WAS AUTOGENERATED BY mode.tmpl.js
*/
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var IoHighlightRules = require("./io_highlight_rules").IoHighlightRules;
var FoldMode = require("./folding/cstyle").FoldMode;
var Mode = function() {
this.HighlightRules = IoHighlightRules;
this.foldingRules = new FoldMode();
};
oop.inherits(Mode, TextMode);
(function() {
this.lineCommentStart = "//";
this.blockComment = {start: "/*", end: "*/"};
// Extra logic goes here.
this.$id = "ace/mode/io"
}).call(Mode.prototype);
exports.Mode = Mode;
});

View file

@ -0,0 +1,120 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2012, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
/* This file was autogenerated from tm bundles\io.tmbundle/Syntaxes/io.plist (uuid: ) */
/****************************************************************************************
* IT MIGHT NOT BE PERFECT ...But it's a good start from an existing *.tmlanguage file. *
* fileTypes *
****************************************************************************************/
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var IoHighlightRules = function() {
// regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used
this.$rules = { start:
[ { token: [ 'text', 'meta.empty-parenthesis.io' ],
regex: '(\\()(\\))',
comment: 'we match this to overload return inside () --Allan; scoping rules for what gets the scope have changed, so we now group the ) instead of the ( -- Rob' },
{ token: [ 'text', 'meta.comma-parenthesis.io' ],
regex: '(\\,)(\\))',
comment: 'We want to do the same for ,) -- Seckar; same as above -- Rob' },
{ token: 'keyword.control.io',
regex: '\\b(?:if|ifTrue|ifFalse|ifTrueIfFalse|for|loop|reverseForeach|foreach|map|continue|break|while|do|return)\\b' },
{ token: 'punctuation.definition.comment.io',
regex: '/\\*',
push:
[ { token: 'punctuation.definition.comment.io',
regex: '\\*/',
next: 'pop' },
{ defaultToken: 'comment.block.io' } ] },
{ token: 'punctuation.definition.comment.io',
regex: '//',
push:
[ { token: 'comment.line.double-slash.io',
regex: '$',
next: 'pop' },
{ defaultToken: 'comment.line.double-slash.io' } ] },
{ token: 'punctuation.definition.comment.io',
regex: '#',
push:
[ { token: 'comment.line.number-sign.io', regex: '$', next: 'pop' },
{ defaultToken: 'comment.line.number-sign.io' } ] },
{ token: 'variable.language.io',
regex: '\\b(?:self|sender|target|proto|protos|parent)\\b',
comment: 'I wonder if some of this isn\'t variable.other.language? --Allan; scoping this as variable.language to match Objective-C\'s handling of \'self\', which is inconsistent with C++\'s handling of \'this\' but perhaps intentionally so -- Rob' },
{ token: 'keyword.operator.io',
regex: '<=|>=|=|:=|\\*|\\||\\|\\||\\+|-|/|&|&&|>|<|\\?|@|@@|\\b(?:and|or)\\b' },
{ token: 'constant.other.io', regex: '\\bGL[\\w_]+\\b' },
{ token: 'support.class.io', regex: '\\b[A-Z](?:\\w+)?\\b' },
{ token: 'support.function.io',
regex: '\\b(?:clone|call|init|method|list|vector|block|\\w+(?=\\s*\\())\\b' },
{ token: 'support.function.open-gl.io',
regex: '\\bgl(?:u|ut)?[A-Z]\\w+\\b' },
{ token: 'punctuation.definition.string.begin.io',
regex: '"""',
push:
[ { token: 'punctuation.definition.string.end.io',
regex: '"""',
next: 'pop' },
{ token: 'constant.character.escape.io', regex: '\\\\.' },
{ defaultToken: 'string.quoted.triple.io' } ] },
{ token: 'punctuation.definition.string.begin.io',
regex: '"',
push:
[ { token: 'punctuation.definition.string.end.io',
regex: '"',
next: 'pop' },
{ token: 'constant.character.escape.io', regex: '\\\\.' },
{ defaultToken: 'string.quoted.double.io' } ] },
{ token: 'constant.numeric.io',
regex: '\\b(?:0(?:x|X)[0-9a-fA-F]*|(?:[0-9]+\\.?[0-9]*|\\.[0-9]+)(?:(?:e|E)(?:\\+|-)?[0-9]+)?)(?:L|l|UL|ul|u|U|F|f)?\\b' },
{ token: 'variable.other.global.io', regex: 'Lobby\\b' },
{ token: 'constant.language.io',
regex: '\\b(?:TRUE|true|FALSE|false|NULL|null|Null|Nil|nil|YES|NO)\\b' } ] }
this.normalizeRules();
};
IoHighlightRules.metaData = { fileTypes: [ 'io' ],
keyEquivalent: '^~I',
name: 'Io',
scopeName: 'source.io' }
oop.inherits(IoHighlightRules, TextHighlightRules);
exports.IoHighlightRules = IoHighlightRules;
});

View file

@ -1979,7 +1979,7 @@ var JSHINT = (function () {
function doOption() {
var nt = state.tokens.next;
var body = nt.body.match(/(-\s+)?[^\s,:]+(?:\s*:\s*(-\s+)?[^\s,]+)?/g);
var body = nt.body.match(/(-\s+)?[^\s,:]+(?:\s*:\s*(-\s+)?[^\s,]+)?/g) || [];
var predef = {};
if (nt.type === "globals") {

View file

@ -35,7 +35,7 @@ var oop = require("../lib/oop");
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var JavaScriptHighlightRules = function() {
var JavaScriptHighlightRules = function(options) {
// see: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects
var keywordMapper = this.createKeywordMapper({
"variable.language":
@ -187,11 +187,11 @@ var JavaScriptHighlightRules = function() {
regex : identifierRe
}, {
token : "keyword.operator",
regex : /--|\+\+|[!$%&*+\-~]|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=/,
regex : /--|\+\+|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|[!$%&*+\-~\/^]=?/,
next : "start"
}, {
token : "punctuation.operator",
regex : /\?|\:|\,|\;|\./,
regex : /[?:,;.]/,
next : "start"
}, {
token : "paren.lparen",
@ -200,10 +200,6 @@ var JavaScriptHighlightRules = function() {
}, {
token : "paren.rparen",
regex : /[\])}]/
}, {
token : "keyword.operator",
regex : /\/=?/,
next : "start"
}, {
token: "comment",
regex: /^#!.*$/
@ -272,7 +268,7 @@ var JavaScriptHighlightRules = function() {
],
"regex_character_class": [
{
token: "regexp.keyword.operator",
token: "regexp.charclass.keyword.operator",
regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
}, {
token: "constant.language.escape",
@ -354,9 +350,49 @@ var JavaScriptHighlightRules = function() {
}
]
};
if (!options || !options.noES6) {
this.$rules.no_regex.unshift({
regex: "[{}]", onMatch: function(val, state, stack) {
this.next = val == "{" ? this.nextState : "";
if (val == "{" && stack.length) {
stack.unshift("start", state);
return "paren";
}
if (val == "}" && stack.length) {
stack.shift();
this.next = stack.shift();
if (this.next.indexOf("string") != -1)
return "paren.quasi.end";
}
return val == "{" ? "paren.lparen" : "paren.rparen";
},
nextState: "start"
}, {
token : "string.quasi.start",
regex : /`/,
push : [{
token : "constant.language.escape",
regex : escapedRe
}, {
token : "paren.quasi.start",
regex : /\${/,
push : "start"
}, {
token : "string.quasi.end",
regex : /`/,
next : "pop"
}, {
defaultToken: "string.quasi"
}]
});
}
this.embedRules(DocCommentHighlightRules, "doc-",
[ DocCommentHighlightRules.getEndRule("no_regex") ]);
this.normalizeRules();
};
oop.inherits(JavaScriptHighlightRules, TextHighlightRules);

View file

@ -14,6 +14,8 @@ var Mode = function() {
oop.inherits(Mode, TextMode);
(function() {
this.type = "text";
this.lineCommentStart = "%";
this.$id = "ace/mode/latex";

View file

@ -4,12 +4,30 @@ define(function(require, exports, module) {
var oop = require("../lib/oop");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var LatexHighlightRules = function() {
var LatexHighlightRules = function() {
this.$rules = {
"start" : [{
// A comment. Tex comments start with % and go to
// the end of the line
token : "comment",
regex : "%.*$"
}, {
// Documentclass and usepackage
token : ["keyword", "lparen", "variable.parameter", "rparen", "lparen", "storage.type", "rparen"],
regex : "(\\\\(?:documentclass|usepackage|input))(?:(\\[)([^\\]]*)(\\]))?({)([^}]*)(})"
}, {
// A label
token : ["keyword","lparen", "variable.parameter", "rparen"],
regex : "(\\\\label)(?:({)([^}]*)(}))?"
}, {
// A block
token : ["storage.type", "lparen", "variable.parameter", "rparen"],
regex : "(\\\\(?:begin|end))({)(\\w*)(})"
}, {
// A tex command e.g. \foo
token : "keyword",
regex : "\\\\(?:[^a-zA-Z]|[a-zA-Z]+)"
token : "storage.type",
regex : "\\\\[a-zA-Z]+"
}, {
// Curly and square braces
token : "lparen",
@ -19,18 +37,35 @@ var LatexHighlightRules = function() {
token : "rparen",
regex : "[\\])}]"
}, {
// Inline math between two $ symbols
token : "string",
regex : "\\$(?:(?:\\\\.)|(?:[^\\$\\\\]))*?\\$"
// Escaped character (including new line)
token : "constant.character.escape",
regex : "\\\\[^a-zA-Z]?"
}, {
// A comment. Tex comments start with % and go to
// the end of the line
// An equation
token : "string",
regex : "\\${1,2}",
next : "equation"
}],
"equation" : [{
token : "comment",
regex : "%.*$"
}, {
token : "string",
regex : "\\${1,2}",
next : "start"
}, {
token : "constant.character.escape",
regex : "\\\\(?:[^a-zA-Z]|[a-zA-Z]+)"
}, {
token : "error",
regex : "^\\s*$",
next : "start"
}, {
defaultToken : "string"
}]
};
};
oop.inherits(LatexHighlightRules, TextHighlightRules);
exports.LatexHighlightRules = LatexHighlightRules;

File diff suppressed because one or more lines are too long

View file

@ -164,15 +164,53 @@ var keywords = (
}, "identifier", true);
this.$rules = {
"start" : [ {
// allowQstring
start: [{
token : "string",
regex : "'",
stateName : "qstring",
next : [{
token : "constant.language.escape",
regex : "''"
}, {
token : "string",
regex : "'|$",
next : "start"
}, {
defaultToken: "string"
}]
}, {
token : "text",
regex : "\\s+"
}, {
regex: "",
next: "noQstring"
}],
noQstring : [{
regex: "^\\s*%{\\s*$",
token: "comment.start",
push: "blockComment"
}, {
token : "comment",
regex : "%[^\r\n]*"
}, {
token : "string", // " string
regex : '".*?"'
}, {
token : "string", // ' string
regex : "'.*?'"
token : "string",
regex : '"',
stateName : "qqstring",
next : [{
token : "constant.language.escape",
regex : /\\./
}, {
token : "string",
regex : "\\\\$",
next : "qqstring"
}, {
token : "string",
regex : '"|$',
next : "start"
}, {
defaultToken: "string"
}]
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
@ -181,21 +219,41 @@ var keywords = (
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token : "keyword.operator",
regex : "\\+|\\-|\\/|\\/\\/|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|="
regex : "\\+|\\-|\\/|\\/\\/|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|=",
next: "start"
}, {
token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\;|\\."
token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\;|\\.",
next: "start"
}, {
token : "paren.lparen",
regex : "[\\(]"
regex : "[({\\[]",
next: "start"
}, {
token : "paren.rparen",
regex : "[\\)]"
regex : "[\\]})]"
}, {
token : "text",
regex : "\\s+"
} ]
}, {
token : "text",
regex : "$",
next : "start"
}],
blockComment: [{
regex: "^\\s*%{\\s*$",
token: "comment.start",
push: "blockComment"
}, {
regex: "^\\s*%}\\s*$",
token: "comment.end",
next: "pop"
}, {
defaultToken: "comment"
}],
};
this.normalizeRules();
};
oop.inherits(MatlabHighlightRules, TextHighlightRules);

View file

@ -1005,7 +1005,7 @@ var PhpLangHighlightRules = function() {
return "string";
stack.shift();
stack.shift();
return "markup.list"
return "markup.list";
},
regex : "^\\w+(?=;?$)",
next: "start"
@ -1016,12 +1016,11 @@ var PhpLangHighlightRules = function() {
],
"comment" : [
{
token : "comment", // closing comment
regex : ".*?\\*\\/",
token : "comment",
regex : "\\*\\/",
next : "start"
}, {
token : "comment", // comment spanning whole line
regex : ".+"
defaultToken : "comment"
}
],
"qqstring" : [
@ -1029,10 +1028,10 @@ var PhpLangHighlightRules = function() {
token : "constant.language.escape",
regex : '\\\\(?:[nrtvef\\\\"$]|[0-7]{1,3}|x[0-9A-Fa-f]{1,2})'
}, {
token : "constant.language.escape",
regex : /\$[\w]+(?:\[[\w\]+]|=>\w+)?/
token : "variable",
regex : /\$[\w]+(?:\[[\w\]+]|[=\-]>\w+)?/
}, {
token : "constant.language.escape",
token : "variable",
regex : /\$\{[^"\}]+\}?/ // this is wrong but ok for now
},
{token : "string", regex : '"', next : "start"},

84
lib/ace/mode/praat.js Normal file
View file

@ -0,0 +1,84 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
var PraatHighlightRules = require("./praat_highlight_rules").PraatHighlightRules;
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
var Range = require("../range").Range;
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
var Mode = function() {
this.HighlightRules = PraatHighlightRules;
this.$outdent = new MatchingBraceOutdent();
};
oop.inherits(Mode, TextMode);
(function() {
this.lineCommentStart = "#";
this.getNextLineIndent = function(state, line, tab) {
var indent = this.$getIndent(line);
var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
var tokens = tokenizedLine.tokens;
if (tokens.length && tokens[tokens.length-1].type == "comment") {
return indent;
}
if (state == "start") {
var match = line.match(/^.*[\{\(\[\:]\s*$/);
if (match) {
indent += tab;
}
}
return indent;
};
this.checkOutdent = function(state, line, input) {
return this.$outdent.checkOutdent(line, input);
};
this.autoOutdent = function(state, doc, row) {
this.$outdent.autoOutdent(doc, row);
};
this.$id = "ace/mode/praat";
}).call(Mode.prototype);
exports.Mode = Mode;
});

View file

@ -0,0 +1,262 @@
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var PraatHighlightRules = function() {
var keywords = (
"if|then|else|elsif|elif|endif|fi|" +
"endfor|endproc|" + // related keywords specified below
"while|endwhile|" +
"repeat|until|" +
"select|plus|minus|" +
"assert"
);
var predefinedVariables = (
"macintosh|windows|unix|" +
"praatVersion|praatVersion\\$" +
"pi|undefined|" +
"newline\\$|tab\\$|" +
"shellDirectory\\$|homeDirectory\\$|preferencesDirectory\\$|" +
"temporaryDirectory\\$|defaultDirectory\\$"
);
// What is "endSendPraat"? Function? Directive?
var directives = (
"clearinfo|endSendPraat"
);
var functions = (
// Info functions
"writeInfo|writeInfoLine|appendInfo|appendInfoLine|" +
"writeFile|writeFileLine|appendFile|appendFileLine|" +
// Math functions
"abs|round|floor|ceiling|min|max|imin|imax|" +
"sqrt|sin|cos|tan|arcsin|arccos|arctan|arctan2|sinc|sincpi|" +
"exp|ln|log10|log2|" +
"sinh|cosh|tanh|arcsinh|arccosh|actanh|" +
"sigmoid|invSigmoid|erf|erfc|" +
"randomUniform|randomInteger|randomGauss|randomPoisson|" +
"lnGamma|gaussP|gaussQ|invGaussQ|" +
"chiSquareP|chiSquareQ|invChiSquareQ|studentP|studentQ|invStudentQ|" +
"fisherP|fisherQ|invFisherQ|" +
"binomialP|binomialQ|invBinomialP|invBinomialQ|" +
"hertzToBark|barkToHerz|" +
"hertzToMel|melToHertz|" +
"hertzToSemitones|semitonesToHerz|" +
"erb|hertzToErb|erbToHertz|" +
"phonToDifferenceLimens|differenceLimensToPhon|" +
"beta|besselI|besselK|" +
// String functions
"selected|selected\\$|numberOfSelected|variableExists|"+
"index|rindex|startsWith|endsWith|"+
"index_regex|rindex_regex|replace_regex\\$|"+
"length|extractWord\\$|extractLine\\$|extractNumber|" +
"left\\$|right\\$|mid\\$|replace\\$|" +
// Pause functions
"beginPause|endPause|" +
// Demo functions
"demoShow|demoWindowTitle|demoInput|demoWaitForInput|" +
"demoClicked|demoClickedIn|demoX|demoY|" +
"demoKeyPressed|demoKey\\$|" +
"demoExtraControlKeyPressed|demoShiftKeyPressed|"+
"demoCommandKeyPressed|demoOptionKeyPressed|" +
// File functions
"environment\\$|chooseReadFile\\$|" +
"chooseDirectory\\$|createDirectory|fileReadable|deleteFile|" +
"selectObject|removeObject|plusObject|minusObject|" +
"runScript|exitScript|" +
// sendpraat functions
"beginSendPraat|endSendPraat"
);
var objectTypes = (
"Activation|AffineTransform|AmplitudeTier|Art|Artword|Autosegment|" +
"BarkFilter|CCA|Categories|Cepstrum|Cepstrumc|ChebyshevSeries|" +
"ClassificationTable|Cochleagram|Collection|Configuration|" +
"Confusion|ContingencyTable|Corpus|Correlation|Covariance|" +
"CrossCorrelationTable|CrossCorrelationTables|DTW|Diagonalizer|" +
"Discriminant|Dissimilarity|Distance|Distributions|DurationTier|" +
"EEG|ERP|ERPTier|Eigen|Excitation|Excitations|ExperimentMFC|FFNet|" +
"FeatureWeights|Formant|FormantFilter|FormantGrid|FormantPoint|" +
"FormantTier|GaussianMixture|HMM|HMM_Observation|" +
"HMM_ObservationSequence|HMM_State|HMM_StateSequence|Harmonicity|" +
"ISpline|Index|Intensity|IntensityTier|IntervalTier|KNN|KlattGrid|" +
"KlattTable|LFCC|LPC|Label|LegendreSeries|LinearRegression|" +
"LogisticRegression|LongSound|Ltas|MFCC|MSpline|ManPages|" +
"Manipulation|Matrix|MelFilter|MixingMatrix|Movie|Network|" +
"OTGrammar|OTHistory|OTMulti|PCA|PairDistribution|ParamCurve|" +
"Pattern|Permutation|Pitch|PitchTier|PointProcess|Polygon|" +
"Polynomial|Procrustes|RealPoint|RealTier|ResultsMFC|Roots|SPINET|" +
"SSCP|SVD|Salience|ScalarProduct|Similarity|SimpleString|" +
"SortedSetOfString|Sound|Speaker|Spectrogram|Spectrum|SpectrumTier|" +
"SpeechSynthesizer|SpellingChecker|Strings|StringsIndex|Table|" +
"TableOfReal|TextGrid|TextInterval|TextPoint|TextTier|Tier|" +
"Transition|VocalTract|Weight|WordList"
);
// regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used
this.$rules = {
"start" : [
{
// Interpolated strings
token : "string.interpolated",
regex : /'((?:[a-z][a-zA-Z0-9_]*)(?:\$|#|:[0-9]+)?)'/
}, {
// stopwatch
token : ["text", "text", "keyword.operator", "text", "keyword"],
regex : /(^\s*)(?:([a-z][a-zA-Z0-9_]*\$?\s+)(=)(\s+))?(stopwatch)/
}, {
// Directives which introduce unquoted strings
token : ["text", "keyword", "text", "string"],
regex : /(^\s*)(print(?:line)?|echo|exit|pause|sendpraat|include|execute)(\s+)(.*)/
}, {
// Directives with no arguments
token : ["text", "keyword"],
regex : "(^\\s*)(" + directives + ")$"
}, {
// Operators
token : ["text", "keyword.operator", "text"],
regex : /(\s+)((?:\+|-|\/|\*|<|>)=?|==?|!=|%|\^|\||and|or|not)(\s+)/
}, {
// Commands
token : ["text", "text", "keyword.operator", "text", "keyword", "text", "keyword"],
regex : /(^\s*)(?:([a-z][a-zA-Z0-9_]*\$?\s+)(=)(\s+))?(?:((?:no)?warn|nocheck|noprogress)(\s+))?((?:[A-Z][^.:"]+)(?:$|(?:\.{3}|:)))/
}, {
// Demo commands
token : ["text", "keyword", "text", "keyword"],
regex : /(^\s*)(?:(demo)?(\s+))((?:[A-Z][^.:"]+)(?:$|(?:\.{3}|:)))/
}, {
// Font-sizing commands
token : ["text", "keyword", "text", "keyword"],
regex : /^(\s*)(?:(demo)(\s+))?(10|12|14|16|24)$/
}, {
// do-style command calls
token : ["text", "support.function", "text"],
regex : /(\s*)(do\$?)(\s*:\s*|\s*\(\s*)/
}, {
// Object types
token : "entity.name.type",
regex : "(" + objectTypes + ")"
}, {
// Predefined variables
token : "variable.language",
regex : "(" + predefinedVariables + ")"
}, {
// Functions
token : ["support.function", "text"],
regex : "((?:" + functions + ")\\$?)(\\s*(?::|\\())"
}, {
// For-loop declarations
token : "keyword",
regex : /(\bfor\b)/,
next : "for"
}, {
// Generic keywords
token : "keyword",
regex : "(\\b(?:" + keywords + ")\\b)"
}, {
// Generic strings
token : "string",
regex : /"[^"]*"/
}, {
// Multiline quoted strings
token : "string",
regex : /"[^"]*$/,
next : "brokenstring"
}, {
// Form declarations
token : ["text", "keyword", "text", "entity.name.section"],
regex : /(^\s*)(\bform\b)(\s+)(.*)/,
next : "form"
}, {
// Numeric constants
token : "constant.numeric",
regex : /\b[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
}, {
// Procedure declarations
token : ["keyword", "text", "entity.name.function"],
regex : /(procedure)(\s+)(\S+)/
}, {
// New-style procedure calls
token : ["entity.name.function", "text"],
regex : /(@\S+)(:|\s*\()/
}, {
// Old-style procedure calls
token : ["text", "keyword", "text", "entity.name.function"],
regex : /(^\s*)(call)(\s+)(\S+)/
}, {
// Comments
token : "comment",
regex : /(^\s*#|;).*$/
}, {
token : "text",
regex : /\s+/
}
],
"form" : [
{
token : ["keyword", "text", "constant.numeric"],
regex : /((?:optionmenu|choice)\s+)(\S+:\s+)([0-9]+)/
}, {
token : ["keyword", "constant.numeric"],
regex : /((?:option|button)\s+)([+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b)/
}, {
token : ["keyword", "string"],
regex : /((?:option|button)\s+)(.*)/
}, {
token : ["keyword", "text", "string"],
regex : /((?:sentence|text)\s+)(\S+\s*)(.*)/
}, {
token : ["keyword", "text", "string", "invalid.illegal"],
regex : /(word\s+)(\S+\s*)(\S+)?(\s.*)?/
}, {
token : ["keyword", "text", "constant.language"],
regex : /(boolean\s+)(\S+\s*)(0|1|"?(?:yes|no)"?)/
}, {
token : ["keyword", "text", "constant.numeric"],
regex : /((?:real|natural|positive|integer)\s+)(\S+\s*)([+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b)/
}, {
token : ["keyword", "string"],
regex : /(comment\s+)(.*)/
}, {
token : "keyword",
regex : 'endform',
next : "start"
}
],
"for" : [
{
token : ["keyword", "text", "constant.numeric", "text"],
regex : /(from|to)(\s+)([+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?)(\s*)/
}, {
token : ["keyword", "text"],
regex : /(from|to)(\s+\S+\s*)/
}, {
token : "text",
regex : /$/,
next : "start"
}
],
"brokenstring" : [
{
token : ["text", "string"],
regex : /(\s*\.{3})([^"]*)/
}, {
token : "string",
regex : /"/,
next : "start"
}
],
};
};
oop.inherits(PraatHighlightRules, TextHighlightRules);
exports.PraatHighlightRules = PraatHighlightRules;
});

View file

@ -36,11 +36,13 @@ var TextMode = require("./text").Mode;
var RubyHighlightRules = require("./ruby_highlight_rules").RubyHighlightRules;
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
var Range = require("../range").Range;
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
var FoldMode = require("./folding/coffee").FoldMode;
var Mode = function() {
this.HighlightRules = RubyHighlightRules;
this.$outdent = new MatchingBraceOutdent();
this.$behaviour = new CstyleBehaviour();
this.foldingRules = new FoldMode();
};
oop.inherits(Mode, TextMode);

View file

@ -53,10 +53,10 @@ var Mode = function() {
oop.inherits(Mode, TextMode);
(function() {
this.lineCommentStart = "/\\*";
this.lineCommentStart = "//";
this.blockComment = {start: "/*", end: "*/"};
this.$id = "ace/mode/rust";
}).call(Mode.prototype);
exports.Mode = Mode;
});
});

View file

@ -99,6 +99,65 @@ var ShHighlightRules = function() {
}, {
defaultToken: "string"
}]
}, {
regex : "<<<",
token : "keyword.operator"
}, {
stateName: "heredoc",
regex : "(<<)(\\s*)(['\"`]?)([\\w\\-]+)(['\"`]?)",
onMatch : function(value, currentState, stack) {
var next = value[2] == '-' ? "indentedHeredoc" : "heredoc";
var tokens = value.split(this.splitRegex);
stack.push(next, tokens[4]);
return [
{type:"constant", value: tokens[1]},
{type:"text", value: tokens[2]},
{type:"string", value: tokens[3]},
{type:"support.class", value: tokens[4]},
{type:"string", value: tokens[5]}
];
},
rules: {
heredoc: [{
onMatch: function(value, currentState, stack) {
if (value === stack[1]) {
stack.shift();
stack.shift();
this.next = stack[0] || "start";
return "support.class";
}
this.next = "";
return "string";
},
regex: ".*$",
next: "start"
}],
indentedHeredoc: [{
token: "string",
regex: "^\t+"
}, {
onMatch: function(value, currentState, stack) {
if (value === stack[1]) {
stack.shift();
stack.shift();
this.next = stack[0] || "start";
return "support.class";
}
this.next = "";
return "string";
},
regex: ".*$",
next: "start"
}]
}
}, {
regex : "$",
token : "empty",
next : function(currentState, stack) {
if (stack[0] === "heredoc" || stack[0] === "indentedHeredoc")
return stack[0];
return currentState;
}
}, {
token : "variable.language",
regex : builtinVariable
@ -122,7 +181,7 @@ var ShHighlightRules = function() {
regex : integer + "\\b"
}, {
token : keywordMapper,
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
regex : "[a-zA-Z_][a-zA-Z0-9_]*\\b"
}, {
token : "keyword.operator",
regex : "\\+|\\-|\\*|\\*\\*|\\/|\\/\\/|~|<|>|<=|=>|=|!="

View file

@ -36,7 +36,7 @@ var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScrip
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var SJSHighlightRules = function() {
var parent = new JavaScriptHighlightRules();
var parent = new JavaScriptHighlightRules({noES6: true});
var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
"u[0-9a-fA-F]{4}|" + // unicode
"[0-2][0-7]{0,2}|" + // oct
@ -177,10 +177,10 @@ var SJSHighlightRules = function() {
// for use within interpreted contexts
// without interfering with context nesting
var embeddableRules = [];
for (var i=0; i<this.$rules.no_regex.length; i++) {
for (var i=0; i < this.$rules.no_regex.length; i++) {
var rule = this.$rules.no_regex[i];
var token = String(rule.token);
if(token.indexOf('paren') == -1 && (!rule.next || rule.next.isContextAware)) {
if (token.indexOf('paren') == -1 && (!rule.next || rule.next.isContextAware)) {
embeddableRules.push(rule);
}
};

View file

@ -104,6 +104,7 @@ oop.inherits(Mode, TextMode);
(function() {
this.$indentWithTabs = true;
this.lineCommentStart = "#";
this.$id = "ace/mode/snippets";
}).call(Mode.prototype);
exports.Mode = Mode;

View file

@ -38,7 +38,7 @@ var SqlHighlightRules = function() {
var keywords = (
"select|insert|update|delete|from|where|and|or|group|by|order|limit|offset|having|as|case|" +
"when|else|end|type|left|right|join|on|outer|desc|asc"
"when|else|end|type|left|right|join|on|outer|desc|asc|union"
);
var builtinConstants = (

View file

@ -60,7 +60,7 @@ var TextHighlightRules = function() {
var state = rules[key];
for (var i = 0; i < state.length; i++) {
var rule = state[i];
if (rule.next) {
if (rule.next || rule.onMatch) {
if (typeof rule.next != "string") {
if (rule.nextState && rule.nextState.indexOf(prefix) !== 0)
rule.nextState = prefix + rule.nextState;
@ -68,7 +68,6 @@ var TextHighlightRules = function() {
if (rule.next.indexOf(prefix) !== 0)
rule.next = prefix + rule.next;
}
}
}
this.$rules[prefix + key] = state;

View file

@ -136,7 +136,7 @@ var ValaHighlightRules = function() {
[ { token: 'meta.class.vala',
regex: '(?=\\w?[\\w\\s]*(?:class|(?:@)?interface|enum|struct|namespace)\\s+\\w+)',
push:
[ { token: 'punctuation.section.class.end.vala',
[ { token: 'paren.vala',
regex: '}',
next: 'pop' },
{ include: '#storage-modifiers' },
@ -166,10 +166,10 @@ var ValaHighlightRules = function() {
{ include: '#object-types-inherited' },
{ include: '#comments' },
{ defaultToken: 'meta.definition.class.implemented.interfaces.vala' } ] },
{ token: 'meta.class.body.vala',
{ token: 'paren.vala',
regex: '{',
push:
[ { token: 'meta.class.body.vala', regex: '(?=})', next: 'pop' },
[ { token: 'paren.vala', regex: '(?=})', next: 'pop' },
{ include: '#class-body' },
{ defaultToken: 'meta.class.body.vala' } ] },
{ defaultToken: 'meta.class.vala' } ],
@ -266,7 +266,7 @@ var ValaHighlightRules = function() {
[ { token: 'meta.method.vala',
regex: '(?!new)(?=\\w.*\\s+)(?=[^=]+\\()',
push:
[ { token: 'meta.method.vala', regex: '}|(?=;)', next: 'pop' },
[ { token: 'paren.vala', regex: '}|(?=;)', next: 'pop' },
{ include: '#storage-modifiers' },
{ token: [ 'entity.name.function.vala', 'meta.method.identifier.vala' ],
regex: '([\\~\\w\\.]+)(\\s*\\()',
@ -285,10 +285,10 @@ var ValaHighlightRules = function() {
{ include: '#all-types' },
{ defaultToken: 'meta.method.return-type.vala' } ] },
{ include: '#throws' },
{ token: 'meta.method.body.vala',
{ token: 'paren.vala',
regex: '{',
push:
[ { token: 'meta.method.body.vala', regex: '(?=})', next: 'pop' },
[ { token: 'paren.vala', regex: '(?=})', next: 'pop' },
{ include: '#code' },
{ defaultToken: 'meta.method.body.vala' } ] },
{ defaultToken: 'meta.method.vala' } ] } ],

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -71,21 +71,20 @@ function DefaultHandlers(mouseHandler) {
var selectionRange = editor.getSelectionRange();
var selectionEmpty = selectionRange.isEmpty();
if (selectionEmpty) {
if (selectionEmpty)
editor.selection.moveToPosition(pos);
}
// 2: contextmenu, 1: linux paste
editor.textInput.onContextMenu(ev.domEvent);
return; // stopping event here breaks contextmenu on ff mac
}
this.mousedownEvent.time = Date.now();
// if this click caused the editor to be focused should not clear the
// selection
if (inSelection && !editor.isFocused()) {
editor.focus();
if (this.$focusTimout && !this.$clickSelection && !editor.inMultiSelectMode) {
this.mousedownEvent.time = Date.now();
this.setState("focusWait");
this.captureMouse(ev);
return;
@ -93,31 +92,21 @@ 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.
this.startSelect(pos);
} else if (inSelection) {
this.mousedownEvent.time = Date.now();
this.startSelect(pos);
}
this.startSelect(pos, ev.domEvent._clicks > 1);
return ev.preventDefault();
};
this.startSelect = function(pos) {
this.startSelect = function(pos, waitForClickSelection) {
pos = pos || this.editor.renderer.screenToTextCoordinates(this.x, this.y);
var editor = this.editor;
// allow double/triple click handlers to change selection
var shiftPressed = this.mousedownEvent.getShiftKey();
setTimeout(function(){
if (shiftPressed) {
editor.selection.selectToPosition(pos);
}
else if (!this.$clickSelection) {
editor.selection.moveToPosition(pos);
}
if (this.mousedownEvent.getShiftKey())
editor.selection.selectToPosition(pos);
else if (!waitForClickSelection)
editor.selection.moveToPosition(pos);
if (!waitForClickSelection)
this.select();
}.bind(this), 0);
if (editor.renderer.scroller.setCapture) {
editor.renderer.scroller.setCapture();
}
@ -216,6 +205,7 @@ function DefaultHandlers(mouseHandler) {
this.setState("selectByWords");
}
this.$clickSelection = range;
this.select();
};
this.onTripleClick = function(ev) {
@ -230,6 +220,7 @@ function DefaultHandlers(mouseHandler) {
} else {
this.$clickSelection = editor.selection.getLineRange(pos.row);
}
this.select();
};
this.onQuadClick = function(ev) {

View file

@ -84,7 +84,7 @@ function DragdropHandler(mouseHandler) {
if (useragent.isOpera) {
editor.container.appendChild(blankImage);
// force layout
blankImage._top = blankImage.offsetTop;
blankImage.scrollTop = 0;
}
dataTransfer.setDragImage && dataTransfer.setDragImage(blankImage, 0, 0);
if (useragent.isOpera) {
@ -110,11 +110,14 @@ function DragdropHandler(mouseHandler) {
editor.renderer.$cursorLayer.setBlinking(true);
}
this.editor.unsetStyle("ace_dragging");
this.editor.renderer.setCursorStyle("");
};
this.onDragEnter = function(e) {
if (editor.getReadOnly() || !canAccept(e.dataTransfer))
return;
x = e.clientX;
y = e.clientY;
if (!dragSelectionMarker)
addDragMarker();
counter++;
@ -126,6 +129,8 @@ function DragdropHandler(mouseHandler) {
this.onDragOver = function(e) {
if (editor.getReadOnly() || !canAccept(e.dataTransfer))
return;
x = e.clientX;
y = e.clientY;
// Opera doesn't trigger dragenter event on drag start
if (!dragSelectionMarker) {
addDragMarker();
@ -133,8 +138,6 @@ function DragdropHandler(mouseHandler) {
}
if (onMouseMoveTimer !== null)
onMouseMoveTimer = null;
x = e.clientX;
y = e.clientY;
e.dataTransfer.dropEffect = dragOperation = getDropEffect(e);
return event.preventDefault(e);
@ -150,7 +153,7 @@ function DragdropHandler(mouseHandler) {
};
this.onDrop = function(e) {
if (!dragSelectionMarker)
if (!dragCursor)
return;
var dataTransfer = e.dataTransfer;
if (isInternal) {
@ -264,6 +267,7 @@ function DragdropHandler(mouseHandler) {
if (editor.isFocused())
editor.renderer.$cursorLayer.setBlinking(false);
clearInterval(timerId);
onDragInterval();
timerId = setInterval(onDragInterval, 20);
counter = 0;
event.addListener(document, "mousemove", onMouseMove);
@ -279,6 +283,7 @@ function DragdropHandler(mouseHandler) {
if (editor.isFocused() && !isInternal)
editor.renderer.$cursorLayer.setBlinking(!editor.getReadOnly());
range = null;
dragCursor = null;
counter = 0;
autoScrollStartTime = null;
cursorMovedTime = null;
@ -345,15 +350,19 @@ function DragdropHandler(mouseHandler) {
this.dragReadyEnd = function(e) {
this.editor.renderer.$cursorLayer.setBlinking(!this.editor.getReadOnly());
this.editor.unsetStyle("ace_dragging");
this.editor.renderer.setCursorStyle("");
this.dragWaitEnd();
};
this.startDrag = function(){
this.cancelDrag = false;
var target = this.editor.container;
var editor = this.editor;
var target = editor.container;
target.draggable = true;
this.editor.renderer.$cursorLayer.setBlinking(false);
this.editor.setStyle("ace_dragging");
editor.renderer.$cursorLayer.setBlinking(false);
editor.setStyle("ace_dragging");
var cursorStyle = useragent.isWin ? "default" : "move";
editor.renderer.setCursorStyle(cursorStyle);
this.setState("dragReady");
};

View file

@ -49,7 +49,7 @@ var MouseHandler = function(editor) {
var focusEditor = function(e) {
if (!editor.isFocused() && editor.textInput)
editor.textInput.onContextMenu(e);
editor.textInput.moveToMouse(e);
editor.focus()
};

View file

@ -58,17 +58,15 @@ module.exports = {
next();
},
"test: double tap. issue #956" : function(done) {
"test: double tap. issue #956" : function() {
// 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}));
setTimeout(function() {
assert.equal(this.editor.getSelectedText(), "Juhu");
done();
}.bind(this));
assert.equal(this.editor.getSelectedText(), "Juhu");
}
};

View file

@ -720,7 +720,7 @@ var Editor = require("./editor").Editor;
* @param {Boolean} skip If `true`, removes the active selection range
* @method Editor.selectMore
**/
this.selectMore = function(dir, skip) {
this.selectMore = function(dir, skip, stopAtFirst) {
var session = this.session;
var sel = session.multiSelect;
@ -729,8 +729,8 @@ var Editor = require("./editor").Editor;
range = session.getWordRange(range.start.row, range.start.column);
range.cursor = dir == -1 ? range.start : range.end;
this.multiSelect.addRange(range);
// todo add option for sublime like behavior
// return;
if (stopAtFirst)
return;
}
var needle = session.getTextRange(range);
@ -890,12 +890,12 @@ function isSamePoint(p1, p2) {
// adds multicursor support to a session
exports.onSessionChange = function(e) {
var session = e.session;
if (!session.multiSelect) {
if (session && !session.multiSelect) {
session.$selectionMarkers = [];
session.selection.$initRangeList();
session.multiSelect = session.selection;
}
this.multiSelect = session.multiSelect;
this.multiSelect = session && session.multiSelect;
var oldSession = e.oldSession;
if (oldSession) {
@ -907,16 +907,16 @@ exports.onSessionChange = function(e) {
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 (session) {
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);
}
if (this.inMultiSelectMode != session.selection.inMultiSelectMode) {
if (session && this.inMultiSelectMode != session.selection.inMultiSelectMode) {
if (session.selection.inMultiSelectMode)
this.$onMultiSelect();
else

View file

@ -37,7 +37,6 @@ var oop = require("./lib/oop");
/**
* @class PlaceHolder
*
*
**/
/**
@ -47,7 +46,6 @@ var oop = require("./lib/oop");
* - others (String):
* - mainClass (String):
* - othersClass (String):
*
*
* @constructor
**/
@ -93,6 +91,10 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
var doc = this.doc;
var session = this.session;
var pos = this.$pos;
this.selectionBefore = session.selection.toJSON();
if (session.selection.inMultiSelectMode)
session.selection.toSingleRange();
this.pos = doc.createAnchor(pos.row, pos.column);
this.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column + this.length), this.mainClass, null, false);
@ -218,9 +220,9 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
**/
this.onCursorChange = function(event) {
if (this.$updating) return;
if (this.$updating || !this.session) return;
var pos = this.session.selection.getCursor();
if(pos.row === this.pos.row && pos.column >= this.pos.column && pos.column <= this.pos.column + this.length) {
if (pos.row === this.pos.row && pos.column >= this.pos.column && pos.column <= this.pos.column + this.length) {
this.showOtherMarkers();
this._emit("cursorEnter", event);
} else {
@ -245,6 +247,7 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
this.others[i].detach();
}
this.session.setUndoSelect(true);
this.session = null;
};
/**
@ -261,6 +264,8 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
for (var i = 0; i < undosRequired; i++) {
undoManager.undo(true);
}
if (this.selectionBefore)
this.session.selection.fromJSON(this.selectionBefore);
};
}).call(PlaceHolder.prototype);

View file

@ -39,7 +39,7 @@ 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.
* The row/columns used in the selection are in document coordinates representing the coordinates as they appear in the document before applying soft wrap and folding.
* @class Selection
**/
@ -143,7 +143,7 @@ var Selection = function(session) {
**/
this.getSelectionAnchor = function() {
if (this.$isEmpty)
return this.getSelectionLead()
return this.getSelectionLead();
else
return this.anchor.getPosition();
};
@ -168,7 +168,7 @@ var Selection = function(session) {
if (this.$isEmpty) {
this.moveCursorTo(this.lead.row, this.lead.column + columns);
return;
};
}
var anchor = this.getSelectionAnchor();
var lead = this.getSelectionLead();
@ -474,7 +474,7 @@ var Selection = function(session) {
if (fold = this.session.getFoldAt(cursor.row, cursor.column, -1)) {
this.moveCursorTo(fold.start.row, fold.start.column);
} else if (cursor.column == 0) {
} else if (cursor.column === 0) {
// cursor is a line (start
if (cursor.row > 0) {
this.moveCursorTo(cursor.row - 1, this.doc.getLine(cursor.row - 1).length);
@ -639,7 +639,7 @@ var Selection = function(session) {
var str = this.session.getFoldStringAt(row, column, -1);
if (str == null) {
str = this.doc.getLine(row).substring(0, column)
str = this.doc.getLine(row).substring(0, column);
}
var leftOfCursor = lang.stringReverse(str);
@ -691,13 +691,13 @@ var Selection = function(session) {
index ++;
if (whitespaceRe.test(ch)) {
if (index > 2) {
index--
index--;
break;
} else {
while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch))
index ++;
if (index > 2)
break
break;
}
}
}
@ -722,11 +722,11 @@ var Selection = function(session) {
var l = this.doc.getLength();
do {
row++;
rightOfCursor = this.doc.getLine(row)
} while (row < l && /^\s*$/.test(rightOfCursor))
rightOfCursor = this.doc.getLine(row);
} while (row < l && /^\s*$/.test(rightOfCursor));
if (!/^\s+/.test(rightOfCursor))
rightOfCursor = ""
rightOfCursor = "";
column = 0;
}
@ -744,15 +744,15 @@ var Selection = function(session) {
return this.moveCursorTo(fold.start.row, fold.start.column);
var line = this.session.getLine(row).substring(0, column);
if (column == 0) {
if (column === 0) {
do {
row--;
line = this.doc.getLine(row);
} while (row > 0 && /^\s*$/.test(line))
} while (row > 0 && /^\s*$/.test(line));
column = line.length;
if (!/\s+$/.test(line))
line = ""
line = "";
}
var leftOfCursor = lang.stringReverse(line);
@ -859,12 +859,12 @@ var Selection = function(session) {
this.lead.detach();
this.anchor.detach();
this.session = this.doc = null;
}
};
this.fromOrientedRange = function(range) {
this.setSelectionRange(range, range.cursor == range.start);
this.$desiredColumn = range.desiredColumn || this.$desiredColumn;
}
};
this.toOrientedRange = function(range) {
var r = this.getRange();
@ -880,7 +880,7 @@ var Selection = function(session) {
range.cursor = this.isBackwards() ? range.start : range.end;
range.desiredColumn = this.$desiredColumn;
return range;
}
};
/**
* Saves the current cursor position and calls `func` that can change the cursor
@ -901,7 +901,7 @@ var Selection = function(session) {
} finally {
this.moveCursorToPosition(start);
}
}
};
this.toJSON = function() {
if (this.rangeCount) {
@ -944,10 +944,10 @@ var Selection = function(session) {
for (var i = this.ranges.length; i--; ) {
if (!this.ranges[i].isEqual(data[i]))
return false
return false;
}
return true;
}
};
}).call(Selection.prototype);

View file

@ -497,6 +497,10 @@ var SnippetManager = function() {
var snippetMap = this.snippetMap;
var snippetNameMap = this.snippetNameMap;
var self = this;
if (!snippets)
snippets = [];
function wrapRegexp(src) {
if (src && !/^\^?\(.*\)\$?$|^\\b$/.test(src))
src = "(?:" + src + ")";
@ -549,7 +553,7 @@ var SnippetManager = function() {
s.endTriggerRe = new RegExp(s.endTrigger, "", true);
}
if (snippets.content)
if (snippets && snippets.content)
addSnippet(snippets);
else if (Array.isArray(snippets))
snippets.forEach(addSnippet);

View file

@ -0,0 +1,7 @@
define(function(require, exports, module) {
"use strict";
exports.snippetText = require("../requirejs/text!./gcode.snippets");
exports.scope = "gcode";
});

View file

View file

@ -0,0 +1,7 @@
define(function(require, exports, module) {
"use strict";
exports.snippetText = require("../requirejs/text!./gitignore.snippets");
exports.scope = "gitignore";
});

View file

69
lib/ace/snippets/io.js Normal file
View file

@ -0,0 +1,69 @@
define(function(require, exports, module) {
"use strict";
exports.snippets = [
{
"content": "assertEquals(${1:expected}, ${2:expr})",
"name": "assertEquals",
"scope": "io",
"tabTrigger": "ae"
},
{
"content": "${1:${2:newValue} := ${3:Object} }clone do(\n\t$0\n)",
"name": "clone do",
"scope": "io",
"tabTrigger": "cdo"
},
{
"content": "docSlot(\"${1:slotName}\", \"${2:documentation}\")",
"name": "docSlot",
"scope": "io",
"tabTrigger": "ds"
},
{
"content": "(${1:header,}\n\t${2:body}\n)$0",
"keyEquivalent": "@(",
"name": "Indented Bracketed Line",
"scope": "io",
"tabTrigger": "("
},
{
"content": "\n\t$0\n",
"keyEquivalent": "\r",
"name": "Special: Return Inside Empty Parenthesis",
"scope": "io meta.empty-parenthesis.io, io meta.comma-parenthesis.io"
},
{
"content": "${1:methodName} := method(${2:args,}\n\t$0\n)",
"name": "method",
"scope": "io",
"tabTrigger": "m"
},
{
"content": "newSlot(\"${1:slotName}\", ${2:defaultValue}, \"${3:docString}\")$0",
"name": "newSlot",
"scope": "io",
"tabTrigger": "ns"
},
{
"content": "${1:name} := Object clone do(\n\t$0\n)",
"name": "Object clone do",
"scope": "io",
"tabTrigger": "ocdo"
},
{
"content": "test${1:SomeFeature} := method(\n\t$0\n)",
"name": "testMethod",
"scope": "io",
"tabTrigger": "ts"
},
{
"content": "${1:Something}Test := ${2:UnitTest} clone do(\n\t$0\n)",
"name": "UnitTest",
"scope": "io",
"tabTrigger": "ut"
}
];
exports.scope = "io";
});

View file

@ -129,6 +129,16 @@ snippet email
{
$0
}
snippet experience_permissions
experience_permissions(${1:key agent_id})
{
$0
}
snippet experience_permissions_denied
experience_permissions_denied(${1:key agent_id}, ${2:integer reason})
{
$0
}
snippet for
for (${1:start}; ${3:condition}; ${3:step})
{
@ -186,6 +196,8 @@ snippet llAddToLandPassList
llAddToLandPassList(${1:key agent}, ${2:float hours});
snippet llAdjustSoundVolume
llAdjustSoundVolume(${1:float volume});
snippet llAgentInExperience
llAgentInExperience(${1:key agent})
snippet llAllowInventoryDrop
llAllowInventoryDrop(${1:integer add});
snippet llAngleBetween
@ -238,12 +250,18 @@ snippet llCos
llCos(${1:float theta})
snippet llCreateCharacter
llCreateCharacter(${1:list options});
snippet llCreateKeyValue
llCreateKeyValue(${1:string k})
snippet llCreateLink
llCreateLink(${1:key target}, ${2:integer parent});
snippet llCSV2List
llCSV2List(${1:string src})
snippet llDataSizeKeyValue
llDataSizeKeyValue()
snippet llDeleteCharacter
llDeleteCharacter();
snippet llDeleteKeyValue
llDeleteKeyValue(${1:string k})
snippet llDeleteSubList
llDeleteSubList(${1:list src}, ${2:integer start}, ${3:integer end})
snippet llDeleteSubString
@ -358,6 +376,10 @@ snippet llGetEnergy
llGetEnergy()
snippet llGetEnv
llGetEnv(${1:string name})
snippet llGetExperienceDetails
llGetExperienceDetails(${1:key experience_id})
snippet llGetExperienceErrorMessage
llGetExperienceErrorMessage(${1:integer error})
snippet llGetForce
llGetForce()
snippet llGetFreeMemory
@ -570,6 +592,10 @@ snippet llJsonValueType
llJsonValueType(${1:string json}, ${2:list specifiers})
snippet llKey2Name
llKey2Name(${1:key id})
snippet llKeyCountKeyValue
llKeyCountKeyValue()
snippet llKeysKeyValue
llKeysKeyValue(${1:integer first}, ${2:integer count})
snippet llLinkParticleSystem
llLinkParticleSystem(${1:integer link}, ${2:list rules});
snippet llLinkSitTarget
@ -680,6 +706,8 @@ snippet llPursue
llPursue(${1:key target}, ${2:list options});
snippet llPushObject
llPushObject(${1:key target}, ${2:vector impulse}, ${3:vector ang_impulse}, ${4:integer local});
snippet llReadKeyValue
llReadKeyValue(${1:string k})
snippet llRegionSay
llRegionSay(${1:integer channel}, ${2:string msg});
snippet llRegionSayTo
@ -704,6 +732,8 @@ snippet llRequestAgentData
llRequestAgentData(${1:key id}, ${2:integer data})
snippet llRequestDisplayName
llRequestDisplayName(${1:key id})
snippet llRequestExperiencePermissions
llRequestExperiencePermissions(${1:key agent}, ${2:string name})
snippet llRequestInventoryData
llRequestInventoryData(${1:string name})
snippet llRequestPermissions
@ -952,6 +982,8 @@ snippet llUnSit
llUnSit(${1:key id});
snippet llUpdateCharacter
llUpdateCharacter(${1:list options})
snippet llUpdateKeyValue
llUpdateKeyValue(${1:string k}, ${2:string v}, ${3:integer checked}, ${4:string ov})
snippet llVecDist
llVecDist(${1:vector vec_a}, ${2:vector vec_b})
snippet llVecMag

View file

@ -0,0 +1,7 @@
define(function(require, exports, module) {
"use strict";
exports.snippetText = require("../requirejs/text!./praat.snippets");
exports.scope = "praat";
});

View file

View file

@ -221,6 +221,10 @@ var Tokenizer = function(rules) {
if (startState && typeof startState != "string") {
var stack = startState.slice(0);
startState = stack[0];
if (startState === "#tmp") {
stack.shift()
startState = stack.shift()
}
} else
var stack = [];
@ -268,11 +272,12 @@ var Tokenizer = function(rules) {
type = rule.token;
if (rule.next) {
if (typeof rule.next == "string")
if (typeof rule.next == "string") {
currentState = rule.next;
else
} else {
currentState = rule.next(currentState, stack);
}
state = this.states[currentState];
if (!state) {
window.console && console.error && console.error(currentState, "doesn't exist");
@ -331,7 +336,7 @@ var Tokenizer = function(rules) {
if (stack.length > 1) {
if (stack[0] !== currentState)
stack.unshift(currentState);
stack.unshift("#tmp", currentState);
}
return {
tokens : tokens,

View file

@ -232,10 +232,7 @@ var VirtualRenderer = function(container, theme) {
this.session.doc.off("changeNewLineMode", this.onChangeNewLineMode);
this.session = session;
if (!session)
return;
if (this.scrollMargin.top && session.getScrollTop() <= 0)
if (session && this.scrollMargin.top && session.getScrollTop() <= 0)
session.setScrollTop(-this.scrollMargin.top);
this.$cursorLayer.setSession(session);
@ -243,6 +240,9 @@ var VirtualRenderer = function(container, theme) {
this.$markerFront.setSession(session);
this.$gutterLayer.setSession(session);
this.$textLayer.setSession(session);
if (!session)
return;
this.$loop.schedule(this.CHANGE_FULL);
this.session.$setFontMetrics(this.$fontMetrics);
@ -258,7 +258,7 @@ var VirtualRenderer = function(container, theme) {
*
*
**/
this.updateLines = function(firstRow, lastRow) {
this.updateLines = function(firstRow, lastRow, force) {
if (lastRow === undefined)
lastRow = Infinity;
@ -276,8 +276,17 @@ var VirtualRenderer = function(container, theme) {
this.$changedLines.lastRow = lastRow;
}
if (this.$changedLines.firstRow > this.layerConfig.lastRow ||
this.$changedLines.lastRow < this.layerConfig.firstRow)
// If the change happened offscreen above us then it's possible
// that a new line wrap will affect the position of the lines on our
// screen so they need redrawn.
// TODO: better solution is to not change scroll position when text is changed outside of visible area
if (this.$changedLines.lastRow < this.layerConfig.firstRow) {
if (force)
this.$changedLines.lastRow = this.layerConfig.lastRow;
else
return;
}
if (this.$changedLines.firstRow > this.layerConfig.lastRow)
return;
this.$loop.schedule(this.CHANGE_LINES);
};
@ -634,18 +643,17 @@ var VirtualRenderer = function(container, theme) {
var val = this.textarea.value.replace(/^\x01+/, "");
w *= (this.session.$getStringScreenWidth(val)[0]+2);
h += 2;
posTop -= 1;
}
posLeft -= this.scrollLeft;
if (posLeft > this.$size.scrollerWidth - w)
posLeft = this.$size.scrollerWidth - w;
posLeft -= this.scrollBar.width;
posLeft += this.gutterWidth;
this.textarea.style.height = h + "px";
this.textarea.style.width = w + "px";
this.textarea.style.right = Math.max(0, this.$size.scrollerWidth - posLeft - w) + "px";
this.textarea.style.bottom = Math.max(0, this.$size.height - posTop - h) + "px";
this.textarea.style.left = Math.min(posLeft, this.$size.scrollerWidth - w) + "px";
this.textarea.style.top = Math.min(posTop, this.$size.height - h) + "px";
};
/**
@ -804,6 +812,20 @@ var VirtualRenderer = function(container, theme) {
changes & this.CHANGE_H_SCROLL
) {
changes |= this.$computeLayerConfig();
// If a change is made offscreen and wrapMode is on, then the onscreen
// lines may have been pushed down. If so, the first screen row will not
// have changed, but the first actual row will. In that case, adjust
// scrollTop so that the cursor and onscreen content stays in the same place.
// TODO: find a better way to handle this, that works non wrapped case and doesn't compute layerConfig twice
if (config.firstRow != this.layerConfig.firstRow && config.firstRowScreen == this.layerConfig.firstRowScreen) {
var st = this.scrollTop + (config.firstRow - this.layerConfig.firstRow) * this.lineHeight;
if (st > 0) {
// this check is needed as a workaround for the documentToScreenRow returning -1 if document.length == 0
this.scrollTop = st;
changes = changes | this.CHANGE_SCROLL;
changes |= this.$computeLayerConfig();
}
}
config = this.layerConfig;
// update scrollbar first to not lose scroll position when gutter calls resize
this.$updateScrollBarV();
@ -906,6 +928,8 @@ var VirtualRenderer = function(container, theme) {
this.$updateCachedSize(true, this.$gutterWidth, w, desiredHeight);
// this.$loop.changes = 0;
this.desiredHeight = desiredHeight;
this._signal("autosize");
}
};
@ -1424,26 +1448,26 @@ var VirtualRenderer = function(container, theme) {
};
/**
*
* Focuses the current container.
**/
*
* Focuses the current container.
**/
this.visualizeFocus = function() {
dom.addCssClass(this.container, "ace_focus");
};
/**
*
* Blurs the current container.
**/
*
* Blurs the current container.
**/
this.visualizeBlur = function() {
dom.removeCssClass(this.container, "ace_focus");
};
/**
* @param {Number} position
*
* @private
**/
* @param {Number} position
*
* @private
**/
this.showComposition = function(position) {
if (!this.$composition)
this.$composition = {
@ -1458,18 +1482,18 @@ var VirtualRenderer = function(container, theme) {
};
/**
* @param {String} text A string of text to use
*
* Sets the inner text of the current composition to `text`.
**/
* @param {String} text A string of text to use
*
* Sets the inner text of the current composition to `text`.
**/
this.setCompositionText = function(text) {
this.$moveTextAreaToCursor();
};
/**
*
* Hides the current composition.
**/
*
* Hides the current composition.
**/
this.hideComposition = function() {
if (!this.$composition)
return;
@ -1481,11 +1505,11 @@ var VirtualRenderer = function(container, theme) {
};
/**
* [Sets a new theme for the editor. `theme` should exist, and be a directory path, like `ace/theme/textmate`.]{: #VirtualRenderer.setTheme}
* @param {String} theme The path to a theme
* @param {Function} cb optional callback
*
**/
* [Sets a new theme for the editor. `theme` should exist, and be a directory path, like `ace/theme/textmate`.]{: #VirtualRenderer.setTheme}
* @param {String} theme The path to a theme
* @param {Function} cb optional callback
*
**/
this.setTheme = function(theme, cb) {
var _self = this;
this.$themeId = theme;
@ -1536,9 +1560,9 @@ var VirtualRenderer = function(container, theme) {
};
/**
* [Returns the path of the current theme.]{: #VirtualRenderer.getTheme}
* @returns {String}
**/
* [Returns the path of the current theme.]{: #VirtualRenderer.getTheme}
* @returns {String}
**/
this.getTheme = function() {
return this.$themeId;
};
@ -1548,39 +1572,39 @@ var VirtualRenderer = function(container, theme) {
// a certain mode that editor is in.
/**
* [Adds a new class, `style`, to the editor.]{: #VirtualRenderer.setStyle}
* @param {String} style A class name
*
**/
* [Adds a new class, `style`, to the editor.]{: #VirtualRenderer.setStyle}
* @param {String} style A class name
*
**/
this.setStyle = function(style, include) {
dom.setCssClass(this.container, style, include !== false);
};
/**
* [Removes the class `style` from the editor.]{: #VirtualRenderer.unsetStyle}
* @param {String} style A class name
*
**/
* [Removes the class `style` from the editor.]{: #VirtualRenderer.unsetStyle}
* @param {String} style A class name
*
**/
this.unsetStyle = function(style) {
dom.removeCssClass(this.container, style);
};
this.setCursorStyle = function(style) {
if (this.content.style.cursor != style)
this.content.style.cursor = style;
if (this.scroller.style.cursor != style)
this.scroller.style.cursor = style;
};
/**
* @param {String} cursorStyle A css cursor style
*
**/
* @param {String} cursorStyle A css cursor style
*
**/
this.setMouseCursor = function(cursorStyle) {
this.content.style.cursor = cursorStyle;
this.scroller.style.cursor = cursorStyle;
};
/**
* Destroys the text and cursor layers for this renderer.
**/
* Destroys the text and cursor layers for this renderer.
**/
this.destroy = function() {
this.$textLayer.destroy();
this.$cursorLayer.destroy();