Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make access open for mocking/subclassing #56

Merged
merged 6 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/Danger.yml
jasonm23 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
name: Danger

on:
pull_request:
push:
branches:
- master

permissions:
pull-requests: write

jobs:
danger:
runs-on: macos-13
Expand Down
2 changes: 1 addition & 1 deletion Lib/Sauce/InputSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import Foundation
import Carbon

public final class InputSource {
open class InputSource {

// MARK: - Properties
public let id: String
Expand Down
6 changes: 3 additions & 3 deletions Lib/Sauce/ModifierTransformer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import Foundation
import Carbon
import AppKit

final class ModifierTransformer {}
open class ModifierTransformer {}

// MARK: - Cocoa & Carbon
extension ModifierTransformer {
func carbonFlags(from cocoaFlags: NSEvent.ModifierFlags) -> Int {
public func carbonFlags(from cocoaFlags: NSEvent.ModifierFlags) -> Int {
var carbonFlags: Int = 0
if cocoaFlags.contains(.command) {
carbonFlags |= cmdKey
Expand All @@ -33,7 +33,7 @@ extension ModifierTransformer {
return carbonFlags
}

func convertCharactorSupportCarbonModifiers(from carbonModifiers: Int) -> Int {
public func convertCharactorSupportCarbonModifiers(from carbonModifiers: Int) -> Int {
var convertedCarbonModifiers: Int = 0
if (carbonModifiers & optionKey) != 0 {
convertedCarbonModifiers |= optionKey
Expand Down
46 changes: 23 additions & 23 deletions Lib/Sauce/Sauce.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
import Foundation
import AppKit

public extension NSNotification.Name {
extension NSNotification.Name {
static let SauceSelectedKeyboardInputSourceChanged = Notification.Name("SauceSelectedKeyboardInputSourceChanged")
static let SauceEnabledKeyboardInputSourcesChanged = Notification.Name("SauceEnabledKeyboardInputSourcesChanged")
static let SauceSelectedKeyboardKeyCodesChanged = Notification.Name("SauceSelectedKeyboardKeyCodesChanged")
}

public final class Sauce {
open class Sauce {

// MARK: - Properties
public static let shared = Sauce()
Expand All @@ -34,81 +34,81 @@ public final class Sauce {
}

// MARK: - Input Sources
public extension Sauce {
func currentInputSources() -> [InputSource] {
extension Sauce {
public func currentInputSources() -> [InputSource] {
return layout.inputSources
}
}

// MARK: - KeyCodes
public extension Sauce {
func keyCode(for key: Key) -> CGKeyCode {
extension Sauce {
public func keyCode(for key: Key) -> CGKeyCode {
return currentKeyCode(for: key) ?? key.QWERTYKeyCode
}

func currentKeyCode(for key: Key) -> CGKeyCode? {
public func currentKeyCode(for key: Key) -> CGKeyCode? {
return layout.currentKeyCode(for: key)
}

func currentKeyCodes() -> [Key: CGKeyCode]? {
public func currentKeyCodes() -> [Key: CGKeyCode]? {
return layout.currentKeyCodes()
}

func keyCode(with source: InputSource, key: Key) -> CGKeyCode? {
public func keyCode(with source: InputSource, key: Key) -> CGKeyCode? {
return layout.keyCode(with: source, key: key)
}

func keyCodes(with source: InputSource) -> [Key: CGKeyCode]? {
public func keyCodes(with source: InputSource) -> [Key: CGKeyCode]? {
return layout.keyCodes(with: source)
}
}

// MARK: - Key
public extension Sauce {
func key(for keyCode: Int) -> Key? {
extension Sauce {
public func key(for keyCode: Int) -> Key? {
return currentKey(for: keyCode) ?? Key(QWERTYKeyCode: keyCode)
}

func currentKey(for keyCode: Int) -> Key? {
public func currentKey(for keyCode: Int) -> Key? {
return layout.currentKey(for: keyCode)
}

func key(with source: InputSource, keyCode: Int) -> Key? {
public func key(with source: InputSource, keyCode: Int) -> Key? {
return layout.key(with: source, keyCode: keyCode)
}
}

// MARK: - Characters
public extension Sauce {
func character(for keyCode: Int, carbonModifiers: Int) -> String? {
extension Sauce {
public func character(for keyCode: Int, carbonModifiers: Int) -> String? {
return currentCharacter(for: keyCode, carbonModifiers: carbonModifiers) ?? currentASCIICapableCharacter(for: keyCode, carbonModifiers: carbonModifiers)
}

func character(for keyCode: Int, cocoaModifiers: NSEvent.ModifierFlags) -> String? {
public func character(for keyCode: Int, cocoaModifiers: NSEvent.ModifierFlags) -> String? {
return character(for: keyCode, carbonModifiers: modifierTransformar.carbonFlags(from: cocoaModifiers))
}

func currentCharacter(for keyCode: Int, carbonModifiers: Int) -> String? {
public func currentCharacter(for keyCode: Int, carbonModifiers: Int) -> String? {
return layout.currentCharacter(for: keyCode, carbonModifiers: carbonModifiers)
}

func currentCharacter(for keyCode: Int, cocoaModifiers: NSEvent.ModifierFlags) -> String? {
public func currentCharacter(for keyCode: Int, cocoaModifiers: NSEvent.ModifierFlags) -> String? {
return currentCharacter(for: keyCode, carbonModifiers: modifierTransformar.carbonFlags(from: cocoaModifiers))
}

func currentASCIICapableCharacter(for keyCode: Int, carbonModifiers: Int) -> String? {
public func currentASCIICapableCharacter(for keyCode: Int, carbonModifiers: Int) -> String? {
return layout.currentASCIICapableCharacter(for: keyCode, carbonModifiers: carbonModifiers)
}

func currentASCIICapableCharacter(for keyCode: Int, cocoaModifiers: NSEvent.ModifierFlags) -> String? {
public func currentASCIICapableCharacter(for keyCode: Int, cocoaModifiers: NSEvent.ModifierFlags) -> String? {
return currentASCIICapableCharacter(for: keyCode, carbonModifiers: modifierTransformar.carbonFlags(from: cocoaModifiers))
}

func character(with source: InputSource, keyCode: Int, carbonModifiers: Int) -> String? {
public func character(with source: InputSource, keyCode: Int, carbonModifiers: Int) -> String? {
return layout.character(with: source, keyCode: keyCode, carbonModifiers: carbonModifiers)
}

func character(with source: InputSource, keyCode: Int, cocoaModifiers: NSEvent.ModifierFlags) -> String? {
public func character(with source: InputSource, keyCode: Int, cocoaModifiers: NSEvent.ModifierFlags) -> String? {
return character(with: source, keyCode: keyCode, carbonModifiers: modifierTransformar.carbonFlags(from: cocoaModifiers))
}
}