Compare commits

...
Sign in to create a new pull request.

10 commits

Author SHA1 Message Date
Sergi Mansilla
ab70b55316 Added Droid Sans Mono as the first font to use by mobile Ace 2011-02-28 14:24:38 +01:00
Sergi Mansilla
fbdfaaf0fc Stop trying to use workers and word highlighting. 2011-02-28 12:33:12 +01:00
Sergi Mansilla
1d05dc78be Forgot to include a require for pilot/useragent 2011-02-27 19:38:22 +01:00
Sergi Mansilla
0ca1e2cf2d Fixed cursor positioning 2011-02-27 19:25:15 +01:00
Sergi Mansilla
1b8ea9a48e Merge branch 'master' into mobile 2011-02-27 12:48:14 +01:00
Sergi Mansilla
4315fd36cf Merge branch 'master' of github.com:ajaxorg/ace 2011-02-27 12:47:56 +01:00
Sergi Mansilla
b3b26a311b Merge branch 'master' of github.com:ajaxorg/ace into mobile 2011-02-27 12:45:08 +01:00
Sergi Mansilla
ff7c1b5182 |pollSizeChanges| is called only on resize, not every 500ms 2011-02-27 12:44:43 +01:00
Sergi Mansilla
c50a765176 Avoid polling for font size changes every 500ms 2011-02-25 17:03:00 +01:00
Sergi Mansilla
fcc37e2068 Avoid polling every 500ms for font size changes 2011-02-25 16:53:02 +01:00
7 changed files with 92 additions and 64 deletions

View file

@ -2,8 +2,8 @@
position: absolute; position: absolute;
overflow: hidden; overflow: hidden;
font-family: "Menlo", "Monaco", "Courier New", monospace; font-family: "Droid Sans Mono", "Monaco", "Courier New", monospace;
font-size: 12px; font-size: 16px;
} }
.ace_scroller { .ace_scroller {
@ -97,7 +97,7 @@
} }
.ace_text-layer { .ace_text-layer {
font-family: Monaco, "Courier New", monospace; font-family: "Droid Sans Mono", Monaco, "Courier New", monospace;
color: black; color: black;
} }

View file

@ -344,7 +344,7 @@ var EditSession = function(text, mode) {
return this.doc.getNewLineMode(); return this.doc.getNewLineMode();
}; };
this.$useWorker = true; this.$useWorker = false;
this.setUseWorker = function(useWorker) { this.setUseWorker = function(useWorker) {
if (this.$useWorker == useWorker) if (this.$useWorker == useWorker)
return; return;

View file

@ -206,6 +206,7 @@ var Editor =function(renderer, session) {
this.resize = function() { this.resize = function() {
this.renderer.onResize(); this.renderer.onResize();
this.renderer.$textLayer.$pollSizeChanges();
}; };
this.setTheme = function(theme) { this.setTheme = function(theme) {
@ -528,7 +529,7 @@ var Editor =function(renderer, session) {
return this.$highlightActiveLine; return this.$highlightActiveLine;
}; };
this.$highlightSelectedWord = true; this.$highlightSelectedWord = false;
this.setHighlightSelectedWord = function(shouldHighlight) { this.setHighlightSelectedWord = function(shouldHighlight) {
if (this.$highlightSelectedWord == shouldHighlight) if (this.$highlightSelectedWord == shouldHighlight)
return; return;

View file

@ -46,6 +46,13 @@ var TextInput = function(parentNode, host) {
var text = dom.createElement("textarea"); var text = dom.createElement("textarea");
text.style.left = "-10000px"; 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); parentNode.appendChild(text);
var PLACEHOLDER = String.fromCharCode(0); var PLACEHOLDER = String.fromCharCode(0);

View file

@ -40,6 +40,7 @@
define(function(require, exports, module) { define(function(require, exports, module) {
var dom = require("pilot/dom"); var dom = require("pilot/dom");
var useragent = require("pilot/useragent");
var Cursor = function(parentEl) { var Cursor = function(parentEl) {
this.element = dom.createElement("div"); this.element = dom.createElement("div");
@ -68,7 +69,9 @@ var Cursor = function(parentEl) {
this.showCursor = function() { this.showCursor = function() {
this.isVisible = true; this.isVisible = true;
this.element.appendChild(this.cursor); if (!useragent.isIPad)
this.element.appendChild(this.cursor);
var cursor = this.cursor; var cursor = this.cursor;
cursor.style.visibility = "visible"; cursor.style.visibility = "visible";
@ -120,7 +123,7 @@ var Cursor = function(parentEl) {
this.cursor.style.width = config.characterWidth + "px"; this.cursor.style.width = config.characterWidth + "px";
this.cursor.style.height = config.lineHeight + "px"; this.cursor.style.height = config.lineHeight + "px";
if (this.isVisible) { if (this.isVisible && !useragent.isIPad) {
this.element.appendChild(this.cursor); this.element.appendChild(this.cursor);
} }

View file

@ -1,4 +1,5 @@
/* vim:ts=4:sts=4:sw=4: /* vim:ts=4:sts=4:sw=4:
*
* ***** BEGIN LICENSE BLOCK ***** * ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
* *
@ -77,13 +78,13 @@ var Text = function(parentEl) {
this.$pollSizeChanges = function() { this.$pollSizeChanges = function() {
var self = this; var self = this;
setInterval(function() { //setInterval(function() {
var size = self.$measureSizes(); var size = self.$measureSizes();
if (self.$characterSize.width !== size.width || self.$characterSize.height !== size.height) { if (self.$characterSize.width !== size.width || self.$characterSize.height !== size.height) {
self.$characterSize = size; self.$characterSize = size;
self._dispatchEvent("changeCharaterSize", {data: size}); self._dispatchEvent("changeCharaterSize", {data: size});
} }
}, 500); //}, 500);
}; };
this.$fontStyles = { this.$fontStyles = {

View file

@ -319,23 +319,39 @@ var VirtualRenderer = function(container, theme) {
}; };
this.getTextAreaContainer = function() { 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) { this.moveTextAreaToCursor = function(textarea) {
// in IE the native cursor always shines through if (!this.layerConfig)
if (useragent.isIE)
return; return;
var pos = this.$cursorLayer.getPixelPosition(); var pos, left, top;
if (!pos) if (useragent.isIPad) {
return; pos = this.$cursorLayer.getPixelPosition(true);
if (!pos)
return;
var bounds = this.content.getBoundingClientRect(); left = pos.left + this.$padding - 3;
var offset = (this.layerConfig && this.layerConfig.offset) || 0; top = pos.top;
} else {
pos = this.$cursorLayer.getPixelPosition();
if (!pos)
return;
textarea.style.left = (bounds.left + pos.left + this.$padding) + "px"; var bounds = this.content.getBoundingClientRect();
textarea.style.top = (bounds.top + pos.top - this.scrollTop + offset) + "px"; 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() { this.getFirstVisibleRow = function() {