convert python mode to exports style and add it to the demo

This commit is contained in:
Fabian Jakobs 2010-12-10 17:11:43 +01:00
commit a4fcd3fd89
5 changed files with 41 additions and 13 deletions

View file

@ -50,6 +50,7 @@ exports.launch = function(env) {
var CssMode = require("ace/mode/css").Css; var CssMode = require("ace/mode/css").Css;
var HtmlMode = require("ace/mode/html").Html; var HtmlMode = require("ace/mode/html").Html;
var XmlMode = require("ace/mode/xml").Xml; var XmlMode = require("ace/mode/xml").Xml;
var PythonMode = require("ace/mode/python").Python;
var TextMode = require("ace/mode/text").Text; var TextMode = require("ace/mode/text").Text;
var UndoManager = require("ace/undomanager").UndoManager; var UndoManager = require("ace/undomanager").UndoManager;
@ -67,6 +68,10 @@ exports.launch = function(env) {
docs.html.setMode(new HtmlMode()); docs.html.setMode(new HtmlMode());
docs.html.setUndoManager(new UndoManager()); docs.html.setUndoManager(new UndoManager());
docs.python = new Document(document.getElementById("pythontext").innerHTML);
docs.python.setMode(new PythonMode());
docs.python.setUndoManager(new UndoManager());
var docEl = document.getElementById("doc"); var docEl = document.getElementById("doc");
var container = document.getElementById("editor"); var container = document.getElementById("editor");
@ -89,6 +94,9 @@ exports.launch = function(env) {
else if (mode instanceof XmlMode) { else if (mode instanceof XmlMode) {
modeEl.value = "xml"; modeEl.value = "xml";
} }
else if (mode instanceof PythonMode) {
modeEl.value = "python";
}
else { else {
modeEl.value = "text"; modeEl.value = "text";
} }
@ -111,7 +119,8 @@ exports.launch = function(env) {
xml: new XmlMode(), xml: new XmlMode(),
html: new HtmlMode(), html: new HtmlMode(),
css: new CssMode(), css: new CssMode(),
javascript: new JavaScriptMode() javascript: new JavaScriptMode(),
python: new PythonMode()
}; };
function getMode() { function getMode() {
@ -182,6 +191,8 @@ exports.launch = function(env) {
mode = "html"; mode = "html";
} else if (/^.*\.css$/i.test(file.name)) { } else if (/^.*\.css$/i.test(file.name)) {
mode = "css"; mode = "css";
} else if (/^.*\.py$/i.test(file.name)) {
mode = "python";
} }
env.editor.onTextInput(reader.result); env.editor.onTextInput(reader.result);

View file

@ -150,6 +150,23 @@
} }
</style> </style>
</head>
<body>
<h1 style="color:red">Juhu Kinners</h1>
</body>
</html>
</script>
<script type="text/editor" id="pythontext">
</style>
</head>
<body>
<h1 style="color:red">Juhu Kinners</h1>
</body>
</html>
</script>
</head> </head>
<body> <body>
<h1 style="color:red">Juhu Kinners</h1> <h1 style="color:red">Juhu Kinners</h1>

View file

@ -37,12 +37,12 @@
define(function(require, exports, module) { define(function(require, exports, module) {
var oop = require("../lib/oop"); var oop = require("pilot/oop").oop;
var TextMode = require("./text"); var TextMode = require("./text").Text;
var Tokenizer = require("../tokenizer"); var Tokenizer = require("../tokenizer").Tokenizer;
var PythonHighlightRules = require("./python_highlight_rules"); var PythonHighlightRules = require("./python_highlight_rules").PythonHighlightRules;
var MatchingBraceOutdent = require("./matching_brace_outdent"); var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
var Range = require("../range"); var Range = require("../range").Range;
var Python = function() { var Python = function() {
this.$tokenizer = new Tokenizer(new PythonHighlightRules().getRules()); this.$tokenizer = new Tokenizer(new PythonHighlightRules().getRules());
@ -112,5 +112,5 @@ oop.inherits(Python, TextMode);
}).call(Python.prototype); }).call(Python.prototype);
return Python; exports.Python = Python;
}); });

View file

@ -40,9 +40,9 @@
define(function(require, exports, module) { define(function(require, exports, module) {
var oop = require("../lib/oop"); var oop = require("pilot/oop").oop;
var lang = require("../lib/lang"); var lang = require("pilot/lang").lang;
var TextHighlightRules = require("./text_highlight_rules"); var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
PythonHighlightRules = function() { PythonHighlightRules = function() {
@ -172,5 +172,5 @@ PythonHighlightRules = function() {
oop.inherits(PythonHighlightRules, TextHighlightRules); oop.inherits(PythonHighlightRules, TextHighlightRules);
return PythonHighlightRules; exports.PythonHighlightRules = PythonHighlightRules;
}); });

@ -1 +1 @@
Subproject commit 0095dc028d0e6f3d40587071fa67622930aa880e Subproject commit 819c4e7b9b1e6e5f99696b5c9f2805891a9e7cfd