Compare commits

...

49 Commits

Author SHA1 Message Date
Kazuki Sakamoto 57900025aa MacVim Snapshot 88
Binary targets OS X 10.8(Mountain Lion), 10.9(Mavericks), 10.10(Yosemite), and 10.11(El Capitan)

- Vim patch 7.4.979
- Fix Emoji unicode characters range
- Fix redraw and redrawstatus issue

Script interfaces have compatibility with these versions

- Lua 5.2
- Perl 5.16
- Python2 2.7
- Python3 3.5
- Ruby 2.0
2015-12-25 17:21:58 -08:00
Kazuki Sakamoto 0d78cd385f Merge pull request #187 from macvim-dev/fix/emoji_range
Fix Emoji range #184
2015-12-25 01:35:38 -08:00
Kazuki Sakamoto dd3bc8209b Fix Emoji range #184 2015-12-25 01:19:10 -08:00
Kazuki Sakamoto 134218f290 Merge pull request #186 from macvim-dev/fix/fail-safe-recurseDraw
Fix a possible infinite recursive recurseDraw call
2015-12-25 00:08:58 -08:00
Kazuki Sakamoto 998888524e Fix a possible infinite recursive recurseDraw call 2015-12-24 23:55:08 -08:00
Kazuki Sakamoto 315c8bd311 Merge pull request #183 from macvim-dev/fix/redraw
Use gui_macvim_force_flush for redraw/redrawstatus
2015-12-19 22:24:11 -08:00
Kazuki Sakamoto 05e488d369 Use gui_macvim_force_flush for redraw/redrawstatus 2015-12-19 22:10:37 -08:00
Kazuki Sakamoto dc8cacd018 Merge pull request #177 from macvim-dev/fix/remove_deprecated_make_icons
Remove deprecated Icon generation code
2015-12-19 21:34:35 -08:00
Kazuki Sakamoto 6ea9b4ad26 Merge pull request #181 from macvim-dev/fix/enable_python2_and_python3
Add --with-properly-linked-python2-python3
2015-12-19 11:38:18 -08:00
Kazuki Sakamoto be450c3825 Add --with-properly-linked-python2-python3
It enables `python` and `python3` commands at the same time. You will
get `deadly signal SEGV` if you don't have properly linked Python 2 and
Python 3.
2015-12-19 10:53:15 -08:00
Kazuki Sakamoto f595588011 Merge remote-tracking branch 'vim/master' 2015-12-19 09:07:55 -08:00
Bram Moolenaar 4a8c2cfc56 patch 7.4.979
Problem:    When changing the crypt key the blocks read from disk are not
            decrypted.
Solution:   Also call ml_decrypt_data() when mf_old_key is set. (Ken Takata)
2015-12-19 15:28:18 +01:00
Bram Moolenaar c42b9c670e patch 7.4.978
Problem:    test_cdo fails when using another language than English.
Solution:   Set the language to C. (Dominique Pelle)
2015-12-19 15:15:54 +01:00
Kazuki Sakamoto 32f12120fc Merge pull request #180 from macvim-dev/fix/make_clean
Remove qlstephen/build in make clean
2015-12-19 00:41:19 -08:00
Kazuki Sakamoto abb224eaab Remove qlstephen/build in make clean 2015-12-19 00:20:05 -08:00
Kazuki Sakamoto 68f4341bc1 Remove deprecated Icon generation code
fix #176
2015-12-18 20:23:32 -08:00
Kazuki Sakamoto 970d2a871e Update .travis.yml for MacVim
Use Xcode 7.2
2015-12-18 04:46:14 -08:00
Kazuki Sakamoto e32eccfe62 Merge remote-tracking branch 'vim/master' 2015-12-17 20:50:04 -08:00
Bram Moolenaar 9bc01ebb95 patch 7.4.977
Problem:    'linebreak' does not work properly when using "space" in
            'listchars'.
Solution:   (Hirohito Higashi, Christian Brabandt)
2015-12-17 21:14:58 +01:00
Kazuki Sakamoto ac15324228 Merge remote-tracking branch 'vim/master' 2015-12-17 07:07:53 -08:00
Bram Moolenaar 8def26a0f5 patch 7.4.976
Problem:    When compiling Vim for MSYS2 (linked with msys-2.0.dll), the Win32
            clipboard is not enabled.
Solution:   Recognize MSYS like CYGWIN. (Ken Takata)
2015-12-17 15:34:53 +01:00
Bram Moolenaar 75e3ad0199 patch 7.4.975
Problem:    Using ":sort" on a very big file sometimes causes text to be
            corrupted. (John Beckett)
Solution:   Copy the line into a buffer before calling ml_append().
2015-12-17 15:07:32 +01:00
Bram Moolenaar f29a82dcd0 patch 7.4.974
Problem:    When using :diffsplit the cursor jumps to the first line.
Solution:   Put the cursor on the line related to where the cursor was before
            the split.
2015-12-17 15:03:55 +01:00
Bram Moolenaar 6f62fed349 patch 7.4.973
Problem:    When pasting on the command line line breaks result in literal
            <CR> characters. This makes pasting a long file name difficult.
Solution:   Skip the characters.
2015-12-17 14:04:24 +01:00
Kazuki Sakamoto 2a0760567b MacVim Snapshot 87
Binary targets OS X 10.8(Mountain Lion), 10.9(Mavericks), 10.10(Yosemite), and 10.11(El Capitan)

- Vim patch 7.4.972
- Import QLStephen to quick-look MacVim file types
- Fix redraw and redrawstatus issue

Script interfaces have compatibility with these versions

- Lua 5.2
- Perl 5.16
- Python2 2.7
- Python3 3.5
- Ruby 2.0
2015-12-16 18:50:18 -08:00
Kazuki Sakamoto 2d3163f649 Merge pull request #175 from macvim-dev/fix/redraw_redrawstatus
Do flush in ex_redraw and ex_redrawstatus
2015-12-16 18:35:41 -08:00
Kazuki Sakamoto e7ca3fe789 Do flush in ex_redraw and ex_redrawstatus
Fix #174
2015-12-15 08:58:29 -08:00
Kazuki Sakamoto ddc5c148e8 Merge remote-tracking branch 'vim/master' 2015-12-13 08:44:46 -08:00
Bram Moolenaar a988496706 patch 7.4.972
Problem:    Memory leak when there is an error in setting an option.
Solution:   Free the saved value (Christian Brabandt)
2015-12-13 15:08:56 +01:00
Bram Moolenaar 099fdde0f0 patch 7.4.971
Problem:    The asin() function can't be used.
Solution:   Sort the function table properly. (Watiko)
2015-12-13 14:45:21 +01:00
Kazuki Sakamoto 01672932c6 Merge remote-tracking branch 'vim/master' 2015-12-12 20:57:10 -08:00
Bram Moolenaar 9ec021a2b0 patch 7.4.970
Problem:    Rare crash in getvcol(). (Timo Mihaljov)
Solution:   Check for the buffer being NULL in init_preedit_start_col.
            (Hirohito Higashi, Christian Brabandt)
2015-12-12 16:23:29 +01:00
Kazuki Sakamoto abca1283d2 Merge pull request #172 from macvim-dev/feature/quicklook
Import QLStephen to quick-look MacVim file types
2015-12-12 01:09:56 -08:00
Kazuki Sakamoto 518ae7168a Import QLStephen to quick-look MacVim file types 2015-12-12 01:05:23 -08:00
Kazuki Sakamoto 92dabee8ac MacVim Snapshot 86
Binary targets OS X 10.8(Mountain Lion), 10.9(Mavericks), 10.10(Yosemite), and 10.11(El Capitan)

- Vim patch 7.4.969
- Add MMNoTitleBarWindow and MMUseMouseTime

Script interfaces have compatibility with these versions

- Lua 5.2
- Perl 5.16
- Python2 2.7
- Python3 3.5
- Ruby 2.0
2015-12-11 14:34:30 -08:00
Kazuki Sakamoto 45fa1f955f s/Key// 2015-12-11 14:33:57 -08:00
Kazuki Sakamoto 421df8e160 Merge pull request #171 from macvim-dev/feature/doc_defaults
Add MMNoTitleBarWindowKey and MMUseMouseTime short description
2015-12-11 14:28:46 -08:00
Kazuki Sakamoto 584eb4b164 Add MMNoTitleBarWindowKey and MMUseMouseTime short description 2015-12-11 14:27:50 -08:00
Kazuki Sakamoto f1d0ecd1c8 Merge remote-tracking branch 'vim/master' 2015-12-11 14:15:07 -08:00
Bram Moolenaar 35be4534c0 patch 7.4.969
Problem:    Compiler warnings on Windowx x64 build.
Solution:   Add type casts. (Mike Williams)
2015-12-11 22:38:36 +01:00
Bram Moolenaar b65c749ac5 patch 7.4.968
Problem:    test86 and test87 are flaky in Appveyor.
Solution:   Reduce the count from 8 to 7. (suggested by ZyX)
2015-12-11 20:53:58 +01:00
Bram Moolenaar 6b90351786 patch 7.4.967
Problem:    Cross compilation on MS-windows doesn't work well.
Solution:   Tidy up cross compilation across architectures with Visual Studio.
            (Mike Williams)
