Add "Complete" action to menu

This commit is contained in:
1024jp 2016-10-07 03:07:17 +09:00
parent 8632cd1394
commit 241b8b9b4d
20 changed files with 71 additions and 60 deletions

View File

@ -5,9 +5,15 @@ Change Log
develop
--------------------------
### Improvements
- Add “Complete” action to “Edit” menu.
- On macOS Sierra, the default shortcut for completion action was changed to `⌥⎋`.
### Fixes
- Fix an issue where text completion list did occasionally not displayed.
- Fix an issue where text completion list didn't occasionally display.

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11201" systemVersion="16A320" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11201"/>
</dependencies>
@ -234,19 +234,8 @@
<binding destination="26" name="value" keyPath="values.completesStandardWords" id="kjP-Da-g0b"/>
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="btC-lZ-pQ7">
<rect key="frame" x="115" y="73" width="417" height="14"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Completion can be performed manually with: Esc or ⌘." id="dmb-pc-4M5">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<binding destination="-2" name="value" keyPath="completionHintMessage" id="XIv-Zf-aQ7"/>
</connections>
</textField>
<button translatesAutoresizingMaskIntoConstraints="NO" id="C2I-Ub-oUU">
<rect key="frame" x="115" y="49" width="227" height="18"/>
<rect key="frame" x="115" y="71" width="227" height="18"/>
<buttonCell key="cell" type="check" title="Suggest completions while typing" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="J1B-wA-rdr">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@ -341,20 +330,29 @@
<binding destination="26" name="value" keyPath="values.enableSmartQuotes" id="yWg-yp-nfz"/>
</connections>
</button>
<textField hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="btC-lZ-pQ7">
<rect key="frame" x="115" y="51" width="417" height="14"/>
<textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" title="⚠️ Select at least one item to enable completion." id="dmb-pc-4M5">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<binding destination="-2" name="hidden" keyPath="isValidCompletion" id="Tsd-w5-YRd"/>
</connections>
</textField>
</subviews>
<constraints>
<constraint firstItem="S9y-ho-0e9" firstAttribute="leading" secondItem="cjn-9F-Q4K" secondAttribute="trailing" constant="8" symbolic="YES" id="097-Gz-7if"/>
<constraint firstAttribute="bottom" secondItem="z5v-7l-1C4" secondAttribute="bottom" constant="20" symbolic="YES" id="0Ke-Pr-SYk"/>
<constraint firstItem="Vf0-M7-9ji" firstAttribute="leading" secondItem="644" secondAttribute="leading" id="0n7-K8-sdI"/>
<constraint firstItem="mWb-Dy-J7g" firstAttribute="leading" secondItem="644" secondAttribute="leading" id="1gk-l0-W8e"/>
<constraint firstItem="z5v-7l-1C4" firstAttribute="top" secondItem="C2I-Ub-oUU" secondAttribute="bottom" constant="10" id="2SF-DL-MKh"/>
<constraint firstItem="644" firstAttribute="leading" secondItem="160" secondAttribute="leading" id="2YC-uB-api"/>
<constraint firstItem="282" firstAttribute="baseline" secondItem="283" secondAttribute="baseline" id="2eo-GD-Kfb"/>
<constraint firstItem="3e2-dM-agj" firstAttribute="bottom" secondItem="S9y-ho-0e9" secondAttribute="bottom" id="2jS-LF-YXG"/>
<constraint firstItem="C2I-Ub-oUU" firstAttribute="leading" secondItem="644" secondAttribute="leading" id="3eN-aj-0ZB"/>
<constraint firstItem="S9y-ho-0e9" firstAttribute="baseline" secondItem="cjn-9F-Q4K" secondAttribute="baseline" id="4qQ-re-z8C"/>
<constraint firstItem="t0Y-p1-xOb" firstAttribute="leading" secondItem="lO2-uf-OLD" secondAttribute="leading" id="5d4-UU-RBZ"/>
<constraint firstItem="C2I-Ub-oUU" firstAttribute="top" secondItem="btC-lZ-pQ7" secondAttribute="bottom" constant="8" id="72F-Be-lUx"/>
<constraint firstItem="MUG-vA-30T" firstAttribute="leading" secondItem="W1V-E2-PcB" secondAttribute="trailing" constant="8" symbolic="YES" id="9fM-Zn-Ko0"/>
<constraint firstItem="lO2-uf-OLD" firstAttribute="top" secondItem="Dte-ly-fKQ" secondAttribute="bottom" constant="8" symbolic="YES" id="Axl-g5-SRk"/>
<constraint firstItem="Dte-ly-fKQ" firstAttribute="leading" secondItem="btC-lZ-pQ7" secondAttribute="leading" id="CyA-0F-v2g"/>
@ -365,6 +363,7 @@
<constraint firstItem="844" firstAttribute="top" secondItem="mWb-Dy-J7g" secondAttribute="bottom" constant="8" id="HZx-MZ-Q0V"/>
<constraint firstItem="oXk-4y-elJ" firstAttribute="baseline" secondItem="Dte-ly-fKQ" secondAttribute="baseline" id="I8r-SF-1u9"/>
<constraint firstItem="283" firstAttribute="top" secondItem="160" secondAttribute="bottom" constant="8" id="IM6-11-CAa"/>
<constraint firstItem="btC-lZ-pQ7" firstAttribute="top" secondItem="C2I-Ub-oUU" secondAttribute="bottom" constant="8" symbolic="YES" id="Kc2-M0-2im"/>
<constraint firstItem="644" firstAttribute="leading" secondItem="IXD-kJ-dvh" secondAttribute="trailing" constant="8" symbolic="YES" id="Kcl-7N-AbQ"/>
<constraint firstItem="cjn-9F-Q4K" firstAttribute="leading" secondItem="644" secondAttribute="leading" id="Lix-GC-NQA"/>
<constraint firstItem="t0Y-p1-xOb" firstAttribute="leading" secondItem="w2P-Vr-ZDY" secondAttribute="leading" id="MaU-8f-QTA"/>
@ -380,11 +379,11 @@
<constraint firstItem="209" firstAttribute="leading" secondItem="4B0-Kj-mzX" secondAttribute="trailing" constant="8" symbolic="YES" id="UcK-lH-Or0"/>
<constraint firstItem="160" firstAttribute="leading" secondItem="283" secondAttribute="leading" id="VwP-1c-FdO"/>
<constraint firstItem="4B0-Kj-mzX" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="s6I-DY-Ii0" secondAttribute="leading" constant="20" symbolic="YES" id="Wny-Wk-nNJ"/>
<constraint firstItem="C2I-Ub-oUU" firstAttribute="top" secondItem="w2P-Vr-ZDY" secondAttribute="bottom" constant="8" id="YAv-6T-LyE"/>
<constraint firstItem="mWb-Dy-J7g" firstAttribute="top" secondItem="644" secondAttribute="bottom" constant="8" id="Z6X-B5-ROj"/>
<constraint firstItem="aZf-lI-jGQ" firstAttribute="leading" secondItem="644" secondAttribute="leading" id="Zgo-o6-Vjl"/>
<constraint firstItem="3e2-dM-agj" firstAttribute="leading" secondItem="S9y-ho-0e9" secondAttribute="trailing" constant="8" symbolic="YES" id="bAb-KD-VNK"/>
<constraint firstItem="cjn-9F-Q4K" firstAttribute="top" secondItem="844" secondAttribute="bottom" constant="8" id="cXA-Ki-aPS"/>
<constraint firstItem="btC-lZ-pQ7" firstAttribute="top" secondItem="w2P-Vr-ZDY" secondAttribute="bottom" constant="8" symbolic="YES" id="dKt-0g-uDe"/>
<constraint firstItem="69" firstAttribute="leading" secondItem="fR5-Ie-WnP" secondAttribute="trailing" constant="8" symbolic="YES" id="e18-6y-ozt"/>
<constraint firstItem="w2P-Vr-ZDY" firstAttribute="top" secondItem="t0Y-p1-xOb" secondAttribute="bottom" constant="8" id="e1S-pc-Nus"/>
<constraint firstItem="N9e-hF-BPy" firstAttribute="leading" secondItem="iub-4d-NyY" secondAttribute="trailing" constant="8" symbolic="YES" id="eJ7-3F-ASx"/>

View File

@ -200,6 +200,15 @@
<action selector="delete:" target="Ady-hI-5gd" id="Ftk-bU-BQH"/>
</connections>
</menuItem>
<menuItem title="Complete" id="Qa9-dA-CF1">
<string key="keyEquivalent" base64-UTF8="YES">
Gw
</string>
<modifierMask key="keyEquivalentModifierMask" option="YES"/>
<connections>
<action selector="complete:" target="Ady-hI-5gd" id="xdV-uV-Chm"/>
</connections>
</menuItem>
<menuItem title="Select All" keyEquivalent="a" id="172">
<connections>
<action selector="selectAll:" target="Ady-hI-5gd" id="Rho-pS-oPz"/>

View File

@ -22,7 +22,10 @@
<p>To complete words, follow the instruction below:</p>
<ol>
<li>Type the first few letters of a word.</li>
<li>Press F5 or ESC.</li>
<li>Select “Complete” action in “Edit” menu, or press:<ul>
<li>Opt + Esc <small>(on macOS Sierra and later)</small></li>
<li>F5 or ESC <small>(on OS X El Capitan an earlier)</small></li>
</ul></li>
<li>Choose the word you want to input from the pop-up list.</li>
</ol>
<ul>

View File

@ -22,7 +22,12 @@
<p>入力補完機能を使用してテキストを入力するには次のようにします。</p>
<ol>
<li>テキストの最初の数文字を入力します。</li>
<li>F5 または ESC キーを押下します。</li>
<li>macOS Sierra では Opt + ESC, El Capitan 以下では F5 または ESC キーを押下します。</li>
<li>「編集」メニューから「単語入力補完」を選択するか、以下のキーを押下します:<ul>
<li>Opt + Esc <small>(macOS Sierra 以降)</small></li>
<li>F5 または ESC <small>(OS X El Capitan 未満)</small></li>
</ul></li>
<li>候補の中から入力したい語句を選択します。</li>
</ol>
<ul>

