@@ -15,6 +15,7 @@ final class AdvancedPref: PrefPane, UiComponent, NSTextFieldDelegate {
15
15
case setUseSnapshotUpdate( Bool )
16
16
case setUseLiveResize( Bool )
17
17
case setDrawsParallel( Bool )
18
+ case setNvimBinary( String )
18
19
}
19
20
20
21
override var displayName : String {
@@ -32,6 +33,7 @@ final class AdvancedPref: PrefPane, UiComponent, NSTextFieldDelegate {
32
33
self . useSnapshotUpdate = state. useSnapshotUpdate
33
34
self . useLiveResize = state. mainWindowTemplate. useLiveResize
34
35
self . drawsParallel = state. mainWindowTemplate. drawsParallel
36
+ self . nvimBinary = state. mainWindowTemplate. nvimBinary
35
37
36
38
super. init ( frame: . zero)
37
39
@@ -42,11 +44,13 @@ final class AdvancedPref: PrefPane, UiComponent, NSTextFieldDelegate {
42
44
. observe ( on: MainScheduler . instance)
43
45
. subscribe ( onNext: { state in
44
46
if self . useInteractiveZsh != state. mainWindowTemplate. useInteractiveZsh
47
+ || self . nvimBinary != state. mainWindowTemplate. nvimBinary
45
48
|| self . useSnapshotUpdate != state. useSnapshotUpdate
46
49
|| self . useLiveResize != state. mainWindowTemplate. useLiveResize
47
50
|| self . drawsParallel != state. mainWindowTemplate. drawsParallel
48
51
{
49
52
self . useInteractiveZsh = state. mainWindowTemplate. useInteractiveZsh
53
+ self . nvimBinary = state. mainWindowTemplate. nvimBinary
50
54
self . useSnapshotUpdate = state. useSnapshotUpdate
51
55
self . useLiveResize = state. mainWindowTemplate. useLiveResize
52
56
self . drawsParallel = state. mainWindowTemplate. drawsParallel
@@ -64,22 +68,29 @@ final class AdvancedPref: PrefPane, UiComponent, NSTextFieldDelegate {
64
68
private var useSnapshotUpdate : Bool
65
69
private var useLiveResize : Bool
66
70
private var drawsParallel : Bool
71
+ private var nvimBinary : String
67
72
68
73
private let useInteractiveZshCheckbox = NSButton ( forAutoLayout: ( ) )
69
74
private let useSnapshotUpdateCheckbox = NSButton ( forAutoLayout: ( ) )
70
75
private let useLiveResizeCheckbox = NSButton ( forAutoLayout: ( ) )
71
76
private let drawsParallelCheckbox = NSButton ( forAutoLayout: ( ) )
77
+ private let nvimBinaryField = NSTextView ( forAutoLayout: ( ) )
72
78
73
79
@available ( * , unavailable)
74
80
required init ? ( coder _: NSCoder ) {
75
81
fatalError ( " init(coder:) has not been implemented " )
76
82
}
77
83
84
+ override func windowWillClose( ) {
85
+ self . nvimBinaryFieldAction ( )
86
+ }
87
+
78
88
private func updateViews( ) {
79
89
self . useSnapshotUpdateCheckbox. boolState = self . useSnapshotUpdate
80
90
self . useInteractiveZshCheckbox. boolState = self . useInteractiveZsh
81
91
self . useLiveResizeCheckbox. boolState = self . useLiveResize
82
92
self . drawsParallelCheckbox. boolState = self . drawsParallel
93
+ self . nvimBinaryField. string = self . nvimBinary
83
94
}
84
95
85
96
private func addViews( ) {
@@ -136,6 +147,9 @@ final class AdvancedPref: PrefPane, UiComponent, NSTextFieldDelegate {
136
147
when scrolling very fast.
137
148
"""# )
138
149
150
+ let nvimBinaryTitle = self . titleTextField ( title: " NeoVim Binary: " )
151
+ let nvimBinaryField = self . nvimBinaryField
152
+
139
153
self . addSubview ( paneTitle)
140
154
141
155
self . addSubview ( useSnapshotUpdate)
@@ -146,6 +160,8 @@ final class AdvancedPref: PrefPane, UiComponent, NSTextFieldDelegate {
146
160
self . addSubview ( useLiveResizeInfo)
147
161
self . addSubview ( drawsParallelBox)
148
162
self . addSubview ( drawsParallelInfo)
163
+ self . addSubview ( nvimBinaryTitle)
164
+ self . addSubview ( nvimBinaryField)
149
165
150
166
paneTitle. autoPinEdge ( toSuperviewEdge: . top, withInset: 18 )
151
167
paneTitle. autoPinEdge ( toSuperviewEdge: . left, withInset: 18 )
@@ -174,6 +190,21 @@ final class AdvancedPref: PrefPane, UiComponent, NSTextFieldDelegate {
174
190
175
191
useInteractiveZshInfo. autoPinEdge ( . top, to: . bottom, of: useInteractiveZsh, withOffset: 5 )
176
192
useInteractiveZshInfo. autoPinEdge ( . left, to: . left, of: useInteractiveZsh)
193
+
194
+ nvimBinaryTitle. autoPinEdge ( . top, to: . bottom, of: useInteractiveZshInfo, withOffset: 18 )
195
+ nvimBinaryTitle. autoPinEdge ( . left, to: . left, of: useLiveResize, withOffset: 5 )
196
+ //nvimBinaryTitle.autoAlignAxis(.baseline, toSameAxisOf: nvimBinaryField)
197
+
198
+ nvimBinaryField. autoPinEdge ( . top, to: . bottom, of: useInteractiveZshInfo, withOffset: 18 )
199
+ nvimBinaryField. autoPinEdge ( . left, to: . right, of: nvimBinaryTitle, withOffset: 5 )
200
+ nvimBinaryField. autoPinEdge ( toSuperviewEdge: . right, withInset: 18 )
201
+ nvimBinaryField. autoSetDimension ( . height, toSize: 20 , relation: . greaterThanOrEqual)
202
+ NotificationCenter . default. addObserver (
203
+ forName: NSControl . textDidEndEditingNotification,
204
+ object: nvimBinaryField,
205
+ queue: nil
206
+ ) { [ weak self] _ in self ? . nvimBinaryFieldAction ( ) }
207
+
177
208
}
178
209
}
179
210
@@ -195,4 +226,9 @@ extension AdvancedPref {
195
226
@objc func useSnapshotUpdateChannelAction( _ sender: NSButton ) {
196
227
self . emit ( . setUseSnapshotUpdate( sender. boolState) )
197
228
}
229
+
230
+ func nvimBinaryFieldAction( ) {
231
+ let newNvimBinary = self . nvimBinaryField. string
232
+ self . emit ( . setNvimBinary( newNvimBinary) )
233
+ }
198
234
}
0 commit comments