Add MMRenderer user default

Set to 0 for Cocoa renderer, 1 for ATSUI, 2 for Core Text.  The default
is 0.
This commit is contained in:
Bjorn Winckler
2009-11-15 22:33:13 +01:00
parent 5f81e8ad27
commit fc698b39fe
7 changed files with 66 additions and 13 deletions
+22
View File
@@ -207,6 +207,7 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
[NSNumber numberWithBool:NO], MMNoFontSubstitutionKey,
[NSNumber numberWithBool:YES], MMLoginShellKey,
[NSNumber numberWithBool:NO], MMAtsuiRendererKey,
[NSNumber numberWithInt:0], MMRendererKey,
[NSNumber numberWithInt:MMUntitledWindowAlways],
MMUntitledWindowKey,
[NSNumber numberWithBool:NO], MMTexturedWindowKey,
@@ -1179,6 +1180,27 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
- (IBAction)atsuiButtonClicked:(id)sender
{
ASLogDebug(@"Toggle ATSUI renderer");
NSInteger renderer = MMRendererDefault;
BOOL enable = ([sender state] == NSOnState);
if (enable) {
#if MM_ENABLE_ATSUI
renderer = MMRendererATSUI;
#else
renderer = MMRendererCoreText;
#endif
}
// Update the user default MMRenderer and synchronize the change so that
// any new Vim process will pick up on the changed setting.
CFPreferencesSetAppValue(
(CFStringRef)MMRendererKey,
(CFPropertyListRef)[NSNumber numberWithInt:renderer],
kCFPreferencesCurrentApplication);
CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
ASLogInfo(@"Use renderer=%d", renderer);
// This action is called when the user clicks the "use ATSUI renderer"
// button in the advanced preferences pane.
[self rebuildPreloadCache];
+11 -8
View File
@@ -93,15 +93,18 @@ enum {
[self setAutoresizesSubviews:YES];
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
if ([ud boolForKey:MMAtsuiRendererKey]) {
// Use ATSUI or CoreText for text rendering.
//
// HACK! 'textView' has type MMTextView, but MM[Atsui|Core]TextView
// is not derived from MMTextView.
#if MM_ENABLE_ATSUI
textView = [[MMAtsuiTextView alloc] initWithFrame:frame];
#else
NSInteger renderer = [ud integerForKey:MMRendererKey];
ASLogInfo(@"Use renderer=%d", renderer);
if (MMRendererCoreText == renderer) {
// HACK! 'textView' has type MMTextView, but MMCoreTextView is not
// derived from MMTextView.
textView = [[MMCoreTextView alloc] initWithFrame:frame];
#if MM_ENABLE_ATSUI
} else if (MMRendererATSUI == renderer) {
// HACK! 'textView' has type MMTextView, but MMAtsuiTextView is not
// derived from MMTextView.
textView = [[MMAtsuiTextView alloc] initWithFrame:frame];
#endif
} else {
// Use Cocoa text system for text rendering.
+7
View File
@@ -247,6 +247,13 @@ extern NSString *MMNoWindowKey;
extern NSString *MMAutosaveRowsKey;
extern NSString *MMAutosaveColumnsKey;
extern NSString *MMRendererKey;
enum {
MMRendererDefault = 0,
MMRendererATSUI,
MMRendererCoreText
};
// Vim pasteboard type (holds motion type + string)
+1
View File
@@ -108,6 +108,7 @@ NSString *MMNoWindowKey = @"MMNoWindow";
NSString *MMAutosaveRowsKey = @"MMAutosaveRows";
NSString *MMAutosaveColumnsKey = @"MMAutosaveColumns";
NSString *MMRendererKey = @"MMRenderer";
// Vim pasteboard type (holds motion type + string)
NSString *VimPBoardType = @"VimPBoardType";
+16 -2
View File
@@ -19,6 +19,9 @@
#import <Foundation/Foundation.h>
// HACK! Used in gui.c to determine which string drawing code to use.
int use_gui_macvim_draw_string = 1;
// NOTE: The default font is bundled with the application.
static NSString *MMDefaultFontName = @"DejaVu Sans Mono";
@@ -131,6 +134,17 @@ gui_macvim_after_fork_init()
gui.num_rows = rows;
gui.num_cols = cols;
}
// Check which code path to take for string drawing.
CFIndex val;
Boolean keyValid;
val = CFPreferencesGetAppIntegerValue((CFStringRef)MMRendererKey,
kCFPreferencesCurrentApplication,
&keyValid);
if (keyValid) {
ASLogInfo(@"Use renderer=%d", val);
use_gui_macvim_draw_string = (val != MMRendererCoreText);
}
}
@@ -415,7 +429,7 @@ gui_macvim_draw_string(int row, int col, char_u *s, int len, int flags)
if (!utf_iscomposing(c)) {
if ((cn > 1 && !wide) || (cn <= 1 && wide)) {
// Changed from normal to wide or vice versa.
[backend drawString:(char*)(s+start) length:i-start
[backend drawString:(s+start) length:i-start
row:row column:startcol
cells:endcol-startcol
flags:(wide ? flags|DRAW_WIDE : flags)];
@@ -430,7 +444,7 @@ gui_macvim_draw_string(int row, int col, char_u *s, int len, int flags)
}
// Output remaining characters.
[backend drawString:(char*)(s+start) length:len-start
[backend drawString:(s+start) length:len-start
row:row column:startcol cells:endcol-startcol
flags:(wide ? flags|DRAW_WIDE : flags)];
+8 -3
View File
@@ -2237,11 +2237,16 @@ gui_outstr_nowrap(s, len, flags, fg, bg, back)
#ifdef HAVE_GTK2
/* The value returned is the length in display cells */
len = gui_gtk2_draw_string(gui.row, col, s, len, draw_flags);
#elif 0 /* defined(FEAT_GUI_MACVIM) && defined(FEAT_MBYTE) */
/* The value returned is the length in display cells */
len = gui_macvim_draw_string(gui.row, col, s, len, draw_flags);
#else
# ifdef FEAT_MBYTE
# ifdef FEAT_GUI_MACVIM
if (use_gui_macvim_draw_string)
{
/* The value returned is the length in display cells */
len = gui_macvim_draw_string(gui.row, col, s, len, draw_flags);
}
else
# endif
if (enc_utf8)
{
int start; /* index of bytes to be drawn */
+1
View File
@@ -1,3 +1,4 @@
extern int use_gui_macvim_draw_string;
void
macvim_early_init();