linux_or_unix

package
v0.9.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2024 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InputHistoryManager

type InputHistoryManager struct {
	History      []string // History stores the list of inputs entered by the user.
	CurrentIndex int      // CurrentIndex represents the position in the input history.
	CurrentInput string   // CurrentInput stores the input currently being edited.
}

InputHistoryManager manages the history of user inputs during a chat session. It allows navigating through the history of commands or messages that have been entered previously.

func NewInputHistoryManager

func NewInputHistoryManager() *InputHistoryManager

NewInputHistoryManager creates and returns a new instance of InputHistoryManager. It initializes the history with an empty slice and sets the current index to -1, indicating that no history entry is currently selected. TODO: Used it for Arrow Up and Down to retrieve previous and next input.

func (*InputHistoryManager) Add

func (m *InputHistoryManager) Add(input string)

Add appends a new input to the end of the history. After adding the input, it resets the current index to -1, which deselects any history entry.

func (*InputHistoryManager) Next

func (m *InputHistoryManager) Next() string

Next retrieves the input that follows the current one in the history. If there is a next input, it updates the current index to point to that input and returns it. If the end of the history is reached or if there is no next input, it returns an empty string and resets the current index.

func (*InputHistoryManager) Previous

func (m *InputHistoryManager) Previous() string

Previous retrieves the input that precedes the current one in the history. If there is a previous input, it updates the current index to point to that input and returns it. If the beginning of the history is reached, it returns the current input without changing the index.

func (*InputHistoryManager) UpdateCurrentInput

func (m *InputHistoryManager) UpdateCurrentInput(input string)

UpdateCurrentInput sets the CurrentInput field to the provided input value. This method is typically called when navigating through the input history to update the input being edited by the user.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL