mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-06-24 18:07:01 +00:00
API to set the text at the prompt
This commit is contained in:
parent
67436a48cd
commit
7223fdaa38
2 changed files with 11 additions and 0 deletions
|
|
@ -52,6 +52,13 @@ func (self *Readline) all_text() string {
|
|||
return strings.Join(self.input_state.lines, "\n")
|
||||
}
|
||||
|
||||
func (self *Readline) set_text(text string) {
|
||||
self.move_to_start()
|
||||
self.erase_chars_after_cursor(123456789, true)
|
||||
self.add_text(text)
|
||||
self.move_to_end()
|
||||
}
|
||||
|
||||
func (self *Readline) add_text(text string) {
|
||||
new_lines := make([]string, 0, len(self.input_state.lines)+4)
|
||||
new_lines = append(new_lines, self.input_state.lines[:self.input_state.cursor.Y]...)
|
||||
|
|
|
|||
|
|
@ -258,6 +258,10 @@ func (self *Readline) AllText() string {
|
|||
return self.all_text()
|
||||
}
|
||||
|
||||
func (self *Readline) SetText(text string) {
|
||||
self.set_text(text)
|
||||
}
|
||||
|
||||
func (self *Readline) MoveCursorToEnd() bool {
|
||||
return self.move_to_end()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue