This commit is contained in:
Kovid Goyal
2022-10-07 12:04:37 +05:30
parent 430bd23870
commit 350060e0f6
3 changed files with 17 additions and 3 deletions

View File

@@ -65,12 +65,19 @@ func shell_loop(rl *readline.Readline, kill_if_signaled bool) (int, error) {
return err
}
if event.Handled {
rl.Redraw()
return nil
}
return nil
}
lp.OnText = rl.OnText
lp.OnText = func(text string, from_key_event, in_bracketed_paste bool) error {
err := rl.OnText(text, from_key_event, in_bracketed_paste)
if err == nil {
rl.Redraw()
}
return err
}
err = lp.Run()
if err != nil {

View File

@@ -49,7 +49,7 @@ func (self *Loop) print_stack() {
}
func (self *Loop) update_screen_size() error {
if self.controlling_term != nil {
if self.controlling_term == nil {
return fmt.Errorf("No controlling terminal cannot update screen size")
}
ws, err := self.controlling_term.GetSize()
@@ -237,6 +237,9 @@ func (self *Loop) run() (err error) {
r_w.Close()
close(tty_reading_done_channel)
if self.OnFinalize != nil {
finalizer += self.OnFinalize()
}
if finalizer != "" {
self.QueueWriteString(finalizer)
}

View File

@@ -53,6 +53,10 @@ func (self *Readline) redraw() {
}
self.loop.MoveCursorVertically(-y + line_with_cursor)
line := self.lines[self.cursor.Y]
line_with_cursor += self.move_cursor_to_text_position(wcswidth.Stringwidth(line[:self.cursor.X]), int(screen_size.WidthCells))
plen := self.prompt_len
if self.cursor.Y > 0 {
plen = self.continuation_prompt_len
}
line_with_cursor += self.move_cursor_to_text_position(plen+wcswidth.Stringwidth(line[:self.cursor.X]), int(screen_size.WidthCells))
self.cursor_y = line_with_cursor
}