diff --git a/lib/ace/config.js b/lib/ace/config.js index e3bd8da2..c617959d 100644 --- a/lib/ace/config.js +++ b/lib/ace/config.js @@ -169,11 +169,6 @@ function deHyphenate(str) { return str.replace(/-(.)/g, function(m, m1) { return m1.toUpperCase(); }); } -function capitalize(str) { - return str[0].toUpperCase() + str.substr(1); -} - - var optionsProvider = { setOptions: function(optList) { Object.keys(optList).forEach(function(key) { @@ -228,11 +223,6 @@ exports.defineOptions = function(obj, path, options) { obj.$options[opt.name] = opt; if ("initialValue" in opt) obj["$" + opt.name] = opt.initialValue; - - opt.setterName = capitalize(opt.name) - if (opt.setterName) { - addSetters(obj, opt.name, opt.setterName); - } }); // implement option provider interface @@ -241,15 +231,6 @@ exports.defineOptions = function(obj, path, options) { return this; }; -function addSetters(obj, name, setterName) { - obj["set" + setterName] = function(value) { - return this.setOption(name, value) - }; - obj["get" + setterName] = function() { - return this.getOption(name) - }; -}; - exports.resetOptions = function(obj) { Object.keys(obj.$options).forEach(function(key) { var opt = obj.$options[key]; diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index 37bbe9b9..f802da0b 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -456,6 +456,27 @@ var EditSession = function(text, mode) { } }; + /** + /** + * Pass `true` to enable the use of soft tabs. Soft tabs means you're using spaces instead of the tab character (`'\t'`). + * @param {Boolean} useSoftTabs Value indicating whether or not to use soft tabs + **/ + this.setUseSoftTabs = function(val) { this.setOption("useSoftTabs", val); }; + /** + * Returns `true` if soft tabs are being used, `false` otherwise. + * @returns {Boolean} + **/ + this.getUseSoftTabs = function() { return this.$useSoftTabs; }; + /** + * Set the number of spaces that define a soft tab; for example, passing in `4` transforms the soft tabs to be equivalent to four spaces. This function also emits the `changeTabSize` event. + * @param {Number} tabSize The new tab size + **/ + this.setTabSize = function(tabSize) { this.setOption("tabSize", tabsSize) } + /** + * Returns the current tab size. + **/ + this.getTabSize = function() { return this.$tabSize; }; + /** * Returns `true` if the character at the position is a soft tab. * @param {Object} position The position to check @@ -823,6 +844,18 @@ var EditSession = function(text, mode) { return this.doc.getNewLineMode(); }; + /** + * Identifies if you want to use a worker for the `EditSession`. + * @param {Boolean} useWorker Set to `true` to use a worker + * + **/ + this.setUseWorker = function(useWorker) { this.setOption("useWorker", useWorker); }; + + /** + * Returns `true` if workers are being used. + **/ + this.getUseWorker = function() { return this.$useWorker; }; + /** * Reloads all the tokens on the current session. This function calls [[BackgroundTokenizer.start `BackgroundTokenizer.start ()`]] to all the rows; it also emits the `'tokenizerUpdate'` event. **/ @@ -2337,26 +2370,7 @@ var EditSession = function(text, mode) { require("./edit_session/folding").Folding.call(EditSession.prototype); require("./edit_session/bracket_match").BracketMatch.call(EditSession.prototype); - /** - * Pass `true` to enable the use of soft tabs. Soft tabs means you're using spaces instead of the tab character (`'\t'`). - * @param {Boolean} useSoftTabs Value indicating whether or not to use soft tabs - * @method EditSession.setUseSoftTabs - **/ - /** - * Set the number of spaces that define a soft tab; for example, passing in `4` transforms the soft tabs to be equivalent to four spaces. This function also emits the `changeTabSize` event. - * @param {Number} tabSize The new tab size - * @method EditSession.setTabSize - **/ - /** - * Identifies if you want to use a worker for the `EditSession`. - * @param {Boolean} useWorker Set to `true` to use a worker - * @method EditSession.setUseWorker - **/ - /** - * Sets the number displayed in the gutter for the first line of code. - * @param {Number} firstLineNumber The number displayed in the gutter for the first line of code. - * @method EditSession.setFirstLineNumber - */ + config.defineOptions(EditSession.prototype, "session", { wrap: { set: function(value) { diff --git a/lib/ace/editor.js b/lib/ace/editor.js index ea7658c5..c87d0705 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -802,12 +802,245 @@ var Editor = function(renderer, session) { this.session.toggleOverwrite(); }; + /** + * Sets how fast the mouse scrolling should do. + * @param {Number} speed A value indicating the new speed (in milliseconds) + **/ + this.setScrollSpeed = function(speed) { + this.setOption("scrollSpeed", speed); + }; + + /** + * Returns the value indicating how fast the mouse scroll speed is (in milliseconds). + * @returns {Number} + **/ + this.getScrollSpeed = function() { + return this.getOption("scrollSpeed"); + }; + + /** + * Sets the delay (in milliseconds) of the mouse drag. + * @param {Number} dragDelay A value indicating the new delay + **/ + this.setDragDelay = function(dragDelay) { + this.setOption("dragDelay", dragDelay); + }; + + /** + * Returns the current mouse drag delay. + * @returns {Number} + **/ + this.getDragDelay = function() { + return this.getOption("dragDelay"); + }; + + /** + * Emitted when the selection style changes, via [[Editor.setSelectionStyle]]. + * @event changeSelectionStyle + * @param {Object} data Contains one property, `data`, which indicates the new selection style + **/ + /** + * Draw selection markers spanning whole line, or only over selected text. Default value is "line" + * @param {String} style The new selection style "line"|"text" + * + **/ + this.setSelectionStyle = function(val) { + this.setOption("selectionStyle", val); + }; + + /** + * Returns the current selection style. + * @returns {String} + **/ + this.getSelectionStyle = function() { + return this.getOption("selectionStyle"); + }; + + /** + * Determines whether or not the current line should be highlighted. + * @param {Boolean} shouldHighlight Set to `true` to highlight the current line + **/ + this.setHighlightActiveLine = function(shouldHighlight) { + this.setOption("highlightActiveLine", shouldHighlight); + }; + /** + * Returns `true` if current lines are always highlighted. + * @return {Boolean} + **/ + this.getHighlightActiveLine = function() { + return this.getOption("highlightActiveLine"); + }; + this.setHighlightGutterLine = function(shouldHighlight) { + this.setOption("highlightGutterLine", shouldHighlight); + }; + + this.getHighlightGutterLine = function() { + return this.getOption("highlightGutterLine"); + }; + /** + * Determines if the currently selected word should be highlighted. + * @param {Boolean} shouldHighlight Set to `true` to highlight the currently selected word + * + **/ + this.setHighlightSelectedWord = function(shouldHighlight) { + this.setOption("highlightSelectedWord", shouldHighlight); + }; + + /** + * Returns `true` if currently highlighted words are to be highlighted. + * @returns {Boolean} + **/ + this.getHighlightSelectedWord = function() { + return this.$highlightSelectedWord; + }; + + this.setAnimatedScroll = function(shouldAnimate){ + this.renderer.setAnimatedScroll(shouldAnimate); + }; + + this.getAnimatedScroll = function(){ + return this.renderer.getAnimatedScroll(); + }; + + /** + * If `showInvisibiles` is set to `true`, invisible characters—like spaces or new lines—are show in the editor. + * @param {Boolean} showInvisibles Specifies whether or not to show invisible characters + * + **/ + this.setShowInvisibles = function(showInvisibles) { + this.renderer.setShowInvisibles(showInvisibles); + }; + + /** + * Returns `true` if invisible characters are being shown. + * @returns {Boolean} + **/ + this.getShowInvisibles = function() { + return this.renderer.getShowInvisibles(); + }; + + this.setDisplayIndentGuides = function(display) { + this.renderer.setDisplayIndentGuides(display); + }; + + this.getDisplayIndentGuides = function() { + return this.renderer.getDisplayIndentGuides(); + }; + + /** + * If `showPrintMargin` is set to `true`, the print margin is shown in the editor. + * @param {Boolean} showPrintMargin Specifies whether or not to show the print margin + * + **/ + this.setShowPrintMargin = function(showPrintMargin) { + this.renderer.setShowPrintMargin(showPrintMargin); + }; + + /** + * Returns `true` if the print margin is being shown. + * @returns {Boolean} + **/ + this.getShowPrintMargin = function() { + return this.renderer.getShowPrintMargin(); + }; + + /** + * Sets the column defining where the print margin should be. + * @param {Number} showPrintMargin Specifies the new print margin + * + **/ + this.setPrintMarginColumn = function(showPrintMargin) { + this.renderer.setPrintMarginColumn(showPrintMargin); + }; + + /** + * Returns the column number of where the print margin is. + * @returns {Number} + **/ + this.getPrintMarginColumn = function() { + return this.renderer.getPrintMarginColumn(); + }; + + /** + * If `readOnly` is true, then the editor is set to read-only mode, and none of the content can change. + * @param {Boolean} readOnly Specifies whether the editor can be modified or not + * + **/ + this.setReadOnly = function(readOnly) { + this.setOption("readOnly", readOnly); + }; + + /** + * Returns `true` if the editor is set to read-only mode. + * @returns {Boolean} + **/ + this.getReadOnly = function() { + return this.getOption("readOnly"); + }; + + /** + * Specifies whether to use behaviors or not. ["Behaviors" in this case is the auto-pairing of special characters, like quotation marks, parenthesis, or brackets.]{: #BehaviorsDef} + * @param {Boolean} enabled Enables or disables behaviors + * + **/ + this.setBehavioursEnabled = function (enabled) { + this.setOption("behavioursEnabled", enabled); + }; + + /** + * Returns `true` if the behaviors are currently enabled. {:BehaviorsDef} + * + * @returns {Boolean} + **/ + this.getBehavioursEnabled = function () { + return this.getOption("behavioursEnabled"); + }; + + /** + * Specifies whether to use wrapping behaviors or not, i.e. automatically wrapping the selection with characters such as brackets + * when such a character is typed in. + * @param {Boolean} enabled Enables or disables wrapping behaviors + * + **/ + this.setWrapBehavioursEnabled = function (enabled) { + this.setOption("wrapBehavioursEnabled", enabled); + }; + + /** + * Returns `true` if the wrapping behaviors are currently enabled. + **/ + this.getWrapBehavioursEnabled = function () { + return this.getOption("wrapBehavioursEnabled"); + }; + + /** + * Indicates whether the fold widgets should be shown or not. + * @param {Boolean} show Specifies whether the fold widgets are shown + **/ + this.setShowFoldWidgets = function(show) { + this.setOption("showFoldWidgets", show); + + }; + /** + * Returns `true` if the fold widgets are shown. + * @return {Boolean} + **/ + this.getShowFoldWidgets = function() { + return this.renderer.$gutterLayer.getShowFoldWidgets(); + }; + + this.setFadeFoldWidgets = function(show) { + this.renderer.setFadeFoldWidgets(show); + }; + + this.getFadeFoldWidgets = function() { + return this.renderer.getFadeFoldWidgets(); + }; + /** * Removes words of text from the editor. A "word" is defined as a string of characters bookended by whitespace. * @param {String} dir The direction of the deletion to occur, either "left" or "right" * - * - * **/ this.remove = function(dir) { if (this.selection.isEmpty()){ @@ -1875,102 +2108,6 @@ var Editor = function(renderer, session) { }).call(Editor.prototype); - /** - * Sets how fast the mouse scrolling should do. - * @param {Number} speed A value indicating the new speed (in milliseconds) - * @method Editor.setScrollSpeed - **/ - /** - * Returns the value indicating how fast the mouse scroll speed is (in milliseconds). - * @returns {Number} - * @method Editor.getScrollSpeed - **/ - /** - * Sets the delay (in milliseconds) of the mouse drag. - * @param {Number} dragDelay A value indicating the new delay - * @method Editor.setDragDelay - **/ - /** - * Returns the current mouse drag delay. - * @returns {Number} - * @method Editor.getDragDelay - **/ - /** - * Emitted when the selection style changes, via [[Editor.setSelectionStyle]]. - * @event changeSelectionStyle - * @param {Object} data Contains one property, `data`, which indicates the new selection style - **/ - /** - * Draw selection markers spanning whole line, or only over selected text. Default value is "line" - * @param {String} style The new selection style "line"|"text" - * @method Editor.setSelectionStyle - **/ - /** - * Determines whether or not the current line should be highlighted. - * @param {Boolean} shouldHighlight Set to `true` to highlight the current line - * @method Editor.setHighlightActiveLine - **/ - /** - * Returns `true` if current lines are always highlighted. - * @return {Boolean} - * @method Editor.getHighlightActiveLine - **/ - /** - * Determines if the currently selected word should be highlighted. - * @param {Boolean} shouldHighlight Set to `true` to highlight the currently selected word - * @method Editor.setHighlightSelectedWord - **/ - /** - * If `showInvisibiles` is set to `true`, invisible characters—like spaces or new lines—are show in the editor. - * @param {Boolean} showInvisibles Specifies whether or not to show invisible characters - * @method Editor.setShowInvisibles - **/ - /** - * If `showPrintMargin` is set to `true`, the print margin is shown in the editor. - * @param {Boolean} showPrintMargin Specifies whether or not to show the print margin - * @method Editor.setShowPrintMargin - **/ - /** - * Returns `true` if the print margin is being shown. - * @returns {Boolean} - * @method Editor.getShowPrintMargin - **/ - /** - * Sets the column defining where the print margin should be. - * @param {Number} showPrintMargin Specifies the new print margin - * @method Editor.setPrintMarginColumn - **/ - /** - * Returns the column number of where the print margin is. - * @returns {Number} - * @method Editor.getPrintMarginColumn - **/ - /** - * If `readOnly` is true, then the editor is set to read-only mode, and none of the content can change. - * @param {Boolean} readOnly Specifies whether the editor can be modified or not - * @method Editor.setReadOnly - **/ - /** - * Returns `true` if the editor is set to read-only mode. - * @returns {Boolean} - * @method Editor.getReadOnly - **/ - /** - * Specifies whether to use behaviors or not. ["Behaviors" in this case is the auto-pairing of special characters, like quotation marks, parenthesis, or brackets.]{: #BehaviorsDef} - * @param {Boolean} enabled Enables or disables behaviors - * @method Editor.setBehavioursEnabled - **/ - /** - * Specifies whether to use wrapping behaviors or not, i.e. automatically wrapping the selection with characters such as brackets - * when such a character is typed in. - * @param {Boolean} enabled Enables or disables wrapping behaviors - * @method Editor.setWrapBehavioursEnabled - **/ - /** - * Indicates whether the fold widgets should be shown or not. - * @param {Boolean} show Specifies whether the fold widgets are shown - * @method Editor.setShowFoldWidgets - **/ config.defineOptions(Editor.prototype, "editor", { selectionStyle: { diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index 7e5faf6a..3a84fbce 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -357,6 +357,113 @@ var VirtualRenderer = function(container, theme) { return this.session.adjustWrapLimit(limit); }; + /** + * Identifies whether you want to have an animated scroll or not. + * @param {Boolean} shouldAnimate Set to `true` to show animated scrolls + * + **/ + this.setAnimatedScroll = function(shouldAnimate){ + this.setOption("animatedScroll", shouldAnimate); + }; + + /** + * Returns whether an animated scroll happens or not. + * @returns {Boolean} + **/ + this.getAnimatedScroll = function() { + return this.$animatedScroll; + }; + + /** + * Identifies whether you want to show invisible characters or not. + * @param {Boolean} showInvisibles Set to `true` to show invisibles + * + **/ + this.setShowInvisibles = function(showInvisibles) { + this.setOption("showInvisibles", showInvisibles); + }; + + /** + * Returns whether invisible characters are being shown or not. + * @returns {Boolean} + **/ + this.getShowInvisibles = function() { + return this.getOption("showInvisibles"); + }; + this.getDisplayIndentGuides = function() { + return this.getOption("displayIndentGuides"); + }; + + this.setDisplayIndentGuides = function(display) { + this.setOption("displayIndentGuides", display); + }; + + /** + * Identifies whether you want to show the print margin or not. + * @param {Boolean} showPrintMargin Set to `true` to show the print margin + * + **/ + this.setShowPrintMargin = function(showPrintMargin) { + this.setOption("showPrintMargin", showPrintMargin); + }; + + /** + * Returns whether the print margin is being shown or not. + * @returns {Boolean} + **/ + this.getShowPrintMargin = function() { + this.getOption("showPrintMargin"); + }; + /** + * Identifies whether you want to show the print margin column or not. + * @param {Boolean} showPrintMargin Set to `true` to show the print margin column + * + **/ + this.setPrintMarginColumn = function(showPrintMargin) { + this.setOption("printMarginColumn", showPrintMargin); + }; + + /** + * Returns whether the print margin column is being shown or not. + * @returns {Boolean} + **/ + this.getPrintMarginColumn = function() { + return this.getOption("printMarginColumn"); + }; + + /** + * Returns `true` if the gutter is being shown. + * @returns {Boolean} + **/ + this.getShowGutter = function(){ + return this.getOption("showGutter"); + }; + + /** + * Identifies whether you want to show the gutter or not. + * @param {Boolean} show Set to `true` to show the gutter + * + **/ + this.setShowGutter = function(show){ + return this.setOption("showGutter", show); + }; + + this.getFadeFoldWidgets = function(){ + return this.getOption("fadeFoldWidgets") + }; + + this.setFadeFoldWidgets = function(show) { + this.setOption("fadeFoldWidgets", show); + }; + + this.setHighlightGutterLine = function(shouldHighlight) { + this.setOption("highlightGutterLine", shouldHighlight); + }; + + this.getHighlightGutterLine = function() { + return this.getOption("highlightGutterLine"); + }; + this.$updateGutterLineHighlight = function() { this.$gutterLineHighlight.style.top = this.$cursorLayer.$pixelPos.top - this.layerConfig.offset + "px"; this.$gutterLineHighlight.style.height = this.layerConfig.lineHeight + "px"; @@ -1220,57 +1327,7 @@ var VirtualRenderer = function(container, theme) { }).call(VirtualRenderer.prototype); - /** - * Identifies whether you want to have an animated scroll or not. - * @param {Boolean} shouldAnimate Set to `true` to show animated scrolls - * @method VirtualRenderer.setAnimatedScroll - * - **/ - /** - * Returns whether an animated scroll happens or not. - * @returns {Boolean} - * @method VirtualRenderer.getAnimatedScroll - **/ - /** - * Identifies whether you want to show invisible characters or not. - * @param {Boolean} showInvisibles Set to `true` to show invisibles - * @method VirtualRenderer.setShowInvisibles - **/ - /** - * Returns whether invisible characters are being shown or not. - * @returns {Boolean} - * @method VirtualRenderer.getShowInvisibles - **/ - /** - * Identifies whether you want to show the print margin or not. - * @param {Boolean} showPrintMargin Set to `true` to show the print margin - * @method VirtualRenderer.setShowPrintMargin - **/ - /** - * Returns whether the print margin is being shown or not. - * @returns {Boolean} - * @method VirtualRenderer.getShowPrintMargin - **/ - /** - * Identifies whether you want to show the print margin column or not. - * @param {Boolean} showPrintMargin Set to `true` to show the print margin column - * @method VirtualRenderer.setPrintMarginColumn - **/ - /** - * Returns whether the print margin column is being shown or not. - * @returns {Boolean} - * @method VirtualRenderer.getPrintMarginColumn - **/ - /** - * Returns `true` if the gutter is being shown. - * @returns {Boolean} - * @method VirtualRenderer.getShowGutter - **/ - /** - * Identifies whether you want to show the gutter or not. - * @param {Boolean} show Set to `true` to show the gutter - * @method VirtualRenderer.setShowGutter - **/ + config.defineOptions(VirtualRenderer.prototype, "renderer", { animatedScroll: {initialValue: false}, showInvisibles: { @@ -1312,7 +1369,6 @@ config.defineOptions(VirtualRenderer.prototype, "renderer", { }, initialValue: true }, - highlightGutterLine: { set: function(shouldHighlight) { if (!this.$gutterLineHighlight) {