mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-21 02:29:23 +00:00
feature(edit) ace v1.1.5
This commit is contained in:
parent
bd823896aa
commit
d5cc93a815
294 changed files with 44517 additions and 45748 deletions
|
|
@ -1,166 +1,5 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2010, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
ace.define('ace/mode/lua', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/mode/lua_highlight_rules', 'ace/mode/folding/lua', 'ace/range', 'ace/worker/worker_client'], function(require, exports, module) {
|
||||
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var LuaHighlightRules = require("./lua_highlight_rules").LuaHighlightRules;
|
||||
var LuaFoldMode = require("./folding/lua").FoldMode;
|
||||
var Range = require("../range").Range;
|
||||
var WorkerClient = require("../worker/worker_client").WorkerClient;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = LuaHighlightRules;
|
||||
|
||||
this.foldingRules = new LuaFoldMode();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.lineCommentStart = "--";
|
||||
this.blockComment = {start: "--[", end: "]--"};
|
||||
|
||||
var indentKeywords = {
|
||||
"function": 1,
|
||||
"then": 1,
|
||||
"do": 1,
|
||||
"else": 1,
|
||||
"elseif": 1,
|
||||
"repeat": 1,
|
||||
"end": -1,
|
||||
"until": -1
|
||||
};
|
||||
var outdentKeywords = [
|
||||
"else",
|
||||
"elseif",
|
||||
"end",
|
||||
"until"
|
||||
];
|
||||
|
||||
function getNetIndentLevel(tokens) {
|
||||
var level = 0;
|
||||
for (var i = 0; i < tokens.length; i++) {
|
||||
var token = tokens[i];
|
||||
if (token.type == "keyword") {
|
||||
if (token.value in indentKeywords) {
|
||||
level += indentKeywords[token.value];
|
||||
}
|
||||
} else if (token.type == "paren.lparen") {
|
||||
level ++;
|
||||
} else if (token.type == "paren.rparen") {
|
||||
level --;
|
||||
}
|
||||
}
|
||||
if (level < 0) {
|
||||
return -1;
|
||||
} else if (level > 0) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
var indent = this.$getIndent(line);
|
||||
var level = 0;
|
||||
|
||||
var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
|
||||
var tokens = tokenizedLine.tokens;
|
||||
|
||||
if (state == "start") {
|
||||
level = getNetIndentLevel(tokens);
|
||||
}
|
||||
if (level > 0) {
|
||||
return indent + tab;
|
||||
} else if (level < 0 && indent.substr(indent.length - tab.length) == tab) {
|
||||
if (!this.checkOutdent(state, line, "\n")) {
|
||||
return indent.substr(0, indent.length - tab.length);
|
||||
}
|
||||
}
|
||||
return indent;
|
||||
};
|
||||
|
||||
this.checkOutdent = function(state, line, input) {
|
||||
if (input != "\n" && input != "\r" && input != "\r\n")
|
||||
return false;
|
||||
|
||||
if (line.match(/^\s*[\)\}\]]$/))
|
||||
return true;
|
||||
|
||||
var tokens = this.getTokenizer().getLineTokens(line.trim(), state).tokens;
|
||||
|
||||
if (!tokens || !tokens.length)
|
||||
return false;
|
||||
|
||||
return (tokens[0].type == "keyword" && outdentKeywords.indexOf(tokens[0].value) != -1);
|
||||
};
|
||||
|
||||
this.autoOutdent = function(state, session, row) {
|
||||
var prevLine = session.getLine(row - 1);
|
||||
var prevIndent = this.$getIndent(prevLine).length;
|
||||
var prevTokens = this.getTokenizer().getLineTokens(prevLine, "start").tokens;
|
||||
var tabLength = session.getTabString().length;
|
||||
var expectedIndent = prevIndent + tabLength * getNetIndentLevel(prevTokens);
|
||||
var curIndent = this.$getIndent(session.getLine(row)).length;
|
||||
if (curIndent < expectedIndent) {
|
||||
return;
|
||||
}
|
||||
session.outdentRows(new Range(row, 0, row + 2, 0));
|
||||
};
|
||||
|
||||
this.createWorker = function(session) {
|
||||
var worker = new WorkerClient(["ace"], "ace/mode/lua_worker", "Worker");
|
||||
worker.attachToDocument(session.getDocument());
|
||||
|
||||
worker.on("error", function(e) {
|
||||
session.setAnnotations([e.data]);
|
||||
});
|
||||
|
||||
worker.on("ok", function(e) {
|
||||
session.clearAnnotations();
|
||||
});
|
||||
|
||||
return worker;
|
||||
};
|
||||
|
||||
this.$id = "ace/mode/lua";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
});
|
||||
|
||||
ace.define('ace/mode/lua_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
|
||||
|
||||
ace.define("ace/mode/lua_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
|
@ -321,8 +160,8 @@ oop.inherits(LuaHighlightRules, TextHighlightRules);
|
|||
exports.LuaHighlightRules = LuaHighlightRules;
|
||||
});
|
||||
|
||||
ace.define('ace/mode/folding/lua', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode', 'ace/range', 'ace/token_iterator'], function(require, exports, module) {
|
||||
|
||||
ace.define("ace/mode/folding/lua",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range","ace/token_iterator"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../../lib/oop");
|
||||
var BaseFoldMode = require("./fold_mode").FoldMode;
|
||||
|
|
@ -454,3 +293,134 @@ oop.inherits(FoldMode, BaseFoldMode);
|
|||
}).call(FoldMode.prototype);
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/mode/lua",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/lua_highlight_rules","ace/mode/folding/lua","ace/range","ace/worker/worker_client"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var LuaHighlightRules = require("./lua_highlight_rules").LuaHighlightRules;
|
||||
var LuaFoldMode = require("./folding/lua").FoldMode;
|
||||
var Range = require("../range").Range;
|
||||
var WorkerClient = require("../worker/worker_client").WorkerClient;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = LuaHighlightRules;
|
||||
|
||||
this.foldingRules = new LuaFoldMode();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.lineCommentStart = "--";
|
||||
this.blockComment = {start: "--[", end: "]--"};
|
||||
|
||||
var indentKeywords = {
|
||||
"function": 1,
|
||||
"then": 1,
|
||||
"do": 1,
|
||||
"else": 1,
|
||||
"elseif": 1,
|
||||
"repeat": 1,
|
||||
"end": -1,
|
||||
"until": -1
|
||||
};
|
||||
var outdentKeywords = [
|
||||
"else",
|
||||
"elseif",
|
||||
"end",
|
||||
"until"
|
||||
];
|
||||
|
||||
function getNetIndentLevel(tokens) {
|
||||
var level = 0;
|
||||
for (var i = 0; i < tokens.length; i++) {
|
||||
var token = tokens[i];
|
||||
if (token.type == "keyword") {
|
||||
if (token.value in indentKeywords) {
|
||||
level += indentKeywords[token.value];
|
||||
}
|
||||
} else if (token.type == "paren.lparen") {
|
||||
level ++;
|
||||
} else if (token.type == "paren.rparen") {
|
||||
level --;
|
||||
}
|
||||
}
|
||||
if (level < 0) {
|
||||
return -1;
|
||||
} else if (level > 0) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
var indent = this.$getIndent(line);
|
||||
var level = 0;
|
||||
|
||||
var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
|
||||
var tokens = tokenizedLine.tokens;
|
||||
|
||||
if (state == "start") {
|
||||
level = getNetIndentLevel(tokens);
|
||||
}
|
||||
if (level > 0) {
|
||||
return indent + tab;
|
||||
} else if (level < 0 && indent.substr(indent.length - tab.length) == tab) {
|
||||
if (!this.checkOutdent(state, line, "\n")) {
|
||||
return indent.substr(0, indent.length - tab.length);
|
||||
}
|
||||
}
|
||||
return indent;
|
||||
};
|
||||
|
||||
this.checkOutdent = function(state, line, input) {
|
||||
if (input != "\n" && input != "\r" && input != "\r\n")
|
||||
return false;
|
||||
|
||||
if (line.match(/^\s*[\)\}\]]$/))
|
||||
return true;
|
||||
|
||||
var tokens = this.getTokenizer().getLineTokens(line.trim(), state).tokens;
|
||||
|
||||
if (!tokens || !tokens.length)
|
||||
return false;
|
||||
|
||||
return (tokens[0].type == "keyword" && outdentKeywords.indexOf(tokens[0].value) != -1);
|
||||
};
|
||||
|
||||
this.autoOutdent = function(state, session, row) {
|
||||
var prevLine = session.getLine(row - 1);
|
||||
var prevIndent = this.$getIndent(prevLine).length;
|
||||
var prevTokens = this.getTokenizer().getLineTokens(prevLine, "start").tokens;
|
||||
var tabLength = session.getTabString().length;
|
||||
var expectedIndent = prevIndent + tabLength * getNetIndentLevel(prevTokens);
|
||||
var curIndent = this.$getIndent(session.getLine(row)).length;
|
||||
if (curIndent < expectedIndent) {
|
||||
return;
|
||||
}
|
||||
session.outdentRows(new Range(row, 0, row + 2, 0));
|
||||
};
|
||||
|
||||
this.createWorker = function(session) {
|
||||
var worker = new WorkerClient(["ace"], "ace/mode/lua_worker", "Worker");
|
||||
worker.attachToDocument(session.getDocument());
|
||||
|
||||
worker.on("error", function(e) {
|
||||
session.setAnnotations([e.data]);
|
||||
});
|
||||
|
||||
worker.on("ok", function(e) {
|
||||
session.clearAnnotations();
|
||||
});
|
||||
|
||||
return worker;
|
||||
};
|
||||
|
||||
this.$id = "ace/mode/lua";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue