From 3ade1b7e2033f95cf53e20fa3381e8354bae2cff Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Tue, 19 Sep 2023 16:02:50 +0800 Subject: [PATCH 1/6] Preferences // Use ObjC instead. --- Preferences/Base.lproj/Preferences.xib | 11 ++++++---- Preferences/Preferences.h | 10 +++++++++ Preferences/Preferences.m | 11 ++++++++++ Preferences/Preferences.swift | 20 ------------------ vChewing.xcodeproj/project.pbxproj | 28 +++++++++----------------- 5 files changed, 37 insertions(+), 43 deletions(-) create mode 100644 Preferences/Preferences.h create mode 100644 Preferences/Preferences.m delete mode 100644 Preferences/Preferences.swift diff --git a/Preferences/Base.lproj/Preferences.xib b/Preferences/Base.lproj/Preferences.xib index af488e3c3..63ebca7ac 100644 --- a/Preferences/Base.lproj/Preferences.xib +++ b/Preferences/Base.lproj/Preferences.xib @@ -1,15 +1,15 @@ - + - + - + @@ -23,7 +23,7 @@ - + @@ -39,6 +39,9 @@ Memo: This screen is only for testing whether customized IME preferences work in + + + diff --git a/Preferences/Preferences.h b/Preferences/Preferences.h new file mode 100644 index 000000000..64e263cfd --- /dev/null +++ b/Preferences/Preferences.h @@ -0,0 +1,10 @@ +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface Preferences : NSPreferencePane +@property (strong) IBOutlet NSTextField *lblDisclaimer; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Preferences/Preferences.m b/Preferences/Preferences.m new file mode 100644 index 000000000..d2a216b49 --- /dev/null +++ b/Preferences/Preferences.m @@ -0,0 +1,11 @@ +#import "Preferences.h" + +@implementation Preferences + +-(void) mainViewDidLoad { + [[self mainView] setFrameSize: NSMakeSize(420.0f, 330.0f)]; + [_lblDisclaimer sizeToFit]; + [_lblDisclaimer setFrameSize: NSMakeSize(384.0f, 296.0f)]; +} + +@end diff --git a/Preferences/Preferences.swift b/Preferences/Preferences.swift deleted file mode 100644 index 04caea8bc..000000000 --- a/Preferences/Preferences.swift +++ /dev/null @@ -1,20 +0,0 @@ -import PreferencePanes - -@objc(Preferences) -public class Preferences: NSPreferencePane { - @IBOutlet var lblDisclaimer: NSTextField! - override public func mainViewDidLoad() { - // let label: NSTextField = { - // let result = NSTextField() - // result.stringValue = "114514" - // result.font = NSFont.systemFont(ofSize: 12) - // result.isEditable = false - // result.isSelectable = false - // return result - // }() - // mainView.addSubview(label) - mainView.setFrameSize(.init(width: 420, height: 330.0)) - lblDisclaimer.sizeToFit() - lblDisclaimer.setFrameSize(.init(width: 384.0, height: 296.0)) - } -} diff --git a/vChewing.xcodeproj/project.pbxproj b/vChewing.xcodeproj/project.pbxproj index 8b5dc910b..98a61b744 100644 --- a/vChewing.xcodeproj/project.pbxproj +++ b/vChewing.xcodeproj/project.pbxproj @@ -11,7 +11,6 @@ 5B0E22A628FC11B900EB7ACA /* Preferences.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 5B0E22A528FC11B900EB7ACA /* Preferences.tiff */; }; 5B0E22A928FC11B900EB7ACA /* Preferences.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5B0E22A728FC11B900EB7ACA /* Preferences.xib */; }; 5B0E22B028FC17CB00EB7ACA /* Preferences.prefPane in Resources */ = {isa = PBXBuildFile; fileRef = 5B0E229F28FC11B900EB7ACA /* Preferences.prefPane */; }; - 5B0E22B228FC318C00EB7ACA /* Preferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B0E22B128FC318C00EB7ACA /* Preferences.swift */; }; 5B0EF55D28CDBF7100F8F7CE /* frmClientListMgr.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5B0EF55C28CDBF7100F8F7CE /* frmClientListMgr.xib */; }; 5B0EF55F28CDBF8E00F8F7CE /* CtlClientListMgr.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B0EF55E28CDBF8E00F8F7CE /* CtlClientListMgr.swift */; }; 5B1C98B929436CEE0019B807 /* data-bpmf-reverse-lookup.json in Resources */ = {isa = PBXBuildFile; fileRef = 5B1C98B729436CED0019B807 /* data-bpmf-reverse-lookup.json */; }; @@ -34,6 +33,8 @@ 5B70F4EA2A0BE900005EA8C4 /* MenuIcon-SCVIM.png in Resources */ = {isa = PBXBuildFile; fileRef = 5B70F4E62A0BE900005EA8C4 /* MenuIcon-SCVIM.png */; }; 5B70F4EB2A0BE900005EA8C4 /* MenuIcon-SCVIM@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 5B70F4E72A0BE900005EA8C4 /* MenuIcon-SCVIM@2x.png */; }; 5B70F4EC2A0BE900005EA8C4 /* MenuIcon-TCVIM@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 5B70F4E82A0BE900005EA8C4 /* MenuIcon-TCVIM@2x.png */; }; + 5B72D55C2AB98B8300FB88CE /* Preferences.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B72D55A2AB98B8300FB88CE /* Preferences.h */; }; + 5B72D55D2AB98B8300FB88CE /* Preferences.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B72D55B2AB98B8300FB88CE /* Preferences.m */; }; 5B765F09293A253C00122315 /* PhraseEditorUI in Frameworks */ = {isa = PBXBuildFile; productRef = 5B765F08293A253C00122315 /* PhraseEditorUI */; }; 5B78EE0D28A562B4009456C1 /* VwrPrefPaneDevZone.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B78EE0C28A562B4009456C1 /* VwrPrefPaneDevZone.swift */; }; 5B7BC4B027AFFBE800F66C24 /* frmPrefWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5B7BC4AE27AFFBE800F66C24 /* frmPrefWindow.xib */; }; @@ -165,7 +166,6 @@ 5B0E22A528FC11B900EB7ACA /* Preferences.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Preferences.tiff; sourceTree = ""; }; 5B0E22A828FC11B900EB7ACA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/Preferences.xib; sourceTree = ""; }; 5B0E22AA28FC11B900EB7ACA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 5B0E22B128FC318C00EB7ACA /* Preferences.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Preferences.swift; sourceTree = ""; }; 5B0EF55C28CDBF7100F8F7CE /* frmClientListMgr.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = frmClientListMgr.xib; sourceTree = ""; }; 5B0EF55E28CDBF8E00F8F7CE /* CtlClientListMgr.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CtlClientListMgr.swift; sourceTree = ""; }; 5B18BA6F27C7BD8B0056EB19 /* LICENSE-CHS.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = "LICENSE-CHS.txt"; sourceTree = ""; }; @@ -198,6 +198,8 @@ 5B70F4E62A0BE900005EA8C4 /* MenuIcon-SCVIM.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "MenuIcon-SCVIM.png"; sourceTree = ""; }; 5B70F4E72A0BE900005EA8C4 /* MenuIcon-SCVIM@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "MenuIcon-SCVIM@2x.png"; sourceTree = ""; }; 5B70F4E82A0BE900005EA8C4 /* MenuIcon-TCVIM@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "MenuIcon-TCVIM@2x.png"; sourceTree = ""; }; + 5B72D55A2AB98B8300FB88CE /* Preferences.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Preferences.h; sourceTree = ""; }; + 5B72D55B2AB98B8300FB88CE /* Preferences.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Preferences.m; sourceTree = ""; }; 5B765F07293A250000122315 /* vChewing_PhraseEditorUI */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = vChewing_PhraseEditorUI; path = Packages/vChewing_PhraseEditorUI; sourceTree = ""; }; 5B78EE0C28A562B4009456C1 /* VwrPrefPaneDevZone.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VwrPrefPaneDevZone.swift; sourceTree = ""; }; 5B7BC4AF27AFFBE800F66C24 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/frmPrefWindow.xib; sourceTree = ""; }; @@ -347,7 +349,8 @@ 5B0E22A028FC11B900EB7ACA /* Preferences */ = { isa = PBXGroup; children = ( - 5B0E22B128FC318C00EB7ACA /* Preferences.swift */, + 5B72D55A2AB98B8300FB88CE /* Preferences.h */, + 5B72D55B2AB98B8300FB88CE /* Preferences.m */, 5B0E22A528FC11B900EB7ACA /* Preferences.tiff */, 5B0E22A728FC11B900EB7ACA /* Preferences.xib */, 5B0E22AA28FC11B900EB7ACA /* Info.plist */, @@ -648,6 +651,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 5B72D55C2AB98B8300FB88CE /* Preferences.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -754,7 +758,7 @@ TargetAttributes = { 5B0E229E28FC11B900EB7ACA = { CreatedOnToolsVersion = 14.0; - LastSwiftMigration = 1400; + LastSwiftMigration = 1500; }; 6A0D4EA115FC0D2D00ABF4B3 = { LastSwiftMigration = 1400; @@ -956,7 +960,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 5B0E22B228FC318C00EB7ACA /* Preferences.swift in Sources */, + 5B72D55D2AB98B8300FB88CE /* Preferences.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1157,13 +1161,6 @@ INFOPLIST_KEY_NSMainNibFile = Preferences; INFOPLIST_KEY_NSPrincipalClass = Preferences; INSTALL_PATH = "$(HOME)/Library/PreferencePanes"; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "$(LD_RUNPATH_SEARCH_PATHS_SHALLOW_BUNDLE_$(SHALLOW_BUNDLE))", - "@loader_path/../Frameworks", - "@loader_path/../../../../Frameworks", - /usr/lib/swift, - ); MACOSX_DEPLOYMENT_TARGET = 10.13.4; MARKETING_VERSION = 3.5.5; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; @@ -1206,13 +1203,6 @@ INFOPLIST_KEY_NSMainNibFile = Preferences; INFOPLIST_KEY_NSPrincipalClass = Preferences; INSTALL_PATH = "$(HOME)/Library/PreferencePanes"; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "$(LD_RUNPATH_SEARCH_PATHS_SHALLOW_BUNDLE_$(SHALLOW_BUNDLE))", - "@loader_path/../Frameworks", - "@loader_path/../../../../Frameworks", - /usr/lib/swift, - ); MACOSX_DEPLOYMENT_TARGET = 10.13.4; MARKETING_VERSION = 3.5.5; MTL_ENABLE_DEBUG_INFO = NO; From 1e6ab8c6e4fb689e1c8f5e6067254e1f69c51f38 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Tue, 19 Sep 2023 16:10:31 +0800 Subject: [PATCH 2/6] Repo // Use Xcode 15 recommended settings. --- vChewing.xcodeproj/project.pbxproj | 14 ++++++++++++-- .../xcshareddata/xcschemes/vChewing.xcscheme | 2 +- .../xcschemes/vChewingInstaller.xcscheme | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/vChewing.xcodeproj/project.pbxproj b/vChewing.xcodeproj/project.pbxproj index 98a61b744..3d97369d6 100644 --- a/vChewing.xcodeproj/project.pbxproj +++ b/vChewing.xcodeproj/project.pbxproj @@ -753,8 +753,9 @@ 6A0D4E9415FC0CFA00ABF4B3 /* Project object */ = { isa = PBXProject; attributes = { + BuildIndependentTargetsInParallel = YES; LastSwiftUpdateCheck = 1340; - LastUpgradeCheck = 1400; + LastUpgradeCheck = 1500; TargetAttributes = { 5B0E229E28FC11B900EB7ACA = { CreatedOnToolsVersion = 14.0; @@ -913,6 +914,10 @@ "$(SRCROOT)/Source/Data/components/common/data-zhuyinwen.txt", "$(SRCROOT)/Source/Data/components/common/phone-header.txt", "$(SRCROOT)/DataCompiler/dataCompiler.swift", + "$(SRCROOT)/Source/Data/components/chs/phrases-custom-genshin-chs.txt", + "$(SRCROOT)/Source/Data/components/cht/phrases-custom-genshin-cht.txt", + "$(SRCROOT)/Source/Data/components/chs/phrases-custom-seikyuutetsudou-chs.txt", + "$(SRCROOT)/Source/Data/components/cht/phrases-custom-seikyuutetsudou-cht.txt", ); name = "Run Script (Build Dictionary Data)"; outputFileListPaths = ( @@ -933,7 +938,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "# Type a script or drag a script file from your workspace to insert its path.\ncd ${SRCROOT}\nswiftc ${SRCROOT}/DataCompiler/dataCompiler.swift -o ${SRCROOT}/DataCompiler/cook_mac.exe\nmv ${SRCROOT}/DataCompiler/cook_mac.exe ${SRCROOT}/Source/Data/bin/cook_mac.exe\ncd ${SRCROOT}/Source/Data/\n./bin/cook_mac.exe\n"; + shellScript = "# Type a script or drag a script file from your workspace to insert its path.\ncd ${SRCROOT}/Source/Data/\nswift ${SRCROOT}/DataCompiler/dataCompiler.swift\n"; }; 6A225A2023679F5F00F685C6 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; @@ -1234,6 +1239,7 @@ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -1244,6 +1250,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; @@ -1279,6 +1286,7 @@ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -1288,6 +1296,7 @@ DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; @@ -1302,6 +1311,7 @@ "$(OTHER_CFLAGS)", "-fcxx-modules", ); + SWIFT_COMPILATION_MODE = wholemodule; }; name = Release; }; diff --git a/vChewing.xcodeproj/xcshareddata/xcschemes/vChewing.xcscheme b/vChewing.xcodeproj/xcshareddata/xcschemes/vChewing.xcscheme index 3216c79f8..8408f2038 100644 --- a/vChewing.xcodeproj/xcshareddata/xcschemes/vChewing.xcscheme +++ b/vChewing.xcodeproj/xcshareddata/xcschemes/vChewing.xcscheme @@ -1,6 +1,6 @@ Date: Tue, 19 Sep 2023 17:26:56 +0800 Subject: [PATCH 3/6] NSAttributedTextView // Fix content size. --- .../NSAttributedTextView/NSAttributedTextView.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Packages/Fuziki_NSAttributedTextView/Sources/NSAttributedTextView/NSAttributedTextView.swift b/Packages/Fuziki_NSAttributedTextView/Sources/NSAttributedTextView/NSAttributedTextView.swift index ae4030f52..2ab8c6a21 100644 --- a/Packages/Fuziki_NSAttributedTextView/Sources/NSAttributedTextView/NSAttributedTextView.swift +++ b/Packages/Fuziki_NSAttributedTextView/Sources/NSAttributedTextView/NSAttributedTextView.swift @@ -72,6 +72,16 @@ public class NSAttributedTextView: NSView { } } + public init() { + super.init(frame: .zero) + clipsToBounds = true // 得手動聲明該特性,否則該 View 的尺寸會失控。 + } + + @available(*, unavailable) + required init?(coder _: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + public func attributedStringValue(areaCalculation: Bool = false) -> NSAttributedString { var newAttributes = attributes let isVertical: Bool = !(direction == .horizontal) From 24207008d91cbe83c8080ad3837ea9958e622bb0 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 20 Sep 2023 13:19:30 +0800 Subject: [PATCH 4/6] NSAttributedTextView // Backporting to macOS 10.9 Mavericks. --- .../Fuziki_NSAttributedTextView/Package.swift | 4 ++ .../NSAttributedTextView.swift | 14 ++++- .../NSAttributedTextViewTests.swift | 62 +++++++++++++++++++ 3 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 Packages/Fuziki_NSAttributedTextView/Tests/NSAttributedTextViewTests/NSAttributedTextViewTests.swift diff --git a/Packages/Fuziki_NSAttributedTextView/Package.swift b/Packages/Fuziki_NSAttributedTextView/Package.swift index 5a574d6ec..aea4a03a7 100644 --- a/Packages/Fuziki_NSAttributedTextView/Package.swift +++ b/Packages/Fuziki_NSAttributedTextView/Package.swift @@ -22,5 +22,9 @@ let package = Package( .product(name: "CocoaExtension", package: "vChewing_CocoaExtension"), ] ), + .testTarget( + name: "NSAttributedTextViewTests", + dependencies: ["NSAttributedTextView"] + ), ] ) diff --git a/Packages/Fuziki_NSAttributedTextView/Sources/NSAttributedTextView/NSAttributedTextView.swift b/Packages/Fuziki_NSAttributedTextView/Sources/NSAttributedTextView/NSAttributedTextView.swift index 2ab8c6a21..3a5128e99 100644 --- a/Packages/Fuziki_NSAttributedTextView/Sources/NSAttributedTextView/NSAttributedTextView.swift +++ b/Packages/Fuziki_NSAttributedTextView/Sources/NSAttributedTextView/NSAttributedTextView.swift @@ -141,8 +141,7 @@ public class NSAttributedTextView: NSView { } override public func draw(_ rect: CGRect) { - let context = NSGraphicsContext.current?.cgContext - guard let context = context else { return } + guard let currentNSGraphicsContext = NSGraphicsContext.current else { return } let setter = CTFramesetterCreateWithAttributedString(attributedStringValue()) let path = CGPath(rect: rect, transform: nil) let theCTFrameProgression: CTFrameProgression = { @@ -162,7 +161,16 @@ public class NSAttributedTextView: NSView { let bgPath: NSBezierPath = .init(roundedRect: rect, xRadius: 0, yRadius: 0) bgPath.fill() currentRect = rect - CTFrameDraw(newFrame, context) + if #unavailable(macOS 10.10) { + // 由於 NSGraphicsContext.current?.cgContext 僅對 macOS 10.10 Yosemite 開始的系統開放, + // 所以這裡必須直接從記憶體位置拿取原始資料來處理。 + let contextPtr: Unmanaged? = Unmanaged.fromOpaque(currentNSGraphicsContext.graphicsPort) + let theContext: CGContext? = contextPtr?.takeUnretainedValue() + guard let theContext = theContext else { return } + CTFrameDraw(newFrame, theContext) + } else { + CTFrameDraw(newFrame, currentNSGraphicsContext.cgContext) + } } } diff --git a/Packages/Fuziki_NSAttributedTextView/Tests/NSAttributedTextViewTests/NSAttributedTextViewTests.swift b/Packages/Fuziki_NSAttributedTextView/Tests/NSAttributedTextViewTests/NSAttributedTextViewTests.swift new file mode 100644 index 000000000..013b2db7a --- /dev/null +++ b/Packages/Fuziki_NSAttributedTextView/Tests/NSAttributedTextViewTests/NSAttributedTextViewTests.swift @@ -0,0 +1,62 @@ +// (c) 2021 and onwards The vChewing Project (MIT-NTL License). +// ==================== +// This code is released under the MIT license (SPDX-License-Identifier: MIT) +// ... with NTL restriction stating that: +// No trademark license is granted to use the trade names, trademarks, service +// marks, or product names of Contributor, except as required to fulfill notice +// requirements defined in MIT License. + +import AppKit +import CocoaExtension +import Foundation +@testable import NSAttributedTextView +import Shared +import XCTest + +class MainAssemblyTests: XCTestCase { + func testView() throws { + let testCtl: testController = .init() + var rect = testCtl.attrView.shrinkFrame() + var bigRect = rect + bigRect.size.width += NSFont.systemFontSize + bigRect.size.height += NSFont.systemFontSize + rect.origin.x += ceil(NSFont.systemFontSize / 2) + rect.origin.y += ceil(NSFont.systemFontSize / 2) + testCtl.attrView.frame = rect + testCtl.window?.setFrame(bigRect, display: true) + testCtl.window?.orderFront(nil) + testCtl.attrView.draw(testCtl.attrView.frame) + testCtl.window?.setIsVisible(true) + } +} + +class testController: NSWindowController { + var attrView: NSAttributedTextView + init() { + let contentRect = NSRect(x: 128.0, y: 128.0, width: 300.0, height: 20.0) + let styleMask: NSWindow.StyleMask = [.borderless, .nonactivatingPanel] + let panel = NSPanel( + contentRect: contentRect, styleMask: styleMask, backing: .buffered, defer: false + ) + panel.level = NSWindow.Level(Int(max(CGShieldingWindowLevel(), kCGPopUpMenuWindowLevel)) + 2) + panel.hasShadow = true + panel.backgroundColor = NSColor.clear + panel.isOpaque = false + panel.isMovable = false + panel.contentView?.wantsLayer = true + panel.contentView?.layer?.cornerRadius = 7 + panel.contentView?.layer?.backgroundColor = NSColor.controlBackgroundColor.cgColor + attrView = NSAttributedTextView() + attrView.backgroundColor = NSColor.clear + attrView.textColor = NSColor.textColor + attrView.needsDisplay = true + attrView.text = "114514" + panel.contentView?.addSubview(attrView) + super.init(window: panel) + } + + @available(*, unavailable) + required init?(coder _: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} From aa1afd146ea088436e04781ed82981799a250119 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 20 Sep 2023 14:28:01 +0800 Subject: [PATCH 5/6] IMKHelper // Fix an error while freeing a pointer. --- .../Sources/IMKUtils/TISInputSourceExtension.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packages/vChewing_IMKUtils/Sources/IMKUtils/TISInputSourceExtension.swift b/Packages/vChewing_IMKUtils/Sources/IMKUtils/TISInputSourceExtension.swift index a291076d9..c6112b3c6 100644 --- a/Packages/vChewing_IMKUtils/Sources/IMKUtils/TISInputSourceExtension.swift +++ b/Packages/vChewing_IMKUtils/Sources/IMKUtils/TISInputSourceExtension.swift @@ -128,7 +128,7 @@ public extension TISInputSource { kTISPropertyInputSourceIsASCIICapable: kCFBooleanTrue as CFBoolean, ] // 返回鍵盤配列清單。 - var result = TISCreateInputSourceList(dicConditions as CFDictionary, true).takeRetainedValue() as? [TISInputSource] ?? .init() + var result = TISCreateInputSourceList(dicConditions as CFDictionary, true)?.takeRetainedValue() as? [TISInputSource] ?? .init() if onlyASCII { result = result.filter { $0.scriptCode == 0 } } From 768fb3f1fc14cd5436987ba7ae37817e3e2c64b0 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 20 Sep 2023 15:57:24 +0800 Subject: [PATCH 6/6] GitHub // Force Xcode 15.x in Github CI. --- .github/workflows/continuous-integration-workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index 3e0643892..d8c631133 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: maxim-lobanov/setup-xcode@v1 with: - xcode-version: latest-stable + xcode-version: '^15.0' - uses: actions/checkout@v1 - name: Clean run: make clean