MCPcopy Create free account
hub / github.com/coder/ghostty-web / checkForTitleChange

Method checkForTitleChange

lib/terminal.ts:1769–1788  ·  view source on GitHub ↗

* Check for title changes in written data (OSC sequences) * Simplified implementation - looks for OSC 0, 1, 2

(data: string)

Source from the content-addressed store, hash-verified

1767 * Simplified implementation - looks for OSC 0, 1, 2
1768 */
1769 private checkForTitleChange(data: string): void {
1770 // OSC sequences: ESC ] Ps ; Pt BEL or ESC ] Ps ; Pt ST
1771 // OSC 0 = icon + title, OSC 1 = icon, OSC 2 = title
1772 const oscRegex = /\x1b\]([012]);([^\x07\x1b]*?)(?:\x07|\x1b\\)/g;
1773 let match: RegExpExecArray | null = null;
1774
1775 // biome-ignore lint/suspicious/noAssignInExpressions: Standard regex pattern
1776 while ((match = oscRegex.exec(data)) !== null) {
1777 const ps = match[1];
1778 const pt = match[2];
1779
1780 // OSC 0 and OSC 2 set the title
1781 if (ps === '0' || ps === '2') {
1782 if (pt !== this.currentTitle) {
1783 this.currentTitle = pt;
1784 this.titleChangeEmitter.fire(pt);
1785 }
1786 }
1787 }
1788 }
1789
1790 // ============================================================================
1791 // Terminal Modes

Callers 1

writeInternalMethod · 0.95

Calls 1

fireMethod · 0.45

Tested by

no test coverage detected