From c10671e6fda0d05ab84823759914a139dafd4920 Mon Sep 17 00:00:00 2001 From: Bjorn Winckler Date: Wed, 29 Aug 2007 10:39:36 +0000 Subject: [PATCH] Added defaultForegroundColor git-svn-id: http://macvim.googlecode.com/svn/trunk@210 96c4425d-ca35-0410-94e5-3396d5c13a8f --- MMTextStorage.h | 2 ++ MMTextStorage.m | 21 ++++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/MMTextStorage.h b/MMTextStorage.h index f40fb69a44..49fb97eba8 100644 --- a/MMTextStorage.h +++ b/MMTextStorage.h @@ -20,6 +20,7 @@ NSAttributedString *emptyRowString; NSFont *font; NSColor *defaultBackgroundColor; + NSColor *defaultForegroundColor; NSSize cellSize; } @@ -51,6 +52,7 @@ - (void)setFont:(NSFont *)newFont; - (NSFont *)font; - (NSColor *)defaultBackgroundColor; +- (NSColor *)defaultForegroundColor; - (NSSize)size; - (NSSize)cellSize; - (NSRect)rectForRowsInRange:(NSRange)range; diff --git a/MMTextStorage.m b/MMTextStorage.m index df11d6ecaf..8d28834286 100644 --- a/MMTextStorage.m +++ b/MMTextStorage.m @@ -55,6 +55,7 @@ [emptyRowString release]; [font release]; [defaultBackgroundColor release]; + [defaultForegroundColor release]; [attribString release]; [super dealloc]; } @@ -374,9 +375,18 @@ - (void)setDefaultColorsBackground:(NSColor *)bgColor foreground:(NSColor *)fgColor { - // NOTE: Foreground color is ignored. - [defaultBackgroundColor release]; - defaultBackgroundColor = bgColor ? [bgColor retain] : nil; + if (defaultBackgroundColor != bgColor) { + [defaultBackgroundColor release]; + defaultBackgroundColor = bgColor ? [bgColor retain] : nil; + } + + // NOTE: The default foreground color isn't actually used for anything, but + // other class instances might want to be able to access it so it is stored + // here. + if (defaultForegroundColor != fgColor) { + [defaultForegroundColor release]; + defaultForegroundColor = fgColor ? [fgColor retain] : nil; + } } - (void)setFont:(NSFont*)newFont @@ -422,6 +432,11 @@ return defaultBackgroundColor; } +- (NSColor *)defaultForegroundColor +{ + return defaultForegroundColor; +} + - (NSSize)size { return NSMakeSize(maxColumns*cellSize.width, maxRows*cellSize.height);