Skip to content

Commit 97ded7e

Browse files
committed
Bugfix.
1 parent 237f8aa commit 97ded7e

File tree

8 files changed

+45
-15
lines changed

8 files changed

+45
-15
lines changed

Application/Base.lproj/Main.storyboard

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<menuItem isSeparatorItem="YES" id="VOq-y0-SEH"/>
2727
<menuItem title="Preferences…" tag="100" keyEquivalent="," id="BOF-NM-1cW">
2828
<connections>
29-
<segue destination="KWJ-lo-l8G" kind="modal" identifier="SettingsSegue" id="zB3-XI-gBu"/>
29+
<segue destination="KWJ-lo-l8G" kind="show" identifier="SettingsSegue" id="zB3-XI-gBu"/>
3030
</connections>
3131
</menuItem>
3232
<menuItem isSeparatorItem="YES" id="wFC-TO-SCJ"/>
@@ -419,7 +419,7 @@ Gw
419419
</string>
420420
</buttonCell>
421421
<connections>
422-
<action selector="dismissController:" target="2Ln-xh-MJc" id="mBw-OH-Ujr"/>
422+
<action selector="performClose:" target="niw-ah-gTT" id="pwZ-nI-8oJ"/>
423423
</connections>
424424
</button>
425425
<segmentedControl verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="CXL-K6-xK1">

Application/PreferencesController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,13 +544,13 @@ class PreferencesController: NSViewController, NSFontChanging {
544544

545545
service?.setSettings(settings as NSDictionary) { _ in
546546
DispatchQueue.main.async {
547+
self.view.window?.performClose(sender)
548+
547549
NSApplication.shared.windows.forEach { (window) in
548550
if let c = window.contentViewController as? ViewController {
549551
c.refresh(nil)
550552
}
551553
}
552-
553-
self.dismiss(sender)
554554
}
555555
}
556556
}

