mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-11 11:25:57 +03:00
Add actions transform Half-width and Full-width
This commit is contained in:
parent
a5c33b34fa
commit
65b2b2f24c
@ -5,6 +5,10 @@ Change Log
|
||||
develop
|
||||
--------------------------
|
||||
|
||||
### New Features
|
||||
|
||||
- Add new actions “Half-width to Full-width” and “Full-width to Half-width” to Text > Transformations menu.
|
||||
|
||||
### Improvements
|
||||
|
||||
- Drop support for __OS X 10.10 Yosemite__.
|
||||
|
@ -1,7 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="12118" systemVersion="16E195" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="13529" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12118"/>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13529"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--Application-->
|
||||
@ -781,13 +782,25 @@ CA
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="HuN-8a-yXL"/>
|
||||
<menuItem title="ASCII to Fullwidth ASCII" id="586">
|
||||
<menuItem title="Half-width to Full-width" id="dVK-1s-xJq">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="exchangeFullwidth:" target="Ady-hI-5gd" id="Kzj-vP-XAT"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Full-width to Half-width" id="Skr-vI-7VN">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="exchangeHalfwidth:" target="Ady-hI-5gd" id="gsG-iw-ufU"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="ASCII to Full-width ASCII" id="586">
|
||||
<attributedString key="attributedTitle"/>
|
||||
<connections>
|
||||
<action selector="exchangeFullwidthRoman:" target="Ady-hI-5gd" id="0zm-yg-bCm"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Fullwidth ASCII to ASCII" id="588">
|
||||
<menuItem title="Full-width ASCII to ASCII" id="588">
|
||||
<attributedString key="attributedTitle"/>
|
||||
<connections>
|
||||
<action selector="exchangeHalfwidthRoman:" target="Ady-hI-5gd" id="U4C-sa-ALD"/>
|
||||
|
@ -31,11 +31,36 @@ extension EditorTextView {
|
||||
|
||||
// MARK: Action Messages (Transformations)
|
||||
|
||||
/// transform all full-width-available half-width characters in selection to full-width
|
||||
@IBAction func exchangeFullwidth(_ sender: Any?) {
|
||||
|
||||
let actionName = NSLocalizedString("To Fullwidth", comment: "")
|
||||
self.transformSelection(actionName: actionName) {
|
||||
$0.applyingTransform(.fullwidthToHalfwidth, reverse: true) ?? $0
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// transform all full-width characters in selection to half-width
|
||||
@IBAction func exchangeHalfwidth(_ sender: Any?) {
|
||||
|
||||
let actionName = NSLocalizedString("To Halfwidth", comment: "")
|
||||
self.transformSelection(actionName: actionName) {
|
||||
$0.applyingTransform(.fullwidthToHalfwidth, reverse: false) ?? $0
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// transform half-width roman characters in selection to full-width
|
||||
@IBAction func exchangeFullwidthRoman(_ sender: Any?) {
|
||||
|
||||
let actionName = NSLocalizedString("To Fullwidth Roman", comment: "")
|
||||
self.transformSelection(actionName: actionName) { $0.fullWidthRoman }
|
||||
self.transformSelection(actionName: actionName) {
|
||||
$0.fullWidthRoman
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -43,7 +68,10 @@ extension EditorTextView {
|
||||
@IBAction func exchangeHalfwidthRoman(_ sender: Any?) {
|
||||
|
||||
let actionName = NSLocalizedString("To Halfwidth Roman", comment: "")
|
||||
self.transformSelection(actionName: actionName) { $0.halfWidthRoman }
|
||||
self.transformSelection(actionName: actionName) {
|
||||
$0.halfWidthRoman
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -51,7 +79,10 @@ extension EditorTextView {
|
||||
@IBAction func exchangeKatakana(_ sender: Any?) {
|
||||
|
||||
let actionName = NSLocalizedString("Hiragana to Katakana", comment: "")
|
||||
self.transformSelection(actionName: actionName) { $0.katakana }
|
||||
self.transformSelection(actionName: actionName) {
|
||||
$0.applyingTransform(.hiraganaToKatakana, reverse: false) ?? $0
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -59,7 +90,10 @@ extension EditorTextView {
|
||||
@IBAction func exchangeHiragana(_ sender: Any?) {
|
||||
|
||||
let actionName = NSLocalizedString("Katakana to Hiragana", comment: "")
|
||||
self.transformSelection(actionName: actionName) { $0.hiragana }
|
||||
self.transformSelection(actionName: actionName) {
|
||||
$0.applyingTransform(.hiraganaToKatakana, reverse: true) ?? $0
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -58,21 +58,6 @@ extension String {
|
||||
.joined()
|
||||
}
|
||||
|
||||
|
||||
/// transform Japanese Katakana to Hiragana
|
||||
var katakana: String {
|
||||
|
||||
return self.applyingTransform(.hiraganaToKatakana, reverse: false) ?? self
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// transform Japanese Hiragana to Katakana
|
||||
var hiragana: String {
|
||||
|
||||
return self.applyingTransform(.hiraganaToKatakana, reverse: true) ?? self
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -377,9 +377,13 @@
|
||||
/* Class = "NSMenuItem"; title = "Capitalize"; ObjectID = "LC4-lg-eO0"; */
|
||||
"LC4-lg-eO0.title" = "Großschreiben";
|
||||
|
||||
/* Class = "NSMenuItem"; title = "ASCII to Fullwidth ASCII"; ObjectID = "586"; */
|
||||
/* Class = "NSMenuItem"; title = "Half-width to Full-width"; ObjectID = "dVK-1s-xJq"; */
|
||||
"586.title" = "Halbbreiten zu Vollbreiten";
|
||||
/* Class = "NSMenuItem"; title = "Full-width to Half-width"; ObjectID = "Skr-vI-7VN"; */
|
||||
"588.title" = "Vollbreiten zu Halbbreiten";
|
||||
/* Class = "NSMenuItem"; title = "ASCII to Full-width ASCII"; ObjectID = "586"; */
|
||||
"586.title" = "ASCII zu Vollbreiten-ASCII";
|
||||
/* Class = "NSMenuItem"; title = "Fullwidth ASCII to ASCII"; ObjectID = "588"; */
|
||||
/* Class = "NSMenuItem"; title = "Full-width ASCII to ASCII"; ObjectID = "588"; */
|
||||
"588.title" = "Vollbreiten-ASCII zu ASCII";
|
||||
|
||||
/* Class = "NSMenuItem"; title = "Japanese Text"; ObjectID = "XWV-by-mnw"; */
|
||||
|
@ -378,9 +378,13 @@
|
||||
/* Class = "NSMenuItem"; title = "Capitalize"; ObjectID = "LC4-lg-eO0"; */
|
||||
"LC4-lg-eO0.title" = "Usa maiuscole";
|
||||
|
||||
/* Class = "NSMenuItem"; title = "ASCII to Fullwidth ASCII"; ObjectID = "586"; */
|
||||
/* Class = "NSMenuItem"; title = "Half-width to Full-width"; ObjectID = "dVK-1s-xJq"; */
|
||||
"586.title" = "Half-width to Full-width"; // FIXME: added
|
||||
/* Class = "NSMenuItem"; title = "Full-width to Half-width"; ObjectID = "Skr-vI-7VN"; */
|
||||
"588.title" = "Full-width to Half-width"; // FIXME: added
|
||||
/* Class = "NSMenuItem"; title = "ASCII to Full-width ASCII"; ObjectID = "586"; */
|
||||
"586.title" = "Da ASCII ad ASCII a tutta larghezza";
|
||||
/* Class = "NSMenuItem"; title = "Fullwidth ASCII to ASCII"; ObjectID = "588"; */
|
||||
/* Class = "NSMenuItem"; title = "Full-width ASCII to ASCII"; ObjectID = "588"; */
|
||||
"588.title" = "Da ASCII a tutta larghezza ad ASCII";
|
||||
|
||||
/* Class = "NSMenuItem"; title = "Japanese Text"; ObjectID = "XWV-by-mnw"; */
|
||||
|
@ -377,9 +377,13 @@
|
||||
/* Class = "NSMenuItem"; title = "Capitalize"; ObjectID = "LC4-lg-eO0"; */
|
||||
"LC4-lg-eO0.title" = "語頭を大文字にする";
|
||||
|
||||
/* Class = "NSMenuItem"; title = "ASCII to Fullwidth ASCII"; ObjectID = "586"; */
|
||||
/* Class = "NSMenuItem"; title = "Half-width to Full-width"; ObjectID = "dVK-1s-xJq"; */
|
||||
"586.title" = "全角にする";
|
||||
/* Class = "NSMenuItem"; title = "Full-width to Half-width"; ObjectID = "Skr-vI-7VN"; */
|
||||
"588.title" = "半角にする";
|
||||
/* Class = "NSMenuItem"; title = "ASCII to Full-width ASCII"; ObjectID = "586"; */
|
||||
"586.title" = "全角英数にする";
|
||||
/* Class = "NSMenuItem"; title = "Fullwidth ASCII to ASCII"; ObjectID = "588"; */
|
||||
/* Class = "NSMenuItem"; title = "Full-width ASCII to ASCII"; ObjectID = "588"; */
|
||||
"588.title" = "半角英数にする";
|
||||
|
||||
/* Class = "NSMenuItem"; title = "Japanese Text"; ObjectID = "XWV-by-mnw"; */
|
||||
|
@ -378,9 +378,13 @@
|
||||
/* Class = "NSMenuItem"; title = "Capitalize"; ObjectID = "LC4-lg-eO0"; */
|
||||
"LC4-lg-eO0.title" = "首字母大写";
|
||||
|
||||
/* Class = "NSMenuItem"; title = "ASCII to Fullwidth ASCII"; ObjectID = "586"; */
|
||||
/* Class = "NSMenuItem"; title = "Half-width to Full-width"; ObjectID = "dVK-1s-xJq"; */
|
||||
"586.title" = "Half-width to Full-width"; // FIXME: added
|
||||
/* Class = "NSMenuItem"; title = "Full-width to Half-width"; ObjectID = "Skr-vI-7VN"; */
|
||||
"588.title" = "Full-width to Half-width"; // FIXME: added
|
||||
/* Class = "NSMenuItem"; title = "ASCII to Full-width ASCII"; ObjectID = "586"; */
|
||||
"586.title" = "ASCII 到全宽 ASCII";
|
||||
/* Class = "NSMenuItem"; title = "Fullwidth ASCII to ASCII"; ObjectID = "588"; */
|
||||
/* Class = "NSMenuItem"; title = "Full-width ASCII to ASCII"; ObjectID = "588"; */
|
||||
"588.title" = "全宽 ASCII 到 ASCII";
|
||||
|
||||
/* Class = "NSMenuItem"; title = "Japanese Text"; ObjectID = "XWV-by-mnw"; */
|
||||
|
@ -99,12 +99,10 @@ class StringExtensionsTests: XCTestCase {
|
||||
|
||||
func testJapaneseTransform() {
|
||||
|
||||
let testString = "犬 イヌ いぬ Inu Dog"
|
||||
let testString = "犬 イヌ いぬ Inu Dog 123 123"
|
||||
|
||||
XCTAssertEqual(testString.fullWidthRoman, "犬 イヌ いぬ Inu Dog")
|
||||
XCTAssertEqual(testString.halfWidthRoman, "犬 イヌ いぬ Inu Dog")
|
||||
XCTAssertEqual(testString.katakana, "犬 イヌ イヌ Inu Dog")
|
||||
XCTAssertEqual(testString.hiragana, "犬 いぬ いぬ Inu Dog")
|
||||
XCTAssertEqual(testString.fullWidthRoman, "犬 イヌ いぬ Inu Dog 123 123")
|
||||
XCTAssertEqual(testString.halfWidthRoman, "犬 イヌ いぬ Inu Dog 123 123")
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user