jonas8 / SourceCodeSyntaxHighlight

MacOS 10.15 Catalina quicklook extension for source files.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Quicklook extension for source files

This project is a test to develop a system extension for MacOS 10.15 Catalina for previewing source files. It's based on the anthonygelibert/QLColorCode. Inside it uses Highlight to render source code with syntax highlighting. The application is distributed with a version of the highlight. If you want you can use a different version customizing the preferences.

MacOS 10.15 Catalina has deprecated the qlgenerator APIs. Moreover a .qlgenerator package inside Library/QuickLook now must be notarized to works. For this reason I tried to migrate the QLColorCode code using the new quicklook extension system.

This project consists of these components:

  • an standalone app that can view source files and provide the interface for the preferences;
  • a quicklook system extension to preview source files;
  • a XPC service that generate preview of source file and pass formatted data to the app or the quicklook extension.

MacOS 10.15 Catalina require sandboxed extension that prevent the execution of external processes (like shell script). To work around this problem, it is possible to use an XPC service that may have different security policies than the application / extension that invokes it. In this case the XPC service is not sandboxed.

The XPC service is executed automatically when requested by the application or the quicklook extension. After closing the quicklook preview the process is automatically closed after some seconds relasing the resources.

To use the extension you must launch the application at least once. In this way the quicklook extension will be discovered by the system. In the standalone app, with the preferences window, you can also customize the preview settings used by plugin extension.

Settings window

In the settings it is possible to choose a different theme to use when OS is in light and dark mode.

The app and quicklook extension can preview files showing the formatted code as html, inside a WKWebView, or as rtf inside a NSTextView.

After the first execution, the quicklook extension will be available among those present in the System preferences/Extensions.

System preferences/Extensions

This extension don't provide a thumbnail service for the Finder icon.

About

MacOS 10.15 Catalina quicklook extension for source files.

License:GNU General Public License v3.0


Languages

Language:Lua 61.0%Language:Swift 34.1%Language:Shell 1.8%Language:F# 1.6%Language:PHP 0.5%Language:JavaScript 0.3%Language:Dart 0.2%Language:CSS 0.2%Language:C 0.1%Language:HTML 0.1%Language:C++ 0.1%Language:Objective-C 0.1%Language:Perl 0.1%Language:TypeScript 0.1%Language:Python 0.0%