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  
     12.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
     92.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
     142.0.8:
     15    * Remove bash_ref_linuxmanpages_com plugin.
     16
    1172.0.7:
    218    * Correct autodetect path on 10.11 (thanks @cc941201).
    319    * Correct LaTeX and Arduino support.
  • Info.plist

    diff --git a/Info.plist b/Info.plist
    index 6fa78d0..2c46e89 100644
    a b  
    1212                        <key>LSItemContentTypes</key>
    1313                        <array>
    1414                                <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>
    1519                                <string>public.css</string>
    1620                                <string>com.apple.applescript.script</string>
    1721                                <string>public.xml</string>
     
    2125                                <string>com.sun.java-class</string>
    2226                                <string>org.vim.vim-script</string>
    2327                                <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>
    2434                        </array>
    2535                </dict>
    2636        </array>
     
    255265                        <key>UTTypeConformsTo</key>
    256266                        <array>
    257267                                <string>public.source-code</string>
     268                                <string>dyn.ah62d4rv4ge81g6pq</string>
    258269                        </array>
    259270                        <key>UTTypeDescription</key>
    260271                        <string>SQL Source File</string>
     
    10351046                                </array>
    10361047                        </dict>
    10371048                </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>
    10381083        </array>
    10391084</dict>
    10401085</plist>
  • QLColorCode.xcodeproj/project.pbxproj

    diff --git a/QLColorCode.xcodeproj/project.pbxproj b/QLColorCode.xcodeproj/project.pbxproj
    index 08bde83..d3f1bb1 100644
    a b  
    2424/* Begin PBXBuildFile section */
    2525                0ECBBA6C0CFCA37500416538 /* QLColorCode.qlgenerator in Copy to Library */ = {isa = PBXBuildFile; fileRef = 8D576316048677EA00EA77CD /* QLColorCode.qlgenerator */; };
    2626                8D576314048677EA00EA77CD /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0AA1909FFE8422F4C02AAC07 /* CoreFoundation.framework */; };
    27                 8D5B49A804867FD3000E48DA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8D5B49A704867FD3000E48DA /* InfoPlist.strings */; };
    2827                C86B05270671AA6E00DD9006 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C86B05260671AA6E00DD9006 /* CoreServices.framework */; };
    2928                EA43671C15F6BF9C009DA6C0 /* colorize.sh in Resources */ = {isa = PBXBuildFile; fileRef = EA43671615F6BF9C009DA6C0 /* colorize.sh */; };
    3029                EA43671D15F6BF9C009DA6C0 /* Common.h in Headers */ = {isa = PBXBuildFile; fileRef = EA43671715F6BF9C009DA6C0 /* Common.h */; };
     
    206205                089C1669FE841209C02AAC07 /* Project object */ = {
    207206                        isa = PBXProject;
    208207                        attributes = {
    209                                 LastUpgradeCheck = 0730;
     208                                LastUpgradeCheck = 0940;
    210209                        };
    211210                        buildConfigurationList = 2CA326220896AD4900168862 /* Build configuration list for PBXProject "QLColorCode" */;
    212211                        compatibilityVersion = "Xcode 3.2";
     
    233232                        isa = PBXResourcesBuildPhase;
    234233                        buildActionMask = 2147483647;
    235234                        files = (
    236                                 8D5B49A804867FD3000E48DA /* InfoPlist.strings in Resources */,
    237235                                EA43671C15F6BF9C009DA6C0 /* colorize.sh in Resources */,
    238236                                EA43672515F6C00B009DA6C0 /* English.lproj in Resources */,
    239237                                EA43672F15F6C1B8009DA6C0 /* CHANGELOG in Resources */,
     
    297295                };
    298296/* End PBXTargetDependency section */
    299297
    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 
    311298/* Begin XCBuildConfiguration section */
    312299                0E0E34EA0D0097020086C1E6 /* Debug */ = {
    313300                        isa = XCBuildConfiguration;
    314301                        buildSettings = {
     302                                CLANG_ENABLE_OBJC_WEAK = YES;
    315303                                COMBINE_HIDPI_IMAGES = YES;
    316304                                COPY_PHASE_STRIP = NO;
    317305                                GCC_DYNAMIC_NO_PIC = NO;
     
    325313                0E0E34EB0D0097020086C1E6 /* Release */ = {
    326314                        isa = XCBuildConfiguration;
    327315                        buildSettings = {
     316                                CLANG_ENABLE_OBJC_WEAK = YES;
    328317                                COMBINE_HIDPI_IMAGES = YES;
    329318                                COPY_PHASE_STRIP = YES;
    330319                                DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
     
    338327                2CA3261F0896AD4900168862 /* Debug */ = {
    339328                        isa = XCBuildConfiguration;
    340329                        buildSettings = {
     330                                CLANG_ENABLE_OBJC_WEAK = YES;
    341331                                COMBINE_HIDPI_IMAGES = YES;
    342332                                OTHER_CFLAGS = "-DDEBUG";
    343333                        };
     
    346336                2CA326200896AD4900168862 /* Release */ = {
    347337                        isa = XCBuildConfiguration;
    348338                        buildSettings = {
     339                                CLANG_ENABLE_OBJC_WEAK = YES;
    349340                                COMBINE_HIDPI_IMAGES = YES;
    350341                        };
    351342                        name = Release;
     
    353344                2CA326230896AD4900168862 /* Debug */ = {
    354345                        isa = XCBuildConfiguration;
    355346                        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;
    356351                                CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES;
    357352                                CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES;
    358353                                CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES;
    359354                                CLANG_ENABLE_MODULES = YES;
     355                                CLANG_UNDEFINED_BEHAVIOR_SANITIZER_INTEGER = YES;
     356                                CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES;
    360357                                CLANG_WARN_ASSIGN_ENUM = YES;
     358                                CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
     359                                CLANG_WARN_COMMA = YES;
     360                                CLANG_WARN_CXX0X_EXTENSIONS = YES;
    361361                                CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
    362362                                CLANG_WARN_EMPTY_BODY = YES;
    363363                                CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES;
     364                                CLANG_WARN_INFINITE_RECURSION = YES;
    364365                                CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES;
    365366                                CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
    366367                                CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
    367368                                CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
    368369                                CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES;
     370                                CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
     371                                CLANG_WARN_STRICT_PROTOTYPES = YES;
    369372                                CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
     373                                CLANG_WARN_SUSPICIOUS_MOVE = YES;
    370374                                CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE;
    371375                                CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
    372376                                COPY_PHASE_STRIP = NO;
    373                                 CURRENT_PROJECT_VERSION = 2.0.7;
     377                                CURRENT_PROJECT_VERSION = 2.1.0;
    374378                                DEAD_CODE_STRIPPING = YES;
    375379                                DSTROOT = "/export/tmp/$(PROJECT_NAME).dst";
    376380                                ENABLE_STRICT_OBJC_MSGSEND = YES;
    377381                                ENABLE_TESTABILITY = YES;
     382                                GCC_NO_COMMON_BLOCKS = YES;
    378383                                GCC_OPTIMIZATION_LEVEL = 0;
    379384                                GCC_PREPROCESSOR_DEFINITIONS = DEBUG;
    380                                 GCC_VERSION = "";
     385                                GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
    381386                                GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
    382387                                GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
    383388                                GCC_WARN_ABOUT_RETURN_TYPE = YES;
    384389                                GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
     390                                GCC_WARN_PEDANTIC = YES;
    385391                                GCC_WARN_SHADOW = YES;
    386392                                GCC_WARN_SIGN_COMPARE = YES;
    387393                                GCC_WARN_STRICT_SELECTOR_MATCH = YES;
     
    393399                                GCC_WARN_UNUSED_PARAMETER = NO;
    394400                                GCC_WARN_UNUSED_VARIABLE = YES;
    395401                                INFOPLIST_FILE = Info.plist;
    396                                 INSTALL_PATH = /Library/QuickLook;
    397                                 MACOSX_DEPLOYMENT_TARGET = 10.11;
     402                                MACOSX_DEPLOYMENT_TARGET = 10.13;
    398403                                ONLY_ACTIVE_ARCH = YES;
    399404                                PRODUCT_BUNDLE_IDENTIFIER = org.n8gray.qlcolorcode;
    400405                                PRODUCT_NAME = QLColorCode;
    401406                                RUN_CLANG_STATIC_ANALYZER = YES;
    402407                                SDKROOT = macosx;
    403                                 VALID_ARCHS = x86_64;
    404408                                WRAPPER_EXTENSION = qlgenerator;
    405409                        };
    406410                        name = Debug;
     
    408412                2CA326240896AD4900168862 /* Release */ = {
    409413                        isa = XCBuildConfiguration;
    410414                        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;
    411419                                CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES;
    412420                                CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES;
    413421                                CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES;
    414422                                CLANG_ENABLE_MODULES = YES;
     423                                CLANG_UNDEFINED_BEHAVIOR_SANITIZER_INTEGER = YES;
     424                                CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES;
    415425                                CLANG_WARN_ASSIGN_ENUM = YES;
     426                                CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
     427                                CLANG_WARN_COMMA = YES;
     428                                CLANG_WARN_CXX0X_EXTENSIONS = YES;
    416429                                CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
    417430                                CLANG_WARN_EMPTY_BODY = YES;
    418431                                CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES;
     432                                CLANG_WARN_INFINITE_RECURSION = YES;
    419433                                CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES;
    420434                                CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
    421435                                CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
    422436                                CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
    423437                                CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES;
     438                                CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
     439                                CLANG_WARN_STRICT_PROTOTYPES = YES;
    424440                                CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
     441                                CLANG_WARN_SUSPICIOUS_MOVE = YES;
    425442                                CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE;
    426443                                CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
    427                                 CURRENT_PROJECT_VERSION = 2.0.7;
     444                                CURRENT_PROJECT_VERSION = 2.1.0;
    428445                                DEAD_CODE_STRIPPING = YES;
    429446                                DSTROOT = "/export/tmp/$(PROJECT_NAME).dst";
    430447                                ENABLE_STRICT_OBJC_MSGSEND = YES;
    431448                                GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
    432                                 GCC_VERSION = "";
     449                                GCC_NO_COMMON_BLOCKS = YES;
     450                                GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
    433451                                GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
    434452                                GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
    435453                                GCC_WARN_ABOUT_RETURN_TYPE = YES;
    436454                                GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
     455                                GCC_WARN_PEDANTIC = YES;
    437456                                GCC_WARN_SHADOW = YES;
    438457                                GCC_WARN_SIGN_COMPARE = YES;
    439458                                GCC_WARN_STRICT_SELECTOR_MATCH = YES;
     
    445464                                GCC_WARN_UNUSED_PARAMETER = NO;
    446465                                GCC_WARN_UNUSED_VARIABLE = YES;
    447466                                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;
    451468                                ONLY_ACTIVE_ARCH = YES;
    452469                                PRODUCT_BUNDLE_IDENTIFIER = org.n8gray.qlcolorcode;
    453470                                PRODUCT_NAME = QLColorCode;
    454471                                RUN_CLANG_STATIC_ANALYZER = YES;
    455472                                SDKROOT = macosx;
    456                                 VALID_ARCHS = x86_64;
    457473                                WRAPPER_EXTENSION = qlgenerator;
    458474                        };
    459475                        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  
    11<?xml version="1.0" encoding="UTF-8"?>
    22<Scheme
    3    LastUpgradeVersion = "0700"
     3   LastUpgradeVersion = "0940"
    44   version = "1.3">
    55   <BuildAction
    66      parallelizeBuildables = "YES"
  • README.md

    diff --git a/README.md b/README.md
    index 93cc961..8a6b1f6 100644
    a b  
    77This is a Quick Look plugin that renders source code with syntax highlighting,
    88using the [Highlight library](http://www.andre-simon.de).
    99
     10To install Highlight, [download the library manualy](http://www.andre-simon.de/zip/download.php), or use homebrew `brew install highlight`
     11
    1012To install the plugin, just drag it to `~/Library/QuickLook`.
    1113You may need to create that folder if it doesn't already exist.
    1214
    Setting the text encoding (default is `UTF-8`). Two settings are required. The 
    2022
    2123    defaults write org.n8gray.QLColorCode textEncoding UTF-16
    2224    defaults write org.n8gray.QLColorCode webkitTextEncoding UTF-16
    23    
     25
    2426Setting the font (default is `Menlo`):
    2527
    2628    defaults write org.n8gray.QLColorCode font Monaco
    27    
     29
    2830Setting the font size (default is `10`):
    2931
    3032    defaults write org.n8gray.QLColorCode fontSizePoints 9
    31    
     33
    3234Setting the color style (default is `edit-xcode`, see [all available themes](http://www.andre-simon.de/dokuwiki/doku.php?id=theme_examples)):
    3335
    3436    defaults write org.n8gray.QLColorCode hlTheme ide-xcode
    35    
     37
    3638Setting the thumbnail color style (deactivated by default):
    3739
    3840    defaults write org.n8gray.QLColorCode hlThumbTheme ide-xcode
    Setting the maximum size (in bytes, deactivated by default) for previewed files: 
    4446Setting any extra command-line flags for Highlight (see below):
    4547
    4648    defaults write org.n8gray.QLColorCode extraHLFlags '-l -W'
    47    
     49
    4850Here are some useful 'highlight' command-line flags (from the man page):
    4951
    5052       -F, --reformat=<style>
    Here are some useful 'highlight' command-line flags (from the man page): 
    5759       -j, --line-number-length=<num>
    5860              line number length incl. left padding
    5961
    60        -l, --linenumbers
     62       -l, --line-numbers
    6163              print line numbers in output file
    6264
    6365       -t  --replace-tabs=<num>
    Here are some useful 'highlight' command-line flags (from the man page): 
    7779              control case of case insensitive keywords
    7880
    7981**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
     85It is also possible to have the HTML preview converted to RTF.  Using RTF
     86allows the contents of the file to be displayed instead of an icon -- similar
     87to QLStephen.
     88
     89    defaults write org.n8gray.QLColorCode rtfRender true
    8290
    8391## Additional information
    8492
    Here are some useful 'highlight' command-line flags (from the man page): 
    8896
    8997QLColorCode decompiles some formats:
    9098
    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`.
    92100- **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`.
    94102
    95103### Highlight
    96104
    QLColorCode enables some Highlight plugins : 
    103111- C/C++: `cpp_syslog`, `cpp_ref_cplusplus_com` and `cpp_ref_local_includes`.
    104112- Perl: `perl_ref_perl_org`.
    105113- Python: `python_ref_python_org`.
    106 - Shell: `bash_functions` and `bash_ref_linuxmanpages_com`.
     114- Shell: `bash_functions`.
    107115- Scala: `scala_ref_scala_lang_org`.
    108116
    109117#### Handled languages
    110 Highlight can handle lots and lots of languages, but this plugin will only be 
     118Highlight can handle lots and lots of languages, but this plugin will only be
    111119invoked 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 
     120only knows about a limited number of languages, I've added Universal Type
     121Identifier (UTI) declarations for several "interesting" languages.  If I've
    114122missed your favorite language, take a look at the Info.plist file inside the
    115123plugin bundle and look for the UTImportedTypeDeclarations section.  I
    116124haven't added all the languages that Highlight can handle because it's rumored
    117125that 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 
     126cause problems.  Note that if you do edit the Info.plist file you need to
    119127nudge the system to tell it something has changed.  Moving the plugin to the
    120128desktop then back to its installed location should do the trick.
    121129
    122130As an aside, by changing colorize.sh you can use this plugin to render any file
    123131type that you can convert to HTML. Have fun, and let me know if you do anything
    124132cool!
     133
     134##### Adding Language Types
     135
     136If QLColorCode doesn't display PHP and JavaScript code properly, their types may
     137need to be added to Info.plist.  Finding the right type string to use is the
     138tricky part.  Getting the type strings and getting Info.plist edits to take effect
     139is easy by following the steps below, which explain how to add support for PHP:
     140
     1410. 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 
     1550. 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 
     1630. 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
     1700. Add an item for `public.php-script`, the type string found in the first step.
     171
     1720. Save the updated Info.plist file.
     173
     1740. 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
     178The Info.plist included with this version of QLColorCode already contains types
     179for PHP and JavaScript code, but these steps show how easy it is to add other
     180types.  (Maybe somebody will develop a Preference Pane for QLColorCode to make
     181this 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  
    11/* Localized versions of Info.plist keys */
    22
    3 CFBundleGetInfoString = "QLColorCode version 2.0.7, Copyright (c) 2016 Nathaniel Gray, Anthony Gelibert.";
    4 NSHumanReadableCopyright = "Copyright (c) 2016 Nathaniel Gray, Anthony Gelibert.";
     3CFBundleGetInfoString = "QLColorCode version 2.1.0, Copyright (c) 2018 Nathaniel Gray, Anthony Gelibert.";
     4NSHumanReadableCopyright = "Copyright (c) 2018 Nathaniel Gray, Anthony Gelibert.";
    55
  • src/Common.m

    diff --git a/src/Common.m b/src/Common.m
    index 1c830bd..5efca97 100644
    a b  
    44 *
    55 *  Created by Nathaniel Gray on 12/6/07.
    66 *  Copyright 2007 Nathaniel Gray.
    7  * 
     7 *
    88 *  Modified by Anthony Gelibert on 9/5/12.
    99 *  Copyright 2012 Anthony Gelibert.
    1010 */
    NSData *runTask(NSString *script, NSDictionary *env, int *exitCode) { 
    2323    [task setEnvironment:env];
    2424    [task setLaunchPath:@"/bin/sh"];
    2525    [task setArguments:[NSArray arrayWithObjects:@"-c", script, nil]];
    26    
     26
    2727    NSPipe *pipe;
    2828    pipe = [NSPipe pipe];
    2929    [task setStandardOutput: pipe];
    3030    // Let stderr go to the usual place
    3131    //[task setStandardError: pipe];
    32    
     32
    3333    NSFileHandle *file;
    3434    file = [pipe fileHandleForReading];
    35    
     35
    3636    [task launch];
    37    
     37
    3838    NSData *data;
    3939    data = [file readDataToEndOfFile];
    4040    [task waitUntilExit];
    41    
     41
    4242    *exitCode = [task terminationStatus];
    4343    [task release];
    4444    /* The docs claim this isn't needed, but we leak descriptors otherwise */
    4545    [file closeFile];
    4646    /*[pipe release];*/
    47    
     47
    4848    return data;
    4949}
    5050
    NSData *colorizeURL(CFBundleRef bundle, CFURLRef url, int *status, int thumbnail 
    6666    n8log(@"url = %@", url);
    6767    NSString *targetEsc = pathOfURL(url);
    6868    n8log(@"targetEsc = %@", targetEsc);
    69    
     69
    7070    // Set up preferences
    7171    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    72    
     72
    7373    NSMutableDictionary *env = [NSMutableDictionary dictionaryWithDictionary:
    7474                                [[NSProcessInfo processInfo] environment]];
    7575
    7676    NSString *path = [env objectForKey: @"PATH"];
    7777    NSString *newPath = [path stringByAppendingString: @":/usr/local/bin:/usr/local/sbin"];
    7878    [env setObject: newPath forKey: @"PATH"];
    79    
     79
    8080    // Try to find highlight location
    8181    NSString *highlightPath = [[defaults persistentDomainForName:myDomain] valueForKey:@"pathHL"];
    8282    if (highlightPath == nil) {
    NSData *colorizeURL(CFBundleRef bundle, CFURLRef url, int *status, int thumbnail 
    9191        }
    9292        [userDefaults release];
    9393    }
    94    
     94
    9595    [env addEntriesFromDictionary:[NSDictionary dictionaryWithObjectsAndKeys:
    9696#ifdef DEBUG
    9797                                   @"1", @"qlcc_debug",
    NSData *colorizeURL(CFBundleRef bundle, CFURLRef url, int *status, int thumbnail 
    9999                                   @"10", @"fontSizePoints",
    100100                                   @"Menlo", @"font",
    101101                                   @"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",
    104104                                   @"/opt/local/bin/highlight", @"pathHL",
    105105                                   @"", @"maxFileSize",
    106                                    @"UTF-8", @"textEncoding", 
     106                                   @"UTF-8", @"textEncoding",
    107107                                   @"UTF-8", @"webkitTextEncoding", nil]];
    108108
    109109    [env addEntriesFromDictionary:[defaults persistentDomainForName:myDomain]];
    110    
     110
    111111    // This overrides hlTheme if hlThumbTheme is set and we're generating a thumbnail
    112112    // (This way we won't irritate people with existing installs)
    113113    // 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 
    119119                     @"'%@/colorize.sh' '%@' '%@' %s",
    120120                     rsrcEsc, rsrcEsc, [targetEsc stringByReplacingOccurrencesOfString:@"'" withString:@"'\\''"], thumbnail ? "1" : "0"];
    121121    n8log(@"cmd = %@", cmd);
    122    
     122
    123123    output = runTask(cmd, env, status);
    124124    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 (%@).",
    126126              *status, cmd);
    127127    }
    128128    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.
    22    See LICENSE.txt for details. */
    33
    44#import <CoreFoundation/CoreFoundation.h>
    55#import <CoreServices/CoreServices.h>
    66#import <Foundation/Foundation.h>
    77#import <QuickLook/QuickLook.h>
     8#import <AppKit/AppKit.h>
    89#import "Common.h"
    910
    1011
    1112/* -----------------------------------------------------------------------------
    1213 Generate a preview for file
    13  
     14
    1415 This function's job is to create preview for designated file
    1516 ----------------------------------------------------------------------------- */
    1617
    17 OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, 
    18                                CFURLRef url, CFStringRef contentTypeUTI, 
     18OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview,
     19                               CFURLRef url, CFStringRef contentTypeUTI,
    1920                               CFDictionaryRef options)
    2021{
    2122#ifdef DEBUG
    OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, 
    2425    n8log(@"Generating Preview");
    2526    if (QLPreviewRequestIsCancelled(preview))
    2627        return noErr;
    27    
     28
    2829    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    29    
     30
    3031    // Invoke colorize.sh
    3132    CFBundleRef bundle = QLPreviewRequestGetGeneratorBundle(preview);
    3233    int status;
    3334    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",
    3536          -[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
    3751    if (status != 0 || QLPreviewRequestIsCancelled(preview)) {
    3852#ifndef DEBUG
    3953        goto done;
    4054#endif
    4155    }
    4256    // Now let WebKit do its thing
    43     NSString *textEncoding = [[NSUserDefaults standardUserDefaults] 
     57    NSString *textEncoding = [[NSUserDefaults standardUserDefaults]
    4458                              stringForKey:@"webkitTextEncoding"];
    4559    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
    4963                                                         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
    5570#ifndef DEBUG
    5671done:
    5772#endif
  • src/GenerateThumbnailForURL.m

    diff --git a/src/GenerateThumbnailForURL.m b/src/GenerateThumbnailForURL.m
    index f9c5208..691eee6 100644
    a b  
    1414   This function's job is to create thumbnail for designated file as fast as possible
    1515   ----------------------------------------------------------------------------- */
    1616
    17 OSStatus 
    18 GenerateThumbnailForURL(void *thisInterface, 
    19                                  QLThumbnailRequestRef thumbnail, 
    20                                  CFURLRef url, 
    21                                  CFStringRef contentTypeUTI, 
    22                                  CFDictionaryRef options, 
     17OSStatus
     18GenerateThumbnailForURL(void *thisInterface,
     19                                 QLThumbnailRequestRef thumbnail,
     20                                 CFURLRef url,
     21                                 CFStringRef contentTypeUTI,
     22                                 CFDictionaryRef options,
    2323                                 CGSize maxSize)
    2424{
    2525    n8log(@"Generating Thumbnail");
    GenerateThumbnailForURL(void *thisInterface, 
    3131#ifdef DEBUG
    3232    NSDate *startDate = [NSDate date];
    3333#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
    3636    // vertically.  This code could be more general.  I'm assuming maxSize is
    3737    // a square, though nothing horrible should happen if it isn't.
    38    
     38
    3939    NSRect renderRect = NSMakeRect(0.0, 0.0, 600.0, 800.0);
    4040    float scale = (float)(maxSize.height/800.0);
    4141    NSSize scaleSize = NSMakeSize(scale, scale);
    4242    CGSize thumbSize = NSSizeToCGSize(
    43                             NSMakeSize((maxSize.width * (600.0/800.0)), 
     43                            NSMakeSize((maxSize.width * (600.0/800.0)),
    4444                                       maxSize.height));
    4545
    4646    /* Based on example code from quicklook-dev mailing list */
    GenerateThumbnailForURL(void *thisInterface, 
    6363    WebView* webView = [[WebView alloc] initWithFrame:renderRect];
    6464    [webView scaleUnitSquareToSize:scaleSize];
    6565    [[[webView mainFrame] frameView] setAllowsScrolling:NO];
    66    
     66
    6767    [[webView mainFrame] loadData:data MIMEType:@"text/html"
    6868                 textEncodingName:@"UTF-8" baseURL:nil];
    69    
     69
    7070    while([webView isLoading]) {
    7171        CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true);
    7272    }
    73    
     73
    7474    // Get a context to render into
    75     CGContextRef context = 
     75    CGContextRef context =
    7676        QLThumbnailRequestCreateContext(thumbnail, thumbSize, false, NULL);
    77    
     77
    7878    if(context != NULL) {
    79         NSGraphicsContext* nsContext = 
     79        NSGraphicsContext* nsContext =
    8080                    [NSGraphicsContext
    81                         graphicsContextWithGraphicsPort:(void *)context 
     81                        graphicsContextWithGraphicsPort:(void *)context
    8282                                                flipped:[webView isFlipped]];
    83        
     83
    8484        [webView displayRectIgnoringOpacity:[webView bounds]
    8585                                  inContext:nsContext];
    86        
     86
    8787        QLThumbnailRequestFlushContext(thumbnail, context);
    88        
     88
    8989        CFRelease(context);
    9090    }
    9191    [webView release];
    92    
     92
    9393#ifndef DEBUG
    9494done:
    9595#endif
    done: 
    100100    return noErr;
    101101}
    102102
    103 void CancelThumbnailGeneration(void* thisInterface, 
     103void CancelThumbnailGeneration(void* thisInterface,
    104104                               QLThumbnailRequestRef thumbnail)
    105105{
    106106    // implement only if supported
  • src/colorize.sh

    diff --git a/src/colorize.sh b/src/colorize.sh
    index 202af95..526c3f5 100755
    a b  
    44# This code is licensed under the GPL v3.  See LICENSE.txt for details.
    55#
    66# Copyright 2007 Nathaniel Gray.
    7 # Copyright 2012-2016 Anthony Gelibert.
     7# Copyright 2012-2018 Anthony Gelibert.
    88#
    99# Expects   $1 = path to resources dir of bundle
    1010#           $2 = name of file to colorize
    esac 
    123123debug "Resolved ${target} to language $lang"
    124124
    125125go4it () {
    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)
    127127
    128128    debug "Generating the preview"
    129     if [ ${thumb} = "1" ]; then
     129    if [ "${thumb}" = "1" ]; then
    130130        ${reader} | head -n 100 | head -c 20000 | ${cmd} ${cmdOpts} && exit 0
    131131    elif [ -n "${maxFileSize}" ]; then
    132132        ${reader} | head -c ${maxFileSize} | ${cmd} -T "${target}" ${cmdOpts} && exit 0