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",
71 "SetPreEditPositionMsgID",
78 // NSUserDefaults keys
79 NSString *MMNoWindowKey = @"MMNoWindow";
80 NSString *MMTabMinWidthKey = @"MMTabMinWidth";
81 NSString *MMTabMaxWidthKey = @"MMTabMaxWidth";
82 NSString *MMTabOptimumWidthKey = @"MMTabOptimumWidth";
83 NSString *MMTextInsetLeftKey = @"MMTextInsetLeft";
84 NSString *MMTextInsetRightKey = @"MMTextInsetRight";
85 NSString *MMTextInsetTopKey = @"MMTextInsetTop";
86 NSString *MMTextInsetBottomKey = @"MMTextInsetBottom";
87 NSString *MMTerminateAfterLastWindowClosedKey
88 = @"MMTerminateAfterLastWindowClosed";
89 NSString *MMTypesetterKey = @"MMTypesetter";
90 NSString *MMCellWidthMultiplierKey = @"MMCellWidthMultiplier";
91 NSString *MMBaselineOffsetKey = @"MMBaselineOffset";
92 NSString *MMTranslateCtrlClickKey = @"MMTranslateCtrlClick";
93 NSString *MMTopLeftPointKey = @"MMTopLeftPoint";
94 NSString *MMOpenFilesInTabsKey = @"MMOpenFilesInTabs";
95 NSString *MMNoFontSubstitutionKey = @"MMNoFontSubstitution";
96 NSString *MMLoginShellKey = @"MMLoginShell";
104 // This loads all fonts from the Resources folder. The fonts are only
105 // available to the process which loaded them, so loading has to be done
106 // once for MacVim and an additional time for each Vim process. The
107 // returned container ref should be used to deactiave the font.
109 // (Code taken from cocoadev.com)
110 ATSFontContainerRef fontContainerRef = 0;
111 NSString *fontsFolder = [[NSBundle mainBundle] resourcePath];
113 NSURL *fontsURL = [NSURL fileURLWithPath:fontsFolder];
117 CFURLGetFSRef((CFURLRef)fontsURL, &fsRef);
119 if (FSGetCatalogInfo(&fsRef, kFSCatInfoNone, NULL, NULL, &fsSpec,
121 ATSFontActivateFromFileSpecification(&fsSpec,
122 kATSFontContextLocal, kATSFontFormatUnspecified, NULL,
123 kATSOptionFlagsDefault, &fontContainerRef);
128 return fontContainerRef;
134 @implementation NSString (MMExtras)
136 - (NSString *)stringByEscapingSpecialFilenameCharacters
138 // NOTE: This code assumes that no characters already have been escaped.
139 NSMutableString *string = [self mutableCopy];
141 [string replaceOccurrencesOfString:@"\\"
143 options:NSLiteralSearch
144 range:NSMakeRange(0, [string length])];
145 [string replaceOccurrencesOfString:@" "
147 options:NSLiteralSearch
148 range:NSMakeRange(0, [string length])];
149 [string replaceOccurrencesOfString:@"\t"
151 options:NSLiteralSearch
152 range:NSMakeRange(0, [string length])];
153 [string replaceOccurrencesOfString:@"%"
155 options:NSLiteralSearch
156 range:NSMakeRange(0, [string length])];
157 [string replaceOccurrencesOfString:@"#"
159 options:NSLiteralSearch
160 range:NSMakeRange(0, [string length])];
161 [string replaceOccurrencesOfString:@"|"
163 options:NSLiteralSearch
164 range:NSMakeRange(0, [string length])];
165 [string replaceOccurrencesOfString:@"\""
167 options:NSLiteralSearch
168 range:NSMakeRange(0, [string length])];
170 return [string autorelease];
173 @end // NSString (MMExtras)
177 @implementation NSIndexSet (MMExtras)
179 + (id)indexSetWithVimList:(NSString *)list
181 NSMutableIndexSet *idxSet = [NSMutableIndexSet indexSet];
182 NSArray *array = [list componentsSeparatedByString:@"\n"];
183 unsigned i, count = [array count];
185 for (i = 0; i < count; ++i) {
186 NSString *entry = [array objectAtIndex:i];
187 if ([entry intValue] > 0)
194 @end // NSIndexSet (MMExtras)