2015-12-11 19:38:44 +01:00
Bram Moolenaar 49222bee65 patch 7.4.966
Problem:    Configure doesn't work with a space in a path.
Solution:   Put paths in quotes. (James McCoy, close #525)
2015-12-11 18:11:30 +01:00
Bram Moolenaar 941aea2b97 patch 7.4.965
Problem:    On FreeBSD /dev/fd/ files are special.
Solution:   Use is_dev_fd_file() also for FreeBSD. (Derek Schrock, closes #521)
2015-12-11 17:14:27 +01:00
Bram Moolenaar 91376b6387 patch 7.4.964
Problem:    Test 87 doesn't work in a shadow directory.
Solution:   Handle the extra subdirectory. (James McCoy, closes #515)
2015-12-11 16:17:02 +01:00
Kazuki Sakamoto e387a4c606 Merge pull request #168 from macvim-dev/feature/mousetime
Add MMUseMouseTime, Revise #77
2015-12-09 19:09:53 -08:00
Kazuki Sakamoto cbd8ff0cb4 Add MMUseMouseTime, Revise #77
`MMUseMouseTime` allows to override the time threshold for detecting multiple
mouse down events using Vim `mousetime` option.

    $ defaults write org.vim.MacVim MMUseMouseTime -bool TRUE
2015-12-09 15:02:36 -08:00
Kazuki Sakamoto 11bd9b9b1d Merge pull request #111 from macvim-dev/feature/no_title_bar_window
MMNoTitleBarWindowKey for hiding titlebar
2015-12-08 20:50:53 -08:00
Kazuki Sakamoto fb26de78b0 MMNoTitleBarWindowKey for hiding titlebar 2015-12-07 21:13:47 -08:00
61 changed files with 4436 additions and 3163 deletions
+6 -1
View File
@@ -97,8 +97,13 @@ src/MacVim/PSMTabBarControl/PSMTabBarControl.xcodeproj/*.mode1v3
src/MacVim/PSMTabBarControl/PSMTabBarControl.xcodeproj/*.pbxuser
src/MacVim/PSMTabBarControl/PSMTabBarControl.xcodeproj/xcuserdata
src/MacVim/PSMTabBarControl/build
src/MacVim/PSMTabBarControl/build
src/MacVim/qlstephen/QuickLookStephen.xcodeproj/*.mode1
src/MacVim/qlstephen/QuickLookStephen.xcodeproj/*.mode1v3
src/MacVim/qlstephen/QuickLookStephen.xcodeproj/*.pbxuser
src/MacVim/qlstephen/QuickLookStephen.xcodeproj/xcuserdata
src/MacVim/qlstephen/build
src/MacVim/build
src/MacVim/DerivedData
src/TAGS
src/Vim
src/auto/config.cache
+1 -1
View File
@@ -3,7 +3,7 @@ language: c
os:
- osx
osx_image: xcode7.1
osx_image: xcode7.2
compiler:
- clang
+2
View File
@@ -259,6 +259,7 @@ MMDialogsTrackPwd open/save dialogs track the Vim pwd [bool]
MMLoginShellArgument login shell parameter [string]
MMLoginShellCommand which shell to use to launch Vim [string]
MMNoFontSubstitution disable automatic font substitution [bool]
MMNoTitleBarWindow hide title bar [bool]
MMShowAddTabButton enable "add tab" button on tabline [bool]
MMTabMaxWidth maximum width of a tab [int]
MMTabMinWidth minimum width of a tab [int]
@@ -269,6 +270,7 @@ MMTextInsetRight text area offset in pixels [int]
MMTextInsetTop text area offset in pixels [int]
MMTexturedWindow use brushed metal window (Tiger only) [bool]
MMTranslateCtrlClick interpret ctrl-click as right-click [bool]
MMUseMouseTime use mousetime to detect multiple clicks [bool]
MMVerticalSplit files open in vertical splits [bool]
MMZoomBoth zoom button maximizes both directions [bool]
+2
View File
@@ -46,6 +46,8 @@ Dmitry Vazhov\
\
Thank you to {\field{\*\fldinst{HYPERLINK "http://www.positivespinmedia.com"}}{\fldrslt Positive Spin Media}} for the PSMTabBarControl Framework.\
\
Thank you to {\field{\*\fldinst{HYPERLINK "https://whomwah.github.io/qlstephen/"}}{\fldrslt Duncan Robertson}} for the QLStephen QuickLook plugin.\
\
Toolbar icons by {\field{\*\fldinst{HYPERLINK "http://www.mattballdesign.com/"}}{\fldrslt Matt Ball}} (free Developer Icons), {\field{\*\fldinst{HYPERLINK "http://www.jonasraskdesign.com/"}}{\fldrslt Jonas Rask}} (Danish Royalty Free icon set), and {\field{\*\fldinst{HYPERLINK "http://www.everaldo.com"}}{\fldrslt Everaldo Coelho}} (Crystal Project Icons, released under LGPL license).\
\
Revamped MacVim icon by RIC.\
+1 -2
View File
@@ -8,7 +8,6 @@
<!-- When adding support for a new file type:
1. Add entry to CFBundleDocumentTypes
2. Add entry to UTExportedTypeDeclarations below (for Quick Look)
3. Add entry to icons/make_icons.py script (for document icon)
For a list of UTIs, see
http://developer.apple.com/documentation/Carbon/Conceptual/
@@ -1256,7 +1255,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>85</string>
<string>88</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
+3 -2
View File
@@ -1844,6 +1844,7 @@ static void netbeansReadCallback(CFSocketRef s,
[NSNumber numberWithBool:mmta], @"p_mmta",
[NSNumber numberWithInt:numTabs], @"numTabs",
[NSNumber numberWithInt:fuoptions_flags], @"fullScreenOptions",
[NSNumber numberWithLong:p_mouset], @"p_mouset",
nil];
// Put the state before all other messages.
@@ -1932,12 +1933,12 @@ static void netbeansReadCallback(CFSocketRef s,
int col = *((int*)bytes); bytes += sizeof(int);
int button = *((int*)bytes); bytes += sizeof(int);
int flags = *((int*)bytes); bytes += sizeof(int);
int count = *((int*)bytes); bytes += sizeof(int);
int repeat = *((int*)bytes); bytes += sizeof(int);
button = eventButtonNumberToVimMouseButton(button);
if (button >= 0) {
flags = eventModifierFlagsToVimMouseModMask(flags);
gui_send_mouse_event(button, col, row, count>1, flags);
gui_send_mouse_event(button, col, row, repeat, flags);
}
} else if (MouseUpMsgID == msgid) {
if (!data) return;
+6
View File
@@ -1261,6 +1261,12 @@ recurseDraw(const unichar *chars, CGGlyph *glyphs, CGPoint *positions,
CFRelease(fallback);
}
if (glyphs == g) {
// No valid chars in the glyphs. Exit from the possible infinite
// recursive call.
break;
}
chars = c;
glyphs = g;
positions = p;
+2
View File
@@ -35,6 +35,8 @@
BOOL interpretKeyEventsSwallowedKey;
NSEvent *currentEvent;
NSMutableDictionary *signImages;
BOOL useMouseTime;
NSDate *mouseDownTime;
// Input Manager
NSRange imRange;
+22 -2
View File
@@ -80,6 +80,11 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b)
signImages = [[NSMutableDictionary alloc] init];
useMouseTime =
[[NSUserDefaults standardUserDefaults] boolForKey:MMUseMouseTimeKey];
if (useMouseTime)
mouseDownTime = [[NSDate date] retain];
return self;
}
@@ -91,6 +96,7 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b)
[markedText release]; markedText = nil;
[markedTextAttributes release]; markedTextAttributes = nil;
[signImages release]; signImages = nil;
[mouseDownTime release]; mouseDownTime = nil;
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
if (asciiImSource) {
@@ -380,7 +386,21 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b)
int button = [event buttonNumber];
int flags = [event modifierFlags];
int count = [event clickCount];
int repeat = 0;
if (useMouseTime) {
// Use Vim mouseTime option to handle multiple mouse down events
NSDate *now = [[NSDate date] retain];
id mouset = [[[self vimController] vimState] objectForKey:@"p_mouset"];
NSTimeInterval interval =
[now timeIntervalSinceDate:mouseDownTime] * 1000.0;
if (interval < (NSTimeInterval)[mouset longValue])
repeat = 1;
mouseDownTime = now;
} else {
repeat = [event clickCount] > 1;
}
NSMutableData *data = [NSMutableData data];
// If desired, intepret Ctrl-Click as a right mouse click.
@@ -398,7 +418,7 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b)
[data appendBytes:&col length:sizeof(int)];
[data appendBytes:&button length:sizeof(int)];
[data appendBytes:&flags length:sizeof(int)];
[data appendBytes:&count length:sizeof(int)];
[data appendBytes:&repeat length:sizeof(int)];
[[self vimController] sendMessage:MouseDownMsgID data:data];
}
+19
View File
@@ -108,6 +108,14 @@ static CGSSetWindowBackgroundBlurRadiusFunction* GetCGSSetWindowBackgroundBlurRa
[super dealloc];
}
- (BOOL) canBecomeMainWindow {
return YES;
}
- (BOOL) canBecomeKeyWindow {
return YES;
}
- (BOOL)hideTablineSeparator:(BOOL)hide
{
BOOL isHidden = [tablineSeparator isHidden];
@@ -227,4 +235,15 @@ static CGSSetWindowBackgroundBlurRadiusFunction* GetCGSSetWindowBackgroundBlurRa
#endif
}
- (void)setToolbar:(NSToolbar *)toolbar
{
if ([[NSUserDefaults standardUserDefaults]
boolForKey:MMNoTitleBarWindowKey]) {
// MacVim can't have toolbar with No title bar setting.
return;
}
[super setToolbar:toolbar];
}
@end // MMWindow
+6
View File
@@ -130,6 +130,12 @@
| NSMiniaturizableWindowMask | NSResizableWindowMask
| NSUnifiedTitleAndToolbarWindowMask;
if ([[NSUserDefaults standardUserDefaults]
boolForKey:MMNoTitleBarWindowKey]) {
// No title bar setting
styleMask &= ~NSTitledWindowMask;
}
// Use textured background on Leopard or later (skip the 'if' on Tiger for
// polished metal window).
if ([[NSUserDefaults standardUserDefaults] boolForKey:MMTexturedWindowKey]
@@ -65,6 +65,7 @@
1DE9B9500D341AB8008FEDD4 /* MMWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DE9B94E0D341AB8008FEDD4 /* MMWindow.m */; };
1DED78600C6DE43D0079945F /* vimrc in Copy Vim Runtime Files */ = {isa = PBXBuildFile; fileRef = 1DED785F0C6DE43D0079945F /* vimrc */; };
1DFE25A50C527BC4003000F7 /* PSMTabBarControl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D493DB90C52533B00AB718C /* PSMTabBarControl.framework */; };
52818B031C1C08CE00F59085 /* QLStephen.qlgenerator in Copy QuickLookPlugin */ = {isa = PBXBuildFile; fileRef = 52818AFF1C1C075300F59085 /* QLStephen.qlgenerator */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 29B97318FDCFA39411CA2CEA /* MainMenu.nib */; };
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
@@ -86,6 +87,20 @@
remoteGlobalIDString = 53DF68FC067E5B5A0090B5B0;
remoteInfo = PSMTabBarControlFramework;
};
52818AFE1C1C075300F59085 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 52818AFA1C1C075300F59085 /* QuickLookStephen.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 8D576316048677EA00EA77CD;
remoteInfo = QuickLookStephen;
};
52818B001C1C084100F59085 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 52818AFA1C1C075300F59085 /* QuickLookStephen.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 8D57630D048677EA00EA77CD;
remoteInfo = QuickLookStephen;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
@@ -124,6 +139,17 @@
name = "Copy Vim Runtime Files";
runOnlyForDeploymentPostprocessing = 0;
};
52818B021C1C088000F59085 /* Copy QuickLookPlugin */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = ../Library/QuickLook;
dstSubfolderSpec = 6;
files = (
52818B031C1C08CE00F59085 /* QLStephen.qlgenerator in Copy QuickLookPlugin */,
);
name = "Copy QuickLookPlugin";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
@@ -209,6 +235,7 @@
29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
32CA4F630368D1EE00C91783 /* MacVim_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacVim_Prefix.pch; sourceTree = "<group>"; };
52818AFA1C1C075300F59085 /* QuickLookStephen.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = QuickLookStephen.xcodeproj; path = qlstephen/QuickLookStephen.xcodeproj; sourceTree = "<group>"; };
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
8D1107320486CEB800E47090 /* MacVim.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MacVim.app; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
@@ -367,6 +394,7 @@
29B97317FDCFA39411CA2CEA /* Resources */,
1DE602460C587F760055263D /* Vim Resources */,
29B97323FDCFA39411CA2CEA /* Frameworks */,
52818AF81C1C073400F59085 /* QuickLook Plugin */,
19C28FACFE9D520D11CA2CBB /* Products */,
);
name = MacVim;
@@ -406,6 +434,22 @@
name = Frameworks;
sourceTree = "<group>";
};
52818AF81C1C073400F59085 /* QuickLook Plugin */ = {
isa = PBXGroup;
children = (
52818AFA1C1C075300F59085 /* QuickLookStephen.xcodeproj */,
);
name = "QuickLook Plugin";
sourceTree = "<group>";
};
52818AFB1C1C075300F59085 /* Products */ = {
isa = PBXGroup;
children = (
52818AFF1C1C075300F59085 /* QLStephen.qlgenerator */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@@ -418,6 +462,7 @@
8D11072E0486CEB800E47090 /* Frameworks */,
1D0DCAD80BA3604D00B6CCFA /* Copy Executables */,
1D9EB2840C366D7B0074B739 /* Copy Frameworks */,
52818B021C1C088000F59085 /* Copy QuickLookPlugin */,
1DE608B80C58807F0055263D /* Copy Vim Runtime Files */,
1D1C31F00EFFBFD6003FE9A5 /* Make Document Icons */,
);
@@ -425,6 +470,7 @@
);
dependencies = (
1D493DCD0C5254A400AB718C /* PBXTargetDependency */,
52818B011C1C084100F59085 /* PBXTargetDependency */,
);
name = MacVim;
productInstallPath = "$(HOME)/Applications";
@@ -458,6 +504,10 @@
ProductGroup = 1D493DB40C52533B00AB718C /* Products */;
ProjectRef = 1D493DB30C52533B00AB718C /* PSMTabBarControl.xcodeproj */;
},
{
ProductGroup = 52818AFB1C1C075300F59085 /* Products */;
ProjectRef = 52818AFA1C1C075300F59085 /* QuickLookStephen.xcodeproj */;
},
);
projectRoot = "";
targets = (
@@ -474,6 +524,13 @@
remoteRef = 1D493DB80C52533B00AB718C /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
52818AFF1C1C075300F59085 /* QLStephen.qlgenerator */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = QLStephen.qlgenerator;
remoteRef = 52818AFE1C1C075300F59085 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
/* Begin PBXResourcesBuildPhase section */
@@ -574,6 +631,11 @@
name = PSMTabBarControlFramework;
targetProxy = 1D493DCC0C5254A400AB718C /* PBXContainerItemProxy */;
};
52818B011C1C084100F59085 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = QuickLookStephen;
targetProxy = 52818B001C1C084100F59085 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
+2
View File
@@ -37,6 +37,7 @@ extern NSString *MMTranslateCtrlClickKey;
extern NSString *MMTopLeftPointKey;
extern NSString *MMOpenInCurrentWindowKey;
extern NSString *MMNoFontSubstitutionKey;
extern NSString *MMNoTitleBarWindowKey;
extern NSString *MMLoginShellKey;
extern NSString *MMUntitledWindowKey;
extern NSString *MMTexturedWindowKey;
@@ -54,6 +55,7 @@ extern NSString *MMUseInlineImKey;
#endif // INCLUDE_OLD_IM_CODE
extern NSString *MMSuppressTerminationAlertKey;
extern NSString *MMNativeFullScreenKey;
extern NSString *MMUseMouseTimeKey;
// Enum for MMUntitledWindowKey
+2
View File
@@ -29,6 +29,7 @@ NSString *MMTranslateCtrlClickKey = @"MMTranslateCtrlClick";
NSString *MMTopLeftPointKey = @"MMTopLeftPoint";
NSString *MMOpenInCurrentWindowKey = @"MMOpenInCurrentWindow";
NSString *MMNoFontSubstitutionKey = @"MMNoFontSubstitution";
NSString *MMNoTitleBarWindowKey = @"MMNoTitleBarWindow";
NSString *MMLoginShellKey = @"MMLoginShell";
NSString *MMUntitledWindowKey = @"MMUntitledWindow";
NSString *MMTexturedWindowKey = @"MMTexturedWindow";
@@ -46,6 +47,7 @@ NSString *MMUseInlineImKey = @"MMUseInlineIm";
#endif // INCLUDE_OLD_IM_CODE
NSString *MMSuppressTerminationAlertKey = @"MMSuppressTerminationAlert";
NSString *MMNativeFullScreenKey = @"MMNativeFullScreen";
NSString *MMUseMouseTimeKey = @"MMUseMouseTime";
+1 -8
View File
@@ -162,18 +162,11 @@ be in when executing these commands):
1. Configure Vim (call "./configure --help" to see a list of flags)
src/$ ./configure
2. Generate document icons (OPTIONAL)
src/MacVim/icons$ make getenvy
src/MacVim/icons$ make all
3. Build
2. Build
src/$ make
The application bundle can be found inside "src/MacVim/build/Release".
If step 2 is skipped a generic document icon will be used for all file types.
It is also possible to download the document icons if this step fails.
Bjorn Winckler <bjorn.winckler@gmail.com>
March 21, 2011
+1 -38
View File
@@ -2,44 +2,7 @@
OUTDIR ?= .
# This script is called during the build phase with OUTDIR set to the Resources
# folder of the app bundle. The default action is to simply copy all files
# named MacVim-*.icns to OUTDIR.
#
# The files in version control are all links to the MacVim-generic.icns file.
# In order to get prettier document icons, call "make all" in this folder
# before building. This will call the document generation program which
# overwrites the MacVim-*.icns links with actual icons (see make_icons.py).
#
# The Envy Code R font can be used to render small icons that are more legible.
# In order to use ECR, call "make getenvy" before calling "make all". This
# step requires an internet connection.
$(OUTDIR)/MacVim-generic.icns:
cp -pR MacVim-*.icns "$(OUTDIR)"/
all: make_icons.py vim-noshadow-512.png loadfont.so
rm -f MacVim-*.icns
$(MAKE) -C makeicns
/usr/bin/python make_icons.py "$(OUTDIR)"
loadfont.so: loadfont.c
/usr/bin/python setup.py install --install-lib .
getenvy: Envy\ Code\ R\ Bold.ttf
Envy\ Code\ R\ Bold.ttf: EnvyCodeR.zip
unzip -jo EnvyCodeR.zip
# unzip uses the file date from the zip file. Change the file date to
# "now", so that the zip is not unzipped in every `make` run.`
touch Envy\ Code\ R\ Bold.ttf
ENVYCODE_URL=http://download.damieng.com/fonts/original/EnvyCodeR-PR7.zip
EnvyCodeR.zip:
curl ${ENVYCODE_URL} --location -o EnvyCodeR.zip
clean:
$(MAKE) -C makeicns clean
rm -f "$(OUTDIR)"/MacVim-*.icns loadfont.so *.pyc \
EnvyCodeR.zip *.ttf *.reg *.txt
rm -rf *.egginfo build # Created by setup.py
all:
-616
View File
@@ -1,616 +0,0 @@
from Foundation import *
from AppKit import *
import itertools
import math
import operator
import os
from optparse import OptionParser
# Resources
DEFAULT_BACKGROUND = '/System/Library/CoreServices/CoreTypes.bundle/' + \
'Contents/Resources/GenericDocumentIcon.icns' # might require leopard?
# Cache both images and background renderers globally
imageCache = {}
bgCache = {}
# Make us not crash
# http://www.cocoabuilder.com/archive/message/cocoa/2008/8/6/214964
NSApplicationLoad()
class Surface(object):
"""Represents a simple bitmapped image."""
def __init__(self, *p, **kw):
if not 'premultiplyAlpha' in kw:
kw['premultiplyAlpha'] = True
if len(p) == 1 and isinstance(p[0], NSBitmapImageRep):
self.bitmapRep = p[0]
elif len(p) == 2 and isinstance(p[0], int) and isinstance(p[1], int):
format = NSAlphaFirstBitmapFormat
if not kw['premultiplyAlpha']:
format += NSAlphaNonpremultipliedBitmapFormat
self.bitmapRep = NSBitmapImageRep.alloc().initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_(
None, p[0], p[1], 8, 4, True, False, NSDeviceRGBColorSpace,
format, 0, 0)
if not hasattr(self, 'bitmapRep') or not self.bitmapRep:
raise Exception('Failed to create surface: ' + str(p))
def size(self):
return map(int, self.bitmapRep.size()) # cocoa returns floats. cocoa ftw
def data(self):
"""Returns data in ARGB order (on intel, at least)."""
r = self.bitmapRep
if (r.bitmapFormat() & ~NSAlphaFirstBitmapFormat !=
NSAlphaNonpremultipliedBitmapFormat) or \
r.bitsPerPixel() != 32 or \
r.isPlanar() or \
r.samplesPerPixel() != 4:
raise Exception("Unsupported image format")
return self.bitmapRep.bitmapData()
def rgbaIndices(self):
r = self.bitmapRep
if r.bitmapFormat() & NSAlphaFirstBitmapFormat != 0:
return 1, 2, 3, 0
else:
return 0, 1, 2, 3
def save(self, filename):
"""Saves image as png file."""
self.bitmapRep.representationUsingType_properties_(NSPNGFileType, None) \
.writeToFile_atomically_(filename, True)
def draw(self):
self.bitmapRep.draw()
def context(self):
# Note: Cocoa only supports contexts with premultiplied alpha
return NSGraphicsContext.graphicsContextWithBitmapImageRep_(self.bitmapRep)
def copy(self):
return Surface(self.bitmapRep.copy())
class Image(object):
"""Represents an image that can consist of several Surfaces."""
def __init__(self, param):
if isinstance(param, str):
self.image = NSImage.alloc().initWithContentsOfFile_(param)
elif isinstance(param, Surface):
self.image = NSImage.alloc().initWithSize_( param.size() )
self.image.addRepresentation_(param.bitmapRep)
if not self.image:
raise Exception('Failed to load image: ' + str(param))
def surfaceOfSize(self, w, h):
"""Returns an ARGB, non-premultiplied surface of size w*h or throws."""
r = None
for rep in self.image.representations():
# Cocoa reports fraction widths for pngs (wtf?!), so use round()
if map(lambda x: int(round(x)), rep.size()) == [w, h]:
r = rep
break
# XXX: Resample in this case? That'd make the program easier to use, but
# can silently create blurry backgrounds. Since this happens with
# the app icon anyways, this might not be a huge deal?
if not r:
raise Exception('Unsupported size %dx%d', w, h)
return Surface(r)
def blend(self):
self.compositeInRect( ((0, 0), self.image.size()) )
def compositeInRect(self, r, mode=NSCompositeSourceOver):
self.image.drawInRect_fromRect_operation_fraction_(r, NSZeroRect,
mode, 1.0)
def sizes(self):
s = set()
for rep in self.image.representations():
s.add(tuple(map(lambda x: int(round(x)), rep.size())))
return s
class Context(object):
# Tiger has only Python2.3, so we can't use __enter__ / __exit__ for this :-(
def __init__(self, surface):
NSGraphicsContext.saveGraphicsState()
c = surface.context()
c.setShouldAntialias_(True);
c.setImageInterpolation_(NSImageInterpolationHigh);
NSGraphicsContext.setCurrentContext_(c)
def done(self):
NSGraphicsContext.restoreGraphicsState()
class SplittableBackground(object):
def __init__(self, unsplitted, shouldSplit=True):
self.unsplitted = unsplitted
self.shouldSplit = shouldSplit
self.ground = {}
self.shadow = {}
def rawGroundAtSize(self, s):
return self.unsplitted.surfaceOfSize(s, s)
def groundAtSize(self, s):
if not self.shouldSplit:
return self.rawGroundAtSize(s)
self._performSplit(s)
return self.ground[s]
def shadowAtSize(self, s):
if not self.shouldSplit:
return None
self._performSplit(s)
return self.shadow[s]
def _performSplit(self, s):
if s in self.ground:
assert s in self.shadow
return
assert s not in self.shadow
ground, shadow = splitGenericDocumentIcon(self.unsplitted, s)
self.ground[s] = ground
self.shadow[s] = shadow
class BackgroundRenderer(object):
def __init__(self, bg, icon=None, r={}):
self.bgRenderer = bg
self.icon = icon
self.cache = {}
self.rect = r
def drawIcon(self, s):
if not self.icon:
return
assert s in [16, 32, 128, 256, 512]
a = list(self.rect[s])
# convert from `flow` coords to cocoa
a[2] = -a[2] # mirror y
w, h = s*a[1], s*a[3]
self.icon.compositeInRect( (((s-w)/2 + a[0], (s-h)/2 + a[2]), (w, h)) )
def drawAtSize(self, s):
if not self.icon:
# No need to split the background if no icons is interleaved -- take
# the faster code path in that case.
self.bgRenderer.rawGroundAtSize(s).draw()
return
self.bgRenderer.groundAtSize(s).draw()
self.drawIcon(s)
if self.bgRenderer.shouldSplit:
# shadow needs to be composited, so it needs to be in an image
Image(self.bgRenderer.shadowAtSize(s)).blend()
def backgroundAtSize(self, s):
if not s in self.cache:
result = Surface(s, s)
context = Context(result)
self.drawAtSize(s)
context.done()
self.cache[s] = result
return self.cache[s]
def splitGenericDocumentIcon(img, s):
"""Takes the generic document icon and splits it into a background and a
shadow layer. For the 32x32 and 16x16 variants, the white pixels of the page
curl are hardcoded into the otherwise transparent shadow layer."""
w, h = s, s
r = img.surfaceOfSize(w, h)
bps = 4*w
data = r.data()
dr, dg, db, da = r.rgbaIndices()
ground = Surface(w, h, premultiplyAlpha=False)
shadow = Surface(w, h, premultiplyAlpha=False)
grounddata = ground.data()
shadowdata = shadow.data()
for y in xrange(h):
for x in xrange(w):
idx = y*bps + 4*x
ia = data[idx + da]
ir = data[idx + dr]
ig = data[idx + dg]
ib = data[idx + db]
if ia != chr(255):
# buffer objects don't support slice assignment :-(
grounddata[idx] = ia
grounddata[idx + 1] = ir
grounddata[idx + 2] = ig
grounddata[idx + 3] = ib
shadowdata[idx] = chr(0)
shadowdata[idx + 1] = chr(0)
shadowdata[idx + 2] = chr(0)
shadowdata[idx + 3] = chr(0)
continue
assert ir == ig == ib
grounddata[idx] = chr(255)
grounddata[idx + 1] = chr(255)
grounddata[idx + 2] = chr(255)
grounddata[idx + 3] = chr(255)
shadowdata[idx] = chr(255 - ord(ir))
shadowdata[idx + 1] = chr(0)
shadowdata[idx + 2] = chr(0)
shadowdata[idx + 3] = chr(0)
# Special-case 16x16 and 32x32 cases: Make some pixels on the fold white.
# Ideally, I could make the fold whiteish in all variants, but I can't.
whitePix = { 16: [(10, 2), (10, 3), (11, 3), (10, 4), (11, 4), (12, 4)],
32: [(21, 4), (21, 5), (22, 5), (21, 6), (22, 6), (23, 6)]}
if (w, h) in [(16, 16), (32, 32)]:
for x, y in whitePix[w]:
idx = y*bps + 4*x
shadowdata[idx] = chr(255)
shadowdata[idx + 1] = chr(255)
shadowdata[idx + 2] = chr(255)
shadowdata[idx + 3] = chr(255)
return ground, shadow
class TextRenderer(object):
def __init__(self):
self.cache = {}
def attribsAtSize(self, s):
if s not in self.cache:
self.cache[s] = self._attribsAtSize(s)
return self.cache[s]
def centeredStyle(self):
style = NSMutableParagraphStyle.new()
style.setParagraphStyle_(NSParagraphStyle.defaultParagraphStyle())
style.setAlignment_(NSCenterTextAlignment)
return style
def _attribsAtSize(self, s):
# This looks not exactly like the font on Preview.app's document icons,
# but I believe that's because Preview's icons are drawn by Photoshop,
# and Adobe's font rendering is different from Apple's.
fontname = 'LucidaGrande-Bold'
# Prepare text format
fontsizes = { 512: 72.0, 256: 36.0, 128: 18.0, 32: 7.0, 16: 3.0 }
# http://developer.apple.com/documentation/Cocoa/Conceptual/AttributedStrings/Articles/standardAttributes.html#//apple_ref/doc/uid/TP40004903
attribs = {
NSParagraphStyleAttributeName: self.centeredStyle(),
NSForegroundColorAttributeName: NSColor.colorWithDeviceWhite_alpha_(
0.34, 1),
NSFontAttributeName: NSFont.fontWithName_size_(fontname, fontsizes[s])
}
# tighten font a bit for some sizes
if s in [256, 512]:
attribs[NSKernAttributeName] = -1.0
elif s == 32:
attribs[NSKernAttributeName] = -0.25
if not attribs[NSFontAttributeName]:
raise Exception('Failed to load font %s' % fontname)
return attribs
def drawTextAtSize(self, text, s):
"""Draws text `s` into the current context of size `s`."""
textRects = {
512: ((0, 7), (512, 119)),
128: ((0, 6), (128, 26.5)),
256: ((0, 7), (256, 57)),
16: ((1, 1), (15, 5)),
#32: ((1, 1), (31, 9))
}
attribs = self.attribsAtSize(s)
text = NSString.stringWithString_(text)
if s in [16, 128, 256, 512]:
text.drawInRect_withAttributes_(textRects[s], attribs)
elif s == 32:
# Try to align text on pixel boundary:
attribs = attribs.copy()
attribs[NSParagraphStyleAttributeName] = \
NSParagraphStyle.defaultParagraphStyle()
ts = text.sizeWithAttributes_(attribs)
text.drawAtPoint_withAttributes_( (math.floor((32.0-ts[0])/2) + 0.5, 1.5),
attribs)
class OfficeTextRenderer(TextRenderer):
"""Uses Office's LucidaSans font for 32x32.
This font looks much better for certain strings (e.g. "PDF") but much worse
for most others (e.g. "VIM", "JAVA") -- and office fonts are usually not
installed. Hence, this class is better not used.
"""
def _attribsAtSize(self, s):
self.useOfficeFont = False
attribs = TextRenderer._attribsAtSize(self, s)
if s == 32:
font = NSFont.fontWithName_size_('LucidaSans-Demi', 7.0)
if font:
attribs[NSFontAttributeName] = font
attribs[NSKernAttributeName] = 0
self.useOfficeFont = True
return attribs
def drawTextAtSize(self, text, s):
attribs = self.attribsAtSize(s)
if not self.useOfficeFont or s != 32:
TextRenderer.drawTextAtSize(self, text, s)
return
text = NSString.stringWithString_(text)
text.drawInRect_withAttributes_( ((0, 1), (31, 11)), attribs)
def createIcon(s, bg, textRenderer, text):
# Fill in background
output = bg.backgroundAtSize(s).copy()
# Draw text on top of shadow
context = Context(output)
if s in text and text[s]:
textRenderer.drawTextAtSize(text[s], s)
context.done()
return output
def textDictFromTextList(l):
assert 1 <= len(l) <= 3
if len(l) == 1:
return dict.fromkeys([16, 32, 128, 256, 512], l[0])
elif len(l) == 2:
return dict(zip([16, 32], 2*[l[1]]) + zip((128, 256, 512), 3*[l[0]]))
elif len(l) == 3:
return dict([(16, l[2]), (32, l[1])] + zip((128, 256, 512), 3*[l[0]]))
def saveIcns(icons, icnsName, makeIcns='./makeicns'):
"""Creates an icns file with several variants.
Params:
icons: A dict that contains icon size as key and Surface as value.
Valid keys are 512, 256, 128, 32, 16
icnsname: Name of the output file
"""
# If IconFamily was less buggy, we could wrap it into a python module and
# call it directly, which is about a lot faster. However, IconFamily does not
# work with NSAlphaNonpremultipliedBitmapFormat correctly, so this has to
# wait.
#import IconFamily
#typeDict = {
#16: IconFamily.kSmall32BitData,
#32: IconFamily.kLarge32BitData,
#128: IconFamily.kThumbnail32BitData,
#256: IconFamily.kIconServices256PixelDataARGB,
#512: IconFamily.IconServices512PixelDataARGB,
#}
#maskDict = {
#16: IconFamily.kSmall8BitMask,
#32: IconFamily.kLarge8BitMask,
#128: IconFamily.kThumbnail8BitMask,
#}
#output = IconFamily.IconFamily.iconFamily()
#for s, icon in icons.items():
#output.setIconFamilyElement_fromBitmapImageRep_(typeDict[s], icon.bitmapRep)
#if s in maskDict:
#output.setIconFamilyElement_fromBitmapImageRep_(
#maskDict[s], icon.bitmapRep)
#output.writeToFile_(icnsName)
TMPFILE = 'docerator_tmp_%d.png'
try:
args = []
for s, icon in icons.items():
assert s in [512, 256, 128, 32, 16]
assert icon.size() == [s, s]
icon.save(TMPFILE % s)
args.append('-%d %s' % (s, TMPFILE % s))
return \
os.system('%s %s -out %s' % (makeIcns, ' '.join(args), icnsName)) == 0
finally:
for s in icons:
if os.access(TMPFILE % s, os.F_OK):
os.remove(TMPFILE % s)
def getOutname(options):
def saneBasename(p):
""" '/my/path/to/file.txt' -> 'file' """
return os.path.splitext(os.path.basename(p))[0]
textPart = 'Generic'
if options.text:
textPart = options.text.split(',')[0]
if options.appicon:
base = saneBasename(options.appicon)
else:
base = saneBasename(getBgName(options))
return '%s-%s.icns' % (base, textPart)
def cachedImage(filename):
absPath = os.path.abspath(filename)
if not absPath in imageCache:
imageCache[absPath] = Image(absPath)
return imageCache[absPath]
def cachedBackground(img, split):
key = (img, split)
if not key in bgCache:
bgCache[key] = SplittableBackground(img, shouldSplit=split)
return bgCache[key]
# taken from running flow on preview
defaultRects = {
16: (-0.30890000000000001, 0.4919, -1.2968, 0.4743),
32: (-0.27810000000000001,
0.58930000000000005,
-2.2292999999999998,
0.57140000000000002),
128: (1.1774, 0.56820000000000004, -0.8246, 0.56799999999999995),
256: (0.5917, 0.56489999999999996, -1.8994, 0.56499999999999995),
512: (0.68700000000000006,
0.56530000000000002,
-4.2813999999999997,
0.56540000000000001)
}
def getBgName(options):
if not hasattr(options, 'background') \
or options.background in ['default-split', 'default-unsplit']:
return DEFAULT_BACKGROUND
else:
return options.background
class IconGenerator(object):
def __init__(self, options):
if hasattr(options, 'textrenderer') and options.textrenderer:
self.textRenderer = options.textrenderer()
else:
self.textRenderer = TextRenderer()
# Prepare input images
splitBackground = options.background == 'default-split'
self.bgIcon = cachedImage(getBgName(options))
self.testIcon = None
if options.appicon:
self.testIcon = cachedImage(options.appicon)
rects = defaultRects.copy()
rects[16] = [ 0.0000, 0.5000, -1.0000, 0.5000] # manually, better
if hasattr(options, 'rects'):
rects.update(options.rects)
bg = cachedBackground(self.bgIcon, splitBackground)
if hasattr(options, 'backgroundrenderer') and options.backgroundrenderer:
self.bgRenderer = options.backgroundrenderer(bg, self.testIcon, rects)
else:
self.bgRenderer = BackgroundRenderer(bg, self.testIcon, rects)
self.testtext = textDictFromTextList(options.text.split(','))
def createIconAtSize(self, s):
return createIcon(s, self.bgRenderer, self.textRenderer, self.testtext)
def iconGenerator(**kwargs):
return IconGenerator(optsFromDict(**kwargs))
def makedocicon_opts(options):
renderer = IconGenerator(options)
if hasattr(options, 'sizes') and options.sizes:
if isinstance(options.sizes, list):
sizes = options.sizes
else:
sizes = map(int, options.sizes.split(','))
else:
sizes = renderer.bgIcon.sizes()
if renderer.testIcon:
sizes = sizes.intersection(renderer.testIcon.sizes())
sizes = sorted(map(operator.itemgetter(0), sizes))
icons = dict([(s, renderer.createIconAtSize(s)) for s in sizes])
if options.debug:
for s, icon in icons.iteritems():
icon.save(options.debug % s)
if hasattr(options, 'outname') and options.outname:
outname = options.outname
else:
outname = getOutname(options)
if saveIcns(icons, outname, options.makeicns):
print 'Wrote', outname
else:
print 'Failed to write %s. Make sure makeicns is in your path.' % outname
def optsFromDict(**kwargs):
options, _ = getopts().parse_args([]) # get default options
for k in kwargs:
setattr(options, k, kwargs[k])
return options
def makedocicon(**kwargs):
makedocicon_opts(optsFromDict(**kwargs))
def makedocicons_opts(options):
if not hasattr(options, 'text') or not options.text:
options.text = ['']
texts = options.text
for text in texts:
options.text = text
makedocicon_opts(options)
def makedocicons(**kwargs):
makedocicons_opts(optsFromDict(**kwargs))
def getopts():
parser = OptionParser(usage='%prog [options]', version='%prog 1.01')
parser.add_option('--background', '--bg', default='default-split',
help='Used as background (special values: "default-split" (default), ' \
'"default-unsplit").')
parser.add_option('--appicon', help='App icon, defaults to no icon.')
parser.add_option('--text', help='Text on icon. Defaults to empty. '
'More than one text is supported, multiple docicons are generated in '
'that case.', action='append')
parser.add_option('--sizes', help='Sizes of icons. ' \
'Defaults to all sizes available in input appicon. Example: "512,128,16"')
# XXX(Nico): This has to go
parser.add_option('--debug', help='If set, write out pngs for all variants.' \
' This needs to look like "debug%d.png".')
# XXX(Nico): This has to go once IconFamily is less buggy and can be used
# directly
parser.add_option('--makeicns', help='Path to makeicns binary',
default='./makeicns')
return parser
def main():
options, args = getopts().parse_args()
makedocicons_opts(options)
if __name__ == '__main__':
main()
-65
View File
@@ -1,65 +0,0 @@
import docerator
import unittest
class TextDictFromTextListTest(unittest.TestCase):
def testBasic(self):
self.assertEquals({16: 'a', 32: 'a', 128: 'a', 256: 'a', 512: 'a'},
docerator.textDictFromTextList(['a']))
self.assertEquals({16: 'b', 32: 'b', 128: 'a', 256: 'a', 512: 'a'},
docerator.textDictFromTextList(['a', 'b']))
self.assertEquals({16: 'c', 32: 'b', 128: 'a', 256: 'a', 512: 'a'},
docerator.textDictFromTextList(['a', 'b', 'c']))
class OutnameTest(unittest.TestCase):
class FakeOptions(object):
def __init__(self, **kwargs):
for k in kwargs:
self.__setattr__(k, kwargs[k])
def testBasic(self):
options = OutnameTest.FakeOptions(
appicon = '/Applications/iTunes.app/Contents/Resources/iTunes.icns',
text='MP3')
self.assertEquals('iTunes-MP3.icns', docerator.getOutname(options))
def testTextList(self):
options = OutnameTest.FakeOptions(
appicon = '/Applications/iTunes.app/Contents/Resources/iTunes.icns',
text='PYTHON,PY')
self.assertEquals('iTunes-PYTHON.icns',
docerator.getOutname(options))
def testEmptyText(self):
options = OutnameTest.FakeOptions(
appicon = '/Applications/iTunes.app/Contents/Resources/iTunes.icns',
text='')
self.assertEquals('iTunes-Generic.icns', docerator.getOutname(options))
options = OutnameTest.FakeOptions(
appicon = '/Applications/iTunes.app/Contents/Resources/iTunes.icns',
text=None)
self.assertEquals('iTunes-Generic.icns',
docerator.getOutname(options))
def testEmptyIcon(self):
options = OutnameTest.FakeOptions(appicon=None, text='MP3')
self.assertEquals('GenericDocumentIcon-MP3.icns',
docerator.getOutname(options))
options = OutnameTest.FakeOptions(appicon=None, text='')
self.assertEquals('GenericDocumentIcon-Generic.icns',
docerator.getOutname(options))
options = OutnameTest.FakeOptions(appicon=None, text='',
background='/Applications/Bla/bgicon.icns')
self.assertEquals('bgicon-Generic.icns',
docerator.getOutname(options))
# XXX(Nico): Look at the doctest module.
if __name__ == '__main__':
unittest.main()
-56
View File
@@ -1,56 +0,0 @@
// A small python module that registers a font with ATS, given the name of
// the font.
#include <Python/Python.h>
#include <CoreFoundation/CoreFoundation.h>
#include <Carbon/Carbon.h>
static PyObject* loadfont(PyObject* self, PyObject* args) {
PyObject* result = Py_False;
const char* path = NULL;
int ok = PyArg_ParseTuple(args, "s", &path);
if (ok) {
CFStringRef componentPath = CFStringCreateWithCString(kCFAllocatorDefault,
path, kCFStringEncodingUTF8);
CFURLRef componentURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
componentPath, kCFURLPOSIXPathStyle, false);
FSRef fsref;
if (CFURLGetFSRef(componentURL, &fsref)) {
OSStatus err = noErr;
ATSFontContainerRef fontContainerRef; // we don't deactivate the font
#if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_4)
err = ATSFontActivateFromFileReference(&fsref,
kATSFontContextLocal, kATSFontFormatUnspecified, NULL,
kATSOptionFlagsDefault, &fontContainerRef);
#else
FSSpec fsSpec;
FSRef fsRef;
if ((err = FSGetCatalogInfo(
&fsRef, kFSCatInfoNone, NULL, NULL, &fsSpec, NULL)) == noErr) {
err = ATSFontActivateFromFileSpecification(&fsSpec,
kATSFontContextLocal, kATSFontFormatUnspecified, NULL,
kATSOptionFlagsDefault, &fontContainerRef);
}
#endif
if (err == noErr) {
result = Py_True;
}
}
CFRelease(componentURL);
CFRelease(componentPath);
}
return result;
}
static PyMethodDef LoadfontMethods[] = {
{ "loadfont", loadfont, METH_VARARGS, "Locally activates font from file." },
{ NULL, NULL, 0, NULL }
};
PyMODINIT_FUNC initloadfont(void) {
Py_InitModule("loadfont", LoadfontMethods);
}
-208
View File
@@ -1,208 +0,0 @@
# Creates all of MacVim document icons.
import os
import sys
fontname = ''
facename = None
# http://www.macresearch.org/cocoa-scientists-part-xx-python-scriptersmeet-cocoa
try:
# Make us independent of sysprefs->appearance->antialias fonts smaller than...
# Needs to happen before docerator is imported.
from AppKit import NSUserDefaults
prefs = NSUserDefaults.standardUserDefaults()
prefs.setInteger_forKey_(4, 'AppleAntiAliasingThreshold')
import docerator
import loadfont
from Foundation import NSString
from AppKit import *
dont_create = False
except Exception, e:
print e
dont_create = True # most likely because we're on tiger
# icon types
LARGE = 0 # 512, 128, 32, 16; about 96kB
SMALL = 1 # 128, 32, 16; about 36kB
LINK = 2 # Create link to generic icon; 4kB (== smallest block size on HFS+)
iconsizes = {
SMALL: [128, 32, 16],
LARGE: [512, 128, 32, 16],
}
# Resources
MAKEICNS = 'makeicns/makeicns'
APPICON = 'vim-noshadow-512.png'
DEFAULT_BACKGROUND = '/System/Library/CoreServices/CoreTypes.bundle/' + \
'Contents/Resources/GenericDocumentIcon.icns'
# List of icons to create
GENERIC_ICON_NAME = 'MacVim-generic'
vimIcons = {
GENERIC_ICON_NAME: [u'', LARGE],
'MacVim-vim': [u'VIM', LARGE],
'MacVim-txt': [u'TXT', SMALL],
'MacVim-tex': [u'TEX', SMALL],
'MacVim-h': [u'H', SMALL],
'MacVim-c': [u'C', SMALL],
'MacVim-m': [u'M', SMALL],
'MacVim-mm': [u'MM', SMALL],
'MacVim-cpp': [u'C\uff0b\uff0b,C++,C++', SMALL], # fullwidth plusses
'MacVim-java': [u'JAVA', SMALL],
'MacVim-f': [u'FTRAN', SMALL],
'MacVim-html': [u'HTML', SMALL],
'MacVim-xml': [u'XML', SMALL],
'MacVim-js': [u'JS', SMALL],
'MacVim-perl': [u'PERL,PL', SMALL],
'MacVim-py': [u'PYTHON,PY', SMALL],
'MacVim-php': [u'PHP', SMALL],
'MacVim-rb': [u'RUBY,RB', SMALL],
'MacVim-bash': [u'SH', SMALL],
'MacVim-patch': [u'DIFF', SMALL],
'MacVim-applescript': [u'\uf8ffSCPT,\uf8ffS', SMALL], # apple sign
'MacVim-as': [u'FLASH', LINK],
'MacVim-asp': [u'ASP', LINK],
'MacVim-bib': [u'BIB', LINK],
'MacVim-cs': [u'C#', LINK],
'MacVim-csfg': [u'CFDG', LINK],
'MacVim-csv': [u'CSV', LINK],
'MacVim-tsv': [u'TSV', LINK],
'MacVim-cgi': [u'CGI', LINK],
'MacVim-cfg': [u'CFG', LINK],
'MacVim-css': [u'CSS', SMALL],
'MacVim-dtd': [u'DTD', LINK],
'MacVim-dylan': [u'DYLAN', LINK],
'MacVim-erl': [u'ERLANG,ERL', SMALL],
'MacVim-fscript': [u'FSCPT,FSCR,FS', SMALL],
'MacVim-hs': [u'HS', SMALL],
'MacVim-inc': [u'INC', LINK],
'MacVim-ics': [u'ICS', SMALL],
'MacVim-ini': [u'INI', LINK],
'MacVim-io': [u'IO', LINK],
'MacVim-bsh': [u'BSH', LINK],
'MacVim-properties': [u'PROP', LINK],
'MacVim-jsp': [u'JSP', SMALL],
'MacVim-lisp': [u'LISP,LISP,LSP', SMALL],
'MacVim-log': [u'LOG', SMALL],
'MacVim-wiki': [u'WIKI', SMALL],
'MacVim-ps': [u'PS', LINK],
#'MacVim-plist': [u'PLIST', SMALL],
'MacVim-sch': [u'SCHEME,SCM', SMALL],
'MacVim-sql': [u'SQL', SMALL],
'MacVim-tcl': [u'TCL', SMALL],
'MacVim-xsl': [u'XSL', LINK],
'MacVim-vcf': [u'VCARD,VCF', SMALL],
'MacVim-vb': [u'VBASIC,VB', LINK],
'MacVim-yaml': [u'YAML,YAML,YML', SMALL],
'MacVim-gtd': [u'GTD', LINK],
'MacVim-markdown': [u'MARK\u2193,M\u2193', LINK], # down arrow
'MacVim-rst': [u'RST', LINK],
'MacVim-vba': [u'VBA', LINK],
}
def createLinks(icons, target):
assert len(icons) > 0
for name in icons:
icnsName = '%s.icns' % name
if os.access(icnsName, os.F_OK):
os.remove(icnsName)
os.symlink(target, icnsName)
if not dont_create:
# define a few classes to render custom 16x16 icons
class NoTextRenderer(docerator.TextRenderer):
def drawTextAtSize(self, text, s):
if s == 16: return # No text at 16x16
docerator.TextRenderer.drawTextAtSize(self, text, s)
class NoIconRenderer(docerator.BackgroundRenderer):
def drawIcon(self, s):
if s == 16: return # no "MacVim" icon on the sheet at 16x16
docerator.BackgroundRenderer.drawIcon(self, s)
class SmallTextRenderer(docerator.TextRenderer):
def _attribsAtSize(self, s):
global facename
attribs = docerator.TextRenderer._attribsAtSize(self, s)
if s == 16 and facename is not None:
font = NSFont.fontWithName_size_(facename, 7.0)
assert font
attribs[NSFontAttributeName] = font
attribs[NSForegroundColorAttributeName] = \
NSColor.colorWithDeviceRed_green_blue_alpha_(
0/255.0, 82/255.0, 0/255.0, 1)
return attribs
def drawTextAtSize(self, text, s):
if s != 16:
docerator.TextRenderer.drawTextAtSize(self, text, s)
return
text = NSString.stringWithString_(text.lower()[0:3]) # at most 3 chars
attribs = self.attribsAtSize(s)
if len(text) <= 2:
attribs[NSKernAttributeName] = 0 # we have some space
else:
attribs[NSKernAttributeName] = -1 # we need all the room we can get
text.drawInRect_withAttributes_( ((1, 2), (15, 11)), attribs)
def main():
if dont_create:
print "PyObjC not found, only using a stock icon for document icons."
# Can't use the constants from docerator in this case
import shutil
shutil.copyfile(DEFAULT_BACKGROUND, '%s.icns' % GENERIC_ICON_NAME)
createLinks([name for name in vimIcons if name != GENERIC_ICON_NAME],
'%s.icns' % GENERIC_ICON_NAME)
return
# choose an icon font
global fontname, facename
# Thanks to DamienG for Envy Code R (redistributed with permission):
# http://damieng.com/blog/2008/05/26/envy-code-r-preview-7-coding-font-released
fonts = [('Envy Code R Bold.ttf', 'EnvyCodeR-Bold'),
('/System/Library/Fonts/Monaco.dfont', 'Monaco')]
for font in fonts:
if loadfont.loadfont(font[0]):
fontname, facename = font
break
print "Building icons with font '" + fontname + "'."
srcdir = os.getcwd()
if len(sys.argv) > 1:
os.chdir(sys.argv[1])
appIcon = os.path.join(srcdir, APPICON)
makeIcns = os.path.join(srcdir, MAKEICNS)
# create LARGE and SMALL icons first...
for name, t in vimIcons.iteritems():
text, size = t
if size == LINK: continue
print name
if name == GENERIC_ICON_NAME:
# The generic icon has no text; make the appicon a bit larger
docerator.makedocicon(outname='%s.icns' % name, appicon=appIcon,
text=text, sizes=iconsizes[size], makeicns=makeIcns,
textrenderer=NoTextRenderer, rects={16:(0.0, 0.5533, 0.0, 0.5533)})
else:
# For the other icons, leave out appicon and render text in Envy Code R
docerator.makedocicon(outname='%s.icns' % name, appicon=appIcon,
text=text, sizes=iconsizes[size], makeicns=makeIcns,
textrenderer=SmallTextRenderer, backgroundrenderer=NoIconRenderer)
# ...create links later (to make sure the link targets exist)
createLinks([name for (name, t) in vimIcons.items() if t[1] == LINK],
'%s.icns' % GENERIC_ICON_NAME)
if __name__ == '__main__':
main()
-190
View File
@@ -1,190 +0,0 @@
// IconFamily.h
// IconFamily class interface
// by Troy Stephens, Thomas Schnitzer, David Remahl, Nathan Day, Ben Haller, Sven Janssen, Peter Hosey, Conor Dearden, Elliot Glaysher, and Dave MacLachlan
// version 0.9.3
//
// Project Home Page:
// http://iconfamily.sourceforge.net/
//
// Problems, shortcomings, and uncertainties that I'm aware of are flagged with "NOTE:". Please address bug reports, bug fixes, suggestions, etc. to the project Forums and bug tracker at https://sourceforge.net/projects/iconfamily/
/*
Copyright (c) 2001-2006 Troy N. Stephens
Portions Copyright (c) 2007 Google Inc.
Use and distribution of this source code is governed by the MIT License, whose terms are as follows.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#import <Cocoa/Cocoa.h>
#import <Carbon/Carbon.h>
// This class is a Cocoa/Objective-C wrapper for the Mac OS X Carbon API's
// "icon family" data type. Its main purpose is to enable Cocoa applications
// to easily create custom file icons from NSImage instances, and thus take
// advantage of Mac OS X's new larger RGBA "thumbnail" icon format to provide
// richly detailed thumbnail previews of the files' contents.
//
// Using IconFamily, this becomes as simple as:
//
// id iconFamily = [IconFamily iconFamilyWithThumbnailsOfImage:anImage];
// [iconFamily setAsCustomIconForFile:anExistingFile];
//
// You can also write an icon family to an .icns file using the -writeToFile:
// method.
@interface IconFamily : NSObject
{
IconFamilyHandle hIconFamily;
}
// Convenience methods. These use the corresponding -init... methods to return
// an autoreleased IconFamily instance.
+ (IconFamily*) iconFamily;
+ (IconFamily*) iconFamilyWithContentsOfFile:(NSString*)path;
+ (IconFamily*) iconFamilyWithIconOfFile:(NSString*)path;
+ (IconFamily*) iconFamilyWithIconFamilyHandle:(IconFamilyHandle)hNewIconFamily;
+ (IconFamily*) iconFamilyWithSystemIcon:(int)fourByteCode;
+ (IconFamily*) iconFamilyWithThumbnailsOfImage:(NSImage*)image;
+ (IconFamily*) iconFamilyWithThumbnailsOfImage:(NSImage*)image usingImageInterpolation:(NSImageInterpolation)imageInterpolation;
// Initializes as a new, empty IconFamily. This is IconFamily's designated
// initializer method.
- init;
// Initializes an IconFamily by loading the contents of an .icns file.
- initWithContentsOfFile:(NSString*)path;
// Initializes an IconFamily from an existing Carbon IconFamilyHandle.
- initWithIconFamilyHandle:(IconFamilyHandle)hNewIconFamily;
// Initializes an IconFamily by loading the Finder icon that's assigned to a
// file.
- initWithIconOfFile:(NSString*)path;
// Initializes an IconFamily by referencing a standard system icon.
- initWithSystemIcon:(int)fourByteCode;
// Initializes an IconFamily by creating its elements from a resampled
// NSImage. The second form of this method allows you to specify the degree
// of antialiasing to be used in resampling the image, by passing in one of
// the NSImageInterpolation... constants that are defined in
// NSGraphicsContext.h. The first form of this initializer simply calls the
// second form with imageInterpolation set to NSImageInterpolationHigh, which
// produces highly smoothed thumbnails.
- initWithThumbnailsOfImage:(NSImage*)image;
- initWithThumbnailsOfImage:(NSImage*)image usingImageInterpolation:(NSImageInterpolation)imageInterpolation;
// Writes the icon family to an .icns file.
- (BOOL) writeToFile:(NSString*)path;
// Sets the image data for one of the icon family's elements from an
// NSBitmapImageRep. The "elementType" parameter must be one of the icon
// family element types listed below, and the format of the "bitmapImageRep"
// must match the corresponding requirements specified below. Regardless of
// the elementType, the bitmapImageRep must also be non-planar and have 8 bits
// per sample.
//
// elementType dimensions format
// ------------------- ---------- ---------------------------------------
// kIconServices512PixelDataARGB 512 x 512 32-bit RGBA, 32-bit RGB, or 24-bit RGB
// kIconServices256PixelDataARGB 256 x 256 32-bit RGBA, 32-bit RGB, or 24-bit RGB
// kThumbnail32BitData 128 x 128 32-bit RGBA, 32-bit RGB, or 24-bit RGB
// kThumbnail8BitMask 128 x 128 32-bit RGBA or 8-bit intensity
// kLarge32BitData 32 x 32 32-bit RGBA, 32-bit RGB, or 24-bit RGB
// kLarge8BitMask 32 x 32 32-bit RGBA or 8-bit intensity
// kLarge1BitMask 32 x 32 32-bit RGBA, 8-bit intensity, or 1-bit
// kSmall32BitData 16 x 16 32-bit RGBA, 32-bit RGB, or 24-bit RGB
// kSmall8BitMask 16 x 16 32-bit RGBA or 8-bit intensity
// kSmall1BitMask 16 x 16 32-bit RGBA, 8-bit intensity, or 1-bit
//
// When an RGBA image is supplied to set a "Mask" element, the mask data is
// taken from the image's alpha channel.
//
// NOTE: Setting an IconFamily's kLarge1BitMask seems to damage the IconFamily
// for some as yet unknown reason. (If you then assign the icon family
// as a file's custom icon using -setAsCustomIconForFile:, the custom
// icon doesn't appear for the file in the Finder.) However, both
// custom icon display and mouse-click hit-testing in the Finder seem to
// work fine when we only set the other four elements (thus keeping the
// existing kLarge1BitMask from the valid icon family from which we
// initialized the IconFamily via -initWithContentsOfFile:, since
// IconFamily's -init method is currently broken...), so it seems safe
// to just leave the kLarge1BitMask alone.
- (BOOL) setIconFamilyElement:(OSType)elementType
fromBitmapImageRep:(NSBitmapImageRep*)bitmapImageRep;
// Gets the image data for one of the icon family's elements as a new, 32-bit
// RGBA NSBitmapImageRep. The specified elementType should be one of
// kIconServices512PixelDataARGB, kIconServices256PixelDataARGB,
// kThumbnail32BitData, kLarge32BitData, or kSmall32BitData.
//
// The returned NSBitmapImageRep will have the corresponding 8-bit mask data
// in its alpha channel, or a fully opaque alpha channel if the icon family
// has no 8-bit mask data for the specified alpha channel.
//
// Returns nil if the requested element cannot be retrieved (e.g. if the
// icon family has no such 32BitData element).
- (NSBitmapImageRep*) bitmapImageRepWithAlphaForIconFamilyElement:(OSType)elementType;
// Creates and returns an NSImage that contains the icon family's various
// elements as its NSImageReps.
- (NSImage*) imageWithAllReps;
// NOTE: Planned method -- not yet implemented.
//
// Gets the image data for one of the icon family's elements as a new
// NSBitmapImageRep. The specified elementType should be one of
// kThumbnail32BitData, kThumbnail8BitMask, kLarge32BitData, kLarge8BitMask,
// kLarge1BitMask, kSmall32BitData, kSmall8BitMask, or kSmall1BitMask.
// - (NSBitmapImageRep*) bitmapImageRepForIconFamilyElement:(OSType)elementType;
// Writes the icon family to the resource fork of the specified file as its
// kCustomIconResource, and sets the necessary Finder bits so the icon will
// be displayed for the file in Finder views.
- (BOOL) setAsCustomIconForFile:(NSString*)path;
- (BOOL) setAsCustomIconForFile:(NSString*)path withCompatibility:(BOOL)compat;
// Same as the -setAsCustomIconForFile:... methods, but for folders (directories).
- (BOOL) setAsCustomIconForDirectory:(NSString*)path;
- (BOOL) setAsCustomIconForDirectory:(NSString*)path withCompatibility:(BOOL)compat;
// Removes the custom icon (if any) from the specified file's resource fork,
// and clears the necessary Finder bits for the file. (Note that this is a
// class method, so you don't need an instance of IconFamily to invoke it.)
+ (BOOL) removeCustomIconFromFile:(NSString*)path;
@end
#if MAC_OS_X_VERSION_MAX_ALLOWED <= 1050 // Scrap Manager has been nixed on Snow Leopard
// Methods for interfacing with the Carbon Scrap Manager (analogous to and
// interoperable with the Cocoa Pasteboard).
@interface IconFamily (ScrapAdditions)
+ (BOOL) canInitWithScrap;
+ (IconFamily*) iconFamilyWithScrap;
- initWithScrap;
- (BOOL) putOnScrap;
@end
#endif
File diff suppressed because it is too large Load Diff
-16
View File
@@ -1,16 +0,0 @@
CFLAGS = -fpascal-strings -O2
.PHONY: clean dist
makeicns: makeicns.o IconFamily.o NSString+CarbonFSRefCreation.o
g++ -o makeicns $^ -O2 \
-framework Foundation -framework AppKit -framework Carbon
clean:
rm -rf makeicns.o IconFamily.o NSString+CarbonFSRefCreation.o
dist: makeicns
rm -rf makeicns-1.0.zip
zip makeicns-1.0.zip Makefile makeicns.m IconFamily.m IconFamily.h \
NSString+CarbonFSRefCreation.m NSString+CarbonFSRefCreation.h \
makeicns
@@ -1,25 +0,0 @@
/*
Copyright (c) 2001-2006 Troy N. Stephens
Use and distribution of this source code is governed by the MIT License, whose terms are as follows.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#import <Foundation/Foundation.h>
#import <Carbon/Carbon.h>
@interface NSString (CarbonFSRefCreation)
// Fills in the given FSRef struct so it specifies the file whose path is in this string.
// If the file doesn't exist, and "createFile" is YES, this method will attempt to create
// an empty file with the specified path. (The caller should insure that the directory
// the file is to be placed in already exists.)
- (BOOL) getFSRef:(FSRef*)fsRef createFileIfNecessary:(BOOL)createFile;
@end
@@ -1,58 +0,0 @@
/*
Copyright (c) 2001-2006 Troy N. Stephens
Use and distribution of this source code is governed by the MIT License, whose terms are as follows.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#import "NSString+CarbonFSRefCreation.h"
@implementation NSString (CarbonFSRefCreation)
- (BOOL) getFSRef:(FSRef*)fsRef createFileIfNecessary:(BOOL)createFile
{
NSFileManager* fileManager = [NSFileManager defaultManager];
CFURLRef urlRef;
Boolean gotFSRef;
// Check whether the file exists already. If not, create an empty file if requested.
if (![fileManager fileExistsAtPath:self]) {
if (createFile) {
if (![@"" writeToFile:self atomically:YES]) {
return NO;
}
} else {
return NO;
}
}
// Create a CFURL with the specified POSIX path.
urlRef = CFURLCreateWithFileSystemPath( kCFAllocatorDefault,
(CFStringRef) self,
kCFURLPOSIXPathStyle,
FALSE /* isDirectory */ );
if (urlRef == NULL) {
// printf( "** Couldn't make a CFURLRef for the file.\n" );
return NO;
}
// Try to create an FSRef from the URL. (If the specified file doesn't exist, this
// function will return false, but if we've reached this code we've already insured
// that the file exists.)
gotFSRef = CFURLGetFSRef( urlRef, fsRef );
CFRelease( urlRef );
if (!gotFSRef) {
// printf( "** Couldn't get an FSRef for the file.\n" );
return NO;
}
return YES;
}
@end
-173
View File
@@ -1,173 +0,0 @@
// makeicns
// Converts images to Apple's icns format.
// Written by nicolasweber@gmx.de, released under MIT license.
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#import <Cocoa/Cocoa.h>
#include "IconFamily.h"
#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
// This is defined in 10.5 and beyond in IconStorage.h
enum {
kIconServices512PixelDataARGB = 'ic09' /* non-premultiplied 512x512 ARGB bitmap*/
};
#endif
#define VERSION "1.0 (20081122)"
void usage() {
fprintf(stderr,
"makeicns v%s\n\n", VERSION);
fprintf(stderr,
"Usage: makeicns [k1=v1] [k2=v2] ...\n\n");
fprintf(stderr,
"Keys and values include:\n");
fprintf(stderr,
" 512: Name of input image for 512x512 variant of icon\n");
fprintf(stderr,
" 256: Name of input image for 256x256 variant of icon\n");
fprintf(stderr,
" 128: Name of input image for 128x128 variant of icon\n");
fprintf(stderr,
" 32: Name of input image for 32x32 variant of icon\n");
fprintf(stderr,
" 16: Name of input image for 16x16 variant of icon\n");
fprintf(stderr,
" in: Name of input image for all variants not having an explicit name\n");
fprintf(stderr,
" out: Name of output file, defaults to first nonempty input name,\n"
" but with icns extension\n\n");
fprintf(stderr,
"Examples:\n\n"
" icns -512 image.png -32 image.png\n"
" Creates image.icns with only a 512x512 and a 32x32 variant.\n\n"
" icns -in myfile.jpg -32 otherfile.png -out outfile.icns\n"
" Creates outfile.icns with sizes 512, 256, 128, and 16 containing data\n"
" from myfile.jpg and with size 32 containing data from otherfile.png.\n");
exit(1);
}
NSBitmapImageRep* getBitmapImageRepOfSize(NSImage* img, int size) {
// Don't resample if it's not necessary
#if 0
// IconFamily does not work correctly with
// NSAlphaNonpremultipliedBitmapFormat images, so this has to stay disabled
// until IconFamily is fixed (if ever).
NSEnumerator* e = [[img representations] objectEnumerator];
NSImageRep* ir;
while ((ir = [e nextObject])) {
if (![ir isKindOfClass:[NSBitmapImageRep class]]) continue;
NSBitmapImageRep* br = (NSBitmapImageRep*)ir;
//NSLog(@"%@", br);
if ([br pixelsWide] == size && [br pixelsHigh] == size
&& ([[br colorSpaceName] isEqualToString:NSDeviceRGBColorSpace]
|| [[br colorSpaceName] isEqualToString:NSCalibratedRGBColorSpace])
&& ([br bitsPerPixel] == 24 || [br bitsPerPixel] == 32)
)
return br;
}
#endif
NSLog(@"Resampling for size %d", size);
NSBitmapImageRep* r = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:NULL
pixelsWide:size
pixelsHigh:size
bitsPerSample:8
samplesPerPixel:4
hasAlpha:YES
isPlanar:NO
colorSpaceName:NSDeviceRGBColorSpace
bitmapFormat:0
bytesPerRow:0
bitsPerPixel:0];
[NSGraphicsContext saveGraphicsState];
NSGraphicsContext* context = [NSGraphicsContext
graphicsContextWithBitmapImageRep:r];
[context setShouldAntialias:YES];
[context setImageInterpolation:NSImageInterpolationHigh];
[NSGraphicsContext setCurrentContext:context];
[img drawInRect:NSMakeRect(0, 0, size, size)
fromRect:NSZeroRect
operation:NSCompositeCopy
fraction:1.0];
[NSGraphicsContext restoreGraphicsState];
return r;
}
int main(int argc, char* argv[]) {
int i;
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSApplicationLoad();
struct {
NSString* paramName;
OSType type, mask;
int size;
NSString* inputName;
} inputs[] = {
{ @"512", kIconServices512PixelDataARGB, 0, 512, nil },
{ @"256", kIconServices256PixelDataARGB, 0, 256, nil },
{ @"128", kThumbnail32BitData, kThumbnail8BitMask, 128, nil },
{ @"32", kLarge32BitData, kLarge8BitMask, 32, nil },
{ @"16", kSmall32BitData, kSmall8BitMask, 16, nil },
};
const int N = sizeof(inputs)/sizeof(inputs[0]);
// Process arguments -- Thanks Greg!
//http://unixjunkie.blogspot.com/2006/07/command-line-processing-in-cocoa.html
NSUserDefaults* args = [NSUserDefaults standardUserDefaults];
BOOL foundInputParam = NO;
NSString* outputName = [args stringForKey:@"out"];
NSString* defaultIn = [args stringForKey:@"in"];
for (i = 0; i < N; ++i) {
inputs[i].inputName = [args stringForKey:inputs[i].paramName];
if (inputs[i].inputName == nil)
inputs[i].inputName = defaultIn;
foundInputParam = foundInputParam || inputs[i].inputName != nil;
// Create default output name if necessary
if (outputName == nil && inputs[i].inputName != nil)
outputName = [[inputs[i].inputName stringByDeletingPathExtension]
stringByAppendingPathExtension:@"icns"];
}
if (!foundInputParam)
usage();
// Create output
IconFamily* output = [IconFamily iconFamily];
for (i = 0; i < N; ++i) {
if (inputs[i].inputName == nil) continue;
NSImage* img = [[[NSImage alloc] initWithContentsOfFile:inputs[i].inputName]
autorelease];
NSBitmapImageRep* rep = getBitmapImageRepOfSize(img, inputs[i].size);
[output setIconFamilyElement:inputs[i].type fromBitmapImageRep:rep];
if (inputs[i].mask != 0)
[output setIconFamilyElement:inputs[i].mask fromBitmapImageRep:rep];
}
// Write output
if ([output writeToFile:outputName])
NSLog(@"Wrote output file \"%@\"", outputName);
else
NSLog(@"Failed to write \"%@\"", outputName);
[pool drain];
return 0;
}
-5
View File
@@ -1,5 +0,0 @@
from distutils.core import setup, Extension
setup(name="loadfont", version="1.0",
ext_modules = [Extension("loadfont", ["loadfont.c"])])
Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.
@@ -0,0 +1,55 @@
#include <CoreFoundation/CoreFoundation.h>
#include <CoreServices/CoreServices.h>
#include <QuickLook/QuickLook.h>
#import <Foundation/Foundation.h>
#import "QLSFileAttributes.h"
// Generate a preview for the document with the given url
OSStatus GeneratePreviewForURL(void *thisInterface,
QLPreviewRequestRef request,
CFURLRef url,
CFStringRef contentTypeUTI,
CFDictionaryRef options) {
@autoreleasepool {
if (QLPreviewRequestIsCancelled(request))
return noErr;
QLSFileAttributes *magicAttributes =
[QLSFileAttributes attributesForItemAtURL:(__bridge NSURL *)url];
if (!magicAttributes) {
NSLog(@"QLStephen: Could not determine attribtues of file %@", url);
return noErr;
}
if (!magicAttributes.isTextFile) {
return noErr;
}
if (magicAttributes.fileEncoding == kCFStringEncodingInvalidId) {
NSLog(@"QLStephen: Could not determine encoding of file %@", url);
return noErr;
}
NSDictionary *previewProperties = @{
(NSString *)kQLPreviewPropertyStringEncodingKey : @( magicAttributes.fileEncoding ),
(NSString *)kQLPreviewPropertyWidthKey : @700,
(NSString *)kQLPreviewPropertyHeightKey : @800
};
QLPreviewRequestSetURLRepresentation(
request,
url,
kUTTypePlainText,
(__bridge CFDictionaryRef)previewProperties);
return noErr;
}
}
void CancelPreviewGeneration(void* thisInterface, QLPreviewRequestRef preview) {
// implement only if supported
}
@@ -0,0 +1,164 @@
#include <CoreFoundation/CoreFoundation.h>
#include <CoreServices/CoreServices.h>
#include <QuickLook/QuickLook.h>
#import <Foundation/Foundation.h>
#import "RegexKitLite.h"
#import "QLSFileAttributes.h"
/**
* This dictionary is used for a file with no extension. It maps the MIME type
* (as returned by file(1)) onto an appropriate thumbnail badge.
*/
static NSDictionary *mimeTypeToBadgeMap() {
return @{
@"application/xml": @"xml",
@"text/x-c" : @"C",
@"text/x-c++" : @"C++",
@"text/x-shellscript" : @"shell",
@"text/x-php" : @"php",
@"text/x-python" : @"python",
@"text/x-perl" : @"perl",
@"text/x-ruby" : @"ruby"
};
}
/**
* Some formats, e.g. Makefiles, have well-known names and no extension.
*/
static NSDictionary *filenameRegexToBadgeMap() {
return @{
@"Makefile" : @"make"
};
}
/**
* @return the string that should be used to badge the thumbnail.
*/
static NSString *ThumbnailBadgeForItemWithAttributes(
QLSFileAttributes *attributes) {
NSString *fileExtension = attributes.url.pathExtension;
NSString *fileName = attributes.url.lastPathComponent;
__block NSString *badge;
// Do we have a file extension? If so, use it as a badge if it's not too
// long.
if (![fileExtension isEqualToString:@""]) {
badge = fileExtension;
// Is the file extension too long to be reasonably displayed in a
// thumbnail? If so, fall back on the additional tests.
// FIXME: use some better test to determine an appropriate length.
// FIXME: perhaps we should truncate the extension (at the end? in the
// middle?) to fit as much in the thumbnail as possible.
if (badge.length >= 10)
badge = nil;
}
// Do we have a well-known MIME type? Note that we only do this test if we
// have no file extension. file(1) might wrongly guess the MIME type, and it
// would be annoying if the file extension were to say one thing and the
// badge another.
if (!badge && [fileExtension isEqualToString:@""]) {
NSDictionary *map = mimeTypeToBadgeMap();
badge = map[attributes.mimeType];
}
// Does the filename match a known pattern? If so, use the appropriate badge.
if (!badge && [fileExtension isEqualToString:@""]) {
NSDictionary *map = filenameRegexToBadgeMap();
[map enumerateKeysAndObjectsUsingBlock:
^(NSString *regex, NSString *candidateBadge, BOOL *stop) {
if ([fileName rkl_isMatchedByRegex:regex]) {
badge = candidateBadge;
*stop = true;
}
}];
}
// Do we have an executable text file? If so, assume it's a script of some
// sort.
if (!badge) {
NSFileManager *fm = [NSFileManager new];
BOOL isExecutable = [fm isExecutableFileAtPath:attributes.url.path];
if (isExecutable)
badge = @"script";
}
// No other tests passed? Just badge it with "txt". I would use "text",
// except that the OS X text QuickLook generator uses "txt", and we ought
// to be consistent with it.
if (!badge) {
badge = @"txt";
}
return [badge uppercaseString];
}
/* -----------------------------------------------------------------------------
Generate a thumbnail for file
This function's job is to create thumbnail for designated file as fast as
possible
-------------------------------------------------------------------------- */
OSStatus GenerateThumbnailForURL(void *thisInterface,
QLThumbnailRequestRef request,
CFURLRef url,
CFStringRef contentTypeUTI,
CFDictionaryRef options,
CGSize maxSize) {
@autoreleasepool {
if (QLThumbnailRequestIsCancelled(request))
return noErr;
QLSFileAttributes *magicAttributes
= [QLSFileAttributes attributesForItemAtURL:(__bridge NSURL *)url];
if (!magicAttributes) {
NSLog(@"QLStephen: Could not determine attribtues of file %@", url);
return noErr;
}
if (!magicAttributes.isTextFile) {
// NSLog(@"QLStephen: I don't think %@ is a text file", url);
return noErr;
}
if (magicAttributes.fileEncoding == kCFStringEncodingInvalidId) {
NSLog(@"QLStephen: Could not determine encoding of file %@", url);
return noErr;
}
NSDictionary *previewProperties = @{
(NSString *)kQLPreviewPropertyStringEncodingKey : @( magicAttributes.fileEncoding )
};
NSString *badge = ThumbnailBadgeForItemWithAttributes(magicAttributes);
NSDictionary *properties = @{
(NSString *)kQLThumbnailPropertyExtensionKey : badge
};
QLThumbnailRequestSetThumbnailWithURLRepresentation(
request,
url,
kUTTypePlainText,
(__bridge CFDictionaryRef)previewProperties,
(__bridge CFDictionaryRef)properties);
return noErr;
}
}
void CancelThumbnailGeneration(void* thisInterface,
QLThumbnailRequestRef thumbnail) {
// implement only if supported
}
+69
View File
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>PlainText</string>
<key>CFBundleTypeRole</key>
<string>QLGenerator</string>
<key>LSItemContentTypes</key>
<array>
<string>public.data</string>
</array>
<key>LSTypeIsPackage</key>
<false/>
<key>NSPersistentStoreTypeKey</key>
<string>XML</string>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>QLStephen</string>
<key>CFBundleShortVersionString</key>
<string>1.4</string>
<key>CFBundleVersion</key>
<string>1.4.2</string>
<key>CFPlugInDynamicRegisterFunction</key>
<string></string>
<key>CFPlugInDynamicRegistration</key>
<string>NO</string>
<key>CFPlugInFactories</key>
<dict>
<key>0CCF41BD-5E94-487C-B19D-FAADBD387609</key>
<string>QuickLookGeneratorPluginFactory</string>
</dict>
<key>CFPlugInTypes</key>
<dict>
<key>5E2D9680-5022-40FA-B806-43349622E5B9</key>
<array>
<string>0CCF41BD-5E94-487C-B19D-FAADBD387609</string>
</array>
</dict>
<key>CFPlugInUnloadFunction</key>
<string></string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2013 Duncan Robertson. All rights reserved.</string>
<key>QLNeedsToBeRunInMainThread</key>
<true/>
<key>QLPreviewHeight</key>
<real>600</real>
<key>QLPreviewWidth</key>
<real>800</real>
<key>QLSupportsConcurrentRequests</key>
<true/>
<key>QLThumbnailMinimumSize</key>
<real>17</real>
</dict>
</plist>
+21
View File
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Duncan Robertson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+21
View File
@@ -0,0 +1,21 @@
//
// QLSMagicFileAttributes.h
// QuickLookStephen
//
// Created by Nick Hutchinson on 31/07/12.
#import <Foundation/Foundation.h>
@interface QLSFileAttributes : NSObject
+ (instancetype)attributesForItemAtURL:(NSURL *)aURL;
@property (readonly) NSURL *url;
@property (readonly) BOOL isTextFile;
@property (readonly) NSString *mimeType;
@property (readonly) CFStringEncoding fileEncoding;
@end
+119
View File
@@ -0,0 +1,119 @@
//
// QLSMagicFileAttributes.m
// QuickLookStephen
//
// Created by Nick Hutchinson on 31/07/12.
//
#import "QLSFileAttributes.h"
#import "RegexKitLite.h"
@interface QLSFileAttributes ()
@property (readwrite) BOOL isTextFile;
@property (readwrite) NSString *mimeType;
@property (readwrite) CFStringEncoding fileEncoding;
@property (readwrite) NSURL *url;
@end
@implementation QLSFileAttributes
+ (instancetype)attributesForItemAtURL:(NSURL *)aURL
{
NSString *magicString = [self magicStringForItemAtURL:aURL];
if (!magicString) return nil;
NSArray *matches = [magicString rkl_captureComponentsMatchedByRegex:
@"(\\S+/\\S+); charset=(\\S+)"];
if (![matches count]) return nil;
NSString *mimeType = matches[1];
NSString *charset = matches[2];
BOOL mimeTypeIsTextual = [self mimeTypeIsTextual:mimeType];
CFStringEncoding encoding =
CFStringConvertIANACharSetNameToEncoding((CFStringRef)charset);
QLSFileAttributes *attributes = [QLSFileAttributes new];
attributes.fileEncoding = encoding;
attributes.isTextFile = mimeTypeIsTextual;
attributes.mimeType = mimeType;
attributes.url = aURL;
return attributes;
}
////////////////////////////////////////////////////////////////////////////////
// Private Methods
////////////////////////////////////////////////////////////////////////////////
+ (NSString *)magicStringForItemAtURL:(NSURL *)aURL
{
NSString *path = [aURL path];
NSParameterAssert(path);
NSMutableDictionary *environment =
[NSProcessInfo.processInfo.environment mutableCopy];
environment[@"LC_ALL"] = @"en_US.UTF-8";
NSTask *task = [NSTask new];
task.launchPath = @"/usr/bin/file";
task.arguments = @[@"--mime", @"--brief", path];
task.environment = environment;
task.standardOutput = [NSPipe new];
[task launch];
NSData *output =
[[task.standardOutput fileHandleForReading] readDataToEndOfFile];
[task waitUntilExit];
if (task.terminationReason != NSTaskTerminationReasonExit
|| task.terminationStatus != 0) {
return nil;
}
NSCharacterSet *whitespaceCharset =
[NSCharacterSet whitespaceAndNewlineCharacterSet];
NSString *stringOutput =
[[NSString alloc] initWithData:output encoding:NSUTF8StringEncoding];
stringOutput =
[stringOutput stringByTrimmingCharactersInSet:whitespaceCharset];
return stringOutput;
}
/**
* @return YES if mimeType contains "text", or if the mime type conforms to the
* public.text UTI.
*/
+ (BOOL)mimeTypeIsTextual:(NSString *)mimeType
{
NSArray *components = [mimeType componentsSeparatedByString:@"/"];
if (components.count != 2)
return NO;
if ([components[0] rangeOfString:@"text"].location != NSNotFound)
return YES;
NSString *UTType =
CFBridgingRelease(UTTypeCreatePreferredIdentifierForTag(
kUTTagClassMIMEType,
(__bridge CFStringRef)mimeType,
kUTTypeData));
if (UTTypeConformsTo((__bridge CFStringRef)UTType, kUTTypeText)) {
return YES;
}
return NO;
}
@end
@@ -0,0 +1,297 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
0107ABFF15C76F2900C65F1A /* QLSFileAttributes.m in Sources */ = {isa = PBXBuildFile; fileRef = 0107ABFD15C76F2900C65F1A /* QLSFileAttributes.m */; };
0149EB3B15F2E8E4003AB298 /* RegexKitLite.m in Sources */ = {isa = PBXBuildFile; fileRef = 0149EB3915F2E8E4003AB298 /* RegexKitLite.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
0149EB3E15F2E9A3003AB298 /* libicucore.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 0149EB3D15F2E9A3003AB298 /* libicucore.dylib */; };
2C05A19C06CAA52B00D84F6F /* GeneratePreviewForURL.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C05A19B06CAA52B00D84F6F /* GeneratePreviewForURL.m */; };
61E3BCFB0870B4F2002186A0 /* GenerateThumbnailForURL.m in Sources */ = {isa = PBXBuildFile; fileRef = 61E3BCFA0870B4F2002186A0 /* GenerateThumbnailForURL.m */; };
8D576312048677EA00EA77CD /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 08FB77B6FE84183AC02AAC07 /* main.c */; settings = {ATTRIBUTES = (); }; };
8D576314048677EA00EA77CD /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0AA1909FFE8422F4C02AAC07 /* CoreFoundation.framework */; };
8D5B49A804867FD3000E48DA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8D5B49A704867FD3000E48DA /* InfoPlist.strings */; };
AE02F6EB0EDDFA6400CBA17D /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AE02F6EA0EDDFA6400CBA17D /* Cocoa.framework */; };
C86B05270671AA6E00DD9006 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C86B05260671AA6E00DD9006 /* CoreServices.framework */; };
F28CFBFD0A3EC0AF000ABFF5 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F28CFBFC0A3EC0AF000ABFF5 /* ApplicationServices.framework */; };
F28CFC030A3EC0C6000ABFF5 /* QuickLook.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F28CFC020A3EC0C6000ABFF5 /* QuickLook.framework */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
0107ABFC15C76F2900C65F1A /* QLSFileAttributes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QLSFileAttributes.h; sourceTree = "<group>"; };
0107ABFD15C76F2900C65F1A /* QLSFileAttributes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QLSFileAttributes.m; sourceTree = "<group>"; };
0149EB3815F2E8E4003AB298 /* RegexKitLite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegexKitLite.h; sourceTree = "<group>"; };
0149EB3915F2E8E4003AB298 /* RegexKitLite.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RegexKitLite.m; sourceTree = "<group>"; };
0149EB3D15F2E9A3003AB298 /* libicucore.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libicucore.dylib; path = usr/lib/libicucore.dylib; sourceTree = SDKROOT; };
089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
08FB77B6FE84183AC02AAC07 /* main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = "<group>"; };
0AA1909FFE8422F4C02AAC07 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; };
2C05A19B06CAA52B00D84F6F /* GeneratePreviewForURL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratePreviewForURL.m; sourceTree = "<group>"; usesTabs = 0; };
61E3BCFA0870B4F2002186A0 /* GenerateThumbnailForURL.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = GenerateThumbnailForURL.m; sourceTree = "<group>"; };
8D576316048677EA00EA77CD /* QLStephen.qlgenerator */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = QLStephen.qlgenerator; sourceTree = BUILT_PRODUCTS_DIR; };
8D576317048677EA00EA77CD /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
AE02F6EA0EDDFA6400CBA17D /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
C86B05260671AA6E00DD9006 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = /System/Library/Frameworks/CoreServices.framework; sourceTree = "<absolute>"; };
F28CFBFC0A3EC0AF000ABFF5 /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = /System/Library/Frameworks/ApplicationServices.framework; sourceTree = "<absolute>"; };
F28CFC020A3EC0C6000ABFF5 /* QuickLook.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuickLook.framework; path = /System/Library/Frameworks/QuickLook.framework; sourceTree = "<absolute>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
8D576313048677EA00EA77CD /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
0149EB3E15F2E9A3003AB298 /* libicucore.dylib in Frameworks */,
8D576314048677EA00EA77CD /* CoreFoundation.framework in Frameworks */,
C86B05270671AA6E00DD9006 /* CoreServices.framework in Frameworks */,
F28CFBFD0A3EC0AF000ABFF5 /* ApplicationServices.framework in Frameworks */,
F28CFC030A3EC0C6000ABFF5 /* QuickLook.framework in Frameworks */,
AE02F6EB0EDDFA6400CBA17D /* Cocoa.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
0149EB3F15F2EC37003AB298 /* Third-Party */ = {
isa = PBXGroup;
children = (
0149EB3815F2E8E4003AB298 /* RegexKitLite.h */,
0149EB3915F2E8E4003AB298 /* RegexKitLite.m */,
);
name = "Third-Party";
sourceTree = "<group>";
};
089C166AFE841209C02AAC07 /* QuickLookStephen */ = {
isa = PBXGroup;
children = (
0149EB3F15F2EC37003AB298 /* Third-Party */,
08FB77AFFE84173DC02AAC07 /* Source */,
089C167CFE841241C02AAC07 /* Resources */,
089C1671FE841209C02AAC07 /* External Frameworks and Libraries */,
19C28FB6FE9D52B211CA2CBB /* Products */,
);
name = QuickLookStephen;
sourceTree = "<group>";
};
089C1671FE841209C02AAC07 /* External Frameworks and Libraries */ = {
isa = PBXGroup;
children = (
0149EB3D15F2E9A3003AB298 /* libicucore.dylib */,
AE02F6EA0EDDFA6400CBA17D /* Cocoa.framework */,
F28CFC020A3EC0C6000ABFF5 /* QuickLook.framework */,
F28CFBFC0A3EC0AF000ABFF5 /* ApplicationServices.framework */,
C86B05260671AA6E00DD9006 /* CoreServices.framework */,
0AA1909FFE8422F4C02AAC07 /* CoreFoundation.framework */,
);
name = "External Frameworks and Libraries";
sourceTree = "<group>";
};
089C167CFE841241C02AAC07 /* Resources */ = {
isa = PBXGroup;
children = (
8D576317048677EA00EA77CD /* Info.plist */,
8D5B49A704867FD3000E48DA /* InfoPlist.strings */,
);
name = Resources;
sourceTree = "<group>";
};
08FB77AFFE84173DC02AAC07 /* Source */ = {
isa = PBXGroup;
children = (
61E3BCFA0870B4F2002186A0 /* GenerateThumbnailForURL.m */,
2C05A19B06CAA52B00D84F6F /* GeneratePreviewForURL.m */,
08FB77B6FE84183AC02AAC07 /* main.c */,
0107ABFC15C76F2900C65F1A /* QLSFileAttributes.h */,
0107ABFD15C76F2900C65F1A /* QLSFileAttributes.m */,
);
name = Source;
sourceTree = "<group>";
};
19C28FB6FE9D52B211CA2CBB /* Products */ = {
isa = PBXGroup;
children = (
8D576316048677EA00EA77CD /* QLStephen.qlgenerator */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
8D57630D048677EA00EA77CD /* QuickLookStephen */ = {
isa = PBXNativeTarget;
buildConfigurationList = 2CA3261E0896AD4900168862 /* Build configuration list for PBXNativeTarget "QuickLookStephen" */;
buildPhases = (
8D57630F048677EA00EA77CD /* Resources */,
8D576311048677EA00EA77CD /* Sources */,
8D576313048677EA00EA77CD /* Frameworks */,
);
buildRules = (
);
dependencies = (
);
name = QuickLookStephen;
productName = QuickLookStephen;
productReference = 8D576316048677EA00EA77CD /* QLStephen.qlgenerator */;
productType = "com.apple.product-type.bundle";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
089C1669FE841209C02AAC07 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0720;
};
buildConfigurationList = 2CA326220896AD4900168862 /* Build configuration list for PBXProject "QuickLookStephen" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
en,
);
mainGroup = 089C166AFE841209C02AAC07 /* QuickLookStephen */;
projectDirPath = "";
projectRoot = "";
targets = (
8D57630D048677EA00EA77CD /* QuickLookStephen */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
8D57630F048677EA00EA77CD /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8D5B49A804867FD3000E48DA /* InfoPlist.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
8D576311048677EA00EA77CD /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8D576312048677EA00EA77CD /* main.c in Sources */,
2C05A19C06CAA52B00D84F6F /* GeneratePreviewForURL.m in Sources */,
61E3BCFB0870B4F2002186A0 /* GenerateThumbnailForURL.m in Sources */,
0107ABFF15C76F2900C65F1A /* QLSFileAttributes.m in Sources */,
0149EB3B15F2E8E4003AB298 /* RegexKitLite.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
8D5B49A704867FD3000E48DA /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
089C167EFE841241C02AAC07 /* English */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
2CA3261F0896AD4900168862 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_OBJC_ARC = YES;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = NO;
INFOPLIST_FILE = Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = com.whomwah.quicklookstephen;
PRODUCT_NAME = QLStephen;
WRAPPER_EXTENSION = qlgenerator;
};
name = Debug;
};
2CA326200896AD4900168862 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_OBJC_ARC = YES;
COMBINE_HIDPI_IMAGES = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = NO;
INFOPLIST_FILE = Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = com.whomwah.quicklookstephen;
PRODUCT_NAME = QLStephen;
WRAPPER_EXTENSION = qlgenerator;
};
name = Release;
};
2CA326230896AD4900168862 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = c99;
GCC_PREPROCESSOR_DEFINITIONS = "RKL_PREPEND_TO_METHODS=rkl_";
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.8;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
WARNING_CFLAGS = (
"-Wextra",
"-Wall",
"-Wno-unused-parameter",
);
};
name = Debug;
};
2CA326240896AD4900168862 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_C_LANGUAGE_STANDARD = c99;
GCC_PREPROCESSOR_DEFINITIONS = "RKL_PREPEND_TO_METHODS=rkl_";
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.8;
SDKROOT = macosx;
WARNING_CFLAGS = (
"-Wextra",
"-Wall",
"-Wno-unused-parameter",
);
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
2CA3261E0896AD4900168862 /* Build configuration list for PBXNativeTarget "QuickLookStephen" */ = {
isa = XCConfigurationList;
buildConfigurations = (
2CA3261F0896AD4900168862 /* Debug */,
2CA326200896AD4900168862 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
2CA326220896AD4900168862 /* Build configuration list for PBXProject "QuickLookStephen" */ = {
isa = XCConfigurationList;
buildConfigurations = (
2CA326230896AD4900168862 /* Debug */,
2CA326240896AD4900168862 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 089C1669FE841209C02AAC07 /* Project object */;
}
+72
View File
@@ -0,0 +1,72 @@
## !! UPDATE !!
Hi all. I'm afriad I don't have time to maintain this project any more. I see the issues mounting but I don't have time to answer them. This was a pet project some time ago and I still use the plugin daily and it works just fine for me in it's current form. If anyone would like to step forward and be added a contributor to move it forward, please send me a message.
Duncan
## Reinforcement have arrived :-)
I have volunteered to bring Duncan's excellent QL plugin a bit more up to date. Don't expect to much though. I will focus on backlogged pull requests to begin with.
Tomas
# QuicklookStephen
QLStephen is a QuickLook plugin that lets you view plain text files without a file extension. Files like:
README
INSTALL
Capfile
CHANGELOG
etc...
## Installation
### Pre-compiled
* [Download the latest version of QuickLookStephen](https://github.com/whomwah/qlstephen/releases)
* Unzip
* Copy the file into `/Library/QuickLook` or `~/Library/QuickLook`
(You can create the `QuickLook` folder if it doesnt exist)
### Manually Compiled
Compliling the project yourself? Just copy the generated `QLStephen.qlgenerator`
file into the relevant `QuickLook` folder (as above).
## Trouble?
If youve installed the plugin, but dont see any changes:
- Make sure you are editing (a) the correct plist of (b) the correct bundle.
(For example, you might have two `QLStephen` plugins. Its possible the plugin in
another directory—perhaps `/Library/QuickLook/`—is what is being read.)
- Run `qlmanage -r` in the Terminal. (This will restart QuickLook, which reloads all plugins.)
## Why “QLStephen”?
Because I was listening to [Adam and Joe](http://www.bbc.co.uk/blogs/adamandjoe/2009/06/test-1.shtml) when I first wrote it.
## Authors
**Original author:** Duncan Robertson
Special thanks to the following people for submitting patches over the years:
* [Guillermo Ignacio Enriquez Gutierrez](https://github.com/nacho4d)
* [Rob Lourens](https://github.com/roblourens)
* [Avi Flax](https://github.com/aviflax)
* [Tony](https://github.com/Zearin)
* [Nicholas Hutchinson](https://github.com/nickhutchinson)
## Contributing
* Fork the project
* Send a pull request
* Dont change the build number (Ill do that when I release a new version)
+295
View File
@@ -0,0 +1,295 @@
//
// RegexKitLite.h
// http://regexkit.sourceforge.net/
// Licensed under the terms of the BSD License, as specified below.
//
/*
Copyright (c) 2008-2010, John Engelhart
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Zang Industries nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef __OBJC__
#import <Foundation/NSArray.h>
#import <Foundation/NSError.h>
#import <Foundation/NSObjCRuntime.h>
#import <Foundation/NSRange.h>
#import <Foundation/NSString.h>
#endif // __OBJC__
#include <limits.h>
#include <stdint.h>
#include <sys/types.h>
#include <TargetConditionals.h>
#include <AvailabilityMacros.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef REGEXKITLITE_VERSION_DEFINED
#define REGEXKITLITE_VERSION_DEFINED
#define _RKL__STRINGIFY(b) #b
#define _RKL_STRINGIFY(a) _RKL__STRINGIFY(a)
#define _RKL_JOIN_VERSION(a,b) _RKL_STRINGIFY(a##.##b)
#define _RKL_VERSION_STRING(a,b) _RKL_JOIN_VERSION(a,b)
#define REGEXKITLITE_VERSION_MAJOR 4
#define REGEXKITLITE_VERSION_MINOR 0
#define REGEXKITLITE_VERSION_CSTRING _RKL_VERSION_STRING(REGEXKITLITE_VERSION_MAJOR, REGEXKITLITE_VERSION_MINOR)
#define REGEXKITLITE_VERSION_NSSTRING @REGEXKITLITE_VERSION_CSTRING
#endif // REGEXKITLITE_VERSION_DEFINED
#if !defined(RKL_BLOCKS) && defined(NS_BLOCKS_AVAILABLE) && (NS_BLOCKS_AVAILABLE == 1)
#define RKL_BLOCKS 1
#endif
#if defined(RKL_BLOCKS) && (RKL_BLOCKS == 1)
#define _RKL_BLOCKS_ENABLED 1
#endif // defined(RKL_BLOCKS) && (RKL_BLOCKS == 1)
#if defined(_RKL_BLOCKS_ENABLED) && !defined(__BLOCKS__)
#warning RegexKitLite support for Blocks is enabled, but __BLOCKS__ is not defined. This compiler may not support Blocks, in which case the behavior is undefined. This will probably cause numerous compiler errors.
#endif // defined(_RKL_BLOCKS_ENABLED) && !defined(__BLOCKS__)
// For Mac OS X < 10.5.
#ifndef NSINTEGER_DEFINED
#define NSINTEGER_DEFINED
#if defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
typedef long NSInteger;
typedef unsigned long NSUInteger;
#define NSIntegerMin LONG_MIN
#define NSIntegerMax LONG_MAX
#define NSUIntegerMax ULONG_MAX
#else // defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
typedef int NSInteger;
typedef unsigned int NSUInteger;
#define NSIntegerMin INT_MIN
#define NSIntegerMax INT_MAX
#define NSUIntegerMax UINT_MAX
#endif // defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
#endif // NSINTEGER_DEFINED
#ifndef RKLREGEXOPTIONS_DEFINED
#define RKLREGEXOPTIONS_DEFINED
// These must be identical to their ICU regex counterparts. See http://www.icu-project.org/userguide/regexp.html
enum {
RKLNoOptions = 0,
RKLCaseless = 2,
RKLComments = 4,
RKLDotAll = 32,
RKLMultiline = 8,
RKLUnicodeWordBoundaries = 256
};
typedef uint32_t RKLRegexOptions; // This must be identical to the ICU 'flags' argument type.
#endif // RKLREGEXOPTIONS_DEFINED
#ifndef RKLREGEXENUMERATIONOPTIONS_DEFINED
#define RKLREGEXENUMERATIONOPTIONS_DEFINED
enum {
RKLRegexEnumerationNoOptions = 0UL,
RKLRegexEnumerationCapturedStringsNotRequired = 1UL << 9,
RKLRegexEnumerationReleaseStringReturnedByReplacementBlock = 1UL << 10,
RKLRegexEnumerationFastCapturedStringsXXX = 1UL << 11,
};
typedef NSUInteger RKLRegexEnumerationOptions;
#endif // RKLREGEXENUMERATIONOPTIONS_DEFINED
#ifndef _REGEXKITLITE_H_
#define _REGEXKITLITE_H_
#if defined(__GNUC__) && (__GNUC__ >= 4) && defined(__APPLE_CC__) && (__APPLE_CC__ >= 5465)
#define RKL_DEPRECATED_ATTRIBUTE __attribute__((deprecated))
#else
#define RKL_DEPRECATED_ATTRIBUTE
#endif
#if defined(NS_REQUIRES_NIL_TERMINATION)
#define RKL_REQUIRES_NIL_TERMINATION NS_REQUIRES_NIL_TERMINATION
#else // defined(NS_REQUIRES_NIL_TERMINATION)
#define RKL_REQUIRES_NIL_TERMINATION
#endif // defined(NS_REQUIRES_NIL_TERMINATION)
// This requires a few levels of rewriting to get the desired results.
#define _RKL_CONCAT_2(c,d) c ## d
#define _RKL_CONCAT(a,b) _RKL_CONCAT_2(a,b)
#ifdef RKL_PREPEND_TO_METHODS
#define RKL_METHOD_PREPEND(x) _RKL_CONCAT(RKL_PREPEND_TO_METHODS, x)
#else // RKL_PREPEND_TO_METHODS
#define RKL_METHOD_PREPEND(x) x
#endif // RKL_PREPEND_TO_METHODS
// If it looks like low memory notifications might be available, add code to register and respond to them.
// This is (should be) harmless if it turns out that this isn't the case, since the notification that we register for,
// UIApplicationDidReceiveMemoryWarningNotification, is dynamically looked up via dlsym().
#if ((defined(TARGET_OS_EMBEDDED) && (TARGET_OS_EMBEDDED != 0)) || (defined(TARGET_OS_IPHONE) && (TARGET_OS_IPHONE != 0))) && (!defined(RKL_REGISTER_FOR_IPHONE_LOWMEM_NOTIFICATIONS) || (RKL_REGISTER_FOR_IPHONE_LOWMEM_NOTIFICATIONS != 0))
#define RKL_REGISTER_FOR_IPHONE_LOWMEM_NOTIFICATIONS 1
#endif
#ifdef __OBJC__
// NSException exception name.
extern NSString * const RKLICURegexException;
// NSError error domains and user info keys.
extern NSString * const RKLICURegexErrorDomain;
extern NSString * const RKLICURegexEnumerationOptionsErrorKey;
extern NSString * const RKLICURegexErrorCodeErrorKey;
extern NSString * const RKLICURegexErrorNameErrorKey;
extern NSString * const RKLICURegexLineErrorKey;
extern NSString * const RKLICURegexOffsetErrorKey;
extern NSString * const RKLICURegexPreContextErrorKey;
extern NSString * const RKLICURegexPostContextErrorKey;
extern NSString * const RKLICURegexRegexErrorKey;
extern NSString * const RKLICURegexRegexOptionsErrorKey;
extern NSString * const RKLICURegexReplacedCountErrorKey;
extern NSString * const RKLICURegexReplacedStringErrorKey;
extern NSString * const RKLICURegexReplacementStringErrorKey;
extern NSString * const RKLICURegexSubjectRangeErrorKey;
extern NSString * const RKLICURegexSubjectStringErrorKey;
@interface NSString (RegexKitLiteAdditions)
+ (void)RKL_METHOD_PREPEND(clearStringCache);
// Although these are marked as deprecated, a bug in GCC prevents a warning from being issues for + class methods. Filed bug with Apple, #6736857.
+ (NSInteger)RKL_METHOD_PREPEND(captureCountForRegex):(NSString *)regex RKL_DEPRECATED_ATTRIBUTE;
+ (NSInteger)RKL_METHOD_PREPEND(captureCountForRegex):(NSString *)regex options:(RKLRegexOptions)options error:(NSError **)error RKL_DEPRECATED_ATTRIBUTE;
- (NSArray *)RKL_METHOD_PREPEND(componentsSeparatedByRegex):(NSString *)regex;
- (NSArray *)RKL_METHOD_PREPEND(componentsSeparatedByRegex):(NSString *)regex range:(NSRange)range;
- (NSArray *)RKL_METHOD_PREPEND(componentsSeparatedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error;
- (BOOL)RKL_METHOD_PREPEND(isMatchedByRegex):(NSString *)regex;
- (BOOL)RKL_METHOD_PREPEND(isMatchedByRegex):(NSString *)regex inRange:(NSRange)range;
- (BOOL)RKL_METHOD_PREPEND(isMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range error:(NSError **)error;
- (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex;
- (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex capture:(NSInteger)capture;
- (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex inRange:(NSRange)range;
- (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range capture:(NSInteger)capture error:(NSError **)error;
- (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex;
- (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex capture:(NSInteger)capture;
- (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex inRange:(NSRange)range;
- (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range capture:(NSInteger)capture error:(NSError **)error;
- (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement;
- (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement range:(NSRange)searchRange;
- (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement options:(RKLRegexOptions)options range:(NSRange)searchRange error:(NSError **)error;
//// >= 3.0
- (NSInteger)RKL_METHOD_PREPEND(captureCount);
- (NSInteger)RKL_METHOD_PREPEND(captureCountWithOptions):(RKLRegexOptions)options error:(NSError **)error;
- (BOOL)RKL_METHOD_PREPEND(isRegexValid);
- (BOOL)RKL_METHOD_PREPEND(isRegexValidWithOptions):(RKLRegexOptions)options error:(NSError **)error;
- (void)RKL_METHOD_PREPEND(flushCachedRegexData);
- (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex;
- (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex capture:(NSInteger)capture;
- (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex range:(NSRange)range;
- (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range capture:(NSInteger)capture error:(NSError **)error;
- (NSArray *)RKL_METHOD_PREPEND(captureComponentsMatchedByRegex):(NSString *)regex;
- (NSArray *)RKL_METHOD_PREPEND(captureComponentsMatchedByRegex):(NSString *)regex range:(NSRange)range;
- (NSArray *)RKL_METHOD_PREPEND(captureComponentsMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error;
- (NSArray *)RKL_METHOD_PREPEND(arrayOfCaptureComponentsMatchedByRegex):(NSString *)regex;
- (NSArray *)RKL_METHOD_PREPEND(arrayOfCaptureComponentsMatchedByRegex):(NSString *)regex range:(NSRange)range;
- (NSArray *)RKL_METHOD_PREPEND(arrayOfCaptureComponentsMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error;
//// >= 4.0
- (NSArray *)RKL_METHOD_PREPEND(arrayOfDictionariesByMatchingRegex):(NSString *)regex withKeysAndCaptures:(id)firstKey, ... RKL_REQUIRES_NIL_TERMINATION;
- (NSArray *)RKL_METHOD_PREPEND(arrayOfDictionariesByMatchingRegex):(NSString *)regex range:(NSRange)range withKeysAndCaptures:(id)firstKey, ... RKL_REQUIRES_NIL_TERMINATION;
- (NSArray *)RKL_METHOD_PREPEND(arrayOfDictionariesByMatchingRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error withKeysAndCaptures:(id)firstKey, ... RKL_REQUIRES_NIL_TERMINATION;
- (NSArray *)RKL_METHOD_PREPEND(arrayOfDictionariesByMatchingRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error withFirstKey:(id)firstKey arguments:(va_list)varArgsList;
- (NSArray *)RKL_METHOD_PREPEND(arrayOfDictionariesByMatchingRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error withKeys:(id *)keys forCaptures:(int *)captures count:(NSUInteger)count;
- (NSDictionary *)RKL_METHOD_PREPEND(dictionaryByMatchingRegex):(NSString *)regex withKeysAndCaptures:(id)firstKey, ... RKL_REQUIRES_NIL_TERMINATION;
- (NSDictionary *)RKL_METHOD_PREPEND(dictionaryByMatchingRegex):(NSString *)regex range:(NSRange)range withKeysAndCaptures:(id)firstKey, ... RKL_REQUIRES_NIL_TERMINATION;
- (NSDictionary *)RKL_METHOD_PREPEND(dictionaryByMatchingRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error withKeysAndCaptures:(id)firstKey, ... RKL_REQUIRES_NIL_TERMINATION;
- (NSDictionary *)RKL_METHOD_PREPEND(dictionaryByMatchingRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error withFirstKey:(id)firstKey arguments:(va_list)varArgsList;
- (NSDictionary *)RKL_METHOD_PREPEND(dictionaryByMatchingRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error withKeys:(id *)keys forCaptures:(int *)captures count:(NSUInteger)count;
#ifdef _RKL_BLOCKS_ENABLED
- (BOOL)RKL_METHOD_PREPEND(enumerateStringsMatchedByRegex):(NSString *)regex usingBlock:(void (^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
- (BOOL)RKL_METHOD_PREPEND(enumerateStringsMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range error:(NSError **)error enumerationOptions:(RKLRegexEnumerationOptions)enumerationOptions usingBlock:(void (^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
- (BOOL)RKL_METHOD_PREPEND(enumerateStringsSeparatedByRegex):(NSString *)regex usingBlock:(void (^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
- (BOOL)RKL_METHOD_PREPEND(enumerateStringsSeparatedByRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range error:(NSError **)error enumerationOptions:(RKLRegexEnumerationOptions)enumerationOptions usingBlock:(void (^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
- (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex usingBlock:(NSString *(^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
- (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range error:(NSError **)error enumerationOptions:(RKLRegexEnumerationOptions)enumerationOptions usingBlock:(NSString *(^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
#endif // _RKL_BLOCKS_ENABLED
@end
@interface NSMutableString (RegexKitLiteAdditions)
- (NSInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement;
- (NSInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement range:(NSRange)searchRange;
- (NSInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement options:(RKLRegexOptions)options range:(NSRange)searchRange error:(NSError **)error;
//// >= 4.0
#ifdef _RKL_BLOCKS_ENABLED
- (NSInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex usingBlock:(NSString *(^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
- (NSInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range error:(NSError **)error enumerationOptions:(RKLRegexEnumerationOptions)enumerationOptions usingBlock:(NSString *(^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
#endif // _RKL_BLOCKS_ENABLED
@end
#endif // __OBJC__
#endif // _REGEXKITLITE_H_
#ifdef __cplusplus
} // extern "C"
#endif
File diff suppressed because it is too large Load Diff
+218
View File
@@ -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 <CoreFoundation/CoreFoundation.h>
#include <CoreFoundation/CFPlugInCOM.h>
#include <CoreServices/CoreServices.h>
#include <QuickLook/QuickLook.h>
// -----------------------------------------------------------------------------
// constants
// -----------------------------------------------------------------------------
// Don't modify this line
#define PLUGIN_ID "0CCF41BD-5E94-487C-B19D-FAADBD387609"
//
// 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;
}
+12 -8
View File
@@ -211,20 +211,24 @@ OBJDIR = $(OBJDIR)d
! ifdef CPU
ASSEMBLY_ARCHITECTURE=$(CPU)
# Using I386 for $ASSEMBLY_ARCHITECTURE doesn't work for VC7.
! if ("$(ASSEMBLY_ARCHITECTURE)" == "i386") || ("$(ASSEMBLY_ARCHITECTURE)" == "I386")
ASSEMBLY_ARCHITECTURE = x86
! endif
! else
CPU = $(PROCESSOR_ARCHITECTURE)
ASSEMBLY_ARCHITECTURE = $(PROCESSOR_ARCHITECTURE)
! if ("$(CPU)" == "x86") || ("$(CPU)" == "X86")
! if "$(CPU)" == "I386"
CPU = i386
! endif
! else # !CPU
CPU = i386
! ifdef PLATFORM
! if ("$(PLATFORM)" == "x64") || ("$(PLATFORM)" == "X64")
CPU = AMD64
! elseif ("$(PLATFORM)" != "x86") && ("$(PLATFORM)" != "X86")
! error *** ERROR Unknown target platform "$(PLATFORM)". Make aborted.
! endif
! endif # !PLATFORM
! endif
!else # !PROCESSOR_ARCHITECTURE
# We're on Windows 95
CPU = i386
!endif # !PROCESSOR_ARCHITECTURE
ASSEMBLY_ARCHITECTURE=$(CPU)
OBJDIR = $(OBJDIR)$(CPU)
# Build a retail version by default
@@ -415,7 +419,7 @@ CPUARG =
!endif
!else
# VC8/9/10 only allows specifying SSE architecture but only for 32bit
!if "$(ASSEMBLY_ARCHITECTURE)" == "x86" && "$(CPUNR)" == "pentium4"
!if "$(ASSEMBLY_ARCHITECTURE)" == "i386" && "$(CPUNR)" == "pentium4"
CPUARG = /arch:SSE2
!endif
!endif
+1 -1
View File
@@ -2964,7 +2964,7 @@ macvim-dmg: macvim
macvimclean:
if test -d MacVim; then \
rm -rf MacVim/build xxd/xxd.dSYM; \
rm -rf MacVim/build MacVim/qlstephen/build xxd/xxd.dSYM; \
fi
+30 -19
View File
@@ -803,6 +803,7 @@ enable_pythoninterp
with_python_config_dir
enable_python3interp
with_python3_config_dir
with_properly_linked_python2_python3
enable_tclinterp
with_tclsh
enable_rubyinterp
@@ -1515,6 +1516,7 @@ Optional Packages:
--with-plthome=PLTHOME Use PLTHOME.
--with-python-config-dir=PATH Python's config directory
--with-python3-config-dir=PATH Python's config directory
--with-properly-linked-python2-python3 Link with properly linked Python 2 and Python 3.
--with-tclsh=PATH which tclsh to use (default: tclsh8.0)
--with-ruby-command=RUBY name of the Ruby command (default: ruby)
--with-x use the X Window System
@@ -5064,7 +5066,7 @@ $as_echo "$vi_cv_version_plain_lua" >&6; }
if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if lua.h can be found in $vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit" >&5
$as_echo_n "checking if lua.h can be found in $vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit... " >&6; }
if test -f $vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h; then
if test -f "$vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
LUA_INC=/luajit-$vi_cv_version_luajit
@@ -5073,7 +5075,7 @@ $as_echo "yes" >&6; }
if test "X$LUA_INC" = "X"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if lua.h can be found in $vi_cv_path_lua_pfx/include" >&5
$as_echo_n "checking if lua.h can be found in $vi_cv_path_lua_pfx/include... " >&6; }
if test -f $vi_cv_path_lua_pfx/include/lua.h; then
if test -f "$vi_cv_path_lua_pfx/include/lua.h"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
@@ -5081,7 +5083,7 @@ $as_echo "yes" >&6; }
$as_echo "no" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if lua.h can be found in $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua" >&5
$as_echo_n "checking if lua.h can be found in $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua... " >&6; }
if test -f $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h; then
if test -f "$vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
LUA_INC=/lua$vi_cv_version_lua
@@ -5332,7 +5334,7 @@ $as_echo "$vi_cv_path_mzscheme_pfx" >&6; }
if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include" >&5
$as_echo_n "checking if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include... " >&6; }
if test -f $vi_cv_path_mzscheme_pfx/include/scheme.h; then
if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then
SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
@@ -5341,7 +5343,7 @@ $as_echo "yes" >&6; }
$as_echo "no" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt" >&5
$as_echo_n "checking if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt... " >&6; }
if test -f $vi_cv_path_mzscheme_pfx/include/plt/scheme.h; then
if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
@@ -5350,7 +5352,7 @@ $as_echo "yes" >&6; }
$as_echo "no" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket" >&5
$as_echo_n "checking if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket... " >&6; }
if test -f $vi_cv_path_mzscheme_pfx/include/racket/scheme.h; then
if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
@@ -5419,16 +5421,16 @@ $as_echo "no" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for racket collects directory" >&5
$as_echo_n "checking for racket collects directory... " >&6; }
if test -d $vi_cv_path_mzscheme_pfx/lib/plt/collects; then
if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then
SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
else
if test -d $vi_cv_path_mzscheme_pfx/lib/racket/collects; then
if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then
SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
else
if test -d $vi_cv_path_mzscheme_pfx/share/racket/collects; then
if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then
SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
else
if test -d $vi_cv_path_mzscheme_pfx/collects; then
if test -d "$vi_cv_path_mzscheme_pfx/collects"; then
SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
fi
fi
@@ -6443,6 +6445,15 @@ fi
# Check whether --with-properly-linked-python2-python3 was given.
if test "${with_properly_linked_python2_python3+set}" = set; then :
withval=$with_properly_linked_python2_python3; vi_cv_with_properly_linked_python2_python3="yes"
else
vi_cv_with_properly_linked_python2_python3="no"
fi
if test "$python_ok" = yes && test "$python3_ok" = yes; then
$as_echo "#define DYNAMIC_PYTHON 1" >>confdefs.h
@@ -6454,7 +6465,7 @@ $as_echo_n "checking whether we can do without RTLD_GLOBAL for Python... " >&6;
CFLAGS="$CFLAGS $PYTHON_CFLAGS"
libs_save=$LIBS
LIBS="-ldl $LIBS"
if test "x$MACOSX" != "xyes"; then
if test "x$MACOSX" != "xyes" || test "$vi_cv_with_properly_linked_python2_python3" = "yes"; then
if test "$cross_compiling" = yes; then :
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
@@ -6912,7 +6923,7 @@ fi
if test "X$vi_cv_path_tcl" != "X"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Tcl version" >&5
$as_echo_n "checking Tcl version... " >&6; }
if echo 'exit [expr [info tclversion] < 8.0]' | $vi_cv_path_tcl - ; then
if echo 'exit [expr [info tclversion] < 8.0]' | "$vi_cv_path_tcl" - ; then
tclver=`echo 'puts [info tclversion]' | $vi_cv_path_tcl -`
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tclver - OK" >&5
$as_echo "$tclver - OK" >&6; };
@@ -6949,10 +6960,10 @@ $as_echo_n "checking for location of tclConfig.sh script... " >&6; }
tclcnf="/System/Library/Frameworks/Tcl.framework"
fi
for try in $tclcnf; do
if test -f $try/tclConfig.sh; then
if test -f "$try/tclConfig.sh"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $try/tclConfig.sh" >&5
$as_echo "$try/tclConfig.sh" >&6; }
. $try/tclConfig.sh
. "$try/tclConfig.sh"
TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
TCL_DEFS=`echo $TCL_DEFS | sed -e 's/\\\\ /\\\\X/g' | tr ' ' '\012' | sed -e '/^[^-]/d' -e '/^-[^D]/d' -e '/-D[^_]/d' -e 's/-D_/ -D_/' | tr '\012' ' ' | sed -e 's/\\\\X/\\\\ /g'`
break
@@ -6969,10 +6980,10 @@ $as_echo_n "checking for Tcl library by myself... " >&6; }
for ver in "" $tclver ; do
for try in $tcllib ; do
trylib=tcl$ver$ext
if test -f $try/lib$trylib ; then
if test -f "$try/lib$trylib" ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $try/lib$trylib" >&5
$as_echo "$try/lib$trylib" >&6; }
TCL_LIBS="-L$try -ltcl$ver -ldl -lm"
TCL_LIBS="-L\"$try\" -ltcl$ver -ldl -lm"
if test "`(uname) 2>/dev/null`" = SunOS &&
uname -r | grep '^5' >/dev/null; then
TCL_LIBS="$TCL_LIBS -R $try"
@@ -9602,10 +9613,10 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CYGWIN environment" >&5
$as_echo_n "checking for CYGWIN environment... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CYGWIN or MSYS environment" >&5
$as_echo_n "checking for CYGWIN or MSYS environment... " >&6; }
case `uname` in
CYGWIN*) CYGWIN=yes; { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
CYGWIN*|MSYS*) CYGWIN=yes; { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CYGWIN clipboard support" >&5
$as_echo_n "checking for CYGWIN clipboard support... " >&6; }
+23 -18
View File
@@ -565,19 +565,19 @@ if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
fi
if test "x$vi_cv_with_luajit" != "xno" && test "X$vi_cv_version_luajit" != "X"; then
AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit)
if test -f $vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h; then
if test -f "$vi_cv_path_lua_pfx/include/luajit-$vi_cv_version_luajit/lua.h"; then
AC_MSG_RESULT(yes)
LUA_INC=/luajit-$vi_cv_version_luajit
fi
fi
if test "X$LUA_INC" = "X"; then
AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include)
if test -f $vi_cv_path_lua_pfx/include/lua.h; then
if test -f "$vi_cv_path_lua_pfx/include/lua.h"; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
AC_MSG_CHECKING(if lua.h can be found in $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua)
if test -f $vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h; then
if test -f "$vi_cv_path_lua_pfx/include/lua$vi_cv_version_lua/lua.h"; then
AC_MSG_RESULT(yes)
LUA_INC=/lua$vi_cv_version_lua
else
@@ -753,19 +753,19 @@ if test "$enable_mzschemeinterp" = "yes"; then
SCHEME_INC=
if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
if test -f $vi_cv_path_mzscheme_pfx/include/scheme.h; then
if test -f "$vi_cv_path_mzscheme_pfx/include/scheme.h"; then
SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
if test -f $vi_cv_path_mzscheme_pfx/include/plt/scheme.h; then
if test -f "$vi_cv_path_mzscheme_pfx/include/plt/scheme.h"; then
AC_MSG_RESULT(yes)
SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
else
AC_MSG_RESULT(no)
AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/racket)
if test -f $vi_cv_path_mzscheme_pfx/include/racket/scheme.h; then
if test -f "$vi_cv_path_mzscheme_pfx/include/racket/scheme.h"; then
AC_MSG_RESULT(yes)
SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/racket
else
@@ -828,16 +828,16 @@ if test "$enable_mzschemeinterp" = "yes"; then
fi
AC_MSG_CHECKING(for racket collects directory)
if test -d $vi_cv_path_mzscheme_pfx/lib/plt/collects; then
if test -d "$vi_cv_path_mzscheme_pfx/lib/plt/collects"; then
SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/plt/
else
if test -d $vi_cv_path_mzscheme_pfx/lib/racket/collects; then
if test -d "$vi_cv_path_mzscheme_pfx/lib/racket/collects"; then
SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/lib/racket/
else
if test -d $vi_cv_path_mzscheme_pfx/share/racket/collects; then
if test -d "$vi_cv_path_mzscheme_pfx/share/racket/collects"; then
SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
else
if test -d $vi_cv_path_mzscheme_pfx/collects; then
if test -d "$vi_cv_path_mzscheme_pfx/collects"; then
SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
fi
fi
@@ -1510,6 +1510,11 @@ AC_SUBST(PYTHON3_CFLAGS)
AC_SUBST(PYTHON3_SRC)
AC_SUBST(PYTHON3_OBJ)
AC_ARG_WITH(properly-linked-python2-python3,
[ --with-properly-linked-python2-python3 Link with properly linked Python 2 and Python 3.],
[vi_cv_with_properly_linked_python2_python3="yes"],
[vi_cv_with_properly_linked_python2_python3="no"])
dnl if python2.x and python3.x are enabled one can only link in code
dnl with dlopen(), dlsym(), dlclose()
if test "$python_ok" = yes && test "$python3_ok" = yes; then
@@ -1521,7 +1526,7 @@ if test "$python_ok" = yes && test "$python3_ok" = yes; then
libs_save=$LIBS
dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
LIBS="-ldl $LIBS"
if test "x$MACOSX" != "xyes"; then
if test "x$MACOSX" != "xyes" || test "$vi_cv_with_properly_linked_python2_python3" = "yes"; then
AC_RUN_IFELSE([AC_LANG_SOURCE([
#include <dlfcn.h>
/* If this program fails, then RTLD_GLOBAL is needed.
@@ -1698,7 +1703,7 @@ if test "$enable_tclinterp" = "yes"; then
fi
if test "X$vi_cv_path_tcl" != "X"; then
AC_MSG_CHECKING(Tcl version)
if echo 'exit [[expr [info tclversion] < 8.0]]' | $vi_cv_path_tcl - ; then
if echo 'exit [[expr [info tclversion] < 8.0]]' | "$vi_cv_path_tcl" - ; then
tclver=`echo 'puts [[info tclversion]]' | $vi_cv_path_tcl -`
AC_MSG_RESULT($tclver - OK);
tclloc=`echo 'set l [[info library]];set i [[string last lib $l]];incr i -2;puts [[string range $l 0 $i]]' | $vi_cv_path_tcl -`
@@ -1732,9 +1737,9 @@ if test "$enable_tclinterp" = "yes"; then
tclcnf="/System/Library/Frameworks/Tcl.framework"
fi
for try in $tclcnf; do
if test -f $try/tclConfig.sh; then
if test -f "$try/tclConfig.sh"; then
AC_MSG_RESULT($try/tclConfig.sh)
. $try/tclConfig.sh
. "$try/tclConfig.sh"
dnl use eval, because tcl 8.2 includes ${TCL_DBGX}
TCL_LIBS=`eval echo "$TCL_LIB_SPEC $TCL_LIBS"`
dnl Use $TCL_DEFS for -D_THREAD_SAFE et al. But only use the
@@ -1752,9 +1757,9 @@ if test "$enable_tclinterp" = "yes"; then
for ver in "" $tclver ; do
for try in $tcllib ; do
trylib=tcl$ver$ext
if test -f $try/lib$trylib ; then
if test -f "$try/lib$trylib" ; then
AC_MSG_RESULT($try/lib$trylib)
TCL_LIBS="-L$try -ltcl$ver -ldl -lm"
TCL_LIBS="-L\"$try\" -ltcl$ver -ldl -lm"
if test "`(uname) 2>/dev/null`" = SunOS &&
uname -r | grep '^5' >/dev/null; then
TCL_LIBS="$TCL_LIBS -R $try"
@@ -2861,9 +2866,9 @@ dnl end of GUI-checking
dnl ---------------------------------------------------------------------------
dnl Check for Cygwin, which needs an extra source file if not using X11
AC_MSG_CHECKING(for CYGWIN environment)
AC_MSG_CHECKING(for CYGWIN or MSYS environment)
case `uname` in
CYGWIN*) CYGWIN=yes; AC_MSG_RESULT(yes)
CYGWIN*|MSYS*) CYGWIN=yes; AC_MSG_RESULT(yes)
AC_MSG_CHECKING(for CYGWIN clipboard support)
if test "x$with_x" = "xno" ; then
OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
+13 -3
View File
@@ -1087,6 +1087,7 @@ ex_diffsplit(eap)
exarg_T *eap;
{
win_T *old_curwin = curwin;
buf_T *old_curbuf = curbuf;
#ifdef FEAT_GUI
need_mouse_correct = TRUE;
@@ -1105,7 +1106,18 @@ ex_diffsplit(eap)
{
/* Set 'diff', 'scrollbind' on and 'wrap' off. */
diff_win_options(curwin, TRUE);
diff_win_options(old_curwin, TRUE);
if (win_valid(old_curwin))
{
diff_win_options(old_curwin, TRUE);
if (buf_valid(old_curbuf))
/* Move the cursor position to that of the old window. */
curwin->w_cursor.lnum = diff_get_corresponding_line(
old_curbuf,
old_curwin->w_cursor.lnum,
curbuf,
curwin->w_cursor.lnum);
}
}
}
}
@@ -2541,7 +2553,6 @@ diff_move_to(dir, count)
return OK;
}
#if defined(FEAT_CURSORBIND) || defined(PROTO)
linenr_T
diff_get_corresponding_line(buf1, lnum1, buf2, lnum3)
buf_T *buf1;
@@ -2610,7 +2621,6 @@ diff_get_corresponding_line(buf1, lnum1, buf2, lnum3)
return lnum2;
}
#endif
#if defined(FEAT_FOLDING) || defined(PROTO)
/*
+3 -1
View File
@@ -8074,11 +8074,13 @@ static struct fst
{"argidx", 0, 0, f_argidx},
{"arglistid", 0, 2, f_arglistid},
{"argv", 0, 1, f_argv},
#ifdef FEAT_FLOAT
{"asin", 1, 1, f_asin}, /* WJMc */
#endif
{"assert_equal", 2, 3, f_assert_equal},
{"assert_false", 1, 2, f_assert_false},
{"assert_true", 1, 2, f_assert_true},
#ifdef FEAT_FLOAT
{"asin", 1, 1, f_asin}, /* WJMc */
{"atan", 1, 1, f_atan},
{"atan2", 2, 2, f_atan2},
#endif
+4 -3
View File
@@ -540,10 +540,11 @@ ex_sort(eap)
if (!unique || i == 0
|| (sort_ic ? STRICMP(s, sortbuf1) : STRCMP(s, sortbuf1)) != 0)
{
if (ml_append(lnum++, s, (colnr_T)0, FALSE) == FAIL)
/* Copy the line into a buffer, it may become invalid in
* ml_append(). And it's needed for "unique". */
STRCPY(sortbuf1, s);
if (ml_append(lnum++, sortbuf1, (colnr_T)0, FALSE) == FAIL)
break;
if (unique)
STRCPY(sortbuf1, s);
}
fast_breakcheck();
if (got_int)
+8
View File
@@ -9662,6 +9662,10 @@ ex_redraw(eap)
need_wait_return = FALSE;
out_flush();
#ifdef FEAT_GUI_MACVIM
if (gui.in_use)
gui_macvim_force_flush();
#endif
}
/*
@@ -9685,6 +9689,10 @@ ex_redrawstatus(eap)
RedrawingDisabled = r;
p_lz = p;
out_flush();
# ifdef FEAT_GUI_MACVIM
if (gui.in_use)
gui_macvim_force_flush();
# endif
#endif
}
+3 -3
View File
@@ -3079,12 +3079,12 @@ restore_cmdline_alloc(p)
#endif
/*
* paste a yank register into the command line.
* used by CTRL-R command in command-line mode
* Paste a yank register into the command line.
* Used by CTRL-R command in command-line mode.
* insert_reg() can't be used here, because special characters from the
* register contents will be interpreted as commands.
*
* return FAIL for failure, OK otherwise
* Return FAIL for failure, OK otherwise.
*/
static int
cmdline_paste(regname, literally, remcr)
+1 -1
View File
@@ -27,7 +27,7 @@
/* Is there any system that doesn't have access()? */
#define USE_MCH_ACCESS
#if defined(sun) && defined(S_ISCHR)
#if (defined(sun) || defined(__FreeBSD__)) && defined(S_ISCHR)
# define OPEN_CHR_FILES
static int is_dev_fd_file(char_u *fname);
#endif
+93 -12
View File
@@ -1244,16 +1244,8 @@ utf_char2cells(c)
static struct interval doublewidth[] =
{
{0x1100, 0x115f},
{0x2300, 0x23ff},
{0x2700, 0x2757},
{0x275d, 0x2767},
{0x2776, 0x27bf},
{0x2b00, 0x2b1c},
{0x2b1f, 0x2b29},
{0x2b2c, 0x2b2d},
{0x2b30, 0x2b55},
{0x2b90, 0x2b91},
{0x2e00, 0x2e99},
{0x2329, 0x232a},
{0x2e80, 0x2e99},
{0x2e9b, 0x2ef3},
{0x2f00, 0x2fd5},
{0x2ff0, 0x2ffb},
@@ -1279,11 +1271,98 @@ utf_char2cells(c)
{0xfe68, 0xfe6b},
{0xff01, 0xff60},
{0xffe0, 0xffe6},
{0x10000, 0x1fffd},
{0x1b000, 0x1b001},
{0x1f200, 0x1f202},
{0x1f210, 0x1f23a},
{0x1f240, 0x1f248},
{0x1f250, 0x1f251},
{0x20000, 0x2fffd},
{0x30000, 0x3fffd}
};
/* Sorted list of non-overlapping intervals of Emoji characters,
* based on http://unicode.org/emoji/charts/emoji-list.html */
static struct interval emoji[] =
{
{0x2196, 0x2199},
{0x21a9, 0x21aa},
{0x231a, 0x231b},
{0x2328, 0x2328},
{0x23cf, 0x23cf},
{0x23e9, 0x23f3},
{0x23f8, 0x23fa},
{0x24c2, 0x24c2},
{0x25b6, 0x25b6},
{0x25c0, 0x25c0},
{0x25fb, 0x25fe},
{0x2600, 0x2604},
{0x260e, 0x260e},
{0x2611, 0x2611},
{0x2614, 0x2615},
{0x2618, 0x2618},
{0x261d, 0x261d},
{0x2620, 0x2620},
{0x2622, 0x2623},
{0x2626, 0x2626},
{0x262a, 0x262a},
{0x262e, 0x262f},
{0x2638, 0x2639},
{0x2648, 0x2653},
{0x2668, 0x2668},
{0x267b, 0x267b},
{0x267f, 0x267f},
{0x2692, 0x2694},
{0x2696, 0x2697},
{0x2699, 0x2699},
{0x269b, 0x269c},
{0x26a0, 0x26a1},
{0x26aa, 0x26ab},
{0x26b0, 0x26b1},
{0x26bd, 0x26be},
{0x26c4, 0x26c5},
{0x26c8, 0x26c8},
{0x26ce, 0x26cf},
{0x26d1, 0x26d1},
{0x26d3, 0x26d4},
{0x26e9, 0x26ea},
{0x26f0, 0x26f5},
{0x26f7, 0x26fa},
{0x26fd, 0x26fd},
{0x2702, 0x2702},
{0x2705, 0x2705},
{0x2708, 0x270b},
{0x270d, 0x270d},
{0x270f, 0x270f},
{0x2712, 0x2712},
{0x2714, 0x2714},
{0x2716, 0x2716},
{0x271d, 0x271d},
{0x2721, 0x2721},
{0x2728, 0x2728},
{0x2733, 0x2734},
{0x2744, 0x2744},
{0x2747, 0x2747},
{0x274c, 0x274c},
{0x274e, 0x274e},
{0x2753, 0x2755},
{0x2757, 0x2757},
{0x2764, 0x2764},
{0x2795, 0x2797},
{0x27a1, 0x27a1},
{0x27b0, 0x27b0},
{0x27bf, 0x27bf},
{0x2934, 0x2935},
{0x2b05, 0x2b07},
{0x2b1b, 0x2b1c},
{0x2b50, 0x2b50},
{0x2b55, 0x2b55},
{0x3030, 0x3030},
{0x303d, 0x303d},
{0x3297, 0x3297},
{0x3299, 0x3299},
{0x1f000, 0x1fffd}
};
/* Sorted list of non-overlapping intervals of East Asian Ambiguous
* characters, generated with ../runtime/tools/unicode.vim. */
static struct interval ambiguous[] =
@@ -1482,6 +1561,8 @@ utf_char2cells(c)
if (intable(doublewidth, sizeof(doublewidth), c))
return 2;
#endif
if (intable(emoji, sizeof(emoji), c))
return 2;
}
/* Characters below 0x100 are influenced by 'isprint' option */
@@ -4552,7 +4633,7 @@ init_preedit_start_col(void)
{
if (State & CMDLINE)
preedit_start_col = cmdline_getvcol_cursor();
else if (curwin != NULL)
else if (curwin != NULL && curwin->w_buffer != NULL)
getvcol(curwin, &curwin->w_cursor, &preedit_start_col, NULL, NULL);
/* Prevent that preediting marks the buffer as changed. */
xim_changed_while_preediting = curbuf->b_changed;
+3 -2
View File
@@ -1032,8 +1032,9 @@ mf_read(mfp, hp)
}
#ifdef FEAT_CRYPT
/* Decrypt if 'key' is set and this is a data block. */
if (*mfp->mf_buffer->b_p_key != NUL)
/* Decrypt if 'key' is set and this is a data block. And when changing the
* key. */
if (*mfp->mf_buffer->b_p_key != NUL || mfp->mf_old_key != NULL)
ml_decrypt_data(mfp, hp->bh_data, offset, size);
#endif
+3 -7
View File
@@ -1577,7 +1577,7 @@ get_spec_reg(regname, argp, allocated, errmsg)
cmdline_paste_reg(regname, literally, remcr)
int regname;
int literally; /* Insert text literally instead of "as typed" */
int remcr; /* don't add trailing CR */
int remcr; /* don't add CR characters */
{
long i;
@@ -1590,12 +1590,8 @@ cmdline_paste_reg(regname, literally, remcr)
cmdline_paste_str(y_current->y_array[i], literally);
/* Insert ^M between lines and after last line if type is MLINE.
* Don't do this when "remcr" is TRUE and the next line is empty. */
if (y_current->y_type == MLINE
|| (i < y_current->y_size - 1
&& !(remcr
&& i == y_current->y_size - 2
&& *y_current->y_array[i + 1] == NUL)))
* Don't do this when "remcr" is TRUE. */
if ((y_current->y_type == MLINE || i < y_current->y_size - 1) && !remcr)
cmdline_paste_str((char_u *)"\r", literally);
/* Check for CTRL-C, in case someone tries to paste a few thousand
+7 -2
View File
@@ -3352,8 +3352,8 @@ set_init_1()
if (opt_idx >= 0)
{
#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
if ((long)options[opt_idx].def_val[VI_DEFAULT] > (long)n
|| (long)options[opt_idx].def_val[VI_DEFAULT] == 0L)
if ((long)(long_i)options[opt_idx].def_val[VI_DEFAULT] > (long)n
|| (long)(long_i)options[opt_idx].def_val[VI_DEFAULT] == 0L)
#endif
options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
}
@@ -5050,7 +5050,12 @@ do_set(arg, opt_flags)
/* If error detected, print the error message. */
if (errmsg != NULL)
{
#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
vim_free(saved_origval);
#endif
goto skip;
}
#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
if (saved_origval != NULL)
{
+41 -36
View File
@@ -3345,14 +3345,18 @@ win_line(wp, lnum, startrow, endrow, nochange)
}
#endif
/* find start of trailing whitespace */
if (wp->w_p_list && lcs_trail)
if (wp->w_p_list)
{
trailcol = (colnr_T)STRLEN(ptr);
while (trailcol > (colnr_T)0 && vim_iswhite(ptr[trailcol - 1]))
--trailcol;
trailcol += (colnr_T) (ptr - line);
extra_check = TRUE;
if (lcs_space || lcs_trail)
extra_check = TRUE;
/* find start of trailing whitespace */
if (lcs_trail)
{
trailcol = (colnr_T)STRLEN(ptr);
while (trailcol > (colnr_T)0 && vim_iswhite(ptr[trailcol - 1]))
--trailcol;
trailcol += (colnr_T) (ptr - line);
}
}
/*
@@ -4354,35 +4358,6 @@ win_line(wp, lnum, startrow, endrow, nochange)
#endif
++ptr;
/* 'list': change char 160 to lcs_nbsp and space to lcs_space. */
if (wp->w_p_list
&& (((c == 160
#ifdef FEAT_MBYTE
|| (mb_utf8 && (mb_c == 160 || mb_c == 0x202f))
#endif
) && lcs_nbsp)
|| (c == ' ' && lcs_space && ptr - line <= trailcol)))
{
c = (c == ' ') ? lcs_space : lcs_nbsp;
if (area_attr == 0 && search_attr == 0)
{
n_attr = 1;
extra_attr = hl_attr(HLF_8);
saved_attr2 = char_attr; /* save current attr */
}
#ifdef FEAT_MBYTE
mb_c = c;
if (enc_utf8 && (*mb_char2len)(c) > 1)
{
mb_utf8 = TRUE;
u8cc[0] = 0;
c = 0xc0;
}
else
mb_utf8 = FALSE;
#endif
}
if (extra_check)
{
#ifdef FEAT_SPELL
@@ -4567,6 +4542,36 @@ win_line(wp, lnum, startrow, endrow, nochange)
}
#endif
/* 'list': change char 160 to lcs_nbsp and space to lcs_space.
*/
if (wp->w_p_list
&& (((c == 160
#ifdef FEAT_MBYTE
|| (mb_utf8 && (mb_c == 160 || mb_c == 0x202f))
#endif
) && lcs_nbsp)
|| (c == ' ' && lcs_space && ptr - line <= trailcol)))
{
c = (c == ' ') ? lcs_space : lcs_nbsp;
if (area_attr == 0 && search_attr == 0)
{
n_attr = 1;
extra_attr = hl_attr(HLF_8);
saved_attr2 = char_attr; /* save current attr */
}
#ifdef FEAT_MBYTE
mb_c = c;
if (enc_utf8 && (*mb_char2len)(c) > 1)
{
mb_utf8 = TRUE;
u8cc[0] = 0;
c = 0xc0;
}
else
mb_utf8 = FALSE;
#endif
}
if (trailcol != MAXCOL && ptr > line + trailcol && c == ' ')
{
c = lcs_trail;
+1 -1
View File
@@ -370,7 +370,7 @@ EOF
:sleep 1
:py t.running = False
:py t.join()
:py l[0] = t.t > 8 # check if the background thread is working
:py l[0] = t.t > 7 # check if the background thread is working
:py del time
:py del threading
:py del t
+14 -3
View File
@@ -367,7 +367,7 @@ EOF
:sleep 1
:py3 t.running = False
:py3 t.join()
:py3 l[0] = t.t > 8 # check if the background thread is working
:py3 l[0] = t.t > 7 # check if the background thread is working
:py3 del time
:py3 del threading
:py3 del t
@@ -910,8 +910,19 @@ fnamemodify = vim.Function('fnamemodify')
cb.append(str(fnamemodify('.', ':p:h:t')))
cb.append(vim.eval('@%'))
os.chdir('..')
cb.append(str(fnamemodify('.', ':p:h:t')))
cb.append(vim.eval('@%').replace(os.path.sep, '/'))
path = fnamemodify('.', ':p:h:t')
if path != b'src':
# Running tests from a shadow directory, so move up another level
# This will result in @% looking like shadow/testdir/test87.in, hence the
# slicing to remove the leading path and path separator
os.chdir('..')
cb.append(str(fnamemodify('.', ':p:h:t')))
cb.append(vim.eval('@%')[len(path)+1:].replace(os.path.sep, '/'))
os.chdir(path)
else:
cb.append(str(fnamemodify('.', ':p:h:t')))
cb.append(vim.eval('@%').replace(os.path.sep, '/'))
del path
os.chdir('testdir')
cb.append(str(fnamemodify('.', ':p:h:t')))
cb.append(vim.eval('@%'))
+1
View File
@@ -2,6 +2,7 @@ Tests for the :cdo, :cfdo, :ldo and :lfdo commands
STARTTEST
:so small.vim
:lang mess C
:if !has('quickfix') | e! test.ok | wq! test.out | endif
:call writefile(["Line1", "Line2", "Line3"], 'Xtestfile1')
+22
View File
@@ -23,20 +23,24 @@ STARTTEST
: $put =g:line
: wincmd p
:endfu
:"
:let g:test="Test 1: set linebreak"
:redraw!
:let line=ScreenChar(winwidth(0))
:call DoRecordScreen()
:"
:let g:test="Test 2: set linebreak + set list"
:set linebreak list listchars=
:redraw!
:let line=ScreenChar(winwidth(0))
:call DoRecordScreen()
:"
:let g:test ="Test 3: set linebreak nolist"
:set nolist linebreak
:redraw!
:let line=ScreenChar(winwidth(0))
:call DoRecordScreen()
:"
:let g:test ="Test 4: set linebreak with tab and 1 line as long as screen: should break!"
:set nolist linebreak ts=8
:let line="1\t".repeat('a', winwidth(0)-2)
@@ -50,6 +54,7 @@ STARTTEST
:$put =line
:$
:norm! zt
:"
:let g:test ="Test 5: set linebreak with conceal and set list and tab displayed by different char (line may not be truncated)"
:set cpo&vim list linebreak conceallevel=2 concealcursor=nv listchars=tab:ab
:syn match ConcealVar contained /_/ conceal
@@ -57,6 +62,7 @@ STARTTEST
:let line=ScreenChar(winwidth(0))
:call DoRecordScreen()
:set cpo&vim linebreak
:"
:let g:test ="Test 6: set linebreak with visual block mode"
:let line="REMOVE: this not"
:$put =g:test
@@ -66,20 +72,24 @@ STARTTEST
:1/^REMOVE:
0jf x:$put
:set cpo&vim linebreak
:"
:let g:test ="Test 7: set linebreak with visual block mode and v_b_A"
:$put =g:test
Golong line: 40afoobar aTARGET at end
:exe "norm! $3B\<C-v>eAx\<Esc>"
:set cpo&vim linebreak sbr=
:"
:let g:test ="Test 8: set linebreak with visual char mode and changing block"
:$put =g:test
Go1111-1111-1111-11-1111-1111-11110f-lv3lc2222bgj.
:"
:let g:test ="Test 9: using redo after block visual mode"
:$put =g:test
Go
aaa
aaa
a2k2j~e.
:"
:let g:test ="Test 10: using normal commands after block-visual"
:$put =g:test
:set linebreak
@@ -87,10 +97,22 @@ Go
abcd{ef
ghijklm
no}pqrs2k0f{c%
:"
:let g:test ="Test 11: using block replace mode after wrapping"
:$put =g:test
:set linebreak wrap
Go150aayypk147|jr0
:"
:let g:test ="Test 12: set linebreak list listchars=space:_,tab:>-,tail:-,eol:$"
:set list listchars=space:_,trail:-,tab:>-,eol:$
:$put =g:test
:let line="a aaaaaaaaaaaaaaaaaaaaaa\ta "
:$put =line
:$
:norm! zt
:redraw!
:let line=ScreenChar(winwidth(0))
:call DoRecordScreen()
:%w! test.out
:qa!
ENDTEST
+8
View File
@@ -52,3 +52,11 @@ abcdpqrs
Test 11: using block replace mode after wrapping
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0aaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0aaa
Test 12: set linebreak list listchars=space:_,tab:>-,tail:-,eol:$
a aaaaaaaaaaaaaaaaaaaaaa a
Test 12: set linebreak list listchars=space:_,tab:>-,tail:-,eol:$
a_
aaaaaaaaaaaaaaaaaaaa
aa>-----a-$
~
+32
View File
@@ -756,6 +756,38 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
979,
/**/
978,
/**/
977,
/**/
976,
/**/
975,
/**/
974,
/**/
973,
/**/
972,
/**/
971,
/**/
970,
/**/
969,
/**/
968,
/**/
967,
/**/
966,
/**/
965,
/**/
964,
/**/
963,
/**/