Merge remote-tracking branch 'remotes/origin/master' into v-1.2
Conflicts: build lib/ace/multi_select_test.js
This commit is contained in:
commit
a4532dd8b9
72 changed files with 2953 additions and 333 deletions
|
|
@ -67,6 +67,7 @@ var Autocomplete = function() {
|
|||
e.stop();
|
||||
}.bind(this));
|
||||
this.popup.focus = this.editor.focus.bind(this.editor);
|
||||
this.popup.on("show", this.tooltipTimer.bind(null, null));
|
||||
this.popup.on("select", this.tooltipTimer.bind(null, null));
|
||||
this.popup.on("changeHoverMarker", this.tooltipTimer.bind(null, null));
|
||||
return this.popup;
|
||||
|
|
@ -177,7 +178,7 @@ var Autocomplete = function() {
|
|||
return false;
|
||||
|
||||
if (data.completer && data.completer.insertMatch) {
|
||||
data.completer.insertMatch(this.editor);
|
||||
data.completer.insertMatch(this.editor, data);
|
||||
} else {
|
||||
if (this.completions.filterText) {
|
||||
var ranges = this.editor.selection.getAllRanges();
|
||||
|
|
@ -344,7 +345,7 @@ var Autocomplete = function() {
|
|||
doc = selected;
|
||||
|
||||
if (typeof doc == "string")
|
||||
doc = {tooltipText: doc}
|
||||
doc = {docText: doc}
|
||||
if (!doc || !(doc.docHTML || doc.docText))
|
||||
return this.hideDocTooltip();
|
||||
this.showDocTooltip(doc);
|
||||
|
|
@ -352,7 +353,7 @@ var Autocomplete = function() {
|
|||
|
||||
this.showDocTooltip = function(item) {
|
||||
if (!this.tooltipNode) {
|
||||
this.tooltipNode = dom.createElement("pre");
|
||||
this.tooltipNode = dom.createElement("div");
|
||||
this.tooltipNode.className = "ace_tooltip ace_doc-tooltip";
|
||||
this.tooltipNode.style.margin = 0;
|
||||
this.tooltipNode.style.pointerEvents = "auto";
|
||||
|
|
@ -381,7 +382,6 @@ var Autocomplete = function() {
|
|||
tooltipNode.style.left = (rect.right + 1) + "px";
|
||||
tooltipNode.style.right = "";
|
||||
}
|
||||
// tooltipNode.style.height = rect.height + "px";
|
||||
tooltipNode.style.display = "block";
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -162,6 +162,28 @@ exports.iSearchCommands = [{
|
|||
exec: function(iSearch) { iSearch.$editor.execCommand('recenterTopBottom'); },
|
||||
readOnly: true,
|
||||
isIncrementalSearchCommand: true
|
||||
}, {
|
||||
name: 'selectAllMatches',
|
||||
bindKey: 'Ctrl-space',
|
||||
exec: function(iSearch) {
|
||||
var ed = iSearch.$editor,
|
||||
hl = ed.session.$isearchHighlight,
|
||||
ranges = hl && hl.cache ? hl.cache
|
||||
.reduce(function(ranges, ea) {
|
||||
return ranges.concat(ea ? ea : []); }, []) : [];
|
||||
iSearch.deactivate(false);
|
||||
ranges.forEach(ed.selection.addRange.bind(ed.selection));
|
||||
},
|
||||
readOnly: true,
|
||||
isIncrementalSearchCommand: true
|
||||
}, {
|
||||
name: 'searchAsRegExp',
|
||||
bindKey: 'Alt-r',
|
||||
exec: function(iSearch) {
|
||||
iSearch.convertNeedleToRegExp();
|
||||
},
|
||||
readOnly: true,
|
||||
isIncrementalSearchCommand: true
|
||||
}];
|
||||
|
||||
function IncrementalSearchKeyboardHandler(iSearch) {
|
||||
|
|
|
|||
|
|
@ -883,7 +883,7 @@ var Editor = function(renderer, session) {
|
|||
/**
|
||||
* Emitted when text is pasted.
|
||||
* @event paste
|
||||
* @param {String} text The pasted text
|
||||
* @param {Object} an object which contains one property, `text`, that represents the text to be pasted. Editing this property will alter the text that is pasted.
|
||||
*
|
||||
*
|
||||
**/
|
||||
|
|
|
|||
|
|
@ -342,29 +342,29 @@ var keymap = {
|
|||
var editorProxy = new AceEmmetEditor();
|
||||
exports.commands = new HashHandler();
|
||||
exports.runEmmetCommand = function(editor) {
|
||||
editorProxy.setupContext(editor);
|
||||
if (editorProxy.getSyntax() == "php")
|
||||
return false;
|
||||
var actions = emmet.require("actions");
|
||||
|
||||
if (this.action == "expand_abbreviation_with_tab") {
|
||||
if (!editor.selection.isEmpty())
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.action == "wrap_with_abbreviation") {
|
||||
// without setTimeout prompt doesn't work on firefox
|
||||
return setTimeout(function() {
|
||||
actions.run("wrap_with_abbreviation", editorProxy);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
var pos = editor.selection.lead;
|
||||
var token = editor.session.getTokenAt(pos.row, pos.column);
|
||||
if (token && /\btag\b/.test(token.type))
|
||||
return false;
|
||||
|
||||
try {
|
||||
editorProxy.setupContext(editor);
|
||||
if (editorProxy.getSyntax() == "php")
|
||||
return false;
|
||||
var actions = emmet.require("actions");
|
||||
|
||||
if (this.action == "expand_abbreviation_with_tab") {
|
||||
if (!editor.selection.isEmpty())
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.action == "wrap_with_abbreviation") {
|
||||
// without setTimeout prompt doesn't work on firefox
|
||||
return setTimeout(function() {
|
||||
actions.run("wrap_with_abbreviation", editorProxy);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
var pos = editor.selection.lead;
|
||||
var token = editor.session.getTokenAt(pos.row, pos.column);
|
||||
if (token && /\btag\b/.test(token.type))
|
||||
return false;
|
||||
|
||||
var result = actions.run(this.action, editorProxy);
|
||||
} catch(e) {
|
||||
editor._signal("changeStatus", typeof e == "string" ? e : e.message);
|
||||
|
|
@ -393,7 +393,7 @@ exports.updateCommands = function(editor, enabled) {
|
|||
};
|
||||
|
||||
exports.isSupportedMode = function(modeId) {
|
||||
return modeId && /css|less|scss|sass|stylus|html|php|twig/.test(modeId);
|
||||
return modeId && /css|less|scss|sass|stylus|html|php|twig|ejs/.test(modeId);
|
||||
};
|
||||
|
||||
var onChangeMode = function(e, target) {
|
||||
|
|
@ -406,9 +406,8 @@ var onChangeMode = function(e, target) {
|
|||
if (enabled) {
|
||||
if (typeof emmetPath == "string") {
|
||||
require("ace/config").loadModule(emmetPath, function() {
|
||||
|
||||
emmetPath = null;
|
||||
});
|
||||
emmetPath = null;
|
||||
}
|
||||
}
|
||||
exports.updateCommands(editor, enabled);
|
||||
|
|
|
|||
|
|
@ -40,6 +40,9 @@ var util = require("../autocomplete/util");
|
|||
var textCompleter = require("../autocomplete/text_completer");
|
||||
var keyWordCompleter = {
|
||||
getCompletions: function(editor, session, pos, prefix, callback) {
|
||||
if (session.$mode.completer) {
|
||||
return session.$mode.completer.getCompletions(editor, session, pos, prefix, callback);
|
||||
}
|
||||
var state = editor.session.getState(pos.row);
|
||||
var completions = session.$mode.getCompletions(state, session, pos, prefix);
|
||||
callback(null, completions);
|
||||
|
|
|
|||
|
|
@ -91,6 +91,12 @@ module.exports.generateSettingsMenu = function generateSettingsMenu (editor) {
|
|||
elements.forEach(function(element) {
|
||||
topmenu.appendChild(element);
|
||||
});
|
||||
|
||||
var el = topmenu.appendChild(document.createElement('div'));
|
||||
var version = "1.1.8";
|
||||
el.style.padding = "1em";
|
||||
el.textContent = "Ace version " + version;
|
||||
|
||||
return topmenu;
|
||||
}
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ var supportedModes = {
|
|||
DummySyntax: ["dummy"],
|
||||
Eiffel: ["e"],
|
||||
EJS: ["ejs"],
|
||||
Elixir: ["ex|exs"],
|
||||
Elm: ["elm"],
|
||||
Erlang: ["erl|hrl"],
|
||||
Forth: ["frt|fs|ldr"],
|
||||
|
|
|
|||
|
|
@ -28,9 +28,8 @@ var StatusBar = function(editor, parentNode) {
|
|||
str && status.push(str, separator || "|");
|
||||
}
|
||||
|
||||
if (editor.$vimModeHandler)
|
||||
add(editor.$vimModeHandler.getStatusText());
|
||||
else if (editor.commands.recording)
|
||||
add(editor.keyBinding.getStatusText(editor));
|
||||
if (editor.commands.recording)
|
||||
add("REC");
|
||||
|
||||
var c = editor.selection.lead;
|
||||
|
|
|
|||
|
|
@ -64,6 +64,34 @@ function IncrementalSearch() {
|
|||
|
||||
oop.inherits(IncrementalSearch, Search);
|
||||
|
||||
// regexp handling
|
||||
|
||||
function isRegExp(obj) {
|
||||
return obj instanceof RegExp;
|
||||
}
|
||||
|
||||
function regExpToObject(re) {
|
||||
var string = String(re),
|
||||
start = string.indexOf('/'),
|
||||
flagStart = string.lastIndexOf('/');
|
||||
return {
|
||||
expression: string.slice(start+1, flagStart),
|
||||
flags: string.slice(flagStart+1)
|
||||
}
|
||||
}
|
||||
|
||||
function stringToRegExp(string, flags) {
|
||||
try {
|
||||
return new RegExp(string, flags);
|
||||
} catch (e) { return string; }
|
||||
}
|
||||
|
||||
function objectToRegExp(obj) {
|
||||
return stringToRegExp(obj.expression, obj.flags);
|
||||
}
|
||||
|
||||
// iSearch class
|
||||
|
||||
;(function() {
|
||||
|
||||
this.activate = function(ed, backwards) {
|
||||
|
|
@ -140,10 +168,12 @@ oop.inherits(IncrementalSearch, Search);
|
|||
// try to find the next occurence and enable highlighting marker
|
||||
options.start = this.$currentPos;
|
||||
var session = this.$editor.session,
|
||||
found = this.find(session);
|
||||
found = this.find(session),
|
||||
shouldSelect = this.$editor.emacsMark ?
|
||||
!!this.$editor.emacsMark() : !this.$editor.selection.isEmpty();
|
||||
if (found) {
|
||||
if (options.backwards) found = Range.fromPoints(found.end, found.start);
|
||||
this.$editor.moveCursorToPosition(found.end);
|
||||
this.$editor.selection.setRange(Range.fromPoints(shouldSelect ? this.$startPos : found.end, found.end));
|
||||
if (moveToNext) this.$currentPos = found.end;
|
||||
// highlight after cursor move, so selection works properly
|
||||
this.highlight(options.re)
|
||||
|
|
@ -156,13 +186,21 @@ oop.inherits(IncrementalSearch, Search);
|
|||
|
||||
this.addString = function(s) {
|
||||
return this.highlightAndFindWithNeedle(false, function(needle) {
|
||||
return needle + s;
|
||||
if (!isRegExp(needle))
|
||||
return needle + s;
|
||||
var reObj = regExpToObject(needle);
|
||||
reObj.expression += s;
|
||||
return objectToRegExp(reObj);
|
||||
});
|
||||
}
|
||||
|
||||
this.removeChar = function(c) {
|
||||
return this.highlightAndFindWithNeedle(false, function(needle) {
|
||||
return needle.length > 0 ? needle.substring(0, needle.length-1) : needle;
|
||||
if (!isRegExp(needle))
|
||||
return needle.substring(0, needle.length-1);
|
||||
var reObj = regExpToObject(needle);
|
||||
reObj.expression = reObj.expression.substring(0, reObj.expression.length-1);
|
||||
return objectToRegExp(reObj);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -189,6 +227,18 @@ oop.inherits(IncrementalSearch, Search);
|
|||
this.addString(text);
|
||||
}
|
||||
|
||||
this.convertNeedleToRegExp = function() {
|
||||
return this.highlightAndFindWithNeedle(false, function(needle) {
|
||||
return isRegExp(needle) ? needle : stringToRegExp(needle, 'ig');
|
||||
});
|
||||
}
|
||||
|
||||
this.convertNeedleToString = function() {
|
||||
return this.highlightAndFindWithNeedle(false, function(needle) {
|
||||
return isRegExp(needle) ? regExpToObject(needle).expression : needle;
|
||||
});
|
||||
}
|
||||
|
||||
this.statusMessage = function(found) {
|
||||
var options = this.$options, msg = '';
|
||||
msg += options.backwards ? 'reverse-' : '';
|
||||
|
|
|
|||
|
|
@ -35,13 +35,17 @@ if (typeof process !== "undefined") {
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var emacs = require('./keyboard/emacs');
|
||||
var EditSession = require("./edit_session").EditSession;
|
||||
var Editor = require("./editor").Editor;
|
||||
var MockRenderer = require("./test/mockrenderer").MockRenderer;
|
||||
var Range = require("./range").Range;
|
||||
var MultiSelect = require("./multi_select").MultiSelect;
|
||||
var assert = require("./test/assertions");
|
||||
var IncrementalSearch = require("./incremental_search").IncrementalSearch;
|
||||
|
||||
require("./multi_select");
|
||||
|
||||
var editor, iSearch;
|
||||
function testRanges(str, ranges) {
|
||||
ranges = ranges || editor.selection.getAllRanges();
|
||||
|
|
@ -69,6 +73,7 @@ module.exports = {
|
|||
setUp: function() {
|
||||
var session = new EditSession(["abc123", "xyz124"]);
|
||||
editor = new Editor(new MockRenderer(), session);
|
||||
new MultiSelect(editor);
|
||||
iSearch = new IncrementalSearch();
|
||||
},
|
||||
|
||||
|
|
@ -195,7 +200,7 @@ module.exports = {
|
|||
editor.keyBinding.addKeyboardHandler(emacs.handler);
|
||||
emacs.handler.commands.setMark.exec(editor);
|
||||
iSearch.activate(editor);
|
||||
iSearch.addString('1'); iSearch.addString('2');;
|
||||
iSearch.addString('1'); iSearch.addString('2');
|
||||
testRanges("Range: [0/0] -> [0/5]", [editor.getSelectionRange()], "sel range");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -125,6 +125,24 @@ exports.handler.attach = function(editor) {
|
|||
return this.session.$emacsMark || this.session.$emacsMarkRing.slice(-1)[0];
|
||||
};
|
||||
|
||||
editor.emacsMarkForSelection = function(replacement) {
|
||||
// find the mark in $emacsMarkRing corresponding to the current
|
||||
// selection
|
||||
var sel = this.selection,
|
||||
multiRangeLength = this.multiSelect ?
|
||||
this.multiSelect.getAllRanges().length : 1,
|
||||
selIndex = sel.index || 0,
|
||||
markRing = this.session.$emacsMarkRing,
|
||||
markIndex = markRing.length - (multiRangeLength - selIndex),
|
||||
lastMark = markRing[markIndex] || sel.anchor;
|
||||
if (replacement) {
|
||||
markRing.splice(markIndex, 1,
|
||||
"row" in replacement && "column" in replacement ?
|
||||
replacement : undefined);
|
||||
}
|
||||
return lastMark;
|
||||
}
|
||||
|
||||
editor.on("click", $resetMarkMode);
|
||||
editor.on("changeSession", $kbSessionChange);
|
||||
editor.renderer.screenToTextCoordinates = screenToTextBlockCoordinates;
|
||||
|
|
@ -146,6 +164,7 @@ exports.handler.detach = function(editor) {
|
|||
editor.commands.removeCommands(commands);
|
||||
editor.removeEventListener('copy', this.onCopy);
|
||||
editor.removeEventListener('paste', this.onPaste);
|
||||
editor.$emacsModeHandler = null;
|
||||
};
|
||||
|
||||
var $kbSessionChange = function(e) {
|
||||
|
|
@ -187,7 +206,7 @@ exports.handler.onCopy = function(e, editor) {
|
|||
if (editor.$handlesEmacsOnCopy) return;
|
||||
editor.$handlesEmacsOnCopy = true;
|
||||
exports.handler.commands.killRingSave.exec(editor);
|
||||
delete editor.$handlesEmacsOnCopy;
|
||||
editor.$handlesEmacsOnCopy = false;
|
||||
};
|
||||
|
||||
exports.handler.onPaste = function(e, editor) {
|
||||
|
|
@ -220,12 +239,22 @@ exports.handler.bindKey = function(key, command) {
|
|||
}, this);
|
||||
};
|
||||
|
||||
exports.handler.getStatusText = function(editor, data) {
|
||||
var str = "";
|
||||
if (data.count)
|
||||
str += data.count;
|
||||
if (data.keyChain)
|
||||
str += " " + data.keyChain
|
||||
return str;
|
||||
};
|
||||
|
||||
exports.handler.handleKeyboard = function(data, hashId, key, keyCode) {
|
||||
// if keyCode == -1 a non-printable key was pressed, such as just
|
||||
// control. Handling those is currently not supported in this handler
|
||||
if (keyCode === -1) return undefined;
|
||||
|
||||
var editor = data.editor;
|
||||
editor._signal("changeStatus");
|
||||
// insertstring data.count times
|
||||
if (hashId == -1) {
|
||||
editor.pushEmacsMark();
|
||||
|
|
@ -236,24 +265,17 @@ exports.handler.handleKeyboard = function(data, hashId, key, keyCode) {
|
|||
}
|
||||
}
|
||||
|
||||
if (key == "\x00") return undefined;
|
||||
|
||||
var modifier = eMods[hashId];
|
||||
|
||||
// CTRL + number / universalArgument for setting data.count
|
||||
if (modifier == "c-" || data.universalArgument) {
|
||||
var prevCount = String(data.count || 0);
|
||||
if (modifier == "c-" || data.count) {
|
||||
var count = parseInt(key[key.length - 1]);
|
||||
if (typeof count === 'number' && !isNaN(count)) {
|
||||
data.count = parseInt(prevCount + count);
|
||||
data.count = Math.max(data.count, 0) || 0;
|
||||
data.count = 10 * data.count + count;
|
||||
return {command: "null"};
|
||||
} else if (data.universalArgument) {
|
||||
// if no number pressed use emacs defaults for universalArgument
|
||||
// which is 4
|
||||
data.count = 4;
|
||||
}
|
||||
}
|
||||
data.universalArgument = false;
|
||||
|
||||
// this.commandKeyBinding maps key specs like "c-p" (for CTRL + P) to
|
||||
// command objects, for lookup key needs to include the modifier
|
||||
|
|
@ -275,7 +297,9 @@ exports.handler.handleKeyboard = function(data, hashId, key, keyCode) {
|
|||
if (command === "null") return {command: "null"};
|
||||
|
||||
if (command === "universalArgument") {
|
||||
data.universalArgument = true;
|
||||
// if no number pressed emacs repeats action 4 times.
|
||||
// minus sign is needed to allow next keypress to replace it
|
||||
data.count = -4;
|
||||
return {command: "null"};
|
||||
}
|
||||
|
||||
|
|
@ -318,7 +342,8 @@ exports.handler.handleKeyboard = function(data, hashId, key, keyCode) {
|
|||
exec: function(editor, args) {
|
||||
for (var i = 0; i < count; i++)
|
||||
command.exec(editor, args);
|
||||
}
|
||||
},
|
||||
multiSelectAction: command.multiSelectAction
|
||||
}
|
||||
};
|
||||
} else {
|
||||
|
|
@ -439,59 +464,63 @@ exports.handler.addCommands({
|
|||
// selection modification commands. That is,
|
||||
// "goto" commands become "select" commands.
|
||||
// Any insertion or mouse click resets mark-mode.
|
||||
// setMark twice in a row at the same place resets markmode
|
||||
// setMark twice in a row at the same place resets markmode.
|
||||
// in multi select mode, ea selection is handled individually
|
||||
|
||||
if (args && args.count) {
|
||||
var mark = editor.popEmacsMark();
|
||||
mark && editor.selection.moveCursorToPosition(mark);
|
||||
if (editor.inMultiSelectMode) editor.forEachSelection(moveToMark);
|
||||
else moveToMark();
|
||||
moveToMark();
|
||||
return;
|
||||
}
|
||||
|
||||
var mark = editor.emacsMark(),
|
||||
transientMarkModeActive = true;
|
||||
|
||||
ranges = editor.selection.getAllRanges(),
|
||||
rangePositions = ranges.map(function(r) { return {row: r.start.row, column: r.start.column}; }),
|
||||
transientMarkModeActive = true,
|
||||
hasNoSelection = ranges.every(function(range) { return range.isEmpty(); });
|
||||
// if transientMarkModeActive then mark behavior is a little
|
||||
// different. Deactivate the mark when setMark is run with active
|
||||
// mark
|
||||
if (transientMarkModeActive && (mark || !editor.selection.isEmpty())) {
|
||||
editor.pushEmacsMark();
|
||||
editor.clearSelection();
|
||||
if (transientMarkModeActive && (mark || !hasNoSelection)) {
|
||||
if (editor.inMultiSelectMode) editor.forEachSelection({exec: editor.clearSelection.bind(editor)})
|
||||
else editor.clearSelection();
|
||||
if (mark) editor.pushEmacsMark(null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mark) {
|
||||
var cp = editor.getCursorPosition();
|
||||
if (editor.selection.isEmpty() &&
|
||||
mark.row == cp.row && mark.column == cp.column) {
|
||||
editor.pushEmacsMark();
|
||||
return;
|
||||
}
|
||||
if (!mark) {
|
||||
rangePositions.forEach(function(pos) { editor.pushEmacsMark(pos); });
|
||||
editor.setEmacsMark(rangePositions[rangePositions.length-1]);
|
||||
return;
|
||||
}
|
||||
// turn on mark mode
|
||||
mark = editor.getCursorPosition();
|
||||
editor.setEmacsMark(mark);
|
||||
editor.selection.setSelectionAnchor(mark.row, mark.column);
|
||||
|
||||
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
||||
|
||||
function moveToMark() {
|
||||
var mark = editor.popEmacsMark();
|
||||
mark && editor.moveCursorToPosition(mark);
|
||||
}
|
||||
|
||||
},
|
||||
readOnly: true,
|
||||
handlesCount: true,
|
||||
multiSelectAction: "forEach"
|
||||
handlesCount: true
|
||||
},
|
||||
exchangePointAndMark: {
|
||||
exec: function(editor, args) {
|
||||
exec: function exchangePointAndMark$exec(editor, args) {
|
||||
var sel = editor.selection;
|
||||
if (args.count) {
|
||||
var pos = editor.getCursorPosition();
|
||||
if (!args.count && !sel.isEmpty()) { // just invert selection
|
||||
sel.setSelectionRange(sel.getRange(), !sel.isBackwards());
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.count) { // replace mark and point
|
||||
var pos = {row: sel.lead.row, column: sel.lead.column};
|
||||
sel.clearSelection();
|
||||
sel.moveCursorToPosition(editor.popEmacsMark());
|
||||
editor.pushEmacsMark(pos);
|
||||
return;
|
||||
sel.moveCursorToPosition(editor.emacsMarkForSelection(pos));
|
||||
} else { // create selection to last mark
|
||||
sel.selectToPosition(editor.emacsMarkForSelection());
|
||||
}
|
||||
var lastMark = editor.getLastEmacsMark();
|
||||
var range = sel.getRange();
|
||||
if (range.isEmpty()) {
|
||||
sel.selectToPosition(lastMark);
|
||||
return;
|
||||
}
|
||||
sel.setSelectionRange(range, !sel.isBackwards());
|
||||
},
|
||||
readOnly: true,
|
||||
handlesCount: true,
|
||||
|
|
@ -544,6 +573,7 @@ exports.handler.addCommands({
|
|||
if (editor.keyBinding.$data.lastCommand != "yank")
|
||||
return;
|
||||
editor.undo();
|
||||
editor.session.$emacsMarkRing.pop(); // also undo recording mark
|
||||
editor.onPaste(exports.killRing.rotate());
|
||||
editor.keyBinding.$data.lastCommand = "yank";
|
||||
},
|
||||
|
|
@ -557,12 +587,25 @@ exports.handler.addCommands({
|
|||
},
|
||||
killRingSave: {
|
||||
exec: function(editor) {
|
||||
// copy text and deselect. will save marks for starts of the
|
||||
// selection(s)
|
||||
|
||||
editor.$handlesEmacsOnCopy = true;
|
||||
var marks = editor.session.$emacsMarkRing.slice(),
|
||||
deselectedMarks = [];
|
||||
exports.killRing.add(editor.getCopyText());
|
||||
|
||||
setTimeout(function() {
|
||||
var sel = editor.selection,
|
||||
range = sel.getRange();
|
||||
editor.pushEmacsMark(sel.isBackwards() ? range.end : range.start);
|
||||
sel.clearSelection();
|
||||
function deselect() {
|
||||
var sel = editor.selection, range = sel.getRange(),
|
||||
pos = sel.isBackwards() ? range.end : range.start;
|
||||
deselectedMarks.push({row: pos.row, column: pos.column});
|
||||
sel.clearSelection();
|
||||
}
|
||||
editor.$handlesEmacsOnCopy = false;
|
||||
if (editor.inMultiSelectMode) editor.forEachSelection({exec: deselect});
|
||||
else deselect();
|
||||
editor.session.$emacsMarkRing = marks.concat(deselectedMarks.reverse());
|
||||
}, 0);
|
||||
},
|
||||
readOnly: true
|
||||
|
|
@ -570,6 +613,7 @@ exports.handler.addCommands({
|
|||
keyboardQuit: function(editor) {
|
||||
editor.selection.clearSelection();
|
||||
editor.setEmacsMark(null);
|
||||
editor.keyBinding.$data.count = null;
|
||||
},
|
||||
focusCommandLine: function(editor, arg) {
|
||||
if (editor.showCommandLine)
|
||||
|
|
|
|||
|
|
@ -35,17 +35,29 @@ if (typeof process !== "undefined") {
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
require("../multi_select");
|
||||
|
||||
var EditSession = require("./../edit_session").EditSession,
|
||||
Editor = require("./../editor").Editor,
|
||||
Range = require("./../range").Range,
|
||||
MockRenderer = require("./../test/mockrenderer").MockRenderer,
|
||||
emacs = require('./emacs'),
|
||||
assert = require("./../test/assertions"),
|
||||
editor;
|
||||
editor, sel;
|
||||
|
||||
function initEditor(docString) {
|
||||
var doc = new EditSession(docString.split("\n"));
|
||||
editor = new Editor(new MockRenderer(), doc);
|
||||
editor.setKeyboardHandler(emacs.handler);
|
||||
sel = editor.selection;
|
||||
}
|
||||
|
||||
function print(obj) {
|
||||
return JSON.stringify(obj, null, 2);
|
||||
}
|
||||
|
||||
function pluck(arr, what) {
|
||||
return arr.map(function(ea) { return ea[what]; });
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
@ -62,6 +74,72 @@ module.exports = {
|
|||
editor.selectAll();
|
||||
editor.execCommand('keyboardQuit');
|
||||
assert.ok(editor.selection.isEmpty(), 'selection non-empty');
|
||||
},
|
||||
|
||||
"test: exchangePointAndMark without mark set": function() {
|
||||
initEditor('foo');
|
||||
sel.setRange(Range.fromPoints({row: 0, column: 1}, {row: 0, column: 3}));
|
||||
editor.execCommand('exchangePointAndMark');
|
||||
assert.deepEqual({row: 0, column: 1}, editor.getCursorPosition(), print(editor.getCursorPosition()));
|
||||
},
|
||||
|
||||
"test: exchangePointAndMark with mark set": function() {
|
||||
initEditor('foo');
|
||||
editor.pushEmacsMark({row: 0, column: 1});
|
||||
editor.pushEmacsMark({row: 0, column: 2});
|
||||
editor.execCommand('exchangePointAndMark', {count: 4});
|
||||
assert.deepEqual({row: 0, column: 2}, editor.getCursorPosition(), print(editor.getCursorPosition()));
|
||||
assert.deepEqual([{row: 0, column: 1}, {row: 0, column: 0}], editor.session.$emacsMarkRing, print(editor.session.$emacsMarkRing));
|
||||
},
|
||||
|
||||
"test: exchangePointAndMark with selection": function() {
|
||||
initEditor('foo');
|
||||
editor.pushEmacsMark({row: 0, column: 1});
|
||||
editor.pushEmacsMark({row: 0, column: 2});
|
||||
sel.setRange(Range.fromPoints({row: 0, column: 0}, {row: 0, column: 1}), true);
|
||||
editor.execCommand('exchangePointAndMark');
|
||||
assert.deepEqual({row: 0, column: 1}, editor.getCursorPosition(), print(editor.getCursorPosition()));
|
||||
assert.deepEqual([{row: 0, column: 1}, {row: 0, column: 2}], editor.session.$emacsMarkRing, print(editor.session.$emacsMarkRing));
|
||||
},
|
||||
|
||||
"test: exchangePointAndMark with multi selection": function() {
|
||||
initEditor('foo\nhello world\n123');
|
||||
var ranges = [[{row: 0, column: 0}, {row: 0, column: 3}],
|
||||
[{row: 1, column: 0}, {row: 1, column: 5}],
|
||||
[{row: 1, column: 6}, {row: 1, column: 11}]]
|
||||
ranges.forEach(function(r) {
|
||||
sel.addRange(Range.fromPoints(r[0], r[1]));
|
||||
});
|
||||
assert.equal("foo\nhello\nworld", editor.getSelectedText());
|
||||
editor.execCommand('exchangePointAndMark');
|
||||
assert.equal("foo\nhello\nworld", editor.getSelectedText());
|
||||
assert.deepEqual(pluck(ranges, 0), pluck(sel.getAllRanges(), 'cursor'), "selections dir not inverted");
|
||||
},
|
||||
|
||||
"test: exchangePointAndMark with multi cursors": function() {
|
||||
initEditor('foo\nhello world\n123');
|
||||
var ranges = [[{row: 0, column: 0}, {row: 0, column: 3}],
|
||||
[{row: 1, column: 0}, {row: 1, column: 5}],
|
||||
[{row: 1, column: 6}, {row: 1, column: 11}]];
|
||||
// move cursors to the start of each range and set a mark to its end
|
||||
// without selecting anything
|
||||
ranges.forEach(function(r) {
|
||||
editor.pushEmacsMark(r[1]);
|
||||
sel.addRange(Range.fromPoints(r[0], r[0]));
|
||||
});
|
||||
assert.deepEqual(pluck(ranges, 0), pluck(sel.getAllRanges(), 'cursor'), print(sel.getAllRanges()));
|
||||
editor.execCommand('exchangePointAndMark');
|
||||
assert.deepEqual(pluck(ranges, 1), pluck(sel.getAllRanges(), 'cursor'), "not inverted: " + print(sel.getAllRanges()));
|
||||
},
|
||||
|
||||
"test: setMark with multi cursors": function() {
|
||||
initEditor('foo\nhello world\n123');
|
||||
var positions = [{row: 0, column: 0},
|
||||
{row: 1, column: 0},
|
||||
{row: 1, column: 6}];
|
||||
positions.forEach(function(p) { sel.addRange(Range.fromPoints(p,p)); });
|
||||
editor.execCommand('setMark');
|
||||
assert.deepEqual(positions, editor.session.$emacsMarkRing, print(editor.session.$emacsMarkRing));
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -89,8 +89,16 @@ var KeyBinding = function(editor) {
|
|||
this.getKeyboardHandler = function() {
|
||||
return this.$handlers[this.$handlers.length - 1];
|
||||
};
|
||||
|
||||
this.getStatusText = function() {
|
||||
var data = this.$data;
|
||||
var editor = data.editor;
|
||||
return this.$handlers.map(function(h) {
|
||||
return h.getStatusText && h.getStatusText(editor, data) || "";
|
||||
}).filter(Boolean).join(" ");
|
||||
};
|
||||
|
||||
this.$callKeyboardHandlers = function (hashId, keyString, keyCode, e) {
|
||||
this.$callKeyboardHandlers = function(hashId, keyString, keyCode, e) {
|
||||
var toExecute;
|
||||
var success = false;
|
||||
var commands = this.$editor.commands;
|
||||
|
|
|
|||
|
|
@ -58,12 +58,13 @@ function checkModes() {
|
|||
}
|
||||
|
||||
function generateTestData() {
|
||||
var docs = jsFileList(cwd + root);
|
||||
var docRoot = root + "/demo/kitchen-sink/docs";
|
||||
var docs = fs.readdirSync(docRoot);
|
||||
var specialDocs = fs.readdirSync(cwd);
|
||||
var modes = modeList();
|
||||
|
||||
console.log("Docs:", docs);
|
||||
console.log("Modes:", modes);
|
||||
// console.log("Docs:", docs);
|
||||
// console.log("Modes:", modes);
|
||||
|
||||
docs.forEach(function(docName) {
|
||||
var p = docName.toLowerCase().split(".");
|
||||
|
|
@ -79,16 +80,19 @@ function generateTestData() {
|
|||
|
||||
var filePath = "text_" + modeName + ".txt";
|
||||
if (specialDocs.indexOf(filePath) == -1) {
|
||||
filePath = root + "/" + docName;
|
||||
filePath = docRoot + "/" + docName;
|
||||
} else {
|
||||
filePath = cwd + filePath;
|
||||
}
|
||||
|
||||
var text = fs.readFileSync(cwd + filePath, "utf8");
|
||||
var text = fs.readFileSync(filePath, "utf8");
|
||||
try {
|
||||
var Mode = require("../" + modeName).Mode;
|
||||
} catch(e) {
|
||||
console.warn("Can't load mode :" + modeName, p, e);
|
||||
return;
|
||||
}
|
||||
console.log(modeName);
|
||||
var tokenizer = new Mode().getTokenizer();
|
||||
|
||||
var state = "start";
|
||||
|
|
|
|||
267
lib/ace/mode/_test/tokens_cirru.json
Normal file
267
lib/ace/mode/_test/tokens_cirru.json
Normal file
|
|
@ -0,0 +1,267 @@
|
|||
[[
|
||||
"start",
|
||||
["comment.line.double-dash","-- https://github.com/Cirru/cirru-gopher/blob/master/code/scope.cr,"]
|
||||
],[
|
||||
"start"
|
||||
],[
|
||||
"line",
|
||||
["support.function","set"],
|
||||
["text"," "],
|
||||
["variable.parameter","a"],
|
||||
["text"," "],
|
||||
["storage.modifier","("],
|
||||
["support.function","int"],
|
||||
["text"," "],
|
||||
["constant.numeric","2"],
|
||||
["storage.modifier",")"]
|
||||
],[
|
||||
"start"
|
||||
],[
|
||||
"line",
|
||||
["support.function","print"],
|
||||
["text"," "],
|
||||
["storage.modifier","("],
|
||||
["support.function","self"],
|
||||
["storage.modifier",")"]
|
||||
],[
|
||||
"start"
|
||||
],[
|
||||
"line",
|
||||
["support.function","set"],
|
||||
["text"," "],
|
||||
["variable.parameter","c"],
|
||||
["text"," "],
|
||||
["storage.modifier","("],
|
||||
["support.function","child"],
|
||||
["storage.modifier",")"]
|
||||
],[
|
||||
"start"
|
||||
],[
|
||||
"line",
|
||||
["support.function","under"],
|
||||
["text"," "],
|
||||
["variable.parameter","c"]
|
||||
],[
|
||||
"line",
|
||||
["markup.raw"," "],
|
||||
["support.function","under"],
|
||||
["text"," "],
|
||||
["variable.parameter","parent"]
|
||||
],[
|
||||
"line",
|
||||
["markup.raw"," "],
|
||||
["support.function","print"],
|
||||
["text"," "],
|
||||
["variable.parameter","a"]
|
||||
],[
|
||||
"start"
|
||||
],[
|
||||
"line",
|
||||
["support.function","print"],
|
||||
["text"," "],
|
||||
["storage.modifier","$"],
|
||||
["text"," "],
|
||||
["support.function","get"],
|
||||
["text"," "],
|
||||
["variable.parameter","c"],
|
||||
["text"," "],
|
||||
["variable.parameter","a"]
|
||||
],[
|
||||
"start"
|
||||
],[
|
||||
"line",
|
||||
["support.function","set"],
|
||||
["text"," "],
|
||||
["variable.parameter","c"],
|
||||
["text"," "],
|
||||
["variable.parameter","x"],
|
||||
["text"," "],
|
||||
["storage.modifier","("],
|
||||
["support.function","int"],
|
||||
["text"," "],
|
||||
["constant.numeric","3"],
|
||||
["storage.modifier",")"]
|
||||
],[
|
||||
"line",
|
||||
["support.function","print"],
|
||||
["text"," "],
|
||||
["storage.modifier","$"],
|
||||
["text"," "],
|
||||
["support.function","get"],
|
||||
["text"," "],
|
||||
["variable.parameter","c"],
|
||||
["text"," "],
|
||||
["variable.parameter","x"]
|
||||
],[
|
||||
"start"
|
||||
],[
|
||||
"line",
|
||||
["support.function","set"],
|
||||
["text"," "],
|
||||
["variable.parameter","just-print"],
|
||||
["text"," "],
|
||||
["storage.modifier","$"],
|
||||
["text"," "],
|
||||
["support.function","code"]
|
||||
],[
|
||||
"line",
|
||||
["markup.raw"," "],
|
||||
["support.function","print"],
|
||||
["text"," "],
|
||||
["variable.parameter","a"]
|
||||
],[
|
||||
"start"
|
||||
],[
|
||||
"line",
|
||||
["support.function","print"],
|
||||
["text"," "],
|
||||
["variable.parameter","just-print"]
|
||||
],[
|
||||
"start"
|
||||
],[
|
||||
"line",
|
||||
["support.function","eval"],
|
||||
["text"," "],
|
||||
["storage.modifier","("],
|
||||
["support.function","self"],
|
||||
["storage.modifier",")"],
|
||||
["text"," "],
|
||||
["variable.parameter","just-print"]
|
||||
],[
|
||||
"line",
|
||||
["support.function","eval"],
|
||||
["text"," "],
|
||||
["variable.parameter","just-print"]
|
||||
],[
|
||||
"start"
|
||||
],[
|
||||
"line",
|
||||
["support.function","print"],
|
||||
["text"," "],
|
||||
["storage.modifier","("],
|
||||
["support.function","string"],
|
||||
["text"," "],
|
||||
["string.quoted.double","\"string with space\""],
|
||||
["storage.modifier",")"]
|
||||
],[
|
||||
"line",
|
||||
["support.function","print"],
|
||||
["text"," "],
|
||||
["storage.modifier","("],
|
||||
["support.function","string"],
|
||||
["text"," "],
|
||||
["string.quoted.double","\"escapes "],
|
||||
["constant.character.escape","\\n"],
|
||||
["string.quoted.double"," "],
|
||||
["constant.character.escape","\\\"\\\\"],
|
||||
["string.quoted.double","\""],
|
||||
["storage.modifier",")"]
|
||||
],[
|
||||
"start"
|
||||
],[
|
||||
"start",
|
||||
["support.function","brackets"],
|
||||
["text"," "],
|
||||
["storage.modifier","((((()))))"]
|
||||
],[
|
||||
"start"
|
||||
],[
|
||||
"line",
|
||||
["string.quoted.double","\"eval\""],
|
||||
["text"," "],
|
||||
["storage.modifier","$"],
|
||||
["text"," "],
|
||||
["support.function","string"],
|
||||
["text"," "],
|
||||
["string.quoted.double","\"eval\""]
|
||||
],[
|
||||
"start"
|
||||
],[
|
||||
"line",
|
||||
["support.function","print"],
|
||||
["text"," "],
|
||||
["storage.modifier","("],
|
||||
["support.function","add"],
|
||||
["text"," "],
|
||||
["storage.modifier","$"],
|
||||
["text"," "],
|
||||
["storage.modifier","("],
|
||||
["support.function","int"],
|
||||
["text"," "],
|
||||
["constant.numeric","1"],
|
||||
["storage.modifier",")"],
|
||||
["text"," "],
|
||||
["storage.modifier","("],
|
||||
["support.function","int"],
|
||||
["text"," "],
|
||||
["constant.numeric","2"],
|
||||
["storage.modifier","))"]
|
||||
],[
|
||||
"start"
|
||||
],[
|
||||
"start",
|
||||
["support.function","print"],
|
||||
["text"," "],
|
||||
["storage.modifier","$"],
|
||||
["text"," "],
|
||||
["support.function","unwrap"],
|
||||
["text"," "],
|
||||
["storage.modifier","$"]
|
||||
],[
|
||||
"line",
|
||||
["text"," "],
|
||||
["support.function","map"],
|
||||
["text"," "],
|
||||
["storage.modifier","("],
|
||||
["support.function","a"],
|
||||
["text"," "],
|
||||
["storage.modifier","$"],
|
||||
["text"," "],
|
||||
["support.function","int"],
|
||||
["text"," "],
|
||||
["constant.numeric","1"],
|
||||
["storage.modifier",")"],
|
||||
["text"," "],
|
||||
["storage.modifier","("],
|
||||
["support.function","b"],
|
||||
["text"," "],
|
||||
["storage.modifier","$"],
|
||||
["text"," "],
|
||||
["support.function","int"],
|
||||
["text"," "],
|
||||
["constant.numeric","2"],
|
||||
["storage.modifier",")"]
|
||||
],[
|
||||
"start"
|
||||
],[
|
||||
"line",
|
||||
["support.function","print"],
|
||||
["text"," "],
|
||||
["variable.parameter","a"]
|
||||
],[
|
||||
"line",
|
||||
["markup.raw"," "],
|
||||
["support.function","int"],
|
||||
["text"," "],
|
||||
["constant.numeric","1"]
|
||||
],[
|
||||
"line",
|
||||
["markup.raw"," "],
|
||||
["storage.modifier",","],
|
||||
["text"," "],
|
||||
["variable.parameter","b"],
|
||||
["text"," "],
|
||||
["variable.parameter","c"]
|
||||
],[
|
||||
"line",
|
||||
["markup.raw"," "],
|
||||
["support.function","int"],
|
||||
["text"," "],
|
||||
["constant.numeric","2"]
|
||||
],[
|
||||
"line",
|
||||
["markup.raw"," "],
|
||||
["storage.modifier",","],
|
||||
["text"," "],
|
||||
["variable.parameter","d"]
|
||||
]]
|
||||
141
lib/ace/mode/_test/tokens_eiffel.json
Normal file
141
lib/ace/mode/_test/tokens_eiffel.json
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
[[
|
||||
"start",
|
||||
["keyword","note"]
|
||||
],[
|
||||
"start",
|
||||
["text","\t"],
|
||||
["identifier","description"],
|
||||
["keyword.operator",":"],
|
||||
["text"," "],
|
||||
["string.quoted.double","\"Represents a person.\""]
|
||||
],[
|
||||
"start"
|
||||
],[
|
||||
"start",
|
||||
["keyword","class"]
|
||||
],[
|
||||
"start",
|
||||
["text","\t"],
|
||||
["entity.name.type","PERSON"]
|
||||
],[
|
||||
"start"
|
||||
],[
|
||||
"start",
|
||||
["keyword","create"]
|
||||
],[
|
||||
"start",
|
||||
["text","\t"],
|
||||
["identifier","make"],
|
||||
["keyword.operator",","],
|
||||
["text"," "],
|
||||
["identifier","make_unknown"]
|
||||
],[
|
||||
"start"
|
||||
],[
|
||||
"start",
|
||||
["keyword","feature"],
|
||||
["text"," "],
|
||||
["paren.lparen","{"],
|
||||
["entity.name.type","NONE"],
|
||||
["paren.rparen","}"],
|
||||
["text"," "],
|
||||
["comment.line.double-dash","-- Creation"]
|
||||
],[
|
||||
"start"
|
||||
],[
|
||||
"start",
|
||||
["text","\t"],
|
||||
["identifier","make"],
|
||||
["text"," "],
|
||||
["paren.lparen","("],
|
||||
["identifier","a_name"],
|
||||
["keyword.operator",":"],
|
||||
["text"," "],
|
||||
["keyword","like"],
|
||||
["text"," "],
|
||||
["identifier","name"],
|
||||
["paren.rparen",")"]
|
||||
],[
|
||||
"start",
|
||||
["text","\t\t\t"],
|
||||
["comment.line.double-dash","-- Create a person with `a_name' as `name'."]
|
||||
],[
|
||||
"start",
|
||||
["text","\t\t"],
|
||||
["keyword","do"]
|
||||
],[
|
||||
"start",
|
||||
["text","\t\t\t"],
|
||||
["identifier","name"],
|
||||
["text"," "],
|
||||
["keyword.operator",":="],
|
||||
["text"," "],
|
||||
["identifier","a_name"]
|
||||
],[
|
||||
"start",
|
||||
["text","\t\t"],
|
||||
["keyword","ensure"]
|
||||
],[
|
||||
"start",
|
||||
["text","\t\t\t"],
|
||||
["identifier","name"],
|
||||
["text"," "],
|
||||
["keyword.operator","="],
|
||||
["text"," "],
|
||||
["identifier","a_name"]
|
||||
],[
|
||||
"start",
|
||||
["text","\t\t"],
|
||||
["keyword","end"]
|
||||
],[
|
||||
"start"
|
||||
],[
|
||||
"start",
|
||||
["text","\t"],
|
||||
["identifier","make_unknown"]
|
||||
],[
|
||||
"start",
|
||||
["text","\t\t"],
|
||||
["keyword","do"],
|
||||
["text"," "],
|
||||
["keyword","ensure"]
|
||||
],[
|
||||
"start",
|
||||
["text","\t\t\t"],
|
||||
["identifier","name"],
|
||||
["text"," "],
|
||||
["keyword.operator","="],
|
||||
["text"," "],
|
||||
["constant.language","Void"]
|
||||
],[
|
||||
"start",
|
||||
["text","\t\t"],
|
||||
["keyword","end"]
|
||||
],[
|
||||
"start"
|
||||
],[
|
||||
"start",
|
||||
["keyword","feature"],
|
||||
["text"," "],
|
||||
["comment.line.double-dash","-- Access"]
|
||||
],[
|
||||
"start"
|
||||
],[
|
||||
"start",
|
||||
["text","\t"],
|
||||
["identifier","name"],
|
||||
["keyword.operator",":"],
|
||||
["text"," "],
|
||||
["keyword","detachable"],
|
||||
["text"," "],
|
||||
["entity.name.type","STRING"]
|
||||
],[
|
||||
"start",
|
||||
["text","\t\t\t"],
|
||||
["comment.line.double-dash","-- Full name or Void if unknown."]
|
||||
],[
|
||||
"start"
|
||||
],[
|
||||
"start",
|
||||
["keyword","end"]
|
||||
]]
|
||||
196
lib/ace/mode/_test/tokens_elixir.json
Normal file
196
lib/ace/mode/_test/tokens_elixir.json
Normal file
|
|
@ -0,0 +1,196 @@
|
|||
[[
|
||||
"start",
|
||||
["keyword.control.module.elixir","defmodule"],
|
||||
["meta.module.elixir"," "],
|
||||
["entity.name.type.module.elixir","HelloModule"],
|
||||
["text"," "],
|
||||
["keyword.control.elixir","do"]
|
||||
],[
|
||||
"comment.documentation.heredoc",
|
||||
["text"," "],
|
||||
["comment.documentation.heredoc","@moduledoc \"\"\""]
|
||||
],[
|
||||
"comment.documentation.heredoc",
|
||||
["comment.documentation.heredoc"," This is supposed to be `markdown`."]
|
||||
],[
|
||||
"comment.documentation.heredoc",
|
||||
["comment.documentation.heredoc"," __Yes__ this is [mark](http://down.format)"]
|
||||
],[
|
||||
"comment.documentation.heredoc"
|
||||
],[
|
||||
"comment.documentation.heredoc",
|
||||
["comment.documentation.heredoc"," # Truly"]
|
||||
],[
|
||||
"comment.documentation.heredoc"
|
||||
],[
|
||||
"comment.documentation.heredoc",
|
||||
["comment.documentation.heredoc"," ## marked"]
|
||||
],[
|
||||
"comment.documentation.heredoc"
|
||||
],[
|
||||
"comment.documentation.heredoc",
|
||||
["comment.documentation.heredoc"," * with lists"]
|
||||
],[
|
||||
"comment.documentation.heredoc",
|
||||
["comment.documentation.heredoc"," * more"]
|
||||
],[
|
||||
"comment.documentation.heredoc",
|
||||
["comment.documentation.heredoc"," * and more"]
|
||||
],[
|
||||
"comment.documentation.heredoc"
|
||||
],[
|
||||
"comment.documentation.heredoc",
|
||||
["comment.documentation.heredoc"," Even.with(code)"]
|
||||
],[
|
||||
"comment.documentation.heredoc",
|
||||
["comment.documentation.heredoc"," blocks |> with |> samples"]
|
||||
],[
|
||||
"comment.documentation.heredoc"
|
||||
],[
|
||||
"comment.documentation.heredoc",
|
||||
["comment.documentation.heredoc"," _Docs are first class citizens in Elixir_ (Jose Valim)"]
|
||||
],[
|
||||
"start",
|
||||
["comment.documentation.heredoc"," \"\"\""]
|
||||
],[
|
||||
"start",
|
||||
["text"," "]
|
||||
],[
|
||||
"start",
|
||||
["text"," "],
|
||||
["punctuation.definition.comment.elixir","#"],
|
||||
["comment.line.number-sign.elixir"," A \"Hello world\" function"]
|
||||
],[
|
||||
"start",
|
||||
["text"," "],
|
||||
["keyword.control.elixir","def"],
|
||||
["text"," some_fun "],
|
||||
["keyword.control.elixir","do"]
|
||||
],[
|
||||
"start",
|
||||
["text"," "],
|
||||
["variable.other.constant.elixir","IO"],
|
||||
["punctuation.separator.method.elixir","."],
|
||||
["text","puts "],
|
||||
["punctuation.definition.string.begin.elixir","\""],
|
||||
["string.quoted.double.elixir","Juhu Kinners!"],
|
||||
["punctuation.definition.string.end.elixir","\""]
|
||||
],[
|
||||
"start",
|
||||
["text"," "],
|
||||
["keyword.control.elixir","end"]
|
||||
],[
|
||||
"start",
|
||||
["text"," "],
|
||||
["punctuation.definition.comment.elixir","#"],
|
||||
["comment.line.number-sign.elixir"," A private function"]
|
||||
],[
|
||||
"start",
|
||||
["text"," "],
|
||||
["keyword.control.elixir","defp"],
|
||||
["text"," priv "],
|
||||
["keyword.control.elixir","do"]
|
||||
],[
|
||||
"punctuation.definition.string.begin.elixir7",
|
||||
["text"," is_regex "],
|
||||
["punctuation.definition.string.begin.elixir","~r\"\"\""]
|
||||
],[
|
||||
"punctuation.definition.string.begin.elixir7",
|
||||
["string.quoted.double.heredoc.elixir"," This is a regex"]
|
||||
],[
|
||||
"punctuation.definition.string.begin.elixir7",
|
||||
["string.quoted.double.heredoc.elixir"," spanning several"]
|
||||
],[
|
||||
"punctuation.definition.string.begin.elixir7",
|
||||
["string.quoted.double.heredoc.elixir"," lines."]
|
||||
],[
|
||||
"start",
|
||||
["punctuation.definition.string.end.elixir"," \"\"\""]
|
||||
],[
|
||||
"start",
|
||||
["text"," x "],
|
||||
["keyword.operator.assignment.elixir","="],
|
||||
["text"," elem"],
|
||||
["punctuation.section.function.elixir","("],
|
||||
["punctuation.section.scope.elixir","{"],
|
||||
["text"," "],
|
||||
["punctuation.definition.constant.elixir",":"],
|
||||
["constant.other.symbol.elixir","a"],
|
||||
["punctuation.separator.object.elixir",","],
|
||||
["text"," "],
|
||||
["punctuation.definition.constant.elixir",":"],
|
||||
["constant.other.symbol.elixir","b"],
|
||||
["punctuation.separator.object.elixir",","],
|
||||
["text"," "],
|
||||
["punctuation.definition.constant.elixir",":"],
|
||||
["constant.other.symbol.elixir","c"],
|
||||
["text"," "],
|
||||
["punctuation.section.scope.elixir","}"],
|
||||
["punctuation.separator.object.elixir",","],
|
||||
["text"," "],
|
||||
["constant.numeric.elixir","0"],
|
||||
["punctuation.section.function.elixir",")"],
|
||||
["text"," "],
|
||||
["punctuation.definition.comment.elixir","#"],
|
||||
["comment.line.number-sign.elixir","=> :a"]
|
||||
],[
|
||||
"start",
|
||||
["text"," "],
|
||||
["keyword.control.elixir","end"]
|
||||
],[
|
||||
"start",
|
||||
["keyword.control.elixir","end"]
|
||||
],[
|
||||
"start"
|
||||
],[
|
||||
"start",
|
||||
["text","test_fun "],
|
||||
["keyword.operator.assignment.elixir","="],
|
||||
["text"," "],
|
||||
["keyword.control.elixir","fn"],
|
||||
["punctuation.section.function.elixir","("],
|
||||
["text","x"],
|
||||
["punctuation.section.function.elixir",")"],
|
||||
["text"," "],
|
||||
["keyword.operator.arithmetic.elixir","-"],
|
||||
["keyword.operator.comparison.elixir",">"]
|
||||
],[
|
||||
"start",
|
||||
["text"," "],
|
||||
["keyword.control.elixir","cond"],
|
||||
["text"," "],
|
||||
["keyword.control.elixir","do"]
|
||||
],[
|
||||
"start",
|
||||
["text"," x "],
|
||||
["keyword.operator.comparison.elixir",">"],
|
||||
["text"," "],
|
||||
["constant.numeric.elixir","10"],
|
||||
["text"," "],
|
||||
["keyword.operator.arithmetic.elixir","-"],
|
||||
["keyword.operator.comparison.elixir",">"]
|
||||
],[
|
||||
"start",
|
||||
["text"," "],
|
||||
["punctuation.definition.constant.elixir",":"],
|
||||
["constant.other.symbol.elixir","greater_than_ten"]
|
||||
],[
|
||||
"start",
|
||||
["text"," "],
|
||||
["constant.language.elixir","true"],
|
||||
["text"," "],
|
||||
["keyword.operator.arithmetic.elixir","-"],
|
||||
["keyword.operator.comparison.elixir",">"]
|
||||
],[
|
||||
"start",
|
||||
["text"," "],
|
||||
["punctuation.definition.constant.elixir",":"],
|
||||
["constant.other.symbol.elixir","maybe_ten"]
|
||||
],[
|
||||
"start",
|
||||
["text"," "],
|
||||
["keyword.control.elixir","end"]
|
||||
],[
|
||||
"start",
|
||||
["keyword.control.elixir","end"]
|
||||
]]
|
||||
198
lib/ace/mode/_test/tokens_elm.json
Normal file
198
lib/ace/mode/_test/tokens_elm.json
Normal file
|
|
@ -0,0 +1,198 @@
|
|||
[[
|
||||
"start",
|
||||
["comment.start","{-"],
|
||||
["comment"," Ace "],
|
||||
["comment.start","{-"],
|
||||
["comment"," 4 "],
|
||||
["comment.end","-}"],
|
||||
["comment"," Elm "],
|
||||
["comment.end","-}"]
|
||||
],[
|
||||
"start",
|
||||
["constant.language","main"],
|
||||
["text"," "],
|
||||
["keyword","="],
|
||||
["text"," "],
|
||||
["identifier","lift"],
|
||||
["text"," "],
|
||||
["identifier","clock"],
|
||||
["text"," "],
|
||||
["paren.lparen","("],
|
||||
["identifier","every"],
|
||||
["text"," "],
|
||||
["identifier","second"],
|
||||
["paren.rparen",")"]
|
||||
],[
|
||||
"start"
|
||||
],[
|
||||
"start",
|
||||
["constant.language","clock"],
|
||||
["text"," "],
|
||||
["identifier","t"],
|
||||
["text"," "],
|
||||
["keyword","="],
|
||||
["text"," "],
|
||||
["identifier","collage"],
|
||||
["text"," "],
|
||||
["constant.numeric","400"],
|
||||
["text"," "],
|
||||
["constant.numeric","400"],
|
||||
["text"," "],
|
||||
["paren.lparen","["],
|
||||
["text"," "],
|
||||
["identifier","filled"],
|
||||
["text"," "],
|
||||
["identifier","lightGrey"],
|
||||
["text"," "],
|
||||
["paren.lparen","("],
|
||||
["identifier","ngon"],
|
||||
["text"," "],
|
||||
["constant.numeric","12"],
|
||||
["text"," "],
|
||||
["constant.numeric","110"],
|
||||
["paren.rparen",")"]
|
||||
],[
|
||||
"start",
|
||||
["text"," "],
|
||||
["operator.punctuation",","],
|
||||
["text"," "],
|
||||
["identifier","outlined"],
|
||||
["text"," "],
|
||||
["paren.lparen","("],
|
||||
["identifier","solid"],
|
||||
["text"," "],
|
||||
["identifier","grey"],
|
||||
["paren.rparen",")"],
|
||||
["text"," "],
|
||||
["paren.lparen","("],
|
||||
["identifier","ngon"],
|
||||
["text"," "],
|
||||
["constant.numeric","12"],
|
||||
["text"," "],
|
||||
["constant.numeric","110"],
|
||||
["paren.rparen",")"]
|
||||
],[
|
||||
"start",
|
||||
["text"," "],
|
||||
["operator.punctuation",","],
|
||||
["text"," "],
|
||||
["identifier","hand"],
|
||||
["text"," "],
|
||||
["identifier","orange"],
|
||||
["text"," "],
|
||||
["constant.numeric","100"],
|
||||
["text"," "],
|
||||
["identifier","t"]
|
||||
],[
|
||||
"start",
|
||||
["text"," "],
|
||||
["operator.punctuation",","],
|
||||
["text"," "],
|
||||
["identifier","hand"],
|
||||
["text"," "],
|
||||
["identifier","charcoal"],
|
||||
["text"," "],
|
||||
["constant.numeric","100"],
|
||||
["text"," "],
|
||||
["paren.lparen","("],
|
||||
["identifier","t"],
|
||||
["keyword.operator","/"],
|
||||
["constant.numeric","60"],
|
||||
["paren.rparen",")"]
|
||||
],[
|
||||
"start",
|
||||
["text"," "],
|
||||
["operator.punctuation",","],
|
||||
["text"," "],
|
||||
["identifier","hand"],
|
||||
["text"," "],
|
||||
["identifier","charcoal"],
|
||||
["text"," "],
|
||||
["constant.numeric","60"],
|
||||
["text"," "],
|
||||
["paren.lparen","("],
|
||||
["identifier","t"],
|
||||
["keyword.operator","/"],
|
||||
["constant.numeric","720"],
|
||||
["paren.rparen",")"],
|
||||
["text"," "],
|
||||
["paren.rparen","]"]
|
||||
],[
|
||||
"start"
|
||||
],[
|
||||
"start",
|
||||
["constant.language","hand"],
|
||||
["text"," "],
|
||||
["identifier","clr"],
|
||||
["text"," "],
|
||||
["identifier","len"],
|
||||
["text"," "],
|
||||
["identifier","time"],
|
||||
["text"," "],
|
||||
["keyword","="]
|
||||
],[
|
||||
"start",
|
||||
["text"," "],
|
||||
["keyword","let"],
|
||||
["text"," "],
|
||||
["identifier","angle"],
|
||||
["text"," "],
|
||||
["keyword","="],
|
||||
["text"," "],
|
||||
["identifier","degrees"],
|
||||
["text"," "],
|
||||
["paren.lparen","("],
|
||||
["constant.numeric","90"],
|
||||
["text"," "],
|
||||
["keyword.operator","-"],
|
||||
["text"," "],
|
||||
["constant.numeric","6"],
|
||||
["text"," "],
|
||||
["keyword.operator","*"],
|
||||
["text"," "],
|
||||
["identifier","inSeconds"],
|
||||
["text"," "],
|
||||
["identifier","time"],
|
||||
["paren.rparen",")"]
|
||||
],[
|
||||
"start",
|
||||
["text"," "],
|
||||
["keyword","in"],
|
||||
["text"," "],
|
||||
["identifier","traced"],
|
||||
["text"," "],
|
||||
["paren.lparen","("],
|
||||
["identifier","solid"],
|
||||
["text"," "],
|
||||
["identifier","clr"],
|
||||
["paren.rparen",")"],
|
||||
["text"," "],
|
||||
["keyword.operator","<|"],
|
||||
["text"," "],
|
||||
["identifier","segment"],
|
||||
["text"," "],
|
||||
["paren.lparen","("],
|
||||
["constant.numeric","0"],
|
||||
["operator.punctuation",","],
|
||||
["constant.numeric","0"],
|
||||
["paren.rparen",")"],
|
||||
["text"," "],
|
||||
["paren.lparen","("],
|
||||
["identifier","len"],
|
||||
["text"," "],
|
||||
["keyword.operator","*"],
|
||||
["text"," "],
|
||||
["identifier","cos"],
|
||||
["text"," "],
|
||||
["identifier","angle"],
|
||||
["operator.punctuation",","],
|
||||
["text"," "],
|
||||
["identifier","len"],
|
||||
["text"," "],
|
||||
["keyword.operator","*"],
|
||||
["text"," "],
|
||||
["identifier","sin"],
|
||||
["text"," "],
|
||||
["identifier","angle"],
|
||||
["paren.rparen",")"]
|
||||
]]
|
||||
296
lib/ace/mode/_test/tokens_gcode.json
Normal file
296
lib/ace/mode/_test/tokens_gcode.json
Normal file
|
|
@ -0,0 +1,296 @@
|
|||
[[
|
||||
"start",
|
||||
["identifier","O"],
|
||||
["constant.numeric","003"],
|
||||
["text"," "],
|
||||
["comment","(DIAMOND SQUARE)"]
|
||||
],[
|
||||
"start",
|
||||
["comment","N2"],
|
||||
["text"," "],
|
||||
["string","G54"],
|
||||
["text"," "],
|
||||
["string","G90"],
|
||||
["text"," "],
|
||||
["string","G49"],
|
||||
["text"," "],
|
||||
["string","G80"]
|
||||
],[
|
||||
"start",
|
||||
["comment","N3"],
|
||||
["text"," "],
|
||||
["string","M6"],
|
||||
["text"," "],
|
||||
["identifier","T"],
|
||||
["constant.numeric","1"],
|
||||
["text"," "],
|
||||
["comment","(1.ENDMILL)"]
|
||||
],[
|
||||
"start",
|
||||
["comment","N4"],
|
||||
["text"," "],
|
||||
["string","M3"],
|
||||
["text"," "],
|
||||
["identifier","S"],
|
||||
["constant.numeric","1800"]
|
||||
],[
|
||||
"start",
|
||||
["comment","N5"],
|
||||
["text"," "],
|
||||
["string","G0"],
|
||||
["text"," "],
|
||||
["identifier","X"],
|
||||
["constant.numeric","-.6"],
|
||||
["text"," "],
|
||||
["identifier","Y"],
|
||||
["constant.numeric","2.050"]
|
||||
],[
|
||||
"start",
|
||||
["comment","N6"],
|
||||
["text"," "],
|
||||
["string","G43"],
|
||||
["text"," "],
|
||||
["identifier","H"],
|
||||
["constant.numeric","1"],
|
||||
["text"," "],
|
||||
["identifier","Z"],
|
||||
["constant.numeric",".1"]
|
||||
],[
|
||||
"start",
|
||||
["comment","N7"],
|
||||
["text"," "],
|
||||
["string","G1"],
|
||||
["text"," "],
|
||||
["identifier","Z"],
|
||||
["constant.numeric","-.3"],
|
||||
["text"," "],
|
||||
["identifier","F"],
|
||||
["constant.numeric","50."]
|
||||
],[
|
||||
"start",
|
||||
["comment","N8"],
|
||||
["text"," "],
|
||||
["string","G41"],
|
||||
["text"," "],
|
||||
["identifier","D"],
|
||||
["constant.numeric","1"],
|
||||
["text"," "],
|
||||
["identifier","Y"],
|
||||
["constant.numeric","1.45"]
|
||||
],[
|
||||
"start",
|
||||
["comment","N9"],
|
||||
["text"," "],
|
||||
["string","G1"],
|
||||
["text"," "],
|
||||
["identifier","X"],
|
||||
["constant.numeric","0"],
|
||||
["text"," "],
|
||||
["identifier","F"],
|
||||
["constant.numeric","20."]
|
||||
],[
|
||||
"start",
|
||||
["comment","N10"],
|
||||
["text"," "],
|
||||
["string","G2"],
|
||||
["text"," "],
|
||||
["identifier","J"],
|
||||
["constant.numeric","-1.45"]
|
||||
],[
|
||||
"start",
|
||||
["comment","(CUTTER COMP CANCEL)"]
|
||||
],[
|
||||
"start",
|
||||
["comment","N11"],
|
||||
["text"," "],
|
||||
["string","G1"],
|
||||
["text"," "],
|
||||
["identifier","Z"],
|
||||
["constant.numeric","-.2"],
|
||||
["text"," "],
|
||||
["identifier","F"],
|
||||
["constant.numeric","50."]
|
||||
],[
|
||||
"start",
|
||||
["comment","N12"],
|
||||
["text"," "],
|
||||
["identifier","Y"],
|
||||
["constant.numeric","-.990"]
|
||||
],[
|
||||
"start",
|
||||
["comment","N13"],
|
||||
["text"," "],
|
||||
["string","G40"]
|
||||
],[
|
||||
"start",
|
||||
["comment","N14"],
|
||||
["text"," "],
|
||||
["string","G0"],
|
||||
["text"," "],
|
||||
["identifier","X"],
|
||||
["constant.numeric","-.6"],
|
||||
["text"," "],
|
||||
["identifier","Y"],
|
||||
["constant.numeric","1.590"]
|
||||
],[
|
||||
"start",
|
||||
["comment","N15"],
|
||||
["text"," "],
|
||||
["string","G0"],
|
||||
["text"," "],
|
||||
["identifier","Z"],
|
||||
["constant.numeric",".1"]
|
||||
],[
|
||||
"start",
|
||||
["comment","N16"],
|
||||
["text"," "],
|
||||
["string","M5"],
|
||||
["text"," "],
|
||||
["string","G49"],
|
||||
["text"," "],
|
||||
["string","G28"],
|
||||
["text"," "],
|
||||
["string","G91"],
|
||||
["text"," "],
|
||||
["identifier","Z"],
|
||||
["constant.numeric","0"]
|
||||
],[
|
||||
"start",
|
||||
["comment","N17"],
|
||||
["text"," "],
|
||||
["identifier","CALL"],
|
||||
["text"," "],
|
||||
["identifier","O"],
|
||||
["constant.numeric","9456"]
|
||||
],[
|
||||
"start",
|
||||
["comment","N18"],
|
||||
["text"," #"],
|
||||
["constant.numeric","500"],
|
||||
["text","="],
|
||||
["constant.numeric","0.004"]
|
||||
],[
|
||||
"start",
|
||||
["comment","N19"],
|
||||
["text"," #"],
|
||||
["constant.numeric","503"],
|
||||
["text","="],
|
||||
["paren.lparen","["],
|
||||
["text","#"],
|
||||
["constant.numeric","500"],
|
||||
["text","+#"],
|
||||
["constant.numeric","501"],
|
||||
["paren.rparen","]"]
|
||||
],[
|
||||
"start",
|
||||
["comment","N20"],
|
||||
["text"," "],
|
||||
["identifier","VC"],
|
||||
["constant.numeric","45"],
|
||||
["text","="],
|
||||
["constant.numeric","0.0006"]
|
||||
],[
|
||||
"start",
|
||||
["identifier","VS"],
|
||||
["constant.numeric","4"],
|
||||
["text","="],
|
||||
["constant.numeric","0.0007"]
|
||||
],[
|
||||
"start",
|
||||
["comment","N21"],
|
||||
["text"," "],
|
||||
["string","G90"],
|
||||
["text"," "],
|
||||
["string","G10"],
|
||||
["text"," "],
|
||||
["identifier","L"],
|
||||
["constant.numeric","20"],
|
||||
["text"," "],
|
||||
["identifier","P"],
|
||||
["constant.numeric","3"],
|
||||
["text"," "],
|
||||
["identifier","X"],
|
||||
["constant.numeric","5."],
|
||||
["identifier","Y"],
|
||||
["constant.numeric","4."],
|
||||
["text"," "],
|
||||
["identifier","Z"],
|
||||
["constant.numeric","6.567"]
|
||||
],[
|
||||
"start",
|
||||
["comment","N22"],
|
||||
["text"," "],
|
||||
["string","G0"],
|
||||
["text"," "],
|
||||
["identifier","X"],
|
||||
["constant.numeric","5000"]
|
||||
],[
|
||||
"start",
|
||||
["comment","N23"],
|
||||
["text"," "],
|
||||
["identifier","IF"],
|
||||
["text"," "],
|
||||
["paren.lparen","["],
|
||||
["text","#"],
|
||||
["constant.numeric","1"],
|
||||
["text"," "],
|
||||
["identifier","LT"],
|
||||
["text"," "],
|
||||
["constant.numeric","0.370"],
|
||||
["paren.rparen","]"],
|
||||
["text"," "],
|
||||
["identifier","GOTO"],
|
||||
["text"," "],
|
||||
["constant.numeric","49"]
|
||||
],[
|
||||
"start",
|
||||
["comment","N24"],
|
||||
["text"," "],
|
||||
["identifier","X"],
|
||||
["constant.numeric","-0.678"],
|
||||
["text"," "],
|
||||
["identifier","Y"],
|
||||
["constant.numeric","+.990"]
|
||||
],[
|
||||
"start",
|
||||
["comment","N25"],
|
||||
["text"," "],
|
||||
["string","G84.3"],
|
||||
["text"," "],
|
||||
["identifier","X"],
|
||||
["constant.numeric","-0.1"]
|
||||
],[
|
||||
"start",
|
||||
["comment","N26"],
|
||||
["text"," #"],
|
||||
["constant.numeric","4"],
|
||||
["text","=#"],
|
||||
["constant.numeric","5"],
|
||||
["text","*"],
|
||||
["identifier","COS"],
|
||||
["paren.lparen","["],
|
||||
["constant.numeric","45"],
|
||||
["paren.rparen","]"]
|
||||
],[
|
||||
"start",
|
||||
["comment","N27"],
|
||||
["text"," #"],
|
||||
["constant.numeric","4"],
|
||||
["text","=#"],
|
||||
["constant.numeric","5"],
|
||||
["text","*"],
|
||||
["identifier","SIN"],
|
||||
["paren.lparen","["],
|
||||
["constant.numeric","45"],
|
||||
["paren.rparen","]"]
|
||||
],[
|
||||
"start",
|
||||
["comment","N28"],
|
||||
["text"," "],
|
||||
["identifier","VZOFZ"],
|
||||
["text","="],
|
||||
["constant.numeric","652.9658"]
|
||||
],[
|
||||
"start",
|
||||
["text","%"]
|
||||
]]
|
||||
|
|
@ -59,9 +59,9 @@
|
|||
["meta.tag.punctuation.tag-open.xml","<"],
|
||||
["meta.tag.tag-name.xml","div"],
|
||||
["meta.tag.punctuation.tag-close.xml",">"],
|
||||
["storage.type.start","{{"],
|
||||
["support.function","{{{"],
|
||||
["variable.parameter","body"],
|
||||
["storage.type.end","}}"],
|
||||
["support.function","}}}"],
|
||||
["meta.tag.punctuation.end-tag-open.xml","</"],
|
||||
["meta.tag.tag-name.xml","div"],
|
||||
["meta.tag.punctuation.tag-close.xml",">"]
|
||||
|
|
|
|||
|
|
@ -144,7 +144,9 @@
|
|||
["text"," "],
|
||||
["support.function","link_to"],
|
||||
["text"," "],
|
||||
["string","'Show'"],
|
||||
["string.start","'"],
|
||||
["string","Show"],
|
||||
["string.end","'"],
|
||||
["text",", "],
|
||||
["identifier","book"],
|
||||
["text"," "],
|
||||
|
|
@ -162,7 +164,9 @@
|
|||
["text"," "],
|
||||
["support.function","link_to"],
|
||||
["text"," "],
|
||||
["string","'Edit'"],
|
||||
["string.start","'"],
|
||||
["string","Edit"],
|
||||
["string.end","'"],
|
||||
["text",", "],
|
||||
["identifier","edit_book_path"],
|
||||
["paren.lparen","("],
|
||||
|
|
@ -183,7 +187,9 @@
|
|||
["text"," "],
|
||||
["support.function","link_to"],
|
||||
["text"," "],
|
||||
["string","'Remove'"],
|
||||
["string.start","'"],
|
||||
["string","Remove"],
|
||||
["string.end","'"],
|
||||
["text",", "],
|
||||
["identifier","book"],
|
||||
["text",", "],
|
||||
|
|
@ -191,7 +197,9 @@
|
|||
["text"," "],
|
||||
["punctuation.separator.key-value","=>"],
|
||||
["text"," "],
|
||||
["string","'Are you sure?'"],
|
||||
["string.start","'"],
|
||||
["string","Are you sure?"],
|
||||
["string.end","'"],
|
||||
["text",", "],
|
||||
["constant.other.symbol.ruby",":method"],
|
||||
["text"," "],
|
||||
|
|
@ -239,7 +247,9 @@
|
|||
["text"," "],
|
||||
["support.function","link_to"],
|
||||
["text"," "],
|
||||
["string","'New book'"],
|
||||
["string.start","'"],
|
||||
["string","New book"],
|
||||
["string.end","'"],
|
||||
["text",", "],
|
||||
["identifier","new_book_path"],
|
||||
["text"," "],
|
||||
|
|
|
|||
49
lib/ace/mode/_test/tokens_io.json
Normal file
49
lib/ace/mode/_test/tokens_io.json
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
[[
|
||||
"start",
|
||||
["punctuation.definition.comment.io","//"],
|
||||
["comment.line.double-slash.io"," computes factorial of a number"]
|
||||
],[
|
||||
"start",
|
||||
["text","factorial "],
|
||||
["keyword.operator.io",":="],
|
||||
["text"," "],
|
||||
["support.function.io","method"],
|
||||
["text","(n,"]
|
||||
],[
|
||||
"start",
|
||||
["text"," "],
|
||||
["keyword.control.io","if"],
|
||||
["text","(n "],
|
||||
["keyword.operator.io","=="],
|
||||
["text"," "],
|
||||
["constant.numeric.io","0"],
|
||||
["text",", "],
|
||||
["keyword.control.io","return"],
|
||||
["text"," "],
|
||||
["constant.numeric.io","1"],
|
||||
["text",")"]
|
||||
],[
|
||||
"start",
|
||||
["text"," res "],
|
||||
["keyword.operator.io",":="],
|
||||
["text"," "],
|
||||
["constant.numeric.io","1"]
|
||||
],[
|
||||
"start",
|
||||
["text"," "],
|
||||
["support.class.io","Range"],
|
||||
["text"," "],
|
||||
["constant.numeric.io","1"],
|
||||
["text"," "],
|
||||
["support.function.io","to"],
|
||||
["text","(n) "],
|
||||
["keyword.control.io","foreach"],
|
||||
["text","(i, res "],
|
||||
["keyword.operator.io","="],
|
||||
["text"," res "],
|
||||
["keyword.operator.io","*"],
|
||||
["text"," i)"]
|
||||
],[
|
||||
"start",
|
||||
["text",")"]
|
||||
]]
|
||||
4
lib/ace/mode/_test/tokens_jsoniq.json
Normal file
4
lib/ace/mode/_test/tokens_jsoniq.json
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
[[
|
||||
"[\"start\"]",
|
||||
["support.function","TODO"]
|
||||
]]
|
||||
|
|
@ -1,4 +1,90 @@
|
|||
[[
|
||||
["blockComment","noQstring"],
|
||||
["comment.start","%{"]
|
||||
],[
|
||||
["blockComment","blockComment","blockComment","noQstring"],
|
||||
["comment.start"," %{"]
|
||||
],[
|
||||
["blockComment","blockComment","blockComment","noQstring"],
|
||||
["comment"," Ace Matlab demo"]
|
||||
],[
|
||||
["blockComment","noQstring"],
|
||||
["comment.end"," %}"]
|
||||
],[
|
||||
"noQstring",
|
||||
["comment.end","%}"]
|
||||
],[
|
||||
"start"
|
||||
],[
|
||||
"start",
|
||||
["identifier","TODO"]
|
||||
["keyword","classdef"],
|
||||
["text"," "],
|
||||
["identifier","hello"]
|
||||
],[
|
||||
"start",
|
||||
["text"," "],
|
||||
["support.function","methods"]
|
||||
],[
|
||||
"start",
|
||||
["text"," "],
|
||||
["keyword","function"],
|
||||
["text"," "],
|
||||
["identifier","greet"],
|
||||
["paren.lparen","("],
|
||||
["identifier","this"],
|
||||
["paren.rparen",")"]
|
||||
],[
|
||||
"start",
|
||||
["text"," "],
|
||||
["support.function","disp"],
|
||||
["paren.lparen","("],
|
||||
["string","'Hello!'"],
|
||||
["paren.rparen",")"],
|
||||
["text"," "],
|
||||
["comment","% say hi"]
|
||||
],[
|
||||
"start",
|
||||
["text"," "],
|
||||
["keyword","end"]
|
||||
],[
|
||||
"start",
|
||||
["text"," "],
|
||||
["keyword","end"]
|
||||
],[
|
||||
"start",
|
||||
["keyword","end"]
|
||||
],[
|
||||
"noQstring"
|
||||
],[
|
||||
"start",
|
||||
["comment","% transpose "]
|
||||
],[
|
||||
"qqstring",
|
||||
["identifier","a"],
|
||||
["text"," "],
|
||||
["keyword.operator","="],
|
||||
["text"," "],
|
||||
["paren.lparen","["],
|
||||
["text"," "],
|
||||
["string","'x"],
|
||||
["constant.language.escape","''"],
|
||||
["string","y'"],
|
||||
["punctuation.operator",","],
|
||||
["text"," "],
|
||||
["string","\"x"],
|
||||
["constant.language.escape","\\n"],
|
||||
["string","\\"]
|
||||
],[
|
||||
"start",
|
||||
["string"," y\""],
|
||||
["punctuation.operator",","],
|
||||
["text"," "],
|
||||
["constant.numeric","1"],
|
||||
["text","' "],
|
||||
["paren.rparen","]"],
|
||||
["text","' "],
|
||||
["keyword.operator","+"],
|
||||
["text"," "],
|
||||
["constant.numeric","2"],
|
||||
["text","'"]
|
||||
]]
|
||||
|
|
@ -145,7 +145,9 @@
|
|||
["text"," "],
|
||||
["punctuation.separator.key-value","=>"],
|
||||
["text"," "],
|
||||
["string","\"value\""],
|
||||
["string.start","\""],
|
||||
["string","value"],
|
||||
["string.end","\""],
|
||||
["paren.rparen","}"]
|
||||
],[
|
||||
"start"
|
||||
|
|
|
|||
|
|
@ -331,4 +331,4 @@
|
|||
["keyword","fi"]
|
||||
],[
|
||||
"start"
|
||||
]]
|
||||
]]
|
||||
|
|
@ -157,13 +157,12 @@
|
|||
["text.xml"," "],
|
||||
["punctuation.definition.tag.begin.soy","{"],
|
||||
["entity.name.tag.soy","param"],
|
||||
["text"," "],
|
||||
["meta.tag.param.soy"," "],
|
||||
["entity.other.attribute-name.soy","name"],
|
||||
["keyword.operator.soy",":"],
|
||||
["meta.tag.param.soy"," "],
|
||||
["variable.other.soy","$additionalName"],
|
||||
["text"," "],
|
||||
["meta.tag.param.soy","/"],
|
||||
["meta.tag.param.soy"," /"],
|
||||
["punctuation.definition.tag.end.soy","}"]
|
||||
],[
|
||||
"start",
|
||||
|
|
|
|||
44
lib/ace/mode/_test/tokens_xquery.json
Normal file
44
lib/ace/mode/_test/tokens_xquery.json
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
[[
|
||||
"[\"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\"]"
|
||||
]]
|
||||
133
lib/ace/mode/behaviour/behaviour_test.js
Normal file
133
lib/ace/mode/behaviour/behaviour_test.js
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
/* ***** 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 ***** */
|
||||
|
||||
if (typeof process !== "undefined") {
|
||||
require("amd-loader");
|
||||
}
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
require("../../multi_select");
|
||||
var assert = require("../../test/assertions");
|
||||
var Range = require("../../range").Range;
|
||||
var Editor = require("../../editor").Editor;
|
||||
var EditSession = require("../../edit_session").EditSession;
|
||||
var MockRenderer = require("../../test/mockrenderer").MockRenderer;
|
||||
var JavaScriptMode = require("../javascript").Mode;
|
||||
var editor;
|
||||
var exec = function(name, times, args) {
|
||||
do {
|
||||
editor.commands.exec(name, editor, args);
|
||||
} while(times --> 1);
|
||||
};
|
||||
var testRanges = function(str) {
|
||||
assert.equal(editor.selection.getAllRanges() + "", str + "");
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
||||
name: "ACE multi_select.js",
|
||||
|
||||
"test: cstyle": function() {
|
||||
function testValue(line) {
|
||||
assert.equal(editor.getValue(), Array(4).join(line + "\n"));
|
||||
}
|
||||
function testSelection(line, col, inc) {
|
||||
editor.selection.rangeList.ranges.forEach(function(r) {
|
||||
assert.range(r, line, col, line, col);
|
||||
line += (inc || 1);
|
||||
});
|
||||
}
|
||||
var doc = new EditSession([
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
], new JavaScriptMode());
|
||||
editor = new Editor(new MockRenderer(), doc);
|
||||
editor.setOption("behavioursEnabled", true);
|
||||
|
||||
editor.navigateFileStart();
|
||||
exec("addCursorBelow", 2);
|
||||
|
||||
exec("insertstring", 1, "if ");
|
||||
|
||||
// pairing (
|
||||
exec("insertstring", 1, "(");
|
||||
testValue("if ()");
|
||||
testSelection(0, 4);
|
||||
exec("insertstring", 1, ")");
|
||||
testValue("if ()");
|
||||
testSelection(0, 5);
|
||||
|
||||
// pairing [
|
||||
exec("gotoleft", 1);
|
||||
exec("insertstring", 1, "[");
|
||||
testValue("if ([])");
|
||||
testSelection(0, 5);
|
||||
|
||||
exec("insertstring", 1, "]");
|
||||
testValue("if ([])");
|
||||
testSelection(0, 6);
|
||||
|
||||
// test deletion
|
||||
exec("gotoleft", 1);
|
||||
exec("backspace", 1);
|
||||
testValue("if ()");
|
||||
testSelection(0, 4);
|
||||
|
||||
exec("gotolineend", 1);
|
||||
exec("insertstring", 1, "{");
|
||||
testValue("if (){}");
|
||||
testSelection(0, 6);
|
||||
|
||||
exec("insertstring", 1, "}");
|
||||
testValue("if (){}");
|
||||
testSelection(0, 7);
|
||||
|
||||
exec("gotolinestart", 1);
|
||||
exec("insertstring", 1, "(");
|
||||
testValue("(if (){}");
|
||||
exec("backspace", 1);
|
||||
|
||||
editor.setValue("");
|
||||
exec("insertstring", 1, "{");
|
||||
assert.equal(editor.getValue(), "{")
|
||||
exec("insertstring", 1, "\n");
|
||||
assert.equal(editor.getValue(), "{\n \n}")
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec();
|
||||
}
|
||||
|
|
@ -42,11 +42,11 @@ var SAFE_INSERT_BEFORE_TOKENS =
|
|||
["text", "paren.rparen", "punctuation.operator", "comment"];
|
||||
|
||||
var context;
|
||||
var contextCache = {}
|
||||
var contextCache = {};
|
||||
var initContext = function(editor) {
|
||||
var id = -1;
|
||||
if (editor.multiSelect) {
|
||||
id = editor.selection.id;
|
||||
id = editor.selection.index;
|
||||
if (contextCache.rangeCount != editor.multiSelect.rangeCount)
|
||||
contextCache = {rangeCount: editor.multiSelect.rangeCount};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* 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
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* * 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
|
||||
|
|
@ -34,6 +34,7 @@ define(function(require, exports, module) {
|
|||
var oop = require("../../lib/oop");
|
||||
var Behaviour = require("../behaviour").Behaviour;
|
||||
var TokenIterator = require("../../token_iterator").TokenIterator;
|
||||
var lang = require("../../lib/lang");
|
||||
|
||||
function is(token, type) {
|
||||
return token.type.lastIndexOf(type + ".xml") > -1;
|
||||
|
|
@ -140,29 +141,59 @@ var XmlBehaviour = function () {
|
|||
return;
|
||||
|
||||
return {
|
||||
text: '>' + '</' + element + '>',
|
||||
text: ">" + "</" + element + ">",
|
||||
selection: [1, 1]
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
this.add('autoindent', 'insertion', function (state, action, editor, session, text) {
|
||||
this.add("autoindent", "insertion", function (state, action, editor, session, text) {
|
||||
if (text == "\n") {
|
||||
var cursor = editor.getCursorPosition();
|
||||
var line = session.getLine(cursor.row);
|
||||
var rightChars = line.substring(cursor.column, cursor.column + 2);
|
||||
if (rightChars == '</') {
|
||||
var next_indent = this.$getIndent(line);
|
||||
var indent = next_indent + session.getTabString();
|
||||
var iterator = new TokenIterator(session, cursor.row, cursor.column);
|
||||
var token = iterator.getCurrentToken();
|
||||
|
||||
return {
|
||||
text: '\n' + indent + '\n' + next_indent,
|
||||
selection: [1, indent.length, 1, indent.length]
|
||||
};
|
||||
if (token && token.type.indexOf("tag-close") !== -1) {
|
||||
//get tag name
|
||||
while (token && token.type.indexOf("tag-name") === -1) {
|
||||
token = iterator.stepBackward();
|
||||
}
|
||||
|
||||
if (!token) {
|
||||
return;
|
||||
}
|
||||
|
||||
var tag = token.value;
|
||||
var row = iterator.getCurrentTokenRow();
|
||||
|
||||
//don't indent after closing tag
|
||||
token = iterator.stepBackward();
|
||||
if (!token || token.type.indexOf("end-tag") !== -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.voidElements && !this.voidElements[tag]) {
|
||||
var nextToken = session.getTokenAt(cursor.row, cursor.column+1);
|
||||
var line = session.getLine(row);
|
||||
var nextIndent = this.$getIndent(line);
|
||||
var indent = nextIndent + session.getTabString();
|
||||
|
||||
if (nextToken && nextToken.value === "</") {
|
||||
return {
|
||||
text: "\n" + indent + "\n" + nextIndent,
|
||||
selection: [1, indent.length, 1, indent.length]
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
text: "\n" + indent
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
};
|
||||
|
||||
oop.inherits(XmlBehaviour, Behaviour);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ var DockerfileHighlightRules = function() {
|
|||
if (startRules[i].token == "variable.language") {
|
||||
startRules.splice(i, 0, {
|
||||
token: "constant.language",
|
||||
regex: "(?:^(?:FROM|MAINTAINER|RUN|CMD|EXPOSE|ENV|ADD|ENTRYPOINT|VOLUME|USER|WORKDIR|ONBUILD)\\b)",
|
||||
regex: "(?:^(?:FROM|MAINTAINER|RUN|CMD|EXPOSE|ENV|ADD|ENTRYPOINT|VOLUME|USER|WORKDIR|ONBUILD|COPY)\\b)",
|
||||
caseInsensitive: true
|
||||
});
|
||||
break;
|
||||
|
|
|
|||
58
lib/ace/mode/elixir.js
Normal file
58
lib/ace/mode/elixir.js
Normal 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 ElixirHighlightRules = require("./elixir_highlight_rules").ElixirHighlightRules;
|
||||
// TODO: pick appropriate fold mode
|
||||
var FoldMode = require("./folding/coffee").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = ElixirHighlightRules;
|
||||
this.foldingRules = new FoldMode();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.lineCommentStart = "#";
|
||||
// this.blockComment = {start: ""/*"", end: ""*/""};
|
||||
// Extra logic goes here.
|
||||
this.$id = "ace/mode/elixir"
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
});
|
||||
433
lib/ace/mode/elixir_highlight_rules.js
Normal file
433
lib/ace/mode/elixir_highlight_rules.js
Normal file
|
|
@ -0,0 +1,433 @@
|
|||
/* ***** 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 https://raw.githubusercontent.com/elixir-lang/elixir-tmbundle/master/Syntaxes/Elixir.tmLanguage (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 ElixirHighlightRules = function() {
|
||||
// regexp must not have capturing parentheses. Use (?:) instead.
|
||||
// regexps are ordered -> the first match is used
|
||||
|
||||
this.$rules = { start:
|
||||
[ { token:
|
||||
[ 'meta.module.elixir',
|
||||
'keyword.control.module.elixir',
|
||||
'meta.module.elixir',
|
||||
'entity.name.type.module.elixir' ],
|
||||
regex: '^(\\s*)(defmodule)(\\s+)((?:[A-Z]\\w*\\s*\\.\\s*)*[A-Z]\\w*)' },
|
||||
{ token: 'comment.documentation.heredoc',
|
||||
regex: '@(?:module|type)?doc (?:~[a-z])?"""',
|
||||
push:
|
||||
[ { token: 'comment.documentation.heredoc',
|
||||
regex: '\\s*"""',
|
||||
next: 'pop' },
|
||||
{ include: '#interpolated_elixir' },
|
||||
{ include: '#escaped_char' },
|
||||
{ defaultToken: 'comment.documentation.heredoc' } ],
|
||||
comment: '@doc with heredocs is treated as documentation' },
|
||||
{ token: 'comment.documentation.heredoc',
|
||||
regex: '@(?:module|type)?doc ~[A-Z]"""',
|
||||
push:
|
||||
[ { token: 'comment.documentation.heredoc',
|
||||
regex: '\\s*"""',
|
||||
next: 'pop' },
|
||||
{ defaultToken: 'comment.documentation.heredoc' } ],
|
||||
comment: '@doc with heredocs is treated as documentation' },
|
||||
{ token: 'comment.documentation.heredoc',
|
||||
regex: '@(?:module|type)?doc (?:~[a-z])?\'\'\'',
|
||||
push:
|
||||
[ { token: 'comment.documentation.heredoc',
|
||||
regex: '\\s*\'\'\'',
|
||||
next: 'pop' },
|
||||
{ include: '#interpolated_elixir' },
|
||||
{ include: '#escaped_char' },
|
||||
{ defaultToken: 'comment.documentation.heredoc' } ],
|
||||
comment: '@doc with heredocs is treated as documentation' },
|
||||
{ token: 'comment.documentation.heredoc',
|
||||
regex: '@(?:module|type)?doc ~[A-Z]\'\'\'',
|
||||
push:
|
||||
[ { token: 'comment.documentation.heredoc',
|
||||
regex: '\\s*\'\'\'',
|
||||
next: 'pop' },
|
||||
{ defaultToken: 'comment.documentation.heredoc' } ],
|
||||
comment: '@doc with heredocs is treated as documentation' },
|
||||
{ token: 'comment.documentation.false',
|
||||
regex: '@(?:module|type)?doc false',
|
||||
comment: '@doc false is treated as documentation' },
|
||||
{ token: 'comment.documentation.string',
|
||||
regex: '@(?:module|type)?doc "',
|
||||
push:
|
||||
[ { token: 'comment.documentation.string',
|
||||
regex: '"',
|
||||
next: 'pop' },
|
||||
{ include: '#interpolated_elixir' },
|
||||
{ include: '#escaped_char' },
|
||||
{ defaultToken: 'comment.documentation.string' } ],
|
||||
comment: '@doc with string is treated as documentation' },
|
||||
{ token: 'keyword.control.elixir',
|
||||
regex: '\\b(?:do|end|case|bc|lc|for|if|cond|unless|try|receive|fn|defmodule|defp?|defprotocol|defimpl|defrecord|defstruct|defmacrop?|defdelegate|defcallback|defmacrocallback|defexception|defoverridable|exit|after|rescue|catch|else|raise|throw|import|require|alias|use|quote|unquote|super)\\b(?![?!])',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
originalRegex: '(?<!\\.)\\b(do|end|case|bc|lc|for|if|cond|unless|try|receive|fn|defmodule|defp?|defprotocol|defimpl|defrecord|defstruct|defmacrop?|defdelegate|defcallback|defmacrocallback|defexception|defoverridable|exit|after|rescue|catch|else|raise|throw|import|require|alias|use|quote|unquote|super)\\b(?![?!])' },
|
||||
{ token: 'keyword.operator.elixir',
|
||||
regex: '\\b(?:and|not|or|when|xor|in|inlist|inbits)\\b',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
originalRegex: '(?<!\\.)\\b(and|not|or|when|xor|in|inlist|inbits)\\b',
|
||||
comment: ' as above, just doesn\'t need a \'end\' and does a logic operation' },
|
||||
{ token: 'constant.language.elixir',
|
||||
regex: '\\b(?:nil|true|false)\\b(?![?!])' },
|
||||
{ token: 'variable.language.elixir',
|
||||
regex: '\\b__(?:CALLER|ENV|MODULE|DIR)__\\b(?![?!])' },
|
||||
{ token:
|
||||
[ 'punctuation.definition.variable.elixir',
|
||||
'variable.other.readwrite.module.elixir' ],
|
||||
regex: '(@)([a-zA-Z_]\\w*)' },
|
||||
{ token:
|
||||
[ 'punctuation.definition.variable.elixir',
|
||||
'variable.other.anonymous.elixir' ],
|
||||
regex: '(&)(\\d*)' },
|
||||
{ token: 'variable.other.constant.elixir',
|
||||
regex: '\\b[A-Z]\\w*\\b' },
|
||||
{ token: 'constant.numeric.elixir',
|
||||
regex: '\\b(?:0x[\\da-fA-F](?:_?[\\da-fA-F])*|\\d(?:_?\\d)*(?:\\.(?![^[:space:][:digit:]])(?:_?\\d)*)?(?:[eE][-+]?\\d(?:_?\\d)*)?|0b[01]+|0o[0-7]+)\\b',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
originalRegex: '\\b(0x\\h(?>_?\\h)*|\\d(?>_?\\d)*(\\.(?![^[:space:][:digit:]])(?>_?\\d)*)?([eE][-+]?\\d(?>_?\\d)*)?|0b[01]+|0o[0-7]+)\\b' },
|
||||
{ token: 'punctuation.definition.constant.elixir',
|
||||
regex: ':\'',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.constant.elixir',
|
||||
regex: '\'',
|
||||
next: 'pop' },
|
||||
{ include: '#interpolated_elixir' },
|
||||
{ include: '#escaped_char' },
|
||||
{ defaultToken: 'constant.other.symbol.single-quoted.elixir' } ] },
|
||||
{ token: 'punctuation.definition.constant.elixir',
|
||||
regex: ':"',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.constant.elixir',
|
||||
regex: '"',
|
||||
next: 'pop' },
|
||||
{ include: '#interpolated_elixir' },
|
||||
{ include: '#escaped_char' },
|
||||
{ defaultToken: 'constant.other.symbol.double-quoted.elixir' } ] },
|
||||
{ token: 'punctuation.definition.string.begin.elixir',
|
||||
regex: '(?:\'\'\')',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
originalRegex: '(?>\'\'\')',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.string.end.elixir',
|
||||
regex: '^\\s*\'\'\'',
|
||||
next: 'pop' },
|
||||
{ include: '#interpolated_elixir' },
|
||||
{ include: '#escaped_char' },
|
||||
{ defaultToken: 'support.function.variable.quoted.single.heredoc.elixir' } ],
|
||||
comment: 'Single-quoted heredocs' },
|
||||
{ token: 'punctuation.definition.string.begin.elixir',
|
||||
regex: '\'',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.string.end.elixir',
|
||||
regex: '\'',
|
||||
next: 'pop' },
|
||||
{ include: '#interpolated_elixir' },
|
||||
{ include: '#escaped_char' },
|
||||
{ defaultToken: 'support.function.variable.quoted.single.elixir' } ],
|
||||
comment: 'single quoted string (allows for interpolation)' },
|
||||
{ token: 'punctuation.definition.string.begin.elixir',
|
||||
regex: '(?:""")',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
originalRegex: '(?>""")',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.string.end.elixir',
|
||||
regex: '^\\s*"""',
|
||||
next: 'pop' },
|
||||
{ include: '#interpolated_elixir' },
|
||||
{ include: '#escaped_char' },
|
||||
{ defaultToken: 'string.quoted.double.heredoc.elixir' } ],
|
||||
comment: 'Double-quoted heredocs' },
|
||||
{ token: 'punctuation.definition.string.begin.elixir',
|
||||
regex: '"',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.string.end.elixir',
|
||||
regex: '"',
|
||||
next: 'pop' },
|
||||
{ include: '#interpolated_elixir' },
|
||||
{ include: '#escaped_char' },
|
||||
{ defaultToken: 'string.quoted.double.elixir' } ],
|
||||
comment: 'double quoted string (allows for interpolation)' },
|
||||
{ token: 'punctuation.definition.string.begin.elixir',
|
||||
regex: '~[a-z](?:""")',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
originalRegex: '~[a-z](?>""")',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.string.end.elixir',
|
||||
regex: '^\\s*"""',
|
||||
next: 'pop' },
|
||||
{ include: '#interpolated_elixir' },
|
||||
{ include: '#escaped_char' },
|
||||
{ defaultToken: 'string.quoted.double.heredoc.elixir' } ],
|
||||
comment: 'Double-quoted heredocs sigils' },
|
||||
{ token: 'punctuation.definition.string.begin.elixir',
|
||||
regex: '~[a-z]\\{',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.string.end.elixir',
|
||||
regex: '\\}[a-z]*',
|
||||
next: 'pop' },
|
||||
{ include: '#interpolated_elixir' },
|
||||
{ include: '#escaped_char' },
|
||||
{ defaultToken: 'string.interpolated.elixir' } ],
|
||||
comment: 'sigil (allow for interpolation)' },
|
||||
{ token: 'punctuation.definition.string.begin.elixir',
|
||||
regex: '~[a-z]\\[',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.string.end.elixir',
|
||||
regex: '\\][a-z]*',
|
||||
next: 'pop' },
|
||||
{ include: '#interpolated_elixir' },
|
||||
{ include: '#escaped_char' },
|
||||
{ defaultToken: 'string.interpolated.elixir' } ],
|
||||
comment: 'sigil (allow for interpolation)' },
|
||||
{ token: 'punctuation.definition.string.begin.elixir',
|
||||
regex: '~[a-z]\\<',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.string.end.elixir',
|
||||
regex: '\\>[a-z]*',
|
||||
next: 'pop' },
|
||||
{ include: '#interpolated_elixir' },
|
||||
{ include: '#escaped_char' },
|
||||
{ defaultToken: 'string.interpolated.elixir' } ],
|
||||
comment: 'sigil (allow for interpolation)' },
|
||||
{ token: 'punctuation.definition.string.begin.elixir',
|
||||
regex: '~[a-z]\\(',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.string.end.elixir',
|
||||
regex: '\\)[a-z]*',
|
||||
next: 'pop' },
|
||||
{ include: '#interpolated_elixir' },
|
||||
{ include: '#escaped_char' },
|
||||
{ defaultToken: 'string.interpolated.elixir' } ],
|
||||
comment: 'sigil (allow for interpolation)' },
|
||||
{ token: 'punctuation.definition.string.begin.elixir',
|
||||
regex: '~[a-z][^\\w]',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.string.end.elixir',
|
||||
regex: '[^\\w][a-z]*',
|
||||
next: 'pop' },
|
||||
{ include: '#interpolated_elixir' },
|
||||
{ include: '#escaped_char' },
|
||||
{ include: '#escaped_char' },
|
||||
{ defaultToken: 'string.interpolated.elixir' } ],
|
||||
comment: 'sigil (allow for interpolation)' },
|
||||
{ token: 'punctuation.definition.string.begin.elixir',
|
||||
regex: '~[A-Z](?:""")',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
originalRegex: '~[A-Z](?>""")',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.string.end.elixir',
|
||||
regex: '^\\s*"""',
|
||||
next: 'pop' },
|
||||
{ defaultToken: 'string.quoted.other.literal.upper.elixir' } ],
|
||||
comment: 'Double-quoted heredocs sigils' },
|
||||
{ token: 'punctuation.definition.string.begin.elixir',
|
||||
regex: '~[A-Z]\\{',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.string.end.elixir',
|
||||
regex: '\\}[a-z]*',
|
||||
next: 'pop' },
|
||||
{ defaultToken: 'string.quoted.other.literal.upper.elixir' } ],
|
||||
comment: 'sigil (without interpolation)' },
|
||||
{ token: 'punctuation.definition.string.begin.elixir',
|
||||
regex: '~[A-Z]\\[',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.string.end.elixir',
|
||||
regex: '\\][a-z]*',
|
||||
next: 'pop' },
|
||||
{ defaultToken: 'string.quoted.other.literal.upper.elixir' } ],
|
||||
comment: 'sigil (without interpolation)' },
|
||||
{ token: 'punctuation.definition.string.begin.elixir',
|
||||
regex: '~[A-Z]\\<',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.string.end.elixir',
|
||||
regex: '\\>[a-z]*',
|
||||
next: 'pop' },
|
||||
{ defaultToken: 'string.quoted.other.literal.upper.elixir' } ],
|
||||
comment: 'sigil (without interpolation)' },
|
||||
{ token: 'punctuation.definition.string.begin.elixir',
|
||||
regex: '~[A-Z]\\(',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.string.end.elixir',
|
||||
regex: '\\)[a-z]*',
|
||||
next: 'pop' },
|
||||
{ defaultToken: 'string.quoted.other.literal.upper.elixir' } ],
|
||||
comment: 'sigil (without interpolation)' },
|
||||
{ token: 'punctuation.definition.string.begin.elixir',
|
||||
regex: '~[A-Z][^\\w]',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.string.end.elixir',
|
||||
regex: '[^\\w][a-z]*',
|
||||
next: 'pop' },
|
||||
{ defaultToken: 'string.quoted.other.literal.upper.elixir' } ],
|
||||
comment: 'sigil (without interpolation)' },
|
||||
{ token: ['punctuation.definition.constant.elixir', 'constant.other.symbol.elixir'],
|
||||
regex: '(:)([a-zA-Z_][\\w@]*(?:[?!]|=(?![>=]))?|\\<\\>|===?|!==?|<<>>|<<<|>>>|~~~|::|<\\-|\\|>|=>|~|~=|=|/|\\\\\\\\|\\*\\*?|\\.\\.?\\.?|>=?|<=?|&&?&?|\\+\\+?|\\-\\-?|\\|\\|?\\|?|\\!|@|\\%?\\{\\}|%|\\[\\]|\\^(?:\\^\\^)?)',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
originalRegex: '(?<!:)(:)(?>[a-zA-Z_][\\w@]*(?>[?!]|=(?![>=]))?|\\<\\>|===?|!==?|<<>>|<<<|>>>|~~~|::|<\\-|\\|>|=>|~|~=|=|/|\\\\\\\\|\\*\\*?|\\.\\.?\\.?|>=?|<=?|&&?&?|\\+\\+?|\\-\\-?|\\|\\|?\\|?|\\!|@|\\%?\\{\\}|%|\\[\\]|\\^(\\^\\^)?)',
|
||||
comment: 'symbols' },
|
||||
{ token: 'punctuation.definition.constant.elixir',
|
||||
regex: '(?:[a-zA-Z_][\\w@]*(?:[?!])?):(?!:)',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
originalRegex: '(?>[a-zA-Z_][\\w@]*(?>[?!])?)(:)(?!:)',
|
||||
comment: 'symbols' },
|
||||
{ token:
|
||||
[ 'punctuation.definition.comment.elixir',
|
||||
'comment.line.number-sign.elixir' ],
|
||||
regex: '(#)(.*)' },
|
||||
{ token: 'constant.numeric.elixir',
|
||||
regex: '\\?(?:\\\\(?:x[\\da-fA-F]{1,2}(?![\\da-fA-F])\\b|[^xMC])|[^\\s\\\\])',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
originalRegex: '(?<!\\w)\\?(\\\\(x\\h{1,2}(?!\\h)\\b|[^xMC])|[^\\s\\\\])',
|
||||
comment: '\n\t\t\tmatches questionmark-letters.\n\n\t\t\texamples (1st alternation = hex):\n\t\t\t?\\x1 ?\\x61\n\n\t\t\texamples (2rd alternation = escaped):\n\t\t\t?\\n ?\\b\n\n\t\t\texamples (3rd alternation = normal):\n\t\t\t?a ?A ?0 \n\t\t\t?* ?" ?( \n\t\t\t?. ?#\n\t\t\t\n\t\t\tthe negative lookbehind prevents against matching\n\t\t\tp(42.tainted?)\n\t\t\t' },
|
||||
/* { token: 'punctuation.separator.variable.elixir',
|
||||
regex: '(?<=\\{|do|\\{\\s|do\\s)\\|',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
originalRegex: '(?<=\\{|do|\\{\\s|do\\s)(\\|)',
|
||||
push:
|
||||
[ { token: 'punctuation.separator.variable.elixir',
|
||||
regex: '\\|',
|
||||
next: 'pop' },
|
||||
{ token: 'variable.other.block.elixir',
|
||||
regex: '[_a-zA-Z][_a-zA-Z0-9]*' },
|
||||
{ token: 'punctuation.separator.variable.elixir', regex: ',' } ] },*/
|
||||
{ token: 'keyword.operator.assignment.augmented.elixir',
|
||||
regex: '\\+=|\\-=|\\|\\|=|~=|&&=' },
|
||||
{ token: 'keyword.operator.comparison.elixir',
|
||||
regex: '===?|!==?|<=?|>=?' },
|
||||
{ token: 'keyword.operator.bitwise.elixir',
|
||||
regex: '\\|{3}|&{3}|\\^{3}|<{3}|>{3}|~{3}' },
|
||||
{ token: 'keyword.operator.logical.elixir',
|
||||
regex: '!+|\\bnot\\b|&&|\\band\\b|\\|\\||\\bor\\b|\\bxor\\b',
|
||||
originalRegex: '(?<=[ \\t])!+|\\bnot\\b|&&|\\band\\b|\\|\\||\\bor\\b|\\bxor\\b' },
|
||||
{ token: 'keyword.operator.arithmetic.elixir',
|
||||
regex: '\\*|\\+|\\-|/' },
|
||||
{ token: 'keyword.operator.other.elixir',
|
||||
regex: '\\||\\+\\+|\\-\\-|\\*\\*|\\\\\\\\|\\<\\-|\\<\\>|\\<\\<|\\>\\>|\\:\\:|\\.\\.|\\|>|~|=>' },
|
||||
{ token: 'keyword.operator.assignment.elixir', regex: '=' },
|
||||
{ token: 'punctuation.separator.other.elixir', regex: ':' },
|
||||
{ token: 'punctuation.separator.statement.elixir',
|
||||
regex: '\\;' },
|
||||
{ token: 'punctuation.separator.object.elixir', regex: ',' },
|
||||
{ token: 'punctuation.separator.method.elixir', regex: '\\.' },
|
||||
{ token: 'punctuation.section.scope.elixir', regex: '\\{|\\}' },
|
||||
{ token: 'punctuation.section.array.elixir', regex: '\\[|\\]' },
|
||||
{ token: 'punctuation.section.function.elixir',
|
||||
regex: '\\(|\\)' } ],
|
||||
'#escaped_char':
|
||||
[ { token: 'constant.character.escape.elixir',
|
||||
regex: '\\\\(?:x[\\da-fA-F]{1,2}|.)' } ],
|
||||
'#interpolated_elixir':
|
||||
[ { token:
|
||||
[ 'source.elixir.embedded.source',
|
||||
'source.elixir.embedded.source.empty' ],
|
||||
regex: '(#\\{)(\\})' },
|
||||
{ todo:
|
||||
{ token: 'punctuation.section.embedded.elixir',
|
||||
regex: '#\\{',
|
||||
push:
|
||||
[ { token: 'punctuation.section.embedded.elixir',
|
||||
regex: '\\}',
|
||||
next: 'pop' },
|
||||
{ include: '#nest_curly_and_self' },
|
||||
{ include: '$self' },
|
||||
{ defaultToken: 'source.elixir.embedded.source' } ] } } ],
|
||||
'#nest_curly_and_self':
|
||||
[ { token: 'punctuation.section.scope.elixir',
|
||||
regex: '\\{',
|
||||
push:
|
||||
[ { token: 'punctuation.section.scope.elixir',
|
||||
regex: '\\}',
|
||||
next: 'pop' },
|
||||
{ include: '#nest_curly_and_self' } ] },
|
||||
{ include: '$self' } ],
|
||||
'#regex_sub':
|
||||
[ { include: '#interpolated_elixir' },
|
||||
{ include: '#escaped_char' },
|
||||
{ token:
|
||||
[ 'punctuation.definition.arbitrary-repitition.elixir',
|
||||
'string.regexp.arbitrary-repitition.elixir',
|
||||
'string.regexp.arbitrary-repitition.elixir',
|
||||
'punctuation.definition.arbitrary-repitition.elixir' ],
|
||||
regex: '(\\{)(\\d+)((?:,\\d+)?)(\\})' },
|
||||
{ token: 'punctuation.definition.character-class.elixir',
|
||||
regex: '\\[(?:\\^?\\])?',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.character-class.elixir',
|
||||
regex: '\\]',
|
||||
next: 'pop' },
|
||||
{ include: '#escaped_char' },
|
||||
{ defaultToken: 'string.regexp.character-class.elixir' } ] },
|
||||
{ token: 'punctuation.definition.group.elixir',
|
||||
regex: '\\(',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.group.elixir',
|
||||
regex: '\\)',
|
||||
next: 'pop' },
|
||||
{ include: '#regex_sub' },
|
||||
{ defaultToken: 'string.regexp.group.elixir' } ] },
|
||||
{ token:
|
||||
[ 'punctuation.definition.comment.elixir',
|
||||
'comment.line.number-sign.elixir' ],
|
||||
regex: '(?:^|\\s)(#)(\\s[[a-zA-Z0-9,. \\t?!-][^\\x00-\\x7F]]*$)',
|
||||
originalRegex: '(?<=^|\\s)(#)\\s[[a-zA-Z0-9,. \\t?!-][^\\x{00}-\\x{7F}]]*$',
|
||||
comment: 'We are restrictive in what we allow to go after the comment character to avoid false positives, since the availability of comments depend on regexp flags.' } ] }
|
||||
|
||||
this.normalizeRules();
|
||||
};
|
||||
|
||||
ElixirHighlightRules.metaData = { comment: 'Textmate bundle for Elixir Programming Language.',
|
||||
fileTypes: [ 'ex', 'exs' ],
|
||||
firstLineMatch: '^#!/.*\\belixir',
|
||||
foldingStartMarker: '(after|else|catch|rescue|\\-\\>|\\{|\\[|do)\\s*$',
|
||||
foldingStopMarker: '^\\s*((\\}|\\]|after|else|catch|rescue)\\s*$|end\\b)',
|
||||
keyEquivalent: '^~E',
|
||||
name: 'Elixir',
|
||||
scopeName: 'source.elixir' }
|
||||
|
||||
|
||||
oop.inherits(ElixirHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.ElixirHighlightRules = ElixirHighlightRules;
|
||||
});
|
||||
|
|
@ -21,7 +21,7 @@ var Mode = function() {
|
|||
oop.inherits(Mode, HtmlMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.blockComment = {start: "{!--", end: "--}"};
|
||||
this.$id = "ace/mode/handlebars";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ var HandlebarsHighlightRules = function() {
|
|||
var hbs = {
|
||||
regex : "(?={{)",
|
||||
push : "handlebars"
|
||||
}
|
||||
};
|
||||
for (var key in this.$rules) {
|
||||
this.$rules[key].unshift(hbs);
|
||||
}
|
||||
|
|
@ -40,22 +40,22 @@ var HandlebarsHighlightRules = function() {
|
|||
defaultToken : "comment"
|
||||
}]
|
||||
}, {
|
||||
token : "storage.type.start", // begin section
|
||||
regex : "{{[#\\^/&]?",
|
||||
token : "support.function", // unescaped variable
|
||||
regex : "{{{",
|
||||
push : [{
|
||||
token : "storage.type.end",
|
||||
regex : "}}",
|
||||
token : "support.function",
|
||||
regex : "}}}",
|
||||
next : pop2
|
||||
}, {
|
||||
token : "variable.parameter",
|
||||
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*"
|
||||
}]
|
||||
}, {
|
||||
token : "support.function", // unescaped variable
|
||||
regex : "{{{",
|
||||
token : "storage.type.start", // begin section
|
||||
regex : "{{[#\\^/&]?",
|
||||
push : [{
|
||||
token : "support.function",
|
||||
regex : "}}}",
|
||||
token : "storage.type.end",
|
||||
regex : "}}",
|
||||
next : pop2
|
||||
}, {
|
||||
token : "variable.parameter",
|
||||
|
|
|
|||
|
|
@ -48,7 +48,8 @@ oop.inherits(JsonWorker, Mirror);
|
|||
var value = this.doc.getValue();
|
||||
|
||||
try {
|
||||
var result = parse(value);
|
||||
if (value)
|
||||
parse(value);
|
||||
} catch (e) {
|
||||
var pos = this.doc.indexToPosition(e.at-1);
|
||||
this.sender.emit("error", {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ var Range = require("../range").Range;
|
|||
var XQueryBehaviour = require("./behaviour/xquery").XQueryBehaviour;
|
||||
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
||||
var Anchor = require("../anchor").Anchor;
|
||||
var LanguageTools = require("../ext/language_tools");
|
||||
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new JSONiqLexer();
|
||||
|
|
@ -52,14 +51,16 @@ oop.inherits(Mode, TextMode);
|
|||
|
||||
(function() {
|
||||
|
||||
LanguageTools.addCompleter({
|
||||
this.completer = {
|
||||
getCompletions: function(editor, session, pos, prefix, callback) {
|
||||
if (!session.$worker)
|
||||
return callback();
|
||||
session.$worker.emit("complete", { data: { pos: pos, prefix: prefix } });
|
||||
session.$worker.on("complete", function(e){
|
||||
callback(null, e.data);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
var indent = this.$getIndent(line);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* 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
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* * 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
|
||||
|
|
@ -41,37 +41,20 @@ var WorkerClient = require("../worker/worker_client").WorkerClient;
|
|||
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
||||
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
||||
var unicode = require("../unicode");
|
||||
var HtmlMode = require("./html").Mode;
|
||||
var JavaScriptMode = require("./javascript").Mode;
|
||||
var CssMode = require("./css").Mode;
|
||||
|
||||
var Mode = function(opts) {
|
||||
this.inlinePhp = opts && opts.inline;
|
||||
var HighlightRules = this.inlinePhp ? PhpLangHighlightRules : PhpHighlightRules;
|
||||
this.HighlightRules = HighlightRules;
|
||||
var PhpMode = function(opts) {
|
||||
this.HighlightRules = PhpLangHighlightRules;
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
this.$behaviour = new CstyleBehaviour();
|
||||
this.foldingRules = new CStyleFoldMode();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
oop.inherits(PhpMode, TextMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.tokenRe = new RegExp("^["
|
||||
+ unicode.packages.L
|
||||
+ unicode.packages.Mn + unicode.packages.Mc
|
||||
+ unicode.packages.Nd
|
||||
+ unicode.packages.Pc + "\_]+", "g"
|
||||
);
|
||||
|
||||
this.nonTokenRe = new RegExp("^(?:[^"
|
||||
+ unicode.packages.L
|
||||
+ unicode.packages.Mn + unicode.packages.Mc
|
||||
+ unicode.packages.Nd
|
||||
+ unicode.packages.Pc + "\_]|\s])+", "g"
|
||||
);
|
||||
|
||||
|
||||
this.lineCommentStart = ["//", "#"];
|
||||
this.blockComment = {start: "/*", end: "*/"};
|
||||
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
var indent = this.$getIndent(line);
|
||||
|
||||
|
|
@ -79,18 +62,17 @@ oop.inherits(Mode, TextMode);
|
|||
var tokens = tokenizedLine.tokens;
|
||||
var endState = tokenizedLine.state;
|
||||
|
||||
|
||||
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
||||
return indent;
|
||||
}
|
||||
|
||||
if (state == "php-start") {
|
||||
if (state == "start") {
|
||||
var match = line.match(/^.*[\{\(\[\:]\s*$/);
|
||||
if (match) {
|
||||
indent += tab;
|
||||
}
|
||||
} else if (state == "php-doc-start") {
|
||||
if (endState != "php-doc-start") {
|
||||
} else if (state == "doc-start") {
|
||||
if (endState != "doc-start") {
|
||||
return "";
|
||||
}
|
||||
var match = line.match(/^\s*(\/?)\*/);
|
||||
|
|
@ -113,10 +95,48 @@ oop.inherits(Mode, TextMode);
|
|||
this.$outdent.autoOutdent(doc, row);
|
||||
};
|
||||
|
||||
this.$id = "ace/mode/php-inline";
|
||||
}).call(PhpMode.prototype);
|
||||
|
||||
var Mode = function(opts) {
|
||||
if (opts && opts.inline) {
|
||||
PhpMode.call(this);
|
||||
return;
|
||||
}
|
||||
HtmlMode.call(this);
|
||||
this.HighlightRules = PhpHighlightRules;
|
||||
this.createModeDelegates({
|
||||
"js-": JavaScriptMode,
|
||||
"css-": CssMode,
|
||||
"php-": PhpMode
|
||||
});
|
||||
};
|
||||
oop.inherits(Mode, HtmlMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.tokenRe = new RegExp("^["
|
||||
+ unicode.packages.L
|
||||
+ unicode.packages.Mn + unicode.packages.Mc
|
||||
+ unicode.packages.Nd
|
||||
+ unicode.packages.Pc + "\_]+", "g"
|
||||
);
|
||||
|
||||
this.nonTokenRe = new RegExp("^(?:[^"
|
||||
+ unicode.packages.L
|
||||
+ unicode.packages.Mn + unicode.packages.Mc
|
||||
+ unicode.packages.Nd
|
||||
+ unicode.packages.Pc + "\_]|\s])+", "g"
|
||||
);
|
||||
|
||||
|
||||
this.lineCommentStart = ["//", "#"];
|
||||
this.blockComment = {start: "/*", end: "*/"};
|
||||
|
||||
this.createWorker = function(session) {
|
||||
var worker = new WorkerClient(["ace"], "ace/mode/php_worker", "PhpWorker");
|
||||
worker.attachToDocument(session.getDocument());
|
||||
|
||||
|
||||
if (this.inlinePhp)
|
||||
worker.call("setOptions", [{inline: true}]);
|
||||
|
||||
|
|
|
|||
65
lib/ace/mode/php_test.js
Normal file
65
lib/ace/mode/php_test.js
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
/* ***** 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 ***** */
|
||||
|
||||
if (typeof process !== "undefined") {
|
||||
require("amd-loader");
|
||||
}
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var EditSession = require("../edit_session").EditSession;
|
||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||
var Mode = require("./php").Mode;
|
||||
var assert = require("../test/assertions");
|
||||
|
||||
module.exports = {
|
||||
"test: inline mode" : function() {
|
||||
var mode = new Mode();
|
||||
var tokenizer = mode.getTokenizer();
|
||||
var tokens = tokenizer.getLineTokens("'juhu kinners' ?> html <? 'php'", "start").tokens;
|
||||
assert.equal("string", tokens[tokens.length - 1].type);
|
||||
assert.notEqual("string", tokens[0].type);
|
||||
assert.equal(tokens.length, 4);
|
||||
|
||||
mode = new Mode({inline: true});
|
||||
tokenizer = mode.getTokenizer();
|
||||
tokens = tokenizer.getLineTokens("'juhu kinners' ?> html <? 'php'", "start").tokens;
|
||||
assert.equal("string", tokens[0].type);
|
||||
assert.equal("string", tokens[tokens.length - 1].type);
|
||||
assert.equal(tokens.length, 9);
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec()
|
||||
}
|
||||
|
|
@ -141,9 +141,71 @@ var RubyHighlightRules = function() {
|
|||
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
|
||||
},
|
||||
|
||||
qString,
|
||||
qqString,
|
||||
tString,
|
||||
[{
|
||||
regex: "[{}]", onMatch: function(val, state, stack) {
|
||||
this.next = val == "{" ? this.nextState : "";
|
||||
if (val == "{" && stack.length) {
|
||||
stack.unshift("start", state);
|
||||
return "paren.lparen";
|
||||
}
|
||||
if (val == "}" && stack.length) {
|
||||
stack.shift();
|
||||
this.next = stack.shift();
|
||||
if (this.next.indexOf("string") != -1)
|
||||
return "paren.end";
|
||||
}
|
||||
return val == "{" ? "paren.lparen" : "paren.rparen";
|
||||
},
|
||||
nextState: "start"
|
||||
}, {
|
||||
token : "string.start",
|
||||
regex : /"/,
|
||||
push : [{
|
||||
token : "constant.language.escape",
|
||||
regex : /\\(?:[nsrtvfbae'"\\]|c.|C-.|M-.(?:\\C-.)?|[0-7]{3}|x[\da-fA-F]{2}|u[\da-fA-F]{4})/
|
||||
}, {
|
||||
token : "paren.start",
|
||||
regex : /\#{/,
|
||||
push : "start"
|
||||
}, {
|
||||
token : "string.end",
|
||||
regex : /"/,
|
||||
next : "pop"
|
||||
}, {
|
||||
defaultToken: "string"
|
||||
}]
|
||||
}, {
|
||||
token : "string.start",
|
||||
regex : /`/,
|
||||
push : [{
|
||||
token : "constant.language.escape",
|
||||
regex : /\\(?:[nsrtvfbae'"\\]|c.|C-.|M-.(?:\\C-.)?|[0-7]{3}|x[\da-fA-F]{2}|u[\da-fA-F]{4})/
|
||||
}, {
|
||||
token : "paren.start",
|
||||
regex : /\#{/,
|
||||
push : "start"
|
||||
}, {
|
||||
token : "string.end",
|
||||
regex : /`/,
|
||||
next : "pop"
|
||||
}, {
|
||||
defaultToken: "string"
|
||||
}]
|
||||
}, {
|
||||
token : "string.start",
|
||||
regex : /'/,
|
||||
push : [{
|
||||
token : "constant.language.escape",
|
||||
regex : /\\['\\]/
|
||||
}, {
|
||||
token : "string.end",
|
||||
regex : /'/,
|
||||
next : "pop"
|
||||
}, {
|
||||
defaultToken: "string"
|
||||
}]
|
||||
}],
|
||||
// TODO: add support for %[QqxWwrs][{[(]
|
||||
|
||||
{
|
||||
token : "text", // namespaces aren't symbols
|
||||
|
|
|
|||
|
|
@ -127,10 +127,14 @@ var RustHighlightRules = function() {
|
|||
regex: '$',
|
||||
next: 'pop' },
|
||||
{ defaultToken: 'comment.line.double-dash.source.rust' } ] },
|
||||
{ token: 'comment.block.source.rust',
|
||||
{ token: 'comment.start.block.source.rust',
|
||||
regex: '/\\*',
|
||||
stateName: 'comment',
|
||||
push:
|
||||
[ { token: 'comment.block.source.rust',
|
||||
[ { token: 'comment.start.block.source.rust',
|
||||
regex: '/\\*',
|
||||
push: 'comment' },
|
||||
{ token: 'comment.end.block.source.rust',
|
||||
regex: '\\*/',
|
||||
next: 'pop' },
|
||||
{ defaultToken: 'comment.block.source.rust' } ] } ],
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ var SoyTemplateHighlightRules = function() {
|
|||
[ 'entity.other.attribute-name.soy',
|
||||
'text',
|
||||
'keyword.operator.soy' ],
|
||||
regex: '\\b([\\w]*)(\\s*)((?::)?)' },
|
||||
regex: '\\b([\\w]+)(\\s*)((?::)?)' },
|
||||
{ defaultToken: 'meta.tag.param.soy' } ] } ],
|
||||
'#primitive':
|
||||
[ { token: 'constant.language.soy',
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ var Range = require("../range").Range;
|
|||
var XQueryBehaviour = require("./behaviour/xquery").XQueryBehaviour;
|
||||
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
||||
var Anchor = require("../anchor").Anchor;
|
||||
var LanguageTools = require("../ext/language_tools");
|
||||
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new XQueryLexer();
|
||||
|
|
@ -51,14 +50,16 @@ oop.inherits(Mode, TextMode);
|
|||
|
||||
(function() {
|
||||
|
||||
LanguageTools.addCompleter({
|
||||
this.completer = {
|
||||
getCompletions: function(editor, session, pos, prefix, callback) {
|
||||
if (!session.$worker)
|
||||
return callback();
|
||||
session.$worker.emit("complete", { data: { pos: pos, prefix: prefix } });
|
||||
session.$worker.on("complete", function(e){
|
||||
callback(null, e.data);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
var indent = this.$getIndent(line);
|
||||
|
|
|
|||
|
|
@ -36,23 +36,23 @@ if (typeof process !== "undefined") {
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var EditSession = require("./edit_session").EditSession;
|
||||
var Editor = require("./editor").Editor;
|
||||
var MockRenderer = require("./test/mockrenderer").MockRenderer;
|
||||
var Range = require("./range").Range;
|
||||
require("./multi_select");
|
||||
var assert = require("./test/assertions");
|
||||
var MultiSelect = require("./multi_select").MultiSelect;
|
||||
var Range = require("./range").Range;
|
||||
var Editor = require("./editor").Editor;
|
||||
var EditSession = require("./edit_session").EditSession;
|
||||
var MockRenderer = require("./test/mockrenderer").MockRenderer;
|
||||
var UndoManager = require("./undomanager").UndoManager;
|
||||
|
||||
var editor;
|
||||
var exec = function(name, times, args) {
|
||||
do {
|
||||
editor.commands.exec(name, editor, args);
|
||||
} while(times --> 1)
|
||||
} while(times --> 1);
|
||||
};
|
||||
var testRanges = function(str) {
|
||||
assert.equal(editor.selection.getAllRanges() + "", str + "");
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
||||
|
|
@ -65,7 +65,6 @@ module.exports = {
|
|||
" wtt.w"
|
||||
]);
|
||||
editor = new Editor(new MockRenderer(), doc);
|
||||
MultiSelect(editor);
|
||||
|
||||
editor.navigateFileEnd();
|
||||
exec("selectMoreBefore", 3);
|
||||
|
|
@ -92,7 +91,6 @@ module.exports = {
|
|||
" wtt.we"
|
||||
]);
|
||||
editor = new Editor(new MockRenderer(), doc);
|
||||
MultiSelect(editor);
|
||||
|
||||
editor.selectMoreLines(1);
|
||||
testRanges("Range: [0/0] -> [0/0],Range: [1/0] -> [1/0]");
|
||||
|
|
@ -115,9 +113,8 @@ module.exports = {
|
|||
" wtt.w"
|
||||
]);
|
||||
editor = new Editor(new MockRenderer(), doc);
|
||||
MultiSelect(editor);
|
||||
|
||||
editor.selectMoreLines(1)
|
||||
editor.selectMoreLines(1);
|
||||
testRanges("Range: [0/0] -> [0/0],Range: [1/0] -> [1/0]");
|
||||
assert.ok(editor.inMultiSelectMode);
|
||||
|
||||
|
|
@ -136,7 +133,6 @@ module.exports = {
|
|||
" wtt.w"
|
||||
]);
|
||||
editor = new Editor(new MockRenderer(), doc);
|
||||
MultiSelect(editor);
|
||||
var selection = editor.selection;
|
||||
|
||||
var range1 = new Range(0, 2, 0, 4);
|
||||
|
|
@ -160,7 +156,6 @@ module.exports = {
|
|||
"test: onPaste in command with multiselect": function() {
|
||||
var doc = new EditSession(["l1", "l2"]);
|
||||
editor = new Editor(new MockRenderer(), doc);
|
||||
MultiSelect(editor);
|
||||
editor.commands.addCommand({
|
||||
name: 'insertfoo',
|
||||
exec: function(ed) { ed.onPaste('foo'); },
|
||||
|
|
@ -169,7 +164,7 @@ module.exports = {
|
|||
var selection = editor.selection;
|
||||
var range1 = new Range(0,2,0,2);
|
||||
var range2 = new Range(1,2,1,2);
|
||||
selection.fromOrientedRange(range1)
|
||||
selection.fromOrientedRange(range1);
|
||||
selection.addRange(range2);
|
||||
editor.execCommand('insertfoo');
|
||||
assert.equal('l1foo\nl2foo', editor.getValue());
|
||||
|
|
@ -178,14 +173,13 @@ module.exports = {
|
|||
"test multiselect fromJSON/toJSON": function() {
|
||||
var doc = new EditSession(["l1", "l2"]);
|
||||
editor = new Editor(new MockRenderer(), doc);
|
||||
MultiSelect(editor);
|
||||
var selection = editor.selection;
|
||||
|
||||
var before = selection.toJSON();
|
||||
|
||||
var range1 = new Range(0,2,0,2);
|
||||
var range2 = new Range(1,2,1,2);
|
||||
selection.fromOrientedRange(range1)
|
||||
selection.fromOrientedRange(range1);
|
||||
selection.addRange(range2);
|
||||
|
||||
var after = selection.toJSON();
|
||||
|
|
@ -217,5 +211,5 @@ module.exports = {
|
|||
});
|
||||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec()
|
||||
require("asyncjs").test.testcase(module.exports).exec();
|
||||
}
|
||||
|
|
|
|||
7
lib/ace/snippets/dockerfile.js
Normal file
7
lib/ace/snippets/dockerfile.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./dockerfile.snippets");
|
||||
exports.scope = "dockerfile";
|
||||
|
||||
});
|
||||
0
lib/ace/snippets/dockerfile.snippets
Normal file
0
lib/ace/snippets/dockerfile.snippets
Normal file
7
lib/ace/snippets/dummy.js
Normal file
7
lib/ace/snippets/dummy.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./.snippets");
|
||||
exports.scope = "";
|
||||
|
||||
});
|
||||
7
lib/ace/snippets/dummy_syntax.js
Normal file
7
lib/ace/snippets/dummy_syntax.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./.snippets");
|
||||
exports.scope = "";
|
||||
|
||||
});
|
||||
7
lib/ace/snippets/eiffel.js
Normal file
7
lib/ace/snippets/eiffel.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./eiffel.snippets");
|
||||
exports.scope = "eiffel";
|
||||
|
||||
});
|
||||
0
lib/ace/snippets/eiffel.snippets
Normal file
0
lib/ace/snippets/eiffel.snippets
Normal file
7
lib/ace/snippets/elixir.js
Normal file
7
lib/ace/snippets/elixir.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./.snippets");
|
||||
exports.scope = "";
|
||||
|
||||
});
|
||||
0
lib/ace/snippets/elixir.snippets
Normal file
0
lib/ace/snippets/elixir.snippets
Normal file
7
lib/ace/snippets/elm.js
Normal file
7
lib/ace/snippets/elm.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./elm.snippets");
|
||||
exports.scope = "elm";
|
||||
|
||||
});
|
||||
0
lib/ace/snippets/elm.snippets
Normal file
0
lib/ace/snippets/elm.snippets
Normal file
0
lib/ace/snippets/io.snippets
Normal file
0
lib/ace/snippets/io.snippets
Normal file
0
lib/ace/snippets/vala.snippets
Normal file
0
lib/ace/snippets/vala.snippets
Normal file
|
|
@ -43,6 +43,7 @@ var testNames = [
|
|||
"ace/mode/folding/pythonic_test",
|
||||
"ace/mode/folding/xml_test",
|
||||
"ace/mode/folding/coffee_test",
|
||||
"ace/mode/behaviour/behaviour_test",
|
||||
"ace/multi_select_test",
|
||||
"ace/mouse/mouse_handler_test",
|
||||
"ace/occur_test",
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ define(function(require, exports, module) {
|
|||
"use strict";
|
||||
|
||||
// tokenizing lines longer than this makes editor very slow
|
||||
var MAX_TOKEN_COUNT = 1000;
|
||||
var MAX_TOKEN_COUNT = 2000;
|
||||
/**
|
||||
* This class takes a set of highlighting rules, and creates a tokenizer out of them. For more information, see [the wiki on extending highlighters](https://github.com/ajaxorg/ace/wiki/Creating-or-Extending-an-Edit-Mode#wiki-extendingTheHighlighter).
|
||||
* @class Tokenizer
|
||||
|
|
@ -77,9 +77,11 @@ var Tokenizer = function(rules) {
|
|||
if (rule.token.length == 1 || matchcount == 1) {
|
||||
rule.token = rule.token[0];
|
||||
} else if (matchcount - 1 != rule.token.length) {
|
||||
throw new Error("number of classes and regexp groups in '" +
|
||||
rule.token + "'\n'" + rule.regex + "' doesn't match\n"
|
||||
+ (matchcount - 1) + "!=" + rule.token.length);
|
||||
this.reportError("number of classes and regexp groups doesn't match", {
|
||||
rule: rule,
|
||||
groupCount: matchcount - 1
|
||||
});
|
||||
rule.token = rule.token[0];
|
||||
} else {
|
||||
rule.tokenArray = rule.token;
|
||||
rule.token = null;
|
||||
|
|
@ -240,6 +242,7 @@ var Tokenizer = function(rules) {
|
|||
|
||||
var match, tokens = [];
|
||||
var lastIndex = 0;
|
||||
var matchAttempts = 0;
|
||||
|
||||
var token = {type: null, value: ""};
|
||||
|
||||
|
|
@ -280,7 +283,7 @@ var Tokenizer = function(rules) {
|
|||
|
||||
state = this.states[currentState];
|
||||
if (!state) {
|
||||
window.console && console.error && console.error(currentState, "doesn't exist");
|
||||
this.reportError("state doesn't exist", currentState);
|
||||
currentState = "start";
|
||||
state = this.states[currentState];
|
||||
}
|
||||
|
|
@ -293,7 +296,7 @@ var Tokenizer = function(rules) {
|
|||
}
|
||||
|
||||
if (value) {
|
||||
if (typeof type == "string") {
|
||||
if (typeof type === "string") {
|
||||
if ((!rule || rule.merge !== false) && token.type === type) {
|
||||
token.value += value;
|
||||
} else {
|
||||
|
|
@ -315,7 +318,13 @@ var Tokenizer = function(rules) {
|
|||
|
||||
lastIndex = index;
|
||||
|
||||
if (tokens.length > MAX_TOKEN_COUNT) {
|
||||
if (matchAttempts++ > MAX_TOKEN_COUNT) {
|
||||
if (matchAttempts > 2 * line.length) {
|
||||
this.reportError("infinite loop with in ace tokenizer", {
|
||||
startState: startState,
|
||||
line: line
|
||||
});
|
||||
}
|
||||
// chrome doens't show contents of text nodes with very long text
|
||||
while (lastIndex < line.length) {
|
||||
if (token.type)
|
||||
|
|
@ -343,7 +352,14 @@ var Tokenizer = function(rules) {
|
|||
state : stack.length ? stack : currentState
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
this.reportError = function(msg, data) {
|
||||
var e = new Error(msg);
|
||||
e.data = data;
|
||||
if (typeof console == "object" && console.error)
|
||||
console.error(e);
|
||||
setTimeout(function() { throw e; });
|
||||
};
|
||||
}).call(Tokenizer.prototype);
|
||||
|
||||
exports.Tokenizer = Tokenizer;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
if (typeof process !== "undefined") {
|
||||
require("amd-loader");
|
||||
require("amd-loader");
|
||||
}
|
||||
|
||||
define(function(require, exports, module) {
|
||||
|
|
@ -59,7 +59,35 @@ module.exports = {
|
|||
var t = new Tokenizer({});
|
||||
var re = t.removeCapturingGroups("(ax(by))[()]");
|
||||
assert.equal(re, "(?:ax(?:by))[()]");
|
||||
}
|
||||
},
|
||||
|
||||
"test: broken highlight rules": function() {
|
||||
var t = new Tokenizer({
|
||||
start: [{
|
||||
token: 's',
|
||||
regex: '&&&|^^^'
|
||||
}, {
|
||||
defaultToken: "def"
|
||||
}],
|
||||
state1: [{
|
||||
token: 'x',
|
||||
regex: /\b([\w]*)(\s*)((?::)?)/
|
||||
}]
|
||||
});
|
||||
var errorReports = 0;
|
||||
t.reportError = function() { errorReports++; };
|
||||
var tokens = t.getLineTokens("x|", "start");
|
||||
assert.deepEqual(tokens, {
|
||||
tokens: [{value: 'x|', type: 'overflow'}],
|
||||
state: 'start'
|
||||
});
|
||||
var tokens = t.getLineTokens("x|", "state1");
|
||||
assert.deepEqual(tokens, {
|
||||
tokens: [{value: 'x', type: 'x'}, {value: '|', type: 'overflow'}],
|
||||
state: 'start'
|
||||
});
|
||||
assert.equal(errorReports, 2);
|
||||
},
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -958,23 +958,24 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.scrollBarH.setVisible(horizScroll);
|
||||
}
|
||||
|
||||
if (!this.$maxLines && this.$scrollPastEnd) {
|
||||
maxHeight += (size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd;
|
||||
}
|
||||
|
||||
var vScroll = !hideScrollbars && (this.$vScrollBarAlwaysVisible ||
|
||||
size.scrollerHeight - maxHeight < 0);
|
||||
var vScrollChanged = this.$vScroll !== vScroll;
|
||||
if (vScrollChanged) {
|
||||
this.$vScroll = vScroll;
|
||||
this.scrollBarV.setVisible(vScroll);
|
||||
}
|
||||
var scrollPastEnd = !this.$maxLines && this.$scrollPastEnd
|
||||
? (size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd
|
||||
: 0;
|
||||
maxHeight += scrollPastEnd;
|
||||
|
||||
this.session.setScrollTop(Math.max(-this.scrollMargin.top,
|
||||
Math.min(this.scrollTop, maxHeight - size.scrollerHeight + this.scrollMargin.bottom)));
|
||||
|
||||
this.session.setScrollLeft(Math.max(-this.scrollMargin.left, Math.min(this.scrollLeft,
|
||||
longestLine + 2 * this.$padding - size.scrollerWidth + this.scrollMargin.right)));
|
||||
|
||||
var vScroll = !hideScrollbars && (this.$vScrollBarAlwaysVisible ||
|
||||
size.scrollerHeight - maxHeight + scrollPastEnd < 0 || this.scrollTop);
|
||||
var vScrollChanged = this.$vScroll !== vScroll;
|
||||
if (vScrollChanged) {
|
||||
this.$vScroll = vScroll;
|
||||
this.scrollBarV.setVisible(vScroll);
|
||||
}
|
||||
|
||||
var lineCount = Math.ceil(minHeight / this.lineHeight) - 1;
|
||||
var firstRow = Math.max(0, Math.round((this.scrollTop - offset) / this.lineHeight));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue