add options for theme and mode
This commit is contained in:
parent
6285bf5d5a
commit
10e2c3049c
3 changed files with 20 additions and 7 deletions
|
|
@ -2534,6 +2534,10 @@ config.defineOptions(EditSession.prototype, "session", {
|
|||
set: function(val) {this.doc.setNewLineMode(val)},
|
||||
get: function() {return this.doc.getNewLineMode()},
|
||||
handlesSet: true
|
||||
},
|
||||
mode: {
|
||||
set: function(val) { this.setMode(val) },
|
||||
get: function() { return this.$modeId }
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ var Editor = function(renderer, session) {
|
|||
this.setKeyboardHandler = function(keyboardHandler) {
|
||||
if (!keyboardHandler) {
|
||||
this.keyBinding.setKeyboardHandler(null);
|
||||
} else if (typeof keyboardHandler == "string") {
|
||||
} else if (typeof keyboardHandler === "string") {
|
||||
this.$keybindingId = keyboardHandler;
|
||||
var _self = this;
|
||||
config.loadModule(["keybinding", keyboardHandler], function(module) {
|
||||
|
|
@ -2424,6 +2424,7 @@ config.defineOptions(Editor.prototype, "editor", {
|
|||
minLines: "renderer",
|
||||
scrollPastEnd: "renderer",
|
||||
fixedWidthGutter: "renderer",
|
||||
theme: "renderer",
|
||||
|
||||
scrollSpeed: "$mouseHandler",
|
||||
dragDelay: "$mouseHandler",
|
||||
|
|
@ -2437,7 +2438,8 @@ config.defineOptions(Editor.prototype, "editor", {
|
|||
useSoftTabs: "session",
|
||||
tabSize: "session",
|
||||
wrap: "session",
|
||||
foldStyle: "session"
|
||||
foldStyle: "session",
|
||||
mode: "session"
|
||||
});
|
||||
|
||||
exports.Editor = Editor;
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ dom.importCssString(editorCss, "ace_editor");
|
|||
|
||||
/**
|
||||
* The class that is responsible for drawing everything you see on the screen!
|
||||
* @related editor.renderer
|
||||
* @class VirtualRenderer
|
||||
**/
|
||||
|
||||
|
|
@ -1469,18 +1470,18 @@ var VirtualRenderer = function(container, theme) {
|
|||
**/
|
||||
this.setTheme = function(theme, cb) {
|
||||
var _self = this;
|
||||
this.$themeValue = theme;
|
||||
this.$themeId = theme;
|
||||
_self._dispatchEvent('themeChange',{theme:theme});
|
||||
|
||||
if (!theme || typeof theme == "string") {
|
||||
var moduleName = theme || "ace/theme/textmate";
|
||||
var moduleName = theme || this.$options.theme.initialValue;
|
||||
config.loadModule(["theme", moduleName], afterLoad);
|
||||
} else {
|
||||
afterLoad(theme);
|
||||
}
|
||||
|
||||
function afterLoad(module) {
|
||||
if (_self.$themeValue != theme)
|
||||
if (_self.$themeId != theme)
|
||||
return cb && cb();
|
||||
if (!module.cssClass)
|
||||
return;
|
||||
|
|
@ -1507,7 +1508,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
// force re-measure of the gutter width
|
||||
if (_self.$size) {
|
||||
_self.$size.width = 0;
|
||||
_self.onResize();
|
||||
_self.$updateSizeAsync();
|
||||
}
|
||||
|
||||
_self._dispatchEvent('themeLoaded', {theme:module});
|
||||
|
|
@ -1520,7 +1521,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
* @returns {String}
|
||||
**/
|
||||
this.getTheme = function() {
|
||||
return this.$themeValue;
|
||||
return this.$themeId;
|
||||
};
|
||||
|
||||
// Methods allows to add / remove CSS classnames to the editor element.
|
||||
|
|
@ -1688,6 +1689,12 @@ config.defineOptions(VirtualRenderer.prototype, "renderer", {
|
|||
this.$gutterLayer.$fixedWidth = !!val;
|
||||
this.$loop.schedule(this.CHANGE_GUTTER);
|
||||
}
|
||||
},
|
||||
theme: {
|
||||
set: function(val) { this.setTheme(val) },
|
||||
get: function() { return this.$themeId || this.theme; },
|
||||
initialValue: "./theme/textmate",
|
||||
handlesSet: true
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue