Skip to content

Commit

Permalink
Extract LineEnding to package
Browse files Browse the repository at this point in the history
  • Loading branch information
1024jp committed Jul 3, 2024
1 parent 356186c commit 565d043
Show file tree
Hide file tree
Showing 16 changed files with 103 additions and 62 deletions.
18 changes: 7 additions & 11 deletions CotEditor.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@
2A50AA63204D513500D10A10 /* FileAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A50AA61204D513500D10A10 /* FileAttributes.swift */; };
2A53F56727585A0E00ED16DF /* RegularExpressionReferenceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A53F56627585A0E00ED16DF /* RegularExpressionReferenceView.swift */; };
2A53F56827585A0E00ED16DF /* RegularExpressionReferenceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A53F56627585A0E00ED16DF /* RegularExpressionReferenceView.swift */; };
2A54BE2C1D40EB24000816B0 /* LineEndingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A54BE2B1D40EB24000816B0 /* LineEndingTests.swift */; };
2A55D5D82B7A728A0092DE48 /* AdvancedCharacterCount.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = 2A55D5D72B7A728A0092DE48 /* AdvancedCharacterCount.xcstrings */; };
2A55D5D92B7A728A0092DE48 /* AdvancedCharacterCount.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = 2A55D5D72B7A728A0092DE48 /* AdvancedCharacterCount.xcstrings */; };
2A55D5EA2B7A86190092DE48 /* IssueReport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A55D5E92B7A86190092DE48 /* IssueReport.swift */; };
Expand Down Expand Up @@ -482,8 +481,8 @@
2AA175FB2AC5634500F6462C /* PopoverHolderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AA175F92AC5634500F6462C /* PopoverHolderView.swift */; };
2AA2C6FC24399A920017D1EC /* Yams in Frameworks */ = {isa = PBXBuildFile; productRef = 2AA2C6FB24399A920017D1EC /* Yams */; };
2AA2C6FE24399AA20017D1EC /* Yams in Frameworks */ = {isa = PBXBuildFile; productRef = 2AA2C6FD24399AA20017D1EC /* Yams */; };
2AA375471D40BDCB0080C27C /* LineEnding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AA375461D40BDCB0080C27C /* LineEnding.swift */; };
2AA375481D40BDCB0080C27C /* LineEnding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AA375461D40BDCB0080C27C /* LineEnding.swift */; };
2AA375471D40BDCB0080C27C /* LineEnding+Localization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AA375461D40BDCB0080C27C /* LineEnding+Localization.swift */; };
2AA375481D40BDCB0080C27C /* LineEnding+Localization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AA375461D40BDCB0080C27C /* LineEnding+Localization.swift */; };
2AA45A4B1D2E871900A1A401 /* EditorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AA45A4A1D2E871900A1A401 /* EditorViewController.swift */; };
2AA45A4C1D2E871900A1A401 /* EditorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AA45A4A1D2E871900A1A401 /* EditorViewController.swift */; };
2AA45A511D2E938500A1A401 /* NavigationBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AA45A501D2E938500A1A401 /* NavigationBar.swift */; };
Expand Down Expand Up @@ -938,7 +937,6 @@
2A4E637F20ADC45F0033CE63 /* NSBezierPath.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSBezierPath.swift; sourceTree = "<group>"; };
2A50AA61204D513500D10A10 /* FileAttributes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileAttributes.swift; sourceTree = "<group>"; };
2A53F56627585A0E00ED16DF /* RegularExpressionReferenceView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegularExpressionReferenceView.swift; sourceTree = "<group>"; };
2A54BE2B1D40EB24000816B0 /* LineEndingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LineEndingTests.swift; sourceTree = "<group>"; };
2A55D5D72B7A728A0092DE48 /* AdvancedCharacterCount.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = AdvancedCharacterCount.xcstrings; sourceTree = "<group>"; };
2A55D5E92B7A86190092DE48 /* IssueReport.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IssueReport.swift; sourceTree = "<group>"; };
2A57B98E294ED75900771696 /* RangedIntegerFormatStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RangedIntegerFormatStyle.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1013,8 +1011,8 @@
2A78BFB21D1B240900A583D2 /* UpdaterManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UpdaterManager.swift; sourceTree = "<group>"; };
2A78BFBB1D1B376000A583D2 /* ServicesProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ServicesProvider.swift; sourceTree = "<group>"; };
2A7C92FB29FD64A8008343C8 /* DefaultKey+FontType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DefaultKey+FontType.swift"; sourceTree = "<group>"; };
2A7E06E52C1A711B00E5396D /* EditorKit */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = EditorKit; sourceTree = "<group>"; };
2A7DFA492BE96C06001D5BDD /* DirectoryDocument+Actions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DirectoryDocument+Actions.swift"; sourceTree = "<group>"; };
2A7E06E52C1A711B00E5396D /* EditorKit */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = EditorKit; sourceTree = "<group>"; };
2A7F4E012871F46D0029CE66 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/PrintPanelAccessory.storyboard; sourceTree = "<group>"; };
2A7FEF0A2B90B05C0042BEFF /* FilterField.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = FilterField.xcstrings; sourceTree = "<group>"; };
2A80BE8C27FFA61700D2F7FF /* LineEndingScanner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LineEndingScanner.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1057,7 +1055,7 @@
2AA14CFE1FA498E900EAF586 /* UnixScript.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnixScript.swift; sourceTree = "<group>"; };
2AA14D011FA4999200EAF586 /* PersistentOSAScript.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PersistentOSAScript.swift; sourceTree = "<group>"; };
2AA175F92AC5634500F6462C /* PopoverHolderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PopoverHolderView.swift; sourceTree = "<group>"; };
2AA375461D40BDCB0080C27C /* LineEnding.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LineEnding.swift; sourceTree = "<group>"; };
2AA375461D40BDCB0080C27C /* LineEnding+Localization.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "LineEnding+Localization.swift"; sourceTree = "<group>"; };
2AA45A4A1D2E871900A1A401 /* EditorViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EditorViewController.swift; sourceTree = "<group>"; };
2AA45A501D2E938500A1A401 /* NavigationBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationBar.swift; sourceTree = "<group>"; };
2AA45A531D2F22C600A1A401 /* NSFont+Size.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSFont+Size.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1766,7 +1764,6 @@
2A505C07298952E5002080AA /* KeyBinding */,
2A78F571298C90520084B8B4 /* Snippet */,
2AC6BFCF21D00A8500FF325C /* Regex Parser */,
2AA375461D40BDCB0080C27C /* LineEnding.swift */,
2A8C338E1D3E1C040005B0B7 /* IncompatibleCharacter.swift */,
2A4257BB1D239F850086DAAD /* Invisible.swift */,
2A50AA61204D513500D10A10 /* FileAttributes.swift */,
Expand Down Expand Up @@ -2000,6 +1997,7 @@
children = (
2A428D432C2B03670051AD4F /* ValueRange+Identifiable.swift */,
2AA7BDDA2C1B10C80075BB6C /* UnicodeNormalizationForm.swift */,
2AA375461D40BDCB0080C27C /* LineEnding+Localization.swift */,
2A1893A91FFF422D00AD244F /* SortPatternError+Localization.swift */,
);
name = Libraries;
Expand Down Expand Up @@ -2111,7 +2109,6 @@
2A63CEC31D0B06D800ED8186 /* SyntaxTests.swift */,
2ACC65311C98033D000574DC /* ThemeTests.swift */,
2A9C07551CF9F982006D672D /* IncompatibleCharacterTests.swift */,
2A54BE2B1D40EB24000816B0 /* LineEndingTests.swift */,
2AED46721E43942300751C45 /* TextFinderTests.swift */,
2AC72EA1253478D5001D3CA0 /* FileDropItemTests.swift */,
2ABEFB6923DC0CA0008769F4 /* EditorCounterTests.swift */,
Expand Down Expand Up @@ -2781,7 +2778,7 @@
2A64F2431D256FCB001B229F /* KeyBindingManager.swift in Sources */,
2AA4D3751D1AA0AC001D261D /* KeyBindingsSettingsView.swift in Sources */,
2A6FD9E81D394F5900A59784 /* LayoutManager.swift in Sources */,
2AA375481D40BDCB0080C27C /* LineEnding.swift in Sources */,
2AA375481D40BDCB0080C27C /* LineEnding+Localization.swift in Sources */,
2A80BE8D27FFA61700D2F7FF /* LineEndingScanner.swift in Sources */,
2A6416A41D2F9F7200FA9E1A /* LineNumberView.swift in Sources */,
2A1125C423F1A86B006A1DB2 /* LineRangeCacheable.swift in Sources */,
Expand Down Expand Up @@ -2961,7 +2958,6 @@
2A9082EF1D325ED900228F50 /* GeometryTests.swift in Sources */,
2A9C07561CF9F982006D672D /* IncompatibleCharacterTests.swift in Sources */,
2A80BE9227FFFA8900D2F7FF /* LineEndingScannerTests.swift in Sources */,
2A54BE2C1D40EB24000816B0 /* LineEndingTests.swift in Sources */,
2A1125C123F180FF006A1DB2 /* LineRangeCacheableTests.swift in Sources */,
2AEBD25A246BB4C200EC97A3 /* NSAttributedStringTests.swift in Sources */,
2A89160C2394B87100AC13EE /* NSLayoutManagerTests.swift in Sources */,
Expand Down Expand Up @@ -3102,7 +3098,7 @@
2A64F2421D256FCB001B229F /* KeyBindingManager.swift in Sources */,
2AA4D3741D1AA0AC001D261D /* KeyBindingsSettingsView.swift in Sources */,
2A6FD9E71D394F5900A59784 /* LayoutManager.swift in Sources */,
2AA375471D40BDCB0080C27C /* LineEnding.swift in Sources */,
2AA375471D40BDCB0080C27C /* LineEnding+Localization.swift in Sources */,
2A80BE8E27FFA61700D2F7FF /* LineEndingScanner.swift in Sources */,
2A6416A31D2F9F7200FA9E1A /* LineNumberView.swift in Sources */,
2A1125C323F1A86B006A1DB2 /* LineRangeCacheable.swift in Sources */,
Expand Down
1 change: 1 addition & 0 deletions CotEditor/Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import UniformTypeIdentifiers
import OSLog
import Defaults
import FileEncoding
import LineEnding
import UnicodeNormalization

extension KeyPath: @retroactive @unchecked Sendable { }
Expand Down
1 change: 1 addition & 0 deletions CotEditor/Sources/Document+ScriptingSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import AppKit
import FileEncoding
import FuzzyRange
import LineEnding

private enum OSALineEnding: FourCharCode {

Expand Down
1 change: 1 addition & 0 deletions CotEditor/Sources/Document.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import OSLog
import Defaults
import FileEncoding
import FilePermissions
import LineEnding
import Syntax

extension Document: EditorSource {
Expand Down
1 change: 1 addition & 0 deletions CotEditor/Sources/DocumentInspectorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import Observation
import Combine
import FileEncoding
import FilePermissions
import LineEnding
import Syntax

final class DocumentInspectorViewController: NSHostingController<DocumentInspectorView>, DocumentOwner {
Expand Down
3 changes: 2 additions & 1 deletion CotEditor/Sources/EditorTextView+CursorMovement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//
// ---------------------------------------------------------------------------
//
// © 2019-2023 1024jp
// © 2019-2024 1024jp
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -24,6 +24,7 @@
//

import AppKit
import LineEnding

extension EditorTextView {

Expand Down
1 change: 1 addition & 0 deletions CotEditor/Sources/EditorTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import AppKit
import Combine
import Defaults
import LineEnding
import Shortcut
import Syntax
import StringBasics
Expand Down
1 change: 1 addition & 0 deletions CotEditor/Sources/FormatSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import SwiftUI
import Defaults
import FileEncoding
import LineEnding

struct FormatSettingsView: View {

Expand Down
1 change: 1 addition & 0 deletions CotEditor/Sources/InconsistentLineEndingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import SwiftUI
import Observation
import LineEnding
import ValueRange

struct InconsistentLineEndingsView: View {
Expand Down
61 changes: 61 additions & 0 deletions CotEditor/Sources/LineEnding+Localization.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// LineEnding+Localization.swift
//
// CotEditor
// https://coteditor.com
//
// Created by 1024jp on 2014-11-30.
//
// ---------------------------------------------------------------------------
//
// © 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.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import LineEnding

extension LineEnding {

var description: String {

switch self {
case .lf:
String(localized: "LineEnding.lf.description",
defaultValue: "macOS / Unix",
table: "LineEnding")
case .cr:
String(localized: "LineEnding.cr.description",
defaultValue: "Classic Mac OS",
table: "LineEnding")
case .crlf:
String(localized: "LineEnding.crlf.description",
defaultValue: "Windows", table: "LineEnding")
case .nel:
String(localized: "LineEnding.nel.description",
defaultValue: "Unix Next Line",
table: "LineEnding",
comment: "Since this is a technical term, it should be left as-is.")
case .lineSeparator:
String(localized: "LineEnding.lineSeparator.description",
defaultValue: "Unix Line Separator",
table: "LineEnding",
comment: "Since this is a technical term, it should be left as-is.")
case .paragraphSeparator:
String(localized: "LineEnding.paragraphSeparator.description",
defaultValue: "Unix Paragraph Separator",
table: "LineEnding",
comment: "Since this is a technical term, it should be left as-is.")
}
}
}
3 changes: 2 additions & 1 deletion CotEditor/Sources/LineEndingScanner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
import Combine
import Foundation
import Observation
import class AppKit.NSTextStorage
import AppKit.NSTextStorage
import LineEnding
import ValueRange

@Observable final class LineEndingScanner {
Expand Down
1 change: 1 addition & 0 deletions CotEditor/Sources/StatusBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import Observation
import Combine
import Defaults
import FileEncoding
import LineEnding

final class StatusBarController: NSHostingController<StatusBar> {

Expand Down
1 change: 1 addition & 0 deletions CotEditor/Sources/TextFinder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import AppKit
import SwiftUI
import LineEnding
import TextFind
import ValueRange

Expand Down
5 changes: 5 additions & 0 deletions Packages/EditorKit/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ let package = Package(
"FileEncoding",
"FilePermissions",
"FuzzyRange",
"LineEnding",
"LineSort",
"Shortcut",
"StringBasics",
Expand All @@ -33,6 +34,7 @@ let package = Package(
.library(name: "FileEncoding", targets: ["FileEncoding"]),
.library(name: "FilePermissions", targets: ["FilePermissions"]),
.library(name: "FuzzyRange", targets: ["FuzzyRange"]),
.library(name: "LineEnding", targets: ["LineEnding"]),
.library(name: "LineSort", targets: ["LineSort"]),
.library(name: "StringBasics", targets: ["StringBasics"]),
.library(name: "Syntax", targets: ["Syntax"]),
Expand Down Expand Up @@ -62,6 +64,9 @@ let package = Package(
.target(name: "FuzzyRange"),
.testTarget(name: "FuzzyRangeTests", dependencies: ["FuzzyRange"]),

.target(name: "LineEnding", dependencies: ["ValueRange"]),
.testTarget(name: "LineEndingTests", dependencies: ["LineEnding"]),

.target(name: "LineSort", dependencies: ["StringBasics"]),
.testTarget(name: "LineSortTests", dependencies: ["LineSort"]),

Expand Down
Loading

0 comments on commit 565d043

Please sign in to comment.