Application/ViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class ViewController: NSViewController {
8383
self.textView!.textContainer?.heightTracksTextView = false
8484

8585
self.textView!.isEditable = false
86-
self.textView!.isSelectable = false
86+
self.textView!.isSelectable = true
8787

8888
self.textView!.isGrammarCheckingEnabled = false
8989

@@ -141,7 +141,7 @@ class ViewController: NSViewController {
141141
webView?.isHidden = true
142142
textScrollView?.isHidden = true
143143

144-
service?.colorize(url: documentUrl, overrideSettings: nil) { (response, settings, error) in
144+
service?.colorize(url: documentUrl, overrideSettings: [SCSHSettings.Key.embedCustomStyle.rawValue: false]) { (response, settings, error) in
145145
let format = settings[SCSHSettings.Key.format.rawValue] as? String ?? SCSHFormat.html.rawValue
146146
DispatchQueue.main.async {
147147
self.initializeView(forMode: format)

QLExtension/PreviewViewController.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import OSLog
2828
import SourceCodeSyntaxHighlightXPCService
2929

3030
class MyDraggingView: NSTextView {
31+
var trackArea: NSTrackingArea? = nil
32+
3133
override var isOpaque: Bool {
3234
get {
3335
return false
@@ -46,6 +48,18 @@ class MyDraggingView: NSTextView {
4648
NSColor.clear.set()
4749
dirtyRect.fill()
4850
}
51+
52+
override func updateTrackingAreas() {
53+
if let trackArea = self.trackArea {
54+
self.removeTrackingArea(trackArea)
55+
}
56+
self.trackArea = NSTrackingArea(rect: self.bounds, options: [NSTrackingArea.Options.activeAlways, NSTrackingArea.Options.cursorUpdate], owner: self, userInfo: nil)
57+
self.addTrackingArea(self.trackArea!)
58+
}
59+
60+
override func cursorUpdate(with event: NSEvent) {
61+
NSCursor.arrow.set()
62+
}
4963
}
5064

5165
class StaticTextView: NSTextView {

SourceCodeSyntaxHighlight.xcodeproj/project.pbxproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@
5151
835923E823585E27001506B6 /* example.html in CopyFiles */ = {isa = PBXBuildFile; fileRef = 835923DE23585DD9001506B6 /* example.html */; };
5252
835923EA235A022C001506B6 /* NSColor+ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 835923E9235A022C001506B6 /* NSColor+ext.swift */; };
5353
835923EC235A3A85001506B6 /* SCSHTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 835923EB235A3A85001506B6 /* SCSHTheme.swift */; };
54-
835923EE235A5D33001506B6 /* SCSHCSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 835923ED235A5D33001506B6 /* SCSHCSettings.swift */; };
55-
835923EF235A5EB9001506B6 /* SCSHCSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 835923ED235A5D33001506B6 /* SCSHCSettings.swift */; };
56-
835923F0235A5EBA001506B6 /* SCSHCSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 835923ED235A5D33001506B6 /* SCSHCSettings.swift */; };
54+
835923EE235A5D33001506B6 /* SCSHSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 835923ED235A5D33001506B6 /* SCSHSettings.swift */; };
55+
835923EF235A5EB9001506B6 /* SCSHSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 835923ED235A5D33001506B6 /* SCSHSettings.swift */; };
56+
835923F0235A5EBA001506B6 /* SCSHSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 835923ED235A5D33001506B6 /* SCSHSettings.swift */; };
5757
835923F1235A6F16001506B6 /* NSColor+ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 835923E9235A022C001506B6 /* NSColor+ext.swift */; };
5858
83A0691123672FD100C795D6 /* style.css in Resources */ = {isa = PBXBuildFile; fileRef = 83A0691023672FD100C795D6 /* style.css */; };
5959
83A06912236730D800C795D6 /* style.css in Resources */ = {isa = PBXBuildFile; fileRef = 83A0691023672FD100C795D6 /* style.css */; };
@@ -191,7 +191,7 @@
191191
835923E223585DFB001506B6 /* example.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = example.xml; sourceTree = "<group>"; };
192192
835923E9235A022C001506B6 /* NSColor+ext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSColor+ext.swift"; sourceTree = "<group>"; };
193193
835923EB235A3A85001506B6 /* SCSHTheme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SCSHTheme.swift; sourceTree = "<group>"; };
194-
835923ED235A5D33001506B6 /* SCSHCSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SCSHCSettings.swift; sourceTree = "<group>"; };
194+
835923ED235A5D33001506B6 /* SCSHSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SCSHSettings.swift; sourceTree = "<group>"; };
195195
83A0691023672FD100C795D6 /* style.css */ = {isa = PBXFileReference; lastKnownFileType = text.css; path = style.css; sourceTree = "<group>"; };
196196
83C09FC0236367140062BF39 /* outhtml_commandbar.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = outhtml_commandbar.lua; sourceTree = "<group>"; };
197197
83C09FDA2365B9360062BF39 /* highlight */ = {isa = PBXFileReference; lastKnownFileType = folder; path = highlight; sourceTree = "<group>"; };
@@ -297,7 +297,7 @@
297297
8359238B23563C1E001506B6 /* XPCServiceRelease.entitlements */,
298298
835923EB235A3A85001506B6 /* SCSHTheme.swift */,
299299
8359239C23570C52001506B6 /* SCSHError.swift */,
300-
835923ED235A5D33001506B6 /* SCSHCSettings.swift */,
300+
835923ED235A5D33001506B6 /* SCSHSettings.swift */,
301301
8359237E23563BDF001506B6 /* SCSHXPCService.swift */,
302302
8359237D23563BDF001506B6 /* SCSHXPCServiceProtocol.swift */,
303303
8359237F23563BDF001506B6 /* SCSHXPCServiceDelegate.swift */,
@@ -485,7 +485,7 @@
485485
8359234B235599F6001506B6 /* ViewController.swift in Sources */,
486486
83592349235599F6001506B6 /* AppDelegate.swift in Sources */,
487487
8359239F23570C5C001506B6 /* SCSHError.swift in Sources */,
488-
835923F0235A5EBA001506B6 /* SCSHCSettings.swift in Sources */,
488+
835923F0235A5EBA001506B6 /* SCSHSettings.swift in Sources */,
489489
835923EA235A022C001506B6 /* NSColor+ext.swift in Sources */,
490490
8311D9C7235DE6D7006DC138 /* Data+Ext.swift in Sources */,
491491
);
@@ -498,7 +498,7 @@
498498
835923F1235A6F16001506B6 /* NSColor+ext.swift in Sources */,
499499
8311D9C8235DE6D7006DC138 /* Data+Ext.swift in Sources */,
500500
8359236223559A2B001506B6 /* PreviewViewController.swift in Sources */,
501-
835923EF235A5EB9001506B6 /* SCSHCSettings.swift in Sources */,
501+
835923EF235A5EB9001506B6 /* SCSHSettings.swift in Sources */,
502502
8359239E23570C5B001506B6 /* SCSHError.swift in Sources */,
503503
);
504504
runOnlyForDeploymentPostprocessing = 0;
@@ -511,7 +511,7 @@
511511
8359239D23570C52001506B6 /* SCSHError.swift in Sources */,
512512
8359238E2356436C001506B6 /* SCSHXPCServiceProtocol.swift in Sources */,
513513
8359238023563BDF001506B6 /* SCSHXPCServiceDelegate.swift in Sources */,
514-
835923EE235A5D33001506B6 /* SCSHCSettings.swift in Sources */,
514+
835923EE235A5D33001506B6 /* SCSHSettings.swift in Sources */,
515515
8359238F23564497001506B6 /* SCSHXPCService.swift in Sources */,
516516
835923EC235A3A85001506B6 /* SCSHTheme.swift in Sources */,
517517
);

