@@ -13,7 +13,7 @@ struct TextEditingPreferencesView: View {
1313 private var prefs : AppPreferencesModel = . shared
1414
1515 /// only allows integer values in the range of `[1...8]`
16- private var numberFormat : NumberFormatter {
16+ private var tabWidthFormatter : NumberFormatter {
1717 let formatter = NumberFormatter ( )
1818 formatter. allowsFloats = false
1919 formatter. minimum = 1
@@ -22,11 +22,24 @@ struct TextEditingPreferencesView: View {
2222 return formatter
2323 }
2424
25+ /// only allows float values in the range of `[0.75...2.00]`
26+ /// and formats to 2 decimal places.
27+ private var lineHeightFormatter : NumberFormatter {
28+ let formatter = NumberFormatter ( )
29+ formatter. allowsFloats = true
30+ formatter. maximumFractionDigits = 2
31+ formatter. minimumFractionDigits = 2
32+ formatter. minimum = 0.75
33+ formatter. maximum = 2.0
34+
35+ return formatter
36+ }
37+
2538 var body : some View {
2639 PreferencesContent {
2740 PreferencesSection ( " Default Tab Width " ) {
2841 HStack ( spacing: 5 ) {
29- TextField ( " " , value: $prefs. preferences. textEditing. defaultTabWidth, formatter: numberFormat )
42+ TextField ( " " , value: $prefs. preferences. textEditing. defaultTabWidth, formatter: tabWidthFormatter )
3043 . multilineTextAlignment ( . trailing)
3144 . frame ( width: 40 )
3245 Stepper ( " Default Tab Width: " ,
@@ -38,6 +51,9 @@ struct TextEditingPreferencesView: View {
3851 PreferencesSection ( " Font " ) {
3952 fontSelector
4053 }
54+ PreferencesSection ( " Line Height " ) {
55+ lineHeight
56+ }
4157 PreferencesSection ( " Code completion " ) {
4258 autocompleteBraces
4359 enableTypeOverCompletion
@@ -86,4 +102,15 @@ struct TextEditingPreferencesView: View {
86102 }
87103 }
88104
105+ private var lineHeight : some View {
106+ HStack ( spacing: 5 ) {
107+ TextField ( " " , value: $prefs. preferences. textEditing. lineHeightMultiple, formatter: lineHeightFormatter)
108+ . multilineTextAlignment ( . trailing)
109+ . frame ( width: 40 )
110+ Stepper ( " Line Height: " ,
111+ value: $prefs. preferences. textEditing. lineHeightMultiple,
112+ in: 0.75 ... 2.0 ,
113+ step: 0.05 )
114+ }
115+ }
89116}
0 commit comments