commit
e316578832
14 changed files with 132 additions and 49 deletions
|
|
@ -617,11 +617,29 @@ env.editor.setOptions({
|
|||
});
|
||||
|
||||
// allow easy access to ace in console, but not in ace code which uses strict
|
||||
function isNonStrict() {
|
||||
try { return !!arguments.callee.caller.caller }
|
||||
catch(e){ return false }
|
||||
void function() {
|
||||
function isStrict() {
|
||||
try { return !arguments.callee.caller.caller.caller}
|
||||
catch(e){ return true }
|
||||
}
|
||||
window.__defineGetter__("ace", function(){ return isNonStrict() && env.editor });
|
||||
window.__defineGetter__("editor", function(){ return isNonStrict() && env.editor });
|
||||
window.__defineGetter__("session", function(){ return isNonStrict() && env.editor.session });
|
||||
window.__defineGetter__("split", function(){ return isNonStrict() && env.split });
|
||||
function warn() {
|
||||
if (isStrict()) {
|
||||
console.error("trying to access to global variable");
|
||||
}
|
||||
}
|
||||
function def(o, key, get) {
|
||||
Object.defineProperty(o, key, {
|
||||
configurable: true,
|
||||
get: get,
|
||||
set: function(val) {
|
||||
delete o[key];
|
||||
o[key] = val;
|
||||
}
|
||||
});
|
||||
}
|
||||
def(window, "ace", function(){ warn(); return env.editor });
|
||||
def(window, "editor", function(){ warn(); return env.editor });
|
||||
def(window, "session", function(){ warn(); return env.editor.session });
|
||||
def(window, "split", function(){ warn(); return env.split });
|
||||
|
||||
}();
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 48 KiB |
|
|
@ -16,9 +16,8 @@ body {
|
|||
color: white;
|
||||
}
|
||||
|
||||
#logo {
|
||||
padding: 15px;
|
||||
margin-left: 70px;
|
||||
#c9-logo, #ace-logo {
|
||||
padding: 0;
|
||||
border: none;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,10 +24,10 @@
|
|||
</head>
|
||||
<body>
|
||||
<div id="optionsPanel" style="position:absolute;height:100%;width:260px">
|
||||
<a href="http://ajaxorg.github.com/ace/" >
|
||||
<img id="logo" src="demo/kitchen-sink/logo.png">
|
||||
<a href="http://c9.io" title="Cloud9 IDE | Your code anywhere, anytime">
|
||||
<img id="c9-logo" src="demo/kitchen-sink/logo.png" style="width: 172px;margin: -9px 30px -12px 51px;">
|
||||
</a>
|
||||
<div style="position: absolute; overflow: hidden; top:80px; bottom:0">
|
||||
<div style="position: absolute; overflow: hidden; top:100px; bottom:0">
|
||||
<div style="width: 120%; height:100%; overflow-y: scroll">
|
||||
|
||||
<table id="controls">
|
||||
|
|
@ -292,6 +292,10 @@
|
|||
</table>
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
<a href="http://ace.c9.io">
|
||||
<img id="ace-logo" src="doc/site/images/ace-logo.png" style="width: 134px;margin: 46px 0px 4px 66px;">
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -83,7 +83,6 @@ var Autocomplete = function() {
|
|||
|
||||
this.popup.show(pos, lineHeight);
|
||||
}
|
||||
renderer.updateText();
|
||||
};
|
||||
|
||||
this.detach = function() {
|
||||
|
|
@ -224,7 +223,7 @@ var Autocomplete = function() {
|
|||
editor.on("mousewheel", this.mousewheelListener);
|
||||
|
||||
this.updateCompletions();
|
||||
}
|
||||
};
|
||||
|
||||
this.updateCompletions = function(keepPopupPosition) {
|
||||
if (keepPopupPosition && this.base && this.completions) {
|
||||
|
|
|
|||
|
|
@ -65,6 +65,8 @@ var AcePopup = function(parentNode) {
|
|||
el.style.display = "none";
|
||||
popup.renderer.content.style.cursor = "default";
|
||||
popup.renderer.setStyle("ace_autocomplete");
|
||||
|
||||
popup.setOption("displayIndentGuides", false);
|
||||
|
||||
var noop = function(){};
|
||||
|
||||
|
|
@ -102,16 +104,22 @@ var AcePopup = function(parentNode) {
|
|||
hoverMarker.id = null;
|
||||
}
|
||||
}
|
||||
popup.setSelectOnHover(false)
|
||||
popup.setSelectOnHover(false);
|
||||
popup.on("mousemove", function(e) {
|
||||
if (!lastMouseEvent) {
|
||||
lastMouseEvent = e;
|
||||
return;
|
||||
}
|
||||
if (lastMouseEvent.x == e.x && lastMouseEvent.y == e.y) {
|
||||
return;
|
||||
}
|
||||
lastMouseEvent = e;
|
||||
lastMouseEvent.scrollTop = popup.renderer.scrollTop;
|
||||
var row = lastMouseEvent.getDocumentPosition().row;
|
||||
if (hoverMarker.start.row != row) {
|
||||
popup.session._emit("changeBackMarker");
|
||||
if (!hoverMarker.id)
|
||||
popup.setRow(row);
|
||||
hoverMarker.start.row = hoverMarker.end.row = row;
|
||||
setHoverMarker(row);
|
||||
}
|
||||
});
|
||||
popup.renderer.on("beforeRender", function() {
|
||||
|
|
@ -120,13 +128,34 @@ var AcePopup = function(parentNode) {
|
|||
var row = lastMouseEvent.getDocumentPosition().row;
|
||||
if (!hoverMarker.id)
|
||||
popup.setRow(row);
|
||||
hoverMarker.start.row = hoverMarker.end.row = row;
|
||||
setHoverMarker(row, true);
|
||||
}
|
||||
});
|
||||
var hideHoverMarker = function() {
|
||||
hoverMarker.start.row = hoverMarker.end.row = -1;
|
||||
popup.session._emit("changeBackMarker");
|
||||
popup.renderer.on("afterRender", function() {
|
||||
var row = popup.getRow();
|
||||
var t = popup.renderer.$textLayer;
|
||||
var selected = t.element.childNodes[row - t.config.firstRow];
|
||||
if (selected == t.selectedNode)
|
||||
return;
|
||||
if (t.selectedNode)
|
||||
dom.removeCssClass(t.selectedNode, "ace_selected");
|
||||
t.selectedNode = selected;
|
||||
if (selected)
|
||||
dom.addCssClass(selected, "ace_selected");
|
||||
});
|
||||
var hideHoverMarker = function() { setHoverMarker(-1) };
|
||||
var setHoverMarker = function(row, suppressRedraw) {
|
||||
if (row !== hoverMarker.start.row) {
|
||||
hoverMarker.start.row = hoverMarker.end.row = row;
|
||||
if (!suppressRedraw)
|
||||
popup.session._emit("changeBackMarker");
|
||||
popup._emit("changeHoverMarker");
|
||||
}
|
||||
};
|
||||
popup.getHoveredRow = function() {
|
||||
return hoverMarker.start.row;
|
||||
};
|
||||
|
||||
event.addListener(popup.container, "mouseout", hideHoverMarker);
|
||||
popup.on("hide", hideHoverMarker);
|
||||
popup.on("changeSelection", hideHoverMarker);
|
||||
|
|
@ -173,6 +202,7 @@ var AcePopup = function(parentNode) {
|
|||
return tokens;
|
||||
};
|
||||
bgTokenizer.$updateOnChange = noop;
|
||||
bgTokenizer.start = noop;
|
||||
|
||||
popup.session.$computeWidth = function() {
|
||||
return this.screenWidth = 0;
|
||||
|
|
@ -183,6 +213,7 @@ var AcePopup = function(parentNode) {
|
|||
popup.setData = function(list) {
|
||||
popup.data = list || [];
|
||||
popup.setValue(lang.stringRepeat("\n", list.length), -1);
|
||||
popup.setRow(0);
|
||||
};
|
||||
popup.getData = function(row) {
|
||||
return popup.data[row];
|
||||
|
|
@ -192,29 +223,35 @@ var AcePopup = function(parentNode) {
|
|||
return selectionMarker.start.row;
|
||||
};
|
||||
popup.setRow = function(line) {
|
||||
line = Math.max(-1, Math.min(this.data.length, line));
|
||||
if (selectionMarker.start.row != line) {
|
||||
popup.selection.clearSelection();
|
||||
selectionMarker.start.row = selectionMarker.end.row = line || 0;
|
||||
popup.session._emit("changeBackMarker");
|
||||
popup.moveCursorTo(line || 0, 0);
|
||||
if (popup.isOpen)
|
||||
popup._signal("select");
|
||||
}
|
||||
};
|
||||
|
||||
popup.hide = function() {
|
||||
this.container.style.display = "none";
|
||||
this._signal("hide");
|
||||
popup.isOpen = false;
|
||||
};
|
||||
popup.show = function(pos, lineHeight) {
|
||||
var el = this.container;
|
||||
var screenHeight = window.innerHeight;
|
||||
var renderer = this.renderer;
|
||||
var maxH = renderer.$maxLines * lineHeight;
|
||||
if (pos.top +maxH > screenHeight - lineHeight) {
|
||||
// var maxLines = Math.min(renderer.$maxLines, this.session.getLength());
|
||||
var maxH = renderer.$maxLines * lineHeight * 1.4;
|
||||
var top = pos.top + this.$borderSize;
|
||||
if (top + maxH > screenHeight - lineHeight) {
|
||||
el.style.top = "";
|
||||
el.style.bottom = screenHeight - pos.top + "px";
|
||||
el.style.bottom = screenHeight - top + "px";
|
||||
} else {
|
||||
pos.top += lineHeight;
|
||||
el.style.top = pos.top + "px";
|
||||
top += lineHeight;
|
||||
el.style.top = top + "px";
|
||||
el.style.bottom = "";
|
||||
}
|
||||
|
||||
|
|
@ -223,11 +260,16 @@ var AcePopup = function(parentNode) {
|
|||
this.renderer.$textLayer.checkForSizeChanges();
|
||||
|
||||
this._signal("show");
|
||||
lastMouseEvent = null;
|
||||
popup.isOpen = true;
|
||||
};
|
||||
|
||||
popup.getTextLeftOffset = function() {
|
||||
return 1 + this.renderer.layerConfig.padding;
|
||||
}
|
||||
return this.$borderSize + this.renderer.$padding + this.$imageSize;
|
||||
};
|
||||
|
||||
popup.$imageSize = 0;
|
||||
popup.$borderSize = 1;
|
||||
|
||||
return popup;
|
||||
};
|
||||
|
|
@ -239,10 +281,12 @@ dom.importCssString("\
|
|||
}\
|
||||
.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;\
|
||||
background: rgba(233,233,253,0.4);\
|
||||
}\
|
||||
.ace_autocomplete .ace_line-hover {\
|
||||
position: absolute;\
|
||||
z-index: 2;\
|
||||
}\
|
||||
.ace_rightAlignedText {\
|
||||
color: gray;\
|
||||
|
|
|
|||
|
|
@ -172,7 +172,8 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
|||
};
|
||||
|
||||
this.scheduleStart = function() {
|
||||
this.running = setTimeout(this.$worker, 700);
|
||||
if (!this.running)
|
||||
this.running = setTimeout(this.$worker, 700);
|
||||
}
|
||||
|
||||
this.$updateOnChange = function(delta) {
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ exports.moduleUrl = function(name, component) {
|
|||
var sep = component == "snippets" ? "/" : "-";
|
||||
var base = parts[parts.length - 1];
|
||||
if (sep == "-") {
|
||||
var re = new RegExp("^" + component + "[\-_]|[\-_]" + component + "$", "g");
|
||||
var re = new RegExp("^" + component + "[\\-_]|[\\-_]" + component + "$", "g");
|
||||
base = base.replace(re, "");
|
||||
}
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ exports.loadModule = function(moduleName, onLoad) {
|
|||
|
||||
try {
|
||||
module = require(moduleName);
|
||||
} catch (e) {};
|
||||
} catch (e) {}
|
||||
// require(moduleName) can return empty object if called after require([moduleName], callback)
|
||||
if (module && !exports.$loading[moduleName])
|
||||
return onLoad && onLoad(module);
|
||||
|
|
@ -218,8 +218,8 @@ var optionsProvider = {
|
|||
return;
|
||||
var opt = this.$options[name];
|
||||
if (!opt) {
|
||||
if (typeof console != "undefined" && console.error)
|
||||
console.error('misspelled option "' + name + '"');
|
||||
if (typeof console != "undefined" && console.warn)
|
||||
console.warn('misspelled option "' + name + '"');
|
||||
return undefined;
|
||||
}
|
||||
if (opt.forwardTo)
|
||||
|
|
@ -233,8 +233,8 @@ var optionsProvider = {
|
|||
getOption: function(name) {
|
||||
var opt = this.$options[name];
|
||||
if (!opt) {
|
||||
if (typeof console != "undefined" && console.error)
|
||||
console.error('misspelled option "' + name + '"');
|
||||
if (typeof console != "undefined" && console.warn)
|
||||
console.warn('misspelled option "' + name + '"');
|
||||
return undefined;
|
||||
}
|
||||
if (opt.forwardTo)
|
||||
|
|
@ -280,7 +280,7 @@ exports.setDefaultValue = function(path, name, value) {
|
|||
var opts = defaultOptions[path] || (defaultOptions[path] = {});
|
||||
if (opts[name]) {
|
||||
if (opts.forwardTo)
|
||||
exports.setDefaultValue(opts.forwardTo, name, value)
|
||||
exports.setDefaultValue(opts.forwardTo, name, value);
|
||||
else
|
||||
opts[name].value = value;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,16 +41,23 @@ function HashHandler(config, platform) {
|
|||
|
||||
// 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() {
|
||||
console.error("commmandKeyBinding has too many m's. use commandKeyBinding")
|
||||
warn();
|
||||
return this.commandKeyBinding;
|
||||
});
|
||||
this.__defineSetter__("commmandKeyBinding", function(val) {
|
||||
console.error("commmandKeyBinding has too many m's. use commandKeyBinding")
|
||||
warn();
|
||||
return this.commandKeyBinding = val;
|
||||
});
|
||||
} else {
|
||||
this.commmandKeyBinding = commandKeyBinding;
|
||||
this.commmandKeyBinding = this.commandKeyBinding;
|
||||
}
|
||||
|
||||
this.addCommands(config);
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ var Gutter = function(parentEl) {
|
|||
this.$cells[index] = cell;
|
||||
}
|
||||
|
||||
var className = "ace_gutter-cell";
|
||||
var className = "ace_gutter-cell ";
|
||||
if (breakpoints[row])
|
||||
className += breakpoints[row];
|
||||
if (decorations[row])
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ var VBScriptHighlightRules = function() {
|
|||
token: [
|
||||
"support.function.asp"
|
||||
],
|
||||
regex: "(?:\\b(Lock|Unlock|SetAbort|SetComplete|BianryRead|AddHeader|AppendToLog|BinaryWrite|Clear|End|Flush|Redirect|Write|CreateObject|HTMLEncode|MapPath|URLEncode|Abandon|Convert|Regex)\\b)"
|
||||
regex: "(?:\\b(Lock|Unlock|SetAbort|SetComplete|BinaryRead|AddHeader|AppendToLog|BinaryWrite|Clear|End|Flush|Redirect|Write|CreateObject|HTMLEncode|MapPath|URLEncode|Abandon|Convert|Regex)\\b)"
|
||||
},
|
||||
{
|
||||
token: [
|
||||
|
|
|
|||
|
|
@ -374,9 +374,15 @@ var SnippetManager = function() {
|
|||
this.$getScope = function(editor) {
|
||||
var scope = editor.session.$mode.$id || "";
|
||||
scope = scope.split("/").pop();
|
||||
if (editor.session.$mode.$modes) {
|
||||
if (scope === "html" || scope === "php") {
|
||||
// PHP is actually HTML
|
||||
if (scope === "php")
|
||||
scope = "html";
|
||||
var c = editor.getCursorPosition()
|
||||
var state = editor.session.getState(c.row);
|
||||
if (typeof state === "object") {
|
||||
state = state[0];
|
||||
}
|
||||
if (state.substring) {
|
||||
if (state.substring(0, 3) == "js-")
|
||||
scope = "javascript";
|
||||
|
|
@ -386,6 +392,7 @@ var SnippetManager = function() {
|
|||
scope = "php";
|
||||
}
|
||||
}
|
||||
|
||||
return scope;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1335,8 +1335,10 @@ var VirtualRenderer = function(container, theme) {
|
|||
- this.layerConfig.maxHeight - (this.$size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd
|
||||
< -1 + this.scrollMargin.bottom)
|
||||
return true;
|
||||
// todo: better handle horizontal scrolling
|
||||
if (deltaX)
|
||||
if (deltaX < 0 && this.session.getScrollLeft() >= 1 - this.scrollMargin.left)
|
||||
return true;
|
||||
if (deltaX > 0 && this.session.getScrollLeft() + this.$size.scrollerWidth
|
||||
- this.layerConfig.width < -1 + this.scrollMargin.right)
|
||||
return true;
|
||||
};
|
||||
|
||||
|
|
@ -1481,7 +1483,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
dom.addCssClass(_self.container, module.cssClass);
|
||||
dom.setCssClass(_self.container, "ace_dark", module.isDark);
|
||||
|
||||
var padding = module.padding || 4;
|
||||
var padding = "padding" in module ? module.padding : 4;
|
||||
if (_self.$padding && padding != _self.$padding)
|
||||
_self.setPadding(padding);
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,8 @@ window.require = function(parentId, id) {
|
|||
}
|
||||
|
||||
var chunks = id.split("/");
|
||||
if (!require.tlns)
|
||||
return console.log("unable to load " + id);
|
||||
chunks[0] = require.tlns[chunks[0]] || chunks[0];
|
||||
var path = chunks.join("/") + ".js";
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue