Dotty Documentation

0.4.0-bin-SNAPSHOT

case class UndoFilter
extends DelegateFilter with Product

A filter that implements "undo" functionality in the ammonite REPL. It shares the same Ctrl - hotkey that the bash undo, but shares behavior with the undo behavior in desktop text editors:

  • Multiple deletes in a row get collapsed
  • In addition to edits you can undo cursor movements: undo will bring your cursor back to location of previous edits before it undoes them
  • Provides "redo" functionality under Alt -/Esc -: un-undo the things you didn't actually want to undo!

[-] Constructors

UndoFilter ( maxUndo: Int )

[-] Members

[+] val maxUndo : Int
[+] var state : UndoState

An enum representing what the user is "currently" doing. Used to collapse sequential actions into one undo step: e.g. 10 plai chars typed becomes 1 undo step, or 10 chars deleted becomes one undo step, but 4 chars typed followed by 3 chars deleted followed by 3 chars typed gets grouped into 3 different undo steps

[+] val undoBuffer : Buffer [ ( Vector [ Char ], Int ) ]

The current stack of states that undo/redo would cycle through.

Not really the appropriate data structure, since when it reaches maxUndo in length we remove one element from the start whenever we append one element to the end, which costs O(n). On the other hand, It also costs O(n) to maintain the buffer of previous states, and so n is probably going to be pretty small anyway (tens?) so O(n) is perfectly fine.

[+] var undoIndex : Int

The current position in the undoStack that the terminal is currently in.

[+] def currentUndo : A
[+] def filter : Filter
[+] def identifier : String

the .toString of this object, except by making it separate we force the implementer to provide something and stop them from accidentally leaving it as the meaningless default.

[+] def pushUndos ( b: Vector [ Char ] , c: Int ) : Unit
[+] def redo ( b: Vector [ Char ] , c: Int ) : ( Vector [ Char ], Int, Str )
[+] def state_= ( x$1: UndoState ) : Unit

An enum representing what the user is "currently" doing. Used to collapse sequential actions into one undo step: e.g. 10 plai chars typed becomes 1 undo step, or 10 chars deleted becomes one undo step, but 4 chars typed followed by 3 chars deleted followed by 3 chars typed gets grouped into 3 different undo steps

[+] def undo ( b: Vector [ Char ] , c: Int ) : ( Vector [ Char ], Int, Str )
[+] def undoIndex_= ( x$1: Int ) : Unit

The current position in the undoStack that the terminal is currently in.

[+] def wrap ( bc: ( Vector [ Char ], Int, Str ) , rest: LazyList [ Int ] ) : TermState