Set window title when showing errors

This commit is contained in:
Kovid Goyal
2023-10-29 08:24:08 +05:30
parent 8dadcf568c
commit 24d9d502b1
2 changed files with 7 additions and 3 deletions

View File

@@ -42,6 +42,7 @@ func main(args []string, opts *Options) (rc int, err error) {
f := markup.New(true)
if opts.Title != "" {
fmt.Println(f.Err(opts.Title))
fmt.Println(loop.EscapeCodeToSetWindowTitle(opts.Title))
fmt.Println()
}
fmt.Println(m.Msg)

View File

@@ -404,10 +404,13 @@ func (self *Loop) AllowLineWrapping(allow bool) {
}
}
func EscapeCodeToSetWindowTitle(title string) string {
title = wcswidth.StripEscapeCodes(title)
return "\033]2;" + title + "\033\\"
}
func (self *Loop) SetWindowTitle(title string) {
title = strings.ReplaceAll(title, "\033", "")
title = strings.ReplaceAll(title, "\x9c", "")
self.QueueWriteString("\033]2;" + title + "\033\\")
self.QueueWriteString(EscapeCodeToSetWindowTitle(title))
}
func (self *Loop) ClearScreen() {