Skip to content

Commit

Permalink
add options for theme and mode
Browse files Browse the repository at this point in the history
  • Loading branch information
nightwing committed Dec 15, 2013
1 parent 6285bf5 commit 10e2c30
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
4 changes: 4 additions & 0 deletions lib/ace/edit_session.js
Expand Up @@ -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 }
}
});

Expand Down
6 changes: 4 additions & 2 deletions lib/ace/editor.js
Expand Up @@ -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) {
Expand Down Expand Up @@ -2424,6 +2424,7 @@ config.defineOptions(Editor.prototype, "editor", {
minLines: "renderer",
scrollPastEnd: "renderer",
fixedWidthGutter: "renderer",
theme: "renderer",

scrollSpeed: "$mouseHandler",
dragDelay: "$mouseHandler",
Expand All @@ -2437,7 +2438,8 @@ config.defineOptions(Editor.prototype, "editor", {
useSoftTabs: "session",
tabSize: "session",
wrap: "session",
foldStyle: "session"
foldStyle: "session",
mode: "session"
});

exports.Editor = Editor;
Expand Down
17 changes: 12 additions & 5 deletions lib/ace/virtual_renderer.js
Expand Up @@ -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
**/

Expand Down Expand Up @@ -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;
Expand All @@ -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});
Expand All @@ -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.
Expand Down Expand Up @@ -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
}
});

Expand Down

0 comments on commit 10e2c30

Please sign in to comment.