├── .gitignore ├── LICENSE ├── PlainTextQuickLook ├── PlainTextQuickLook.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── PlainTextQuickLook │ ├── ExtensionsBlackList.plist │ ├── ExtensionsWhiteList.plist │ ├── FileNameWhiteList.plist │ ├── GeneratePreviewForURL.m │ ├── GenerateThumbnailForURL.m │ ├── Info.plist │ ├── LewFileAttributes.h │ ├── LewFileAttributes.m │ ├── filenameToBadgeMap.plist │ └── main.c ├── Podfile ├── qlmanage ├── test.gradle └── test.md └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | #Pods/ 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 独奏 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /PlainTextQuickLook/PlainTextQuickLook.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | FE7EBCEB1BF0363B001F421F /* GenerateThumbnailForURL.m in Sources */ = {isa = PBXBuildFile; fileRef = FE7EBCEA1BF0363B001F421F /* GenerateThumbnailForURL.m */; }; 11 | FE7EBCED1BF0363B001F421F /* GeneratePreviewForURL.m in Sources */ = {isa = PBXBuildFile; fileRef = FE7EBCEC1BF0363B001F421F /* GeneratePreviewForURL.m */; }; 12 | FE7EBCEF1BF0363B001F421F /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = FE7EBCEE1BF0363B001F421F /* main.c */; }; 13 | FE7EBCF71BF04B68001F421F /* PlainTextQuickLook.qlgenerator in CopyFiles */ = {isa = PBXBuildFile; fileRef = FE7EBCE71BF0363B001F421F /* PlainTextQuickLook.qlgenerator */; }; 14 | FE7EBCFE1BF07EA6001F421F /* LewFileAttributes.h in Headers */ = {isa = PBXBuildFile; fileRef = FE7EBCFC1BF07EA6001F421F /* LewFileAttributes.h */; }; 15 | FE7EBCFF1BF07EA6001F421F /* LewFileAttributes.m in Sources */ = {isa = PBXBuildFile; fileRef = FE7EBCFD1BF07EA6001F421F /* LewFileAttributes.m */; }; 16 | FE7EBD061BF18C35001F421F /* ExtensionsBlackList.plist in Resources */ = {isa = PBXBuildFile; fileRef = FE7EBD041BF18C35001F421F /* ExtensionsBlackList.plist */; }; 17 | FE7EBD071BF18C35001F421F /* FileNameWhiteList.plist in Resources */ = {isa = PBXBuildFile; fileRef = FE7EBD051BF18C35001F421F /* FileNameWhiteList.plist */; }; 18 | FE7EBD091BF19125001F421F /* FileNameToBadgeMap.plist in Resources */ = {isa = PBXBuildFile; fileRef = FE7EBD081BF19125001F421F /* FileNameToBadgeMap.plist */; }; 19 | FE7EBD0B1BF1F8C3001F421F /* ExtensionsWhiteList.plist in Resources */ = {isa = PBXBuildFile; fileRef = FE7EBD0A1BF1F8C3001F421F /* ExtensionsWhiteList.plist */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXCopyFilesBuildPhase section */ 23 | FE7EBCF61BF04B3D001F421F /* CopyFiles */ = { 24 | isa = PBXCopyFilesBuildPhase; 25 | buildActionMask = 2147483647; 26 | dstPath = "~/Library/QuickLook"; 27 | dstSubfolderSpec = 0; 28 | files = ( 29 | FE7EBCF71BF04B68001F421F /* PlainTextQuickLook.qlgenerator in CopyFiles */, 30 | ); 31 | runOnlyForDeploymentPostprocessing = 0; 32 | }; 33 | /* End PBXCopyFilesBuildPhase section */ 34 | 35 | /* Begin PBXFileReference section */ 36 | FE7EBCE71BF0363B001F421F /* PlainTextQuickLook.qlgenerator */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PlainTextQuickLook.qlgenerator; sourceTree = BUILT_PRODUCTS_DIR; }; 37 | FE7EBCEA1BF0363B001F421F /* GenerateThumbnailForURL.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GenerateThumbnailForURL.m; sourceTree = ""; }; 38 | FE7EBCEC1BF0363B001F421F /* GeneratePreviewForURL.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GeneratePreviewForURL.m; sourceTree = ""; }; 39 | FE7EBCEE1BF0363B001F421F /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = ""; }; 40 | FE7EBCF01BF0363B001F421F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 41 | FE7EBCFC1BF07EA6001F421F /* LewFileAttributes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LewFileAttributes.h; sourceTree = ""; }; 42 | FE7EBCFD1BF07EA6001F421F /* LewFileAttributes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LewFileAttributes.m; sourceTree = ""; }; 43 | FE7EBD041BF18C35001F421F /* ExtensionsBlackList.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = ExtensionsBlackList.plist; sourceTree = ""; }; 44 | FE7EBD051BF18C35001F421F /* FileNameWhiteList.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = FileNameWhiteList.plist; sourceTree = ""; }; 45 | FE7EBD081BF19125001F421F /* FileNameToBadgeMap.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = FileNameToBadgeMap.plist; sourceTree = ""; }; 46 | FE7EBD0A1BF1F8C3001F421F /* ExtensionsWhiteList.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = ExtensionsWhiteList.plist; sourceTree = ""; }; 47 | /* End PBXFileReference section */ 48 | 49 | /* Begin PBXFrameworksBuildPhase section */ 50 | FE7EBCE31BF0363B001F421F /* Frameworks */ = { 51 | isa = PBXFrameworksBuildPhase; 52 | buildActionMask = 2147483647; 53 | files = ( 54 | ); 55 | runOnlyForDeploymentPostprocessing = 0; 56 | }; 57 | /* End PBXFrameworksBuildPhase section */ 58 | 59 | /* Begin PBXGroup section */ 60 | FE7EBCDD1BF0363B001F421F = { 61 | isa = PBXGroup; 62 | children = ( 63 | FE7EBCE91BF0363B001F421F /* PlainTextQuickLook */, 64 | FE7EBCE81BF0363B001F421F /* Products */, 65 | ); 66 | sourceTree = ""; 67 | }; 68 | FE7EBCE81BF0363B001F421F /* Products */ = { 69 | isa = PBXGroup; 70 | children = ( 71 | FE7EBCE71BF0363B001F421F /* PlainTextQuickLook.qlgenerator */, 72 | ); 73 | name = Products; 74 | sourceTree = ""; 75 | }; 76 | FE7EBCE91BF0363B001F421F /* PlainTextQuickLook */ = { 77 | isa = PBXGroup; 78 | children = ( 79 | FE7EBD0A1BF1F8C3001F421F /* ExtensionsWhiteList.plist */, 80 | FE7EBD081BF19125001F421F /* FileNameToBadgeMap.plist */, 81 | FE7EBD051BF18C35001F421F /* FileNameWhiteList.plist */, 82 | FE7EBD041BF18C35001F421F /* ExtensionsBlackList.plist */, 83 | FE7EBCEA1BF0363B001F421F /* GenerateThumbnailForURL.m */, 84 | FE7EBCEC1BF0363B001F421F /* GeneratePreviewForURL.m */, 85 | FE7EBCEE1BF0363B001F421F /* main.c */, 86 | FE7EBCF01BF0363B001F421F /* Info.plist */, 87 | FE7EBCFC1BF07EA6001F421F /* LewFileAttributes.h */, 88 | FE7EBCFD1BF07EA6001F421F /* LewFileAttributes.m */, 89 | ); 90 | path = PlainTextQuickLook; 91 | sourceTree = ""; 92 | }; 93 | /* End PBXGroup section */ 94 | 95 | /* Begin PBXHeadersBuildPhase section */ 96 | FE7EBCE41BF0363B001F421F /* Headers */ = { 97 | isa = PBXHeadersBuildPhase; 98 | buildActionMask = 2147483647; 99 | files = ( 100 | FE7EBCFE1BF07EA6001F421F /* LewFileAttributes.h in Headers */, 101 | ); 102 | runOnlyForDeploymentPostprocessing = 0; 103 | }; 104 | /* End PBXHeadersBuildPhase section */ 105 | 106 | /* Begin PBXNativeTarget section */ 107 | FE7EBCE61BF0363B001F421F /* PlainTextQuickLook */ = { 108 | isa = PBXNativeTarget; 109 | buildConfigurationList = FE7EBCF31BF0363B001F421F /* Build configuration list for PBXNativeTarget "PlainTextQuickLook" */; 110 | buildPhases = ( 111 | FE7EBCE21BF0363B001F421F /* Sources */, 112 | FE7EBCE31BF0363B001F421F /* Frameworks */, 113 | FE7EBCE41BF0363B001F421F /* Headers */, 114 | FE7EBCE51BF0363B001F421F /* Resources */, 115 | FE7EBCF61BF04B3D001F421F /* CopyFiles */, 116 | ); 117 | buildRules = ( 118 | ); 119 | dependencies = ( 120 | ); 121 | name = PlainTextQuickLook; 122 | productName = PlainTextQuickLook; 123 | productReference = FE7EBCE71BF0363B001F421F /* PlainTextQuickLook.qlgenerator */; 124 | productType = "com.apple.product-type.bundle"; 125 | }; 126 | /* End PBXNativeTarget section */ 127 | 128 | /* Begin PBXProject section */ 129 | FE7EBCDE1BF0363B001F421F /* Project object */ = { 130 | isa = PBXProject; 131 | attributes = { 132 | LastUpgradeCheck = 0710; 133 | ORGANIZATIONNAME = pljhonglu; 134 | TargetAttributes = { 135 | FE7EBCE61BF0363B001F421F = { 136 | CreatedOnToolsVersion = 7.1; 137 | }; 138 | }; 139 | }; 140 | buildConfigurationList = FE7EBCE11BF0363B001F421F /* Build configuration list for PBXProject "PlainTextQuickLook" */; 141 | compatibilityVersion = "Xcode 3.2"; 142 | developmentRegion = English; 143 | hasScannedForEncodings = 0; 144 | knownRegions = ( 145 | en, 146 | ); 147 | mainGroup = FE7EBCDD1BF0363B001F421F; 148 | productRefGroup = FE7EBCE81BF0363B001F421F /* Products */; 149 | projectDirPath = ""; 150 | projectRoot = ""; 151 | targets = ( 152 | FE7EBCE61BF0363B001F421F /* PlainTextQuickLook */, 153 | ); 154 | }; 155 | /* End PBXProject section */ 156 | 157 | /* Begin PBXResourcesBuildPhase section */ 158 | FE7EBCE51BF0363B001F421F /* Resources */ = { 159 | isa = PBXResourcesBuildPhase; 160 | buildActionMask = 2147483647; 161 | files = ( 162 | FE7EBD0B1BF1F8C3001F421F /* ExtensionsWhiteList.plist in Resources */, 163 | FE7EBD091BF19125001F421F /* FileNameToBadgeMap.plist in Resources */, 164 | FE7EBD061BF18C35001F421F /* ExtensionsBlackList.plist in Resources */, 165 | FE7EBD071BF18C35001F421F /* FileNameWhiteList.plist in Resources */, 166 | ); 167 | runOnlyForDeploymentPostprocessing = 0; 168 | }; 169 | /* End PBXResourcesBuildPhase section */ 170 | 171 | /* Begin PBXSourcesBuildPhase section */ 172 | FE7EBCE21BF0363B001F421F /* Sources */ = { 173 | isa = PBXSourcesBuildPhase; 174 | buildActionMask = 2147483647; 175 | files = ( 176 | FE7EBCEB1BF0363B001F421F /* GenerateThumbnailForURL.m in Sources */, 177 | FE7EBCFF1BF07EA6001F421F /* LewFileAttributes.m in Sources */, 178 | FE7EBCED1BF0363B001F421F /* GeneratePreviewForURL.m in Sources */, 179 | FE7EBCEF1BF0363B001F421F /* main.c in Sources */, 180 | ); 181 | runOnlyForDeploymentPostprocessing = 0; 182 | }; 183 | /* End PBXSourcesBuildPhase section */ 184 | 185 | /* Begin XCBuildConfiguration section */ 186 | FE7EBCF11BF0363B001F421F /* Debug */ = { 187 | isa = XCBuildConfiguration; 188 | buildSettings = { 189 | ALWAYS_SEARCH_USER_PATHS = NO; 190 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 191 | CLANG_CXX_LIBRARY = "libc++"; 192 | CLANG_ENABLE_MODULES = YES; 193 | CLANG_ENABLE_OBJC_ARC = YES; 194 | CLANG_WARN_BOOL_CONVERSION = YES; 195 | CLANG_WARN_CONSTANT_CONVERSION = YES; 196 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 197 | CLANG_WARN_EMPTY_BODY = YES; 198 | CLANG_WARN_ENUM_CONVERSION = YES; 199 | CLANG_WARN_INT_CONVERSION = YES; 200 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 201 | CLANG_WARN_UNREACHABLE_CODE = YES; 202 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 203 | CODE_SIGN_IDENTITY = "-"; 204 | COPY_PHASE_STRIP = NO; 205 | DEBUG_INFORMATION_FORMAT = dwarf; 206 | ENABLE_STRICT_OBJC_MSGSEND = YES; 207 | ENABLE_TESTABILITY = YES; 208 | GCC_C_LANGUAGE_STANDARD = gnu99; 209 | GCC_DYNAMIC_NO_PIC = NO; 210 | GCC_NO_COMMON_BLOCKS = YES; 211 | GCC_OPTIMIZATION_LEVEL = 0; 212 | GCC_PREPROCESSOR_DEFINITIONS = ( 213 | "DEBUG=1", 214 | "$(inherited)", 215 | ); 216 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 217 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 218 | GCC_WARN_UNDECLARED_SELECTOR = YES; 219 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 220 | GCC_WARN_UNUSED_FUNCTION = YES; 221 | GCC_WARN_UNUSED_VARIABLE = YES; 222 | MACOSX_DEPLOYMENT_TARGET = 10.11; 223 | MTL_ENABLE_DEBUG_INFO = YES; 224 | ONLY_ACTIVE_ARCH = YES; 225 | SDKROOT = macosx; 226 | }; 227 | name = Debug; 228 | }; 229 | FE7EBCF21BF0363B001F421F /* Release */ = { 230 | isa = XCBuildConfiguration; 231 | buildSettings = { 232 | ALWAYS_SEARCH_USER_PATHS = NO; 233 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 234 | CLANG_CXX_LIBRARY = "libc++"; 235 | CLANG_ENABLE_MODULES = YES; 236 | CLANG_ENABLE_OBJC_ARC = YES; 237 | CLANG_WARN_BOOL_CONVERSION = YES; 238 | CLANG_WARN_CONSTANT_CONVERSION = YES; 239 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 240 | CLANG_WARN_EMPTY_BODY = YES; 241 | CLANG_WARN_ENUM_CONVERSION = YES; 242 | CLANG_WARN_INT_CONVERSION = YES; 243 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 244 | CLANG_WARN_UNREACHABLE_CODE = YES; 245 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 246 | CODE_SIGN_IDENTITY = "-"; 247 | COPY_PHASE_STRIP = NO; 248 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 249 | ENABLE_NS_ASSERTIONS = NO; 250 | ENABLE_STRICT_OBJC_MSGSEND = YES; 251 | GCC_C_LANGUAGE_STANDARD = gnu99; 252 | GCC_NO_COMMON_BLOCKS = YES; 253 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 254 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 255 | GCC_WARN_UNDECLARED_SELECTOR = YES; 256 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 257 | GCC_WARN_UNUSED_FUNCTION = YES; 258 | GCC_WARN_UNUSED_VARIABLE = YES; 259 | MACOSX_DEPLOYMENT_TARGET = 10.11; 260 | MTL_ENABLE_DEBUG_INFO = NO; 261 | SDKROOT = macosx; 262 | }; 263 | name = Release; 264 | }; 265 | FE7EBCF41BF0363B001F421F /* Debug */ = { 266 | isa = XCBuildConfiguration; 267 | buildSettings = { 268 | COMBINE_HIDPI_IMAGES = YES; 269 | INFOPLIST_FILE = PlainTextQuickLook/Info.plist; 270 | INSTALL_PATH = /Library/QuickLook; 271 | PRODUCT_BUNDLE_IDENTIFIER = com.pljhonglu.PlainTextQuickLook; 272 | PRODUCT_NAME = "$(TARGET_NAME)"; 273 | WRAPPER_EXTENSION = qlgenerator; 274 | }; 275 | name = Debug; 276 | }; 277 | FE7EBCF51BF0363B001F421F /* Release */ = { 278 | isa = XCBuildConfiguration; 279 | buildSettings = { 280 | COMBINE_HIDPI_IMAGES = YES; 281 | INFOPLIST_FILE = PlainTextQuickLook/Info.plist; 282 | INSTALL_PATH = /Library/QuickLook; 283 | PRODUCT_BUNDLE_IDENTIFIER = com.pljhonglu.PlainTextQuickLook; 284 | PRODUCT_NAME = "$(TARGET_NAME)"; 285 | WRAPPER_EXTENSION = qlgenerator; 286 | }; 287 | name = Release; 288 | }; 289 | /* End XCBuildConfiguration section */ 290 | 291 | /* Begin XCConfigurationList section */ 292 | FE7EBCE11BF0363B001F421F /* Build configuration list for PBXProject "PlainTextQuickLook" */ = { 293 | isa = XCConfigurationList; 294 | buildConfigurations = ( 295 | FE7EBCF11BF0363B001F421F /* Debug */, 296 | FE7EBCF21BF0363B001F421F /* Release */, 297 | ); 298 | defaultConfigurationIsVisible = 0; 299 | defaultConfigurationName = Release; 300 | }; 301 | FE7EBCF31BF0363B001F421F /* Build configuration list for PBXNativeTarget "PlainTextQuickLook" */ = { 302 | isa = XCConfigurationList; 303 | buildConfigurations = ( 304 | FE7EBCF41BF0363B001F421F /* Debug */, 305 | FE7EBCF51BF0363B001F421F /* Release */, 306 | ); 307 | defaultConfigurationIsVisible = 0; 308 | defaultConfigurationName = Release; 309 | }; 310 | /* End XCConfigurationList section */ 311 | }; 312 | rootObject = FE7EBCDE1BF0363B001F421F /* Project object */; 313 | } 314 | -------------------------------------------------------------------------------- /PlainTextQuickLook/PlainTextQuickLook.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /PlainTextQuickLook/PlainTextQuickLook/ExtensionsBlackList.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | lib 6 | dll 7 | a 8 | o 9 | dmg 10 | zip 11 | rar 12 | tar 13 | tgz 14 | gz 15 | tbz 16 | bz2 17 | taz 18 | z 19 | tlz 20 | lz 21 | txz 22 | xz 23 | gzip 24 | 25 | 26 | -------------------------------------------------------------------------------- /PlainTextQuickLook/PlainTextQuickLook/ExtensionsWhiteList.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | gradle 6 | 7 | 8 | -------------------------------------------------------------------------------- /PlainTextQuickLook/PlainTextQuickLook/FileNameWhiteList.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Podfile 6 | Makefile 7 | README 8 | 9 | 10 | -------------------------------------------------------------------------------- /PlainTextQuickLook/PlainTextQuickLook/GeneratePreviewForURL.m: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #import 6 | #import "LewFileAttributes.h" 7 | 8 | OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options); 9 | void CancelPreviewGeneration(void *thisInterface, QLPreviewRequestRef preview); 10 | 11 | /* ----------------------------------------------------------------------------- 12 | Generate a preview for file 13 | 14 | This function's job is to create preview for designated file 15 | ----------------------------------------------------------------------------- */ 16 | 17 | OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options) 18 | { 19 | // To complete your generator please implement the function GeneratePreviewForURL in GeneratePreviewForURL.c 20 | @autoreleasepool{ 21 | if (QLPreviewRequestIsCancelled(preview)) 22 | return noErr; 23 | 24 | CFBundleRef bundle = QLPreviewRequestGetGeneratorBundle(preview); 25 | CFURLRef bundleURL = CFBundleCopyBundleURL(bundle); 26 | LewFileAttributes *file = [LewFileAttributes fileAttributesForItemAtURL:(__bridge NSURL *)(url) bundleURL:(__bridge NSURL *)(bundleURL)]; 27 | 28 | if (!file.isTextFile) { 29 | return noErr; 30 | } 31 | 32 | QLPreviewRequestSetURLRepresentation(preview, url, kUTTypePlainText, NULL); 33 | return noErr; 34 | } 35 | } 36 | 37 | void CancelPreviewGeneration(void *thisInterface, QLPreviewRequestRef preview) 38 | { 39 | // Implement only if supported 40 | } 41 | -------------------------------------------------------------------------------- /PlainTextQuickLook/PlainTextQuickLook/GenerateThumbnailForURL.m: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #import 5 | #import "LewFileAttributes.h" 6 | 7 | OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef thumbnail, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options, CGSize maxSize); 8 | void CancelThumbnailGeneration(void *thisInterface, QLThumbnailRequestRef thumbnail); 9 | 10 | /* ----------------------------------------------------------------------------- 11 | Generate a thumbnail for file 12 | 13 | This function's job is to create thumbnail for designated file as fast as possible 14 | ----------------------------------------------------------------------------- */ 15 | 16 | OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef thumbnail, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options, CGSize maxSize) 17 | { 18 | // To complete your generator please implement the function GenerateThumbnailForURL in GenerateThumbnailForURL.c 19 | @autoreleasepool{ 20 | if (QLThumbnailRequestIsCancelled(thumbnail)) 21 | return noErr; 22 | 23 | CFBundleRef bundle = QLThumbnailRequestGetGeneratorBundle(thumbnail); 24 | CFURLRef bundleURL = CFBundleCopyBundleURL(bundle); 25 | LewFileAttributes *file = [LewFileAttributes fileAttributesForItemAtURL:(__bridge NSURL *)(url) bundleURL:(__bridge NSURL *)(bundleURL)]; 26 | if (!file.isTextFile) { 27 | return noErr; 28 | } 29 | 30 | NSDictionary *properties = @{(NSString *)kQLThumbnailPropertyExtensionKey: file.fileBadge}; 31 | 32 | QLThumbnailRequestSetThumbnailWithURLRepresentation(thumbnail, url, kUTTypePlainText, NULL, (__bridge CFDictionaryRef)(properties)); 33 | 34 | return noErr; 35 | } 36 | } 37 | 38 | void CancelThumbnailGeneration(void *thisInterface, QLThumbnailRequestRef thumbnail) 39 | { 40 | // Implement only if supported 41 | } 42 | -------------------------------------------------------------------------------- /PlainTextQuickLook/PlainTextQuickLook/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDocumentTypes 8 | 9 | 10 | CFBundleTypeName 11 | PlainText 12 | CFBundleTypeRole 13 | QLGenerator 14 | LSItemContentTypes 15 | 16 | public.data 17 | 18 | LSTypeIsPackage 19 | 20 | 21 | 22 | CFBundleExecutable 23 | $(EXECUTABLE_NAME) 24 | CFBundleIdentifier 25 | $(PRODUCT_BUNDLE_IDENTIFIER) 26 | CFBundleInfoDictionaryVersion 27 | 6.0 28 | CFBundleName 29 | $(PRODUCT_NAME) 30 | CFBundleShortVersionString 31 | 1.0 32 | CFBundleSignature 33 | ???? 34 | CFBundleVersion 35 | 1 36 | CFPlugInDynamicRegisterFunction 37 | 38 | CFPlugInDynamicRegistration 39 | NO 40 | CFPlugInFactories 41 | 42 | 879428DC-DB39-4934-B442-85B6341BF045 43 | QuickLookGeneratorPluginFactory 44 | 45 | CFPlugInTypes 46 | 47 | 5E2D9680-5022-40FA-B806-43349622E5B9 48 | 49 | 879428DC-DB39-4934-B442-85B6341BF045 50 | 51 | 52 | CFPlugInUnloadFunction 53 | 54 | NSHumanReadableCopyright 55 | Copyright © 2015年 pljhonglu. All rights reserved. 56 | QLNeedsToBeRunInMainThread 57 | 58 | QLPreviewHeight 59 | 600 60 | QLPreviewWidth 61 | 800 62 | QLSupportsConcurrentRequests 63 | 64 | QLThumbnailMinimumSize 65 | 17 66 | 67 | 68 | -------------------------------------------------------------------------------- /PlainTextQuickLook/PlainTextQuickLook/LewFileAttributes.h: -------------------------------------------------------------------------------- 1 | // 2 | // LewFileAttributes.h 3 | // PlainTextQuickLook 4 | // 5 | // Created by pljhonglu on 15/11/9. 6 | // Copyright © 2015年 pljhonglu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface LewFileAttributes : NSObject 12 | @property (readonly) NSURL *url; 13 | 14 | @property (nonatomic, assign, readonly) BOOL isTextFile; 15 | @property (nonatomic, copy, readonly) NSString *mimeType; 16 | @property (nonatomic, copy, readonly) NSString *fileExtension; 17 | @property (nonatomic, copy, readonly) NSString *fileName; 18 | @property (nonatomic, copy, readonly) NSString *fileBadge; 19 | 20 | + (instancetype)fileAttributesForItemAtURL:(NSURL *)URL bundleURL:(NSURL *)bundleURL; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /PlainTextQuickLook/PlainTextQuickLook/LewFileAttributes.m: -------------------------------------------------------------------------------- 1 | // 2 | // LewFileAttributes.m 3 | // PlainTextQuickLook 4 | // 5 | // Created by pljhonglu on 15/11/9. 6 | // Copyright © 2015年 pljhonglu. All rights reserved. 7 | // 8 | 9 | #define FNExtensionsBlackList @"ExtensionsBlackList" 10 | #define FNFileNameWhiteList @"FileNameWhiteList" 11 | #define FNFileNameToBadgeMap @"FileNameToBadgeMap" 12 | #define FNExtensionsWhiteList @"ExtensionsWhiteList" 13 | 14 | #import "LewFileAttributes.h" 15 | 16 | @interface LewFileAttributes () 17 | @property (nonatomic, assign) BOOL isTextFile; 18 | @property (nonatomic, strong) NSURL *url; 19 | @property (nonatomic, copy) NSString *mimeType; 20 | @property (nonatomic, copy) NSString *fileExtension; 21 | @property (nonatomic, copy) NSString *fileName; 22 | @property (nonatomic, copy) NSString *fileBadge; 23 | 24 | @end 25 | 26 | @implementation LewFileAttributes 27 | 28 | static NSDictionary * MimeTypeToBadgeMap; 29 | static NSBundle *BUNDLE; 30 | 31 | + (instancetype)fileAttributesForItemAtURL:(NSURL *)URL bundleURL:(NSURL *)bundleURL{ 32 | 33 | LewFileAttributes *file = [[LewFileAttributes alloc]init]; 34 | file.url = URL; 35 | file.fileExtension = [URL pathExtension]; 36 | file.fileName = [URL lastPathComponent]; 37 | file.isTextFile = NO; 38 | 39 | BUNDLE = [NSBundle bundleWithURL:bundleURL]; 40 | 41 | if (!file.fileExtension || file.fileExtension.length == 0) { 42 | NSString *fileNameWhiteListPath = [BUNDLE pathForResource:FNFileNameWhiteList ofType:@"plist"]; 43 | NSArray *fileNameWhiteList = [NSArray arrayWithContentsOfFile:fileNameWhiteListPath]; 44 | if ([fileNameWhiteList containsObject:file.fileName]) { 45 | file.isTextFile = YES; 46 | } 47 | }else{ 48 | NSString *extensionBlackListPath = [BUNDLE pathForResource:FNExtensionsBlackList ofType:@"plist"]; 49 | NSArray *extensionBlackList = [NSArray arrayWithContentsOfFile:extensionBlackListPath]; 50 | if (![extensionBlackList containsObject:file.fileName]) { 51 | CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef _Nonnull)(file.fileExtension), NULL); 52 | if (UTTypeConformsTo(UTI, kUTTypeText)) { 53 | file.isTextFile = YES; 54 | }else{ 55 | NSString *extensionWhiteListPath = [BUNDLE pathForResource:FNExtensionsWhiteList ofType:@"plist"]; 56 | NSArray *extensionWhiteList = [NSArray arrayWithContentsOfFile:extensionWhiteListPath]; 57 | if ([extensionWhiteList containsObject:file.fileExtension]) { 58 | file.isTextFile = YES; 59 | } 60 | } 61 | CFStringRef mimeType = UTTypeCopyPreferredTagWithClass (UTI, kUTTagClassMIMEType); 62 | CFRelease(UTI); 63 | file.mimeType = (__bridge NSString *)(mimeType); 64 | } 65 | } 66 | 67 | return file; 68 | } 69 | 70 | #pragma mark - getter 71 | - (NSString *)fileBadge{ 72 | if(!_isTextFile){ 73 | return nil; 74 | } 75 | 76 | MimeTypeToBadgeMap = @{ 77 | @"application/xml": @"xml", 78 | @"text/x-c" : @"C", 79 | @"text/x-c++" : @"C++", 80 | @"text/x-shellscript" : @"shell", 81 | @"text/x-php" : @"php", 82 | @"text/x-python" : @"python", 83 | @"text/x-perl" : @"perl", 84 | @"text/x-ruby" : @"ruby" 85 | }; 86 | 87 | if (!_fileExtension || _fileExtension.length == 0) { 88 | NSString *fileNameToBadgeMapPath = [BUNDLE pathForResource:FNFileNameToBadgeMap ofType:@"plist"]; 89 | NSDictionary *fileNameToBadgeMap = [NSDictionary dictionaryWithContentsOfFile:fileNameToBadgeMapPath]; 90 | _fileBadge = fileNameToBadgeMap[_fileName]; 91 | }else{ 92 | if (_fileExtension.length < 10) { 93 | _fileBadge = _fileExtension; 94 | }else if(_mimeType && _mimeType.length > 0){ 95 | _fileBadge = MimeTypeToBadgeMap[_mimeType]; 96 | } 97 | } 98 | if (!_fileBadge || _fileBadge.length == 0) { 99 | _fileBadge = @"unknown"; 100 | } 101 | 102 | return _fileBadge; 103 | } 104 | @end 105 | 106 | 107 | -------------------------------------------------------------------------------- /PlainTextQuickLook/PlainTextQuickLook/filenameToBadgeMap.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Podfile 6 | pod 7 | Makefile 8 | make 9 | README 10 | readme 11 | 12 | 13 | -------------------------------------------------------------------------------- /PlainTextQuickLook/PlainTextQuickLook/main.c: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // 3 | // DO NO MODIFY THE CONTENT OF THIS FILE 4 | // 5 | // This file contains the generic CFPlug-in code necessary for your generator 6 | // To complete your generator implement the function in GenerateThumbnailForURL/GeneratePreviewForURL.c 7 | // 8 | //============================================================================== 9 | 10 | 11 | 12 | 13 | 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | // ----------------------------------------------------------------------------- 21 | // constants 22 | // ----------------------------------------------------------------------------- 23 | 24 | // Don't modify this line 25 | #define PLUGIN_ID "879428DC-DB39-4934-B442-85B6341BF045" 26 | 27 | // 28 | // Below is the generic glue code for all plug-ins. 29 | // 30 | // You should not have to modify this code aside from changing 31 | // names if you decide to change the names defined in the Info.plist 32 | // 33 | 34 | 35 | // ----------------------------------------------------------------------------- 36 | // typedefs 37 | // ----------------------------------------------------------------------------- 38 | 39 | // The thumbnail generation function to be implemented in GenerateThumbnailForURL.c 40 | OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef thumbnail, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options, CGSize maxSize); 41 | void CancelThumbnailGeneration(void* thisInterface, QLThumbnailRequestRef thumbnail); 42 | 43 | // The preview generation function to be implemented in GeneratePreviewForURL.c 44 | OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options); 45 | void CancelPreviewGeneration(void *thisInterface, QLPreviewRequestRef preview); 46 | 47 | // The layout for an instance of QuickLookGeneratorPlugIn 48 | typedef struct __QuickLookGeneratorPluginType 49 | { 50 | void *conduitInterface; 51 | CFUUIDRef factoryID; 52 | UInt32 refCount; 53 | } QuickLookGeneratorPluginType; 54 | 55 | // ----------------------------------------------------------------------------- 56 | // prototypes 57 | // ----------------------------------------------------------------------------- 58 | // Forward declaration for the IUnknown implementation. 59 | // 60 | 61 | QuickLookGeneratorPluginType *AllocQuickLookGeneratorPluginType(CFUUIDRef inFactoryID); 62 | void DeallocQuickLookGeneratorPluginType(QuickLookGeneratorPluginType *thisInstance); 63 | HRESULT QuickLookGeneratorQueryInterface(void *thisInstance,REFIID iid,LPVOID *ppv); 64 | void *QuickLookGeneratorPluginFactory(CFAllocatorRef allocator,CFUUIDRef typeID); 65 | ULONG QuickLookGeneratorPluginAddRef(void *thisInstance); 66 | ULONG QuickLookGeneratorPluginRelease(void *thisInstance); 67 | 68 | // ----------------------------------------------------------------------------- 69 | // myInterfaceFtbl definition 70 | // ----------------------------------------------------------------------------- 71 | // The QLGeneratorInterfaceStruct function table. 72 | // 73 | static QLGeneratorInterfaceStruct myInterfaceFtbl = { 74 | NULL, 75 | QuickLookGeneratorQueryInterface, 76 | QuickLookGeneratorPluginAddRef, 77 | QuickLookGeneratorPluginRelease, 78 | NULL, 79 | NULL, 80 | NULL, 81 | NULL 82 | }; 83 | 84 | 85 | // ----------------------------------------------------------------------------- 86 | // AllocQuickLookGeneratorPluginType 87 | // ----------------------------------------------------------------------------- 88 | // Utility function that allocates a new instance. 89 | // You can do some initial setup for the generator here if you wish 90 | // like allocating globals etc... 91 | // 92 | QuickLookGeneratorPluginType *AllocQuickLookGeneratorPluginType(CFUUIDRef inFactoryID) 93 | { 94 | QuickLookGeneratorPluginType *theNewInstance; 95 | 96 | theNewInstance = (QuickLookGeneratorPluginType *)malloc(sizeof(QuickLookGeneratorPluginType)); 97 | memset(theNewInstance,0,sizeof(QuickLookGeneratorPluginType)); 98 | 99 | /* Point to the function table Malloc enough to store the stuff and copy the filler from myInterfaceFtbl over */ 100 | theNewInstance->conduitInterface = malloc(sizeof(QLGeneratorInterfaceStruct)); 101 | memcpy(theNewInstance->conduitInterface,&myInterfaceFtbl,sizeof(QLGeneratorInterfaceStruct)); 102 | 103 | /* Retain and keep an open instance refcount for each factory. */ 104 | theNewInstance->factoryID = CFRetain(inFactoryID); 105 | CFPlugInAddInstanceForFactory(inFactoryID); 106 | 107 | /* This function returns the IUnknown interface so set the refCount to one. */ 108 | theNewInstance->refCount = 1; 109 | return theNewInstance; 110 | } 111 | 112 | // ----------------------------------------------------------------------------- 113 | // DeallocQuickLookGeneratorPluginType 114 | // ----------------------------------------------------------------------------- 115 | // Utility function that deallocates the instance when 116 | // the refCount goes to zero. 117 | // In the current implementation generator interfaces are never deallocated 118 | // but implement this as this might change in the future 119 | // 120 | void DeallocQuickLookGeneratorPluginType(QuickLookGeneratorPluginType *thisInstance) 121 | { 122 | CFUUIDRef theFactoryID; 123 | 124 | theFactoryID = thisInstance->factoryID; 125 | /* Free the conduitInterface table up */ 126 | free(thisInstance->conduitInterface); 127 | 128 | /* Free the instance structure */ 129 | free(thisInstance); 130 | if (theFactoryID){ 131 | CFPlugInRemoveInstanceForFactory(theFactoryID); 132 | CFRelease(theFactoryID); 133 | } 134 | } 135 | 136 | // ----------------------------------------------------------------------------- 137 | // QuickLookGeneratorQueryInterface 138 | // ----------------------------------------------------------------------------- 139 | // Implementation of the IUnknown QueryInterface function. 140 | // 141 | HRESULT QuickLookGeneratorQueryInterface(void *thisInstance,REFIID iid,LPVOID *ppv) 142 | { 143 | CFUUIDRef interfaceID; 144 | 145 | interfaceID = CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault,iid); 146 | 147 | if (CFEqual(interfaceID,kQLGeneratorCallbacksInterfaceID)){ 148 | /* If the Right interface was requested, bump the ref count, 149 | * set the ppv parameter equal to the instance, and 150 | * return good status. 151 | */ 152 | ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType *)thisInstance)->conduitInterface)->GenerateThumbnailForURL = GenerateThumbnailForURL; 153 | ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType *)thisInstance)->conduitInterface)->CancelThumbnailGeneration = CancelThumbnailGeneration; 154 | ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType *)thisInstance)->conduitInterface)->GeneratePreviewForURL = GeneratePreviewForURL; 155 | ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType *)thisInstance)->conduitInterface)->CancelPreviewGeneration = CancelPreviewGeneration; 156 | ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType*)thisInstance)->conduitInterface)->AddRef(thisInstance); 157 | *ppv = thisInstance; 158 | CFRelease(interfaceID); 159 | return S_OK; 160 | }else{ 161 | /* Requested interface unknown, bail with error. */ 162 | *ppv = NULL; 163 | CFRelease(interfaceID); 164 | return E_NOINTERFACE; 165 | } 166 | } 167 | 168 | // ----------------------------------------------------------------------------- 169 | // QuickLookGeneratorPluginAddRef 170 | // ----------------------------------------------------------------------------- 171 | // Implementation of reference counting for this type. Whenever an interface 172 | // is requested, bump the refCount for the instance. NOTE: returning the 173 | // refcount is a convention but is not required so don't rely on it. 174 | // 175 | ULONG QuickLookGeneratorPluginAddRef(void *thisInstance) 176 | { 177 | ((QuickLookGeneratorPluginType *)thisInstance )->refCount += 1; 178 | return ((QuickLookGeneratorPluginType*) thisInstance)->refCount; 179 | } 180 | 181 | // ----------------------------------------------------------------------------- 182 | // QuickLookGeneratorPluginRelease 183 | // ----------------------------------------------------------------------------- 184 | // When an interface is released, decrement the refCount. 185 | // If the refCount goes to zero, deallocate the instance. 186 | // 187 | ULONG QuickLookGeneratorPluginRelease(void *thisInstance) 188 | { 189 | ((QuickLookGeneratorPluginType*)thisInstance)->refCount -= 1; 190 | if (((QuickLookGeneratorPluginType*)thisInstance)->refCount == 0){ 191 | DeallocQuickLookGeneratorPluginType((QuickLookGeneratorPluginType*)thisInstance ); 192 | return 0; 193 | }else{ 194 | return ((QuickLookGeneratorPluginType*) thisInstance )->refCount; 195 | } 196 | } 197 | 198 | // ----------------------------------------------------------------------------- 199 | // QuickLookGeneratorPluginFactory 200 | // ----------------------------------------------------------------------------- 201 | void *QuickLookGeneratorPluginFactory(CFAllocatorRef allocator,CFUUIDRef typeID) 202 | { 203 | QuickLookGeneratorPluginType *result; 204 | CFUUIDRef uuid; 205 | 206 | /* If correct type is being requested, allocate an 207 | * instance of kQLGeneratorTypeID and return the IUnknown interface. 208 | */ 209 | if (CFEqual(typeID,kQLGeneratorTypeID)){ 210 | uuid = CFUUIDCreateFromString(kCFAllocatorDefault,CFSTR(PLUGIN_ID)); 211 | result = AllocQuickLookGeneratorPluginType(uuid); 212 | CFRelease(uuid); 213 | return result; 214 | } 215 | /* If the requested type is incorrect, return NULL. */ 216 | return NULL; 217 | } 218 | 219 | -------------------------------------------------------------------------------- /PlainTextQuickLook/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '6.0' 3 | 4 | target 'MyApp' do 5 | pod 'AFNetworking' 6 | end 7 | 8 | target 'MyAppTests' do 9 | 10 | end 11 | -------------------------------------------------------------------------------- /PlainTextQuickLook/qlmanage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pljhonglu/PlainTextQuickLook/9da43b2651423bef0dd9e321fa06c5a2bd3df74a/PlainTextQuickLook/qlmanage -------------------------------------------------------------------------------- /PlainTextQuickLook/test.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | maven { 4 | url 'file:../lib' 5 | } } 6 | dependencies { 7 | classpath group: 'davenkin', name: 'datetimeplugin', 8 | version: '1.0' 9 | } 10 | } 11 | apply plugin: 'time' 12 | 13 | dateAndTime { 14 | timeFormat = 'HH:mm:ss.SSS' 15 | dateFormat = 'MM/dd/yyyy' 16 | } -------------------------------------------------------------------------------- /PlainTextQuickLook/test.md: -------------------------------------------------------------------------------- 1 | ### 匆匆 2 | 3 | 燕子去了,有再来的时候;杨柳枯了,有再青的时候;桃花谢了,有再开的时候。但是,聪明的,你告诉我,我们的日子为什么一去不复返呢?——是有人偷了他们罢:那是谁?又藏在何处呢?是他们自己逃走了罢——如今又到了哪里呢? 4 | 5 | 我不知道他们给了我多少日子,但我的手确乎是渐渐空虚了。在默默里算着,八千多日子已经从我手中溜去,像针尖上一滴水滴在大海里,我的日子滴在时间的流里,没有声音,也没有影子。我不禁头涔涔而泪潸潸了。 6 | 7 | 去的尽管去了,来的尽管来着;去来的中间,又怎样地匆匆呢?早上我起来的时候,小屋里射进两三方斜斜的太阳。太阳他有脚啊,轻轻悄悄地挪移了;我也茫茫然跟着旋转。于是——洗手的时候,日子从水盆里过去;吃饭的时候,日子从饭碗里过去;默默时,便从凝然的双眼前过去。我觉察他去的匆匆了,伸出手遮挽时,他又从遮挽着的手边过去,天黑时,我躺在床上,他便伶伶俐俐地从我身上跨过,从我脚边飞去了。等我睁开眼和太阳再见,这算又溜走了一日。我掩着面叹息。但是新来的日子的影儿又开始在叹息里闪过了。 8 | 9 | 在逃去如飞的日子里,在千门万户的世界里的我能做些什么呢?只有徘徊罢了,只有匆匆罢了;在八千多日的匆匆里,除徘徊外,又剩些什么呢?过去的日子如轻烟,被微风吹散了,如薄雾,被初阳蒸融了;我留着些什么痕迹呢?我何曾留着像游丝样的痕迹呢?我赤裸裸来到这世界,转眼间也将赤裸裸的回去罢?但不能平的,为什么偏要白白走这一遭啊? 10 | 11 | 你聪明的,告诉我,我们的日子为什么一去不复返呢? 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PlainTextQuickLook 2 | OS X 上的快速预览插件,支持文本文件预览,不限扩展名 3 | 4 | 主要是本人电脑上一大堆 markdown 文件,还有 podfile 和 makefile 文件,没办法预览,索性就写了个文本文件预览的插件。主要参考 [qlstephen][] 作者的思路 5 | 6 | ## 安装 7 | 8 | 从[这里下载][Download]插件包,解压缩之后把`PlainTextQuickLook.qlgenerator`文件拷贝到`/Library/QuickLook`或者`~/Library/Quicklook`目录下。 9 | 10 | 注销系统重新登录或执行下面命令 11 | 12 | ``` 13 | /usr/bin/qlmanage -r 14 | ``` 15 | 16 | ## 代码调试 17 | 18 | 调试依赖 qlmanager 19 | 20 | 1. 删除 `~/Library/Quicklook` 下的`PlainTextQuickLook.qlgenerator`文件 21 | 2. 执行 `cp /usr/bin/qlmanager PROJECT_PATH`,把 qlmanager 复制到工程目录下 22 | 3. Xcode 选择 `product -> scheme -> edit scheme`,选择 run 选项,info 下面的 executable 选择 other,找到刚刚的拷贝过来的 qlmanager,同时勾选 `debug executable` 23 | 4. 选择 argument ,在 `arguments passed on launch` 中添加 `-p text.md` 24 | 25 | 接下来就可以像平时开发一样做断点调试了,qlmanager 的调试参数可以参考苹果的官方文档[debug][]部分 26 | 27 | 参考: 28 | 29 | [Debugging Quicklook Plugin in Xcode 4.6](http://stackoverflow.com/questions/16811547/debugging-quicklook-plugin-in-xcode-4-6) 30 | [Debugging and Testing a Generator](https://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/Quicklook_Programming_Guide/Articles/QLDebugTest.html) 31 | 32 | [debug]: https://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/Quicklook_Programming_Guide/Articles/QLDebugTest.html "debug" 33 | [Download]: https://github.com/pljhonglu/PlainTextQuickLook/releases "Download" 34 | [qlstephen]: https://github.com/whomwah/qlstephen#2-edit-the-appropriate-plist-file-in-your-favorite-text-editor "qlstephen" 35 | --------------------------------------------------------------------------------