let the document act as anchor factory

This commit is contained in:
Fabian Jakobs 2011-02-17 16:11:03 +01:00
commit 8e3c1e6096
2 changed files with 7 additions and 3 deletions

View file

@ -40,6 +40,7 @@ define(function(require, exports, module) {
var oop = require("pilot/oop");
var EventEmitter = require("pilot/event_emitter").EventEmitter;
var Range = require("ace/range").Range;
var Anchor = require("ace/anchor").Anchor;
var Document = function(text) {
this.$lines = [];
@ -69,6 +70,10 @@ var Document = function(text) {
this.getValue = function() {
return this.getAllLines().join(this.getNewLineCharacter());
};
this.createAnchor = function(row, column) {
return new Anchor(this, row, column);
};
// check for IE split bug
if ("aaa".split(/a/).length == 0)

View file

@ -42,15 +42,14 @@ var oop = require("pilot/oop");
var lang = require("pilot/lang");
var EventEmitter = require("pilot/event_emitter").EventEmitter;
var Range = require("ace/range").Range;
var Anchor = require("ace/anchor").Anchor;
var Selection = function(session) {
this.session = session;
this.doc = session.getDocument();
this.clearSelection();
this.selectionLead = new Anchor(this.doc, 0, 0);
this.selectionAnchor = new Anchor(this.doc, 0, 0);
this.selectionLead = this.doc.createAnchor(0, 0);
this.selectionAnchor = this.doc.createAnchor(0, 0);
var _self = this;
this.selectionLead.on("change", function(e) {