Commit b47aa350 authored by Denton Liu's avatar Denton Liu

Revert "Corrected whitespace issues"

This reverts commit 6273b618.
parent 6273b618
...@@ -15,10 +15,10 @@ loaded via http. If you clone/download the repository, use the ...@@ -15,10 +15,10 @@ loaded via http. If you clone/download the repository, use the
Many dependencies are only provided via npm: Many dependencies are only provided via npm:
npm install # fetch dependencies npm install # fetch dependencies
npm run build # build application into build/app.js npm run build # build application into build/app.js
Now point your browser to `index.html` to open the application. Now point your browser to `index.html` to open the application.
## Usage as a Chrome Extension ## Usage as a Chrome Extension
......
...@@ -71,7 +71,7 @@ code, pre { ...@@ -71,7 +71,7 @@ code, pre {
pre { pre {
padding:8px 15px; padding:8px 15px;
background: #f8f8f8; background: #f8f8f8;
border-radius:5px; border-radius:5px;
border:1px solid #e5e5e5; border:1px solid #e5e5e5;
overflow-x: auto; overflow-x: auto;
...@@ -110,9 +110,9 @@ header { ...@@ -110,9 +110,9 @@ header {
header ul { header ul {
list-style:none; list-style:none;
height:40px; height:40px;
padding:0; padding:0;
background: #eee; background: #eee;
background: -moz-linear-gradient(top, #f8f8f8 0%, #dddddd 100%); background: -moz-linear-gradient(top, #f8f8f8 0%, #dddddd 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#dddddd)); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#dddddd));
...@@ -120,7 +120,7 @@ header ul { ...@@ -120,7 +120,7 @@ header ul {
background: -o-linear-gradient(top, #f8f8f8 0%,#dddddd 100%); background: -o-linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
background: -ms-linear-gradient(top, #f8f8f8 0%,#dddddd 100%); background: -ms-linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
background: linear-gradient(top, #f8f8f8 0%,#dddddd 100%); background: linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
border-radius:5px; border-radius:5px;
border:1px solid #d2d2d2; border:1px solid #d2d2d2;
box-shadow:inset #fff 0 1px 0, inset rgba(0,0,0,0.03) 0 -1px 0; box-shadow:inset #fff 0 1px 0, inset rgba(0,0,0,0.03) 0 -1px 0;
...@@ -214,33 +214,33 @@ footer { ...@@ -214,33 +214,33 @@ footer {
} }
@media print, screen and (max-width: 960px) { @media print, screen and (max-width: 960px) {
div.wrapper { div.wrapper {
width:auto; width:auto;
margin:0; margin:0;
} }
header, section, footer { header, section, footer {
float:none; float:none;
position:static; position:static;
width:auto; width:auto;
} }
header { header {
padding-right:320px; padding-right:320px;
} }
section { section {
border:1px solid #e5e5e5; border:1px solid #e5e5e5;
border-width:1px 0; border-width:1px 0;
padding:20px 0; padding:20px 0;
margin:0 0 20px; margin:0 0 20px;
} }
header a small { header a small {
display:inline; display:inline;
} }
header ul { header ul {
position:absolute; position:absolute;
right:50px; right:50px;
...@@ -252,15 +252,15 @@ footer { ...@@ -252,15 +252,15 @@ footer {
body { body {
word-wrap:break-word; word-wrap:break-word;
} }
header { header {
padding:0; padding:0;
} }
header ul, header p.view { header ul, header p.view {
position:static; position:static;
} }
pre, code { pre, code {
word-wrap:normal; word-wrap:normal;
} }
...@@ -270,7 +270,7 @@ footer { ...@@ -270,7 +270,7 @@ footer {
body { body {
padding:15px; padding:15px;
} }
header ul { header ul {
display:none; display:none;
} }
......
chrome.browserAction.onClicked.addListener(function(tab) { chrome.browserAction.onClicked.addListener(function(tab) {
chrome.storage.sync.set({"chrome-app-sync": true}); chrome.storage.sync.set({"chrome-app-sync": true});
chrome.tabs.create({'url': chrome.extension.getURL('index.html')}, function(tab) { chrome.tabs.create({'url': chrome.extension.getURL('index.html')}, function(tab) {
// tab opened // tab opened
}); });
}); });
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
</head> </head>
<body> <body>
<div id="editor"> <div id="editor">
<span class="newFile" title="New File"><i class="fa fa-file-code-o"></i></span> <span class="newFile" title="New File"><i class="fa fa-file-code-o"></i></span>
...@@ -107,19 +107,20 @@ ...@@ -107,19 +107,20 @@
<label for="web3"> <label for="web3">
<input id="web3" type="radio" value="web3" name="executionContext"> <input id="web3" type="radio" value="web3" name="executionContext">
<strong>Web3 Provider</strong> <strong>Web3 Provider</strong>
<p>Execution environment connects to node at localhost (or via IPC if available), transactions will be sent to the network and can cause loss of money or worse!<br/> <p>Execution environment connects to node at localhost (or via IPC if available), transactions will be sent to the network and can cause loss of money or worse!<br/>
<b>If this page is served via https and you access your node via http, it might not work. In this case, try cloning the repository and serving it via http.</b></p> <b>If this page is served via https and you access your node via http, it might not work. In this case, try cloning the repository and serving it via http.</b></p>
<label for="web3Endpoint"> <label for="web3Endpoint">
<strong>Web3 Provider Endpoint</strong>: <input type="text" id="web3Endpoint" value="http://localhost:8545"> <strong>Web3 Provider Endpoint</strong>: <input type="text" id="web3Endpoint" value="http://localhost:8545">
</label> </label>
</label> </label>
</span> </span>
</div> </div>
</div> </div>
</div> </div>
<div id="output"></div> <div id="output"></div>
</div> </div>
<script src="build/app.js"></script> <script src="build/app.js"></script>
</body> </body>
</html> </html>
...@@ -181,7 +181,7 @@ var run = function() { ...@@ -181,7 +181,7 @@ var run = function() {
var untitledCount = ''; var untitledCount = '';
if (!getFiles().length || window.localStorage['sol-cache']) { if (!getFiles().length || window.localStorage['sol-cache']) {
if(loadingFromGist) return; if(loadingFromGist) return;
// Backwards-compatibility // Backwards-compatibility
while (window.localStorage[SOL_CACHE_UNTITLED + untitledCount]) while (window.localStorage[SOL_CACHE_UNTITLED + untitledCount])
untitledCount = (untitledCount - 0) + 1; untitledCount = (untitledCount - 0) + 1;
SOL_CACHE_FILE = SOL_CACHE_UNTITLED + untitledCount; SOL_CACHE_FILE = SOL_CACHE_UNTITLED + untitledCount;
...@@ -262,7 +262,7 @@ var run = function() { ...@@ -262,7 +262,7 @@ var run = function() {
// ------------------ gist publish -------------- // ------------------ gist publish --------------
var packageFiles = function() { var packageFiles = function() {
var files = {}; var files = {};
var filesArr = getFiles(); var filesArr = getFiles();
...@@ -272,7 +272,7 @@ var run = function() { ...@@ -272,7 +272,7 @@ var run = function() {
content: localStorage[filesArr[f]] content: localStorage[filesArr[f]]
}; };
} }
return files; return files;
}; };
$('#gist').click(function(){ $('#gist').click(function(){
...@@ -281,7 +281,7 @@ var run = function() { ...@@ -281,7 +281,7 @@ var run = function() {
var files = packageFiles(); var files = packageFiles();
var description = "Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. \n Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=" + getQueryParams().version + "&optimize="+ getQueryParams().optimize +"&gist="; var description = "Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. \n Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=" + getQueryParams().version + "&optimize="+ getQueryParams().optimize +"&gist=";
$.ajax({ $.ajax({
url: 'https://api.github.com/gists', url: 'https://api.github.com/gists',
type: 'POST', type: 'POST',
data: JSON.stringify({ data: JSON.stringify({
...@@ -397,7 +397,7 @@ var run = function() { ...@@ -397,7 +397,7 @@ var run = function() {
for (var f in files) { for (var f in files) {
$filesEl.append(fileTabTemplate(files[f])); $filesEl.append(fileTabTemplate(files[f]));
} }
if (SOL_CACHE_FILE) { if (SOL_CACHE_FILE) {
var active = fileTabFromKey(SOL_CACHE_FILE); var active = fileTabFromKey(SOL_CACHE_FILE);
active.addClass('active'); active.addClass('active');
...@@ -511,9 +511,9 @@ var run = function() { ...@@ -511,9 +511,9 @@ var run = function() {
updateQueryParams({version: $('#versionSelector').val() }); updateQueryParams({version: $('#versionSelector').val() });
loadVersion($('#versionSelector').val()); loadVersion($('#versionSelector').val());
}); });
// ----------------- resizeable ui --------------- // ----------------- resizeable ui ---------------
var EDITOR_SIZE_CACHE_KEY = "editor-size-cache"; var EDITOR_SIZE_CACHE_KEY = "editor-size-cache";
var dragging = false; var dragging = false;
$('#dragbar').mousedown(function(e){ $('#dragbar').mousedown(function(e){
...@@ -566,13 +566,13 @@ var run = function() { ...@@ -566,13 +566,13 @@ var run = function() {
var hidingRHP = false; var hidingRHP = false;
$('.toggleRHP').click(function(){ $('.toggleRHP').click(function(){
hidingRHP = !hidingRHP; hidingRHP = !hidingRHP;
setEditorSize( hidingRHP ? 0 : window.localStorage[EDITOR_SIZE_CACHE_KEY] ); setEditorSize( hidingRHP ? 0 : window.localStorage[EDITOR_SIZE_CACHE_KEY] );
$('.toggleRHP i').toggleClass('fa-angle-double-right', !hidingRHP); $('.toggleRHP i').toggleClass('fa-angle-double-right', !hidingRHP);
$('.toggleRHP i').toggleClass('fa-angle-double-left', hidingRHP); $('.toggleRHP i').toggleClass('fa-angle-double-left', hidingRHP);
if (!hidingRHP) compile(); if (!hidingRHP) compile();
}); });
// ----------------- editor resize --------------- // ----------------- editor resize ---------------
...@@ -595,7 +595,7 @@ var run = function() { ...@@ -595,7 +595,7 @@ var run = function() {
document.querySelector('#editor').addEventListener('change', onResize); document.querySelector('#editor').addEventListener('change', onResize);
document.querySelector('#editorWrap').addEventListener('change', onResize); document.querySelector('#editorWrap').addEventListener('change', onResize);
// ----------------- compiler ---------------------- // ----------------- compiler ----------------------
var compileJSON; var compileJSON;
...@@ -637,13 +637,13 @@ var run = function() { ...@@ -637,13 +637,13 @@ var run = function() {
if (errortype(err) !== 'warning') noFatalErrors = false; if (errortype(err) !== 'warning') noFatalErrors = false;
}); });
} }
if (missingInputs !== undefined && missingInputs.length > 0) if (missingInputs !== undefined && missingInputs.length > 0)
compile(missingInputs); compile(missingInputs);
else if (noFatalErrors && !hidingRHP) else if (noFatalErrors && !hidingRHP)
renderContracts(data, editor.getValue()); renderContracts(data, editor.getValue());
}; };
var compileTimeout = null; var compileTimeout = null;
var onChange = function() { var onChange = function() {
var input = editor.getValue(); var input = editor.getValue();
...@@ -860,18 +860,18 @@ var run = function() { ...@@ -860,18 +860,18 @@ var run = function() {
code += "var " + contractName + "Contract = web3.eth.contract(" + interface.replace("\n","") + ");" code += "var " + contractName + "Contract = web3.eth.contract(" + interface.replace("\n","") + ");"
+"\nvar " + contractName + " = " + contractName + "Contract.new("; +"\nvar " + contractName + " = " + contractName + "Contract.new(";
$.each(funABI.inputs, function(i, inp) { $.each(funABI.inputs, function(i, inp) {
code += "\n " + inp.name + ","; code += "\n " + inp.name + ",";
}); });
code += "\n {"+ code += "\n {"+
"\n from: web3.eth.accounts[0], "+ "\n from: web3.eth.accounts[0], "+
"\n data: '"+bytecode+"', "+ "\n data: '"+bytecode+"', "+
"\n gas: 3000000"+ "\n gas: 3000000"+
"\n }, function(e, contract){"+ "\n }, function(e, contract){"+
"\n console.log(e, contract);"+ "\n console.log(e, contract);"+
"\n if (typeof contract.address != 'undefined') {"+ "\n if (typeof contract.address != 'undefined') {"+
"\n console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);" + "\n console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);" +
"\n }" + "\n }" +
"\n })"; "\n })";
...@@ -1010,7 +1010,7 @@ var run = function() { ...@@ -1010,7 +1010,7 @@ var run = function() {
return text; return text;
}; };
$('.asmOutput button').click(function() {$(this).parent().find('pre').toggle(); }); $('.asmOutput button').click(function() {$(this).parent().find('pre').toggle(); });
var getConstructorInterface = function(abi) { var getConstructorInterface = function(abi) {
......
...@@ -7,42 +7,42 @@ var oop = acequire("../lib/oop"); ...@@ -7,42 +7,42 @@ var oop = acequire("../lib/oop");
var TextHighlightRules = acequire("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = acequire("./text_highlight_rules").TextHighlightRules;
var DocCommentHighlightRules = function() { var DocCommentHighlightRules = function() {
this.$rules = { this.$rules = {
"start" : [ { "start" : [ {
token : "comment.doc.tag", token : "comment.doc.tag",
regex : "@[\\w\\d_]+" // TODO: fix email addresses regex : "@[\\w\\d_]+" // TODO: fix email addresses
}, },
DocCommentHighlightRules.getTagRule(), DocCommentHighlightRules.getTagRule(),
{ {
defaultToken : "comment.doc", defaultToken : "comment.doc",
caseInsensitive: true caseInsensitive: true
}] }]
}; };
}; };
oop.inherits(DocCommentHighlightRules, TextHighlightRules); oop.inherits(DocCommentHighlightRules, TextHighlightRules);
DocCommentHighlightRules.getTagRule = function(start) { DocCommentHighlightRules.getTagRule = function(start) {
return { return {
token : "comment.doc.tag.storage.type", token : "comment.doc.tag.storage.type",
regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b" regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b"
}; };
} }
DocCommentHighlightRules.getStartRule = function(start) { DocCommentHighlightRules.getStartRule = function(start) {
return { return {
token : "comment.doc", // doc comment token : "comment.doc", // doc comment
regex : "\\/\\*(?=\\*)", regex : "\\/\\*(?=\\*)",
next : start next : start
}; };
}; };
DocCommentHighlightRules.getEndRule = function (start) { DocCommentHighlightRules.getEndRule = function (start) {
return { return {
token : "comment.doc", // closing comment token : "comment.doc", // closing comment
regex : "\\*\\/", regex : "\\*\\/",
next : start next : start
}; };
}; };
...@@ -58,332 +58,332 @@ var DocCommentHighlightRules = acequire("./doc_comment_highlight_rules").DocComm ...@@ -58,332 +58,332 @@ var DocCommentHighlightRules = acequire("./doc_comment_highlight_rules").DocComm
var TextHighlightRules = acequire("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = acequire("./text_highlight_rules").TextHighlightRules;
var JavaScriptHighlightRules = function(options) { var JavaScriptHighlightRules = function(options) {
var intTypes = 'bytes|int|uint'; var intTypes = 'bytes|int|uint';
for (var width = 8; width <= 256; width += 8) for (var width = 8; width <= 256; width += 8)
intTypes += '|bytes' + (width / 8) + '|uint' + width + '|int' + width; intTypes += '|bytes' + (width / 8) + '|uint' + width + '|int' + width;
var keywordMapper = this.createKeywordMapper({ var keywordMapper = this.createKeywordMapper({
"variable.language": "variable.language":
"this|bool|string|byte|bytes|bytes0|address|" + intTypes, "this|bool|string|byte|bytes|bytes0|address|" + intTypes,
"keyword": "keyword":
"contract|library|constant|event|modifier|" + "contract|library|constant|event|modifier|" +
"struct|mapping|enum|break|continue|delete|else|for|function|" + "struct|mapping|enum|break|continue|delete|else|for|function|" +
"if|new|return|returns|var|while|using|" + "if|new|return|returns|var|while|using|" +
"private|public|external|internal|storage|memory", "private|public|external|internal|storage|memory",
"storage.type": "storage.type":
"constant|var|function", "constant|var|function",
"constant.language.boolean": "true|false" "constant.language.boolean": "true|false"
}, "identifier"); }, "identifier");
var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void"; var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b"; var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b";
var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
"u[0-9a-fA-F]{4}|" + // unicode "u[0-9a-fA-F]{4}|" + // unicode
"[0-2][0-7]{0,2}|" + // oct "[0-2][0-7]{0,2}|" + // oct
"3[0-6][0-7]?|" + // oct "3[0-6][0-7]?|" + // oct
"37[0-7]?|" + // oct "37[0-7]?|" + // oct
"[4-7][0-7]?|" + //oct "[4-7][0-7]?|" + //oct
".)"; ".)";
this.$rules = { this.$rules = {
"no_regex" : [ "no_regex" : [
{ {
token : "comment", token : "comment",
regex : "\\/\\/", regex : "\\/\\/",
next : "line_comment" next : "line_comment"
}, },
DocCommentHighlightRules.getStartRule("doc-start"), DocCommentHighlightRules.getStartRule("doc-start"),
{ {
token : "comment", // multi line comment token : "comment", // multi line comment
regex : /\/\*/, regex : /\/\*/,
next : "comment" next : "comment"
}, { }, {
token : "string", token : "string",
regex : "'(?=.)", regex : "'(?=.)",
next : "qstring" next : "qstring"
}, { }, {
token : "string", token : "string",
regex : '"(?=.)', regex : '"(?=.)',
next : "qqstring" next : "qqstring"
}, { }, {
token : "constant.numeric", // hex token : "constant.numeric", // hex
regex : /0[xX][0-9a-fA-F]+\b/ regex : /0[xX][0-9a-fA-F]+\b/
}, { }, {
token : "constant.numeric", // float token : "constant.numeric", // float
regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/ regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
}, { }, {
token : [ token : [
"storage.type", "punctuation.operator", "support.function", "storage.type", "punctuation.operator", "support.function",
"punctuation.operator", "entity.name.function", "text","keyword.operator" "punctuation.operator", "entity.name.function", "text","keyword.operator"
], ],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)", regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)",
next: "function_arguments" next: "function_arguments"
}, { }, {
token : [ token : [
"storage.type", "punctuation.operator", "entity.name.function", "text", "storage.type", "punctuation.operator", "entity.name.function", "text",
"keyword.operator", "text", "storage.type", "text", "paren.lparen" "keyword.operator", "text", "storage.type", "text", "paren.lparen"
], ],
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
next: "function_arguments" next: "function_arguments"
}, { }, {
token : [ token : [
"entity.name.function", "text", "keyword.operator", "text", "storage.type", "entity.name.function", "text", "keyword.operator", "text", "storage.type",
"text", "paren.lparen" "text", "paren.lparen"
], ],
regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
next: "function_arguments" next: "function_arguments"
}, { }, {
token : [ token : [
"storage.type", "punctuation.operator", "entity.name.function", "text", "storage.type", "punctuation.operator", "entity.name.function", "text",
"keyword.operator", "text", "keyword.operator", "text",
"storage.type", "text", "entity.name.function", "text", "paren.lparen" "storage.type", "text", "entity.name.function", "text", "paren.lparen"
], ],
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()", regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",
next: "function_arguments" next: "function_arguments"
}, { }, {
token : [ token : [
"storage.type", "text", "entity.name.function", "text", "paren.lparen" "storage.type", "text", "entity.name.function", "text", "paren.lparen"
], ],
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()", regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
next: "function_arguments" next: "function_arguments"
}, { }, {
token : [ token : [
"entity.name.function", "text", "punctuation.operator", "entity.name.function", "text", "punctuation.operator",
"text", "storage.type", "text", "paren.lparen" "text", "storage.type", "text", "paren.lparen"
], ],
regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()", regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",
next: "function_arguments" next: "function_arguments"
}, { }, {
token : [ token : [
"text", "text", "storage.type", "text", "paren.lparen" "text", "text", "storage.type", "text", "paren.lparen"
], ],
regex : "(:)(\\s*)(function)(\\s*)(\\()", regex : "(:)(\\s*)(function)(\\s*)(\\()",
next: "function_arguments" next: "function_arguments"
}, { }, {
token : "keyword", token : "keyword",
regex : "(?:" + kwBeforeRe + ")\\b", regex : "(?:" + kwBeforeRe + ")\\b",
next : "start" next : "start"
}, { }, {
token : ["punctuation.operator", "support.function"], token : ["punctuation.operator", "support.function"],
regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/ regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
}, { }, {
token : ["punctuation.operator", "support.function.dom"], token : ["punctuation.operator", "support.function.dom"],
regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/ regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
}, { }, {
token : ["punctuation.operator", "support.constant"], token : ["punctuation.operator", "support.constant"],
regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/ regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
}, { }, {
token : ["support.constant"], token : ["support.constant"],
regex : /that\b/ regex : /that\b/
}, { }, {
token : ["storage.type", "punctuation.operator", "support.function.firebug"], token : ["storage.type", "punctuation.operator", "support.function.firebug"],
regex : /(console)(\.)(warn|info|log|error|time|trace|timeEnd|assert)\b/ regex : /(console)(\.)(warn|info|log|error|time|trace|timeEnd|assert)\b/
}, { }, {
token : keywordMapper, token : keywordMapper,
regex : identifierRe regex : identifierRe
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : /--|\*\*|\+\+|===|==|=|!=|!==|=>|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|[!$%&*+\-~\/^]=?/, regex : /--|\*\*|\+\+|===|==|=|!=|!==|=>|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|[!$%&*+\-~\/^]=?/,
next : "start" next : "start"
}, { }, {
token : "punctuation.operator", token : "punctuation.operator",
regex : /[?:,;.]/, regex : /[?:,;.]/,
next : "start" next : "start"
}, { }, {
token : "paren.lparen", token : "paren.lparen",
regex : /[\[({]/, regex : /[\[({]/,
next : "start" next : "start"
}, { }, {
token : "paren.rparen", token : "paren.rparen",
regex : /[\])}]/ regex : /[\])}]/
}, { }, {
token: "comment", token: "comment",
regex: /^#!.*$/ regex: /^#!.*$/
} }
], ],
"start": [ "start": [
DocCommentHighlightRules.getStartRule("doc-start"), DocCommentHighlightRules.getStartRule("doc-start"),
{ {
token : "comment", // multi line comment token : "comment", // multi line comment
regex : "\\/\\*", regex : "\\/\\*",
next : "comment_regex_allowed" next : "comment_regex_allowed"
}, { }, {
token : "comment", token : "comment",
regex : "\\/\\/", regex : "\\/\\/",
next : "line_comment_regex_allowed" next : "line_comment_regex_allowed"
}, { }, {
token: "string.regexp", token: "string.regexp",
regex: "\\/", regex: "\\/",
next: "regex" next: "regex"
}, { }, {
token : "text", token : "text",
regex : "\\s+|^$", regex : "\\s+|^$",
next : "start" next : "start"
}, { }, {
token: "empty", token: "empty",
regex: "", regex: "",
next: "no_regex" next: "no_regex"
} }
], ],
"regex": [ "regex": [
{ {
token: "regexp.keyword.operator", token: "regexp.keyword.operator",
regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
}, { }, {
token: "string.regexp", token: "string.regexp",
regex: "/[sxngimy]*", regex: "/[sxngimy]*",
next: "no_regex" next: "no_regex"
}, { }, {
token : "invalid", token : "invalid",
regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/ regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
}, { }, {
token : "constant.language.escape", token : "constant.language.escape",
regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/ regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/
}, { }, {
token : "constant.language.delimiter", token : "constant.language.delimiter",
regex: /\|/ regex: /\|/
}, { }, {
token: "constant.language.escape", token: "constant.language.escape",
regex: /\[\^?/, regex: /\[\^?/,
next: "regex_character_class" next: "regex_character_class"
}, { }, {
token: "empty", token: "empty",
regex: "$", regex: "$",
next: "no_regex" next: "no_regex"
}, { }, {
defaultToken: "string.regexp" defaultToken: "string.regexp"
} }
], ],
"regex_character_class": [ "regex_character_class": [
{ {
token: "regexp.charclass.keyword.operator", token: "regexp.charclass.keyword.operator",
regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
}, { }, {
token: "constant.language.escape", token: "constant.language.escape",
regex: "]", regex: "]",
next: "regex" next: "regex"
}, { }, {
token: "constant.language.escape", token: "constant.language.escape",
regex: "-" regex: "-"
}, { }, {
token: "empty", token: "empty",
regex: "$", regex: "$",
next: "no_regex" next: "no_regex"
}, { }, {
defaultToken: "string.regexp.charachterclass" defaultToken: "string.regexp.charachterclass"
} }
], ],
"function_arguments": [ "function_arguments": [
{ {
token: "variable.parameter", token: "variable.parameter",
regex: identifierRe regex: identifierRe
}, { }, {
token: "punctuation.operator", token: "punctuation.operator",
regex: "[, ]+" regex: "[, ]+"
}, { }, {
token: "punctuation.operator", token: "punctuation.operator",
regex: "$" regex: "$"
}, { }, {
token: "empty", token: "empty",
regex: "", regex: "",
next: "no_regex" next: "no_regex"
} }
], ],
"comment_regex_allowed" : [ "comment_regex_allowed" : [
DocCommentHighlightRules.getTagRule(), DocCommentHighlightRules.getTagRule(),
{token : "comment", regex : "\\*\\/", next : "start"}, {token : "comment", regex : "\\*\\/", next : "start"},
{defaultToken : "comment", caseInsensitive: true} {defaultToken : "comment", caseInsensitive: true}
], ],
"comment" : [ "comment" : [
DocCommentHighlightRules.getTagRule(), DocCommentHighlightRules.getTagRule(),
{token : "comment", regex : "\\*\\/", next : "no_regex"}, {token : "comment", regex : "\\*\\/", next : "no_regex"},
{defaultToken : "comment", caseInsensitive: true} {defaultToken : "comment", caseInsensitive: true}
], ],
"line_comment_regex_allowed" : [ "line_comment_regex_allowed" : [
DocCommentHighlightRules.getTagRule(), DocCommentHighlightRules.getTagRule(),
{token : "comment", regex : "$|^", next : "start"}, {token : "comment", regex : "$|^", next : "start"},
{defaultToken : "comment", caseInsensitive: true} {defaultToken : "comment", caseInsensitive: true}
], ],
"line_comment" : [ "line_comment" : [
DocCommentHighlightRules.getTagRule(), DocCommentHighlightRules.getTagRule(),
{token : "comment", regex : "$|^", next : "no_regex"}, {token : "comment", regex : "$|^", next : "no_regex"},
{defaultToken : "comment", caseInsensitive: true} {defaultToken : "comment", caseInsensitive: true}
], ],
"qqstring" : [ "qqstring" : [
{ {
token : "constant.language.escape", token : "constant.language.escape",
regex : escapedRe regex : escapedRe
}, { }, {
token : "string", token : "string",
regex : "\\\\$", regex : "\\\\$",
next : "qqstring" next : "qqstring"
}, { }, {
token : "string", token : "string",
regex : '"|$', regex : '"|$',
next : "no_regex" next : "no_regex"
}, { }, {
defaultToken: "string" defaultToken: "string"
} }
], ],
"qstring" : [ "qstring" : [
{ {
token : "constant.language.escape", token : "constant.language.escape",
regex : escapedRe regex : escapedRe
}, { }, {
token : "string", token : "string",
regex : "\\\\$", regex : "\\\\$",
next : "qstring" next : "qstring"
}, { }, {
token : "string", token : "string",
regex : "'|$", regex : "'|$",
next : "no_regex" next : "no_regex"
}, { }, {
defaultToken: "string" defaultToken: "string"
} }
] ]
}; };
if (!options || !options.noES6) { if (!options || !options.noES6) {
this.$rules.no_regex.unshift({ this.$rules.no_regex.unshift({
regex: "[{}]", onMatch: function(val, state, stack) { regex: "[{}]", onMatch: function(val, state, stack) {
this.next = val == "{" ? this.nextState : ""; this.next = val == "{" ? this.nextState : "";
if (val == "{" && stack.length) { if (val == "{" && stack.length) {
stack.unshift("start", state); stack.unshift("start", state);
return "paren"; return "paren";
} }
if (val == "}" && stack.length) { if (val == "}" && stack.length) {
stack.shift(); stack.shift();
this.next = stack.shift(); this.next = stack.shift();
if (this.next.indexOf("string") != -1) if (this.next.indexOf("string") != -1)
return "paren.quasi.end"; return "paren.quasi.end";
} }
return val == "{" ? "paren.lparen" : "paren.rparen"; return val == "{" ? "paren.lparen" : "paren.rparen";
}, },
nextState: "start" nextState: "start"
}, { }, {
token : "string.quasi.start", token : "string.quasi.start",
regex : /`/, regex : /`/,
push : [{ push : [{
token : "constant.language.escape", token : "constant.language.escape",
regex : escapedRe regex : escapedRe
}, { }, {
token : "paren.quasi.start", token : "paren.quasi.start",
regex : /\${/, regex : /\${/,
push : "start" push : "start"
}, { }, {
token : "string.quasi.end", token : "string.quasi.end",
regex : /`/, regex : /`/,
next : "pop" next : "pop"
}, { }, {
defaultToken: "string.quasi" defaultToken: "string.quasi"
}] }]
}); });
} }
this.embedRules(DocCommentHighlightRules, "doc-", this.embedRules(DocCommentHighlightRules, "doc-",
[ DocCommentHighlightRules.getEndRule("no_regex") ]); [ DocCommentHighlightRules.getEndRule("no_regex") ]);
this.normalizeRules(); this.normalizeRules();
}; };
oop.inherits(JavaScriptHighlightRules, TextHighlightRules); oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
...@@ -400,31 +400,31 @@ var MatchingBraceOutdent = function() {}; ...@@ -400,31 +400,31 @@ var MatchingBraceOutdent = function() {};
(function() { (function() {
this.checkOutdent = function(line, input) { this.checkOutdent = function(line, input) {
if (! /^\s+$/.test(line)) if (! /^\s+$/.test(line))
return false; return false;
return /^\s*\}/.test(input); return /^\s*\}/.test(input);
}; };
this.autoOutdent = function(doc, row) { this.autoOutdent = function(doc, row) {
var line = doc.getLine(row); var line = doc.getLine(row);
var match = line.match(/^(\s*\})/); var match = line.match(/^(\s*\})/);
if (!match) return 0; if (!match) return 0;
var column = match[1].length; var column = match[1].length;
var openBracePos = doc.findMatchingBracket({row: row, column: column}); var openBracePos = doc.findMatchingBracket({row: row, column: column});
if (!openBracePos || openBracePos.row == row) return 0; if (!openBracePos || openBracePos.row == row) return 0;
var indent = this.$getIndent(doc.getLine(openBracePos.row)); var indent = this.$getIndent(doc.getLine(openBracePos.row));
doc.replace(new Range(row, 0, row, column-1), indent); doc.replace(new Range(row, 0, row, column-1), indent);
}; };
this.$getIndent = function(line) { this.$getIndent = function(line) {
return line.match(/^\s*/)[0]; return line.match(/^\s*/)[0];
}; };
}).call(MatchingBraceOutdent.prototype); }).call(MatchingBraceOutdent.prototype);
...@@ -440,346 +440,346 @@ var TokenIterator = acequire("../../token_iterator").TokenIterator; ...@@ -440,346 +440,346 @@ var TokenIterator = acequire("../../token_iterator").TokenIterator;
var lang = acequire("../../lib/lang"); var lang = acequire("../../lib/lang");
var SAFE_INSERT_IN_TOKENS = var SAFE_INSERT_IN_TOKENS =
["text", "paren.rparen", "punctuation.operator"]; ["text", "paren.rparen", "punctuation.operator"];
var SAFE_INSERT_BEFORE_TOKENS = var SAFE_INSERT_BEFORE_TOKENS =
["text", "paren.rparen", "punctuation.operator", "comment"]; ["text", "paren.rparen", "punctuation.operator", "comment"];
var context; var context;
var contextCache = {}; var contextCache = {};
var initContext = function(editor) { var initContext = function(editor) {
var id = -1; var id = -1;
if (editor.multiSelect) { if (editor.multiSelect) {
id = editor.selection.index; id = editor.selection.index;
if (contextCache.rangeCount != editor.multiSelect.rangeCount) if (contextCache.rangeCount != editor.multiSelect.rangeCount)
contextCache = {rangeCount: editor.multiSelect.rangeCount}; contextCache = {rangeCount: editor.multiSelect.rangeCount};
} }
if (contextCache[id]) if (contextCache[id])
return context = contextCache[id]; return context = contextCache[id];
context = contextCache[id] = { context = contextCache[id] = {
autoInsertedBrackets: 0, autoInsertedBrackets: 0,
autoInsertedRow: -1, autoInsertedRow: -1,
autoInsertedLineEnd: "", autoInsertedLineEnd: "",
maybeInsertedBrackets: 0, maybeInsertedBrackets: 0,
maybeInsertedRow: -1, maybeInsertedRow: -1,
maybeInsertedLineStart: "", maybeInsertedLineStart: "",
maybeInsertedLineEnd: "" maybeInsertedLineEnd: ""
}; };
}; };
var CstyleBehaviour = function() { var CstyleBehaviour = function() {
this.add("braces", "insertion", function(state, action, editor, session, text) { this.add("braces", "insertion", function(state, action, editor, session, text) {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
if (text == '{') { if (text == '{') {
initContext(editor); initContext(editor);
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) { if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
}; };
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) { } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) { if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
CstyleBehaviour.recordAutoInsert(editor, session, "}"); CstyleBehaviour.recordAutoInsert(editor, session, "}");
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
}; };
} else { } else {
CstyleBehaviour.recordMaybeInsert(editor, session, "{"); CstyleBehaviour.recordMaybeInsert(editor, session, "{");
return { return {
text: '{', text: '{',
selection: [1, 1] selection: [1, 1]
}; };
} }
} }
} else if (text == '}') { } else if (text == '}') {
initContext(editor); initContext(editor);
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '}') { if (rightChar == '}') {
var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row}); var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) { if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
CstyleBehaviour.popAutoInsertedClosing(); CstyleBehaviour.popAutoInsertedClosing();
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
}; };
} }
} }
} else if (text == "\n" || text == "\r\n") { } else if (text == "\n" || text == "\r\n") {
initContext(editor); initContext(editor);
var closing = ""; var closing = "";
if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) { if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
closing = lang.stringRepeat("}", context.maybeInsertedBrackets); closing = lang.stringRepeat("}", context.maybeInsertedBrackets);
CstyleBehaviour.clearMaybeInsertedClosing(); CstyleBehaviour.clearMaybeInsertedClosing();
} }
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar === '}') { if (rightChar === '}') {
var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column+1}, '}'); var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column+1}, '}');
if (!openBracePos) if (!openBracePos)
return null; return null;
var next_indent = this.$getIndent(session.getLine(openBracePos.row)); var next_indent = this.$getIndent(session.getLine(openBracePos.row));
} else if (closing) { } else if (closing) {
var next_indent = this.$getIndent(line); var next_indent = this.$getIndent(line);
} else { } else {
CstyleBehaviour.clearMaybeInsertedClosing(); CstyleBehaviour.clearMaybeInsertedClosing();
return; return;
} }
var indent = next_indent + session.getTabString(); var indent = next_indent + session.getTabString();
return { return {
text: '\n' + indent + '\n' + next_indent + closing, text: '\n' + indent + '\n' + next_indent + closing,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
}; };
} else { } else {
CstyleBehaviour.clearMaybeInsertedClosing(); CstyleBehaviour.clearMaybeInsertedClosing();
} }
}); });
this.add("braces", "deletion", function(state, action, editor, session, range) { this.add("braces", "deletion", function(state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '{') { if (!range.isMultiLine() && selected == '{') {
initContext(editor); initContext(editor);
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.end.column, range.end.column + 1); var rightChar = line.substring(range.end.column, range.end.column + 1);
if (rightChar == '}') { if (rightChar == '}') {
range.end.column++; range.end.column++;
return range; return range;
} else { } else {
context.maybeInsertedBrackets--; context.maybeInsertedBrackets--;
} }
} }
}); });
this.add("parens", "insertion", function(state, action, editor, session, text) { this.add("parens", "insertion", function(state, action, editor, session, text) {
if (text == '(') { if (text == '(') {
initContext(editor); initContext(editor);
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "" && editor.getWrapBehavioursEnabled()) { if (selected !== "" && editor.getWrapBehavioursEnabled()) {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
}; };
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) { } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
CstyleBehaviour.recordAutoInsert(editor, session, ")"); CstyleBehaviour.recordAutoInsert(editor, session, ")");
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
}; };
} }
} else if (text == ')') { } else if (text == ')') {
initContext(editor); initContext(editor);
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == ')') { if (rightChar == ')') {
var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row}); var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) { if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
CstyleBehaviour.popAutoInsertedClosing(); CstyleBehaviour.popAutoInsertedClosing();
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
}; };
} }
} }
} }
}); });
this.add("parens", "deletion", function(state, action, editor, session, range) { this.add("parens", "deletion", function(state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '(') { if (!range.isMultiLine() && selected == '(') {
initContext(editor); initContext(editor);
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == ')') { if (rightChar == ')') {
range.end.column++; range.end.column++;
return range; return range;
} }
} }
}); });
this.add("brackets", "insertion", function(state, action, editor, session, text) { this.add("brackets", "insertion", function(state, action, editor, session, text) {
if (text == '[') { if (text == '[') {
initContext(editor); initContext(editor);
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "" && editor.getWrapBehavioursEnabled()) { if (selected !== "" && editor.getWrapBehavioursEnabled()) {
return { return {
text: '[' + selected + ']', text: '[' + selected + ']',
selection: false selection: false
}; };
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) { } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
CstyleBehaviour.recordAutoInsert(editor, session, "]"); CstyleBehaviour.recordAutoInsert(editor, session, "]");
return { return {
text: '[]', text: '[]',
selection: [1, 1] selection: [1, 1]
}; };
} }
} else if (text == ']') { } else if (text == ']') {
initContext(editor); initContext(editor);
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == ']') { if (rightChar == ']') {
var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row}); var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) { if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
CstyleBehaviour.popAutoInsertedClosing(); CstyleBehaviour.popAutoInsertedClosing();
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
}; };
} }
} }
} }
}); });
this.add("brackets", "deletion", function(state, action, editor, session, range) { this.add("brackets", "deletion", function(state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '[') { if (!range.isMultiLine() && selected == '[') {
initContext(editor); initContext(editor);
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == ']') { if (rightChar == ']') {
range.end.column++; range.end.column++;
return range; return range;
} }
} }
}); });
this.add("string_dquotes", "insertion", function(state, action, editor, session, text) { this.add("string_dquotes", "insertion", function(state, action, editor, session, text) {
if (text == '"' || text == "'") { if (text == '"' || text == "'") {
initContext(editor); initContext(editor);
var quote = text; var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) { if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
return { return {
text: quote + selected + quote, text: quote + selected + quote,
selection: false selection: false
}; };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
var leftChar = line.substring(cursor.column-1, cursor.column); var leftChar = line.substring(cursor.column-1, cursor.column);
if (leftChar == '\\') { if (leftChar == '\\') {
return null; return null;
} }
var tokens = session.getTokens(selection.start.row); var tokens = session.getTokens(selection.start.row);
var col = 0, token; var col = 0, token;
var quotepos = -1; // Track whether we're inside an open quote. var quotepos = -1; // Track whether we're inside an open quote.
for (var x = 0; x < tokens.length; x++) { for (var x = 0; x < tokens.length; x++) {
token = tokens[x]; token = tokens[x];
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf(quote); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
} }
col += tokens[x].value.length; col += tokens[x].value.length;
} }
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
if (!CstyleBehaviour.isSaneInsertion(editor, session)) if (!CstyleBehaviour.isSaneInsertion(editor, session))
return; return;
return { return {
text: quote + quote, text: quote + quote,
selection: [1,1] selection: [1,1]
}; };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == quote) { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
}; };
} }
} }
} }
} }
}); });
this.add("string_dquotes", "deletion", function(state, action, editor, session, range) { this.add("string_dquotes", "deletion", function(state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && (selected == '"' || selected == "'")) { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
initContext(editor); initContext(editor);
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == selected) { if (rightChar == selected) {
range.end.column++; range.end.column++;
return range; return range;
} }
} }
}); });
}; };
CstyleBehaviour.isSaneInsertion = function(editor, session) { CstyleBehaviour.isSaneInsertion = function(editor, session) {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var iterator = new TokenIterator(session, cursor.row, cursor.column); var iterator = new TokenIterator(session, cursor.row, cursor.column);
if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) { if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1); var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
return false; return false;
} }
iterator.stepForward(); iterator.stepForward();
return iterator.getCurrentTokenRow() !== cursor.row || return iterator.getCurrentTokenRow() !== cursor.row ||
this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS); this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
}; };
CstyleBehaviour.$matchTokenType = function(token, types) { CstyleBehaviour.$matchTokenType = function(token, types) {
return types.indexOf(token.type || token) > -1; return types.indexOf(token.type || token) > -1;
}; };
CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) { CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
if (!this.isAutoInsertedClosing(cursor, line, context.autoInsertedLineEnd[0])) if (!this.isAutoInsertedClosing(cursor, line, context.autoInsertedLineEnd[0]))
context.autoInsertedBrackets = 0; context.autoInsertedBrackets = 0;
context.autoInsertedRow = cursor.row; context.autoInsertedRow = cursor.row;
context.autoInsertedLineEnd = bracket + line.substr(cursor.column); context.autoInsertedLineEnd = bracket + line.substr(cursor.column);
context.autoInsertedBrackets++; context.autoInsertedBrackets++;
}; };
CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) { CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
if (!this.isMaybeInsertedClosing(cursor, line)) if (!this.isMaybeInsertedClosing(cursor, line))
context.maybeInsertedBrackets = 0; context.maybeInsertedBrackets = 0;
context.maybeInsertedRow = cursor.row; context.maybeInsertedRow = cursor.row;
context.maybeInsertedLineStart = line.substr(0, cursor.column) + bracket; context.maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
context.maybeInsertedLineEnd = line.substr(cursor.column); context.maybeInsertedLineEnd = line.substr(cursor.column);
context.maybeInsertedBrackets++; context.maybeInsertedBrackets++;
}; };
CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) { CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
return context.autoInsertedBrackets > 0 && return context.autoInsertedBrackets > 0 &&
cursor.row === context.autoInsertedRow && cursor.row === context.autoInsertedRow &&
bracket === context.autoInsertedLineEnd[0] && bracket === context.autoInsertedLineEnd[0] &&
line.substr(cursor.column) === context.autoInsertedLineEnd; line.substr(cursor.column) === context.autoInsertedLineEnd;
}; };
CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) { CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
return context.maybeInsertedBrackets > 0 && return context.maybeInsertedBrackets > 0 &&
cursor.row === context.maybeInsertedRow && cursor.row === context.maybeInsertedRow &&
line.substr(cursor.column) === context.maybeInsertedLineEnd && line.substr(cursor.column) === context.maybeInsertedLineEnd &&
line.substr(0, cursor.column) == context.maybeInsertedLineStart; line.substr(0, cursor.column) == context.maybeInsertedLineStart;
}; };
CstyleBehaviour.popAutoInsertedClosing = function() { CstyleBehaviour.popAutoInsertedClosing = function() {
context.autoInsertedLineEnd = context.autoInsertedLineEnd.substr(1); context.autoInsertedLineEnd = context.autoInsertedLineEnd.substr(1);
context.autoInsertedBrackets--; context.autoInsertedBrackets--;
}; };
CstyleBehaviour.clearMaybeInsertedClosing = function() { CstyleBehaviour.clearMaybeInsertedClosing = function() {
if (context) { if (context) {
context.maybeInsertedBrackets = 0; context.maybeInsertedBrackets = 0;
context.maybeInsertedRow = -1; context.maybeInsertedRow = -1;
} }
}; };
...@@ -797,88 +797,88 @@ var Range = acequire("../../range").Range; ...@@ -797,88 +797,88 @@ var Range = acequire("../../range").Range;
var BaseFoldMode = acequire("./fold_mode").FoldMode; var BaseFoldMode = acequire("./fold_mode").FoldMode;
var FoldMode = exports.FoldMode = function(commentRegex) { var FoldMode = exports.FoldMode = function(commentRegex) {
if (commentRegex) { if (commentRegex) {
this.foldingStartMarker = new RegExp( this.foldingStartMarker = new RegExp(
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start) this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
); );
this.foldingStopMarker = new RegExp( this.foldingStopMarker = new RegExp(
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end) this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
); );
} }
}; };
oop.inherits(FoldMode, BaseFoldMode); oop.inherits(FoldMode, BaseFoldMode);
(function() { (function() {
this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) { this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
var line = session.getLine(row); var line = session.getLine(row);
var match = line.match(this.foldingStartMarker); var match = line.match(this.foldingStartMarker);
if (match) { if (match) {
var i = match.index; var i = match.index;
if (match[1]) if (match[1])
return this.openingBracketBlock(session, match[1], row, i); return this.openingBracketBlock(session, match[1], row, i);
var range = session.getCommentFoldRange(row, i + match[0].length, 1); var range = session.getCommentFoldRange(row, i + match[0].length, 1);
if (range && !range.isMultiLine()) { if (range && !range.isMultiLine()) {
if (forceMultiline) { if (forceMultiline) {
range = this.getSectionRange(session, row); range = this.getSectionRange(session, row);
} else if (foldStyle != "all") } else if (foldStyle != "all")
range = null; range = null;
} }
return range; return range;
} }
if (foldStyle === "markbegin") if (foldStyle === "markbegin")
return; return;
var match = line.match(this.foldingStopMarker); var match = line.match(this.foldingStopMarker);
if (match) { if (match) {
var i = match.index + match[0].length; var i = match.index + match[0].length;
if (match[1]) if (match[1])
return this.closingBracketBlock(session, match[1], row, i); return this.closingBracketBlock(session, match[1], row, i);
return session.getCommentFoldRange(row, i, -1); return session.getCommentFoldRange(row, i, -1);
} }
}; };
this.getSectionRange = function(session, row) { this.getSectionRange = function(session, row) {
var line = session.getLine(row); var line = session.getLine(row);
var startIndent = line.search(/\S/); var startIndent = line.search(/\S/);
var startRow = row; var startRow = row;
var startColumn = line.length; var startColumn = line.length;
row = row + 1; row = row + 1;
var endRow = row; var endRow = row;
var maxRow = session.getLength(); var maxRow = session.getLength();
while (++row < maxRow) { while (++row < maxRow) {
line = session.getLine(row); line = session.getLine(row);
var indent = line.search(/\S/); var indent = line.search(/\S/);
if (indent === -1) if (indent === -1)
continue; continue;
if (startIndent > indent) if (startIndent > indent)
break; break;
var subRange = this.getFoldWidgetRange(session, "all", row); var subRange = this.getFoldWidgetRange(session, "all", row);
if (subRange) { if (subRange) {
if (subRange.start.row <= startRow) { if (subRange.start.row <= startRow) {
break; break;
} else if (subRange.isMultiLine()) { } else if (subRange.isMultiLine()) {
row = subRange.end.row; row = subRange.end.row;
} else if (startIndent == indent) { } else if (startIndent == indent) {
break; break;
} }
} }
endRow = row; endRow = row;
} }
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length); return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
}; };
}).call(FoldMode.prototype); }).call(FoldMode.prototype);
...@@ -897,75 +897,75 @@ var CstyleBehaviour = acequire("./behaviour/cstyle").CstyleBehaviour; ...@@ -897,75 +897,75 @@ var CstyleBehaviour = acequire("./behaviour/cstyle").CstyleBehaviour;
var CStyleFoldMode = acequire("./folding/cstyle").FoldMode; var CStyleFoldMode = acequire("./folding/cstyle").FoldMode;
var Mode = function() { var Mode = function() {
this.HighlightRules = JavaScriptHighlightRules; this.HighlightRules = JavaScriptHighlightRules;
this.$outdent = new MatchingBraceOutdent(); this.$outdent = new MatchingBraceOutdent();
this.$behaviour = new CstyleBehaviour(); this.$behaviour = new CstyleBehaviour();
this.foldingRules = new CStyleFoldMode(); this.foldingRules = new CStyleFoldMode();
}; };
oop.inherits(Mode, TextMode); oop.inherits(Mode, TextMode);
(function() { (function() {
this.lineCommentStart = "//"; this.lineCommentStart = "//";
this.blockComment = {start: "/*", end: "*/"}; this.blockComment = {start: "/*", end: "*/"};
this.getNextLineIndent = function(state, line, tab) { this.getNextLineIndent = function(state, line, tab) {
var indent = this.$getIndent(line); var indent = this.$getIndent(line);
var tokenizedLine = this.getTokenizer().getLineTokens(line, state); var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
var tokens = tokenizedLine.tokens; var tokens = tokenizedLine.tokens;
var endState = tokenizedLine.state; var endState = tokenizedLine.state;
if (tokens.length && tokens[tokens.length-1].type == "comment") { if (tokens.length && tokens[tokens.length-1].type == "comment") {
return indent; return indent;
} }
if (state == "start" || state == "no_regex") { if (state == "start" || state == "no_regex") {
var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/); var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
if (match) { if (match) {
indent += tab; indent += tab;
} }
} else if (state == "doc-start") { } else if (state == "doc-start") {
if (endState == "start" || endState == "no_regex") { if (endState == "start" || endState == "no_regex") {
return ""; return "";
} }
var match = line.match(/^\s*(\/?)\*/); var match = line.match(/^\s*(\/?)\*/);
if (match) { if (match) {
if (match[1]) { if (match[1]) {
indent += " "; indent += " ";
} }
indent += "* "; indent += "* ";
} }
} }
return indent; return indent;
}; };
this.checkOutdent = function(state, line, input) { this.checkOutdent = function(state, line, input) {
return this.$outdent.checkOutdent(line, input); return this.$outdent.checkOutdent(line, input);
}; };
this.autoOutdent = function(state, doc, row) { this.autoOutdent = function(state, doc, row) {
this.$outdent.autoOutdent(doc, row); this.$outdent.autoOutdent(doc, row);
}; };
// this.createWorker = function(session) { // this.createWorker = function(session) {
// var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker"); // var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
// worker.attachToDocument(session.getDocument()); // worker.attachToDocument(session.getDocument());
// //
// worker.on("jslint", function(results) { // worker.on("jslint", function(results) {
// session.setAnnotations(results.data); // session.setAnnotations(results.data);
// }); // });
// //
// worker.on("terminate", function() { // worker.on("terminate", function() {
// session.clearAnnotations(); // session.clearAnnotations();
// }); // });
// //
// return worker; // return worker;
// }; // };
this.$id = "ace/mode/javascript"; this.$id = "ace/mode/javascript";
}).call(Mode.prototype); }).call(Mode.prototype);
exports.Mode = Mode; exports.Mode = Mode;
......
...@@ -150,7 +150,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar ...@@ -150,7 +150,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
var $createInterface = $('<div class="createContract"/>'); var $createInterface = $('<div class="createContract"/>');
var appendFunctions = function (address, $el){ var appendFunctions = function (address, $el){
var $instance = $('<div class="instance"/>'); var $instance = $('<div class="instance"/>');
if (self.options.removable_instances) { if (self.options.removable_instances) {
var $close = $('<div class="udapp-close" />') var $close = $('<div class="udapp-close" />')
...@@ -185,8 +185,8 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar ...@@ -185,8 +185,8 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
$.each(abi, function(i, funABI) { $.each(abi, function(i, funABI) {
if (funABI.type !== 'event') return; if (funABI.type !== 'event') return;
var hash = ethJSABI.eventID(funABI.name, funABI.inputs.map(function(item) { return item.type })) var hash = ethJSABI.eventID(funABI.name, funABI.inputs.map(function(item) { return item.type }))
eventABI[hash.toString('hex')] = { event: funABI.name, inputs: funABI.inputs }; eventABI[hash.toString('hex')] = { event: funABI.name, inputs: funABI.inputs };
}); });
self.vm.on('afterTx', function(response){ self.vm.on('afterTx', function(response){
...@@ -254,7 +254,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar ...@@ -254,7 +254,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
} else { } else {
appendFunctions( address, $target ); appendFunctions( address, $target );
} }
return $createInterface; return $createInterface;
} }
...@@ -330,7 +330,7 @@ UniversalDApp.prototype.getCallButton = function(args) { ...@@ -330,7 +330,7 @@ UniversalDApp.prototype.getCallButton = function(args) {
var handleCallButtonClick = function(ev, $result) { var handleCallButtonClick = function(ev, $result) {
if (!$result) { if (!$result) {
$result = getOutput(); $result = getOutput();
if (lookupOnly && !inputs.length) if (lookupOnly && !inputs.length)
$outputOverride.empty().append( $result ); $outputOverride.empty().append( $result );
else else
...@@ -423,7 +423,7 @@ UniversalDApp.prototype.getCallButton = function(args) { ...@@ -423,7 +423,7 @@ UniversalDApp.prototype.getCallButton = function(args) {
} else if (args.abi.constant && !isConstructor) { } else if (args.abi.constant && !isConstructor) {
replaceOutput($result, getReturnOutput(result)); replaceOutput($result, getReturnOutput(result));
} else { } else {
function tryTillResponse (txhash, done) { function tryTillResponse (txhash, done) {
web3.eth.getTransactionReceipt(result, testResult ); web3.eth.getTransactionReceipt(result, testResult );
...@@ -444,7 +444,7 @@ UniversalDApp.prototype.getCallButton = function(args) { ...@@ -444,7 +444,7 @@ UniversalDApp.prototype.getCallButton = function(args) {
$result.append(getReturnOutput(result)).append(getGasUsedOutput(result)); $result.append(getReturnOutput(result)).append(getGasUsedOutput(result));
} }
}) })
} }
}); });
} }
...@@ -517,7 +517,7 @@ UniversalDApp.prototype.clickNewContract = function ( self, $contract, contract ...@@ -517,7 +517,7 @@ UniversalDApp.prototype.clickNewContract = function ( self, $contract, contract
} }
UniversalDApp.prototype.clickContractAt = function ( self, $output, contract ) { UniversalDApp.prototype.clickContractAt = function ( self, $output, contract ) {
var address = prompt( "What Address is this contract at in the Blockchain? ie: '0xdeadbeaf...'" ) var address = prompt( "What Address is this contract at in the Blockchain? ie: '0xdeadbeaf...'" )
self.getInstanceInterface(contract, address, $output ); self.getInstanceInterface(contract, address, $output );
} }
...@@ -539,7 +539,7 @@ UniversalDApp.prototype.runTx = function( data, args, cb) { ...@@ -539,7 +539,7 @@ UniversalDApp.prototype.runTx = function( data, args, cb) {
return cb(e); return cb(e);
} }
} }
if (!this.vm) { if (!this.vm) {
var tx = { var tx = {
from: self.options.getAddress ? self.options.getAddress() : web3.eth.accounts[0], from: self.options.getAddress ? self.options.getAddress() : web3.eth.accounts[0],
...@@ -585,4 +585,4 @@ UniversalDApp.prototype.runTx = function( data, args, cb) { ...@@ -585,4 +585,4 @@ UniversalDApp.prototype.runTx = function( data, args, cb) {
} }
} }
module.exports = UniversalDApp; module.exports = UniversalDApp;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment