1 /* vi:set ts=8 sts=4 sw=4 ft=objc:
3 * VIM - Vi IMproved by Bram Moolenaar
4 * MacVim GUI port by Bjorn Winckler
6 * Do ":help uganda" in Vim to read copying and usage conditions.
7 * Do ":help credits" in Vim to see a list of people who contributed.
8 * See README.txt for an overview of the Vim source code.
11 * MacVim.m: Code shared between Vim and MacVim.
16 char *MessageStrings[] =
31 "SetTextDimensionsMsgID",
32 "SetWindowTitleMsgID",
40 "RemoveMenuItemMsgID",
41 "EnableMenuItemMsgID",
45 "CreateScrollbarMsgID",
46 "DestroyScrollbarMsgID",
48 "SetScrollbarPositionMsgID",
49 "SetScrollbarThumbMsgID",
50 "ScrollbarEventMsgID",
53 "VimShouldCloseMsgID",
54 "SetDefaultColorsMsgID",
63 "AdjustLinespaceMsgID",
66 "EnterFullscreenMsgID",
67 "LeaveFullscreenMsgID",
68 "BuffersNotModifiedMsgID",
69 "BuffersModifiedMsgID",
76 // NSUserDefaults keys
77 NSString *MMNoWindowKey = @"MMNoWindow";
78 NSString *MMTabMinWidthKey = @"MMTabMinWidth";
79 NSString *MMTabMaxWidthKey = @"MMTabMaxWidth";
80 NSString *MMTabOptimumWidthKey = @"MMTabOptimumWidth";
81 NSString *MMTextInsetLeftKey = @"MMTextInsetLeft";
82 NSString *MMTextInsetRightKey = @"MMTextInsetRight";
83 NSString *MMTextInsetTopKey = @"MMTextInsetTop";
84 NSString *MMTextInsetBottomKey = @"MMTextInsetBottom";
85 NSString *MMTerminateAfterLastWindowClosedKey
86 = @"MMTerminateAfterLastWindowClosed";
87 NSString *MMTypesetterKey = @"MMTypesetter";
88 NSString *MMCellWidthMultiplierKey = @"MMCellWidthMultiplier";
89 NSString *MMBaselineOffsetKey = @"MMBaselineOffset";
90 NSString *MMTranslateCtrlClickKey = @"MMTranslateCtrlClick";
91 NSString *MMTopLeftPointKey = @"MMTopLeftPoint";
92 NSString *MMOpenFilesInTabsKey = @"MMOpenFilesInTabs";
93 NSString *MMNoFontSubstitutionKey = @"MMNoFontSubstitution";
94 NSString *MMLoginShellKey = @"MMLoginShell";
102 // This loads all fonts from the Resources folder. The fonts are only
103 // available to the process which loaded them, so loading has to be done
104 // once for MacVim and an additional time for each Vim process. The
105 // returned container ref should be used to deactiave the font.
107 // (Code taken from cocoadev.com)
108 ATSFontContainerRef fontContainerRef = 0;
109 NSString *fontsFolder = [[NSBundle mainBundle] resourcePath];
111 NSURL *fontsURL = [NSURL fileURLWithPath:fontsFolder];
115 CFURLGetFSRef((CFURLRef)fontsURL, &fsRef);
117 if (FSGetCatalogInfo(&fsRef, kFSCatInfoNone, NULL, NULL, &fsSpec,
119 ATSFontActivateFromFileSpecification(&fsSpec,
120 kATSFontContextLocal, kATSFontFormatUnspecified, NULL,
121 kATSOptionFlagsDefault, &fontContainerRef);
126 return fontContainerRef;
132 @implementation NSString (MMExtras)
134 - (NSString *)stringByEscapingSpecialFilenameCharacters
136 // NOTE: This code assumes that no characters already have been escaped.
137 NSMutableString *string = [self mutableCopy];
139 [string replaceOccurrencesOfString:@"\\"
141 options:NSLiteralSearch
142 range:NSMakeRange(0, [string length])];
143 [string replaceOccurrencesOfString:@" "
145 options:NSLiteralSearch
146 range:NSMakeRange(0, [string length])];
147 [string replaceOccurrencesOfString:@"\t"
149 options:NSLiteralSearch
150 range:NSMakeRange(0, [string length])];
151 [string replaceOccurrencesOfString:@"%"
153 options:NSLiteralSearch
154 range:NSMakeRange(0, [string length])];
155 [string replaceOccurrencesOfString:@"#"
157 options:NSLiteralSearch
158 range:NSMakeRange(0, [string length])];
159 [string replaceOccurrencesOfString:@"|"
161 options:NSLiteralSearch
162 range:NSMakeRange(0, [string length])];
163 [string replaceOccurrencesOfString:@"\""
165 options:NSLiteralSearch
166 range:NSMakeRange(0, [string length])];
168 return [string autorelease];
171 @end // NSString (MMExtras)
175 @implementation NSIndexSet (MMExtras)
177 + (id)indexSetWithVimList:(NSString *)list
179 NSMutableIndexSet *idxSet = [NSMutableIndexSet indexSet];
180 NSArray *array = [list componentsSeparatedByString:@"\n"];
181 unsigned i, count = [array count];
183 for (i = 0; i < count; ++i) {
184 NSString *entry = [array objectAtIndex:i];
185 if ([entry intValue] > 0)
192 @end // NSIndexSet (MMExtras)