-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathSettingsViewController.swift
More file actions
53 lines (40 loc) · 1.33 KB
/
SettingsViewController.swift
File metadata and controls
53 lines (40 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//
// SettingsViewController.swift
// Comment Wrapper Host
//
// Created by Peter Schorn on 5/11/21.
// Copyright © 2021 Steve Barnegren. All rights reserved.
//
import AppKit
class SettingsViewController: NSViewController {
@IBOutlet weak var lineLengthPopupButton: NSPopUpButton!
override func viewDidLoad() {
super.viewDidLoad()
for option in LineLengthOption.allCases {
self.lineLengthPopupButton.addItem(withTitle: option.rawValue)
}
switch Settings.lineLength {
case .absolute:
self.lineLengthPopupButton.selectItem(at: 1)
default /* .excludingLeadingIndentation */:
self.lineLengthPopupButton.selectItem(at: 0)
}
}
@IBAction func selectedLineLengthPopupButton(
_ popupButton: NSPopUpButton
) {
let lineLength: LineLengthOption
let index = popupButton.indexOfSelectedItem
switch index {
case 0:
lineLength = .excludingLeadingIndentation
case 1:
lineLength = .absolute
default:
print("unexpected index for popup button: \(index)")
return
}
Settings.lineLength = lineLength
print("set line length to \(lineLength)")
}
}