From b4a75e8ea45787828981945972db2543fb14605c Mon Sep 17 00:00:00 2001 From: Mateusz Drewniak Date: Fri, 28 Jul 2023 23:26:55 +0200 Subject: [PATCH] Change the signature of ExecuteOnEnterCallback --- CHANGELOG.md | 16 +++ _example/automatic-indenter/main.go | 4 +- _example/bang-executor/main.go | 4 +- _example/http-prompt/main.go | 1 + constructor.go | 6 +- emacs.go | 22 ++--- emacs_test.go | 2 +- key_bind_func.go | 12 +-- prompt.go | 147 +++++++++++++++------------- 9 files changed, 122 insertions(+), 92 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 638de464..9f760321 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.1.1] - 28.07.2023 + +[Diff](https://github.com/elk-language/go-prompt/compare/v1.1.0...elk-language:go-prompt:v1.1.1) + +### Added +- `func (*prompt.Prompt).TerminalColumns() strings.Width` +- `func (*prompt.Prompt).TerminalRows() int` + +### Changed +- Change signatures: + - `prompt.ExecuteOnEnterCallback` + - from `func(buffer *prompt.Buffer, indentSize int) (indent int, execute bool)` + - to `func(p *prompt.Prompt, indentSize int) (indent int, execute bool)` +- Change `(*Prompt).Buffer` from a public field to a public getter method + + ## [1.1.0] - 28.07.2023 [Diff](https://github.com/elk-language/go-prompt/compare/v1.0.3...elk-language:go-prompt:v1.1.0) diff --git a/_example/automatic-indenter/main.go b/_example/automatic-indenter/main.go index dd333eea..a8dd48b6 100644 --- a/_example/automatic-indenter/main.go +++ b/_example/automatic-indenter/main.go @@ -18,8 +18,8 @@ func main() { p.Run() } -func ExecuteOnEnter(buffer *prompt.Buffer, indentSize int) (int, bool) { - input := buffer.Text() +func ExecuteOnEnter(p *prompt.Prompt, indentSize int) (int, bool) { + input := p.Buffer().Text() lines := strings.SplitAfter(input, "\n") var spaces int if len(lines) > 0 { diff --git a/_example/bang-executor/main.go b/_example/bang-executor/main.go index 04323325..735cc062 100644 --- a/_example/bang-executor/main.go +++ b/_example/bang-executor/main.go @@ -17,8 +17,8 @@ func main() { p.Run() } -func ExecuteOnEnter(buffer *prompt.Buffer, indentSize int) (int, bool) { - input := buffer.Text() +func ExecuteOnEnter(p *prompt.Prompt, indentSize int) (int, bool) { + input := p.Buffer().Text() char, _ := utf8.DecodeLastRuneInString(input) return 0, char == '!' } diff --git a/_example/http-prompt/main.go b/_example/http-prompt/main.go index 67fbfb5e..38d4f743 100644 --- a/_example/http-prompt/main.go +++ b/_example/http-prompt/main.go @@ -160,6 +160,7 @@ func executor(in string) { func completer(in prompt.Document) ([]prompt.Suggest, istrings.RuneNumber, istrings.RuneNumber) { endIndex := in.CurrentRuneIndex() + in. w := in.GetWordBeforeCursor() if w == "" { return []prompt.Suggest{}, 0, 0 diff --git a/constructor.go b/constructor.go index 8b44f3af..a6759e51 100644 --- a/constructor.go +++ b/constructor.go @@ -80,7 +80,7 @@ func WithPrefix(prefix string) Option { // WithInitialText can be used to set the initial buffer text. func WithInitialText(text string) Option { return func(p *Prompt) error { - p.Buffer.InsertTextMoveCursor(text, p.renderer.col, int(p.renderer.row), true) + p.buffer.InsertTextMoveCursor(text, p.renderer.col, int(p.renderer.row), true) return nil } } @@ -286,7 +286,7 @@ func WithExitChecker(fn ExitChecker) Option { } } -func DefaultExecuteOnEnterCallback(buffer *Buffer, indentSize int) (int, bool) { +func DefaultExecuteOnEnterCallback(p *Prompt, indentSize int) (int, bool) { return 0, true } @@ -299,7 +299,7 @@ func New(executor Executor, opts ...Option) *Prompt { pt := &Prompt{ reader: NewStdinReader(), renderer: NewRenderer(), - Buffer: NewBuffer(), + buffer: NewBuffer(), executor: executor, history: NewHistory(), completion: NewCompletionManager(6), diff --git a/emacs.go b/emacs.go index 79ea4f43..6df9c9d6 100644 --- a/emacs.go +++ b/emacs.go @@ -47,7 +47,7 @@ var emacsKeyBindings = []KeyBind{ Key: ControlE, Fn: func(p *Prompt) bool { return p.CursorRightRunes( - istrings.RuneCountInString(p.Buffer.Document().CurrentLineAfterCursor()), + istrings.RuneCountInString(p.buffer.Document().CurrentLineAfterCursor()), ) }, }, @@ -56,7 +56,7 @@ var emacsKeyBindings = []KeyBind{ Key: ControlA, Fn: func(p *Prompt) bool { return p.CursorLeftRunes( - p.Buffer.Document().FindStartOfFirstWordOfLine(), + p.buffer.Document().FindStartOfFirstWordOfLine(), ) }, }, @@ -64,8 +64,8 @@ var emacsKeyBindings = []KeyBind{ { Key: ControlK, Fn: func(p *Prompt) bool { - p.Buffer.DeleteRunes( - istrings.RuneCountInString(p.Buffer.Document().CurrentLineAfterCursor()), + p.buffer.DeleteRunes( + istrings.RuneCountInString(p.buffer.Document().CurrentLineAfterCursor()), p.renderer.col, p.renderer.row, ) @@ -76,8 +76,8 @@ var emacsKeyBindings = []KeyBind{ { Key: ControlU, Fn: func(p *Prompt) bool { - p.Buffer.DeleteBeforeCursorRunes( - istrings.RuneCountInString(p.Buffer.Document().CurrentLineBeforeCursor()), + p.buffer.DeleteBeforeCursorRunes( + istrings.RuneCountInString(p.buffer.Document().CurrentLineBeforeCursor()), p.renderer.col, p.renderer.row, ) @@ -88,8 +88,8 @@ var emacsKeyBindings = []KeyBind{ { Key: ControlD, Fn: func(p *Prompt) bool { - if p.Buffer.Text() != "" { - p.Buffer.Delete(1, p.renderer.col, p.renderer.row) + if p.buffer.Text() != "" { + p.buffer.Delete(1, p.renderer.col, p.renderer.row) return true } return false @@ -99,7 +99,7 @@ var emacsKeyBindings = []KeyBind{ { Key: ControlH, Fn: func(p *Prompt) bool { - p.Buffer.DeleteBeforeCursor(1, p.renderer.col, p.renderer.row) + p.buffer.DeleteBeforeCursor(1, p.renderer.col, p.renderer.row) return true }, }, @@ -115,7 +115,7 @@ var emacsKeyBindings = []KeyBind{ Key: AltRight, Fn: func(p *Prompt) bool { return p.CursorRightRunes( - p.Buffer.Document().FindRuneNumberUntilEndOfCurrentWord(), + p.buffer.Document().FindRuneNumberUntilEndOfCurrentWord(), ) }, }, @@ -131,7 +131,7 @@ var emacsKeyBindings = []KeyBind{ Key: AltLeft, Fn: func(p *Prompt) bool { return p.CursorLeftRunes( - p.Buffer.Document().FindRuneNumberUntilStartOfPreviousWord(), + p.buffer.Document().FindRuneNumberUntilStartOfPreviousWord(), ) }, }, diff --git a/emacs_test.go b/emacs_test.go index 69adba2d..e42fc69e 100644 --- a/emacs_test.go +++ b/emacs_test.go @@ -8,7 +8,7 @@ import ( func TestEmacsKeyBindings(t *testing.T) { p := New(NoopExecutor) - buf := p.Buffer + buf := p.buffer buf.InsertTextMoveCursor("abcde", DefColCount, DefRowCount, false) if buf.cursorPosition != istrings.RuneNumber(len("abcde")) { t.Errorf("Want %d, but got %d", len("abcde"), buf.cursorPosition) diff --git a/key_bind_func.go b/key_bind_func.go index 7b997a14..5216d76c 100644 --- a/key_bind_func.go +++ b/key_bind_func.go @@ -6,25 +6,25 @@ import ( // GoLineEnd Go to the End of the line func GoLineEnd(p *Prompt) bool { - x := []rune(p.Buffer.Document().TextAfterCursor()) + x := []rune(p.buffer.Document().TextAfterCursor()) return p.CursorRightRunes(istrings.RuneNumber(len(x))) } // GoLineBeginning Go to the beginning of the line func GoLineBeginning(p *Prompt) bool { - x := []rune(p.Buffer.Document().TextBeforeCursor()) + x := []rune(p.buffer.Document().TextBeforeCursor()) return p.CursorLeftRunes(istrings.RuneNumber(len(x))) } // DeleteChar Delete character under the cursor func DeleteChar(p *Prompt) bool { - p.Buffer.Delete(1, p.renderer.col, p.renderer.row) + p.buffer.Delete(1, p.renderer.col, p.renderer.row) return true } // DeleteBeforeChar Go to Backspace func DeleteBeforeChar(p *Prompt) bool { - p.Buffer.DeleteBeforeCursor(1, p.renderer.col, p.renderer.row) + p.buffer.DeleteBeforeCursor(1, p.renderer.col, p.renderer.row) return true } @@ -39,8 +39,8 @@ func GoLeftChar(p *Prompt) bool { } func DeleteWordBeforeCursor(p *Prompt) bool { - p.Buffer.DeleteBeforeCursorRunes( - istrings.RuneCountInString(p.Buffer.Document().GetWordBeforeCursorWithSpace()), + p.buffer.DeleteBeforeCursorRunes( + istrings.RuneCountInString(p.buffer.Document().GetWordBeforeCursorWithSpace()), p.renderer.col, p.renderer.row, ) diff --git a/prompt.go b/prompt.go index 5838b3ea..683aa7f9 100644 --- a/prompt.go +++ b/prompt.go @@ -2,8 +2,6 @@ package prompt import ( "bytes" - "fmt" - "log" "os" "strings" "time" @@ -33,7 +31,7 @@ type ExitChecker func(in string, breakline bool) bool // If this function returns true, the Executor callback will be called // otherwise a newline will be added to the buffer containing user input // and optionally indentation made up of `indentSize * indent` spaces. -type ExecuteOnEnterCallback func(buffer *Buffer, indentSize int) (indent int, execute bool) +type ExecuteOnEnterCallback func(prompt *Prompt, indentSize int) (indent int, execute bool) // Completer is a function that returns // a slice of suggestions for the given Document. @@ -45,7 +43,7 @@ type Completer func(Document) (suggestions []Suggest, startChar, endChar istring // Prompt is a core struct of go-prompt. type Prompt struct { reader Reader - Buffer *Buffer + buffer *Buffer renderer *Renderer executor Executor history *History @@ -75,10 +73,10 @@ func (p *Prompt) Run() { defer p.Close() if p.completion.showAtStart { - p.completion.Update(*p.Buffer.Document()) + p.completion.Update(*p.buffer.Document()) } - p.renderer.Render(p.Buffer, p.completion, p.lexer) + p.renderer.Render(p.buffer, p.completion, p.lexer) bufCh := make(chan []byte, 128) stopReadBufCh := make(chan struct{}) @@ -93,7 +91,7 @@ func (p *Prompt) Run() { select { case b := <-bufCh: if shouldExit, rerender, input := p.feed(b); shouldExit { - p.renderer.BreakLine(p.Buffer, p.lexer) + p.renderer.BreakLine(p.buffer, p.lexer) stopReadBufCh <- struct{}{} stopHandleSignalCh <- struct{}{} return @@ -107,9 +105,9 @@ func (p *Prompt) Run() { debug.AssertNoError(p.reader.Close()) p.executor(input.input) - p.completion.Update(*p.Buffer.Document()) + p.completion.Update(*p.buffer.Document()) - p.renderer.Render(p.Buffer, p.completion, p.lexer) + p.renderer.Render(p.buffer, p.completion, p.lexer) if p.exitChecker != nil && p.exitChecker(input.input, true) { p.skipClose = true @@ -121,17 +119,17 @@ func (p *Prompt) Run() { go p.handleSignals(exitCh, winSizeCh, stopHandleSignalCh) } else if rerender { if p.completion.shouldUpdate { - p.completion.Update(*p.Buffer.Document()) + p.completion.Update(*p.buffer.Document()) } - p.renderer.Render(p.Buffer, p.completion, p.lexer) + p.renderer.Render(p.buffer, p.completion, p.lexer) } case w := <-winSizeCh: p.renderer.UpdateWinSize(w) - p.Buffer.resetStartLine() - p.Buffer.recalculateStartLine(p.renderer.UserInputColumns(), int(p.renderer.row)) - p.renderer.Render(p.Buffer, p.completion, p.lexer) + p.buffer.resetStartLine() + p.buffer.recalculateStartLine(p.renderer.UserInputColumns(), int(p.renderer.row)) + p.renderer.Render(p.buffer, p.completion, p.lexer) case code := <-exitCh: - p.renderer.BreakLine(p.Buffer, p.lexer) + p.renderer.BreakLine(p.buffer, p.lexer) p.Close() os.Exit(code) default: @@ -140,23 +138,38 @@ func (p *Prompt) Run() { } } -func Log(format string, a ...any) { - f, err := os.OpenFile("log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) - if err != nil { - log.Fatalf("error opening file: %v", err) - } - defer f.Close() - fmt.Fprintf(f, format+"\n", a...) -} +// func Log(format string, a ...any) { +// f, err := os.OpenFile("log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) +// if err != nil { +// log.Fatalf("error opening file: %v", err) +// } +// defer f.Close() +// fmt.Fprintf(f, format+"\n", a...) +// } // Returns the configured indent size. func (p *Prompt) IndentSize() int { return p.renderer.indentSize } +// Returns the current amount of columns that the terminal can display. +func (p *Prompt) TerminalColumns() istrings.Width { + return p.renderer.col +} + +// Returns the current amount of rows that the terminal can display. +func (p *Prompt) TerminalRows() int { + return p.renderer.row +} + +// Returns the buffer struct. +func (p *Prompt) Buffer() *Buffer { + return p.buffer +} + func (p *Prompt) feed(b []byte) (shouldExit bool, rerender bool, userInput *UserInput) { key := GetKey(b) - p.Buffer.lastKeyStroke = key + p.buffer.lastKeyStroke = key // completion completing := p.completion.Completing() if p.handleCompletionKeyBinding(b, key, completing) { @@ -168,31 +181,31 @@ func (p *Prompt) feed(b []byte) (shouldExit bool, rerender bool, userInput *User switch key { case Enter, ControlJ, ControlM: - indent, execute := p.executeOnEnterCallback(p.Buffer, p.renderer.indentSize) + indent, execute := p.executeOnEnterCallback(p, p.renderer.indentSize) if !execute { - p.Buffer.NewLine(cols, rows, false) + p.buffer.NewLine(cols, rows, false) var indentStrBuilder strings.Builder indentUnitCount := indent * p.renderer.indentSize for i := 0; i < indentUnitCount; i++ { indentStrBuilder.WriteRune(IndentUnit) } - p.Buffer.InsertTextMoveCursor(indentStrBuilder.String(), cols, rows, false) + p.buffer.InsertTextMoveCursor(indentStrBuilder.String(), cols, rows, false) break } - p.renderer.BreakLine(p.Buffer, p.lexer) - userInput = &UserInput{input: p.Buffer.Text()} - p.Buffer = NewBuffer() + p.renderer.BreakLine(p.buffer, p.lexer) + userInput = &UserInput{input: p.buffer.Text()} + p.buffer = NewBuffer() if userInput.input != "" { p.history.Add(userInput.input) } case ControlC: - p.renderer.BreakLine(p.Buffer, p.lexer) - p.Buffer = NewBuffer() + p.renderer.BreakLine(p.buffer, p.lexer) + p.buffer = NewBuffer() p.history.Clear() case Up, ControlP: - line := p.Buffer.Document().CursorPositionRow() + line := p.buffer.Document().CursorPositionRow() if line > 0 { rerender = p.CursorUp(1) return false, rerender, nil @@ -201,13 +214,13 @@ func (p *Prompt) feed(b []byte) (shouldExit bool, rerender bool, userInput *User break } - if newBuf, changed := p.history.Older(p.Buffer, cols, rows); changed { - p.Buffer = newBuf + if newBuf, changed := p.history.Older(p.buffer, cols, rows); changed { + p.buffer = newBuf } case Down, ControlN: - endOfTextRow := p.Buffer.Document().TextEndPositionRow() - row := p.Buffer.Document().CursorPositionRow() + endOfTextRow := p.buffer.Document().TextEndPositionRow() + row := p.buffer.Document().CursorPositionRow() if endOfTextRow > row { rerender = p.CursorDown(1) return false, rerender, nil @@ -217,12 +230,12 @@ func (p *Prompt) feed(b []byte) (shouldExit bool, rerender bool, userInput *User break } - if newBuf, changed := p.history.Newer(p.Buffer, cols, rows); changed { - p.Buffer = newBuf + if newBuf, changed := p.history.Newer(p.buffer, cols, rows); changed { + p.buffer = newBuf } return false, true, nil case ControlD: - if p.Buffer.Text() == "" { + if p.buffer.Text() == "" { return true, true, nil } case NotDefined: @@ -237,7 +250,7 @@ func (p *Prompt) feed(b []byte) (shouldExit bool, rerender bool, userInput *User return false, false, nil } - p.Buffer.InsertTextMoveCursor(string(b), cols, rows, false) + p.buffer.InsertTextMoveCursor(string(b), cols, rows, false) } shouldExit, rerender = p.handleKeyBinding(key, cols, rows) @@ -294,7 +307,7 @@ keySwitch: newBytes = append(newBytes, byt) } } - p.Buffer.InsertTextMoveCursor(string(newBytes), cols, rows, false) + p.buffer.InsertTextMoveCursor(string(newBytes), cols, rows, false) return true case BackTab: if completionLen > 0 { @@ -305,21 +318,21 @@ keySwitch: return true } - text := p.Buffer.Document().CurrentLineBeforeCursor() + text := p.buffer.Document().CurrentLineBeforeCursor() for _, char := range text { if char != IndentUnit { break keySwitch } } - p.Buffer.DeleteBeforeCursorRunes(istrings.RuneNumber(p.renderer.indentSize), cols, rows) + p.buffer.DeleteBeforeCursorRunes(istrings.RuneNumber(p.renderer.indentSize), cols, rows) return true default: if s, ok := p.completion.GetSelectedSuggestion(); ok { - w := p.Buffer.Document().GetWordBeforeCursorUntilSeparator(p.completion.wordSeparator) + w := p.buffer.Document().GetWordBeforeCursorUntilSeparator(p.completion.wordSeparator) if w != "" { - p.Buffer.DeleteBeforeCursorRunes(istrings.RuneCountInString(w), cols, rows) + p.buffer.DeleteBeforeCursorRunes(istrings.RuneCountInString(w), cols, rows) } - p.Buffer.InsertTextMoveCursor(s.Text, cols, rows, false) + p.buffer.InsertTextMoveCursor(s.Text, cols, rows, false) } if completionLen > 0 { p.completionReset = true @@ -349,13 +362,13 @@ func (p *Prompt) updateSuggestions(fn func()) { // insert the new selection if !prevSelected { - p.Buffer.DeleteBeforeCursorRunes(p.completion.endCharIndex-p.completion.startCharIndex, cols, rows) - p.Buffer.InsertTextMoveCursor(newSuggestion.Text, cols, rows, false) + p.buffer.DeleteBeforeCursorRunes(p.completion.endCharIndex-p.completion.startCharIndex, cols, rows) + p.buffer.InsertTextMoveCursor(newSuggestion.Text, cols, rows, false) return } // delete the previous selection if !newSelected { - p.Buffer.DeleteBeforeCursorRunes( + p.buffer.DeleteBeforeCursorRunes( istrings.RuneCountInString(prevSuggestion.Text)-(prevEnd-prevStart), cols, rows, @@ -364,13 +377,13 @@ func (p *Prompt) updateSuggestions(fn func()) { } // delete previous selection and render the new one - p.Buffer.DeleteBeforeCursorRunes( + p.buffer.DeleteBeforeCursorRunes( istrings.RuneCountInString(prevSuggestion.Text), cols, rows, ) - p.Buffer.InsertTextMoveCursor(newSuggestion.Text, cols, rows, false) + p.buffer.InsertTextMoveCursor(newSuggestion.Text, cols, rows, false) } func (p *Prompt) handleKeyBinding(key Key, cols istrings.Width, rows int) (shouldExit bool, rerender bool) { @@ -411,7 +424,7 @@ func (p *Prompt) handleKeyBinding(key Key, cols istrings.Width, rows int) (shoul } } } - if p.exitChecker != nil && p.exitChecker(p.Buffer.Text(), false) { + if p.exitChecker != nil && p.exitChecker(p.buffer.Text(), false) { shouldExit = true } if !executed && !rerender { @@ -442,10 +455,10 @@ func (p *Prompt) Input() string { defer p.Close() if p.completion.showAtStart { - p.completion.Update(*p.Buffer.Document()) + p.completion.Update(*p.buffer.Document()) } - p.renderer.Render(p.Buffer, p.completion, p.lexer) + p.renderer.Render(p.buffer, p.completion, p.lexer) bufCh := make(chan []byte, 128) stopReadBufCh := make(chan struct{}) go p.readBuffer(bufCh, stopReadBufCh) @@ -454,7 +467,7 @@ func (p *Prompt) Input() string { select { case b := <-bufCh: if shouldExit, rerender, input := p.feed(b); shouldExit { - p.renderer.BreakLine(p.Buffer, p.lexer) + p.renderer.BreakLine(p.buffer, p.lexer) stopReadBufCh <- struct{}{} return "" } else if input != nil { @@ -462,8 +475,8 @@ func (p *Prompt) Input() string { stopReadBufCh <- struct{}{} return input.input } else if rerender { - p.completion.Update(*p.Buffer.Document()) - p.renderer.Render(p.Buffer, p.completion, p.lexer) + p.completion.Update(*p.buffer.Document()) + p.renderer.Render(p.buffer, p.completion, p.lexer) } default: time.Sleep(10 * time.Millisecond) @@ -528,25 +541,25 @@ func (p *Prompt) setup() { // Move to the left on the current line by the given amount of graphemes (visible characters). // Returns true when the view should be rerendered. func (p *Prompt) CursorLeft(count istrings.GraphemeNumber) bool { - return promptCursorHorizontalMove(p, p.Buffer.CursorLeft, count) + return promptCursorHorizontalMove(p, p.buffer.CursorLeft, count) } // Move to the left on the current line by the given amount of runes. // Returns true when the view should be rerendered. func (p *Prompt) CursorLeftRunes(count istrings.RuneNumber) bool { - return promptCursorHorizontalMove(p, p.Buffer.CursorLeftRunes, count) + return promptCursorHorizontalMove(p, p.buffer.CursorLeftRunes, count) } // Move the cursor to the right on the current line by the given amount of graphemes (visible characters). // Returns true when the view should be rerendered. func (p *Prompt) CursorRight(count istrings.GraphemeNumber) bool { - return promptCursorHorizontalMove(p, p.Buffer.CursorRight, count) + return promptCursorHorizontalMove(p, p.buffer.CursorRight, count) } // Move the cursor to the right on the current line by the given amount of runes. // Returns true when the view should be rerendered. func (p *Prompt) CursorRightRunes(count istrings.RuneNumber) bool { - return promptCursorHorizontalMove(p, p.Buffer.CursorRightRunes, count) + return promptCursorHorizontalMove(p, p.buffer.CursorRightRunes, count) } type horizontalCursorModifier[CountT ~int] func(CountT, istrings.Width, int) bool @@ -554,7 +567,7 @@ type horizontalCursorModifier[CountT ~int] func(CountT, istrings.Width, int) boo // Move to the left or right on the current line. // Returns true when the view should be rerendered. func promptCursorHorizontalMove[CountT ~int](p *Prompt, modifierFunc horizontalCursorModifier[CountT], count CountT) bool { - b := p.Buffer + b := p.buffer cols := p.renderer.UserInputColumns() previousCursor := b.DisplayCursorPosition(cols) @@ -573,11 +586,11 @@ func promptCursorHorizontalMove[CountT ~int](p *Prompt, modifierFunc horizontalC // Move the cursor up. // Returns true when the view should be rerendered. func (p *Prompt) CursorUp(count int) bool { - b := p.Buffer + b := p.buffer cols := p.renderer.UserInputColumns() previousCursor := b.DisplayCursorPosition(cols) - rerender := p.Buffer.CursorUp(count, cols, p.renderer.row) || p.completionReset || len(p.completion.tmp) > 0 + rerender := p.buffer.CursorUp(count, cols, p.renderer.row) || p.completionReset || len(p.completion.tmp) > 0 if rerender { return true } @@ -592,11 +605,11 @@ func (p *Prompt) CursorUp(count int) bool { // Move the cursor down. // Returns true when the view should be rerendered. func (p *Prompt) CursorDown(count int) bool { - b := p.Buffer + b := p.buffer cols := p.renderer.UserInputColumns() previousCursor := b.DisplayCursorPosition(cols) - rerender := p.Buffer.CursorDown(count, cols, p.renderer.row) || p.completionReset || len(p.completion.tmp) > 0 + rerender := p.buffer.CursorDown(count, cols, p.renderer.row) || p.completionReset || len(p.completion.tmp) > 0 if rerender { return true }