View File

@ -32,7 +32,7 @@ final class EditPaneController: NSViewController {
// MARK: Private Properties
private dynamic var completionHintMessage = ""
private dynamic var isValidCompletion = true
@ -73,14 +73,11 @@ final class EditPaneController: NSViewController {
/// update hint for word completion
private func updateCompletionHintMessage() {
if !Defaults[.completesDocumentWords] &&
!Defaults[.completesSyntaxWords] &&
!Defaults[.completesStandartWords]
{
self.completionHintMessage = "⚠️ " + NSLocalizedString("Select at least one item to enable completion.", comment: "")
} else {
self.completionHintMessage = String(format: NSLocalizedString("Completion can be performed manually with: %@ or %@", comment: ""), "Esc", "⌘.")
}
self.isValidCompletion = (
Defaults[.completesDocumentWords] ||
Defaults[.completesSyntaxWords] ||
Defaults[.completesStandartWords]
)
}
}

View File

@ -135,7 +135,7 @@ final class MenuKeyBindingManager: KeyBindingManager {
let shortcut = self.shortcut(for: action, defaults: false)
guard shortcut.modifierMask.contains(.command) else { return .none }
guard !shortcut.keyEquivalent.isEmpty, !shortcut.modifierMask.isEmpty else { return .none }
return shortcut
}
@ -256,8 +256,8 @@ final class MenuKeyBindingManager: KeyBindingManager {
let shortcut = self.shortcut(for: action)
// apply only if keyEquivalent exists and the Command key is included
guard shortcut.modifierMask.contains(.command) else { return }
// apply only if both keyEquivalent and modifierMask exist
guard !shortcut.keyEquivalent.isEmpty, !shortcut.modifierMask.isEmpty else { return }
menuItem.keyEquivalent = shortcut.keyEquivalent
menuItem.keyEquivalentModifierMask = shortcut.modifierMask

View File

@ -233,7 +233,7 @@ struct Shortcut: Hashable, CustomStringConvertible {
0x08: "", // = Backspace, (delete backword)
0x03: "", // = Enter
0x31: "", // = Backtab
0x33: "", // = Escape
0x1b: "", // = Escape
]
// cast key from Int to UnicodeScalar

View File

@ -87,3 +87,6 @@
/* Class = "NSButtonCell"; title = "Suggest completions while typing"; ObjectID = "J1B-wA-rdr"; */
"J1B-wA-rdr.title" = "Während der Texteingabe Vervollständigungen vorschlagen";
/* Class = "NSTextFieldCell"; title = "⚠️ Select at least one item to enable completion."; ObjectID = "dmb-pc-4M5"; */
"dmb-pc-4M5.title" = "⚠️ Wählen Sie mindestens ein Element, um die Vervollständigung zu aktivieren.";

View File

@ -308,13 +308,6 @@
"Stylesheet Keywords" = "CSS-Schlüsselwörter";
/* MARK: CEPreferencesWindowController */
// Hint message for the completion list
"Completion can be performed manually with: %@ or %@" = "Vervollständigung manuell durchführen mit: %@ oder %@";
"Select at least one item to enable completion." = "Wählen Sie mindestens ein Element, um die Vervollständigung zu aktivieren.";
// Genearal pane
// Autosave setting update alert
"The change will be applied first at the next launch." = "Die Änderung wird erst beim nächsten Start angewendet.";

View File

@ -129,6 +129,8 @@
"171.title" = "Einsetzen";
/* Class = "NSMenuItem"; title = "Delete"; ObjectID = "164"; */
"164.title" = "Löschen";
/* Class = "NSMenuItem"; title = "Complete"; ObjectID = "Qa9-dA-CF1"; */
"Qa9-dA-CF1.title" = "Vervollständigen";
/* Class = "NSMenuItem"; title = "Select All"; ObjectID = "172"; */
"172.title" = "Alles auswählen";
/* Class = "NSMenuItem"; title = "Select Line"; ObjectID = "Cwp-ys-LJc"; */

View File

@ -88,3 +88,6 @@
/* Class = "NSButtonCell"; title = "Suggest completions while typing"; ObjectID = "J1B-wA-rdr"; */
"J1B-wA-rdr.title" = "Suggerisci completamento durante linserimento";
/* Class = "NSTextFieldCell"; title = "⚠️ Select at least one item to enable completion."; ObjectID = "dmb-pc-4M5"; */
"dmb-pc-4M5.title" = "⚠️ Selezionare almeno un elemento per azionare il completamento.";

View File

@ -309,13 +309,6 @@
"Stylesheet Keywords" = "Parole chiave CSS";
/* MARK: CEPreferencesWindowController */
// Hint message for the completion list
"Completion can be performed manually with: %@ or %@" = "Il completamento si può effettuare a mano con %@ oppure %@";
"Select at least one item to enable completion." = "Selezionare almeno un elemento per azionare il completamento.";
// Genearal pane
// Autosave setting update alert
"The change will be applied first at the next launch." = "La modifica verrà applicata al prossimo avvio.";

View File

@ -130,6 +130,8 @@
"171.title" = "Incolla";
/* Class = "NSMenuItem"; title = "Delete"; ObjectID = "164"; */
"164.title" = "Elimina";
/* Class = "NSMenuItem"; title = "Complete"; ObjectID = "Qa9-dA-CF1"; */
"Qa9-dA-CF1.title" = "Completa";
/* Class = "NSMenuItem"; title = "Select All"; ObjectID = "172"; */
"172.title" = "Seleziona tutto";
/* Class = "NSMenuItem"; title = "Select Line"; ObjectID = "Cwp-ys-LJc"; */

View File

@ -87,3 +87,6 @@
/* Class = "NSButtonCell"; title = "Suggest completions while typing"; ObjectID = "J1B-wA-rdr"; */
"J1B-wA-rdr.title" = "入力中に補完候補を表示";
/* Class = "NSTextFieldCell"; title = "⚠️ Select at least one item to enable completion."; ObjectID = "dmb-pc-4M5"; */
"dmb-pc-4M5.title" = "⚠️ 入力補完を有効にするためには1つ以上の項目を選択する必要があります。";

View File

@ -310,13 +310,6 @@
"Stylesheet Keywords" = "スタイルシートキーワード";
/* MARK: CEPreferencesWindowController */
// Hint message for the completion list
"Completion can be performed manually with: %@ or %@" = "入力補完候補リストの表示: %@ もしくは %@";
"Select at least one item to enable completion." = "入力補完を有効にするためには1つ以上の項目を選択する必要があります。";
// Genearal pane
// Autosave setting update alert
"The change will be applied first at the next launch." = "この変更は次回アプリケーション起動時に適用されます。";

View File

@ -129,6 +129,8 @@
"171.title" = "ペースト";
/* Class = "NSMenuItem"; title = "Delete"; ObjectID = "164"; */
"164.title" = "削除";
/* Class = "NSMenuItem"; title = "Complete"; ObjectID = "Qa9-dA-CF1"; */
"Qa9-dA-CF1.title" = "単語入力補完";
/* Class = "NSMenuItem"; title = "Select All"; ObjectID = "172"; */
"172.title" = "すべてを選択";
/* Class = "NSMenuItem"; title = "Select Line"; ObjectID = "Cwp-ys-LJc"; */

View File

@ -88,3 +88,6 @@
/* Class = "NSButtonCell"; title = "Suggest completions while typing"; ObjectID = "J1B-wA-rdr"; */
"J1B-wA-rdr.title" = "忽略字符串中的制表符和换行符";
/* Class = "NSTextFieldCell"; title = "⚠️ Select at least one item to enable completion."; ObjectID = "dmb-pc-4M5"; */
"dmb-pc-4M5.title" = "⚠️ 至少选择一个条目来激活补全。";

View File

@ -307,13 +307,6 @@
"Stylesheet Keywords" = "样式表关键字";
/* MARK: CEPreferencesWindowController */
// Hint message for the completion list
"Completion can be performed manually with: %@ or %@" = "补全可以通过 %@ 或 %@ 手动完成";
"Select at least one item to enable completion." = "至少选择一个条目来激活补全。";
// Genearal pane
// Autosave setting update alert
"The change will be applied first at the next launch." = "变更将在下次启动时生效。";

View File

@ -131,6 +131,8 @@
"171.title" = "粘贴";
/* Class = "NSMenuItem"; title = "Delete"; ObjectID = "164"; */
"164.title" = "删除";
/* Class = "NSMenuItem"; title = "Complete"; ObjectID = "Qa9-dA-CF1"; */
"Qa9-dA-CF1.title" = "联想";
/* Class = "NSMenuItem"; title = "Select All"; ObjectID = "172"; */
"172.title" = "全选";
/* Class = "NSMenuItem"; title = "Select Line"; ObjectID = "Cwp-ys-LJc"; */