diff options
| author | adamdotdevin <[email protected]> | 2025-08-05 19:00:08 -0500 |
|---|---|---|
| committer | adamdotdevin <[email protected]> | 2025-08-05 19:05:44 -0500 |
| commit | 6b25b7e95ea68321df73e22d62ad33e11154db85 (patch) | |
| tree | d3d787f3ded38b9b359fb14897e35a8209b2022f /packages/tui/internal/util | |
| parent | 030a3a7446f0f151fd2fc4d3699cc4c712dc1170 (diff) | |
| download | opencode-6b25b7e95ea68321df73e22d62ad33e11154db85.tar.gz opencode-6b25b7e95ea68321df73e22d62ad33e11154db85.zip | |
feat: better assistant message visual
Diffstat (limited to 'packages/tui/internal/util')
| -rw-r--r-- | packages/tui/internal/util/text.go | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/packages/tui/internal/util/text.go b/packages/tui/internal/util/text.go deleted file mode 100644 index 8ac98ebc5..000000000 --- a/packages/tui/internal/util/text.go +++ /dev/null @@ -1,52 +0,0 @@ -package util - -import ( - "regexp" - "strings" - - "github.com/charmbracelet/lipgloss/v2" -) - -// PreventHyphenBreaks replaces regular hyphens with non-breaking hyphens to prevent -// sparse word breaks in hyphenated terms like "claude-code-action". -// This improves readability by keeping hyphenated words together. -// Only preserves hyphens within words, not markdown syntax like bullet points. -func PreventHyphenBreaks(text string) string { - // Use regex to match hyphens that are between word characters - // This preserves hyphens in words like "claude-code-action" but not in "- [ ]" - re := regexp.MustCompile(`(\w)-(\w)`) - return re.ReplaceAllString(text, "$1\u2011$2") -} - -// RestoreHyphens converts non-breaking hyphens back to regular hyphens. -// This should be called after text processing (like word wrapping) is complete. -func RestoreHyphens(text string) string { - return strings.ReplaceAll(text, "\u2011", "-") -} - -// ProcessTextWithHyphens applies hyphen preservation to text during processing. -// It wraps the provided processFunc with hyphen handling. -func ProcessTextWithHyphens(text string, processFunc func(string) string) string { - preserved := PreventHyphenBreaks(text) - processed := processFunc(preserved) - return RestoreHyphens(processed) -} - -// GetMessageContainerFrame calculates the actual horizontal frame size -// (padding + borders) for message containers based on current theme. -func GetMessageContainerFrame() int { - style := lipgloss.NewStyle(). - BorderStyle(lipgloss.ThickBorder()). - BorderLeft(true). - BorderRight(true). - PaddingLeft(2). - PaddingRight(2) - return style.GetHorizontalFrameSize() -} - -// GetMarkdownContainerFrame calculates the actual horizontal frame size -// for markdown containers based on current theme. -func GetMarkdownContainerFrame() int { - // Markdown containers use the same styling as message containers - return GetMessageContainerFrame() -} |
