Skip to content

Commit

Permalink
Bugfix.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbarex committed Oct 29, 2019
1 parent 237f8aa commit 97ded7e
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Application/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<menuItem isSeparatorItem="YES" id="VOq-y0-SEH"/>
<menuItem title="Preferences…" tag="100" keyEquivalent="," id="BOF-NM-1cW">
<connections>
<segue destination="KWJ-lo-l8G" kind="modal" identifier="SettingsSegue" id="zB3-XI-gBu"/>
<segue destination="KWJ-lo-l8G" kind="show" identifier="SettingsSegue" id="zB3-XI-gBu"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="wFC-TO-SCJ"/>
Expand Down Expand Up @@ -419,7 +419,7 @@ Gw
</string>
</buttonCell>
<connections>
<action selector="dismissController:" target="2Ln-xh-MJc" id="mBw-OH-Ujr"/>
<action selector="performClose:" target="niw-ah-gTT" id="pwZ-nI-8oJ"/>
</connections>
</button>
<segmentedControl verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="CXL-K6-xK1">
Expand Down
4 changes: 2 additions & 2 deletions Application/PreferencesController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -544,13 +544,13 @@ class PreferencesController: NSViewController, NSFontChanging {

service?.setSettings(settings as NSDictionary) { _ in
DispatchQueue.main.async {
self.view.window?.performClose(sender)

NSApplication.shared.windows.forEach { (window) in
if let c = window.contentViewController as? ViewController {
c.refresh(nil)
}
}

self.dismiss(sender)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Application/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class ViewController: NSViewController {
self.textView!.textContainer?.heightTracksTextView = false

self.textView!.isEditable = false
self.textView!.isSelectable = false
self.textView!.isSelectable = true

self.textView!.isGrammarCheckingEnabled = false

Expand Down Expand Up @@ -141,7 +141,7 @@ class ViewController: NSViewController {
webView?.isHidden = true
textScrollView?.isHidden = true

service?.colorize(url: documentUrl, overrideSettings: nil) { (response, settings, error) in
service?.colorize(url: documentUrl, overrideSettings: [SCSHSettings.Key.embedCustomStyle.rawValue: false]) { (response, settings, error) in
let format = settings[SCSHSettings.Key.format.rawValue] as? String ?? SCSHFormat.html.rawValue
DispatchQueue.main.async {
self.initializeView(forMode: format)
Expand Down
14 changes: 14 additions & 0 deletions QLExtension/PreviewViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import OSLog
import SourceCodeSyntaxHighlightXPCService

class MyDraggingView: NSTextView {
var trackArea: NSTrackingArea? = nil

override var isOpaque: Bool {
get {
return false
Expand All @@ -46,6 +48,18 @@ class MyDraggingView: NSTextView {
NSColor.clear.set()
dirtyRect.fill()
}

override func updateTrackingAreas() {
if let trackArea = self.trackArea {
self.removeTrackingArea(trackArea)
}
self.trackArea = NSTrackingArea(rect: self.bounds, options: [NSTrackingArea.Options.activeAlways, NSTrackingArea.Options.cursorUpdate], owner: self, userInfo: nil)
self.addTrackingArea(self.trackArea!)
}

override func cursorUpdate(with event: NSEvent) {
NSCursor.arrow.set()
}
}

class StaticTextView: NSTextView {
Expand Down
16 changes: 8 additions & 8 deletions SourceCodeSyntaxHighlight.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
835923E823585E27001506B6 /* example.html in CopyFiles */ = {isa = PBXBuildFile; fileRef = 835923DE23585DD9001506B6 /* example.html */; };
835923EA235A022C001506B6 /* NSColor+ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 835923E9235A022C001506B6 /* NSColor+ext.swift */; };
835923EC235A3A85001506B6 /* SCSHTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 835923EB235A3A85001506B6 /* SCSHTheme.swift */; };
835923EE235A5D33001506B6 /* SCSHCSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 835923ED235A5D33001506B6 /* SCSHCSettings.swift */; };
835923EF235A5EB9001506B6 /* SCSHCSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 835923ED235A5D33001506B6 /* SCSHCSettings.swift */; };
835923F0235A5EBA001506B6 /* SCSHCSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 835923ED235A5D33001506B6 /* SCSHCSettings.swift */; };
835923EE235A5D33001506B6 /* SCSHSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 835923ED235A5D33001506B6 /* SCSHSettings.swift */; };
835923EF235A5EB9001506B6 /* SCSHSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 835923ED235A5D33001506B6 /* SCSHSettings.swift */; };
835923F0235A5EBA001506B6 /* SCSHSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 835923ED235A5D33001506B6 /* SCSHSettings.swift */; };
835923F1235A6F16001506B6 /* NSColor+ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 835923E9235A022C001506B6 /* NSColor+ext.swift */; };
83A0691123672FD100C795D6 /* style.css in Resources */ = {isa = PBXBuildFile; fileRef = 83A0691023672FD100C795D6 /* style.css */; };
83A06912236730D800C795D6 /* style.css in Resources */ = {isa = PBXBuildFile; fileRef = 83A0691023672FD100C795D6 /* style.css */; };
Expand Down Expand Up @@ -191,7 +191,7 @@
835923E223585DFB001506B6 /* example.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = example.xml; sourceTree = "<group>"; };
835923E9235A022C001506B6 /* NSColor+ext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSColor+ext.swift"; sourceTree = "<group>"; };
835923EB235A3A85001506B6 /* SCSHTheme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SCSHTheme.swift; sourceTree = "<group>"; };
835923ED235A5D33001506B6 /* SCSHCSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SCSHCSettings.swift; sourceTree = "<group>"; };
835923ED235A5D33001506B6 /* SCSHSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SCSHSettings.swift; sourceTree = "<group>"; };
83A0691023672FD100C795D6 /* style.css */ = {isa = PBXFileReference; lastKnownFileType = text.css; path = style.css; sourceTree = "<group>"; };
83C09FC0236367140062BF39 /* outhtml_commandbar.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = outhtml_commandbar.lua; sourceTree = "<group>"; };
83C09FDA2365B9360062BF39 /* highlight */ = {isa = PBXFileReference; lastKnownFileType = folder; path = highlight; sourceTree = "<group>"; };
Expand Down Expand Up @@ -297,7 +297,7 @@
8359238B23563C1E001506B6 /* XPCServiceRelease.entitlements */,
835923EB235A3A85001506B6 /* SCSHTheme.swift */,
8359239C23570C52001506B6 /* SCSHError.swift */,
835923ED235A5D33001506B6 /* SCSHCSettings.swift */,
835923ED235A5D33001506B6 /* SCSHSettings.swift */,
8359237E23563BDF001506B6 /* SCSHXPCService.swift */,
8359237D23563BDF001506B6 /* SCSHXPCServiceProtocol.swift */,
8359237F23563BDF001506B6 /* SCSHXPCServiceDelegate.swift */,
Expand Down Expand Up @@ -485,7 +485,7 @@
8359234B235599F6001506B6 /* ViewController.swift in Sources */,
83592349235599F6001506B6 /* AppDelegate.swift in Sources */,
8359239F23570C5C001506B6 /* SCSHError.swift in Sources */,
835923F0235A5EBA001506B6 /* SCSHCSettings.swift in Sources */,
835923F0235A5EBA001506B6 /* SCSHSettings.swift in Sources */,
835923EA235A022C001506B6 /* NSColor+ext.swift in Sources */,
8311D9C7235DE6D7006DC138 /* Data+Ext.swift in Sources */,
);
Expand All @@ -498,7 +498,7 @@
835923F1235A6F16001506B6 /* NSColor+ext.swift in Sources */,
8311D9C8235DE6D7006DC138 /* Data+Ext.swift in Sources */,
8359236223559A2B001506B6 /* PreviewViewController.swift in Sources */,
835923EF235A5EB9001506B6 /* SCSHCSettings.swift in Sources */,
835923EF235A5EB9001506B6 /* SCSHSettings.swift in Sources */,
8359239E23570C5B001506B6 /* SCSHError.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -511,7 +511,7 @@
8359239D23570C52001506B6 /* SCSHError.swift in Sources */,
8359238E2356436C001506B6 /* SCSHXPCServiceProtocol.swift in Sources */,
8359238023563BDF001506B6 /* SCSHXPCServiceDelegate.swift in Sources */,
835923EE235A5D33001506B6 /* SCSHCSettings.swift in Sources */,
835923EE235A5D33001506B6 /* SCSHSettings.swift in Sources */,
8359238F23564497001506B6 /* SCSHXPCService.swift in Sources */,
835923EC235A3A85001506B6 /* SCSHTheme.swift in Sources */,
);
Expand Down
14 changes: 14 additions & 0 deletions XPCService/SCSHCSettings.swift → XPCService/SCSHSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ struct SCSHSettings {
static let debug: Self = {
return Self("debug")
}()

static let embedCustomStyle: Self = {
return Self("embed-style")
}()
}

/// Name of theme for light visualization.
Expand Down Expand Up @@ -148,6 +152,9 @@ struct SCSHSettings {

var debug = false

/// Embed custom style in the output.
var embedCustomStyle = true

/// Domain for storing defaults.
let domain: String

Expand Down Expand Up @@ -252,6 +259,8 @@ struct SCSHSettings {

Key.fontFamily.rawValue: self.fontFamily,
Key.fontSize.rawValue: self.fontSize,

Key.embedCustomStyle.rawValue: self.embedCustomStyle,
]

switch self.lineNumbers {
Expand Down Expand Up @@ -328,6 +337,9 @@ struct SCSHSettings {
if let v = data[Key.fontSize.rawValue] as? Float {
self.fontSize = v
}
if let v = data[Key.embedCustomStyle.rawValue] as? Bool {
self.embedCustomStyle = v
}
}

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

final_settings.embedCustomStyle = override?[Key.embedCustomStyle.rawValue] as? Bool ?? embedCustomStyle

return final_settings
}
}
2 changes: 1 addition & 1 deletion XPCService/SCSHXPCService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class SCSHXPCService: NSObject, SCSHXPCServiceProtocol {
if format == SCSHFormat.rtf.rawValue {
env["extraHLFlags"]! += " --page-color --char-styles"
} else {
if let style = Bundle.main.path(forResource: "style", ofType: "css") {
if custom_settings.embedCustomStyle, let style = Bundle.main.path(forResource: "style", ofType: "css") {
env["extraHLFlags"]! += " --style-infile=\(style)"
}
}
Expand Down
2 changes: 2 additions & 0 deletions XPCService/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
user-select: none !important;
-moz-user-select: none !important;
-webkit-user-select: none !important;

cursor: default !important;
}

0 comments on commit 97ded7e

Please sign in to comment.