Display message for incompatible scan (fix #1218)

This commit is contained in:
1024jp 2021-11-27 14:43:58 +09:00
parent e63f489edf
commit c51303ca65
16 changed files with 71 additions and 28 deletions

View File

@ -9,6 +9,7 @@ Change Log
- Fix an issue that File Drop settings were not saved if both the extensions and syntax styles are for “all.”
- Fix an issue that shortcuts for snippet did not accept Shift with a non-letter character, such as Shift + Return.
- Fix an issue that the rainbow cursor appeared when the document has a large number of incompatible characters.
- Fix an issue that the rainbow cursor appeared when expanding the selection by “⌥⇧←” shortut and invisible characters are contained in the new selection.
- Fix an issue that the writing direction could be changed to right to left although when the text orientation is vertical.

View File

@ -181,6 +181,7 @@
</textFieldCell>
<connections>
<binding destination="nX3-cC-y6b" name="hidden" keyPath="incompatibleCharacters.@count" id="wC7-7S-FId"/>
<binding destination="nX3-cC-y6b" name="value" keyPath="message" id="xSa-zI-RXk"/>
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="wLI-76-6zT">

View File

@ -33,6 +33,7 @@ final class IncompatibleCharacterScanner {
var shouldScan = false
@Published private(set) var incompatibleCharacters: [IncompatibleCharacter] = [] // line endings applied
@Published private(set) var isScanning = false
// MARK: Private Properties
@ -87,9 +88,11 @@ final class IncompatibleCharacterScanner {
DispatchQueue.main.async {
self?.incompatibleCharacters = incompatibleCharacters
self?.isScanning = false
}
}
self.isScanning = true
self.queue.addOperation(operation)
}

View File

@ -34,9 +34,10 @@ final class IncompatibleCharactersViewController: NSViewController {
private var document: Document? { self.representedObject as? Document }
private var scanner: IncompatibleCharacterScanner? { self.document?.incompatibleCharacterScanner }
@objc private dynamic var message: String?
@objc private dynamic var incompatibleCharacters: [IncompatibleCharacter] = []
private var scannerObserver: AnyCancellable?
private var scannerObservers: [AnyCancellable] = []
@IBOutlet private var incompatibleCharsController: NSArrayController?
@ -83,6 +84,8 @@ final class IncompatibleCharactersViewController: NSViewController {
override var representedObject: Any? {
willSet {
self.scannerObservers.removeAll()
guard newValue is Document else {
assertionFailure("representedObject of \(self.className) must be an instance of \(Document.self)")
return
@ -90,13 +93,25 @@ final class IncompatibleCharactersViewController: NSViewController {
}
didSet {
self.scanner?.shouldScan = self.isViewShown
self.scanner?.invalidate()
guard let scanner = self.scanner else { return }
self.scannerObserver = self.scanner?.$incompatibleCharacters
scanner.shouldScan = self.isViewShown
scanner.invalidate()
scanner.$incompatibleCharacters
.removeDuplicates()
.receive(on: DispatchQueue.main)
.sink { [weak self] in self?.didUpdateIncompatibleCharacters($0) }
.store(in: &self.scannerObservers)
scanner.$isScanning
.map { $0
? "Scanning incompatible characters…"
: scanner.incompatibleCharacters.isEmpty
? "No incompatible characters were found."
: nil }
.receive(on: DispatchQueue.main)
.sink { [weak self] in self?.message = $0 }
.store(in: &self.scannerObservers)
}
}

View File

@ -9,7 +9,7 @@
------------------------------------------------------------------------------
© 2015-2018 1024jp
© 2015-2021 1024jp
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -34,6 +34,3 @@
"Nhb-U5-BOF.headerCell.title" = "Zeichen";
/* Class = "NSTableColumn"; headerCell.title = "Line"; ObjectID = "weY-lf-jGz"; */
"weY-lf-jGz.headerCell.title" = "Zeile";
/* Class = "NSTextFieldCell"; title = "No incompatible characters were found."; ObjectID = "wsL-BG-Ii8"; */
"wsL-BG-Ii8.title" = "Keine inkompatiblen Zeichen gefunden.";

View File

@ -328,6 +328,13 @@
/* MARK: Inspector */
// Incompatible characters
"No incompatible characters were found." = "Keine inkompatiblen Zeichen gefunden.";
"Scanning incompatible characters…" = "Inkompatiblen Zeichen scannen …";
/* MARK: EditorTextView */
// Undo action names
"Replace Text" = "Text ersetzen";

View File

@ -9,7 +9,7 @@
Localized by Aurélien Roy
------------------------------------------------------------------------------
© 2015-2019 CotEditor Project
© 2015-2021 CotEditor Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -34,6 +34,3 @@
"Nhb-U5-BOF.headerCell.title" = "Caractère";
/* Class = "NSTableColumn"; headerCell.title = "Line"; ObjectID = "weY-lf-jGz"; */
"weY-lf-jGz.headerCell.title" = "Ligne";
/* Class = "NSTextFieldCell"; title = "No incompatible characters were found."; ObjectID = "wsL-BG-Ii8"; */
"wsL-BG-Ii8.title" = "Aucun caractère incompatible trouvé.";

View File

@ -327,6 +327,13 @@
/* MARK: Inspector */
// Incompatible characters
"No incompatible characters were found." = "Aucun caractère incompatible trouvé.";
"Scanning incompatible characters…" = "Scanning incompatible characters…"; // FIXME: added
/* MARK: EditorTextView */
// Undo action names
"Replace Text" = "Remplacer du Texte";

View File

@ -10,7 +10,7 @@
------------------------------------------------------------------------------
© 2016-2018 CotEditor Project
© 2016-2021 CotEditor Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -35,6 +35,3 @@
"Nhb-U5-BOF.headerCell.title" = "Carattere";
/* Class = "NSTableColumn"; headerCell.title = "Line"; ObjectID = "weY-lf-jGz"; */
"weY-lf-jGz.headerCell.title" = "Riga";
/* Class = "NSTextFieldCell"; title = "No incompatible characters were found."; ObjectID = "wsL-BG-Ii8"; */
"wsL-BG-Ii8.title" = "Nessun carattere incompatibile trovato.";

View File

@ -329,6 +329,13 @@
/* MARK: Inspector */
// Incompatible characters
"No incompatible characters were found." = "Nessun carattere incompatibile trovato.";
"Scanning incompatible characters…" = "Scanning incompatible characters…"; // FIXME: added
/* MARK: EditorTextView */
// Undo action names
"Replace Text" = "Sostituisci testo";

View File

@ -9,7 +9,7 @@
------------------------------------------------------------------------------
© 2014-2018 CotEditor Project
© 2014-2021 CotEditor Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -34,6 +34,3 @@
"Nhb-U5-BOF.headerCell.title" = "文字";
/* Class = "NSTableColumn"; headerCell.title = "Line"; ObjectID = "weY-lf-jGz"; */
"weY-lf-jGz.headerCell.title" = "行";
/* Class = "NSTextFieldCell"; title = "No incompatible characters were found."; ObjectID = "wsL-BG-Ii8"; */
"wsL-BG-Ii8.title" = "非互換文字は見つかりませんでした。";

View File

@ -329,6 +329,12 @@
/* MARK: Inspector */
// Incompatible characters
"No incompatible characters were found." = "非互換文字は見つかりませんでした。";
"Scanning incompatible characters…" = "非互換文字を走査中...";
/* MARK: EditorTextView */
// Undo action names
"Replace Text" = "テキストを置換";

View File

@ -9,7 +9,7 @@
//
// ------------------------------------------------------------------------------
//
// © 2018 CotEditor Project
// © 2018-2021 CotEditor Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -33,6 +33,3 @@
"Nhb-U5-BOF.headerCell.title" = "Caractere";
/* Class = "NSTableColumn"; headerCell.title = "Line"; ObjectID = "weY-lf-jGz"; */
"weY-lf-jGz.headerCell.title" = "Linha";
/* Class = "NSTextFieldCell"; title = "No incompatible characters were found."; ObjectID = "wsL-BG-Ii8"; */
"wsL-BG-Ii8.title" = "Nenhum caractere incompatível encontrado.";

View File

@ -329,6 +329,13 @@
/* MARK: Inspector */
// Incompatible characters
"No incompatible characters were found." = "Nenhum caractere incompatível encontrado.";
"Scanning incompatible characters…" = "Scanning incompatible characters…"; // FIXME: added
/* MARK: EditorTextView */
// Undo action names
"Replace Text" = "Substituir Texto";

View File

@ -10,7 +10,7 @@
------------------------------------------------------------------------------
© 2014-2018 CotEditor Project
© 2014-2021 CotEditor Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -35,6 +35,3 @@
"Nhb-U5-BOF.headerCell.title" = "字符";
/* Class = "NSTableColumn"; headerCell.title = "Line"; ObjectID = "weY-lf-jGz"; */
"weY-lf-jGz.headerCell.title" = "行";
/* Class = "NSTextFieldCell"; title = "No incompatible characters were found."; ObjectID = "wsL-BG-Ii8"; */
"wsL-BG-Ii8.title" = "没有找到不兼容字符";

View File

@ -328,6 +328,13 @@
/* MARK: Inspector */
// Incompatible characters
"No incompatible characters were found." = "没有找到不兼容字符";
"Scanning incompatible characters…" = "Scanning incompatible characters…"; // FIXME: added
/* MARK: EditorTextView */
// Undo action names
"Replace Text" = "替换文本";