@@ -9,6 +9,12 @@ import AppKit
99import CodeEditTextView
1010
1111protocol LineFoldPlaceholderDelegate : AnyObject {
12+ func placeholderBackgroundColor( ) -> NSColor
13+ func placeholderTextColor( ) -> NSColor
14+
15+ func placeholderSelectedColor( ) -> NSColor
16+ func placeholderSelectedTextColor( ) -> NSColor
17+
1218 func placeholderDiscarded( fold: FoldRange )
1319}
1420
@@ -25,34 +31,46 @@ class LineFoldPlaceholder: TextAttachment {
2531 }
2632
2733 var width : CGFloat {
28- charWidth * 3
34+ charWidth * 5
2935 }
3036
3137 func draw( in context: CGContext , rect: NSRect ) {
3238 context. saveGState ( )
3339
34- let size = charWidth / 3.0
40+ guard let delegate else { return }
41+
42+ let size = charWidth / 2.5
3543 let centerY = rect. midY - ( size / 2.0 )
3644
3745 if isSelected {
38- context. setFillColor ( NSColor . controlAccentColor . cgColor)
46+ context. setFillColor ( delegate . placeholderSelectedColor ( ) . cgColor)
3947 } else {
40- context. setFillColor ( NSColor . tertiaryLabelColor . cgColor)
48+ context. setFillColor ( delegate . placeholderBackgroundColor ( ) . cgColor)
4149 }
4250
4351 context. addPath (
4452 NSBezierPath (
45- rect: rect. transform ( x: 2.0 , y: 2 , width: - 4.0 , height: - 4.0 ) ,
53+ rect: rect. transform ( x: charWidth , y: 2.0 , width: - charWidth * 2 , height: - 4.0 ) ,
4654 roundedCorners: . all,
47- cornerRadius: ( rect. height - 4 ) / 2
55+ cornerRadius: rect. height / 2
4856 ) . cgPathFallback
4957 )
5058 context. fillPath ( )
5159
52- context. setFillColor ( NSColor . secondaryLabelColor. cgColor)
53- context. addEllipse ( in: CGRect ( x: rect. minX + charWidth - ( size / 2 ) , y: centerY, width: size, height: size) )
54- context. addEllipse ( in: CGRect ( x: rect. midX - ( size / 2 ) , y: centerY, width: size, height: size) )
55- context. addEllipse ( in: CGRect ( x: rect. maxX - charWidth - ( size / 2 ) , y: centerY, width: size, height: size) )
60+ if isSelected {
61+ context. setFillColor ( delegate. placeholderSelectedTextColor ( ) . cgColor)
62+ } else {
63+ context. setFillColor ( delegate. placeholderTextColor ( ) . cgColor)
64+ }
65+ context. addEllipse (
66+ in: CGRect ( x: rect. minX + ( charWidth * 2 ) - size, y: centerY, width: size, height: size)
67+ )
68+ context. addEllipse (
69+ in: CGRect ( x: rect. midX - ( size / 2 ) , y: centerY, width: size, height: size)
70+ )
71+ context. addEllipse (
72+ in: CGRect ( x: rect. maxX - ( charWidth * 2 ) , y: centerY, width: size, height: size)
73+ )
5674 context. fillPath ( )
5775
5876 context. restoreGState ( )
0 commit comments