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);
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue