Ticket #58035: QL_208_210.diff
File QL_208_210.diff, 31.6 KB (added by iEFdev, 6 years ago) |
---|
-
CHANGELOG
diff --git a/CHANGELOG b/CHANGELOG index 7c37ece..7f7933e 100644
a b 1 2.1.0: 2 * Add option to preview file as RTF (thanks @silum). 3 * Add Kotlin/Gradle (thanks @sonique6784). 4 * Remove JSON support (thanks @erdtsksn). 5 * Add C# support. 6 * Add Scala support. 7 * Add "reduce_filesize" plugin by default. 8 9 2.0.9: 10 * Add PHP/JS support (thanks @sloanlance). 11 * Add C#/F# support (thanks @breiter). 12 * Compile with XCode 9.0 targeting 10.13. 13 14 2.0.8: 15 * Remove bash_ref_linuxmanpages_com plugin. 16 1 17 2.0.7: 2 18 * Correct autodetect path on 10.11 (thanks @cc941201). 3 19 * Correct LaTeX and Arduino support. -
Info.plist
diff --git a/Info.plist b/Info.plist index 6fa78d0..2c46e89 100644
a b 12 12 <key>LSItemContentTypes</key> 13 13 <array> 14 14 <string>public.source-code</string> 15 <string>public.php-script</string> 16 <string>com.netscape.javascript-source</string> 17 <string>com.microsoft.c-sharp</string> 18 <string>com.microsoft.f-sharp</string> 15 19 <string>public.css</string> 16 20 <string>com.apple.applescript.script</string> 17 21 <string>public.xml</string> … … 21 25 <string>com.sun.java-class</string> 22 26 <string>org.vim.vim-script</string> 23 27 <string>public.tex</string> 28 <string>public.text</string> 29 <string>dyn.ah62d4rv4ge81g6pq</string> 30 <string>dyn.ah62d4rv4ge8007a</string> 31 <string>dyn.ah62d4rv4ge80s6xbqv0gn</string> 32 <string>dyn.ah62d4rv4ge81g25brvuu</string> 33 <string>dyn.ah62d4rv4ge80g62</string> 24 34 </array> 25 35 </dict> 26 36 </array> … … 255 265 <key>UTTypeConformsTo</key> 256 266 <array> 257 267 <string>public.source-code</string> 268 <string>dyn.ah62d4rv4ge81g6pq</string> 258 269 </array> 259 270 <key>UTTypeDescription</key> 260 271 <string>SQL Source File</string> … … 1035 1046 </array> 1036 1047 </dict> 1037 1048 </dict> 1049 <dict> 1050 <key>UTTypeConformsTo</key> 1051 <array> 1052 <string>dyn.ah62d4rv4ge8007a</string> 1053 </array> 1054 <key>UTTypeDescription</key> 1055 <string>Kotlin Source File</string> 1056 <key>UTTypeIdentifier</key> 1057 <string>org.kotlinlang.source</string> 1058 <key>UTTypeTagSpecification</key> 1059 <dict> 1060 <key>public.filename-extension</key> 1061 <array> 1062 <string>kt</string> 1063 </array> 1064 </dict> 1065 </dict> 1066 <dict> 1067 <key>UTTypeConformsTo</key> 1068 <array> 1069 <string>dyn.ah62d4rv4ge80s6xbqv0gn</string> 1070 </array> 1071 <key>UTTypeDescription</key> 1072 <string>Gradle Source File</string> 1073 <key>UTTypeIdentifier</key> 1074 <string>org.gradle.source</string> 1075 <key>UTTypeTagSpecification</key> 1076 <dict> 1077 <key>public.filename-extension</key> 1078 <array> 1079 <string>gradle</string> 1080 </array> 1081 </dict> 1082 </dict> 1038 1083 </array> 1039 1084 </dict> 1040 1085 </plist> -
QLColorCode.xcodeproj/project.pbxproj
diff --git a/QLColorCode.xcodeproj/project.pbxproj b/QLColorCode.xcodeproj/project.pbxproj index 08bde83..d3f1bb1 100644
a b 24 24 /* Begin PBXBuildFile section */ 25 25 0ECBBA6C0CFCA37500416538 /* QLColorCode.qlgenerator in Copy to Library */ = {isa = PBXBuildFile; fileRef = 8D576316048677EA00EA77CD /* QLColorCode.qlgenerator */; }; 26 26 8D576314048677EA00EA77CD /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0AA1909FFE8422F4C02AAC07 /* CoreFoundation.framework */; }; 27 8D5B49A804867FD3000E48DA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8D5B49A704867FD3000E48DA /* InfoPlist.strings */; };28 27 C86B05270671AA6E00DD9006 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C86B05260671AA6E00DD9006 /* CoreServices.framework */; }; 29 28 EA43671C15F6BF9C009DA6C0 /* colorize.sh in Resources */ = {isa = PBXBuildFile; fileRef = EA43671615F6BF9C009DA6C0 /* colorize.sh */; }; 30 29 EA43671D15F6BF9C009DA6C0 /* Common.h in Headers */ = {isa = PBXBuildFile; fileRef = EA43671715F6BF9C009DA6C0 /* Common.h */; }; … … 206 205 089C1669FE841209C02AAC07 /* Project object */ = { 207 206 isa = PBXProject; 208 207 attributes = { 209 LastUpgradeCheck = 0 730;208 LastUpgradeCheck = 0940; 210 209 }; 211 210 buildConfigurationList = 2CA326220896AD4900168862 /* Build configuration list for PBXProject "QLColorCode" */; 212 211 compatibilityVersion = "Xcode 3.2"; … … 233 232 isa = PBXResourcesBuildPhase; 234 233 buildActionMask = 2147483647; 235 234 files = ( 236 8D5B49A804867FD3000E48DA /* InfoPlist.strings in Resources */,237 235 EA43671C15F6BF9C009DA6C0 /* colorize.sh in Resources */, 238 236 EA43672515F6C00B009DA6C0 /* English.lproj in Resources */, 239 237 EA43672F15F6C1B8009DA6C0 /* CHANGELOG in Resources */, … … 297 295 }; 298 296 /* End PBXTargetDependency section */ 299 297 300 /* Begin PBXVariantGroup section */301 8D5B49A704867FD3000E48DA /* InfoPlist.strings */ = {302 isa = PBXVariantGroup;303 children = (304 );305 name = InfoPlist.strings;306 path = /Users/tony/Documents/Projects/qlcolorcode;307 sourceTree = "<absolute>";308 };309 /* End PBXVariantGroup section */310 311 298 /* Begin XCBuildConfiguration section */ 312 299 0E0E34EA0D0097020086C1E6 /* Debug */ = { 313 300 isa = XCBuildConfiguration; 314 301 buildSettings = { 302 CLANG_ENABLE_OBJC_WEAK = YES; 315 303 COMBINE_HIDPI_IMAGES = YES; 316 304 COPY_PHASE_STRIP = NO; 317 305 GCC_DYNAMIC_NO_PIC = NO; … … 325 313 0E0E34EB0D0097020086C1E6 /* Release */ = { 326 314 isa = XCBuildConfiguration; 327 315 buildSettings = { 316 CLANG_ENABLE_OBJC_WEAK = YES; 328 317 COMBINE_HIDPI_IMAGES = YES; 329 318 COPY_PHASE_STRIP = YES; 330 319 DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; … … 338 327 2CA3261F0896AD4900168862 /* Debug */ = { 339 328 isa = XCBuildConfiguration; 340 329 buildSettings = { 330 CLANG_ENABLE_OBJC_WEAK = YES; 341 331 COMBINE_HIDPI_IMAGES = YES; 342 332 OTHER_CFLAGS = "-DDEBUG"; 343 333 }; … … 346 336 2CA326200896AD4900168862 /* Release */ = { 347 337 isa = XCBuildConfiguration; 348 338 buildSettings = { 339 CLANG_ENABLE_OBJC_WEAK = YES; 349 340 COMBINE_HIDPI_IMAGES = YES; 350 341 }; 351 342 name = Release; … … 353 344 2CA326230896AD4900168862 /* Debug */ = { 354 345 isa = XCBuildConfiguration; 355 346 buildSettings = { 347 ARCHS = "$(ARCHS_STANDARD)"; 348 CLANG_ADDRESS_SANITIZER_CONTAINER_OVERFLOW = YES; 349 CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = YES; 350 CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 356 351 CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES; 357 352 CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES; 358 353 CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; 359 354 CLANG_ENABLE_MODULES = YES; 355 CLANG_UNDEFINED_BEHAVIOR_SANITIZER_INTEGER = YES; 356 CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES; 360 357 CLANG_WARN_ASSIGN_ENUM = YES; 358 CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 359 CLANG_WARN_COMMA = YES; 360 CLANG_WARN_CXX0X_EXTENSIONS = YES; 361 361 CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 362 362 CLANG_WARN_EMPTY_BODY = YES; 363 363 CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; 364 CLANG_WARN_INFINITE_RECURSION = YES; 364 365 CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES; 365 366 CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES; 366 367 CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 367 368 CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES; 368 369 CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES; 370 CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 371 CLANG_WARN_STRICT_PROTOTYPES = YES; 369 372 CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; 373 CLANG_WARN_SUSPICIOUS_MOVE = YES; 370 374 CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE; 371 375 CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 372 376 COPY_PHASE_STRIP = NO; 373 CURRENT_PROJECT_VERSION = 2. 0.7;377 CURRENT_PROJECT_VERSION = 2.1.0; 374 378 DEAD_CODE_STRIPPING = YES; 375 379 DSTROOT = "/export/tmp/$(PROJECT_NAME).dst"; 376 380 ENABLE_STRICT_OBJC_MSGSEND = YES; 377 381 ENABLE_TESTABILITY = YES; 382 GCC_NO_COMMON_BLOCKS = YES; 378 383 GCC_OPTIMIZATION_LEVEL = 0; 379 384 GCC_PREPROCESSOR_DEFINITIONS = DEBUG; 380 GCC_ VERSION = "";385 GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 381 386 GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; 382 387 GCC_WARN_ABOUT_MISSING_NEWLINE = YES; 383 388 GCC_WARN_ABOUT_RETURN_TYPE = YES; 384 389 GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; 390 GCC_WARN_PEDANTIC = YES; 385 391 GCC_WARN_SHADOW = YES; 386 392 GCC_WARN_SIGN_COMPARE = YES; 387 393 GCC_WARN_STRICT_SELECTOR_MATCH = YES; … … 393 399 GCC_WARN_UNUSED_PARAMETER = NO; 394 400 GCC_WARN_UNUSED_VARIABLE = YES; 395 401 INFOPLIST_FILE = Info.plist; 396 INSTALL_PATH = /Library/QuickLook; 397 MACOSX_DEPLOYMENT_TARGET = 10.11; 402 MACOSX_DEPLOYMENT_TARGET = 10.13; 398 403 ONLY_ACTIVE_ARCH = YES; 399 404 PRODUCT_BUNDLE_IDENTIFIER = org.n8gray.qlcolorcode; 400 405 PRODUCT_NAME = QLColorCode; 401 406 RUN_CLANG_STATIC_ANALYZER = YES; 402 407 SDKROOT = macosx; 403 VALID_ARCHS = x86_64;404 408 WRAPPER_EXTENSION = qlgenerator; 405 409 }; 406 410 name = Debug; … … 408 412 2CA326240896AD4900168862 /* Release */ = { 409 413 isa = XCBuildConfiguration; 410 414 buildSettings = { 415 ARCHS = "$(ARCHS_STANDARD)"; 416 CLANG_ADDRESS_SANITIZER_CONTAINER_OVERFLOW = YES; 417 CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = YES; 418 CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 411 419 CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES; 412 420 CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES; 413 421 CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; 414 422 CLANG_ENABLE_MODULES = YES; 423 CLANG_UNDEFINED_BEHAVIOR_SANITIZER_INTEGER = YES; 424 CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES; 415 425 CLANG_WARN_ASSIGN_ENUM = YES; 426 CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 427 CLANG_WARN_COMMA = YES; 428 CLANG_WARN_CXX0X_EXTENSIONS = YES; 416 429 CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 417 430 CLANG_WARN_EMPTY_BODY = YES; 418 431 CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; 432 CLANG_WARN_INFINITE_RECURSION = YES; 419 433 CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES; 420 434 CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES; 421 435 CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 422 436 CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES; 423 437 CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES; 438 CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 439 CLANG_WARN_STRICT_PROTOTYPES = YES; 424 440 CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; 441 CLANG_WARN_SUSPICIOUS_MOVE = YES; 425 442 CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE; 426 443 CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 427 CURRENT_PROJECT_VERSION = 2. 0.7;444 CURRENT_PROJECT_VERSION = 2.1.0; 428 445 DEAD_CODE_STRIPPING = YES; 429 446 DSTROOT = "/export/tmp/$(PROJECT_NAME).dst"; 430 447 ENABLE_STRICT_OBJC_MSGSEND = YES; 431 448 GCC_GENERATE_DEBUGGING_SYMBOLS = NO; 432 GCC_VERSION = ""; 449 GCC_NO_COMMON_BLOCKS = YES; 450 GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 433 451 GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; 434 452 GCC_WARN_ABOUT_MISSING_NEWLINE = YES; 435 453 GCC_WARN_ABOUT_RETURN_TYPE = YES; 436 454 GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; 455 GCC_WARN_PEDANTIC = YES; 437 456 GCC_WARN_SHADOW = YES; 438 457 GCC_WARN_SIGN_COMPARE = YES; 439 458 GCC_WARN_STRICT_SELECTOR_MATCH = YES; … … 445 464 GCC_WARN_UNUSED_PARAMETER = NO; 446 465 GCC_WARN_UNUSED_VARIABLE = YES; 447 466 INFOPLIST_FILE = Info.plist; 448 INSTALL_PATH = /Library/QuickLook; 449 LLVM_LTO = YES; 450 MACOSX_DEPLOYMENT_TARGET = 10.11; 467 MACOSX_DEPLOYMENT_TARGET = 10.13; 451 468 ONLY_ACTIVE_ARCH = YES; 452 469 PRODUCT_BUNDLE_IDENTIFIER = org.n8gray.qlcolorcode; 453 470 PRODUCT_NAME = QLColorCode; 454 471 RUN_CLANG_STATIC_ANALYZER = YES; 455 472 SDKROOT = macosx; 456 VALID_ARCHS = x86_64;457 473 WRAPPER_EXTENSION = qlgenerator; 458 474 }; 459 475 name = Release; -
QLColorCode.xcodeproj/xcshareddata/xcschemes/Travis.xcscheme
diff --git a/QLColorCode.xcodeproj/xcshareddata/xcschemes/Travis.xcscheme b/QLColorCode.xcodeproj/xcshareddata/xcschemes/Travis.xcscheme index 6bfb552..0148541 100644
a b 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <Scheme 3 LastUpgradeVersion = "0 700"3 LastUpgradeVersion = "0940" 4 4 version = "1.3"> 5 5 <BuildAction 6 6 parallelizeBuildables = "YES" -
README.md
diff --git a/README.md b/README.md index 93cc961..8a6b1f6 100644
a b 7 7 This is a Quick Look plugin that renders source code with syntax highlighting, 8 8 using the [Highlight library](http://www.andre-simon.de). 9 9 10 To install Highlight, [download the library manualy](http://www.andre-simon.de/zip/download.php), or use homebrew `brew install highlight` 11 10 12 To install the plugin, just drag it to `~/Library/QuickLook`. 11 13 You may need to create that folder if it doesn't already exist. 12 14 … … Setting the text encoding (default is `UTF-8`). Two settings are required. The 20 22 21 23 defaults write org.n8gray.QLColorCode textEncoding UTF-16 22 24 defaults write org.n8gray.QLColorCode webkitTextEncoding UTF-16 23 25 24 26 Setting the font (default is `Menlo`): 25 27 26 28 defaults write org.n8gray.QLColorCode font Monaco 27 29 28 30 Setting the font size (default is `10`): 29 31 30 32 defaults write org.n8gray.QLColorCode fontSizePoints 9 31 33 32 34 Setting the color style (default is `edit-xcode`, see [all available themes](http://www.andre-simon.de/dokuwiki/doku.php?id=theme_examples)): 33 35 34 36 defaults write org.n8gray.QLColorCode hlTheme ide-xcode 35 37 36 38 Setting the thumbnail color style (deactivated by default): 37 39 38 40 defaults write org.n8gray.QLColorCode hlThumbTheme ide-xcode … … Setting the maximum size (in bytes, deactivated by default) for previewed files: 44 46 Setting any extra command-line flags for Highlight (see below): 45 47 46 48 defaults write org.n8gray.QLColorCode extraHLFlags '-l -W' 47 49 48 50 Here are some useful 'highlight' command-line flags (from the man page): 49 51 50 52 -F, --reformat=<style> … … Here are some useful 'highlight' command-line flags (from the man page): 57 59 -j, --line-number-length=<num> 58 60 line number length incl. left padding 59 61 60 -l, --line numbers62 -l, --line-numbers 61 63 print line numbers in output file 62 64 63 65 -t --replace-tabs=<num> … … Here are some useful 'highlight' command-line flags (from the man page): 77 79 control case of case insensitive keywords 78 80 79 81 **Warning:** my fork uses an external `Highlight`. It will attempt to find `highlight` on your `PATH` (so it should work out of the box for homebrew and MacPorts), but if it can't find it, it'll use `/opt/local/bin/highlight` (MacPorts default). This can be changed: 80 81 defaults write org.n8gray.QLColorCode pathHL /path/to/your/highlight 82 83 defaults write org.n8gray.QLColorCode pathHL /path/to/your/highlight 84 85 It is also possible to have the HTML preview converted to RTF. Using RTF 86 allows the contents of the file to be displayed instead of an icon -- similar 87 to QLStephen. 88 89 defaults write org.n8gray.QLColorCode rtfRender true 82 90 83 91 ## Additional information 84 92 … … Here are some useful 'highlight' command-line flags (from the man page): 88 96 89 97 QLColorCode decompiles some formats: 90 98 91 - **Java class**. It requires [jad](http://varaneckas.com/jad/) installed at `/usr/local/bin/jad`. 99 - **Java class**. It requires [jad](http://varaneckas.com/jad/) installed at `/usr/local/bin/jad`. 92 100 - **Compiled AppleScript**. It requires `osadecompile` installed at `/usr/bin/osadecompile`. 93 - **Binary PLIST**. It requires `plutil` installed at `/usr/bin/plutil`. 101 - **Binary PLIST**. It requires `plutil` installed at `/usr/bin/plutil`. 94 102 95 103 ### Highlight 96 104 … … QLColorCode enables some Highlight plugins : 103 111 - C/C++: `cpp_syslog`, `cpp_ref_cplusplus_com` and `cpp_ref_local_includes`. 104 112 - Perl: `perl_ref_perl_org`. 105 113 - Python: `python_ref_python_org`. 106 - Shell: `bash_functions` and `bash_ref_linuxmanpages_com`.114 - Shell: `bash_functions`. 107 115 - Scala: `scala_ref_scala_lang_org`. 108 116 109 117 #### Handled languages 110 Highlight can handle lots and lots of languages, but this plugin will only be 118 Highlight can handle lots and lots of languages, but this plugin will only be 111 119 invoked for file types that the OS knows are type "source-code". Since the OS 112 only knows about a limited number of languages, I've added Universal Type 113 Identifier (UTI) declarations for several "interesting" languages. If I've 120 only knows about a limited number of languages, I've added Universal Type 121 Identifier (UTI) declarations for several "interesting" languages. If I've 114 122 missed your favorite language, take a look at the Info.plist file inside the 115 123 plugin bundle and look for the UTImportedTypeDeclarations section. I 116 124 haven't added all the languages that Highlight can handle because it's rumored 117 125 that having two conflicting UTI declarations for the same file extension can 118 cause problems. Note that if you do edit the Info.plist file you need to 126 cause problems. Note that if you do edit the Info.plist file you need to 119 127 nudge the system to tell it something has changed. Moving the plugin to the 120 128 desktop then back to its installed location should do the trick. 121 129 122 130 As an aside, by changing colorize.sh you can use this plugin to render any file 123 131 type that you can convert to HTML. Have fun, and let me know if you do anything 124 132 cool! 133 134 ##### Adding Language Types 135 136 If QLColorCode doesn't display PHP and JavaScript code properly, their types may 137 need to be added to Info.plist. Finding the right type string to use is the 138 tricky part. Getting the type strings and getting Info.plist edits to take effect 139 is easy by following the steps below, which explain how to add support for PHP: 140 141 0. In Terminal.app (or any shell prompt), enter the command: 142 143 ``` bash 144 mdls -name kMDItemContentType /full/path/to/file.php 145 ``` 146 147 Use the path to any PHP file. The response will be: 148 149 ``` txt 150 kMDItemContentType = "public.php-script" 151 ``` 152 153 The string `public.php-script` is the type string needed in a later step. 154 155 0. Again at a shell prompt, enter the command: 156 157 ``` bash 158 open ~/Library/QuickLook/QLColorCode.qlgenerator/Contents/Info.plist 159 ``` 160 161 This will open Info.plist in Xcode.app. 162 163 0. In Xcode.app's edit window for Info.plist, go to: 164 165 Document types > Item 0 > Document Content Type UTIs 166 167 (If the editor is showing raw keys, that's: 168 CFBundleDocumentTypes > Item 0 > LSItemContentTypes) 169 170 0. Add an item for `public.php-script`, the type string found in the first step. 171 172 0. Save the updated Info.plist file. 173 174 0. Try it in Finder. (It's usually unnecessary to move/return the QLColorCode 175 extension, restart QuickLook, or restart the Finder, but it wouldn't be surprising 176 that some users might need to do so.) 177 178 The Info.plist included with this version of QLColorCode already contains types 179 for PHP and JavaScript code, but these steps show how easy it is to add other 180 types. (Maybe somebody will develop a Preference Pane for QLColorCode to make 181 this even easier.) -
rsrc/English.lproj/InfoPlist.strings
diff --git a/rsrc/English.lproj/InfoPlist.strings b/rsrc/English.lproj/InfoPlist.strings index 852fc68..12f77e3 100644
a b 1 1 /* Localized versions of Info.plist keys */ 2 2 3 CFBundleGetInfoString = "QLColorCode version 2. 0.7, Copyright (c) 2016Nathaniel Gray, Anthony Gelibert.";4 NSHumanReadableCopyright = "Copyright (c) 201 6Nathaniel Gray, Anthony Gelibert.";3 CFBundleGetInfoString = "QLColorCode version 2.1.0, Copyright (c) 2018 Nathaniel Gray, Anthony Gelibert."; 4 NSHumanReadableCopyright = "Copyright (c) 2018 Nathaniel Gray, Anthony Gelibert."; 5 5 -
src/Common.m
diff --git a/src/Common.m b/src/Common.m index 1c830bd..5efca97 100644
a b 4 4 * 5 5 * Created by Nathaniel Gray on 12/6/07. 6 6 * Copyright 2007 Nathaniel Gray. 7 * 7 * 8 8 * Modified by Anthony Gelibert on 9/5/12. 9 9 * Copyright 2012 Anthony Gelibert. 10 10 */ … … NSData *runTask(NSString *script, NSDictionary *env, int *exitCode) { 23 23 [task setEnvironment:env]; 24 24 [task setLaunchPath:@"/bin/sh"]; 25 25 [task setArguments:[NSArray arrayWithObjects:@"-c", script, nil]]; 26 26 27 27 NSPipe *pipe; 28 28 pipe = [NSPipe pipe]; 29 29 [task setStandardOutput: pipe]; 30 30 // Let stderr go to the usual place 31 31 //[task setStandardError: pipe]; 32 32 33 33 NSFileHandle *file; 34 34 file = [pipe fileHandleForReading]; 35 35 36 36 [task launch]; 37 37 38 38 NSData *data; 39 39 data = [file readDataToEndOfFile]; 40 40 [task waitUntilExit]; 41 41 42 42 *exitCode = [task terminationStatus]; 43 43 [task release]; 44 44 /* The docs claim this isn't needed, but we leak descriptors otherwise */ 45 45 [file closeFile]; 46 46 /*[pipe release];*/ 47 47 48 48 return data; 49 49 } 50 50 … … NSData *colorizeURL(CFBundleRef bundle, CFURLRef url, int *status, int thumbnail 66 66 n8log(@"url = %@", url); 67 67 NSString *targetEsc = pathOfURL(url); 68 68 n8log(@"targetEsc = %@", targetEsc); 69 69 70 70 // Set up preferences 71 71 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 72 72 73 73 NSMutableDictionary *env = [NSMutableDictionary dictionaryWithDictionary: 74 74 [[NSProcessInfo processInfo] environment]]; 75 75 76 76 NSString *path = [env objectForKey: @"PATH"]; 77 77 NSString *newPath = [path stringByAppendingString: @":/usr/local/bin:/usr/local/sbin"]; 78 78 [env setObject: newPath forKey: @"PATH"]; 79 79 80 80 // Try to find highlight location 81 81 NSString *highlightPath = [[defaults persistentDomainForName:myDomain] valueForKey:@"pathHL"]; 82 82 if (highlightPath == nil) { … … NSData *colorizeURL(CFBundleRef bundle, CFURLRef url, int *status, int thumbnail 91 91 } 92 92 [userDefaults release]; 93 93 } 94 94 95 95 [env addEntriesFromDictionary:[NSDictionary dictionaryWithObjectsAndKeys: 96 96 #ifdef DEBUG 97 97 @"1", @"qlcc_debug", … … NSData *colorizeURL(CFBundleRef bundle, CFURLRef url, int *status, int thumbnail 99 99 @"10", @"fontSizePoints", 100 100 @"Menlo", @"font", 101 101 @"edit-xcode", @"hlTheme", 102 // @"-lz -j 3 -t 4 --kw-case=capitalize ", @"extraHLFlags", 103 @"-t 4 --kw-case=capitalize ", @"extraHLFlags", 102 // @"-lz -j 3 -t 4 --kw-case=capitalize ", @"extraHLFlags", 103 @"-t 4 --kw-case=capitalize ", @"extraHLFlags", 104 104 @"/opt/local/bin/highlight", @"pathHL", 105 105 @"", @"maxFileSize", 106 @"UTF-8", @"textEncoding", 106 @"UTF-8", @"textEncoding", 107 107 @"UTF-8", @"webkitTextEncoding", nil]]; 108 108 109 109 [env addEntriesFromDictionary:[defaults persistentDomainForName:myDomain]]; 110 110 111 111 // This overrides hlTheme if hlThumbTheme is set and we're generating a thumbnail 112 112 // (This way we won't irritate people with existing installs) 113 113 // Admittedly, it's a little shady, overriding the set value, but I'd rather complicate the compiled code … … NSData *colorizeURL(CFBundleRef bundle, CFURLRef url, int *status, int thumbnail 119 119 @"'%@/colorize.sh' '%@' '%@' %s", 120 120 rsrcEsc, rsrcEsc, [targetEsc stringByReplacingOccurrencesOfString:@"'" withString:@"'\\''"], thumbnail ? "1" : "0"]; 121 121 n8log(@"cmd = %@", cmd); 122 122 123 123 output = runTask(cmd, env, status); 124 124 if (*status != 0) { 125 NSLog(@"QLColorCode: colorize.sh failed with exit code %d. Command was (%@).", 125 NSLog(@"QLColorCode: colorize.sh failed with exit code %d. Command was (%@).", 126 126 *status, cmd); 127 127 } 128 128 return output; -
src/GeneratePreviewForURL.m
diff --git a/src/GeneratePreviewForURL.m b/src/GeneratePreviewForURL.m index 087e89b..f3b991b 100644
a b 1 /* This code is copyright Nathaniel Gray, licensed under the GPL v3. 1 /* This code is copyright Nathaniel Gray, licensed under the GPL v3. 2 2 See LICENSE.txt for details. */ 3 3 4 4 #import <CoreFoundation/CoreFoundation.h> 5 5 #import <CoreServices/CoreServices.h> 6 6 #import <Foundation/Foundation.h> 7 7 #import <QuickLook/QuickLook.h> 8 #import <AppKit/AppKit.h> 8 9 #import "Common.h" 9 10 10 11 11 12 /* ----------------------------------------------------------------------------- 12 13 Generate a preview for file 13 14 14 15 This function's job is to create preview for designated file 15 16 ----------------------------------------------------------------------------- */ 16 17 17 OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, 18 CFURLRef url, CFStringRef contentTypeUTI, 18 OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, 19 CFURLRef url, CFStringRef contentTypeUTI, 19 20 CFDictionaryRef options) 20 21 { 21 22 #ifdef DEBUG … … OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, 24 25 n8log(@"Generating Preview"); 25 26 if (QLPreviewRequestIsCancelled(preview)) 26 27 return noErr; 27 28 28 29 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 29 30 30 31 // Invoke colorize.sh 31 32 CFBundleRef bundle = QLPreviewRequestGetGeneratorBundle(preview); 32 33 int status; 33 34 NSData *output = colorizeURL(bundle, url, &status, 0); 34 n8log(@"Generated preview html page in %.3f sec", 35 n8log(@"Generated preview html page in %.3f sec", 35 36 -[startDate timeIntervalSinceNow] ); 36 37 38 NSData *rtf = nil; 39 NSUserDefaults *defaults = [[NSUserDefaults alloc] initWithSuiteName:myDomain]; 40 BOOL use_rtf = [defaults boolForKey:@"rtfPreview"]; 41 [defaults release]; 42 43 if (use_rtf) { 44 NSDictionary *attrs; 45 NSAttributedString *string = [[NSAttributedString alloc] initWithHTML:output documentAttributes:&attrs]; 46 NSRange range = NSMakeRange(0, [string length]); 47 rtf = [string RTFFromRange:range documentAttributes:attrs]; 48 [string release]; 49 } 50 37 51 if (status != 0 || QLPreviewRequestIsCancelled(preview)) { 38 52 #ifndef DEBUG 39 53 goto done; 40 54 #endif 41 55 } 42 56 // Now let WebKit do its thing 43 NSString *textEncoding = [[NSUserDefaults standardUserDefaults] 57 NSString *textEncoding = [[NSUserDefaults standardUserDefaults] 44 58 stringForKey:@"webkitTextEncoding"]; 45 59 if (!textEncoding || [textEncoding length] == 0) 46 textEncoding = @"UTF-8"; 47 CFDictionaryRef properties = 48 (CFDictionaryRef)[NSDictionary dictionaryWithObject:textEncoding 60 textEncoding = @"UTF-8"; 61 CFDictionaryRef properties = 62 (CFDictionaryRef)[NSDictionary dictionaryWithObject:textEncoding 49 63 forKey:(NSString *)kQLPreviewPropertyTextEncodingNameKey]; 50 QLPreviewRequestSetDataRepresentation(preview, (CFDataRef)output, 51 //kUTTypePlainText, 52 kUTTypeHTML, 53 properties); 54 64 65 if (use_rtf) 66 QLPreviewRequestSetDataRepresentation(preview, (CFDataRef)rtf, kUTTypeRTF, properties); 67 else 68 QLPreviewRequestSetDataRepresentation(preview, (CFDataRef)output, kUTTypeHTML, properties); 69 55 70 #ifndef DEBUG 56 71 done: 57 72 #endif -
src/GenerateThumbnailForURL.m
diff --git a/src/GenerateThumbnailForURL.m b/src/GenerateThumbnailForURL.m index f9c5208..691eee6 100644
a b 14 14 This function's job is to create thumbnail for designated file as fast as possible 15 15 ----------------------------------------------------------------------------- */ 16 16 17 OSStatus 18 GenerateThumbnailForURL(void *thisInterface, 19 QLThumbnailRequestRef thumbnail, 20 CFURLRef url, 21 CFStringRef contentTypeUTI, 22 CFDictionaryRef options, 17 OSStatus 18 GenerateThumbnailForURL(void *thisInterface, 19 QLThumbnailRequestRef thumbnail, 20 CFURLRef url, 21 CFStringRef contentTypeUTI, 22 CFDictionaryRef options, 23 23 CGSize maxSize) 24 24 { 25 25 n8log(@"Generating Thumbnail"); … … GenerateThumbnailForURL(void *thisInterface, 31 31 #ifdef DEBUG 32 32 NSDate *startDate = [NSDate date]; 33 33 #endif 34 35 // Render as though there is an 600x800 window, and fill the thumbnail 34 35 // Render as though there is an 600x800 window, and fill the thumbnail 36 36 // vertically. This code could be more general. I'm assuming maxSize is 37 37 // a square, though nothing horrible should happen if it isn't. 38 38 39 39 NSRect renderRect = NSMakeRect(0.0, 0.0, 600.0, 800.0); 40 40 float scale = (float)(maxSize.height/800.0); 41 41 NSSize scaleSize = NSMakeSize(scale, scale); 42 42 CGSize thumbSize = NSSizeToCGSize( 43 NSMakeSize((maxSize.width * (600.0/800.0)), 43 NSMakeSize((maxSize.width * (600.0/800.0)), 44 44 maxSize.height)); 45 45 46 46 /* Based on example code from quicklook-dev mailing list */ … … GenerateThumbnailForURL(void *thisInterface, 63 63 WebView* webView = [[WebView alloc] initWithFrame:renderRect]; 64 64 [webView scaleUnitSquareToSize:scaleSize]; 65 65 [[[webView mainFrame] frameView] setAllowsScrolling:NO]; 66 66 67 67 [[webView mainFrame] loadData:data MIMEType:@"text/html" 68 68 textEncodingName:@"UTF-8" baseURL:nil]; 69 69 70 70 while([webView isLoading]) { 71 71 CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true); 72 72 } 73 73 74 74 // Get a context to render into 75 CGContextRef context = 75 CGContextRef context = 76 76 QLThumbnailRequestCreateContext(thumbnail, thumbSize, false, NULL); 77 77 78 78 if(context != NULL) { 79 NSGraphicsContext* nsContext = 79 NSGraphicsContext* nsContext = 80 80 [NSGraphicsContext 81 graphicsContextWithGraphicsPort:(void *)context 81 graphicsContextWithGraphicsPort:(void *)context 82 82 flipped:[webView isFlipped]]; 83 83 84 84 [webView displayRectIgnoringOpacity:[webView bounds] 85 85 inContext:nsContext]; 86 86 87 87 QLThumbnailRequestFlushContext(thumbnail, context); 88 88 89 89 CFRelease(context); 90 90 } 91 91 [webView release]; 92 92 93 93 #ifndef DEBUG 94 94 done: 95 95 #endif … … done: 100 100 return noErr; 101 101 } 102 102 103 void CancelThumbnailGeneration(void* thisInterface, 103 void CancelThumbnailGeneration(void* thisInterface, 104 104 QLThumbnailRequestRef thumbnail) 105 105 { 106 106 // implement only if supported -
src/colorize.sh
diff --git a/src/colorize.sh b/src/colorize.sh index 202af95..526c3f5 100755
a b 4 4 # This code is licensed under the GPL v3. See LICENSE.txt for details. 5 5 # 6 6 # Copyright 2007 Nathaniel Gray. 7 # Copyright 2012-201 6Anthony Gelibert.7 # Copyright 2012-2018 Anthony Gelibert. 8 8 # 9 9 # Expects $1 = path to resources dir of bundle 10 10 # $2 = name of file to colorize … … esac 123 123 debug "Resolved ${target} to language $lang" 124 124 125 125 go4it () { 126 cmdOpts=( ${plugin} --plug-in outhtml_codefold --syntax=${lang} --quiet --include-style --font=${font} --font-size=${fontSizePoints} --style=${hlTheme} --encoding=${textEncoding} ${=extraHLFlags} --validate-input)126 cmdOpts=(--plug-in reduce_filesize ${plugin} --plug-in outhtml_codefold --syntax=${lang} --quiet --include-style --font=${font} --font-size=${fontSizePoints} --style=${hlTheme} --encoding=${textEncoding} ${=extraHLFlags} --validate-input) 127 127 128 128 debug "Generating the preview" 129 if [ ${thumb}= "1" ]; then129 if [ "${thumb}" = "1" ]; then 130 130 ${reader} | head -n 100 | head -c 20000 | ${cmd} ${cmdOpts} && exit 0 131 131 elif [ -n "${maxFileSize}" ]; then 132 132 ${reader} | head -c ${maxFileSize} | ${cmd} -T "${target}" ${cmdOpts} && exit 0