Skip to content

Commit 7b1a851

Browse files
author
oil3
committed
mvp
1 parent 1cf519e commit 7b1a851

File tree

14 files changed

+88
-107
lines changed

14 files changed

+88
-107
lines changed

CodeColors.xcodeproj/project.pbxproj

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -413,13 +413,15 @@
413413
ENABLE_HARDENED_RUNTIME = YES;
414414
ENABLE_PREVIEWS = YES;
415415
GENERATE_INFOPLIST_FILE = YES;
416-
INFOPLIST_KEY_CFBundleDisplayName = "Code Colors";
417-
INFOPLIST_KEY_NSHumanReadableCopyright = "";
416+
INFOPLIST_KEY_CFBundleDisplayName = "Code Colors ";
417+
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools";
418+
INFOPLIST_KEY_NSHumanReadableCopyright = "Quet Almahdi Morris";
418419
LD_RUNPATH_SEARCH_PATHS = (
419420
"$(inherited)",
420421
"@executable_path/../Frameworks",
421422
);
422-
MARKETING_VERSION = 1.0;
423+
MACOSX_DEPLOYMENT_TARGET = 12.2;
424+
MARKETING_VERSION = oct2024;
423425
PRODUCT_BUNDLE_IDENTIFIER = com.oil3.CodeColors;
424426
PRODUCT_NAME = "$(TARGET_NAME)";
425427
SWIFT_EMIT_LOC_STRINGS = YES;
@@ -442,13 +444,15 @@
442444
ENABLE_HARDENED_RUNTIME = YES;
443445
ENABLE_PREVIEWS = YES;
444446
GENERATE_INFOPLIST_FILE = YES;
445-
INFOPLIST_KEY_CFBundleDisplayName = "Code Colors";
446-
INFOPLIST_KEY_NSHumanReadableCopyright = "";
447+
INFOPLIST_KEY_CFBundleDisplayName = "Code Colors ";
448+
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools";
449+
INFOPLIST_KEY_NSHumanReadableCopyright = "Quet Almahdi Morris";
447450
LD_RUNPATH_SEARCH_PATHS = (
448451
"$(inherited)",
449452
"@executable_path/../Frameworks",
450453
);
451-
MARKETING_VERSION = 1.0;
454+
MACOSX_DEPLOYMENT_TARGET = 12.2;
455+
MARKETING_VERSION = oct2024;
452456
PRODUCT_BUNDLE_IDENTIFIER = com.oil3.CodeColors;
453457
PRODUCT_NAME = "$(TARGET_NAME)";
454458
SWIFT_EMIT_LOC_STRINGS = YES;
@@ -468,12 +472,13 @@
468472
INFOPLIST_FILE = QuickCodeColorLook/Info.plist;
469473
INFOPLIST_KEY_CFBundleDisplayName = QuickCodeColorLook;
470474
INFOPLIST_KEY_LSApplicationCategoryType = "";
471-
INFOPLIST_KEY_NSHumanReadableCopyright = "";
475+
INFOPLIST_KEY_NSHumanReadableCopyright = "Quet Almahdi Morris";
472476
LD_RUNPATH_SEARCH_PATHS = (
473477
"$(inherited)",
474478
"@executable_path/../Frameworks",
475479
"@executable_path/../../../../Frameworks",
476480
);
481+
MACOSX_DEPLOYMENT_TARGET = 12.2;
477482
MARKETING_VERSION = 1.0;
478483
PRODUCT_BUNDLE_IDENTIFIER = com.oil3.CodeColors.QuickCodeColorLook;
479484
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -495,12 +500,13 @@
495500
INFOPLIST_FILE = QuickCodeColorLook/Info.plist;
496501
INFOPLIST_KEY_CFBundleDisplayName = QuickCodeColorLook;
497502
INFOPLIST_KEY_LSApplicationCategoryType = "";
498-
INFOPLIST_KEY_NSHumanReadableCopyright = "";
503+
INFOPLIST_KEY_NSHumanReadableCopyright = "Quet Almahdi Morris";
499504
LD_RUNPATH_SEARCH_PATHS = (
500505
"$(inherited)",
501506
"@executable_path/../Frameworks",
502507
"@executable_path/../../../../Frameworks",
503508
);
509+
MACOSX_DEPLOYMENT_TARGET = 12.2;
504510
MARKETING_VERSION = 1.0;
505511
PRODUCT_BUNDLE_IDENTIFIER = com.oil3.CodeColors.QuickCodeColorLook;
506512
PRODUCT_NAME = "$(TARGET_NAME)";

