Skip to content

Commit

Permalink
fix: 修复变量名拼写错误的问题 close #85
Browse files Browse the repository at this point in the history
  • Loading branch information
qwertyyb committed Nov 5, 2022
1 parent 80c839c commit 9901456
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 33 deletions.
8 changes: 4 additions & 4 deletions Fire.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
4500AC622869F8CC006F3FCC /* PunctutionPane.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4500AC612869F8CC006F3FCC /* PunctutionPane.swift */; };
4500AC622869F8CC006F3FCC /* PunctuationPane.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4500AC612869F8CC006F3FCC /* PunctuationPane.swift */; };
4500AC64286F2B42006F3FCC /* UserDictPane.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4500AC63286F2B42006F3FCC /* UserDictPane.swift */; };
4500AC68287036CB006F3FCC /* DictManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4500AC67287036CB006F3FCC /* DictManager.swift */; };
450B7D9A26A2847D00808A4D /* ApplicationPane.swift in Sources */ = {isa = PBXBuildFile; fileRef = 450B7D9926A2847D00808A4D /* ApplicationPane.swift */; };
Expand Down Expand Up @@ -79,7 +79,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
4500AC612869F8CC006F3FCC /* PunctutionPane.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PunctutionPane.swift; sourceTree = "<group>"; };
4500AC612869F8CC006F3FCC /* PunctuationPane.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PunctuationPane.swift; sourceTree = "<group>"; };
4500AC63286F2B42006F3FCC /* UserDictPane.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDictPane.swift; sourceTree = "<group>"; };
4500AC67287036CB006F3FCC /* DictManager.swift */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.swift; path = DictManager.swift; sourceTree = "<group>"; };
450B7D9926A2847D00808A4D /* ApplicationPane.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplicationPane.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -255,7 +255,7 @@
450B7D9926A2847D00808A4D /* ApplicationPane.swift */,
45DB6EC827E609CB00A39925 /* ThemePane.swift */,
45EBB54F283A311C00A56CBA /* StatisticsPane.swift */,
4500AC612869F8CC006F3FCC /* PunctutionPane.swift */,
4500AC612869F8CC006F3FCC /* PunctuationPane.swift */,
4500AC63286F2B42006F3FCC /* UserDictPane.swift */,
);
path = Preferences;
Expand Down Expand Up @@ -477,7 +477,7 @@
451E6056232E24A5007B0463 /* FireInputController.swift in Sources */,
672C1987287EDAF8002B2540 /* FireInputServer.swift in Sources */,
451E605F232E400B007B0463 /* Fire.swift in Sources */,
4500AC622869F8CC006F3FCC /* PunctutionPane.swift in Sources */,
4500AC622869F8CC006F3FCC /* PunctuationPane.swift in Sources */,
45587F2D24E8FBFB005F291B /* Utils.swift in Sources */,
45577E502543F03F0064325B /* build.swift in Sources */,
45D996AA253C5232001460A8 /* GeneralPane.swift in Sources */,
Expand Down
12 changes: 6 additions & 6 deletions Fire/Fire.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ class Fire: NSObject {

var inputMode: InputMode = .zhhans

func transformPunctution(_ origin: String)-> String? {
let isPunctution = punctution.keys.contains(origin)
if !isPunctution {
func transformPunctuation(_ origin: String)-> String? {
let isPunctuation = punctuation.keys.contains(origin)
if !isPunctuation {
return nil
}
let mode = Defaults[.punctutionMode]
let mode = Defaults[.punctuationMode]
if mode == .enUs {
return origin
}
if mode == .zhhans {
return punctution[origin]
return punctuation[origin]
}
if mode == .custom {
return Defaults[.customPunctutionSettings][origin]
return Defaults[.customPunctuationSettings][origin]
}
return nil
}
Expand Down
6 changes: 3 additions & 3 deletions Fire/FireInputController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ class FireInputController: IMKInputController {
return nil
}

private func punctutionKeyHandler(event: NSEvent) -> Bool? {
private func punctuationKeyHandler(event: NSEvent) -> Bool? {
// 获取输入的字符
let string = event.characters!

// 如果输入的字符是标点符号,转换标点符号为中文符号
if inputMode == .zhhans, let result = Fire.shared.transformPunctution(string) {
if inputMode == .zhhans, let result = Fire.shared.transformPunctuation(string) {
insertText(result)
return true
}
Expand Down Expand Up @@ -268,7 +268,7 @@ class FireInputController: IMKInputController {
deleteKeyHandler,
charKeyHandler,
numberKeyHandlder,
punctutionKeyHandler,
punctuationKeyHandler,
escKeyHandler,
enterKeyHandler,
spaceKeyHandler
Expand Down
2 changes: 1 addition & 1 deletion Fire/Preferences/FirePreferencesController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class FirePreferencesController: NSObject, NSWindowDelegate {
title: "标点符号",
toolbarIcon: NSImage(named: NSImage.fontPanelName) ?? NSImage(named: "general")!
) {
PunctutionPane()
PunctuationPane()
},
Preferences.Pane(
identifier: Preferences.PaneIdentifier(rawValue: "用户词库"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// PunctutionPane.swift
// PunctuationPane.swift
// Fire
//
// Created by 虚幻 on 2022/6/27.
Expand All @@ -10,17 +10,17 @@ import SwiftUI
import Preferences
import Defaults

struct PunctutionPane: View {
@Default(.punctutionMode) private var punctutionMode
@Default(.customPunctutionSettings) private var customPunctutionSettings
struct PunctuationPane: View {
@Default(.punctuationMode) private var punctuationMode
@Default(.customPunctuationSettings) private var customPunctuationSettings
var body: some View {
Preferences.Container(contentWidth: 450) {
Preferences.Section(title: "") {
HStack {
Picker("标点符号方案", selection: $punctutionMode) {
Text("半角").tag(PunctutionMode.enUs)
Text("全角").tag(PunctutionMode.zhhans)
Text("自定义").tag(PunctutionMode.custom)
Picker("标点符号方案", selection: $punctuationMode) {
Text("半角").tag(PunctuationMode.enUs)
Text("全角").tag(PunctuationMode.zhhans)
Text("自定义").tag(PunctuationMode.custom)
}
Spacer(minLength: 150)
}
Expand All @@ -36,21 +36,21 @@ struct PunctutionPane: View {
}
ScrollView {
ForEach(
customPunctutionSettings.sorted(by: <),
customPunctuationSettings.sorted(by: <),
id: \.key) { (key, value) -> AnyView in
AnyView(HStack(spacing: 0) {
Text(key)
.frame(width: 200, alignment: .center)
Picker("", selection: Binding<String>(
get: { value },
set: {
customPunctutionSettings[key] = $0
customPunctuationSettings[key] = $0
}
)) {
Text(key)
.tag(key)
Text(punctution[key]!)
.tag(punctution[key]!)
Text(punctuation[key]!)
.tag(punctuation[key]!)
}
.frame(width: 200, alignment: .center)
})
Expand All @@ -62,14 +62,14 @@ struct PunctutionPane: View {
.padding(.top, 4)
.background(Color(.sRGB, red: 0.4, green: 0.4, blue: 0.4, opacity: 0.2))
}
.disabled(punctutionMode != .custom)
.disabled(punctuationMode != .custom)
}
}
}
}

struct PunctutionPane_Previews: PreviewProvider {
struct PunctuationPane_Previews: PreviewProvider {
static var previews: some View {
PunctutionPane()
PunctuationPane()
}
}
8 changes: 4 additions & 4 deletions Fire/types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class ApplicationSettingItem: ObservableObject, Codable, Identifiable {
}
}

enum PunctutionMode: Codable {
enum PunctuationMode: Codable {
case enUs // 半角
case zhhans // 全角
case custom // 自定义
Expand Down Expand Up @@ -113,8 +113,8 @@ extension Defaults.Keys {
default: [:]
)
// 标点符号配置
static let punctutionMode = Key<PunctutionMode>("punctutionMode", default: PunctutionMode.zhhans)
static let customPunctutionSettings = Key<[String: String]>("customPunctutionSettings", default: punctution)
static let punctuationMode = Key<PunctuationMode>("punctuationMode", default: PunctuationMode.zhhans)
static let customPunctuationSettings = Key<[String: String]>("customPunctuationSettings", default: punctuation)

static let wbTablePath = Key<String>(
"wbTableURL",
Expand Down Expand Up @@ -161,7 +161,7 @@ enum CodeMode: Int, CaseIterable, Decodable, Encodable {
case wubiPinyin
}

let punctution: [String: String] = [
let punctuation: [String: String] = [
",": "",
".": "",
"/": "",
Expand Down

0 comments on commit 9901456

Please sign in to comment.