mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
colorscheme now works (even after resizing window).
git-svn-id: http://macvim.googlecode.com/svn/trunk@27 96c4425d-ca35-0410-94e5-3396d5c13a8f
This commit is contained in:
@@ -84,6 +84,13 @@ static int eventButtonNumberToVimMouseButton(int buttonNumber);
|
||||
{
|
||||
defaultBackgroundColor = bg;
|
||||
defaultForegroundColor = fg;
|
||||
|
||||
NSMutableData *data = [NSMutableData data];
|
||||
|
||||
[data appendBytes:&bg length:sizeof(int)];
|
||||
[data appendBytes:&fg length:sizeof(int)];
|
||||
|
||||
[self queueMessage:SetDefaultColorsMsgID data:data];
|
||||
}
|
||||
|
||||
- (BOOL)checkin
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
int maxRows, maxColumns;
|
||||
NSAttributedString *emptyRowString;
|
||||
NSFont *font;
|
||||
NSColor *defaultBackgroundColor;
|
||||
//NSMutableParagraphStyle *paragraphStyle;
|
||||
}
|
||||
|
||||
@@ -43,6 +44,8 @@
|
||||
- (void)clearBlockFromRow:(int)row1 column:(int)col1 toRow:(int)row2
|
||||
column:(int)col2 color:(NSColor *)color;
|
||||
- (void)clearAllWithColor:(NSColor *)color;
|
||||
- (void)setDefaultColorsBackground:(NSColor *)bgColor
|
||||
foreground:(NSColor *)fgColor;
|
||||
- (void)setFont:(NSFont*)newFont;
|
||||
- (NSFont*)font;
|
||||
- (float)widthOfEmptyRow;
|
||||
|
||||
+36
-4
@@ -59,6 +59,7 @@
|
||||
[emptyRowString release];
|
||||
//[paragraphStyle release];
|
||||
[font release];
|
||||
[defaultBackgroundColor release];
|
||||
[attribString release];
|
||||
[super dealloc];
|
||||
}
|
||||
@@ -130,9 +131,15 @@
|
||||
|
||||
NSString *fmt = [NSString stringWithFormat:@"%%%dc\%C", maxColumns,
|
||||
NSLineSeparatorCharacter];
|
||||
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
font, NSFontAttributeName,
|
||||
nil];
|
||||
NSDictionary *dict;
|
||||
if (defaultBackgroundColor) {
|
||||
dict = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
font, NSFontAttributeName,
|
||||
defaultBackgroundColor, NSBackgroundColorAttributeName, nil];
|
||||
} else {
|
||||
dict = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
font, NSFontAttributeName, nil];
|
||||
}
|
||||
|
||||
[emptyRowString release];
|
||||
emptyRowString = [[NSAttributedString alloc]
|
||||
@@ -359,6 +366,31 @@
|
||||
[self edited:NSTextStorageEditedAttributes range:range changeInLength:0];
|
||||
}
|
||||
|
||||
- (void)setDefaultColorsBackground:(NSColor *)bgColor
|
||||
foreground:(NSColor *)fgColor
|
||||
{
|
||||
// NOTE: Foreground color is ignored.
|
||||
[defaultBackgroundColor release];
|
||||
|
||||
#if 0
|
||||
if (bgColor) {
|
||||
defaultBackgroundColor = [bgColor retain];
|
||||
#if 1
|
||||
NSMutableAttributedString *string = [emptyRowString mutableCopy];
|
||||
[string addAttribute:NSBackgroundColorAttributeName value:bgColor
|
||||
range:NSMakeRange(0, [emptyRowString length])];
|
||||
[emptyRowString release];
|
||||
emptyRowString = string;
|
||||
#endif
|
||||
[self clearAllWithColor:bgColor];
|
||||
} else {
|
||||
defaultBackgroundColor = nil;
|
||||
}
|
||||
#else
|
||||
defaultBackgroundColor = bgColor ? [bgColor retain] : nil;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)setFont:(NSFont*)newFont
|
||||
{
|
||||
#if 0
|
||||
@@ -374,7 +406,7 @@
|
||||
changeInLength:0];
|
||||
}
|
||||
#else
|
||||
if (font != newFont) {
|
||||
if (newFont && font != newFont) {
|
||||
//NSLog(@"Setting font %@", newFont);
|
||||
[font release];
|
||||
font = [newFont retain];
|
||||
|
||||
@@ -650,6 +650,17 @@ static NSMenuItem *findMenuItemWithTagInMenu(NSMenu *root, int tag)
|
||||
}
|
||||
|
||||
[name release];
|
||||
} else if (SetDefaultColorsMsgID == msgid) {
|
||||
const void *bytes = [data bytes];
|
||||
int bg = *((int*)bytes); bytes += sizeof(int);
|
||||
int fg = *((int*)bytes); bytes += sizeof(int);
|
||||
|
||||
MMTextStorage *textStorage = [windowController textStorage];
|
||||
if (textStorage) {
|
||||
[textStorage
|
||||
setDefaultColorsBackground:[NSColor colorWithRgbInt:bg]
|
||||
foreground:[NSColor colorWithRgbInt:fg]];
|
||||
}
|
||||
} else {
|
||||
NSLog(@"WARNING: Unknown message received (msgid=%d)", msgid);
|
||||
}
|
||||
|
||||
@@ -81,6 +81,7 @@ enum {
|
||||
ScrollbarEventMsgID,
|
||||
SetFontMsgID,
|
||||
VimShouldCloseMsgID,
|
||||
SetDefaultColorsMsgID,
|
||||
};
|
||||
|
||||
|
||||
|
||||
+10
-3
@@ -83,9 +83,7 @@ gui_mch_init(void)
|
||||
gui.char_width = 1;
|
||||
gui.char_ascent = 0;
|
||||
|
||||
// Default foreground and background colors are black and white.
|
||||
gui.def_norm_pixel = gui.norm_pixel = 0;
|
||||
gui.def_back_pixel = gui.back_pixel = 0xffffff;
|
||||
gui_mch_def_colors();
|
||||
|
||||
[[MMBackend sharedInstance]
|
||||
setDefaultColorsBackground:gui.back_pixel foreground:gui.norm_pixel];
|
||||
@@ -1060,6 +1058,15 @@ gui_mch_new_colors(void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gui_mch_def_colors()
|
||||
{
|
||||
// Default foreground and background colors are black and white.
|
||||
gui.def_norm_pixel = gui.norm_pixel = 0;
|
||||
gui.def_back_pixel = gui.back_pixel = 0xffffff;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set the current text background color.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user