Add error message to pattern sort sheet

This commit is contained in:
1024jp 2022-07-25 20:52:31 +09:00
parent d5c40c19e5
commit d95fd8e480
12 changed files with 116 additions and 7 deletions

View File

@ -20,6 +20,7 @@ Change Log
- Store the state of the “Dont ask again for this document” option for the inconsistent line endings alert and respect it for future open.
- Support the split cursor for bidirectional languages in multi-cursor editing.
- Update the CotEditor's setting view in the print panel.
- Display the error message in the pattern sort dialog if the regular expression pattern is invalid.
- Improve the algorithm to parse numbers in the Sort by Pattern command.
- Improve the algorithm of uncommenting.
- Deprecate the “Ignore line endings when counting characters” option.

View File

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="uia-jw-3Md">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="21208.1" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="uia-jw-3Md">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="20037"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21208.1"/>
<capability name="Image references" minToolsVersion="12.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
@ -107,7 +108,7 @@ Gw
</connections>
</button>
<containerView translatesAutoresizingMaskIntoConstraints="NO" id="dBa-xL-w0w">
<rect key="frame" x="100" y="168" width="392" height="101"/>
<rect key="frame" x="100" y="168" width="372" height="101"/>
<connections>
<segue destination="UQP-be-J0h" kind="embed" id="Jqt-CD-otV"/>
</connections>
@ -244,7 +245,7 @@ Gw
<constraint firstItem="dx8-zl-dSu" firstAttribute="leading" secondItem="sc1-QB-34d" secondAttribute="trailing" constant="8" symbolic="YES" id="bfA-ij-0mz"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="XDJ-2v-jYy" secondAttribute="trailing" constant="20" symbolic="YES" id="bvu-Pr-bjY"/>
<constraint firstItem="CQO-oZ-nKa" firstAttribute="leading" secondItem="pgB-9B-CeZ" secondAttribute="leading" priority="750" constant="20" symbolic="YES" id="d1y-Yd-imT"/>
<constraint firstAttribute="trailing" secondItem="dBa-xL-w0w" secondAttribute="trailing" id="dH5-Kc-gkE"/>
<constraint firstAttribute="trailing" secondItem="dBa-xL-w0w" secondAttribute="trailing" constant="20" symbolic="YES" id="dH5-Kc-gkE"/>
<constraint firstItem="fPh-fe-6Jh" firstAttribute="leading" secondItem="CQO-oZ-nKa" secondAttribute="trailing" constant="8" symbolic="YES" id="eT7-i2-vIY"/>
<constraint firstItem="bN6-xc-HWj" firstAttribute="leading" secondItem="dx8-zl-dSu" secondAttribute="trailing" constant="12" id="fQc-Wt-6vB"/>
<constraint firstItem="dBa-xL-w0w" firstAttribute="leading" secondItem="oqP-25-2rA" secondAttribute="trailing" constant="8" symbolic="YES" id="gf2-zF-2Xp"/>
@ -425,7 +426,7 @@ Gw
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="kD8-MY-cO8" customClass="RegexTextField" customModule="CotEditor" customModuleProvider="target">
<rect key="frame" x="56" y="54" width="244" height="21"/>
<rect key="frame" x="56" y="54" width="264" height="21"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" placeholderString="Regular Expression" drawsBackground="YES" usesSingleLineMode="YES" id="Ia7-Mb-FNn">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@ -507,9 +508,41 @@ Gw
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="749" translatesAutoresizingMaskIntoConstraints="NO" id="fb7-9T-3g2">
<rect key="frame" x="243" y="32" width="79" height="14"/>
<textFieldCell key="cell" controlSize="small" lineBreakMode="clipping" title="Invalid pattern" id="aoG-Ov-SSQ">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<binding destination="bCX-ZR-9aZ" name="hidden" keyPath="selection.errorMessage" id="6be-Gb-vNL">
<dictionary key="options">
<string key="NSValueTransformerName">NSIsNil</string>
</dictionary>
</binding>
<binding destination="bCX-ZR-9aZ" name="value" keyPath="selection.errorMessage" id="V99-Rg-wB0"/>
</connections>
</textField>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="ZsF-yo-SL5">
<rect key="frame" x="224" y="32.5" width="17.5" height="15"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="eEL-HN-geY">
<imageReference key="image" image="exclamationmark.triangle.fill" catalog="system" symbolScale="default" renderingMode="original"/>
</imageCell>
<connections>
<binding destination="bCX-ZR-9aZ" name="hidden" keyPath="selection.errorMessage" id="hI6-ZE-9rV">
<dictionary key="options">
<string key="NSValueTransformerName">NSIsNil</string>
</dictionary>
</binding>
</connections>
</imageView>
</subviews>
<constraints>
<constraint firstItem="Mfy-cT-iBU" firstAttribute="leading" secondItem="7vg-Vr-uMI" secondAttribute="leading" id="00V-au-TXG"/>
<constraint firstItem="fb7-9T-3g2" firstAttribute="top" secondItem="kD8-MY-cO8" secondAttribute="bottom" constant="8" symbolic="YES" id="1no-gr-QIT"/>
<constraint firstItem="fb7-9T-3g2" firstAttribute="firstBaseline" secondItem="ZsF-yo-SL5" secondAttribute="firstBaseline" id="6qZ-y6-gcn"/>
<constraint firstItem="fb7-9T-3g2" firstAttribute="leading" secondItem="ZsF-yo-SL5" secondAttribute="trailing" constant="4" id="Blx-89-Lnh"/>
<constraint firstItem="kD8-MY-cO8" firstAttribute="leading" secondItem="AxG-SI-oKl" secondAttribute="trailing" constant="8" symbolic="YES" id="MQt-Oa-hzJ"/>
<constraint firstItem="Mfy-cT-iBU" firstAttribute="top" secondItem="bO8-kP-FOx" secondAttribute="bottom" constant="8" symbolic="YES" id="PMh-zI-xJe"/>
<constraint firstItem="vol-xC-ylG" firstAttribute="leading" secondItem="Mfy-cT-iBU" secondAttribute="trailing" constant="8" symbolic="YES" id="RF3-Ii-AnH"/>
@ -519,12 +552,14 @@ Gw
<constraint firstItem="ooD-sC-3Cd" firstAttribute="centerY" secondItem="vol-xC-ylG" secondAttribute="centerY" id="k6Q-e4-elg"/>
<constraint firstItem="kD8-MY-cO8" firstAttribute="top" secondItem="7vg-Vr-uMI" secondAttribute="top" constant="8" id="ow4-NH-dRO"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="ooD-sC-3Cd" secondAttribute="trailing" constant="20" symbolic="YES" id="ruo-xp-LLx"/>
<constraint firstItem="ZsF-yo-SL5" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="bO8-kP-FOx" secondAttribute="trailing" constant="8" symbolic="YES" id="ryq-Tb-11N"/>
<constraint firstAttribute="trailing" secondItem="fb7-9T-3g2" secondAttribute="trailing" id="s9e-gK-eTb"/>
<constraint firstItem="vol-xC-ylG" firstAttribute="baseline" secondItem="Mfy-cT-iBU" secondAttribute="baseline" id="tvf-9T-7T4"/>
<constraint firstItem="AxG-SI-oKl" firstAttribute="leading" secondItem="7vg-Vr-uMI" secondAttribute="leading" priority="750" id="uJk-Z5-sGf"/>
<constraint firstItem="kD8-MY-cO8" firstAttribute="baseline" secondItem="AxG-SI-oKl" secondAttribute="baseline" id="ukN-JC-C9v"/>
<constraint firstItem="ooD-sC-3Cd" firstAttribute="leading" secondItem="vol-xC-ylG" secondAttribute="trailing" constant="4" id="wQ4-2t-uM6"/>
<constraint firstItem="bO8-kP-FOx" firstAttribute="leading" secondItem="AxG-SI-oKl" secondAttribute="trailing" constant="8" symbolic="YES" id="x92-E8-Rrn"/>
<constraint firstAttribute="trailing" secondItem="kD8-MY-cO8" secondAttribute="trailing" constant="20" symbolic="YES" id="xjp-hu-xUZ"/>
<constraint firstAttribute="trailing" secondItem="kD8-MY-cO8" secondAttribute="trailing" id="xjp-hu-xUZ"/>
</constraints>
</view>
</viewController>
@ -536,7 +571,10 @@ Gw
</connections>
</objectController>
</objects>
<point key="canvasLocation" x="840" y="-340"/>
<point key="canvasLocation" x="840" y="-340.5"/>
</scene>
</scenes>
<resources>
<image name="exclamationmark.triangle.fill" catalog="system" width="17" height="15"/>
</resources>
</document>

View File

@ -161,6 +161,7 @@ final class RegularExpressionSortPattern: NSObject, SortPattern {
@objc dynamic var usesCaptureGroup: Bool = false
@objc dynamic var group: Int = 1
@objc private(set) dynamic var errorMessage: String?
@objc private(set) dynamic var numberOfCaptureGroups: Int = 0
@ -205,12 +206,18 @@ final class RegularExpressionSortPattern: NSObject, SortPattern {
} catch {
self.regex = nil
self.numberOfCaptureGroups = 0
if self.searchPattern.isEmpty {
self.errorMessage = "Empty pattern".localized
} else {
self.errorMessage = "Invalid pattern".localized
}
throw error
}
self.regex = regex
self.numberOfCaptureGroups = regex.numberOfCaptureGroups
self.errorMessage = nil
}
}

View File

@ -719,6 +719,13 @@
/* MARK: Pattern Sort View */
// error messages
"Invalid pattern" = "Ungültiges Muster";
"Empty pattern" = "Leeres Muster";
/* MARK: Syntax Mapping Conflicts View */
"Syntax Style Mapping Conflicts" = "Dateizuordnungskonflikte";
"The following file mapping rules are registered in multiple styles. CotEditor uses the first style automatically. To resolve conflicts, edit each syntax style." = "Die folgenden Dateizuordnungsregeln sind in mehreren Stilen registriert.CotEditor verwendet den ersten Stil automatisch. Um Konflikte zu beheben, bearbeite jeden Syntaxstil.";

View File

@ -719,6 +719,13 @@
/* MARK: Pattern Sort View */
// error messages
"Invalid pattern" = "Invalid pattern";
"Empty pattern" = "Empty pattern";
/* MARK: Syntax Mapping Conflicts View */
"Syntax Style Mapping Conflicts" = "Syntax Style Mapping Conflicts";
"The following file mapping rules are registered in multiple styles. CotEditor uses the first style automatically. To resolve conflicts, edit each syntax style." = "The following file mapping rules are registered in multiple styles. CotEditor uses the first style automatically. To resolve conflicts, edit each syntax style.";

View File

@ -719,6 +719,13 @@
/* MARK: Pattern Sort View */
// error messages
"Invalid pattern" = "Invalid pattern"; // FIXME: new
"Empty pattern" = "Empty pattern"; // FIXME: new
/* MARK: Syntax Mapping Conflicts View */
"Syntax Style Mapping Conflicts" = "Conflits dassociations entre syntaxes";
"The following file mapping rules are registered in multiple styles. CotEditor uses the first style automatically. To resolve conflicts, edit each syntax style." = "Les associations de fichiers suivantes sont définies dans plusieurs syntaxes. Dans ce cas, CotEditor utilisera la première syntaxe. Pour résoudre les conflits, éditez chaque syntaxe.";

View File

@ -719,6 +719,13 @@
/* MARK: Pattern Sort View */
// error messages
"Invalid pattern" = "Invalid pattern"; // FIXME: new
"Empty pattern" = "Empty pattern"; // FIXME: new
/* MARK: Syntax Mapping Conflicts View */
"Syntax Style Mapping Conflicts" = "Mappatura dei conflitti di stile sintassi";
"The following file mapping rules are registered in multiple styles. CotEditor uses the first style automatically. To resolve conflicts, edit each syntax style." = "Le seguenti regole di mappatura del file sono registrate per più stili. CotEditor usa automaticamente il primo stile. Per risolvere eventuali conflitti, modificare ciascuno stile di sintassi";

View File

@ -719,6 +719,13 @@
/* MARK: Pattern Sort View */
// error messages
"Invalid pattern" = "無効なパターン";
"Empty pattern" = "空のパターン";
/* MARK: Syntax Mapping Conflicts View */
"Syntax Style Mapping Conflicts" = "ファイル関連付けのコンフリクト";
"The following file mapping rules are registered in multiple styles. CotEditor uses the first style automatically. To resolve conflicts, edit each syntax style." = "以下のファイル関連付けルールはいくつかのスタイルで重複して登録されています。CotEditorは自動的に最初のスタイルを使用します。解決するには、それぞれのシンタックススタイルを編集してください。";

View File

@ -719,6 +719,13 @@
/* MARK: Pattern Sort View */
// error messages
"Invalid pattern" = "Invalid pattern"; // FIXME: new
"Empty pattern" = "Empty pattern"; // FIXME: new
/* MARK: Syntax Mapping Conflicts View */
"Syntax Style Mapping Conflicts" = "Conflitos de Mapeamento de Estilos de Sintaxe";
"The following file mapping rules are registered in multiple styles. CotEditor uses the first style automatically. To resolve conflicts, edit each syntax style." = "As seguintes regras de mapeamento de arquivo estão registradas em vários estilos. O CotEditor usa o primeiro estilo automaticamente. Para resolver conflitos, edite cada estilo de sintaxe.";

View File

@ -719,6 +719,13 @@
/* MARK: Pattern Sort View */
// error messages
"Invalid pattern" = "Invalid pattern"; // FIXME: new
"Empty pattern" = "Empty pattern"; // FIXME: new
/* MARK: Syntax Mapping Conflicts View */
"Syntax Style Mapping Conflicts" = "Sözdizim Biçemli Eşlemleme Çakışmaları";
"The following file mapping rules are registered in multiple styles. CotEditor uses the first style automatically. To resolve conflicts, edit each syntax style." = "Aşağıdaki dosya eşlemleme kuralları birden çok biçemde kayıtlıdır. CotEditor, kendiliğinden ilk biçemi kullanır. Çakışmaları çözmek için her bir sözdizim biçemini düzenleyin.";

View File

@ -719,6 +719,13 @@
/* MARK: Pattern Sort View */
// error messages
"Invalid pattern" = "Invalid pattern"; // FIXME: new
"Empty pattern" = "Empty pattern"; // FIXME: new
/* MARK: Syntax Mapping Conflicts View */
"Syntax Style Mapping Conflicts" = "语法样式映射冲突";
"The following file mapping rules are registered in multiple styles. CotEditor uses the first style automatically. To resolve conflicts, edit each syntax style." = "下列文件映射规则被注册了多种格式。CotEditor自动使用第一个格式。可以通过编辑每个语法格式来解决冲突。";

View File

@ -719,6 +719,13 @@
/* MARK: Pattern Sort View */
// error messages
"Invalid pattern" = "Invalid pattern"; // FIXME: new
"Empty pattern" = "Empty pattern"; // FIXME: new
/* MARK: Syntax Mapping Conflicts View */
"Syntax Style Mapping Conflicts" = "文法樣式對映衝突";
"The following file mapping rules are registered in multiple styles. CotEditor uses the first style automatically. To resolve conflicts, edit each syntax style." = "下列檔案對映規則被註冊了多種格式。CotEditor自動使用第一個格式。可以透過編輯每個文法格式來解決衝突。";