pull back changes from cloud9

This commit is contained in:
nightwing 2013-07-02 11:39:03 +04:00
commit 1400d82d34
8 changed files with 31 additions and 35 deletions

View file

@ -52,15 +52,13 @@ var EventEmitter = require("./lib/event_emitter").EventEmitter;
**/ **/
var Anchor = exports.Anchor = function(doc, row, column) { var Anchor = exports.Anchor = function(doc, row, column) {
this.document = doc; this.$onChange = this.onChange.bind(this);
this.attach(doc);
if (typeof column == "undefined") if (typeof column == "undefined")
this.setPosition(row.row, row.column); this.setPosition(row.row, row.column);
else else
this.setPosition(row, column); this.setPosition(row, column);
this.$onChange = this.onChange.bind(this);
doc.on("change", this.$onChange);
}; };
(function() { (function() {
@ -71,7 +69,6 @@ var Anchor = exports.Anchor = function(doc, row, column) {
* Returns an object identifying the `row` and `column` position of the current anchor. * Returns an object identifying the `row` and `column` position of the current anchor.
* @returns {Object} * @returns {Object}
**/ **/
this.getPosition = function() { this.getPosition = function() {
return this.$clipPositionToDocument(this.row, this.column); return this.$clipPositionToDocument(this.row, this.column);
}; };
@ -81,7 +78,6 @@ var Anchor = exports.Anchor = function(doc, row, column) {
* Returns the current document. * Returns the current document.
* @returns {Document} * @returns {Document}
**/ **/
this.getDocument = function() { this.getDocument = function() {
return this.document; return this.document;
}; };
@ -98,9 +94,7 @@ var Anchor = exports.Anchor = function(doc, row, column) {
* - `old`: An object describing the old Anchor position * - `old`: An object describing the old Anchor position
* - `value`: An object describing the new Anchor position * - `value`: An object describing the new Anchor position
* *
*
**/ **/
this.onChange = function(e) { this.onChange = function(e) {
var delta = e.data; var delta = e.data;
var range = delta.range; var range = delta.range;
@ -122,6 +116,7 @@ var Anchor = exports.Anchor = function(doc, row, column) {
if (delta.action === "insertText") { if (delta.action === "insertText") {
if (start.row === row && start.column <= column) { if (start.row === row && start.column <= column) {
if (start.row === end.row) { if (start.row === end.row) {
//if (start.column == column)
column += end.column - start.column; column += end.column - start.column;
} else { } else {
column -= start.column; column -= start.column;
@ -169,10 +164,7 @@ var Anchor = exports.Anchor = function(doc, row, column) {
* @param {Number} column The column index to move the anchor to * @param {Number} column The column index to move the anchor to
* @param {Boolean} noClip Identifies if you want the position to be clipped * @param {Boolean} noClip Identifies if you want the position to be clipped
* *
*
*
**/ **/
this.setPosition = function(row, column, noClip) { this.setPosition = function(row, column, noClip) {
var pos; var pos;
if (noClip) { if (noClip) {
@ -204,10 +196,13 @@ var Anchor = exports.Anchor = function(doc, row, column) {
* When called, the `'change'` event listener is removed. * When called, the `'change'` event listener is removed.
* *
**/ **/
this.detach = function() { this.detach = function() {
this.document.removeEventListener("change", this.$onChange); this.document.removeEventListener("change", this.$onChange);
}; };
this.attach = function(doc) {
this.document = doc || this.document;
this.document.on("change", this.$onChange);
};
/** /**
* Clips the anchor position to the specified row and column. * Clips the anchor position to the specified row and column.

View file

@ -395,8 +395,8 @@ exports.commands = [{
}, { }, {
name: "backspace", name: "backspace",
bindKey: bindKey( bindKey: bindKey(
"Command-Backspace|Option-Backspace|Shift-Backspace|Backspace", "Shift-Backspace|Backspace",
"Ctrl-Backspace|Command-Backspace|Shift-Backspace|Backspace|Ctrl-H" "Ctrl-Backspace|Shift-Backspace|Backspace|Ctrl-H"
), ),
exec: function(editor) { editor.remove("left"); }, exec: function(editor) { editor.remove("left"); },
multiSelectAction: "forEach" multiSelectAction: "forEach"

View file

@ -212,7 +212,7 @@ var Document = function(text) {
**/ **/
this.getTextRange = function(range) { this.getTextRange = function(range) {
if (range.start.row == range.end.row) { if (range.start.row == range.end.row) {
return this.$lines[range.start.row] return this.getLine(range.start.row)
.substring(range.start.column, range.end.column); .substring(range.start.column, range.end.column);
} }
var lines = this.getLines(range.start.row, range.end.row); var lines = this.getLines(range.start.row, range.end.row);

View file

@ -174,7 +174,7 @@ var Gutter = function(parentEl) {
var gutterWidth = ("" + lastLineNumber).length * config.characterWidth; var gutterWidth = ("" + lastLineNumber).length * config.characterWidth;
var padding = this.$padding || this.$computePadding(); var padding = this.$padding || this.$computePadding();
gutterWidth += padding.left + padding.right; gutterWidth += padding.left + padding.right;
if (gutterWidth !== this.gutterWidth) { if (gutterWidth !== this.gutterWidth && !isNaN(gutterWidth)) {
this.gutterWidth = gutterWidth; this.gutterWidth = gutterWidth;
this.element.style.width = Math.ceil(this.gutterWidth) + "px"; this.element.style.width = Math.ceil(this.gutterWidth) + "px";
this._emit("changeGutterWidth", gutterWidth); this._emit("changeGutterWidth", gutterWidth);
@ -200,9 +200,9 @@ var Gutter = function(parentEl) {
if (!this.element.firstChild) if (!this.element.firstChild)
return {left: 0, right: 0}; return {left: 0, right: 0};
var style = dom.computedStyle(this.element.firstChild); var style = dom.computedStyle(this.element.firstChild);
this.$padding = {} this.$padding = {};
this.$padding.left = parseInt(style.paddingLeft) + 1; this.$padding.left = parseInt(style.paddingLeft) + 1 || 0;
this.$padding.right = parseInt(style.paddingRight); this.$padding.right = parseInt(style.paddingRight) || 0;
return this.$padding; return this.$padding;
}; };

View file

@ -13,10 +13,6 @@
color: #FFFFFF color: #FFFFFF
} }
.ace-idle-fingers .ace_text-layer {
color: #FFFFFF
}
.ace-idle-fingers .ace_cursor { .ace-idle-fingers .ace_cursor {
border-left: 2px solid #91FF00 border-left: 2px solid #91FF00
} }

View file

@ -14,8 +14,7 @@
} }
.ace-solarized-dark .ace_entity.ace_other.ace_attribute-name, .ace-solarized-dark .ace_entity.ace_other.ace_attribute-name,
.ace-solarized-dark .ace_storage, .ace-solarized-dark .ace_storage {
.ace-solarized-dark .ace_text-layer {
color: #93A1A1 color: #93A1A1
} }

View file

@ -33,7 +33,6 @@ define(function(require, exports, module) {
var oop = require("./lib/oop"); var oop = require("./lib/oop");
var dom = require("./lib/dom"); var dom = require("./lib/dom");
var event = require("./lib/event");
var useragent = require("./lib/useragent"); var useragent = require("./lib/useragent");
var config = require("./config"); var config = require("./config");
var GutterLayer = require("./layer/gutter").Gutter; var GutterLayer = require("./layer/gutter").Gutter;
@ -159,7 +158,7 @@ var VirtualRenderer = function(container, theme) {
bottom: 0, bottom: 0,
v: 0, v: 0,
h: 0 h: 0
} };
this.$loop = new RenderLoop( this.$loop = new RenderLoop(
this.$renderChanges.bind(this), this.$renderChanges.bind(this),
@ -311,7 +310,7 @@ var VirtualRenderer = function(container, theme) {
this.onResize = function(force, gutterWidth, width, height) { this.onResize = function(force, gutterWidth, width, height) {
if (this.resizing > 2) if (this.resizing > 2)
return; return;
else if (this.resizing > 1) else if (this.resizing > 0)
this.resizing++; this.resizing++;
else else
this.resizing = force ? 1 : 0; this.resizing = force ? 1 : 0;
@ -338,7 +337,7 @@ var VirtualRenderer = function(container, theme) {
}; };
this.$updateCachedSize = function(force, gutterWidth, width, height) { this.$updateCachedSize = function(force, gutterWidth, width, height) {
var changes = this.$changes || 0; var changes = 0;
var size = this.$size; var size = this.$size;
if (height && (force || size.height != height)) { if (height && (force || size.height != height)) {
size.height = height; size.height = height;
@ -360,7 +359,7 @@ var VirtualRenderer = function(container, theme) {
changes = this.CHANGE_SIZE; changes = this.CHANGE_SIZE;
size.width = width; size.width = width;
var gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0; gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0;
this.scrollBarH.element.style.left = this.scrollBarH.element.style.left =
this.scroller.style.left = gutterWidth + "px"; this.scroller.style.left = gutterWidth + "px";
size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBarV.getWidth()); size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBarV.getWidth());
@ -373,11 +372,19 @@ var VirtualRenderer = function(container, theme) {
if (this.session && this.session.getUseWrapMode() && this.adjustWrapLimit() || force) if (this.session && this.session.getUseWrapMode() && this.adjustWrapLimit() || force)
changes = changes | this.CHANGE_FULL; changes = changes | this.CHANGE_FULL;
} }
if (changes)
this._signal("resize");
if (this.$changes) {
changes |= this.$changes;
this.$changes = 0;
}
return changes; return changes;
}; };
this.onGutterResize = function() { this.onGutterResize = function() {
var width = this.$size.width;
var gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0; var gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0;
this.$updateCachedSize(true, gutterWidth, this.$size.width, this.$size.height); this.$updateCachedSize(true, gutterWidth, this.$size.width, this.$size.height);

View file

@ -88,10 +88,9 @@ window.define = function(id, deps, factory) {
}; };
require.modules[id] = { require.modules[id] = {
exports: {},
factory: function() { factory: function() {
var module = { var module = this;
exports: {}
};
var returnExports = factory(req, module.exports, module); var returnExports = factory(req, module.exports, module);
if (returnExports) if (returnExports)
module.exports = returnExports; module.exports = returnExports;