• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythonwindowsphpgamebathyscapheguic翻訳omegattwitterframeworkbtronvb.net計画中(planning stage)testdomarduinodirectxpreviewerゲームエンジン

TextMate is a graphical text editor for OS X 10.7+


Commit MetaInfo

Revisionb8b25a46c862c8ae67b4ce4ad751ccaf61144103 (tree)
Time2012-08-23 21:42:11
AuthorDavid Howden <dhowden@gmai...>
CommiterAllan Odgaard

Log Message

Extend gutter theming to selection foreground

New theme setting: gutterSelectionForeground

Change Summary

Incremental Difference

--- a/Frameworks/OakTextView/src/GutterView.h
+++ b/Frameworks/OakTextView/src/GutterView.h
@@ -35,12 +35,14 @@ struct GVLineRecord
3535 NSFont* lineNumberFont;
3636 NSColor* foregroundColor;
3737 NSColor* backgroundColor;
38- NSColor* selectionColor;
38+ NSColor* selectionForegroundColor;
39+ NSColor* selectionBackgroundColor;
3940 id <GutterViewDelegate> delegate;
4041 std::vector<struct data_source_t> columnDataSources;
4142 NSMutableSet* hiddenColumns;
4243 std::string highlightedRange;
4344 std::vector<CGRect> backgroundRects, borderRects;
45+ std::set<size_t> selectedLines;
4446
4547 NSPoint mouseDownAtPoint;
4648 NSPoint mouseHoveringAtPoint;
@@ -50,7 +52,8 @@ struct GVLineRecord
5052 @property (nonatomic, assign) id <GutterViewDelegate> delegate;
5153 @property (nonatomic, retain) NSColor* foregroundColor;
5254 @property (nonatomic, retain) NSColor* backgroundColor;
53-@property (nonatomic, retain) NSColor* selectionColor;
55+@property (nonatomic, retain) NSColor* selectionForegroundColor;
56+@property (nonatomic, retain) NSColor* selectionBackgroundColor;
5457 - (void)setHighlightedRange:(std::string const&)str;
5558 - (void)reloadData:(id)sender;
5659 - (void)insertColumnWithIdentifier:(NSString*)columnIdentifier atPosition:(NSUInteger)index dataSource:(id <GutterViewColumnDataSource>)columnDataSource delegate:(id <GutterViewColumnDelegate>)columnDelegate;
--- a/Frameworks/OakTextView/src/GutterView.mm
+++ b/Frameworks/OakTextView/src/GutterView.mm
@@ -41,7 +41,7 @@ struct data_source_t
4141
4242 @implementation GutterView
4343 @synthesize partnerView, lineNumberFont, delegate;
44-@synthesize foregroundColor, backgroundColor, selectionColor;
44+@synthesize foregroundColor, backgroundColor, selectionForegroundColor, selectionBackgroundColor;
4545
4646 // ==================
4747 // = Setup/Teardown =
@@ -100,7 +100,8 @@ struct data_source_t
100100 self.lineNumberFont = nil;
101101 self.foregroundColor = nil;
102102 self.backgroundColor = nil;
103- self.selectionColor = nil;
103+ self.selectionForegroundColor = nil;
104+ self.selectionBackgroundColor = nil;
104105 iterate(it, columnDataSources)
105106 {
106107 if(it->datasource)
@@ -115,6 +116,7 @@ struct data_source_t
115116 {
116117 backgroundRects.clear();
117118 borderRects.clear();
119+ selectedLines.clear();
118120
119121 citerate(range, text::selection_t(highlightedRange))
120122 {
@@ -123,6 +125,12 @@ struct data_source_t
123125 auto fragment = [delegate lineFragmentForLine:to.line column:to.column];
124126 CGFloat lastY = to.column == 0 && from.line != to.line ? fragment.firstY : fragment.lastY;
125127
128+ for(size_t i = from.line; i < to.line; ++i)
129+ selectedLines.insert(i);
130+
131+ if(!(to.column == 0 && from.line != to.line))
132+ selectedLines.insert(to.line);
133+
126134 backgroundRects.push_back(CGRectMake(0, firstY+1, self.frame.size.width, lastY - firstY - 2));
127135 borderRects.push_back(CGRectMake(0, firstY, self.frame.size.width, 1));
128136 borderRects.push_back(CGRectMake(0, lastY-1, self.frame.size.width, 1));
@@ -340,7 +348,7 @@ static void DrawText (std::string const& text, CGRect const& rect, CGFloat basel
340348
341349 [self setupSelectionRects];
342350
343- [self.selectionColor set];
351+ [self.selectionBackgroundColor set];
344352 iterate(rect, backgroundRects)
345353 NSRectFillUsingOperation(NSIntersectionRect(*rect, NSIntersectionRect(aRect, self.frame)), NSCompositeSourceOver);
346354
@@ -356,12 +364,17 @@ static void DrawText (std::string const& text, CGRect const& rect, CGFloat basel
356364 break;
357365 prevLine = std::make_pair(record.lineNumber, record.softlineOffset);
358366
367+ NSColor* textColor;
368+ if(selectedLines.find(record.lineNumber) != selectedLines.end())
369+ textColor = self.selectionForegroundColor;
370+ else textColor = self.foregroundColor;
371+
359372 citerate(dataSource, [self visibleColumnDataSources])
360373 {
361374 NSRect columnRect = NSMakeRect(dataSource->x0, record.firstY, dataSource->width, record.lastY - record.firstY);
362375 if(dataSource->identifier == GVLineNumbersColumnIdentifier.UTF8String)
363376 {
364- DrawText(record.softlineOffset == 0 ? text::format("%ld", record.lineNumber + 1) : "·", columnRect, NSMinY(columnRect) + record.baseline, self.lineNumberFont, self.foregroundColor);
377+ DrawText(record.softlineOffset == 0 ? text::format("%ld", record.lineNumber + 1) : "·", columnRect, NSMinY(columnRect) + record.baseline, self.lineNumberFont, textColor);
365378 }
366379 else if(record.softlineOffset == 0)
367380 {
--- a/Frameworks/OakTextView/src/OakDocumentView.mm
+++ b/Frameworks/OakTextView/src/OakDocumentView.mm
@@ -268,7 +268,8 @@ private:
268268 gutterView.foregroundColor = [NSColor colorWithCGColor:styles.gutterForeground()];
269269 gutterView.backgroundColor = [NSColor colorWithCGColor:styles.gutterBackground()];
270270 gutterScrollView.backgroundColor = gutterView.backgroundColor;
271- gutterView.selectionColor = [NSColor colorWithCGColor:styles.gutterSelectionBackground()];
271+ gutterView.selectionForegroundColor = [NSColor colorWithCGColor:styles.gutterSelectionForeground()];
272+ gutterView.selectionBackgroundColor = [NSColor colorWithCGColor:styles.gutterSelectionBackground()];
272273
273274 [self setNeedsDisplay:YES];
274275 [textView setNeedsDisplay:YES];
--- a/Frameworks/theme/src/theme.cc
+++ b/Frameworks/theme/src/theme.cc
@@ -34,6 +34,7 @@ theme_t::decomposed_style_t theme_t::parse_styles (plist::dictionary_t const& pl
3434 get_key_path(plist, "settings.gutterForeground", res.gutterForeground);
3535 get_key_path(plist, "settings.gutterBackground", res.gutterBackground);
3636 get_key_path(plist, "settings.gutterDivider", res.gutterDivider);
37+ get_key_path(plist, "settings.gutterSelectionForeground", res.gutterSelectionForeground);
3738 get_key_path(plist, "settings.gutterSelectionBackground", res.gutterSelectionBackground);
3839 get_key_path(plist, "settings.caret", res.caret);
3940 get_key_path(plist, "settings.selection", res.selection);
@@ -212,11 +213,12 @@ styles_t const& theme_t::styles_for_scope (scope::context_t const& scope, std::s
212213 cf::color_t gutterForeground = base.gutterForeground.is_blank() ? soften(foreground, 0.5 ) : base.gutterForeground;
213214 cf::color_t gutterBackground = base.gutterBackground.is_blank() ? soften(background, 0.87) : base.gutterBackground;
214215 cf::color_t gutterDivider = base.gutterDivider.is_blank() ? soften(foreground, 0.4 ) : base.gutterDivider;
216+ cf::color_t gutterSelectionForeground = base.gutterSelectionForeground.is_blank() ? soften(foreground, 0.95) : base.gutterSelectionForeground;
215217 cf::color_t gutterSelectionBackground = base.gutterSelectionBackground.is_blank() ? soften(background, 0.95) : base.gutterSelectionBackground;
216218 cf::color_t selection = base.selection.is_blank() ? cf::color_t("#4D97FF54") : base.selection;
217219 cf::color_t caret = base.caret.is_blank() ? cf::color_t("#000000" ) : base.caret;
218220
219- styles_t res(foreground, background, gutterForeground, gutterBackground, gutterDivider, gutterSelectionBackground, selection, caret, font, base.underlined == bool_true, base.misspelled == bool_true);
221+ styles_t res(foreground, background, gutterForeground, gutterBackground, gutterDivider, gutterSelectionForeground, gutterSelectionBackground, selection, caret, font, base.underlined == bool_true, base.misspelled == bool_true);
220222 styles = _cache.insert(std::make_pair(key_t(scope, fontName, fontSize), res)).first;
221223 }
222224 return styles->second;
@@ -326,6 +328,7 @@ theme_t::decomposed_style_t& theme_t::decomposed_style_t::operator+= (theme_t::d
326328 alpha_blend(gutterForeground, rhs.gutterForeground);
327329 alpha_blend(gutterBackground, rhs.gutterBackground);
328330 alpha_blend(gutterDivider, rhs.gutterDivider);
331+ alpha_blend(gutterSelectionForeground, rhs.gutterSelectionForeground);
329332 alpha_blend(gutterSelectionBackground, rhs.gutterSelectionBackground);
330333 alpha_blend(caret, rhs.caret);
331334 alpha_blend(selection, rhs.selection);
--- a/Frameworks/theme/src/theme.h
+++ b/Frameworks/theme/src/theme.h
@@ -9,13 +9,14 @@ typedef std::tr1::shared_ptr<struct __CTFont const> CTFontPtr;
99
1010 struct PUBLIC styles_t
1111 {
12- styles_t (cf::color_t const& foreground, cf::color_t const& background, cf::color_t const& gutterForeground, cf::color_t const& gutterBackground, cf::color_t const& gutterDivider, cf::color_t const& gutterSelectionBackground, cf::color_t const& selection, cf::color_t const& caret, CTFontPtr font, bool underlined, bool misspelled) : _foreground(foreground), _background(background), _gutterForeground(gutterForeground), _gutterBackground(gutterBackground), _gutterDivider(gutterDivider), _gutterSelectionBackground(gutterSelectionBackground), _selection(selection), _caret(caret), _font(font), _underlined(underlined), _misspelled(misspelled) { }
12+ styles_t (cf::color_t const& foreground, cf::color_t const& background, cf::color_t const& gutterForeground, cf::color_t const& gutterBackground, cf::color_t const& gutterDivider, cf::color_t const& gutterSelectionForeground, cf::color_t const& gutterSelectionBackground, cf::color_t const& selection, cf::color_t const& caret, CTFontPtr font, bool underlined, bool misspelled) : _foreground(foreground), _background(background), _gutterForeground(gutterForeground), _gutterBackground(gutterBackground), _gutterDivider(gutterDivider), _gutterSelectionForeground(gutterSelectionForeground), _gutterSelectionBackground(gutterSelectionBackground), _selection(selection), _caret(caret), _font(font), _underlined(underlined), _misspelled(misspelled) { }
1313
1414 CGColorRef foreground () const { return _foreground; }
1515 CGColorRef background () const { return _background; }
1616 CGColorRef gutterForeground () const { return _gutterForeground; }
1717 CGColorRef gutterBackground () const { return _gutterBackground; }
1818 CGColorRef gutterDivider () const { return _gutterDivider; }
19+ CGColorRef gutterSelectionForeground() const { return _gutterSelectionForeground; }
1920 CGColorRef gutterSelectionBackground() const { return _gutterSelectionBackground; }
2021 CGColorRef caret () const { return _caret; }
2122 CGColorRef selection () const { return _selection; }
@@ -29,6 +30,7 @@ private:
2930 cf::color_t _gutterForeground;
3031 cf::color_t _gutterBackground;
3132 cf::color_t _gutterDivider;
33+ cf::color_t _gutterSelectionForeground;
3234 cf::color_t _gutterSelectionBackground;
3335 cf::color_t _selection;
3436 cf::color_t _caret;
@@ -75,6 +77,7 @@ private:
7577 color_info_t gutterForeground;
7678 color_info_t gutterBackground;
7779 color_info_t gutterDivider;
80+ color_info_t gutterSelectionForeground;
7881 color_info_t gutterSelectionBackground;
7982 color_info_t caret;
8083 color_info_t selection;