Code Monkey home page Code Monkey logo

undo-experiment-2's Introduction

Undo experiment 2

This project is an experiment to implement the ideas described here:

https://github.com/zaboople/klonk/blob/master/TheGURQ.md

The application is a simple grid that the user can "edit". Edit operations include:

  1. Writing a character to a cell.
  2. Insert a row/column.
  3. Delete a row/column.
  4. Undo the last edit operation (using Ctrl-z).
  5. Redo the last undo (using Ctrl-y).

The user can move a cursor using the arrow keys. Cursor moves are not undoable.

The experiment aims to demonstrate a method for implementing undo/redo that is easy for users to understand and allows them to return to any previous state, regardless of the undo/redo actions taken. This is different from traditional undo methods, where it can be difficult to recover a previous state if an action is taken after undoing.

Undoing user operations

I tried two different approaches to undoing individual user operations. Hence there are two undo experiments (in separate GitHub repos). The two approaches are:

Undo experiment 1

Take a copy of the current grid state before making any changes. To undo the operation, revert to the stored copy.

While this may seem like it would use a lot of memory, I can use immutable data and take advantage of "structural sharing" to avoid multiple copies of parts of the state that do not change.

For the purpose of this experiment, the data representation I use is not optimized for structural sharing, but it's fine as a proof of concept.

Undo experiment 2 (this repo)

For each possible operation that changes the grid state, calculate the sequence of operations needed to restore the original grid state. This should be more efficient than approach 1 in terms of memory usage. However, it is more complicated to implement, and it's easy to make a mistake in undo calculation, so that undo does not restore the state correctly.

I am more familar with approach 2. I'm not sure how well approach 1 would scale in a "real" application.

undo-experiment-2's People

Contributors

kdemoore avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.