8
8
"fmt"
9
9
"path/filepath"
10
10
"strconv"
11
+ "strings"
11
12
12
13
rgb "image/color"
13
14
@@ -16,6 +17,7 @@ import (
16
17
"github.com/pgavlin/femto/runtime"
17
18
"github.com/rivo/tview"
18
19
"github.com/tectiv3/go-lsp"
20
+ "zen108.com/lspvi/pkg/debug"
19
21
"zen108.com/lspvi/pkg/treesittertheme"
20
22
// lspcore "zen108.com/lspvi/pkg/lsp"
21
23
)
@@ -95,16 +97,40 @@ func IntToRGB(colorInt tcell.Color) rgb.RGBA {
95
97
r , g , b := colorInt .RGB ()
96
98
return rgb.RGBA {uint8 (r ), uint8 (g ), uint8 (b ), 255 } // 默认Alpha通道为255(完全不透明)
97
99
}
100
+ func HexToRGB (hexString string ) (int , int , int , error ) {
101
+ // 去掉前缀 #
102
+ hexString = strings .TrimPrefix (hexString , "#" )
103
+
104
+ // 将十六进制字符串转换为整数
105
+ value , err := strconv .ParseUint (hexString , 16 , 32 )
106
+ if err != nil {
107
+ return 0 , 0 , 0 , err
108
+ }
109
+
110
+ // 提取红色、绿色和蓝色的分量
111
+ blue := int (value & 255 )
112
+ green := int ((value >> 8 ) & 255 )
113
+ red := int ((value >> 16 ) & 255 )
114
+
115
+ return red , green , blue , nil
116
+ }
98
117
func (mgr * symbol_colortheme ) set_currsor_line () {
99
118
if ret := mgr .get_color ("cursorline" ); ret != nil {
100
119
_ , bg , _ := ret .Decompose ()
101
- x := lightenColor (IntToRGB (bg ), 0.0 )
120
+ ss := bg .Hex ()
121
+ debug .DebugLogf ("color" , "#%x %s" , ss , mgr .name )
122
+ x := lightenColor (IntToRGB (bg ), 0.2 )
102
123
v := ColorToCellColor (x )
103
124
s := ret .Background (v )
104
- mgr .colorscheme ["cursor-line" ] = s //*ret
105
- // if _, ok := mgr.colorscheme["selection"]; !ok {
106
- // mgr.colorscheme["selection"] = *ret
107
- // }
125
+ _ , bg , _ = s .Decompose ()
126
+ debug .DebugLogf ("color" , "#%x %s" , bg .Hex (), mgr .name )
127
+ mgr .colorscheme ["cursor-line" ] = s
128
+ }
129
+ if bg := global_config .Color .Cursorline ; bg != nil {
130
+ if r , g , b , err := hexToRGB (* bg ); err == nil {
131
+ s := tcell .StyleDefault .Background (tcell .NewRGBColor (r , g , b ))
132
+ mgr .colorscheme ["cursor-line" ] = s
133
+ }
108
134
}
109
135
if ret := mgr .get_color ("visual" ); ret != nil {
110
136
mgr .colorscheme ["selection" ] = * ret
0 commit comments