Merge pull request #1391 from ajaxorg/cleanup

Cleanup
This commit is contained in:
Lennart Kats 2013-04-24 03:49:41 -07:00
commit 985566b38d
6 changed files with 87 additions and 28 deletions

View file

@ -20,8 +20,7 @@ var theme = require("../../lib/ace/theme/twilight");
var port = process.env.PORT || 2222; var port = process.env.PORT || 2222;
http.createServer(function(req, res) { http.createServer(function(req, res) {
res.writeHead(200, {"Content-Type": "text/html"}); res.writeHead(200, {"Content-Type": "text/html; charset=utf-8"});
fs.readFile(__filename, "utf8", function(err, data) { fs.readFile(__filename, "utf8", function(err, data) {
var highlighted = highlighter.render(data, new JavaScriptMode(), theme); var highlighted = highlighter.render(data, new JavaScriptMode(), theme);
res.end('<html><body>\n\ res.end('<html><body>\n\

View file

@ -967,6 +967,11 @@ oop.inherits(FoldMode, BaseFoldMode);
<div class="text-logo" style="margin-left:-17px;font-family:'Henny Penny',cursive;">ChocolateJs</div> <div class="text-logo" style="margin-left:-17px;font-family:'Henny Penny',cursive;">ChocolateJs</div>
<a href="https://chocolatejs.org">Chocolatejs</a> <a href="https://chocolatejs.org">Chocolatejs</a>
</li> </li>
<li>
<img src="http://multiplay.io/images/logo.png"
style="position: relative; left: 4px; width: 96px;top: -17px;">
<a href="http://multiPlay.io/">MultiPlay.io</a>
</li>
<li> <li>
<a href="https://github.com/Gozala/sky-edit">Sky Edit</a> <a href="https://github.com/Gozala/sky-edit">Sky Edit</a>
</li> </li>

View file

@ -344,8 +344,8 @@ var Editor = function(renderer, session) {
* Gets the current font size of the editor text. * Gets the current font size of the editor text.
*/ */
this.getFontSize = function () { this.getFontSize = function () {
return this.setOption("fontSize") || return this.getOption("fontSize") ||
dom.computedStyle(ace.container, "fontSize") dom.computedStyle(this.container, "fontSize");
}; };
/** /**

View file

@ -45,35 +45,39 @@ function assertLocation(e, sl, sc, el, ec) {
assert.equal(e.location.last_column, ec); assert.equal(e.location.last_column, ec);
} }
function parse(str) {
try {
coffee.parse(str).compile();
} catch (e) {
return e;
}
}
module.exports = { module.exports = {
"test parse valid coffee script": function() { "test parse valid coffee script": function() {
coffee.parse("square = (x) -> x * x"); coffee.parse("square = (x) -> x * x");
}, },
"test parse invalid coffee script": function() { "test parse invalid coffee script": function() {
try { var e = parse("a = 12 f");
coffee.parse("a = 12 f");
} catch (e) {
assert.equal(e.message, "Unexpected 'IDENTIFIER'"); assert.equal(e.message, "Unexpected 'IDENTIFIER'");
assertLocation(e, 0, 4, 0, 5); assertLocation(e, 0, 4, 0, 5);
}
}, },
"test parse missing bracket": function() { "test parse missing bracket": function() {
try { var e = parse("a = 12 f {\n\n");
coffee.parse("a = 12 f {\n\n");
} catch (e) {
assert.equal(e.message, "missing }"); assert.equal(e.message, "missing }");
assertLocation(e, 0, 10, 0, 10); assertLocation(e, 0, 10, 0, 10);
}
}, },
"test unexpected indent": function() { "test unexpected indent": function() {
try { var e = parse("a\n a\n");
coffee.parse("a\n a\n");
} catch (e) {
assert.equal(e.message, "Unexpected 'INDENT'"); assert.equal(e.message, "Unexpected 'INDENT'");
assertLocation(e, 0, 0, 0, 0); assertLocation(e, 0, 0, 0, 0);
} },
"test invalid destructuring": function() {
var e = parse("\n{b: 5} = {}");
assert.equal(e.message, '"5" cannot be assigned');
assertLocation(e, 1, 4, 1, 4);
} }
}; };

View file

@ -40,7 +40,7 @@ window.addEventListener = function() {};
var Worker = exports.Worker = function(sender) { var Worker = exports.Worker = function(sender) {
Mirror.call(this, sender); Mirror.call(this, sender);
this.setTimeout(200); this.setTimeout(250);
}; };
oop.inherits(Worker, Mirror); oop.inherits(Worker, Mirror);
@ -51,7 +51,7 @@ oop.inherits(Worker, Mirror);
var value = this.doc.getValue(); var value = this.doc.getValue();
try { try {
coffee.parse(value); coffee.parse(value).compile();
} catch(e) { } catch(e) {
var loc = e.location; var loc = e.location;
if (loc) { if (loc) {

View file

@ -10,9 +10,13 @@
<link href="../doc/site/images/favicon.ico" rel="icon" type="image/x-icon"> <link href="../doc/site/images/favicon.ico" rel="icon" type="image/x-icon">
</head> </head>
<body> <body>
<div id="optionsPanel" style="position:absolute;height:100%;width:260px">
<a href="http://ajaxorg.github.com/ace/" > <a href="http://ajaxorg.github.com/ace/" >
<img id="logo" src="demo/kitchen-sink/logo.png"> <img id="logo" src="demo/kitchen-sink/logo.png">
</a> </a>
<div style="position: absolute; overflow: hidden; top:80px; bottom:0">
<div style="width: 120%; height:100%; overflow-y: scroll">
<table id="controls"> <table id="controls">
<tr> <tr>
<td colspan="2"> <td colspan="2">
@ -78,8 +82,11 @@
<option value="ace/theme/solarized_light">Solarized Light</option> <option value="ace/theme/solarized_light">Solarized Light</option>
<option value="ace/theme/textmate" selected="selected">TextMate</option> <option value="ace/theme/textmate" selected="selected">TextMate</option>
<option value="ace/theme/tomorrow">Tomorrow</option> <option value="ace/theme/tomorrow">Tomorrow</option>
<option value="ace/theme/xcode">XCode</option>
</optgroup> </optgroup>
<optgroup label="Dark"> <optgroup label="Dark">
<option value="ace/theme/ambiance">Ambiance</option>
<option value="ace/theme/chaos">Chaos</option>
<option value="ace/theme/clouds_midnight">Clouds Midnight</option> <option value="ace/theme/clouds_midnight">Clouds Midnight</option>
<option value="ace/theme/cobalt">Cobalt</option> <option value="ace/theme/cobalt">Cobalt</option>
<option value="ace/theme/idle_fingers">idleFingers</option> <option value="ace/theme/idle_fingers">idleFingers</option>
@ -109,8 +116,10 @@
<option value="10px">10px</option> <option value="10px">10px</option>
<option value="11px">11px</option> <option value="11px">11px</option>
<option value="12px" selected="selected">12px</option> <option value="12px" selected="selected">12px</option>
<option value="13px">13px</option>
<option value="14px">14px</option> <option value="14px">14px</option>
<option value="16px">16px</option> <option value="16px">16px</option>
<option value="18px">18px</option>
<option value="20px">20px</option> <option value="20px">20px</option>
<option value="24px">24px</option> <option value="24px">24px</option>
</select> </select>
@ -238,14 +247,54 @@
<label for="fade_fold_widgets">Fade Fold Widgets</label> <label for="fade_fold_widgets">Fade Fold Widgets</label>
</td> </td>
<td> <td>
<input type="checkbox" id="fade_fold_widgets" checked> <input type="checkbox" id="fade_fold_widgets">
</td>
</tr>
<tr>
<td >
<label for="elastic_tabstops">Enable Elastic Tabstops</label>
</td>
<td>
<input type="checkbox" id="elastic_tabstops">
</td>
</tr>
<tr>
<td >
<label for="isearch">Incremental Search</label>
</td>
<td>
<input type="checkbox" id="isearch">
</td>
</tr>
<tr>
<td >
<label for="highlight_token">Show token info</label>
</td>
<td>
<input type="checkbox" id="highlight_token">
</td>
</tr>
<tr>
<td >
<label for="read_only">Read-only</label>
</td>
<td>
<input type="checkbox" id="read_only">
</td>
</tr>
<tr>
<td colspan="2">
<input type="button" value="Edit Snippets", onclick="env.editSnippets()">
</td> </td>
</tr> </tr>
</table> </table>
</td></tr> </td></tr>
</table> </table>
</div>
</div>
</div> </div>
<div id="editor"></div> <div id="editor-container"></div>
<!--DEVEL--> <!--DEVEL-->
<script type="text/javascript"> <script type="text/javascript">
@ -284,7 +333,9 @@
} }
function end(){ function end(){
shouldProfile && console.profileEnd() shouldProfile && console.profileEnd()
console.log(startTime - Date.now()) var dt = startTime - Date.now()
console.log(dt)
ace.cmdLine.setValue(dt+"", 1)
} }
/*editor.renderer.scrollToY(0); /*editor.renderer.scrollToY(0);