commit
fe1f945343
13 changed files with 252 additions and 19 deletions
44
demo/ie7.html
Normal file
44
demo/ie7.html
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<title>ACE Editor StatusBar Demo</title>
|
||||
<style type="text/css" media="screen">
|
||||
/*!important without this top: 0; bottom: 0 doesn't work */
|
||||
body, html {
|
||||
position: absolute;
|
||||
top: 0px; bottom: 0; left: 0; right: 0;
|
||||
margin:0; padding:0;
|
||||
overflow:hidden
|
||||
}
|
||||
|
||||
#editor {
|
||||
margin: 0;
|
||||
position: absolute;
|
||||
top: 0; bottom: 0; left: 0; right: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<pre id="editor">
|
||||
require("ace/ext/old_ie");
|
||||
// now ace will work even on ie7!
|
||||
var editor = ace.edit("editor");
|
||||
</pre>
|
||||
|
||||
<script src="../build/src/ace.js"></script>
|
||||
<script src="../build/src/ext-old_ie.js"></script>
|
||||
<script>
|
||||
// before creating an editor patch up things for old ie
|
||||
require("ace/ext/old_ie");
|
||||
// now ace will work even on ie7!
|
||||
var editor = ace.edit("editor");
|
||||
editor.setTheme("ace/theme/textmate");
|
||||
editor.session.setMode("ace/mode/javascript");
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
108
lib/ace/ext/old_ie.js
Normal file
108
lib/ace/ext/old_ie.js
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
/* ***** 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";
|
||||
var MAX_TOKEN_COUNT = 1000;
|
||||
var useragent = require("../lib/useragent");
|
||||
var TokenizerModule = require("../tokenizer");
|
||||
|
||||
function patch(obj, name, regexp, replacement) {
|
||||
eval("obj['" + name + "']=" + obj[name].toString().replace(
|
||||
regexp, replacement
|
||||
));
|
||||
}
|
||||
|
||||
if (useragent.isIE && useragent.isIE < 10 && window.top.document.compatMode === "BackCompat")
|
||||
useragent.isOldIE = true;
|
||||
|
||||
if (typeof document != "undefined" && !document.documentElement.querySelector) {
|
||||
useragent.isOldIE = true;
|
||||
var qs = function(el, selector) {
|
||||
if (selector.charAt(0) == ".") {
|
||||
var classNeme = selector.slice(1);
|
||||
} else {
|
||||
var m = selector.match(/(\w+)=(\w+)/);
|
||||
var attr = m && m[1];
|
||||
var attrVal = m && m[2];
|
||||
}
|
||||
for (var i = 0; i < el.all.length; i++) {
|
||||
var ch = el.all[i];
|
||||
if (classNeme) {
|
||||
if (ch.className.indexOf(classNeme) != -1)
|
||||
return ch;
|
||||
} else if (attr) {
|
||||
if (ch.getAttribute(attr) == attrVal)
|
||||
return ch;
|
||||
}
|
||||
}
|
||||
};
|
||||
var sb = require("./searchbox").SearchBox.prototype;
|
||||
patch(
|
||||
sb, "$initElements",
|
||||
/([^\s=]*).querySelector\((".*?")\)/g,
|
||||
"qs($1, $2)"
|
||||
);
|
||||
}
|
||||
|
||||
var compliantExecNpcg = /()??/.exec("")[1] === undefined;
|
||||
if (compliantExecNpcg)
|
||||
return;
|
||||
var proto = TokenizerModule.Tokenizer.prototype;
|
||||
TokenizerModule.Tokenizer_orig = TokenizerModule.Tokenizer;
|
||||
proto.getLineTokens_orig = proto.getLineTokens;
|
||||
|
||||
patch(
|
||||
TokenizerModule, "Tokenizer",
|
||||
"ruleRegExps.push(adjustedregex);\n",
|
||||
function(m) {
|
||||
return m + '\
|
||||
if (state[i].next && RegExp(adjustedregex).test(""))\n\
|
||||
rule._qre = RegExp(adjustedregex, "g");\n\
|
||||
';
|
||||
}
|
||||
);
|
||||
TokenizerModule.Tokenizer.prototype = proto;
|
||||
patch(
|
||||
proto, "getLineTokens",
|
||||
/if \(match\[i \+ 1\] === undefined\)\s*continue;/,
|
||||
"if (!match[i + 1]) {\n\
|
||||
if (value)continue;\n\
|
||||
var qre = state[mapping[i]]._qre;\n\
|
||||
if (!qre) continue;\n\
|
||||
qre.lastIndex = lastIndex;\n\
|
||||
if (!qre.exec(line) || qre.lastIndex != lastIndex)\n\
|
||||
continue;\n\
|
||||
}"
|
||||
);
|
||||
|
||||
useragent.isOldIE = true;
|
||||
|
||||
});
|
||||
77
lib/ace/ext/old_ie_test.js
Normal file
77
lib/ace/ext/old_ie_test.js
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2010, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
if (typeof process !== "undefined") {
|
||||
require("amd-loader");
|
||||
}
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var assert = require("../test/assertions");
|
||||
|
||||
module.exports = {
|
||||
"test: getTokenizer() (smoke test)" : function() {
|
||||
var exec = RegExp.prototype.exec
|
||||
var brokenExec = function(str) {
|
||||
var result = exec.call(this, str);
|
||||
if (result) {
|
||||
for (var i = result.length; i--;)
|
||||
if (!result[i])
|
||||
result[i] = "";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
// break this to emulate old ie
|
||||
RegExp.prototype.exec = brokenExec;
|
||||
require("./old_ie");
|
||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||
var JavaScriptHighlightRules = require("../mode/javascript_highlight_rules").JavaScriptHighlightRules;
|
||||
var tokenizer = new Tokenizer((new JavaScriptHighlightRules).getRules());
|
||||
|
||||
var tokens = tokenizer.getLineTokens("'juhu'", "start").tokens;
|
||||
assert.equal("string", tokens[0].type);
|
||||
} finally {
|
||||
// restore modified functions
|
||||
RegExp.prototype.exec = exec;
|
||||
var module = require("../tokenizer");
|
||||
module.Tokenizer = module.Tokenizer_orig;
|
||||
module.Tokenizer.prototype.getLineTokens = module.Tokenizer.prototype.getLineTokens_orig;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
if (typeof module !== "undefined" && module === require.main) {
|
||||
require("asyncjs").test.testcase(module.exports).exec()
|
||||
}
|
||||
|
|
@ -75,9 +75,7 @@ var SearchBox = function(editor, range, showReplaceForm) {
|
|||
this.editor = editor;
|
||||
};
|
||||
|
||||
this.$init = function() {
|
||||
var sb = this.element;
|
||||
|
||||
this.$initElements = function(sb) {
|
||||
this.searchBox = sb.querySelector(".ace_search_form");
|
||||
this.replaceBox = sb.querySelector(".ace_replace_form");
|
||||
this.searchOptions = sb.querySelector(".ace_search_options");
|
||||
|
|
@ -86,7 +84,13 @@ var SearchBox = function(editor, range, showReplaceForm) {
|
|||
this.wholeWordOption = sb.querySelector("[action=toggleWholeWords]");
|
||||
this.searchInput = this.searchBox.querySelector(".ace_search_field");
|
||||
this.replaceInput = this.replaceBox.querySelector(".ace_search_field");
|
||||
|
||||
};
|
||||
|
||||
this.$init = function() {
|
||||
var sb = this.element;
|
||||
|
||||
this.$initElements(sb);
|
||||
|
||||
var _this = this;
|
||||
event.addListener(sb, "mousedown", function(e) {
|
||||
setTimeout(function(){
|
||||
|
|
|
|||
|
|
@ -215,18 +215,18 @@ var TextInput = function(parentNode, host) {
|
|||
if (data)
|
||||
host.onPaste(data);
|
||||
pasted = false;
|
||||
} else if (data == PLACEHOLDER[0]) {
|
||||
} else if (data == PLACEHOLDER.charAt(0)) {
|
||||
if (afterContextMenu)
|
||||
host.execCommand("del", {source: "ace"});
|
||||
} else {
|
||||
if (data.substring(0, 2) == PLACEHOLDER)
|
||||
data = data.substr(2);
|
||||
else if (data[0] == PLACEHOLDER[0])
|
||||
else if (data.charAt(0) == PLACEHOLDER.charAt(0))
|
||||
data = data.substr(1);
|
||||
else if (data[data.length - 1] == PLACEHOLDER[0])
|
||||
else if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
|
||||
data = data.slice(0, -1);
|
||||
// can happen if undo in textarea isn't stopped
|
||||
if (data[data.length - 1] == PLACEHOLDER[0])
|
||||
if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
|
||||
data = data.slice(0, -1);
|
||||
|
||||
if (data)
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ var HtmlHighlightRules = function() {
|
|||
token : "keyword.operator.separator",
|
||||
regex : "=",
|
||||
push : [{
|
||||
include: "space",
|
||||
include: "space"
|
||||
}, {
|
||||
token : "string",
|
||||
regex : "[^<>='\"`\\s]+",
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ var JsRegexHighlightRules = function() {
|
|||
// flag
|
||||
token: "string.regexp",
|
||||
regex: "/\\w*",
|
||||
next: "start",
|
||||
next: "start"
|
||||
}, {
|
||||
token : ["string", "string.regex"],
|
||||
regex: quantifier,
|
||||
|
|
@ -43,7 +43,7 @@ var JsRegexHighlightRules = function() {
|
|||
}, {
|
||||
token: "constant.language.escape",
|
||||
regex: /\[\^?/,
|
||||
next: "character_class",
|
||||
next: "character_class"
|
||||
}, {
|
||||
token: "empty",
|
||||
regex: "$",
|
||||
|
|
@ -63,7 +63,7 @@ var JsRegexHighlightRules = function() {
|
|||
}, {
|
||||
token: "constant.language.escape",
|
||||
regex: "]",
|
||||
next: "start",
|
||||
next: "start"
|
||||
}, {
|
||||
token: "constant.language.escape",
|
||||
regex: "-"
|
||||
|
|
|
|||
|
|
@ -559,7 +559,7 @@ var MushCodeRules = function() {
|
|||
}, {
|
||||
token : "text",
|
||||
regex : "\\s+"
|
||||
} ],
|
||||
} ]
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ var MysqlHighlightRules = function() {
|
|||
"comment" : [
|
||||
{token : "comment", regex : "\\*\\/", next : "start"},
|
||||
{defaultToken : "comment"}
|
||||
],
|
||||
]
|
||||
};
|
||||
|
||||
this.embedRules(DocCommentHighlightRules, "doc-", [ DocCommentHighlightRules.getEndRule("start") ]);
|
||||
|
|
|
|||
|
|
@ -1013,7 +1013,7 @@ var PhpLangHighlightRules = function() {
|
|||
next: "start"
|
||||
}, {
|
||||
token: "string",
|
||||
regex : ".*",
|
||||
regex : ".*"
|
||||
}
|
||||
],
|
||||
"comment" : [
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ var PropertiesHighlightRules = function() {
|
|||
next : "value"
|
||||
}, {
|
||||
token : "constant.language.escape",
|
||||
regex : escapeRe,
|
||||
regex : escapeRe
|
||||
}, {
|
||||
defaultToken: "variable"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ var SnippetGroupHighlightRules = function() {
|
|||
{onMatch: function(value, state, stack) {
|
||||
stack.splice(stack.length);
|
||||
return this.tokenName;
|
||||
}, tokenName: "text", regex: "^(?!\t)", next: "start"},
|
||||
}, tokenName: "text", regex: "^(?!\t)", next: "start"}
|
||||
])
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ var TwigHighlightRules = function() {
|
|||
}, {
|
||||
token : "string",
|
||||
regex : '"',
|
||||
next : "twig-start",
|
||||
next : "twig-start"
|
||||
}, {
|
||||
defaultToken : "string"
|
||||
}
|
||||
|
|
@ -151,7 +151,7 @@ var TwigHighlightRules = function() {
|
|||
}, {
|
||||
token : "string",
|
||||
regex : "'",
|
||||
next : "twig-start",
|
||||
next : "twig-start"
|
||||
}, {
|
||||
defaultToken : "string"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue