mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-10-26 19:10:11 +03:00
Merge branch 'feature/509_UTF8BOM' into develop
This commit is contained in:
commit
11f82077ba
@ -7,6 +7,10 @@ develop
|
||||
|
||||
### New Features
|
||||
|
||||
- Add independent “Unicode (UTF-8) with BOM” encoding to encoding list.
|
||||
- Respect the existance of the UTF-8 BOM in opened files.
|
||||
- Enable switching the document encoding between with and without BOM from the toolbar popup button and the “Format” menu.
|
||||
- The “Unicode (UTF-8) with BOM” item will be automatically added to just after the normal “Unicode (UTF-8)”.
|
||||
- Now, the execute permission can be given to the file to save from the save panel.
|
||||
- Add a new theme “Lakritz”.
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15D21" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10116"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="CEEncodingListSheetController">
|
||||
@ -24,13 +24,13 @@
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="38">
|
||||
<rect key="frame" x="20" y="61" width="244" height="228"/>
|
||||
<rect key="frame" x="20" y="97" width="244" height="192"/>
|
||||
<clipView key="contentView" id="aNc-UC-u91">
|
||||
<rect key="frame" x="1" y="1" width="255" height="209"/>
|
||||
<rect key="frame" x="1" y="1" width="242" height="190"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" autosaveColumns="NO" rowSizeStyle="automatic" viewBased="YES" id="39">
|
||||
<rect key="frame" x="0.0" y="0.0" width="242" height="0.0"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="242" height="190"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<size key="intercellSpacing" width="3" height="2"/>
|
||||
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
@ -180,6 +180,14 @@ Auto-Detect tries these encodings from the top of the list.</string>
|
||||
<binding destination="47" name="enabled" keyPath="canRestore" id="Dzd-6R-0kZ"/>
|
||||
</connections>
|
||||
</button>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="yhP-zg-tBc">
|
||||
<rect key="frame" x="18" y="61" width="364" height="28"/>
|
||||
<textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" title="“Unicode (UTF-8) with BOM” will be automatically added to just after the normal “Unicode (UTF-8)”." id="jXZ-7k-86F">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="56" firstAttribute="top" secondItem="62" secondAttribute="bottom" constant="8" symbolic="YES" id="0LZ-QG-oir"/>
|
||||
@ -192,19 +200,22 @@ Auto-Detect tries these encodings from the top of the list.</string>
|
||||
<constraint firstItem="54" firstAttribute="leading" secondItem="38" secondAttribute="trailing" constant="8" symbolic="YES" id="8nX-ho-0wW"/>
|
||||
<constraint firstItem="62" firstAttribute="leading" secondItem="37" secondAttribute="leading" constant="20" symbolic="YES" id="F8d-xT-wcD"/>
|
||||
<constraint firstItem="56" firstAttribute="leading" secondItem="37" secondAttribute="leading" constant="20" symbolic="YES" id="J98-aR-gdw"/>
|
||||
<constraint firstAttribute="trailing" secondItem="yhP-zg-tBc" secondAttribute="trailing" constant="20" symbolic="YES" id="LOS-u4-EbQ"/>
|
||||
<constraint firstItem="54" firstAttribute="top" secondItem="56" secondAttribute="bottom" constant="8" symbolic="YES" id="LzJ-7I-MxY"/>
|
||||
<constraint firstItem="62" firstAttribute="top" secondItem="37" secondAttribute="top" constant="20" symbolic="YES" id="N7H-D8-BSH"/>
|
||||
<constraint firstItem="43" firstAttribute="leading" secondItem="42" secondAttribute="trailing" constant="12" symbolic="YES" id="Nt9-gb-shF"/>
|
||||
<constraint firstItem="55" firstAttribute="top" secondItem="54" secondAttribute="bottom" constant="10" symbolic="YES" id="QDo-Jt-bsV"/>
|
||||
<constraint firstAttribute="bottom" secondItem="42" secondAttribute="bottom" constant="20" symbolic="YES" id="RUg-QY-MXl"/>
|
||||
<constraint firstItem="38" firstAttribute="top" secondItem="56" secondAttribute="bottom" constant="8" symbolic="YES" id="Syx-Wi-LNT"/>
|
||||
<constraint firstItem="42" firstAttribute="top" secondItem="38" secondAttribute="bottom" constant="20" symbolic="YES" id="UsJ-hk-9IV"/>
|
||||
<constraint firstItem="700" firstAttribute="top" secondItem="yhP-zg-tBc" secondAttribute="bottom" constant="20" symbolic="YES" id="U9t-AY-A15"/>
|
||||
<constraint firstItem="yhP-zg-tBc" firstAttribute="top" secondItem="38" secondAttribute="bottom" constant="8" symbolic="YES" id="Yus-lX-4eS"/>
|
||||
<constraint firstItem="42" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="700" secondAttribute="trailing" constant="12" symbolic="YES" id="ZWT-Y8-hTY"/>
|
||||
<constraint firstItem="38" firstAttribute="leading" secondItem="37" secondAttribute="leading" constant="20" symbolic="YES" id="a28-Q1-dxx"/>
|
||||
<constraint firstAttribute="trailing" secondItem="55" secondAttribute="trailing" constant="20" symbolic="YES" id="aMR-De-Syy"/>
|
||||
<constraint firstItem="700" firstAttribute="leading" secondItem="37" secondAttribute="leading" constant="20" symbolic="YES" id="dyn-hT-SiN"/>
|
||||
<constraint firstItem="55" firstAttribute="leading" secondItem="38" secondAttribute="trailing" constant="8" symbolic="YES" id="elU-g8-NQF"/>
|
||||
<constraint firstAttribute="trailing" secondItem="62" secondAttribute="trailing" constant="20" symbolic="YES" id="lH1-Xj-Qid"/>
|
||||
<constraint firstItem="yhP-zg-tBc" firstAttribute="leading" secondItem="37" secondAttribute="leading" constant="20" symbolic="YES" id="oXl-7m-K9H"/>
|
||||
<constraint firstItem="700" firstAttribute="top" secondItem="42" secondAttribute="top" id="s5v-Cs-JaZ"/>
|
||||
</constraints>
|
||||
</view>
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10116"/>
|
||||
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
@ -28,7 +28,7 @@
|
||||
</declaredKeys>
|
||||
</arrayController>
|
||||
<customView horizontalHuggingPriority="750" verticalCompressionResistancePriority="250" id="745" userLabel="Format Pane">
|
||||
<rect key="frame" x="0.0" y="0.0" width="550" height="425"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="550" height="416"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<button horizontalHuggingPriority="750" verticalHuggingPriority="750" tag="5" translatesAutoresizingMaskIntoConstraints="NO" id="2157">
|
||||
@ -42,7 +42,7 @@
|
||||
</connections>
|
||||
</button>
|
||||
<textField horizontalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="17">
|
||||
<rect key="frame" x="32" y="388" width="128" height="17"/>
|
||||
<rect key="frame" x="32" y="379" width="128" height="17"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" alignment="left" title="Default line endings:" usesSingleLineMode="YES" id="3273">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
@ -50,7 +50,7 @@
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="13">
|
||||
<rect key="frame" x="164" y="382" width="225" height="26"/>
|
||||
<rect key="frame" x="164" y="373" width="225" height="26"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="220" id="D2Q-g5-p9Z"/>
|
||||
</constraints>
|
||||
@ -70,7 +70,7 @@
|
||||
</connections>
|
||||
</popUpButton>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="44">
|
||||
<rect key="frame" x="393" y="270" width="106" height="28"/>
|
||||
<rect key="frame" x="393" y="285" width="106" height="28"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="96" id="iGy-QY-Sx5"/>
|
||||
</constraints>
|
||||
@ -83,7 +83,7 @@
|
||||
</connections>
|
||||
</button>
|
||||
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="76">
|
||||
<rect key="frame" x="164" y="272" width="225" height="26"/>
|
||||
<rect key="frame" x="164" y="287" width="225" height="26"/>
|
||||
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="clipping" borderStyle="borderAndBezel" inset="2" arrowPosition="arrowAtCenter" preferredEdge="maxY" id="3276">
|
||||
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="menu"/>
|
||||
@ -94,11 +94,12 @@
|
||||
</menu>
|
||||
</popUpButtonCell>
|
||||
<connections>
|
||||
<action selector="checkSelectedItemOfEncodingMenuInOpen:" target="-2" id="tKD-WQ-wzk"/>
|
||||
<binding destination="26" name="selectedTag" keyPath="values.encodingInOpen" id="98"/>
|
||||
</connections>
|
||||
</popUpButton>
|
||||
<textField horizontalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="77">
|
||||
<rect key="frame" x="69" y="278" width="91" height="17"/>
|
||||
<rect key="frame" x="69" y="293" width="91" height="17"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" alignment="right" title="Opening Files:" usesSingleLineMode="YES" id="3277">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
@ -106,7 +107,7 @@
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="79">
|
||||
<rect key="frame" x="22" y="335" width="138" height="17"/>
|
||||
<rect key="frame" x="22" y="326" width="138" height="17"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" alignment="right" title="Default text encoding:" usesSingleLineMode="YES" id="3278">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
@ -114,7 +115,7 @@
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="80">
|
||||
<rect key="frame" x="164" y="329" width="225" height="26"/>
|
||||
<rect key="frame" x="164" y="320" width="225" height="26"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="220" id="7pp-Cr-TTw"/>
|
||||
</constraints>
|
||||
@ -128,11 +129,12 @@
|
||||
</menu>
|
||||
</popUpButtonCell>
|
||||
<connections>
|
||||
<action selector="changeEncodingInNewDocument:" target="-2" id="9hU-WD-9Xj"/>
|
||||
<binding destination="26" name="selectedTag" keyPath="values.encodingInNew" id="100"/>
|
||||
</connections>
|
||||
</popUpButton>
|
||||
<button translatesAutoresizingMaskIntoConstraints="NO" id="877">
|
||||
<rect key="frame" x="164" y="251" width="201" height="18"/>
|
||||
<rect key="frame" x="164" y="266" width="201" height="18"/>
|
||||
<buttonCell key="cell" type="check" title="Refer to encoding declaration" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="3280">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
@ -141,20 +143,10 @@
|
||||
<binding destination="26" name="value" keyPath="values.referToEncodingTag" id="879"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button translatesAutoresizingMaskIntoConstraints="NO" id="3248">
|
||||
<rect key="frame" x="163" y="309" width="283" height="18"/>
|
||||
<buttonCell key="cell" type="check" title="Save UTF-8 files with a BOM (not recommended)" bezelStyle="regularSquare" imagePosition="left" alignment="left" controlSize="small" inset="2" id="3281">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<binding destination="26" name="value" keyPath="values.saveUTF8BOM" id="3250"/>
|
||||
</connections>
|
||||
</button>
|
||||
<scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Gmu-7H-gv5">
|
||||
<rect key="frame" x="166" y="82" width="280" height="80"/>
|
||||
<rect key="frame" x="166" y="82" width="280" height="95"/>
|
||||
<clipView key="contentView" id="tYa-xS-9xx">
|
||||
<rect key="frame" x="1" y="1" width="258" height="78"/>
|
||||
<rect key="frame" x="1" y="1" width="278" height="93"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnReordering="NO" columnSelection="YES" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" viewBased="YES" id="i9j-3p-xYF">
|
||||
@ -235,7 +227,7 @@
|
||||
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</clipView>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="80" id="AZ7-Fe-3Vq"/>
|
||||
<constraint firstAttribute="height" constant="95" id="AZ7-Fe-3Vq"/>
|
||||
<constraint firstAttribute="width" constant="280" id="LVm-Np-QAF"/>
|
||||
</constraints>
|
||||
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" controlSize="small" horizontal="YES" id="uuG-1x-3ZZ">
|
||||
@ -248,7 +240,7 @@
|
||||
</scroller>
|
||||
</scrollView>
|
||||
<textField horizontalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="734">
|
||||
<rect key="frame" x="33" y="177" width="127" height="17"/>
|
||||
<rect key="frame" x="33" y="192" width="127" height="17"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Default syntax style:" usesSingleLineMode="YES" id="3329">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
@ -259,7 +251,7 @@
|
||||
</connections>
|
||||
</textField>
|
||||
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="727">
|
||||
<rect key="frame" x="164" y="171" width="285" height="26"/>
|
||||
<rect key="frame" x="164" y="186" width="285" height="26"/>
|
||||
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="clipping" borderStyle="borderAndBezel" inset="2" arrowPosition="arrowAtCenter" preferredEdge="maxY" id="3328">
|
||||
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="menu"/>
|
||||
@ -274,7 +266,7 @@
|
||||
</connections>
|
||||
</popUpButton>
|
||||
<button translatesAutoresizingMaskIntoConstraints="NO" id="703">
|
||||
<rect key="frame" x="339" y="203" width="97" height="18"/>
|
||||
<rect key="frame" x="339" y="218" width="97" height="18"/>
|
||||
<buttonCell key="cell" type="check" title="Delay coloring" bezelStyle="regularSquare" imagePosition="left" alignment="left" controlSize="small" inset="2" id="3327">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
@ -285,7 +277,7 @@
|
||||
</connections>
|
||||
</button>
|
||||
<button translatesAutoresizingMaskIntoConstraints="NO" id="430">
|
||||
<rect key="frame" x="18" y="204" width="181" height="18"/>
|
||||
<rect key="frame" x="18" y="219" width="181" height="18"/>
|
||||
<buttonCell key="cell" type="check" title="Enable syntax highlighting" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="3326">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
@ -295,7 +287,7 @@
|
||||
</connections>
|
||||
</button>
|
||||
<textField horizontalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="710">
|
||||
<rect key="frame" x="203" y="205" width="133" height="14"/>
|
||||
<rect key="frame" x="203" y="220" width="133" height="14"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="(Including Outline Menu)" usesSingleLineMode="YES" id="3325">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
|
||||
@ -303,13 +295,13 @@
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<box verticalHuggingPriority="750" title="Box" boxType="separator" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="eoL-rv-xwG">
|
||||
<rect key="frame" x="20" y="234" width="500" height="5"/>
|
||||
<rect key="frame" x="20" y="249" width="500" height="5"/>
|
||||
<color key="borderColor" white="0.0" alpha="0.41999999999999998" colorSpace="calibratedWhite"/>
|
||||
<color key="fillColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<font key="titleFont" metaFont="system"/>
|
||||
</box>
|
||||
<box verticalHuggingPriority="750" title="Box" boxType="separator" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="lnk-dB-keR">
|
||||
<rect key="frame" x="20" y="366" width="500" height="5"/>
|
||||
<rect key="frame" x="20" y="357" width="500" height="5"/>
|
||||
<color key="borderColor" white="0.0" alpha="0.41999999999999998" colorSpace="calibratedWhite"/>
|
||||
<color key="fillColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<font key="titleFont" metaFont="system"/>
|
||||
@ -402,7 +394,7 @@
|
||||
</popUpButtonCell>
|
||||
</popUpButton>
|
||||
<textField horizontalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="XBA-8h-9hb">
|
||||
<rect key="frame" x="18" y="145" width="142" height="17"/>
|
||||
<rect key="frame" x="18" y="160" width="142" height="17"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Installed syntax styles:" usesSingleLineMode="YES" id="vlw-Tc-sLl">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
@ -415,7 +407,6 @@
|
||||
<constraint firstItem="2157" firstAttribute="top" secondItem="Q0c-oI-um3" secondAttribute="bottom" constant="12" symbolic="YES" id="43f-mz-vRR"/>
|
||||
<constraint firstItem="eoL-rv-xwG" firstAttribute="top" secondItem="877" secondAttribute="bottom" constant="16" id="4y3-GY-gzI"/>
|
||||
<constraint firstItem="727" firstAttribute="leading" secondItem="Gmu-7H-gv5" secondAttribute="leading" id="5CS-fb-lfz"/>
|
||||
<constraint firstItem="76" firstAttribute="top" secondItem="3248" secondAttribute="bottom" constant="16" id="5hC-hZ-y9j"/>
|
||||
<constraint firstItem="XBA-8h-9hb" firstAttribute="top" secondItem="Gmu-7H-gv5" secondAttribute="top" id="5tP-bp-VT1"/>
|
||||
<constraint firstAttribute="bottom" secondItem="2157" secondAttribute="bottom" constant="20" symbolic="YES" id="8ks-ow-A0O"/>
|
||||
<constraint firstItem="80" firstAttribute="leading" secondItem="79" secondAttribute="trailing" constant="8" symbolic="YES" id="AGp-lv-YXm"/>
|
||||
@ -433,7 +424,6 @@
|
||||
<constraint firstItem="Q0c-oI-um3" firstAttribute="top" secondItem="dI1-Dk-Mce" secondAttribute="top" id="OAn-Dg-S9c"/>
|
||||
<constraint firstItem="lnk-dB-keR" firstAttribute="leading" secondItem="745" secondAttribute="leading" constant="20" symbolic="YES" id="OLT-NK-aNo"/>
|
||||
<constraint firstItem="430" firstAttribute="top" secondItem="eoL-rv-xwG" secondAttribute="bottom" constant="16" id="Qae-Js-xzh"/>
|
||||
<constraint firstItem="3248" firstAttribute="top" secondItem="80" secondAttribute="bottom" constant="8" symbolic="YES" id="R8O-n1-SOc"/>
|
||||
<constraint firstItem="734" firstAttribute="top" secondItem="430" secondAttribute="bottom" constant="12" id="Rbw-79-gar"/>
|
||||
<constraint firstItem="76" firstAttribute="leading" secondItem="877" secondAttribute="leading" id="Rro-td-IxJ"/>
|
||||
<constraint firstItem="76" firstAttribute="baseline" secondItem="77" secondAttribute="baseline" id="SG1-jN-DZG"/>
|
||||
@ -450,6 +440,7 @@
|
||||
<constraint firstItem="mI2-B3-2Dr" firstAttribute="leading" secondItem="dI1-Dk-Mce" secondAttribute="trailing" constant="-1" id="eVq-oK-0ma"/>
|
||||
<constraint firstItem="44" firstAttribute="leading" secondItem="76" secondAttribute="trailing" constant="12" id="fkf-DX-XIS"/>
|
||||
<constraint firstItem="703" firstAttribute="leading" secondItem="710" secondAttribute="trailing" constant="8" symbolic="YES" id="h71-40-mVu"/>
|
||||
<constraint firstItem="76" firstAttribute="top" secondItem="80" secondAttribute="bottom" constant="12" id="kZX-KV-FSh"/>
|
||||
<constraint firstItem="727" firstAttribute="leading" secondItem="13" secondAttribute="leading" id="neP-RT-EpQ"/>
|
||||
<constraint firstItem="710" firstAttribute="baseline" secondItem="430" secondAttribute="baseline" id="oAx-4E-BLj"/>
|
||||
<constraint firstItem="Hma-8v-2gu" firstAttribute="top" secondItem="Gmu-7H-gv5" secondAttribute="bottom" constant="8" symbolic="YES" id="pqR-Qg-wsM"/>
|
||||
@ -458,7 +449,6 @@
|
||||
<constraint firstItem="mI2-B3-2Dr" firstAttribute="top" secondItem="Hma-8v-2gu" secondAttribute="top" id="qSa-9V-JrY"/>
|
||||
<constraint firstItem="77" firstAttribute="baseline" secondItem="44" secondAttribute="baseline" id="r46-Uo-ajg"/>
|
||||
<constraint firstItem="Q0c-oI-um3" firstAttribute="trailing" secondItem="Gmu-7H-gv5" secondAttribute="trailing" id="rPT-EM-bI7"/>
|
||||
<constraint firstItem="3248" firstAttribute="leading" secondItem="80" secondAttribute="leading" id="sVQ-Zi-KPR"/>
|
||||
<constraint firstAttribute="trailing" secondItem="lnk-dB-keR" secondAttribute="trailing" constant="30" id="sr3-RZ-lke"/>
|
||||
<constraint firstAttribute="trailing" secondItem="eoL-rv-xwG" secondAttribute="trailing" constant="30" id="tDE-tc-SUo"/>
|
||||
<constraint firstItem="430" firstAttribute="baseline" secondItem="703" secondAttribute="baseline" id="tdc-VO-aPr"/>
|
||||
|
@ -40,10 +40,6 @@
|
||||
<dt>Default text encoding</dt>
|
||||
<dd>You can set the default character encoding used when creating a new document.</dd>
|
||||
|
||||
<dt>Save UTF-8 files with a BOM (not recommended)</dt>
|
||||
<dd>Turn this option on if you want to add a BOM (Byte Order Mark) to any file you save as UTF-8.<br />
|
||||
UTF-8 with BOM can be problematic in some cases, so use this option with care. Leaving this option off is recommended unless you have a specific need for it.</dd>
|
||||
|
||||
<dt>Opening Files</dt>
|
||||
<dd>You can set the default character encoding used when opening an existing file. Auto-Detect will do fine for most cases.</dd>
|
||||
<dd><dl>
|
||||
|
@ -40,10 +40,6 @@
|
||||
<dt>エンコーディング</dt>
|
||||
<dd>新規作成する書類の文字エンコーディングを設定します。</dd>
|
||||
|
||||
<dt>UTF-8 のとき BOM も保存(非推奨)</dt>
|
||||
<dd>エンコーディングを「UTF-8」で保存するとき、冒頭に識別のための「BOM」を追加します。<br />
|
||||
用途によっては読み込めないなどの問題が起きることがありますので取扱には注意してください。特に必要がなければオフのままの使用をお勧めします。</dd>
|
||||
|
||||
<dt>ファイルを開くとき</dt>
|
||||
<dd>既存のファイルを開くときに使用する文字エンコーディングを設定します。通常は「自動認識」でよいでしょう。</dd>
|
||||
<dd><ul>
|
||||
|
@ -285,7 +285,7 @@
|
||||
NSString *actionName = [NSString stringWithFormat:NSLocalizedString(@"Encoding to “%@”", nil),
|
||||
[NSString localizedNameOfStringEncoding:encoding]];
|
||||
|
||||
BOOL success = [self doSetEncoding:encoding updateDocument:YES askLossy:NO lossy:lossy asActionName:actionName];
|
||||
BOOL success = [self doSetEncoding:encoding withUTF8BOM:NO updateDocument:YES askLossy:NO lossy:lossy asActionName:actionName];
|
||||
|
||||
return @(success);
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
© 2004-2007 nakamuxu
|
||||
© 2014-2015 1024jp
|
||||
© 2014-2016 1024jp
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -54,6 +54,7 @@ extern NSString *_Nonnull const CEIncompatibleConvertedCharKey;
|
||||
@property (readonly, nonatomic, nullable) CEEditorWrapper *editor;
|
||||
@property (readonly, nonatomic, nonnull) CETextSelection *selection;
|
||||
@property (readonly, nonatomic) NSStringEncoding encoding;
|
||||
@property (readonly, nonatomic) BOOL hasUTF8BOM;
|
||||
@property (readonly, nonatomic) CENewLineType lineEnding;
|
||||
@property (readonly, nonatomic, nullable, copy) NSDictionary<NSString *, id> *fileAttributes;
|
||||
@property (readonly, nonatomic, getter=isWritable) BOOL writable;
|
||||
@ -71,7 +72,7 @@ extern NSString *_Nonnull const CEIncompatibleConvertedCharKey;
|
||||
- (nullable NSString *)IANACharSetName;
|
||||
- (nullable NSArray<NSDictionary<NSString *, id> *> *)findCharsIncompatibleWithEncoding:(NSStringEncoding)encoding;
|
||||
- (BOOL)reinterpretWithEncoding:(NSStringEncoding)encoding error:(NSError * _Nullable __autoreleasing * _Nullable)outError;
|
||||
- (BOOL)doSetEncoding:(NSStringEncoding)encoding updateDocument:(BOOL)updateDocument askLossy:(BOOL)askLossy lossy:(BOOL)lossy asActionName:(nullable NSString *)actionName;
|
||||
- (BOOL)doSetEncoding:(NSStringEncoding)encoding withUTF8BOM:(BOOL)withUTF8BOM updateDocument:(BOOL)updateDocument askLossy:(BOOL)askLossy lossy:(BOOL)lossy asActionName:(nullable NSString *)actionName;
|
||||
|
||||
// line ending
|
||||
- (void)doSetLineEnding:(CENewLineType)lineEnding;
|
||||
|
@ -95,6 +95,7 @@ NSString *_Nonnull const CEIncompatibleConvertedCharKey = @"convertedChar";
|
||||
@property (readwrite, nonatomic, nullable) CEWindowController *windowController;
|
||||
@property (readwrite, nonatomic, nonnull) CETextSelection *selection;
|
||||
@property (readwrite, nonatomic) NSStringEncoding encoding;
|
||||
@property (readwrite, nonatomic) BOOL hasUTF8BOM;
|
||||
@property (readwrite, nonatomic) CENewLineType lineEnding;
|
||||
@property (readwrite, nonatomic, nullable, copy) NSDictionary<NSString *, id> *fileAttributes;
|
||||
@property (readwrite, nonatomic, getter=isWritable) BOOL writable;
|
||||
@ -148,6 +149,9 @@ NSString *_Nonnull const CEIncompatibleConvertedCharKey = @"convertedChar";
|
||||
|
||||
_encoding = [[NSUserDefaults standardUserDefaults] integerForKey:CEDefaultEncodingInNewKey];
|
||||
_lineEnding = [[NSUserDefaults standardUserDefaults] integerForKey:CEDefaultLineEndCharCodeKey];
|
||||
if (_encoding == NSUTF8StringEncoding) {
|
||||
_hasUTF8BOM = [[NSUserDefaults standardUserDefaults] boolForKey:CEDefaultSaveUTF8BOMKey];
|
||||
}
|
||||
_syntaxStyle = [[CESyntaxManager sharedManager] styleWithName:[[NSUserDefaults standardUserDefaults] stringForKey:CEDefaultSyntaxStyleKey]];
|
||||
_selection = [[CETextSelection alloc] initWithDocument:self];
|
||||
_writable = YES;
|
||||
@ -244,12 +248,14 @@ NSString *_Nonnull const CEIncompatibleConvertedCharKey = @"convertedChar";
|
||||
|
||||
NSStringEncoding usedEncoding;
|
||||
NSString *string = [self stringFromData:data encoding:[self readingEncoding] xattrEncoding:xattrEncoding usedEncoding:&usedEncoding error:outError];
|
||||
BOOL hasUTF8BOM = (usedEncoding == NSUTF8StringEncoding) ? [data hasUTF8BOM] : NO;
|
||||
|
||||
if (!string) { return NO; }
|
||||
|
||||
// set read values
|
||||
[self setFileContentString:string]; // _fileContentString will be released in `setStringToEditor`
|
||||
[self setEncoding:usedEncoding];
|
||||
[self setHasUTF8BOM:hasUTF8BOM];
|
||||
|
||||
CENewLineType lineEnding = [string detectNewLineType];
|
||||
if (lineEnding != CENewLineNone) { // keep default if no line endings are found
|
||||
@ -306,6 +312,7 @@ NSString *_Nonnull const CEIncompatibleConvertedCharKey = @"convertedChar";
|
||||
// ------------------------------------------------------
|
||||
{
|
||||
NSStringEncoding encoding = [self encoding];
|
||||
BOOL hasUTF8BOM = [self hasUTF8BOM];
|
||||
|
||||
// convert Yen sign in consideration of the current encoding
|
||||
NSString *string = [self convertCharacterString:[self string] encoding:encoding];
|
||||
@ -325,9 +332,7 @@ NSString *_Nonnull const CEIncompatibleConvertedCharKey = @"convertedChar";
|
||||
if (!data) { return nil; }
|
||||
|
||||
// add UTF-8 BOM if needed
|
||||
if ([[NSUserDefaults standardUserDefaults] boolForKey:CEDefaultSaveUTF8BOMKey] &&
|
||||
(encoding == NSUTF8StringEncoding))
|
||||
{
|
||||
if ((encoding == NSUTF8StringEncoding) && hasUTF8BOM) {
|
||||
data = [data dataByAddingUTF8BOM];
|
||||
}
|
||||
|
||||
@ -617,7 +622,7 @@ NSString *_Nonnull const CEIncompatibleConvertedCharKey = @"convertedChar";
|
||||
|
||||
[document setSyntaxStyleWithName:[[self syntaxStyle] styleName]];
|
||||
[document doSetLineEnding:[self lineEnding]];
|
||||
[document doSetEncoding:[self encoding] updateDocument:NO askLossy:NO lossy:NO asActionName:nil];
|
||||
[document doSetEncoding:[self encoding] withUTF8BOM:[self hasUTF8BOM] updateDocument:NO askLossy:NO lossy:NO asActionName:nil];
|
||||
|
||||
// apply text orientation
|
||||
CEEditorWrapper *editor = [self editor];
|
||||
@ -713,19 +718,24 @@ NSString *_Nonnull const CEIncompatibleConvertedCharKey = @"convertedChar";
|
||||
if ([menuItem action] == @selector(saveDocument:)) {
|
||||
// 書き込み不可の時は、アラートが表示され「OK」されるまで保存メニューを無効化する
|
||||
return ([self isWritable] || [self didAlertNotWritable]);
|
||||
|
||||
} else if ([menuItem action] == @selector(changeEncoding:)) {
|
||||
state = ([menuItem tag] == [self encoding]) ? NSOnState : NSOffState;
|
||||
NSInteger encodingTag = [self hasUTF8BOM] ? -[self encoding] : [self encoding];
|
||||
state = ([menuItem tag] == encodingTag) ? NSOnState : NSOffState;
|
||||
|
||||
} else if (([menuItem action] == @selector(changeLineEndingToLF:)) ||
|
||||
([menuItem action] == @selector(changeLineEndingToCR:)) ||
|
||||
([menuItem action] == @selector(changeLineEndingToCRLF:)) ||
|
||||
([menuItem action] == @selector(changeLineEnding:)))
|
||||
{
|
||||
state = ([menuItem tag] == [self lineEnding]) ? NSOnState : NSOffState;
|
||||
|
||||
} else if ([menuItem action] == @selector(changeSyntaxStyle:)) {
|
||||
NSString *name = [[self syntaxStyle] styleName];
|
||||
if (name && [[menuItem title] isEqualToString:name]) {
|
||||
state = NSOnState;
|
||||
}
|
||||
|
||||
}
|
||||
[menuItem setState:state];
|
||||
|
||||
@ -987,10 +997,10 @@ NSString *_Nonnull const CEIncompatibleConvertedCharKey = @"convertedChar";
|
||||
|
||||
// ------------------------------------------------------
|
||||
/// 新規エンコーディングをセット
|
||||
- (BOOL)doSetEncoding:(NSStringEncoding)encoding updateDocument:(BOOL)updateDocument askLossy:(BOOL)askLossy lossy:(BOOL)lossy asActionName:(nullable NSString *)actionName
|
||||
- (BOOL)doSetEncoding:(NSStringEncoding)encoding withUTF8BOM:(BOOL)withUTF8BOM updateDocument:(BOOL)updateDocument askLossy:(BOOL)askLossy lossy:(BOOL)lossy asActionName:(nullable NSString *)actionName
|
||||
// ------------------------------------------------------
|
||||
{
|
||||
if (encoding == [self encoding]) {
|
||||
if (encoding == [self encoding] && withUTF8BOM == [self hasUTF8BOM]) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
@ -1022,7 +1032,8 @@ NSString *_Nonnull const CEIncompatibleConvertedCharKey = @"convertedChar";
|
||||
|
||||
// register undo
|
||||
NSUndoManager *undoManager = [self undoManager];
|
||||
[[undoManager prepareWithInvocationTarget:self] redoSetEncoding:encoding updateDocument:updateDocument
|
||||
[[undoManager prepareWithInvocationTarget:self] redoSetEncoding:encoding withUTF8BOM:withUTF8BOM
|
||||
updateDocument:updateDocument
|
||||
askLossy:NO lossy:allowsLossy
|
||||
asActionName:actionName]; // redo in undo
|
||||
if (shouldShowList) {
|
||||
@ -1030,12 +1041,15 @@ NSString *_Nonnull const CEIncompatibleConvertedCharKey = @"convertedChar";
|
||||
}
|
||||
[[undoManager prepareWithInvocationTarget:self] updateEncodingInToolbarAndInfo];
|
||||
[[undoManager prepareWithInvocationTarget:self] setEncoding:[self encoding]]; // エンコード値設定
|
||||
[[undoManager prepareWithInvocationTarget:self] setHasUTF8BOM:[self hasUTF8BOM]]; // エンコード値設定
|
||||
|
||||
if (actionName) {
|
||||
[undoManager setActionName:actionName];
|
||||
}
|
||||
}
|
||||
|
||||
[self setEncoding:encoding];
|
||||
[self setHasUTF8BOM:withUTF8BOM];
|
||||
[self updateEncodingInToolbarAndInfo]; // ツールバーのエンコーディングメニュー、ステータスバー、インスペクタを更新
|
||||
|
||||
if (shouldShowList) {
|
||||
@ -1204,15 +1218,19 @@ NSString *_Nonnull const CEIncompatibleConvertedCharKey = @"convertedChar";
|
||||
- (IBAction)changeEncoding:(nullable id)sender
|
||||
// ------------------------------------------------------
|
||||
{
|
||||
NSStringEncoding encoding = [sender tag];
|
||||
NSStringEncoding encoding = labs([sender tag]);
|
||||
BOOL withUTF8BOM = ([sender tag] == -NSUTF8StringEncoding);
|
||||
|
||||
if ((encoding < 1) || (encoding == [self encoding])) { return; }
|
||||
if ((encoding == [self encoding]) && (withUTF8BOM == [self hasUTF8BOM])) { return; }
|
||||
|
||||
NSInteger result;
|
||||
NSString *encodingName = [sender title];
|
||||
|
||||
// 文字列がないまたは未保存の時は直ちに変換プロセスへ
|
||||
if (([[[self editor] string] length] < 1) || ![self fileURL]) {
|
||||
if (([[[self editor] string] length] < 1) || // no content yet
|
||||
![self fileURL] || // not yet saved
|
||||
(encoding == NSUTF8StringEncoding && encoding == [self encoding])) // toggle only BOM existance
|
||||
{
|
||||
result = NSAlertFirstButtonReturn;
|
||||
|
||||
} else {
|
||||
@ -1229,9 +1247,9 @@ NSString *_Nonnull const CEIncompatibleConvertedCharKey = @"convertedChar";
|
||||
|
||||
if (result == NSAlertFirstButtonReturn) { // = Convert 変換
|
||||
NSString *actionName = [NSString stringWithFormat:NSLocalizedString(@"Encoding to “%@”", nil),
|
||||
[NSString localizedNameOfStringEncoding:encoding]];
|
||||
[NSString localizedNameOfStringEncoding:encoding withUTF8BOM:withUTF8BOM]];
|
||||
|
||||
[self doSetEncoding:encoding updateDocument:YES askLossy:YES lossy:NO asActionName:actionName];
|
||||
[self doSetEncoding:encoding withUTF8BOM:withUTF8BOM updateDocument:YES askLossy:YES lossy:NO asActionName:actionName];
|
||||
|
||||
} else if (result == NSAlertSecondButtonReturn) { // = Reinterpret 再解釈
|
||||
if (![self fileURL]) { return; } // まだファイル保存されていない時(ファイルがない時)は、戻る
|
||||
@ -1245,7 +1263,7 @@ NSString *_Nonnull const CEIncompatibleConvertedCharKey = @"convertedChar";
|
||||
NSInteger secondResult = [alert runModal];
|
||||
if (secondResult != NSAlertSecondButtonReturn) { // = Cancel
|
||||
// ツールバーから変更された場合のため、ツールバーアイテムの選択状態をリセット
|
||||
[[[self windowController] toolbarController] setSelectedEncoding:[self encoding]];
|
||||
[[[self windowController] toolbarController] setSelectedEncoding:[self encoding] withUTF8BOM:[self hasUTF8BOM]];
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1263,7 +1281,7 @@ NSString *_Nonnull const CEIncompatibleConvertedCharKey = @"convertedChar";
|
||||
}
|
||||
|
||||
// ツールバーから変更された場合のため、ツールバーアイテムの選択状態をリセット
|
||||
[[[self windowController] toolbarController] setSelectedEncoding:[self encoding]];
|
||||
[[[self windowController] toolbarController] setSelectedEncoding:[self encoding] withUTF8BOM:[self hasUTF8BOM]];
|
||||
}
|
||||
|
||||
|
||||
@ -1342,7 +1360,7 @@ NSString *_Nonnull const CEIncompatibleConvertedCharKey = @"convertedChar";
|
||||
// ------------------------------------------------------
|
||||
{
|
||||
// ツールバーのエンコーディングメニューを更新
|
||||
[[[self windowController] toolbarController] setSelectedEncoding:[self encoding]];
|
||||
[[[self windowController] toolbarController] setSelectedEncoding:[self encoding] withUTF8BOM:[self hasUTF8BOM]];
|
||||
|
||||
// ステータスバー、インスペクタを更新
|
||||
[[self windowController] updateModeInfoIfNeeded];
|
||||
@ -1549,10 +1567,10 @@ NSString *_Nonnull const CEIncompatibleConvertedCharKey = @"convertedChar";
|
||||
|
||||
// ------------------------------------------------------
|
||||
/// エンコードを変更するアクションのRedo登録
|
||||
- (void)redoSetEncoding:(NSStringEncoding)encoding updateDocument:(BOOL)updateDocument askLossy:(BOOL)askLossy lossy:(BOOL)lossy asActionName:(nullable NSString *)actionName
|
||||
- (void)redoSetEncoding:(NSStringEncoding)encoding withUTF8BOM:(BOOL)withUTF8BOM updateDocument:(BOOL)updateDocument askLossy:(BOOL)askLossy lossy:(BOOL)lossy asActionName:(nullable NSString *)actionName
|
||||
// ------------------------------------------------------
|
||||
{
|
||||
[[[self undoManager] prepareWithInvocationTarget:self] doSetEncoding:encoding updateDocument:updateDocument
|
||||
[[[self undoManager] prepareWithInvocationTarget:self] doSetEncoding:encoding withUTF8BOM:withUTF8BOM updateDocument:updateDocument
|
||||
askLossy:askLossy lossy:lossy asActionName:actionName];
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
#import "CEEditorWrapper.h"
|
||||
#import "CECharacterInfo.h"
|
||||
#import "NSString+CECounting.h"
|
||||
#import "NSString+CEEncoding.h"
|
||||
#import "CEDefaults.h"
|
||||
|
||||
|
||||
@ -135,7 +136,7 @@ NSString *_Nonnull const CEAnalyzerDidUpdateEditorInfoNotification = @"CEAnalyze
|
||||
{
|
||||
CEDocument *document = [self document];
|
||||
|
||||
self.encoding = [NSString localizedNameOfStringEncoding:[document encoding]];
|
||||
self.encoding = [NSString localizedNameOfStringEncoding:[document encoding] withUTF8BOM:[document hasUTF8BOM]];
|
||||
self.charsetName = [document IANACharSetName];
|
||||
self.lineEndings = [NSString newLineNameWithType:[document lineEnding]];
|
||||
|
||||
|
@ -30,6 +30,8 @@
|
||||
#import "CEDefaults.h"
|
||||
#import "CEEncodings.h"
|
||||
|
||||
#import "NSString+CEEncoding.h"
|
||||
|
||||
|
||||
NSString *_Nonnull const CEEncodingListDidUpdateNotification = @"CESyntaxListDidUpdateNotification";
|
||||
|
||||
@ -172,6 +174,15 @@ NSString *_Nonnull const CEEncodingListDidUpdateNotification = @"CESyntaxListDid
|
||||
[item setAction:@selector(changeEncoding:)];
|
||||
[item setTarget:nil];
|
||||
[menu addItem:item];
|
||||
|
||||
// add "UTF-8 with BOM" item just after the normal UTF-8
|
||||
if ([item tag] == NSUTF8StringEncoding) {
|
||||
NSMenuItem *bomItem = [[NSMenuItem alloc] initWithTitle:[NSString localizedNameOfUTF8EncodingWithBOM]
|
||||
action:@selector(changeEncoding:)
|
||||
keyEquivalent:@""];
|
||||
[bomItem setTag:-NSUTF8StringEncoding]; // negative value is sign for "with BOM"
|
||||
[menu addItem:bomItem];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,12 +37,14 @@
|
||||
#import "CEEncodings.h"
|
||||
#import "Constants.h"
|
||||
|
||||
#import "NSString+CEEncoding.h"
|
||||
#import "NSAlert+BlockMethods.h"
|
||||
|
||||
|
||||
// constants
|
||||
NSString *_Nonnull const StyleNameKey = @"name";
|
||||
NSString *_Nonnull const StyleStateKey = @"state";
|
||||
NSString *_Nonnull const IsUTF8WithBOM = @"UTF-8 with BOM";
|
||||
|
||||
|
||||
@interface CEFormatPaneController () <NSTableViewDelegate>
|
||||
@ -99,8 +101,6 @@ NSString *_Nonnull const StyleStateKey = @"state";
|
||||
[[self syntaxTableView] setTarget:self];
|
||||
|
||||
[self setupEncodingMenus];
|
||||
[[self encodingMenuInOpen] setAction:@selector(checkSelectedItemOfEncodingMenuInOpen:)];
|
||||
[[self encodingMenuInOpen] setTarget:self];
|
||||
|
||||
// シンタックススタイルリスト更新の通知依頼
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
@ -144,8 +144,8 @@ NSString *_Nonnull const StyleStateKey = @"state";
|
||||
} else {
|
||||
representedStyleName = [[self stylesController] arrangedObjects][clickedrow][StyleNameKey];
|
||||
}
|
||||
[menuItem setRepresentedObject:representedStyleName];
|
||||
}
|
||||
[menuItem setRepresentedObject:representedStyleName];
|
||||
|
||||
BOOL isCustomized = NO;
|
||||
BOOL isBundled = NO;
|
||||
@ -243,6 +243,17 @@ NSString *_Nonnull const StyleStateKey = @"state";
|
||||
|
||||
#pragma mark Action Messages
|
||||
|
||||
// ------------------------------------------------------
|
||||
/// save also availability of UTF-8 BOM
|
||||
- (IBAction)changeEncodingInNewDocument:(nullable id)sender
|
||||
// ------------------------------------------------------
|
||||
{
|
||||
BOOL withUTF8BOM = [[[[self encodingMenuInNew] selectedItem] representedObject] isEqualToString:IsUTF8WithBOM];
|
||||
|
||||
[[NSUserDefaults standardUserDefaults] setBool:withUTF8BOM forKey:CEDefaultSaveUTF8BOMKey];
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------
|
||||
/// エンコーディングリスト編集シートを開き、閉じる
|
||||
- (IBAction)openEncodingEditSheet:(nullable id)sender
|
||||
@ -469,12 +480,35 @@ NSString *_Nonnull const StyleStateKey = @"state";
|
||||
for (NSMenuItem *item in menuItems) {
|
||||
[[[self encodingMenuInOpen] menu] addItem:[item copy]];
|
||||
[[[self encodingMenuInNew] menu] addItem:[item copy]];
|
||||
|
||||
// add "UTF-8 with BOM" item only to "In New" menu
|
||||
if ([item tag] == NSUTF8StringEncoding) {
|
||||
NSMenuItem *bomItem = [[NSMenuItem alloc] initWithTitle:[NSString localizedNameOfUTF8EncodingWithBOM]
|
||||
action:NULL
|
||||
keyEquivalent:@""];
|
||||
[bomItem setTag:NSUTF8StringEncoding];
|
||||
[bomItem setRepresentedObject:IsUTF8WithBOM];
|
||||
[[[self encodingMenuInNew] menu] addItem:bomItem];
|
||||
}
|
||||
}
|
||||
|
||||
// (エンコーディング設定メニューはバインディングを使っているが、タグの選択がバインディングで行われた後に
|
||||
// メニューが追加/削除されるため、結果的に選択がうまく動かない。しかたないので、コードから選択している)
|
||||
[[self encodingMenuInOpen] selectItemWithTag:[[NSUserDefaults standardUserDefaults] integerForKey:CEDefaultEncodingInOpenKey]];
|
||||
[[self encodingMenuInNew] selectItemWithTag:[[NSUserDefaults standardUserDefaults] integerForKey:CEDefaultEncodingInNewKey]];
|
||||
|
||||
NSStringEncoding encodingInNew = [[NSUserDefaults standardUserDefaults] integerForKey:CEDefaultEncodingInNewKey];
|
||||
if (encodingInNew == NSUTF8StringEncoding) {
|
||||
NSUInteger index = [[self encodingMenuInNew] indexOfItemWithRepresentedObject:IsUTF8WithBOM];
|
||||
|
||||
// -> The normal "UTF-8" is just above "UTF-8 with BOM".
|
||||
if (![[NSUserDefaults standardUserDefaults] boolForKey:CEDefaultSaveUTF8BOMKey]) {
|
||||
index--;
|
||||
}
|
||||
[[self encodingMenuInNew] selectItemAtIndex:index];
|
||||
|
||||
} else {
|
||||
[[self encodingMenuInNew] selectItemWithTag:encodingInNew];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -63,7 +63,7 @@ typedef NS_ENUM(NSInteger, CEToolbarItemTag) {
|
||||
|
||||
// Public method
|
||||
- (void)toggleItemWithTag:(CEToolbarItemTag)tag setOn:(BOOL)setOn;
|
||||
- (void)setSelectedEncoding:(NSStringEncoding)encoding;
|
||||
- (void)setSelectedEncoding:(NSStringEncoding)encoding withUTF8BOM:(BOOL)withUTF8BOM;
|
||||
- (void)setSelectedLineEnding:(CENewLineType)lineEnding;
|
||||
- (void)setSelectedSyntaxWithName:(nonnull NSString *)name;
|
||||
|
||||
|
@ -111,10 +111,11 @@
|
||||
|
||||
// ------------------------------------------------------
|
||||
/// select item in the encoding popup menu
|
||||
- (void)setSelectedEncoding:(NSStringEncoding)encoding
|
||||
- (void)setSelectedEncoding:(NSStringEncoding)encoding withUTF8BOM:(BOOL)withUTF8BOM
|
||||
// ------------------------------------------------------
|
||||
{
|
||||
[[self encodingPopupButton] selectItemWithTag:encoding];
|
||||
NSInteger tag = withUTF8BOM ? -encoding : encoding;
|
||||
[[self encodingPopupButton] selectItemWithTag:tag];
|
||||
}
|
||||
|
||||
|
||||
@ -242,12 +243,12 @@
|
||||
// ------------------------------------------------------
|
||||
{
|
||||
// store current selection
|
||||
NSStringEncoding encoding = [[self encodingPopupButton] selectedTag];
|
||||
NSInteger tag = [[self encodingPopupButton] selectedTag];
|
||||
|
||||
[[CEEncodingManager sharedManager] updateChangeEncodingMenu:[[self encodingPopupButton] menu]];
|
||||
|
||||
// reapply to the menu
|
||||
[[self encodingPopupButton] selectItemWithTag:encoding];
|
||||
[[self encodingPopupButton] selectItemWithTag:tag];
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,6 +34,9 @@ BOOL CEIsCompatibleIANACharSetEncoding(NSStringEncoding IANACharsetEncoding, NSS
|
||||
|
||||
@interface NSString (CEEncoding)
|
||||
|
||||
+ (nonnull NSString *)localizedNameOfStringEncoding:(NSStringEncoding)encoding withUTF8BOM:(BOOL)withBOM;
|
||||
+ (nonnull NSString *)localizedNameOfUTF8EncodingWithBOM;
|
||||
|
||||
/// obtain string from NSData with intelligent encoding detection
|
||||
- (nullable instancetype)initWithData:(nonnull NSData *)data suggestedCFEncodings:(nonnull NSArray<NSNumber *> *)suggestedCFEncodings usedEncoding:(nonnull NSStringEncoding *)usedEncoding error:(NSError * _Nullable __autoreleasing * _Nullable)outError;
|
||||
|
||||
@ -47,5 +50,6 @@ BOOL CEIsCompatibleIANACharSetEncoding(NSStringEncoding IANACharsetEncoding, NSS
|
||||
@interface NSData (UTF8BOM)
|
||||
|
||||
- (nonnull NSData *)dataByAddingUTF8BOM;
|
||||
- (BOOL)hasUTF8BOM;
|
||||
|
||||
@end
|
||||
|
@ -66,12 +66,35 @@ BOOL CEIsCompatibleIANACharSetEncoding(NSStringEncoding IANACharsetEncoding, NSS
|
||||
|
||||
#pragma mark Public Methods
|
||||
|
||||
//------------------------------------------------------
|
||||
/// human-readable encoding name considering UTF-8 BOM
|
||||
+ (nonnull NSString *)localizedNameOfStringEncoding:(NSStringEncoding)encoding withUTF8BOM:(BOOL)withBOM
|
||||
//------------------------------------------------------
|
||||
{
|
||||
if (encoding == NSUTF8StringEncoding && withBOM) {
|
||||
return [self localizedNameOfUTF8EncodingWithBOM];
|
||||
}
|
||||
|
||||
return [NSString localizedNameOfStringEncoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------
|
||||
/// human-readable encoding name for UTF-8 with BOM
|
||||
+ (nonnull NSString *)localizedNameOfUTF8EncodingWithBOM
|
||||
//------------------------------------------------------
|
||||
{
|
||||
return [NSString stringWithFormat:NSLocalizedString(@"%@ with BOM", @"Unicode (UTF-8) with BOM"),
|
||||
[NSString localizedNameOfStringEncoding:NSUTF8StringEncoding]];
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------
|
||||
/// obtain string from NSData with intelligent encoding detection
|
||||
- (nullable instancetype)initWithData:(nonnull NSData *)data suggestedCFEncodings:(NSArray<NSNumber *> *)suggestedCFEncodings usedEncoding:(nonnull NSStringEncoding *)usedEncoding error:(NSError * _Nullable __autoreleasing * _Nullable)outError
|
||||
//------------------------------------------------------
|
||||
{
|
||||
// detect enoding from so-called "magic numbers"
|
||||
// detect encoding from so-called "magic numbers"
|
||||
NSStringEncoding triedEncoding = NSNotFound;
|
||||
if ([data length] > 1) {
|
||||
char miniBytes[4] = {0};
|
||||
@ -246,7 +269,15 @@ BOOL CEIsCompatibleIANACharSetEncoding(NSStringEncoding IANACharsetEncoding, NSS
|
||||
[mutableData appendData:self];
|
||||
|
||||
return [NSData dataWithData:mutableData];
|
||||
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------
|
||||
/// check if data starts with UTF-8 BOM
|
||||
- (BOOL)hasUTF8BOM
|
||||
//------------------------------------------------------
|
||||
{
|
||||
return !memcmp([self bytes], kUTF8Bom, 3);
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
© 2015 1024jp
|
||||
© 2015-2016 1024jp
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -39,6 +39,9 @@
|
||||
/* Class = "NSButtonCell"; title = "Delete Separator"; ObjectID = "3393"; */
|
||||
"3393.title" = "Separater löschen";
|
||||
|
||||
/* Class = "NSTextFieldCell"; title = "“Unicode (UTF-8) with BOM” will be automatically added to just after the normal “Unicode (UTF-8)”."; ObjectID = "jXZ-7k-86F"; */
|
||||
"jXZ-7k-86F.title" = "„Unicode (UTF-8) mit BOM“ wird gerade nach der normalen „Unicode (UTF-8)“ automatisch hinzugefügt.";
|
||||
|
||||
/* Class = "NSButtonCell"; title = "Restore Defaults"; ObjectID = "3396"; */
|
||||
"3396.title" = "Auf Standard zurücksetzen";
|
||||
/* Class = "NSButtonCell"; title = "Cancel"; ObjectID = "3390"; */
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
© 2015 1024jp
|
||||
© 2015-2016 1024jp
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -37,8 +37,6 @@
|
||||
|
||||
/* Class = "NSTextFieldCell"; title = "Default text encoding:"; ObjectID = "3278"; */
|
||||
"3278.title" = "Standard-Codierung:";
|
||||
/* Class = "NSButtonCell"; title = "Save UTF-8 files with a BOM (not recommended)"; ObjectID = "3281"; */
|
||||
"3281.title" = "UTF8-Dateien mit BOM sichern (nicht zu empfehlen)";
|
||||
|
||||
/* Class = "NSTextFieldCell"; title = "Opening Files:"; ObjectID = "3277"; */
|
||||
"3277.title" = "Beim Öffnen:";
|
||||
|
@ -501,3 +501,9 @@
|
||||
"The script file “%@” couldn’t be opened." = "Die Skriptdatei „%@“ konnte nicht geöffnet werden.";
|
||||
"The script “%@” can’t be executed because you don’t have the execute permission.\n\nCheck permission of the script file." = "Das Skript „%@“ kann nicht ausgeführt werden, da Sie nicht den Ausführrecht haben.\n\nPrüfen Sie die Zugriffsrechte der Skriptdatei.";
|
||||
"The script “%@” couldn’t be read." = "Das Skript „%@“ konnte nicht gelesen werden.";
|
||||
|
||||
|
||||
|
||||
/* NSString Categories */
|
||||
// Encoding name for UTF-8 with BOM (`%@` is the system localized name for UTF-8)
|
||||
"%@ with BOM" = "%@ mit BOM";
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
© 2014 CotEditor Project
|
||||
© 2014-2016 CotEditor Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -39,6 +39,9 @@
|
||||
/* Class = "NSButtonCell"; title = "Delete Separator"; ObjectID = "3393"; */
|
||||
"3393.title" = "区切り線を削除";
|
||||
|
||||
/* Class = "NSTextFieldCell"; title = "“Unicode (UTF-8) with BOM” will be automatically added to just after the normal “Unicode (UTF-8)”."; ObjectID = "jXZ-7k-86F"; */
|
||||
"jXZ-7k-86F.title" = "“Unicode(UTF-8)BOM 付き”は“Unicode(UTF-8)”の次に自動的に追加されます。";
|
||||
|
||||
/* Class = "NSButtonCell"; title = "Restore Defaults"; ObjectID = "3396"; */
|
||||
"3396.title" = "デフォルトに戻す";
|
||||
/* Class = "NSButtonCell"; title = "Cancel"; ObjectID = "3390"; */
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
© 2014 CotEditor Project
|
||||
© 2014-2016 CotEditor Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -37,8 +37,6 @@
|
||||
|
||||
/* Class = "NSTextFieldCell"; title = "Default text encoding:"; ObjectID = "3278"; */
|
||||
"3278.title" = "エンコーディング:";
|
||||
/* Class = "NSButtonCell"; title = "Save UTF-8 files with a BOM (not recommended)"; ObjectID = "3281"; */
|
||||
"3281.title" = "UTF-8 のとき BOM も保存(非推奨)";
|
||||
|
||||
/* Class = "NSTextFieldCell"; title = "Opening Files:"; ObjectID = "3277"; */
|
||||
"3277.title" = "ファイルを開くとき:";
|
||||
|
@ -503,3 +503,9 @@
|
||||
"The script file “%@” couldn’t be opened." = "スクリプトファイル“%@”を開けませんでした。";
|
||||
"The script “%@” can’t be executed because you don’t have the execute permission.\n\nCheck permission of the script file." = "実行権がないため、スクリプト„%@“を実行できません。\n\nスクリプトファイルのアクセス権を確認してください。";
|
||||
"The script “%@” couldn’t be read." = "スクリプト“%@”を読み込めませんでした。";
|
||||
|
||||
|
||||
|
||||
/* NSString Categories */
|
||||
// Encoding name for UTF-8 with BOM (`%@` is the system localized name for UTF-8)
|
||||
"%@ with BOM" = "%@BOM 付き";
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
© 2014-2015 CotEditor Project
|
||||
© 2014-2016 CotEditor Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -40,6 +40,9 @@
|
||||
/* Class = "NSButtonCell"; title = "Delete Separator"; ObjectID = "3393"; */
|
||||
"3393.title" = "删除分隔线";
|
||||
|
||||
/* Class = "NSTextFieldCell"; title = "“Unicode (UTF-8) with BOM” will be automatically added to just after the normal “Unicode (UTF-8)”."; ObjectID = "jXZ-7k-86F"; */
|
||||
"jXZ-7k-86F.title" = "“Unicode (UTF-8) with BOM” will be automatically added to just after the normal “Unicode (UTF-8)”."; // FIXME: added
|
||||
|
||||
/* Class = "NSButtonCell"; title = "Restore Defaults"; ObjectID = "3396"; */
|
||||
"3396.title" = "恢复默认";
|
||||
/* Class = "NSButtonCell"; title = "Cancel"; ObjectID = "3390"; */
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
© 2014-2015 CotEditor Project
|
||||
© 2014-2016 CotEditor Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -38,8 +38,6 @@
|
||||
|
||||
/* Class = "NSTextFieldCell"; title = "Default text encoding:"; ObjectID = "3278"; */
|
||||
"3278.title" = "默认文本编码:";
|
||||
/* Class = "NSButtonCell"; title = "Save UTF-8 files with a BOM (not recommended)"; ObjectID = "3281"; */
|
||||
"3281.title" = "以带有 BOM 的方式保存 UTF-8 文件(不推荐)";
|
||||
|
||||
/* Class = "NSTextFieldCell"; title = "Opening Files:"; ObjectID = "3277"; */
|
||||
"3277.title" = "打开文件:";
|
||||
|
@ -501,3 +501,9 @@
|
||||
"The script file “%@” couldn’t be opened." = "无法打开脚本文件“%@”。";
|
||||
"The script “%@” can’t be executed because you don’t have the execute permission.\n\nCheck permission of the script file." = "由于没有执行权限,无法执行脚本“%@”。\n\n请确认脚本文件的权限。";
|
||||
"The script “%@” couldn’t be read." = "无法读取脚本“%@”。";
|
||||
|
||||
|
||||
|
||||
/* NSString Categories */
|
||||
// Encoding name for UTF-8 with BOM (`%@` is the system localized name for UTF-8)
|
||||
"%@ with BOM" = "%@ with BOM"; // FIXME: added
|
||||
|
Loading…
Reference in New Issue
Block a user