@@ -27,8 +27,9 @@ final class SquirrelTheme {
27
27
}
28
28
}
29
29
30
- var native = true
31
- var memorizeSize = true
30
+ private( set) var available = true
31
+ private( set) var native = true
32
+ private( set) var memorizeSize = true
32
33
private var colorSpace : RimeColorSpace = . sRGB
33
34
34
35
var backgroundColor : NSColor = . windowBackgroundColor
@@ -213,55 +214,57 @@ final class SquirrelTheme {
213
214
var commentFontSize = config. getDouble ( " style/comment_font_point " )
214
215
215
216
let colorSchemeOption = dark ? " style/color_scheme_dark " : " style/color_scheme "
216
- if let colorScheme = config. getString ( colorSchemeOption) , colorScheme != " native " {
217
- native = false
218
- let prefix = " preset_color_schemes/ \( colorScheme) "
219
- colorSpace = . from( name: config. getString ( " \( prefix) /color_space " ) ?? " " )
220
- backgroundColor ?= config. getColor ( " \( prefix) /back_color " , inSpace: colorSpace)
221
- highlightedPreeditColor = config. getColor ( " \( prefix) /hilited_back_color " , inSpace: colorSpace)
222
- highlightedBackColor = config. getColor ( " \( prefix) /hilited_candidate_back_color " , inSpace: colorSpace) ?? highlightedPreeditColor
223
- preeditBackgroundColor = config. getColor ( " \( prefix) /preedit_back_color " , inSpace: colorSpace)
224
- candidateBackColor = config. getColor ( " \( prefix) /candidate_back_color " , inSpace: colorSpace)
225
- borderColor = config. getColor ( " \( prefix) /border_color " , inSpace: colorSpace)
217
+ if let colorScheme = config. getString ( colorSchemeOption) {
218
+ if colorScheme != " native " {
219
+ native = false
220
+ let prefix = " preset_color_schemes/ \( colorScheme) "
221
+ colorSpace = . from( name: config. getString ( " \( prefix) /color_space " ) ?? " " )
222
+ backgroundColor ?= config. getColor ( " \( prefix) /back_color " , inSpace: colorSpace)
223
+ highlightedPreeditColor = config. getColor ( " \( prefix) /hilited_back_color " , inSpace: colorSpace)
224
+ highlightedBackColor = config. getColor ( " \( prefix) /hilited_candidate_back_color " , inSpace: colorSpace) ?? highlightedPreeditColor
225
+ preeditBackgroundColor = config. getColor ( " \( prefix) /preedit_back_color " , inSpace: colorSpace)
226
+ candidateBackColor = config. getColor ( " \( prefix) /candidate_back_color " , inSpace: colorSpace)
227
+ borderColor = config. getColor ( " \( prefix) /border_color " , inSpace: colorSpace)
226
228
227
- textColor ?= config. getColor ( " \( prefix) /text_color " , inSpace: colorSpace)
228
- highlightedTextColor = config. getColor ( " \( prefix) /hilited_text_color " , inSpace: colorSpace) ?? textColor
229
- candidateTextColor = config. getColor ( " \( prefix) /candidate_text_color " , inSpace: colorSpace) ?? textColor
230
- highlightedCandidateTextColor = config. getColor ( " \( prefix) /hilited_candidate_text_color " , inSpace: colorSpace) ?? highlightedTextColor
231
- candidateLabelColor = config. getColor ( " \( prefix) /label_color " , inSpace: colorSpace)
232
- highlightedCandidateLabelColor = config. getColor ( " \( prefix) /hilited_candidate_label_color " , inSpace: colorSpace)
233
- commentTextColor = config. getColor ( " \( prefix) /comment_text_color " , inSpace: colorSpace)
234
- highlightedCommentTextColor = config. getColor ( " \( prefix) /hilited_comment_text_color " , inSpace: colorSpace)
229
+ textColor ?= config. getColor ( " \( prefix) /text_color " , inSpace: colorSpace)
230
+ highlightedTextColor = config. getColor ( " \( prefix) /hilited_text_color " , inSpace: colorSpace) ?? textColor
231
+ candidateTextColor = config. getColor ( " \( prefix) /candidate_text_color " , inSpace: colorSpace) ?? textColor
232
+ highlightedCandidateTextColor = config. getColor ( " \( prefix) /hilited_candidate_text_color " , inSpace: colorSpace) ?? highlightedTextColor
233
+ candidateLabelColor = config. getColor ( " \( prefix) /label_color " , inSpace: colorSpace)
234
+ highlightedCandidateLabelColor = config. getColor ( " \( prefix) /hilited_candidate_label_color " , inSpace: colorSpace)
235
+ commentTextColor = config. getColor ( " \( prefix) /comment_text_color " , inSpace: colorSpace)
236
+ highlightedCommentTextColor = config. getColor ( " \( prefix) /hilited_comment_text_color " , inSpace: colorSpace)
235
237
236
- // the following per-color-scheme configurations, if exist, will
237
- // override configurations with the same name under the global 'style'
238
- // section
239
- linear ?= config. getString ( " \( prefix) /candidate_list_layout " ) . map { $0 == " linear " }
240
- vertical ?= config. getString ( " \( prefix) /text_orientation " ) . map { $0 == " vertical " }
241
- inlinePreedit ?= config. getBool ( " \( prefix) /inline_preedit " )
242
- inlineCandidate ?= config. getBool ( " \( prefix) /inline_candidate " )
243
- translucency ?= config. getBool ( " \( prefix) /translucency " )
244
- mutualExclusive ?= config. getBool ( " \( prefix) /mutual_exclusive " )
245
- candidateFormat ?= config. getString ( " \( prefix) /candidate_format " )
246
- fontName ?= config. getString ( " \( prefix) /font_face " )
247
- fontSize ?= config. getDouble ( " \( prefix) /font_point " )
248
- labelFontName ?= config. getString ( " \( prefix) /label_font_face " )
249
- labelFontSize ?= config. getDouble ( " \( prefix) /label_font_point " )
250
- commentFontName ?= config. getString ( " \( prefix) /comment_font_face " )
251
- commentFontSize ?= config. getDouble ( " \( prefix) /comment_font_point " )
238
+ // the following per-color-scheme configurations, if exist, will
239
+ // override configurations with the same name under the global 'style'
240
+ // section
241
+ linear ?= config. getString ( " \( prefix) /candidate_list_layout " ) . map { $0 == " linear " }
242
+ vertical ?= config. getString ( " \( prefix) /text_orientation " ) . map { $0 == " vertical " }
243
+ inlinePreedit ?= config. getBool ( " \( prefix) /inline_preedit " )
244
+ inlineCandidate ?= config. getBool ( " \( prefix) /inline_candidate " )
245
+ translucency ?= config. getBool ( " \( prefix) /translucency " )
246
+ mutualExclusive ?= config. getBool ( " \( prefix) /mutual_exclusive " )
247
+ candidateFormat ?= config. getString ( " \( prefix) /candidate_format " )
248
+ fontName ?= config. getString ( " \( prefix) /font_face " )
249
+ fontSize ?= config. getDouble ( " \( prefix) /font_point " )
250
+ labelFontName ?= config. getString ( " \( prefix) /label_font_face " )
251
+ labelFontSize ?= config. getDouble ( " \( prefix) /label_font_point " )
252
+ commentFontName ?= config. getString ( " \( prefix) /comment_font_face " )
253
+ commentFontSize ?= config. getDouble ( " \( prefix) /comment_font_point " )
252
254
253
- alpha ?= config. getDouble ( " \( prefix) /alpha " ) . map { max ( 0 , min ( 1 , $0) ) }
254
- cornerRadius ?= config. getDouble ( " \( prefix) /corner_radius " )
255
- hilitedCornerRadius ?= config. getDouble ( " \( prefix) /hilited_corner_radius " )
256
- surroundingExtraExpansion ?= config. getDouble ( " \( prefix) /surrounding_extra_expansion " )
257
- borderHeight ?= config. getDouble ( " \( prefix) /border_height " )
258
- borderWidth ?= config. getDouble ( " \( prefix) /border_width " )
259
- linespace ?= config. getDouble ( " \( prefix) /line_spacing " )
260
- preeditLinespace ?= config. getDouble ( " \( prefix) /spacing " )
261
- baseOffset ?= config. getDouble ( " \( prefix) /base_offset " )
262
- shadowSize ?= config. getDouble ( " \( prefix) /shadow_size " ) . map { max ( 0 , $0) }
255
+ alpha ?= config. getDouble ( " \( prefix) /alpha " ) . map { max ( 0 , min ( 1 , $0) ) }
256
+ cornerRadius ?= config. getDouble ( " \( prefix) /corner_radius " )
257
+ hilitedCornerRadius ?= config. getDouble ( " \( prefix) /hilited_corner_radius " )
258
+ surroundingExtraExpansion ?= config. getDouble ( " \( prefix) /surrounding_extra_expansion " )
259
+ borderHeight ?= config. getDouble ( " \( prefix) /border_height " )
260
+ borderWidth ?= config. getDouble ( " \( prefix) /border_width " )
261
+ linespace ?= config. getDouble ( " \( prefix) /line_spacing " )
262
+ preeditLinespace ?= config. getDouble ( " \( prefix) /spacing " )
263
+ baseOffset ?= config. getDouble ( " \( prefix) /base_offset " )
264
+ shadowSize ?= config. getDouble ( " \( prefix) /shadow_size " ) . map { max ( 0 , $0) }
265
+ }
263
266
} else {
264
- native = true
267
+ available = false
265
268
}
266
269
267
270
fonts = decodeFonts ( from: fontName)
0 commit comments