CodeColors.xcodeproj/xcuserdata/ssz.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -3,66 +3,4 @@
33
uuid = "60919A6F-13ED-4CF9-8607-2F6AA9EC1D1D"
44
type = "1"
55
version = "2.0">
6-
<Breakpoints>
7-
<BreakpointProxy
8-
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
9-
<BreakpointContent
10-
uuid = "3C42B69D-4F10-4EFA-962E-AE6A10F5F046"
11-
shouldBeEnabled = "Yes"
12-
ignoreCount = "0"
13-
continueAfterRunningActions = "No"
14-
filePath = "QuickCodeColorLook/PreviewProvider.swift"
15-
startingColumnNumber = "9223372036854775807"
16-
endingColumnNumber = "9223372036854775807"
17-
startingLineNumber = "6"
18-
endingLineNumber = "6"
19-
landmarkName = "PreviewProvider"
20-
landmarkType = "3">
21-
<Locations>
22-
<Location
23-
uuid = "3C42B69D-4F10-4EFA-962E-AE6A10F5F046 - 3c2fcbce1918509b"
24-
shouldBeEnabled = "Yes"
25-
ignoreCount = "0"
26-
continueAfterRunningActions = "No"
27-
symbolName = "QuickCodeColorLook.PreviewProvider.__allocating_init() -&gt; QuickCodeColorLook.PreviewProvider"
28-
moduleName = "QuickCodeColorLook"
29-
usesParentBreakpointCondition = "Yes"
30-
urlString = "file:///Users/ssz/Documents/CodeColors/QuickCodeColorLook/PreviewProvider.swift"
31-
startingColumnNumber = "9223372036854775807"
32-
endingColumnNumber = "9223372036854775807"
33-
startingLineNumber = "0"
34-
endingLineNumber = "0">
35-
</Location>
36-
<Location
37-
uuid = "3C42B69D-4F10-4EFA-962E-AE6A10F5F046 - 61e72b3e7660e087"
38-
shouldBeEnabled = "Yes"
39-
ignoreCount = "0"
40-
continueAfterRunningActions = "No"
41-
symbolName = "QuickCodeColorLook.PreviewProvider.init() -&gt; QuickCodeColorLook.PreviewProvider"
42-
moduleName = "QuickCodeColorLook"
43-
usesParentBreakpointCondition = "Yes"
44-
urlString = "file:///Users/ssz/Documents/CodeColors/%3Ccompiler-generated%3E"
45-
startingColumnNumber = "9223372036854775807"
46-
endingColumnNumber = "9223372036854775807"
47-
startingLineNumber = "0"
48-
endingLineNumber = "0">
49-
</Location>
50-
<Location
51-
uuid = "3C42B69D-4F10-4EFA-962E-AE6A10F5F046 - 41f0be72b60e8e96"
52-
shouldBeEnabled = "Yes"
53-
ignoreCount = "0"
54-
continueAfterRunningActions = "No"
55-
symbolName = "QuickCodeColorLook.PreviewProvider.__deallocating_deinit"
56-
moduleName = "QuickCodeColorLook"
57-
usesParentBreakpointCondition = "Yes"
58-
urlString = "file:///Users/ssz/Documents/CodeColors/QuickCodeColorLook/PreviewProvider.swift"
59-
startingColumnNumber = "9223372036854775807"
60-
endingColumnNumber = "9223372036854775807"
61-
startingLineNumber = "0"
62-
endingLineNumber = "0">
63-
</Location>
64-
</Locations>
65-
</BreakpointContent>
66-
</BreakpointProxy>
67-
</Breakpoints>
686
</Bucket>

CodeColors/CodeColors.entitlements

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<true/>
77
<key>com.apple.security.application-groups</key>
88
<array>
9-
<string>$(TeamIdentifierPrefix)</string>
9+
<string>com.oil3.codecolors</string>
1010
</array>
1111
<key>com.apple.security.files.user-selected.read-write</key>
1212
<true/>

CodeColors/CodeColorsApp.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@ struct CodeColorsApp: App {
1515
}
1616
}
1717
}
18+
19+
20+
//
21+
// Copyright Almahdi Morris Quet 2024
22+
//

CodeColors/SettingsView.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ struct SettingsView: View {
3030
.frame(width: 400)
3131
}
3232
}
33+
34+

CodeColors/SyntaxSettings.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Combine
33

44
class SyntaxSettings: ObservableObject {
55
static let shared = SyntaxSettings()
6-
private let userDefaults = UserDefaults(suiteName: "com.oil3.codecolors")
6+
let userDefaults = UserDefaults(suiteName: "com.oil3.codecolors")
77

88
@Published var syntaxColors: [String: Color] = [:]
99

@@ -89,3 +89,8 @@ extension Color {
8989
#endif
9090
}
9191
}
92+
93+
94+
//
95+
// Copyright Almahdi Morris Quet 2024
96+
//

QuickCodeColorLook/CodeContentLoader.swift

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1+
// CodeContentLoader.swift
2+
13
import SwiftUI
24
import Combine
35

