update highlighting when mode is changed
This commit is contained in:
parent
30445fd2f8
commit
201210fefa
1 changed files with 12 additions and 8 deletions
|
|
@ -23,40 +23,43 @@ var editor2 = window.editor2 = splitEditor.editor1;
|
||||||
new TokenTooltip(editor2);
|
new TokenTooltip(editor2);
|
||||||
|
|
||||||
var timeout = null;
|
var timeout = null;
|
||||||
schedule = function() {
|
var schedule = function() {
|
||||||
if(timeout != null) {
|
if (timeout != null) {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
}
|
}
|
||||||
timeout = setTimeout(run, 800);
|
timeout = setTimeout(run, 800);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
setAutorunEnabled = function(val) {
|
var setAutorunEnabled = function(val) {
|
||||||
if (val)
|
if (val)
|
||||||
editor1.on('change', schedule);
|
editor1.on('change', schedule);
|
||||||
else
|
else
|
||||||
editor1.removeEventListener('change', schedule);
|
editor1.removeEventListener('change', schedule);
|
||||||
}
|
};
|
||||||
|
|
||||||
util.bindCheckbox("autorunEl", setAutorunEnabled);
|
util.bindCheckbox("autorunEl", setAutorunEnabled);
|
||||||
|
|
||||||
|
|
||||||
docEl = document.getElementById("doc");
|
var docEl = document.getElementById("doc");
|
||||||
util.fillDropdown(docEl, doclist.docs);
|
util.fillDropdown(docEl, doclist.docs);
|
||||||
util.bindDropdown("doc", function(value) {
|
util.bindDropdown("doc", function(value) {
|
||||||
doclist.loadDoc(value, function(session) {
|
doclist.loadDoc(value, function(session) {
|
||||||
if (session) {
|
if (session) {
|
||||||
editor2.setSession(session);
|
editor2.setSession(session);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
modeEl = document.getElementById("modeEl");
|
var modeEl = document.getElementById("modeEl");
|
||||||
util.fillDropdown(modeEl, modelist.modes);
|
util.fillDropdown(modeEl, modelist.modes);
|
||||||
var modeSessions = {};
|
var modeSessions = {};
|
||||||
util.bindDropdown(modeEl, function(value) {
|
util.bindDropdown(modeEl, function(value) {
|
||||||
if (modeSessions[value])
|
if (modeSessions[value]) {
|
||||||
editor1.setSession(modeSessions[value]);
|
editor1.setSession(modeSessions[value]);
|
||||||
|
schedule();
|
||||||
|
return;
|
||||||
|
}
|
||||||
var hp = "./lib/ace/mode/" + value + "_highlight_rules.js";
|
var hp = "./lib/ace/mode/" + value + "_highlight_rules.js";
|
||||||
net.get(hp, function(text) {
|
net.get(hp, function(text) {
|
||||||
text = util.stripLeadingComments(text);
|
text = util.stripLeadingComments(text);
|
||||||
|
|
@ -67,6 +70,7 @@ util.bindDropdown(modeEl, function(value) {
|
||||||
session.setMode("ace/mode/javascript");
|
session.setMode("ace/mode/javascript");
|
||||||
|
|
||||||
editor1.setSession(modeSessions[value]);
|
editor1.setSession(modeSessions[value]);
|
||||||
|
schedule();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue