Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Unified Diff: samples/total/client/UndoStack.dart

Issue 10635015: Delete proxy and total samples, which have bit-rotted. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samples/total/client/TotalLib.dart ('k') | samples/total/client/UndoableAction.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/total/client/UndoStack.dart
===================================================================
--- samples/total/client/UndoStack.dart (revision 9011)
+++ samples/total/client/UndoStack.dart (working copy)
@@ -1,70 +0,0 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-/**
- * A stack of [Command]s with a current position that supports [execute], [undo], and [redo]
- * methods. Calling [execute] destroys any previously "undone" commands beyond the current
- * position. Attempting to undo beyond the first command or redo beyond the last command are
- * treated as no-ops.
- */
-class UndoStack {
-
- int _undoPosition;
- List<Command> _undoStack;
-
- UndoStack() {
- this._undoStack = new List<Command>();
- this._undoPosition = -1;
- }
-
- /**
- * Return [:true:] if there is a command on the stack that can be "redone."
- */
- bool canRedo() => _undoPosition < _undoStack.length - 1;
-
- /**
- * Return [:true:] if there is a command on the stack that can be "undone."
- */
- bool canUndo() => _undoPosition >= 0;
-
- /**
- * Execute a command and make it the next "undoable" command.
- * Any commands that have previously been "undone" will be removed from the stack.
- */
- void execute(Command command) {
- int pos = ++_undoPosition;
- if (pos == _undoStack.length) {
- _undoStack.add(command);
- } else {
- _undoStack[pos] = command;
- // Remove susequent commands on the stack
- _undoStack.length = pos + 1;
- }
- command.execute();
- }
-
- /**
- * Redo the most recently "undone" command, or do nothing if there is none.
- */
- void redo() {
- if (_undoPosition < _undoStack.length - 1) {
- ++_undoPosition;
- Command command = _undoStack[_undoPosition];
- print("Redo ${command.description}");
- command.execute();
- }
- }
-
- /**
- * Undo the most recent command, or do nothing if there is none.
- */
- void undo() {
- if (_undoPosition >= 0) {
- Command command = _undoStack[_undoPosition];
- _undoPosition--;
- print("Undo ${command.description}");
- command.unexecute();
- }
- }
-}
« no previous file with comments | « samples/total/client/TotalLib.dart ('k') | samples/total/client/UndoableAction.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698