diff --git a/build/update.js b/build/update.js
index 228f16ab..f8982fc0 100644
--- a/build/update.js
+++ b/build/update.js
@@ -20,7 +20,7 @@ var workersrcdir = path.join(braceroot, 'workersrc');
var workerdir = path.join(braceroot, 'worker');
var buildroot = path.join(__dirname, 'ace-build');
-var aceTag = 'v1.2.9';
+var aceTag = 'v1.4.2';
+function updateCleanAndPutInOrder() {
diff --git a/ext/beautify.js b/ext/beautify.js
index af20a635..c870de97 100644
--- a/ext/beautify.js
+++ b/ext/beautify.js
@@ -1,321 +1,301 @@
-ace.define("ace/ext/beautify/php_rules",["require","exports","module","ace/token_iterator"], function(acequire, exports, module) {
+ace.define("ace/ext/beautify",["require","exports","module","ace/token_iterator"], function(acequire, exports, module) {
"use strict";
-var TokenIterator = acequire("ace/token_iterator").TokenIterator;
-exports.newLines = [{
- type: 'support.php_tag',
- value: ''
-}, {
- type: 'paren.lparen',
- value: '{',
- indent: true
-}, {
- type: 'paren.rparen',
- breakBefore: true,
- value: '}',
- indent: false
-}, {
- type: 'paren.rparen',
- breakBefore: true,
- value: '})',
- indent: false,
- dontBreak: true
-}, {
- type: 'comment'
-}, {
- type: 'text',
- value: ';'
-}, {
- type: 'text',
- value: ':',
- context: 'php'
-}, {
- type: 'keyword',
- value: 'case',
- indent: true,
- dontBreak: true
-}, {
- type: 'keyword',
- value: 'default',
- indent: true,
- dontBreak: true
-}, {
- type: 'keyword',
- value: 'break',
- indent: false,
- dontBreak: true
-}, {
- type: 'punctuation.doctype.end',
- value: '>'
-}, {
- type: 'meta.tag.punctuation.end',
- value: '>'
-}, {
- type: 'meta.tag.punctuation.begin',
- value: '<',
- blockTag: true,
- indent: true,
- dontBreak: true
-}, {
- type: 'meta.tag.punctuation.begin',
- value: '',
- indent: false,
- breakBefore: true,
- dontBreak: true
-}, {
- type: 'punctuation.operator',
- value: ';'
-}];
+var TokenIterator = acequire("../token_iterator").TokenIterator;
-exports.spaces = [{
- type: 'xml-pe',
- prepend: true
-},{
- type: 'entity.other.attribute-name',
- prepend: true
-}, {
- type: 'storage.type',
- value: 'var',
- append: true
-}, {
- type: 'storage.type',
- value: 'function',
- append: true
-}, {
- type: 'keyword.operator',
- value: '='
-}, {
- type: 'keyword',
- value: 'as',
- prepend: true,
- append: true
-}, {
- type: 'keyword',
- value: 'function',
- append: true
-}, {
- type: 'support.function',
- next: /[^\(]/,
- append: true
-}, {
- type: 'keyword',
- value: 'or',
- append: true,
- prepend: true
-}, {
- type: 'keyword',
- value: 'and',
- append: true,
- prepend: true
-}, {
- type: 'keyword',
- value: 'case',
- append: true
-}, {
- type: 'keyword.operator',
- value: '||',
- append: true,
- prepend: true
-}, {
- type: 'keyword.operator',
- value: '&&',
- append: true,
- prepend: true
-}];
-exports.singleTags = ['!doctype','area','base','br','hr','input','img','link','meta'];
+function is(token, type) {
+ return token.type.lastIndexOf(type + ".xml") > -1;
+}
+exports.singletonTags = ["area", "base", "br", "col", "command", "embed", "hr", "html", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
+exports.blockTags = ["article", "aside", "blockquote", "body", "div", "dl", "fieldset", "footer", "form", "head", "header", "html", "nav", "ol", "p", "script", "section", "style", "table", "tbody", "tfoot", "thead", "ul"];
-exports.transform = function(iterator, maxPos, context) {
+exports.beautify = function(session) {
+ var iterator = new TokenIterator(session, 0, 0);
var token = iterator.getCurrentToken();
-
- var newLines = exports.newLines;
- var spaces = exports.spaces;
- var singleTags = exports.singleTags;
-
- var code = '';
-
- var indentation = 0;
- var dontBreak = false;
- var tag;
- var lastTag;
- var lastToken = {};
- var nextTag;
- var nextToken = {};
- var breakAdded = false;
- var value = '';
-
- while (token!==null) {
- console.log(token);
-
- if( !token ){
- token = iterator.stepForward();
- continue;
- }
- if( token.type == 'support.php_tag' && token.value != '?>' ){
- context = 'php';
- }
- else if( token.type == 'support.php_tag' && token.value == '?>' ){
- context = 'html';
- }
- else if( token.type == 'meta.tag.name.style' && context != 'css' ){
- context = 'css';
- }
- else if( token.type == 'meta.tag.name.style' && context == 'css' ){
- context = 'html';
- }
- else if( token.type == 'meta.tag.name.script' && context != 'js' ){
- context = 'js';
- }
- else if( token.type == 'meta.tag.name.script' && context == 'js' ){
- context = 'html';
- }
+ var tabString = session.getTabString();
+ var singletonTags = exports.singletonTags;
+ var blockTags = exports.blockTags;
+ var nextToken;
+ var breakBefore = false;
+ var spaceBefore = false;
+ var spaceAfter = false;
+ var code = "";
+ var value = "";
+ var tagName = "";
+ var depth = 0;
+ var lastDepth = 0;
+ var lastIndent = 0;
+ var indent = 0;
+ var unindent = 0;
+ var roundDepth = 0;
+ var onCaseLine = false;
+ var row;
+ var curRow = 0;
+ var rowsToAdd = 0;
+ var rowTokens = [];
+ var abort = false;
+ var i;
+ var indentNextLine = false;
+ var inTag = false;
+ var inCSS = false;
+ var inBlock = false;
+ var levels = {0: 0};
+ var parents = {};
+
+ var trimNext = function() {
+ if (nextToken && nextToken.value && nextToken.type !== 'string.regexp')
+ nextToken.value = nextToken.value.trim();
+ };
+
+ var trimLine = function() {
+ code = code.replace(/ +$/, "");
+ };
+ var trimCode = function() {
+ code = code.trimRight();
+ breakBefore = false;
+ };
+
+ while (token !== null) {
+ curRow = iterator.getCurrentTokenRow();
+ rowTokens = iterator.$rowTokens;
nextToken = iterator.stepForward();
- if (nextToken && nextToken.type.indexOf('meta.tag.name') == 0) {
- nextTag = nextToken.value;
- }
- if ( lastToken.type == 'support.php_tag' && lastToken.value == '=') {
- dontBreak = true;
- }
- if (token.type == 'meta.tag.name') {
- token.value = token.value.toLowerCase();
- }
- if (token.type == 'text') {
- token.value = token.value.trim();
- }
- if (!token.value) {
- token = nextToken;
- continue;
- }
- value = token.value;
- for (var i in spaces) {
- if (
- token.type == spaces[i].type &&
- (!spaces[i].value || token.value == spaces[i].value) &&
- (
- nextToken &&
- (!spaces[i].next || spaces[i].next.test(nextToken.value))
- )
- ) {
- if (spaces[i].prepend) {
- value = ' ' + token.value;
- }
- if (spaces[i].append) {
- value += ' ';
+ if (typeof token !== "undefined") {
+ value = token.value;
+ unindent = 0;
+ inCSS = (tagName === "style" || session.$modeId === "ace/mode/css");
+ if (is(token, "tag-open")) {
+ inTag = true;
+ if (nextToken)
+ inBlock = (blockTags.indexOf(nextToken.value) !== -1);
+ if (value === "") {
+ if (inBlock && !breakBefore && rowsToAdd < 1)
+ rowsToAdd++;
+
+ if (inCSS)
+ rowsToAdd = 1;
+
+ unindent = 1;
+ inBlock = false;
}
+ } else if (is(token, "tag-close")) {
+ inTag = false;
+ } else if (is(token, "comment.start")) {
+ inBlock = true;
+ } else if (is(token, "comment.end")) {
+ inBlock = false;
+ }
+ if (!inTag && !rowsToAdd && token.type === "paren.rparen" && token.value.substr(0, 1) === "}") {
+ rowsToAdd++;
+ }
+ if (curRow !== row) {
+ rowsToAdd = curRow;
+
+ if (row)
+ rowsToAdd -= row;
}
- }
- if (token.type.indexOf('meta.tag.name') == 0) {
- tag = token.value;
- }
- breakAdded = false;
- for (i in newLines) {
- if (
- token.type == newLines[i].type &&
- (
- !newLines[i].value ||
- token.value == newLines[i].value
- ) &&
- (
- !newLines[i].blockTag ||
- singleTags.indexOf(nextTag) === -1
- ) &&
- (
- !newLines[i].context ||
- newLines[i].context === context
- )
- ) {
- if (newLines[i].indent === false) {
- indentation--;
- }
- if (
- newLines[i].breakBefore &&
- ( !newLines[i].prev || newLines[i].prev.test(lastToken.value) )
- ) {
+ if (rowsToAdd) {
+ trimCode();
+ for (; rowsToAdd > 0; rowsToAdd--)
code += "\n";
- breakAdded = true;
- for (i = 0; i < indentation; i++) {
- code += "\t";
- }
- }
- break;
+ breakBefore = true;
+ if (!is(token, "comment") && !token.type.match(/^(comment|string)$/))
+ value = value.trimLeft();
}
- }
- if (dontBreak===false) {
- for (i in newLines) {
- if (
- lastToken.type == newLines[i].type &&
- (
- !newLines[i].value || lastToken.value == newLines[i].value
- ) &&
- (
- !newLines[i].blockTag ||
- singleTags.indexOf(tag) === -1
- ) &&
- (
- !newLines[i].context ||
- newLines[i].context === context
- )
- ) {
- if (newLines[i].indent === true) {
- indentation++;
+ if (value) {
+ if (token.type === "keyword" && value.match(/^(if|else|elseif|for|foreach|while|switch)$/)) {
+ parents[depth] = value;
+
+ trimNext();
+ spaceAfter = true;
+ if (value.match(/^(else|elseif)$/)) {
+ if (code.match(/\}[\s]*$/)) {
+ trimCode();
+ spaceBefore = true;
+ }
}
+ } else if (token.type === "paren.lparen") {
+ trimNext();
+ if (value.substr(-1) === "{") {
+ spaceAfter = true;
+ indentNextLine = false;
- if (!newLines[i].dontBreak && !breakAdded) {
- code += "\n";
- for (i = 0; i < indentation; i++) {
- code += "\t";
+ if(!inTag)
+ rowsToAdd = 1;
+ }
+ if (value.substr(0, 1) === "{") {
+ spaceBefore = true;
+ if (code.substr(-1) !== '[' && code.trimRight().substr(-1) === '[') {
+ trimCode();
+ spaceBefore = false;
+ } else if (code.trimRight().substr(-1) === ')') {
+ trimCode();
+ } else {
+ trimLine();
}
}
+ } else if (token.type === "paren.rparen") {
+ unindent = 1;
+ if (value.substr(0, 1) === "}") {
+ if (parents[depth-1] === 'case')
+ unindent++;
+
+ if (code.trimRight().substr(-1) === '{') {
+ trimCode();
+ } else {
+ spaceBefore = true;
- break;
+ if (inCSS)
+ rowsToAdd+=2;
+ }
+ }
+ if (value.substr(0, 1) === "]") {
+ if (code.substr(-1) !== '}' && code.trimRight().substr(-1) === '}') {
+ spaceBefore = false;
+ indent++;
+ trimCode();
+ }
+ }
+ if (value.substr(0, 1) === ")") {
+ if (code.substr(-1) !== '(' && code.trimRight().substr(-1) === '(') {
+ spaceBefore = false;
+ indent++;
+ trimCode();
+ }
+ }
+
+ trimLine();
+ } else if ((token.type === "keyword.operator" || token.type === "keyword") && value.match(/^(=|==|===|!=|!==|&&|\|\||and|or|xor|\+=|.=|>|>=|<|<=|=>)$/)) {
+ trimCode();
+ trimNext();
+ spaceBefore = true;
+ spaceAfter = true;
+ } else if (token.type === "punctuation.operator" && value === ';') {
+ trimCode();
+ trimNext();
+ spaceAfter = true;
+
+ if (inCSS)
+ rowsToAdd++;
+ } else if (token.type === "punctuation.operator" && value.match(/^(:|,)$/)) {
+ trimCode();
+ trimNext();
+ spaceAfter = true;
+ breakBefore = false;
+ } else if (token.type === "support.php_tag" && value === "?>" && !breakBefore) {
+ trimCode();
+ spaceBefore = true;
+ } else if (is(token, "attribute-name") && code.substr(-1).match(/^\s$/)) {
+ spaceBefore = true;
+ } else if (is(token, "attribute-equals")) {
+ trimLine();
+ trimNext();
+ } else if (is(token, "tag-close")) {
+ trimLine();
+ if(value === "/>")
+ spaceBefore = true;
}
- }
- }
+ if (breakBefore && !(token.type.match(/^(comment)$/) && !value.substr(0, 1).match(/^[/#]$/)) && !(token.type.match(/^(string)$/) && !value.substr(0, 1).match(/^['"]$/))) {
- code += value;
- if ( lastToken.type == 'support.php_tag' && lastToken.value == '?>' ) {
- dontBreak = false;
- }
- lastTag = tag;
+ indent = lastIndent;
- lastToken = token;
+ if(depth > lastDepth) {
+ indent++;
- token = nextToken;
+ for (i=depth; i > lastDepth; i--)
+ levels[i] = indent;
+ } else if(depth < lastDepth)
+ indent = levels[depth];
- if (token===null) {
- break;
- }
- }
-
- return code;
-};
+ lastDepth = depth;
+ lastIndent = indent;
+ if(unindent)
+ indent -= unindent;
+ if (indentNextLine && !roundDepth) {
+ indent++;
+ indentNextLine = false;
+ }
-});
+ for (i = 0; i < indent; i++)
+ code += tabString;
+ }
-ace.define("ace/ext/beautify",["require","exports","module","ace/token_iterator","ace/ext/beautify/php_rules"], function(acequire, exports, module) {
-"use strict";
-var TokenIterator = acequire("ace/token_iterator").TokenIterator;
-var phpTransform = acequire("./beautify/php_rules").transform;
+ if (token.type === "keyword" && value.match(/^(case|default)$/)) {
+ parents[depth] = value;
+ depth++;
+ }
-exports.beautify = function(session) {
- var iterator = new TokenIterator(session, 0, 0);
- var token = iterator.getCurrentToken();
- var context = session.$modeId.split("/").pop();
+ if (token.type === "keyword" && value.match(/^(break)$/)) {
+ if(parents[depth-1] && parents[depth-1].match(/^(case|default)$/)) {
+ depth--;
+ }
+ }
+ if (token.type === "paren.lparen") {
+ roundDepth += (value.match(/\(/g) || []).length;
+ depth += value.length;
+ }
- var code = phpTransform(iterator, context);
+ if (token.type === "keyword" && value.match(/^(if|else|elseif|for|while)$/)) {
+ indentNextLine = true;
+ roundDepth = 0;
+ } else if (!roundDepth && value.trim() && token.type !== "comment")
+ indentNextLine = false;
+
+ if (token.type === "paren.rparen") {
+ roundDepth -= (value.match(/\)/g) || []).length;
+
+ for (i = 0; i < value.length; i++) {
+ depth--;
+ if(value.substr(i, 1)==='}' && parents[depth]==='case') {
+ depth--;
+ }
+ }
+ }
+ if (spaceBefore && !breakBefore) {
+ trimLine();
+ if (code.substr(-1) !== "\n")
+ code += " ";
+ }
+
+ code += value;
+
+ if (spaceAfter)
+ code += " ";
+
+ breakBefore = false;
+ spaceBefore = false;
+ spaceAfter = false;
+ if ((is(token, "tag-close") && (inBlock || blockTags.indexOf(tagName) !== -1)) || (is(token, "doctype") && value === ">")) {
+ if (inBlock && nextToken && nextToken.value === "")
+ rowsToAdd = -1;
+ else
+ rowsToAdd = 1;
+ }
+ if (is(token, "tag-open") && value === "") {
+ depth--;
+ } else if (is(token, "tag-open") && value === "<" && singletonTags.indexOf(nextToken.value) === -1) {
+ depth++;
+ } else if (is(token, "tag-name")) {
+ tagName = value;
+ } else if (is(token, "tag-close") && value === "/>" && singletonTags.indexOf(tagName) === -1){
+ depth--;
+ }
+
+ row = curRow;
+ }
+ }
+
+ token = nextToken;
+ }
+
+ code = code.trim();
session.doc.setValue(code);
};
@@ -327,8 +307,11 @@ exports.commands = [{
bindKey: "Ctrl-Shift-B"
}];
-});
- (function() {
- ace.acequire(["ace/ext/beautify"], function() {});
+}); (function() {
+ ace.acequire(["ace/ext/beautify"], function(m) {
+ if (typeof module == "object" && typeof exports == "object" && module) {
+ module.exports = m;
+ }
+ });
})();
\ No newline at end of file
diff --git a/ext/chromevox.js b/ext/chromevox.js
deleted file mode 100644
index c69c5451..00000000
--- a/ext/chromevox.js
+++ /dev/null
@@ -1,540 +0,0 @@
-ace.define("ace/ext/chromevox",["require","exports","module","ace/editor","ace/config"], function(acequire, exports, module) {
-var cvoxAce = {};
-cvoxAce.SpeechProperty;
-cvoxAce.Cursor;
-cvoxAce.Token;
-cvoxAce.Annotation;
-var CONSTANT_PROP = {
- 'rate': 0.8,
- 'pitch': 0.4,
- 'volume': 0.9
-};
-var DEFAULT_PROP = {
- 'rate': 1,
- 'pitch': 0.5,
- 'volume': 0.9
-};
-var ENTITY_PROP = {
- 'rate': 0.8,
- 'pitch': 0.8,
- 'volume': 0.9
-};
-var KEYWORD_PROP = {
- 'rate': 0.8,
- 'pitch': 0.3,
- 'volume': 0.9
-};
-var STORAGE_PROP = {
- 'rate': 0.8,
- 'pitch': 0.7,
- 'volume': 0.9
-};
-var VARIABLE_PROP = {
- 'rate': 0.8,
- 'pitch': 0.8,
- 'volume': 0.9
-};
-var DELETED_PROP = {
- 'punctuationEcho': 'none',
- 'relativePitch': -0.6
-};
-var ERROR_EARCON = 'ALERT_NONMODAL';
-var MODE_SWITCH_EARCON = 'ALERT_MODAL';
-var NO_MATCH_EARCON = 'INVALID_KEYPRESS';
-var INSERT_MODE_STATE = 'insertMode';
-var COMMAND_MODE_STATE = 'start';
-
-var REPLACE_LIST = [
- {
- substr: ';',
- newSubstr: ' semicolon '
- },
- {
- substr: ':',
- newSubstr: ' colon '
- }
-];
-var Command = {
- SPEAK_ANNOT: 'annots',
- SPEAK_ALL_ANNOTS: 'all_annots',
- TOGGLE_LOCATION: 'toggle_location',
- SPEAK_MODE: 'mode',
- SPEAK_ROW_COL: 'row_col',
- TOGGLE_DISPLACEMENT: 'toggle_displacement',
- FOCUS_TEXT: 'focus_text'
-};
-var KEY_PREFIX = 'CONTROL + SHIFT ';
-cvoxAce.editor = null;
-var lastCursor = null;
-var annotTable = {};
-var shouldSpeakRowLocation = false;
-var shouldSpeakDisplacement = false;
-var changed = false;
-var vimState = null;
-var keyCodeToShortcutMap = {};
-var cmdToShortcutMap = {};
-var getKeyShortcutString = function(keyCode) {
- return KEY_PREFIX + String.fromCharCode(keyCode);
-};
-var isVimMode = function() {
- var keyboardHandler = cvoxAce.editor.keyBinding.getKeyboardHandler();
- return keyboardHandler.$id === 'ace/keyboard/vim';
-};
-var getCurrentToken = function(cursor) {
- return cvoxAce.editor.getSession().getTokenAt(cursor.row, cursor.column + 1);
-};
-var getCurrentLine = function(cursor) {
- return cvoxAce.editor.getSession().getLine(cursor.row);
-};
-var onRowChange = function(currCursor) {
- if (annotTable[currCursor.row]) {
- cvox.Api.playEarcon(ERROR_EARCON);
- }
- if (shouldSpeakRowLocation) {
- cvox.Api.stop();
- speakChar(currCursor);
- speakTokenQueue(getCurrentToken(currCursor));
- speakLine(currCursor.row, 1);
- } else {
- speakLine(currCursor.row, 0);
- }
-};
-var isWord = function(cursor) {
- var line = getCurrentLine(cursor);
- var lineSuffix = line.substr(cursor.column - 1);
- if (cursor.column === 0) {
- lineSuffix = ' ' + line;
- }
- var firstWordRegExp = /^\W(\w+)/;
- var words = firstWordRegExp.exec(lineSuffix);
- return words !== null;
-};
-var rules = {
- 'constant': {
- prop: CONSTANT_PROP
- },
- 'entity': {
- prop: ENTITY_PROP
- },
- 'keyword': {
- prop: KEYWORD_PROP
- },
- 'storage': {
- prop: STORAGE_PROP
- },
- 'variable': {
- prop: VARIABLE_PROP
- },
- 'meta': {
- prop: DEFAULT_PROP,
- replace: [
- {
- substr: '',
- newSubstr: ' closing tag '
- },
- {
- substr: '/>',
- newSubstr: ' close tag '
- },
- {
- substr: '<',
- newSubstr: ' tag start '
- },
- {
- substr: '>',
- newSubstr: ' tag end '
- }
- ]
- }
-};
-var DEFAULT_RULE = {
- prop: DEFAULT_RULE
-};
-var expand = function(value, replaceRules) {
- var newValue = value;
- for (var i = 0; i < replaceRules.length; i++) {
- var replaceRule = replaceRules[i];
- var regexp = new RegExp(replaceRule.substr, 'g');
- newValue = newValue.replace(regexp, replaceRule.newSubstr);
- }
- return newValue;
-};
-var mergeTokens = function(tokens, start, end) {
- var newToken = {};
- newToken.value = '';
- newToken.type = tokens[start].type;
- for (var j = start; j < end; j++) {
- newToken.value += tokens[j].value;
- }
- return newToken;
-};
-var mergeLikeTokens = function(tokens) {
- if (tokens.length <= 1) {
- return tokens;
- }
- var newTokens = [];
- var lastLikeIndex = 0;
- for (var i = 1; i < tokens.length; i++) {
- var lastLikeToken = tokens[lastLikeIndex];
- var currToken = tokens[i];
- if (getTokenRule(lastLikeToken) !== getTokenRule(currToken)) {
- newTokens.push(mergeTokens(tokens, lastLikeIndex, i));
- lastLikeIndex = i;
- }
- }
- newTokens.push(mergeTokens(tokens, lastLikeIndex, tokens.length));
- return newTokens;
-};
-var isRowWhiteSpace = function(row) {
- var line = cvoxAce.editor.getSession().getLine(row);
- var whiteSpaceRegexp = /^\s*$/;
- return whiteSpaceRegexp.exec(line) !== null;
-};
-var speakLine = function(row, queue) {
- var tokens = cvoxAce.editor.getSession().getTokens(row);
- if (tokens.length === 0 || isRowWhiteSpace(row)) {
- cvox.Api.playEarcon('EDITABLE_TEXT');
- return;
- }
- tokens = mergeLikeTokens(tokens);
- var firstToken = tokens[0];
- tokens = tokens.filter(function(token) {
- return token !== firstToken;
- });
- speakToken_(firstToken, queue);
- tokens.forEach(speakTokenQueue);
-};
-var speakTokenFlush = function(token) {
- speakToken_(token, 0);
-};
-var speakTokenQueue = function(token) {
- speakToken_(token, 1);
-};
-var getTokenRule = function(token) {
- if (!token || !token.type) {
- return;
- }
- var split = token.type.split('.');
- if (split.length === 0) {
- return;
- }
- var type = split[0];
- var rule = rules[type];
- if (!rule) {
- return DEFAULT_RULE;
- }
- return rule;
-};
-var speakToken_ = function(token, queue) {
- var rule = getTokenRule(token);
- var value = expand(token.value, REPLACE_LIST);
- if (rule.replace) {
- value = expand(value, rule.replace);
- }
- cvox.Api.speak(value, queue, rule.prop);
-};
-var speakChar = function(cursor) {
- var line = getCurrentLine(cursor);
- cvox.Api.speak(line[cursor.column], 1);
-};
-var speakDisplacement = function(lastCursor, currCursor) {
- var line = getCurrentLine(currCursor);
- var displace = line.substring(lastCursor.column, currCursor.column);
- displace = displace.replace(/ /g, ' space ');
- cvox.Api.speak(displace);
-};
-var speakCharOrWordOrLine = function(lastCursor, currCursor) {
- if (Math.abs(lastCursor.column - currCursor.column) !== 1) {
- var currLineLength = getCurrentLine(currCursor).length;
- if (currCursor.column === 0 || currCursor.column === currLineLength) {
- speakLine(currCursor.row, 0);
- return;
- }
- if (isWord(currCursor)) {
- cvox.Api.stop();
- speakTokenQueue(getCurrentToken(currCursor));
- return;
- }
- }
- speakChar(currCursor);
-};
-var onColumnChange = function(lastCursor, currCursor) {
- if (!cvoxAce.editor.selection.isEmpty()) {
- speakDisplacement(lastCursor, currCursor);
- cvox.Api.speak('selected', 1);
- }
- else if (shouldSpeakDisplacement) {
- speakDisplacement(lastCursor, currCursor);
- } else {
- speakCharOrWordOrLine(lastCursor, currCursor);
- }
-};
-var onCursorChange = function(evt) {
- if (changed) {
- changed = false;
- return;
- }
- var currCursor = cvoxAce.editor.selection.getCursor();
- if (currCursor.row !== lastCursor.row) {
- onRowChange(currCursor);
- } else {
- onColumnChange(lastCursor, currCursor);
- }
- lastCursor = currCursor;
-};
-var onSelectionChange = function(evt) {
- if (cvoxAce.editor.selection.isEmpty()) {
- cvox.Api.speak('unselected');
- }
-};
-var onChange = function(delta) {
- switch (delta.action) {
- case 'remove':
- cvox.Api.speak(delta.text, 0, DELETED_PROP);
- changed = true;
- break;
- case 'insert':
- cvox.Api.speak(delta.text, 0);
- changed = true;
- break;
- }
-};
-var isNewAnnotation = function(annot) {
- var row = annot.row;
- var col = annot.column;
- return !annotTable[row] || !annotTable[row][col];
-};
-var populateAnnotations = function(annotations) {
- annotTable = {};
- for (var i = 0; i < annotations.length; i++) {
- var annotation = annotations[i];
- var row = annotation.row;
- var col = annotation.column;
- if (!annotTable[row]) {
- annotTable[row] = {};
- }
- annotTable[row][col] = annotation;
- }
-};
-var onAnnotationChange = function(evt) {
- var annotations = cvoxAce.editor.getSession().getAnnotations();
- var newAnnotations = annotations.filter(isNewAnnotation);
- if (newAnnotations.length > 0) {
- cvox.Api.playEarcon(ERROR_EARCON);
- }
- populateAnnotations(annotations);
-};
-var speakAnnot = function(annot) {
- var annotText = annot.type + ' ' + annot.text + ' on ' +
- rowColToString(annot.row, annot.column);
- annotText = annotText.replace(';', 'semicolon');
- cvox.Api.speak(annotText, 1);
-};
-var speakAnnotsByRow = function(row) {
- var annots = annotTable[row];
- for (var col in annots) {
- speakAnnot(annots[col]);
- }
-};
-var rowColToString = function(row, col) {
- return 'row ' + (row + 1) + ' column ' + (col + 1);
-};
-var speakCurrRowAndCol = function() {
- cvox.Api.speak(rowColToString(lastCursor.row, lastCursor.column));
-};
-var speakAllAnnots = function() {
- for (var row in annotTable) {
- speakAnnotsByRow(row);
- }
-};
-var speakMode = function() {
- if (!isVimMode()) {
- return;
- }
- switch (cvoxAce.editor.keyBinding.$data.state) {
- case INSERT_MODE_STATE:
- cvox.Api.speak('Insert mode');
- break;
- case COMMAND_MODE_STATE:
- cvox.Api.speak('Command mode');
- break;
- }
-};
-var toggleSpeakRowLocation = function() {
- shouldSpeakRowLocation = !shouldSpeakRowLocation;
- if (shouldSpeakRowLocation) {
- cvox.Api.speak('Speak location on row change enabled.');
- } else {
- cvox.Api.speak('Speak location on row change disabled.');
- }
-};
-var toggleSpeakDisplacement = function() {
- shouldSpeakDisplacement = !shouldSpeakDisplacement;
- if (shouldSpeakDisplacement) {
- cvox.Api.speak('Speak displacement on column changes.');
- } else {
- cvox.Api.speak('Speak current character or word on column changes.');
- }
-};
-var onKeyDown = function(evt) {
- if (evt.ctrlKey && evt.shiftKey) {
- var shortcut = keyCodeToShortcutMap[evt.keyCode];
- if (shortcut) {
- shortcut.func();
- }
- }
-};
-var onChangeStatus = function(evt, editor) {
- if (!isVimMode()) {
- return;
- }
- var state = editor.keyBinding.$data.state;
- if (state === vimState) {
- return;
- }
- switch (state) {
- case INSERT_MODE_STATE:
- cvox.Api.playEarcon(MODE_SWITCH_EARCON);
- cvox.Api.setKeyEcho(true);
- break;
- case COMMAND_MODE_STATE:
- cvox.Api.playEarcon(MODE_SWITCH_EARCON);
- cvox.Api.setKeyEcho(false);
- break;
- }
- vimState = state;
-};
-var contextMenuHandler = function(evt) {
- var cmd = evt.detail['customCommand'];
- var shortcut = cmdToShortcutMap[cmd];
- if (shortcut) {
- shortcut.func();
- cvoxAce.editor.focus();
- }
-};
-var initContextMenu = function() {
- var ACTIONS = SHORTCUTS.map(function(shortcut) {
- return {
- desc: shortcut.desc + getKeyShortcutString(shortcut.keyCode),
- cmd: shortcut.cmd
- };
- });
- var body = document.querySelector('body');
- body.setAttribute('contextMenuActions', JSON.stringify(ACTIONS));
- body.addEventListener('ATCustomEvent', contextMenuHandler, true);
-};
-var onFindSearchbox = function(evt) {
- if (evt.match) {
- speakLine(lastCursor.row, 0);
- } else {
- cvox.Api.playEarcon(NO_MATCH_EARCON);
- }
-};
-var focus = function() {
- cvoxAce.editor.focus();
-};
-var SHORTCUTS = [
- {
- keyCode: 49,
- func: function() {
- speakAnnotsByRow(lastCursor.row);
- },
- cmd: Command.SPEAK_ANNOT,
- desc: 'Speak annotations on line'
- },
- {
- keyCode: 50,
- func: speakAllAnnots,
- cmd: Command.SPEAK_ALL_ANNOTS,
- desc: 'Speak all annotations'
- },
- {
- keyCode: 51,
- func: speakMode,
- cmd: Command.SPEAK_MODE,
- desc: 'Speak Vim mode'
- },
- {
- keyCode: 52,
- func: toggleSpeakRowLocation,
- cmd: Command.TOGGLE_LOCATION,
- desc: 'Toggle speak row location'
- },
- {
- keyCode: 53,
- func: speakCurrRowAndCol,
- cmd: Command.SPEAK_ROW_COL,
- desc: 'Speak row and column'
- },
- {
- keyCode: 54,
- func: toggleSpeakDisplacement,
- cmd: Command.TOGGLE_DISPLACEMENT,
- desc: 'Toggle speak displacement'
- },
- {
- keyCode: 55,
- func: focus,
- cmd: Command.FOCUS_TEXT,
- desc: 'Focus text'
- }
-];
-var onFocus = function(_, editor) {
- cvoxAce.editor = editor;
- editor.getSession().selection.on('changeCursor', onCursorChange);
- editor.getSession().selection.on('changeSelection', onSelectionChange);
- editor.getSession().on('change', onChange);
- editor.getSession().on('changeAnnotation', onAnnotationChange);
- editor.on('changeStatus', onChangeStatus);
- editor.on('findSearchBox', onFindSearchbox);
- editor.container.addEventListener('keydown', onKeyDown);
-
- lastCursor = editor.selection.getCursor();
-};
-var init = function(editor) {
- onFocus(null, editor);
- SHORTCUTS.forEach(function(shortcut) {
- keyCodeToShortcutMap[shortcut.keyCode] = shortcut;
- cmdToShortcutMap[shortcut.cmd] = shortcut;
- });
-
- editor.on('focus', onFocus);
- if (isVimMode()) {
- cvox.Api.setKeyEcho(false);
- }
- initContextMenu();
-};
-function cvoxApiExists() {
- return (typeof(cvox) !== 'undefined') && cvox && cvox.Api;
-}
-var tries = 0;
-var MAX_TRIES = 15;
-function watchForCvoxLoad(editor) {
- if (cvoxApiExists()) {
- init(editor);
- } else {
- tries++;
- if (tries >= MAX_TRIES) {
- return;
- }
- window.setTimeout(watchForCvoxLoad, 500, editor);
- }
-}
-
-var Editor = acequire('../editor').Editor;
-acequire('../config').defineOptions(Editor.prototype, 'editor', {
- enableChromevoxEnhancements: {
- set: function(val) {
- if (val) {
- watchForCvoxLoad(this);
- }
- },
- value: true // turn it on by default or check for window.cvox
- }
-});
-
-});
- (function() {
- ace.acequire(["ace/ext/chromevox"], function() {});
- })();
-
\ No newline at end of file
diff --git a/ext/elastic_tabstops_lite.js b/ext/elastic_tabstops_lite.js
index c21a487a..8e457adb 100644
--- a/ext/elastic_tabstops_lite.js
+++ b/ext/elastic_tabstops_lite.js
@@ -267,8 +267,11 @@ acequire("../config").defineOptions(Editor.prototype, "editor", {
}
});
-});
- (function() {
- ace.acequire(["ace/ext/elastic_tabstops_lite"], function() {});
+}); (function() {
+ ace.acequire(["ace/ext/elastic_tabstops_lite"], function(m) {
+ if (typeof module == "object" && typeof exports == "object" && module) {
+ module.exports = m;
+ }
+ });
})();
\ No newline at end of file
diff --git a/ext/emmet.js b/ext/emmet.js
index eca04edf..8c8acd38 100644
--- a/ext/emmet.js
+++ b/ext/emmet.js
@@ -509,10 +509,10 @@ var SnippetManager = function() {
return;
s.startRe = guardedRegexp(s.trigger, s.guard, true);
- s.triggerRe = new RegExp(s.trigger, "", true);
+ s.triggerRe = new RegExp(s.trigger);
s.endRe = guardedRegexp(s.endTrigger, s.endGuard, true);
- s.endTriggerRe = new RegExp(s.endTrigger, "", true);
+ s.endTriggerRe = new RegExp(s.endTrigger);
}
if (snippets && snippets.content)
@@ -1128,7 +1128,7 @@ exports.runEmmetCommand = function runEmmetCommand(editor) {
var result = actions.run(this.action, editorProxy);
} catch(e) {
if (!emmet) {
- load(runEmmetCommand.bind(this, editor));
+ exports.load(runEmmetCommand.bind(this, editor));
return true;
}
editor._signal("changeStatus", typeof e == "string" ? e : e.message);
@@ -1186,11 +1186,11 @@ var onChangeMode = function(e, target) {
if (e.enableEmmet === false)
enabled = false;
if (enabled)
- load();
+ exports.load();
exports.updateCommands(editor, enabled);
};
-var load = function(cb) {
+exports.load = function(cb) {
if (typeof emmetPath == "string") {
acequire("ace/config").loadModule(emmetPath, function() {
emmetPath = null;
@@ -1216,8 +1216,11 @@ exports.setCore = function(e) {
else
emmet = e;
};
-});
- (function() {
- ace.acequire(["ace/ext/emmet"], function() {});
+}); (function() {
+ ace.acequire(["ace/ext/emmet"], function(m) {
+ if (typeof module == "object" && typeof exports == "object" && module) {
+ module.exports = m;
+ }
+ });
})();
\ No newline at end of file
diff --git a/ext/error_marker.js b/ext/error_marker.js
index 8304fcb0..f1f35263 100644
--- a/ext/error_marker.js
+++ b/ext/error_marker.js
@@ -1,6 +1,9 @@
-;
- (function() {
- ace.acequire(["ace/ext/error_marker"], function() {});
+; (function() {
+ ace.acequire(["ace/ext/error_marker"], function(m) {
+ if (typeof module == "object" && typeof exports == "object" && module) {
+ module.exports = m;
+ }
+ });
})();
\ No newline at end of file
diff --git a/ext/keybinding_menu.js b/ext/keybinding_menu.js
index cbe30d78..aa9e9d1e 100644
--- a/ext/keybinding_menu.js
+++ b/ext/keybinding_menu.js
@@ -22,7 +22,6 @@ color: black;\
}\
.ace_optionsMenuEntry:hover {\
background-color: rgba(100, 100, 100, 0.1);\
--webkit-transition: all 0.5s;\
transition: all 0.3s\
}\
.ace_closeButton {\
@@ -33,7 +32,7 @@ padding: 7px;\
position: absolute;\
right: -8px;\
top: -8px;\
-z-index: 1000;\
+z-index: 100000;\
}\
.ace_closeButton{\
background: rgba(245, 146, 146, 0.9);\
@@ -45,6 +44,22 @@ font-weight: bold;\
.ace_optionsMenuCommand {\
color: darkcyan;\
font-weight: normal;\
+}\
+.ace_optionsMenuEntry input, .ace_optionsMenuEntry button {\
+vertical-align: middle;\
+}\
+.ace_optionsMenuEntry button[ace_selected_button=true] {\
+background: #e7e7e7;\
+box-shadow: 1px 0px 2px 0px #adadad inset;\
+border-color: #adadad;\
+}\
+.ace_optionsMenuEntry button {\
+background: white;\
+border: 1px solid lightgray;\
+margin: 0px;\
+}\
+.ace_optionsMenuEntry button:hover{\
+background: #f0f0f0;\
}";
dom.importCssString(cssText);
module.exports.overlayPage = function overlayPage(editor, contentElement, top, right, bottom, left) {
@@ -163,8 +178,11 @@ ace.define("ace/ext/keybinding_menu",["require","exports","module","ace/editor",
}]);
};
-});
- (function() {
- ace.acequire(["ace/ext/keybinding_menu"], function() {});
+}); (function() {
+ ace.acequire(["ace/ext/keybinding_menu"], function(m) {
+ if (typeof module == "object" && typeof exports == "object" && module) {
+ module.exports = m;
+ }
+ });
})();
\ No newline at end of file
diff --git a/ext/language_tools.js b/ext/language_tools.js
index 1d6b1e87..ca893593 100644
--- a/ext/language_tools.js
+++ b/ext/language_tools.js
@@ -509,10 +509,10 @@ var SnippetManager = function() {
return;
s.startRe = guardedRegexp(s.trigger, s.guard, true);
- s.triggerRe = new RegExp(s.trigger, "", true);
+ s.triggerRe = new RegExp(s.trigger);
s.endRe = guardedRegexp(s.endTrigger, s.endGuard, true);
- s.endTriggerRe = new RegExp(s.endTrigger, "", true);
+ s.endTriggerRe = new RegExp(s.endTrigger);
}
if (snippets && snippets.content)
@@ -928,7 +928,7 @@ var $singleLineEditor = function(el) {
editor.renderer.setShowGutter(false);
editor.renderer.setHighlightGutterLine(false);
- editor.$mouseHandler.$focusWaitTimout = 0;
+ editor.$mouseHandler.$focusTimeout = 0;
editor.$highlightTagPending = true;
return editor;
@@ -1012,9 +1012,7 @@ var AcePopup = function(parentNode) {
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)
+ if (selected !== t.selectedNode && t.selectedNode)
dom.removeCssClass(t.selectedNode, "ace_selected");
t.selectedNode = selected;
if (selected)
@@ -1055,30 +1053,35 @@ var AcePopup = function(parentNode) {
return tokens;
if (typeof data == "string")
data = {value: data};
- if (!data.caption)
- data.caption = data.value || data.name;
-
- var last = -1;
- var flag, c;
- for (var i = 0; i < data.caption.length; i++) {
- c = data.caption[i];
- flag = data.matchMask & (1 << i) ? 1 : 0;
- if (last !== flag) {
- tokens.push({type: data.className || "" + ( flag ? "completion-highlight" : ""), value: c});
- last = flag;
- } else {
- tokens[tokens.length - 1].value += c;
- }
- }
+ var caption = data.caption || data.value || data.name;
- if (data.meta) {
- var maxW = popup.renderer.$size.scrollerWidth / popup.renderer.layerConfig.characterWidth;
- var metaData = data.meta;
- if (metaData.length + data.caption.length > maxW - 2) {
- metaData = metaData.substr(0, maxW - data.caption.length - 3) + "\u2026";
+ function addToken(value, className) {
+ value && tokens.push({
+ type: (data.className || "") + (className || ""),
+ value: value
+ });
+ }
+
+ var lower = caption.toLowerCase();
+ var filterText = (popup.filterText || "").toLowerCase();
+ var lastIndex = 0;
+ var lastI = 0;
+ for (var i = 0; i <= filterText.length; i++) {
+ if (i != lastI && (data.matchMask & (1 << i) || i == filterText.length)) {
+ var sub = filterText.slice(lastI, i);
+ lastI = i;
+ var index = lower.indexOf(sub, lastIndex);
+ if (index == -1) continue;
+ addToken(caption.slice(lastIndex, index), "");
+ lastIndex = index + sub.length;
+ addToken(caption.slice(index, lastIndex), "completion-highlight");
}
- tokens.push({type: "rightAlignedText", value: metaData});
}
+ addToken(caption.slice(lastIndex, caption.length), "");
+
+ if (data.meta)
+ tokens.push({type: "completion-meta", value: data.meta});
+
return tokens;
};
bgTokenizer.$updateOnChange = noop;
@@ -1087,14 +1090,14 @@ var AcePopup = function(parentNode) {
popup.session.$computeWidth = function() {
return this.screenWidth = 0;
};
-
- popup.$blockScrolling = Infinity;
popup.isOpen = false;
popup.isTopdown = false;
popup.autoSelect = true;
+ popup.filterText = "";
popup.data = [];
- popup.setData = function(list) {
+ popup.setData = function(list, filterText) {
+ popup.filterText = filterText || "";
popup.setValue(lang.stringRepeat("\n", list.length), -1);
popup.data = list || [];
popup.setRow(0);
@@ -1151,7 +1154,6 @@ var AcePopup = function(parentNode) {
}
el.style.display = "";
- this.renderer.$textLayer.checkForSizeChanges();
var left = pos.left;
if (left + el.offsetWidth > screenWidth)
@@ -1179,42 +1181,47 @@ dom.importCssString("\
background-color: #CAD6FA;\
z-index: 1;\
}\
+.ace_dark.ace_editor.ace_autocomplete .ace_marker-layer .ace_active-line {\
+ background-color: #3a674e;\
+}\
.ace_editor.ace_autocomplete .ace_line-hover {\
border: 1px solid #abbffe;\
margin-top: -1px;\
background: rgba(233,233,253,0.4);\
-}\
-.ace_editor.ace_autocomplete .ace_line-hover {\
position: absolute;\
z-index: 2;\
}\
-.ace_editor.ace_autocomplete .ace_scroller {\
- background: none;\
- border: none;\
- box-shadow: none;\
+.ace_dark.ace_editor.ace_autocomplete .ace_line-hover {\
+ border: 1px solid rgba(109, 150, 13, 0.8);\
+ background: rgba(58, 103, 78, 0.62);\
}\
-.ace_rightAlignedText {\
- color: gray;\
- display: inline-block;\
- position: absolute;\
- right: 4px;\
- text-align: right;\
- z-index: -1;\
+.ace_completion-meta {\
+ opacity: 0.5;\
+ margin: 0.9em;\
}\
.ace_editor.ace_autocomplete .ace_completion-highlight{\
- color: #000;\
- text-shadow: 0 0 0.01em;\
+ color: #2d69c7;\
+}\
+.ace_dark.ace_editor.ace_autocomplete .ace_completion-highlight{\
+ color: #93ca12;\
}\
.ace_editor.ace_autocomplete {\
- width: 280px;\
+ width: 300px;\
z-index: 200000;\
- background: #fbfbfb;\
- color: #444;\
border: 1px lightgray solid;\
position: fixed;\
box-shadow: 2px 3px 5px rgba(0,0,0,.2);\
line-height: 1.4;\
-}");
+ background: #fefefe;\
+ color: #111;\
+}\
+.ace_dark.ace_editor.ace_autocomplete {\
+ border: 1px #484747 solid;\
+ box-shadow: 2px 3px 5px rgba(0, 0, 0, 0.51);\
+ line-height: 1.4;\
+ background: #25282c;\
+ color: #c1c1c1;\
+}", "autocompletion.css");
exports.AcePopup = AcePopup;
@@ -1334,9 +1341,9 @@ var Autocomplete = function() {
if (!this.popup)
this.$init();
- this.popup.autoSelect = this.autoSelect;
+ this.popup.autoSelect = this.autoSelect;
- this.popup.setData(this.completions.filtered);
+ this.popup.setData(this.completions.filtered, this.completions.filterText);
editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
@@ -1618,14 +1625,28 @@ var Autocomplete = function() {
tooltipNode.style.top = popup.container.style.top;
tooltipNode.style.bottom = popup.container.style.bottom;
+ tooltipNode.style.display = "block";
if (window.innerWidth - rect.right < 320) {
- tooltipNode.style.right = window.innerWidth - rect.left + "px";
- tooltipNode.style.left = "";
+ if (rect.left < 320) {
+ if(popup.isTopdown) {
+ tooltipNode.style.top = rect.bottom + "px";
+ tooltipNode.style.left = rect.left + "px";
+ tooltipNode.style.right = "";
+ tooltipNode.style.bottom = "";
+ } else {
+ tooltipNode.style.top = popup.container.offsetTop - tooltipNode.offsetHeight + "px";
+ tooltipNode.style.left = rect.left + "px";
+ tooltipNode.style.right = "";
+ tooltipNode.style.bottom = "";
+ }
+ } else {
+ tooltipNode.style.right = window.innerWidth - rect.left + "px";
+ tooltipNode.style.left = "";
+ }
} else {
tooltipNode.style.left = (rect.right + 1) + "px";
tooltipNode.style.right = "";
}
- tooltipNode.style.display = "block";
};
this.hideDocTooltip = function() {
@@ -1638,7 +1659,7 @@ var Autocomplete = function() {
if (el.parentNode)
el.parentNode.removeChild(el);
};
-
+
this.onTooltipClick = function(e) {
var a = e.target;
while (a && a != this.tooltipNode) {
@@ -1682,7 +1703,8 @@ var FilteredList = function(array, filterText) {
this.filterText = str;
matches = this.filterCompletions(matches, this.filterText);
matches = matches.sort(function(a, b) {
- return b.exactMatch - a.exactMatch || b.score - a.score;
+ return b.exactMatch - a.exactMatch || b.$score - a.$score
+ || (a.caption || a.value) < (b.caption || b.value);
});
var prev = null;
matches = matches.filter(function(item){
@@ -1699,7 +1721,7 @@ var FilteredList = function(array, filterText) {
var upper = needle.toUpperCase();
var lower = needle.toLowerCase();
loop: for (var i = 0, item; item = items[i]; i++) {
- var caption = item.value || item.caption || item.snippet;
+ var caption = item.caption || item.value || item.snippet;
if (!caption) continue;
var lastIndex = -1;
var matchMask = 0;
@@ -1709,26 +1731,31 @@ var FilteredList = function(array, filterText) {
if (this.exactMatch) {
if (needle !== caption.substr(0, needle.length))
continue loop;
- }else{
- for (var j = 0; j < needle.length; j++) {
- var i1 = caption.indexOf(lower[j], lastIndex + 1);
- var i2 = caption.indexOf(upper[j], lastIndex + 1);
- index = (i1 >= 0) ? ((i2 < 0 || i1 < i2) ? i1 : i2) : i2;
- if (index < 0)
- continue loop;
- distance = index - lastIndex - 1;
- if (distance > 0) {
- if (lastIndex === -1)
- penalty += 10;
- penalty += distance;
+ } else {
+ var fullMatchIndex = caption.toLowerCase().indexOf(lower);
+ if (fullMatchIndex > -1) {
+ penalty = fullMatchIndex;
+ } else {
+ for (var j = 0; j < needle.length; j++) {
+ var i1 = caption.indexOf(lower[j], lastIndex + 1);
+ var i2 = caption.indexOf(upper[j], lastIndex + 1);
+ index = (i1 >= 0) ? ((i2 < 0 || i1 < i2) ? i1 : i2) : i2;
+ if (index < 0)
+ continue loop;
+ distance = index - lastIndex - 1;
+ if (distance > 0) {
+ if (lastIndex === -1)
+ penalty += 10;
+ penalty += distance;
+ matchMask = matchMask | (1 << j);
+ }
+ lastIndex = index;
}
- matchMask = matchMask | (1 << index);
- lastIndex = index;
}
}
item.matchMask = matchMask;
item.exactMatch = penalty ? 0 : 1;
- item.score = (item.score || 0) - penalty;
+ item.$score = (item.score || 0) - penalty;
results.push(item);
}
return results;
@@ -1771,7 +1798,7 @@ ace.define("ace/autocomplete/text_completer",["require","exports","module","ace/
}
exports.getCompletions = function(editor, session, pos, prefix, callback) {
- var wordScore = wordDistance(session, pos, prefix);
+ var wordScore = wordDistance(session, pos);
var wordList = Object.keys(wordScore);
callback(null, wordList.map(function(word) {
return {
@@ -1807,9 +1834,16 @@ var keyWordCompleter = {
var snippetCompleter = {
getCompletions: function(editor, session, pos, prefix, callback) {
+ var scopes = [];
+ var token = session.getTokenAt(pos.row, pos.column);
+ if (token && token.type.match(/(tag-name|tag-open|tag-whitespace|attribute-name|attribute-value)\.xml$/))
+ scopes.push('html-tag');
+ else
+ scopes = snippetManager.getActiveScopes(editor);
+
var snippetMap = snippetManager.snippetMap;
var completions = [];
- snippetManager.getActiveScopes(editor).forEach(function(scope) {
+ scopes.forEach(function(scope) {
var snippets = snippetMap[scope] || [];
for (var i = snippets.length; i--;) {
var s = snippets[i];
@@ -1949,8 +1983,11 @@ acequire("../config").defineOptions(Editor.prototype, "editor", {
value: false
}
});
-});
- (function() {
- ace.acequire(["ace/ext/language_tools"], function() {});
+}); (function() {
+ ace.acequire(["ace/ext/language_tools"], function(m) {
+ if (typeof module == "object" && typeof exports == "object" && module) {
+ module.exports = m;
+ }
+ });
})();
\ No newline at end of file
diff --git a/ext/linking.js b/ext/linking.js
index 2aad5007..20af5a69 100644
--- a/ext/linking.js
+++ b/ext/linking.js
@@ -54,8 +54,11 @@ function onClick(e) {
}
}
-});
- (function() {
- ace.acequire(["ace/ext/linking"], function() {});
+}); (function() {
+ ace.acequire(["ace/ext/linking"], function(m) {
+ if (typeof module == "object" && typeof exports == "object" && module) {
+ module.exports = m;
+ }
+ });
})();
\ No newline at end of file
diff --git a/ext/modelist.js b/ext/modelist.js
index 8f3f9e7a..de6b606f 100644
--- a/ext/modelist.js
+++ b/ext/modelist.js
@@ -41,8 +41,10 @@ var supportedModes = {
ADA: ["ada|adb"],
Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"],
AsciiDoc: ["asciidoc|adoc"],
+ ASL: ["dsl|asl"],
Assembly_x86:["asm|a"],
AutoHotKey: ["ahk"],
+ Apex: ["apex|cls|trigger|tgr"],
BatchFile: ["bat|cmd"],
Bro: ["bro"],
C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp|ino"],
@@ -64,8 +66,7 @@ var supportedModes = {
Dockerfile: ["^Dockerfile"],
Dot: ["dot"],
Drools: ["drl"],
- Dummy: ["dummy"],
- DummySyntax: ["dummy"],
+ Edifact: ["edi"],
Eiffel: ["e|ge"],
EJS: ["ejs"],
Elixir: ["ex|exs"],
@@ -73,6 +74,8 @@ var supportedModes = {
Erlang: ["erl|hrl"],
Forth: ["frt|fs|ldr|fth|4th"],
Fortran: ["f|f90"],
+ FSharp: ["fsi|fs|ml|mli|fsx|fsscript"],
+ FSL: ["fsl"],
FTL: ["ftl"],
Gcode: ["gcode"],
Gherkin: ["feature"],
@@ -120,6 +123,7 @@ var supportedModes = {
MATLAB: ["matlab"],
Maze: ["mz"],
MEL: ["mel"],
+ MIXAL: ["mixal"],
MUSHCode: ["mc|mush"],
MySQL: ["mysql"],
Nix: ["nix"],
@@ -128,8 +132,11 @@ var supportedModes = {
OCaml: ["ml|mli"],
Pascal: ["pas|p"],
Perl: ["pl|pm"],
+ Perl6: ["p6|pl6|pm6"],
pgSQL: ["pgsql"],
- PHP: ["php|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"],
+ PHP_Laravel_blade: ["blade.php"],
+ PHP: ["inc|php|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"],
+ Puppet: ["epp|pp"],
Pig: ["pig"],
Powershell: ["ps1"],
Praat: ["praat|praatscript|psc|proc"],
@@ -152,6 +159,7 @@ var supportedModes = {
SCSS: ["scss"],
SH: ["sh|bash|^.bashrc"],
SJS: ["sjs"],
+ Slim: ["slim|skim"],
Smarty: ["smarty|tpl"],
snippets: ["snippets"],
Soy_Template:["soy"],
@@ -162,18 +170,20 @@ var supportedModes = {
SVG: ["svg"],
Swift: ["swift"],
Tcl: ["tcl"],
+ Terraform: ["tf", "tfvars", "terragrunt"],
Tex: ["tex"],
Text: ["txt"],
Textile: ["textile"],
Toml: ["toml"],
TSX: ["tsx"],
- Twig: ["twig|swig"],
+ Twig: ["latte|twig|swig"],
Typescript: ["ts|typescript|str"],
Vala: ["vala"],
VBScript: ["vbs|vb"],
Velocity: ["vm"],
Verilog: ["v|vh|sv|svh"],
VHDL: ["vhd|vhdl"],
+ Visualforce: ["vfp|component|page"],
Wollok: ["wlk|wpgm|wtest"],
XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"],
XQuery: ["xq"],
@@ -192,7 +202,9 @@ var nameOverrides = {
coffee: "CoffeeScript",
HTML_Ruby: "HTML (Ruby)",
HTML_Elixir: "HTML (Elixir)",
- FTL: "FreeMarker"
+ FTL: "FreeMarker",
+ PHP_Laravel_blade: "PHP (Blade Template)",
+ Perl6: "Perl 6"
};
var modesByName = {};
for (var name in supportedModes) {
@@ -210,8 +222,11 @@ module.exports = {
modesByName: modesByName
};
-});
- (function() {
- ace.acequire(["ace/ext/modelist"], function() {});
+}); (function() {
+ ace.acequire(["ace/ext/modelist"], function(m) {
+ if (typeof module == "object" && typeof exports == "object" && module) {
+ module.exports = m;
+ }
+ });
})();
\ No newline at end of file
diff --git a/ext/old_ie.js b/ext/old_ie.js
deleted file mode 100644
index 8cb95662..00000000
--- a/ext/old_ie.js
+++ /dev/null
@@ -1,502 +0,0 @@
-ace.define("ace/ext/searchbox",["require","exports","module","ace/lib/dom","ace/lib/lang","ace/lib/event","ace/keyboard/hash_handler","ace/lib/keys"], function(acequire, exports, module) {
-"use strict";
-
-var dom = acequire("../lib/dom");
-var lang = acequire("../lib/lang");
-var event = acequire("../lib/event");
-var searchboxCss = "\
-.ace_search {\
-background-color: #ddd;\
-border: 1px solid #cbcbcb;\
-border-top: 0 none;\
-max-width: 325px;\
-overflow: hidden;\
-margin: 0;\
-padding: 4px;\
-padding-right: 6px;\
-padding-bottom: 0;\
-position: absolute;\
-top: 0px;\
-z-index: 99;\
-white-space: normal;\
-}\
-.ace_search.left {\
-border-left: 0 none;\
-border-radius: 0px 0px 5px 0px;\
-left: 0;\
-}\
-.ace_search.right {\
-border-radius: 0px 0px 0px 5px;\
-border-right: 0 none;\
-right: 0;\
-}\
-.ace_search_form, .ace_replace_form {\
-border-radius: 3px;\
-border: 1px solid #cbcbcb;\
-float: left;\
-margin-bottom: 4px;\
-overflow: hidden;\
-}\
-.ace_search_form.ace_nomatch {\
-outline: 1px solid red;\
-}\
-.ace_search_field {\
-background-color: white;\
-color: black;\
-border-right: 1px solid #cbcbcb;\
-border: 0 none;\
--webkit-box-sizing: border-box;\
--moz-box-sizing: border-box;\
-box-sizing: border-box;\
-float: left;\
-height: 22px;\
-outline: 0;\
-padding: 0 7px;\
-width: 214px;\
-margin: 0;\
-}\
-.ace_searchbtn,\
-.ace_replacebtn {\
-background: #fff;\
-border: 0 none;\
-border-left: 1px solid #dcdcdc;\
-cursor: pointer;\
-float: left;\
-height: 22px;\
-margin: 0;\
-position: relative;\
-}\
-.ace_searchbtn:last-child,\
-.ace_replacebtn:last-child {\
-border-top-right-radius: 3px;\
-border-bottom-right-radius: 3px;\
-}\
-.ace_searchbtn:disabled {\
-background: none;\
-cursor: default;\
-}\
-.ace_searchbtn {\
-background-position: 50% 50%;\
-background-repeat: no-repeat;\
-width: 27px;\
-}\
-.ace_searchbtn.prev {\
-background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAFCAYAAAB4ka1VAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADFJREFUeNpiSU1NZUAC/6E0I0yACYskCpsJiySKIiY0SUZk40FyTEgCjGgKwTRAgAEAQJUIPCE+qfkAAAAASUVORK5CYII=); \
-}\
-.ace_searchbtn.next {\
-background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAFCAYAAAB4ka1VAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADRJREFUeNpiTE1NZQCC/0DMyIAKwGJMUAYDEo3M/s+EpvM/mkKwCQxYjIeLMaELoLMBAgwAU7UJObTKsvAAAAAASUVORK5CYII=); \
-}\
-.ace_searchbtn_close {\
-background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAcCAYAAABRVo5BAAAAZ0lEQVR42u2SUQrAMAhDvazn8OjZBilCkYVVxiis8H4CT0VrAJb4WHT3C5xU2a2IQZXJjiQIRMdkEoJ5Q2yMqpfDIo+XY4k6h+YXOyKqTIj5REaxloNAd0xiKmAtsTHqW8sR2W5f7gCu5nWFUpVjZwAAAABJRU5ErkJggg==) no-repeat 50% 0;\
-border-radius: 50%;\
-border: 0 none;\
-color: #656565;\
-cursor: pointer;\
-float: right;\
-font: 16px/16px Arial;\
-height: 14px;\
-margin: 5px 1px 9px 5px;\
-padding: 0;\
-text-align: center;\
-width: 14px;\
-}\
-.ace_searchbtn_close:hover {\
-background-color: #656565;\
-background-position: 50% 100%;\
-color: white;\
-}\
-.ace_replacebtn.prev {\
-width: 54px\
-}\
-.ace_replacebtn.next {\
-width: 27px\
-}\
-.ace_button {\
-margin-left: 2px;\
-cursor: pointer;\
--webkit-user-select: none;\
--moz-user-select: none;\
--o-user-select: none;\
--ms-user-select: none;\
-user-select: none;\
-overflow: hidden;\
-opacity: 0.7;\
-border: 1px solid rgba(100,100,100,0.23);\
-padding: 1px;\
--moz-box-sizing: border-box;\
-box-sizing: border-box;\
-color: black;\
-}\
-.ace_button:hover {\
-background-color: #eee;\
-opacity:1;\
-}\
-.ace_button:active {\
-background-color: #ddd;\
-}\
-.ace_button.checked {\
-border-color: #3399ff;\
-opacity:1;\
-}\
-.ace_search_options{\
-margin-bottom: 3px;\
-text-align: right;\
--webkit-user-select: none;\
--moz-user-select: none;\
--o-user-select: none;\
--ms-user-select: none;\
-user-select: none;\
-}";
-var HashHandler = acequire("../keyboard/hash_handler").HashHandler;
-var keyUtil = acequire("../lib/keys");
-
-dom.importCssString(searchboxCss, "ace_searchbox");
-
-var html = '
\
-
+\
\
.*\
@@ -190,11 +190,12 @@ var SearchBox = function(editor, range, showReplaceForm) {
var div = dom.createElement("div");
div.innerHTML = html;
this.element = div.firstChild;
-
+
this.setSession = this.setSession.bind(this);
this.$init();
this.setEditor(editor);
+ dom.importCssString(searchboxCss, "ace_searchbox", editor.container);
};
(function() {
@@ -203,7 +204,7 @@ var SearchBox = function(editor, range, showReplaceForm) {
editor.renderer.scroller.appendChild(this.element);
this.editor = editor;
};
-
+
this.setSession = function(e) {
this.searchRange = null;
this.$syncOptions(true);
@@ -286,6 +287,8 @@ var SearchBox = function(editor, range, showReplaceForm) {
sb.searchInput.focus();
},
"Ctrl-H|Command-Option-F": function(sb) {
+ if (sb.editor.getReadOnly())
+ return;
sb.replaceOption.checked = true;
sb.$syncOptions();
sb.replaceInput.focus();
@@ -354,7 +357,7 @@ var SearchBox = function(editor, range, showReplaceForm) {
sb.$syncOptions();
}
}]);
-
+
this.setSearchRange = function(range) {
this.searchRange = range;
if (range) {
@@ -372,7 +375,9 @@ var SearchBox = function(editor, range, showReplaceForm) {
dom.setCssClass(this.regExpOption, "checked", this.regExpOption.checked);
dom.setCssClass(this.wholeWordOption, "checked", this.wholeWordOption.checked);
dom.setCssClass(this.caseSensitiveOption, "checked", this.caseSensitiveOption.checked);
- this.replaceBox.style.display = this.replaceOption.checked ? "" : "none";
+ var readOnly = this.editor.getReadOnly();
+ this.replaceOption.style.display = readOnly ? "none" : "";
+ this.replaceBox.style.display = this.replaceOption.checked && !readOnly ? "" : "none";
this.find(false, false, preventScroll);
};
@@ -406,11 +411,11 @@ var SearchBox = function(editor, range, showReplaceForm) {
var value = this.searchRange
? editor.session.getTextRange(this.searchRange)
: editor.getValue();
-
+
var offset = editor.session.doc.positionToIndex(editor.selection.anchor);
if (this.searchRange)
offset -= editor.session.doc.positionToIndex(this.searchRange.start);
-
+
var last = regex.lastIndex = 0;
var m;
while ((m = regex.exec(value))) {
@@ -466,7 +471,7 @@ var SearchBox = function(editor, range, showReplaceForm) {
this.active = false;
this.setSearchRange(null);
this.editor.off("changeSession", this.setSession);
-
+
this.element.style.display = "none";
this.editor.keyBinding.removeKeyboardHandler(this.$closeSearchBarKb);
this.editor.focus();
@@ -476,7 +481,7 @@ var SearchBox = function(editor, range, showReplaceForm) {
this.editor.on("changeSession", this.setSession);
this.element.style.display = "";
this.replaceOption.checked = isReplace;
-
+
if (value)
this.searchInput.value = value;
@@ -484,7 +489,7 @@ var SearchBox = function(editor, range, showReplaceForm) {
this.searchInput.select();
this.editor.keyBinding.addKeyboardHandler(this.$closeSearchBarKb);
-
+
this.$syncOptions(true);
};
@@ -501,8 +506,11 @@ exports.Search = function(editor, isReplace) {
sb.show(editor.session.getTextRange(), isReplace);
};
-});
- (function() {
- ace.acequire(["ace/ext/searchbox"], function() {});
+}); (function() {
+ ace.acequire(["ace/ext/searchbox"], function(m) {
+ if (typeof module == "object" && typeof exports == "object" && module) {
+ module.exports = m;
+ }
+ });
})();
\ No newline at end of file
diff --git a/ext/settings_menu.js b/ext/settings_menu.js
index 62cf815c..286cfb38 100644
--- a/ext/settings_menu.js
+++ b/ext/settings_menu.js
@@ -1,55 +1,115 @@
-ace.define("ace/ext/menu_tools/element_generator",["require","exports","module"], function(acequire, exports, module) {
+ace.define("ace/ext/menu_tools/overlay_page",["require","exports","module","ace/lib/dom"], function(acequire, exports, module) {
'use strict';
-module.exports.createOption = function createOption (obj) {
- var attribute;
- var el = document.createElement('option');
- for(attribute in obj) {
- if(obj.hasOwnProperty(attribute)) {
- if(attribute === 'selected') {
- el.setAttribute(attribute, obj[attribute]);
- } else {
- el[attribute] = obj[attribute];
- }
+var dom = acequire("../../lib/dom");
+var cssText = "#ace_settingsmenu, #kbshortcutmenu {\
+background-color: #F7F7F7;\
+color: black;\
+box-shadow: -5px 4px 5px rgba(126, 126, 126, 0.55);\
+padding: 1em 0.5em 2em 1em;\
+overflow: auto;\
+position: absolute;\
+margin: 0;\
+bottom: 0;\
+right: 0;\
+top: 0;\
+z-index: 9991;\
+cursor: default;\
+}\
+.ace_dark #ace_settingsmenu, .ace_dark #kbshortcutmenu {\
+box-shadow: -20px 10px 25px rgba(126, 126, 126, 0.25);\
+background-color: rgba(255, 255, 255, 0.6);\
+color: black;\
+}\
+.ace_optionsMenuEntry:hover {\
+background-color: rgba(100, 100, 100, 0.1);\
+transition: all 0.3s\
+}\
+.ace_closeButton {\
+background: rgba(245, 146, 146, 0.5);\
+border: 1px solid #F48A8A;\
+border-radius: 50%;\
+padding: 7px;\
+position: absolute;\
+right: -8px;\
+top: -8px;\
+z-index: 100000;\
+}\
+.ace_closeButton{\
+background: rgba(245, 146, 146, 0.9);\
+}\
+.ace_optionsMenuKey {\
+color: darkslateblue;\
+font-weight: bold;\
+}\
+.ace_optionsMenuCommand {\
+color: darkcyan;\
+font-weight: normal;\
+}\
+.ace_optionsMenuEntry input, .ace_optionsMenuEntry button {\
+vertical-align: middle;\
+}\
+.ace_optionsMenuEntry button[ace_selected_button=true] {\
+background: #e7e7e7;\
+box-shadow: 1px 0px 2px 0px #adadad inset;\
+border-color: #adadad;\
+}\
+.ace_optionsMenuEntry button {\
+background: white;\
+border: 1px solid lightgray;\
+margin: 0px;\
+}\
+.ace_optionsMenuEntry button:hover{\
+background: #f0f0f0;\
+}";
+dom.importCssString(cssText);
+module.exports.overlayPage = function overlayPage(editor, contentElement, top, right, bottom, left) {
+ top = top ? 'top: ' + top + ';' : '';
+ bottom = bottom ? 'bottom: ' + bottom + ';' : '';
+ right = right ? 'right: ' + right + ';' : '';
+ left = left ? 'left: ' + left + ';' : '';
+
+ var closer = document.createElement('div');
+ var contentContainer = document.createElement('div');
+
+ function documentEscListener(e) {
+ if (e.keyCode === 27) {
+ closer.click();
}
}
- return el;
-};
-module.exports.createCheckbox = function createCheckbox (id, checked, clss) {
- var el = document.createElement('input');
- el.setAttribute('type', 'checkbox');
- el.setAttribute('id', id);
- el.setAttribute('name', id);
- el.setAttribute('value', checked);
- el.setAttribute('class', clss);
- if(checked) {
- el.setAttribute('checked', 'checked');
- }
- return el;
-};
-module.exports.createInput = function createInput (id, value, clss) {
- var el = document.createElement('input');
- el.setAttribute('type', 'text');
- el.setAttribute('id', id);
- el.setAttribute('name', id);
- el.setAttribute('value', value);
- el.setAttribute('class', clss);
- return el;
-};
-module.exports.createLabel = function createLabel (text, labelFor) {
- var el = document.createElement('label');
- el.setAttribute('for', labelFor);
- el.textContent = text;
- return el;
-};
-module.exports.createSelection = function createSelection (id, values, clss) {
- var el = document.createElement('select');
- el.setAttribute('id', id);
- el.setAttribute('name', id);
- el.setAttribute('class', clss);
- values.forEach(function(item) {
- el.appendChild(module.exports.createOption(item));
+
+ closer.style.cssText = 'margin: 0; padding: 0; ' +
+ 'position: fixed; top:0; bottom:0; left:0; right:0;' +
+ 'z-index: 9990; ' +
+ 'background-color: rgba(0, 0, 0, 0.3);';
+ closer.addEventListener('click', function() {
+ document.removeEventListener('keydown', documentEscListener);
+ closer.parentNode.removeChild(closer);
+ editor.focus();
+ closer = null;
+ });
+ document.addEventListener('keydown', documentEscListener);
+
+ contentContainer.style.cssText = top + right + bottom + left;
+ contentContainer.addEventListener('click', function(e) {
+ e.stopPropagation();
});
- return el;
+
+ var wrapper = dom.createElement("div");
+ wrapper.style.position = "relative";
+
+ var closeButton = dom.createElement("div");
+ closeButton.className = "ace_closeButton";
+ closeButton.addEventListener('click', function() {
+ closer.click();
+ });
+
+ wrapper.appendChild(closeButton);
+ contentContainer.appendChild(wrapper);
+
+ contentContainer.appendChild(contentElement);
+ closer.appendChild(contentContainer);
+ document.body.appendChild(closer);
+ editor.blur();
};
});
@@ -97,8 +157,10 @@ var supportedModes = {
ADA: ["ada|adb"],
Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"],
AsciiDoc: ["asciidoc|adoc"],
+ ASL: ["dsl|asl"],
Assembly_x86:["asm|a"],
AutoHotKey: ["ahk"],
+ Apex: ["apex|cls|trigger|tgr"],
BatchFile: ["bat|cmd"],
Bro: ["bro"],
C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp|ino"],
@@ -120,8 +182,7 @@ var supportedModes = {
Dockerfile: ["^Dockerfile"],
Dot: ["dot"],
Drools: ["drl"],
- Dummy: ["dummy"],
- DummySyntax: ["dummy"],
+ Edifact: ["edi"],
Eiffel: ["e|ge"],
EJS: ["ejs"],
Elixir: ["ex|exs"],
@@ -129,6 +190,8 @@ var supportedModes = {
Erlang: ["erl|hrl"],
Forth: ["frt|fs|ldr|fth|4th"],
Fortran: ["f|f90"],
+ FSharp: ["fsi|fs|ml|mli|fsx|fsscript"],
+ FSL: ["fsl"],
FTL: ["ftl"],
Gcode: ["gcode"],
Gherkin: ["feature"],
@@ -176,6 +239,7 @@ var supportedModes = {
MATLAB: ["matlab"],
Maze: ["mz"],
MEL: ["mel"],
+ MIXAL: ["mixal"],
MUSHCode: ["mc|mush"],
MySQL: ["mysql"],
Nix: ["nix"],
@@ -184,8 +248,11 @@ var supportedModes = {
OCaml: ["ml|mli"],
Pascal: ["pas|p"],
Perl: ["pl|pm"],
+ Perl6: ["p6|pl6|pm6"],
pgSQL: ["pgsql"],
- PHP: ["php|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"],
+ PHP_Laravel_blade: ["blade.php"],
+ PHP: ["inc|php|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"],
+ Puppet: ["epp|pp"],
Pig: ["pig"],
Powershell: ["ps1"],
Praat: ["praat|praatscript|psc|proc"],
@@ -208,6 +275,7 @@ var supportedModes = {
SCSS: ["scss"],
SH: ["sh|bash|^.bashrc"],
SJS: ["sjs"],
+ Slim: ["slim|skim"],
Smarty: ["smarty|tpl"],
snippets: ["snippets"],
Soy_Template:["soy"],
@@ -218,18 +286,20 @@ var supportedModes = {
SVG: ["svg"],
Swift: ["swift"],
Tcl: ["tcl"],
+ Terraform: ["tf", "tfvars", "terragrunt"],
Tex: ["tex"],
Text: ["txt"],
Textile: ["textile"],
Toml: ["toml"],
TSX: ["tsx"],
- Twig: ["twig|swig"],
+ Twig: ["latte|twig|swig"],
Typescript: ["ts|typescript|str"],
Vala: ["vala"],
VBScript: ["vbs|vb"],
Velocity: ["vm"],
Verilog: ["v|vh|sv|svh"],
VHDL: ["vhd|vhdl"],
+ Visualforce: ["vfp|component|page"],
Wollok: ["wlk|wpgm|wtest"],
XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"],
XQuery: ["xq"],
@@ -248,7 +318,9 @@ var nameOverrides = {
coffee: "CoffeeScript",
HTML_Ruby: "HTML (Ruby)",
HTML_Elixir: "HTML (Elixir)",
- FTL: "FreeMarker"
+ FTL: "FreeMarker",
+ PHP_Laravel_blade: "PHP (Blade Template)",
+ Perl6: "Perl 6"
};
var modesByName = {};
for (var name in supportedModes) {
@@ -268,9 +340,8 @@ module.exports = {
});
-ace.define("ace/ext/themelist",["require","exports","module","ace/lib/fixoldbrowsers"], function(acequire, exports, module) {
+ace.define("ace/ext/themelist",["require","exports","module"], function(acequire, exports, module) {
"use strict";
-acequire("ace/lib/fixoldbrowsers");
var themeData = [
["Chrome" ],
@@ -291,6 +362,7 @@ var themeData = [
["Ambiance" ,"ambiance" , "dark"],
["Chaos" ,"chaos" , "dark"],
["Clouds Midnight" ,"clouds_midnight" , "dark"],
+ ["Dracula" ,"" , "dark"],
["Cobalt" ,"cobalt" , "dark"],
["Gruvbox" ,"gruvbox" , "dark"],
["Green on Black" ,"gob" , "dark"],
@@ -327,336 +399,364 @@ exports.themes = themeData.map(function(data) {
});
-ace.define("ace/ext/menu_tools/add_editor_menu_options",["require","exports","module","ace/ext/modelist","ace/ext/themelist"], function(acequire, exports, module) {
-'use strict';
-module.exports.addEditorMenuOptions = function addEditorMenuOptions (editor) {
- var modelist = acequire('../modelist');
- var themelist = acequire('../themelist');
- editor.menuOptions = {
- setNewLineMode: [{
- textContent: "unix",
- value: "unix"
- }, {
- textContent: "windows",
- value: "windows"
- }, {
- textContent: "auto",
- value: "auto"
- }],
- setTheme: [],
- setMode: [],
- setKeyboardHandler: [{
- textContent: "ace",
- value: ""
- }, {
- textContent: "vim",
- value: "ace/keyboard/vim"
- }, {
- textContent: "emacs",
- value: "ace/keyboard/emacs"
- }, {
- textContent: "textarea",
- value: "ace/keyboard/textarea"
- }, {
- textContent: "sublime",
- value: "ace/keyboard/sublime"
- }]
- };
+ace.define("ace/ext/options",["require","exports","module","ace/ext/menu_tools/overlay_page","ace/lib/dom","ace/lib/oop","ace/lib/event_emitter","ace/ext/modelist","ace/ext/themelist"], function(acequire, exports, module) {
+"use strict";
+var overlayPage = acequire('./menu_tools/overlay_page').overlayPage;
- editor.menuOptions.setTheme = themelist.themes.map(function(theme) {
- return {
- textContent: theme.caption,
- value: theme.theme
- };
- });
+
+var dom = acequire("../lib/dom");
+var oop = acequire("../lib/oop");
+var EventEmitter = acequire("../lib/event_emitter").EventEmitter;
+var buildDom = dom.buildDom;
- editor.menuOptions.setMode = modelist.modes.map(function(mode) {
- return {
- textContent: mode.name,
- value: mode.mode
- };
- });
-};
+var modelist = acequire("./modelist");
+var themelist = acequire("./themelist");
+var themes = { Bright: [], Dark: [] };
+themelist.themes.forEach(function(x) {
+ themes[x.isDark ? "Dark" : "Bright"].push({ caption: x.caption, value: x.theme });
+});
+var modes = modelist.modes.map(function(x){
+ return { caption: x.caption, value: x.mode };
});
-ace.define("ace/ext/menu_tools/get_set_functions",["require","exports","module"], function(acequire, exports, module) {
-'use strict';
-module.exports.getSetFunctions = function getSetFunctions (editor) {
- var out = [];
- var my = {
- 'editor' : editor,
- 'session' : editor.session,
- 'renderer' : editor.renderer
- };
- var opts = [];
- var skip = [
- 'setOption',
- 'setUndoManager',
- 'setDocument',
- 'setValue',
- 'setBreakpoints',
- 'setScrollTop',
- 'setScrollLeft',
- 'setSelectionStyle',
- 'setWrapLimitRange'
- ];
- ['renderer', 'session', 'editor'].forEach(function(esra) {
- var esr = my[esra];
- var clss = esra;
- for(var fn in esr) {
- if(skip.indexOf(fn) === -1) {
- if(/^set/.test(fn) && opts.indexOf(fn) === -1) {
- opts.push(fn);
- out.push({
- 'functionName' : fn,
- 'parentObj' : esr,
- 'parentName' : clss
- });
- }
- }
+
+var optionGroups = {
+ Main: {
+ Mode: {
+ path: "mode",
+ type: "select",
+ items: modes
+ },
+ Theme: {
+ path: "theme",
+ type: "select",
+ items: themes
+ },
+ "Keybinding": {
+ type: "buttonBar",
+ path: "keyboardHandler",
+ items: [
+ { caption : "Ace", value : null },
+ { caption : "Vim", value : "ace/keyboard/vim" },
+ { caption : "Emacs", value : "ace/keyboard/emacs" }
+ ]
+ },
+ "Font Size": {
+ path: "fontSize",
+ type: "number",
+ defaultValue: 12,
+ defaults: [
+ {caption: "12px", value: 12},
+ {caption: "24px", value: 24}
+ ]
+ },
+ "Soft Wrap": {
+ type: "buttonBar",
+ path: "wrap",
+ items: [
+ { caption : "Off", value : "off" },
+ { caption : "View", value : "free" },
+ { caption : "margin", value : "printMargin" },
+ { caption : "40", value : "40" }
+ ]
+ },
+ "Cursor Style": {
+ path: "cursorStyle",
+ items: [
+ { caption : "Ace", value : "ace" },
+ { caption : "Slim", value : "slim" },
+ { caption : "Smooth", value : "smooth" },
+ { caption : "Smooth And Slim", value : "smooth slim" },
+ { caption : "Wide", value : "wide" }
+ ]
+ },
+ "Folding": {
+ path: "foldStyle",
+ items: [
+ { caption : "Manual", value : "manual" },
+ { caption : "Mark begin", value : "markbegin" },
+ { caption : "Mark begin and end", value : "markbeginend" }
+ ]
+ },
+ "Soft Tabs": [{
+ path: "useSoftTabs"
+ }, {
+ path: "tabSize",
+ type: "number",
+ values: [2, 3, 4, 8, 16]
+ }],
+ "Overscroll": {
+ type: "buttonBar",
+ path: "scrollPastEnd",
+ items: [
+ { caption : "None", value : 0 },
+ { caption : "Half", value : 0.5 },
+ { caption : "Full", value : 1 }
+ ]
}
- });
- return out;
+ },
+ More: {
+ "Atomic soft tabs": {
+ path: "navigateWithinSoftTabs"
+ },
+ "Enable Behaviours": {
+ path: "behavioursEnabled"
+ },
+ "Full Line Selection": {
+ type: "checkbox",
+ values: "text|line",
+ path: "selectionStyle"
+ },
+ "Highlight Active Line": {
+ path: "highlightActiveLine"
+ },
+ "Show Invisibles": {
+ path: "showInvisibles"
+ },
+ "Show Indent Guides": {
+ path: "displayIndentGuides"
+ },
+ "Persistent Scrollbar": [{
+ path: "hScrollBarAlwaysVisible"
+ }, {
+ path: "vScrollBarAlwaysVisible"
+ }],
+ "Animate scrolling": {
+ path: "animatedScroll"
+ },
+ "Show Gutter": {
+ path: "showGutter"
+ },
+ "Show Line Numbers": {
+ path: "showLineNumbers"
+ },
+ "Relative Line Numbers": {
+ path: "relativeLineNumbers"
+ },
+ "Fixed Gutter Width": {
+ path: "fixedWidthGutter"
+ },
+ "Show Print Margin": [{
+ path: "showPrintMargin"
+ }, {
+ type: "number",
+ path: "printMarginColumn"
+ }],
+ "Indented Soft Wrap": {
+ path: "indentedSoftWrap"
+ },
+ "Highlight selected word": {
+ path: "highlightSelectedWord"
+ },
+ "Fade Fold Widgets": {
+ path: "fadeFoldWidgets"
+ },
+ "Use textarea for IME": {
+ path: "useTextareaForIME"
+ },
+ "Merge Undo Deltas": {
+ path: "mergeUndoDeltas",
+ items: [
+ { caption : "Always", value : "always" },
+ { caption : "Never", value : "false" },
+ { caption : "Timed", value : "true" }
+ ]
+ },
+ "Elastic Tabstops": {
+ path: "useElasticTabstops"
+ },
+ "Incremental Search": {
+ path: "useIncrementalSearch"
+ },
+ "Read-only": {
+ path: "readOnly"
+ },
+ "Copy without selection": {
+ path: "copyWithEmptySelection"
+ },
+ "Live Autocompletion": {
+ path: "enableLiveAutocompletion"
+ }
+ }
};
-});
-ace.define("ace/ext/menu_tools/generate_settings_menu",["require","exports","module","ace/ext/menu_tools/element_generator","ace/ext/menu_tools/add_editor_menu_options","ace/ext/menu_tools/get_set_functions","ace/ace"], function(acequire, exports, module) {
-'use strict';
-var egen = acequire('./element_generator');
-var addEditorMenuOptions = acequire('./add_editor_menu_options').addEditorMenuOptions;
-var getSetFunctions = acequire('./get_set_functions').getSetFunctions;
-module.exports.generateSettingsMenu = function generateSettingsMenu (editor) {
- var elements = [];
- function cleanupElementsList() {
- elements.sort(function(a, b) {
- var x = a.getAttribute('contains');
- var y = b.getAttribute('contains');
- return x.localeCompare(y);
- });
- }
- function wrapElements() {
- var topmenu = document.createElement('div');
- topmenu.setAttribute('id', 'ace_settingsmenu');
- elements.forEach(function(element) {
- topmenu.appendChild(element);
- });
+var OptionPanel = function(editor, element) {
+ this.editor = editor;
+ this.container = element || document.createElement("div");
+ this.groups = [];
+ this.options = {};
+};
+
+(function() {
+
+ oop.implement(this, EventEmitter);
+
+ this.add = function(config) {
+ if (config.Main)
+ oop.mixin(optionGroups.Main, config.Main);
+ if (config.More)
+ oop.mixin(optionGroups.More, config.More);
+ };
+
+ this.render = function() {
+ this.container.innerHTML = "";
+ buildDom(["table", {id: "controls"},
+ this.renderOptionGroup(optionGroups.Main),
+ ["tr", null, ["td", {colspan: 2},
+ ["table", {id: "more-controls"},
+ this.renderOptionGroup(optionGroups.More)
+ ]
+ ]]
+ ], this.container);
+ };
+
+ this.renderOptionGroup = function(group) {
+ return Object.keys(group).map(function(key, i) {
+ var item = group[key];
+ if (!item.position)
+ item.position = i / 10000;
+ if (!item.label)
+ item.label = key;
+ return item;
+ }).sort(function(a, b) {
+ return a.position - b.position;
+ }).map(function(item) {
+ return this.renderOption(item.label, item);
+ }, this);
+ };
+
+ this.renderOptionControl = function(key, option) {
+ var self = this;
+ if (Array.isArray(option)) {
+ return option.map(function(x) {
+ return self.renderOptionControl(key, x);
+ });
+ }
+ var control;
- var el = topmenu.appendChild(document.createElement('div'));
- var version = acequire("../../ace").version;
- el.style.padding = "1em";
- el.textContent = "Ace version " + version;
+ var value = self.getOption(option);
- return topmenu;
- }
- function createNewEntry(obj, clss, item, val) {
- var el;
- var div = document.createElement('div');
- div.setAttribute('contains', item);
- div.setAttribute('class', 'ace_optionsMenuEntry');
- div.setAttribute('style', 'clear: both;');
-
- div.appendChild(egen.createLabel(
- item.replace(/^set/, '').replace(/([A-Z])/g, ' $1').trim(),
- item
- ));
-
- if (Array.isArray(val)) {
- el = egen.createSelection(item, val, clss);
- el.addEventListener('change', function(e) {
- try{
- editor.menuOptions[e.target.id].forEach(function(x) {
- if(x.textContent !== e.target.textContent) {
- delete x.selected;
- }
- });
- obj[e.target.id](e.target.value);
- } catch (err) {
- throw new Error(err);
- }
- });
- } else if(typeof val === 'boolean') {
- el = egen.createCheckbox(item, val, clss);
- el.addEventListener('change', function(e) {
- try{
- obj[e.target.id](!!e.target.checked);
- } catch (err) {
- throw new Error(err);
- }
- });
- } else {
- el = egen.createInput(item, val, clss);
- el.addEventListener('change', function(e) {
- try{
- if(e.target.value === 'true') {
- obj[e.target.id](true);
- } else if(e.target.value === 'false') {
- obj[e.target.id](false);
- } else {
- obj[e.target.id](e.target.value);
- }
- } catch (err) {
- throw new Error(err);
- }
+ if (option.values && option.type != "checkbox") {
+ if (typeof option.values == "string")
+ option.values = option.values.split("|");
+ option.items = option.values.map(function(v) {
+ return { value: v, name: v };
});
}
- el.style.cssText = 'float:right;';
- div.appendChild(el);
- return div;
- }
- function makeDropdown(item, esr, clss, fn) {
- var val = editor.menuOptions[item];
- var currentVal = esr[fn]();
- if (typeof currentVal == 'object')
- currentVal = currentVal.$id;
- val.forEach(function(valuex) {
- if (valuex.value === currentVal)
- valuex.selected = 'selected';
- });
- return createNewEntry(esr, clss, item, val);
- }
- function handleSet(setObj) {
- var item = setObj.functionName;
- var esr = setObj.parentObj;
- var clss = setObj.parentName;
- var val;
- var fn = item.replace(/^set/, 'get');
- if(editor.menuOptions[item] !== undefined) {
- elements.push(makeDropdown(item, esr, clss, fn));
- } else if(typeof esr[fn] === 'function') {
- try {
- val = esr[fn]();
- if(typeof val === 'object') {
- val = val.$id;
- }
- elements.push(
- createNewEntry(esr, clss, item, val)
- );
- } catch (e) {
+
+ if (option.type == "buttonBar") {
+ control = ["div", option.items.map(function(item) {
+ return ["button", {
+ value: item.value,
+ ace_selected_button: value == item.value,
+ onclick: function() {
+ self.setOption(option, item.value);
+ var nodes = this.parentNode.querySelectorAll("[ace_selected_button]");
+ for (var i = 0; i < nodes.length; i++) {
+ nodes[i].removeAttribute("ace_selected_button");
+ }
+ this.setAttribute("ace_selected_button", true);
+ }
+ }, item.desc || item.caption || item.name];
+ })];
+ } else if (option.type == "number") {
+ control = ["input", {type: "number", value: value || option.defaultValue, style:"width:3em", oninput: function() {
+ self.setOption(option, parseInt(this.value));
+ }}];
+ if (option.defaults) {
+ control = [control, option.defaults.map(function(item) {
+ return ["button", {onclick: function() {
+ var input = this.parentNode.firstChild;
+ input.value = item.value;
+ input.oninput();
+ }}, item.caption];
+ })];
+ }
+ } else if (option.items) {
+ var buildItems = function(items) {
+ return items.map(function(item) {
+ return ["option", { value: item.value || item.name }, item.desc || item.caption || item.name];
+ });
+ };
+
+ var items = Array.isArray(option.items)
+ ? buildItems(option.items)
+ : Object.keys(option.items).map(function(key) {
+ return ["optgroup", {"label": key}, buildItems(option.items[key])];
+ });
+ control = ["select", { id: key, value: value, onchange: function() {
+ self.setOption(option, this.value);
+ } }, items];
+ } else {
+ if (typeof option.values == "string")
+ option.values = option.values.split("|");
+ if (option.values) value = value == option.values[1];
+ control = ["input", { type: "checkbox", id: key, checked: value || null, onchange: function() {
+ var value = this.checked;
+ if (option.values) value = option.values[value ? 1 : 0];
+ self.setOption(option, value);
+ }}];
+ if (option.type == "checkedNumber") {
+ control = [control, []];
}
}
- }
- addEditorMenuOptions(editor);
- getSetFunctions(editor).forEach(function(setObj) {
- handleSet(setObj);
- });
- cleanupElementsList();
- return wrapElements();
-};
-
-});
-
-ace.define("ace/ext/menu_tools/overlay_page",["require","exports","module","ace/lib/dom"], function(acequire, exports, module) {
-'use strict';
-var dom = acequire("../../lib/dom");
-var cssText = "#ace_settingsmenu, #kbshortcutmenu {\
-background-color: #F7F7F7;\
-color: black;\
-box-shadow: -5px 4px 5px rgba(126, 126, 126, 0.55);\
-padding: 1em 0.5em 2em 1em;\
-overflow: auto;\
-position: absolute;\
-margin: 0;\
-bottom: 0;\
-right: 0;\
-top: 0;\
-z-index: 9991;\
-cursor: default;\
-}\
-.ace_dark #ace_settingsmenu, .ace_dark #kbshortcutmenu {\
-box-shadow: -20px 10px 25px rgba(126, 126, 126, 0.25);\
-background-color: rgba(255, 255, 255, 0.6);\
-color: black;\
-}\
-.ace_optionsMenuEntry:hover {\
-background-color: rgba(100, 100, 100, 0.1);\
--webkit-transition: all 0.5s;\
-transition: all 0.3s\
-}\
-.ace_closeButton {\
-background: rgba(245, 146, 146, 0.5);\
-border: 1px solid #F48A8A;\
-border-radius: 50%;\
-padding: 7px;\
-position: absolute;\
-right: -8px;\
-top: -8px;\
-z-index: 1000;\
-}\
-.ace_closeButton{\
-background: rgba(245, 146, 146, 0.9);\
-}\
-.ace_optionsMenuKey {\
-color: darkslateblue;\
-font-weight: bold;\
-}\
-.ace_optionsMenuCommand {\
-color: darkcyan;\
-font-weight: normal;\
-}";
-dom.importCssString(cssText);
-module.exports.overlayPage = function overlayPage(editor, contentElement, top, right, bottom, left) {
- top = top ? 'top: ' + top + ';' : '';
- bottom = bottom ? 'bottom: ' + bottom + ';' : '';
- right = right ? 'right: ' + right + ';' : '';
- left = left ? 'left: ' + left + ';' : '';
-
- var closer = document.createElement('div');
- var contentContainer = document.createElement('div');
-
- function documentEscListener(e) {
- if (e.keyCode === 27) {
- closer.click();
- }
- }
-
- closer.style.cssText = 'margin: 0; padding: 0; ' +
- 'position: fixed; top:0; bottom:0; left:0; right:0;' +
- 'z-index: 9990; ' +
- 'background-color: rgba(0, 0, 0, 0.3);';
- closer.addEventListener('click', function() {
- document.removeEventListener('keydown', documentEscListener);
- closer.parentNode.removeChild(closer);
- editor.focus();
- closer = null;
- });
- document.addEventListener('keydown', documentEscListener);
-
- contentContainer.style.cssText = top + right + bottom + left;
- contentContainer.addEventListener('click', function(e) {
- e.stopPropagation();
- });
-
- var wrapper = dom.createElement("div");
- wrapper.style.position = "relative";
+ return control;
+ };
- var closeButton = dom.createElement("div");
- closeButton.className = "ace_closeButton";
- closeButton.addEventListener('click', function() {
- closer.click();
- });
+ this.renderOption = function(key, option) {
+ if (option.path && !option.onchange && !this.editor.$options[option.path])
+ return;
+ this.options[option.path] = option;
+ var safeKey = "-" + option.path;
+ var control = this.renderOptionControl(safeKey, option);
+ return ["tr", {class: "ace_optionsMenuEntry"}, ["td",
+ ["label", {for: safeKey}, key]
+ ], ["td", control]];
+ };
- wrapper.appendChild(closeButton);
- contentContainer.appendChild(wrapper);
+ this.setOption = function(option, value) {
+ if (typeof option == "string")
+ option = this.options[option];
+ if (value == "false") value = false;
+ if (value == "true") value = true;
+ if (value == "null") value = null;
+ if (value == "undefined") value = undefined;
+ if (typeof value == "string" && parseFloat(value).toString() == value)
+ value = parseFloat(value);
+ if (option.onchange)
+ option.onchange(value);
+ else if (option.path)
+ this.editor.setOption(option.path, value);
+ this._signal("setOption", {name: option.path, value: value});
+ };
- contentContainer.appendChild(contentElement);
- closer.appendChild(contentContainer);
- document.body.appendChild(closer);
- editor.blur();
-};
+ this.getOption = function(option) {
+ if (option.getValue)
+ return option.getValue();
+ return this.editor.getOption(option.path);
+ };
+
+}).call(OptionPanel.prototype);
+
+exports.OptionPanel = OptionPanel;
});
-ace.define("ace/ext/settings_menu",["require","exports","module","ace/ext/menu_tools/generate_settings_menu","ace/ext/menu_tools/overlay_page","ace/editor"], function(acequire, exports, module) {
+ace.define("ace/ext/settings_menu",["require","exports","module","ace/ext/options","ace/ext/menu_tools/overlay_page","ace/editor"], function(acequire, exports, module) {
"use strict";
-var generateSettingsMenu = acequire('./menu_tools/generate_settings_menu').generateSettingsMenu;
+var OptionPanel = acequire("ace/ext/options").OptionPanel;
var overlayPage = acequire('./menu_tools/overlay_page').overlayPage;
function showSettingsMenu(editor) {
- var sm = document.getElementById('ace_settingsmenu');
- if (!sm)
- overlayPage(editor, generateSettingsMenu(editor), '0', '0', '0');
+ if (!document.getElementById('ace_settingsmenu')) {
+ var options = new OptionPanel(editor);
+ options.render();
+ options.container.id = "ace_settingsmenu";
+ overlayPage(editor, options.container, '0', '0', '0');
+ options.container.querySelector("select,input,button,checkbox").focus();
+ }
}
module.exports.init = function(editor) {
var Editor = acequire("ace/editor").Editor;
@@ -664,8 +764,11 @@ module.exports.init = function(editor) {
showSettingsMenu(this);
};
};
-});
- (function() {
- ace.acequire(["ace/ext/settings_menu"], function() {});
+}); (function() {
+ ace.acequire(["ace/ext/settings_menu"], function(m) {
+ if (typeof module == "object" && typeof exports == "object" && module) {
+ module.exports = m;
+ }
+ });
})();
\ No newline at end of file
diff --git a/ext/spellcheck.js b/ext/spellcheck.js
index 5cf6183e..653efb3a 100644
--- a/ext/spellcheck.js
+++ b/ext/spellcheck.js
@@ -64,8 +64,11 @@ acequire("../config").defineOptions(Editor.prototype, "editor", {
}
});
-});
- (function() {
- ace.acequire(["ace/ext/spellcheck"], function() {});
+}); (function() {
+ ace.acequire(["ace/ext/spellcheck"], function(m) {
+ if (typeof module == "object" && typeof exports == "object" && module) {
+ module.exports = m;
+ }
+ });
})();
\ No newline at end of file
diff --git a/ext/split.js b/ext/split.js
index aafd0d39..49a380ec 100644
--- a/ext/split.js
+++ b/ext/split.js
@@ -120,11 +120,7 @@ var Split = function(container, theme, splits) {
var s = new EditSession(session.getDocument(), session.getMode());
var undoManager = session.getUndoManager();
- if (undoManager) {
- var undoManagerProxy = new UndoManagerProxy(undoManager, s);
- s.setUndoManager(undoManagerProxy);
- }
- s.$informUndoManager = lang.delayedCall(function() { s.$deltas = []; });
+ s.setUndoManager(undoManager);
s.setTabSize(session.getTabSize());
s.setUseSoftTabs(session.getUseSoftTabs());
s.setOverwrite(session.getOverwrite());
@@ -194,44 +190,6 @@ var Split = function(container, theme, splits) {
}).call(Split.prototype);
-
-function UndoManagerProxy(undoManager, session) {
- this.$u = undoManager;
- this.$doc = session;
-}
-
-(function() {
- this.execute = function(options) {
- this.$u.execute(options);
- };
-
- this.undo = function() {
- var selectionRange = this.$u.undo(true);
- if (selectionRange) {
- this.$doc.selection.setSelectionRange(selectionRange);
- }
- };
-
- this.redo = function() {
- var selectionRange = this.$u.redo(true);
- if (selectionRange) {
- this.$doc.selection.setSelectionRange(selectionRange);
- }
- };
-
- this.reset = function() {
- this.$u.reset();
- };
-
- this.hasUndo = function() {
- return this.$u.hasUndo();
- };
-
- this.hasRedo = function() {
- return this.$u.hasRedo();
- };
-}).call(UndoManagerProxy.prototype);
-
exports.Split = Split;
});
@@ -239,8 +197,11 @@ ace.define("ace/ext/split",["require","exports","module","ace/split"], function(
"use strict";
module.exports = acequire("../split");
-});
- (function() {
- ace.acequire(["ace/ext/split"], function() {});
+}); (function() {
+ ace.acequire(["ace/ext/split"], function(m) {
+ if (typeof module == "object" && typeof exports == "object" && module) {
+ module.exports = m;
+ }
+ });
})();
\ No newline at end of file
diff --git a/ext/static_highlight.js b/ext/static_highlight.js
index 7c26b2e8..2e59ba51 100644
--- a/ext/static_highlight.js
+++ b/ext/static_highlight.js
@@ -1,4 +1,4 @@
-ace.define("ace/ext/static_highlight",["require","exports","module","ace/edit_session","ace/layer/text","ace/config","ace/lib/dom"], function(acequire, exports, module) {
+ace.define("ace/ext/static_highlight",["require","exports","module","ace/edit_session","ace/layer/text","ace/config","ace/lib/dom","ace/lib/lang"], function(acequire, exports, module) {
"use strict";
var EditSession = acequire("../edit_session").EditSession;
@@ -13,6 +13,7 @@ width: 2em;\
text-align: right;\
padding: 0 3px 0 0;\
margin-right: 3px;\
+contain: none;\
}\
.ace_static_highlight.ace_show_gutter .ace_line {\
padding-left: 2.6em;\
@@ -38,9 +39,61 @@ counter-reset: ace_line;\
";
var config = acequire("../config");
var dom = acequire("../lib/dom");
+var escapeHTML = acequire("../lib/lang").escapeHTML;
+
+function Element(type) {
+ this.type = type;
+ this.style = {};
+ this.textContent = "";
+}
+Element.prototype.cloneNode = function() {
+ return this;
+};
+Element.prototype.appendChild = function(child) {
+ this.textContent += child.toString();
+};
+Element.prototype.toString = function() {
+ var stringBuilder = [];
+ if (this.type != "fragment") {
+ stringBuilder.push("<", this.type);
+ if (this.className)
+ stringBuilder.push(" class='", this.className, "'");
+ var styleStr = [];
+ for (var key in this.style) {
+ styleStr.push(key, ":", this.style[key]);
+ }
+ if (styleStr.length)
+ stringBuilder.push(" style='", styleStr.join(""), "'");
+ stringBuilder.push(">");
+ }
+
+ if (this.textContent) {
+ stringBuilder.push(this.textContent);
+ }
+
+ if (this.type != "fragment") {
+ stringBuilder.push("", this.type, ">");
+ }
+
+ return stringBuilder.join("");
+};
+
+
+var simpleDom = {
+ createTextNode: function(textContent, element) {
+ return escapeHTML(textContent);
+ },
+ createElement: function(type) {
+ return new Element(type);
+ },
+ createFragment: function() {
+ return new Element("fragment");
+ }
+};
var SimpleTextLayer = function() {
this.config = {};
+ this.dom = simpleDom;
};
SimpleTextLayer.prototype = TextLayer.prototype;
@@ -66,7 +119,7 @@ var highlight = function(el, opts, callback) {
}
}
} else {
- data = dom.getInnerText(el);
+ data = el.textContent;
if (opts.trim)
data = data.trim();
}
@@ -123,39 +176,54 @@ highlight.renderSync = function(input, mode, theme, lineStart, disableGutter) {
var textLayer = new SimpleTextLayer();
textLayer.setSession(session);
+ Object.keys(textLayer.$tabStrings).forEach(function(k) {
+ if (typeof textLayer.$tabStrings[k] == "string") {
+ var el = simpleDom.createFragment();
+ el.textContent = textLayer.$tabStrings[k];
+ textLayer.$tabStrings[k] = el;
+ }
+ });
session.setValue(input);
-
- var stringBuilder = [];
var length = session.getLength();
+
+ var outerEl = simpleDom.createElement("div");
+ outerEl.className = theme.cssClass;
+
+ var innerEl = simpleDom.createElement("div");
+ innerEl.className = "ace_static_highlight" + (disableGutter ? "" : " ace_show_gutter");
+ innerEl.style["counter-reset"] = "ace_line " + (lineStart - 1);
- for(var ix = 0; ix < length; ix++) {
- stringBuilder.push("
");
- if (!disableGutter)
- stringBuilder.push("" + /*(ix + lineStart) + */ "");
- textLayer.$renderLine(stringBuilder, ix, true, false);
- stringBuilder.push("\n
");
+ for (var ix = 0; ix < length; ix++) {
+ var lineEl = simpleDom.createElement("div");
+ lineEl.className = "ace_line";
+
+ if (!disableGutter) {
+ var gutterEl = simpleDom.createElement("span");
+ gutterEl.className ="ace_gutter ace_gutter-cell";
+ gutterEl.textContent = "";
+ lineEl.appendChild(gutterEl);
+ }
+ textLayer.$renderLine(lineEl, ix, false);
+ lineEl.textContent += "\n";
+ innerEl.appendChild(lineEl);
}
- var html = "
" +
- "
" +
- stringBuilder.join("") +
- "
" +
- "
";
-
- textLayer.destroy();
+ outerEl.appendChild(innerEl);
return {
css: baseStyles + theme.cssText,
- html: html,
+ html: outerEl.toString(),
session: session
};
};
module.exports = highlight;
module.exports.highlight = highlight;
-});
- (function() {
- ace.acequire(["ace/ext/static_highlight"], function() {});
+}); (function() {
+ ace.acequire(["ace/ext/static_highlight"], function(m) {
+ if (typeof module == "object" && typeof exports == "object" && module) {
+ module.exports = m;
+ }
+ });
})();
\ No newline at end of file
diff --git a/ext/statusbar.js b/ext/statusbar.js
index 2401f462..d1dcd38e 100644
--- a/ext/statusbar.js
+++ b/ext/statusbar.js
@@ -46,8 +46,11 @@ var StatusBar = function(editor, parentNode) {
exports.StatusBar = StatusBar;
-});
- (function() {
- ace.acequire(["ace/ext/statusbar"], function() {});
+}); (function() {
+ ace.acequire(["ace/ext/statusbar"], function(m) {
+ if (typeof module == "object" && typeof exports == "object" && module) {
+ module.exports = m;
+ }
+ });
})();
\ No newline at end of file
diff --git a/ext/textarea.js b/ext/textarea.js
index f42c12c2..addca14f 100644
--- a/ext/textarea.js
+++ b/ext/textarea.js
@@ -123,6 +123,7 @@ border: 1px solid rgb(200, 200, 250);\
background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\
}\
";
+exports.$id = "ace/theme/textmate";
var dom = acequire("../lib/dom");
dom.importCssString(exports.cssText, exports.cssClass);
@@ -203,6 +204,7 @@ function setupContainer(element, getValue) {
}
exports.transformTextarea = function(element, options) {
+ var isFocused = element.autofocus || document.activeElement == element;
var session;
var container = setupContainer(element, function() {
return session.getValue();
@@ -225,12 +227,9 @@ exports.transformTextarea = function(element, options) {
position: "absolute",
right: "0px",
bottom: "0px",
- background: "red",
cursor: "nw-resize",
- borderStyle: "solid",
- borderWidth: "9px 8px 10px 9px",
- width: "2px",
- borderColor: "lightblue gray gray lightblue",
+ border: "solid 9px",
+ borderColor: "lightblue gray gray #ceade6",
zIndex: 101
});
@@ -263,9 +262,10 @@ exports.transformTextarea = function(element, options) {
session = editor.getSession();
session.setValue(element.value || element.innerHTML);
- editor.focus();
+ if (isFocused)
+ editor.focus();
container.appendChild(settingOpener);
- setupApi(editor, editorDiv, settingDiv, ace, options, load);
+ setupApi(editor, editorDiv, settingDiv, ace, options);
setupSettingPanel(settingDiv, settingOpener, editor);
var state = "";
@@ -282,6 +282,7 @@ exports.transformTextarea = function(element, options) {
});
event.addListener(settingOpener, "mousedown", function(e) {
+ e.preventDefault();
if (state == "toggle") {
editor.setDisplaySettings();
return;
@@ -306,10 +307,9 @@ function load(url, module, callback) {
});
}
-function setupApi(editor, editorDiv, settingDiv, ace, options, loader) {
+function setupApi(editor, editorDiv, settingDiv, ace, options) {
var session = editor.getSession();
var renderer = editor.renderer;
- loader = loader || load;
function toBool(value) {
return value === "true" || value == true;
@@ -353,7 +353,7 @@ function setupApi(editor, editorDiv, settingDiv, ace, options, loader) {
}
break;
- case "softWrap":
+ case "wrap":
case "fontSize":
editor.$setOption(key, value);
break;
@@ -553,8 +553,11 @@ exports.defaultOptions = {
showInvisibles: "false"
};
-});
- (function() {
- ace.acequire(["ace/ext/textarea"], function() {});
+}); (function() {
+ ace.acequire(["ace/ext/textarea"], function(m) {
+ if (typeof module == "object" && typeof exports == "object" && module) {
+ module.exports = m;
+ }
+ });
})();
\ No newline at end of file
diff --git a/ext/themelist.js b/ext/themelist.js
index c224d896..81edd463 100644
--- a/ext/themelist.js
+++ b/ext/themelist.js
@@ -1,6 +1,5 @@
-ace.define("ace/ext/themelist",["require","exports","module","ace/lib/fixoldbrowsers"], function(acequire, exports, module) {
+ace.define("ace/ext/themelist",["require","exports","module"], function(acequire, exports, module) {
"use strict";
-acequire("ace/lib/fixoldbrowsers");
var themeData = [
["Chrome" ],
@@ -21,6 +20,7 @@ var themeData = [
["Ambiance" ,"ambiance" , "dark"],
["Chaos" ,"chaos" , "dark"],
["Clouds Midnight" ,"clouds_midnight" , "dark"],
+ ["Dracula" ,"" , "dark"],
["Cobalt" ,"cobalt" , "dark"],
["Gruvbox" ,"gruvbox" , "dark"],
["Green on Black" ,"gob" , "dark"],
@@ -55,8 +55,11 @@ exports.themes = themeData.map(function(data) {
return theme;
});
-});
- (function() {
- ace.acequire(["ace/ext/themelist"], function() {});
+}); (function() {
+ ace.acequire(["ace/ext/themelist"], function(m) {
+ if (typeof module == "object" && typeof exports == "object" && module) {
+ module.exports = m;
+ }
+ });
})();
\ No newline at end of file
diff --git a/ext/whitespace.js b/ext/whitespace.js
index fa01c8f5..ff511431 100644
--- a/ext/whitespace.js
+++ b/ext/whitespace.js
@@ -181,8 +181,8 @@ exports.commands = [{
}
}, {
name: "trimTrailingSpace",
- exec: function(editor) {
- exports.trimTrailingSpace(editor.session);
+ exec: function(editor, args) {
+ exports.trimTrailingSpace(editor.session, args);
}
}, {
name: "convertIndentation",
@@ -199,8 +199,11 @@ exports.commands = [{
}
}];
-});
- (function() {
- ace.acequire(["ace/ext/whitespace"], function() {});
+}); (function() {
+ ace.acequire(["ace/ext/whitespace"], function(m) {
+ if (typeof module == "object" && typeof exports == "object" && module) {
+ module.exports = m;
+ }
+ });
})();
\ No newline at end of file
diff --git a/index.d.ts b/index.d.ts
index f81fa309..e9c79a6a 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -52,6 +52,10 @@ declare namespace AceAjax {
export interface TokenInfo {
value: string;
+
+ index?: number;
+
+ start?: number;
}
export interface Position {
@@ -97,6 +101,29 @@ declare namespace AceAjax {
transformAction(state: any, action: any, editor: any, session: any, param: any): any;
}
+ export interface OptionProvider {
+
+ /**
+ * Sets a Configuration Option
+ **/
+ setOption(optionName: string, optionValue: any): void;
+
+ /**
+ * Sets Configuration Options
+ **/
+ setOptions(keyValueTuples: any): void;
+
+ /**
+ * Get a Configuration Option
+ **/
+ getOption(name: string):any;
+
+ /**
+ * Get Configuration Options
+ **/
+ getOptions():any;
+ }
+
////////////////
/// Ace
////////////////
@@ -137,7 +164,7 @@ export function createEditSession(text: Document, mode: TextMode): IEdit
* @param mode {:modeParam}
**/
export function createEditSession(text: string, mode: TextMode): IEditSession;
-
+ }
////////////////
/// Anchor
@@ -148,7 +175,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
**/
export interface Anchor {
- on(event: string, fn: (e: any) => any): void;
+export function on(event: string, fn: (e: any) => any): void;
/**
* Returns an object identifying the `row` and `column` position of the current anchor.
@@ -168,7 +195,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* - `old`: An object describing the old Anchor position
* - `value`: An object describing the new Anchor position
**/
- onChange(e: any): void;
+export function onChange(e: any): void;
/**
* Sets the anchor position to the specified row and column. If `noClip` is `true`, the position is not clipped.
@@ -176,7 +203,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param column The column index to move the anchor to
* @param noClip Identifies if you want the position to be clipped
**/
- setPosition(row: number, column: number, noClip: boolean): void;
+export function setPosition(row: number, column: number, noClip: boolean): void;
/**
* When called, the `'change'` event listener is removed.
@@ -190,7 +217,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param row The starting row position
* @param column The starting column position
**/
- new(doc: Document, row: number, column: number): Anchor;
+export function new(doc: Document, row: number, column: number): Anchor;
}
////////////////////////////////
@@ -209,26 +236,26 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Sets a new tokenizer for this object.
* @param tokenizer The new tokenizer to use
**/
- setTokenizer(tokenizer: Tokenizer): void;
+export function setTokenizer(tokenizer: Tokenizer): void;
/**
* Sets a new document to associate with this object.
* @param doc The new document to associate with
**/
- setDocument(doc: Document): void;
+export function setDocument(doc: Document): void;
/**
* Emits the `'update'` event. `firstRow` and `lastRow` are used to define the boundaries of the region to be updated.
* @param firstRow The starting row region
* @param lastRow The final row region
**/
- fireUpdateEvent(firstRow: number, lastRow: number): void;
+export function fireUpdateEvent(firstRow: number, lastRow: number): void;
/**
* Starts tokenizing at the row indicated.
* @param startRow The row to start at
**/
- start(startRow: number): void;
+export function start(startRow: number): void;
/**
* Stops tokenizing.
@@ -239,13 +266,13 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Gives list of tokens of the row. (tokens are cached)
* @param row The row to get tokens at
**/
- getTokens(row: number): TokenInfo[];
+export function getTokens(row: number): TokenInfo[];
/**
* [Returns the state of tokenization at the end of a row.]{: #BackgroundTokenizer.getState}
* @param row The row to get state at
**/
- getState(row: number): string;
+export function getState(row: number): string;
}
var BackgroundTokenizer: {
/**
@@ -253,7 +280,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param tokenizer The tokenizer to use
* @param editor The editor to associate with
**/
- new(tokenizer: Tokenizer, editor: Editor): BackgroundTokenizer;
+export function new(tokenizer: Tokenizer, editor: Editor): BackgroundTokenizer;
}
////////////////
@@ -266,13 +293,13 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
**/
export interface Document {
- on(event: string, fn: (e: any) => any): void;
+export function on(event: string, fn: (e: any) => any): void;
/**
* Replaces all the lines in the current `Document` with the value of `text`.
* @param text The text to use
**/
- setValue(text: string): void;
+export function setValue(text: string): void;
/**
* Returns all the lines in the document as a single string, split by the new line character.
@@ -284,7 +311,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param row The row number to use
* @param column The column number to use
**/
- createAnchor(row: number, column: number): void;
+export function createAnchor(row: number, column: number): void;
/**
* Returns the newline character that's being used, depending on the value of `newLineMode`.
@@ -295,7 +322,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* [Sets the new line mode.]{: #Document.setNewLineMode.desc}
* @param newLineMode [The newline mode to use; can be either `windows`, `unix`, or `auto`]{: #Document.setNewLineMode.param}
**/
- setNewLineMode(newLineMode: string): void;
+export function setNewLineMode(newLineMode: string): void;
/**
* [Returns the type of newlines being used; either `windows`, `unix`, or `auto`]{: #Document.getNewLineMode}
@@ -306,20 +333,20 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Returns `true` if `text` is a newline character (either `\r\n`, `\r`, or `\n`).
* @param text The text to check
**/
- isNewLine(text: string): boolean;
+export function isNewLine(text: string): boolean;
/**
* Returns a verbatim copy of the given line as it is in the document
* @param row The row index to retrieve
**/
- getLine(row: number): string;
+export function getLine(row: number): string;
/**
* Returns an array of strings of the rows between `firstRow` and `lastRow`. This function is inclusive of `lastRow`.
* @param firstRow The first row index to retrieve
* @param lastRow The final row index to retrieve
**/
- getLines(firstRow: number, lastRow: number): string[];
+export function getLines(firstRow: number, lastRow: number): string[];
/**
* Returns all lines in the document as string array. Warning: The caller should not modify this array!
@@ -335,40 +362,69 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* [Given a range within the document, this function returns all the text within that range as a single string.]{: #Document.getTextRange.desc}
* @param range The range to work with
**/
- getTextRange(range: Range): string;
+export function getTextRange(range: Range): string;
/**
* Inserts a block of `text` and the indicated `position`.
* @param position The position to start inserting at
* @param text A chunk of text to insert
**/
- insert(position: Position, text: string): any;
+export function insert(position: Position, text: string): any;
/**
- * Inserts the elements in `lines` into the document, starting at the row index given by `row`. This method also triggers the `'change'` event.
- * @param row The index of the row to insert at
- * @param lines An array of strings
- **/
- insertLines(row: number, lines: string[]): any;
+ * @deprecated Use the insertFullLines method instead.
+ */
+export function insertLines(row: number, lines: string[]): any;
/**
- * Inserts a new line into the document at the current row's `position`. This method also triggers the `'change'` event.
- * @param position The position to insert at
- **/
- insertNewLine(position: Position): any;
+ * Inserts the elements in `lines` into the document as full lines (does not merge with existing line), starting at the row index given by `row`. This method also triggers the `"change"` event.
+ * @param {Number} row The index of the row to insert at
+ * @param {Array} lines An array of strings
+ * @returns {Object} Contains the final row and column, like this:
+ * ```
+ * {row: endRow, column: 0}
+ * ```
+ * If `lines` is empty, this function returns an object containing the current row, and column, like this:
+ * ```
+ * {row: row, column: 0}
+ * ```
+ *
+ **/
+export function insertFullLines(row: number, lines: string[]): any;
+
+ /**
+ * @deprecated Use insertMergedLines(position, ['', '']) instead.
+ */
+export function insertNewLine(position: Position): any;
+
+ /**
+ * Inserts the elements in `lines` into the document, starting at the position index given by `row`. This method also triggers the `"change"` event.
+ * @param {Number} row The index of the row to insert at
+ * @param {Array} lines An array of strings
+ * @returns {Object} Contains the final row and column, like this:
+ * ```
+ * {row: endRow, column: 0}
+ * ```
+ * If `lines` is empty, this function returns an object containing the current row, and column, like this:
+ * ```
+ * {row: row, column: 0}
+ * ```
+ *
+ **/
+export function insertMergedLines(row: number, lines: string[]): any;
/**
* Inserts `text` into the `position` at the current row. This method also triggers the `'change'` event.
* @param position The position to insert at
* @param text A chunk of text
**/
- insertInLine(position: any, text: string): any;
+export function insertInLine(position: any, text: string): any;
/**
* Removes the `range` from the document.
* @param range A specified Range to remove
**/
- remove(range: Range): any;
+export function remove(range: Range): any;
/**
* Removes the specified columns from the `row`. This method also triggers the `'change'` event.
@@ -376,37 +432,44 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param startColumn The column to start removing at
* @param endColumn The column to stop removing at
**/
- removeInLine(row: number, startColumn: number, endColumn: number): any;
+export function removeInLine(row: number, startColumn: number, endColumn: number): any;
/**
- * Removes a range of full lines. This method also triggers the `'change'` event.
- * @param firstRow The first row to be removed
- * @param lastRow The last row to be removed
- **/
- removeLines(firstRow: number, lastRow: number): string[];
+ * @deprecated Use the removeFullLines method instead.
+ */
+export function removeLines(firstRow: number, lastRow: number): string[];
+
+ /**
+ * Removes a range of full lines. This method also triggers the `"change"` event.
+ * @param {Number} firstRow The first row to be removed
+ * @param {Number} lastRow The last row to be removed
+ * @returns {[String]} Returns all the removed lines.
+ *
+ **/
+export function removeFullLines(firstRow: number, lastRow: number): string[];
/**
* Removes the new line between `row` and the row immediately following it. This method also triggers the `'change'` event.
* @param row The row to check
**/
- removeNewLine(row: number): void;
+export function removeNewLine(row: number): void;
/**
* Replaces a range in the document with the new `text`.
* @param range A specified Range to replace
* @param text The new text to use as a replacement
**/
- replace(range: Range, text: string): any;
+export function replace(range: Range, text: string): any;
/**
* Applies all the changes previously accumulated. These can be either `'includeText'`, `'insertLines'`, `'removeText'`, and `'removeLines'`.
**/
- applyDeltas(deltas: Delta[]): void;
+export function applyDeltas(deltas: Delta[]): void;
/**
* Reverts any changes previously applied. These can be either `'includeText'`, `'insertLines'`, `'removeText'`, and `'removeLines'`.
**/
- revertDeltas(deltas: Delta[]): void;
+export function revertDeltas(deltas: Delta[]): void;
/**
* Converts an index position in a document to a `{row, column}` object.
@@ -419,7 +482,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param index An index to convert
* @param startRow=0 The row from which to start the conversion
**/
- indexToPosition(index: number, startRow: number): Position;
+export function indexToPosition(index: number, startRow: number): Position;
/**
* Converts the `{row, column}` position in a document to the character's index.
@@ -432,19 +495,19 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param pos The `{row, column}` to convert
* @param startRow=0 The row from which to start the conversion
**/
- positionToIndex(pos: Position, startRow: number): number;
+export function positionToIndex(pos: Position, startRow: number): number;
}
var Document: {
/**
* Creates a new `Document`. If `text` is included, the `Document` contains those strings; otherwise, it's empty.
* @param text The starting text
**/
- new(text?: string): Document;
+export function new(text?: string): Document;
/**
* Creates a new `Document`. If `text` is included, the `Document` contains those strings; otherwise, it's empty.
* @param text The starting text
**/
- new(text?: string[]): Document;
+export function new(text?: string[]): Document;
}
////////////////////////////////
@@ -455,7 +518,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Stores all the data about [[Editor `Editor`]] state providing easy way to change editors state.
* `EditSession` can be attached to only one [[Document `Document`]]. Same `Document` can be attached to several `EditSession`s.
**/
- export interface IEditSession {
+ export interface IEditSession extends OptionProvider {
selection: Selection;
@@ -463,35 +526,35 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
doc: Document;
- on(event: string, fn: (e: any) => any): void;
+export function on(event: string, fn: (e: any) => any): void;
- findMatchingBracket(position: Position): void;
+export function findMatchingBracket(position: Position): void;
- addFold(text: string, range: Range): void;
+export function addFold(text: string, range: Range): void;
- getFoldAt(row: number, column: number): any;
+export function getFoldAt(row: number, column: number): any;
- removeFold(arg: any): void;
+export function removeFold(arg: any): void;
- expandFold(arg: any): void;
+export function expandFold(arg: any): void;
foldAll(startRow?: number, endRow?: number, depth?: number): void
- unfold(arg1: any, arg2: boolean): void;
+export function unfold(arg1: any, arg2: boolean): void;
- screenToDocumentColumn(row: number, column: number): void;
+export function screenToDocumentColumn(row: number, column: number): void;
- getFoldDisplayLine(foldLine: any, docRow: number, docColumn: number): any;
+export function getFoldDisplayLine(foldLine: any, docRow: number, docColumn: number): any;
- getFoldsInRange(range: Range): any;
+export function getFoldsInRange(range: Range): any;
- highlight(text: string): void;
+export function highlight(text: string): void;
/**
* Sets the `EditSession` to point to a new `Document`. If a `BackgroundTokenizer` exists, it also points to `doc`.
* @param doc The new `Document` to use
**/
- setDocument(doc: Document): void;
+export function setDocument(doc: Document): void;
/**
* Returns the `Document` associated with this session.
@@ -502,15 +565,15 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* undefined
* @param row The row to work with
**/
- $resetRowCache(row: number): void;
+export function $resetRowCache(row: number): void;
/**
* Sets the session text.
* @param text The new text to place
**/
- setValue(text: string): void;
+export function setValue(text: string): void;
- setMode(mode: string): void;
+export function setMode(mode: string): void;
/**
* Returns the current [[Document `Document`]] as a string.
@@ -526,26 +589,26 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* {:BackgroundTokenizer.getState}
* @param row The row to start at
**/
- getState(row: number): string;
+export function getState(row: number): string;
/**
* Starts tokenizing at the row indicated. Returns a list of objects of the tokenized rows.
* @param row The row to start at
**/
- getTokens(row: number): TokenInfo[];
+export function getTokens(row: number): TokenInfo[];
/**
* Returns an object indicating the token at the current row. The object has two properties: `index` and `start`.
* @param row The row number to retrieve from
* @param column The column number to retrieve from
**/
- getTokenAt(row: number, column: number): TokenInfo;
+export function getTokenAt(row: number, column: number): TokenInfo|null;
/**
* Sets the undo manager.
* @param undoManager The new undo manager
**/
- setUndoManager(undoManager: UndoManager): void;
+export function setUndoManager(undoManager: UndoManager): void;
/**
* Returns the current undo manager.
@@ -553,7 +616,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
getUndoManager(): UndoManager;
/**
- * Returns the current value for tabs. If the user is using soft tabs, this will be a series of spaces (defined by [[EditSession.getTabSize `getTabSize()`]]): void; otherwise it's simply `'\t'`.
+export function * Returns the current value for tabs. If the user is using soft tabs, this will be a series of spaces (defined by [[EditSession.getTabSize `getTabSize()`]]): void; otherwise it's simply `'\t'`.
**/
getTabString(): string;
@@ -561,7 +624,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Pass `true` to enable the use of soft tabs. Soft tabs means you're using spaces instead of the tab character (`'\t'`).
* @param useSoftTabs Value indicating whether or not to use soft tabs
**/
- setUseSoftTabs(useSoftTabs: boolean): void;
+export function setUseSoftTabs(useSoftTabs: boolean): void;
/**
* Returns `true` if soft tabs are being used, `false` otherwise.
@@ -572,7 +635,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Set the number of spaces that define a soft tab; for example, passing in `4` transforms the soft tabs to be equivalent to four spaces. This function also emits the `changeTabSize` event.
* @param tabSize The new tab size
**/
- setTabSize(tabSize: number): void;
+export function setTabSize(tabSize: number): void;
/**
* Returns the current tab size.
@@ -583,14 +646,14 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Returns `true` if the character at the position is a soft tab.
* @param position The position to check
**/
- isTabStop(position: any): boolean;
+export function isTabStop(position: any): boolean;
/**
* Pass in `true` to enable overwrites in your session, or `false` to disable.
* If overwrites is enabled, any text you enter will type over any text after it. If the value of `overwrite` changes, this function also emites the `changeOverwrite` event.
* @param overwrite Defines wheter or not to set overwrites
**/
- setOverwrite(overwrite: boolean): void;
+export function setOverwrite(overwrite: boolean): void;
/**
* Returns `true` if overwrites are enabled; `false` otherwise.
@@ -607,14 +670,14 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param row The row number
* @param className The class to add
**/
- addGutterDecoration(row: number, className: string): void;
+export function addGutterDecoration(row: number, className: string): void;
/**
* Removes `className` from the `row`.
* @param row The row number
* @param className The class to add
**/
- removeGutterDecoration(row: number, className: string): void;
+export function removeGutterDecoration(row: number, className: string): void;
/**
* Returns an array of numbers, indicating which rows have breakpoints.
@@ -625,7 +688,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Sets a breakpoint on every row number given by `rows`. This function also emites the `'changeBreakpoint'` event.
* @param rows An array of row indices
**/
- setBreakpoints(rows: any[]): void;
+export function setBreakpoints(rows: any[]): void;
/**
* Removes all breakpoints on the rows. This function also emites the `'changeBreakpoint'` event.
@@ -637,13 +700,13 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param row A row index
* @param className Class of the breakpoint
**/
- setBreakpoint(row: number, className: string): void;
+export function setBreakpoint(row: number, className: string): void;
/**
* Removes a breakpoint on the row number given by `rows`. This function also emites the `'changeBreakpoint'` event.
* @param row A row index
**/
- clearBreakpoint(row: number): void;
+export function clearBreakpoint(row: number): void;
/**
* Adds a new marker to the given `Range`. If `inFront` is `true`, a front marker is defined, and the `'changeFrontMarker'` event fires; otherwise, the `'changeBackMarker'` event fires.
@@ -652,7 +715,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param type Identify the type of the marker
* @param inFront Set to `true` to establish a front marker
**/
- addMarker(range: Range, clazz: string, type: Function, inFront: boolean): number;
+export function addMarker(range: Range, clazz: string, type: Function, inFront: boolean): number;
/**
* Adds a new marker to the given `Range`. If `inFront` is `true`, a front marker is defined, and the `'changeFrontMarker'` event fires; otherwise, the `'changeBackMarker'` event fires.
@@ -661,32 +724,32 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param type Identify the type of the marker
* @param inFront Set to `true` to establish a front marker
**/
- addMarker(range: Range, clazz: string, type: string, inFront: boolean): number;
+export function addMarker(range: Range, clazz: string, type: string, inFront: boolean): number;
/**
* Adds a dynamic marker to the session.
* @param marker object with update method
* @param inFront Set to `true` to establish a front marker
**/
- addDynamicMarker(marker: any, inFront: boolean): void;
+export function addDynamicMarker(marker: any, inFront: boolean): void;
/**
* Removes the marker with the specified ID. If this marker was in front, the `'changeFrontMarker'` event is emitted. If the marker was in the back, the `'changeBackMarker'` event is emitted.
* @param markerId A number representing a marker
**/
- removeMarker(markerId: number): void;
+export function removeMarker(markerId: number): void;
/**
* Returns an array containing the IDs of all the markers, either front or back.
* @param inFront If `true`, indicates you only want front markers; `false` indicates only back markers
**/
- getMarkers(inFront: boolean): any[];
+export function getMarkers(inFront: boolean): any[];
/**
* Sets annotations for the `EditSession`. This functions emits the `'changeAnnotation'` event.
* @param annotations A list of annotations
**/
- setAnnotations(annotations: Annotation[]): void;
+export function setAnnotations(annotations: Annotation[]): void;
/**
* Returns the annotations for the `EditSession`.
@@ -702,27 +765,27 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* If `text` contains either the newline (`\n`) or carriage-return ('\r') characters, `$autoNewLine` stores that value.
* @param text A block of text
**/
- $detectNewLine(text: string): void;
+export function $detectNewLine(text: string): void;
/**
* Given a starting row and column, this method returns the `Range` of the first word boundary it finds.
* @param row The row to start at
* @param column The column to start at
**/
- getWordRange(row: number, column: number): Range;
+export function getWordRange(row: number, column: number): Range;
/**
* Gets the range of a word, including its right whitespace.
* @param row The row number to start from
* @param column The column number to start from
**/
- getAWordRange(row: number, column: number): any;
+export function getAWordRange(row: number, column: number): any;
/**
* {:Document.setNewLineMode.desc}
* @param newLineMode {:Document.setNewLineMode.param}
**/
- setNewLineMode(newLineMode: string): void;
+export function setNewLineMode(newLineMode: string): void;
/**
* Returns the current new line mode.
@@ -733,7 +796,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Identifies if you want to use a worker for the `EditSession`.
* @param useWorker Set to `true` to use a worker
**/
- setUseWorker(useWorker: boolean): void;
+export function setUseWorker(useWorker: boolean): void;
/**
* Returns `true` if workers are being used.
@@ -749,7 +812,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Sets a new text mode for the `EditSession`. This method also emits the `'changeMode'` event. If a [[BackgroundTokenizer `BackgroundTokenizer`]] is set, the `'tokenizerUpdate'` event is also emitted.
* @param mode Set a new text mode
**/
- $mode(mode: TextMode): void;
+export function $mode(mode: TextMode): void;
/**
* Returns the current text mode.
@@ -760,7 +823,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* This function sets the scroll top value. It also emits the `'changeScrollTop'` event.
* @param scrollTop The new scroll top value
**/
- setScrollTop(scrollTop: number): void;
+export function setScrollTop(scrollTop: number): void;
/**
* [Returns the value of the distance between the top of the editor and the topmost part of the visible content.]{: #EditSession.getScrollTop}
@@ -769,8 +832,9 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
/**
* [Sets the value of the distance between the left of the editor and the leftmost part of the visible content.]{: #EditSession.setScrollLeft}
+ * @param scrollLeft The new scroll left value
**/
- setScrollLeft(): void;
+export function setScrollLeft(scrollLeft: number): void;
/**
* [Returns the value of the distance between the left of the editor and the leftmost part of the visible content.]{: #EditSession.getScrollLeft}
@@ -786,14 +850,14 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Returns a verbatim copy of the given line as it is in the document
* @param row The row to retrieve from
**/
- getLine(row: number): string;
+export function getLine(row: number): string;
/**
* Returns an array of strings of the rows between `firstRow` and `lastRow`. This function is inclusive of `lastRow`.
* @param firstRow The first row index to retrieve
* @param lastRow The final row index to retrieve
**/
- getLines(firstRow: number, lastRow: number): string[];
+export function getLines(firstRow: number, lastRow: number): string[];
/**
* Returns the number of rows in the document.
@@ -804,47 +868,47 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* {:Document.getTextRange.desc}
* @param range The range to work with
**/
- getTextRange(range: Range): string;
+export function getTextRange(range: Range): string;
/**
* Inserts a block of `text` and the indicated `position`.
* @param position The position {row, column} to start inserting at
* @param text A chunk of text to insert
**/
- insert(position: Position, text: string): any;
+export function insert(position: Position, text: string): any;
/**
* Removes the `range` from the document.
* @param range A specified Range to remove
**/
- remove(range: Range): any;
+export function remove(range: Range): any;
/**
* Reverts previous changes to your document.
* @param deltas An array of previous changes
* @param dontSelect [If `true`, doesn't select the range of where the change occured]{: #dontSelect}
**/
- undoChanges(deltas: any[], dontSelect: boolean): Range;
+export function undoChanges(deltas: any[], dontSelect: boolean): Range;
/**
* Re-implements a previously undone change to your document.
* @param deltas An array of previous changes
* @param dontSelect {:dontSelect}
**/
- redoChanges(deltas: any[], dontSelect: boolean): Range;
+export function redoChanges(deltas: any[], dontSelect: boolean): Range;
/**
* Enables or disables highlighting of the range where an undo occured.
* @param enable If `true`, selects the range of the reinserted change
**/
- setUndoSelect(enable: boolean): void;
+export function setUndoSelect(enable: boolean): void;
/**
* Replaces a range in the document with the new `text`.
* @param range A specified Range to replace
* @param text The new text to use as a replacement
**/
- replace(range: Range, text: string): any;
+export function replace(range: Range, text: string): any;
/**
* Moves a range of text from the given range to the given position. `toPosition` is an object that looks like this:
@@ -854,7 +918,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param fromRange The range of text you want moved within the document
* @param toPosition The location (row and column) where you want to move the text to
**/
- moveText(fromRange: Range, toPosition: any): Range;
+export function moveText(fromRange: Range, toPosition: any): Range;
/**
* Indents all the rows, from `startRow` to `endRow` (inclusive), by prefixing each row with the token in `indentString`.
@@ -863,40 +927,40 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param endRow Ending row
* @param indentString The indent token
**/
- indentRows(startRow: number, endRow: number, indentString: string): void;
+export function indentRows(startRow: number, endRow: number, indentString: string): void;
/**
* Outdents all the rows defined by the `start` and `end` properties of `range`.
* @param range A range of rows
**/
- outdentRows(range: Range): void;
+export function outdentRows(range: Range): void;
/**
* Shifts all the lines in the document up one, starting from `firstRow` and ending at `lastRow`.
* @param firstRow The starting row to move up
* @param lastRow The final row to move up
**/
- moveLinesUp(firstRow: number, lastRow: number): number;
+export function moveLinesUp(firstRow: number, lastRow: number): number;
/**
* Shifts all the lines in the document down one, starting from `firstRow` and ending at `lastRow`.
* @param firstRow The starting row to move down
* @param lastRow The final row to move down
**/
- moveLinesDown(firstRow: number, lastRow: number): number;
+export function moveLinesDown(firstRow: number, lastRow: number): number;
/**
* Duplicates all the text between `firstRow` and `lastRow`.
* @param firstRow The starting row to duplicate
* @param lastRow The final row to duplicate
**/
- duplicateLines(firstRow: number, lastRow: number): number;
+export function duplicateLines(firstRow: number, lastRow: number): number;
/**
* Sets whether or not line wrapping is enabled. If `useWrapMode` is different than the current value, the `'changeWrapMode'` event is emitted.
* @param useWrapMode Enable (or disable) wrap mode
**/
- setUseWrapMode(useWrapMode: boolean): void;
+export function setUseWrapMode(useWrapMode: boolean): void;
/**
* Returns `true` if wrap mode is being used; `false` otherwise.
@@ -908,13 +972,13 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param min The minimum wrap value (the left side wrap)
* @param max The maximum wrap value (the right side wrap)
**/
- setWrapLimitRange(min: number, max: number): void;
+export function setWrapLimitRange(min: number, max: number): void;
/**
* This should generally only be called by the renderer when a resize is detected.
* @param desiredLimit The new wrap limit
**/
- adjustWrapLimit(desiredLimit: number): boolean;
+export function adjustWrapLimit(desiredLimit: number): boolean;
/**
* Returns the value of wrap limit.
@@ -932,7 +996,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param str The string to check
* @param offset The value to start at
**/
- $getDisplayTokens(str: string, offset: number): void;
+export function $getDisplayTokens(str: string, offset: number): void;
/**
* Calculates the width of the string `str` on the screen while assuming that the string starts at the first column on the screen.
@@ -940,33 +1004,33 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param maxScreenColumn
* @param screenColumn
**/
- $getStringScreenWidth(str: string, maxScreenColumn: number, screenColumn: number): number[];
+export function $getStringScreenWidth(str: string, maxScreenColumn: number, screenColumn: number): number[];
/**
* Returns number of screenrows in a wrapped line.
* @param row The row number to check
**/
- getRowLength(row: number): number;
+export function getRowLength(row: number): number;
/**
* Returns the position (on screen) for the last character in the provided screen row.
* @param screenRow The screen row to check
**/
- getScreenLastRowColumn(screenRow: number): number;
+export function getScreenLastRowColumn(screenRow: number): number;
/**
* For the given document row and column, this returns the column position of the last screen row.
* @param docRow
* @param docColumn
**/
- getDocumentLastRowColumn(docRow: number, docColumn: number): number;
+export function getDocumentLastRowColumn(docRow: number, docColumn: number): number;
/**
* For the given document row and column, this returns the document position of the last row.
* @param docRow
* @param docColumn
**/
- getDocumentLastRowColumnPosition(docRow: number, docColumn: number): number;
+export function getDocumentLastRowColumnPosition(docRow: number, docColumn: number): number;
/**
* For the given row, this returns the split data.
@@ -977,35 +1041,35 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* The distance to the next tab stop at the specified screen column.
* @param screenColumn The screen column to check
**/
- getScreenTabSize(screenColumn: number): number;
+export function getScreenTabSize(screenColumn: number): number;
/**
* Converts characters coordinates on the screen to characters coordinates within the document. [This takes into account code folding, word wrap, tab size, and any other visual modifications.]{: #conversionConsiderations}
* @param screenRow The screen row to check
* @param screenColumn The screen column to check
**/
- screenToDocumentPosition(screenRow: number, screenColumn: number): any;
+export function screenToDocumentPosition(screenRow: number, screenColumn: number): any;
/**
* Converts document coordinates to screen coordinates. {:conversionConsiderations}
* @param docRow The document row to check
* @param docColumn The document column to check
**/
- documentToScreenPosition(docRow: number, docColumn: number): any;
+export function documentToScreenPosition(docRow: number, docColumn: number): any;
/**
* For the given document row and column, returns the screen column.
* @param row
* @param docColumn
**/
- documentToScreenColumn(row: number, docColumn: number): number;
+export function documentToScreenColumn(row: number, docColumn: number): number;
/**
* For the given document row and column, returns the screen row.
* @param docRow
* @param docColumn
**/
- documentToScreenRow(docRow: number, docColumn: number): void;
+export function documentToScreenRow(docRow: number, docColumn: number): void;
/**
* Returns the length of the screen.
@@ -1018,9 +1082,9 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param text [If `text` is a `Document`, it associates the `EditSession` with it. Otherwise, a new `Document` is created, with the initial text]{: #textParam}
* @param mode [The inital language mode to use for the document]{: #modeParam}
**/
- new(text: string, mode?: TextMode): IEditSession;
+export function new(text: string, mode?: TextMode): IEditSession;
- new(content: string, mode?: string): IEditSession;
+export function new(content: string, mode?: string): IEditSession;
new (text: string[], mode?: string): IEditSession;
}
@@ -1034,26 +1098,26 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* The `Editor` manages the [[EditSession]] (which manages [[Document]]s), as well as the [[VirtualRenderer]], which draws everything to the screen.
* Event sessions dealing with the mouse and keyboard are bubbled up from `Document` to the `Editor`, which decides what to do with them.
**/
- export interface Editor {
+ export interface Editor extends OptionProvider {
- on(ev: string, callback: (e: any) => any): void;
+export function on(ev: string, callback: (e: any) => any): void;
- addEventListener(ev: 'change', callback: (ev: EditorChangeEvent) => any): void;
- addEventListener(ev: string, callback: Function): void;
+export function addEventListener(ev: 'change', callback: (ev: EditorChangeEvent) => any): void;
+export function addEventListener(ev: string, callback: Function): void;
- off(ev: string, callback: Function): void;
+export function off(ev: string, callback: Function): void;
- removeListener(ev: string, callback: Function): void;
+export function removeListener(ev: string, callback: Function): void;
- removeEventListener(ev: string, callback: Function): void;
+export function removeEventListener(ev: string, callback: Function): void;
inMultiSelectMode: boolean;
- selectMoreLines(n: number): void;
+export function selectMoreLines(n: number): void;
- onTextInput(text: string): void;
+export function onTextInput(text: string): void;
- onCommandKey(e: any, hashId: any, keyCode: any): void;
+export function onCommandKey(e: any, hashId: any, keyCode: any): void;
commands: CommandManager;
@@ -1067,31 +1131,11 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
container: HTMLElement;
- onSelectionChange(e: any): void;
+export function onSelectionChange(e: any): void;
- onChangeMode(e?: any): void;
+export function onChangeMode(e?: any): void;
- execCommand(command:string, args?: any): void;
-
- /**
- * Sets a Configuration Option
- **/
- setOption(optionName: any, optionValue: any): void;
-
- /**
- * Sets Configuration Options
- **/
- setOptions(keyValueTuples: any): void;
-
- /**
- * Get a Configuration Option
- **/
- getOption(name: any):any;
-
- /**
- * Get Configuration Options
- **/
- getOptions():any;
+export function execCommand(command:string, args?: any): void;
/**
* Get rid of console warning by setting this to Infinity
@@ -1102,7 +1146,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Sets a new key handler, such as "vim" or "windows".
* @param keyboardHandler The new key handler
**/
- setKeyboardHandler(keyboardHandler: string): void;
+export function setKeyboardHandler(keyboardHandler: string): void;
/**
* Returns the keyboard handler, such as "vim" or "windows".
@@ -1113,7 +1157,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Sets a new editsession to use. This method also emits the `'changeSession'` event.
* @param session The new session to use
**/
- setSession(session: IEditSession): void;
+export function setSession(session: IEditSession): void;
/**
* Returns the current session being used.
@@ -1125,7 +1169,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param val The new value to set for the document
* @param cursorPos Where to set the new value. `undefined` or 0 is selectAll, -1 is at the document start, and 1 is at the end
**/
- setValue(val: string, cursorPos?: number): string;
+export function setValue(val: string, cursorPos?: number): string;
/**
* Returns the current session's content.
@@ -1141,13 +1185,13 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* {:VirtualRenderer.onResize}
* @param force If `true`, recomputes the size, even if the height and width haven't changed
**/
- resize(force?: boolean): void;
+export function resize(force?: boolean): void;
/**
* {:VirtualRenderer.setTheme}
* @param theme The path to a theme
**/
- setTheme(theme: string): void;
+export function setTheme(theme: string): void;
/**
* {:VirtualRenderer.getTheme}
@@ -1158,7 +1202,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* {:VirtualRenderer.setStyle}
* @param style A class name
**/
- setStyle(style: string): void;
+export function setStyle(style: string): void;
/**
* {:VirtualRenderer.unsetStyle}
@@ -1169,7 +1213,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Set a new font size (in pixels) for the editor text.
* @param size A font size ( _e.g._ "12px")
**/
- setFontSize(size: string): void;
+export function setFontSize(size: string): void;
/**
* Brings the current `textInput` into focus.
@@ -1179,7 +1223,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
/**
* Returns `true` if the current `textInput` is in focus.
**/
- isFocused(): void;
+ isFocused(): boolean;
/**
* Blurs the current `textInput`.
@@ -1200,7 +1244,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Emitted whenever the document is changed.
* @param e Contains a single property, `data`, which has the delta of changes
**/
- onDocumentChange(e: any): void;
+export function onDocumentChange(e: any): void;
/**
* Emitted when the selection changes.
@@ -1226,19 +1270,19 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Called whenever a text "paste" happens.
* @param text The pasted text
**/
- onPaste(text: string): void;
+export function onPaste(text: string): void;
/**
* Inserts `text` into wherever the cursor is pointing.
* @param text The new text to add
**/
- insert(text: string): void;
+export function insert(text: string): void;
/**
* Pass in `true` to enable overwrites in your session, or `false` to disable. If overwrites is enabled, any text you enter will type over any text after it. If the value of `overwrite` changes, this function also emites the `changeOverwrite` event.
* @param overwrite Defines wheter or not to set overwrites
**/
- setOverwrite(overwrite: boolean): void;
+export function setOverwrite(overwrite: boolean): void;
/**
* Returns `true` if overwrites are enabled; `false` otherwise.
@@ -1254,7 +1298,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Sets how fast the mouse scrolling should do.
* @param speed A value indicating the new speed (in milliseconds)
**/
- setScrollSpeed(speed: number): void;
+export function setScrollSpeed(speed: number): void;
/**
* Returns the value indicating how fast the mouse scroll speed is (in milliseconds).
@@ -1265,7 +1309,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Sets the delay (in milliseconds) of the mouse drag.
* @param dragDelay A value indicating the new delay
**/
- setDragDelay(dragDelay: number): void;
+export function setDragDelay(dragDelay: number): void;
/**
* Returns the current mouse drag delay.
@@ -1279,7 +1323,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* This function also emits the `'changeSelectionStyle'` event.
* @param style The new selection style
**/
- setSelectionStyle(style: string): void;
+export function setSelectionStyle(style: string): void;
/**
* Returns the current selection style.
@@ -1290,7 +1334,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Determines whether or not the current line should be highlighted.
* @param shouldHighlight Set to `true` to highlight the current line
**/
- setHighlightActiveLine(shouldHighlight: boolean): void;
+export function setHighlightActiveLine(shouldHighlight: boolean): void;
/**
* Returns `true` if current lines are always highlighted.
@@ -1301,7 +1345,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Determines if the currently selected word should be highlighted.
* @param shouldHighlight Set to `true` to highlight the currently selected word
**/
- setHighlightSelectedWord(shouldHighlight: boolean): void;
+export function setHighlightSelectedWord(shouldHighlight: boolean): void;
/**
* Returns `true` if currently highlighted words are to be highlighted.
@@ -1312,7 +1356,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* If `showInvisibiles` is set to `true`, invisible characters—like spaces or new lines—are show in the editor.
* @param showInvisibles Specifies whether or not to show invisible characters
**/
- setShowInvisibles(showInvisibles: boolean): void;
+export function setShowInvisibles(showInvisibles: boolean): void;
/**
* Returns `true` if invisible characters are being shown.
@@ -1323,7 +1367,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* If `showPrintMargin` is set to `true`, the print margin is shown in the editor.
* @param showPrintMargin Specifies whether or not to show the print margin
**/
- setShowPrintMargin(showPrintMargin: boolean): void;
+export function setShowPrintMargin(showPrintMargin: boolean): void;
/**
* Returns `true` if the print margin is being shown.
@@ -1334,7 +1378,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Sets the column defining where the print margin should be.
* @param showPrintMargin Specifies the new print margin
**/
- setPrintMarginColumn(showPrintMargin: number): void;
+export function setPrintMarginColumn(showPrintMargin: number): void;
/**
* Returns the column number of where the print margin is.
@@ -1345,7 +1389,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* If `readOnly` is true, then the editor is set to read-only mode, and none of the content can change.
* @param readOnly Specifies whether the editor can be modified or not
**/
- setReadOnly(readOnly: boolean): void;
+export function setReadOnly(readOnly: boolean): void;
/**
* Returns `true` if the editor is set to read-only mode.
@@ -1356,7 +1400,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Specifies whether to use behaviors or not. ["Behaviors" in this case is the auto-pairing of special characters, like quotation marks, parenthesis, or brackets.]{: #BehaviorsDef}
* @param enabled Enables or disables behaviors
**/
- setBehavioursEnabled(enabled: boolean): void;
+export function setBehavioursEnabled(enabled: boolean): void;
/**
* Returns `true` if the behaviors are currently enabled. {:BehaviorsDef}
@@ -1368,7 +1412,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* when such a character is typed in.
* @param enabled Enables or disables wrapping behaviors
**/
- setWrapBehavioursEnabled(enabled: boolean): void;
+export function setWrapBehavioursEnabled(enabled: boolean): void;
/**
* Returns `true` if the wrapping behaviors are currently enabled.
@@ -1379,7 +1423,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Indicates whether the fold widgets are shown or not.
* @param show Specifies whether the fold widgets are shown
**/
- setShowFoldWidgets(show: boolean): void;
+export function setShowFoldWidgets(show: boolean): void;
/**
* Returns `true` if the fold widgets are shown.
@@ -1390,7 +1434,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Removes words of text from the editor. A "word" is defined as a string of characters bookended by whitespace.
* @param dir The direction of the deletion to occur, either "left" or "right"
**/
- remove(dir: string): void;
+export function remove(dir: string): void;
/**
* Removes the word directly to the right of the current selection.
@@ -1445,7 +1489,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
/**
* Outdents the current line.
**/
- blockOutdent(arg?: string): void;
+export function blockOutdent(arg?: string): void;
/**
* Given the currently selected range, this function either comments all the lines, or uncomments all of them.
@@ -1461,7 +1505,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* If the character before the cursor is a number, this functions changes its value by `amount`.
* @param amount The value to change the numeral by (can be negative to decrease value)
**/
- modifyNumber(amount: number): void;
+export function modifyNumber(amount: number): void;
/**
* Removes all the lines in the current selection
@@ -1486,7 +1530,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param fromRange The range of text you want moved within the document
* @param toPosition The location (row and column) where you want to move the text to
**/
- moveText(fromRange: Range, toPosition: any): Range;
+export function moveText(fromRange: Range, toPosition: any): Range;
/**
* Copies all the selected lines up one row.
@@ -1512,13 +1556,13 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Indicates if the row is currently visible on the screen.
* @param row The row to check
**/
- isRowVisible(row: number): boolean;
+export function isRowVisible(row: number): boolean;
/**
* Indicates if the entire row is currently visible on the screen.
* @param row The row to check
**/
- isRowFullyVisible(row: number): boolean;
+export function isRowFullyVisible(row: number): boolean;
/**
* Selects the text from the current position of the document until where a "page down" finishes.
@@ -1562,7 +1606,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param animate If `true` animates scrolling
* @param callback Function to be called when the animation has finished
**/
- scrollToLine(line: number, center: boolean, animate: boolean, callback: Function): void;
+export function scrollToLine(line: number, center: boolean, animate: boolean, callback: Function): void;
/**
* Attempts to center the current selection on the screen.
@@ -1599,13 +1643,13 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param row The new row number
* @param column The new column number
**/
- moveCursorTo(row: number, column?: number, animate?:boolean): void;
+export function moveCursorTo(row: number, column?: number, animate?:boolean): void;
/**
* Moves the cursor to the position indicated by `pos.row` and `pos.column`.
* @param position An object with two properties, row and column
**/
- moveCursorToPosition(position: Position): void;
+export function moveCursorToPosition(position: Position): void;
/**
* Moves the cursor's row and column to the next matching bracket.
@@ -1618,38 +1662,38 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param column A column number to go to
* @param animate If `true` animates scolling
**/
- gotoLine(lineNumber: number, column?: number, animate?: boolean): void;
+export function gotoLine(lineNumber: number, column?: number, animate?: boolean): void;
/**
* Moves the cursor to the specified row and column. Note that this does de-select the current selection.
* @param row The new row number
* @param column The new column number
**/
- navigateTo(row: number, column: number): void;
+export function navigateTo(row: number, column: number): void;
/**
* Moves the cursor up in the document the specified number of times. Note that this does de-select the current selection.
* @param times The number of times to change navigation
**/
- navigateUp(times?: number): void;
+export function navigateUp(times?: number): void;
/**
* Moves the cursor down in the document the specified number of times. Note that this does de-select the current selection.
* @param times The number of times to change navigation
**/
- navigateDown(times?: number): void;
+export function navigateDown(times?: number): void;
/**
* Moves the cursor left in the document the specified number of times. Note that this does de-select the current selection.
* @param times The number of times to change navigation
**/
- navigateLeft(times?: number): void;
+export function navigateLeft(times?: number): void;
/**
* Moves the cursor right in the document the specified number of times. Note that this does de-select the current selection.
* @param times The number of times to change navigation
**/
- navigateRight(times: number): void;
+export function navigateRight(times: number): void;
/**
* Moves the cursor to the start of the current line. Note that this does de-select the current selection.
@@ -1686,14 +1730,14 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param replacement The text to replace with
* @param options The [[Search `Search`]] options to use
**/
- replace(replacement: string, options?: any): void;
+export function replace(replacement: string, options?: any): void;
/**
* Replaces all occurances of `options.needle` with the value in `replacement`.
* @param replacement The text to replace with
* @param options The [[Search `Search`]] options to use
**/
- replaceAll(replacement: string, options?: any): void;
+export function replaceAll(replacement: string, options?: any): void;
/**
* {:Search.getOptions} For more information on `options`, see [[Search `Search`]].
@@ -1706,21 +1750,21 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param options An object defining various search properties
* @param animate If `true` animate scrolling
**/
- find(needle: string, options?: any, animate?: boolean): void;
+export function find(needle: string, options?: any, animate?: boolean): void;
/**
* Performs another search for `needle` in the document. For more information on `options`, see [[Search `Search`]].
* @param options search options
* @param animate If `true` animate scrolling
**/
- findNext(options?: any, animate?: boolean): void;
+export function findNext(options?: any, animate?: boolean): void;
/**
* Performs a search for `needle` backwards. For more information on `options`, see [[Search `Search`]].
* @param options search options
* @param animate If `true` animate scrolling
**/
- findPrevious(options?: any, animate?: boolean): void;
+export function findPrevious(options?: any, animate?: boolean): void;
/**
* {:UndoManager.undo}
@@ -1745,7 +1789,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param renderer Associated `VirtualRenderer` that draws everything
* @param session The `EditSession` to refer to
**/
- new(renderer: VirtualRenderer, session?: IEditSession): Editor;
+export function new(renderer: VirtualRenderer, session?: IEditSession): Editor;
}
interface EditorChangeEvent {
@@ -1761,7 +1805,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
export interface PlaceHolder {
- on(event: string, fn: (e: any) => any): void;
+export function on(event: string, fn: (e: any) => any): void;
/**
* PlaceHolder.setup()
@@ -1826,15 +1870,15 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
export interface IRangeList {
ranges: Range[];
- pointIndex(pos: Position, startIndex?: number): void;
+export function pointIndex(pos: Position, startIndex?: number): void;
- addList(ranges: Range[]): void;
+export function addList(ranges: Range[]): void;
- add(ranges: Range): void;
+export function add(ranges: Range): void;
merge(): Range[];
- substractPoint(pos: Position): void;
+export function substractPoint(pos: Position): void;
}
export var RangeList: {
new (): IRangeList;
@@ -1867,7 +1911,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Returns `true` if and only if the starting row and column, and ending row and column, are equivalent to those given by `range`.
* @param range A range to check against
**/
- isEqual(range: Range): void;
+export function isEqual(range: Range): void;
/**
* Returns a string containing the range's row and column information, given like this:
@@ -1886,122 +1930,122 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param row A row to check for
* @param column A column to check for
**/
- contains(row: number, column: number): boolean;
+export function contains(row: number, column: number): boolean;
/**
* Compares `this` range (A) with another range (B).
* @param range A range to compare with
**/
- compareRange(range: Range): number;
+export function compareRange(range: Range): number;
/**
* Checks the row and column points of `p` with the row and column points of the calling range.
* @param p A point to compare with
**/
- comparePoint(p: Range): number;
+export function comparePoint(p: Range): number;
/**
* Checks the start and end points of `range` and compares them to the calling range. Returns `true` if the `range` is contained within the caller's range.
* @param range A range to compare with
**/
- containsRange(range: Range): boolean;
+export function containsRange(range: Range): boolean;
/**
* Returns `true` if passed in `range` intersects with the one calling this method.
* @param range A range to compare with
**/
- intersects(range: Range): boolean;
+export function intersects(range: Range): boolean;
/**
* Returns `true` if the caller's ending row point is the same as `row`, and if the caller's ending column is the same as `column`.
* @param row A row point to compare with
* @param column A column point to compare with
**/
- isEnd(row: number, column: number): boolean;
+export function isEnd(row: number, column: number): boolean;
/**
* Returns `true` if the caller's starting row point is the same as `row`, and if the caller's starting column is the same as `column`.
* @param row A row point to compare with
* @param column A column point to compare with
**/
- isStart(row: number, column: number): boolean;
+export function isStart(row: number, column: number): boolean;
/**
* Sets the starting row and column for the range.
* @param row A row point to set
* @param column A column point to set
**/
- setStart(row: number, column: number): void;
+export function setStart(row: number, column: number): void;
/**
* Sets the starting row and column for the range.
* @param row A row point to set
* @param column A column point to set
**/
- setEnd(row: number, column: number): void;
+export function setEnd(row: number, column: number): void;
/**
* Returns `true` if the `row` and `column` are within the given range.
* @param row A row point to compare with
* @param column A column point to compare with
**/
- inside(row: number, column: number): boolean;
+export function inside(row: number, column: number): boolean;
/**
* Returns `true` if the `row` and `column` are within the given range's starting points.
* @param row A row point to compare with
* @param column A column point to compare with
**/
- insideStart(row: number, column: number): boolean;
+export function insideStart(row: number, column: number): boolean;
/**
* Returns `true` if the `row` and `column` are within the given range's ending points.
* @param row A row point to compare with
* @param column A column point to compare with
**/
- insideEnd(row: number, column: number): boolean;
+export function insideEnd(row: number, column: number): boolean;
/**
* Checks the row and column points with the row and column points of the calling range.
* @param row A row point to compare with
* @param column A column point to compare with
**/
- compare(row: number, column: number): number;
+export function compare(row: number, column: number): number;
/**
* Checks the row and column points with the row and column points of the calling range.
* @param row A row point to compare with
* @param column A column point to compare with
**/
- compareStart(row: number, column: number): number;
+export function compareStart(row: number, column: number): number;
/**
* Checks the row and column points with the row and column points of the calling range.
* @param row A row point to compare with
* @param column A column point to compare with
**/
- compareEnd(row: number, column: number): number;
+export function compareEnd(row: number, column: number): number;
/**
* Checks the row and column points with the row and column points of the calling range.
* @param row A row point to compare with
* @param column A column point to compare with
**/
- compareInside(row: number, column: number): number;
+export function compareInside(row: number, column: number): number;
/**
* Returns the part of the current `Range` that occurs within the boundaries of `firstRow` and `lastRow` as a new `Range` object.
* @param firstRow The starting row
* @param lastRow The ending row
**/
- clipRows(firstRow: number, lastRow: number): Range;
+export function clipRows(firstRow: number, lastRow: number): Range;
/**
* Changes the row and column points for the calling range for both the starting and ending points.
* @param row A new row to extend to
* @param column A new column to extend to
**/
- extend(row: number, column: number): Range;
+export function extend(row: number, column: number): Range;
/**
* Returns `true` if the range spans across multiple lines.
@@ -2022,14 +2066,14 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Given the current `Range`, this function converts those starting and ending points into screen positions, and then returns a new `Range` object.
* @param session The `EditSession` to retrieve coordinates from
**/
- toScreenRange(session: IEditSession): Range;
+export function toScreenRange(session: IEditSession): Range;
/**
* Creates and returns a new `Range` based on the row and column of the given parameters.
* @param start A starting point to use
* @param end An ending point to use
**/
- fromPoints(start: Range, end: Range): Range;
+export function fromPoints(start: Range, end: Range): Range;
}
/**
@@ -2040,8 +2084,8 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param endColumn The ending column
**/
var Range: {
- fromPoints(pos1: Position, pos2: Position): Range;
- new(startRow: number, startColumn: number, endRow: number, endColumn: number): Range;
+export function fromPoints(pos1: Position, pos2: Position): Range;
+export function new(startRow: number, startColumn: number, endRow: number, endColumn: number): Range;
}
////////////////
@@ -2066,7 +2110,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Emitted when the scroll bar, well, scrolls.
* @param e Contains one property, `"data"`, which indicates the current scroll top position
**/
- onScroll(e: any): void;
+export function onScroll(e: any): void;
/**
* Returns the width of the scroll bar.
@@ -2077,26 +2121,26 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Sets the height of the scroll bar, in pixels.
* @param height The new height
**/
- setHeight(height: number): void;
+export function setHeight(height: number): void;
/**
* Sets the inner height of the scroll bar, in pixels.
* @param height The new inner height
**/
- setInnerHeight(height: number): void;
+export function setInnerHeight(height: number): void;
/**
* Sets the scroll top of the scroll bar.
* @param scrollTop The new scroll top
**/
- setScrollTop(scrollTop: number): void;
+export function setScrollTop(scrollTop: number): void;
}
var ScrollBar: {
/**
* Creates a new `ScrollBar`. `parent` is the owner of the scroll bar.
* @param parent A DOM element
**/
- new(parent: HTMLElement): ScrollBar;
+export function new(parent: HTMLElement): ScrollBar;
}
////////////////
@@ -2112,7 +2156,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Sets the search options via the `options` parameter.
* @param options An object containing all the new search properties
**/
- set(options: any): Search;
+export function set(options: any): Search;
/**
* [Returns an object containing all the search options.]{: #Search.getOptions}
@@ -2123,19 +2167,19 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Sets the search options via the `options` parameter.
* @param An object containing all the search propertie
**/
- setOptions(An: any): void;
+export function setOptions(An: any): void;
/**
* Searches for `options.needle`. If found, this method returns the [[Range `Range`]] where the text first occurs. If `options.backwards` is `true`, the search goes backwards in the session.
* @param session The session to search with
**/
- find(session: IEditSession): Range;
+export function find(session: IEditSession): Range;
/**
* Searches for all occurances `options.needle`. If found, this method returns an array of [[Range `Range`s]] where the text first occurs. If `options.backwards` is `true`, the search goes backwards in the session.
* @param session The session to search with
**/
- findAll(session: IEditSession): Range[];
+export function findAll(session: IEditSession): Range[];
/**
* Searches for `options.needle` in `input`, and, if found, replaces it with `replacement`.
@@ -2144,7 +2188,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* + (String): If `options.regExp` is `true`, this function returns `input` with the replacement already made. Otherwise, this function just returns `replacement`.
* If `options.needle` was not found, this function returns `null`.
**/
- replace(input: string, replacement: string): string;
+export function replace(input: string, replacement: string): string;
}
var Search: {
/**
@@ -2172,29 +2216,29 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
**/
export interface Selection {
- on(ev: string, callback: Function): void;
+export function on(ev: string, callback: Function): void;
- addEventListener(ev: string, callback: Function): void;
+export function addEventListener(ev: string, callback: Function): void;
- off(ev: string, callback: Function): void;
+export function off(ev: string, callback: Function): void;
- removeListener(ev: string, callback: Function): void;
+export function removeListener(ev: string, callback: Function): void;
- removeEventListener(ev: string, callback: Function): void;
+export function removeEventListener(ev: string, callback: Function): void;
moveCursorWordLeft(): void;
moveCursorWordRight(): void;
- fromOrientedRange(range: Range): void;
+export function fromOrientedRange(range: Range): void;
- setSelectionRange(match: any): void;
+export function setSelectionRange(match: any): void;
getAllRanges(): Range[];
- on(event: string, fn: (e: any) => any): void;
+export function on(event: string, fn: (e: any) => any): void;
- addRange(range: Range): void;
+export function addRange(range: Range): void;
/**
* Returns `true` if the selection is empty.
@@ -2216,7 +2260,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param row The new row
* @param column The new column
**/
- setSelectionAnchor(row: number, column: number): void;
+export function setSelectionAnchor(row: number, column: number): void;
/**
* Returns an object containing the `row` and `column` of the calling selection anchor.
@@ -2232,7 +2276,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Shifts the selection up (or down, if [[Selection.isBackwards `isBackwards()`]] is true) the given number of columns.
* @param columns The number of columns to shift by
**/
- shiftSelection(columns: number): void;
+export function shiftSelection(columns: number): void;
/**
* Returns `true` if the selection is going backwards in the document.
@@ -2259,20 +2303,20 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param range The range of text to select
* @param reverse Indicates if the range should go backwards (`true`) or not
**/
- setRange(range: Range, reverse: boolean): void;
+export function setRange(range: Range, reverse: boolean): void;
/**
* Moves the selection cursor to the indicated row and column.
* @param row The row to select to
* @param column The column to select to
**/
- selectTo(row: number, column: number): void;
+export function selectTo(row: number, column: number): void;
/**
* Moves the selection cursor to the row and column indicated by `pos`.
* @param pos An object containing the row and column
**/
- selectToPosition(pos: any): void;
+export function selectToPosition(pos: any): void;
/**
* Moves the selection up one row.
@@ -2399,13 +2443,13 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param rows The number of rows to move by
* @param chars The number of characters to move by
**/
- moveCursorBy(rows: number, chars: number): void;
+export function moveCursorBy(rows: number, chars: number): void;
/**
* Moves the selection to the position indicated by its `row` and `column`.
* @param position The position to move to
**/
- moveCursorToPosition(position: any): void;
+export function moveCursorToPosition(position: any): void;
/**
* Moves the cursor to the row and column provided. [If `preventUpdateDesiredColumn` is `true`, then the cursor stays in the same column position as its original point.]{: #preventUpdateBoolDesc}
@@ -2413,7 +2457,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param column The column to move to
* @param keepDesiredColumn [If `true`, the cursor move does not respect the previous column]{: #preventUpdateBool}
**/
- moveCursorTo(row: number, column: number, keepDesiredColumn?: boolean): void;
+export function moveCursorTo(row: number, column: number, keepDesiredColumn?: boolean): void;
/**
* Moves the cursor to the screen position indicated by row and column. {:preventUpdateBoolDesc}
@@ -2421,14 +2465,14 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param column The column to move to
* @param keepDesiredColumn {:preventUpdateBool}
**/
- moveCursorToScreen(row: number, column: number, keepDesiredColumn: boolean): void;
+export function moveCursorToScreen(row: number, column: number, keepDesiredColumn: boolean): void;
}
var Selection: {
/**
* Creates a new `Selection` object.
* @param session The session to use
**/
- new(session: IEditSession): Selection;
+export function new(session: IEditSession): Selection;
}
////////////////
@@ -2446,7 +2490,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Returns the editor identified by the index `idx`.
* @param idx The index of the editor you want
**/
- getEditor(idx: number): void;
+export function getEditor(idx: number): void;
/**
* Returns the current editor.
@@ -2467,33 +2511,33 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Sets a theme for each of the available editors.
* @param theme The name of the theme to set
**/
- setTheme(theme: string): void;
+export function setTheme(theme: string): void;
/**
* Sets the keyboard handler for the editor.
* @param keybinding
**/
- setKeyboardHandler(keybinding: string): void;
+export function setKeyboardHandler(keybinding: string): void;
/**
* Executes `callback` on all of the available editors.
* @param callback A callback function to execute
* @param scope The default scope for the callback
**/
- forEach(callback: Function, scope: string): void;
+export function forEach(callback: Function, scope: string): void;
/**
* Sets the font size, in pixels, for all the available editors.
* @param size The new font size
**/
- setFontSize(size: number): void;
+export function setFontSize(size: number): void;
/**
* Sets a new [[EditSession `EditSession`]] for the indicated editor.
* @param session The new edit session
* @param idx The editor's index you're interested in
**/
- setSession(session: IEditSession, idx: number): void;
+export function setSession(session: IEditSession, idx: number): void;
/**
* Returns the orientation.
@@ -2504,7 +2548,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Sets the orientation.
* @param orientation The new orientation value
**/
- setOrientation(orientation: number): void;
+export function setOrientation(orientation: number): void;
/**
* Resizes the editor.
@@ -2556,7 +2600,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param initialRow The row to start the tokenizing at
* @param initialColumn The column to start the tokenizing at
**/
- new(session: IEditSession, initialRow: number, initialColumn: number): TokenIterator;
+export function new(session: IEditSession, initialRow: number, initialColumn: number): TokenIterator;
}
//////////////////
@@ -2580,7 +2624,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param rules The highlighting rules
* @param flag Any additional regular expression flags to pass (like "i" for case insensitive)
**/
- new(rules: any, flag: string): Tokenizer;
+export function new(rules: any, flag: string): Tokenizer;
}
//////////////////
@@ -2598,19 +2642,19 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* - `args[1]` is the document to associate with
* @param options Contains additional properties
**/
- execute(options: any): void;
+export function execute(options: any): void;
/**
* [Perform an undo operation on the document, reverting the last change.]{: #UndoManager.undo}
* @param dontSelect {:dontSelect}
**/
- undo(dontSelect?: boolean): Range;
+export function undo(dontSelect?: boolean): Range;
/**
* [Perform a redo operation on the document, reimplementing the last change.]{: #UndoManager.redo}
* @param dontSelect {:dontSelect}
**/
- redo(dontSelect: boolean): void;
+export function redo(dontSelect: boolean): void;
/**
* Destroys the stack of undo and redo redo operations.
@@ -2652,7 +2696,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
/**
* The class that is responsible for drawing everything you see on the screen!
**/
- export interface VirtualRenderer {
+ export interface VirtualRenderer extends OptionProvider {
scroller: any;
@@ -2660,21 +2704,21 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
lineHeight: number;
- setScrollMargin(top:number, bottom:number, left: number, right: number): void;
+export function setScrollMargin(top:number, bottom:number, left: number, right: number): void;
- screenToTextCoordinates(left: number, top: number): void;
+export function screenToTextCoordinates(left: number, top: number): void;
/**
* Associates the renderer with an [[EditSession `EditSession`]].
**/
- setSession(session: IEditSession): void;
+export function setSession(session: IEditSession): void;
/**
* Triggers a partial update of the text, from the range given by the two parameters.
* @param firstRow The first row to update
* @param lastRow The last row to update
**/
- updateLines(firstRow: number, lastRow: number): void;
+export function updateLines(firstRow: number, lastRow: number): void;
/**
* Triggers a full update of the text, for all the rows.
@@ -2685,7 +2729,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Triggers a full update of all the layers, for all the rows.
* @param force If `true`, forces the changes through
**/
- updateFull(force: boolean): void;
+export function updateFull(force: boolean): void;
/**
* Updates the font size.
@@ -2699,7 +2743,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param width The width of the editor in pixels
* @param height The hiehgt of the editor, in pixels
**/
- onResize(force: boolean, gutterWidth: number, width: number, height: number): void;
+export function onResize(force: boolean, gutterWidth: number, width: number, height: number): void;
/**
* Adjusts the wrap limit, which is the number of characters that can fit within the width of the edit area on screen.
@@ -2710,7 +2754,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Identifies whether you want to have an animated scroll or not.
* @param shouldAnimate Set to `true` to show animated scrolls
**/
- setAnimatedScroll(shouldAnimate: boolean): void;
+export function setAnimatedScroll(shouldAnimate: boolean): void;
/**
* Returns whether an animated scroll happens or not.
@@ -2721,7 +2765,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Identifies whether you want to show invisible characters or not.
* @param showInvisibles Set to `true` to show invisibles
**/
- setShowInvisibles(showInvisibles: boolean): void;
+export function setShowInvisibles(showInvisibles: boolean): void;
/**
* Returns whether invisible characters are being shown or not.
@@ -2732,7 +2776,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Identifies whether you want to show the print margin or not.
* @param showPrintMargin Set to `true` to show the print margin
**/
- setShowPrintMargin(showPrintMargin: boolean): void;
+export function setShowPrintMargin(showPrintMargin: boolean): void;
/**
* Returns whether the print margin is being shown or not.
@@ -2743,7 +2787,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Identifies whether you want to show the print margin column or not.
* @param showPrintMargin Set to `true` to show the print margin column
**/
- setPrintMarginColumn(showPrintMargin: boolean): void;
+export function setPrintMarginColumn(showPrintMargin: boolean): void;
/**
* Returns whether the print margin column is being shown or not.
@@ -2759,7 +2803,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Identifies whether you want to show the gutter or not.
* @param show Set to `true` to show the gutter
**/
- setShowGutter(show: boolean): void;
+export function setShowGutter(show: boolean): void;
/**
* Returns the root element containing this renderer.
@@ -2800,7 +2844,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Sets the padding for all the layers.
* @param padding A new padding value (in pixels)
**/
- setPadding(padding: number): void;
+export function setPadding(padding: number): void;
/**
* Returns whether the horizontal scrollbar is set to be always visible.
@@ -2811,7 +2855,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Identifies whether you want to show the horizontal scrollbar or not.
* @param alwaysVisible Set to `true` to make the horizontal scroll bar visible
**/
- setHScrollBarAlwaysVisible(alwaysVisible: boolean): void;
+export function setHScrollBarAlwaysVisible(alwaysVisible: boolean): void;
/**
* Schedules an update to all the front markers in the document.
@@ -2842,7 +2886,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Sets annotations for the gutter.
* @param annotations An array containing annotations
**/
- setAnnotations(annotations: any[]): void;
+export function setAnnotations(annotations: any[]): void;
/**
* Updates the cursor icon.
@@ -2888,7 +2932,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Gracefully scrolls from the top of the editor to the row indicated.
* @param row A row id
**/
- scrollToRow(row: number): void;
+export function scrollToRow(row: number): void;
/**
* Gracefully scrolls the editor to the row indicated.
@@ -2897,40 +2941,40 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param animate If `true` animates scrolling
* @param callback Function to be called after the animation has finished
**/
- scrollToLine(line: number, center: boolean, animate: boolean, callback: Function): void;
+export function scrollToLine(line: number, center: boolean, animate: boolean, callback: Function): void;
/**
* Scrolls the editor to the y pixel indicated.
* @param scrollTop The position to scroll to
**/
- scrollToY(scrollTop: number): number;
+export function scrollToY(scrollTop: number): number;
/**
* Scrolls the editor across the x-axis to the pixel indicated.
* @param scrollLeft The position to scroll to
**/
- scrollToX(scrollLeft: number): number;
+export function scrollToX(scrollLeft: number): number;
/**
* Scrolls the editor across both x- and y-axes.
* @param deltaX The x value to scroll by
* @param deltaY The y value to scroll by
**/
- scrollBy(deltaX: number, deltaY: number): void;
+export function scrollBy(deltaX: number, deltaY: number): void;
/**
* Returns `true` if you can still scroll by either parameter; in other words, you haven't reached the end of the file or line.
* @param deltaX The x value to scroll by
* @param deltaY The y value to scroll by
**/
- isScrollableBy(deltaX: number, deltaY: number): boolean;
+export function isScrollableBy(deltaX: number, deltaY: number): boolean;
/**
* Returns an object containing the `pageX` and `pageY` coordinates of the document position.
* @param row The document row position
* @param column The document column position
**/
- textToScreenCoordinates(row: number, column: number): any;
+export function textToScreenCoordinates(row: number, column: number): any;
/**
* Focuses the current container.
@@ -2946,13 +2990,13 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* undefined
* @param position
**/
- showComposition(position: number): void;
+export function showComposition(position: number): void;
/**
* Sets the inner text of the current composition to `text`.
* @param text A string of text to use
**/
- setCompositionText(text: string): void;
+export function setCompositionText(text: string): void;
/**
* Hides the current composition.
@@ -2963,7 +3007,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* [Sets a new theme for the editor. `theme` should exist, and be a directory path, like `ace/theme/textmate`.]{: #VirtualRenderer.setTheme}
* @param theme The path to a theme
**/
- setTheme(theme: string): void;
+export function setTheme(theme: string): void;
/**
* [Returns the path of the current theme.]{: #VirtualRenderer.getTheme}
@@ -2974,13 +3018,13 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* [Adds a new class, `style`, to the editor.]{: #VirtualRenderer.setStyle}
* @param style A class name
**/
- setStyle(style: string): void;
+export function setStyle(style: string): void;
/**
* [Removes the class `style` from the editor.]{: #VirtualRenderer.unsetStyle}
* @param style A class name
**/
- unsetStyle(style: string): void;
+export function unsetStyle(style: string): void;
/**
* Destroys the text and cursor layers for this renderer.
@@ -2994,8 +3038,39 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param container The root element of the editor
* @param theme The starting theme
**/
- new(container: HTMLElement, theme?: string): VirtualRenderer;
+export function new(container: HTMLElement, theme?: string): VirtualRenderer;
}
+
+ export interface Completer {
+ /**
+ * Provides possible completion results asynchronously using the given callback.
+ * @param editor The editor to associate with
+ * @param session The `EditSession` to refer to
+ * @param pos An object containing the row and column
+ * @param prefix The prefixing string before the current position
+ * @param callback Function to provide the results or error
+ */
+ getCompletions: (editor: Editor, session: IEditSession, pos: Position, prefix: string, callback: CompletionCallback) => void;
+
+ /**
+ * Provides tooltip information about a completion result.
+ * @param item The completion result
+ */
+ getDocTooltip?: (item: Completion) => void;
+ }
+
+ export interface Completion {
+ value: string;
+ meta: string;
+ type?: string;
+ caption?: string;
+ snippet?: any;
+ score?: number;
+ exactMatch?: number;
+ docHTML?: string;
+ }
+
+ export type CompletionCallback = (error: Error, results: Completion[]) => void;
}
export = AceAjax;
diff --git a/index.js b/index.js
index 5999cf67..82fdcb43 100644
--- a/index.js
+++ b/index.js
@@ -948,14 +948,123 @@ ace.define("ace/lib/fixoldbrowsers",["require","exports","module","ace/lib/regex
acequire("./regexp");
acequire("./es5-shim");
+if (typeof Element != "undefined" && !Element.prototype.remove) {
+ Object.defineProperty(Element.prototype, "remove", {
+ enumerable: false,
+ writable: true,
+ configurable: true,
+ value: function() { this.parentNode && this.parentNode.removeChild(this); }
+ });
+}
+
+
+});
+
+ace.define("ace/lib/useragent",["require","exports","module"], function(acequire, exports, module) {
+"use strict";
+exports.OS = {
+ LINUX: "LINUX",
+ MAC: "MAC",
+ WINDOWS: "WINDOWS"
+};
+exports.getOS = function() {
+ if (exports.isMac) {
+ return exports.OS.MAC;
+ } else if (exports.isLinux) {
+ return exports.OS.LINUX;
+ } else {
+ return exports.OS.WINDOWS;
+ }
+};
+if (typeof navigator != "object")
+ return;
+
+var os = (navigator.platform.match(/mac|win|linux/i) || ["other"])[0].toLowerCase();
+var ua = navigator.userAgent;
+exports.isWin = (os == "win");
+exports.isMac = (os == "mac");
+exports.isLinux = (os == "linux");
+exports.isIE =
+ (navigator.appName == "Microsoft Internet Explorer" || navigator.appName.indexOf("MSAppHost") >= 0)
+ ? parseFloat((ua.match(/(?:MSIE |Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1])
+ : parseFloat((ua.match(/(?:Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]); // for ie
+
+exports.isOldIE = exports.isIE && exports.isIE < 9;
+exports.isGecko = exports.isMozilla = ua.match(/ Gecko\/\d+/);
+exports.isOpera = window.opera && Object.prototype.toString.call(window.opera) == "[object Opera]";
+exports.isWebKit = parseFloat(ua.split("WebKit/")[1]) || undefined;
+
+exports.isChrome = parseFloat(ua.split(" Chrome/")[1]) || undefined;
+
+exports.isEdge = parseFloat(ua.split(" Edge/")[1]) || undefined;
+
+exports.isAIR = ua.indexOf("AdobeAIR") >= 0;
+
+exports.isIPad = ua.indexOf("iPad") >= 0;
+
+exports.isAndroid = ua.indexOf("Android") >= 0;
+
+exports.isChromeOS = ua.indexOf(" CrOS ") >= 0;
+
+exports.isIOS = /iPad|iPhone|iPod/.test(ua) && !window.MSStream;
+
+if (exports.isIOS) exports.isMac = true;
+
+exports.isMobile = exports.isIPad || exports.isAndroid;
});
-ace.define("ace/lib/dom",["require","exports","module"], function(acequire, exports, module) {
+ace.define("ace/lib/dom",["require","exports","module","ace/lib/useragent"], function(acequire, exports, module) {
"use strict";
+var useragent = acequire("./useragent");
var XHTML_NS = "http://www.w3.org/1999/xhtml";
+exports.buildDom = function buildDom(arr, parent, refs) {
+ if (typeof arr == "string" && arr) {
+ var txt = document.createTextNode(arr);
+ if (parent)
+ parent.appendChild(txt);
+ return txt;
+ }
+
+ if (!Array.isArray(arr))
+ return arr;
+ if (typeof arr[0] != "string" || !arr[0]) {
+ var els = [];
+ for (var i = 0; i < arr.length; i++) {
+ var ch = buildDom(arr[i], parent, refs);
+ ch && els.push(ch);
+ }
+ return els;
+ }
+
+ var el = document.createElement(arr[0]);
+ var options = arr[1];
+ var childIndex = 1;
+ if (options && typeof options == "object" && !Array.isArray(options))
+ childIndex = 2;
+ for (var i = childIndex; i < arr.length; i++)
+ buildDom(arr[i], el, refs);
+ if (childIndex == 2) {
+ Object.keys(options).forEach(function(n) {
+ var val = options[n];
+ if (n === "class") {
+ el.className = Array.isArray(val) ? val.join(" ") : val;
+ } else if (typeof val == "function" || n == "value") {
+ el[n] = val;
+ } else if (n === "ref") {
+ if (refs) refs[val] = el;
+ } else if (val != null) {
+ el.setAttribute(n, val);
+ }
+ });
+ }
+ if (parent)
+ parent.appendChild(el);
+ return el;
+};
+
exports.getDocumentHead = function(doc) {
if (!doc)
doc = document;
@@ -968,6 +1077,20 @@ exports.createElement = function(tag, ns) {
document.createElement(tag);
};
+exports.removeChildren = function(element) {
+ element.innerHTML = "";
+};
+
+exports.createTextNode = function(textContent, element) {
+ var doc = element ? element.ownerDocument : document;
+ return doc.createTextNode(textContent);
+};
+
+exports.createFragment = function(element) {
+ var doc = element ? element.ownerDocument : document;
+ return doc.createDocumentFragment();
+};
+
exports.hasCssClass = function(el, name) {
var classes = (el.className + "").split(/\s+/g);
return classes.indexOf(name) !== -1;
@@ -1016,71 +1139,43 @@ exports.setCssClass = function(node, className, include) {
exports.hasCssString = function(id, doc) {
var index = 0, sheets;
doc = doc || document;
-
- if (doc.createStyleSheet && (sheets = doc.styleSheets)) {
- while (index < sheets.length)
- if (sheets[index++].owningElement.id === id) return true;
- } else if ((sheets = doc.getElementsByTagName("style"))) {
+ if ((sheets = doc.querySelectorAll("style"))) {
while (index < sheets.length)
- if (sheets[index++].id === id) return true;
+ if (sheets[index++].id === id)
+ return true;
}
-
- return false;
};
-exports.importCssString = function importCssString(cssText, id, doc) {
- doc = doc || document;
- if (id && exports.hasCssString(id, doc))
- return null;
+exports.importCssString = function importCssString(cssText, id, target) {
+ var container = target;
+ if (!target || !target.getRootNode) {
+ container = document;
+ } else {
+ container = target.getRootNode();
+ if (!container || container == target)
+ container = document;
+ }
- var style;
+ var doc = container.ownerDocument || container;
+ if (id && exports.hasCssString(id, container))
+ return null;
if (id)
cssText += "\n/*# sourceURL=ace/css/" + id + " */";
- if (doc.createStyleSheet) {
- style = doc.createStyleSheet();
- style.cssText = cssText;
- if (id)
- style.owningElement.id = id;
- } else {
- style = exports.createElement("style");
- style.appendChild(doc.createTextNode(cssText));
- if (id)
- style.id = id;
+ var style = exports.createElement("style");
+ style.appendChild(doc.createTextNode(cssText));
+ if (id)
+ style.id = id;
- exports.getDocumentHead(doc).appendChild(style);
- }
+ if (container == doc)
+ container = exports.getDocumentHead(doc);
+ container.insertBefore(style, container.firstChild);
};
exports.importCssStylsheet = function(uri, doc) {
- if (doc.createStyleSheet) {
- doc.createStyleSheet(uri);
- } else {
- var link = exports.createElement('link');
- link.rel = 'stylesheet';
- link.href = uri;
-
- exports.getDocumentHead(doc).appendChild(link);
- }
-};
-
-exports.getInnerWidth = function(element) {
- return (
- parseInt(exports.computedStyle(element, "paddingLeft"), 10) +
- parseInt(exports.computedStyle(element, "paddingRight"), 10) +
- element.clientWidth
- );
-};
-
-exports.getInnerHeight = function(element) {
- return (
- parseInt(exports.computedStyle(element, "paddingTop"), 10) +
- parseInt(exports.computedStyle(element, "paddingBottom"), 10) +
- element.clientHeight
- );
+ exports.buildDom(["link", {rel: "stylesheet", href: uri}], exports.getDocumentHead(doc));
};
-
exports.scrollbarWidth = function(document) {
var inner = exports.createElement("ace_inner");
inner.style.width = "100%";
@@ -1120,70 +1215,44 @@ exports.scrollbarWidth = function(document) {
if (typeof document == "undefined") {
exports.importCssString = function() {};
- return;
}
-if (window.pageYOffset !== undefined) {
- exports.getPageScrollTop = function() {
- return window.pageYOffset;
- };
-
- exports.getPageScrollLeft = function() {
- return window.pageXOffset;
- };
-}
-else {
- exports.getPageScrollTop = function() {
- return document.body.scrollTop;
- };
-
- exports.getPageScrollLeft = function() {
- return document.body.scrollLeft;
- };
-}
-
-if (window.getComputedStyle)
- exports.computedStyle = function(element, style) {
- if (style)
- return (window.getComputedStyle(element, "") || {})[style] || "";
- return window.getComputedStyle(element, "") || {};
- };
-else
- exports.computedStyle = function(element, style) {
- if (style)
- return element.currentStyle[style];
- return element.currentStyle;
- };
-exports.setInnerHtml = function(el, innerHtml) {
- var element = el.cloneNode(false);//document.createElement("div");
- element.innerHTML = innerHtml;
- el.parentNode.replaceChild(element, el);
- return element;
+exports.computedStyle = function(element, style) {
+ return window.getComputedStyle(element, "") || {};
};
-if ("textContent" in document.documentElement) {
- exports.setInnerText = function(el, innerText) {
- el.textContent = innerText;
- };
+exports.setStyle = function(styles, property, value) {
+ if (styles[property] !== value) {
+ styles[property] = value;
+ }
+};
- exports.getInnerText = function(el) {
- return el.textContent;
- };
+exports.HAS_CSS_ANIMATION = false;
+exports.HAS_CSS_TRANSFORMS = false;
+exports.HI_DPI = useragent.isWin
+ ? typeof window !== "undefined" && window.devicePixelRatio >= 1.5
+ : true;
+
+if (typeof document !== "undefined") {
+ var div = document.createElement("div");
+ if (exports.HI_DPI && div.style.transform !== undefined)
+ exports.HAS_CSS_TRANSFORMS = true;
+ if (!useragent.isEdge && typeof div.style.animationName !== "undefined")
+ exports.HAS_CSS_ANIMATION = true;
+ div = null;
}
-else {
- exports.setInnerText = function(el, innerText) {
- el.innerText = innerText;
- };
- exports.getInnerText = function(el) {
- return el.innerText;
+if (exports.HAS_CSS_TRANSFORMS) {
+ exports.translate = function(element, tx, ty) {
+ element.style.transform = "translate(" + Math.round(tx) + "px, " + Math.round(ty) +"px)";
+ };
+} else {
+ exports.translate = function(element, tx, ty) {
+ element.style.top = Math.round(ty) + "px";
+ element.style.left = Math.round(tx) + "px";
};
}
-exports.getParentWindow = function(document) {
- return document.defaultView || document.parentWindow;
-};
-
});
ace.define("ace/lib/oop",["require","exports","module"], function(acequire, exports, module) {
@@ -1214,11 +1283,9 @@ exports.implement = function(proto, mixin) {
});
-ace.define("ace/lib/keys",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/oop"], function(acequire, exports, module) {
+ace.define("ace/lib/keys",["require","exports","module","ace/lib/oop"], function(acequire, exports, module) {
"use strict";
-acequire("./fixoldbrowsers");
-
var oop = acequire("./oop");
var Keys = (function() {
var ret = {
@@ -1329,55 +1396,6 @@ exports.keyCodeToString = function(keyCode) {
});
-ace.define("ace/lib/useragent",["require","exports","module"], function(acequire, exports, module) {
-"use strict";
-exports.OS = {
- LINUX: "LINUX",
- MAC: "MAC",
- WINDOWS: "WINDOWS"
-};
-exports.getOS = function() {
- if (exports.isMac) {
- return exports.OS.MAC;
- } else if (exports.isLinux) {
- return exports.OS.LINUX;
- } else {
- return exports.OS.WINDOWS;
- }
-};
-if (typeof navigator != "object")
- return;
-
-var os = (navigator.platform.match(/mac|win|linux/i) || ["other"])[0].toLowerCase();
-var ua = navigator.userAgent;
-exports.isWin = (os == "win");
-exports.isMac = (os == "mac");
-exports.isLinux = (os == "linux");
-exports.isIE =
- (navigator.appName == "Microsoft Internet Explorer" || navigator.appName.indexOf("MSAppHost") >= 0)
- ? parseFloat((ua.match(/(?:MSIE |Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1])
- : parseFloat((ua.match(/(?:Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]); // for ie
-
-exports.isOldIE = exports.isIE && exports.isIE < 9;
-exports.isGecko = exports.isMozilla = (window.Controllers || window.controllers) && window.navigator.product === "Gecko";
-exports.isOldGecko = exports.isGecko && parseInt((ua.match(/rv:(\d+)/)||[])[1], 10) < 4;
-exports.isOpera = window.opera && Object.prototype.toString.call(window.opera) == "[object Opera]";
-exports.isWebKit = parseFloat(ua.split("WebKit/")[1]) || undefined;
-
-exports.isChrome = parseFloat(ua.split(" Chrome/")[1]) || undefined;
-
-exports.isAIR = ua.indexOf("AdobeAIR") >= 0;
-
-exports.isIPad = ua.indexOf("iPad") >= 0;
-
-exports.isChromeOS = ua.indexOf(" CrOS ") >= 0;
-
-exports.isIOS = /iPad|iPhone|iPod/.test(ua) && !window.MSStream;
-
-if (exports.isIOS) exports.isMac = true;
-
-});
-
ace.define("ace/lib/event",["require","exports","module","ace/lib/keys","ace/lib/useragent"], function(acequire, exports, module) {
"use strict";
@@ -1468,7 +1486,7 @@ exports.addTouchMoveListener = function (el, callback) {
exports.addListener(el, "touchmove", function (e) {
var touches = e.touches;
if (touches.length > 1) return;
-
+
var touchObj = touches[0];
e.wheelX = startx - touchObj.clientX;
@@ -1697,18 +1715,42 @@ if (typeof window == "object" && window.postMessage && !useragent.isOldIE) {
var postMessageId = 1;
exports.nextTick = function(callback, win) {
win = win || window;
- var messageName = "zero-timeout-message-" + postMessageId;
- exports.addListener(win, "message", function listener(e) {
+ var messageName = "zero-timeout-message-" + (postMessageId++);
+
+ var listener = function(e) {
if (e.data == messageName) {
exports.stopPropagation(e);
exports.removeListener(win, "message", listener);
callback();
}
- });
+ };
+
+ exports.addListener(win, "message", listener);
win.postMessage(messageName, "*");
};
}
+exports.$idleBlocked = false;
+exports.onIdle = function(cb, timeout) {
+ return setTimeout(function handler() {
+ if (!exports.$idleBlocked) {
+ cb();
+ } else {
+ setTimeout(handler, 100);
+ }
+ }, timeout);
+};
+
+exports.$idleBlockId = null;
+exports.blockIdle = function(delay) {
+ if (exports.$idleBlockId)
+ clearTimeout(exports.$idleBlockId);
+
+ exports.$idleBlocked = true;
+ exports.$idleBlockId = setTimeout(function() {
+ exports.$idleBlocked = false;
+ }, delay || 100);
+};
exports.nextFrame = typeof window == "object" && (window.requestAnimationFrame
|| window.mozRequestAnimationFrame
@@ -1724,668 +1766,434 @@ else
};
});
-ace.define("ace/lib/lang",["require","exports","module"], function(acequire, exports, module) {
+ace.define("ace/range",["require","exports","module"], function(acequire, exports, module) {
"use strict";
-
-exports.last = function(a) {
- return a[a.length - 1];
-};
-
-exports.stringReverse = function(string) {
- return string.split("").reverse().join("");
-};
-
-exports.stringRepeat = function (string, count) {
- var result = '';
- while (count > 0) {
- if (count & 1)
- result += string;
-
- if (count >>= 1)
- string += string;
- }
- return result;
-};
-
-var trimBeginRegexp = /^\s\s*/;
-var trimEndRegexp = /\s\s*$/;
-
-exports.stringTrimLeft = function (string) {
- return string.replace(trimBeginRegexp, '');
+var comparePoints = function(p1, p2) {
+ return p1.row - p2.row || p1.column - p2.column;
};
+var Range = function(startRow, startColumn, endRow, endColumn) {
+ this.start = {
+ row: startRow,
+ column: startColumn
+ };
-exports.stringTrimRight = function (string) {
- return string.replace(trimEndRegexp, '');
+ this.end = {
+ row: endRow,
+ column: endColumn
+ };
};
-exports.copyObject = function(obj) {
- var copy = {};
- for (var key in obj) {
- copy[key] = obj[key];
- }
- return copy;
-};
+(function() {
+ this.isEqual = function(range) {
+ return this.start.row === range.start.row &&
+ this.end.row === range.end.row &&
+ this.start.column === range.start.column &&
+ this.end.column === range.end.column;
+ };
+ this.toString = function() {
+ return ("Range: [" + this.start.row + "/" + this.start.column +
+ "] -> [" + this.end.row + "/" + this.end.column + "]");
+ };
-exports.copyArray = function(array){
- var copy = [];
- for (var i=0, l=array.length; i
this.end.column ? 1 : 0);
+ }
+ }
- return _self;
-};
-});
-
-ace.define("ace/keyboard/textinput_ios",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/lib/dom","ace/lib/lang","ace/lib/keys"], function(acequire, exports, module) {
-"use strict";
-
-var event = acequire("../lib/event");
-var useragent = acequire("../lib/useragent");
-var dom = acequire("../lib/dom");
-var lang = acequire("../lib/lang");
-var KEYS = acequire("../lib/keys");
-var MODS = KEYS.KEY_MODS;
-var BROKEN_SETDATA = useragent.isChrome < 18;
-var USE_IE_MIME_TYPE = useragent.isIE;
-
-var TextInput = function(parentNode, host) {
- var self = this;
- var text = dom.createElement("textarea");
- text.className = useragent.isIOS ? "ace_text-input ace_text-input-ios" : "ace_text-input";
-
- if (useragent.isTouchPad)
- text.setAttribute("x-palm-disable-auto-cap", true);
-
- text.setAttribute("wrap", "off");
- text.setAttribute("autocorrect", "off");
- text.setAttribute("autocapitalize", "off");
- text.setAttribute("spellcheck", false);
+ if (row < this.start.row)
+ return -1;
- text.style.opacity = "0";
- parentNode.insertBefore(text, parentNode.firstChild);
+ if (row > this.end.row)
+ return 1;
- var PLACEHOLDER = "\n aaaa a\n";
+ if (this.start.row === row)
+ return column >= this.start.column ? 0 : -1;
- var copied = false;
- var cut = false;
- var pasted = false;
- var inComposition = false;
- var tempStyle = '';
- var isSelectionEmpty = true;
- try { var isFocused = document.activeElement === text; } catch(e) {}
+ if (this.end.row === row)
+ return column <= this.end.column ? 0 : 1;
- event.addListener(text, "blur", function(e) {
- host.onBlur(e);
- isFocused = false;
- });
- event.addListener(text, "focus", function(e) {
- isFocused = true;
- host.onFocus(e);
- resetSelection();
- });
- this.focus = function() {
- if (tempStyle) return text.focus();
- text.style.position = "fixed";
- text.focus();
- };
- this.blur = function() {
- text.blur();
+ return 0;
};
- this.isFocused = function() {
- return isFocused;
+ this.compareStart = function(row, column) {
+ if (this.start.row == row && this.start.column == column) {
+ return -1;
+ } else {
+ return this.compare(row, column);
+ }
};
- var syncSelection = lang.delayedCall(function() {
- isFocused && resetSelection(isSelectionEmpty);
- });
- var syncValue = lang.delayedCall(function() {
- if (!inComposition) {
- text.value = PLACEHOLDER;
- isFocused && resetSelection();
- }
- });
-
- function resetSelection(isEmpty) {
- if (inComposition)
- return;
- inComposition = true;
-
- if (inputHandler) {
- selectionStart = 0;
- selectionEnd = isEmpty ? 0 : text.value.length - 1;
+ this.compareEnd = function(row, column) {
+ if (this.end.row == row && this.end.column == column) {
+ return 1;
} else {
- var selectionStart = 4;
- var selectionEnd = 5;
+ return this.compare(row, column);
}
- try {
- text.setSelectionRange(selectionStart, selectionEnd);
- } catch(e) {}
-
- inComposition = false;
- }
-
- function resetValue() {
- if (inComposition)
- return;
- text.value = PLACEHOLDER;
- if (useragent.isWebKit)
- syncValue.schedule();
- }
-
- useragent.isWebKit || host.addEventListener('changeSelection', function() {
- if (host.selection.isEmpty() != isSelectionEmpty) {
- isSelectionEmpty = !isSelectionEmpty;
- syncSelection.schedule();
+ };
+ this.compareInside = function(row, column) {
+ if (this.end.row == row && this.end.column == column) {
+ return 1;
+ } else if (this.start.row == row && this.start.column == column) {
+ return -1;
+ } else {
+ return this.compare(row, column);
}
- });
-
- resetValue();
- if (isFocused)
- host.onFocus();
-
-
- var isAllSelected = function(text) {
- return text.selectionStart === 0 && text.selectionEnd === text.value.length;
};
+ this.clipRows = function(firstRow, lastRow) {
+ if (this.end.row > lastRow)
+ var end = {row: lastRow + 1, column: 0};
+ else if (this.end.row < firstRow)
+ var end = {row: firstRow, column: 0};
- var onSelect = function(e) {
- if (isAllSelected(text)) {
- host.selectAll();
- resetSelection();
- } else if (inputHandler) {
- resetSelection(host.selection.isEmpty());
- }
+ if (this.start.row > lastRow)
+ var start = {row: lastRow + 1, column: 0};
+ else if (this.start.row < firstRow)
+ var start = {row: firstRow, column: 0};
+
+ return Range.fromPoints(start || this.start, end || this.end);
};
+ this.extend = function(row, column) {
+ var cmp = this.compare(row, column);
- var inputHandler = null;
- this.setInputHandler = function(cb) {inputHandler = cb;};
- this.getInputHandler = function() {return inputHandler;};
- var afterContextMenu = false;
+ if (cmp == 0)
+ return this;
+ else if (cmp == -1)
+ var start = {row: row, column: column};
+ else
+ var end = {row: row, column: column};
- var sendText = function(data) {
- if (text.selectionStart === 4 && text.selectionEnd === 5) {
- return;
- }
- if (inputHandler) {
- data = inputHandler(data);
- inputHandler = null;
- }
- if (pasted) {
- resetSelection();
- if (data)
- host.onPaste(data);
- pasted = false;
- } else if (data == PLACEHOLDER.substr(0) && text.selectionStart === 4) {
- if (afterContextMenu)
- host.execCommand("del", {source: "ace"});
- else // some versions of android do not fire keydown when pressing backspace
- host.execCommand("backspace", {source: "ace"});
- } else if (!copied) {
- if (data.substring(0, 9) == PLACEHOLDER && data.length > PLACEHOLDER.length)
- data = data.substr(9);
- else if (data.substr(0, 4) == PLACEHOLDER.substr(0, 4))
- data = data.substr(4, data.length - PLACEHOLDER.length + 1);
- else if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
- data = data.slice(0, -1);
- if (data == PLACEHOLDER.charAt(0)) {
- } else if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
- data = data.slice(0, -1);
+ return Range.fromPoints(start || this.start, end || this.end);
+ };
- if (data)
- host.onTextInput(data);
- }
- if (copied) {
- copied = false;
- }
- if (afterContextMenu)
- afterContextMenu = false;
+ this.isEmpty = function() {
+ return (this.start.row === this.end.row && this.start.column === this.end.column);
};
- var onInput = function(e) {
- if (inComposition)
- return;
- var data = text.value;
- sendText(data);
- resetValue();
+ this.isMultiLine = function() {
+ return (this.start.row !== this.end.row);
};
-
- var handleClipboardData = function(e, data, forceIEMime) {
- var clipboardData = e.clipboardData || window.clipboardData;
- if (!clipboardData || BROKEN_SETDATA)
- return;
- var mime = USE_IE_MIME_TYPE || forceIEMime ? "Text" : "text/plain";
- try {
- if (data) {
- return clipboardData.setData(mime, data) !== false;
- } else {
- return clipboardData.getData(mime);
- }
- } catch(e) {
- if (!forceIEMime)
- return handleClipboardData(e, data, true);
- }
+ this.clone = function() {
+ return Range.fromPoints(this.start, this.end);
};
-
- var doCopy = function(e, isCut) {
- var data = host.getCopyText();
- if (!data)
- return event.preventDefault(e);
-
- if (handleClipboardData(e, data)) {
- if (useragent.isIOS) {
- cut = isCut;
- text.value = "\n aa" + data + "a a\n";
- text.setSelectionRange(4, 4 + data.length);
- copied = {
- value: data
- };
- }
- isCut ? host.onCut() : host.onCopy();
- if (!useragent.isIOS) event.preventDefault(e);
- } else {
- copied = true;
- text.value = data;
- text.select();
- setTimeout(function(){
- copied = false;
- resetValue();
- resetSelection();
- isCut ? host.onCut() : host.onCopy();
- });
- }
+ this.collapseRows = function() {
+ if (this.end.column == 0)
+ return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0);
+ else
+ return new Range(this.start.row, 0, this.end.row, 0);
};
+ this.toScreenRange = function(session) {
+ var screenPosStart = session.documentToScreenPosition(this.start);
+ var screenPosEnd = session.documentToScreenPosition(this.end);
- var onCut = function(e) {
- doCopy(e, true);
+ return new Range(
+ screenPosStart.row, screenPosStart.column,
+ screenPosEnd.row, screenPosEnd.column
+ );
};
-
- var onCopy = function(e) {
- doCopy(e, false);
+ this.moveBy = function(row, column) {
+ this.start.row += row;
+ this.start.column += column;
+ this.end.row += row;
+ this.end.column += column;
};
- var onPaste = function(e) {
- var data = handleClipboardData(e);
- if (typeof data == "string") {
- if (data)
- host.onPaste(data, e);
- if (useragent.isIE)
- setTimeout(resetSelection);
- event.preventDefault(e);
- }
- else {
- text.value = "";
- pasted = true;
- }
- };
+}).call(Range.prototype);
+Range.fromPoints = function(start, end) {
+ return new Range(start.row, start.column, end.row, end.column);
+};
+Range.comparePoints = comparePoints;
- event.addCommandKeyListener(text, host.onCommandKey.bind(host));
+Range.comparePoints = function(p1, p2) {
+ return p1.row - p2.row || p1.column - p2.column;
+};
- event.addListener(text, "select", onSelect);
- event.addListener(text, "input", onInput);
+exports.Range = Range;
+});
- event.addListener(text, "cut", onCut);
- event.addListener(text, "copy", onCopy);
- event.addListener(text, "paste", onPaste);
- var onCompositionStart = function(e) {
- if (inComposition || !host.onCompositionStart || host.$readOnly)
- return;
- inComposition = {};
- inComposition.canUndo = host.session.$undoManager;
- host.onCompositionStart();
- setTimeout(onCompositionUpdate, 0);
- host.on("mousedown", onCompositionEnd);
- if (inComposition.canUndo && !host.selection.isEmpty()) {
- host.insert("");
- host.session.markUndoGroup();
- host.selection.clearSelection();
- }
- host.session.markUndoGroup();
- };
+ace.define("ace/lib/lang",["require","exports","module"], function(acequire, exports, module) {
+"use strict";
- var onCompositionUpdate = function() {
- if (!inComposition || !host.onCompositionUpdate || host.$readOnly)
- return;
- var val = text.value.replace(/\x01/g, "");
- if (inComposition.lastValue === val) return;
+exports.last = function(a) {
+ return a[a.length - 1];
+};
- host.onCompositionUpdate(val);
- if (inComposition.lastValue)
- host.undo();
- if (inComposition.canUndo)
- inComposition.lastValue = val;
- if (inComposition.lastValue) {
- var r = host.selection.getRange();
- host.insert(inComposition.lastValue);
- host.session.markUndoGroup();
- inComposition.range = host.selection.getRange();
- host.selection.setRange(r);
- host.selection.clearSelection();
- }
- };
+exports.stringReverse = function(string) {
+ return string.split("").reverse().join("");
+};
- var onCompositionEnd = function(e) {
- if (!host.onCompositionEnd || host.$readOnly) return;
- var c = inComposition;
- inComposition = false;
- var timer = setTimeout(function() {
- timer = null;
- var str = text.value.replace(/\x01/g, "");
- if (inComposition)
- return;
- else if (str == c.lastValue)
- resetValue();
- else if (!c.lastValue && str) {
- resetValue();
- sendText(str);
- }
- });
- inputHandler = function compositionInputHandler(str) {
- if (timer)
- clearTimeout(timer);
- str = str.replace(/\x01/g, "");
- if (str == c.lastValue)
- return "";
- if (c.lastValue && timer)
- host.undo();
- return str;
- };
- host.onCompositionEnd();
- host.removeListener("mousedown", onCompositionEnd);
- if (e.type == "compositionend" && c.range) {
- host.selection.setRange(c.range);
- }
- var needsOnInput =
- (!!useragent.isChrome && useragent.isChrome >= 53) ||
- (!!useragent.isWebKit && useragent.isWebKit >= 603);
+exports.stringRepeat = function (string, count) {
+ var result = '';
+ while (count > 0) {
+ if (count & 1)
+ result += string;
- if (needsOnInput) {
- onInput();
- }
- };
+ if (count >>= 1)
+ string += string;
+ }
+ return result;
+};
+var trimBeginRegexp = /^\s\s*/;
+var trimEndRegexp = /\s\s*$/;
+exports.stringTrimLeft = function (string) {
+ return string.replace(trimBeginRegexp, '');
+};
- var syncComposition = lang.delayedCall(onCompositionUpdate, 50);
+exports.stringTrimRight = function (string) {
+ return string.replace(trimEndRegexp, '');
+};
- event.addListener(text, "compositionstart", onCompositionStart);
- if (useragent.isGecko) {
- event.addListener(text, "text", function(){syncComposition.schedule();});
- } else {
- event.addListener(text, "keyup", function(){syncComposition.schedule();});
- event.addListener(text, "keydown", function(){syncComposition.schedule();});
+exports.copyObject = function(obj) {
+ var copy = {};
+ for (var key in obj) {
+ copy[key] = obj[key];
}
- event.addListener(text, "compositionend", onCompositionEnd);
+ return copy;
+};
- this.getElement = function() {
- return text;
- };
+exports.copyArray = function(array){
+ var copy = [];
+ for (var i=0, l=array.length; i 63;
+var MAX_LINE_LENGTH = 400;
-var TextInputIOS = acequire("./textinput_ios").TextInput;
-var TextInput = function(parentNode, host) {
- if (useragent.isIOS)
- return TextInputIOS.call(this, parentNode, host);
+var KEYS = acequire("../lib/keys");
+var MODS = KEYS.KEY_MODS;
+var isIOS = useragent.isIOS;
+var valueResetRegex = isIOS ? /\s/ : /\n/;
+var TextInput = function(parentNode, host) {
var text = dom.createElement("textarea");
text.className = "ace_text-input";
@@ -2411,30 +2222,76 @@ var TextInput = function(parentNode, host) {
text.style.opacity = "0";
parentNode.insertBefore(text, parentNode.firstChild);
- var PLACEHOLDER = "\u2028\u2028";
-
var copied = false;
var pasted = false;
var inComposition = false;
+ var sendingText = false;
var tempStyle = '';
var isSelectionEmpty = true;
+ var copyWithEmptySelection = false;
+
+ if (!useragent.isMobile)
+ text.style.fontSize = "1px";
+
+ var commandMode = false;
+ var ignoreFocusEvents = false;
+
+ var lastValue = "";
+ var lastSelectionStart = 0;
+ var lastSelectionEnd = 0;
try { var isFocused = document.activeElement === text; } catch(e) {}
event.addListener(text, "blur", function(e) {
+ if (ignoreFocusEvents) return;
host.onBlur(e);
isFocused = false;
});
event.addListener(text, "focus", function(e) {
+ if (ignoreFocusEvents) return;
isFocused = true;
+ if (useragent.isEdge) {
+ try {
+ if (!document.hasFocus())
+ return;
+ } catch(e) {}
+ }
host.onFocus(e);
- resetSelection();
+ if (useragent.isEdge)
+ setTimeout(resetSelection);
+ else
+ resetSelection();
});
+ this.$focusScroll = false;
this.focus = function() {
- if (tempStyle) return text.focus();
+ if (tempStyle || HAS_FOCUS_ARGS || this.$focusScroll == "browser")
+ return text.focus({ preventScroll: true });
+
var top = text.style.top;
text.style.position = "fixed";
text.style.top = "0px";
- text.focus();
+ try {
+ var isTransformed = text.getBoundingClientRect().top != 0;
+ } catch(e) {
+ return;
+ }
+ var ancestors = [];
+ if (isTransformed) {
+ var t = text.parentElement;
+ while (t && t.nodeType == 1) {
+ ancestors.push(t);
+ t.setAttribute("ace_nocontext", true);
+ if (!t.parentElement && t.getRootNode)
+ t = t.getRootNode().host;
+ else
+ t = t.parentElement;
+ }
+ }
+ text.focus({ preventScroll: true });
+ if (isTransformed) {
+ ancestors.forEach(function(p) {
+ p.removeAttribute("ace_nocontext");
+ });
+ }
setTimeout(function() {
text.style.position = "";
if (text.style.top == "0px")
@@ -2447,67 +2304,113 @@ var TextInput = function(parentNode, host) {
this.isFocused = function() {
return isFocused;
};
- var syncSelection = lang.delayedCall(function() {
- isFocused && resetSelection(isSelectionEmpty);
- });
- var syncValue = lang.delayedCall(function() {
- if (!inComposition) {
- text.value = PLACEHOLDER;
- isFocused && resetSelection();
- }
+
+ host.on("beforeEndOperation", function() {
+ if (host.curOp && host.curOp.command.name == "insertstring")
+ return;
+ if (inComposition) {
+ lastValue = text.value = "";
+ onCompositionEnd();
+ }
+ resetSelection();
});
+
+ var resetSelection = isIOS
+ ? function(value) {
+ if (!isFocused || (copied && !value)) return;
+ if (!value)
+ value = "";
+ var newValue = "\n ab" + value + "cde fg\n";
+ if (newValue != text.value)
+ text.value = lastValue = newValue;
+
+ var selectionStart = 4;
+ var selectionEnd = 4 + (value.length || (host.selection.isEmpty() ? 0 : 1));
- function resetSelection(isEmpty) {
- if (inComposition)
+ if (lastSelectionStart != selectionStart || lastSelectionEnd != selectionEnd) {
+ text.setSelectionRange(selectionStart, selectionEnd);
+ }
+ lastSelectionStart = selectionStart;
+ lastSelectionEnd = selectionEnd;
+ }
+ : function() {
+ if (inComposition || sendingText)
+ return;
+ if (!isFocused && !afterContextMenu)
return;
inComposition = true;
- if (inputHandler) {
- var selectionStart = 0;
- var selectionEnd = isEmpty ? 0 : text.value.length - 1;
- } else {
- var selectionStart = isEmpty ? 2 : 1;
- var selectionEnd = 2;
+ var selection = host.selection;
+ var range = selection.getRange();
+ var row = selection.cursor.row;
+ var selectionStart = range.start.column;
+ var selectionEnd = range.end.column;
+ var line = host.session.getLine(row);
+
+ if (range.start.row != row) {
+ var prevLine = host.session.getLine(row - 1);
+ selectionStart = range.start.row < row - 1 ? 0 : selectionStart;
+ selectionEnd += prevLine.length + 1;
+ line = prevLine + "\n" + line;
+ }
+ else if (range.end.row != row) {
+ var nextLine = host.session.getLine(row + 1);
+ selectionEnd = range.end.row > row + 1 ? nextLine.length : selectionEnd;
+ selectionEnd += line.length + 1;
+ line = line + "\n" + nextLine;
+ }
+
+ if (line.length > MAX_LINE_LENGTH) {
+ if (selectionStart < MAX_LINE_LENGTH && selectionEnd < MAX_LINE_LENGTH) {
+ line = line.slice(0, MAX_LINE_LENGTH);
+ } else {
+ line = "\n";
+ selectionStart = 0;
+ selectionEnd = 1;
+ }
}
- try {
- text.setSelectionRange(selectionStart, selectionEnd);
- } catch(e){}
-
- inComposition = false;
- }
-
- function resetValue() {
- if (inComposition)
- return;
- text.value = PLACEHOLDER;
- if (useragent.isWebKit)
- syncValue.schedule();
- }
- useragent.isWebKit || host.addEventListener('changeSelection', function() {
- if (host.selection.isEmpty() != isSelectionEmpty) {
- isSelectionEmpty = !isSelectionEmpty;
- syncSelection.schedule();
+ var newValue = line + "\n\n";
+ if (newValue != lastValue) {
+ text.value = lastValue = newValue;
+ lastSelectionStart = lastSelectionEnd = newValue.length;
}
- });
+ if (afterContextMenu) {
+ lastSelectionStart = text.selectionStart;
+ lastSelectionEnd = text.selectionEnd;
+ }
+ if (
+ lastSelectionEnd != selectionEnd
+ || lastSelectionStart != selectionStart
+ || text.selectionEnd != lastSelectionEnd // on ie edge selectionEnd changes silently after the initialization
+ ) {
+ try {
+ text.setSelectionRange(selectionStart, selectionEnd);
+ lastSelectionStart = selectionStart;
+ lastSelectionEnd = selectionEnd;
+ } catch(e){}
+ }
+ inComposition = false;
+ };
- resetValue();
if (isFocused)
host.onFocus();
var isAllSelected = function(text) {
- return text.selectionStart === 0 && text.selectionEnd === text.value.length;
+ return text.selectionStart === 0 && text.selectionEnd >= lastValue.length
+ && text.value === lastValue && lastValue
+ && text.selectionEnd !== lastSelectionEnd;
};
var onSelect = function(e) {
+ if (inComposition)
+ return;
if (copied) {
copied = false;
} else if (isAllSelected(text)) {
host.selectAll();
resetSelection();
- } else if (inputHandler) {
- resetSelection(host.selection.isEmpty());
}
};
@@ -2516,43 +2419,69 @@ var TextInput = function(parentNode, host) {
this.getInputHandler = function() {return inputHandler;};
var afterContextMenu = false;
- var sendText = function(data) {
- if (inputHandler) {
- data = inputHandler(data);
- inputHandler = null;
- }
+ var sendText = function(value, fromInput) {
+ if (afterContextMenu)
+ afterContextMenu = false;
if (pasted) {
resetSelection();
- if (data)
- host.onPaste(data);
+ if (value)
+ host.onPaste(value);
pasted = false;
- } else if (data == PLACEHOLDER.charAt(0)) {
- if (afterContextMenu)
- host.execCommand("del", {source: "ace"});
- else // some versions of android do not fire keydown when pressing backspace
- host.execCommand("backspace", {source: "ace"});
+ return "";
} else {
- if (data.substring(0, 2) == PLACEHOLDER)
- data = data.substr(2);
- else if (data.charAt(0) == PLACEHOLDER.charAt(0))
- data = data.substr(1);
- else if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
- data = data.slice(0, -1);
- if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
- data = data.slice(0, -1);
+ var selectionStart = text.selectionStart;
+ var selectionEnd = text.selectionEnd;
+
+ var extendLeft = lastSelectionStart;
+ var extendRight = lastValue.length - lastSelectionEnd;
- if (data)
- host.onTextInput(data);
+ var inserted = value;
+ var restoreStart = value.length - selectionStart;
+ var restoreEnd = value.length - selectionEnd;
+
+ var i = 0;
+ while (extendLeft > 0 && lastValue[i] == value[i]) {
+ i++;
+ extendLeft--;
+ }
+ inserted = inserted.slice(i);
+ i = 1;
+ while (extendRight > 0 && lastValue.length - i > lastSelectionStart - 1 && lastValue[lastValue.length - i] == value[value.length - i]) {
+ i++;
+ extendRight--;
+ }
+ restoreStart -= i-1;
+ restoreEnd -= i-1;
+ inserted = inserted.slice(0, inserted.length - i+1);
+ if (!fromInput && restoreStart == inserted.length && !extendLeft && !extendRight && !restoreEnd)
+ return "";
+
+ sendingText = true;
+ if (inserted && !extendLeft && !extendRight && !restoreStart && !restoreEnd || commandMode) {
+ host.onTextInput(inserted);
+ } else {
+ host.onTextInput(inserted, {
+ extendLeft: extendLeft,
+ extendRight: extendRight,
+ restoreStart: restoreStart,
+ restoreEnd: restoreEnd
+ });
+ }
+ sendingText = false;
+
+ lastValue = value;
+ lastSelectionStart = selectionStart;
+ lastSelectionEnd = selectionEnd;
+ return inserted;
}
- if (afterContextMenu)
- afterContextMenu = false;
};
var onInput = function(e) {
if (inComposition)
- return;
+ return onCompositionUpdate();
var data = text.value;
- sendText(data);
- resetValue();
+ var inserted = sendText(data, true);
+ if (data.length > MAX_LINE_LENGTH + 100 || valueResetRegex.test(inserted))
+ resetSelection();
};
var handleClipboardData = function(e, data, forceIEMime) {
@@ -2578,6 +2507,13 @@ var TextInput = function(parentNode, host) {
return event.preventDefault(e);
if (handleClipboardData(e, data)) {
+ if (isIOS) {
+ resetSelection(data);
+ copied = data;
+ setTimeout(function () {
+ copied = false;
+ }, 10);
+ }
isCut ? host.onCut() : host.onCopy();
event.preventDefault(e);
} else {
@@ -2586,7 +2522,6 @@ var TextInput = function(parentNode, host) {
text.select();
setTimeout(function(){
copied = false;
- resetValue();
resetSelection();
isCut ? host.onCut() : host.onCopy();
});
@@ -2619,7 +2554,6 @@ var TextInput = function(parentNode, host) {
event.addCommandKeyListener(text, host.onCommandKey.bind(host));
event.addListener(text, "select", onSelect);
-
event.addListener(text, "input", onInput);
event.addListener(text, "cut", onCut);
@@ -2646,104 +2580,113 @@ var TextInput = function(parentNode, host) {
var onCompositionStart = function(e) {
if (inComposition || !host.onCompositionStart || host.$readOnly)
return;
+
inComposition = {};
- inComposition.canUndo = host.session.$undoManager;
- host.onCompositionStart();
+
+ if (commandMode)
+ return;
+
setTimeout(onCompositionUpdate, 0);
- host.on("mousedown", onCompositionEnd);
- if (inComposition.canUndo && !host.selection.isEmpty()) {
- host.insert("");
- host.session.markUndoGroup();
- host.selection.clearSelection();
+ host.on("mousedown", cancelComposition);
+
+ var range = host.getSelectionRange();
+ range.end.row = range.start.row;
+ range.end.column = range.start.column;
+ inComposition.markerRange = range;
+ inComposition.selectionStart = lastSelectionStart;
+ host.onCompositionStart(inComposition);
+
+ if (inComposition.useTextareaForIME) {
+ text.value = "";
+ lastValue = "";
+ lastSelectionStart = 0;
+ lastSelectionEnd = 0;
+ }
+ else {
+ if (text.msGetInputContext)
+ inComposition.context = text.msGetInputContext();
+ if (text.getInputContext)
+ inComposition.context = text.getInputContext();
}
- host.session.markUndoGroup();
};
var onCompositionUpdate = function() {
if (!inComposition || !host.onCompositionUpdate || host.$readOnly)
return;
- var val = text.value.replace(/\u2028/g, "");
- if (inComposition.lastValue === val) return;
+ if (commandMode)
+ return cancelComposition();
- host.onCompositionUpdate(val);
- if (inComposition.lastValue)
- host.undo();
- if (inComposition.canUndo)
- inComposition.lastValue = val;
- if (inComposition.lastValue) {
- var r = host.selection.getRange();
- host.insert(inComposition.lastValue);
- host.session.markUndoGroup();
- inComposition.range = host.selection.getRange();
- host.selection.setRange(r);
- host.selection.clearSelection();
+ if (inComposition.useTextareaForIME) {
+ host.onCompositionUpdate(text.value);
+ }
+ else {
+ var data = text.value;
+ sendText(data);
+ if (inComposition.markerRange) {
+ if (inComposition.context) {
+ inComposition.markerRange.start.column = inComposition.selectionStart
+ = inComposition.context.compositionStartOffset;
+ }
+ inComposition.markerRange.end.column = inComposition.markerRange.start.column
+ + lastSelectionEnd - inComposition.selectionStart;
+ }
}
};
var onCompositionEnd = function(e) {
if (!host.onCompositionEnd || host.$readOnly) return;
- var c = inComposition;
inComposition = false;
- var timer = setTimeout(function() {
- timer = null;
- var str = text.value.replace(/\u2028/g, "");
- if (inComposition)
- return;
- else if (str == c.lastValue)
- resetValue();
- else if (!c.lastValue && str) {
- resetValue();
- sendText(str);
- }
- });
- inputHandler = function compositionInputHandler(str) {
- if (timer)
- clearTimeout(timer);
- str = str.replace(/\u2028/g, "");
- if (str == c.lastValue)
- return "";
- if (c.lastValue && timer)
- host.undo();
- return str;
- };
host.onCompositionEnd();
- host.removeListener("mousedown", onCompositionEnd);
- if (e.type == "compositionend" && c.range) {
- host.selection.setRange(c.range);
- }
- var needsOnInput =
- (!!useragent.isChrome && useragent.isChrome >= 53) ||
- (!!useragent.isWebKit && useragent.isWebKit >= 603);
-
- if (needsOnInput) {
- onInput();
- }
+ host.off("mousedown", cancelComposition);
+ if (e) onInput();
};
-
- var syncComposition = lang.delayedCall(onCompositionUpdate, 50);
+ function cancelComposition() {
+ ignoreFocusEvents = true;
+ text.blur();
+ text.focus();
+ ignoreFocusEvents = false;
+ }
+
+ var syncComposition = lang.delayedCall(onCompositionUpdate, 50).schedule.bind(null, null);
+
+ function onKeyup(e) {
+ if (e.keyCode == 27 && text.value.length < text.selectionStart) {
+ if (!inComposition)
+ lastValue = text.value;
+ lastSelectionStart = lastSelectionEnd = -1;
+ resetSelection();
+ }
+ syncComposition();
+ }
event.addListener(text, "compositionstart", onCompositionStart);
- if (useragent.isGecko) {
- event.addListener(text, "text", function(){syncComposition.schedule();});
- } else {
- event.addListener(text, "keyup", function(){syncComposition.schedule();});
- event.addListener(text, "keydown", function(){syncComposition.schedule();});
- }
+ event.addListener(text, "compositionupdate", onCompositionUpdate);
+ event.addListener(text, "keyup", onKeyup);
+ event.addListener(text, "keydown", syncComposition);
event.addListener(text, "compositionend", onCompositionEnd);
this.getElement = function() {
return text;
};
-
+ this.setCommandMode = function(value) {
+ commandMode = value;
+ text.readOnly = false;
+ };
+
this.setReadOnly = function(readOnly) {
- text.readOnly = readOnly;
+ if (!commandMode)
+ text.readOnly = readOnly;
+ };
+
+ this.setCopyWithEmptySelection = function(value) {
+ copyWithEmptySelection = value;
};
this.onContextMenu = function(e) {
afterContextMenu = true;
- resetSelection(host.selection.isEmpty());
+ resetSelection();
host._emit("nativecontextmenu", {target: host, domEvent: e});
this.moveToMouse(e, true);
};
@@ -2752,8 +2695,8 @@ var TextInput = function(parentNode, host) {
if (!tempStyle)
tempStyle = text.style.cssText;
text.style.cssText = (bringToFront ? "z-index:100000;" : "")
- + "height:" + text.style.height + ";"
- + (useragent.isIE ? "opacity:0.1;" : "");
+ + (useragent.isIE ? "opacity:0.1;" : "")
+ + "text-indent: -" + (lastSelectionStart + lastSelectionEnd) * host.renderer.characterWidth * 0.5 + "px;";
var rect = host.container.getBoundingClientRect();
var style = dom.computedStyle(host.container);
@@ -2804,20 +2747,99 @@ var TextInput = function(parentNode, host) {
});
event.addListener(host.renderer.scroller, "contextmenu", onContextMenu);
event.addListener(text, "contextmenu", onContextMenu);
+
+ if (isIOS)
+ addIosSelectionHandler(parentNode, host, text);
+
+ function addIosSelectionHandler(parentNode, host, text) {
+ var typingResetTimeout = null;
+ var typing = false;
+
+ text.addEventListener("keydown", function (e) {
+ if (typingResetTimeout) clearTimeout(typingResetTimeout);
+ typing = true;
+ }, true);
+
+ text.addEventListener("keyup", function (e) {
+ typingResetTimeout = setTimeout(function () {
+ typing = false;
+ }, 100);
+ }, true);
+ var detectArrowKeys = function(e) {
+ if (document.activeElement !== text) return;
+ if (typing || inComposition) return;
+
+ if (copied) {
+ return;
+ }
+ var selectionStart = text.selectionStart;
+ var selectionEnd = text.selectionEnd;
+
+ var key = null;
+ var modifier = 0;
+ console.log(selectionStart, selectionEnd);
+ if (selectionStart == 0) {
+ key = KEYS.up;
+ } else if (selectionStart == 1) {
+ key = KEYS.home;
+ } else if (selectionEnd > lastSelectionEnd && lastValue[selectionEnd] == "\n") {
+ key = KEYS.end;
+ } else if (selectionStart < lastSelectionStart && lastValue[selectionStart - 1] == " ") {
+ key = KEYS.left;
+ modifier = MODS.option;
+ } else if (
+ selectionStart < lastSelectionStart
+ || (
+ selectionStart == lastSelectionStart
+ && lastSelectionEnd != lastSelectionStart
+ && selectionStart == selectionEnd
+ )
+ ) {
+ key = KEYS.left;
+ } else if (selectionEnd > lastSelectionEnd && lastValue.slice(0, selectionEnd).split("\n").length > 2) {
+ key = KEYS.down;
+ } else if (selectionEnd > lastSelectionEnd && lastValue[selectionEnd - 1] == " ") {
+ key = KEYS.right;
+ modifier = MODS.option;
+ } else if (
+ selectionEnd > lastSelectionEnd
+ || (
+ selectionEnd == lastSelectionEnd
+ && lastSelectionEnd != lastSelectionStart
+ && selectionStart == selectionEnd
+ )
+ ) {
+ key = KEYS.right;
+ }
+
+ if (selectionStart !== selectionEnd)
+ modifier |= MODS.shift;
+
+ if (key) {
+ host.onCommandKey(null, modifier, key);
+ lastSelectionStart = selectionStart;
+ lastSelectionEnd = selectionEnd;
+ resetSelection("");
+ }
+ };
+ document.addEventListener("selectionchange", detectArrowKeys);
+ host.on("destroy", function() {
+ document.removeEventListener("selectionchange", detectArrowKeys);
+ });
+ }
+
};
exports.TextInput = TextInput;
});
-ace.define("ace/mouse/default_handlers",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"], function(acequire, exports, module) {
+ace.define("ace/mouse/default_handlers",["require","exports","module","ace/lib/useragent"], function(acequire, exports, module) {
"use strict";
-var dom = acequire("../lib/dom");
-var event = acequire("../lib/event");
var useragent = acequire("../lib/useragent");
var DRAG_OFFSET = 0; // pixels
-var SCROLL_COOLDOWN_T = 250; // milliseconds
+var SCROLL_COOLDOWN_T = 550; // milliseconds
function DefaultHandlers(mouseHandler) {
mouseHandler.$clickSelection = null;
@@ -2853,10 +2875,8 @@ function DefaultHandlers(mouseHandler) {
if (button !== 0) {
var selectionRange = editor.getSelectionRange();
var selectionEmpty = selectionRange.isEmpty();
- editor.$blockScrolling++;
if (selectionEmpty || button == 1)
editor.selection.moveToPosition(pos);
- editor.$blockScrolling--;
if (button == 2) {
editor.textInput.onContextMenu(ev.domEvent);
if (!useragent.isMozilla)
@@ -2868,7 +2888,7 @@ function DefaultHandlers(mouseHandler) {
this.mousedownEvent.time = Date.now();
if (inSelection && !editor.isFocused()) {
editor.focus();
- if (this.$focusTimout && !this.$clickSelection && !editor.inMultiSelectMode) {
+ if (this.$focusTimeout && !this.$clickSelection && !editor.inMultiSelectMode) {
this.setState("focusWait");
this.captureMouse(ev);
return;
@@ -2883,7 +2903,7 @@ function DefaultHandlers(mouseHandler) {
this.startSelect = function(pos, waitForClickSelection) {
pos = pos || this.editor.renderer.screenToTextCoordinates(this.x, this.y);
var editor = this.editor;
- editor.$blockScrolling++;
+ if (!this.mousedownEvent) return;
if (this.mousedownEvent.getShiftKey())
editor.selection.selectToPosition(pos);
else if (!waitForClickSelection)
@@ -2895,13 +2915,11 @@ function DefaultHandlers(mouseHandler) {
}
editor.setStyle("ace_selecting");
this.setState("select");
- editor.$blockScrolling--;
};
this.select = function() {
var anchor, editor = this.editor;
var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
- editor.$blockScrolling++;
if (this.$clickSelection) {
var cmp = this.$clickSelection.comparePoint(cursor);
@@ -2917,7 +2935,6 @@ function DefaultHandlers(mouseHandler) {
editor.selection.setSelectionAnchor(anchor.row, anchor.column);
}
editor.selection.selectToPosition(cursor);
- editor.$blockScrolling--;
editor.renderer.scrollCursorIntoView();
};
@@ -2925,7 +2942,6 @@ function DefaultHandlers(mouseHandler) {
var anchor, editor = this.editor;
var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
var range = editor.selection[unitName](cursor.row, cursor.column);
- editor.$blockScrolling++;
if (this.$clickSelection) {
var cmpStart = this.$clickSelection.comparePoint(range.start);
var cmpEnd = this.$clickSelection.comparePoint(range.end);
@@ -2949,7 +2965,6 @@ function DefaultHandlers(mouseHandler) {
editor.selection.setSelectionAnchor(anchor.row, anchor.column);
}
editor.selection.selectToPosition(cursor);
- editor.$blockScrolling--;
editor.renderer.scrollCursorIntoView();
};
@@ -2968,7 +2983,7 @@ function DefaultHandlers(mouseHandler) {
var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
var time = Date.now();
- if (distance > DRAG_OFFSET || time - this.mousedownEvent.time > this.$focusTimout)
+ if (distance > DRAG_OFFSET || time - this.mousedownEvent.time > this.$focusTimeout)
this.startSelect(this.mousedownEvent.getDocumentPosition());
};
@@ -3024,33 +3039,33 @@ function DefaultHandlers(mouseHandler) {
}
var editor = this.editor;
-
+
if (!this.$lastScroll)
this.$lastScroll = { t: 0, vx: 0, vy: 0, allowed: 0 };
-
+
var prevScroll = this.$lastScroll;
var t = ev.domEvent.timeStamp;
var dt = t - prevScroll.t;
- var vx = ev.wheelX / dt;
- var vy = ev.wheelY / dt;
+ var vx = dt ? ev.wheelX / dt : prevScroll.vx;
+ var vy = dt ? ev.wheelY / dt : prevScroll.vy;
if (dt < SCROLL_COOLDOWN_T) {
vx = (vx + prevScroll.vx) / 2;
vy = (vy + prevScroll.vy) / 2;
}
-
+
var direction = Math.abs(vx / vy);
-
+
var canScroll = false;
if (direction >= 1 && editor.renderer.isScrollableBy(ev.wheelX * ev.speed, 0))
canScroll = true;
if (direction <= 1 && editor.renderer.isScrollableBy(0, ev.wheelY * ev.speed))
canScroll = true;
-
+
if (canScroll) {
prevScroll.allowed = t;
} else if (t - prevScroll.allowed < SCROLL_COOLDOWN_T) {
- var isSlower = Math.abs(vx) <= 1.1 * Math.abs(prevScroll.vx)
- && Math.abs(vy) <= 1.1 * Math.abs(prevScroll.vy);
+ var isSlower = Math.abs(vx) <= 1.5 * Math.abs(prevScroll.vx)
+ && Math.abs(vy) <= 1.5 * Math.abs(prevScroll.vy);
if (isSlower) {
canScroll = true;
prevScroll.allowed = t;
@@ -3059,7 +3074,7 @@ function DefaultHandlers(mouseHandler) {
prevScroll.allowed = 0;
}
}
-
+
prevScroll.t = t;
prevScroll.vx = vx;
prevScroll.vy = vy;
@@ -3069,7 +3084,7 @@ function DefaultHandlers(mouseHandler) {
return ev.stop();
}
};
-
+
this.onTouchMove = function(ev) {
this.editor._emit("mousewheel", ev);
};
@@ -3121,7 +3136,7 @@ function Tooltip (parentNode) {
return this.$element || this.$init();
};
this.setText = function(text) {
- dom.setInnerText(this.getElement(), text);
+ this.getElement().textContent = text;
};
this.setHtml = function(html) {
this.getElement().innerHTML = html;
@@ -3156,7 +3171,7 @@ function Tooltip (parentNode) {
this.getWidth = function() {
return this.getElement().offsetWidth;
};
-
+
this.destroy = function() {
this.isOpen = false;
if (this.$element && this.$element.parentNode) {
@@ -3559,9 +3574,7 @@ function DragdropHandler(mouseHandler) {
var vMovement = !prevCursor || cursor.row != prevCursor.row;
var hMovement = !prevCursor || cursor.column != prevCursor.column;
if (!cursorMovedTime || vMovement || hMovement) {
- editor.$blockScrolling += 1;
editor.moveCursorToPosition(cursor);
- editor.$blockScrolling -= 1;
cursorMovedTime = now;
cursorPointOnCaretMoved = {x: x, y: y};
} else {
@@ -3636,9 +3649,7 @@ function DragdropHandler(mouseHandler) {
clearInterval(timerId);
editor.session.removeMarker(dragSelectionMarker);
dragSelectionMarker = null;
- editor.$blockScrolling += 1;
editor.selection.fromOrientedRange(range);
- editor.$blockScrolling -= 1;
if (editor.isFocused() && !isInternal)
editor.renderer.$cursorLayer.setBlinking(!editor.getReadOnly());
range = null;
@@ -3867,10 +3878,15 @@ EventEmitter._signal = function(eventName, e) {
EventEmitter.once = function(eventName, callback) {
var _self = this;
- callback && this.addEventListener(eventName, function newCallback() {
+ this.addEventListener(eventName, function newCallback() {
_self.removeEventListener(eventName, newCallback);
callback.apply(null, arguments);
});
+ if (!callback) {
+ return new Promise(function(resolve) {
+ callback = resolve;
+ });
+ }
};
@@ -3898,7 +3914,6 @@ EventEmitter.removeDefaultHandler = function(eventName, callback) {
var disabled = handlers._disabled_[eventName];
if (handlers[eventName] == callback) {
- var old = handlers[eventName];
if (disabled)
this.setDefaultHandler(eventName, disabled.pop());
} else if (disabled) {
@@ -3958,7 +3973,10 @@ var optionsProvider = {
getOptions: function(optionNames) {
var result = {};
if (!optionNames) {
- optionNames = Object.keys(this.$options);
+ var options = this.$options;
+ optionNames = Object.keys(options).filter(function(key) {
+ return !options[key].hidden;
+ });
} else if (!Array.isArray(optionNames)) {
result = optionNames;
optionNames = Object.keys(result);
@@ -4106,6 +4124,8 @@ exports.set = function(key, value) {
exports.all = function() {
return lang.copyObject(options);
};
+
+exports.$modes = {};
exports.moduleUrl = function(name, component) {
if (options.$moduleUrls[name])
return options.$moduleUrls[name];
@@ -4171,7 +4191,24 @@ exports.loadModule = function(moduleName, onLoad) {
if (!exports.get("packaged"))
return afterLoad();
+
net.loadScript(exports.moduleUrl(moduleName, moduleType), afterLoad);
+ reportErrorIfPathIsNotConfigured();
+};
+
+var reportErrorIfPathIsNotConfigured = function() {
+ if (
+ !options.basePath && !options.workerPath
+ && !options.modePath && !options.themePath
+ && !Object.keys(options.$moduleUrls).length
+ ) {
+ console.error(
+ "Unable to infer path to ace from script src,",
+ "use ace.config.set('basePath', 'path') to enable dynamic loading of modes and themes",
+ "or with webpack use ace/webpack-resolver"
+ );
+ reportErrorIfPathIsNotConfigured = function() {};
+ }
};
init(true);function init(packaged) {
@@ -4337,6 +4374,7 @@ var MouseHandler = function(editor) {
this.y = ev.y;
this.isMousePressed = true;
+ var editor = this.editor;
var renderer = this.editor.renderer;
if (renderer.$keepTextAreaAtCursor)
renderer.$keepTextAreaAtCursor = null;
@@ -4355,6 +4393,7 @@ var MouseHandler = function(editor) {
};
var onCaptureEnd = function(e) {
+ editor.off("beforeEndOperation", onOperationEnd);
clearInterval(timerId);
onCaptureInterval();
self[self.state + "End"] && self[self.state + "End"](e);
@@ -4366,6 +4405,7 @@ var MouseHandler = function(editor) {
self.isMousePressed = false;
self.$onCaptureMouseMove = self.releaseMouse = null;
e && self.onMouseEvent("mouseup", e);
+ editor.endOperation();
};
var onCaptureInterval = function() {
@@ -4377,6 +4417,18 @@ var MouseHandler = function(editor) {
return setTimeout(function() {onCaptureEnd(ev);});
}
+ var onOperationEnd = function(e) {
+ if (!self.releaseMouse) return;
+ if (editor.curOp.command.name && editor.curOp.selectionChanged) {
+ self[self.state + "End"] && self[self.state + "End"]();
+ self.state = "";
+ self.releaseMouse();
+ }
+ };
+
+ editor.on("beforeEndOperation", onOperationEnd);
+ editor.startOperation({command: {name: "mouse"}});
+
self.$onCaptureMouseMove = onMouseMove;
self.releaseMouse = event.capture(this.editor.container, onMouseMove, onCaptureEnd);
var timerId = setInterval(onCaptureInterval, 20);
@@ -4399,7 +4451,7 @@ config.defineOptions(MouseHandler.prototype, "mouseHandler", {
scrollSpeed: {initialValue: 2},
dragDelay: {initialValue: (useragent.isMac ? 150 : 0)},
dragEnabled: {initialValue: true},
- focusTimout: {initialValue: 0},
+ focusTimeout: {initialValue: 0},
tooltipFollowsMouse: {initialValue: true}
});
@@ -4407,8 +4459,9 @@ config.defineOptions(MouseHandler.prototype, "mouseHandler", {
exports.MouseHandler = MouseHandler;
});
-ace.define("ace/mouse/fold_handler",["require","exports","module"], function(acequire, exports, module) {
+ace.define("ace/mouse/fold_handler",["require","exports","module","ace/lib/dom"], function(acequire, exports, module) {
"use strict";
+var dom = acequire("../lib/dom");
function FoldHandler(editor) {
@@ -4424,6 +4477,14 @@ function FoldHandler(editor) {
e.stop();
}
+
+ var target = e.domEvent && e.domEvent.target;
+ if (target && dom.hasCssClass(target, "ace_inline_button")) {
+ if (dom.hasCssClass(target, "ace_toggle_wrap")) {
+ session.setOption("wrap", true);
+ editor.renderer.scrollCursorIntoView();
+ }
+ }
});
editor.on("gutterclick", function(e) {
@@ -4741,7 +4802,7 @@ function _invertLevel(lev, levels, _array) {
}
}
-function _getCharClass(chars, types, classes, ix) {
+function _getCharClass(chars, types, classes, ix) {
var cType = types[ix], wType, nType, len, i;
switch(cType){
case L:
@@ -4796,7 +4857,7 @@ function _getCharClass(chars, types, classes, ix) {
}
if (i < len){
var c = chars[ix], rtlCandidate = (c >= 0x0591 && c <= 0x08FF) || c == 0xFB1E;
-
+
wType = types[i];
if (rtlCandidate && (wType == R || wType == AL)){
return R;
@@ -4825,10 +4886,10 @@ function _getCharClass(chars, types, classes, ix) {
}
}
-function _getCharacterType( ch ) {
+function _getCharacterType( ch ) {
var uc = ch.charCodeAt(0), hi = uc >> 8;
-
- if (hi == 0) {
+
+ if (hi == 0) {
return ((uc > 0x00BF) ? L : UnicodeTBL00[uc]);
} else if (hi == 5) {
return (/[\u0591-\u05f4]/.test(ch) ? R : L);
@@ -4840,15 +4901,15 @@ function _getCharacterType( ch ) {
else if (uc == 0x066A)
return ET;
else if (/[\u06f0-\u06f9]/.test(ch))
- return EN;
+ return EN;
else
return AL;
} else if (hi == 0x20 && uc <= 0x205F) {
return UnicodeTBL20[uc & 0xFF];
} else if (hi == 0xFE) {
return (uc >= 0xFE70 ? AL : ON);
- }
- return ON;
+ }
+ return ON;
}
function _isArabicDiacritics( ch ) {
@@ -4861,14 +4922,15 @@ exports.ON_R = 3;
exports.AN = 4;
exports.R_H = 5;
exports.B = 6;
+exports.RLE = 7;
exports.DOT = "\xB7";
exports.doBidiReorder = function(text, textCharTypes, isRtl) {
if (text.length < 2)
return {};
-
+
var chars = text.split(""), logicalFromVisual = new Array(chars.length),
- bidiLevels = new Array(chars.length), levels = [];
+ bidiLevels = new Array(chars.length), levels = [];
dir = isRtl ? RTL : LTR;
@@ -4882,7 +4944,7 @@ exports.doBidiReorder = function(text, textCharTypes, isRtl) {
for (var i = 0; i < logicalFromVisual.length - 1; i++) { //fix levels to reflect character width
if (textCharTypes[i] === AN) {
levels[i] = exports.AN;
- } else if (levels[i] === R && ((textCharTypes[i] > AL && textCharTypes[i] < LRE)
+ } else if (levels[i] === R && ((textCharTypes[i] > AL && textCharTypes[i] < LRE)
|| textCharTypes[i] === ON || textCharTypes[i] === BN)) {
levels[i] = exports.ON_R;
} else if ((i > 0 && chars[i - 1] === '\u0644') && /\u0622|\u0623|\u0625|\u0627/.test(chars[i])) {
@@ -4892,7 +4954,10 @@ exports.doBidiReorder = function(text, textCharTypes, isRtl) {
}
if (chars[chars.length - 1] === exports.DOT)
levels[chars.length - 1] = exports.B;
-
+
+ if (chars[0] === '\u202B')
+ levels[0] = exports.RLE;
+
for (var i = 0; i < logicalFromVisual.length; i++) {
bidiLevels[i] = levels[logicalFromVisual[i]];
}
@@ -4903,11 +4968,11 @@ exports.hasBidiCharacters = function(text, textCharTypes){
var ret = false;
for (var i = 0; i < text.length; i++){
textCharTypes[i] = _getCharacterType(text.charAt(i));
- if (!ret && (textCharTypes[i] == R || textCharTypes[i] == AL))
+ if (!ret && (textCharTypes[i] == R || textCharTypes[i] == AL || textCharTypes[i] == AN))
ret = true;
}
return ret;
-};
+};
exports.getVisualFromLogicalIdx = function(logIdx, rowMap) {
for (var i = 0; i < rowMap.logicalFromVisual.length; i++) {
if (rowMap.logicalFromVisual[i] == logIdx)
@@ -4918,13 +4983,12 @@ exports.getVisualFromLogicalIdx = function(logIdx, rowMap) {
});
-ace.define("ace/bidihandler",["require","exports","module","ace/lib/bidiutil","ace/lib/lang","ace/lib/useragent"], function(acequire, exports, module) {
+ace.define("ace/bidihandler",["require","exports","module","ace/lib/bidiutil","ace/lib/lang"], function(acequire, exports, module) {
"use strict";
var bidiUtil = acequire("./lib/bidiutil");
var lang = acequire("./lib/lang");
-var useragent = acequire("./lib/useragent");
-var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
+var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\u202B]/;
var BidiHandler = function(session) {
this.session = session;
this.bidiMap = {};
@@ -4936,9 +5000,14 @@ var BidiHandler = function(session) {
this.isRtlDir = false;
this.line = "";
this.wrapIndent = 0;
- this.isLastRow = false;
this.EOF = "\xB6";
- this.seenBidi = false;
+ this.RLE = "\u202B";
+ this.contentWidth = 0;
+ this.fontMetrics = null;
+ this.rtlLineOffset = 0;
+ this.wrapOffset = 0;
+ this.isMoveLeftOperation = false;
+ this.seenBidi = bidiRE.test(session.getValue());
};
(function() {
@@ -4959,7 +5028,7 @@ var BidiHandler = function(session) {
this.seenBidi = true;
this.currentRow = null;
}
- }
+ }
else {
this.currentRow = null;
}
@@ -4990,6 +5059,8 @@ var BidiHandler = function(session) {
prevIndex = currentIndex;
splitIndex++;
}
+ } else {
+ splitIndex = this.currentRow;
}
return splitIndex;
@@ -4998,10 +5069,13 @@ var BidiHandler = function(session) {
this.updateRowLine = function(docRow, splitIndex) {
if (docRow === undefined)
docRow = this.getDocumentRow();
+
+ var isLastRow = (docRow === this.session.getLength() - 1),
+ endOfLine = isLastRow ? this.EOF : this.EOL;
this.wrapIndent = 0;
- this.isLastRow = (docRow === this.session.getLength() - 1);
this.line = this.session.getLine(docRow);
+ this.isRtlDir = this.line.charAt(0) === this.RLE;
if (this.session.$useWrapMode) {
var splits = this.session.$wrapData[docRow];
if (splits) {
@@ -5010,13 +5084,18 @@ var BidiHandler = function(session) {
if(splitIndex > 0 && splits.length) {
this.wrapIndent = splits.indent;
+ this.wrapOffset = this.wrapIndent * this.charWidths[bidiUtil.L];
this.line = (splitIndex < splits.length) ?
- this.line.substring(splits[splitIndex - 1], splits[splits.length - 1]) :
+ this.line.substring(splits[splitIndex - 1], splits[splitIndex]) :
this.line.substring(splits[splits.length - 1]);
} else {
this.line = this.line.substring(0, splits[splitIndex]);
}
}
+ if (splitIndex == splits.length)
+ this.line += (this.showInvisibles) ? endOfLine : bidiUtil.DOT;
+ } else {
+ this.line += this.showInvisibles ? endOfLine : bidiUtil.DOT;
}
var session = this.session, shift = 0, size;
this.line = this.line.replace(/\t|[\u1100-\u2029, \u202F-\uFFE6]/g, function(ch, i){
@@ -5027,13 +5106,17 @@ var BidiHandler = function(session) {
}
return ch;
});
- };
+ if (this.isRtlDir) {
+ this.fontMetrics.$main.innerHTML = (this.line.charAt(this.line.length - 1) == bidiUtil.DOT) ? this.line.substr(0, this.line.length - 1) : this.line;
+ this.rtlLineOffset = this.contentWidth - this.fontMetrics.$main.getBoundingClientRect().width;
+ }
+ };
+
this.updateBidiMap = function() {
- var textCharTypes = [], endOfLine = this.isLastRow ? this.EOF : this.EOL;
- var line = this.line + (this.showInvisibles ? endOfLine : bidiUtil.DOT);
- if (bidiUtil.hasBidiCharacters(line, textCharTypes)) {
- this.bidiMap = bidiUtil.doBidiReorder(line, textCharTypes, this.isRtlDir);
+ var textCharTypes = [];
+ if (bidiUtil.hasBidiCharacters(this.line, textCharTypes) || this.isRtlDir) {
+ this.bidiMap = bidiUtil.doBidiReorder(this.line, textCharTypes, this.isRtlDir);
} else {
this.bidiMap = {};
}
@@ -5042,62 +5125,82 @@ var BidiHandler = function(session) {
this.currentRow = null;
};
this.updateCharacterWidths = function(fontMetrics) {
- if (!this.seenBidi)
- return;
if (this.characterWidth === fontMetrics.$characterSize.width)
return;
+ this.fontMetrics = fontMetrics;
var characterWidth = this.characterWidth = fontMetrics.$characterSize.width;
var bidiCharWidth = fontMetrics.$measureCharWidth("\u05d4");
this.charWidths[bidiUtil.L] = this.charWidths[bidiUtil.EN] = this.charWidths[bidiUtil.ON_R] = characterWidth;
this.charWidths[bidiUtil.R] = this.charWidths[bidiUtil.AN] = bidiCharWidth;
- this.charWidths[bidiUtil.R_H] = useragent.isChrome ? bidiCharWidth : bidiCharWidth * 0.45;
- this.charWidths[bidiUtil.B] = 0;
+ this.charWidths[bidiUtil.R_H] = bidiCharWidth * 0.45;
+ this.charWidths[bidiUtil.B] = this.charWidths[bidiUtil.RLE] = 0;
this.currentRow = null;
};
- this.getShowInvisibles = function() {
- return this.showInvisibles;
- };
-
this.setShowInvisibles = function(showInvisibles) {
this.showInvisibles = showInvisibles;
this.currentRow = null;
};
this.setEolChar = function(eolChar) {
- this.EOL = eolChar;
+ this.EOL = eolChar;
+ };
+
+ this.setContentWidth = function(width) {
+ this.contentWidth = width;
+ };
+
+ this.isRtlLine = function(row) {
+ if (row != undefined)
+ return (this.session.getLine(row).charAt(0) == this.RLE);
+ else
+ return this.isRtlDir;
};
- this.setTextDir = function(isRtlDir) {
- this.isRtlDir = isRtlDir;
+ this.setRtlDirection = function(editor, isRtlDir) {
+ var cursor = editor.getCursorPosition();
+ for (var row = editor.selection.getSelectionAnchor().row; row <= cursor.row; row++) {
+ if (!isRtlDir && editor.session.getLine(row).charAt(0) === editor.session.$bidiHandler.RLE)
+ editor.session.doc.removeInLine(row, 0, 1);
+ else if (isRtlDir && editor.session.getLine(row).charAt(0) !== editor.session.$bidiHandler.RLE)
+ editor.session.doc.insert({column: 0, row: row}, editor.session.$bidiHandler.RLE);
+ }
};
this.getPosLeft = function(col) {
col -= this.wrapIndent;
- var visualIdx = bidiUtil.getVisualFromLogicalIdx(col > 0 ? col - 1 : 0, this.bidiMap),
+ var leftBoundary = (this.line.charAt(0) === this.RLE) ? 1 : 0;
+ var logicalIdx = (col > leftBoundary) ? (this.session.getOverwrite() ? col : col - 1) : leftBoundary;
+ var visualIdx = bidiUtil.getVisualFromLogicalIdx(logicalIdx, this.bidiMap),
levels = this.bidiMap.bidiLevels, left = 0;
- if (col === 0 && levels[visualIdx] % 2 !== 0)
+ if (!this.session.getOverwrite() && col <= leftBoundary && levels[visualIdx] % 2 !== 0)
visualIdx++;
-
+
for (var i = 0; i < visualIdx; i++) {
left += this.charWidths[levels[i]];
}
- if (col !== 0 && levels[visualIdx] % 2 === 0)
+ if (!this.session.getOverwrite() && (col > leftBoundary) && (levels[visualIdx] % 2 === 0))
left += this.charWidths[levels[visualIdx]];
if (this.wrapIndent)
- left += this.wrapIndent * this.charWidths[bidiUtil.L];
+ left += this.isRtlDir ? (-1 * this.wrapOffset) : this.wrapOffset;
+
+ if (this.isRtlDir)
+ left += this.rtlLineOffset;
return left;
};
this.getSelections = function(startCol, endCol) {
- var map = this.bidiMap, levels = map.bidiLevels, level, offset = this.wrapIndent * this.charWidths[bidiUtil.L], selections = [],
+ var map = this.bidiMap, levels = map.bidiLevels, level, selections = [], offset = 0,
selColMin = Math.min(startCol, endCol) - this.wrapIndent, selColMax = Math.max(startCol, endCol) - this.wrapIndent,
isSelected = false, isSelectedPrev = false, selectionStart = 0;
+
+ if (this.wrapIndent)
+ offset += this.isRtlDir ? (-1 * this.wrapOffset) : this.wrapOffset;
for (var logIdx, visIdx = 0; visIdx < levels.length; visIdx++) {
logIdx = map.logicalFromVisual[visIdx];
@@ -5116,289 +5219,60 @@ var BidiHandler = function(session) {
selections.push({left: selectionStart, width: offset - selectionStart});
}
+ if(this.isRtlDir) {
+ for (var i = 0; i < selections.length; i++) {
+ selections[i].left += this.rtlLineOffset;
+ }
+ }
return selections;
};
this.offsetToCol = function(posX) {
+ if(this.isRtlDir)
+ posX -= this.rtlLineOffset;
+
var logicalIdx = 0, posX = Math.max(posX, 0),
offset = 0, visualIdx = 0, levels = this.bidiMap.bidiLevels,
charWidth = this.charWidths[levels[visualIdx]];
- if (this.wrapIndent) {
- posX -= this.wrapIndent * this.charWidths[bidiUtil.L];
- }
-
+ if (this.wrapIndent)
+ posX -= this.isRtlDir ? (-1 * this.wrapOffset) : this.wrapOffset;
+
while(posX > offset + charWidth/2) {
offset += charWidth;
if(visualIdx === levels.length - 1) {
charWidth = 0;
break;
- }
- charWidth = this.charWidths[levels[++visualIdx]];
- }
-
- if (visualIdx > 0 && (levels[visualIdx - 1] % 2 !== 0) && (levels[visualIdx] % 2 === 0)){
- if(posX < offset)
- visualIdx--;
- logicalIdx = this.bidiMap.logicalFromVisual[visualIdx];
-
- } else if (visualIdx > 0 && (levels[visualIdx - 1] % 2 === 0) && (levels[visualIdx] % 2 !== 0)){
- logicalIdx = 1 + ((posX > offset) ? this.bidiMap.logicalFromVisual[visualIdx]
- : this.bidiMap.logicalFromVisual[visualIdx - 1]);
-
- } else if ((this.isRtlDir && visualIdx === levels.length - 1 && charWidth === 0 && (levels[visualIdx - 1] % 2 === 0))
- || (!this.isRtlDir && visualIdx === 0 && (levels[visualIdx] % 2 !== 0))){
- logicalIdx = 1 + this.bidiMap.logicalFromVisual[visualIdx];
- } else {
- if (visualIdx > 0 && (levels[visualIdx - 1] % 2 !== 0) && charWidth !== 0)
- visualIdx--;
- logicalIdx = this.bidiMap.logicalFromVisual[visualIdx];
- }
-
- return (logicalIdx + this.wrapIndent);
- };
-
-}).call(BidiHandler.prototype);
-
-exports.BidiHandler = BidiHandler;
-});
-
-ace.define("ace/range",["require","exports","module"], function(acequire, exports, module) {
-"use strict";
-var comparePoints = function(p1, p2) {
- return p1.row - p2.row || p1.column - p2.column;
-};
-var Range = function(startRow, startColumn, endRow, endColumn) {
- this.start = {
- row: startRow,
- column: startColumn
- };
-
- this.end = {
- row: endRow,
- column: endColumn
- };
-};
-
-(function() {
- this.isEqual = function(range) {
- return this.start.row === range.start.row &&
- this.end.row === range.end.row &&
- this.start.column === range.start.column &&
- this.end.column === range.end.column;
- };
- this.toString = function() {
- return ("Range: [" + this.start.row + "/" + this.start.column +
- "] -> [" + this.end.row + "/" + this.end.column + "]");
- };
-
- this.contains = function(row, column) {
- return this.compare(row, column) == 0;
- };
- this.compareRange = function(range) {
- var cmp,
- end = range.end,
- start = range.start;
-
- cmp = this.compare(end.row, end.column);
- if (cmp == 1) {
- cmp = this.compare(start.row, start.column);
- if (cmp == 1) {
- return 2;
- } else if (cmp == 0) {
- return 1;
- } else {
- return 0;
- }
- } else if (cmp == -1) {
- return -2;
- } else {
- cmp = this.compare(start.row, start.column);
- if (cmp == -1) {
- return -1;
- } else if (cmp == 1) {
- return 42;
- } else {
- return 0;
- }
- }
- };
- this.comparePoint = function(p) {
- return this.compare(p.row, p.column);
- };
- this.containsRange = function(range) {
- return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
- };
- this.intersects = function(range) {
- var cmp = this.compareRange(range);
- return (cmp == -1 || cmp == 0 || cmp == 1);
- };
- this.isEnd = function(row, column) {
- return this.end.row == row && this.end.column == column;
- };
- this.isStart = function(row, column) {
- return this.start.row == row && this.start.column == column;
- };
- this.setStart = function(row, column) {
- if (typeof row == "object") {
- this.start.column = row.column;
- this.start.row = row.row;
- } else {
- this.start.row = row;
- this.start.column = column;
- }
- };
- this.setEnd = function(row, column) {
- if (typeof row == "object") {
- this.end.column = row.column;
- this.end.row = row.row;
- } else {
- this.end.row = row;
- this.end.column = column;
- }
- };
- this.inside = function(row, column) {
- if (this.compare(row, column) == 0) {
- if (this.isEnd(row, column) || this.isStart(row, column)) {
- return false;
- } else {
- return true;
- }
- }
- return false;
- };
- this.insideStart = function(row, column) {
- if (this.compare(row, column) == 0) {
- if (this.isEnd(row, column)) {
- return false;
- } else {
- return true;
- }
- }
- return false;
- };
- this.insideEnd = function(row, column) {
- if (this.compare(row, column) == 0) {
- if (this.isStart(row, column)) {
- return false;
- } else {
- return true;
- }
- }
- return false;
- };
- this.compare = function(row, column) {
- if (!this.isMultiLine()) {
- if (row === this.start.row) {
- return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
- }
- }
-
- if (row < this.start.row)
- return -1;
-
- if (row > this.end.row)
- return 1;
-
- if (this.start.row === row)
- return column >= this.start.column ? 0 : -1;
-
- if (this.end.row === row)
- return column <= this.end.column ? 0 : 1;
-
- return 0;
- };
- this.compareStart = function(row, column) {
- if (this.start.row == row && this.start.column == column) {
- return -1;
- } else {
- return this.compare(row, column);
- }
- };
- this.compareEnd = function(row, column) {
- if (this.end.row == row && this.end.column == column) {
- return 1;
- } else {
- return this.compare(row, column);
- }
- };
- this.compareInside = function(row, column) {
- if (this.end.row == row && this.end.column == column) {
- return 1;
- } else if (this.start.row == row && this.start.column == column) {
- return -1;
- } else {
- return this.compare(row, column);
- }
- };
- this.clipRows = function(firstRow, lastRow) {
- if (this.end.row > lastRow)
- var end = {row: lastRow + 1, column: 0};
- else if (this.end.row < firstRow)
- var end = {row: firstRow, column: 0};
-
- if (this.start.row > lastRow)
- var start = {row: lastRow + 1, column: 0};
- else if (this.start.row < firstRow)
- var start = {row: firstRow, column: 0};
-
- return Range.fromPoints(start || this.start, end || this.end);
- };
- this.extend = function(row, column) {
- var cmp = this.compare(row, column);
+ }
+ charWidth = this.charWidths[levels[++visualIdx]];
+ }
+
+ if (visualIdx > 0 && (levels[visualIdx - 1] % 2 !== 0) && (levels[visualIdx] % 2 === 0)){
+ if(posX < offset)
+ visualIdx--;
+ logicalIdx = this.bidiMap.logicalFromVisual[visualIdx];
- if (cmp == 0)
- return this;
- else if (cmp == -1)
- var start = {row: row, column: column};
- else
- var end = {row: row, column: column};
+ } else if (visualIdx > 0 && (levels[visualIdx - 1] % 2 === 0) && (levels[visualIdx] % 2 !== 0)){
+ logicalIdx = 1 + ((posX > offset) ? this.bidiMap.logicalFromVisual[visualIdx]
+ : this.bidiMap.logicalFromVisual[visualIdx - 1]);
- return Range.fromPoints(start || this.start, end || this.end);
- };
+ } else if ((this.isRtlDir && visualIdx === levels.length - 1 && charWidth === 0 && (levels[visualIdx - 1] % 2 === 0))
+ || (!this.isRtlDir && visualIdx === 0 && (levels[visualIdx] % 2 !== 0))){
+ logicalIdx = 1 + this.bidiMap.logicalFromVisual[visualIdx];
+ } else {
+ if (visualIdx > 0 && (levels[visualIdx - 1] % 2 !== 0) && charWidth !== 0)
+ visualIdx--;
+ logicalIdx = this.bidiMap.logicalFromVisual[visualIdx];
+ }
- this.isEmpty = function() {
- return (this.start.row === this.end.row && this.start.column === this.end.column);
- };
- this.isMultiLine = function() {
- return (this.start.row !== this.end.row);
- };
- this.clone = function() {
- return Range.fromPoints(this.start, this.end);
- };
- this.collapseRows = function() {
- if (this.end.column == 0)
- return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0);
- else
- return new Range(this.start.row, 0, this.end.row, 0);
- };
- this.toScreenRange = function(session) {
- var screenPosStart = session.documentToScreenPosition(this.start);
- var screenPosEnd = session.documentToScreenPosition(this.end);
+ if (logicalIdx === 0 && this.isRtlDir)
+ logicalIdx++;
- return new Range(
- screenPosStart.row, screenPosStart.column,
- screenPosEnd.row, screenPosEnd.column
- );
- };
- this.moveBy = function(row, column) {
- this.start.row += row;
- this.start.column += column;
- this.end.row += row;
- this.end.column += column;
+ return (logicalIdx + this.wrapIndent);
};
-}).call(Range.prototype);
-Range.fromPoints = function(start, end) {
- return new Range(start.row, start.column, end.row, end.column);
-};
-Range.comparePoints = comparePoints;
-
-Range.comparePoints = function(p1, p2) {
- return p1.row - p2.row || p1.column - p2.column;
-};
-
+}).call(BidiHandler.prototype);
-exports.Range = Range;
+exports.BidiHandler = BidiHandler;
});
ace.define("ace/selection",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter","ace/range"], function(acequire, exports, module) {
@@ -5413,20 +5287,24 @@ var Selection = function(session) {
this.doc = session.getDocument();
this.clearSelection();
- this.lead = this.selectionLead = this.doc.createAnchor(0, 0);
- this.anchor = this.selectionAnchor = this.doc.createAnchor(0, 0);
+ this.cursor = this.lead = this.doc.createAnchor(0, 0);
+ this.anchor = this.doc.createAnchor(0, 0);
+ this.$silent = false;
var self = this;
- this.lead.on("change", function(e) {
- self._emit("changeCursor");
- if (!self.$isEmpty)
+ this.cursor.on("change", function(e) {
+ self.$cursorChanged = true;
+ if (!self.$silent)
+ self._emit("changeCursor");
+ if (!self.$isEmpty && !self.$silent)
self._emit("changeSelection");
if (!self.$keepDesiredColumnOnChange && e.old.column != e.value.column)
self.$desiredColumn = null;
});
- this.selectionAnchor.on("change", function() {
- if (!self.$isEmpty)
+ this.anchor.on("change", function() {
+ self.$anchorChanged = true;
+ if (!self.$isEmpty && !self.$silent)
self._emit("changeSelection");
});
};
@@ -5435,58 +5313,31 @@ var Selection = function(session) {
oop.implement(this, EventEmitter);
this.isEmpty = function() {
- return (this.$isEmpty || (
+ return this.$isEmpty || (
this.anchor.row == this.lead.row &&
this.anchor.column == this.lead.column
- ));
+ );
};
this.isMultiLine = function() {
- if (this.isEmpty()) {
- return false;
- }
-
- return this.getRange().isMultiLine();
+ return !this.$isEmpty && this.anchor.row != this.cursor.row;
};
this.getCursor = function() {
return this.lead.getPosition();
};
this.setSelectionAnchor = function(row, column) {
+ this.$isEmpty = false;
this.anchor.setPosition(row, column);
-
- if (this.$isEmpty) {
- this.$isEmpty = false;
- this._emit("changeSelection");
- }
};
+ this.getAnchor =
this.getSelectionAnchor = function() {
if (this.$isEmpty)
return this.getSelectionLead();
- else
- return this.anchor.getPosition();
+
+ return this.anchor.getPosition();
};
this.getSelectionLead = function() {
return this.lead.getPosition();
};
- this.shiftSelection = function(columns) {
- if (this.$isEmpty) {
- this.moveCursorTo(this.lead.row, this.lead.column + columns);
- return;
- }
-
- var anchor = this.getSelectionAnchor();
- var lead = this.getSelectionLead();
-
- var isBackwards = this.isBackwards();
-
- if (!isBackwards || anchor.column !== 0)
- this.setSelectionAnchor(anchor.row, anchor.column + columns);
-
- if (isBackwards || lead.column !== 0) {
- this.$moveSelection(function() {
- this.moveCursorTo(lead.row, lead.column + columns);
- });
- }
- };
this.isBackwards = function() {
var anchor = this.anchor;
var lead = this.lead;
@@ -5496,15 +5347,12 @@ var Selection = function(session) {
var anchor = this.anchor;
var lead = this.lead;
- if (this.isEmpty())
+ if (this.$isEmpty)
return Range.fromPoints(lead, lead);
- if (this.isBackwards()) {
- return Range.fromPoints(lead, anchor);
- }
- else {
- return Range.fromPoints(anchor, lead);
- }
+ return this.isBackwards()
+ ? Range.fromPoints(lead, anchor)
+ : Range.fromPoints(anchor, lead);
};
this.clearSelection = function() {
if (!this.$isEmpty) {
@@ -5513,22 +5361,28 @@ var Selection = function(session) {
}
};
this.selectAll = function() {
- var lastRow = this.doc.getLength() - 1;
- this.setSelectionAnchor(0, 0);
- this.moveCursorTo(lastRow, this.doc.getLine(lastRow).length);
+ this.$setSelection(0, 0, Number.MAX_VALUE, Number.MAX_VALUE);
};
this.setRange =
this.setSelectionRange = function(range, reverse) {
- if (reverse) {
- this.setSelectionAnchor(range.end.row, range.end.column);
- this.selectTo(range.start.row, range.start.column);
- } else {
- this.setSelectionAnchor(range.start.row, range.start.column);
- this.selectTo(range.end.row, range.end.column);
- }
- if (this.getRange().isEmpty())
- this.$isEmpty = true;
- this.$desiredColumn = null;
+ var start = reverse ? range.end : range.start;
+ var end = reverse ? range.start : range.end;
+ this.$setSelection(start.row, start.column, end.row, end.column);
+ };
+
+ this.$setSelection = function(anchorRow, anchorColumn, cursorRow, cursorColumn) {
+ var wasEmpty = this.$isEmpty;
+ var wasMultiselect = this.inMultiSelectMode;
+ this.$silent = true;
+ this.$cursorChanged = this.$anchorChanged = false;
+ this.anchor.setPosition(anchorRow, anchorColumn);
+ this.cursor.setPosition(cursorRow, cursorColumn);
+ this.$isEmpty = !Range.comparePoints(this.anchor, this.cursor);
+ this.$silent = false;
+ if (this.$cursorChanged)
+ this._emit("changeCursor");
+ if (this.$cursorChanged || this.$anchorChanged || wasEmpty != this.$isEmpty || wasMultiselect)
+ this._emit("changeSelection");
};
this.$moveSelection = function(mover) {
@@ -5722,7 +5576,6 @@ var Selection = function(session) {
var line = this.doc.getLine(row);
var rightOfCursor = line.substring(column);
- var match;
this.session.nonTokenRe.lastIndex = 0;
this.session.tokenRe.lastIndex = 0;
var fold = this.session.getFoldAt(row, column, 1);
@@ -5730,7 +5583,7 @@ var Selection = function(session) {
this.moveCursorTo(fold.end.row, fold.end.column);
return;
}
- if (match = this.session.nonTokenRe.exec(rightOfCursor)) {
+ if (this.session.nonTokenRe.exec(rightOfCursor)) {
column += this.session.nonTokenRe.lastIndex;
this.session.nonTokenRe.lastIndex = 0;
rightOfCursor = line.substring(column);
@@ -5742,7 +5595,7 @@ var Selection = function(session) {
this.moveCursorWordRight();
return;
}
- if (match = this.session.tokenRe.exec(rightOfCursor)) {
+ if (this.session.tokenRe.exec(rightOfCursor)) {
column += this.session.tokenRe.lastIndex;
this.session.tokenRe.lastIndex = 0;
}
@@ -5764,10 +5617,9 @@ var Selection = function(session) {
}
var leftOfCursor = lang.stringReverse(str);
- var match;
this.session.nonTokenRe.lastIndex = 0;
this.session.tokenRe.lastIndex = 0;
- if (match = this.session.nonTokenRe.exec(leftOfCursor)) {
+ if (this.session.nonTokenRe.exec(leftOfCursor)) {
column -= this.session.nonTokenRe.lastIndex;
leftOfCursor = leftOfCursor.slice(this.session.nonTokenRe.lastIndex);
this.session.nonTokenRe.lastIndex = 0;
@@ -5779,7 +5631,7 @@ var Selection = function(session) {
this.moveCursorWordLeft();
return;
}
- if (match = this.session.tokenRe.exec(leftOfCursor)) {
+ if (this.session.tokenRe.exec(leftOfCursor)) {
column -= this.session.tokenRe.lastIndex;
this.session.tokenRe.lastIndex = 0;
}
@@ -5788,12 +5640,12 @@ var Selection = function(session) {
};
this.$shortWordEndIndex = function(rightOfCursor) {
- var match, index = 0, ch;
+ var index = 0, ch;
var whitespaceRe = /\s/;
var tokenRe = this.session.tokenRe;
tokenRe.lastIndex = 0;
- if (match = this.session.tokenRe.exec(rightOfCursor)) {
+ if (this.session.tokenRe.exec(rightOfCursor)) {
index = this.session.tokenRe.lastIndex;
} else {
while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch))
@@ -5982,9 +5834,9 @@ var Selection = function(session) {
try {
func(this);
var end = this.getCursor();
- return Range.fromPoints(start,end);
+ return Range.fromPoints(start, end);
} catch(e) {
- return Range.fromPoints(start,start);
+ return Range.fromPoints(start, start);
} finally {
this.moveCursorToPosition(start);
}
@@ -6015,8 +5867,9 @@ var Selection = function(session) {
this.addRange(r, true);
}
return;
- } else
+ } else {
data = data[0];
+ }
}
if (this.rangeList)
this.toSingleRange(data);
@@ -6169,7 +6022,7 @@ var Tokenizer = function(rules) {
this.removeCapturingGroups = function(src) {
var r = src.replace(
- /\[(?:\\.|[^\]])*?\]|\\.|\(\?[:=!]|(\()/g,
+ /\\.|\[(?:\\.|[^\\\]])*|\(\?[:=!]|(\()/g,
function(x, y) {return y ? "(?:" : x;}
);
return r;
@@ -6693,7 +6546,7 @@ var TokenIterator = function(session, initialRow, initialColumn) {
var column = this.getCurrentTokenColumn();
return new Range(this.$row, column, this.$row, column + token.value.length);
};
-
+
}).call(TokenIterator.prototype);
exports.TokenIterator = TokenIterator;
@@ -6925,7 +6778,7 @@ var CstyleBehaviour = function(options) {
this.add("string_dquotes", "insertion", function(state, action, editor, session, text) {
var quotes = session.$mode.$quotes || defaultQuotes;
if (text.length == 1 && quotes[text]) {
- if (this.lineCommentStart && this.lineCommentStart.indexOf(text) != -1)
+ if (this.lineCommentStart && this.lineCommentStart.indexOf(text) != -1)
return;
initContext(editor);
var quote = text;
@@ -6938,15 +6791,15 @@ var CstyleBehaviour = function(options) {
var line = session.doc.getLine(cursor.row);
var leftChar = line.substring(cursor.column-1, cursor.column);
var rightChar = line.substring(cursor.column, cursor.column + 1);
-
+
var token = session.getTokenAt(cursor.row, cursor.column);
var rightToken = session.getTokenAt(cursor.row, cursor.column + 1);
if (leftChar == "\\" && token && /escape/.test(token.type))
return null;
-
+
var stringBefore = token && /string|escape/.test(token.type);
var stringAfter = !rightToken || /string|escape/.test(rightToken.type);
-
+
var pair;
if (rightChar == quote) {
pair = stringBefore !== stringAfter;
@@ -6977,8 +6830,10 @@ var CstyleBehaviour = function(options) {
});
this.add("string_dquotes", "deletion", function(state, action, editor, session, range) {
+ var quotes = session.$mode.$quotes || defaultQuotes;
+
var selected = session.doc.getTextRange(range);
- if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
+ if (!range.isMultiLine() && quotes.hasOwnProperty(selected)) {
initContext(editor);
var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
@@ -6991,7 +6846,7 @@ var CstyleBehaviour = function(options) {
};
-
+
CstyleBehaviour.isSaneInsertion = function(editor, session) {
var cursor = editor.getCursorPosition();
var iterator = new TokenIterator(session, cursor.row, cursor.column);
@@ -7065,58 +6920,23 @@ exports.CstyleBehaviour = CstyleBehaviour;
ace.define("ace/unicode",["require","exports","module"], function(acequire, exports, module) {
"use strict";
-exports.packages = {};
-
-addUnicodePackage({
- L: "0041-005A0061-007A00AA00B500BA00C0-00D600D8-00F600F8-02C102C6-02D102E0-02E402EC02EE0370-037403760377037A-037D03860388-038A038C038E-03A103A3-03F503F7-0481048A-05250531-055605590561-058705D0-05EA05F0-05F20621-064A066E066F0671-06D306D506E506E606EE06EF06FA-06FC06FF07100712-072F074D-07A507B107CA-07EA07F407F507FA0800-0815081A082408280904-0939093D09500958-0961097109720979-097F0985-098C098F09900993-09A809AA-09B009B209B6-09B909BD09CE09DC09DD09DF-09E109F009F10A05-0A0A0A0F0A100A13-0A280A2A-0A300A320A330A350A360A380A390A59-0A5C0A5E0A72-0A740A85-0A8D0A8F-0A910A93-0AA80AAA-0AB00AB20AB30AB5-0AB90ABD0AD00AE00AE10B05-0B0C0B0F0B100B13-0B280B2A-0B300B320B330B35-0B390B3D0B5C0B5D0B5F-0B610B710B830B85-0B8A0B8E-0B900B92-0B950B990B9A0B9C0B9E0B9F0BA30BA40BA8-0BAA0BAE-0BB90BD00C05-0C0C0C0E-0C100C12-0C280C2A-0C330C35-0C390C3D0C580C590C600C610C85-0C8C0C8E-0C900C92-0CA80CAA-0CB30CB5-0CB90CBD0CDE0CE00CE10D05-0D0C0D0E-0D100D12-0D280D2A-0D390D3D0D600D610D7A-0D7F0D85-0D960D9A-0DB10DB3-0DBB0DBD0DC0-0DC60E01-0E300E320E330E40-0E460E810E820E840E870E880E8A0E8D0E94-0E970E99-0E9F0EA1-0EA30EA50EA70EAA0EAB0EAD-0EB00EB20EB30EBD0EC0-0EC40EC60EDC0EDD0F000F40-0F470F49-0F6C0F88-0F8B1000-102A103F1050-1055105A-105D106110651066106E-10701075-1081108E10A0-10C510D0-10FA10FC1100-1248124A-124D1250-12561258125A-125D1260-1288128A-128D1290-12B012B2-12B512B8-12BE12C012C2-12C512C8-12D612D8-13101312-13151318-135A1380-138F13A0-13F41401-166C166F-167F1681-169A16A0-16EA1700-170C170E-17111720-17311740-17511760-176C176E-17701780-17B317D717DC1820-18771880-18A818AA18B0-18F51900-191C1950-196D1970-19741980-19AB19C1-19C71A00-1A161A20-1A541AA71B05-1B331B45-1B4B1B83-1BA01BAE1BAF1C00-1C231C4D-1C4F1C5A-1C7D1CE9-1CEC1CEE-1CF11D00-1DBF1E00-1F151F18-1F1D1F20-1F451F48-1F4D1F50-1F571F591F5B1F5D1F5F-1F7D1F80-1FB41FB6-1FBC1FBE1FC2-1FC41FC6-1FCC1FD0-1FD31FD6-1FDB1FE0-1FEC1FF2-1FF41FF6-1FFC2071207F2090-209421022107210A-211321152119-211D212421262128212A-212D212F-2139213C-213F2145-2149214E218321842C00-2C2E2C30-2C5E2C60-2CE42CEB-2CEE2D00-2D252D30-2D652D6F2D80-2D962DA0-2DA62DA8-2DAE2DB0-2DB62DB8-2DBE2DC0-2DC62DC8-2DCE2DD0-2DD62DD8-2DDE2E2F300530063031-3035303B303C3041-3096309D-309F30A1-30FA30FC-30FF3105-312D3131-318E31A0-31B731F0-31FF3400-4DB54E00-9FCBA000-A48CA4D0-A4FDA500-A60CA610-A61FA62AA62BA640-A65FA662-A66EA67F-A697A6A0-A6E5A717-A71FA722-A788A78BA78CA7FB-A801A803-A805A807-A80AA80C-A822A840-A873A882-A8B3A8F2-A8F7A8FBA90A-A925A930-A946A960-A97CA984-A9B2A9CFAA00-AA28AA40-AA42AA44-AA4BAA60-AA76AA7AAA80-AAAFAAB1AAB5AAB6AAB9-AABDAAC0AAC2AADB-AADDABC0-ABE2AC00-D7A3D7B0-D7C6D7CB-D7FBF900-FA2DFA30-FA6DFA70-FAD9FB00-FB06FB13-FB17FB1DFB1F-FB28FB2A-FB36FB38-FB3CFB3EFB40FB41FB43FB44FB46-FBB1FBD3-FD3DFD50-FD8FFD92-FDC7FDF0-FDFBFE70-FE74FE76-FEFCFF21-FF3AFF41-FF5AFF66-FFBEFFC2-FFC7FFCA-FFCFFFD2-FFD7FFDA-FFDC",
- Ll: "0061-007A00AA00B500BA00DF-00F600F8-00FF01010103010501070109010B010D010F01110113011501170119011B011D011F01210123012501270129012B012D012F01310133013501370138013A013C013E014001420144014601480149014B014D014F01510153015501570159015B015D015F01610163016501670169016B016D016F0171017301750177017A017C017E-0180018301850188018C018D019201950199-019B019E01A101A301A501A801AA01AB01AD01B001B401B601B901BA01BD-01BF01C601C901CC01CE01D001D201D401D601D801DA01DC01DD01DF01E101E301E501E701E901EB01ED01EF01F001F301F501F901FB01FD01FF02010203020502070209020B020D020F02110213021502170219021B021D021F02210223022502270229022B022D022F02310233-0239023C023F0240024202470249024B024D024F-02930295-02AF037103730377037B-037D039003AC-03CE03D003D103D5-03D703D903DB03DD03DF03E103E303E503E703E903EB03ED03EF-03F303F503F803FB03FC0430-045F04610463046504670469046B046D046F04710473047504770479047B047D047F0481048B048D048F04910493049504970499049B049D049F04A104A304A504A704A904AB04AD04AF04B104B304B504B704B904BB04BD04BF04C204C404C604C804CA04CC04CE04CF04D104D304D504D704D904DB04DD04DF04E104E304E504E704E904EB04ED04EF04F104F304F504F704F904FB04FD04FF05010503050505070509050B050D050F05110513051505170519051B051D051F0521052305250561-05871D00-1D2B1D62-1D771D79-1D9A1E011E031E051E071E091E0B1E0D1E0F1E111E131E151E171E191E1B1E1D1E1F1E211E231E251E271E291E2B1E2D1E2F1E311E331E351E371E391E3B1E3D1E3F1E411E431E451E471E491E4B1E4D1E4F1E511E531E551E571E591E5B1E5D1E5F1E611E631E651E671E691E6B1E6D1E6F1E711E731E751E771E791E7B1E7D1E7F1E811E831E851E871E891E8B1E8D1E8F1E911E931E95-1E9D1E9F1EA11EA31EA51EA71EA91EAB1EAD1EAF1EB11EB31EB51EB71EB91EBB1EBD1EBF1EC11EC31EC51EC71EC91ECB1ECD1ECF1ED11ED31ED51ED71ED91EDB1EDD1EDF1EE11EE31EE51EE71EE91EEB1EED1EEF1EF11EF31EF51EF71EF91EFB1EFD1EFF-1F071F10-1F151F20-1F271F30-1F371F40-1F451F50-1F571F60-1F671F70-1F7D1F80-1F871F90-1F971FA0-1FA71FB0-1FB41FB61FB71FBE1FC2-1FC41FC61FC71FD0-1FD31FD61FD71FE0-1FE71FF2-1FF41FF61FF7210A210E210F2113212F21342139213C213D2146-2149214E21842C30-2C5E2C612C652C662C682C6A2C6C2C712C732C742C76-2C7C2C812C832C852C872C892C8B2C8D2C8F2C912C932C952C972C992C9B2C9D2C9F2CA12CA32CA52CA72CA92CAB2CAD2CAF2CB12CB32CB52CB72CB92CBB2CBD2CBF2CC12CC32CC52CC72CC92CCB2CCD2CCF2CD12CD32CD52CD72CD92CDB2CDD2CDF2CE12CE32CE42CEC2CEE2D00-2D25A641A643A645A647A649A64BA64DA64FA651A653A655A657A659A65BA65DA65FA663A665A667A669A66BA66DA681A683A685A687A689A68BA68DA68FA691A693A695A697A723A725A727A729A72BA72DA72F-A731A733A735A737A739A73BA73DA73FA741A743A745A747A749A74BA74DA74FA751A753A755A757A759A75BA75DA75FA761A763A765A767A769A76BA76DA76FA771-A778A77AA77CA77FA781A783A785A787A78CFB00-FB06FB13-FB17FF41-FF5A",
- Lu: "0041-005A00C0-00D600D8-00DE01000102010401060108010A010C010E01100112011401160118011A011C011E01200122012401260128012A012C012E01300132013401360139013B013D013F0141014301450147014A014C014E01500152015401560158015A015C015E01600162016401660168016A016C016E017001720174017601780179017B017D018101820184018601870189-018B018E-0191019301940196-0198019C019D019F01A001A201A401A601A701A901AC01AE01AF01B1-01B301B501B701B801BC01C401C701CA01CD01CF01D101D301D501D701D901DB01DE01E001E201E401E601E801EA01EC01EE01F101F401F6-01F801FA01FC01FE02000202020402060208020A020C020E02100212021402160218021A021C021E02200222022402260228022A022C022E02300232023A023B023D023E02410243-02460248024A024C024E03700372037603860388-038A038C038E038F0391-03A103A3-03AB03CF03D2-03D403D803DA03DC03DE03E003E203E403E603E803EA03EC03EE03F403F703F903FA03FD-042F04600462046404660468046A046C046E04700472047404760478047A047C047E0480048A048C048E04900492049404960498049A049C049E04A004A204A404A604A804AA04AC04AE04B004B204B404B604B804BA04BC04BE04C004C104C304C504C704C904CB04CD04D004D204D404D604D804DA04DC04DE04E004E204E404E604E804EA04EC04EE04F004F204F404F604F804FA04FC04FE05000502050405060508050A050C050E05100512051405160518051A051C051E0520052205240531-055610A0-10C51E001E021E041E061E081E0A1E0C1E0E1E101E121E141E161E181E1A1E1C1E1E1E201E221E241E261E281E2A1E2C1E2E1E301E321E341E361E381E3A1E3C1E3E1E401E421E441E461E481E4A1E4C1E4E1E501E521E541E561E581E5A1E5C1E5E1E601E621E641E661E681E6A1E6C1E6E1E701E721E741E761E781E7A1E7C1E7E1E801E821E841E861E881E8A1E8C1E8E1E901E921E941E9E1EA01EA21EA41EA61EA81EAA1EAC1EAE1EB01EB21EB41EB61EB81EBA1EBC1EBE1EC01EC21EC41EC61EC81ECA1ECC1ECE1ED01ED21ED41ED61ED81EDA1EDC1EDE1EE01EE21EE41EE61EE81EEA1EEC1EEE1EF01EF21EF41EF61EF81EFA1EFC1EFE1F08-1F0F1F18-1F1D1F28-1F2F1F38-1F3F1F48-1F4D1F591F5B1F5D1F5F1F68-1F6F1FB8-1FBB1FC8-1FCB1FD8-1FDB1FE8-1FEC1FF8-1FFB21022107210B-210D2110-211221152119-211D212421262128212A-212D2130-2133213E213F214521832C00-2C2E2C602C62-2C642C672C692C6B2C6D-2C702C722C752C7E-2C802C822C842C862C882C8A2C8C2C8E2C902C922C942C962C982C9A2C9C2C9E2CA02CA22CA42CA62CA82CAA2CAC2CAE2CB02CB22CB42CB62CB82CBA2CBC2CBE2CC02CC22CC42CC62CC82CCA2CCC2CCE2CD02CD22CD42CD62CD82CDA2CDC2CDE2CE02CE22CEB2CEDA640A642A644A646A648A64AA64CA64EA650A652A654A656A658A65AA65CA65EA662A664A666A668A66AA66CA680A682A684A686A688A68AA68CA68EA690A692A694A696A722A724A726A728A72AA72CA72EA732A734A736A738A73AA73CA73EA740A742A744A746A748A74AA74CA74EA750A752A754A756A758A75AA75CA75EA760A762A764A766A768A76AA76CA76EA779A77BA77DA77EA780A782A784A786A78BFF21-FF3A",
- Lt: "01C501C801CB01F21F88-1F8F1F98-1F9F1FA8-1FAF1FBC1FCC1FFC",
- Lm: "02B0-02C102C6-02D102E0-02E402EC02EE0374037A0559064006E506E607F407F507FA081A0824082809710E460EC610FC17D718431AA71C78-1C7D1D2C-1D611D781D9B-1DBF2071207F2090-20942C7D2D6F2E2F30053031-3035303B309D309E30FC-30FEA015A4F8-A4FDA60CA67FA717-A71FA770A788A9CFAA70AADDFF70FF9EFF9F",
- Lo: "01BB01C0-01C3029405D0-05EA05F0-05F20621-063F0641-064A066E066F0671-06D306D506EE06EF06FA-06FC06FF07100712-072F074D-07A507B107CA-07EA0800-08150904-0939093D09500958-096109720979-097F0985-098C098F09900993-09A809AA-09B009B209B6-09B909BD09CE09DC09DD09DF-09E109F009F10A05-0A0A0A0F0A100A13-0A280A2A-0A300A320A330A350A360A380A390A59-0A5C0A5E0A72-0A740A85-0A8D0A8F-0A910A93-0AA80AAA-0AB00AB20AB30AB5-0AB90ABD0AD00AE00AE10B05-0B0C0B0F0B100B13-0B280B2A-0B300B320B330B35-0B390B3D0B5C0B5D0B5F-0B610B710B830B85-0B8A0B8E-0B900B92-0B950B990B9A0B9C0B9E0B9F0BA30BA40BA8-0BAA0BAE-0BB90BD00C05-0C0C0C0E-0C100C12-0C280C2A-0C330C35-0C390C3D0C580C590C600C610C85-0C8C0C8E-0C900C92-0CA80CAA-0CB30CB5-0CB90CBD0CDE0CE00CE10D05-0D0C0D0E-0D100D12-0D280D2A-0D390D3D0D600D610D7A-0D7F0D85-0D960D9A-0DB10DB3-0DBB0DBD0DC0-0DC60E01-0E300E320E330E40-0E450E810E820E840E870E880E8A0E8D0E94-0E970E99-0E9F0EA1-0EA30EA50EA70EAA0EAB0EAD-0EB00EB20EB30EBD0EC0-0EC40EDC0EDD0F000F40-0F470F49-0F6C0F88-0F8B1000-102A103F1050-1055105A-105D106110651066106E-10701075-1081108E10D0-10FA1100-1248124A-124D1250-12561258125A-125D1260-1288128A-128D1290-12B012B2-12B512B8-12BE12C012C2-12C512C8-12D612D8-13101312-13151318-135A1380-138F13A0-13F41401-166C166F-167F1681-169A16A0-16EA1700-170C170E-17111720-17311740-17511760-176C176E-17701780-17B317DC1820-18421844-18771880-18A818AA18B0-18F51900-191C1950-196D1970-19741980-19AB19C1-19C71A00-1A161A20-1A541B05-1B331B45-1B4B1B83-1BA01BAE1BAF1C00-1C231C4D-1C4F1C5A-1C771CE9-1CEC1CEE-1CF12135-21382D30-2D652D80-2D962DA0-2DA62DA8-2DAE2DB0-2DB62DB8-2DBE2DC0-2DC62DC8-2DCE2DD0-2DD62DD8-2DDE3006303C3041-3096309F30A1-30FA30FF3105-312D3131-318E31A0-31B731F0-31FF3400-4DB54E00-9FCBA000-A014A016-A48CA4D0-A4F7A500-A60BA610-A61FA62AA62BA66EA6A0-A6E5A7FB-A801A803-A805A807-A80AA80C-A822A840-A873A882-A8B3A8F2-A8F7A8FBA90A-A925A930-A946A960-A97CA984-A9B2AA00-AA28AA40-AA42AA44-AA4BAA60-AA6FAA71-AA76AA7AAA80-AAAFAAB1AAB5AAB6AAB9-AABDAAC0AAC2AADBAADCABC0-ABE2AC00-D7A3D7B0-D7C6D7CB-D7FBF900-FA2DFA30-FA6DFA70-FAD9FB1DFB1F-FB28FB2A-FB36FB38-FB3CFB3EFB40FB41FB43FB44FB46-FBB1FBD3-FD3DFD50-FD8FFD92-FDC7FDF0-FDFBFE70-FE74FE76-FEFCFF66-FF6FFF71-FF9DFFA0-FFBEFFC2-FFC7FFCA-FFCFFFD2-FFD7FFDA-FFDC",
- M: "0300-036F0483-04890591-05BD05BF05C105C205C405C505C70610-061A064B-065E067006D6-06DC06DE-06E406E706E806EA-06ED07110730-074A07A6-07B007EB-07F30816-0819081B-08230825-08270829-082D0900-0903093C093E-094E0951-0955096209630981-098309BC09BE-09C409C709C809CB-09CD09D709E209E30A01-0A030A3C0A3E-0A420A470A480A4B-0A4D0A510A700A710A750A81-0A830ABC0ABE-0AC50AC7-0AC90ACB-0ACD0AE20AE30B01-0B030B3C0B3E-0B440B470B480B4B-0B4D0B560B570B620B630B820BBE-0BC20BC6-0BC80BCA-0BCD0BD70C01-0C030C3E-0C440C46-0C480C4A-0C4D0C550C560C620C630C820C830CBC0CBE-0CC40CC6-0CC80CCA-0CCD0CD50CD60CE20CE30D020D030D3E-0D440D46-0D480D4A-0D4D0D570D620D630D820D830DCA0DCF-0DD40DD60DD8-0DDF0DF20DF30E310E34-0E3A0E47-0E4E0EB10EB4-0EB90EBB0EBC0EC8-0ECD0F180F190F350F370F390F3E0F3F0F71-0F840F860F870F90-0F970F99-0FBC0FC6102B-103E1056-1059105E-10601062-10641067-106D1071-10741082-108D108F109A-109D135F1712-17141732-1734175217531772177317B6-17D317DD180B-180D18A91920-192B1930-193B19B0-19C019C819C91A17-1A1B1A55-1A5E1A60-1A7C1A7F1B00-1B041B34-1B441B6B-1B731B80-1B821BA1-1BAA1C24-1C371CD0-1CD21CD4-1CE81CED1CF21DC0-1DE61DFD-1DFF20D0-20F02CEF-2CF12DE0-2DFF302A-302F3099309AA66F-A672A67CA67DA6F0A6F1A802A806A80BA823-A827A880A881A8B4-A8C4A8E0-A8F1A926-A92DA947-A953A980-A983A9B3-A9C0AA29-AA36AA43AA4CAA4DAA7BAAB0AAB2-AAB4AAB7AAB8AABEAABFAAC1ABE3-ABEAABECABEDFB1EFE00-FE0FFE20-FE26",
- Mn: "0300-036F0483-04870591-05BD05BF05C105C205C405C505C70610-061A064B-065E067006D6-06DC06DF-06E406E706E806EA-06ED07110730-074A07A6-07B007EB-07F30816-0819081B-08230825-08270829-082D0900-0902093C0941-0948094D0951-095509620963098109BC09C1-09C409CD09E209E30A010A020A3C0A410A420A470A480A4B-0A4D0A510A700A710A750A810A820ABC0AC1-0AC50AC70AC80ACD0AE20AE30B010B3C0B3F0B41-0B440B4D0B560B620B630B820BC00BCD0C3E-0C400C46-0C480C4A-0C4D0C550C560C620C630CBC0CBF0CC60CCC0CCD0CE20CE30D41-0D440D4D0D620D630DCA0DD2-0DD40DD60E310E34-0E3A0E47-0E4E0EB10EB4-0EB90EBB0EBC0EC8-0ECD0F180F190F350F370F390F71-0F7E0F80-0F840F860F870F90-0F970F99-0FBC0FC6102D-10301032-10371039103A103D103E10581059105E-10601071-1074108210851086108D109D135F1712-17141732-1734175217531772177317B7-17BD17C617C9-17D317DD180B-180D18A91920-19221927192819321939-193B1A171A181A561A58-1A5E1A601A621A65-1A6C1A73-1A7C1A7F1B00-1B031B341B36-1B3A1B3C1B421B6B-1B731B801B811BA2-1BA51BA81BA91C2C-1C331C361C371CD0-1CD21CD4-1CE01CE2-1CE81CED1DC0-1DE61DFD-1DFF20D0-20DC20E120E5-20F02CEF-2CF12DE0-2DFF302A-302F3099309AA66FA67CA67DA6F0A6F1A802A806A80BA825A826A8C4A8E0-A8F1A926-A92DA947-A951A980-A982A9B3A9B6-A9B9A9BCAA29-AA2EAA31AA32AA35AA36AA43AA4CAAB0AAB2-AAB4AAB7AAB8AABEAABFAAC1ABE5ABE8ABEDFB1EFE00-FE0FFE20-FE26",
- Mc: "0903093E-09400949-094C094E0982098309BE-09C009C709C809CB09CC09D70A030A3E-0A400A830ABE-0AC00AC90ACB0ACC0B020B030B3E0B400B470B480B4B0B4C0B570BBE0BBF0BC10BC20BC6-0BC80BCA-0BCC0BD70C01-0C030C41-0C440C820C830CBE0CC0-0CC40CC70CC80CCA0CCB0CD50CD60D020D030D3E-0D400D46-0D480D4A-0D4C0D570D820D830DCF-0DD10DD8-0DDF0DF20DF30F3E0F3F0F7F102B102C10311038103B103C105610571062-10641067-106D108310841087-108C108F109A-109C17B617BE-17C517C717C81923-19261929-192B193019311933-193819B0-19C019C819C91A19-1A1B1A551A571A611A631A641A6D-1A721B041B351B3B1B3D-1B411B431B441B821BA11BA61BA71BAA1C24-1C2B1C341C351CE11CF2A823A824A827A880A881A8B4-A8C3A952A953A983A9B4A9B5A9BAA9BBA9BD-A9C0AA2FAA30AA33AA34AA4DAA7BABE3ABE4ABE6ABE7ABE9ABEAABEC",
- Me: "0488048906DE20DD-20E020E2-20E4A670-A672",
- N: "0030-003900B200B300B900BC-00BE0660-066906F0-06F907C0-07C90966-096F09E6-09EF09F4-09F90A66-0A6F0AE6-0AEF0B66-0B6F0BE6-0BF20C66-0C6F0C78-0C7E0CE6-0CEF0D66-0D750E50-0E590ED0-0ED90F20-0F331040-10491090-10991369-137C16EE-16F017E0-17E917F0-17F91810-18191946-194F19D0-19DA1A80-1A891A90-1A991B50-1B591BB0-1BB91C40-1C491C50-1C5920702074-20792080-20892150-21822185-21892460-249B24EA-24FF2776-27932CFD30073021-30293038-303A3192-31953220-32293251-325F3280-328932B1-32BFA620-A629A6E6-A6EFA830-A835A8D0-A8D9A900-A909A9D0-A9D9AA50-AA59ABF0-ABF9FF10-FF19",
- Nd: "0030-00390660-066906F0-06F907C0-07C90966-096F09E6-09EF0A66-0A6F0AE6-0AEF0B66-0B6F0BE6-0BEF0C66-0C6F0CE6-0CEF0D66-0D6F0E50-0E590ED0-0ED90F20-0F291040-10491090-109917E0-17E91810-18191946-194F19D0-19DA1A80-1A891A90-1A991B50-1B591BB0-1BB91C40-1C491C50-1C59A620-A629A8D0-A8D9A900-A909A9D0-A9D9AA50-AA59ABF0-ABF9FF10-FF19",
- Nl: "16EE-16F02160-21822185-218830073021-30293038-303AA6E6-A6EF",
- No: "00B200B300B900BC-00BE09F4-09F90BF0-0BF20C78-0C7E0D70-0D750F2A-0F331369-137C17F0-17F920702074-20792080-20892150-215F21892460-249B24EA-24FF2776-27932CFD3192-31953220-32293251-325F3280-328932B1-32BFA830-A835",
- P: "0021-00230025-002A002C-002F003A003B003F0040005B-005D005F007B007D00A100AB00B700BB00BF037E0387055A-055F0589058A05BE05C005C305C605F305F40609060A060C060D061B061E061F066A-066D06D40700-070D07F7-07F90830-083E0964096509700DF40E4F0E5A0E5B0F04-0F120F3A-0F3D0F850FD0-0FD4104A-104F10FB1361-13681400166D166E169B169C16EB-16ED1735173617D4-17D617D8-17DA1800-180A1944194519DE19DF1A1E1A1F1AA0-1AA61AA8-1AAD1B5A-1B601C3B-1C3F1C7E1C7F1CD32010-20272030-20432045-20512053-205E207D207E208D208E2329232A2768-277527C527C627E6-27EF2983-299829D8-29DB29FC29FD2CF9-2CFC2CFE2CFF2E00-2E2E2E302E313001-30033008-30113014-301F3030303D30A030FBA4FEA4FFA60D-A60FA673A67EA6F2-A6F7A874-A877A8CEA8CFA8F8-A8FAA92EA92FA95FA9C1-A9CDA9DEA9DFAA5C-AA5FAADEAADFABEBFD3EFD3FFE10-FE19FE30-FE52FE54-FE61FE63FE68FE6AFE6BFF01-FF03FF05-FF0AFF0C-FF0FFF1AFF1BFF1FFF20FF3B-FF3DFF3FFF5BFF5DFF5F-FF65",
- Pd: "002D058A05BE140018062010-20152E172E1A301C303030A0FE31FE32FE58FE63FF0D",
- Ps: "0028005B007B0F3A0F3C169B201A201E2045207D208D23292768276A276C276E27702772277427C527E627E827EA27EC27EE2983298529872989298B298D298F299129932995299729D829DA29FC2E222E242E262E283008300A300C300E3010301430163018301A301DFD3EFE17FE35FE37FE39FE3BFE3DFE3FFE41FE43FE47FE59FE5BFE5DFF08FF3BFF5BFF5FFF62",
- Pe: "0029005D007D0F3B0F3D169C2046207E208E232A2769276B276D276F27712773277527C627E727E927EB27ED27EF298429862988298A298C298E2990299229942996299829D929DB29FD2E232E252E272E293009300B300D300F3011301530173019301B301E301FFD3FFE18FE36FE38FE3AFE3CFE3EFE40FE42FE44FE48FE5AFE5CFE5EFF09FF3DFF5DFF60FF63",
- Pi: "00AB2018201B201C201F20392E022E042E092E0C2E1C2E20",
- Pf: "00BB2019201D203A2E032E052E0A2E0D2E1D2E21",
- Pc: "005F203F20402054FE33FE34FE4D-FE4FFF3F",
- Po: "0021-00230025-0027002A002C002E002F003A003B003F0040005C00A100B700BF037E0387055A-055F058905C005C305C605F305F40609060A060C060D061B061E061F066A-066D06D40700-070D07F7-07F90830-083E0964096509700DF40E4F0E5A0E5B0F04-0F120F850FD0-0FD4104A-104F10FB1361-1368166D166E16EB-16ED1735173617D4-17D617D8-17DA1800-18051807-180A1944194519DE19DF1A1E1A1F1AA0-1AA61AA8-1AAD1B5A-1B601C3B-1C3F1C7E1C7F1CD3201620172020-20272030-2038203B-203E2041-20432047-205120532055-205E2CF9-2CFC2CFE2CFF2E002E012E06-2E082E0B2E0E-2E162E182E192E1B2E1E2E1F2E2A-2E2E2E302E313001-3003303D30FBA4FEA4FFA60D-A60FA673A67EA6F2-A6F7A874-A877A8CEA8CFA8F8-A8FAA92EA92FA95FA9C1-A9CDA9DEA9DFAA5C-AA5FAADEAADFABEBFE10-FE16FE19FE30FE45FE46FE49-FE4CFE50-FE52FE54-FE57FE5F-FE61FE68FE6AFE6BFF01-FF03FF05-FF07FF0AFF0CFF0EFF0FFF1AFF1BFF1FFF20FF3CFF61FF64FF65",
- S: "0024002B003C-003E005E0060007C007E00A2-00A900AC00AE-00B100B400B600B800D700F702C2-02C502D2-02DF02E5-02EB02ED02EF-02FF03750384038503F604820606-0608060B060E060F06E906FD06FE07F609F209F309FA09FB0AF10B700BF3-0BFA0C7F0CF10CF20D790E3F0F01-0F030F13-0F170F1A-0F1F0F340F360F380FBE-0FC50FC7-0FCC0FCE0FCF0FD5-0FD8109E109F13601390-139917DB194019E0-19FF1B61-1B6A1B74-1B7C1FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE20442052207A-207C208A-208C20A0-20B8210021012103-21062108210921142116-2118211E-2123212521272129212E213A213B2140-2144214A-214D214F2190-2328232B-23E82400-24262440-244A249C-24E92500-26CD26CF-26E126E326E8-26FF2701-27042706-2709270C-27272729-274B274D274F-27522756-275E2761-276727942798-27AF27B1-27BE27C0-27C427C7-27CA27CC27D0-27E527F0-29822999-29D729DC-29FB29FE-2B4C2B50-2B592CE5-2CEA2E80-2E992E9B-2EF32F00-2FD52FF0-2FFB300430123013302030363037303E303F309B309C319031913196-319F31C0-31E33200-321E322A-32503260-327F328A-32B032C0-32FE3300-33FF4DC0-4DFFA490-A4C6A700-A716A720A721A789A78AA828-A82BA836-A839AA77-AA79FB29FDFCFDFDFE62FE64-FE66FE69FF04FF0BFF1C-FF1EFF3EFF40FF5CFF5EFFE0-FFE6FFE8-FFEEFFFCFFFD",
- Sm: "002B003C-003E007C007E00AC00B100D700F703F60606-060820442052207A-207C208A-208C2140-2144214B2190-2194219A219B21A021A321A621AE21CE21CF21D221D421F4-22FF2308-230B23202321237C239B-23B323DC-23E125B725C125F8-25FF266F27C0-27C427C7-27CA27CC27D0-27E527F0-27FF2900-29822999-29D729DC-29FB29FE-2AFF2B30-2B442B47-2B4CFB29FE62FE64-FE66FF0BFF1C-FF1EFF5CFF5EFFE2FFE9-FFEC",
- Sc: "002400A2-00A5060B09F209F309FB0AF10BF90E3F17DB20A0-20B8A838FDFCFE69FF04FFE0FFE1FFE5FFE6",
- Sk: "005E006000A800AF00B400B802C2-02C502D2-02DF02E5-02EB02ED02EF-02FF0375038403851FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE309B309CA700-A716A720A721A789A78AFF3EFF40FFE3",
- So: "00A600A700A900AE00B000B60482060E060F06E906FD06FE07F609FA0B700BF3-0BF80BFA0C7F0CF10CF20D790F01-0F030F13-0F170F1A-0F1F0F340F360F380FBE-0FC50FC7-0FCC0FCE0FCF0FD5-0FD8109E109F13601390-1399194019E0-19FF1B61-1B6A1B74-1B7C210021012103-21062108210921142116-2118211E-2123212521272129212E213A213B214A214C214D214F2195-2199219C-219F21A121A221A421A521A7-21AD21AF-21CD21D021D121D321D5-21F32300-2307230C-231F2322-2328232B-237B237D-239A23B4-23DB23E2-23E82400-24262440-244A249C-24E92500-25B625B8-25C025C2-25F72600-266E2670-26CD26CF-26E126E326E8-26FF2701-27042706-2709270C-27272729-274B274D274F-27522756-275E2761-276727942798-27AF27B1-27BE2800-28FF2B00-2B2F2B452B462B50-2B592CE5-2CEA2E80-2E992E9B-2EF32F00-2FD52FF0-2FFB300430123013302030363037303E303F319031913196-319F31C0-31E33200-321E322A-32503260-327F328A-32B032C0-32FE3300-33FF4DC0-4DFFA490-A4C6A828-A82BA836A837A839AA77-AA79FDFDFFE4FFE8FFEDFFEEFFFCFFFD",
- Z: "002000A01680180E2000-200A20282029202F205F3000",
- Zs: "002000A01680180E2000-200A202F205F3000",
- Zl: "2028",
- Zp: "2029",
- C: "0000-001F007F-009F00AD03780379037F-0383038B038D03A20526-05300557055805600588058B-059005C8-05CF05EB-05EF05F5-0605061C061D0620065F06DD070E070F074B074C07B2-07BF07FB-07FF082E082F083F-08FF093A093B094F095609570973-097809800984098D098E0991099209A909B109B3-09B509BA09BB09C509C609C909CA09CF-09D609D8-09DB09DE09E409E509FC-0A000A040A0B-0A0E0A110A120A290A310A340A370A3A0A3B0A3D0A43-0A460A490A4A0A4E-0A500A52-0A580A5D0A5F-0A650A76-0A800A840A8E0A920AA90AB10AB40ABA0ABB0AC60ACA0ACE0ACF0AD1-0ADF0AE40AE50AF00AF2-0B000B040B0D0B0E0B110B120B290B310B340B3A0B3B0B450B460B490B4A0B4E-0B550B58-0B5B0B5E0B640B650B72-0B810B840B8B-0B8D0B910B96-0B980B9B0B9D0BA0-0BA20BA5-0BA70BAB-0BAD0BBA-0BBD0BC3-0BC50BC90BCE0BCF0BD1-0BD60BD8-0BE50BFB-0C000C040C0D0C110C290C340C3A-0C3C0C450C490C4E-0C540C570C5A-0C5F0C640C650C70-0C770C800C810C840C8D0C910CA90CB40CBA0CBB0CC50CC90CCE-0CD40CD7-0CDD0CDF0CE40CE50CF00CF3-0D010D040D0D0D110D290D3A-0D3C0D450D490D4E-0D560D58-0D5F0D640D650D76-0D780D800D810D840D97-0D990DB20DBC0DBE0DBF0DC7-0DC90DCB-0DCE0DD50DD70DE0-0DF10DF5-0E000E3B-0E3E0E5C-0E800E830E850E860E890E8B0E8C0E8E-0E930E980EA00EA40EA60EA80EA90EAC0EBA0EBE0EBF0EC50EC70ECE0ECF0EDA0EDB0EDE-0EFF0F480F6D-0F700F8C-0F8F0F980FBD0FCD0FD9-0FFF10C6-10CF10FD-10FF1249124E124F12571259125E125F1289128E128F12B112B612B712BF12C112C612C712D7131113161317135B-135E137D-137F139A-139F13F5-13FF169D-169F16F1-16FF170D1715-171F1737-173F1754-175F176D17711774-177F17B417B517DE17DF17EA-17EF17FA-17FF180F181A-181F1878-187F18AB-18AF18F6-18FF191D-191F192C-192F193C-193F1941-1943196E196F1975-197F19AC-19AF19CA-19CF19DB-19DD1A1C1A1D1A5F1A7D1A7E1A8A-1A8F1A9A-1A9F1AAE-1AFF1B4C-1B4F1B7D-1B7F1BAB-1BAD1BBA-1BFF1C38-1C3A1C4A-1C4C1C80-1CCF1CF3-1CFF1DE7-1DFC1F161F171F1E1F1F1F461F471F4E1F4F1F581F5A1F5C1F5E1F7E1F7F1FB51FC51FD41FD51FDC1FF01FF11FF51FFF200B-200F202A-202E2060-206F20722073208F2095-209F20B9-20CF20F1-20FF218A-218F23E9-23FF2427-243F244B-245F26CE26E226E4-26E727002705270A270B2728274C274E2753-2755275F27602795-279727B027BF27CB27CD-27CF2B4D-2B4F2B5A-2BFF2C2F2C5F2CF2-2CF82D26-2D2F2D66-2D6E2D70-2D7F2D97-2D9F2DA72DAF2DB72DBF2DC72DCF2DD72DDF2E32-2E7F2E9A2EF4-2EFF2FD6-2FEF2FFC-2FFF3040309730983100-3104312E-3130318F31B8-31BF31E4-31EF321F32FF4DB6-4DBF9FCC-9FFFA48D-A48FA4C7-A4CFA62C-A63FA660A661A674-A67BA698-A69FA6F8-A6FFA78D-A7FAA82C-A82FA83A-A83FA878-A87FA8C5-A8CDA8DA-A8DFA8FC-A8FFA954-A95EA97D-A97FA9CEA9DA-A9DDA9E0-A9FFAA37-AA3FAA4EAA4FAA5AAA5BAA7C-AA7FAAC3-AADAAAE0-ABBFABEEABEFABFA-ABFFD7A4-D7AFD7C7-D7CAD7FC-F8FFFA2EFA2FFA6EFA6FFADA-FAFFFB07-FB12FB18-FB1CFB37FB3DFB3FFB42FB45FBB2-FBD2FD40-FD4FFD90FD91FDC8-FDEFFDFEFDFFFE1A-FE1FFE27-FE2FFE53FE67FE6C-FE6FFE75FEFD-FF00FFBF-FFC1FFC8FFC9FFD0FFD1FFD8FFD9FFDD-FFDFFFE7FFEF-FFFBFFFEFFFF",
- Cc: "0000-001F007F-009F",
- Cf: "00AD0600-060306DD070F17B417B5200B-200F202A-202E2060-2064206A-206FFEFFFFF9-FFFB",
- Co: "E000-F8FF",
- Cs: "D800-DFFF",
- Cn: "03780379037F-0383038B038D03A20526-05300557055805600588058B-059005C8-05CF05EB-05EF05F5-05FF06040605061C061D0620065F070E074B074C07B2-07BF07FB-07FF082E082F083F-08FF093A093B094F095609570973-097809800984098D098E0991099209A909B109B3-09B509BA09BB09C509C609C909CA09CF-09D609D8-09DB09DE09E409E509FC-0A000A040A0B-0A0E0A110A120A290A310A340A370A3A0A3B0A3D0A43-0A460A490A4A0A4E-0A500A52-0A580A5D0A5F-0A650A76-0A800A840A8E0A920AA90AB10AB40ABA0ABB0AC60ACA0ACE0ACF0AD1-0ADF0AE40AE50AF00AF2-0B000B040B0D0B0E0B110B120B290B310B340B3A0B3B0B450B460B490B4A0B4E-0B550B58-0B5B0B5E0B640B650B72-0B810B840B8B-0B8D0B910B96-0B980B9B0B9D0BA0-0BA20BA5-0BA70BAB-0BAD0BBA-0BBD0BC3-0BC50BC90BCE0BCF0BD1-0BD60BD8-0BE50BFB-0C000C040C0D0C110C290C340C3A-0C3C0C450C490C4E-0C540C570C5A-0C5F0C640C650C70-0C770C800C810C840C8D0C910CA90CB40CBA0CBB0CC50CC90CCE-0CD40CD7-0CDD0CDF0CE40CE50CF00CF3-0D010D040D0D0D110D290D3A-0D3C0D450D490D4E-0D560D58-0D5F0D640D650D76-0D780D800D810D840D97-0D990DB20DBC0DBE0DBF0DC7-0DC90DCB-0DCE0DD50DD70DE0-0DF10DF5-0E000E3B-0E3E0E5C-0E800E830E850E860E890E8B0E8C0E8E-0E930E980EA00EA40EA60EA80EA90EAC0EBA0EBE0EBF0EC50EC70ECE0ECF0EDA0EDB0EDE-0EFF0F480F6D-0F700F8C-0F8F0F980FBD0FCD0FD9-0FFF10C6-10CF10FD-10FF1249124E124F12571259125E125F1289128E128F12B112B612B712BF12C112C612C712D7131113161317135B-135E137D-137F139A-139F13F5-13FF169D-169F16F1-16FF170D1715-171F1737-173F1754-175F176D17711774-177F17DE17DF17EA-17EF17FA-17FF180F181A-181F1878-187F18AB-18AF18F6-18FF191D-191F192C-192F193C-193F1941-1943196E196F1975-197F19AC-19AF19CA-19CF19DB-19DD1A1C1A1D1A5F1A7D1A7E1A8A-1A8F1A9A-1A9F1AAE-1AFF1B4C-1B4F1B7D-1B7F1BAB-1BAD1BBA-1BFF1C38-1C3A1C4A-1C4C1C80-1CCF1CF3-1CFF1DE7-1DFC1F161F171F1E1F1F1F461F471F4E1F4F1F581F5A1F5C1F5E1F7E1F7F1FB51FC51FD41FD51FDC1FF01FF11FF51FFF2065-206920722073208F2095-209F20B9-20CF20F1-20FF218A-218F23E9-23FF2427-243F244B-245F26CE26E226E4-26E727002705270A270B2728274C274E2753-2755275F27602795-279727B027BF27CB27CD-27CF2B4D-2B4F2B5A-2BFF2C2F2C5F2CF2-2CF82D26-2D2F2D66-2D6E2D70-2D7F2D97-2D9F2DA72DAF2DB72DBF2DC72DCF2DD72DDF2E32-2E7F2E9A2EF4-2EFF2FD6-2FEF2FFC-2FFF3040309730983100-3104312E-3130318F31B8-31BF31E4-31EF321F32FF4DB6-4DBF9FCC-9FFFA48D-A48FA4C7-A4CFA62C-A63FA660A661A674-A67BA698-A69FA6F8-A6FFA78D-A7FAA82C-A82FA83A-A83FA878-A87FA8C5-A8CDA8DA-A8DFA8FC-A8FFA954-A95EA97D-A97FA9CEA9DA-A9DDA9E0-A9FFAA37-AA3FAA4EAA4FAA5AAA5BAA7C-AA7FAAC3-AADAAAE0-ABBFABEEABEFABFA-ABFFD7A4-D7AFD7C7-D7CAD7FC-D7FFFA2EFA2FFA6EFA6FFADA-FAFFFB07-FB12FB18-FB1CFB37FB3DFB3FFB42FB45FBB2-FBD2FD40-FD4FFD90FD91FDC8-FDEFFDFEFDFFFE1A-FE1FFE27-FE2FFE53FE67FE6C-FE6FFE75FEFDFEFEFF00FFBF-FFC1FFC8FFC9FFD0FFD1FFD8FFD9FFDD-FFDFFFE7FFEF-FFF8FFFEFFFF"
-});
-
-function addUnicodePackage (pack) {
- var codePoint = /\w{4}/g;
- for (var name in pack)
- exports.packages[name] = pack[name].replace(codePoint, "\\u$&");
+var wordChars = [48,9,8,25,5,0,2,25,48,0,11,0,5,0,6,22,2,30,2,457,5,11,15,4,8,0,2,0,18,116,2,1,3,3,9,0,2,2,2,0,2,19,2,82,2,138,2,4,3,155,12,37,3,0,8,38,10,44,2,0,2,1,2,1,2,0,9,26,6,2,30,10,7,61,2,9,5,101,2,7,3,9,2,18,3,0,17,58,3,100,15,53,5,0,6,45,211,57,3,18,2,5,3,11,3,9,2,1,7,6,2,2,2,7,3,1,3,21,2,6,2,0,4,3,3,8,3,1,3,3,9,0,5,1,2,4,3,11,16,2,2,5,5,1,3,21,2,6,2,1,2,1,2,1,3,0,2,4,5,1,3,2,4,0,8,3,2,0,8,15,12,2,2,8,2,2,2,21,2,6,2,1,2,4,3,9,2,2,2,2,3,0,16,3,3,9,18,2,2,7,3,1,3,21,2,6,2,1,2,4,3,8,3,1,3,2,9,1,5,1,2,4,3,9,2,0,17,1,2,5,4,2,2,3,4,1,2,0,2,1,4,1,4,2,4,11,5,4,4,2,2,3,3,0,7,0,15,9,18,2,2,7,2,2,2,22,2,9,2,4,4,7,2,2,2,3,8,1,2,1,7,3,3,9,19,1,2,7,2,2,2,22,2,9,2,4,3,8,2,2,2,3,8,1,8,0,2,3,3,9,19,1,2,7,2,2,2,22,2,15,4,7,2,2,2,3,10,0,9,3,3,9,11,5,3,1,2,17,4,23,2,8,2,0,3,6,4,0,5,5,2,0,2,7,19,1,14,57,6,14,2,9,40,1,2,0,3,1,2,0,3,0,7,3,2,6,2,2,2,0,2,0,3,1,2,12,2,2,3,4,2,0,2,5,3,9,3,1,35,0,24,1,7,9,12,0,2,0,2,0,5,9,2,35,5,19,2,5,5,7,2,35,10,0,58,73,7,77,3,37,11,42,2,0,4,328,2,3,3,6,2,0,2,3,3,40,2,3,3,32,2,3,3,6,2,0,2,3,3,14,2,56,2,3,3,66,5,0,33,15,17,84,13,619,3,16,2,25,6,74,22,12,2,6,12,20,12,19,13,12,2,2,2,1,13,51,3,29,4,0,5,1,3,9,34,2,3,9,7,87,9,42,6,69,11,28,4,11,5,11,11,39,3,4,12,43,5,25,7,10,38,27,5,62,2,28,3,10,7,9,14,0,89,75,5,9,18,8,13,42,4,11,71,55,9,9,4,48,83,2,2,30,14,230,23,280,3,5,3,37,3,5,3,7,2,0,2,0,2,0,2,30,3,52,2,6,2,0,4,2,2,6,4,3,3,5,5,12,6,2,2,6,67,1,20,0,29,0,14,0,17,4,60,12,5,0,4,11,18,0,5,0,3,9,2,0,4,4,7,0,2,0,2,0,2,3,2,10,3,3,6,4,5,0,53,1,2684,46,2,46,2,132,7,6,15,37,11,53,10,0,17,22,10,6,2,6,2,6,2,6,2,6,2,6,2,6,2,6,2,31,48,0,470,1,36,5,2,4,6,1,5,85,3,1,3,2,2,89,2,3,6,40,4,93,18,23,57,15,513,6581,75,20939,53,1164,68,45,3,268,4,27,21,31,3,13,13,1,2,24,9,69,11,1,38,8,3,102,3,1,111,44,25,51,13,68,12,9,7,23,4,0,5,45,3,35,13,28,4,64,15,10,39,54,10,13,3,9,7,22,4,1,5,66,25,2,227,42,2,1,3,9,7,11171,13,22,5,48,8453,301,3,61,3,105,39,6,13,4,6,11,2,12,2,4,2,0,2,1,2,1,2,107,34,362,19,63,3,53,41,11,5,15,17,6,13,1,25,2,33,4,2,134,20,9,8,25,5,0,2,25,12,88,4,5,3,5,3,5,3,2];
+
+var code = 0;
+var str = [];
+for (var i = 0; i < wordChars.length; i += 2) {
+ str.push(code += wordChars[i]);
+ if (wordChars[i + 1])
+ str.push(45, code += wordChars[i + 1]);
}
+exports.wordChars = String.fromCharCode.apply(null, str);
+
});
-ace.define("ace/mode/text",["require","exports","module","ace/tokenizer","ace/mode/text_highlight_rules","ace/mode/behaviour/cstyle","ace/unicode","ace/lib/lang","ace/token_iterator","ace/range"], function(acequire, exports, module) {
+ace.define("ace/mode/text",["require","exports","module","ace/config","ace/tokenizer","ace/mode/text_highlight_rules","ace/mode/behaviour/cstyle","ace/unicode","ace/lib/lang","ace/token_iterator","ace/range"], function(acequire, exports, module) {
"use strict";
+var config = acequire("../config");
var Tokenizer = acequire("../tokenizer").Tokenizer;
var TextHighlightRules = acequire("./text_highlight_rules").TextHighlightRules;
@@ -7133,19 +6953,9 @@ var Mode = function() {
(function() {
this.$defaultBehaviour = new CstyleBehaviour();
- this.tokenRe = new RegExp("^["
- + unicode.packages.L
- + unicode.packages.Mn + unicode.packages.Mc
- + unicode.packages.Nd
- + unicode.packages.Pc + "\\$_]+", "g"
- );
+ this.tokenRe = new RegExp("^[" + unicode.wordChars + "\\$_]+", "g");
- this.nonTokenRe = new RegExp("^(?:[^"
- + unicode.packages.L
- + unicode.packages.Mn + unicode.packages.Mc
- + unicode.packages.Nd
- + unicode.packages.Pc + "\\$_]|\\s])+", "g"
- );
+ this.nonTokenRe = new RegExp("^(?:[^" + unicode.wordChars + "\\$_]|\\s])+", "g");
this.getTokenizer = function() {
if (!this.$tokenizer) {
@@ -7247,7 +7057,6 @@ var Mode = function() {
return spaces % tabSize != tabSize - 1;
else
return spaces % tabSize == 0;
- return true;
};
}
@@ -7365,8 +7174,15 @@ var Mode = function() {
this.$modes = {};
for (var i in mapping) {
if (mapping[i]) {
+ var Mode = mapping[i];
+ var id = Mode.prototype.$id;
+ var mode = config.$modes[id];
+ if (!mode)
+ config.$modes[id] = mode = new Mode();
+ if (!config.$modes[i])
+ config.$modes[i] = mode;
this.$embeds.push(i);
- this.$modes[i] = new mapping[i]();
+ this.$modes[i] = mode;
}
}
@@ -7386,8 +7202,16 @@ var Mode = function() {
this.$delegator = function(method, args, defaultHandler) {
var state = args[0];
- if (typeof state != "string")
+ if (typeof state != "string") {
+ if (Array.isArray(state[2])) {
+ var language = state[2][state[2].length - 1];
+ var mode = this.$modes[language];
+ if (mode)
+ return mode[method].apply(mode, [state[1]].concat([].slice.call(args, 1)));
+ }
state = state[0];
+ }
+
for (var i = 0; i < this.$embeds.length; i++) {
if (!this.$modes[this.$embeds[i]]) continue;
@@ -7949,28 +7773,23 @@ var Document = function(textOrLines) {
return;
}
- if (isInsert && delta.lines.length > 20000)
+ if (isInsert && delta.lines.length > 20000) {
this.$splitAndapplyLargeDelta(delta, 20000);
- applyDelta(this.$lines, delta, doNotValidate);
- this._signal("change", delta);
+ }
+ else {
+ applyDelta(this.$lines, delta, doNotValidate);
+ this._signal("change", delta);
+ }
};
this.$splitAndapplyLargeDelta = function(delta, MAX) {
var lines = delta.lines;
- var l = lines.length;
+ var l = lines.length - MAX + 1;
var row = delta.start.row;
var column = delta.start.column;
- var from = 0, to = 0;
- do {
- from = to;
+ for (var from = 0, to = 0; from < l; from = to) {
to += MAX - 1;
var chunk = lines.slice(from, to);
- if (to > l) {
- delta.lines = chunk;
- delta.start.row = row + from;
- delta.start.column = column;
- break;
- }
chunk.push("");
this.applyDelta({
start: this.pos(row + from, column),
@@ -7978,7 +7797,11 @@ var Document = function(textOrLines) {
action: delta.action,
lines: chunk
}, true);
- } while(true);
+ }
+ delta.lines = lines.slice(from);
+ delta.start.row = row + from;
+ delta.start.column = column;
+ this.applyDelta(delta, true);
};
this.revertDelta = function(delta) {
this.applyDelta({
@@ -7996,7 +7819,7 @@ var Document = function(textOrLines) {
if (index < 0)
return {row: i, column: index + lines[i].length + newlineLength};
}
- return {row: l-1, column: lines[l-1].length};
+ return {row: l-1, column: index + lines[l-1].length + newlineLength};
};
this.positionToIndex = function(pos, startRow) {
var lines = this.$lines || this.getAllLines();
@@ -8051,7 +7874,7 @@ var BackgroundTokenizer = function(tokenizer, editor) {
currentLine++;
} while (self.lines[currentLine]);
processedLines ++;
- if ((processedLines % 5 === 0) && (new Date() - workerStart) > 20) {
+ if ((processedLines % 5 === 0) && (new Date() - workerStart) > 20) {
self.running = setTimeout(self.$worker, 20);
break;
}
@@ -8060,7 +7883,7 @@ var BackgroundTokenizer = function(tokenizer, editor) {
if (endLine == -1)
endLine = currentLine;
-
+
if (startLine <= endLine)
self.fireUpdateEvent(startLine, endLine);
};
@@ -8583,44 +8406,102 @@ var RangeList = function() {
};
this.$onChange = function(delta) {
- if (delta.action == "insert"){
- var start = delta.start;
- var end = delta.end;
- } else {
- var end = delta.start;
- var start = delta.end;
- }
+ var start = delta.start;
+ var end = delta.end;
var startRow = start.row;
var endRow = end.row;
- var lineDif = endRow - startRow;
-
- var colDiff = -start.column + end.column;
var ranges = this.ranges;
-
for (var i = 0, n = ranges.length; i < n; i++) {
var r = ranges[i];
- if (r.end.row < startRow)
- continue;
- if (r.start.row > startRow)
+ if (r.end.row >= startRow)
break;
-
- if (r.start.row == startRow && r.start.column >= start.column ) {
- if (r.start.column == start.column && this.$insertRight) {
- } else {
- r.start.column += colDiff;
- r.start.row += lineDif;
+ }
+
+ if (delta.action == "insert") {
+ var lineDif = endRow - startRow;
+ var colDiff = -start.column + end.column;
+ for (; i < n; i++) {
+ var r = ranges[i];
+ if (r.start.row > startRow)
+ break;
+
+ if (r.start.row == startRow && r.start.column >= start.column) {
+ if (r.start.column == start.column && this.$insertRight) {
+ } else {
+ r.start.column += colDiff;
+ r.start.row += lineDif;
+ }
+ }
+ if (r.end.row == startRow && r.end.column >= start.column) {
+ if (r.end.column == start.column && this.$insertRight) {
+ continue;
+ }
+ if (r.end.column == start.column && colDiff > 0 && i < n - 1) {
+ if (r.end.column > r.start.column && r.end.column == ranges[i+1].start.column)
+ r.end.column -= colDiff;
+ }
+ r.end.column += colDiff;
+ r.end.row += lineDif;
}
}
- if (r.end.row == startRow && r.end.column >= start.column) {
- if (r.end.column == start.column && this.$insertRight) {
- continue;
+ } else {
+ var lineDif = startRow - endRow;
+ var colDiff = start.column - end.column;
+ for (; i < n; i++) {
+ var r = ranges[i];
+
+ if (r.start.row > endRow)
+ break;
+
+ if (r.end.row < endRow
+ && (
+ startRow < r.end.row
+ || startRow == r.end.row && start.column < r.end.column
+ )
+ ) {
+ r.end.row = startRow;
+ r.end.column = start.column;
}
- if (r.end.column == start.column && colDiff > 0 && i < n - 1) {
- if (r.end.column > r.start.column && r.end.column == ranges[i+1].start.column)
- r.end.column -= colDiff;
+ else if (r.end.row == endRow) {
+ if (r.end.column <= end.column) {
+ if (lineDif || r.end.column > start.column) {
+ r.end.column = start.column;
+ r.end.row = start.row;
+ }
+ }
+ else {
+ r.end.column += colDiff;
+ r.end.row += lineDif;
+ }
+ }
+ else if (r.end.row > endRow) {
+ r.end.row += lineDif;
+ }
+
+ if (r.start.row < endRow
+ && (
+ startRow < r.start.row
+ || startRow == r.start.row && start.column < r.start.column
+ )
+ ) {
+ r.start.row = startRow;
+ r.start.column = start.column;
+ }
+ else if (r.start.row == endRow) {
+ if (r.start.column <= end.column) {
+ if (lineDif || r.start.column > start.column) {
+ r.start.column = start.column;
+ r.start.row = start.row;
+ }
+ }
+ else {
+ r.start.column += colDiff;
+ r.start.row += lineDif;
+ }
+ }
+ else if (r.start.row > endRow) {
+ r.start.row += lineDif;
}
- r.end.column += colDiff;
- r.end.row += lineDif;
}
}
@@ -9706,9 +9587,9 @@ var EditSession = function(text, mode) {
if (typeof text != "object" || !text.getLine)
text = new Document(text);
- this.$bidiHandler = new BidiHandler(this);
this.setDocument(text);
this.selection = new Selection(this);
+ this.$bidiHandler = new BidiHandler(this);
config.resetOptions(this);
this.setMode(mode);
@@ -9789,15 +9670,17 @@ EditSession.$uid = 0;
this.$resetRowCache(delta.start.row);
var removedFolds = this.$updateInternalDataOnChange(delta);
- if (!this.$fromUndo && this.$undoManager && !delta.ignore) {
- this.$deltasDoc.push(delta);
- if (removedFolds && removedFolds.length != 0) {
- this.$deltasFold.push({
+ if (!this.$fromUndo && this.$undoManager) {
+ if (removedFolds && removedFolds.length) {
+ this.$undoManager.add({
action: "removeFolds",
folds: removedFolds
- });
+ }, this.mergeUndoDeltas);
+ this.mergeUndoDeltas = true;
}
-
+ this.$undoManager.add(delta, this.mergeUndoDeltas);
+ this.mergeUndoDeltas = true;
+
this.$informUndoManager.schedule();
}
@@ -9809,9 +9692,6 @@ EditSession.$uid = 0;
this.selection.moveTo(0, 0);
this.$resetRowCache(0);
- this.$deltas = [];
- this.$deltasDoc = [];
- this.$deltasFold = [];
this.setUndoManager(this.$undoManager);
this.getUndoManager().reset();
};
@@ -9850,46 +9730,20 @@ EditSession.$uid = 0;
};
this.setUndoManager = function(undoManager) {
this.$undoManager = undoManager;
- this.$deltas = [];
- this.$deltasDoc = [];
- this.$deltasFold = [];
-
+
if (this.$informUndoManager)
this.$informUndoManager.cancel();
-
+
if (undoManager) {
var self = this;
-
+ undoManager.addSession(this);
this.$syncInformUndoManager = function() {
self.$informUndoManager.cancel();
-
- if (self.$deltasFold.length) {
- self.$deltas.push({
- group: "fold",
- deltas: self.$deltasFold
- });
- self.$deltasFold = [];
- }
-
- if (self.$deltasDoc.length) {
- self.$deltas.push({
- group: "doc",
- deltas: self.$deltasDoc
- });
- self.$deltasDoc = [];
- }
-
- if (self.$deltas.length > 0) {
- undoManager.execute({
- action: "aceupdate",
- args: [self.$deltas, self],
- merge: self.mergeUndoDeltas
- });
- }
self.mergeUndoDeltas = false;
- self.$deltas = [];
};
this.$informUndoManager = lang.delayedCall(this.$syncInformUndoManager);
+ } else {
+ this.$syncInformUndoManager = function() {};
}
};
this.markUndoGroup = function() {
@@ -9900,7 +9754,11 @@ EditSession.$uid = 0;
this.$defaultUndoManager = {
undo: function() {},
redo: function() {},
- reset: function() {}
+ reset: function() {},
+ add: function() {},
+ addSelection: function() {},
+ startNewGroup: function() {},
+ addSession: function() {}
};
this.getUndoManager = function() {
return this.$undoManager || this.$defaultUndoManager;
@@ -10026,10 +9884,8 @@ EditSession.$uid = 0;
return;
var markers = marker.inFront ? this.$frontMarkers : this.$backMarkers;
- if (marker) {
- delete (markers[markerId]);
- this._signal(marker.inFront ? "changeFrontMarker" : "changeBackMarker");
- }
+ delete (markers[markerId]);
+ this._signal(marker.inFront ? "changeFrontMarker" : "changeBackMarker");
};
this.getMarkers = function(inFront) {
return inFront ? this.$frontMarkers : this.$backMarkers;
@@ -10128,7 +9984,7 @@ EditSession.$uid = 0;
this._signal("tokenizerUpdate", e);
};
- this.$modes = {};
+ this.$modes = config.$modes;
this.$mode = null;
this.$modeId = null;
this.setMode = function(mode, cb) {
@@ -10332,69 +10188,68 @@ EditSession.$uid = 0;
return;
this.$fromUndo = true;
- var lastUndoRange = null;
for (var i = deltas.length - 1; i != -1; i--) {
var delta = deltas[i];
- if (delta.group == "doc") {
- this.doc.revertDeltas(delta.deltas);
- lastUndoRange =
- this.$getUndoSelection(delta.deltas, true, lastUndoRange);
- } else {
- delta.deltas.forEach(function(foldDelta) {
- this.addFolds(foldDelta.folds);
- }, this);
+ if (delta.action == "insert" || delta.action == "remove") {
+ this.doc.revertDelta(delta);
+ } else if (delta.folds) {
+ this.addFolds(delta.folds);
}
}
+ if (!dontSelect && this.$undoSelect) {
+ if (deltas.selectionBefore)
+ this.selection.fromJSON(deltas.selectionBefore);
+ else
+ this.selection.setRange(this.$getUndoSelection(deltas, true));
+ }
this.$fromUndo = false;
- lastUndoRange &&
- this.$undoSelect &&
- !dontSelect &&
- this.selection.setSelectionRange(lastUndoRange);
- return lastUndoRange;
};
this.redoChanges = function(deltas, dontSelect) {
if (!deltas.length)
return;
this.$fromUndo = true;
- var lastUndoRange = null;
for (var i = 0; i < deltas.length; i++) {
var delta = deltas[i];
- if (delta.group == "doc") {
- this.doc.applyDeltas(delta.deltas);
- lastUndoRange =
- this.$getUndoSelection(delta.deltas, false, lastUndoRange);
+ if (delta.action == "insert" || delta.action == "remove") {
+ this.doc.applyDelta(delta);
}
}
+
+ if (!dontSelect && this.$undoSelect) {
+ if (deltas.selectionAfter)
+ this.selection.fromJSON(deltas.selectionAfter);
+ else
+ this.selection.setRange(this.$getUndoSelection(deltas, false));
+ }
this.$fromUndo = false;
- lastUndoRange &&
- this.$undoSelect &&
- !dontSelect &&
- this.selection.setSelectionRange(lastUndoRange);
- return lastUndoRange;
};
this.setUndoSelect = function(enable) {
this.$undoSelect = enable;
};
- this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) {
+ this.$getUndoSelection = function(deltas, isUndo) {
function isInsert(delta) {
return isUndo ? delta.action !== "insert" : delta.action === "insert";
}
- var delta = deltas[0];
var range, point;
- var lastDeltaIsInsert = false;
- if (isInsert(delta)) {
- range = Range.fromPoints(delta.start, delta.end);
- lastDeltaIsInsert = true;
- } else {
- range = Range.fromPoints(delta.start, delta.start);
- lastDeltaIsInsert = false;
- }
+ var lastDeltaIsInsert;
- for (var i = 1; i < deltas.length; i++) {
- delta = deltas[i];
+ for (var i = 0; i < deltas.length; i++) {
+ var delta = deltas[i];
+ if (!delta.start) continue; // skip folds
+ if (!range) {
+ if (isInsert(delta)) {
+ range = Range.fromPoints(delta.start, delta.end);
+ lastDeltaIsInsert = true;
+ } else {
+ range = Range.fromPoints(delta.start, delta.start);
+ lastDeltaIsInsert = false;
+ }
+ continue;
+ }
+
if (isInsert(delta)) {
point = delta.start;
if (range.compare(point.row, point.column) == -1) {
@@ -10413,20 +10268,6 @@ EditSession.$uid = 0;
lastDeltaIsInsert = false;
}
}
- if (lastUndoRange != null) {
- if (Range.comparePoints(lastUndoRange.start, range.start) === 0) {
- lastUndoRange.start.column += range.end.column - range.start.column;
- lastUndoRange.end.column += range.end.column - range.start.column;
- }
-
- var cmp = lastUndoRange.compareRange(range);
- if (cmp == 1) {
- range.setStart(lastUndoRange.start);
- } else if (cmp == -1) {
- range.setEnd(lastUndoRange.end);
- }
- }
-
return range;
};
this.replace = function(range, text) {
@@ -10867,15 +10708,11 @@ EditSession.$uid = 0;
return Math.min(indentation, maxIndent);
}
function addSplit(screenPos) {
- var displayed = tokens.slice(lastSplit, screenPos);
- var len = displayed.length;
- displayed.join("")
- .replace(/12/g, function() {
- len -= 1;
- })
- .replace(/2/g, function() {
- len -= 1;
- });
+ var len = screenPos - lastSplit;
+ for (var i = lastSplit; i < screenPos; i++) {
+ var ch = tokens[i];
+ if (ch === 12 || ch === 2) len -= 1;
+ }
if (!splits.length) {
indent = getWrapIndent();
@@ -11381,15 +11218,22 @@ config.defineOptions(EditSession.prototype, "session", {
if (val != this.$wrapAsCode) {
this.$wrapAsCode = val;
if (this.$useWrapMode) {
- this.$modified = true;
- this.$resetRowCache(0);
- this.$updateWrapData(0, this.getLength() - 1);
+ this.$useWrapMode = false;
+ this.setUseWrapMode(true);
}
}
},
initialValue: "auto"
},
- indentedSoftWrap: { initialValue: true },
+ indentedSoftWrap: {
+ set: function() {
+ if (this.$useWrapMode) {
+ this.$useWrapMode = false;
+ this.setUseWrapMode(true);
+ }
+ },
+ initialValue: true
+ },
firstLineNumber: {
set: function() {this._signal("changeBreakpoint");},
initialValue: 1
@@ -11418,6 +11262,10 @@ config.defineOptions(EditSession.prototype, "session", {
handlesSet: true
},
navigateWithinSoftTabs: {initialValue: false},
+ foldStyle: {
+ set: function(val) {this.setFoldStyle(val);},
+ handlesSet: true
+ },
overwrite: {
set: function(val) {this._signal("changeOverwrite");},
initialValue: false
@@ -11429,7 +11277,8 @@ config.defineOptions(EditSession.prototype, "session", {
},
mode: {
set: function(val) { this.setMode(val); },
- get: function() { return this.$modeId; }
+ get: function() { return this.$modeId; },
+ handlesSet: true
}
});
@@ -11473,7 +11322,7 @@ var Search = function() {
firstRange = null;
return false;
}
-
+
return true;
});
@@ -11633,7 +11482,7 @@ var Search = function() {
var firstRow = range ? range.start.row : 0;
var lastRow = range ? range.end.row : session.getLength() - 1;
-
+
if (backwards) {
var forEach = function(callback) {
var row = start.row;
@@ -11712,8 +11561,8 @@ var Search = function() {
else {
var forEachInLine = function(row, startIndex, callback) {
var line = session.getLine(row);
+ var last;
var m;
- var last = startIndex;
re.lastIndex = startIndex;
while((m = re.exec(line))) {
var length = m[0].length;
@@ -11832,7 +11681,7 @@ MultiHashHandler.prototype = HashHandler.prototype;
function getPosition(command) {
return typeof command == "object" && command.bindKey
- && command.bindKey.position
+ && command.bindKey.position
|| (command.isDefault ? -100 : 0);
}
this._addCommandToBinding = function(keyId, command, position) {
@@ -11847,7 +11696,7 @@ MultiHashHandler.prototype = HashHandler.prototype;
} else if ((i = ckb[keyId].indexOf(command)) != -1) {
ckb[keyId].splice(i, 1);
}
-
+
if (typeof position != "number") {
position = getPosition(command);
}
@@ -12003,7 +11852,7 @@ oop.inherits(CommandManager, MultiHashHandler);
if (editor && editor.$readOnly && !command.readOnly)
return false;
- if (command.isAvailable && !command.isAvailable(editor))
+ if (this.$checkCommandState != false && command.isAvailable && !command.isAvailable(editor))
return false;
var e = {editor: editor, command: command, args: args};
@@ -12099,7 +11948,7 @@ exports.commands = [{
name: "goToNextError",
bindKey: bindKey("Alt-E", "F4"),
exec: function(editor) {
- config.loadModule("ace/ext/error_marker", function(module) {
+ config.loadModule("./ext/error_marker", function(module) {
module.showErrorMarker(editor, 1);
});
},
@@ -12109,7 +11958,7 @@ exports.commands = [{
name: "goToPreviousError",
bindKey: bindKey("Alt-Shift-E", "Shift-F4"),
exec: function(editor) {
- config.loadModule("ace/ext/error_marker", function(module) {
+ config.loadModule("./ext/error_marker", function(module) {
module.showErrorMarker(editor, -1);
});
},
@@ -12128,8 +11977,9 @@ exports.commands = [{
}, {
name: "gotoline",
bindKey: bindKey("Ctrl-L", "Command-L"),
- exec: function(editor) {
- var line = parseInt(prompt("Enter line number:"), 10);
+ exec: function(editor, line) {
+ if (typeof line !== "number")
+ line = parseInt(prompt("Enter line number:"), 10);
if (!isNaN(line)) {
editor.gotoLine(line);
}
@@ -12474,13 +12324,13 @@ exports.commands = [{
{
name: "cut",
exec: function(editor) {
- var range = editor.getSelectionRange();
+ var cutLine = editor.$copyWithEmptySelection && editor.selection.isEmpty();
+ var range = cutLine ? editor.selection.getLineRange() : editor.selection.getRange();
editor._emit("cut", range);
- if (!editor.selection.isEmpty()) {
+ if (!range.isEmpty())
editor.session.remove(range);
- editor.clearSelection();
- }
+ editor.clearSelection();
},
scrollIntoView: "cursor",
multiSelectAction: "forEach"
@@ -12788,7 +12638,14 @@ exports.commands = [{
});
-ace.define("ace/editor",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/keyboard/textinput","ace/mouse/mouse_handler","ace/mouse/fold_handler","ace/keyboard/keybinding","ace/edit_session","ace/search","ace/range","ace/lib/event_emitter","ace/commands/command_manager","ace/commands/default_commands","ace/config","ace/token_iterator"], function(acequire, exports, module) {
+ace.define("ace/clipboard",["require","exports","module"], function(acequire, exports, module) {
+"use strict";
+
+module.exports = { lineMode: false };
+
+});
+
+ace.define("ace/editor",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/keyboard/textinput","ace/mouse/mouse_handler","ace/mouse/fold_handler","ace/keyboard/keybinding","ace/edit_session","ace/search","ace/range","ace/lib/event_emitter","ace/commands/command_manager","ace/commands/default_commands","ace/config","ace/token_iterator","ace/clipboard"], function(acequire, exports, module) {
"use strict";
acequire("./lib/fixoldbrowsers");
@@ -12809,7 +12666,9 @@ var CommandManager = acequire("./commands/command_manager").CommandManager;
var defaultCommands = acequire("./commands/default_commands").commands;
var config = acequire("./config");
var TokenIterator = acequire("./token_iterator").TokenIterator;
-var Editor = function(renderer, session) {
+
+var clipboard = acequire("./clipboard");
+var Editor = function(renderer, session, options) {
var container = renderer.getContainerElement();
this.container = container;
this.renderer = renderer;
@@ -12817,7 +12676,7 @@ var Editor = function(renderer, session) {
this.commands = new CommandManager(useragent.isMac ? "mac" : "win", defaultCommands);
if (typeof document == "object") {
- this.textInput = new TextInput(renderer.getTextAreaContainer(), this);
+ this.textInput = new TextInput(renderer.getTextAreaContainer(), this);
this.renderer.textarea = this.textInput.getElement();
this.$mouseHandler = new MouseHandler(this);
new FoldHandler(this);
@@ -12825,7 +12684,6 @@ var Editor = function(renderer, session) {
this.keyBinding = new KeyBinding(this);
- this.$blockScrolling = 0;
this.$search = new Search().set({
wrap: true
});
@@ -12845,8 +12703,10 @@ var Editor = function(renderer, session) {
_self._$emitInputEvent.schedule(31);
});
- this.setSession(session || new EditSession(""));
+ this.setSession(session || options && options.session || new EditSession(""));
config.resetOptions(this);
+ if (options)
+ this.setOptions(options);
config._signal("editor", this);
};
@@ -12857,56 +12717,58 @@ Editor.$uid = 0;
oop.implement(this, EventEmitter);
this.$initOperationListeners = function() {
- function last(a) {return a[a.length - 1];}
-
- this.selections = [];
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));
-
+ this.$opResetTimer = lang.delayedCall(this.endOperation.bind(this, true));
this.on("change", function() {
- this.curOp || this.startOperation();
+ if (!this.curOp) {
+ this.startOperation();
+ this.curOp.selectionBefore = this.$lastSel;
+ }
this.curOp.docChanged = true;
}.bind(this), true);
-
+
this.on("changeSelection", function() {
- this.curOp || this.startOperation();
+ if (!this.curOp) {
+ this.startOperation();
+ this.curOp.selectionBefore = this.$lastSel;
+ }
this.curOp.selectionChanged = true;
}.bind(this), true);
};
this.curOp = null;
this.prevOp = {};
- this.startOperation = function(commadEvent) {
+ this.startOperation = function(commandEvent) {
if (this.curOp) {
- if (!commadEvent || this.curOp.command)
+ if (!commandEvent || this.curOp.command)
return;
this.prevOp = this.curOp;
}
- if (!commadEvent) {
+ if (!commandEvent) {
this.previousCommand = null;
- commadEvent = {};
+ commandEvent = {};
}
this.$opResetTimer.schedule();
- this.curOp = {
- command: commadEvent.command || {},
- args: commadEvent.args,
+ this.curOp = this.session.curOp = {
+ command: commandEvent.command || {},
+ args: commandEvent.args,
scrollTop: this.renderer.scrollTop
};
- if (this.curOp.command.name && this.curOp.command.scrollIntoView !== undefined)
- this.$blockScrolling++;
+ this.curOp.selectionBefore = this.selection.toJSON();
};
this.endOperation = function(e) {
if (this.curOp) {
if (e && e.returnValue === false)
- return this.curOp = null;
+ return (this.curOp = null);
+ if (e == true && this.curOp.command && this.curOp.command.name == "mouse")
+ return;
this._signal("beforeEndOperation");
+ if (!this.curOp) return;
var command = this.curOp.command;
- if (command.name && this.$blockScrolling > 0)
- this.$blockScrolling--;
var scrollIntoView = command && command.scrollIntoView;
if (scrollIntoView) {
switch (scrollIntoView) {
@@ -12932,7 +12794,10 @@ Editor.$uid = 0;
if (scrollIntoView == "animate")
this.renderer.animateScrolling(this.curOp.scrollTop);
}
-
+ var sel = this.selection.toJSON();
+ this.curOp.selectionAfter = sel;
+ this.$lastSel = this.selection.toJSON();
+ this.session.getUndoManager().addSelection(sel);
this.prevOp = this.curOp;
this.curOp = null;
}
@@ -12973,7 +12838,7 @@ Editor.$uid = 0;
this.sequenceStartTime = Date.now();
};
this.setKeyboardHandler = function(keyboardHandler, cb) {
- if (keyboardHandler && typeof keyboardHandler === "string") {
+ if (keyboardHandler && typeof keyboardHandler === "string" && keyboardHandler != "ace") {
this.$keybindingId = keyboardHandler;
var _self = this;
config.loadModule(["keybinding", keyboardHandler], function(module) {
@@ -13071,9 +12936,7 @@ Editor.$uid = 0;
this.onChangeMode();
- this.$blockScrolling += 1;
this.onCursorChange();
- this.$blockScrolling -= 1;
this.onScrollTopChange();
this.onScrollLeftChange();
@@ -13098,7 +12961,7 @@ Editor.$uid = 0;
oldSession && oldSession._signal("changeEditor", {oldEditor: this});
session && session._signal("changeEditor", {editor: this});
-
+
if (session && session.bgTokenizer)
session.bgTokenizer.scheduleStart();
};
@@ -13140,7 +13003,7 @@ Editor.$uid = 0;
};
this.getFontSize = function () {
return this.getOption("fontSize") ||
- dom.computedStyle(this.container, "fontSize");
+ dom.computedStyle(this.container).fontSize;
};
this.setFontSize = function(size) {
this.setOption("fontSize", size);
@@ -13247,14 +13110,15 @@ Editor.$uid = 0;
session.$tagHighlight = null;
}
- if (range && !session.$tagHighlight)
+ if (!session.$tagHighlight)
session.$tagHighlight = session.addMarker(range, "ace_bracket", "text");
}, 50);
};
this.focus = function() {
var _self = this;
setTimeout(function() {
- _self.textInput.focus();
+ if (!_self.isFocused())
+ _self.textInput.focus();
});
this.textInput.focus();
};
@@ -13310,14 +13174,6 @@ Editor.$uid = 0;
this.onCursorChange = function() {
this.$cursorChange();
- if (!this.$blockScrolling) {
- config.warn("Automatically scrolling cursor into view after selection change",
- "this will be disabled in the next version",
- "set editor.$blockScrolling = Infinity to disable this message"
- );
- this.renderer.scrollCursorIntoView();
- }
-
this.$highlightBrackets();
this.$highlightTags();
this.$updateHighlightActiveLine();
@@ -13329,8 +13185,10 @@ Editor.$uid = 0;
var highlight;
if (this.$highlightActiveLine) {
- if ((this.$selectionStyle != "line" || !this.selection.isMultiLine()))
+ if (this.$selectionStyle != "line" || !this.selection.isMultiLine())
highlight = this.getCursorPosition();
+ if (this.renderer.theme && this.renderer.theme.$selectionColorConflict && !this.selection.isEmpty())
+ highlight = false;
if (this.renderer.$maxLines && this.session.getLength() === 1 && !(this.renderer.$minLines > 1))
highlight = false;
}
@@ -13379,18 +13237,12 @@ Editor.$uid = 0;
if (selection.isEmpty() || selection.isMultiLine())
return;
- var startOuter = selection.start.column - 1;
- var endOuter = selection.end.column + 1;
+ var startColumn = selection.start.column;
+ var endColumn = selection.end.column;
var line = session.getLine(selection.start.row);
- var lineCols = line.length;
- var needle = line.substring(Math.max(startOuter, 0),
- Math.min(endOuter, lineCols));
- if ((startOuter >= 0 && /^[\w\d]/.test(needle)) ||
- (endOuter <= lineCols && /[\w\d]$/.test(needle)))
- return;
-
- needle = line.substring(selection.start.column, selection.end.column);
- if (!/^[\w\d]+$/.test(needle))
+
+ var needle = line.substring(startColumn, endColumn);
+ if (needle.length > 5000 || !/[\w\d]/.test(needle))
return;
var re = this.$search.$assembleRegExp({
@@ -13398,7 +13250,11 @@ Editor.$uid = 0;
caseSensitive: true,
needle: needle
});
-
+
+ var wordWithBoundary = line.substring(startColumn - 1, endColumn + 1);
+ if (!re.test(wordWithBoundary))
+ return;
+
return re;
};
@@ -13445,8 +13301,22 @@ Editor.$uid = 0;
};
this.getCopyText = function() {
var text = this.getSelectedText();
- this._signal("copy", text);
- return text;
+ var nl = this.session.doc.getNewLineCharacter();
+ var copyLine= false;
+ if (!text && this.$copyWithEmptySelection) {
+ copyLine = true;
+ var ranges = this.selection.getAllRanges();
+ for (var i = 0; i < ranges.length; i++) {
+ var range = ranges[i];
+ if (i && ranges[i - 1].start.row == range.start.row)
+ continue;
+ text += this.session.getLine(range.start.row) + nl;
+ }
+ }
+ var e = {text: text};
+ this._signal("copy", e);
+ clipboard.lineMode = copyLine ? e.text : "";
+ return e.text;
};
this.onCopy = function() {
this.commands.exec("copy", this);
@@ -13464,8 +13334,18 @@ Editor.$uid = 0;
e = {text: e};
this._signal("paste", e);
var text = e.text;
+
+ var lineMode = text == clipboard.lineMode;
+ var session = this.session;
if (!this.inMultiSelectMode || this.inVirtualSelectionMode) {
- this.insert(text);
+ if (lineMode)
+ session.insert({ row: this.selection.lead.row, column: 0 }, text);
+ else
+ this.insert(text);
+ } else if (lineMode) {
+ this.selection.rangeList.ranges.forEach(function(range) {
+ session.insert({ row: range.start.row, column: 0 }, text);
+ });
} else {
var lines = text.split(/\r\n|\r|\n/);
var ranges = this.selection.rangeList.ranges;
@@ -13476,9 +13356,9 @@ Editor.$uid = 0;
for (var i = ranges.length; i--;) {
var range = ranges[i];
if (!range.isEmpty())
- this.session.remove(range);
+ session.remove(range);
- this.session.insert(range.start, lines[i]);
+ session.insert(range.start, lines[i]);
}
}
};
@@ -13495,8 +13375,10 @@ Editor.$uid = 0;
var transform = mode.transformAction(session.getState(cursor.row), 'insertion', this, session, text);
if (transform) {
if (text !== transform.text) {
- this.session.mergeUndoDeltas = false;
- this.$mergeNextCommand = false;
+ if (!this.inVirtualSelectionMode) {
+ this.session.mergeUndoDeltas = false;
+ this.mergeNextCommand = false;
+ }
}
text = transform.text;
@@ -13554,8 +13436,36 @@ Editor.$uid = 0;
mode.autoOutdent(lineState, session, cursor.row);
};
- this.onTextInput = function(text) {
- this.keyBinding.onTextInput(text);
+ this.onTextInput = function(text, composition) {
+ if (!composition)
+ return this.keyBinding.onTextInput(text);
+
+ this.startOperation({command: { name: "insertstring" }});
+ var applyComposition = this.applyComposition.bind(this, text, composition);
+ if (this.selection.rangeCount)
+ this.forEachSelection(applyComposition);
+ else
+ applyComposition();
+ this.endOperation();
+ };
+
+ this.applyComposition = function(text, composition) {
+ if (composition.extendLeft || composition.extendRight) {
+ var r = this.selection.getRange();
+ r.start.column -= composition.extendLeft;
+ r.end.column += composition.extendRight;
+ this.selection.setRange(r);
+ if (!text && !r.isEmpty())
+ this.remove();
+ }
+ if (text || !this.selection.isEmpty())
+ this.insert(text, true);
+ if (composition.restoreStart || composition.restoreEnd) {
+ var r = this.selection.getRange();
+ r.start.column -= composition.restoreStart;
+ r.end.column -= composition.restoreEnd;
+ this.selection.setRange(r);
+ }
};
this.onCommandKey = function(e, hashId, keyCode) {
@@ -13920,6 +13830,84 @@ Editor.$uid = 0;
this.moveCursorTo(row, Math.max(nr.start +1, column + nnr.length - nr.value.length));
}
+ } else {
+ this.toggleWord();
+ }
+ };
+
+ this.$toggleWordPairs = [
+ ["first", "last"],
+ ["true", "false"],
+ ["yes", "no"],
+ ["width", "height"],
+ ["top", "bottom"],
+ ["right", "left"],
+ ["on", "off"],
+ ["x", "y"],
+ ["get", "set"],
+ ["max", "min"],
+ ["horizontal", "vertical"],
+ ["show", "hide"],
+ ["add", "remove"],
+ ["up", "down"],
+ ["before", "after"],
+ ["even", "odd"],
+ ["inside", "outside"],
+ ["next", "previous"],
+ ["increase", "decrease"],
+ ["attach", "detach"],
+ ["&&", "||"],
+ ["==", "!="]
+ ];
+
+ this.toggleWord = function () {
+ var row = this.selection.getCursor().row;
+ var column = this.selection.getCursor().column;
+ this.selection.selectWord();
+ var currentState = this.getSelectedText();
+ var currWordStart = this.selection.getWordRange().start.column;
+ var wordParts = currentState.replace(/([a-z]+|[A-Z]+)(?=[A-Z_]|$)/g, '$1 ').split(/\s/);
+ var delta = column - currWordStart - 1;
+ if (delta < 0) delta = 0;
+ var curLength = 0, itLength = 0;
+ var that = this;
+ if (currentState.match(/[A-Za-z0-9_]+/)) {
+ wordParts.forEach(function (item, i) {
+ itLength = curLength + item.length;
+ if (delta >= curLength && delta <= itLength) {
+ currentState = item;
+ that.selection.clearSelection();
+ that.moveCursorTo(row, curLength + currWordStart);
+ that.selection.selectTo(row, itLength + currWordStart);
+ }
+ curLength = itLength;
+ });
+ }
+
+ var wordPairs = this.$toggleWordPairs;
+ var reg;
+ for (var i = 0; i < wordPairs.length; i++) {
+ var item = wordPairs[i];
+ for (var j = 0; j <= 1; j++) {
+ var negate = +!j;
+ var firstCondition = currentState.match(new RegExp('^\\s?_?(' + lang.escapeRegExp(item[j]) + ')\\s?$', 'i'));
+ if (firstCondition) {
+ var secondCondition = currentState.match(new RegExp('([_]|^|\\s)(' + lang.escapeRegExp(firstCondition[1]) + ')($|\\s)', 'g'));
+ if (secondCondition) {
+ reg = currentState.replace(new RegExp(lang.escapeRegExp(item[j]), 'i'), function (result) {
+ var res = item[negate];
+ if (result.toUpperCase() == result) {
+ res = res.toUpperCase();
+ } else if (result.charAt(0).toUpperCase() == result.charAt(0)) {
+ res = res.substr(0, 0) + item[negate].charAt(0).toUpperCase() + res.substr(1);
+ }
+ return res;
+ });
+ this.insert(reg);
+ reg = "";
+ }
+ }
+ }
}
};
this.removeLines = function() {
@@ -14018,8 +14006,8 @@ Editor.$uid = 0;
};
};
- this.onCompositionStart = function(text) {
- this.renderer.showComposition(this.getCursorPosition());
+ this.onCompositionStart = function(compositionState) {
+ this.renderer.showComposition(compositionState);
};
this.onCompositionUpdate = function(text) {
@@ -14050,7 +14038,6 @@ Editor.$uid = 0;
var config = this.renderer.layerConfig;
var rows = dir * Math.floor(config.height / config.lineHeight);
- this.$blockScrolling++;
if (select === true) {
this.selection.$moveSelection(function(){
this.moveCursorBy(rows, 0);
@@ -14059,7 +14046,6 @@ Editor.$uid = 0;
this.selection.moveCursorBy(rows, 0);
this.selection.clearSelection();
}
- this.$blockScrolling--;
var scrollTop = renderer.scrollTop;
@@ -14111,9 +14097,7 @@ Editor.$uid = 0;
return this.selection.getRange();
};
this.selectAll = function() {
- this.$blockScrolling += 1;
this.selection.selectAll();
- this.$blockScrolling -= 1;
};
this.clearSelection = function() {
this.selection.clearSelection();
@@ -14177,7 +14161,7 @@ Editor.$uid = 0;
}
}
}
- else if (token && token.type.indexOf('tag-name') !== -1) {
+ else if (token.type.indexOf('tag-name') !== -1) {
if (isNaN(depth[token.value])) {
depth[token.value] = 0;
}
@@ -14281,11 +14265,8 @@ Editor.$uid = 0;
this.gotoLine = function(lineNumber, column, animate) {
this.selection.clearSelection();
this.session.unfold({row: lineNumber - 1, column: column || 0});
-
- this.$blockScrolling += 1;
this.exitMultiSelectMode && this.exitMultiSelectMode();
this.moveCursorTo(lineNumber - 1, column || 0);
- this.$blockScrolling -= 1;
if (!this.isRowFullyVisible(lineNumber - 1))
this.scrollToLine(lineNumber - 1, true, animate);
@@ -14371,10 +14352,9 @@ Editor.$uid = 0;
if (this.$tryReplace(range, replacement)) {
replaced = 1;
}
- if (range !== null) {
- this.selection.setSelectionRange(range);
- this.renderer.scrollSelectionIntoView(range.start, range.end);
- }
+
+ this.selection.setSelectionRange(range);
+ this.renderer.scrollSelectionIntoView(range.start, range.end);
return replaced;
};
@@ -14388,8 +14368,6 @@ Editor.$uid = 0;
if (!ranges.length)
return replaced;
- this.$blockScrolling += 1;
-
var selection = this.getSelectionRange();
this.selection.moveTo(0, 0);
@@ -14400,7 +14378,6 @@ Editor.$uid = 0;
}
this.selection.setSelectionRange(selection);
- this.$blockScrolling -= 1;
return replaced;
};
@@ -14463,10 +14440,8 @@ Editor.$uid = 0;
};
this.revealRange = function(range, animate) {
- this.$blockScrolling += 1;
this.session.unfold(range);
this.selection.setSelectionRange(range);
- this.$blockScrolling -= 1;
var scrollTop = this.renderer.scrollTop;
this.renderer.scrollSelectionIntoView(range.start, range.end, 0.5);
@@ -14474,15 +14449,11 @@ Editor.$uid = 0;
this.renderer.animateScrolling(scrollTop);
};
this.undo = function() {
- this.$blockScrolling++;
- this.session.getUndoManager().undo();
- this.$blockScrolling--;
+ this.session.getUndoManager().undo(this.session);
this.renderer.scrollCursorIntoView(null, 0.5);
};
this.redo = function() {
- this.$blockScrolling++;
- this.session.getUndoManager().redo();
- this.$blockScrolling--;
+ this.session.getUndoManager().redo(this.session);
this.renderer.scrollCursorIntoView(null, 0.5);
};
this.destroy = function() {
@@ -14578,10 +14549,17 @@ config.defineOptions(Editor.prototype, "editor", {
},
readOnly: {
set: function(readOnly) {
+ this.textInput.setReadOnly(readOnly);
this.$resetCursorStyle();
},
initialValue: false
},
+ copyWithEmptySelection: {
+ set: function(value) {
+ this.textInput.setCopyWithEmptySelection(value);
+ },
+ initialValue: false
+ },
cursorStyle: {
set: function(val) { this.$resetCursorStyle(); },
values: ["ace", "slim", "smooth", "wide"],
@@ -14598,9 +14576,41 @@ config.defineOptions(Editor.prototype, "editor", {
},
keyboardHandler: {
set: function(val) { this.setKeyboardHandler(val); },
- get: function() { return this.keybindingId; },
+ get: function() { return this.$keybindingId; },
handlesSet: true
},
+ value: {
+ set: function(val) { this.session.setValue(val); },
+ get: function() { return this.getValue(); },
+ handlesSet: true,
+ hidden: true
+ },
+ session: {
+ set: function(val) { this.setSession(val); },
+ get: function() { return this.session; },
+ handlesSet: true,
+ hidden: true
+ },
+
+ showLineNumbers: {
+ set: function(show) {
+ this.renderer.$gutterLayer.setShowLineNumbers(show);
+ this.renderer.$loop.schedule(this.renderer.CHANGE_GUTTER);
+ if (show && this.$relativeLineNumbers)
+ relativeNumberRenderer.attach(this);
+ else
+ relativeNumberRenderer.detach(this);
+ },
+ initialValue: true
+ },
+ relativeLineNumbers: {
+ set: function(value) {
+ if (this.$showLineNumbers && value)
+ relativeNumberRenderer.attach(this);
+ else
+ relativeNumberRenderer.detach(this);
+ }
+ },
hScrollBarAlwaysVisible: "renderer",
vScrollBarAlwaysVisible: "renderer",
@@ -14612,9 +14622,8 @@ config.defineOptions(Editor.prototype, "editor", {
printMargin: "renderer",
fadeFoldWidgets: "renderer",
showFoldWidgets: "renderer",
- showLineNumbers: "renderer",
- showGutter: "renderer",
displayIndentGuides: "renderer",
+ showGutter: "renderer",
fontSize: "renderer",
fontFamily: "renderer",
maxLines: "renderer",
@@ -14622,11 +14631,14 @@ config.defineOptions(Editor.prototype, "editor", {
scrollPastEnd: "renderer",
fixedWidthGutter: "renderer",
theme: "renderer",
+ hasCssTransforms: "renderer",
+ maxPixelHeight: "renderer",
+ useTextareaForIME: "renderer",
scrollSpeed: "$mouseHandler",
dragDelay: "$mouseHandler",
dragEnabled: "$mouseHandler",
- focusTimout: "$mouseHandler",
+ focusTimeout: "$mouseHandler",
tooltipFollowsMouse: "$mouseHandler",
firstLineNumber: "session",
@@ -14634,6 +14646,7 @@ config.defineOptions(Editor.prototype, "editor", {
newLineMode: "session",
useWorker: "session",
useSoftTabs: "session",
+ navigateWithinSoftTabs: "session",
tabSize: "session",
wrap: "session",
indentedSoftWrap: "session",
@@ -14641,123 +14654,652 @@ config.defineOptions(Editor.prototype, "editor", {
mode: "session"
});
+
+var relativeNumberRenderer = {
+ getText: function(session, row) {
+ return (Math.abs(session.selection.lead.row - row) || (row + 1 + (row < 9 ? "\xb7" : ""))) + "";
+ },
+ getWidth: function(session, lastLineNumber, config) {
+ return Math.max(
+ lastLineNumber.toString().length,
+ (config.lastRow + 1).toString().length,
+ 2
+ ) * config.characterWidth;
+ },
+ update: function(e, editor) {
+ editor.renderer.$loop.schedule(editor.renderer.CHANGE_GUTTER);
+ },
+ attach: function(editor) {
+ editor.renderer.$gutterLayer.$renderer = this;
+ editor.on("changeSelection", this.update);
+ this.update(null, editor);
+ },
+ detach: function(editor) {
+ if (editor.renderer.$gutterLayer.$renderer == this)
+ editor.renderer.$gutterLayer.$renderer = null;
+ editor.off("changeSelection", this.update);
+ this.update(null, editor);
+ }
+};
+
exports.Editor = Editor;
});
-ace.define("ace/undomanager",["require","exports","module"], function(acequire, exports, module) {
+ace.define("ace/undomanager",["require","exports","module","ace/range"], function(acequire, exports, module) {
"use strict";
var UndoManager = function() {
+ this.$maxRev = 0;
+ this.$fromUndo = false;
this.reset();
};
(function() {
- this.execute = function(options) {
- var deltaSets = options.args[0];
- this.$doc = options.args[1];
- if (options.merge && this.hasUndo()){
- this.dirtyCounter--;
- deltaSets = this.$undoStack.pop().concat(deltaSets);
- }
- this.$undoStack.push(deltaSets);
- this.$redoStack = [];
- if (this.dirtyCounter < 0) {
- this.dirtyCounter = NaN;
+
+ this.addSession = function(session) {
+ this.$session = session;
+ };
+ this.add = function(delta, allowMerge, session) {
+ if (this.$fromUndo) return;
+ if (delta == this.$lastDelta) return;
+ if (allowMerge === false || !this.lastDeltas) {
+ this.lastDeltas = [];
+ this.$undoStack.push(this.lastDeltas);
+ delta.id = this.$rev = ++this.$maxRev;
+ }
+ if (delta.action == "remove" || delta.action == "insert")
+ this.$lastDelta = delta;
+ this.lastDeltas.push(delta);
+ };
+
+ this.addSelection = function(selection, rev) {
+ this.selections.push({
+ value: selection,
+ rev: rev || this.$rev
+ });
+ };
+
+ this.startNewGroup = function() {
+ this.lastDeltas = null;
+ return this.$rev;
+ };
+
+ this.markIgnored = function(from, to) {
+ if (to == null) to = this.$rev + 1;
+ var stack = this.$undoStack;
+ for (var i = stack.length; i--;) {
+ var delta = stack[i][0];
+ if (delta.id <= from)
+ break;
+ if (delta.id < to)
+ delta.ignore = true;
+ }
+ this.lastDeltas = null;
+ };
+
+ this.getSelection = function(rev, after) {
+ var stack = this.selections;
+ for (var i = stack.length; i--;) {
+ var selection = stack[i];
+ if (selection.rev < rev) {
+ if (after)
+ selection = stack[i + 1];
+ return selection;
+ }
+ }
+ };
+
+ this.getRevision = function() {
+ return this.$rev;
+ };
+
+ this.getDeltas = function(from, to) {
+ if (to == null) to = this.$rev + 1;
+ var stack = this.$undoStack;
+ var end = null, start = 0;
+ for (var i = stack.length; i--;) {
+ var delta = stack[i][0];
+ if (delta.id < to && !end)
+ end = i+1;
+ if (delta.id <= from) {
+ start = i + 1;
+ break;
+ }
}
- this.dirtyCounter++;
+ return stack.slice(start, end);
};
- this.undo = function(dontSelect) {
- var deltaSets = this.$undoStack.pop();
+
+ this.getChangedRanges = function(from, to) {
+ if (to == null) to = this.$rev + 1;
+
+ };
+
+ this.getChangedLines = function(from, to) {
+ if (to == null) to = this.$rev + 1;
+
+ };
+ this.undo = function(session, dontSelect) {
+ this.lastDeltas = null;
+ var stack = this.$undoStack;
+
+ if (!rearrangeUndoStack(stack, stack.length))
+ return;
+
+ if (!session)
+ session = this.$session;
+
+ if (this.$redoStackBaseRev !== this.$rev && this.$redoStack.length)
+ this.$redoStack = [];
+
+ this.$fromUndo = true;
+
+ var deltaSet = stack.pop();
var undoSelectionRange = null;
- if (deltaSets) {
- undoSelectionRange = this.$doc.undoChanges(deltaSets, dontSelect);
- this.$redoStack.push(deltaSets);
- this.dirtyCounter--;
+ if (deltaSet && deltaSet.length) {
+ undoSelectionRange = session.undoChanges(deltaSet, dontSelect);
+ this.$redoStack.push(deltaSet);
+ this.$syncRev();
}
+
+ this.$fromUndo = false;
return undoSelectionRange;
};
- this.redo = function(dontSelect) {
- var deltaSets = this.$redoStack.pop();
+ this.redo = function(session, dontSelect) {
+ this.lastDeltas = null;
+
+ if (!session)
+ session = this.$session;
+
+ this.$fromUndo = true;
+ if (this.$redoStackBaseRev != this.$rev) {
+ var diff = this.getDeltas(this.$redoStackBaseRev, this.$rev + 1);
+ rebaseRedoStack(this.$redoStack, diff);
+ this.$redoStackBaseRev = this.$rev;
+ this.$redoStack.forEach(function(x) {
+ x[0].id = ++this.$maxRev;
+ }, this);
+ }
+ var deltaSet = this.$redoStack.pop();
var redoSelectionRange = null;
- if (deltaSets) {
- redoSelectionRange =
- this.$doc.redoChanges(this.$deserializeDeltas(deltaSets), dontSelect);
- this.$undoStack.push(deltaSets);
- this.dirtyCounter++;
+
+ if (deltaSet) {
+ redoSelectionRange = session.redoChanges(deltaSet, dontSelect);
+ this.$undoStack.push(deltaSet);
+ this.$syncRev();
}
+ this.$fromUndo = false;
+
return redoSelectionRange;
};
+
+ this.$syncRev = function() {
+ var stack = this.$undoStack;
+ var nextDelta = stack[stack.length - 1];
+ var id = nextDelta && nextDelta[0].id || 0;
+ this.$redoStackBaseRev = id;
+ this.$rev = id;
+ };
this.reset = function() {
+ this.lastDeltas = null;
+ this.$lastDelta = null;
this.$undoStack = [];
this.$redoStack = [];
- this.dirtyCounter = 0;
+ this.$rev = 0;
+ this.mark = 0;
+ this.$redoStackBaseRev = this.$rev;
+ this.selections = [];
};
- this.hasUndo = function() {
+ this.canUndo = function() {
return this.$undoStack.length > 0;
};
- this.hasRedo = function() {
- return this.$redoStack.length > 0;
+ this.canRedo = function() {
+ return this.$redoStack.length > 0;
+ };
+ this.bookmark = function(rev) {
+ if (rev == undefined)
+ rev = this.$rev;
+ this.mark = rev;
+ };
+ this.isAtBookmark = function() {
+ return this.$rev === this.mark;
+ };
+
+ this.toJSON = function() {
+
+ };
+
+ this.fromJSON = function() {
+
+ };
+
+ this.hasUndo = this.canUndo;
+ this.hasRedo = this.canRedo;
+ this.isClean = this.isAtBookmark;
+ this.markClean = this.bookmark;
+
+ this.$prettyPrint = function(delta) {
+ if (delta) return stringifyDelta(delta);
+ return stringifyDelta(this.$undoStack) + "\n---\n" + stringifyDelta(this.$redoStack);
+ };
+}).call(UndoManager.prototype);
+
+function rearrangeUndoStack(stack, pos) {
+ for (var i = pos; i--; ) {
+ var deltaSet = stack[i];
+ if (deltaSet && !deltaSet[0].ignore) {
+ while(i < pos - 1) {
+ var swapped = swapGroups(stack[i], stack[i + 1]);
+ stack[i] = swapped[0];
+ stack[i + 1] = swapped[1];
+ i++;
+ }
+ return true;
+ }
+ }
+}
+
+var Range = acequire("./range").Range;
+var cmp = Range.comparePoints;
+var comparePoints = Range.comparePoints;
+
+function $updateMarkers(delta) {
+ var isInsert = delta.action == "insert";
+ var start = delta.start;
+ var end = delta.end;
+ var rowShift = (end.row - start.row) * (isInsert ? 1 : -1);
+ var colShift = (end.column - start.column) * (isInsert ? 1 : -1);
+ if (isInsert) end = start;
+
+ for (var i in this.marks) {
+ var point = this.marks[i];
+ var cmp = comparePoints(point, start);
+ if (cmp < 0) {
+ continue; // delta starts after the range
+ }
+ if (cmp === 0) {
+ if (isInsert) {
+ if (point.bias == 1) {
+ cmp = 1;
+ }
+ else {
+ point.bias == -1;
+ continue;
+ }
+ }
+ }
+ var cmp2 = isInsert ? cmp : comparePoints(point, end);
+ if (cmp2 > 0) {
+ point.row += rowShift;
+ point.column += point.row == end.row ? colShift : 0;
+ continue;
+ }
+ if (!isInsert && cmp2 <= 0) {
+ point.row = start.row;
+ point.column = start.column;
+ if (cmp2 === 0)
+ point.bias = 1;
+ }
+ }
+}
+
+
+
+function clonePos(pos) {
+ return {row: pos.row,column: pos.column};
+}
+function cloneDelta(d) {
+ return {
+ start: clonePos(d.start),
+ end: clonePos(d.end),
+ action: d.action,
+ lines: d.lines.slice()
+ };
+}
+function stringifyDelta(d) {
+ d = d || this;
+ if (Array.isArray(d)) {
+ return d.map(stringifyDelta).join("\n");
+ }
+ var type = "";
+ if (d.action) {
+ type = d.action == "insert" ? "+" : "-";
+ type += "[" + d.lines + "]";
+ } else if (d.value) {
+ if (Array.isArray(d.value)) {
+ type = d.value.map(stringifyRange).join("\n");
+ } else {
+ type = stringifyRange(d.value);
+ }
+ }
+ if (d.start) {
+ type += stringifyRange(d);
+ }
+ if (d.id || d.rev) {
+ type += "\t(" + (d.id || d.rev) + ")";
+ }
+ return type;
+}
+function stringifyRange(r) {
+ return r.start.row + ":" + r.start.column
+ + "=>" + r.end.row + ":" + r.end.column;
+}
+
+function swap(d1, d2) {
+ var i1 = d1.action == "insert";
+ var i2 = d2.action == "insert";
+
+ if (i1 && i2) {
+ if (cmp(d2.start, d1.end) >= 0) {
+ shift(d2, d1, -1);
+ } else if (cmp(d2.start, d1.start) <= 0) {
+ shift(d1, d2, +1);
+ } else {
+ return null;
+ }
+ } else if (i1 && !i2) {
+ if (cmp(d2.start, d1.end) >= 0) {
+ shift(d2, d1, -1);
+ } else if (cmp(d2.end, d1.start) <= 0) {
+ shift(d1, d2, -1);
+ } else {
+ return null;
+ }
+ } else if (!i1 && i2) {
+ if (cmp(d2.start, d1.start) >= 0) {
+ shift(d2, d1, +1);
+ } else if (cmp(d2.start, d1.start) <= 0) {
+ shift(d1, d2, +1);
+ } else {
+ return null;
+ }
+ } else if (!i1 && !i2) {
+ if (cmp(d2.start, d1.start) >= 0) {
+ shift(d2, d1, +1);
+ } else if (cmp(d2.end, d1.start) <= 0) {
+ shift(d1, d2, -1);
+ } else {
+ return null;
+ }
+ }
+ return [d2, d1];
+}
+function swapGroups(ds1, ds2) {
+ for (var i = ds1.length; i--; ) {
+ for (var j = 0; j < ds2.length; j++) {
+ if (!swap(ds1[i], ds2[j])) {
+ while (i < ds1.length) {
+ while (j--) {
+ swap(ds2[j], ds1[i]);
+ }
+ j = ds2.length;
+ i++;
+ }
+ return [ds1, ds2];
+ }
+ }
+ }
+ ds1.selectionBefore = ds2.selectionBefore =
+ ds1.selectionAfter = ds2.selectionAfter = null;
+ return [ds2, ds1];
+}
+function xform(d1, c1) {
+ var i1 = d1.action == "insert";
+ var i2 = c1.action == "insert";
+
+ if (i1 && i2) {
+ if (cmp(d1.start, c1.start) < 0) {
+ shift(c1, d1, 1);
+ } else {
+ shift(d1, c1, 1);
+ }
+ } else if (i1 && !i2) {
+ if (cmp(d1.start, c1.end) >= 0) {
+ shift(d1, c1, -1);
+ } else if (cmp(d1.start, c1.start) <= 0) {
+ shift(c1, d1, +1);
+ } else {
+ shift(d1, Range.fromPoints(c1.start, d1.start), -1);
+ shift(c1, d1, +1);
+ }
+ } else if (!i1 && i2) {
+ if (cmp(c1.start, d1.end) >= 0) {
+ shift(c1, d1, -1);
+ } else if (cmp(c1.start, d1.start) <= 0) {
+ shift(d1, c1, +1);
+ } else {
+ shift(c1, Range.fromPoints(d1.start, c1.start), -1);
+ shift(d1, c1, +1);
+ }
+ } else if (!i1 && !i2) {
+ if (cmp(c1.start, d1.end) >= 0) {
+ shift(c1, d1, -1);
+ } else if (cmp(c1.end, d1.start) <= 0) {
+ shift(d1, c1, -1);
+ } else {
+ var before, after;
+ if (cmp(d1.start, c1.start) < 0) {
+ before = d1;
+ d1 = splitDelta(d1, c1.start);
+ }
+ if (cmp(d1.end, c1.end) > 0) {
+ after = splitDelta(d1, c1.end);
+ }
+
+ shiftPos(c1.end, d1.start, d1.end, -1);
+ if (after && !before) {
+ d1.lines = after.lines;
+ d1.start = after.start;
+ d1.end = after.end;
+ after = d1;
+ }
+
+ return [c1, before, after].filter(Boolean);
+ }
+ }
+ return [c1, d1];
+}
+
+function shift(d1, d2, dir) {
+ shiftPos(d1.start, d2.start, d2.end, dir);
+ shiftPos(d1.end, d2.start, d2.end, dir);
+}
+function shiftPos(pos, start, end, dir) {
+ if (pos.row == (dir == 1 ? start : end).row) {
+ pos.column += dir * (end.column - start.column);
+ }
+ pos.row += dir * (end.row - start.row);
+}
+function splitDelta(c, pos) {
+ var lines = c.lines;
+ var end = c.end;
+ c.end = clonePos(pos);
+ var rowsBefore = c.end.row - c.start.row;
+ var otherLines = lines.splice(rowsBefore, lines.length);
+
+ var col = rowsBefore ? pos.column : pos.column - c.start.column;
+ lines.push(otherLines[0].substring(0, col));
+ otherLines[0] = otherLines[0].substr(col) ;
+ var rest = {
+ start: clonePos(pos),
+ end: end,
+ lines: otherLines,
+ action: c.action
+ };
+ return rest;
+}
+
+function moveDeltasByOne(redoStack, d) {
+ d = cloneDelta(d);
+ for (var j = redoStack.length; j--;) {
+ var deltaSet = redoStack[j];
+ for (var i = 0; i < deltaSet.length; i++) {
+ var x = deltaSet[i];
+ var xformed = xform(x, d);
+ d = xformed[0];
+ if (xformed.length != 2) {
+ if (xformed[2]) {
+ deltaSet.splice(i + 1, 1, xformed[1], xformed[2]);
+ i++;
+ } else if (!xformed[1]) {
+ deltaSet.splice(i, 1);
+ i--;
+ }
+ }
+ }
+ if (!deltaSet.length) {
+ redoStack.splice(j, 1);
+ }
+ }
+ return redoStack;
+}
+function rebaseRedoStack(redoStack, deltaSets) {
+ for (var i = 0; i < deltaSets.length; i++) {
+ var deltas = deltaSets[i];
+ for (var j = 0; j < deltas.length; j++) {
+ moveDeltasByOne(redoStack, deltas[j]);
+ }
+ }
+}
+
+exports.UndoManager = UndoManager;
+
+});
+
+ace.define("ace/layer/lines",["require","exports","module","ace/lib/dom"], function(acequire, exports, module) {
+"use strict";
+
+var dom = acequire("../lib/dom");
+
+var Lines = function(element, canvasHeight) {
+ this.element = element;
+ this.canvasHeight = canvasHeight || 500000;
+ this.element.style.height = (this.canvasHeight * 2) + "px";
+
+ this.cells = [];
+ this.cellCache = [];
+ this.$offsetCoefficient = 0;
+};
+
+(function() {
+
+ this.moveContainer = function(config) {
+ dom.translate(this.element, 0, -((config.firstRowScreen * config.lineHeight) % this.canvasHeight) - config.offset * this.$offsetCoefficient);
+ };
+
+ this.pageChanged = function(oldConfig, newConfig) {
+ return (
+ Math.floor((oldConfig.firstRowScreen * oldConfig.lineHeight) / this.canvasHeight) !==
+ Math.floor((newConfig.firstRowScreen * newConfig.lineHeight) / this.canvasHeight)
+ );
+ };
+
+ this.computeLineTop = function(row, config, session) {
+ var screenTop = config.firstRowScreen * config.lineHeight;
+ var screenPage = Math.floor(screenTop / this.canvasHeight);
+ var lineTop = session.documentToScreenRow(row, 0) * config.lineHeight;
+ return lineTop - (screenPage * this.canvasHeight);
+ };
+
+ this.computeLineHeight = function(row, config, session) {
+ return config.lineHeight * session.getRowLength(row);
+ };
+
+ this.getLength = function() {
+ return this.cells.length;
+ };
+
+ this.get = function(index) {
+ return this.cells[index];
+ };
+
+ this.shift = function() {
+ this.$cacheCell(this.cells.shift());
};
- this.markClean = function() {
- this.dirtyCounter = 0;
+
+ this.pop = function() {
+ this.$cacheCell(this.cells.pop());
};
- this.isClean = function() {
- return this.dirtyCounter === 0;
+
+ this.push = function(cell) {
+ if (Array.isArray(cell)) {
+ this.cells.push.apply(this.cells, cell);
+ var fragment = dom.createFragment(this.element);
+ for (var i=0; i foldStart) {
row = fold.end.row + 1;
@@ -14862,100 +15408,249 @@ var Gutter = function(parentEl) {
foldStart = fold ? fold.start.row : Infinity;
}
if (row > lastRow) {
- while (this.$cells.length > index + 1) {
- cell = this.$cells.pop();
- this.element.removeChild(cell.element);
- }
+ while (this.$lines.getLength() > index + 1)
+ this.$lines.pop();
+
break;
}
- cell = this.$cells[++index];
- if (!cell) {
- cell = {element: null, textNode: null, foldWidget: null};
- cell.element = dom.createElement("div");
- cell.textNode = document.createTextNode('');
- cell.element.appendChild(cell.textNode);
- this.element.appendChild(cell.element);
- this.$cells[index] = cell;
- }
-
- var className = "ace_gutter-cell ";
- if (breakpoints[row])
- className += breakpoints[row];
- if (decorations[row])
- className += decorations[row];
- if (this.$annotations[row])
- className += this.$annotations[row].className;
- if (cell.element.className != className)
- cell.element.className = className;
-
- var height = session.getRowLength(row) * config.lineHeight + "px";
- if (height != cell.element.style.height)
- cell.element.style.height = height;
-
- if (foldWidgets) {
- var c = foldWidgets[row];
- if (c == null)
- c = foldWidgets[row] = session.getFoldWidget(row);
- }
-
- if (c) {
- if (!cell.foldWidget) {
- cell.foldWidget = dom.createElement("span");
- cell.element.appendChild(cell.foldWidget);
- }
- var className = "ace_fold-widget ace_" + c;
- if (c == "start" && row == foldStart && row < fold.end.row)
- className += " ace_closed";
- else
- className += " ace_open";
- if (cell.foldWidget.className != className)
- cell.foldWidget.className = className;
-
- var height = config.lineHeight + "px";
- if (cell.foldWidget.style.height != height)
- cell.foldWidget.style.height = height;
+ cell = this.$lines.get(++index);
+ if (cell) {
+ cell.row = row;
} else {
- if (cell.foldWidget) {
- cell.element.removeChild(cell.foldWidget);
- cell.foldWidget = null;
- }
+ cell = this.$lines.createCell(row, config, this.session, onCreateCell);
+ this.$lines.push(cell);
}
-
- var text = lastLineNumber = gutterRenderer
- ? gutterRenderer.getText(session, row)
- : row + firstLineNumber;
- if (text !== cell.textNode.data)
- cell.textNode.data = text;
+ this.$renderCell(cell, config, fold, row);
row++;
}
+
+ this._signal("afterRender");
+ this.$updateGutterWidth(config);
+ };
- this.element.style.height = config.minHeight + "px";
-
+ this.$updateGutterWidth = function(config) {
+ var session = this.session;
+
+ var gutterRenderer = session.gutterRenderer || this.$renderer;
+
+ var firstLineNumber = session.$firstLineNumber;
+ var lastLineText = this.$lines.last() ? this.$lines.last().text : "";
+
if (this.$fixedWidth || session.$useWrapMode)
- lastLineNumber = session.getLength() + firstLineNumber;
+ lastLineText = session.getLength() + firstLineNumber - 1;
var gutterWidth = gutterRenderer
- ? gutterRenderer.getWidth(session, lastLineNumber, config)
- : lastLineNumber.toString().length * config.characterWidth;
+ ? gutterRenderer.getWidth(session, lastLineText, config)
+ : lastLineText.toString().length * config.characterWidth;
var padding = this.$padding || this.$computePadding();
gutterWidth += padding.left + padding.right;
if (gutterWidth !== this.gutterWidth && !isNaN(gutterWidth)) {
this.gutterWidth = gutterWidth;
+ this.element.parentNode.style.width =
this.element.style.width = Math.ceil(this.gutterWidth) + "px";
- this._emit("changeGutterWidth", gutterWidth);
+ this._signal("changeGutterWidth", gutterWidth);
+ }
+ };
+
+ this.$updateCursorRow = function() {
+ if (!this.$highlightGutterLine)
+ return;
+
+ var position = this.session.selection.getCursor();
+ if (this.$cursorRow === position.row)
+ return;
+
+ this.$cursorRow = position.row;
+ };
+
+ this.updateLineHighlight = function() {
+ if (!this.$highlightGutterLine)
+ return;
+ var row = this.session.selection.cursor.row;
+ this.$cursorRow = row;
+
+ if (this.$cursorCell && this.$cursorCell.row == row)
+ return;
+ if (this.$cursorCell)
+ this.$cursorCell.element.className = this.$cursorCell.element.className.replace("ace_gutter-active-line ", "");
+ var cells = this.$lines.cells;
+ this.$cursorCell = null;
+ for (var i = 0; i < cells.length; i++) {
+ var cell = cells[i];
+ if (cell.row >= this.$cursorRow) {
+ if (cell.row > this.$cursorRow) {
+ var fold = this.session.getFoldLine(this.$cursorRow);
+ if (i > 0 && fold && fold.start.row == cells[i - 1].row)
+ cell = cells[i - 1];
+ else
+ break;
+ }
+ cell.element.className = "ace_gutter-active-line " + cell.element.className;
+ this.$cursorCell = cell;
+ break;
+ }
+ }
+ };
+
+ this.scrollLines = function(config) {
+ var oldConfig = this.config;
+ this.config = config;
+
+ this.$updateCursorRow();
+ if (this.$lines.pageChanged(oldConfig, config))
+ return this.update(config);
+
+ this.$lines.moveContainer(config);
+
+ var lastRow = Math.min(config.lastRow + config.gutterOffset, // needed to compensate for hor scollbar
+ this.session.getLength() - 1);
+ var oldLastRow = this.oldLastRow;
+ this.oldLastRow = lastRow;
+
+ if (!oldConfig || oldLastRow < config.firstRow)
+ return this.update(config);
+
+ if (lastRow < oldConfig.firstRow)
+ return this.update(config);
+
+ if (oldConfig.firstRow < config.firstRow)
+ for (var row=this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row>0; row--)
+ this.$lines.shift();
+
+ if (oldLastRow > lastRow)
+ for (var row=this.session.getFoldedRowCount(lastRow + 1, oldLastRow); row>0; row--)
+ this.$lines.pop();
+
+ if (config.firstRow < oldConfig.firstRow) {
+ this.$lines.unshift(this.$renderLines(config, config.firstRow, oldConfig.firstRow - 1));
+ }
+
+ if (lastRow > oldLastRow) {
+ this.$lines.push(this.$renderLines(config, oldLastRow + 1, lastRow));
+ }
+
+ this.updateLineHighlight();
+
+ this._signal("afterRender");
+ this.$updateGutterWidth(config);
+ };
+
+ this.$renderLines = function(config, firstRow, lastRow) {
+ var fragment = [];
+ var row = firstRow;
+ var foldLine = this.session.getNextFoldLine(row);
+ var foldStart = foldLine ? foldLine.start.row : Infinity;
+
+ while (true) {
+ if (row > foldStart) {
+ row = foldLine.end.row+1;
+ foldLine = this.session.getNextFoldLine(row, foldLine);
+ foldStart = foldLine ? foldLine.start.row : Infinity;
+ }
+ if (row > lastRow)
+ break;
+
+ var cell = this.$lines.createCell(row, config, this.session, onCreateCell);
+ this.$renderCell(cell, config, foldLine, row);
+ fragment.push(cell);
+
+ row++;
+ }
+ return fragment;
+ };
+
+ this.$renderCell = function(cell, config, fold, row) {
+ var element = cell.element;
+
+ var session = this.session;
+
+ var textNode = element.childNodes[0];
+ var foldWidget = element.childNodes[1];
+
+ var firstLineNumber = session.$firstLineNumber;
+
+ var breakpoints = session.$breakpoints;
+ var decorations = session.$decorations;
+ var gutterRenderer = session.gutterRenderer || this.$renderer;
+ var foldWidgets = this.$showFoldWidgets && session.foldWidgets;
+ var foldStart = fold ? fold.start.row : Number.MAX_VALUE;
+
+ var className = "ace_gutter-cell ";
+ if (this.$highlightGutterLine) {
+ if (row == this.$cursorRow || (fold && row < this.$cursorRow && row >= foldStart && this.$cursorRow <= fold.end.row)) {
+ className += "ace_gutter-active-line ";
+ if (this.$cursorCell != cell) {
+ if (this.$cursorCell)
+ this.$cursorCell.element.className = this.$cursorCell.element.className.replace("ace_gutter-active-line ", "");
+ this.$cursorCell = cell;
+ }
+ }
+ }
+
+ if (breakpoints[row])
+ className += breakpoints[row];
+ if (decorations[row])
+ className += decorations[row];
+ if (this.$annotations[row])
+ className += this.$annotations[row].className;
+ if (element.className != className)
+ element.className = className;
+
+ if (foldWidgets) {
+ var c = foldWidgets[row];
+ if (c == null)
+ c = foldWidgets[row] = session.getFoldWidget(row);
+ }
+
+ if (c) {
+ var className = "ace_fold-widget ace_" + c;
+ if (c == "start" && row == foldStart && row < fold.end.row)
+ className += " ace_closed";
+ else
+ className += " ace_open";
+ if (foldWidget.className != className)
+ foldWidget.className = className;
+
+ var foldHeight = config.lineHeight + "px";
+ dom.setStyle(foldWidget.style, "height", foldHeight);
+ dom.setStyle(foldWidget.style, "display", "inline-block");
+ } else {
+ if (foldWidget) {
+ dom.setStyle(foldWidget.style, "display", "none");
+ }
}
+
+ var text = (gutterRenderer
+ ? gutterRenderer.getText(session, row)
+ : row + firstLineNumber).toString();
+
+ if (text !== textNode.data) {
+ textNode.data = text;
+ }
+
+ dom.setStyle(cell.element.style, "height", this.$lines.computeLineHeight(row, config, session) + "px");
+ dom.setStyle(cell.element.style, "top", this.$lines.computeLineTop(row, config, session) + "px");
+
+ cell.text = text;
+ return cell;
};
this.$fixedWidth = false;
+ this.$highlightGutterLine = true;
+ this.$renderer = "";
+ this.setHighlightGutterLine = function(highlightGutterLine) {
+ this.$highlightGutterLine = highlightGutterLine;
+ };
+
this.$showLineNumbers = true;
this.$renderer = "";
this.setShowLineNumbers = function(show) {
this.$renderer = !show && {
- getWidth: function() {return "";},
+ getWidth: function() {return 0;},
getText: function() {return "";}
};
};
@@ -14984,8 +15679,10 @@ var Gutter = function(parentEl) {
return {left: 0, right: 0};
var style = dom.computedStyle(this.element.firstChild);
this.$padding = {};
- this.$padding.left = parseInt(style.paddingLeft) + 1 || 0;
- this.$padding.right = parseInt(style.paddingRight) || 0;
+ this.$padding.left = (parseInt(style.borderLeftWidth) || 0)
+ + (parseInt(style.paddingLeft) || 0) + 1;
+ this.$padding.right = (parseInt(style.borderRightWidth) || 0)
+ + (parseInt(style.paddingRight) || 0);
return this.$padding;
};
@@ -15000,6 +15697,16 @@ var Gutter = function(parentEl) {
}).call(Gutter.prototype);
+function onCreateCell(element) {
+ var textNode = document.createTextNode('');
+ element.appendChild(textNode);
+
+ var foldWidget = dom.createElement("span");
+ element.appendChild(foldWidget);
+
+ return element;
+}
+
exports.Gutter = Gutter;
});
@@ -15030,14 +15737,27 @@ var Marker = function(parentEl) {
this.setMarkers = function(markers) {
this.markers = markers;
};
+
+ this.elt = function(className, css) {
+ var x = this.i != -1 && this.element.childNodes[this.i];
+ if (!x) {
+ x = document.createElement("div");
+ this.element.appendChild(x);
+ this.i = -1;
+ } else {
+ this.i++;
+ }
+ x.style.cssText = css;
+ x.className = className;
+ };
this.update = function(config) {
if (!config) return;
this.config = config;
-
- var html = [];
+ this.i = 0;
+ var html;
for (var key in this.markers) {
var marker = this.markers[key];
@@ -15052,9 +15772,7 @@ var Marker = function(parentEl) {
range = range.toScreenRange(this.session);
if (marker.renderer) {
var top = this.$getTop(range.start.row, config);
- var left = this.$padding + (this.session.$bidiHandler.isBidiRow(range.start.row)
- ? this.session.$bidiHandler.getPosLeft(range.start.column)
- : range.start.column * config.characterWidth);
+ var left = this.$padding + range.start.column * config.characterWidth;
marker.renderer(html, range, left, top, config);
} else if (marker.type == "fullLine") {
this.drawFullLineMarker(html, range, marker.clazz, config);
@@ -15066,14 +15784,13 @@ var Marker = function(parentEl) {
else
this.drawMultiLineMarker(html, range, marker.clazz, config);
} else {
- if (this.session.$bidiHandler.isBidiRow(range.start.row)) {
- this.drawBidiSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config);
- } else {
- this.drawSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config);
- }
+ this.drawSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config);
}
}
- this.element.innerHTML = html.join("");
+ if (this.i !=-1) {
+ while (this.i < this.element.childElementCount)
+ this.element.removeChild(this.element.lastChild);
+ }
};
this.$getTop = function(row, layerConfig) {
@@ -15091,7 +15808,6 @@ var Marker = function(parentEl) {
var prev = 0;
var curr = 0;
var next = session.getScreenLastRowColumn(row);
- var clazzModified = null;
var lineRange = new Range(row, range.start.column, row, curr);
for (; row <= end; row++) {
lineRange.start.row = lineRange.end.row = row;
@@ -15100,38 +15816,29 @@ var Marker = function(parentEl) {
prev = curr;
curr = next;
next = row + 1 < end ? session.getScreenLastRowColumn(row + 1) : row == end ? 0 : range.end.column;
- clazzModified = clazz + (row == start ? " ace_start" : "") + " ace_br"
- + getBorderClass(row == start || row == start + 1 && range.start.column, prev < curr, curr > next, row == end);
-
- if (this.session.$bidiHandler.isBidiRow(row)) {
- this.drawBidiSingleLineMarker(stringBuilder, lineRange, clazzModified,
- layerConfig, row == end ? 0 : 1, extraStyle);
- } else {
- this.drawSingleLineMarker(stringBuilder, lineRange, clazzModified,
- layerConfig, row == end ? 0 : 1, extraStyle);
- }
+ this.drawSingleLineMarker(stringBuilder, lineRange,
+ clazz + (row == start ? " ace_start" : "") + " ace_br"
+ + getBorderClass(row == start || row == start + 1 && range.start.column, prev < curr, curr > next, row == end),
+ layerConfig, row == end ? 0 : 1, extraStyle);
}
};
this.drawMultiLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
var padding = this.$padding;
- var height, top, left;
+ var height = config.lineHeight;
+ var top = this.$getTop(range.start.row, config);
+ var left = padding + range.start.column * config.characterWidth;
extraStyle = extraStyle || "";
- if (this.session.$bidiHandler.isBidiRow(range.start.row)) {
+
+ if (this.session.$bidiHandler.isBidiRow(range.start.row)) {
var range1 = range.clone();
range1.end.row = range1.start.row;
range1.end.column = this.session.getLine(range1.start.row).length;
this.drawBidiSingleLineMarker(stringBuilder, range1, clazz + " ace_br1 ace_start", config, null, extraStyle);
} else {
- height = config.lineHeight;
- top = this.$getTop(range.start.row, config);
- left = padding + range.start.column * config.characterWidth;
- stringBuilder.push(
- ""
- );
+ this.elt(
+ clazz + " ace_br1 ace_start",
+ "height:"+ height+ "px;"+ "right:0;"+ "top:"+top+ "px;left:"+ left+ "px;" + (extraStyle || "")
+ );
}
if (this.session.$bidiHandler.isBidiRow(range.end.row)) {
var range1 = range.clone();
@@ -15139,16 +15846,16 @@ var Marker = function(parentEl) {
range1.start.column = 0;
this.drawBidiSingleLineMarker(stringBuilder, range1, clazz + " ace_br12", config, null, extraStyle);
} else {
- var width = range.end.column * config.characterWidth;
- height = config.lineHeight;
- top = this.$getTop(range.end.row, config);
- stringBuilder.push(
- ""
- );
+ top = this.$getTop(range.end.row, config);
+ var width = range.end.column * config.characterWidth;
+
+ this.elt(
+ clazz + " ace_br12",
+ "height:"+ height+ "px;"+
+ "width:"+ width+ "px;"+
+ "top:"+ top+ "px;"+
+ "left:"+ padding+ "px;"+ (extraStyle || "")
+ );
}
height = (range.end.row - range.start.row - 1) * config.lineHeight;
if (height <= 0)
@@ -15157,27 +15864,29 @@ var Marker = function(parentEl) {
var radiusClass = (range.start.column ? 1 : 0) | (range.end.column ? 0 : 8);
- stringBuilder.push(
- ""
+ this.elt(
+ clazz + (radiusClass ? " ace_br" + radiusClass : ""),
+ "height:"+ height+ "px;"+
+ "right:0;"+
+ "top:"+ top+ "px;"+
+ "left:"+ padding+ "px;"+ (extraStyle || "")
);
};
this.drawSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength, extraStyle) {
+ if (this.session.$bidiHandler.isBidiRow(range.start.row))
+ return this.drawBidiSingleLineMarker(stringBuilder, range, clazz, config, extraLength, extraStyle);
var height = config.lineHeight;
var width = (range.end.column + (extraLength || 0) - range.start.column) * config.characterWidth;
var top = this.$getTop(range.start.row, config);
var left = this.$padding + range.start.column * config.characterWidth;
- stringBuilder.push(
- ""
+ this.elt(
+ clazz,
+ "height:"+ height+ "px;"+
+ "width:"+ width+ "px;"+
+ "top:"+ top+ "px;"+
+ "left:"+ left+ "px;"+ (extraStyle || "")
);
};
this.drawBidiSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength, extraStyle) {
@@ -15185,14 +15894,14 @@ var Marker = function(parentEl) {
var selections = this.session.$bidiHandler.getSelections(range.start.column, range.end.column);
selections.forEach(function(selection) {
- stringBuilder.push(
- ""
+ this.elt(
+ clazz,
+ "height:" + height + "px;" +
+ "width:" + selection.width + (extraLength || 0) + "px;" +
+ "top:" + top + "px;" +
+ "left:" + (padding + selection.left) + "px;" + (extraStyle || "")
);
- });
+ }, this);
};
this.drawFullLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
@@ -15201,11 +15910,11 @@ var Marker = function(parentEl) {
if (range.start.row != range.end.row)
height += this.$getTop(range.end.row, config) - top;
- stringBuilder.push(
- ""
+ this.elt(
+ clazz,
+ "height:"+ height+ "px;"+
+ "top:"+ top+ "px;"+
+ "left:0;right:0;"+ (extraStyle || "")
);
};
@@ -15213,11 +15922,11 @@ var Marker = function(parentEl) {
var top = this.$getTop(range.start.row, config);
var height = config.lineHeight;
- stringBuilder.push(
- ""
+ this.elt(
+ clazz,
+ "height:"+ height+ "px;"+
+ "top:"+ top+ "px;"+
+ "left:0;right:0;"+ (extraStyle || "")
);
};
@@ -15227,20 +15936,22 @@ exports.Marker = Marker;
});
-ace.define("ace/layer/text",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/lib/event_emitter"], function(acequire, exports, module) {
+ace.define("ace/layer/text",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/layer/lines","ace/lib/event_emitter"], function(acequire, exports, module) {
"use strict";
var oop = acequire("../lib/oop");
var dom = acequire("../lib/dom");
var lang = acequire("../lib/lang");
-var useragent = acequire("../lib/useragent");
+var Lines = acequire("./lines").Lines;
var EventEmitter = acequire("../lib/event_emitter").EventEmitter;
var Text = function(parentEl) {
- this.element = dom.createElement("div");
+ this.dom = dom;
+ this.element = this.dom.createElement("div");
this.element.className = "ace_layer ace_text-layer";
parentEl.appendChild(this.element);
this.$updateEolChar = this.$updateEolChar.bind(this);
+ this.$lines = new Lines(this.element);
};
(function() {
@@ -15254,11 +15965,12 @@ var Text = function(parentEl) {
this.TAB_CHAR = "\u2014"; //"\u21E5";
this.SPACE_CHAR = "\xB7";
this.$padding = 0;
+ this.MAX_LINE_LENGTH = 10000;
this.$updateEolChar = function() {
- var EOL_CHAR = this.session.doc.getNewLineCharacter() == "\n"
- ? this.EOL_CHAR_LF
- : this.EOL_CHAR_CRLF;
+ var doc = this.session.doc;
+ var unixMode = doc.getNewLineCharacter() == "\n" && doc.getNewLineMode() != "windows";
+ var EOL_CHAR = unixMode ? this.EOL_CHAR_LF : this.EOL_CHAR_CRLF;
if (this.EOL_CHAR != EOL_CHAR) {
this.EOL_CHAR = EOL_CHAR;
return true;
@@ -15267,7 +15979,7 @@ var Text = function(parentEl) {
this.setPadding = function(padding) {
this.$padding = padding;
- this.element.style.padding = "0 " + padding + "px";
+ this.element.style.margin = "0 " + padding + "px";
};
this.getLineHeight = function() {
@@ -15326,11 +16038,12 @@ var Text = function(parentEl) {
var tabStr = this.$tabStrings = [0];
for (var i = 1; i < tabSize + 1; i++) {
if (this.showInvisibles) {
- tabStr.push(""
- + lang.stringRepeat(this.TAB_CHAR, i)
- + "");
+ var span = this.dom.createElement("span");
+ span.className = "ace_invisible ace_invisible_tab";
+ span.textContent = lang.stringRepeat(this.TAB_CHAR, i);
+ tabStr.push(span);
} else {
- tabStr.push(lang.stringRepeat(" ", i));
+ tabStr.push(this.dom.createTextNode(lang.stringRepeat(" ", i), this.element));
}
}
if (this.displayIndentGuides) {
@@ -15344,21 +16057,29 @@ var Text = function(parentEl) {
tabClass = " ace_invisible_tab";
var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize);
var tabContent = lang.stringRepeat(this.TAB_CHAR, this.tabSize);
- } else{
+ } else {
var spaceContent = lang.stringRepeat(" ", this.tabSize);
var tabContent = spaceContent;
}
- this.$tabStrings[" "] = "" + spaceContent + "";
- this.$tabStrings["\t"] = "" + tabContent + "";
+ var span = this.dom.createElement("span");
+ span.className = className + spaceClass;
+ span.textContent = spaceContent;
+ this.$tabStrings[" "] = span;
+
+ var span = this.dom.createElement("span");
+ span.className = className + tabClass;
+ span.textContent = tabContent;
+ this.$tabStrings["\t"] = span;
}
};
this.updateLines = function(config, firstRow, lastRow) {
if (this.config.lastRow != config.lastRow ||
this.config.firstRow != config.firstRow) {
- this.scrollLines(config);
+ return this.update(config);
}
+
this.config = config;
var first = Math.max(firstRow, config.firstRow);
@@ -15380,6 +16101,7 @@ var Text = function(parentEl) {
lineElementsIdx ++;
}
+ var heightChanged = false;
var row = first;
var foldLine = this.session.getNextFoldLine(row);
var foldStart = foldLine ? foldLine.start.row : Infinity;
@@ -15395,52 +16117,69 @@ var Text = function(parentEl) {
var lineElement = lineElements[lineElementsIdx++];
if (lineElement) {
- var html = [];
+ this.dom.removeChildren(lineElement);
this.$renderLine(
- html, row, !this.$useLineGroups(), row == foldStart ? foldLine : false
+ lineElement, row, row == foldStart ? foldLine : false
);
- lineElement.style.height = config.lineHeight * this.session.getRowLength(row) + "px";
- lineElement.innerHTML = html.join("");
+ var height = (config.lineHeight * this.session.getRowLength(row)) + "px";
+ if (lineElement.style.height != height) {
+ heightChanged = true;
+ lineElement.style.height = height;
+ }
}
row++;
}
+ if (heightChanged) {
+ while (lineElementsIdx < this.$lines.cells.length) {
+ var cell = this.$lines.cells[lineElementsIdx++];
+ cell.element.style.top = this.$lines.computeLineTop(cell.row, config, this.session) + "px";
+ }
+ }
};
this.scrollLines = function(config) {
var oldConfig = this.config;
this.config = config;
+ if (this.$lines.pageChanged(oldConfig, config))
+ return this.update(config);
+
+ this.$lines.moveContainer(config);
+
+ var lastRow = config.lastRow;
+ var oldLastRow = oldConfig ? oldConfig.lastRow : -1;
+
+ if (!oldConfig || oldLastRow < config.firstRow)
+ return this.update(config);
+
+ if (lastRow < oldConfig.firstRow)
+ return this.update(config);
+
if (!oldConfig || oldConfig.lastRow < config.firstRow)
return this.update(config);
if (config.lastRow < oldConfig.firstRow)
return this.update(config);
- var el = this.element;
if (oldConfig.firstRow < config.firstRow)
for (var row=this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row>0; row--)
- el.removeChild(el.firstChild);
+ this.$lines.shift();
if (oldConfig.lastRow > config.lastRow)
for (var row=this.session.getFoldedRowCount(config.lastRow + 1, oldConfig.lastRow); row>0; row--)
- el.removeChild(el.lastChild);
+ this.$lines.pop();
if (config.firstRow < oldConfig.firstRow) {
- var fragment = this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1);
- if (el.firstChild)
- el.insertBefore(fragment, el.firstChild);
- else
- el.appendChild(fragment);
+ this.$lines.unshift(this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1));
}
if (config.lastRow > oldConfig.lastRow) {
- var fragment = this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow);
- el.appendChild(fragment);
+ this.$lines.push(this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow));
}
};
this.$renderLinesFragment = function(config, firstRow, lastRow) {
- var fragment = this.element.ownerDocument.createDocumentFragment();
+ var fragment = [];
var row = firstRow;
var foldLine = this.session.getNextFoldLine(row);
var foldStart = foldLine ? foldLine.start.row : Infinity;
@@ -15454,20 +16193,20 @@ var Text = function(parentEl) {
if (row > lastRow)
break;
- var container = dom.createElement("div");
+ var line = this.$lines.createCell(row, config, this.session);
+
+ var lineEl = line.element;
+ this.dom.removeChildren(lineEl);
+ dom.setStyle(lineEl.style, "height", this.$lines.computeLineHeight(row, config, this.session) + "px");
+ dom.setStyle(lineEl.style, "top", this.$lines.computeLineTop(row, config, this.session) + "px");
+ this.$renderLine(lineEl, row, row == foldStart ? foldLine : false);
- var html = [];
- this.$renderLine(html, row, false, row == foldStart ? foldLine : false);
- container.innerHTML = html.join("");
if (this.$useLineGroups()) {
- container.className = 'ace_line_group';
- fragment.appendChild(container);
- container.style.height = config.lineHeight * this.session.getRowLength(row) + "px";
-
+ lineEl.className = "ace_line_group";
} else {
- while(container.firstChild)
- fragment.appendChild(container.firstChild);
+ lineEl.className = "ace_line";
}
+ fragment.push(line);
row++;
}
@@ -15475,35 +16214,18 @@ var Text = function(parentEl) {
};
this.update = function(config) {
+ this.$lines.moveContainer(config);
+
this.config = config;
- var html = [];
- var firstRow = config.firstRow, lastRow = config.lastRow;
-
- var row = firstRow;
- var foldLine = this.session.getNextFoldLine(row);
- var foldStart = foldLine ? foldLine.start.row : Infinity;
-
- while (true) {
- if (row > foldStart) {
- row = foldLine.end.row+1;
- foldLine = this.session.getNextFoldLine(row, foldLine);
- foldStart = foldLine ? foldLine.start.row :Infinity;
- }
- if (row > lastRow)
- break;
-
- if (this.$useLineGroups())
- html.push("");
-
- this.$renderLine(html, row, false, row == foldStart ? foldLine : false);
-
- if (this.$useLineGroups())
- html.push("
"); // end the line group
+ var firstRow = config.firstRow;
+ var lastRow = config.lastRow;
- row++;
- }
- this.element.innerHTML = html.join("");
+ var lines = this.$lines;
+ while (lines.getLength())
+ lines.pop();
+
+ lines.push(this.$renderLinesFragment(config, firstRow, lastRow));
};
this.$textToken = {
@@ -15512,108 +16234,153 @@ var Text = function(parentEl) {
"lparen": true
};
- this.$renderToken = function(stringBuilder, screenColumn, token, value) {
+ this.$renderToken = function(parent, screenColumn, token, value) {
var self = this;
- var replaceReg = /\t|&|<|>|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF\uFFF9-\uFFFC])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
- var replaceFunc = function(c, a, b, tabIdx, idx4) {
- if (a) {
- return self.showInvisibles
- ? "" + lang.stringRepeat(self.SPACE_CHAR, c.length) + ""
- : c;
- } else if (c == "&") {
- return "&";
- } else if (c == "<") {
- return "<";
- } else if (c == ">") {
- return ">";
- } else if (c == "\t") {
- var tabSize = self.session.getScreenTabSize(screenColumn + tabIdx);
+ var re = /(\t)|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\uFEFF\uFFF9-\uFFFC]+)|(\u3000)|([\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3001-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]|[\uD800-\uDBFF][\uDC00-\uDFFF])/g;
+
+ var valueFragment = this.dom.createFragment(this.element);
+
+ var m;
+ var i = 0;
+ while (m = re.exec(value)) {
+ var tab = m[1];
+ var simpleSpace = m[2];
+ var controlCharacter = m[3];
+ var cjkSpace = m[4];
+ var cjk = m[5];
+
+ if (!self.showInvisibles && simpleSpace)
+ continue;
+
+ var before = i != m.index ? value.slice(i, m.index) : "";
+
+ i = m.index + m[0].length;
+
+ if (before) {
+ valueFragment.appendChild(this.dom.createTextNode(before, this.element));
+ }
+
+ if (tab) {
+ var tabSize = self.session.getScreenTabSize(screenColumn + m.index);
+ valueFragment.appendChild(self.$tabStrings[tabSize].cloneNode(true));
screenColumn += tabSize - 1;
- return self.$tabStrings[tabSize];
- } else if (c == "\u3000") {
- var classToUse = self.showInvisibles ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk";
+ } else if (simpleSpace) {
+ if (self.showInvisibles) {
+ var span = this.dom.createElement("span");
+ span.className = "ace_invisible ace_invisible_space";
+ span.textContent = lang.stringRepeat(self.SPACE_CHAR, simpleSpace.length);
+ valueFragment.appendChild(span);
+ } else {
+ valueFragment.appendChild(this.com.createTextNode(simpleSpace, this.element));
+ }
+ } else if (controlCharacter) {
+ var span = this.dom.createElement("span");
+ span.className = "ace_invisible ace_invisible_space ace_invalid";
+ span.textContent = lang.stringRepeat(self.SPACE_CHAR, controlCharacter.length);
+ valueFragment.appendChild(span);
+ } else if (cjkSpace) {
var space = self.showInvisibles ? self.SPACE_CHAR : "";
screenColumn += 1;
- return "" + space + "";
- } else if (b) {
- return "" + self.SPACE_CHAR + "";
- } else {
+
+ var span = this.dom.createElement("span");
+ span.style.width = (self.config.characterWidth * 2) + "px";
+ span.className = self.showInvisibles ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk";
+ span.textContent = self.showInvisibles ? self.SPACE_CHAR : "";
+ valueFragment.appendChild(span);
+ } else if (cjk) {
screenColumn += 1;
- return "" + c + "";
+ var span = dom.createElement("span");
+ span.style.width = (self.config.characterWidth * 2) + "px";
+ span.className = "ace_cjk";
+ span.textContent = cjk;
+ valueFragment.appendChild(span);
}
- };
-
- var output = value.replace(replaceReg, replaceFunc);
+ }
+
+ valueFragment.appendChild(this.dom.createTextNode(i ? value.slice(i) : value, this.element));
if (!this.$textToken[token.type]) {
var classes = "ace_" + token.type.replace(/\./g, " ace_");
- var style = "";
+ var span = this.dom.createElement("span");
if (token.type == "fold")
- style = " style='width:" + (token.value.length * this.config.characterWidth) + "px;' ";
- stringBuilder.push("", output, "");
+ span.style.width = (token.value.length * this.config.characterWidth) + "px";
+
+ span.className = classes;
+ span.appendChild(valueFragment);
+
+ parent.appendChild(span);
}
else {
- stringBuilder.push(output);
+ parent.appendChild(valueFragment);
}
+
return screenColumn + value.length;
};
- this.renderIndentGuide = function(stringBuilder, value, max) {
+ this.renderIndentGuide = function(parent, value, max) {
var cols = value.search(this.$indentGuideRe);
if (cols <= 0 || cols >= max)
return value;
if (value[0] == " ") {
cols -= cols % this.tabSize;
- stringBuilder.push(lang.stringRepeat(this.$tabStrings[" "], cols/this.tabSize));
+ var count = cols/this.tabSize;
+ for (var i=0; i= splitChars) {
screenColumn = this.$renderToken(
- stringBuilder, screenColumn,
+ lineEl, screenColumn,
token, value.substring(0, splitChars - chars)
);
value = value.substring(splitChars - chars);
chars = splitChars;
- if (!onlyContents) {
- stringBuilder.push(" ",
- "