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.
13 char *MessageStrings[] =
28 "SetTextDimensionsMsgID",
29 "SetWindowTitleMsgID",
37 "RemoveMenuItemMsgID",
38 "EnableMenuItemMsgID",
42 "CreateScrollbarMsgID",
43 "DestroyScrollbarMsgID",
45 "SetScrollbarPositionMsgID",
46 "SetScrollbarThumbMsgID",
47 "ScrollbarEventMsgID",
49 "VimShouldCloseMsgID",
50 "SetDefaultColorsMsgID",
59 "AdjustLinespaceMsgID",
62 "EnterFullscreenMsgID",
63 "LeaveFullscreenMsgID",
69 // NSUserDefaults keys
70 NSString *MMNoWindowKey = @"MMNoWindow";
71 NSString *MMTabMinWidthKey = @"MMTabMinWidth";
72 NSString *MMTabMaxWidthKey = @"MMTabMaxWidth";
73 NSString *MMTabOptimumWidthKey = @"MMTabOptimumWidth";
74 NSString *MMTextInsetLeftKey = @"MMTextInsetLeft";
75 NSString *MMTextInsetRightKey = @"MMTextInsetRight";
76 NSString *MMTextInsetTopKey = @"MMTextInsetTop";
77 NSString *MMTextInsetBottomKey = @"MMTextInsetBottom";
78 NSString *MMTerminateAfterLastWindowClosedKey
79 = @"MMTerminateAfterLastWindowClosed";
80 NSString *MMTypesetterKey = @"MMTypesetter";
81 NSString *MMCellWidthMultiplierKey = @"MMCellWidthMultiplier";
82 NSString *MMBaselineOffsetKey = @"MMBaselineOffset";
83 NSString *MMTranslateCtrlClickKey = @"MMTranslateCtrlClick";
84 NSString *MMTopLeftPointKey = @"MMTopLeftPoint";
85 NSString *MMOpenFilesInTabsKey = @"MMOpenFilesInTabs";
93 // This loads all fonts from the Resources folder. The fonts are only
94 // available to the process which loaded them, so loading has to be done
95 // once for MacVim and an additional time for each Vim process. The
96 // returned container ref should be used to deactiave the font.
98 // (Code taken from cocoadev.com)
99 ATSFontContainerRef fontContainerRef = 0;
100 NSString *fontsFolder = [[NSBundle mainBundle] resourcePath];
102 NSURL *fontsURL = [NSURL fileURLWithPath:fontsFolder];
106 CFURLGetFSRef((CFURLRef)fontsURL, &fsRef);
108 if (FSGetCatalogInfo(&fsRef, kFSCatInfoNone, NULL, NULL, &fsSpec,
110 ATSFontActivateFromFileSpecification(&fsSpec,
111 kATSFontContextLocal, kATSFontFormatUnspecified, NULL,
112 kATSOptionFlagsDefault, &fontContainerRef);
117 return fontContainerRef;
123 @implementation NSString (MMExtras)
125 - (NSString *)stringByEscapingPercent
127 NSMutableString *string = [self mutableCopy];
129 // Some '%' may already be escaped, so un-escape first...
130 [string replaceOccurrencesOfString:@"\\%"
132 options:NSLiteralSearch
133 range:NSMakeRange(0, [string length])];
134 // ...then escape all '%'
135 [string replaceOccurrencesOfString:@"%"
137 options:NSLiteralSearch
138 range:NSMakeRange(0, [string length])];
140 return [string autorelease];
143 - (NSString *)stringByEscapingSpace
145 NSMutableString *string = [self mutableCopy];
147 // Some space chars may already be escaped, so un-escape first...
148 [string replaceOccurrencesOfString:@"\\ "
150 options:NSLiteralSearch
151 range:NSMakeRange(0, [string length])];
152 // ...then escape all space chars
153 [string replaceOccurrencesOfString:@" "
155 options:NSLiteralSearch
156 range:NSMakeRange(0, [string length])];
158 return [string autorelease];
161 - (NSString *)stringByEscapingInvalidFilenameCharacters
163 return [[self stringByEscapingSpace] stringByEscapingPercent];
167 @end // NSString (MMExtras)