diff --git a/prompt/buffer.go b/prompt/buffer.go index bf33f33..8328450 100644 --- a/prompt/buffer.go +++ b/prompt/buffer.go @@ -9,7 +9,6 @@ type Buffer struct { workingLines []string // The working lines. Similar to history workingIndex int CursorPosition int - selectionState *SelectionState cacheDocument *Document // TODO: More effective cache using Queue or map. See https://github.com/jonathanslenders/python-prompt-toolkit/blob/master/prompt_toolkit/cache.py#L55-L93 preferredColumn int // Remember the original column for the next up/down movement. } @@ -19,17 +18,14 @@ func (b *Buffer) Text() string { return b.workingLines[b.workingIndex] } -// Document method to return document instance from the current text, -// cursor position and selection state. +// Document method to return document instance from the current text and cursor position. func (b *Buffer) Document() (d *Document) { if b.cacheDocument == nil || b.cacheDocument.Text != b.Text() || - b.cacheDocument.CursorPosition != b.CursorPosition || - b.cacheDocument.selectionState != b.cacheDocument.selectionState { + b.cacheDocument.CursorPosition != b.CursorPosition { b.cacheDocument = &Document{ Text: b.Text(), CursorPosition: b.CursorPosition, - selectionState: b.selectionState, } } return b.cacheDocument diff --git a/prompt/completions.go b/prompt/completions.go deleted file mode 100644 index 049e6d5..0000000 --- a/prompt/completions.go +++ /dev/null @@ -1,24 +0,0 @@ -package prompt - -type Completion struct { - // The new string that will be inserted into document. - text string - // Position relative to the cursor position where the new text will start. - startPosition int -} - -func (c *Completion) NewCompletionFromPosition(position int) *Completion { - if position < c.startPosition { - panic("position argument must be smaller than start position.") - } - - return &Completion{ - text: c.text[position-c.startPosition:], - } -} - -func NewCompletion(text string) *Completion { - return &Completion{ - text: text, - } -} diff --git a/prompt/document.go b/prompt/document.go index 77ae700..c9399fb 100644 --- a/prompt/document.go +++ b/prompt/document.go @@ -9,7 +9,6 @@ import ( type Document struct { Text string CursorPosition int - selectionState *SelectionState } // GetCharRelativeToCursor return character relative to cursor position, or empty string diff --git a/prompt/selection.go b/prompt/selection.go deleted file mode 100644 index 206776f..0000000 --- a/prompt/selection.go +++ /dev/null @@ -1,19 +0,0 @@ -package prompt - -// SelectionType expresses how characters selected. -type SelectionType int - -const ( - // CHARACTERS selected freely. - CHARACTERS SelectionType = iota - // LINES selected current line. - LINES - // BLOCK selected the word block. - BLOCK -) - -// SelectionState holds cursor position and selected characters. -type SelectionState struct { - OriginalCursorPosition int - Type SelectionType -} diff --git a/prompt/selectiontype_string.go b/prompt/selectiontype_string.go deleted file mode 100644 index 228ab3c..0000000 --- a/prompt/selectiontype_string.go +++ /dev/null @@ -1,16 +0,0 @@ -// Code generated by "stringer -type SelectionType selection.go"; DO NOT EDIT - -package prompt - -import "fmt" - -const _SelectionType_name = "CHARACTERSLINESBLOCK" - -var _SelectionType_index = [...]uint8{0, 10, 15, 20} - -func (i SelectionType) String() string { - if i < 0 || i >= SelectionType(len(_SelectionType_index)-1) { - return fmt.Sprintf("SelectionType(%d)", i) - } - return _SelectionType_name[_SelectionType_index[i]:_SelectionType_index[i+1]] -}