46
class CodeContentLoader: ObservableObject {
5-
@Published var attributedLines: [AttributedString] = []
7+
@Published var attributedContent: AttributedString = AttributedString()
68
@Published var isLoading = false
79
@Published var totalLines = 0
810
@Published var fileSize: Int64 = 0
911

1012
private var shouldCancel = false
1113

12-
func loadFile(at url: URL, maxFileSize: Int64 = 5 * 1024 * 1024) {
14+
func loadFile(at url: URL, maxFileSize: Int64 = 50 * 1024 * 1024) {
1315
self.isLoading = true
1416
self.shouldCancel = false
15-
self.attributedLines = []
17+
self.attributedContent = AttributedString()
1618

1719
// Check file size
1820
if let fileSize = try? url.resourceValues(forKeys: [.fileSizeKey]).fileSize {
@@ -39,16 +41,30 @@ class CodeContentLoader: ObservableObject {
3941
reader.close()
4042
}
4143

44+
var lineNumber = 1
45+
4246
while let line = reader.nextLine() {
4347
if self.shouldCancel {
4448
break
4549
}
4650

47-
let attributedLine = SyntaxHighlighter.highlightLine(line: line, fileExtension: fileExtension)
51+
// Highlight the line
52+
var attributedLine = SyntaxHighlighter.highlightLine(line: line, fileExtension: fileExtension)
53+
54+
// Prepend line number
55+
// var lineNumberString = AttributedString("\(lineNumber) ")
56+
// lineNumberString.foregroundColor = .gray
57+
58+
lineNumber += 1
59+
60+
// Combine line number and content
61+
// lineNumberString.append(attributedLine)
62+
// Append newline character
63+
attributedLine.append(AttributedString("\n"))
4864

4965
DispatchQueue.main.async {
50-
self.attributedLines.append(attributedLine)
51-
self.totalLines = self.attributedLines.count
66+
self.attributedContent.append(attributedLine)
67+
self.totalLines = lineNumber - 1
5268
}
5369
}
5470

@@ -62,3 +78,6 @@ class CodeContentLoader: ObservableObject {
6278
shouldCancel = true
6379
}
6480
}
81+
//
82+
// Copyright Almahdi Morris Quet 2024
83+
//

QuickCodeColorLook/Info.plist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<array>
1313
<string>public.python-script</string>
1414
<string>public.yaml</string>
15+
<string>public.data</string>
1516
<string>public.xml</string>
1617
<string>public.json</string>
1718
<string>public.swift-source</string>

QuickCodeColorLook/LineReader.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,6 @@ class LineReader {
6060
close()
6161
}
6262
}
63+
//
64+
// Copyright Almahdi Morris Quet 2024
65+
//

QuickCodeColorLook/PreviewProvider.swift

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,24 @@ class PreviewProvider: QLPreviewProvider {
77
func providePreview(for request: QLFilePreviewRequest, handler: @escaping (QLPreviewReply?, Error?) -> Void) {
88
}
99
}
10-
struct ContentView: View {
11-
@ObservedObject var loader: CodeContentLoader
12-
@State private var fontSize: CGFloat = 12.0
10+
// ContentView.swift
1311

14-
var body: some View {
15-
ScrollView {
16-
LazyVStack(alignment: .leading, spacing: 0) {
17-
ForEach(loader.attributedLines.indices, id: \.self) { index in
18-
HStack(alignment: .top, spacing: 5)
19-
{
20-
Text("\(index + 1)")
21-
.font(.system(size: fontSize, weight: .regular, design: .monospaced))
22-
.foregroundColor(.gray)
23-
.frame(width: 40, alignment: .trailing)
24-
.padding(.trailing, 5)
25-
//need to fix so we can select multiple lines, and having line numbers without including them in the selection, while keeping lazy loading
26-
Text(loader.attributedLines[index])
27-
.font(.system(size: fontSize, weight: .regular, design: .monospaced))
28-
}
29-
.textSelection(.enabled)
12+
import SwiftUI
3013

31-
}
32-
}
33-
.padding()
14+
struct ContentView: View {
15+
@ObservedObject var loader: CodeContentLoader
16+
@State private var fontSize: CGFloat = 12.0
17+
18+
var body: some View {
19+
ScrollView([.vertical, .horizontal]) {
20+
Text(loader.attributedContent)
21+
.font(.system(size: fontSize, weight: .regular, design: .monospaced))
22+
.textSelection(.enabled)
23+
.padding()
3424
}
3525
.gesture(MagnificationGesture()
3626
.onChanged { value in
3727
self.fontSize = max(8.0, min(24.0, 12.0 * value))
3828
})
3929
}
40-
4130
}

0 commit comments

Comments
 (0)