Skip to content

Commit 3d222a7

Browse files
matthewkastornightwing
authored andcommitted
better example code for modelist demo
1 parent e306b09 commit 3d222a7

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

demo/mode_list.html

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,20 @@
2121
</head>
2222
<body>
2323

24-
<pre id="editor">Editor.prototype.showKeyboardShortcuts = function () {
25-
showKeyboardShortcuts(this);
26-
};
27-
editor.commands.addCommands([{
28-
name: "showKeyboardShortcuts",
29-
bindKey: {win: "Ctrl-Alt-h", mac: "Command-Alt-h"},
30-
exec: function(editor, line) {
31-
editor.showKeyboardShortcuts();
32-
}
33-
}]);
24+
<pre id="editor">var editor = ace.edit("editor");
25+
editor.setTheme("ace/theme/twilight");
26+
(function () {
27+
var modelist = ace.require('ace/ext/modelist');
28+
// the file path could come from an xmlhttp request, a drop event,
29+
// or any other scriptable file loading process.
30+
// Extensions could consume the modelist and use it to dynamically
31+
// set the editor mode. Webmasters could use it in their scripts
32+
// for site specific purposes as well.
33+
var filePath = 'blahblah/weee/some.js';
34+
var mode = modelist.getModeFromPath(filePath).mode;
35+
console.log(mode);
36+
editor.getSession().setMode(mode);
37+
}());
3438
</pre>
3539

3640
<script src="../build/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>

0 commit comments

Comments
 (0)