diff --git a/QLAnsilove/Frameworks/AnsiLove.framework/AnsiLove b/QLAnsilove/Frameworks/AnsiLove.framework/AnsiLove new file mode 120000 index 0000000..c92ae5c --- /dev/null +++ b/QLAnsilove/Frameworks/AnsiLove.framework/AnsiLove @@ -0,0 +1 @@ +Versions/Current/AnsiLove \ No newline at end of file diff --git a/QLAnsilove/Frameworks/AnsiLove.framework/Headers b/QLAnsilove/Frameworks/AnsiLove.framework/Headers new file mode 120000 index 0000000..a177d2a --- /dev/null +++ b/QLAnsilove/Frameworks/AnsiLove.framework/Headers @@ -0,0 +1 @@ +Versions/Current/Headers \ No newline at end of file diff --git a/QLAnsilove/Frameworks/AnsiLove.framework/Resources b/QLAnsilove/Frameworks/AnsiLove.framework/Resources new file mode 120000 index 0000000..953ee36 --- /dev/null +++ b/QLAnsilove/Frameworks/AnsiLove.framework/Resources @@ -0,0 +1 @@ +Versions/Current/Resources \ No newline at end of file diff --git a/QLAnsilove/Frameworks/AnsiLove.framework/Versions/6/AnsiLove b/QLAnsilove/Frameworks/AnsiLove.framework/Versions/6/AnsiLove new file mode 100755 index 0000000..42ff3d3 Binary files /dev/null and b/QLAnsilove/Frameworks/AnsiLove.framework/Versions/6/AnsiLove differ diff --git a/QLAnsilove/Frameworks/AnsiLove.framework/Versions/6/Headers/ALAnsiGenerator.h b/QLAnsilove/Frameworks/AnsiLove.framework/Versions/6/Headers/ALAnsiGenerator.h new file mode 100755 index 0000000..3e5f823 --- /dev/null +++ b/QLAnsilove/Frameworks/AnsiLove.framework/Versions/6/Headers/ALAnsiGenerator.h @@ -0,0 +1,44 @@ +// +// ALAnsiGenerator.h +// AnsiLove.framework +// +// Copyright (C) 2011-2015 Stefan Vogt. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause License. +// See the file LICENSE for details. +// + +#import + +@interface ALAnsiGenerator : NSObject + +// Affecting supported output formats. +@property (nonatomic, assign) BOOL generatesRetinaFile; + +// Affecting implemented rendering options. +@property (nonatomic, assign) BOOL usesDefaultFont; +@property (nonatomic, assign) BOOL usesDefaultBits; +@property (nonatomic, assign) BOOL usesDefaultColumns; +@property (nonatomic, assign) BOOL hasSauceRecord; + +// ANSi file +@property (nonatomic, strong) NSString *ansi_inputFile; +@property (nonatomic, strong) NSString *ansi_outputFile; +@property (nonatomic, strong) NSString *ansi_retinaOutputFile; +@property (nonatomic, strong) NSString *ansi_font; +@property (nonatomic, strong) NSString *ansi_bits; +@property (nonatomic, assign) BOOL ansi_iceColors; +@property (nonatomic, strong) NSString *ansi_columns; +@property (nonatomic, strong) NSString *rawOutputString; + +// One method to make the magic happen. +- (void)renderAnsiFile:(NSString *)inputFile + outputFile:(NSString *)outputFile + font:(NSString *)font + bits:(NSString *)bits + iceColors:(BOOL )iceColors + columns:(NSString *)columns + retina:(BOOL )generateRetina; + +@end diff --git a/QLAnsilove/Frameworks/AnsiLove.framework/Versions/6/Headers/ALSauceMachine.h b/QLAnsilove/Frameworks/AnsiLove.framework/Versions/6/Headers/ALSauceMachine.h new file mode 100755 index 0000000..ffecb9b --- /dev/null +++ b/QLAnsilove/Frameworks/AnsiLove.framework/Versions/6/Headers/ALSauceMachine.h @@ -0,0 +1,82 @@ +// +// ALSauceMachine.h +// AnsiLove.framework +// +// Copyright (C) 2011-2015 Stefan Vogt. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause License. +// See the file LICENSE for details. +// +// Based on libsauce. Copyright (c) 2010, Brian Cassidy. +// + +#import + +// better readability for strcmp() methods +#define IDENTICAL 0 + +// internal defines and typedefs +#define RECORD_SIZE 128 +#define COMMENT_SIZE 64 +#define SAUCE_ID "SAUCE" +#define COMMENT_ID "COMNT" + +typedef struct { + char ID[6]; + char version[3]; + char title[36]; + char author[21]; + char group[21]; + char date[9]; + int fileSize; + unsigned char dataType; + unsigned char fileType; + unsigned short tinfo1; + unsigned short tinfo2; + unsigned short tinfo3; + unsigned short tinfo4; + unsigned char comments; + unsigned char flags; + char filler[23]; + char **comment_lines; +} sauce; + +@interface ALSauceMachine : NSObject + +// SAUCE record properties +@property (nonatomic, strong) NSString *ID; +@property (nonatomic, strong) NSString *version; +@property (nonatomic, strong) NSString *title; +@property (nonatomic, strong) NSString *author; +@property (nonatomic, strong) NSString *group; +@property (nonatomic, strong) NSString *date; +@property (nonatomic, assign) NSInteger dataType; +@property (nonatomic, assign) NSInteger fileType; +@property (nonatomic, assign) NSInteger tinfo1; +@property (nonatomic, assign) NSInteger tinfo2; +@property (nonatomic, assign) NSInteger tinfo3; +@property (nonatomic, assign) NSInteger tinfo4; +@property (nonatomic, strong) NSString *comments; +@property (nonatomic, assign) NSInteger flags; + +// SAUCE record BOOL properties +@property (nonatomic, assign) BOOL fileHasRecord; +@property (nonatomic, assign) BOOL fileHasComments; +@property (nonatomic, assign) BOOL fileHasFlags; + +// bridge methods (Cocoa) +- (void)readRecordFromFile:(NSString *)inputFile; + +// class internal (ye good olde C) +sauce *sauceReadFileName(char *fileName); +sauce *sauceReadFile(FILE *file); +void readRecord(FILE *file, sauce *record); +void readComments(FILE *file, char **comment_lines, NSInteger comments); +NSInteger sauceWriteFileName(char *fileName, sauce *record); +NSInteger sauceWriteFile(FILE *file, sauce *record); +NSInteger writeRecord(FILE *file, sauce *record); +NSInteger sauceRemoveFileName(char *fileName); +NSInteger sauceRemoveFile(FILE *file); + +@end diff --git a/QLAnsilove/Frameworks/AnsiLove.framework/Versions/6/Headers/AnsiLove.h b/QLAnsilove/Frameworks/AnsiLove.framework/Versions/6/Headers/AnsiLove.h new file mode 100755 index 0000000..f93264b --- /dev/null +++ b/QLAnsilove/Frameworks/AnsiLove.framework/Versions/6/Headers/AnsiLove.h @@ -0,0 +1,13 @@ +// +// AnsiLove.h +// AnsiLove.framework +// +// Copyright (C) 2011-2015 Stefan Vogt. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause License. +// See the file LICENSE for details. +// + +#import "ALAnsiGenerator.h" +#import "ALSauceMachine.h" diff --git a/QLAnsilove/Frameworks/AnsiLove.framework/Versions/6/Resources/Info.plist b/QLAnsilove/Frameworks/AnsiLove.framework/Versions/6/Resources/Info.plist new file mode 100755 index 0000000..d9bac36 --- /dev/null +++ b/QLAnsilove/Frameworks/AnsiLove.framework/Versions/6/Resources/Info.plist @@ -0,0 +1,42 @@ + + + + + BuildMachineOSBuild + 14E46 + CFBundleDevelopmentRegion + English + CFBundleExecutable + AnsiLove + CFBundleIdentifier + com.byteproject.AnsiLove + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + AnsiLove + CFBundlePackageType + FMWK + CFBundleShortVersionString + 6.1.0 + CFBundleSignature + ???? + CFBundleVersion + 86 + DTCompiler + com.apple.compilers.llvm.clang.1_0 + DTPlatformBuild + 6E35b + DTPlatformVersion + GM + DTSDKBuild + 13F34 + DTSDKName + macosx10.9 + DTXcode + 0640 + DTXcodeBuild + 6E35b + NSHumanReadableCopyright + Copyright © 2011-2015 Stefan Vogt. All rights reserved. + + diff --git a/QLAnsilove/Frameworks/AnsiLove.framework/Versions/6/Resources/en.lproj/InfoPlist.strings b/QLAnsilove/Frameworks/AnsiLove.framework/Versions/6/Resources/en.lproj/InfoPlist.strings new file mode 100755 index 0000000..5e45963 Binary files /dev/null and b/QLAnsilove/Frameworks/AnsiLove.framework/Versions/6/Resources/en.lproj/InfoPlist.strings differ diff --git a/QLAnsilove/Frameworks/AnsiLove.framework/Versions/6/libgd.3.dylib b/QLAnsilove/Frameworks/AnsiLove.framework/Versions/6/libgd.3.dylib new file mode 100755 index 0000000..5b2bae0 Binary files /dev/null and b/QLAnsilove/Frameworks/AnsiLove.framework/Versions/6/libgd.3.dylib differ diff --git a/QLAnsilove/Frameworks/AnsiLove.framework/Versions/6/libpng16.16.dylib b/QLAnsilove/Frameworks/AnsiLove.framework/Versions/6/libpng16.16.dylib new file mode 100755 index 0000000..ceef1bd Binary files /dev/null and b/QLAnsilove/Frameworks/AnsiLove.framework/Versions/6/libpng16.16.dylib differ diff --git a/QLAnsilove/Frameworks/AnsiLove.framework/Versions/Current b/QLAnsilove/Frameworks/AnsiLove.framework/Versions/Current new file mode 120000 index 0000000..62f9457 --- /dev/null +++ b/QLAnsilove/Frameworks/AnsiLove.framework/Versions/Current @@ -0,0 +1 @@ +6 \ No newline at end of file diff --git a/QLAnsilove/QLAnsilove.xcodeproj/project.pbxproj b/QLAnsilove/QLAnsilove.xcodeproj/project.pbxproj new file mode 100644 index 0000000..f25d741 --- /dev/null +++ b/QLAnsilove/QLAnsilove.xcodeproj/project.pbxproj @@ -0,0 +1,370 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 48; + objects = { + +/* Begin PBXBuildFile section */ + 9E6D277E1FABB5720068F2CE /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 9E6D277D1FABB5720068F2CE /* main.c */; }; + 9E6D27871FABB7080068F2CE /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9E6D27861FABB7080068F2CE /* ApplicationServices.framework */; }; + 9E6D27891FABB70F0068F2CE /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9E6D27881FABB70F0068F2CE /* Cocoa.framework */; }; + 9E6D278B1FABB7150068F2CE /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9E6D278A1FABB7150068F2CE /* CoreServices.framework */; }; + 9E6D278D1FABB71B0068F2CE /* QuickLook.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9E6D278C1FABB71B0068F2CE /* QuickLook.framework */; }; + 9E6D27911FABB7A10068F2CE /* Shared.h in Headers */ = {isa = PBXBuildFile; fileRef = 9E6D27901FABB7A10068F2CE /* Shared.h */; }; + 9E6D27931FABB7D80068F2CE /* GenerateThumbnailForURL.m in Sources */ = {isa = PBXBuildFile; fileRef = 9E6D27921FABB7D80068F2CE /* GenerateThumbnailForURL.m */; }; + 9E6D27951FABB8580068F2CE /* GeneratePreviewForURL.m in Sources */ = {isa = PBXBuildFile; fileRef = 9E6D27941FABB8580068F2CE /* GeneratePreviewForURL.m */; }; + 9E6D279B1FABBABE0068F2CE /* AnsiLove.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9E6D279A1FABBABE0068F2CE /* AnsiLove.framework */; }; + 9E6D279C1FABBAC70068F2CE /* AnsiLove.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9E6D279A1FABBABE0068F2CE /* AnsiLove.framework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9E6D27961FABBA6A0068F2CE /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 9E6D279C1FABBAC70068F2CE /* AnsiLove.framework in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 9E6D27761FABB5720068F2CE /* QLAnsilove.qlgenerator */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = QLAnsilove.qlgenerator; sourceTree = BUILT_PRODUCTS_DIR; }; + 9E6D277D1FABB5720068F2CE /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = ""; }; + 9E6D277F1FABB5720068F2CE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 9E6D27861FABB7080068F2CE /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = System/Library/Frameworks/ApplicationServices.framework; sourceTree = SDKROOT; }; + 9E6D27881FABB70F0068F2CE /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; + 9E6D278A1FABB7150068F2CE /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = System/Library/Frameworks/CoreServices.framework; sourceTree = SDKROOT; }; + 9E6D278C1FABB71B0068F2CE /* QuickLook.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuickLook.framework; path = System/Library/Frameworks/QuickLook.framework; sourceTree = SDKROOT; }; + 9E6D27901FABB7A10068F2CE /* Shared.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Shared.h; sourceTree = ""; }; + 9E6D27921FABB7D80068F2CE /* GenerateThumbnailForURL.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GenerateThumbnailForURL.m; sourceTree = ""; }; + 9E6D27941FABB8580068F2CE /* GeneratePreviewForURL.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GeneratePreviewForURL.m; sourceTree = ""; }; + 9E6D279A1FABBABE0068F2CE /* AnsiLove.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AnsiLove.framework; path = Frameworks/AnsiLove.framework; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 9E6D27721FABB5720068F2CE /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 9E6D279B1FABBABE0068F2CE /* AnsiLove.framework in Frameworks */, + 9E6D278D1FABB71B0068F2CE /* QuickLook.framework in Frameworks */, + 9E6D278B1FABB7150068F2CE /* CoreServices.framework in Frameworks */, + 9E6D27891FABB70F0068F2CE /* Cocoa.framework in Frameworks */, + 9E6D27871FABB7080068F2CE /* ApplicationServices.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9E6D276C1FABB5720068F2CE = { + isa = PBXGroup; + children = ( + 9E6D27781FABB5720068F2CE /* QLAnsilove */, + 9E6D27771FABB5720068F2CE /* Products */, + 9E6D27851FABB7080068F2CE /* Frameworks */, + ); + sourceTree = ""; + tabWidth = 2; + }; + 9E6D27771FABB5720068F2CE /* Products */ = { + isa = PBXGroup; + children = ( + 9E6D27761FABB5720068F2CE /* QLAnsilove.qlgenerator */, + ); + name = Products; + sourceTree = ""; + }; + 9E6D27781FABB5720068F2CE /* QLAnsilove */ = { + isa = PBXGroup; + children = ( + 9E6D277D1FABB5720068F2CE /* main.c */, + 9E6D277F1FABB5720068F2CE /* Info.plist */, + 9E6D27901FABB7A10068F2CE /* Shared.h */, + 9E6D27921FABB7D80068F2CE /* GenerateThumbnailForURL.m */, + 9E6D27941FABB8580068F2CE /* GeneratePreviewForURL.m */, + ); + path = QLAnsilove; + sourceTree = ""; + }; + 9E6D27851FABB7080068F2CE /* Frameworks */ = { + isa = PBXGroup; + children = ( + 9E6D279A1FABBABE0068F2CE /* AnsiLove.framework */, + 9E6D278C1FABB71B0068F2CE /* QuickLook.framework */, + 9E6D278A1FABB7150068F2CE /* CoreServices.framework */, + 9E6D27881FABB70F0068F2CE /* Cocoa.framework */, + 9E6D27861FABB7080068F2CE /* ApplicationServices.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 9E6D27731FABB5720068F2CE /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 9E6D27911FABB7A10068F2CE /* Shared.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 9E6D27751FABB5720068F2CE /* QLAnsilove */ = { + isa = PBXNativeTarget; + buildConfigurationList = 9E6D27821FABB5720068F2CE /* Build configuration list for PBXNativeTarget "QLAnsilove" */; + buildPhases = ( + 9E6D27711FABB5720068F2CE /* Sources */, + 9E6D27721FABB5720068F2CE /* Frameworks */, + 9E6D27731FABB5720068F2CE /* Headers */, + 9E6D27961FABBA6A0068F2CE /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = QLAnsilove; + productName = QLAnsilove; + productReference = 9E6D27761FABB5720068F2CE /* QLAnsilove.qlgenerator */; + productType = "com.apple.product-type.bundle"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 9E6D276D1FABB5720068F2CE /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0900; + ORGANIZATIONNAME = Ansilove; + TargetAttributes = { + 9E6D27751FABB5720068F2CE = { + CreatedOnToolsVersion = 9.0; + ProvisioningStyle = Manual; + }; + }; + }; + buildConfigurationList = 9E6D27701FABB5720068F2CE /* Build configuration list for PBXProject "QLAnsilove" */; + compatibilityVersion = "Xcode 8.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 9E6D276C1FABB5720068F2CE; + productRefGroup = 9E6D27771FABB5720068F2CE /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 9E6D27751FABB5720068F2CE /* QLAnsilove */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 9E6D27711FABB5720068F2CE /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9E6D27951FABB8580068F2CE /* GeneratePreviewForURL.m in Sources */, + 9E6D27931FABB7D80068F2CE /* GenerateThumbnailForURL.m in Sources */, + 9E6D277E1FABB5720068F2CE /* main.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 9E6D27801FABB5720068F2CE /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = ""; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.12; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 9E6D27811FABB5720068F2CE /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = ""; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.12; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + }; + name = Release; + }; + 9E6D27831FABB5720068F2CE /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = ""; + CODE_SIGN_STYLE = Manual; + COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = ""; + Deployment = ""; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Frameworks", + "$(PROJECT_DIR)", + ); + GCC_NO_COMMON_BLOCKS = NO; + INFOPLIST_FILE = QLAnsilove/Info.plist; + INSTALL_PATH = /Library/QuickLook; + LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Library/Frameworks @loader_path/../Frameworks"; + "LD_RUNPATH_SEARCH_PATHS[arch=*]" = "@loader_path/../Library/Frameworks @loader_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.11; + OTHER_LDFLAGS = "\"-rpath @load_path/../Frameworks\""; + "OTHER_LDFLAGS[arch=*]" = ""; + PRODUCT_BUNDLE_IDENTIFIER = org.ansilove.QLAnsilove; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SCAN_ALL_SOURCE_FILES_FOR_INCLUDES = YES; + WRAPPER_EXTENSION = qlgenerator; + }; + name = Debug; + }; + 9E6D27841FABB5720068F2CE /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = ""; + CODE_SIGN_STYLE = Manual; + COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = ""; + Deployment = ""; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Frameworks", + "$(PROJECT_DIR)", + ); + GCC_NO_COMMON_BLOCKS = NO; + INFOPLIST_FILE = QLAnsilove/Info.plist; + INSTALL_PATH = /Library/QuickLook; + LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks @loader_path/../Library/Frameworks"; + "LD_RUNPATH_SEARCH_PATHS[arch=*]" = "@loader_path/../Library/Frameworks @loader_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.11; + OTHER_LDFLAGS = "\"-rpath @load_path/../Frameworks\""; + "OTHER_LDFLAGS[arch=*]" = ""; + PRODUCT_BUNDLE_IDENTIFIER = org.ansilove.QLAnsilove; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SCAN_ALL_SOURCE_FILES_FOR_INCLUDES = YES; + WRAPPER_EXTENSION = qlgenerator; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 9E6D27701FABB5720068F2CE /* Build configuration list for PBXProject "QLAnsilove" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9E6D27801FABB5720068F2CE /* Debug */, + 9E6D27811FABB5720068F2CE /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 9E6D27821FABB5720068F2CE /* Build configuration list for PBXNativeTarget "QLAnsilove" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9E6D27831FABB5720068F2CE /* Debug */, + 9E6D27841FABB5720068F2CE /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 9E6D276D1FABB5720068F2CE /* Project object */; +} diff --git a/QLAnsilove/QLAnsilove.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/QLAnsilove/QLAnsilove.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..3f40762 --- /dev/null +++ b/QLAnsilove/QLAnsilove.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/QLAnsilove/QLAnsilove/GeneratePreviewForURL.m b/QLAnsilove/QLAnsilove/GeneratePreviewForURL.m new file mode 100644 index 0000000..db6dce4 --- /dev/null +++ b/QLAnsilove/QLAnsilove/GeneratePreviewForURL.m @@ -0,0 +1,150 @@ +// +// GeneratePreviewForURL.m +// QLAnsilove +// +// QLAnsilove is Copyright © 2017, Christian R. Vozar / Alpha King +// AnsiLove.framework is Copyright © 2010-2017, Stefan Vogt +// Ansilove/C is Copyright © 2011-2017, Stefan Vogt, Brian Cassidy, and Frederic Cambus +// +// All rights reserved. +// + +#import "Shared.h" + +#include +#include +#include +#include + +OSStatus GeneratePreviewForURL(void* thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options); + +OSStatus GeneratePreviewForURL(__unused void* thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, __unused CFDictionaryRef options) +{ + @autoreleasepool + { + // Generate 'Application support' folder. + NSFileManager *fileManager = [[NSFileManager alloc] init]; + + NSString *folder = @"~/Library/Application Support/QLAnsilove/"; + folder = [folder stringByExpandingTildeInPath]; + + if ([fileManager fileExistsAtPath:folder] == NO) + { + [fileManager createDirectoryAtPath:folder + withIntermediateDirectories:YES + attributes:nil + error:nil]; + } + + + + // Instantiate ALAnsiGenerator. + ansiGen = [ALAnsiGenerator new]; + + NSString* extension = [[(__bridge NSURL*)url pathExtension] lowercaseString]; + if ([extension isEqualToString:@"ans"] || [extension isEqualToString:@"nfo"] || [extension isEqualToString:@"mem"] || [extension isEqualToString:@"diz"] || [extension isEqualToString:@"asc"] || [extension isEqualToString:@"idf"] || [extension isEqualToString:@"xb"] || [extension isEqualToString:@"tnd"] || [extension isEqualToString:@"cia"]) + { + alBits = @"8"; + alColumns = @"160"; + + bool isIceColors = YES; + // Determine if iCE Colors should stay on or off + + // If there is no content string, create one. + if (contentString == nil) { + contentString = [[NSMutableAttributedString alloc] initWithString:@""]; + } + + // Get the current file URL and convert it to an UNIX path. + NSURL *tnCurrentURL = (__bridge NSURL *)url; + alURLString = [tnCurrentURL path]; + + // Get the currrent file name without any path informations. + NSString *tnPureFileName = [alURLString lastPathComponent]; + + ansiCacheFile = [NSString stringWithFormat: + @"~/Library/Application Support/QLAnsilove/%@.png", tnPureFileName]; + + retinaCacheFile = [NSString stringWithFormat: + @"~/Library/Application Support/QLAnsilove/%@@2x.png", tnPureFileName]; + + // Expand tilde in cache file path. + ansiCacheFile = [ansiCacheFile stringByExpandingTildeInPath]; + retinaCacheFile = [retinaCacheFile stringByExpandingTildeInPath]; + + // Create string we can pass as outputfile flag. + alOutputString = [NSString stringWithFormat: + @"~/Library/Application Support/QLAnsilove/%@", tnPureFileName]; + alOutputString = [alOutputString stringByExpandingTildeInPath]; + + // Invoke AnsiLove to generate rendered image. + [ansiGen renderAnsiFile:alURLString + outputFile:alOutputString + font:@"80x25" + bits:alBits + iceColors:isIceColors + columns:alColumns + retina:YES]; + + // Wait for AnsiLove.framework to finish rendering. + // TODO: Replace with ansilove.framework rendering out an NSImage rather than a file to disk. + [NSThread sleepForTimeInterval:0.2]; + + NSImage *renderedImage = [[NSImage alloc] initWithContentsOfFile:ansiGen.ansi_retinaOutputFile]; + + CGDataProviderRef imgDataProvider = CGDataProviderCreateWithCFData((CFDataRef)[NSData dataWithContentsOfFile:ansiCacheFile]); + CGImageRef image_ref = CGImageCreateWithPNGDataProvider(imgDataProvider, NULL, true, kCGRenderingIntentDefault); + + canvasSize = renderedImage.size; + + // Draw rendered png to graphics context provided by QuickLook. + if (image_ref != NULL) + { + CGContextRef cgContext = QLPreviewRequestCreateContext(preview, *(CGSize *)&canvasSize, false, NULL); + if(cgContext) { + NSGraphicsContext* context = [NSGraphicsContext graphicsContextWithGraphicsPort:(void *)cgContext flipped:YES]; + if(context) { + // Create a rect to display + NSRect theRect = NSMakeRect(0.0,0.0, canvasSize.width, canvasSize.height); + + [NSGraphicsContext saveGraphicsState]; + [NSGraphicsContext setCurrentContext:context]; + + [context saveGraphicsState]; + + [renderedImage drawAtPoint:NSZeroPoint fromRect:theRect operation:NSCompositingOperationSourceOver fraction:1]; + + //This line sets the context back to what it was when we're done + [NSGraphicsContext restoreGraphicsState]; + } + + // Flush request graphics context. + QLPreviewRequestFlushContext(preview, cgContext); + + CFRelease(cgContext); + } + + CGImageRelease(image_ref); + + if ([fileManager fileExistsAtPath:ansiCacheFile] == YES) + { + [fileManager removeItemAtPath:ansiCacheFile error:nil]; + } + + if ([fileManager fileExistsAtPath:retinaCacheFile] == YES) + { + [fileManager removeItemAtPath:retinaCacheFile error:nil]; + } + } + + return noErr; + } + } + return kQLReturnNoError; +} + +void CancelPreviewGeneration(void* thisInterface, QLPreviewRequestRef preview) +{ + // Not implemented. +} + diff --git a/QLAnsilove/QLAnsilove/GenerateThumbnailForURL.m b/QLAnsilove/QLAnsilove/GenerateThumbnailForURL.m new file mode 100644 index 0000000..2884a7a --- /dev/null +++ b/QLAnsilove/QLAnsilove/GenerateThumbnailForURL.m @@ -0,0 +1,150 @@ +// +// GenerateThumbnailForURL.m +// QLAnsilove +// +// QLAnsilove is Copyright © 2017, Christian R. Vozar / Alpha King +// AnsiLove.framework is Copyright © 2010-2017, Stefan Vogt +// Ansilove/C is Copyright © 2011-2017, Stefan Vogt, Brian Cassidy, and Frederic Cambus +// +// All rights reserved. +// + +#import "Shared.h" + +#include +#include +#include +#include + +OSStatus +GenerateThumbnailForURL(void *thisInterface, + QLThumbnailRequestRef thumbnail, + CFURLRef url, + CFStringRef contentTypeUTI, + CFDictionaryRef options, + CGSize maxSize) +{ + @autoreleasepool { + // Generate 'Application Support' folder. + NSFileManager *fileManager = [[NSFileManager alloc] init]; + + NSString *folder = @"~/Library/Application Support/QLAnsilove/"; + folder = [folder stringByExpandingTildeInPath]; + + if ([fileManager fileExistsAtPath:folder] == NO) + { + [fileManager createDirectoryAtPath:folder + withIntermediateDirectories:YES + attributes:nil + error:nil]; + } + + // Instantiate ALAnsiGenerator. + ansiGen = [ALAnsiGenerator new]; + + // Explicitly utilize filename extension in case UTI is not registered for file. + NSString* extension = [[(__bridge NSURL*)url pathExtension] lowercaseString]; + if ([extension isEqualToString:@"ans"] || [extension isEqualToString:@"nfo"] || [extension isEqualToString:@"mem"] || [extension isEqualToString:@"diz"] || [extension isEqualToString:@"asc"] || [extension isEqualToString:@"idf"] || [extension isEqualToString:@"xb"] || [extension isEqualToString:@"tnd"] || [extension isEqualToString:@"cia"]) + { + alBits = @"8"; + alColumns = @"160"; + + bool isIceColors = YES; + // Determine if iCE Colors should stay on or off + + // If there is no content string, create one. + if (contentString == nil) { + contentString = [[NSMutableAttributedString alloc] initWithString:@""]; + } + + // Get current file URL and convert it to an UNIX path. + NSURL *tnCurrentURL = (__bridge NSURL *)url; + alURLString = [tnCurrentURL path]; + + // Get currrent file name without any path informations. + NSString *tnPureFileName = [alURLString lastPathComponent]; + + ansiCacheFile = [NSString stringWithFormat: + @"~/Library/Application Support/QLAnsilove/%@.png", tnPureFileName]; + + retinaCacheFile = [NSString stringWithFormat: + @"~/Library/Application Support/QLAnsilove/%@@2x.png", tnPureFileName]; + + // Expand tilde in cache file path. + ansiCacheFile = [ansiCacheFile stringByExpandingTildeInPath]; + retinaCacheFile = [retinaCacheFile stringByExpandingTildeInPath]; + + // Create string we can pass as outputfile flag. + alOutputString = [NSString stringWithFormat: + @"~/Library/Application Support/QLAnsilove/%@", tnPureFileName]; + alOutputString = [alOutputString stringByExpandingTildeInPath]; + + // Invoke AnsiLove to generate rendered image. + [ansiGen renderAnsiFile:alURLString + outputFile:alOutputString + font:@"80x25" + bits:alBits + iceColors:isIceColors + columns:alColumns + retina:YES]; + + // Wait for AnsiLove.framework to finish rendering. + // TODO: Replace with ansilove.framework rendering out an NSImage rather than a file to disk. + [NSThread sleepForTimeInterval:0.1]; + + NSImage *renderedImage = [[NSImage alloc] initWithContentsOfFile:ansiGen.ansi_retinaOutputFile]; + + CGDataProviderRef imgDataProvider = CGDataProviderCreateWithCFData((CFDataRef)[NSData dataWithContentsOfFile:ansiCacheFile]); + CGImageRef image_ref = CGImageCreateWithPNGDataProvider(imgDataProvider, NULL, true, kCGRenderingIntentDefault); + + canvasSize = renderedImage.size; + + // Draw rendered png to graphics context provided by QuickLook. + if (image_ref != NULL) + { + CGContextRef cgContext = QLThumbnailRequestCreateContext(thumbnail, *(CGSize *)&canvasSize, false, NULL); + if(cgContext) { + NSGraphicsContext* context = [NSGraphicsContext graphicsContextWithGraphicsPort:(void *)cgContext flipped:YES]; + if(context) { + + NSRect theRect = NSMakeRect(0.0,0.0, canvasSize.width, canvasSize.height); + + [NSGraphicsContext saveGraphicsState]; + [NSGraphicsContext setCurrentContext:context]; + + [context saveGraphicsState]; + + [renderedImage drawAtPoint:NSZeroPoint fromRect:theRect operation:NSCompositingOperationSourceOver fraction:1]; + + // Set context back. + [NSGraphicsContext restoreGraphicsState]; + } + + // Flush request graphics context. + QLThumbnailRequestFlushContext(thumbnail, cgContext); + + CFRelease(cgContext); + } + CGImageRelease(image_ref); + + if ([fileManager fileExistsAtPath:ansiCacheFile] == YES) + { + [fileManager removeItemAtPath:ansiCacheFile error:nil]; + } + + if ([fileManager fileExistsAtPath:retinaCacheFile] == YES) + { + [fileManager removeItemAtPath:retinaCacheFile error:nil]; + } + } + return noErr; + } + } + return kQLReturnNoError; +} + +void CancelThumbnailGeneration(void* thisInterface, QLThumbnailRequestRef thumbnail) +{ + // Not implemented. +} + diff --git a/QLAnsilove/QLAnsilove/Info.plist b/QLAnsilove/QLAnsilove/Info.plist new file mode 100644 index 0000000..b7fe5f5 --- /dev/null +++ b/QLAnsilove/QLAnsilove/Info.plist @@ -0,0 +1,369 @@ + + + + + UTExportedTypeDeclarations + + + UTTypeDescription + iCE Draw Document + UTTypeConformsTo + + public.data + + UTTypeIdentifier + org.ansilove.idf + UTTypeTagSpecification + + public.filename-extension + + idf + + + + + UTTypeDescription + PCBoard BBS Document + UTTypeConformsTo + + public.data + + UTTypeIdentifier + org.ansilove.pcb + UTTypeTagSpecification + + public.filename-extension + + pcb + + + + + UTTypeDescription + Tundra Draw Document + UTTypeConformsTo + + public.data + + UTTypeIdentifier + org.ansilove.tnd + UTTypeTagSpecification + + public.filename-extension + + tnd + + + + + UTTypeDescription + eXtended Binary Document + UTTypeConformsTo + + public.data + + UTTypeIdentifier + org.ansilove.xb + UTTypeTagSpecification + + public.filename-extension + + xb + + + + + UTTypeDescription + Release Information Document + UTTypeConformsTo + + public.data + + UTTypeIdentifier + org.ansilove.nfo + UTTypeTagSpecification + + public.filename-extension + + nfo + + + + + UTTypeDescription + Member Description Document + UTTypeConformsTo + + public.data + + UTTypeIdentifier + org.ansilove.mem + UTTypeTagSpecification + + public.filename-extension + + mem + + + + + UTTypeDescription + Art Pack Description Document + UTTypeConformsTo + + public.data + + UTTypeIdentifier + org.ansilove.diz + UTTypeTagSpecification + + public.filename-extension + + diz + + + + + UTTypeDescription + ASCii Art Document + UTTypeConformsTo + + public.data + + UTTypeIdentifier + org.ansilove.asc + UTTypeTagSpecification + + public.firename-extension + + asc + + + + + UTTypeDescription + ANSi Art Document + UTTypeConformsTo + + public.data + + UTTypeIdentifier + org.ansilove.ans + UTTypeTagSpecification + + com.apple.ostype + TEXT + public.filename-extension + + ice + cia + ans + diz + nfo + + + + + UTImportedTypeDeclarations + + + UTTypeReferenceURL + http://blocktronics.org + UTTypeIdentifier + org.blocktronics.quicklook + UTTypeConformsTo + + public.data + public.item + + UTTypeDescription + ANSi Document + UTTypeTagSpecification + + public.filename-extension + + ans + diz + asc + xb + nfo + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDocumentTypes + + + CFBundleTypeExtensions + + idf + + CFBundleTypeName + iCE Draw File (.idf) + CFBundleTypeRole + QLGenerator + LSItemContentTypes + + org.ansilove.idf + org.blocktronics.idf + com.byteproject.ascension.idf + + + + LSItemContentTypes + + org.ansilove.tnd + org.blocktronics.tnd + com.byteproject.ascension.tnd + + CFBundleTypeRole + QLGenerator + CFBundleTypeName + Tundra Draw Document + CFBundleTypeExtensions + + tnd + + + + LSItemContentTypes + + org.ansilove.xb + org.blocktronics.xb + com.byteproject.ascension.xb + + CFBundleTypeRole + QLGenerator + CFBundleTypeName + eXtended Binary Art Document + CFBundleTypeExtensions + + xb + + + + LSItemContentTypes + + org.ansilove.ans + org.blocktronics.ans + com.byteproject.ascension.ans + + CFBundleTypeRole + QLGenerator + CFBundleTypeName + ANSi Art Document + CFBundleTypeExtensions + + ice + cia + ans + + + + LSItemContentTypes + + org.ansilove.asc + org.blocktronics.asc + com.byteproject.ascension.asc + + CFBundleTypeRole + QLGenerator + CFBundleTypeName + ASCii Art Document + CFBundleTypeExtensions + + asc + + + + LSItemContentTypes + + org.ansilove.diz + org.blocktronics.diz + com.byteproject.ascension.diz + + CFBundleTypeRole + QLGenerator + CFBundleTypeName + Art Pack Description Document + CFBundleTypeExtensions + + diz + + + + LSItemContentTypes + + org.ansilove.nfo + org.blocktronics.nfo + com.byteproject.ascension.nfo + + CFBundleTypeRole + QLGenerator + CFBundleTypeName + Release Information Document + CFBundleTypeExtensions + + nfo + + + + CFBundleTypeName + Undeclared UTIs for AnsiLove + CFBundleTypeRole + QLGenerator + LSItemContentTypes + + org.blocktronics.quicklook + dyn.ah62d4rv4ge80k4p4 + dyn.ah62d4rv4ge80c5xx + dyn.ah62d4rv4ge81u2u + + + + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + CFPlugInDynamicRegisterFunction + + CFPlugInDynamicRegistration + NO + CFPlugInFactories + + C21AAD3D-D7CE-4D9B-9537-FB4F492C03DD + QuickLookGeneratorPluginFactory + + CFPlugInTypes + + 5E2D9680-5022-40FA-B806-43349622E5B9 + + C21AAD3D-D7CE-4D9B-9537-FB4F492C03DD + + + CFPlugInUnloadFunction + + NSHumanReadableCopyright + Copyright © 2017 Christian R. Vozar. All rights reserved. + QLNeedsToBeRunInMainThread + + QLPreviewHeight + 600 + QLPreviewWidth + 800 + QLSupportsConcurrentRequests + + QLThumbnailMinimumSize + 17 + + diff --git a/QLAnsilove/QLAnsilove/Shared.h b/QLAnsilove/QLAnsilove/Shared.h new file mode 100644 index 0000000..e247bc0 --- /dev/null +++ b/QLAnsilove/QLAnsilove/Shared.h @@ -0,0 +1,32 @@ +// +// Shared.h +// QLAnsilove +// +// Created by Christian Vozar on 11/2/17. +// Copyright © 2017 Ansilove. All rights reserved. +// + +#import + +// instances +ALAnsiGenerator *ansiGen; + +// strings +NSMutableAttributedString *contentString; +NSMutableAttributedString *rawAnsiString; +NSString *ansiCacheFile; +NSString *retinaCacheFile; +NSString *exportCacheFile; +NSString *exportURLString; +NSString *alURLString; +NSString *alOutputString; +NSString *alFont; +NSString *alBits; +NSString *alColumns; +NSString *fontName; +NSStringEncoding txtEncoding; +NSStringEncoding exportEncoding; +NSSize canvasSize; + +// images +NSImage *renderedAnsiImage; diff --git a/QLAnsilove/QLAnsilove/main.c b/QLAnsilove/QLAnsilove/main.c new file mode 100644 index 0000000..1492aba --- /dev/null +++ b/QLAnsilove/QLAnsilove/main.c @@ -0,0 +1,218 @@ +//============================================================================== +// +// DO NO MODIFY THE CONTENT OF THIS FILE +// +// This file contains the generic CFPlug-in code necessary for your generator +// To complete your generator implement the function in GenerateThumbnailForURL/GeneratePreviewForURL.c +// +//============================================================================== + + + + + + +#include +#include +#include +#include + +// ----------------------------------------------------------------------------- +// constants +// ----------------------------------------------------------------------------- + +// Don't modify this line +#define PLUGIN_ID "089F9C7E-A10E-4EC6-A410-FE7BDD466AC1" + +// +// Below is the generic glue code for all plug-ins. +// +// You should not have to modify this code aside from changing +// names if you decide to change the names defined in the Info.plist +// + + +// ----------------------------------------------------------------------------- +// typedefs +// ----------------------------------------------------------------------------- + +// The thumbnail generation function to be implemented in GenerateThumbnailForURL.c +OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef thumbnail, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options, CGSize maxSize); +void CancelThumbnailGeneration(void* thisInterface, QLThumbnailRequestRef thumbnail); + +// The preview generation function to be implemented in GeneratePreviewForURL.c +OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options); +void CancelPreviewGeneration(void *thisInterface, QLPreviewRequestRef preview); + +// The layout for an instance of QuickLookGeneratorPlugIn +typedef struct __QuickLookGeneratorPluginType +{ + void *conduitInterface; + CFUUIDRef factoryID; + UInt32 refCount; +} QuickLookGeneratorPluginType; + +// ----------------------------------------------------------------------------- +// prototypes +// ----------------------------------------------------------------------------- +// Forward declaration for the IUnknown implementation. +// + +QuickLookGeneratorPluginType *AllocQuickLookGeneratorPluginType(CFUUIDRef inFactoryID); +void DeallocQuickLookGeneratorPluginType(QuickLookGeneratorPluginType *thisInstance); +HRESULT QuickLookGeneratorQueryInterface(void *thisInstance,REFIID iid,LPVOID *ppv); +void *QuickLookGeneratorPluginFactory(CFAllocatorRef allocator,CFUUIDRef typeID); +ULONG QuickLookGeneratorPluginAddRef(void *thisInstance); +ULONG QuickLookGeneratorPluginRelease(void *thisInstance); + +// ----------------------------------------------------------------------------- +// myInterfaceFtbl definition +// ----------------------------------------------------------------------------- +// The QLGeneratorInterfaceStruct function table. +// +static QLGeneratorInterfaceStruct myInterfaceFtbl = { + NULL, + QuickLookGeneratorQueryInterface, + QuickLookGeneratorPluginAddRef, + QuickLookGeneratorPluginRelease, + NULL, + NULL, + NULL, + NULL +}; + + +// ----------------------------------------------------------------------------- +// AllocQuickLookGeneratorPluginType +// ----------------------------------------------------------------------------- +// Utility function that allocates a new instance. +// You can do some initial setup for the generator here if you wish +// like allocating globals etc... +// +QuickLookGeneratorPluginType *AllocQuickLookGeneratorPluginType(CFUUIDRef inFactoryID) +{ + QuickLookGeneratorPluginType *theNewInstance; + + theNewInstance = (QuickLookGeneratorPluginType *)malloc(sizeof(QuickLookGeneratorPluginType)); + memset(theNewInstance,0,sizeof(QuickLookGeneratorPluginType)); + + /* Point to the function table Malloc enough to store the stuff and copy the filler from myInterfaceFtbl over */ + theNewInstance->conduitInterface = malloc(sizeof(QLGeneratorInterfaceStruct)); + memcpy(theNewInstance->conduitInterface,&myInterfaceFtbl,sizeof(QLGeneratorInterfaceStruct)); + + /* Retain and keep an open instance refcount for each factory. */ + theNewInstance->factoryID = CFRetain(inFactoryID); + CFPlugInAddInstanceForFactory(inFactoryID); + + /* This function returns the IUnknown interface so set the refCount to one. */ + theNewInstance->refCount = 1; + return theNewInstance; +} + +// ----------------------------------------------------------------------------- +// DeallocQuickLookGeneratorPluginType +// ----------------------------------------------------------------------------- +// Utility function that deallocates the instance when +// the refCount goes to zero. +// In the current implementation generator interfaces are never deallocated +// but implement this as this might change in the future +// +void DeallocQuickLookGeneratorPluginType(QuickLookGeneratorPluginType *thisInstance) +{ + CFUUIDRef theFactoryID; + + theFactoryID = thisInstance->factoryID; + /* Free the conduitInterface table up */ + free(thisInstance->conduitInterface); + + /* Free the instance structure */ + free(thisInstance); + if (theFactoryID){ + CFPlugInRemoveInstanceForFactory(theFactoryID); + CFRelease(theFactoryID); + } +} + +// ----------------------------------------------------------------------------- +// QuickLookGeneratorQueryInterface +// ----------------------------------------------------------------------------- +// Implementation of the IUnknown QueryInterface function. +// +HRESULT QuickLookGeneratorQueryInterface(void *thisInstance,REFIID iid,LPVOID *ppv) +{ + CFUUIDRef interfaceID; + + interfaceID = CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault,iid); + + if (CFEqual(interfaceID,kQLGeneratorCallbacksInterfaceID)){ + /* If the Right interface was requested, bump the ref count, + * set the ppv parameter equal to the instance, and + * return good status. + */ + ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType *)thisInstance)->conduitInterface)->GenerateThumbnailForURL = GenerateThumbnailForURL; + ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType *)thisInstance)->conduitInterface)->CancelThumbnailGeneration = CancelThumbnailGeneration; + ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType *)thisInstance)->conduitInterface)->GeneratePreviewForURL = GeneratePreviewForURL; + ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType *)thisInstance)->conduitInterface)->CancelPreviewGeneration = CancelPreviewGeneration; + ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType*)thisInstance)->conduitInterface)->AddRef(thisInstance); + *ppv = thisInstance; + CFRelease(interfaceID); + return S_OK; + }else{ + /* Requested interface unknown, bail with error. */ + *ppv = NULL; + CFRelease(interfaceID); + return E_NOINTERFACE; + } +} + +// ----------------------------------------------------------------------------- +// QuickLookGeneratorPluginAddRef +// ----------------------------------------------------------------------------- +// Implementation of reference counting for this type. Whenever an interface +// is requested, bump the refCount for the instance. NOTE: returning the +// refcount is a convention but is not required so don't rely on it. +// +ULONG QuickLookGeneratorPluginAddRef(void *thisInstance) +{ + ((QuickLookGeneratorPluginType *)thisInstance )->refCount += 1; + return ((QuickLookGeneratorPluginType*) thisInstance)->refCount; +} + +// ----------------------------------------------------------------------------- +// QuickLookGeneratorPluginRelease +// ----------------------------------------------------------------------------- +// When an interface is released, decrement the refCount. +// If the refCount goes to zero, deallocate the instance. +// +ULONG QuickLookGeneratorPluginRelease(void *thisInstance) +{ + ((QuickLookGeneratorPluginType*)thisInstance)->refCount -= 1; + if (((QuickLookGeneratorPluginType*)thisInstance)->refCount == 0){ + DeallocQuickLookGeneratorPluginType((QuickLookGeneratorPluginType*)thisInstance ); + return 0; + }else{ + return ((QuickLookGeneratorPluginType*) thisInstance )->refCount; + } +} + +// ----------------------------------------------------------------------------- +// QuickLookGeneratorPluginFactory +// ----------------------------------------------------------------------------- +void *QuickLookGeneratorPluginFactory(CFAllocatorRef allocator,CFUUIDRef typeID) +{ + QuickLookGeneratorPluginType *result; + CFUUIDRef uuid; + + /* If correct type is being requested, allocate an + * instance of kQLGeneratorTypeID and return the IUnknown interface. + */ + if (CFEqual(typeID,kQLGeneratorTypeID)){ + uuid = CFUUIDCreateFromString(kCFAllocatorDefault,CFSTR(PLUGIN_ID)); + result = AllocQuickLookGeneratorPluginType(uuid); + CFRelease(uuid); + return result; + } + /* If the requested type is incorrect, return NULL. */ + return NULL; +} + diff --git a/README.markdown b/README.markdown new file mode 100644 index 0000000..0aa8d9a --- /dev/null +++ b/README.markdown @@ -0,0 +1,31 @@ +# QLAnsilove + +macOS QuickLook plugin for text-mode art supported by the ansilove library. All file formats supported by ansilove are supported by the plugin. + +The latest compiled version can be downloaded from [Releases](https://github.com/ansilove/QLAnsilove/releases). + +![example rendered folder of files](https://github.com/ansilove/QLAnsilove/blob/master/rendered-folder-example.png) + +## Installation + +Decompress the .zip file and place `QLAnsilove.qlgenerator` in your `/Library/QuickLook` folder. + +You may need to logout of your macOS session or reload the quicklook demon for the plugin to take effect. To reload the quicklook daemon and refresh plugins type `qlmanage -r` from the terminal. + +# File Types Supported + +- ANSi (.ANS, .CIA, .ICE) +- Binary (.BIN) +- Artworx (.ADF) +- iCE Draw (.IDF) +- Xbin (.XB) +- PCBoard (.PCB) +- Tundra (.TND) +- ASCII (.ASC) +- Release info (.NFO) +- Description in zipfile (.DIZ) +- Membership in zipfile (.MEM) + +## Acknowledgements + +This plugin is based on the amazing work of [ansilove/C](https://github.com/ansilove/ansilove) and the [ansilove.framework](https://github.com/ansilove/AnsiLove.framework). diff --git a/README.md b/README.md deleted file mode 100644 index 7aa384c..0000000 --- a/README.md +++ /dev/null @@ -1 +0,0 @@ -# QLAnsilove \ No newline at end of file diff --git a/rendered-folder-example.png b/rendered-folder-example.png new file mode 100644 index 0000000..4da0948 Binary files /dev/null and b/rendered-folder-example.png differ