diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index d5c42311..60b0d4a2 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -159,11 +159,10 @@ var EditSession = function(text, mode) { text = new Document(text); this.setDocument(text); - this.selection = new Selection(this); - this.setMode(mode); config.resetOptions(this); + this.setMode(mode); config._emit("session", this); }; diff --git a/lib/ace/editor.js b/lib/ace/editor.js index 0abcecbf..14174422 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -2188,6 +2188,15 @@ var Editor = function(renderer, session) { }; }; + this.$resetCursorStyle = function() { + var style = this.$cursorStyle || "ace"; + var cursorLayer = this.renderer.$cursorLayer; + if (!cursorLayer) + return; + cursorLayer.setSmoothBlinking(style == "smooth"); + cursorLayer.isBlinking = !this.$readOnly && style != "wide"; + }; + }).call(Editor.prototype); @@ -2209,13 +2218,14 @@ config.defineOptions(Editor.prototype, "editor", { initialValue: true }, readOnly: { - set: function(readOnly) { - this.textInput.setReadOnly(readOnly); - var cursorLayer = this.renderer.$cursorLayer; - cursorLayer && cursorLayer.setBlinking(!readOnly); - }, + set: function(readOnly) { this.$resetCursorStyle(); }, initialValue: false }, + cursorStyle: { + set: function(val) { this.$resetCursorStyle(); }, + values: ["ace", "slim", "smooth", "wide"], + initialValue: "ace" + }, behavioursEnabled: {initialValue: true}, wrapBehavioursEnabled: {initialValue: true}, diff --git a/lib/ace/worker/mirror.js b/lib/ace/worker/mirror.js index 198432be..c521f8fd 100644 --- a/lib/ace/worker/mirror.js +++ b/lib/ace/worker/mirror.js @@ -12,7 +12,7 @@ var Mirror = exports.Mirror = function(sender) { var _self = this; sender.on("change", function(e) { - doc.applyDeltas([e.data]); + doc.applyDeltas(e.data); deferredUpdate.schedule(_self.$timeout); }); }; diff --git a/lib/ace/worker/worker_client.js b/lib/ace/worker/worker_client.js index b9cf7851..d54c38a7 100644 --- a/lib/ace/worker/worker_client.js +++ b/lib/ace/worker/worker_client.js @@ -36,6 +36,7 @@ var EventEmitter = require("../lib/event_emitter").EventEmitter; var config = require("../config"); var WorkerClient = function(topLevelNamespaces, mod, classname) { + this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this); this.changeListener = this.changeListener.bind(this); this.onMessage = this.onMessage.bind(this); this.onError = this.onError.bind(this); @@ -152,17 +153,28 @@ var WorkerClient = function(topLevelNamespaces, mod, classname) { }; this.changeListener = function(e) { - e.range = { - start: e.data.range.start, - end: e.data.range.end - }; - this.emit("change", e); + if (!this.deltaQueue) { + this.deltaQueue = [e.data]; + setTimeout(this.$sendDeltaQueue, 1); + } else + this.deltaQueue.push(e.data); }; + this.$sendDeltaQueue = function() { + var q = this.deltaQueue; + if (!q) return; + this.deltaQueue = null; + if (q.length > 20 && q.length > this.$doc.getLength() >> 1) { + this.call("setValue", [this.$doc.getValue()]); + } else + this.emit("change", {data: q}); + } + }).call(WorkerClient.prototype); var UIWorkerClient = function(topLevelNamespaces, mod, classname) { + this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this); this.changeListener = this.changeListener.bind(this); this.callbackId = 1; this.callbacks = {}; @@ -207,6 +219,6 @@ var UIWorkerClient = function(topLevelNamespaces, mod, classname) { UIWorkerClient.prototype = WorkerClient.prototype; exports.UIWorkerClient = UIWorkerClient; -exports.WorkerClient = WorkerClient; +exports.WorkerClient = UIWorkerClient; });