commit
d1738b0eb2
17 changed files with 226 additions and 79 deletions
|
|
@ -346,6 +346,21 @@ var buildAce = function(options) {
|
|||
dest: targetDir + '/' + name + ".js"
|
||||
});
|
||||
|
||||
console.log('# ace extensions ---------');
|
||||
|
||||
project.assumeAllFilesLoaded();
|
||||
options.extensions.forEach(function(ext) {
|
||||
console.log("extensions " + ext);
|
||||
copy({
|
||||
source: [{
|
||||
project: cloneProject(project),
|
||||
require: [ 'ace/ext/' + ext ]
|
||||
}],
|
||||
filter: getWriteFilters(options, "ext"),
|
||||
dest: targetDir + "/ext-" + ext + ".js"
|
||||
});
|
||||
});
|
||||
|
||||
console.log('# ace modes ---------');
|
||||
|
||||
project.assumeAllFilesLoaded();
|
||||
|
|
@ -380,21 +395,6 @@ var buildAce = function(options) {
|
|||
});
|
||||
});
|
||||
|
||||
console.log('# ace extensions ---------');
|
||||
|
||||
project.assumeAllFilesLoaded();
|
||||
options.extensions.forEach(function(ext) {
|
||||
console.log("extensions " + ext);
|
||||
copy({
|
||||
source: [{
|
||||
project: cloneProject(project),
|
||||
require: [ 'ace/ext/' + ext ]
|
||||
}],
|
||||
filter: getWriteFilters(options, "ext"),
|
||||
dest: targetDir + "/ext-" + ext + ".js"
|
||||
});
|
||||
});
|
||||
|
||||
console.log('# ace key bindings ---------');
|
||||
|
||||
// copy key bindings
|
||||
|
|
|
|||
2
build
2
build
|
|
@ -1 +1 @@
|
|||
Subproject commit 49c348c49aab9b705a110a10312a7ca457fab4a9
|
||||
Subproject commit cf536740d866276b65cfd351610001c2a841e751
|
||||
44
demo/autocompletion.html
Normal file
44
demo/autocompletion.html
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>ACE Autocompletion demo</title>
|
||||
<style type="text/css" media="screen">
|
||||
body {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#editor {
|
||||
margin: 0;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<pre id="editor"></pre>
|
||||
|
||||
<!-- load ace -->
|
||||
<script src="../build/src-noconflict/ace.js"></script>
|
||||
<!-- load ace language tools -->
|
||||
<script src="../build/src-noconflict/ext-language_tools.js"></script>
|
||||
<script>
|
||||
// trigger extension
|
||||
ace.require("ace/ext/language_tools");
|
||||
var editor = ace.edit("editor");
|
||||
editor.session.setMode("ace/mode/html");
|
||||
editor.setTheme("ace/theme/tomorrow");
|
||||
// enable autocompletion and snippets
|
||||
editor.setOptions({
|
||||
enableBasicAutocompletion: true,
|
||||
enableSnippets: true
|
||||
});
|
||||
</script>
|
||||
|
||||
<script src="./show_own_source.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
42
demo/emmet.html
Normal file
42
demo/emmet.html
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>ACE Emmet demo</title>
|
||||
<style type="text/css" media="screen">
|
||||
body {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#editor {
|
||||
margin: 0;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<pre id="editor"></pre>
|
||||
|
||||
<!-- load ace -->
|
||||
<script src="../build/src-noconflict/ace.js"></script>
|
||||
<!-- load ace emmet extension -->
|
||||
<script src="../build/src-noconflict/ext-emmet.js"></script>
|
||||
<!-- load core emmet files -->
|
||||
<script src="http://nightwing.github.io/emmet-core/emmet.js"></script>
|
||||
<script>
|
||||
// trigger extension
|
||||
ace.require("ace/ext/emmet");
|
||||
var editor = ace.edit("editor");
|
||||
editor.session.setMode("ace/mode/html");
|
||||
// enable emmet on the current editor
|
||||
editor.setOption("enableEmmet", true);
|
||||
</script>
|
||||
|
||||
<script src="./show_own_source.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -41,6 +41,6 @@
|
|||
})
|
||||
</script>
|
||||
|
||||
<script src="./demo_helper.js"></script>
|
||||
<script src="./show_own_source.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -43,6 +43,6 @@
|
|||
|
||||
</script>
|
||||
|
||||
<script src="./demo_helper.js"></script>
|
||||
<script src="./show_own_source.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -40,6 +40,6 @@
|
|||
}]);
|
||||
</script>
|
||||
|
||||
<script src="./demo_helper.js"></script>
|
||||
<script src="./show_own_source.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -52,6 +52,6 @@
|
|||
editor.session.setMode("ace/mode/html");
|
||||
</script>
|
||||
|
||||
<script src="./demo_helper.js"></script>
|
||||
<script src="./show_own_source.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
2
doc/wiki
2
doc/wiki
|
|
@ -1 +1 @@
|
|||
Subproject commit 743d9d01185813dae9a37134fe9876da081ffe5b
|
||||
Subproject commit d93670b47d776987b38bb2c31777c4e488338fac
|
||||
|
|
@ -32,6 +32,8 @@ define(function(require, exports, module) {
|
|||
"use strict";
|
||||
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) {
|
||||
|
|
@ -165,43 +167,17 @@ AceEmmetEditor.prototype = {
|
|||
if (end == null)
|
||||
end = start == null ? this.getContent().length : start;
|
||||
if (start == null)
|
||||
start = 0;
|
||||
var utils = emmet.require("utils");
|
||||
|
||||
// indent new value
|
||||
if (!noIndent) {
|
||||
value = utils.padString(value, utils.getLinePaddingFromPosition(this.getContent(), start));
|
||||
}
|
||||
|
||||
// find new caret position
|
||||
var tabstopData = emmet.require("tabStops").extract(value, {
|
||||
escape: function(ch) {
|
||||
return ch;
|
||||
}
|
||||
});
|
||||
|
||||
value = tabstopData.text;
|
||||
var firstTabStop = tabstopData.tabstops[0];
|
||||
|
||||
if (firstTabStop) {
|
||||
firstTabStop.start += start;
|
||||
firstTabStop.end += start;
|
||||
} else {
|
||||
firstTabStop = {
|
||||
start: value.length + start,
|
||||
end: value.length + start
|
||||
};
|
||||
}
|
||||
|
||||
var range = this.ace.getSelectionRange();
|
||||
range.start = this.ace.indexToPosition(start);
|
||||
range.end = this.ace.indexToPosition(end);
|
||||
|
||||
this.ace.session.replace(range, value);
|
||||
|
||||
range.start = this.ace.indexToPosition(firstTabStop.start);
|
||||
range.end = this.ace.indexToPosition(firstTabStop.end);
|
||||
this.ace.selection.setRange(range);
|
||||
start = 0;
|
||||
|
||||
var editor = this.ace;
|
||||
var range = Range.fromPoints(editor.indexToPosition(start), editor.indexToPosition(end));
|
||||
editor.session.remove(range);
|
||||
|
||||
range.end = range.start;
|
||||
//editor.selection.setRange(range);
|
||||
|
||||
value = this.$updateTabstops(value);
|
||||
snippetManager.insertSnippet(editor, value)
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -282,6 +258,59 @@ AceEmmetEditor.prototype = {
|
|||
*/
|
||||
getFilePath: function() {
|
||||
return "";
|
||||
},
|
||||
|
||||
// update tabstops: make sure all caret placeholders are unique
|
||||
// by default, abbreviation parser generates all unlinked (un-mirrored)
|
||||
// tabstops as ${0}, so we have upgrade all caret tabstops with unique
|
||||
// positions but make sure that all other tabstops are not linked accidentally
|
||||
// based on https://github.com/sergeche/emmet-sublime/blob/master/editor.js#L119-L171
|
||||
$updateTabstops: function(value) {
|
||||
var base = 1000;
|
||||
var zeroBase = 0;
|
||||
var lastZero = null;
|
||||
var range = emmet.require('range');
|
||||
var ts = emmet.require('tabStops');
|
||||
var settings = emmet.require('resources').getVocabulary("user");
|
||||
var tabstopOptions = {
|
||||
tabstop: function(data) {
|
||||
var group = parseInt(data.group, 10);
|
||||
var isZero = group === 0;
|
||||
if (isZero)
|
||||
group = ++zeroBase;
|
||||
else
|
||||
group += base;
|
||||
|
||||
var placeholder = data.placeholder;
|
||||
if (placeholder) {
|
||||
// recursively update nested tabstops
|
||||
placeholder = ts.processText(placeholder, tabstopOptions);
|
||||
}
|
||||
|
||||
var result = '${' + group + (placeholder ? ':' + placeholder : '') + '}';
|
||||
|
||||
if (isZero) {
|
||||
lastZero = range.create(data.start, result);
|
||||
}
|
||||
|
||||
return result
|
||||
},
|
||||
escape: function(ch) {
|
||||
if (ch == '$') return '\\$';
|
||||
if (ch == '\\') return '\\\\';
|
||||
return ch;
|
||||
}
|
||||
};
|
||||
|
||||
value = ts.processText(value, tabstopOptions);
|
||||
|
||||
if (settings.variables['insert_final_tabstop'] && !/\$\{0\}$/.test(value)) {
|
||||
value += '${0}';
|
||||
} else if (lastZero) {
|
||||
value = emmet.require('utils').replaceSubstring(value, '${0}', lastZero);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -359,7 +388,7 @@ var onChangeMode = function(e, target) {
|
|||
if (!editor)
|
||||
return;
|
||||
var modeId = editor.session.$modeId;
|
||||
var enabled = modeId && /css|less|sass|html|php/.test(modeId);
|
||||
var enabled = modeId && /css|less|scss|sass|stylus|html|php/.test(modeId);
|
||||
if (e.enableEmmet === false)
|
||||
enabled = false;
|
||||
if (enabled)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ test: only space between #s is not a valid header
|
|||
# #
|
||||
|
||||
# test links [Cloud9 IDE](http://www.c9.io/) #
|
||||
* [demo](http://ajaxorg.github.com/ace/)
|
||||
* [demo](http://ajaxorg.github.com/ace/) [+](escape(\) ) [+](a "title") [+](a "space" )
|
||||
* usually *work* fine (_em_)
|
||||
in lists
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,26 @@
|
|||
["text","]("],
|
||||
["markup.underline","http://ajaxorg.github.com/ace/"],
|
||||
["text",")"],
|
||||
["list"," "]
|
||||
["list"," "],
|
||||
["text","["],
|
||||
["string","+"],
|
||||
["text","]("],
|
||||
["markup.underline","escape(\\) "],
|
||||
["text",")"],
|
||||
["list"," "],
|
||||
["text","["],
|
||||
["string","+"],
|
||||
["text","]("],
|
||||
["markup.underline","a"],
|
||||
["string"," \"title\""],
|
||||
["text",")"],
|
||||
["list"," "],
|
||||
["text","["],
|
||||
["string","+"],
|
||||
["text","]("],
|
||||
["markup.underline","a"],
|
||||
["string"," \"space\" "],
|
||||
["text",")"]
|
||||
],[
|
||||
"listblock",
|
||||
["markup.list","* "],
|
||||
|
|
|
|||
|
|
@ -32,12 +32,17 @@ define(function(require, exports, module) {
|
|||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var lang = require("../lib/lang");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
|
||||
var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
|
||||
var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
|
||||
var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
|
||||
|
||||
var escaped = function(ch) {
|
||||
return "(?:[^" + lang.escapeRegExp(ch) + "\\\\]|\\\\.)*";
|
||||
}
|
||||
|
||||
function github_embed(tag, prefix) {
|
||||
return { // Github style block
|
||||
token : "support.function",
|
||||
|
|
@ -104,15 +109,15 @@ var MarkdownHighlightRules = function() {
|
|||
regex : "^([ ]{0,3}\\[)([^\\]]+)(\\]:\\s*)([^ ]+)(\\s*(?:[\"][^\"]+[\"])?(\\s*))$"
|
||||
}, { // link by reference
|
||||
token : ["text", "string", "text", "constant", "text"],
|
||||
regex : "(\\[)((?:[[^\\]]*\\]|[^\\[\\]])*)(\\][ ]?(?:\\n[ ]*)?\\[)(.*?)(\\])"
|
||||
regex : "(\\[)(" + escaped("]") + ")(\\]\s*\\[)("+ escaped("]") + ")(\\])"
|
||||
}, { // link by url
|
||||
token : ["text", "string", "text", "markup.underline", "string", "text"],
|
||||
regex : "(\\[)"+
|
||||
"(\\[[^\\]]*\\]|[^\\[\\]]*)"+
|
||||
"(\\]\\([ \\t]*)"+
|
||||
"(<?(?:(?:[^\\(]*?\\([^\\)]*?\\)\\S*?)|(?:.*?))>?)"+
|
||||
"((?:[ \t]*\"(?:.*?)\"[ \\t]*)?)"+
|
||||
"(\\))"
|
||||
regex : "(\\[)(" + // [
|
||||
escaped("]") + // link text
|
||||
")(\\]\\()"+ // ](
|
||||
'((?:[^\\)\\s\\\\]|\\\\.|\\s(?=[^"]))*)' + // href
|
||||
'(\\s*"' + escaped('"') + '"\\s*)?' + // "title"
|
||||
"(\\))" // )
|
||||
}, { // strong ** __
|
||||
token : "string",
|
||||
regex : "([*]{2}|[_]{2}(?=\\S))(.*?\\S[*_]*)(\\1)"
|
||||
|
|
|
|||
|
|
@ -80,9 +80,6 @@ var PerlHighlightRules = function() {
|
|||
this.$rules = {
|
||||
"start" : [
|
||||
{
|
||||
token : "comment",
|
||||
regex : "#.*$"
|
||||
}, {
|
||||
token : "comment.doc",
|
||||
regex : "^=(?:begin|item)\\b",
|
||||
next : "block_comment"
|
||||
|
|
@ -114,7 +111,10 @@ var PerlHighlightRules = function() {
|
|||
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
||||
}, {
|
||||
token : "keyword.operator",
|
||||
regex : "\\.\\.\\.|\\|\\|=|>>=|<<=|<=>|&&=|=>|!~|\\^=|&=|\\|=|\\.=|x=|%=|\\/=|\\*=|\\-=|\\+=|=~|\\*\\*|\\-\\-|\\.\\.|\\|\\||&&|\\+\\+|\\->|!=|==|>=|<=|>>|<<|,|=|\\?\\:|\\^|\\||x|%|\\/|\\*|<|&|\\\\|~|!|>|\\.|\\-|\\+|\\-C|\\-b|\\-S|\\-u|\\-t|\\-p|\\-l|\\-d|\\-f|\\-g|\\-s|\\-z|\\-k|\\-e|\\-O|\\-T|\\-B|\\-M|\\-A|\\-X|\\-W|\\-c|\\-R|\\-o|\\-x|\\-w|\\-r|\\b(?:and|cmp|eq|ge|gt|le|lt|ne|not|or|xor)"
|
||||
regex : "%#|\\$#|\\.\\.\\.|\\|\\|=|>>=|<<=|<=>|&&=|=>|!~|\\^=|&=|\\|=|\\.=|x=|%=|\\/=|\\*=|\\-=|\\+=|=~|\\*\\*|\\-\\-|\\.\\.|\\|\\||&&|\\+\\+|\\->|!=|==|>=|<=|>>|<<|,|=|\\?\\:|\\^|\\||x|%|\\/|\\*|<|&|\\\\|~|!|>|\\.|\\-|\\+|\\-C|\\-b|\\-S|\\-u|\\-t|\\-p|\\-l|\\-d|\\-f|\\-g|\\-s|\\-z|\\-k|\\-e|\\-O|\\-T|\\-B|\\-M|\\-A|\\-X|\\-W|\\-c|\\-R|\\-o|\\-x|\\-w|\\-r|\\b(?:and|cmp|eq|ge|gt|le|lt|ne|not|or|xor)"
|
||||
}, {
|
||||
token : "comment",
|
||||
regex : "#.*$"
|
||||
}, {
|
||||
token : "lparen",
|
||||
regex : "[[({]"
|
||||
|
|
|
|||
|
|
@ -675,15 +675,20 @@ var TabstopManager = function(editor) {
|
|||
ts = this.tabstops[this.index];
|
||||
if (!ts || !ts.length)
|
||||
return;
|
||||
|
||||
|
||||
this.selectedTabstop = ts;
|
||||
var sel = this.editor.multiSelect;
|
||||
sel.toSingleRange(ts.firstNonLinked.clone());
|
||||
for (var i = ts.length; i--;) {
|
||||
if (ts.hasLinkedRanges && ts[i].linked)
|
||||
continue;
|
||||
sel.addRange(ts[i].clone(), true);
|
||||
if (!this.editor.inVirtualSelectionMode) {
|
||||
var sel = this.editor.multiSelect;
|
||||
sel.toSingleRange(ts.firstNonLinked.clone());
|
||||
for (var i = ts.length; i--;) {
|
||||
if (ts.hasLinkedRanges && ts[i].linked)
|
||||
continue;
|
||||
sel.addRange(ts[i].clone(), true);
|
||||
}
|
||||
} else {
|
||||
this.editor.selection.setRange(ts.firstNonLinked);
|
||||
}
|
||||
|
||||
this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
|
||||
};
|
||||
this.addTabstops = function(tabstops, start, end) {
|
||||
|
|
|
|||
|
|
@ -738,6 +738,9 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.$changes |= changes;
|
||||
return;
|
||||
}
|
||||
if (!this.$size.width)
|
||||
return this.onResize(true);
|
||||
|
||||
// this.$logChanges(changes);
|
||||
|
||||
this._signal("beforeRender");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue