Merge remote branch 'tomtasche/master'

This commit is contained in:
Fabian Jakobs 2011-02-03 09:45:19 +01:00
commit bd5b68d767
5 changed files with 189 additions and 1 deletions

1
.c9settings.xml Normal file
View file

@ -0,0 +1 @@
<settings version="0.0.2" ><auto><configurations /><panel>{"ext/editors/editors":{"parent":{"visible":2,"flex":1},"visible":2,"flex":1},"ext/tree/tree":{"parent":{"visible":2,"width":"200"},"visible":true,"flex":3,"state":"normal"},"ext/console/console":{"parent":{"visible":2,"height":"41"},"visible":false,"flex":1}}</panel><tree>["folder[1]"]</tree><files active="/tomtasche/ace/workspace/gitignore"><file path="/tomtasche/ace/workspace/gitignore" type="file" size="11" name="gitignore" contenttype="text/plain; charset=utf-8" creationdate="" lockable="false" hidden="false" executable="false" scriptname="/home/ide_tomtasche/workspaces/ace/gitignore"/></files></auto><general name="General" page="pgSettingsGeneral" saveallbeforerun="true"/><editors name="Editor" page="pgSettingsEditors"><code name="Code Editor" overwrite="false" selectstyle="line" activeline="true" showinvisibles="false" showprintmargin="true" printmargincolumn="80" softtabs="true" tabsize="4" scrollspeed="2"/></editors></settings>

View file

@ -52,6 +52,7 @@ exports.launch = function(env) {
var XmlMode = require("ace/mode/xml").Mode;
var PythonMode = require("ace/mode/python").Mode;
var PhpMode = require("ace/mode/php").Mode;
var JavaMode = require("ace/mode/java").Mode;
var TextMode = require("ace/mode/text").Mode;
var UndoManager = require("ace/undomanager").UndoManager;
@ -101,6 +102,10 @@ exports.launch = function(env) {
docs.php = new EditSession(document.getElementById("phptext").innerHTML);
docs.php.setMode(new PhpMode());
docs.php.setUndoManager(new UndoManager());
docs.java = new EditSession(document.getElementById("javatext").innerHTML);
docs.java.setMode(new JavaMode());
docs.java.setUndoManager(new UndoManager());
var container = document.getElementById("editor");
@ -113,7 +118,8 @@ exports.launch = function(env) {
css: new CssMode(),
javascript: new JavaScriptMode(),
python: new PythonMode(),
php: new PhpMode()
php: new PhpMode(),
java: new JavaMode()
};
function getMode() {
@ -146,6 +152,9 @@ exports.launch = function(env) {
else if (mode instanceof PhpMode) {
modeEl.value = "php";
}
else if (mode instanceof JavaMode) {
modeEl.value = "java";
}
else {
modeEl.value = "text";
}
@ -271,6 +280,8 @@ exports.launch = function(env) {
mode = "python";
} else if (/^.*\.php$/i.test(file.name)) {
mode = "php";
} else if (/^.*\.java$/i.test(file.name)) {
mode = "java";
}
env.editor.onTextInput(reader.result);

View file

@ -19,6 +19,7 @@
<option value="css">CSS Document</option>
<option value="python">Python Document</option>
<option value="php">PHP Document</option>
<option value="java">Java Document</option>
<option value="plain">Text Document</option>
</select>
</td>
@ -72,6 +73,7 @@
<option value="css">CSS</option>
<option value="python">Python</option>
<option value="php">PHP</option>
<option value="java">Java</option>
</select>
</td>
<td align="right">
@ -136,6 +138,22 @@
</body>
</html></script>
<script type="text/editor" id="javatext">public class InfiniteLoop {
/*
* This will cause the program to hang...
*
* Taken from:
* http://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308/
*/
public static void main(String[] args) {
double d = Double.parseDouble("2.2250738585072012e-308");
// unreachable code
System.out.println("Value: " + d);
}
}</script>
<script type="text/editor" id="pythontext">#!/usr/local/bin/python
import string, sys

24
lib/ace/mode/java.js Normal file
View file

@ -0,0 +1,24 @@
define(function(require, exports, module) {
var oop = require("pilot/oop");
var JavaScriptMode = require("ace/mode/javascript").Mode;
var Tokenizer = require("ace/tokenizer").Tokenizer;
var JavaHighlightRules = require("ace/mode/java_highlight_rules").JavaHighlightRules;
var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent;
var Mode = function() {
this.$tokenizer = new Tokenizer(new JavaHighlightRules().getRules());
this.$outdent = new MatchingBraceOutdent();
};
oop.inherits(Mode, JavaScriptMode);
(function() {
this.createWorker = function(session) {
return null;
};
}).call(Mode.prototype);
exports.Mode = Mode;
});

View file

@ -0,0 +1,134 @@
define(function(require, exports, module) {
var oop = require("pilot/oop");
var lang = require("pilot/lang");
var DocCommentHighlightRules = require("ace/mode/doc_comment_highlight_rules").DocCommentHighlightRules;
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
JavaHighlightRules = function() {
var docComment = new DocCommentHighlightRules();
// taken from http://download.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html
var keywords = lang.arrayToMap(
("abstract|continue|for|new|switch|" +
"assert|default|goto|package|synchronized" +
"boolean|do|if|private|this" +
"break|double|implements|protected|throw" +
"byte|else|import|public|throws" +
"case|enum|instanceof|return|transient" +
"catch|extends|int|short|try" +
"char|final|interface|static|void" +
"class|finally|long|strictfp|volatile|" +
"const|float|native|super|while").split("|")
);
var buildinConstants = lang.arrayToMap(
("null|Infinity|NaN|undefined").split("|")
);
// regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used
this.$rules = {
"start" : [
{
token : "comment",
regex : "\\/\\/.*$"
},
docComment.getStartRule("doc-start"),
{
token : "comment", // multi line comment
regex : "\\/\\*",
next : "comment"
}, {
token : "comment", // multi line comment
regex : "\\/\\*\\*",
next : "comment"
}, {
token : "string.regexp",
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
}, {
token : "string", // single line
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, {
token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, {
token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : "constant.language.boolean",
regex : "(?:true|false)\\b"
}, {
token : function(value) {
if (value == "this")
return "variable.language";
else if (keywords[value])
return "keyword";
else if (buildinConstants[value])
return "constant.language";
else
return "identifier";
},
// TODO: Unicode escape sequences
// TODO: Unicode identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
}, {
token : "lparen",
regex : "[[({]"
}, {
token : "rparen",
regex : "[\\])}]"
}, {
token : "text",
regex : "\\s+"
}
],
"comment" : [
{
token : "comment", // closing comment
regex : ".*?\\*\\/",
next : "start"
}, {
token : "comment", // comment spanning whole line
regex : ".+"
}
],
"qqstring" : [
{
token : "string",
regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
next : "start"
}, {
token : "string",
regex : '.+'
}
],
"qstring" : [
{
token : "string",
regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
next : "start"
}, {
token : "string",
regex : '.+'
}
]
};
this.addRules(docComment.getRules(), "doc-");
this.$rules["doc-start"][0].next = "start";
};
oop.inherits(JavaHighlightRules, TextHighlightRules);
exports.JavaHighlightRules = JavaHighlightRules;
});