mirror of
https://github.com/marcusDenslow/terminalShop.git
synced 2026-10-26 10:18:46 +01:00
feat(tui): use BEL terminator for tracking url osc 8 link - hopefully this works
This commit is contained in:
@@ -196,7 +196,7 @@ func (m Model) buildOrderDetailView(order models.Order, _ int) string {
|
||||
b.WriteString("\n")
|
||||
}
|
||||
if order.TrackingURL != "" {
|
||||
b.WriteString(dimStyle.Render(" " + order.TrackingURL))
|
||||
b.WriteString(hyperlink(dimStyle.Render(fmt.Sprintf(" View on %s ->", order.Carrier)), order.TrackingURL))
|
||||
b.WriteString("\n")
|
||||
}
|
||||
}
|
||||
@@ -248,3 +248,11 @@ func (m Model) displayStyle(k models.DisplayKind) lipgloss.Style {
|
||||
}
|
||||
return m.theme.TextHighlight()
|
||||
}
|
||||
|
||||
// hyperlink wraps label in OSC 8 escape sequences so supporting terminals
|
||||
// render it as a clickable link to url. Uses BEL (\x07) as the string
|
||||
// terminator — some renderers in the pipeline (bubbletea/lipgloss) handled
|
||||
// the BEL form when they didn't handle the ST (\x1b\\) form.
|
||||
func hyperlink(label, url string) string {
|
||||
return fmt.Sprintf("\x1b]8;;%s\x07%s\x1b]8;;\x07", url, label)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user