diff --git a/tools/cmd/at/shell.go b/tools/cmd/at/shell.go index d02705eda..183838d7a 100644 --- a/tools/cmd/at/shell.go +++ b/tools/cmd/at/shell.go @@ -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 { diff --git a/tools/tui/loop/run.go b/tools/tui/loop/run.go index 753d789ec..fb06e83ed 100644 --- a/tools/tui/loop/run.go +++ b/tools/tui/loop/run.go @@ -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) } diff --git a/tools/tui/readline/draw.go b/tools/tui/readline/draw.go index c31aee378..47629e6ad 100644 --- a/tools/tui/readline/draw.go +++ b/tools/tui/readline/draw.go @@ -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 }