Permalink
Browse files

fix undoManager wip

  • Loading branch information...
1 parent 6ef0ef3 commit 4c3519de29b92bc202f8adcbd598c6c2a5939788 @nightwing nightwing committed Aug 31, 2012
Showing with 19 additions and 15 deletions.
  1. +5 −8 lib/ace/edit_session.js
  2. +9 −4 lib/ace/editor.js
  3. +2 −2 lib/ace/keyboard/textinput.js
  4. +1 −1 lib/ace/mouse/mouse_handler.js
  5. +2 −0 lib/ace/undomanager.js
View
@@ -246,7 +246,6 @@ var EditSession = function(text, mode) {
this.selection.clearSelection();
this.$resetRowCache(0);
- this.$deltas = [];
rogeliomr
rogeliomr Jan 8, 2015

activate my account

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,28 +356,27 @@ 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
});
self.$deltasFold = [];
}
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
@@ -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)
@@ -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();
@@ -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
@@ -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) {

0 comments on commit 4c3519d

Please sign in to comment.