XPCService/SCSHCSettings.swift renamed to XPCService/SCSHSettings.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ struct SCSHSettings {
111111
static let debug: Self = {
112112
return Self("debug")
113113
}()
114+
115+
static let embedCustomStyle: Self = {
116+
return Self("embed-style")
117+
}()
114118
}
115119

116120
/// Name of theme for light visualization.
@@ -148,6 +152,9 @@ struct SCSHSettings {
148152

149153
var debug = false
150154

155+
/// Embed custom style in the output.
156+
var embedCustomStyle = true
157+
151158
/// Domain for storing defaults.
152159
let domain: String
153160

@@ -252,6 +259,8 @@ struct SCSHSettings {
252259

253260
Key.fontFamily.rawValue: self.fontFamily,
254261
Key.fontSize.rawValue: self.fontSize,
262+
263+
Key.embedCustomStyle.rawValue: self.embedCustomStyle,
255264
]
256265

257266
switch self.lineNumbers {
@@ -328,6 +337,9 @@ struct SCSHSettings {
328337
if let v = data[Key.fontSize.rawValue] as? Float {
329338
self.fontSize = v
330339
}
340+
if let v = data[Key.embedCustomStyle.rawValue] as? Bool {
341+
self.embedCustomStyle = v
342+
}
331343
}
332344

333345
/// Create a new settings overriding current values
@@ -388,6 +400,8 @@ struct SCSHSettings {
388400
// Debug
389401
final_settings.debug = override?[Key.debug.rawValue] as? Bool ?? debug
390402

403+
final_settings.embedCustomStyle = override?[Key.embedCustomStyle.rawValue] as? Bool ?? embedCustomStyle
404+
391405
return final_settings
392406
}
393407
}

XPCService/SCSHXPCService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ class SCSHXPCService: NSObject, SCSHXPCServiceProtocol {
219219
if format == SCSHFormat.rtf.rawValue {
220220
env["extraHLFlags"]! += " --page-color --char-styles"
221221
} else {
222-
if let style = Bundle.main.path(forResource: "style", ofType: "css") {
222+
if custom_settings.embedCustomStyle, let style = Bundle.main.path(forResource: "style", ofType: "css") {
223223
env["extraHLFlags"]! += " --style-infile=\(style)"
224224
}
225225
}

XPCService/style.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
user-select: none !important;
33
-moz-user-select: none !important;
44
-webkit-user-select: none !important;
5+
6+
cursor: default !important;
57
}

0 commit comments

Comments
 (0)