Merge branch 'master' into v-1.2
Conflicts: lib/ace/commands/command_manager.js
This commit is contained in:
commit
bb827051a6
60 changed files with 3013 additions and 484 deletions
|
|
@ -36,7 +36,7 @@ var EventEmitter = require("./lib/event_emitter").EventEmitter;
|
|||
|
||||
/**
|
||||
*
|
||||
* Defines the floating pointer in the document. Whenever text is inserted or deleted before the cursor, the position of the cursor is updated.
|
||||
* Defines a floating pointer in the document. Whenever text is inserted or deleted before the cursor, the position of the anchor is updated.
|
||||
*
|
||||
* @class Anchor
|
||||
**/
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ var AcePopup = require("./autocomplete/popup").AcePopup;
|
|||
var util = require("./autocomplete/util");
|
||||
var event = require("./lib/event");
|
||||
var lang = require("./lib/lang");
|
||||
var dom = require("./lib/dom");
|
||||
var snippetManager = require("./snippets").snippetManager;
|
||||
|
||||
var Autocomplete = function() {
|
||||
|
|
@ -52,6 +53,8 @@ var Autocomplete = function() {
|
|||
this.changeTimer = lang.delayedCall(function() {
|
||||
this.updateCompletions(true);
|
||||
}.bind(this));
|
||||
|
||||
this.tooltipTimer = lang.delayedCall(this.updateDocTooltip.bind(this), 50);
|
||||
};
|
||||
|
||||
(function() {
|
||||
|
|
@ -64,6 +67,13 @@ var Autocomplete = function() {
|
|||
e.stop();
|
||||
}.bind(this));
|
||||
this.popup.focus = this.editor.focus.bind(this.editor);
|
||||
this.popup.on("select", this.tooltipTimer.bind(null, null));
|
||||
this.popup.on("changeHoverMarker", this.tooltipTimer.bind(null, null));
|
||||
return this.popup;
|
||||
};
|
||||
|
||||
this.getPopup = function() {
|
||||
return this.popup || this.$init();
|
||||
};
|
||||
|
||||
this.openPopup = function(editor, prefix, keepPopupPosition) {
|
||||
|
|
@ -101,6 +111,7 @@ var Autocomplete = function() {
|
|||
this.editor.off("mousedown", this.mousedownListener);
|
||||
this.editor.off("mousewheel", this.mousewheelListener);
|
||||
this.changeTimer.cancel();
|
||||
this.hideDocTooltip();
|
||||
|
||||
if (this.popup && this.popup.isOpen) {
|
||||
this.gatherCompletionsId += 1;
|
||||
|
|
@ -124,12 +135,17 @@ var Autocomplete = function() {
|
|||
this.detach();
|
||||
};
|
||||
|
||||
this.blurListener = function() {
|
||||
this.blurListener = function(e) {
|
||||
// we have to check if activeElement is a child of popup because
|
||||
// on IE preventDefault doesn't stop scrollbar from being focussed
|
||||
var el = document.activeElement;
|
||||
if (el != this.editor.textInput.getElement() && el.parentNode != this.popup.container)
|
||||
var text = this.editor.textInput.getElement()
|
||||
if (el != text && el.parentNode != this.popup.container
|
||||
&& el != this.tooltipNode && e.relatedTarget != this.tooltipNode
|
||||
&& e.relatedTarget != text
|
||||
) {
|
||||
this.detach();
|
||||
}
|
||||
};
|
||||
|
||||
this.mousedownListener = function(e) {
|
||||
|
|
@ -178,6 +194,7 @@ var Autocomplete = function() {
|
|||
this.detach();
|
||||
};
|
||||
|
||||
|
||||
this.commands = {
|
||||
"Up": function(editor) { editor.completer.goTo("up"); },
|
||||
"Down": function(editor) { editor.completer.goTo("down"); },
|
||||
|
|
@ -310,6 +327,74 @@ var Autocomplete = function() {
|
|||
this.cancelContextMenu = function() {
|
||||
this.editor.$mouseHandler.cancelContextMenu();
|
||||
};
|
||||
|
||||
this.updateDocTooltip = function() {
|
||||
var popup = this.popup;
|
||||
var all = popup.data;
|
||||
var selected = all && (all[popup.getHoveredRow()] || all[popup.getRow()]);
|
||||
var doc = null;
|
||||
if (!selected || !this.editor || !this.popup.isOpen)
|
||||
return this.hideDocTooltip();
|
||||
this.editor.completers.some(function(completer) {
|
||||
if (completer.getDocTooltip)
|
||||
doc = completer.getDocTooltip(selected);
|
||||
return doc;
|
||||
});
|
||||
if (!doc)
|
||||
doc = selected;
|
||||
|
||||
if (typeof doc == "string")
|
||||
doc = {tooltipText: doc}
|
||||
if (!doc || !(doc.docHTML || doc.docText))
|
||||
return this.hideDocTooltip();
|
||||
this.showDocTooltip(doc);
|
||||
};
|
||||
|
||||
this.showDocTooltip = function(item) {
|
||||
if (!this.tooltipNode) {
|
||||
this.tooltipNode = dom.createElement("pre");
|
||||
this.tooltipNode.className = "ace_tooltip ace_doc-tooltip";
|
||||
this.tooltipNode.style.margin = 0;
|
||||
this.tooltipNode.style.pointerEvents = "auto";
|
||||
this.tooltipNode.tabIndex = -1;
|
||||
this.tooltipNode.onblur = this.blurListener.bind(this);
|
||||
}
|
||||
|
||||
var tooltipNode = this.tooltipNode;
|
||||
if (item.docHTML) {
|
||||
tooltipNode.innerHTML = item.docHTML;
|
||||
} else if (item.docText) {
|
||||
tooltipNode.textContent = item.docText;
|
||||
}
|
||||
|
||||
if (!tooltipNode.parentNode)
|
||||
document.body.appendChild(tooltipNode);
|
||||
var popup = this.popup;
|
||||
var rect = popup.container.getBoundingClientRect();
|
||||
tooltipNode.style.top = popup.container.style.top;
|
||||
tooltipNode.style.bottom = popup.container.style.bottom;
|
||||
|
||||
if (window.innerWidth - rect.right < 320) {
|
||||
tooltipNode.style.right = window.innerWidth - rect.left + "px";
|
||||
tooltipNode.style.left = "";
|
||||
} else {
|
||||
tooltipNode.style.left = (rect.right + 1) + "px";
|
||||
tooltipNode.style.right = "";
|
||||
}
|
||||
// tooltipNode.style.height = rect.height + "px";
|
||||
tooltipNode.style.display = "block";
|
||||
};
|
||||
|
||||
this.hideDocTooltip = function() {
|
||||
this.tooltipTimer.cancel();
|
||||
if (!this.tooltipNode) return;
|
||||
var el = this.tooltipNode;
|
||||
if (!this.editor.isFocused() && document.activeElement == el)
|
||||
this.editor.focus();
|
||||
this.tooltipNode = null;
|
||||
if (el.parentNode)
|
||||
el.parentNode.removeChild(el);
|
||||
};
|
||||
|
||||
}).call(Autocomplete.prototype);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,13 +2,12 @@ define(function(require, exports, module) {
|
|||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var HashHandler = require("../keyboard/hash_handler").HashHandler;
|
||||
var MultiHashHandler = require("../keyboard/hash_handler").MultiHashHandler;
|
||||
var EventEmitter = require("../lib/event_emitter").EventEmitter;
|
||||
|
||||
/**
|
||||
* @class CommandManager
|
||||
*
|
||||
*
|
||||
**/
|
||||
|
||||
/**
|
||||
|
|
@ -19,20 +18,27 @@ var EventEmitter = require("../lib/event_emitter").EventEmitter;
|
|||
**/
|
||||
|
||||
var CommandManager = function(platform, commands) {
|
||||
HashHandler.call(this, commands, platform);
|
||||
MultiHashHandler.call(this, commands, platform);
|
||||
this.byName = this.commands;
|
||||
this.setDefaultHandler("exec", function(e) {
|
||||
return e.command.exec(e.editor, e.args || {});
|
||||
});
|
||||
};
|
||||
|
||||
oop.inherits(CommandManager, HashHandler);
|
||||
oop.inherits(CommandManager, MultiHashHandler);
|
||||
|
||||
(function() {
|
||||
|
||||
oop.implement(this, EventEmitter);
|
||||
|
||||
this.exec = function(command, editor, args) {
|
||||
if (Array.isArray(command)) {
|
||||
for (var i = command.length; i--; ) {
|
||||
if (this.exec(command[i], editor, args)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof command === "string")
|
||||
command = this.commands[command];
|
||||
|
||||
|
|
@ -43,10 +49,10 @@ oop.inherits(CommandManager, HashHandler);
|
|||
return false;
|
||||
|
||||
var e = {editor: editor, command: command, args: args};
|
||||
var retvalue = this._emit("exec", e);
|
||||
e.returnValue = this._emit("exec", e);
|
||||
this._signal("afterExec", e);
|
||||
|
||||
return retvalue === false ? false : true;
|
||||
return e.returnValue === false ? false : true;
|
||||
};
|
||||
|
||||
this.toggleRecording = function(editor) {
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ module.exports = {
|
|||
assert.equal(command, "cm2");
|
||||
|
||||
var command = this.cm.findKeyCommand(0, "return");
|
||||
assert.equal(command, "cm3");
|
||||
assert.equal(command + "", ["cm4", "cm3"] + "");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -289,13 +289,12 @@ function Folding() {
|
|||
if (startFold && endFold == startFold)
|
||||
return startFold.addSubFold(fold);
|
||||
|
||||
if (
|
||||
(startFold && !startFold.range.isStart(startRow, startColumn))
|
||||
|| (endFold && !endFold.range.isEnd(endRow, endColumn))
|
||||
) {
|
||||
throw new Error("A fold can't intersect already existing fold" + fold.range + startFold.range);
|
||||
}
|
||||
|
||||
if (startFold && !startFold.range.isStart(startRow, startColumn))
|
||||
this.removeFold(startFold);
|
||||
|
||||
if (endFold && !endFold.range.isEnd(endRow, endColumn))
|
||||
this.removeFold(endFold);
|
||||
|
||||
// Check if there are folds in the range we create the new fold for.
|
||||
var folds = this.getFoldsInRange(fold.range);
|
||||
if (folds.length > 0) {
|
||||
|
|
|
|||
|
|
@ -115,30 +115,8 @@ var Editor = function(renderer, session) {
|
|||
function last(a) {return a[a.length - 1]}
|
||||
|
||||
this.selections = [];
|
||||
this.commands.on("exec", function(e) {
|
||||
this.startOperation(e);
|
||||
|
||||
var command = e.command;
|
||||
if (command.aceCommandGroup == "fileJump") {
|
||||
var prev = this.prevOp;
|
||||
if (!prev || prev.command.aceCommandGroup != "fileJump") {
|
||||
this.lastFileJumpPos = last(this.selections);
|
||||
}
|
||||
} else {
|
||||
this.lastFileJumpPos = null;
|
||||
}
|
||||
}.bind(this), true);
|
||||
|
||||
this.commands.on("afterExec", function(e) {
|
||||
var command = e.command;
|
||||
|
||||
if (command.aceCommandGroup == "fileJump") {
|
||||
if (this.lastFileJumpPos && !this.curOp.selectionChanged) {
|
||||
this.selection.fromJSON(this.lastFileJumpPos);
|
||||
}
|
||||
}
|
||||
this.endOperation(e);
|
||||
}.bind(this), true);
|
||||
this.commands.on("exec", this.startOperation.bind(this), true);
|
||||
this.commands.on("afterExec", this.endOperation.bind(this), true);
|
||||
|
||||
this.$opResetTimer = lang.delayedCall(this.endOperation.bind(this));
|
||||
|
||||
|
|
@ -173,18 +151,16 @@ var Editor = function(renderer, session) {
|
|||
scrollTop: this.renderer.scrollTop
|
||||
};
|
||||
|
||||
var command = this.curOp.command;
|
||||
if (command && command.scrollIntoView)
|
||||
this.$blockScrolling++;
|
||||
|
||||
this.selections.push(this.selection.toJSON());
|
||||
// this.selections.push(this.selection.toJSON());
|
||||
};
|
||||
|
||||
this.endOperation = function() {
|
||||
this.endOperation = function(e) {
|
||||
if (this.curOp) {
|
||||
if (e && e.returnValue === false)
|
||||
return this.curOp = null;
|
||||
|
||||
var command = this.curOp.command;
|
||||
if (command && command.scrollIntoView) {
|
||||
this.$blockScrolling--;
|
||||
switch (command.scrollIntoView) {
|
||||
case "center":
|
||||
this.renderer.scrollCursorIntoView(null, 0.5);
|
||||
|
|
@ -255,19 +231,19 @@ var Editor = function(renderer, session) {
|
|||
* @param {String} keyboardHandler The new key handler
|
||||
*
|
||||
**/
|
||||
this.setKeyboardHandler = function(keyboardHandler) {
|
||||
if (!keyboardHandler) {
|
||||
this.keyBinding.setKeyboardHandler(null);
|
||||
} else if (typeof keyboardHandler === "string") {
|
||||
this.setKeyboardHandler = function(keyboardHandler, cb) {
|
||||
if (keyboardHandler && typeof keyboardHandler === "string") {
|
||||
this.$keybindingId = keyboardHandler;
|
||||
var _self = this;
|
||||
config.loadModule(["keybinding", keyboardHandler], function(module) {
|
||||
if (_self.$keybindingId == keyboardHandler)
|
||||
_self.keyBinding.setKeyboardHandler(module && module.handler);
|
||||
cb && cb();
|
||||
});
|
||||
} else {
|
||||
this.$keybindingId = null;
|
||||
this.keyBinding.setKeyboardHandler(keyboardHandler);
|
||||
cb && cb();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -662,13 +638,13 @@ var Editor = function(renderer, session) {
|
|||
*
|
||||
*
|
||||
**/
|
||||
this.onFocus = function() {
|
||||
this.onFocus = function(e) {
|
||||
if (this.$isFocused)
|
||||
return;
|
||||
this.$isFocused = true;
|
||||
this.renderer.showCursor();
|
||||
this.renderer.visualizeFocus();
|
||||
this._emit("focus");
|
||||
this._emit("focus", e);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -677,13 +653,13 @@ var Editor = function(renderer, session) {
|
|||
*
|
||||
*
|
||||
**/
|
||||
this.onBlur = function() {
|
||||
this.onBlur = function(e) {
|
||||
if (!this.$isFocused)
|
||||
return;
|
||||
this.$isFocused = false;
|
||||
this.renderer.hideCursor();
|
||||
this.renderer.visualizeBlur();
|
||||
this._emit("blur");
|
||||
this._emit("blur", e);
|
||||
};
|
||||
|
||||
this.$cursorChange = function() {
|
||||
|
|
@ -927,9 +903,8 @@ var Editor = function(renderer, session) {
|
|||
this.insert(e.text, true);
|
||||
};
|
||||
|
||||
|
||||
this.execCommand = function(command, args) {
|
||||
this.commands.exec(command, this, args);
|
||||
return this.commands.exec(command, this, args);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -2541,7 +2516,9 @@ var Editor = function(renderer, session) {
|
|||
rect = self.renderer.container.getBoundingClientRect();
|
||||
});
|
||||
var onAfterRender = this.renderer.on("afterRender", function() {
|
||||
if (shouldScroll && rect && self.isFocused()) {
|
||||
if (shouldScroll && rect && (self.isFocused()
|
||||
|| self.searchBox && self.searchBox.isFocused())
|
||||
) {
|
||||
var renderer = self.renderer;
|
||||
var pos = renderer.$cursorLayer.$pixelPos;
|
||||
var config = renderer.layerConfig;
|
||||
|
|
|
|||
|
|
@ -34,15 +34,7 @@ var HashHandler = require("ace/keyboard/hash_handler").HashHandler;
|
|||
var Editor = require("ace/editor").Editor;
|
||||
var snippetManager = require("ace/snippets").snippetManager;
|
||||
var Range = require("ace/range").Range;
|
||||
var emmet;
|
||||
|
||||
Editor.prototype.indexToPosition = function(index) {
|
||||
return this.session.doc.indexToPosition(index);
|
||||
};
|
||||
|
||||
Editor.prototype.positionToIndex = function(pos) {
|
||||
return this.session.doc.positionToIndex(pos);
|
||||
};
|
||||
var emmet, emmetPath;
|
||||
|
||||
/**
|
||||
* Implementation of {@link IEmmetEditor} interface for Ace
|
||||
|
|
@ -72,9 +64,10 @@ AceEmmetEditor.prototype = {
|
|||
getSelectionRange: function() {
|
||||
// TODO should start be caret position instead?
|
||||
var range = this.ace.getSelectionRange();
|
||||
var doc = this.ace.session.doc;
|
||||
return {
|
||||
start: this.ace.positionToIndex(range.start),
|
||||
end: this.ace.positionToIndex(range.end)
|
||||
start: doc.positionToIndex(range.start),
|
||||
end: doc.positionToIndex(range.end)
|
||||
};
|
||||
},
|
||||
|
||||
|
|
@ -91,9 +84,10 @@ AceEmmetEditor.prototype = {
|
|||
* editor.createSelection(15);
|
||||
*/
|
||||
createSelection: function(start, end) {
|
||||
var doc = this.ace.session.doc;
|
||||
this.ace.selection.setRange({
|
||||
start: this.ace.indexToPosition(start),
|
||||
end: this.ace.indexToPosition(end)
|
||||
start: doc.indexToPosition(start),
|
||||
end: doc.indexToPosition(end)
|
||||
});
|
||||
},
|
||||
|
||||
|
|
@ -106,9 +100,10 @@ AceEmmetEditor.prototype = {
|
|||
* alert(range.start + ', ' + range.end);
|
||||
*/
|
||||
getCurrentLineRange: function() {
|
||||
var row = this.ace.getCursorPosition().row;
|
||||
var lineLength = this.ace.session.getLine(row).length;
|
||||
var index = this.ace.positionToIndex({row: row, column: 0});
|
||||
var ace = this.ace;
|
||||
var row = ace.getCursorPosition().row;
|
||||
var lineLength = ace.session.getLine(row).length;
|
||||
var index = ace.session.doc.positionToIndex({row: row, column: 0});
|
||||
return {
|
||||
start: index,
|
||||
end: index + lineLength
|
||||
|
|
@ -121,7 +116,7 @@ AceEmmetEditor.prototype = {
|
|||
*/
|
||||
getCaretPos: function(){
|
||||
var pos = this.ace.getCursorPosition();
|
||||
return this.ace.positionToIndex(pos);
|
||||
return this.ace.session.doc.positionToIndex(pos);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -129,7 +124,7 @@ AceEmmetEditor.prototype = {
|
|||
* @param {Number} index Caret position
|
||||
*/
|
||||
setCaretPos: function(index){
|
||||
var pos = this.ace.indexToPosition(index);
|
||||
var pos = this.ace.session.doc.indexToPosition(index);
|
||||
this.ace.selection.moveToPosition(pos);
|
||||
},
|
||||
|
||||
|
|
@ -169,14 +164,15 @@ AceEmmetEditor.prototype = {
|
|||
start = 0;
|
||||
|
||||
var editor = this.ace;
|
||||
var range = Range.fromPoints(editor.indexToPosition(start), editor.indexToPosition(end));
|
||||
var doc = editor.session.doc;
|
||||
var range = Range.fromPoints(doc.indexToPosition(start), doc.indexToPosition(end));
|
||||
editor.session.remove(range);
|
||||
|
||||
range.end = range.start;
|
||||
//editor.selection.setRange(range);
|
||||
|
||||
value = this.$updateTabstops(value);
|
||||
snippetManager.insertSnippet(editor, value)
|
||||
snippetManager.insertSnippet(editor, value);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -292,7 +288,7 @@ AceEmmetEditor.prototype = {
|
|||
lastZero = range.create(data.start, result);
|
||||
}
|
||||
|
||||
return result
|
||||
return result;
|
||||
},
|
||||
escape: function(ch) {
|
||||
if (ch == '$') return '\\$';
|
||||
|
|
@ -363,12 +359,17 @@ exports.runEmmetCommand = function(editor) {
|
|||
}, 0);
|
||||
}
|
||||
|
||||
var pos = editor.selection.lead;
|
||||
var token = editor.session.getTokenAt(pos.row, pos.column);
|
||||
if (token && /\btag\b/.test(token.type))
|
||||
return false;
|
||||
|
||||
try {
|
||||
var result = actions.run(this.action, editorProxy);
|
||||
} catch(e) {
|
||||
editor._signal("changeStatus", typeof e == "string" ? e : e.message);
|
||||
console.log(e);
|
||||
result = false
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
|
@ -383,21 +384,36 @@ for (var command in keymap) {
|
|||
});
|
||||
}
|
||||
|
||||
exports.updateCommands = function(editor, enabled) {
|
||||
if (enabled) {
|
||||
editor.keyBinding.addKeyboardHandler(exports.commands);
|
||||
} else {
|
||||
editor.keyBinding.removeKeyboardHandler(exports.commands);
|
||||
}
|
||||
};
|
||||
|
||||
exports.isSupportedMode = function(modeId) {
|
||||
return modeId && /css|less|scss|sass|stylus|html|php|twig/.test(modeId);
|
||||
};
|
||||
|
||||
var onChangeMode = function(e, target) {
|
||||
var editor = target;
|
||||
if (!editor)
|
||||
return;
|
||||
var modeId = editor.session.$modeId;
|
||||
var enabled = modeId && /css|less|scss|sass|stylus|html|php/.test(modeId);
|
||||
var enabled = exports.isSupportedMode(editor.session.$modeId);
|
||||
if (e.enableEmmet === false)
|
||||
enabled = false;
|
||||
if (enabled)
|
||||
editor.keyBinding.addKeyboardHandler(exports.commands);
|
||||
else
|
||||
editor.keyBinding.removeKeyboardHandler(exports.commands);
|
||||
if (enabled) {
|
||||
if (typeof emmetPath == "string") {
|
||||
require("ace/config").loadModule(emmetPath, function() {
|
||||
|
||||
});
|
||||
emmetPath = null;
|
||||
}
|
||||
}
|
||||
exports.updateCommands(editor, enabled);
|
||||
};
|
||||
|
||||
|
||||
exports.AceEmmetEditor = AceEmmetEditor;
|
||||
require("ace/config").defineOptions(Editor.prototype, "editor", {
|
||||
enableEmmet: {
|
||||
|
|
@ -409,7 +425,11 @@ require("ace/config").defineOptions(Editor.prototype, "editor", {
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
exports.setCore = function(e) {emmet = e;};
|
||||
exports.setCore = function(e) {
|
||||
if (typeof e == "string")
|
||||
emmetPath = e;
|
||||
else
|
||||
emmet = e;
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ define(function(require, exports, module) {
|
|||
var snippetManager = require("../snippets").snippetManager;
|
||||
var Autocomplete = require("../autocomplete").Autocomplete;
|
||||
var config = require("../config");
|
||||
var lang = require("../lib/lang");
|
||||
var util = require("../autocomplete/util");
|
||||
|
||||
var textCompleter = require("../autocomplete/text_completer");
|
||||
|
|
@ -59,15 +60,29 @@ var snippetCompleter = {
|
|||
completions.push({
|
||||
caption: caption,
|
||||
snippet: s.content,
|
||||
meta: s.tabTrigger && !s.name ? s.tabTrigger + "\u21E5 " : "snippet"
|
||||
meta: s.tabTrigger && !s.name ? s.tabTrigger + "\u21E5 " : "snippet",
|
||||
type: "snippet"
|
||||
});
|
||||
}
|
||||
}, this);
|
||||
callback(null, completions);
|
||||
},
|
||||
getDocTooltip: function(item) {
|
||||
if (item.type == "snippet" && !item.docHTML) {
|
||||
item.docHTML = [
|
||||
"<b>", lang.escapeHTML(item.caption), "</b>", "<hr></hr>",
|
||||
lang.escapeHTML(item.snippet)
|
||||
].join("");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var completers = [snippetCompleter, textCompleter, keyWordCompleter];
|
||||
// Allows default completers to be removed or replaced with a explict set of completers
|
||||
// A null argument here will result in an empty completer array, not a null attribute
|
||||
exports.setCompleters = function(val) {
|
||||
completers = val || [];
|
||||
};
|
||||
exports.addCompleter = function(completer) {
|
||||
completers.push(completer);
|
||||
};
|
||||
|
|
@ -80,9 +95,7 @@ exports.snippetCompleter = snippetCompleter;
|
|||
var expandSnippet = {
|
||||
name: "expandSnippet",
|
||||
exec: function(editor) {
|
||||
var success = snippetManager.expandWithTab(editor);
|
||||
if (!success)
|
||||
editor.execCommand("indent");
|
||||
return snippetManager.expandWithTab(editor);
|
||||
},
|
||||
bindKey: "Tab"
|
||||
};
|
||||
|
|
|
|||
|
|
@ -69,29 +69,20 @@ module.exports.getEditorKeybordShortcuts = function(editor) {
|
|||
editor.keyBinding.$handlers.forEach(function(handler) {
|
||||
var ckb = handler.commandKeyBinding;
|
||||
for (var i in ckb) {
|
||||
var modifier = parseInt(i);
|
||||
if (modifier == -1) {
|
||||
modifier = "";
|
||||
} else if(isNaN(modifier)) {
|
||||
modifier = i;
|
||||
} else {
|
||||
modifier = "" +
|
||||
(modifier & KEY_MODS.command ? "Cmd-" : "") +
|
||||
(modifier & KEY_MODS.ctrl ? "Ctrl-" : "") +
|
||||
(modifier & KEY_MODS.alt ? "Alt-" : "") +
|
||||
(modifier & KEY_MODS.shift ? "Shift-" : "");
|
||||
}
|
||||
for (var key in ckb[i]) {
|
||||
var command = ckb[i][key]
|
||||
var key = i.replace(/(^|-)\w/g, function(x) { return x.toUpperCase(); });
|
||||
var commands = ckb[i];
|
||||
if (!Array.isArray(commands))
|
||||
commands = [commands];
|
||||
commands.forEach(function(command) {
|
||||
if (typeof command != "string")
|
||||
command = command.name
|
||||
if (commandMap[command]) {
|
||||
commandMap[command].key += "|" + modifier + key;
|
||||
commandMap[command].key += "|" + key;
|
||||
} else {
|
||||
commandMap[command] = {key: modifier+key, command: command};
|
||||
commandMap[command] = {key: key, command: command};
|
||||
keybindings.push(commandMap[command]);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return keybindings;
|
||||
|
|
|
|||
|
|
@ -65,8 +65,11 @@ var supportedModes = {
|
|||
Diff: ["diff|patch"],
|
||||
Dockerfile: ["^Dockerfile"],
|
||||
Dot: ["dot"],
|
||||
Dummy: ["dummy"],
|
||||
DummySyntax: ["dummy"],
|
||||
Eiffel: ["e"],
|
||||
EJS: ["ejs"],
|
||||
Elm: ["elm"],
|
||||
Erlang: ["erl|hrl"],
|
||||
Forth: ["frt|fs|ldr"],
|
||||
FTL: ["ftl"],
|
||||
|
|
|
|||
|
|
@ -281,6 +281,10 @@ var SearchBox = function(editor, range, showReplaceForm) {
|
|||
this.editor.keyBinding.addKeyboardHandler(this.$closeSearchBarKb);
|
||||
};
|
||||
|
||||
this.isFocused = function() {
|
||||
var el = document.activeElement;
|
||||
return el == this.searchInput || el == this.replaceInput;
|
||||
}
|
||||
}).call(SearchBox.prototype);
|
||||
|
||||
exports.SearchBox = SearchBox;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ exports.handler.attach = function(editor) {
|
|||
initialized = true;
|
||||
dom.importCssString('\
|
||||
.emacs-mode .ace_cursor{\
|
||||
border: 2px rgba(50,250,50,0.8) solid!important;\
|
||||
border: 1px rgba(50,250,50,0.8) solid!important;\
|
||||
-moz-box-sizing: border-box!important;\
|
||||
-webkit-box-sizing: border-box!important;\
|
||||
box-sizing: border-box!important;\
|
||||
|
|
@ -195,6 +195,8 @@ exports.handler.onPaste = function(e, editor) {
|
|||
};
|
||||
|
||||
exports.handler.bindKey = function(key, command) {
|
||||
if (typeof key == "object")
|
||||
key = key[this.platform];
|
||||
if (!key)
|
||||
return;
|
||||
|
||||
|
|
|
|||
|
|
@ -33,37 +33,25 @@ define(function(require, exports, module) {
|
|||
|
||||
var keyUtil = require("../lib/keys");
|
||||
var useragent = require("../lib/useragent");
|
||||
var KEY_MODS = keyUtil.KEY_MODS;
|
||||
|
||||
function HashHandler(config, platform) {
|
||||
this.platform = platform || (useragent.isMac ? "mac" : "win");
|
||||
this.commands = {};
|
||||
this.commandKeyBinding = {};
|
||||
|
||||
// todo remove this after a while
|
||||
if (this.__defineGetter__ && this.__defineSetter__ && typeof console != "undefined" && console.error) {
|
||||
var warned = false;
|
||||
var warn = function() {
|
||||
if (!warned) {
|
||||
warned = true;
|
||||
console.error("commmandKeyBinding has too many m's. use commandKeyBinding");
|
||||
}
|
||||
};
|
||||
this.__defineGetter__("commmandKeyBinding", function() {
|
||||
warn();
|
||||
return this.commandKeyBinding;
|
||||
});
|
||||
this.__defineSetter__("commmandKeyBinding", function(val) {
|
||||
warn();
|
||||
return this.commandKeyBinding = val;
|
||||
});
|
||||
} else {
|
||||
this.commmandKeyBinding = this.commandKeyBinding;
|
||||
}
|
||||
|
||||
this.addCommands(config);
|
||||
};
|
||||
this.$singleCommand = true;
|
||||
}
|
||||
|
||||
function MultiHashHandler(config, platform) {
|
||||
HashHandler.call(this, config, platform);
|
||||
this.$singleCommand = false;
|
||||
}
|
||||
|
||||
MultiHashHandler.prototype = HashHandler.prototype;
|
||||
|
||||
(function() {
|
||||
|
||||
|
||||
this.addCommand = function(command) {
|
||||
if (this.commands[command.name])
|
||||
|
|
@ -75,37 +63,76 @@ function HashHandler(config, platform) {
|
|||
this._buildKeyHash(command);
|
||||
};
|
||||
|
||||
this.removeCommand = function(command) {
|
||||
var name = (typeof command === 'string' ? command : command.name);
|
||||
this.removeCommand = function(command, keepCommand) {
|
||||
var name = command && (typeof command === 'string' ? command : command.name);
|
||||
command = this.commands[name];
|
||||
delete this.commands[name];
|
||||
if (!keepCommand)
|
||||
delete this.commands[name];
|
||||
|
||||
// exhaustive search is brute force but since removeCommand is
|
||||
// not a performance critical operation this should be OK
|
||||
var ckb = this.commandKeyBinding;
|
||||
for (var hashId in ckb) {
|
||||
for (var key in ckb[hashId]) {
|
||||
if (ckb[hashId][key] == command)
|
||||
delete ckb[hashId][key];
|
||||
for (var keyId in ckb) {
|
||||
var cmdGroup = ckb[keyId];
|
||||
if (cmdGroup == command) {
|
||||
delete ckb[keyId];
|
||||
} else if (Array.isArray(cmdGroup)) {
|
||||
var i = cmdGroup.indexOf(command);
|
||||
if (i != -1) {
|
||||
cmdGroup.splice(i, 1);
|
||||
if (cmdGroup.length == 1)
|
||||
ckb[keyId] = cmdGroup[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.bindKey = function(key, command) {
|
||||
if(!key)
|
||||
this.bindKey = function(key, command, asDefault) {
|
||||
if (typeof key == "object")
|
||||
key = key[this.platform];
|
||||
if (!key)
|
||||
return;
|
||||
if (typeof command == "function") {
|
||||
this.addCommand({exec: command, bindKey: key, name: command.name || key});
|
||||
return;
|
||||
}
|
||||
|
||||
var ckb = this.commandKeyBinding;
|
||||
if (typeof command == "function")
|
||||
return this.addCommand({exec: command, bindKey: key, name: command.name || key});
|
||||
|
||||
key.split("|").forEach(function(keyPart) {
|
||||
var binding = this.parseKeys(keyPart, command);
|
||||
var hashId = binding.hashId;
|
||||
(ckb[hashId] || (ckb[hashId] = {}))[binding.key] = command;
|
||||
var chain = "";
|
||||
if (keyPart.indexOf(" ") != -1) {
|
||||
var parts = keyPart.split(/\s+/);
|
||||
keyPart = parts.pop();
|
||||
parts.forEach(function(keyPart) {
|
||||
var binding = this.parseKeys(keyPart);
|
||||
var id = KEY_MODS[binding.hashId] + binding.key;
|
||||
chain += (chain ? " " : "") + id;
|
||||
this._addCommandToBinding(chain, "chainKeys");
|
||||
}, this);
|
||||
chain += " ";
|
||||
}
|
||||
var binding = this.parseKeys(keyPart);
|
||||
var id = KEY_MODS[binding.hashId] + binding.key;
|
||||
this._addCommandToBinding(chain + id, command, asDefault);
|
||||
}, this);
|
||||
};
|
||||
|
||||
this._addCommandToBinding = function(keyId, command, asDefault) {
|
||||
var ckb = this.commandKeyBinding, i;
|
||||
if (!command) {
|
||||
delete ckb[keyId];
|
||||
} else if (!ckb[keyId] || this.$singleCommand) {
|
||||
ckb[keyId] = command;
|
||||
} else {
|
||||
if (!Array.isArray(ckb[keyId])) {
|
||||
ckb[keyId] = [ckb[keyId]];
|
||||
} else if ((i = ckb[keyId].indexOf(command)) != -1) {
|
||||
ckb[keyId].splice(i, 1);
|
||||
}
|
||||
|
||||
if (asDefault || command.isDefault)
|
||||
ckb[keyId].unshift(command);
|
||||
else
|
||||
ckb[keyId].push(command);
|
||||
}
|
||||
};
|
||||
|
||||
this.addCommands = function(commands) {
|
||||
commands && Object.keys(commands).forEach(function(name) {
|
||||
|
|
@ -142,21 +169,12 @@ function HashHandler(config, platform) {
|
|||
};
|
||||
|
||||
this._buildKeyHash = function(command) {
|
||||
var binding = command.bindKey;
|
||||
if (!binding)
|
||||
return;
|
||||
|
||||
var key = typeof binding == "string" ? binding: binding[this.platform];
|
||||
this.bindKey(key, command);
|
||||
this.bindKey(command.bindKey, command);
|
||||
};
|
||||
|
||||
// accepts keys in the form ctrl+Enter or ctrl-Enter
|
||||
// keys without modifiers or shift only
|
||||
this.parseKeys = function(keys) {
|
||||
// todo support keychains
|
||||
if (keys.indexOf(" ") != -1)
|
||||
keys = keys.split(/\s+/).pop();
|
||||
|
||||
var parts = keys.toLowerCase().split(/[\-\+]([\-\+])?/).filter(function(x){return x});
|
||||
var key = parts.pop();
|
||||
|
||||
|
|
@ -173,7 +191,7 @@ function HashHandler(config, platform) {
|
|||
var modifier = keyUtil.KEY_MODS[parts[i]];
|
||||
if (modifier == null) {
|
||||
if (typeof console != "undefined")
|
||||
console.error("invalid modifier " + parts[i] + " in " + keys);
|
||||
console.error("invalid modifier " + parts[i] + " in " + keys);
|
||||
return false;
|
||||
}
|
||||
hashId |= modifier;
|
||||
|
|
@ -182,17 +200,32 @@ function HashHandler(config, platform) {
|
|||
};
|
||||
|
||||
this.findKeyCommand = function findKeyCommand(hashId, keyString) {
|
||||
var ckbr = this.commandKeyBinding;
|
||||
return ckbr[hashId] && ckbr[hashId][keyString];
|
||||
var key = KEY_MODS[hashId] + keyString;
|
||||
return this.commandKeyBinding[key];
|
||||
};
|
||||
|
||||
this.handleKeyboard = function(data, hashId, keyString, keyCode) {
|
||||
return {
|
||||
command: this.findKeyCommand(hashId, keyString)
|
||||
};
|
||||
var key = KEY_MODS[hashId] + keyString;
|
||||
var command = this.commandKeyBinding[key];
|
||||
if (data.$keyChain) {
|
||||
data.$keyChain += " " + key;
|
||||
command = this.commandKeyBinding[data.$keyChain] || command;
|
||||
}
|
||||
|
||||
if (command) {
|
||||
if (command == "chainKeys" || command[command.length - 1] == "chainKeys") {
|
||||
data.$keyChain = data.$keyChain || key;
|
||||
return {command: "null"};
|
||||
}
|
||||
}
|
||||
|
||||
if (data.$keyChain && keyCode > 0)
|
||||
data.$keyChain = "";
|
||||
return {command: command};
|
||||
};
|
||||
|
||||
}).call(HashHandler.prototype)
|
||||
}).call(HashHandler.prototype);
|
||||
|
||||
exports.HashHandler = HashHandler;
|
||||
exports.MultiHashHandler = MultiHashHandler;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -66,13 +66,13 @@ var TextInput = function(parentNode, host) {
|
|||
// ie9 throws error if document.activeElement is accessed too soon
|
||||
try { var isFocused = document.activeElement === text; } catch(e) {}
|
||||
|
||||
event.addListener(text, "blur", function() {
|
||||
host.onBlur();
|
||||
event.addListener(text, "blur", function(e) {
|
||||
host.onBlur(e);
|
||||
isFocused = false;
|
||||
});
|
||||
event.addListener(text, "focus", function() {
|
||||
event.addListener(text, "focus", function(e) {
|
||||
isFocused = true;
|
||||
host.onFocus();
|
||||
host.onFocus(e);
|
||||
resetSelection();
|
||||
});
|
||||
this.focus = function() { text.focus(); };
|
||||
|
|
|
|||
|
|
@ -145,6 +145,9 @@ var Keys = (function() {
|
|||
}
|
||||
})();
|
||||
|
||||
ret.KEY_MODS[0] = "";
|
||||
ret.KEY_MODS[-1] = "input";
|
||||
|
||||
return ret;
|
||||
})();
|
||||
oop.mixin(exports, Keys);
|
||||
|
|
|
|||
|
|
@ -45,9 +45,10 @@ function LineWidgets(session) {
|
|||
this.renderWidgets = this.renderWidgets.bind(this);
|
||||
this.measureWidgets = this.measureWidgets.bind(this);
|
||||
this.session._changedWidgets = [];
|
||||
this.detach = this.detach.bind(this);
|
||||
this.$onChangeEditor = this.$onChangeEditor.bind(this);
|
||||
|
||||
this.session.on("change", this.updateOnChange);
|
||||
this.session.on("changeEditor", this.$onChangeEditor);
|
||||
}
|
||||
|
||||
(function() {
|
||||
|
|
@ -73,8 +74,12 @@ function LineWidgets(session) {
|
|||
return screenRows;
|
||||
};
|
||||
|
||||
this.$onChangeEditor = function(e) {
|
||||
this.attach(e.editor);
|
||||
};
|
||||
|
||||
this.attach = function(editor) {
|
||||
if (editor.widgetManager && editor.widgetManager != this)
|
||||
if (editor && editor.widgetManager && editor.widgetManager != this)
|
||||
editor.widgetManager.detach();
|
||||
|
||||
if (this.editor == editor)
|
||||
|
|
@ -83,21 +88,16 @@ function LineWidgets(session) {
|
|||
this.detach();
|
||||
this.editor = editor;
|
||||
|
||||
this.editor.on("changeSession", this.detach);
|
||||
|
||||
editor.widgetManager = this;
|
||||
|
||||
editor.renderer.on("beforeRender", this.measureWidgets);
|
||||
editor.renderer.on("afterRender", this.renderWidgets);
|
||||
if (editor) {
|
||||
editor.widgetManager = this;
|
||||
editor.renderer.on("beforeRender", this.measureWidgets);
|
||||
editor.renderer.on("afterRender", this.renderWidgets);
|
||||
}
|
||||
};
|
||||
this.detach = function(e) {
|
||||
if (e && e.session == this.session)
|
||||
return; // sometimes attach can be called before setSession
|
||||
var editor = this.editor;
|
||||
if (!editor)
|
||||
return;
|
||||
|
||||
editor.off("changeSession", this.detach);
|
||||
|
||||
this.editor = null;
|
||||
editor.widgetManager = null;
|
||||
|
|
|
|||
|
|
@ -1,20 +1,66 @@
|
|||
var fs = require("fs");
|
||||
var path = require("path");
|
||||
if (!fs.existsSync)
|
||||
fs.existsSync = require("path").existsSync;
|
||||
fs.existsSync = path.existsSync;
|
||||
|
||||
require("amd-loader");
|
||||
|
||||
var cwd = __dirname + "/";
|
||||
var root = path.normalize(cwd + Array(5).join("../"));
|
||||
|
||||
function jsFileList(path, filter) {
|
||||
if (!filter) filter = /_test/;
|
||||
return fs.readdirSync(path).map(function(x) {
|
||||
if (x.slice(-3) == ".js" && !filter.test(x) && !/\s/.test(x))
|
||||
return x.slice(0, -3);
|
||||
}).filter(Boolean);
|
||||
}
|
||||
|
||||
function modeList() {
|
||||
return jsFileList(cwd + "../", /_highlight_rules|_test|_worker|xml_util|_outdent|behaviour|completions/);
|
||||
}
|
||||
|
||||
function checkModes() {
|
||||
modeList().forEach(function(modeName) {
|
||||
try {
|
||||
var Mode = require("../" + modeName).Mode;
|
||||
} catch(e) {
|
||||
console.warn("Can't load mode :" + modeName, e);
|
||||
return;
|
||||
}
|
||||
var m = new Mode();
|
||||
if (!m.lineCommentStart && !m.blockComment)
|
||||
console.warn("missing comment in " + modeName);
|
||||
if (!m.$id)
|
||||
console.warn("missing id in " + modeName);
|
||||
var tokenizer = (new Mode).getTokenizer();
|
||||
if (m.lineCommentStart) {
|
||||
if (Array.isArray(m.lineCommentStart)) {
|
||||
m.lineCommentStart.forEach(function(x) {
|
||||
testLineComment(tokenizer, x, modeName)
|
||||
});
|
||||
} else {
|
||||
testLineComment(tokenizer, m.lineCommentStart, modeName)
|
||||
}
|
||||
}
|
||||
// if (m.blockComment) {
|
||||
// var tokens = tok.getLineTokens(m.lineCommentStart, "start");
|
||||
// if (!/comment/.test(tokens[0]))
|
||||
// console.warn("broken lineCommentStart in " + modeName);
|
||||
// }
|
||||
});
|
||||
|
||||
function testLineComment(tokenizer, commentStart, modeName) {
|
||||
var tokens = tokenizer.getLineTokens(commentStart + " ", "start").tokens;
|
||||
if (!/comment/.test(tokens[0].type))
|
||||
console.warn("broken lineCommentStart in " + modeName);
|
||||
}
|
||||
}
|
||||
|
||||
function generateTestData() {
|
||||
var root = Array(5).join("../") + "/demo/kitchen-sink/docs";
|
||||
var docs = fs.readdirSync(cwd + root);
|
||||
var docs = jsFileList(cwd + root);
|
||||
var specialDocs = fs.readdirSync(cwd);
|
||||
var modes = fs.readdirSync(cwd + "../").filter(function(x){
|
||||
return !/(_highlight_rules|behaviour|worker)\.js$/.test(x) && /\.js$/.test(x);
|
||||
}).map(function(x) {
|
||||
return x.replace(/\.js$/, "");
|
||||
});
|
||||
var modes = modeList();
|
||||
|
||||
console.log("Docs:", docs);
|
||||
console.log("Modes:", modes);
|
||||
|
|
@ -61,7 +107,7 @@ function generateTestData() {
|
|||
return tmp.join(",\n ");
|
||||
});
|
||||
|
||||
jsonStr = "[[\n " + data.join("\n],[\n ") + "\n]]";
|
||||
var jsonStr = "[[\n " + data.join("\n],[\n ") + "\n]]";
|
||||
fs.writeFileSync(cwd + "tokens_" + modeName + ".json", jsonStr, "utf8");
|
||||
});
|
||||
}
|
||||
|
|
@ -91,7 +137,7 @@ function testMode(modeName, i) {
|
|||
lineData.state = lineData.shift();
|
||||
var line = null;
|
||||
if (typeof lineData[lineData.length - 1] == "string")
|
||||
line = lineData.pop()
|
||||
line = lineData.pop();
|
||||
lineData.forEach(function(x) {
|
||||
lineData.types.push(x[0]);
|
||||
lineData.values.push(x[1]);
|
||||
|
|
@ -103,14 +149,13 @@ function testMode(modeName, i) {
|
|||
var values = tokens.tokens.map(function(x) {return x.value;});
|
||||
var types = tokens.tokens.map(function(x) {return x.type;});
|
||||
|
||||
var success = true;
|
||||
var err = testEqual([
|
||||
JSON.stringify(lineData.state), JSON.stringify(tokens.state),
|
||||
lineData.types, types,
|
||||
lineData.values, values]);
|
||||
|
||||
if (err) {
|
||||
console.log(line)
|
||||
console.log(line);
|
||||
throw "error";
|
||||
}
|
||||
|
||||
|
|
@ -150,10 +195,12 @@ function padNumber(num, digits) {
|
|||
// cli
|
||||
var arg = process.argv[2];
|
||||
if (!arg)
|
||||
test()
|
||||
test();
|
||||
else if (/--?g(en)?/.test(arg))
|
||||
generateTestData(process.argv.splice(3));
|
||||
else if (/--?c(heck)?/.test(arg))
|
||||
checkModes(process.argv.splice(3));
|
||||
else if (/\d+/.test(arg))
|
||||
test(parseInt(process.argv[2],10) || 0);
|
||||
else
|
||||
testMode(arg, -1)
|
||||
testMode(arg, -1);
|
||||
|
|
@ -11,13 +11,13 @@
|
|||
["comment","# Repo formats:"]
|
||||
],[
|
||||
"start",
|
||||
["comment","# ssh git@github.com:richoH/gh_pr.git"]
|
||||
["comment","# ssh git@github.com:richo/gh_pr.git"]
|
||||
],[
|
||||
"start",
|
||||
["comment","# http https://richoH@github.com/richoH/gh_pr.git"]
|
||||
["comment","# http https://richoH@github.com/richo/gh_pr.git"]
|
||||
],[
|
||||
"start",
|
||||
["comment","# git git://github.com/richoH/gh_pr.git"]
|
||||
["comment","# git git://github.com/richo/gh_pr.git"]
|
||||
],[
|
||||
"start"
|
||||
],[
|
||||
|
|
@ -331,4 +331,4 @@
|
|||
["keyword","fi"]
|
||||
],[
|
||||
"start"
|
||||
]]
|
||||
]]
|
||||
|
|
|
|||
|
|
@ -27,10 +27,6 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -26,11 +26,6 @@
|
|||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
|
|
@ -53,7 +48,7 @@ var Mode = function() {
|
|||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.lineCommentStart = "/\\*";
|
||||
this.lineCommentStart = ";";
|
||||
this.blockComment = {start: "/*", end: "*/"};
|
||||
this.$id = "ace/mode/autohotkey";
|
||||
}).call(Mode.prototype);
|
||||
|
|
|
|||
|
|
@ -50,11 +50,12 @@ var c_cppHighlightRules = function() {
|
|||
// regexp must not have capturing parentheses. Use (?:) instead.
|
||||
// regexps are ordered -> the first match is used
|
||||
|
||||
this.$rules = {
|
||||
this.$rules = {
|
||||
"start" : [
|
||||
{
|
||||
token : "comment",
|
||||
regex : "\\/\\/.*$"
|
||||
regex : "//",
|
||||
next : "singleLineComment"
|
||||
},
|
||||
DocCommentHighlightRules.getStartRule("doc-start"),
|
||||
{
|
||||
|
|
@ -121,14 +122,26 @@ var c_cppHighlightRules = function() {
|
|||
regex : ".+"
|
||||
}
|
||||
],
|
||||
"singleLineComment" : [
|
||||
{
|
||||
token : "comment",
|
||||
regex : /\\$/,
|
||||
next : "singleLineComment"
|
||||
}, {
|
||||
token : "comment",
|
||||
regex : /$/,
|
||||
next : "start"
|
||||
}, {
|
||||
defaultToken: "comment"
|
||||
}
|
||||
],
|
||||
"qqstring" : [
|
||||
{
|
||||
token : "string",
|
||||
regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
|
||||
next : "start"
|
||||
}, {
|
||||
token : "string",
|
||||
regex : '.+'
|
||||
defaultToken : "string"
|
||||
}
|
||||
],
|
||||
"qstring" : [
|
||||
|
|
@ -137,8 +150,7 @@ var c_cppHighlightRules = function() {
|
|||
regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
|
||||
next : "start"
|
||||
}, {
|
||||
token : "string",
|
||||
regex : '.+'
|
||||
defaultToken : "string"
|
||||
}
|
||||
],
|
||||
"directive" : [
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ define(function(require, exports, module) {
|
|||
}
|
||||
if (val == "}" && stack.length) {
|
||||
stack.shift();
|
||||
this.next = stack.shift();
|
||||
this.next = stack.shift() || "";
|
||||
if (this.next.indexOf("string") != -1)
|
||||
return "paren.string";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ var Mode = function() {
|
|||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.lineCommentStart = "/\\+";
|
||||
this.lineCommentStart = "//";
|
||||
this.blockComment = {start: "/*", end: "*/"};
|
||||
this.$id = "ace/mode/d";
|
||||
}).call(Mode.prototype);
|
||||
|
|
|
|||
|
|
@ -35,22 +35,28 @@ var oop = require("../lib/oop");
|
|||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var DocCommentHighlightRules = function() {
|
||||
|
||||
this.$rules = {
|
||||
"start" : [ {
|
||||
token : "comment.doc.tag",
|
||||
regex : "@[\\w\\d_]+" // TODO: fix email addresses
|
||||
}, {
|
||||
token : "comment.doc.tag",
|
||||
regex : "\\bTODO\\b"
|
||||
}, {
|
||||
defaultToken : "comment.doc"
|
||||
},
|
||||
DocCommentHighlightRules.getTagRule(),
|
||||
{
|
||||
defaultToken : "comment.doc",
|
||||
caseInsensitive: true
|
||||
}]
|
||||
};
|
||||
};
|
||||
|
||||
oop.inherits(DocCommentHighlightRules, TextHighlightRules);
|
||||
|
||||
DocCommentHighlightRules.getTagRule = function(start) {
|
||||
return {
|
||||
token : "comment.doc.tag.storage.type",
|
||||
regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b"
|
||||
};
|
||||
}
|
||||
|
||||
DocCommentHighlightRules.getStartRule = function(start) {
|
||||
return {
|
||||
token : "comment.doc", // doc comment
|
||||
|
|
|
|||
58
lib/ace/mode/elm.js
Normal file
58
lib/ace/mode/elm.js
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2012, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
THIS FILE WAS AUTOGENERATED BY mode.tmpl.js
|
||||
*/
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var HighlightRules = require("./elm_highlight_rules").ElmHighlightRules;
|
||||
// TODO: pick appropriate fold mode
|
||||
var FoldMode = require("./folding/cstyle").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = HighlightRules;
|
||||
this.foldingRules = new FoldMode();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.lineCommentStart = "--";
|
||||
this.blockComment = {start: "{-", end: "-}"};
|
||||
// Extra logic goes here.
|
||||
this.$id = "ace/mode/elm";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
});
|
||||
162
lib/ace/mode/elm_highlight_rules.js
Normal file
162
lib/ace/mode/elm_highlight_rules.js
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
/* ***** 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 ***** */
|
||||
|
||||
// TODO check with https://github.com/deadfoxygrandpa/Elm.tmLanguage
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var ElmHighlightRules = function() {
|
||||
var keywordMapper = this.createKeywordMapper({
|
||||
"keyword": "as|case|class|data|default|deriving|do|else|export|foreign|" +
|
||||
"hiding|jsevent|if|import|in|infix|infixl|infixr|instance|let|" +
|
||||
"module|newtype|of|open|then|type|where|_|port|\u03BB"
|
||||
}, "identifier");
|
||||
|
||||
var escapeRe = /\\(\d+|['"\\&trnbvf])/;
|
||||
|
||||
var smallRe = /[a-z_]/.source;
|
||||
var largeRe = /[A-Z]/.source;
|
||||
var idRe = /[a-z_A-Z0-9\']/.source;
|
||||
|
||||
this.$rules = {
|
||||
start: [{
|
||||
token: "string.start",
|
||||
regex: '"',
|
||||
next: "string"
|
||||
}, {
|
||||
token: "string.character",
|
||||
regex: "'(?:" + escapeRe.source + "|.)'?"
|
||||
}, {
|
||||
regex: /0(?:[xX][0-9A-Fa-f]+|[oO][0-7]+)|\d+(\.\d+)?([eE][-+]?\d*)?/,
|
||||
token: "constant.numeric"
|
||||
}, {
|
||||
token : "keyword",
|
||||
regex : /\.\.|\||:|=|\\|\"|->|<-|\u2192/
|
||||
}, {
|
||||
token : "keyword.operator",
|
||||
regex : /[-!#$%&*+.\/<=>?@\\^|~:\u03BB\u2192]+/
|
||||
}, {
|
||||
token : "operator.punctuation",
|
||||
regex : /[,;`]/
|
||||
}, {
|
||||
regex : largeRe + idRe + "+\\.?",
|
||||
token : function(value) {
|
||||
if (value[value.length - 1] == ".")
|
||||
return "entity.name.function";
|
||||
return "constant.language";
|
||||
}
|
||||
}, {
|
||||
regex : "^" + smallRe + idRe + "+",
|
||||
token : function(value) {
|
||||
return "constant.language";
|
||||
}
|
||||
}, {
|
||||
token : keywordMapper,
|
||||
regex : "[\\w\\xff-\\u218e\\u2455-\\uffff]+\\b"
|
||||
}, {
|
||||
regex: "{-#?",
|
||||
token: "comment.start",
|
||||
onMatch: function(value, currentState, stack) {
|
||||
this.next = value.length == 2 ? "blockComment" : "docComment";
|
||||
return this.token;
|
||||
}
|
||||
}, {
|
||||
token: "variable.language",
|
||||
regex: /\[markdown\|/,
|
||||
next: "markdown"
|
||||
}, {
|
||||
token: "paren.lparen",
|
||||
regex: /[\[({]/
|
||||
}, {
|
||||
token: "paren.rparen",
|
||||
regex: /[\])}]/
|
||||
}, ],
|
||||
markdown: [{
|
||||
regex: /\|\]/,
|
||||
next: "start"
|
||||
}, {
|
||||
defaultToken : "string"
|
||||
}],
|
||||
blockComment: [{
|
||||
regex: "{-",
|
||||
token: "comment.start",
|
||||
push: "blockComment"
|
||||
}, {
|
||||
regex: "-}",
|
||||
token: "comment.end",
|
||||
next: "pop"
|
||||
}, {
|
||||
defaultToken: "comment"
|
||||
}],
|
||||
docComment: [{
|
||||
regex: "{-",
|
||||
token: "comment.start",
|
||||
push: "docComment"
|
||||
}, {
|
||||
regex: "-}",
|
||||
token: "comment.end",
|
||||
next: "pop"
|
||||
}, {
|
||||
defaultToken: "doc.comment"
|
||||
}],
|
||||
string: [{
|
||||
token: "constant.language.escape",
|
||||
regex: escapeRe,
|
||||
}, {
|
||||
token: "text",
|
||||
regex: /\\(\s|$)/,
|
||||
next: "stringGap"
|
||||
}, {
|
||||
token: "string.end",
|
||||
regex: '"',
|
||||
next: "start"
|
||||
}],
|
||||
stringGap: [{
|
||||
token: "text",
|
||||
regex: /\\/,
|
||||
next: "string"
|
||||
}, {
|
||||
token: "error",
|
||||
regex: "",
|
||||
next: "start"
|
||||
}],
|
||||
};
|
||||
|
||||
this.normalizeRules();
|
||||
};
|
||||
|
||||
oop.inherits(ElmHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.ElmHighlightRules = ElmHighlightRules;
|
||||
});
|
||||
|
|
@ -27,10 +27,6 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
|
|
@ -53,7 +49,7 @@ var Mode = function() {
|
|||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.lineCommentStart = "(?<=^|\\s)\\.?\\( [^)]*\\)";
|
||||
this.lineCommentStart = "--";
|
||||
this.blockComment = {start: "/*", end: "*/"};
|
||||
this.$id = "ace/mode/forth";
|
||||
}).call(Mode.prototype);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ var Mode = function() {
|
|||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.lineCommentStart = "#";
|
||||
this.$id = "ace/mode/gitignore";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
|
|
|
|||
|
|
@ -302,20 +302,24 @@ var JavaScriptHighlightRules = function(options) {
|
|||
}
|
||||
],
|
||||
"comment_regex_allowed" : [
|
||||
DocCommentHighlightRules.getTagRule(),
|
||||
{token : "comment", regex : "\\*\\/", next : "start"},
|
||||
{defaultToken : "comment"}
|
||||
{defaultToken : "comment", caseInsensitive: true}
|
||||
],
|
||||
"comment" : [
|
||||
DocCommentHighlightRules.getTagRule(),
|
||||
{token : "comment", regex : "\\*\\/", next : "no_regex"},
|
||||
{defaultToken : "comment"}
|
||||
{defaultToken : "comment", caseInsensitive: true}
|
||||
],
|
||||
"line_comment_regex_allowed" : [
|
||||
DocCommentHighlightRules.getTagRule(),
|
||||
{token : "comment", regex : "$|^", next : "start"},
|
||||
{defaultToken : "comment"}
|
||||
{defaultToken : "comment", caseInsensitive: true}
|
||||
],
|
||||
"line_comment" : [
|
||||
DocCommentHighlightRules.getTagRule(),
|
||||
{token : "comment", regex : "$|^", next : "no_regex"},
|
||||
{defaultToken : "comment"}
|
||||
{defaultToken : "comment", caseInsensitive: true}
|
||||
],
|
||||
"qqstring" : [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,11 +26,6 @@
|
|||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -27,10 +27,6 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -29,10 +29,6 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* This file was autogenerated from https://raw.github.com/dbp/sublime-rust/master/Rust.tmLanguage (uuid: ) */
|
||||
/****************************************************************************************
|
||||
* IT MIGHT NOT BE PERFECT ...But it's a good start from an existing *.tmlanguage file. *
|
||||
* fileTypes *
|
||||
****************************************************************************************/
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
|
@ -55,6 +51,35 @@ var RustHighlightRules = function() {
|
|||
next: 'pop' },
|
||||
{ include: '#rust_escaped_character' },
|
||||
{ defaultToken: 'string.quoted.single.source.rust' } ] },
|
||||
{
|
||||
stateName: "bracketedComment",
|
||||
onMatch : function(value, currentState, stack){
|
||||
stack.unshift(this.next, value.length - 1, currentState);
|
||||
return "string.quoted.raw.source.rust";
|
||||
},
|
||||
regex : /r#*"/,
|
||||
next : [
|
||||
{
|
||||
onMatch : function(value, currentState, stack) {
|
||||
var token = "string.quoted.raw.source.rust";
|
||||
if (value.length >= stack[1]) {
|
||||
if (value.length > stack[1])
|
||||
token = "invalid";
|
||||
stack.shift();
|
||||
stack.shift();
|
||||
this.next = stack.shift();
|
||||
} else {
|
||||
this.next = "";
|
||||
}
|
||||
return token;
|
||||
},
|
||||
regex : /"#*/,
|
||||
next : "start"
|
||||
}, {
|
||||
defaultToken : "string.quoted.raw.source.rust"
|
||||
}
|
||||
]
|
||||
},
|
||||
{ token: 'string.quoted.double.source.rust',
|
||||
regex: '"',
|
||||
push:
|
||||
|
|
|
|||
|
|
@ -51,7 +51,10 @@ var Mode = function() {
|
|||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
(function() {
|
||||
this.lineCommentStart = "//";
|
||||
this.blockComment = {start: "/*", end: "*/"};
|
||||
|
||||
this.$id = "ace/mode/stylus";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ var Mode = function() {
|
|||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.type = "text";
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
if (state == "intag")
|
||||
return tab;
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ var Search = function() {
|
|||
if (options.wholeWord)
|
||||
needle = "\\b" + needle + "\\b";
|
||||
|
||||
var modifier = options.caseSensitive ? "g" : "gi";
|
||||
var modifier = options.caseSensitive ? "gm" : "gmi";
|
||||
|
||||
options.$isMultiLine = !$disableFakeMultiline && /[\n\r]/.test(needle);
|
||||
if (options.$isMultiLine)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
.ace-cobalt .ace_gutter {
|
||||
background: #011e3a;
|
||||
color: #fff
|
||||
color: rgb(128,145,160)
|
||||
}
|
||||
|
||||
.ace-cobalt .ace_print-margin {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
.ace-idle-fingers .ace_gutter {
|
||||
background: #3b3b3b;
|
||||
color: #fff
|
||||
color: rgb(153,153,153)
|
||||
}
|
||||
|
||||
.ace-idle-fingers .ace_print-margin {
|
||||
|
|
|
|||
|
|
@ -34,12 +34,13 @@
|
|||
margin: -1px 0 0 -1px;
|
||||
border: 1px solid #888888
|
||||
}
|
||||
|
||||
.ace-tomorrow-night-bright .ace_marker-layer .ace_highlight {
|
||||
border: 1px solid rgb(110, 119, 0);
|
||||
border-bottom: 0;
|
||||
box-shadow: inset 0 -1px rgb(110, 119, 0);
|
||||
margin: -1px 0 0 -1px;
|
||||
background: rgba(255, 235, 0, 0.1);
|
||||
border: 1px solid rgb(110, 119, 0);
|
||||
border-bottom: 0;
|
||||
box-shadow: inset 0 -1px rgb(110, 119, 0);
|
||||
margin: -1px 0 0 -1px;
|
||||
background: rgba(255, 235, 0, 0.1)
|
||||
}
|
||||
|
||||
.ace-tomorrow-night-bright .ace_marker-layer .ace_active-line {
|
||||
|
|
@ -132,7 +133,7 @@
|
|||
}
|
||||
|
||||
.ace-tomorrow-night-bright .ace_c9searchresults.ace_keyword {
|
||||
color: #C2C280;
|
||||
color: #C2C280
|
||||
}
|
||||
|
||||
.ace-tomorrow-night-bright .ace_indent-guide {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,13 @@ window.window = window;
|
|||
window.ace = window;
|
||||
|
||||
window.onerror = function(message, file, line, col, err) {
|
||||
console.error("Worker " + (err ? err.stack : message));
|
||||
postMessage({type: "error", data: {
|
||||
message: message,
|
||||
file: file,
|
||||
line: line,
|
||||
col: col,
|
||||
stack: err.stack
|
||||
}});
|
||||
};
|
||||
|
||||
window.normalizeModule = function(parentId, moduleName) {
|
||||
|
|
@ -84,15 +90,20 @@ window.define = function(id, deps, factory) {
|
|||
deps = [];
|
||||
id = window.require.id;
|
||||
}
|
||||
|
||||
if (typeof factory != "function") {
|
||||
window.require.modules[id] = {
|
||||
exports: factory,
|
||||
initialized: true
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
if (!deps.length)
|
||||
// If there is no dependencies, we inject 'require', 'exports' and
|
||||
// 'module' as dependencies, to provide CommonJS compatibility.
|
||||
deps = ['require', 'exports', 'module'];
|
||||
|
||||
if (id.indexOf("text!") === 0)
|
||||
return;
|
||||
|
||||
var req = function(childId) {
|
||||
return window.require(id, childId);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -92,14 +92,9 @@ var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) {
|
|||
this.onMessage = function(e) {
|
||||
var msg = e.data;
|
||||
switch(msg.type) {
|
||||
case "log":
|
||||
window.console && console.log && console.log.apply(console, msg.data);
|
||||
break;
|
||||
|
||||
case "event":
|
||||
this._signal(msg.name, {data: msg.data});
|
||||
break;
|
||||
|
||||
case "call":
|
||||
var callback = this.callbacks[msg.id];
|
||||
if (callback) {
|
||||
|
|
@ -107,8 +102,18 @@ var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) {
|
|||
delete this.callbacks[msg.id];
|
||||
}
|
||||
break;
|
||||
case "error":
|
||||
this.reportError(msg.data);
|
||||
break;
|
||||
case "log":
|
||||
window.console && console.log && console.log.apply(console, msg.data);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
this.reportError = function(err) {
|
||||
window.console && console.error && console.error(err);
|
||||
};
|
||||
|
||||
this.$normalizePath = function(path) {
|
||||
return net.qualifyURL(path);
|
||||
|
|
@ -119,7 +124,8 @@ var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) {
|
|||
this.deltaQueue = null;
|
||||
this.$worker.terminate();
|
||||
this.$worker = null;
|
||||
this.$doc.removeEventListener("change", this.changeListener);
|
||||
if (this.$doc)
|
||||
this.$doc.off("change", this.changeListener);
|
||||
this.$doc = null;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue