@@ -8,18 +8,20 @@ import (
88 "github.com/charmbracelet/x/ansi"
99)
1010
11- // === deepx 文字 banner(给右栏顶部用 )===
11+ // === deepx-code 文字 banner(右栏顶部 )===
1212//
1313// 5 行布局:
14- // - 顶 `/` 装饰条
15- // - 3 行 5×3 block art "deepx",每个字母粉→紫渐变
16- // - 底 `/` 装饰条
14+ // - 顶 ‹──────› 尖括号框
15+ // - 3 行 5×3 block art "deepx",每个字母青→蓝渐变;中间行尾接 "-code" 后缀
16+ // - 底 ‹──────› 尖括号框
1717//
18- // 之前还有一行 "deepx code™" 标签,跟 chat 区右栏顶部的文字 logo 重复,这里只留 art 。
18+ // 配色青→蓝、装饰用尖括号(代码母题),自有辨识度 。
1919const (
2020 bannerArtRows = 3
2121 bannerArtWidth = 3 * 5 + 4 // 5 字母 × 3 列 + 4 字母间空格 = 19
22- bannerMinWidth = bannerArtWidth
22+ bannerIndent = 2 // art 左缩进
23+ bannerSuffix = " -code"
24+ bannerMinWidth = bannerIndent + bannerArtWidth
2325)
2426
2527// deepxLetters 5 个字母的 3×3 像素艺术。
@@ -31,53 +33,59 @@ var deepxLetters = [5][bannerArtRows]string{
3133 {"█ █" , "▀▄▀" , "▀ ▀" }, // x
3234}
3335
34- // deepxLetterColors 每个字母一色,组成粉→紫渐变 。ANSI 256 调色板等距取色,跨终端稳。
36+ // deepxLetterColors 每个字母一色,组成青→蓝渐变 。ANSI 256 调色板等距取色,跨终端稳。
3537var deepxLetterColors = [5 ]color.Color {
36- lipgloss .Color ("213 " ), // 亮粉
37- lipgloss .Color ("177 " ), // 粉紫
38- lipgloss .Color ("141 " ), // 中紫
39- lipgloss .Color ("105 " ), // 蓝紫
40- lipgloss .Color ("99 " ), // 深紫
38+ lipgloss .Color ("51 " ), // 亮青
39+ lipgloss .Color ("45 " ), // 青
40+ lipgloss .Color ("39 " ), // 青蓝
41+ lipgloss .Color ("33 " ), // 蓝
42+ lipgloss .Color ("27 " ), // 索蓝
4143}
4244
43- // bannerDecoColor 上下 `/` 修饰条颜色。
44- var bannerDecoColor color.Color = lipgloss .Color ("63" )
45+ // bannerSuffixColor "-code" 后缀色(浅灰,作字样副件);bannerDecoColor 尖括号框色(亦被
46+ // scrollbar 轨道 / reasoning 角色名复用,留作通用蓝色强调)。
47+ var (
48+ bannerSuffixColor color.Color = lipgloss .Color ("250" )
49+ bannerDecoColor color.Color = lipgloss .Color ("67" ) // 钢蓝
50+ )
4551
4652// renderBanner 返回 5 行 × width 列的 banner。width < bannerMinWidth 时返回空。
4753func renderBanner (width int ) string {
4854 if width < bannerMinWidth {
4955 return ""
5056 }
5157
52- deco := lipgloss . NewStyle ().
53- Foreground (bannerDecoColor ).
54- Render (strings .Repeat ("/ " , width ) )
58+ // 尖括号框:‹ + ─×(width-2) + ›
59+ deco := lipgloss . NewStyle (). Foreground (bannerDecoColor ).
60+ Render ("‹" + strings .Repeat ("─ " , width - 2 ) + "›" )
5561
56- leftPad := (width - bannerArtWidth ) / 2
57- if leftPad < 0 {
58- leftPad = 0
59- }
60- padStr := strings .Repeat (" " , leftPad )
62+ pad := strings .Repeat (" " , bannerIndent )
63+ suffixFits := bannerIndent + bannerArtWidth + ansi .StringWidth (bannerSuffix ) <= width
6164
6265 rows := make ([]string , 0 , 5 )
6366 rows = append (rows , deco )
6467 for r := range bannerArtRows {
6568 var sb strings.Builder
66- sb .WriteString (padStr )
69+ sb .WriteString (pad )
6770 for i , letter := range deepxLetters {
6871 if i > 0 {
6972 sb .WriteByte (' ' )
7073 }
71- sb .WriteString (lipgloss .NewStyle ().
72- Foreground (deepxLetterColors [i ]).
73- Render (letter [r ]))
74+ sb .WriteString (lipgloss .NewStyle ().Foreground (deepxLetterColors [i ]).Render (letter [r ]))
7475 }
75- raw := sb .String ()
76- if cur := ansi .StringWidth (raw ); cur < width {
77- raw += strings .Repeat (" " , width - cur )
76+ if r == 1 && suffixFits { // 中间行尾接 "-code"
77+ sb .WriteString (lipgloss .NewStyle ().Foreground (bannerSuffixColor ).Render (bannerSuffix ))
7878 }
79- rows = append (rows , raw )
79+ rows = append (rows , padBannerRow ( sb . String (), width ) )
8080 }
8181 rows = append (rows , deco )
8282 return strings .Join (rows , "\n " )
8383}
84+
85+ // padBannerRow 把行右补空格到 width 列(按显示宽度算,忽略 ANSI 转义)。
86+ func padBannerRow (s string , width int ) string {
87+ if cur := ansi .StringWidth (s ); cur < width {
88+ return s + strings .Repeat (" " , width - cur )
89+ }
90+ return s
91+ }
0 commit comments