mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-11 11:25:57 +03:00
Refactor character view in document inspector
This commit is contained in:
parent
037069135e
commit
f43d1c45c9
@ -18,6 +18,7 @@
|
||||
### Fixes
|
||||
|
||||
- Fix an issue on macOS 13 that the stepper in the custom tab width view worked only once.
|
||||
- Fix an issue that the character code point display in the document inspector could be broken when the application is localized.
|
||||
- Fix an issue that a part of the Portuguese localization was not applied.
|
||||
- Fix Italian localization (Thanks to Roccobot and DAnn2012!).
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="22154" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="NoI-km-aN6">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="NoI-km-aN6">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22154"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
|
||||
<capability name="NSView safe area layout guides" minToolsVersion="12.0"/>
|
||||
<capability name="System colors introduced in macOS 10.14" minToolsVersion="10.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
@ -389,7 +389,7 @@
|
||||
</textFieldCell>
|
||||
<connections>
|
||||
<accessibilityConnection property="title" destination="UJf-4P-eSh" id="usV-O8-Rmy"/>
|
||||
<binding destination="KUC-8F-iAD" name="value" keyPath="selection.unicode" id="sru-km-SZJ">
|
||||
<binding destination="KUC-8F-iAD" name="value" keyPath="selection.codePoints" id="CDW-n5-3Zf">
|
||||
<dictionary key="options">
|
||||
<string key="NSNullPlaceholder">Not selected</string>
|
||||
</dictionary>
|
||||
|
@ -47,7 +47,7 @@ final class EditorInfo: NSObject {
|
||||
@objc dynamic var line: String? // current line
|
||||
@objc dynamic var column: String? // cursor location from the beginning of line
|
||||
|
||||
@objc dynamic var unicode: String? // Unicode of selected single character (or surrogate-pair)
|
||||
@objc dynamic var codePoints: [String]? // code points of selected single character
|
||||
}
|
||||
|
||||
|
||||
@ -172,7 +172,7 @@ final class DocumentInspectorViewController: NSViewController, DocumentOwner {
|
||||
info.location = result.location?.formatted()
|
||||
info.line = result.line?.formatted()
|
||||
info.column = result.column?.formatted()
|
||||
info.unicode = result.unicode
|
||||
info.codePoints = result.character?.unicodeScalars.map(\.codePoint)
|
||||
},
|
||||
]
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// © 2014-2023 1024jp
|
||||
// © 2014-2024 1024jp
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@ -33,9 +33,9 @@ struct EditorInfoTypes: OptionSet {
|
||||
static let location = Self(rawValue: 1 << 3)
|
||||
static let line = Self(rawValue: 1 << 4)
|
||||
static let column = Self(rawValue: 1 << 5)
|
||||
static let unicode = Self(rawValue: 1 << 6)
|
||||
static let character = Self(rawValue: 1 << 6)
|
||||
|
||||
static let all: Self = [.characters, .lines, .words, .location, .line, .column, .unicode]
|
||||
static let all: Self = [.characters, .lines, .words, .location, .line, .column, .character]
|
||||
|
||||
static let cursors: Self = [.location, .line, .column]
|
||||
}
|
||||
@ -57,7 +57,7 @@ struct EditorCountResult: Equatable {
|
||||
var line: Int? // current line
|
||||
var column: Int? // cursor location from the beginning of line
|
||||
|
||||
var unicode: String? // Unicode of selected single character (or surrogate-pair)
|
||||
var character: Character? // Selected character (only when selection is single character)
|
||||
}
|
||||
|
||||
|
||||
@ -159,9 +159,9 @@ final actor EditorCounter {
|
||||
result.column = self.string.columnNumber(at: self.selectedRanges[0].lowerBound)
|
||||
}
|
||||
|
||||
if self.requiredInfo.contains(.unicode) {
|
||||
result.unicode = (selectedStrings[0].compareCount(with: 1) == .equal)
|
||||
? selectedStrings[0].first?.unicodeScalars.map(\.codePoint).formatted(.list(type: .and, width: .narrow))
|
||||
if self.requiredInfo.contains(.character) {
|
||||
result.character = (selectedStrings[0].compareCount(with: 1) == .equal)
|
||||
? selectedStrings[0].first
|
||||
: nil
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// © 2022-2023 1024jp
|
||||
// © 2022-2024 1024jp
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@ -32,16 +32,15 @@ final class TokenFormatter: Formatter {
|
||||
/// Converts to plain string.
|
||||
override func string(for obj: Any?) -> String? {
|
||||
|
||||
obj as? String
|
||||
(obj as? [String])?.formatted(.list(type: .and, width: .narrow))
|
||||
}
|
||||
|
||||
|
||||
/// Creates attributed string from object.
|
||||
override func attributedString(for obj: Any, withDefaultAttributes attrs: [NSAttributedString.Key: Any]? = nil) -> NSAttributedString? {
|
||||
|
||||
self.string(for: obj)?
|
||||
.split(separator: ", ")
|
||||
.map { NSAttributedString(attachment: .init(token: String($0), attributes: attrs)) }
|
||||
(obj as? [String])?
|
||||
.map { NSAttributedString(attachment: .init(token: $0, attributes: attrs)) }
|
||||
.joined(separator: .init(string: " ", attributes: attrs))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user