class Fancyline::History

Overview

Manages the input history

Defined in:

fancyline/history.cr

Constant Summary

DEFAULT_IGNORE_PREFIX = " "

Default ignore prefix

DEFAULT_MAX_SIZE = 1000

Default value of maximum history size

Constructors

Instance Method Summary

Constructor Detail

def self.new(max : Int32 = DEFAULT_MAX_SIZE) #

[View source]

Instance Method Detail

def 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.


[View source]
def ignore?(line : String | Nil) #

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


[View source]
def ignore_prefix : String #

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


[View source]
def ignore_prefix=(ignore_prefix : String) #

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


[View source]
def lines : Array(String) #

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


[View source]
def 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.


[View source]
def max : Int32 #

Max count of history entries to keep


[View source]
def max=(max : Int32) #

Max count of history entries to keep


[View source]
def save(io : IO) #

Writes the history into io.


[View source]