class

Fancyline::History

Inherits Reference / Object

Manages the input history

Constants

DEFAULT_IGNORE_PREFIX = " "

Default ignore prefix

DEFAULT_MAX_SIZE = 1000

Default value of maximum history size

Constructors

new(max : Int32 = DEFAULT_MAX_SIZE)
Source

Instance methods

add(line : String | Nil) : Bool

Adds line to the history, except if:

  • line is nil
  • line is empty
  • line only consists of blank characters
  • line starts with the #ignore_prefix
  • line matches the most recent entry in the history

Returns true if the line was added.

Source
ignore?(line : String | Nil)

Returns true if line should be ignored. See #add for all rules.

Source
ignore_prefix

If a line to add starts with this string, it's not recorded.

Source
ignore_prefix=(ignore_prefix : String)

If a line to add starts with this string, it's not recorded.

Source
lines

Lines in the history. The first entry is the oldest. Maximum size can be controlled through #max=

Source
load(io : IO)

Replaces the current history with the lines from io. io is read till the end, with later lines representing more-recent history entries.

Source
max

Max count of history entries to keep

Source
max=(max : Int32)

Max count of history entries to keep

Source
save(io : IO)

Writes the history into io.

Source