diff --git a/lib/ace/css/editor.css b/lib/ace/css/editor.css index 06bc87b9..6d94ba83 100644 --- a/lib/ace/css/editor.css +++ b/lib/ace/css/editor.css @@ -2,14 +2,14 @@ position: absolute; overflow: hidden; - font-family: "Menlo", "Monaco", "Courier New", monospace; - font-size: 12px; + font-family: "Droid Sans Mono", "Monaco", "Courier New", monospace; + font-size: 16px; } .ace_scroller { position: absolute; overflow-x: scroll; - overflow-y: hidden; + overflow-y: hidden; } .ace_content { @@ -90,14 +90,14 @@ .ace_layer { z-index: 1; position: absolute; - overflow: hidden; + overflow: hidden; white-space: nowrap; height: 100%; width: 100%; } .ace_text-layer { - font-family: Monaco, "Courier New", monospace; + font-family: "Droid Sans Mono", Monaco, "Courier New", monospace; color: black; } diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index 6c33c449..5a886b63 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -344,20 +344,20 @@ var EditSession = function(text, mode) { return this.doc.getNewLineMode(); }; - this.$useWorker = true; + this.$useWorker = false; this.setUseWorker = function(useWorker) { if (this.$useWorker == useWorker) return; - + if (useWorker && !this.$worker && window.Worker) this.$worker = mode.createWorker(this); - + if (!useWorker && this.$worker) { this.$worker.terminate(); this.$worker = null; } }; - + this.getUseWorker = function() { return this.$useWorker; }; @@ -601,7 +601,7 @@ var EditSession = function(text, mode) { var actions = [{}]; - + // collapse insert and remove operations for (var i=0; i= 0; --i) this.$tryReplace(ranges[i], replacement); - + this.selection.setSelectionRange(selection); this.$blockScrolling -= 1; }, diff --git a/lib/ace/keyboard/textinput.js b/lib/ace/keyboard/textinput.js index 2ecb1b6e..b793a280 100644 --- a/lib/ace/keyboard/textinput.js +++ b/lib/ace/keyboard/textinput.js @@ -46,6 +46,13 @@ var TextInput = function(parentNode, host) { var text = dom.createElement("textarea"); text.style.left = "-10000px"; + // We have too many moving parts in the iPad, so we set the text + // positioning to absolute to be able to calculate the precise position for + // cursor. Otherwise the cursor position would be relative to the screen + // coordinates (position: fixed). + if (useragent.isIPad) + text.style.position = "absolute"; + parentNode.appendChild(text); var PLACEHOLDER = String.fromCharCode(0); @@ -164,7 +171,7 @@ var TextInput = function(parentNode, host) { }; if (useragent.isIE) { - event.addListener(text, "beforecopy", function(e) { + event.addListener(text, "beforecopy", function(e) { var copyText = host.getCopyText(); if(copyText) clipboardData.setData("Text", copyText); diff --git a/lib/ace/layer/cursor.js b/lib/ace/layer/cursor.js index a1cd4698..4bdf012a 100644 --- a/lib/ace/layer/cursor.js +++ b/lib/ace/layer/cursor.js @@ -40,6 +40,7 @@ define(function(require, exports, module) { var dom = require("pilot/dom"); +var useragent = require("pilot/useragent"); var Cursor = function(parentEl) { this.element = dom.createElement("div"); @@ -68,7 +69,9 @@ var Cursor = function(parentEl) { this.showCursor = function() { this.isVisible = true; - this.element.appendChild(this.cursor); + if (!useragent.isIPad) + this.element.appendChild(this.cursor); + var cursor = this.cursor; cursor.style.visibility = "visible"; @@ -120,16 +123,16 @@ var Cursor = function(parentEl) { this.cursor.style.width = config.characterWidth + "px"; this.cursor.style.height = config.lineHeight + "px"; - if (this.isVisible) { + if (this.isVisible && !useragent.isIPad) { this.element.appendChild(this.cursor); } - + if (this.session.getOverwrite()) { dom.addCssClass(this.cursor, "ace_overwrite"); } else { dom.removeCssClass(this.cursor, "ace_overwrite"); } - + this.restartTimer(); }; diff --git a/lib/ace/layer/text.js b/lib/ace/layer/text.js index 84d2d2ec..f78bbc46 100644 --- a/lib/ace/layer/text.js +++ b/lib/ace/layer/text.js @@ -1,4 +1,5 @@ /* vim:ts=4:sts=4:sw=4: + * * ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -77,13 +78,13 @@ var Text = function(parentEl) { this.$pollSizeChanges = function() { var self = this; - setInterval(function() { + //setInterval(function() { var size = self.$measureSizes(); if (self.$characterSize.width !== size.width || self.$characterSize.height !== size.height) { self.$characterSize = size; self._dispatchEvent("changeCharaterSize", {data: size}); } - }, 500); + //}, 500); }; this.$fontStyles = { diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index 0027d18c..385348d8 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -277,7 +277,7 @@ var VirtualRenderer = function(container, theme) { this.getPrintMarginColumn = function() { return this.$printMarginColumn; }; - + this.getShowGutter = function(){ return this.showGutter; } @@ -319,23 +319,39 @@ var VirtualRenderer = function(container, theme) { }; this.getTextAreaContainer = function() { - return this.container; + // Let's make it play nice wit iPad. Otherwise the default padding of + // the container will make the cursor shift to the left. + return useragent.isIPad ? this.content : this.container; + }; this.moveTextAreaToCursor = function(textarea) { - // in IE the native cursor always shines through - if (useragent.isIE) + if (!this.layerConfig) return; - var pos = this.$cursorLayer.getPixelPosition(); - if (!pos) - return; + var pos, left, top; + if (useragent.isIPad) { + pos = this.$cursorLayer.getPixelPosition(true); + if (!pos) + return; - var bounds = this.content.getBoundingClientRect(); - var offset = (this.layerConfig && this.layerConfig.offset) || 0; + left = pos.left + this.$padding - 3; + top = pos.top; + } else { + pos = this.$cursorLayer.getPixelPosition(); + if (!pos) + return; - textarea.style.left = (bounds.left + pos.left + this.$padding) + "px"; - textarea.style.top = (bounds.top + pos.top - this.scrollTop + offset) + "px"; + var bounds = this.content.getBoundingClientRect(); + var offset = this.layerConfig.offset; + + left = bounds.left + pos.left + this.$padding; + top = bounds.top + pos.top - this.scrollTop + offset; + } + + textarea.style.left = left + "px"; + textarea.style.top = top + "px"; + textarea.style.lineHeight = this.layerConfig.lineHeight + "px"; }; this.getFirstVisibleRow = function() { @@ -592,7 +608,7 @@ var VirtualRenderer = function(container, theme) { // the editor is not visible if (this.$size.scrollerHeight === 0) return; - + var pos = this.$cursorLayer.getPixelPosition(); var left = pos.left + this.$padding; @@ -646,7 +662,7 @@ var VirtualRenderer = function(container, theme) { for (var l = 1; l < line; l++) { offset += this.session.getRowHeight(lineHeight, l-1); } - + if (center) { offset -= this.$size.scrollerHeight / 2; }