Set window title when showing errors
This commit is contained in:
@@ -42,6 +42,7 @@ func main(args []string, opts *Options) (rc int, err error) {
|
|||||||
f := markup.New(true)
|
f := markup.New(true)
|
||||||
if opts.Title != "" {
|
if opts.Title != "" {
|
||||||
fmt.Println(f.Err(opts.Title))
|
fmt.Println(f.Err(opts.Title))
|
||||||
|
fmt.Println(loop.EscapeCodeToSetWindowTitle(opts.Title))
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
}
|
}
|
||||||
fmt.Println(m.Msg)
|
fmt.Println(m.Msg)
|
||||||
|
|||||||
@@ -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) {
|
func (self *Loop) SetWindowTitle(title string) {
|
||||||
title = strings.ReplaceAll(title, "\033", "")
|
self.QueueWriteString(EscapeCodeToSetWindowTitle(title))
|
||||||
title = strings.ReplaceAll(title, "\x9c", "")
|
|
||||||
self.QueueWriteString("\033]2;" + title + "\033\\")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Loop) ClearScreen() {
|
func (self *Loop) ClearScreen() {
|
||||||
|
|||||||
Reference in New Issue
Block a user