Merge pull request #1189 from ajaxorg/feature/codecomplete
Implement basic code completion
This commit is contained in:
commit
fa13f377e1
215 changed files with 1725 additions and 78 deletions
|
|
@ -155,7 +155,7 @@ function ace() {
|
|||
source: ACE_HOME + "/ChangeLog.txt",
|
||||
dest: BUILD_DIR + "/ChangeLog.txt"
|
||||
});
|
||||
|
||||
|
||||
return project;
|
||||
}
|
||||
|
||||
|
|
@ -211,7 +211,7 @@ function demo(project) {
|
|||
});
|
||||
|
||||
var demo = copy.createDataObject();
|
||||
|
||||
|
||||
project.assumeAllFilesLoaded();
|
||||
copy({
|
||||
source: [{
|
||||
|
|
@ -309,7 +309,7 @@ var buildAce = function(options) {
|
|||
for(var key in defaults)
|
||||
if (!options.hasOwnProperty(key))
|
||||
options[key] = defaults[key];
|
||||
|
||||
|
||||
generateThemesModule(options.themes);
|
||||
|
||||
addSuffix(options);
|
||||
|
|
@ -334,7 +334,7 @@ var buildAce = function(options) {
|
|||
filter: [ copy.filter.moduleDefines ],
|
||||
dest: ace
|
||||
});
|
||||
|
||||
|
||||
if (options.coreOnly)
|
||||
return project;
|
||||
|
||||
|
|
@ -349,6 +349,7 @@ var buildAce = function(options) {
|
|||
project.assumeAllFilesLoaded();
|
||||
options.modes.forEach(function(mode) {
|
||||
console.log("mode " + mode);
|
||||
addSnippetFile(mode, project, targetDir, options);
|
||||
copy({
|
||||
source: [{
|
||||
project: cloneProject(project),
|
||||
|
|
@ -441,7 +442,7 @@ var buildAce = function(options) {
|
|||
dest: BUILD_DIR + '/ace-min.js'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return project;
|
||||
};
|
||||
|
||||
|
|
@ -460,6 +461,30 @@ var buildAce = function(fn) {
|
|||
}
|
||||
}(buildAce);
|
||||
|
||||
var addSnippetFile = function(modeName, project, targetDir, options) {
|
||||
var snippetFilePath = ACE_HOME + "/lib/ace/snippets/" + modeName;
|
||||
if (!fs.existsSync(snippetFilePath + ".js")) {
|
||||
copy({
|
||||
source: ACE_HOME + "/tool/snippets.tmpl.js",
|
||||
dest: snippetFilePath + ".js",
|
||||
filter: [
|
||||
function(t) {return t.replace(/%modeName%/g, modeName);}
|
||||
]
|
||||
});
|
||||
}
|
||||
if (!fs.existsSync(snippetFilePath + ".snippets")) {
|
||||
fs.writeFileSync(snippetFilePath + ".snippets", "")
|
||||
}
|
||||
copy({
|
||||
source: [{
|
||||
project: cloneProject(project),
|
||||
require: [ 'ace/snippets/' + modeName ]
|
||||
}],
|
||||
filter: getWriteFilters(options, "mode"),
|
||||
dest: targetDir + "/snippets/" + modeName + ".js"
|
||||
});
|
||||
}
|
||||
|
||||
var textModules = {}
|
||||
var detectTextModules = function(input, source) {
|
||||
if (!source)
|
||||
|
|
@ -469,7 +494,7 @@ var detectTextModules = function(input, source) {
|
|||
input = input.toString();
|
||||
|
||||
var module = source.isLocation ? source.path : source;
|
||||
|
||||
|
||||
input = input.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
||||
if (/\.css$/.test(module)) {
|
||||
// remove unnecessary whitespace from css
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ env.editor.commands.addCommands([{
|
|||
bindKey: "ctrl+enter",
|
||||
exec: function(editor) {
|
||||
try {
|
||||
var r = eval(editor.getCopyText()||editor.getValue());
|
||||
var r = window.eval(editor.getCopyText()||editor.getValue());
|
||||
} catch(e) {
|
||||
r = e;
|
||||
}
|
||||
|
|
@ -196,7 +196,7 @@ commands.addCommand({
|
|||
exec: function() {alert("Fake Save File");}
|
||||
});
|
||||
|
||||
var keybindings = {
|
||||
var keybindings = {
|
||||
ace: null, // Null = use "default" keymapping
|
||||
vim: require("ace/keyboard/vim").handler,
|
||||
emacs: "ace/keyboard/emacs",
|
||||
|
|
@ -431,7 +431,7 @@ bindDropdown("split", function(value) {
|
|||
sp.setSplits(1);
|
||||
} else {
|
||||
var newEditor = (sp.getSplits() == 1);
|
||||
sp.setOrientation(value == "below" ? sp.BELOW : sp.BESIDE);
|
||||
sp.setOrientation(value == "below" ? sp.BELOW : sp.BESIDE);
|
||||
sp.setSplits(2);
|
||||
|
||||
if (newEditor) {
|
||||
|
|
@ -517,17 +517,9 @@ net.loadScript("https://rawgithub.com/nightwing/emmet-core/master/emmet.js", fun
|
|||
})
|
||||
|
||||
|
||||
require("ace/placeholder").PlaceHolder;
|
||||
// require("ace/placeholder").PlaceHolder;
|
||||
|
||||
var snippetManager = require("ace/snippets").snippetManager
|
||||
var jsSnippets = require("ace/snippets/javascript");
|
||||
window.snippetManager = snippetManager
|
||||
saveSnippets()
|
||||
|
||||
function saveSnippets() {
|
||||
jsSnippets.snippets = snippetManager.parseSnippetFile(jsSnippets.snippetText);
|
||||
snippetManager.register(jsSnippets.snippets, "javascript")
|
||||
}
|
||||
var snippetManager = require("ace/snippets").snippetManager;
|
||||
|
||||
env.editSnippets = function() {
|
||||
var sp = env.split;
|
||||
|
|
@ -538,25 +530,32 @@ env.editSnippets = function() {
|
|||
sp.setSplits(1);
|
||||
sp.setSplits(2);
|
||||
sp.setOrientation(sp.BESIDE);
|
||||
var editor = sp.$editors[1]
|
||||
if (!env.snippetSession) {
|
||||
var file = jsSnippets.snippetText;
|
||||
env.snippetSession = doclist.initDoc(file, "", {});
|
||||
env.snippetSession.setMode("ace/mode/tmsnippet");
|
||||
env.snippetSession.setUseSoftTabs(false);
|
||||
var editor = sp.$editors[1];
|
||||
var id = sp.$editors[0].session.$mode.$id || "";
|
||||
var m = snippetManager.files[id];
|
||||
if (!doclist["snippets/" + id]) {
|
||||
var text = m.snippetText;
|
||||
var s = doclist.initDoc(text, "", {});
|
||||
s.setMode("ace/mode/snippets");
|
||||
doclist["snippets/" + id] = s
|
||||
}
|
||||
editor.on("blur", function() {
|
||||
jsSnippets.snippetText = editor.getValue();
|
||||
saveSnippets();
|
||||
m.snippetText = editor.getValue();
|
||||
snippetManager.unregister(m.snippets);
|
||||
m.snippets = snippetManager.parseSnippetFile(m.snippetText);
|
||||
snippetManager.register(m.snippets);
|
||||
})
|
||||
editor.setSession(env.snippetSession, 1);
|
||||
sp.$editors[0].once("changeMode", function() {
|
||||
sp.setSplits(1);
|
||||
})
|
||||
editor.setSession(doclist["snippets/" + id], 1);
|
||||
editor.focus();
|
||||
}
|
||||
|
||||
ace.commands.bindKey("Tab", function(editor) {
|
||||
var success = snippetManager.expandWithTab(editor);
|
||||
if (!success)
|
||||
editor.execCommand("indent");
|
||||
require("ace/ext/language_tools");
|
||||
env.editor.setOptions({
|
||||
enableBasicAutocompletion: true,
|
||||
enableSnippets: true
|
||||
})
|
||||
|
||||
});
|
||||
|
|
|
|||
267
lib/ace/autocomplete.js
Normal file
267
lib/ace/autocomplete.js
Normal file
|
|
@ -0,0 +1,267 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2012, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var HashHandler = require("./keyboard/hash_handler").HashHandler;
|
||||
var AcePopup = require("./autocomplete/popup").AcePopup;
|
||||
var util = require("./autocomplete/util");
|
||||
var event = require("./lib/event");
|
||||
var lang = require("./lib/lang");
|
||||
|
||||
var Autocomplete = function() {
|
||||
this.keyboardHandler = new HashHandler();
|
||||
this.keyboardHandler.bindKeys(this.commands);
|
||||
|
||||
this.blurListener = this.blurListener.bind(this);
|
||||
this.changeListener = this.changeListener.bind(this);
|
||||
this.mousedownListener = this.mousedownListener.bind(this);
|
||||
this.mousewheelListener = this.mousewheelListener.bind(this);
|
||||
|
||||
this.changeTimer = lang.delayedCall(function() {
|
||||
this.updateCompletions(true);
|
||||
}.bind(this))
|
||||
};
|
||||
|
||||
(function() {
|
||||
this.$init = function() {
|
||||
this.popup = new AcePopup(document.body || document.documentElement);
|
||||
this.popup.on("click", function(e) {
|
||||
this.insertMatch();
|
||||
e.stop();
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
this.openPopup = function(editor, keepPopupPosition) {
|
||||
if (!this.popup)
|
||||
this.$init();
|
||||
|
||||
this.popup.setData(this.completions.filtered);
|
||||
|
||||
var renderer = editor.renderer;
|
||||
if (!keepPopupPosition) {
|
||||
var lineHeight = renderer.layerConfig.lineHeight;
|
||||
var pos = renderer.$cursorLayer.getPixelPosition(null, true);
|
||||
var rect = editor.container.getBoundingClientRect();
|
||||
pos.top += rect.top - renderer.layerConfig.offset;
|
||||
pos.left += rect.left;
|
||||
pos.left += renderer.$gutterLayer.gutterWidth;
|
||||
|
||||
this.popup.show(pos, lineHeight);
|
||||
}
|
||||
renderer.updateText();
|
||||
};
|
||||
|
||||
this.detach = function() {
|
||||
this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler);
|
||||
this.editor.removeEventListener("changeSelection", this.changeListener);
|
||||
this.editor.removeEventListener("blur", this.changeListener);
|
||||
this.editor.removeEventListener("mousedown", this.changeListener);
|
||||
this.changeTimer.cancel();
|
||||
|
||||
if (this.popup)
|
||||
this.popup.hide();
|
||||
|
||||
this.activated = false;
|
||||
};
|
||||
|
||||
this.changeListener = function(e) {
|
||||
if (this.activated)
|
||||
this.changeTimer.schedule();
|
||||
else
|
||||
this.detach();
|
||||
};
|
||||
|
||||
this.blurListener = function() {
|
||||
if (document.activeElement != this.editor.textInput.getElement())
|
||||
this.detach();
|
||||
};
|
||||
|
||||
this.mousedownListener = function(e) {
|
||||
this.detach();
|
||||
};
|
||||
|
||||
this.mousewheelListener = function(e) {
|
||||
this.detach();
|
||||
};
|
||||
|
||||
this.goTo = function(where) {
|
||||
var row = this.popup.getRow();
|
||||
var max = this.popup.session.getLength() - 1;
|
||||
|
||||
switch(where) {
|
||||
case "up": row = row <= 0 ? max : row - 1; break;
|
||||
case "down": row = row >= max ? 0 : row + 1; break;
|
||||
case "start": row = 0; break;
|
||||
case "end": row = max; break;
|
||||
}
|
||||
|
||||
this.popup.setRow(row);
|
||||
};
|
||||
|
||||
this.insertMatch = function(data) {
|
||||
this.detach();
|
||||
if (!data)
|
||||
data = this.popup.getData(this.popup.getRow());
|
||||
if (!data)
|
||||
return false;
|
||||
if (data.completer && data.completer.insertMatch) {
|
||||
data.completer.insertMatch(this.editor);
|
||||
} else {
|
||||
if (data.value)
|
||||
data = data.value;
|
||||
if (this.completions.filterText)
|
||||
this.editor.removeWordLeft();
|
||||
this.editor.insert(data);
|
||||
}
|
||||
};
|
||||
|
||||
this.commands = {
|
||||
"Up": function(editor) { editor.completer.goTo("up"); },
|
||||
"Down": function(editor) { editor.completer.goTo("down"); },
|
||||
"Ctrl-Up|Ctrl-Home": function(editor) { editor.completer.goTo("start"); },
|
||||
"Ctrl-Down|Ctrl-End": function(editor) { editor.completer.goTo("end"); },
|
||||
|
||||
"Esc": function(editor) { editor.completer.detach(); },
|
||||
"Space": function(editor) { editor.completer.detach(); editor.insert(" ");},
|
||||
"Return": function(editor) { editor.completer.insertMatch(); },
|
||||
"Shift-Return": function(editor) { editor.completer.insertMatch(true); },
|
||||
"Tab": function(editor) { editor.completer.insertMatch(); },
|
||||
|
||||
"PageUp": function(editor) { editor.completer.popup.gotoPageDown(); },
|
||||
"PageDown": function(editor) { editor.completer.popup.gotoPageUp(); }
|
||||
};
|
||||
|
||||
this.gatherCompletions = function(editor, callback) {
|
||||
var session = editor.getSession();
|
||||
var pos = editor.getCursorPosition();
|
||||
|
||||
var line = session.getLine(pos.row);
|
||||
var prefix = util.retrievePrecedingIdentifier(line, pos.column);
|
||||
|
||||
var matches = [];
|
||||
util.parForEach(editor.completers, function(completer, next) {
|
||||
completer.getCompletions(session, pos, prefix, function(err, results) {
|
||||
if (!err)
|
||||
matches = matches.concat(results);
|
||||
next();
|
||||
});
|
||||
}, function() {
|
||||
matches.sort(function(a, b) {
|
||||
return b.score - a.score;
|
||||
});
|
||||
callback(null, {
|
||||
prefix: prefix,
|
||||
matches: matches
|
||||
});
|
||||
});
|
||||
return true;
|
||||
};
|
||||
|
||||
this.showPopup = function(editor) {
|
||||
if (this.editor)
|
||||
this.detach();
|
||||
|
||||
this.activated = true;
|
||||
|
||||
this.editor = editor;
|
||||
if (editor.completer != this) {
|
||||
if (editor.completer)
|
||||
editor.completer.detach();
|
||||
editor.completer = this;
|
||||
}
|
||||
|
||||
editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
|
||||
editor.on("changeSelection", this.changeListener);
|
||||
editor.on("blur", this.blurListener);
|
||||
editor.on("mousedown", this.mousedownListener);
|
||||
this.updateCompletions();
|
||||
}
|
||||
|
||||
this.updateCompletions = function(keepPopupPosition) {
|
||||
this.gatherCompletions(this.editor, function(err, results) {
|
||||
var matches = results && results.matches;
|
||||
if (!matches || !matches.length)
|
||||
return this.detach();
|
||||
// TODO reenable this when we have proper change tracking
|
||||
// if (matches.length == 1)
|
||||
// return this.insertMatch(matches[0]);
|
||||
|
||||
this.completions = new FilteredList(matches);
|
||||
this.completions.setFilter(results.prefix);
|
||||
this.openPopup(this.editor, keepPopupPosition);
|
||||
this.popup.setHighlight(results.prefix);
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
this.cancelContextMenu = function() {
|
||||
var stop = function(e) {
|
||||
this.editor.off("nativecontextmenu", stop);
|
||||
if (e && e.domEvent)
|
||||
event.stopEvent(e.domEvent);
|
||||
}.bind(this);
|
||||
setTimeout(stop, 10);
|
||||
this.editor.on("nativecontextmenu", stop);
|
||||
};
|
||||
|
||||
}).call(Autocomplete.prototype);
|
||||
|
||||
Autocomplete.startCommand = {
|
||||
name: "startAutocomplete",
|
||||
exec: function(editor) {
|
||||
if (!editor.completer)
|
||||
editor.completer = new Autocomplete();
|
||||
editor.completer.showPopup(editor);
|
||||
// needed for firefox on mac
|
||||
editor.completer.cancelContextMenu();
|
||||
},
|
||||
bindKey: "Ctrl-Space|Shift-Space|Alt-Space"
|
||||
};
|
||||
Autocomplete.addTo = function(editor) {
|
||||
editor.commands.addCommand(Autocomplete.startCommand);
|
||||
};
|
||||
|
||||
var FilteredList = function(array, mutateData) {
|
||||
this.all = array;
|
||||
this.filtered = array.concat();
|
||||
this.filterText = "";
|
||||
};
|
||||
(function(){
|
||||
this.setFilter = function(str) {
|
||||
this.filterText = str;
|
||||
};
|
||||
|
||||
}).call(FilteredList.prototype);
|
||||
|
||||
exports.Autocomplete = Autocomplete;
|
||||
exports.FilteredList = FilteredList;
|
||||
|
||||
});
|
||||
261
lib/ace/autocomplete/popup.js
Normal file
261
lib/ace/autocomplete/popup.js
Normal file
|
|
@ -0,0 +1,261 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2012, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var EditSession = require("../edit_session").EditSession;
|
||||
var Renderer = require("../virtual_renderer").VirtualRenderer;
|
||||
var Editor = require("../editor").Editor;
|
||||
var Range = require("../range").Range;
|
||||
var event = require("../lib/event");
|
||||
var lang = require("../lib/lang");
|
||||
var dom = require("../lib/dom");
|
||||
|
||||
var $singleLineEditor = function(el) {
|
||||
var renderer = new Renderer(el);
|
||||
|
||||
renderer.maxLines = 4;
|
||||
renderer.$computeLayerConfigWithScroll = renderer.$computeLayerConfig;
|
||||
renderer.scrollBar.orginalWidth = renderer.scrollBar.getWidth();
|
||||
renderer.$computeLayerConfig = function() {
|
||||
var height = this.session.getScreenLength() * this.lineHeight;
|
||||
var maxHeight = this.maxLines * this.lineHeight;
|
||||
var desiredHeight = Math.max(this.lineHeight, Math.min(maxHeight, height));
|
||||
var vScroll = height > maxHeight;
|
||||
if (desiredHeight != this.desiredHeight || vScroll != this.$vScroll) {
|
||||
if (vScroll != this.$vScroll) {
|
||||
if (vScroll) {
|
||||
this.scrollBar.element.style.display = "";
|
||||
this.scrollBar.width = this.scrollBar.orginalWidth;
|
||||
|
||||
height = maxHeight;
|
||||
this.scrollTop = height - this.maxLines * this.lineHeight;
|
||||
} else {
|
||||
this.scrollBar.element.style.display = "none";
|
||||
this.scrollBar.width = 0;
|
||||
}
|
||||
|
||||
this.$size.height = 0;
|
||||
this.$size.width = 0;
|
||||
|
||||
this.$vScroll = vScroll;
|
||||
}
|
||||
|
||||
this.container.style.height = desiredHeight + "px";
|
||||
this.onResize();
|
||||
this.$loop.changes = 0;
|
||||
this.desiredHeight = desiredHeight;
|
||||
this.scroller.style.overflowX = "hidden";
|
||||
}
|
||||
return renderer.$computeLayerConfigWithScroll();
|
||||
};
|
||||
|
||||
var editor = new Editor(renderer);
|
||||
|
||||
editor.setHighlightActiveLine(false);
|
||||
editor.setShowPrintMargin(false);
|
||||
editor.renderer.setShowGutter(false);
|
||||
editor.renderer.setHighlightGutterLine(false);
|
||||
|
||||
editor.$mouseHandler.$focusWaitTimout = 0;
|
||||
|
||||
return editor;
|
||||
};
|
||||
|
||||
var AcePopup = function(parentNode) {
|
||||
var el = dom.createElement("div");
|
||||
var popup = new $singleLineEditor(el);
|
||||
|
||||
if (parentNode)
|
||||
parentNode.appendChild(el);
|
||||
el.style.display = "none";
|
||||
popup.renderer.content.style.cursor = "default";
|
||||
popup.renderer.setStyle("ace_autocomplete");
|
||||
|
||||
var noop = function(){};
|
||||
|
||||
popup.focus = noop;
|
||||
popup.$isFocused = true;
|
||||
|
||||
popup.renderer.$cursorLayer.restartTimer = noop;
|
||||
popup.renderer.$cursorLayer.element.style.opacity = 0;
|
||||
|
||||
popup.renderer.maxLines = 8;
|
||||
popup.renderer.$keepTextAreaAtCursor = false;
|
||||
|
||||
popup.setHighlightActiveLine(true);
|
||||
// set default highlight color
|
||||
popup.session.highlight("");
|
||||
popup.session.$searchHighlight.clazz = "ace_highlight-marker";
|
||||
|
||||
popup.on("mousedown", function(e) {
|
||||
var pos = e.getDocumentPosition();
|
||||
popup.moveCursorToPosition(pos);
|
||||
popup.selection.clearSelection();
|
||||
e.stop();
|
||||
});
|
||||
|
||||
var hoverMarker = new Range(-1,0,-1,Infinity);
|
||||
hoverMarker.id = popup.session.addMarker(hoverMarker, "ace_line-hover", "fullLine");
|
||||
popup.on("mousemove", function(e) {
|
||||
//if (popup.lastOpened)
|
||||
var row = e.getDocumentPosition().row;
|
||||
hoverMarker.start.row = hoverMarker.end.row = row;
|
||||
popup.session._emit("changeBackMarker");
|
||||
});
|
||||
var hideHoverMarker = function() {
|
||||
hoverMarker.start.row = hoverMarker.end.row = -1;
|
||||
popup.session._emit("changeBackMarker");
|
||||
};
|
||||
event.addListener(popup.container, "mouseout", hideHoverMarker);
|
||||
popup.on("hide", hideHoverMarker);
|
||||
popup.on("changeSelection", hideHoverMarker);
|
||||
popup.on("mousewheel", function(e) {
|
||||
setTimeout(function() {
|
||||
popup._signal("mousemove", e);
|
||||
});
|
||||
});
|
||||
|
||||
popup.session.doc.getLength = function() {
|
||||
return popup.data.length;
|
||||
};
|
||||
popup.session.doc.getLine = function(i) {
|
||||
var data = popup.data[i];
|
||||
if (typeof data == "string")
|
||||
return data;
|
||||
return (data && data.value) || "";
|
||||
};
|
||||
|
||||
var bgTokenizer = popup.session.bgTokenizer;
|
||||
bgTokenizer.$tokenizeRow = function(i) {
|
||||
var data = popup.data[i];
|
||||
var tokens = [];
|
||||
if (!data)
|
||||
return tokens;
|
||||
if (typeof data == "string")
|
||||
data = {value: data};
|
||||
|
||||
tokens.push({type: data.className || "", value: data.value});
|
||||
if (data.meta) {
|
||||
var maxW = popup.renderer.$size.scrollerWidth / popup.renderer.layerConfig.characterWidth;
|
||||
if (data.meta.length + data.value.length < maxW - 2)
|
||||
tokens.push({type: "rightAlignedText", value: data.meta});
|
||||
}
|
||||
return tokens;
|
||||
};
|
||||
bgTokenizer.$updateOnChange = noop;
|
||||
|
||||
popup.session.$computeWidth = function() {
|
||||
return this.screenWidth = 0;
|
||||
}
|
||||
|
||||
// public
|
||||
popup.data = [];
|
||||
popup.setData = function(list) {
|
||||
popup.data = list || [];
|
||||
popup.setValue(lang.stringRepeat("\n", list.length), -1);
|
||||
};
|
||||
popup.getData = function(row) {
|
||||
return popup.data[row];
|
||||
};
|
||||
|
||||
popup.getRow = function() {
|
||||
var line = this.getCursorPosition().row;
|
||||
if (line == 0 && !this.getHighlightActiveLine())
|
||||
line = -1;
|
||||
return line;
|
||||
};
|
||||
popup.setRow = function(line) {
|
||||
popup.setHighlightActiveLine(line != -1);
|
||||
popup.selection.clearSelection();
|
||||
popup.moveCursorTo(line, 0 || 0);
|
||||
};
|
||||
|
||||
popup.setHighlight = function(re) {
|
||||
popup.session.highlight(re);
|
||||
popup.session._emit("changeFrontMarker");
|
||||
};
|
||||
|
||||
popup.hide = function() {
|
||||
this.container.style.display = "none";
|
||||
this._signal("hide");
|
||||
};
|
||||
popup.show = function(pos, lineHeight) {
|
||||
var el = this.container;
|
||||
if (pos.top > window.innerHeight / 2 + lineHeight) {
|
||||
el.style.top = "";
|
||||
el.style.bottom = window.innerHeight - pos.top + "px";
|
||||
} else {
|
||||
pos.top += lineHeight;
|
||||
el.style.top = pos.top + "px";
|
||||
el.style.bottom = "";
|
||||
}
|
||||
|
||||
el.style.left = pos.left + "px";
|
||||
el.style.display = "";
|
||||
|
||||
this._signal("show");
|
||||
};
|
||||
|
||||
return popup;
|
||||
};
|
||||
|
||||
dom.importCssString("\
|
||||
.ace_autocomplete.ace-tm .ace_marker-layer .ace_active-line {\
|
||||
background-color: #abbffe;\
|
||||
}\
|
||||
.ace_autocomplete.ace-tm .ace_line-hover {\
|
||||
border: 1px solid #abbffe;\
|
||||
position: absolute;\
|
||||
background: rgba(233,233,253,0.4);\
|
||||
z-index: 2;\
|
||||
margin-top: -1px;\
|
||||
}\
|
||||
.ace_rightAlignedText {\
|
||||
color: gray;\
|
||||
display: inline-block;\
|
||||
position: absolute;\
|
||||
right: 4px;\
|
||||
text-align: right;\
|
||||
z-index: -1;\
|
||||
}\
|
||||
.ace_autocomplete {\
|
||||
width: 200px;\
|
||||
z-index: 200000;\
|
||||
background: #f8f8f8;\
|
||||
border: 1px lightgray solid;\
|
||||
position: fixed;\
|
||||
box-shadow: 2px 3px 5px rgba(0,0,0,.2);\
|
||||
}");
|
||||
|
||||
exports.AcePopup = AcePopup;
|
||||
|
||||
});
|
||||
89
lib/ace/autocomplete/text_completer.js
Normal file
89
lib/ace/autocomplete/text_completer.js
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2012, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
var Range = require("ace/range").Range;
|
||||
|
||||
var splitRegex = /[^a-zA-Z_0-9\$\-]+/;
|
||||
|
||||
function getWordIndex(doc, pos) {
|
||||
var textBefore = doc.getTextRange(Range.fromPoints({row: 0, column:0}, pos));
|
||||
return textBefore.split(splitRegex).length - 1;
|
||||
}
|
||||
|
||||
// NOTE: Naive implementation O(n), can be O(log n) with binary search
|
||||
function filterPrefix(prefix, words) {
|
||||
var results = [];
|
||||
for (var i = 0; i < words.length; i++) {
|
||||
if (words[i].lastIndexOf(prefix, 0) === 0) {
|
||||
results.push(words[i]);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does a distance analysis of the word `prefix` at position `pos` in `doc`.
|
||||
* @return Map
|
||||
*/
|
||||
function wordDistance(doc, pos) {
|
||||
var prefixPos = getWordIndex(doc, pos);
|
||||
var words = doc.getValue().split(splitRegex);
|
||||
var wordScores = Object.create(null);
|
||||
|
||||
var currentWord = words[prefixPos];
|
||||
|
||||
words.forEach(function(word, idx) {
|
||||
if (!word || word === currentWord) return;
|
||||
|
||||
var distance = Math.abs(prefixPos - idx);
|
||||
var score = words.length - distance;
|
||||
if (wordScores[word]) {
|
||||
wordScores[word] = Math.max(score, wordScores[word]);
|
||||
} else {
|
||||
wordScores[word] = score;
|
||||
}
|
||||
});
|
||||
return wordScores;
|
||||
}
|
||||
|
||||
exports.getCompletions = function(session, pos, prefix, callback) {
|
||||
var wordScore = wordDistance(session, pos, prefix);
|
||||
var wordList = filterPrefix(prefix, Object.keys(wordScore));
|
||||
callback(null, wordList.map(function(word) {
|
||||
return {
|
||||
name: word,
|
||||
value: word,
|
||||
score: wordScore[word],
|
||||
meta: "local"
|
||||
};
|
||||
}));
|
||||
};
|
||||
});
|
||||
74
lib/ace/autocomplete/util.js
Normal file
74
lib/ace/autocomplete/util.js
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2012, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.parForEach = function(array, fn, callback) {
|
||||
var completed = 0;
|
||||
var arLength = array.length;
|
||||
if (arLength === 0)
|
||||
callback();
|
||||
for (var i = 0; i < arLength; i++) {
|
||||
fn(array[i], function(result, err) {
|
||||
completed++;
|
||||
if (completed === arLength)
|
||||
callback(result, err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var ID_REGEX = /[a-zA-Z_0-9\$]/;
|
||||
|
||||
exports.retrievePrecedingIdentifier = function(text, pos, regex) {
|
||||
regex = regex || ID_REGEX;
|
||||
var buf = [];
|
||||
for (var i = pos-1; i >= 0; i--) {
|
||||
if (regex.test(text[i]))
|
||||
buf.push(text[i]);
|
||||
else
|
||||
break;
|
||||
}
|
||||
return buf.reverse().join("");
|
||||
}
|
||||
|
||||
exports.retrieveFollowingIdentifier = function(text, pos, regex) {
|
||||
regex = regex || ID_REGEX;
|
||||
var buf = [];
|
||||
for (var i = pos; i < text.length; i++) {
|
||||
if (regex.test(text[i]))
|
||||
buf.push(text[i]);
|
||||
else
|
||||
break;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
@ -16,9 +16,6 @@ var EventEmitter = require("../lib/event_emitter").EventEmitter;
|
|||
* @param {String} platform Identifier for the platform; must be either `'mac'` or `'win'`
|
||||
* @param {Array} commands A list of commands
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
**/
|
||||
|
||||
var CommandManager = function(platform, commands) {
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@
|
|||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.ace_marker-layer .ace_step {
|
||||
.ace_marker-layer .ace_step, .ace_marker-layer .ace_stack {
|
||||
position: absolute;
|
||||
z-index: 3;
|
||||
}
|
||||
|
|
@ -386,3 +386,16 @@
|
|||
.ace_italic {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
|
||||
.ace_error-marker {
|
||||
background-color: rgba(255, 0, 0,0.2);
|
||||
position: absolute;
|
||||
z-index: 9;
|
||||
}
|
||||
|
||||
.ace_highlight-marker {
|
||||
background-color: rgba(255, 255, 0,0.2);
|
||||
position: absolute;
|
||||
z-index: 8;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -461,7 +461,8 @@ var EditSession = function(text, mode) {
|
|||
* @returns {Boolean}
|
||||
**/
|
||||
this.getUseSoftTabs = function() {
|
||||
return this.$useSoftTabs;
|
||||
// todo might need more general way for changing settings from mode, but this is ok for now
|
||||
return this.$useSoftTabs && !this.$mode.$indentWithTabs;
|
||||
};
|
||||
/**
|
||||
* Set the number of spaces that define a soft tab; for example, passing in `4` transforms the soft tabs to be equivalent to four spaces. This function also emits the `changeTabSize` event.
|
||||
|
|
|
|||
|
|
@ -639,8 +639,8 @@ function Folding() {
|
|||
if (range && range.end.row <= endRow) try {
|
||||
var fold = this.addFold("...", range);
|
||||
fold.collapseChildren = depth;
|
||||
row = range.end.row;
|
||||
} catch(e) {}
|
||||
row = range.end.row;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
115
lib/ace/ext/language_tools.js
Normal file
115
lib/ace/ext/language_tools.js
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2012, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var snippetManager = require("../snippets").snippetManager;
|
||||
var Autocomplete = require("../autocomplete").Autocomplete;
|
||||
var config = require("../config");
|
||||
|
||||
var textCompleter = require("../autocomplete/text_completer");
|
||||
var keyWordCompleter = {
|
||||
getCompletions: function(session, pos, prefix, callback) {
|
||||
var keywords = session.$mode.$keywordList || [];
|
||||
keywords = keywords.filter(function(w) {
|
||||
return w.lastIndexOf(prefix, 0) == 0;
|
||||
});
|
||||
callback(null, keywords.map(function(word) {
|
||||
return {
|
||||
name: word,
|
||||
value: word,
|
||||
score: 0,
|
||||
meta: "keyword"
|
||||
};
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
var completers = [textCompleter, keyWordCompleter]; // todo add snippets completer
|
||||
exports.addCompleter = function(completer) {
|
||||
completers.push(completer);
|
||||
};
|
||||
|
||||
var expandSnippet = {
|
||||
name: "expandSnippet",
|
||||
exec: function(editor) {
|
||||
var success = snippetManager.expandWithTab(editor);
|
||||
if (!success)
|
||||
editor.execCommand("indent");
|
||||
},
|
||||
bindKey: "tab"
|
||||
}
|
||||
|
||||
var onChangeMode = function(e, editor) {
|
||||
var mode = editor.session.$mode;
|
||||
var id = mode.$id
|
||||
if (!snippetManager.files) snippetManager.files = {};
|
||||
if (id && !snippetManager.files[id]) {
|
||||
var snippetFilePath = id.replace("mode", "snippets");
|
||||
config.loadModule(snippetFilePath, function(m) {
|
||||
if (m) {
|
||||
snippetManager.files[id] = m;
|
||||
m.snippets = snippetManager.parseSnippetFile(m.snippetText);
|
||||
snippetManager.register(m.snippets, m.scope);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var Editor = require("../editor").Editor;
|
||||
require("../config").defineOptions(Editor.prototype, "editor", {
|
||||
enableBasicAutocompletion: {
|
||||
set: function(val) {
|
||||
if (val) {
|
||||
this.completers = completers
|
||||
this.commands.addCommand(Autocomplete.startCommand);
|
||||
} else {
|
||||
this.commands.removeCommand(Autocomplete.startCommand);
|
||||
}
|
||||
},
|
||||
value: false
|
||||
},
|
||||
enableSnippets: {
|
||||
set: function(val) {
|
||||
if (val) {
|
||||
this.commands.addCommand(expandSnippet);
|
||||
this.on("changeMode", onChangeMode);
|
||||
onChangeMode(null, this)
|
||||
} else {
|
||||
this.commands.removeCommand(expandSnippet);
|
||||
this.off("changeMode", onChangeMode);
|
||||
}
|
||||
},
|
||||
value: false
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
40
lib/ace/ext/split.js
Normal file
40
lib/ace/ext/split.js
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2010, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* this is experimental, and subject to change, use at your own risk!
|
||||
*/
|
||||
module.exports = require("../split");
|
||||
|
||||
});
|
||||
|
||||
|
|
@ -40,8 +40,8 @@ var BROKEN_SETDATA = useragent.isChrome < 18;
|
|||
var TextInput = function(parentNode, host) {
|
||||
var text = dom.createElement("textarea");
|
||||
text.className = "ace_text-input";
|
||||
/*/ debug
|
||||
text.style.cssText = "opacity:1;background:rgba(0, 250, 0, 0.3);outline:rgba(0, 250, 0, 0.8) solid 1px;outline-offset:3px;width:5em;z-index:500";
|
||||
// debug
|
||||
text.style.cssText = "opacity:1;background:rgba(0, 250, 0, 0.3);outline:rgba(0, 250, 0, 0.8) solid 1px;outline-offset:3px;width:5em;z-pindex:500";
|
||||
/**/
|
||||
if (useragent.isTouchPad)
|
||||
text.setAttribute("x-palm-disable-auto-cap", true);
|
||||
|
|
@ -436,10 +436,10 @@ var TextInput = function(parentNode, host) {
|
|||
tempStyle = text.style.cssText;
|
||||
|
||||
text.style.cssText = "z-index:100000;" + (useragent.isIE ? "opacity:0.1;" : "");
|
||||
// text.style.cssText += "background:rgba(250, 0, 0, 0.3); opacity:1;";
|
||||
text.style.cssText += "background:rgba(250, 0, 0, 0.3); opacity:1;";
|
||||
|
||||
resetSelection(host.selection.isEmpty());
|
||||
host._emit("nativecontextmenu", {target: host});
|
||||
host._emit("nativecontextmenu", {target: host, domEvent: e});
|
||||
var rect = host.container.getBoundingClientRect();
|
||||
var style = dom.computedStyle(host.container);
|
||||
var top = rect.top + (parseInt(style.borderTopWidth) || 0);
|
||||
|
|
@ -477,7 +477,7 @@ var TextInput = function(parentNode, host) {
|
|||
}
|
||||
|
||||
// firefox fires contextmenu event after opening it
|
||||
if (!useragent.isGecko) {
|
||||
if (!useragent.isGecko || useragent.isMac) {
|
||||
event.addListener(text, "contextmenu", function(e) {
|
||||
host.textInput.onContextMenu(e);
|
||||
onContextMenuClose();
|
||||
|
|
|
|||
|
|
@ -39,7 +39,9 @@ var TextMode = require("./text").Mode;
|
|||
var oop = require("../lib/oop");
|
||||
|
||||
function Mode() {
|
||||
this.$tokenizer = new Tokenizer(new Rules().getRules());
|
||||
var highlighter = new Rules();
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$keywordList = new Rules(highlighter.$keywordList);
|
||||
this.foldingRules = new FoldMode();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,9 +41,13 @@ var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
|||
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new c_cppHighlightRules().getRules());
|
||||
var highlighter = new c_cppHighlightRules();
|
||||
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
this.$behaviour = new CstyleBehaviour();
|
||||
this.$keywordList = highlighter.$keywordList;
|
||||
|
||||
this.foldingRules = new CStyleFoldMode();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,9 @@ var MatchingParensOutdent = require("./matching_parens_outdent").MatchingParensO
|
|||
var Range = require("../range").Range;
|
||||
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new ClojureHighlightRules().getRules());
|
||||
var highlighter = new ClojureHighlightRules();
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$keywordList = highlighter.$keywordList;
|
||||
this.$outdent = new MatchingParensOutdent();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
|
|
|||
|
|
@ -41,8 +41,10 @@ var WorkerClient = require("../worker/worker_client").WorkerClient;
|
|||
var oop = require("../lib/oop");
|
||||
|
||||
function Mode() {
|
||||
this.$tokenizer = new Tokenizer(new Rules().getRules());
|
||||
var highlighter = new Rules();
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$outdent = new Outdent();
|
||||
this.$keywordList = highlighter.$keywordList;
|
||||
this.foldingRules = new FoldMode();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,9 +10,11 @@ var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
|||
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new CSharpHighlightRules().getRules());
|
||||
var highlighter = new CSharpHighlightRules();
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
this.$behaviour = new CstyleBehaviour();
|
||||
this.$keywordList = highlighter.$keywordList;
|
||||
this.foldingRules = new CStyleFoldMode();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
|
|
|||
|
|
@ -41,9 +41,11 @@ var CssBehaviour = require("./behaviour/css").CssBehaviour;
|
|||
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new CssHighlightRules().getRules());
|
||||
var highlighter = new CssHighlightRules();
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
this.$behaviour = new CssBehaviour();
|
||||
this.$keywordList = highlighter.$keywordList;
|
||||
this.foldingRules = new CStyleFoldMode();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ var Mode = function() {
|
|||
this.foldingRules = new CStyleFoldMode();
|
||||
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$keywordList = highlighter.$keywordList;
|
||||
};
|
||||
oop.inherits(Mode, CMode);
|
||||
|
||||
|
|
|
|||
|
|
@ -41,9 +41,12 @@ var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
|||
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new glslHighlightRules().getRules());
|
||||
var highlighter = new glslHighlightRules();
|
||||
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
this.$behaviour = new CstyleBehaviour();
|
||||
this.$keywordList = highlighter.$keywordList;
|
||||
this.foldingRules = new CStyleFoldMode();
|
||||
};
|
||||
oop.inherits(Mode, CMode);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,10 @@ var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
|||
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new GolangHighlightRules().getRules());
|
||||
var highlighter = new GolangHighlightRules();
|
||||
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$keywordList = highlighter.$keywordList;
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
this.foldingRules = new CStyleFoldMode();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ var GroovyHighlightRules = require("./groovy_highlight_rules").GroovyHighlightRu
|
|||
|
||||
var Mode = function() {
|
||||
JavaScriptMode.call(this);
|
||||
this.$tokenizer = new Tokenizer(new GroovyHighlightRules().getRules());
|
||||
var highlighter = new GroovyHighlightRules();
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$keywordList = highlighter.$keywordList;
|
||||
};
|
||||
oop.inherits(Mode, JavaScriptMode);
|
||||
|
||||
|
|
|
|||
|
|
@ -10,9 +10,12 @@ var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
|||
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new HaxeHighlightRules().getRules());
|
||||
var highlighter = new HaxeHighlightRules();
|
||||
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
this.$behaviour = new CstyleBehaviour();
|
||||
this.$keywordList = highlighter.$keywordList;
|
||||
this.foldingRules = new CStyleFoldMode();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
|
|
|||
|
|
@ -8,8 +8,10 @@ var JavaHighlightRules = require("./java_highlight_rules").JavaHighlightRules;
|
|||
|
||||
var Mode = function() {
|
||||
JavaScriptMode.call(this);
|
||||
var highlighter = new JavaHighlightRules();
|
||||
|
||||
this.$tokenizer = new Tokenizer(new JavaHighlightRules().getRules());
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$keywordList = highlighter.$keywordList;
|
||||
};
|
||||
oop.inherits(Mode, JavaScriptMode);
|
||||
|
||||
|
|
|
|||
|
|
@ -42,9 +42,12 @@ var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
|||
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules());
|
||||
var highlighter = new JavaScriptHighlightRules();
|
||||
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
this.$behaviour = new CstyleBehaviour();
|
||||
this.$keywordList = highlighter.$keywordList;
|
||||
this.foldingRules = new CStyleFoldMode();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ var JavaScriptHighlightRules = function() {
|
|||
next : "start"
|
||||
}, {
|
||||
token : ["punctuation.operator", "support.function"],
|
||||
regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:opzzzz|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
|
||||
regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
|
||||
}, {
|
||||
token : ["punctuation.operator", "support.function.dom"],
|
||||
regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
|
||||
|
|
|
|||
|
|
@ -38,7 +38,10 @@ var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutd
|
|||
var Range = require("../range").Range;
|
||||
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new LiquidHighlightRules().getRules());
|
||||
var highlighter = new LiquidHighlightRules();
|
||||
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$keywordList = highlighter.$keywordList;
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ var Mode = function() {
|
|||
var highlighter = new LispHighlightRules();
|
||||
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$keywordList = highlighter.$keywordList;
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
|
|
|
|||
|
|
@ -40,8 +40,11 @@ var Range = require("../range").Range;
|
|||
var WorkerClient = require("../worker/worker_client").WorkerClient;
|
||||
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new LuaHighlightRules().getRules());
|
||||
var highlighter = new LuaHighlightRules();
|
||||
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.foldingRules = new LuaFoldMode();
|
||||
this.$keywordList = highlighter.$keywordList;
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
|
|
|
|||
|
|
@ -51,12 +51,15 @@ var Mode = function() {
|
|||
this.foldingRules = new FoldMode();
|
||||
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$keywordList = highlighter.$keywordList;
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.lineCommentStart = "#";
|
||||
this.lineCommentStart = "#";
|
||||
this.$indentWithTabs = true;
|
||||
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
|
|
|
|||
|
|
@ -39,8 +39,11 @@ var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutd
|
|||
var Range = require("../range").Range;
|
||||
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new OcamlHighlightRules().getRules());
|
||||
var highlighter = new OcamlHighlightRules();
|
||||
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
this.$keywordList = highlighter.$keywordList;
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
|
|
|
|||
|
|
@ -40,9 +40,12 @@ var Range = require("../range").Range;
|
|||
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new PerlHighlightRules().getRules());
|
||||
var highlighter = new PerlHighlightRules();
|
||||
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
this.foldingRules = new CStyleFoldMode({start: "^=(begin|item)\\b", end: "^=(cut)\\b"});
|
||||
this.$keywordList = highlighter.$keywordList;
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
|
|
|
|||
|
|
@ -37,11 +37,14 @@ var PgsqlHighlightRules = require("./pgsql_highlight_rules").PgsqlHighlightRules
|
|||
var Range = require("../range").Range;
|
||||
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new PgsqlHighlightRules().getRules());
|
||||
var highlighter = new PgsqlHighlightRules();
|
||||
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$keywordList = highlighter.$keywordList;
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
(function() {
|
||||
this.lineCommentStart = "--";
|
||||
this.blockComment = {start: "/*", end: "*/"};
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,10 @@ var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
|||
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new PowershellHighlightRules().getRules());
|
||||
var highlighter = new PowershellHighlightRules();
|
||||
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$keywordList = highlighter.$keywordList;
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
this.$behaviour = new CstyleBehaviour();
|
||||
this.foldingRules = new CStyleFoldMode({start: "^\\s*(<#)", end: "^[#\\s]>\\s*$"});
|
||||
|
|
|
|||
|
|
@ -39,7 +39,9 @@ var PythonFoldMode = require("./folding/pythonic").FoldMode;
|
|||
var Range = require("../range").Range;
|
||||
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new PythonHighlightRules().getRules());
|
||||
var highlighter = new PythonHighlightRules();
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$keywordList = highlighter.$keywordList;
|
||||
this.foldingRules = new PythonFoldMode("\\:");
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
|
|
|||
|
|
@ -40,7 +40,10 @@ var Range = require("../range").Range;
|
|||
var FoldMode = require("./folding/coffee").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new RubyHighlightRules().getRules());
|
||||
var highlighter = new RubyHighlightRules();
|
||||
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$keywordList = highlighter.$keywordList;
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
this.foldingRules = new FoldMode();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -41,7 +41,10 @@ var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
|||
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new scadHighlightRules().getRules());
|
||||
var highlighter = new scadHighlightRules();
|
||||
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$keywordList = highlighter.$keywordList;
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
this.$behaviour = new CstyleBehaviour();
|
||||
this.foldingRules = new CStyleFoldMode();
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@ var ScalaHighlightRules = require("./scala_highlight_rules").ScalaHighlightRules
|
|||
var Mode = function() {
|
||||
JavaScriptMode.call(this);
|
||||
|
||||
this.$tokenizer = new Tokenizer(new ScalaHighlightRules().getRules());
|
||||
var highlighter = new ScalaHighlightRules();
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$keywordList = highlighter.$keywordList;
|
||||
};
|
||||
oop.inherits(Mode, JavaScriptMode);
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,10 @@ var ShHighlightRules = require("./sh_highlight_rules").ShHighlightRules;
|
|||
var Range = require("../range").Range;
|
||||
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new ShHighlightRules().getRules());
|
||||
var highlighter = new ShHighlightRules();
|
||||
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$keywordList = highlighter.$keywordList;
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
|
|
|
|||
|
|
@ -105,9 +105,7 @@ var Mode = function() {
|
|||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
return this.$getIndent(line);
|
||||
};
|
||||
this.$indentWithTabs = true;
|
||||
}).call(Mode.prototype);
|
||||
exports.Mode = Mode;
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,10 @@ var SqlHighlightRules = require("./sql_highlight_rules").SqlHighlightRules;
|
|||
var Range = require("../range").Range;
|
||||
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new SqlHighlightRules().getRules());
|
||||
var highlighter = new SqlHighlightRules();
|
||||
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$keywordList = highlighter.$keywordList;
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ var Mode = function() {
|
|||
this.foldingRules = new FoldMode();
|
||||
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.$keywordList = highlighter.$keywordList;
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
|
|
|
|||
|
|
@ -325,7 +325,38 @@ var Mode = function() {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
this.getKeywords = function(append) {
|
||||
// this is for autocompletion to pick up regexp'ed keywords
|
||||
if (!this.completionKeywords) {
|
||||
var rules = this.$tokenizer.rules;
|
||||
var completionKeywords = [];
|
||||
for (var rule in rules) {
|
||||
var ruleItr = rules[rule];
|
||||
for (var r = 0, l = ruleItr.length; r < l; r++) {
|
||||
if (typeof ruleItr[r].token === "string") {
|
||||
if (/keyword|support|storage/.test(ruleItr[r].token))
|
||||
completionKeywords.push(ruleItr[r].regex);
|
||||
}
|
||||
else if (typeof ruleItr[r].token === "object") {
|
||||
for (var a = 0, aLength = ruleItr[r].token.length; a < aLength; a++) {
|
||||
if (/keyword|support|storage/.test(ruleItr[r].token[a])) {
|
||||
// drop surrounding parens
|
||||
var rule = ruleItr[r].regex.match(/\(.+?\)/g)[a];
|
||||
completionKeywords.push(rule.substr(1, rule.length - 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.completionKeywords = completionKeywords;
|
||||
}
|
||||
// this is for highlighting embed rules, like HAML/Ruby or Obj-C/C
|
||||
if (!append)
|
||||
return this.$keywordList;
|
||||
return completionKeywords.concat(this.$keywordList || []);
|
||||
};
|
||||
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
|
|
|
|||
|
|
@ -204,6 +204,7 @@ var TextHighlightRules = function() {
|
|||
for (var i = list.length; i--; )
|
||||
keywords[list[i]] = className;
|
||||
});
|
||||
this.$keywordList = Object.keys(keywords);
|
||||
map = null;
|
||||
return ignoreCase
|
||||
? function(value) {return keywords[value.toLowerCase()] || defaultToken }
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ function GutterHandler(mouseHandler) {
|
|||
var gutter = editor.renderer.$gutterLayer;
|
||||
|
||||
mouseHandler.editor.setDefaultHandler("guttermousedown", function(e) {
|
||||
if (!editor.isFocused())
|
||||
if (!editor.isFocused() || e.getButton() != 0)
|
||||
return;
|
||||
var gutterRegion = gutter.getRegion(e);
|
||||
|
||||
|
|
|
|||
|
|
@ -374,7 +374,7 @@ var Editor = require("./editor").Editor;
|
|||
|
||||
/**
|
||||
* Removes the selection marker.
|
||||
* @param {Range} The selection range added with [[Editor.addSelectionMarker `addSelectionMarker()`]].
|
||||
* @param {Range} range The selection range added with [[Editor.addSelectionMarker `addSelectionMarker()`]].
|
||||
* @method Editor.removeSelectionMarker
|
||||
**/
|
||||
this.removeSelectionMarker = function(range) {
|
||||
|
|
|
|||
|
|
@ -533,7 +533,6 @@ var SnippetManager = function() {
|
|||
}).call(SnippetManager.prototype);
|
||||
|
||||
|
||||
|
||||
var TabstopManager = function(editor) {
|
||||
if (editor.tabstopManager)
|
||||
return editor.tabstopManager;
|
||||
|
|
|
|||
7
lib/ace/snippets/abap.js
Normal file
7
lib/ace/snippets/abap.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./abap.snippets");
|
||||
exports.scope = "abap";
|
||||
|
||||
});
|
||||
0
lib/ace/snippets/abap.snippets
Normal file
0
lib/ace/snippets/abap.snippets
Normal file
7
lib/ace/snippets/actionscript.js
Normal file
7
lib/ace/snippets/actionscript.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./actionscript.snippets");
|
||||
exports.scope = "actionscript";
|
||||
|
||||
});
|
||||
7
lib/ace/snippets/ada.js
Normal file
7
lib/ace/snippets/ada.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./ada.snippets");
|
||||
exports.scope = "ada";
|
||||
|
||||
});
|
||||
0
lib/ace/snippets/ada.snippets
Normal file
0
lib/ace/snippets/ada.snippets
Normal file
7
lib/ace/snippets/asciidoc.js
Normal file
7
lib/ace/snippets/asciidoc.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./asciidoc.snippets");
|
||||
exports.scope = "asciidoc";
|
||||
|
||||
});
|
||||
0
lib/ace/snippets/asciidoc.snippets
Normal file
0
lib/ace/snippets/asciidoc.snippets
Normal file
7
lib/ace/snippets/assembly_x86.js
Normal file
7
lib/ace/snippets/assembly_x86.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./assembly_x86.snippets");
|
||||
exports.scope = "assembly_x86";
|
||||
|
||||
});
|
||||
0
lib/ace/snippets/assembly_x86.snippets
Normal file
0
lib/ace/snippets/assembly_x86.snippets
Normal file
7
lib/ace/snippets/autohotkey.js
Normal file
7
lib/ace/snippets/autohotkey.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./autohotkey.snippets");
|
||||
exports.scope = "autohotkey";
|
||||
|
||||
});
|
||||
0
lib/ace/snippets/autohotkey.snippets
Normal file
0
lib/ace/snippets/autohotkey.snippets
Normal file
7
lib/ace/snippets/batchfile.js
Normal file
7
lib/ace/snippets/batchfile.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./batchfile.snippets");
|
||||
exports.scope = "batchfile";
|
||||
|
||||
});
|
||||
0
lib/ace/snippets/batchfile.snippets
Normal file
0
lib/ace/snippets/batchfile.snippets
Normal file
7
lib/ace/snippets/c9search.js
Normal file
7
lib/ace/snippets/c9search.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./c9search.snippets");
|
||||
exports.scope = "c9search";
|
||||
|
||||
});
|
||||
0
lib/ace/snippets/c9search.snippets
Normal file
0
lib/ace/snippets/c9search.snippets
Normal file
7
lib/ace/snippets/c_cpp.js
Normal file
7
lib/ace/snippets/c_cpp.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./c_cpp.snippets");
|
||||
exports.scope = "c_cpp";
|
||||
|
||||
});
|
||||
7
lib/ace/snippets/clojure.js
Normal file
7
lib/ace/snippets/clojure.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./clojure.snippets");
|
||||
exports.scope = "clojure";
|
||||
|
||||
});
|
||||
7
lib/ace/snippets/cobol.js
Normal file
7
lib/ace/snippets/cobol.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./cobol.snippets");
|
||||
exports.scope = "cobol";
|
||||
|
||||
});
|
||||
0
lib/ace/snippets/cobol.snippets
Normal file
0
lib/ace/snippets/cobol.snippets
Normal file
7
lib/ace/snippets/coffee.js
Normal file
7
lib/ace/snippets/coffee.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./coffee.snippets");
|
||||
exports.scope = "coffee";
|
||||
|
||||
});
|
||||
7
lib/ace/snippets/coldfusion.js
Normal file
7
lib/ace/snippets/coldfusion.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./coldfusion.snippets");
|
||||
exports.scope = "coldfusion";
|
||||
|
||||
});
|
||||
0
lib/ace/snippets/coldfusion.snippets
Normal file
0
lib/ace/snippets/coldfusion.snippets
Normal file
7
lib/ace/snippets/csharp.js
Normal file
7
lib/ace/snippets/csharp.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./csharp.snippets");
|
||||
exports.scope = "csharp";
|
||||
|
||||
});
|
||||
0
lib/ace/snippets/csharp.snippets
Normal file
0
lib/ace/snippets/csharp.snippets
Normal file
7
lib/ace/snippets/css.js
Normal file
7
lib/ace/snippets/css.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./css.snippets");
|
||||
exports.scope = "css";
|
||||
|
||||
});
|
||||
7
lib/ace/snippets/curly.js
Normal file
7
lib/ace/snippets/curly.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./curly.snippets");
|
||||
exports.scope = "curly";
|
||||
|
||||
});
|
||||
0
lib/ace/snippets/curly.snippets
Normal file
0
lib/ace/snippets/curly.snippets
Normal file
7
lib/ace/snippets/d.js
Normal file
7
lib/ace/snippets/d.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./d.snippets");
|
||||
exports.scope = "d";
|
||||
|
||||
});
|
||||
0
lib/ace/snippets/d.snippets
Normal file
0
lib/ace/snippets/d.snippets
Normal file
7
lib/ace/snippets/dart.js
Normal file
7
lib/ace/snippets/dart.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./dart.snippets");
|
||||
exports.scope = "dart";
|
||||
|
||||
});
|
||||
7
lib/ace/snippets/diff.js
Normal file
7
lib/ace/snippets/diff.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./diff.snippets");
|
||||
exports.scope = "diff";
|
||||
|
||||
});
|
||||
7
lib/ace/snippets/django.js
Normal file
7
lib/ace/snippets/django.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./django.snippets");
|
||||
exports.scope = "django";
|
||||
|
||||
});
|
||||
7
lib/ace/snippets/dot.js
Normal file
7
lib/ace/snippets/dot.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./dot.snippets");
|
||||
exports.scope = "dot";
|
||||
|
||||
});
|
||||
0
lib/ace/snippets/dot.snippets
Normal file
0
lib/ace/snippets/dot.snippets
Normal file
7
lib/ace/snippets/ejs.js
Normal file
7
lib/ace/snippets/ejs.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./ejs.snippets");
|
||||
exports.scope = "ejs";
|
||||
|
||||
});
|
||||
0
lib/ace/snippets/ejs.snippets
Normal file
0
lib/ace/snippets/ejs.snippets
Normal file
7
lib/ace/snippets/erlang.js
Normal file
7
lib/ace/snippets/erlang.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./erlang.snippets");
|
||||
exports.scope = "erlang";
|
||||
|
||||
});
|
||||
7
lib/ace/snippets/forth.js
Normal file
7
lib/ace/snippets/forth.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./forth.snippets");
|
||||
exports.scope = "forth";
|
||||
|
||||
});
|
||||
0
lib/ace/snippets/forth.snippets
Normal file
0
lib/ace/snippets/forth.snippets
Normal file
7
lib/ace/snippets/ftl.js
Normal file
7
lib/ace/snippets/ftl.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./ftl.snippets");
|
||||
exports.scope = "ftl";
|
||||
|
||||
});
|
||||
0
lib/ace/snippets/ftl.snippets
Normal file
0
lib/ace/snippets/ftl.snippets
Normal file
7
lib/ace/snippets/glsl.js
Normal file
7
lib/ace/snippets/glsl.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./glsl.snippets");
|
||||
exports.scope = "glsl";
|
||||
|
||||
});
|
||||
0
lib/ace/snippets/glsl.snippets
Normal file
0
lib/ace/snippets/glsl.snippets
Normal file
7
lib/ace/snippets/golang.js
Normal file
7
lib/ace/snippets/golang.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./golang.snippets");
|
||||
exports.scope = "golang";
|
||||
|
||||
});
|
||||
0
lib/ace/snippets/golang.snippets
Normal file
0
lib/ace/snippets/golang.snippets
Normal file
7
lib/ace/snippets/groovy.js
Normal file
7
lib/ace/snippets/groovy.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./groovy.snippets");
|
||||
exports.scope = "groovy";
|
||||
|
||||
});
|
||||
0
lib/ace/snippets/groovy.snippets
Normal file
0
lib/ace/snippets/groovy.snippets
Normal file
7
lib/ace/snippets/haml.js
Normal file
7
lib/ace/snippets/haml.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./haml.snippets");
|
||||
exports.scope = "haml";
|
||||
|
||||
});
|
||||
7
lib/ace/snippets/haskell.js
Normal file
7
lib/ace/snippets/haskell.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./haskell.snippets");
|
||||
exports.scope = "haskell";
|
||||
|
||||
});
|
||||
7
lib/ace/snippets/haxe.js
Normal file
7
lib/ace/snippets/haxe.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.snippetText = require("../requirejs/text!./haxe.snippets");
|
||||
exports.scope = "haxe";
|
||||
|
||||
});
|
||||
0
lib/ace/snippets/haxe.snippets
Normal file
0
lib/ace/snippets/haxe.snippets
Normal file
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue