From dc198344d51d218d0c06f4e51a89ebe98549467a Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 12 Apr 2013 12:09:15 +0400 Subject: [PATCH] revert changes to worker --- lib/ace/commands/command_manager.js | 4 +- lib/ace/editor.js | 222 ++++++++++++++-------------- lib/ace/mode/golang.js | 88 +++++------ lib/ace/mode/pgsql.js | 42 +++--- lib/ace/mode/text.js | 2 +- lib/ace/worker/mirror.js | 18 +-- lib/ace/worker/worker_client.js | 6 +- 7 files changed, 186 insertions(+), 196 deletions(-) diff --git a/lib/ace/commands/command_manager.js b/lib/ace/commands/command_manager.js index 46a4b604..e8a581ad 100644 --- a/lib/ace/commands/command_manager.js +++ b/lib/ace/commands/command_manager.js @@ -8,7 +8,7 @@ var EventEmitter = require("../lib/event_emitter").EventEmitter; /** * @class CommandManager * - * + * **/ /** @@ -24,7 +24,7 @@ var CommandManager = function(platform, commands) { this.commmandKeyBinding = {}; this.addCommands(commands); - + this.setDefaultHandler("exec", function(e) { return e.command.exec(e.editor, e.args || {}); }); diff --git a/lib/ace/editor.js b/lib/ace/editor.js index 92d218f6..62a4c37f 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -3,7 +3,7 @@ * * Copyright (c) 2010, Ajax.org B.V. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright @@ -14,7 +14,7 @@ * * Neither the name of Ajax.org B.V. nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -46,16 +46,15 @@ var Search = require("./search").Search; var Range = require("./range").Range; var EventEmitter = require("./lib/event_emitter").EventEmitter; var CommandManager = require("./commands/command_manager").CommandManager; -var Autocomplete = require("./autocomplete").Autocomplete; var defaultCommands = require("./commands/default_commands").commands; var config = require("./config"); /** * * - * The main entry point into the Ace functionality. + * The main entry point into the Ace functionality. * - * The `Editor` manages the [[EditSession]] (which manages [[Document]]s), as well as the [[VirtualRenderer]], which draws everything to the screen. + * The `Editor` manages the [[EditSession]] (which manages [[Document]]s), as well as the [[VirtualRenderer]], which draws everything to the screen. * * Event sessions dealing with the mouse and keyboard are bubbled up from `Document` to the `Editor`, which decides what to do with them. * @class Editor @@ -90,7 +89,6 @@ var Editor = function(renderer, session) { }); this.setSession(session || new EditSession("")); - Autocomplete.addTo(this); config.resetOptions(this); config._emit("editor", this); }; @@ -103,7 +101,7 @@ var Editor = function(renderer, session) { * Sets a new key handler, such as "vim" or "windows". * @param {String} keyboardHandler The new key handler * - * + * **/ this.setKeyboardHandler = function(keyboardHandler) { if (!keyboardHandler) { @@ -121,11 +119,11 @@ var Editor = function(renderer, session) { } }; - /** + /** * Returns the keyboard handler, such as "vim" or "windows". * * @returns {String} - * + * **/ this.getKeyboardHandler = function() { return this.keyBinding.getKeyboardHandler(); @@ -252,7 +250,7 @@ var Editor = function(renderer, session) { return this.session; }; - /** + /** * Sets the current document to `val`. * @param {String} val The new value to set for the document * @param {Number} cursorPos Where to set the new value. `undefined` or 0 is selectAll, -1 is at the document start, and 1 is at the end @@ -273,7 +271,7 @@ var Editor = function(renderer, session) { return val; }; - /** + /** * Returns the current session's content. * * @returns {String} @@ -284,7 +282,7 @@ var Editor = function(renderer, session) { }; /** - * + * * Returns the currently highlighted selection. * @returns {String} The highlighted selection **/ @@ -292,11 +290,11 @@ var Editor = function(renderer, session) { return this.selection; }; - /** + /** * {:VirtualRenderer.onResize} * @param {Boolean} force If `true`, recomputes the size, even if the height and width haven't changed * - * + * * @related VirtualRenderer.onResize **/ this.resize = function(force) { @@ -313,9 +311,9 @@ var Editor = function(renderer, session) { this.renderer.setTheme(theme); }; - /** + /** * {:VirtualRenderer.getTheme} - * + * * @returns {String} The set theme * @related VirtualRenderer.getTheme **/ @@ -327,14 +325,14 @@ var Editor = function(renderer, session) { * {:VirtualRenderer.setStyle} * @param {String} style A class name * - * + * * @related VirtualRenderer.setStyle **/ this.setStyle = function(style) { this.renderer.setStyle(style); }; - /** + /** * {:VirtualRenderer.unsetStyle} * @related VirtualRenderer.unsetStyle **/ @@ -353,8 +351,8 @@ var Editor = function(renderer, session) { /** * Set a new font size (in pixels) for the editor text. * @param {String} size A font size ( _e.g._ "12px") - * - * + * + * **/ this.setFontSize = function(size) { this.setOption("fontSize", size); @@ -388,7 +386,7 @@ var Editor = function(renderer, session) { }; /** - * + * * Brings the current `textInput` into focus. **/ this.focus = function() { @@ -411,7 +409,7 @@ var Editor = function(renderer, session) { }; /** - * + * * Blurs the current `textInput`. **/ this.blur = function() { @@ -420,9 +418,9 @@ var Editor = function(renderer, session) { /** * Emitted once the editor comes into focus. - * @event focus - * - * + * @event focus + * + * **/ this.onFocus = function() { if (this.$isFocused) @@ -436,8 +434,8 @@ var Editor = function(renderer, session) { /** * Emitted once the editor has been blurred. * @event blur - * - * + * + * **/ this.onBlur = function() { if (!this.$isFocused) @@ -453,12 +451,12 @@ var Editor = function(renderer, session) { }; /** - * Emitted whenever the document is changed. + * Emitted whenever the document is changed. * @event change * @param {Object} e Contains a single property, `data`, which has the delta of changes * * - * + * **/ this.onDocumentChange = function(e) { var delta = e.data; @@ -486,14 +484,14 @@ var Editor = function(renderer, session) { this.onScrollTopChange = function() { this.renderer.scrollToY(this.session.getScrollTop()); }; - + this.onScrollLeftChange = function() { this.renderer.scrollToX(this.session.getScrollLeft()); }; /** * Emitted when the selection changes. - * + * **/ this.onCursorChange = function() { this.$cursorChange(); @@ -549,7 +547,7 @@ var Editor = function(renderer, session) { var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp() this.session.highlight(re); - + this._emit("changeSelection"); }; @@ -629,10 +627,10 @@ var Editor = function(renderer, session) { /** * Emitted when text is copied. - * @event copy + * @event copy * @param {String} text The copied text * - * + * **/ /** * @@ -678,7 +676,7 @@ var Editor = function(renderer, session) { **/ this.onPaste = function(text) { // todo this should change when paste becomes a command - if (this.$readOnly) + if (this.$readOnly) return; this._emit("paste", text); this.insert(text); @@ -692,8 +690,8 @@ var Editor = function(renderer, session) { /** * Inserts `text` into wherever the cursor is pointing. * @param {String} text The new text to add - * - * + * + * **/ this.insert = function(text) { var session = this.session; @@ -793,10 +791,10 @@ var Editor = function(renderer, session) { this.keyBinding.onCommandKey(e, hashId, keyCode); }; - /** + /** * Pass in `true` to enable overwrites in your session, or `false` to disable. If overwrites is enabled, any text you enter will type over any text after it. If the value of `overwrite` changes, this function also emites the `changeOverwrite` event. * @param {Boolean} overwrite Defines wheter or not to set overwrites - * + * * * @related EditSession.setOverwrite **/ @@ -804,7 +802,7 @@ var Editor = function(renderer, session) { this.session.setOverwrite(overwrite); }; - /** + /** * Returns `true` if overwrites are enabled; `false` otherwise. * @returns {Boolean} * @related EditSession.getOverwrite @@ -813,7 +811,7 @@ var Editor = function(renderer, session) { return this.session.getOverwrite(); }; - /** + /** * Sets the value of overwrite to the opposite of whatever it currently is. * @related EditSession.toggleOverwrite **/ @@ -861,7 +859,7 @@ var Editor = function(renderer, session) { /** * 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); @@ -924,7 +922,7 @@ var Editor = function(renderer, session) { /** * If `showInvisibles` 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); @@ -949,7 +947,7 @@ var Editor = function(renderer, session) { /** * 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); @@ -983,7 +981,7 @@ var Editor = function(renderer, session) { /** * 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); @@ -1000,7 +998,7 @@ var Editor = function(renderer, session) { /** * 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); @@ -1008,7 +1006,7 @@ var Editor = function(renderer, session) { /** * Returns `true` if the behaviors are currently enabled. {:BehaviorsDef} - * + * * @returns {Boolean} **/ this.getBehavioursEnabled = function () { @@ -1019,7 +1017,7 @@ var Editor = function(renderer, session) { * 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); @@ -1059,7 +1057,7 @@ var Editor = function(renderer, session) { /** * 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()){ @@ -1204,7 +1202,7 @@ var Editor = function(renderer, session) { /** * Inserts an indentation into the current cursor position or indents the selected lines. - * + * * @related EditSession.indentRows **/ this.indent = function() { @@ -1311,7 +1309,7 @@ var Editor = function(renderer, session) { } return null; }; - + /** * If the character before the cursor is a number, this functions changes its value by `amount`. * @param {Number} amount The value to change the numeral by (can be negative to decrease value) @@ -1336,14 +1334,14 @@ var Editor = function(renderer, session) { var t = parseFloat(nr.value); t *= Math.pow(10, decimals); - + if(fp !== nr.end && column < fp){ amount *= Math.pow(10, nr.end - column - 1); } else { amount *= Math.pow(10, nr.end - column); } - + t += amount; t /= Math.pow(10, decimals); var nnr = t.toFixed(decimals); @@ -1358,8 +1356,8 @@ var Editor = function(renderer, session) { } } }; - - /** + + /** * Removes all the lines in the current selection * @related EditSession.remove **/ @@ -1390,12 +1388,12 @@ var Editor = function(renderer, session) { var endPoint = doc.insert(point, doc.getTextRange(range), false); range.start = point; range.end = endPoint; - + sel.setSelectionRange(range, reverse) } }; - - /** + + /** * Shifts all the selected lines down one row. * * @returns {Number} On success, it returns -1. @@ -1407,7 +1405,7 @@ var Editor = function(renderer, session) { }); }; - /** + /** * Shifts all the selected lines up one row. * @returns {Number} On success, it returns -1. * @related EditSession.moveLinesDown @@ -1418,14 +1416,14 @@ var Editor = function(renderer, session) { }); }; - /** + /** * Moves a range of text from the given range to the given position. `toPosition` is an object that looks like this: * ```json * { row: newRowLocation, column: newColumnLocation } * ``` * @param {Range} fromRange The range of text you want moved within the document * @param {Object} toPosition The location (row and column) where you want to move the text to - * + * * @returns {Range} The new range where the text was moved to. * @related EditSession.moveText **/ @@ -1433,10 +1431,10 @@ var Editor = function(renderer, session) { return this.session.moveText(range, toPosition); }; - /** + /** * Copies all the selected lines up one row. * @returns {Number} On success, returns 0. - * + * **/ this.copyLinesUp = function() { this.$moveLines(function(firstRow, lastRow) { @@ -1445,7 +1443,7 @@ var Editor = function(renderer, session) { }); }; - /** + /** * Copies all the selected lines down one row. * @returns {Number} On success, returns the number of new rows added; in other words, `lastRow - firstRow + 1`. * @related EditSession.duplicateLines @@ -1460,7 +1458,7 @@ var Editor = function(renderer, session) { /** * Executes a specific function, which can be anything that manipulates selected lines, such as copying them, duplicating them, or shifting them. * @param {Function} mover A method to call on each selected row - * + * * **/ this.$moveLines = function(mover) { @@ -1468,7 +1466,7 @@ var Editor = function(renderer, session) { if (!selection.inMultiSelectMode || this.inVirtualSelectionMode) { var range = selection.toOrientedRange(); var rows = this.$getSelectedRows(range); - var linesMoved = mover.call(this, rows.first, rows.last); + var linesMoved = mover.call(this, rows.first, rows.last); range.moveBy(linesMoved, 0); selection.fromOrientedRange(range); } else { @@ -1486,14 +1484,14 @@ var Editor = function(renderer, session) { first = rows.end.row; else break; - } + } i++; var linesMoved = mover.call(this, first, last); while (rangeIndex >= i) { ranges[rangeIndex].moveBy(linesMoved, 0); rangeIndex--; - } + } } selection.fromOrientedRange(selection.ranges[0]); selection.rangeList.attach(this.session); @@ -1530,7 +1528,7 @@ var Editor = function(renderer, session) { this.renderer.hideComposition(); }; - /** + /** * {:VirtualRenderer.getFirstVisibleRow} * * @returns {Number} @@ -1540,7 +1538,7 @@ var Editor = function(renderer, session) { return this.renderer.getFirstVisibleRow(); }; - /** + /** * {:VirtualRenderer.getLastVisibleRow} * * @returns {Number} @@ -1553,7 +1551,7 @@ var Editor = function(renderer, session) { /** * Indicates if the row is currently visible on the screen. * @param {Number} row The row to check - * + * * @returns {Boolean} **/ this.isRowVisible = function(row) { @@ -1563,8 +1561,8 @@ var Editor = function(renderer, session) { /** * Indicates if the entire row is currently visible on the screen. * @param {Number} row The row to check - * - * + * + * * @returns {Boolean} **/ this.isRowFullyVisible = function(row) { @@ -1646,7 +1644,7 @@ var Editor = function(renderer, session) { this.$moveByPage(-1); }; - /** + /** * Moves the editor to the specified row. * @related VirtualRenderer.scrollToRow **/ @@ -1654,14 +1652,14 @@ var Editor = function(renderer, session) { this.renderer.scrollToRow(row); }; - /** + /** * Scrolls to a line. If `center` is `true`, it puts the line in middle of screen (or attempts to). * @param {Number} line The line to scroll to - * @param {Boolean} center If `true` + * @param {Boolean} center If `true` * @param {Boolean} animate If `true` animates scrolling * @param {Function} callback Function to be called when the animation has finished * - * + * * @related VirtualRenderer.scrollToLine **/ this.scrollToLine = function(line, center, animate, callback) { @@ -1680,9 +1678,9 @@ var Editor = function(renderer, session) { this.renderer.alignCursor(pos, 0.5); }; - /** + /** * Gets the current position of the cursor. - * @returns {Object} An object that looks something like this: + * @returns {Object} An object that looks something like this: * * ```json * { row: currRow, column: currCol } @@ -1694,7 +1692,7 @@ var Editor = function(renderer, session) { return this.selection.getCursor(); }; - /** + /** * Returns the screen position of the cursor. * @returns {Number} * @related EditSession.documentToScreenPosition @@ -1703,7 +1701,7 @@ var Editor = function(renderer, session) { return this.session.documentToScreenPosition(this.getCursorPosition()); }; - /** + /** * {:Selection.getRange} * @returns {Range} * @related Selection.getRange @@ -1713,7 +1711,7 @@ var Editor = function(renderer, session) { }; - /** + /** * Selects all the text in editor. * @related Selection.selectAll **/ @@ -1723,7 +1721,7 @@ var Editor = function(renderer, session) { this.$blockScrolling -= 1; }; - /** + /** * {:Selection.clearSelection} * @related Selection.clearSelection **/ @@ -1731,7 +1729,7 @@ var Editor = function(renderer, session) { this.selection.clearSelection(); }; - /** + /** * Moves the cursor to the specified row and column. Note that this does not de-select the current selection. * @param {Number} row The new row number * @param {Number} column The new column number @@ -1743,10 +1741,10 @@ var Editor = function(renderer, session) { this.selection.moveCursorTo(row, column); }; - /** + /** * Moves the cursor to the position indicated by `pos.row` and `pos.column`. * @param {Object} pos An object with two properties, row and column - * + * * * @related Selection.moveCursorToPosition **/ @@ -1754,7 +1752,7 @@ var Editor = function(renderer, session) { this.selection.moveCursorToPosition(pos); }; - /** + /** * Moves the cursor's row and column to the next matching bracket. * **/ @@ -1774,7 +1772,7 @@ var Editor = function(renderer, session) { if (pos.row == cursor.row && Math.abs(pos.column - cursor.column) < 2) range = this.session.getBracketRange(pos); } - + pos = range && range.cursor || pos; if (pos) { if (select) { @@ -1794,7 +1792,7 @@ var Editor = function(renderer, session) { * @param {Number} lineNumber The line number to go to * @param {Number} column A column number to go to * @param {Boolean} animate If `true` animates scolling - * + * **/ this.gotoLine = function(lineNumber, column, animate) { this.selection.clearSelection(); @@ -1810,7 +1808,7 @@ var Editor = function(renderer, session) { this.scrollToLine(lineNumber - 1, true, animate); }; - /** + /** * Moves the cursor to the specified row and column. Note that this does de-select the current selection. * @param {Number} row The new row number * @param {Number} column The new column number @@ -1826,8 +1824,8 @@ var Editor = function(renderer, session) { /** * Moves the cursor up in the document the specified number of times. Note that this does de-select the current selection. * @param {Number} times The number of times to change navigation - * - * + * + * **/ this.navigateUp = function(times) { if (this.selection.isMultiLine() && !this.selection.isBackwards()) { @@ -1842,8 +1840,8 @@ var Editor = function(renderer, session) { /** * Moves the cursor down in the document the specified number of times. Note that this does de-select the current selection. * @param {Number} times The number of times to change navigation - * - * + * + * **/ this.navigateDown = function(times) { if (this.selection.isMultiLine() && this.selection.isBackwards()) { @@ -1858,8 +1856,8 @@ var Editor = function(renderer, session) { /** * Moves the cursor left in the document the specified number of times. Note that this does de-select the current selection. * @param {Number} times The number of times to change navigation - * - * + * + * **/ this.navigateLeft = function(times) { if (!this.selection.isEmpty()) { @@ -1878,8 +1876,8 @@ var Editor = function(renderer, session) { /** * Moves the cursor right in the document the specified number of times. Note that this does de-select the current selection. * @param {Number} times The number of times to change navigation - * - * + * + * **/ this.navigateRight = function(times) { if (!this.selection.isEmpty()) { @@ -1896,7 +1894,7 @@ var Editor = function(renderer, session) { }; /** - * + * * Moves the cursor to the start of the current line. Note that this does de-select the current selection. **/ this.navigateLineStart = function() { @@ -1905,7 +1903,7 @@ var Editor = function(renderer, session) { }; /** - * + * * Moves the cursor to the end of the current line. Note that this does de-select the current selection. **/ this.navigateLineEnd = function() { @@ -1914,7 +1912,7 @@ var Editor = function(renderer, session) { }; /** - * + * * Moves the cursor to the end of the current file. Note that this does de-select the current selection. **/ this.navigateFileEnd = function() { @@ -1925,7 +1923,7 @@ var Editor = function(renderer, session) { }; /** - * + * * Moves the cursor to the start of the current file. Note that this does de-select the current selection. **/ this.navigateFileStart = function() { @@ -1936,7 +1934,7 @@ var Editor = function(renderer, session) { }; /** - * + * * Moves the cursor to the word immediately to the right of the current position. Note that this does de-select the current selection. **/ this.navigateWordRight = function() { @@ -1945,7 +1943,7 @@ var Editor = function(renderer, session) { }; /** - * + * * Moves the cursor to the word immediately to the left of the current position. Note that this does de-select the current selection. **/ this.navigateWordLeft = function() { @@ -2026,7 +2024,7 @@ var Editor = function(renderer, session) { } }; - /** + /** * {:Search.getOptions} For more information on `options`, see [[Search `Search`]]. * @related Search.getOptions * @returns {Object} @@ -2035,7 +2033,7 @@ var Editor = function(renderer, session) { return this.$search.getOptions(); }; - /** + /** * Attempts to find `needle` within the document. For more information on `options`, see [[Search `Search`]]. * @param {String} needle The text to search for (optional) * @param {Object} options An object defining various search properties @@ -2083,7 +2081,7 @@ var Editor = function(renderer, session) { this.selection.setRange(range); }; - /** + /** * Performs another search for `needle` in the document. For more information on `options`, see [[Search `Search`]]. * @param {Object} options search options * @param {Boolean} animate If `true` animate scrolling @@ -2095,7 +2093,7 @@ var Editor = function(renderer, session) { this.find({skipCurrent: true, backwards: false}, options, animate); }; - /** + /** * Performs a search for `needle` backwards. For more information on `options`, see [[Search `Search`]]. * @param {Object} options search options * @param {Boolean} animate If `true` animate scrolling @@ -2119,7 +2117,7 @@ var Editor = function(renderer, session) { this.renderer.animateScrolling(scrollTop); }; - /** + /** * {:UndoManager.undo} * @related UndoManager.undo **/ @@ -2130,7 +2128,7 @@ var Editor = function(renderer, session) { this.renderer.scrollCursorIntoView(null, 0.5); }; - /** + /** * {:UndoManager.redo} * @related UndoManager.redo **/ @@ -2141,8 +2139,8 @@ var Editor = function(renderer, session) { this.renderer.scrollCursorIntoView(null, 0.5); }; - /** - * + /** + * * Cleans up the entire editor. **/ this.destroy = function() { diff --git a/lib/ace/mode/golang.js b/lib/ace/mode/golang.js index 72262022..91b3e085 100644 --- a/lib/ace/mode/golang.js +++ b/lib/ace/mode/golang.js @@ -1,58 +1,58 @@ define(function(require, exports, module) { - var oop = require("../lib/oop"); - var TextMode = require("./text").Mode; - var Tokenizer = require("../tokenizer").Tokenizer; - var GolangHighlightRules = require("./golang_highlight_rules").GolangHighlightRules; - var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; - var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; - var CStyleFoldMode = require("./folding/cstyle").FoldMode; +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var GolangHighlightRules = require("./golang_highlight_rules").GolangHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + var highlighter = new GolangHighlightRules(); + + this.$tokenizer = new Tokenizer(highlighter.getRules()); + this.$keywordList = highlighter.$keywordList; + this.$outdent = new MatchingBraceOutdent(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { - var Mode = function() { - var highlighter = new GolangHighlightRules(); - - this.$tokenizer = new Tokenizer(highlighter.getRules()); - this.$keywordList = highlighter.$keywordList; - this.$outdent = new MatchingBraceOutdent(); - this.foldingRules = new CStyleFoldMode(); - }; - oop.inherits(Mode, TextMode); - - (function() { - this.lineCommentStart = "//"; this.blockComment = {start: "/*", end: "*/"}; - this.getNextLineIndent = function(state, line, tab) { - var indent = this.$getIndent(line); + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); - var tokenizedLine = this.$tokenizer.getLineTokens(line, state); - var tokens = tokenizedLine.tokens; - var endState = tokenizedLine.state; - - if (tokens.length && tokens[tokens.length-1].type == "comment") { - return indent; - } - - if (state == "start") { - var match = line.match(/^.*[\{\(\[]\s*$/); - if (match) { - indent += tab; - } - } + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + var endState = tokenizedLine.state; + if (tokens.length && tokens[tokens.length-1].type == "comment") { return indent; - };//end getNextLineIndent + } + + if (state == "start") { + var match = line.match(/^.*[\{\(\[]\s*$/); + if (match) { + indent += tab; + } + } - this.checkOutdent = function(state, line, input) { - return this.$outdent.checkOutdent(line, input); - }; + return indent; + };//end getNextLineIndent - this.autoOutdent = function(state, doc, row) { - this.$outdent.autoOutdent(doc, row); - }; + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; - }).call(Mode.prototype); + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; - exports.Mode = Mode; +}).call(Mode.prototype); + +exports.Mode = Mode; }); diff --git a/lib/ace/mode/pgsql.js b/lib/ace/mode/pgsql.js index 4ebaec80..2398ea83 100755 --- a/lib/ace/mode/pgsql.js +++ b/lib/ace/mode/pgsql.js @@ -30,33 +30,33 @@ define(function(require, exports, module) { - var oop = require("../lib/oop"); - var TextMode = require("../mode/text").Mode; - var Tokenizer = require("../tokenizer").Tokenizer; - var PgsqlHighlightRules = require("./pgsql_highlight_rules").PgsqlHighlightRules; - var Range = require("../range").Range; +var oop = require("../lib/oop"); +var TextMode = require("../mode/text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var PgsqlHighlightRules = require("./pgsql_highlight_rules").PgsqlHighlightRules; +var Range = require("../range").Range; - var Mode = function() { - var highlighter = new PgsqlHighlightRules(); - - this.$tokenizer = new Tokenizer(highlighter.getRules()); - this.$keywordList = highlighter.$keywordList; - }; - oop.inherits(Mode, TextMode); +var Mode = function() { + var highlighter = new PgsqlHighlightRules(); - (function() { + this.$tokenizer = new Tokenizer(highlighter.getRules()); + this.$keywordList = highlighter.$keywordList; +}; +oop.inherits(Mode, TextMode); + +(function() { this.lineCommentStart = "--"; this.blockComment = {start: "/*", end: "*/"}; - this.getNextLineIndent = function(state, line, tab) { - if (state == "start" || state == "keyword.statementEnd") { - return ""; - } else { - return this.$getIndent(line); // Keep whatever indent the previous line has - } + this.getNextLineIndent = function(state, line, tab) { + if (state == "start" || state == "keyword.statementEnd") { + return ""; + } else { + return this.$getIndent(line); // Keep whatever indent the previous line has } + } - }).call(Mode.prototype); +}).call(Mode.prototype); - exports.Mode = Mode; +exports.Mode = Mode; }); diff --git a/lib/ace/mode/text.js b/lib/ace/mode/text.js index 6bf36018..1af608a5 100644 --- a/lib/ace/mode/text.js +++ b/lib/ace/mode/text.js @@ -347,7 +347,7 @@ var Mode = function() { } } } - } + } } this.completionKeywords = completionKeywords; } diff --git a/lib/ace/worker/mirror.js b/lib/ace/worker/mirror.js index dd804865..c521f8fd 100644 --- a/lib/ace/worker/mirror.js +++ b/lib/ace/worker/mirror.js @@ -7,34 +7,26 @@ var lang = require("../lib/lang"); var Mirror = exports.Mirror = function(sender) { this.sender = sender; var doc = this.doc = new Document(""); - this.data = {}; - + var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this)); - + var _self = this; sender.on("change", function(e) { doc.applyDeltas(e.data); - if (_self.$defer) - deferredUpdate.schedule(_self.$timeout); + deferredUpdate.schedule(_self.$timeout); }); }; (function() { this.$timeout = 500; - this.$defer = true; - + this.setTimeout = function(timeout) { this.$timeout = timeout; }; - this.setDeferredUpdate = function(defer) { - this.$defer = defer; - }; - - this.setValue = function(value, data) { + this.setValue = function(value) { this.doc.setValue(value); - this.data = data; this.deferredUpdate.schedule(this.$timeout); }; diff --git a/lib/ace/worker/worker_client.js b/lib/ace/worker/worker_client.js index 91dc6ca5..5a682fe5 100644 --- a/lib/ace/worker/worker_client.js +++ b/lib/ace/worker/worker_client.js @@ -144,12 +144,12 @@ var WorkerClient = function(topLevelNamespaces, mod, classname) { catch(ex) {} }; - this.attachToDocument = function(doc, data, ignore) { - if (this.$doc && !ignore) + this.attachToDocument = function(doc) { + if(this.$doc) this.terminate(); this.$doc = doc; - this.call("setValue", [doc.getValue(), data]); + this.call("setValue", [doc.getValue()]); doc.on("change", this.changeListener); };