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",
77 // NSUserDefaults keys
78 NSString *MMNoWindowKey = @"MMNoWindow";
79 NSString *MMTabMinWidthKey = @"MMTabMinWidth";
80 NSString *MMTabMaxWidthKey = @"MMTabMaxWidth";
81 NSString *MMTabOptimumWidthKey = @"MMTabOptimumWidth";
82 NSString *MMTextInsetLeftKey = @"MMTextInsetLeft";
83 NSString *MMTextInsetRightKey = @"MMTextInsetRight";
84 NSString *MMTextInsetTopKey = @"MMTextInsetTop";
85 NSString *MMTextInsetBottomKey = @"MMTextInsetBottom";
86 NSString *MMTerminateAfterLastWindowClosedKey
87 = @"MMTerminateAfterLastWindowClosed";
88 NSString *MMTypesetterKey = @"MMTypesetter";
89 NSString *MMCellWidthMultiplierKey = @"MMCellWidthMultiplier";
90 NSString *MMBaselineOffsetKey = @"MMBaselineOffset";
91 NSString *MMTranslateCtrlClickKey = @"MMTranslateCtrlClick";
92 NSString *MMTopLeftPointKey = @"MMTopLeftPoint";
93 NSString *MMOpenFilesInTabsKey = @"MMOpenFilesInTabs";
94 NSString *MMNoFontSubstitutionKey = @"MMNoFontSubstitution";
95 NSString *MMLoginShellKey = @"MMLoginShell";
103 // This loads all fonts from the Resources folder. The fonts are only
104 // available to the process which loaded them, so loading has to be done
105 // once for MacVim and an additional time for each Vim process. The
106 // returned container ref should be used to deactiave the font.
108 // (Code taken from cocoadev.com)
109 ATSFontContainerRef fontContainerRef = 0;
110 NSString *fontsFolder = [[NSBundle mainBundle] resourcePath];
112 NSURL *fontsURL = [NSURL fileURLWithPath:fontsFolder];
116 CFURLGetFSRef((CFURLRef)fontsURL, &fsRef);
118 if (FSGetCatalogInfo(&fsRef, kFSCatInfoNone, NULL, NULL, &fsSpec,
120 ATSFontActivateFromFileSpecification(&fsSpec,
121 kATSFontContextLocal, kATSFontFormatUnspecified, NULL,
122 kATSOptionFlagsDefault, &fontContainerRef);
127 return fontContainerRef;
133 @implementation NSString (MMExtras)
135 - (NSString *)stringByEscapingSpecialFilenameCharacters
137 // NOTE: This code assumes that no characters already have been escaped.
138 NSMutableString *string = [self mutableCopy];
140 [string replaceOccurrencesOfString:@"\\"
142 options:NSLiteralSearch
143 range:NSMakeRange(0, [string length])];
144 [string replaceOccurrencesOfString:@" "
146 options:NSLiteralSearch
147 range:NSMakeRange(0, [string length])];
148 [string replaceOccurrencesOfString:@"\t"
150 options:NSLiteralSearch
151 range:NSMakeRange(0, [string length])];
152 [string replaceOccurrencesOfString:@"%"
154 options:NSLiteralSearch
155 range:NSMakeRange(0, [string length])];
156 [string replaceOccurrencesOfString:@"#"
158 options:NSLiteralSearch
159 range:NSMakeRange(0, [string length])];
160 [string replaceOccurrencesOfString:@"|"
162 options:NSLiteralSearch
163 range:NSMakeRange(0, [string length])];
164 [string replaceOccurrencesOfString:@"\""
166 options:NSLiteralSearch
167 range:NSMakeRange(0, [string length])];
169 return [string autorelease];
172 @end // NSString (MMExtras)
176 @implementation NSIndexSet (MMExtras)
178 + (id)indexSetWithVimList:(NSString *)list
180 NSMutableIndexSet *idxSet = [NSMutableIndexSet indexSet];
181 NSArray *array = [list componentsSeparatedByString:@"\n"];
182 unsigned i, count = [array count];
184 for (i = 0; i < count; ++i) {
185 NSString *entry = [array objectAtIndex:i];
186 if ([entry intValue] > 0)
193 @end // NSIndexSet (MMExtras)