File: title.go

package info (click to toggle)
golang-github-charmbracelet-x 0.0~git20251028.0cf22f8%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,940 kB
  • sloc: sh: 124; makefile: 5
file content (48 lines) | stat: -rw-r--r-- 1,374 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package ansi

// SetIconNameWindowTitle returns a sequence for setting the icon name and
// window title.
//
//	OSC 0 ; title ST
//	OSC 0 ; title BEL
//
// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Operating-System-Commands
func SetIconNameWindowTitle(s string) string {
	return "\x1b]0;" + s + "\x07"
}

// SetIconName returns a sequence for setting the icon name.
//
//	OSC 1 ; title ST
//	OSC 1 ; title BEL
//
// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Operating-System-Commands
func SetIconName(s string) string {
	return "\x1b]1;" + s + "\x07"
}

// SetWindowTitle returns a sequence for setting the window title.
//
//	OSC 2 ; title ST
//	OSC 2 ; title BEL
//
// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Operating-System-Commands
func SetWindowTitle(s string) string {
	return "\x1b]2;" + s + "\x07"
}

// DECSWT is a sequence for setting the window title.
//
// This is an alias for [SetWindowTitle]("1;<name>").
// See: EK-VT520-RM 5–156 https://vt100.net/dec/ek-vt520-rm.pdf
func DECSWT(name string) string {
	return SetWindowTitle("1;" + name)
}

// DECSIN is a sequence for setting the icon name.
//
// This is an alias for [SetWindowTitle]("L;<name>").
// See: EK-VT520-RM 5–134 https://vt100.net/dec/ek-vt520-rm.pdf
func DECSIN(name string) string {
	return SetWindowTitle("L;" + name)
}