fix undoManager wip

This commit is contained in:
nightwing 2012-08-31 12:44:00 +04:00
commit 4c3519de29
5 changed files with 19 additions and 15 deletions

View file

@ -246,7 +246,6 @@ var EditSession = function(text, mode) {
this.selection.clearSelection();
this.$resetRowCache(0);
this.$deltas = [];
this.$deltasDoc = [];
this.$deltasFold = [];
this.getUndoManager().reset();
@ -343,7 +342,6 @@ var EditSession = function(text, mode) {
**/
this.setUndoManager = function(undoManager) {
this.$undoManager = undoManager;
this.$deltas = [];
this.$deltasDoc = [];
this.$deltasFold = [];
@ -358,10 +356,9 @@ var EditSession = function(text, mode) {
*
**/
this.$syncInformUndoManager = function() {
self.$informUndoManager.cancel();
var $deltas = [];
if (self.$deltasFold.length) {
self.$deltas.push({
$deltas.push({
group: "fold",
deltas: self.$deltasFold
});
@ -369,17 +366,17 @@ var EditSession = function(text, mode) {
}
if (self.$deltasDoc.length) {
self.$deltas.push({
$deltas.push({
group: "doc",
deltas: self.$deltasDoc
});
self.$deltasDoc = [];
}
if (self.$deltas.length > 0) {
if ($deltas.length > 0) {
undoManager.execute({
action: "aceupdate",
args: [self.$deltas, self]
args: [$deltas, self]
});
}

View file

@ -84,12 +84,13 @@ var Editor = function(renderer, session) {
this.keyBinding = new KeyBinding(this);
// TODO detect touch event support
if (useragent.isIPad) {
/* if (useragent.isIPad) {
//this.$mouseHandler = new TouchHandler(this);
} else {
this.$mouseHandler = new MouseHandler(this);
new FoldHandler(this);
}
} */
this.$mouseHandler = new MouseHandler(this);
new FoldHandler(this);
this.$blockScrolling = 0;
this.$search = new Search().set({
@ -689,6 +690,10 @@ var Editor = function(renderer, session) {
this._emit("paste", text);
this.insert(text);
};
this.execCommand = function(cmd, args) {
return this.commands.exec(cmd, this, args);
};
/**
* Editor.insert(text)

View file

@ -145,7 +145,7 @@ var TextInput = function(parentNode, host) {
var copyText = host.getCopyText();
if(copyText) {
text.value = copyText;
host.onCopy(copyText);
host.execCommand("copy", copyText);
} else
e.preventDefault();
reset();
@ -159,7 +159,7 @@ var TextInput = function(parentNode, host) {
var copyText = host.getCopyText();
if(copyText) {
text.value = copyText;
host.onCut(copyText);
host.execCommand("cut", copyText);
} else
e.preventDefault();
reset();

View file

@ -62,7 +62,7 @@ var MouseHandler = function(editor) {
var mouseTarget = editor.renderer.getMouseEventTarget();
event.addListener(mouseTarget, "click", this.onMouseEvent.bind(this, "click"));
event.addListener(mouseTarget, "mousemove", this.onMouseMove.bind(this, "mousemove"));
event.addMultiMouseDownListener(mouseTarget, [300, 300, 250], this, "onMouseEvent");
event.addMultiMouseDownListener(mouseTarget, [350, 300, 250], this, "onMouseEvent");
event.addMouseWheelListener(editor.container, this.onMouseWheel.bind(this, "mousewheel"));
var gutterEl = editor.renderer.$gutter;

View file

@ -82,6 +82,7 @@ var UndoManager = function() {
* [Perform an undo operation on the document, reverting the last change. Returns the range of the undo.]{: #UndoManager.undo}
**/
this.undo = function(dontSelect) {
this.$doc.$syncInformUndoManager();
var deltas = this.$undoStack.pop();
var undoSelectionRange = null;
if (deltas) {
@ -99,6 +100,7 @@ var UndoManager = function() {
* [Perform a redo operation on the document, reimplementing the last change.]{: #UndoManager.redo}
**/
this.redo = function(dontSelect) {
this.$doc.$syncInformUndoManager();
var deltas = this.$redoStack.pop();
var redoSelectionRange = null;
if (deltas) {