Skip to content

Commit

Permalink
Rename cwk namespace to cw
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanbaird committed Dec 24, 2023
1 parent 848b656 commit 1fffe7a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Sources/ColorWellKit/Utilities/ColorHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct ColorInfo: CustomStringConvertible {
init(color: NSColor) {
switch color.colorSpace.colorSpaceModel {
case _ where color.type != .componentBased:
cwk_log(
cw_log(
"Attempted to get the components for a non component-based color",
category: .components,
type: .error
Expand Down
2 changes: 1 addition & 1 deletion Sources/ColorWellKit/Utilities/Logging.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ extension LogCategory {
}

/// Sends a message to the logging system using the given category and log level.
func cwk_log(_ message: String, category: LogCategory = .main, type: OSLogType = .default) {
func cw_log(_ message: String, category: LogCategory = .main, type: OSLogType = .default) {
os_log("%@", log: category.log, type: type, message)
}
12 changes: 6 additions & 6 deletions Sources/ColorWellKit/Views/Cocoa/CWColorWellBaseControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,9 @@ extension _CWColorWellBaseControl {
private extension NSColorWell {
@nonobjc static let swizzler: () = {
let originalActivateSel = #selector(activate)
let swizzledActivateSel = #selector(cwk_swizzled_activate)
let swizzledActivateSel = #selector(cw_swizzled_activate)
let originalDeactivateSel = #selector(deactivate)
let swizzledDeactivateSel = #selector(cwk_swizzled_deactivate)
let swizzledDeactivateSel = #selector(cw_swizzled_deactivate)

guard
let originalActivateMethod = class_getInstanceMethod(NSColorWell.self, originalActivateSel),
Expand All @@ -296,7 +296,7 @@ private extension NSColorWell {

// MARK: Activate

@objc private func cwk_swizzled_activate(_ exclusive: Bool) {
@objc private func cw_swizzled_activate(_ exclusive: Bool) {
// important that we capture the last attached object and its color
// BEFORE activating and attaching, so we know what color to take
let lastAttachedObject = NSColorPanel.shared.attachedObjects.last
Expand All @@ -308,7 +308,7 @@ private extension NSColorWell {

// NOTE: since this method and the original have been swizzled,
// a call to this method is actually a call to the original
cwk_swizzled_activate(exclusive)
cw_swizzled_activate(exclusive)

// attach to match CWColorWell's behavior
NSColorPanel.shared.attach(self)
Expand All @@ -327,10 +327,10 @@ private extension NSColorWell {

// MARK: Deactivate

@objc private func cwk_swizzled_deactivate() {
@objc private func cw_swizzled_deactivate() {
// NOTE: since this method and the original have been swizzled,
// a call to this method is actually a call to the original
cwk_swizzled_deactivate()
cw_swizzled_deactivate()

// detach to match CWColorWell's behavior
NSColorPanel.shared.detach(self)
Expand Down
4 changes: 2 additions & 2 deletions Sources/ColorWellKit/Views/Cocoa/CWColorWellPopover.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ extension CWColorWellPopover {

func setPadding() {
guard layoutView.superview === self else {
cwk_log(
cw_log(
"Popover layout view is missing from its expected superview.",
category: .popover
)
Expand Down Expand Up @@ -173,7 +173,7 @@ extension CWColorWellPopover {

private func setRows(with colorWell: CWColorWell) {
guard swatches.isEmpty else {
cwk_log("SwatchLayout rows already set", category: .popover)
cw_log("SwatchLayout rows already set", category: .popover)
return
}

Expand Down

0 comments on commit 1fffe7a

Please sign in to comment.