diff --git a/Frameworks/DocumentWindow/src/DocumentController.h b/Frameworks/DocumentWindow/src/DocumentController.h index 6e87e3b3..bbf14764 100644 --- a/Frameworks/DocumentWindow/src/DocumentController.h +++ b/Frameworks/DocumentWindow/src/DocumentController.h @@ -1,14 +1,13 @@ #import "DocumentOpenHelper.h" #import #import +#import #import #import #import #import @class ProjectLayoutView; -@class OakDocumentView; -@class OakTextView; @class OakFilterWindowController; @class OakHTMLOutputView; @@ -17,7 +16,7 @@ typedef std::shared_ptr document_tab_ptr; namespace bundles { struct item_t; typedef std::shared_ptr item_ptr; } -PUBLIC @interface DocumentController : NSWindowController +PUBLIC @interface DocumentController : NSWindowController { OBJC_WATCH_LEAKS(DocumentController); diff --git a/Frameworks/DocumentWindow/src/DocumentController.mm b/Frameworks/DocumentWindow/src/DocumentController.mm index 721e3779..79e55c28 100644 --- a/Frameworks/DocumentWindow/src/DocumentController.mm +++ b/Frameworks/DocumentWindow/src/DocumentController.mm @@ -20,7 +20,6 @@ namespace find_tags #import #import #import -#import #import #import #import @@ -487,6 +486,7 @@ OAK_DEBUG_VAR(DocumentController); layoutView.documentView = documentView; textView = documentView.textView; + textView.delegate = self; tabBarView.delegate = self; tabBarView.dataSource = self; @@ -614,6 +614,22 @@ OAK_DEBUG_VAR(DocumentController); [self goToFileCounterpart:self]; } +// ======================== +// = OakTextView Delegate = +// ======================== + +- (NSString*)scopeAttributes +{ + if(selectedTabIndex >= documentTabs.size()) + { + fprintf(stderr, "*** error: selected tab out of bounds: %zu >= %zu\n", selectedTabIndex, documentTabs.size()); + return nil; + } + + document::document_ptr doc = [self selectedDocument]; + return doc ? [NSString stringWithCxxString:doc->path_attributes()] : nil; +} + // ============================= // = OakTabBarView Data Source = // ============================= diff --git a/Frameworks/OakTextView/src/OakTextView.h b/Frameworks/OakTextView/src/OakTextView.h index face563a..89d928f4 100644 --- a/Frameworks/OakTextView/src/OakTextView.h +++ b/Frameworks/OakTextView/src/OakTextView.h @@ -20,6 +20,11 @@ struct buffer_refresh_callback_t; enum folding_state_t { kFoldingNone, kFoldingTop, kFoldingCollapsed, kFoldingBottom }; +@protocol OakTextViewDelegate +@optional +- (NSString*)scopeAttributes; +@end + PUBLIC @interface OakTextView : OakView { document::document_ptr document; @@ -91,6 +96,7 @@ PUBLIC @interface OakTextView : OakView } - (void)setDocument:(document::document_ptr const&)aDocument; +@property (nonatomic, assign) id delegate; @property (nonatomic, assign) theme_ptr const& theme; @property (nonatomic, retain) NSCursor* ibeamCursor; @property (nonatomic, retain) NSFont* font; diff --git a/Frameworks/OakTextView/src/OakTextView.mm b/Frameworks/OakTextView/src/OakTextView.mm index 94287745..b6021be3 100644 --- a/Frameworks/OakTextView/src/OakTextView.mm +++ b/Frameworks/OakTextView/src/OakTextView.mm @@ -299,6 +299,19 @@ static std::string shell_quote (std::vector paths) @synthesize refreshNestCount; @synthesize liveSearchViewController, liveSearchString, liveSearchRanges; +// ================================= +// = OakTextView Delegate Wrappers = +// ================================= + +- (NSString*)scopeAttributes +{ + if([self.delegate respondsToSelector:@selector(scopeAttributes)]) + return [self.delegate scopeAttributes]; + return nil; +} + +// ================================= + - (NSImage*)imageForRanges:(ng::ranges_t const&)ranges imageRect:(NSRect*)outRect { NSRect srcRect = NSZeroRect, visibleRect = [self visibleRect];