UndoFilter

ammonite.terminal.filters.UndoFilter
See theUndoFilter companion object
case class UndoFilter(maxUndo: Int) extends DelegateFilter

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!

Attributes

maxUndo:

the maximum number of undo-frames that are stored.

Companion:
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Filter
class Object
trait Matchable
class Any

Members list

Concise view

Value members

Concrete methods

def currentUndo: (Vector[Char], Int)
def pushUndos(b: Vector[Char], c: Int): Unit
def redo(b: Vector[Char], c: Int): (Vector[Char], Int, Str)
def undo(b: Vector[Char], c: Int): (Vector[Char], Int, Str)
def wrap(bc: (Vector[Char], Int, Str), rest: LazyList[Int]): TermState

Inherited methods

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.

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.

Attributes

Inherited from:
DelegateFilter
def op(ti: TermInfo): Option[TermAction]

Attributes

Inherited from:
DelegateFilter
def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product
override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns:

a string representation of the object.

Definition Classes
Filter -> Any
Inherited from:
Filter

Concrete fields

An enum representing what the user is "currently" doing. Used to collapse sequential actions into one undo step: e.g. 10 plain 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

An enum representing what the user is "currently" doing. Used to collapse sequential actions into one undo step: e.g. 10 plain 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

Attributes

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

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

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.

Attributes

var undoIndex: Int

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

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

Attributes

Implicits

Inherited implicits

implicit val enclosing: Enclosing

Attributes

Inherited from:
DelegateFilter