Skip to content

Commit d1fa2e3

Browse files
committed
discover system input method switching shortcut
1 parent afb3b9e commit d1fa2e3

File tree

9 files changed

+14
-87
lines changed

9 files changed

+14
-87
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ Currently, only Persian is supported, but it is straightforward to add other lan
1212

1313
`goftam.app` must be placed in `/Library/Input Methods` to install it for all users or `~/Library/Input Methods` to install it for a particular user.
1414

15-
**Install option 1: run the installer**
15+
**Install option 1: run the installer (easiset)**
1616

17-
Download the most recent installer (`GoftamInstaller.pkg`) from [releases](https://github.com/brettferdosi/goftam/releases) and run it. You will have to follow Apple's instructions for [opening an app from an unidentified developer](https://support.apple.com/guide/mac-help/open-a-mac-app-from-an-unidentified-developer-mh40616/mac). It will install Goftam for all users, but you can move `goftam.app` to a particular user's directory after installation if desired. If there is already a version of `goftam.app` on your system, the installer will detect and overwrite it.
17+
Download the most recent installer (`GoftamInstaller.pkg`) from [releases](https://github.com/brettferdosi/goftam/releases) and run it. You will have to follow Apple's instructions for [opening an app from an unidentified developer](https://support.apple.com/guide/mac-help/open-a-mac-app-from-an-unidentified-developer-mh40616/mac) (basically, control-click the installer, click *Open*, then click *Open* again). It will install Goftam for all users, but you can move `goftam.app` to a particular user's directory after installation if desired. If there is already a version of `goftam.app` on your system, the installer will detect and overwrite it.
1818

1919
**Install option 2: build from source**
2020

2121
Clone this git repository and run `xcodebuild -project goftam.xcodeproj`. `goftam.app` will be placed into `build/Release`, and you can move it to the appropriate directory depending on whether you want to install Goftam for all users or a particular user.
2222

2323
**Enabling Goftam**
2424

25-
Open System Preferences > Keyboard and click the + button to add input sources. Add Goftam Bypass, which is categorized as an English input method, and additional Goftam inputs as desired, which are categorized by their target languages (e.g. Goftam Persian is categorized as a Persian input method). You can then enable Goftam inputs by selecting them from the input menu bar button.
25+
Open System Preferences > Keyboard and click the + button to add input sources. Add Goftam inputs, which are categorized by their target languages (e.g. Goftam Persian is categorized as a Persian input method), as desired. You can then enable Goftam inputs by selecting them from the input menu bar button.
2626

2727
<img src="https://github.com/brettferdosi/goftam/raw/doc/menubar.png" width="500px">
2828

29-
If selecting one of the Goftam input methods does not work immediately after installing it, you may need to log out then back in.
29+
If selecting a Goftam input method does not work immediately after installing it, you may need to log out then back in.
3030

3131
**Uninstalling Goftam**
3232

@@ -38,9 +38,9 @@ With a Goftam input enabled, the input keyboard layout is set to the most recent
3838

3939
Typing a punctuation mark or symbol commits the in-progress composition by selecting the currently highlighted candidate, and the (potentially translated) symbol is then inserted. Typing a numeric digit while there is no composition in progress inserts a translated version of the digit.
4040

41-
Goftam supports a bypass mode that inputs keystrokes directly without transliteration. Press `shift-commmand-space` while you have a text box selected to toggle transliteration bypass. In bypass mode, the Goftam icon in the menu bar becomes faded.
41+
Typing `shift-space` will insert a [zero-width non-joiner character](https://en.wikipedia.org/wiki/Zero-width_non-joiner), which is useful for various scripts and languages.
4242

43-
In non-bypass input modes, typing `shift-space` will insert a [zero-width non-joiner character](https://en.wikipedia.org/wiki/Zero-width_non-joiner), which is useful for various scripts and languages.
43+
To switch between input modes quickly, you can use the *Select the previous input source* system keyboard shortcut. This is `control-space` by default.
4444

4545
## Goftam Persian
4646

Resources/Assets.xcassets/BypassMenuIcon.imageset/Contents.json

Lines changed: 0 additions & 21 deletions
This file was deleted.
-345 Bytes
Binary file not shown.
Binary file not shown.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
goftampersian = "Goftam Persian";
2-
goftambypass = "Goftam Bypass";
32

43
CFBundleName = "Goftam";

Resources/Info.plist

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,28 +67,10 @@
6767
<key>tsInputModeIsVisibleKey</key>
6868
<true/>
6969
</dict>
70-
<key>goftambypass</key>
71-
<dict>
72-
<key>TISIntendedLanguage</key>
73-
<string>en</string>
74-
<key>TISInputSourceID</key>
75-
<string>$(PRODUCT_BUNDLE_IDENTIFIER).bypass</string>
76-
<key>tsInputModeScriptKey</key>
77-
<string>smRoman</string>
78-
<key>tsInputModeMenuIconFileKey</key>
79-
<string>BypassMenuIcon</string>
80-
<key>tsInputModeAlternateMenuIconFileKey</key>
81-
<string>BypassMenuIcon</string>
82-
<key>tsInputModeDefaultStateKey</key>
83-
<true/>
84-
<key>tsInputModeIsVisibleKey</key>
85-
<true/>
86-
</dict>
8770
</dict>
8871
<key>tsVisibleInputModeOrderedArrayKey</key>
8972
<array>
9073
<string>goftampersian</string>
91-
<string>goftambypass</string>
9274
</array>
9375
</dict>
9476
<key>tsInputMethodCharacterRepertoireKey</key>

Sources/AppDelegate.swift

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,18 @@ var wordStore: GoftamWordStore = GoftamWordStore()
2323
var transliterators: Dictionary<String, GoftamTransliterator> =
2424
[PersianGoftamTransliterator.transliteratorName: PersianGoftamTransliterator()]
2525

26-
// BFG: different default behavior when more languages added?
2726
var activeTransliterator: GoftamTransliterator =
2827
transliterators[PersianGoftamTransliterator.transliteratorName]!
2928

30-
// bypass control
31-
var bypassTransliteration: Bool = false
32-
var bypassTransliteratorName: String = "goftambypass"
33-
34-
// select the transliterator to use (or enable bypass mode) by
35-
// its input mode name (from ComponentInputModeDict in Info.plist)
29+
// select the transliterator to use by its input mode
30+
// name (from ComponentInputModeDict in Info.plist)
3631
func selectTransliterator(_ mode: String) {
3732
goftamLog(logLevel: .VERBOSE, "mode \(mode)")
38-
if mode == bypassTransliteratorName {
39-
bypassTransliteration = true
40-
} else {
41-
guard let transliterator = transliterators[mode] else {
42-
goftamLog("invalid transliterator selected")
43-
abort()
44-
}
45-
bypassTransliteration = false
46-
activeTransliterator = transliterator
33+
guard let transliterator = transliterators[mode] else {
34+
goftamLog("invalid transliterator selected")
35+
abort()
4736
}
37+
activeTransliterator = transliterator
4838
}
4939

5040
// logging

Sources/GoftamIMKInputController.swift

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,8 @@ class GoftamIMKInputController: IMKInputController {
6666
override func menu() -> NSMenu! {
6767
goftamLog(logLevel: .VERBOSE, "")
6868
let menu = NSMenu()
69-
if !bypassTransliteration {
70-
menu.addItem(NSMenuItem(title: "Clear History", action: #selector(clearHistory(_:)), keyEquivalent: ""))
71-
}
72-
menu.addItem(NSMenuItem(title: "About", action: #selector(showAboutPanel(_:)), keyEquivalent: "")) // todo build id
69+
menu.addItem(NSMenuItem(title: "Clear History", action: #selector(clearHistory(_:)), keyEquivalent: ""))
70+
menu.addItem(NSMenuItem(title: "About", action: #selector(showAboutPanel(_:)), keyEquivalent: ""))
7371
return menu
7472
}
7573

@@ -274,25 +272,6 @@ class GoftamIMKInputController: IMKInputController {
274272
}
275273
let char = event.characters!.first!
276274

277-
// shift-command-space toggles transliteration bypass
278-
if (char == " ") && event.modifierFlags.contains([.shift, .command]) {
279-
// sender.selectMode() will call :selectValue() above with
280-
// the appropriate tag. if either the bypass input mode
281-
// or the main language input modes are not loaded, then
282-
// this design will fail gracefully because selectMode()
283-
// will not result in a :selectValue() call.
284-
if bypassTransliteration {
285-
sender.selectMode(type(of: activeTransliterator).transliteratorName)
286-
} else {
287-
sender.selectMode(bypassTransliteratorName)
288-
}
289-
return true
290-
}
291-
292-
if bypassTransliteration {
293-
return false
294-
}
295-
296275
// if a command sequence was not handled by the application, ignore it
297276
if event.modifierFlags.contains(.command) {
298277
return false

goftam.xcodeproj/project.pbxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
8B49FC4C2469FDB700B08771 /* GoftamTransliterator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B49FC4B2469FDB700B08771 /* GoftamTransliterator.swift */; };
1313
8B523E79246DB8DB00B4A04C /* Base.lproj in Resources */ = {isa = PBXBuildFile; fileRef = 8B523E78246DB8DB00B4A04C /* Base.lproj */; };
1414
8B523E7C246DB90200B4A04C /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 8B523E7A246DB90100B4A04C /* LICENSE */; };
15-
8B523E7D246DB90200B4A04C /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 8B523E7B246DB90200B4A04C /* README.md */; };
1615
8BA9129F245CC84D00C9A683 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BA9129E245CC84D00C9A683 /* AppDelegate.swift */; };
1716
8BA912A1245CC85000C9A683 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8BA912A0245CC85000C9A683 /* Assets.xcassets */; };
1817
8BA912B1245CCA4F00C9A683 /* GoftamIMKInputController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BA912B0245CCA4F00C9A683 /* GoftamIMKInputController.swift */; };
@@ -160,7 +159,6 @@
160159
buildActionMask = 2147483647;
161160
files = (
162161
8B47A60624798B39004A391C /* MainMenu.xib in Resources */,
163-
8B523E7D246DB90200B4A04C /* README.md in Resources */,
164162
8BA912A1245CC85000C9A683 /* Assets.xcassets in Resources */,
165163
8B523E79246DB8DB00B4A04C /* Base.lproj in Resources */,
166164
8BC92BD7246F345B00D171C4 /* goftam.sqlite in Resources */,

0 commit comments

Comments
 (0)