mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
Let CreateAttributedStringWithMarkedUpRanges take NSLineBreakMode
Remove the offset argument (as nothing relies on this anymore).
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include <oak/misc.h>
|
||||
|
||||
PUBLIC NSMutableAttributedString* CreateAttributedStringWithMarkedUpRanges (std::string const& in, std::vector< std::pair<size_t, size_t> > const& ranges, size_t offset = 0);
|
||||
PUBLIC NSMutableAttributedString* CreateAttributedStringWithMarkedUpRanges (std::string const& in, std::vector< std::pair<size_t, size_t> > const& ranges, NSLineBreakMode lineBreakMode = NSLineBreakByTruncatingMiddle);
|
||||
|
||||
PUBLIC @interface OakFileTableCellView : NSTableCellView
|
||||
- (instancetype)initWithCloseButton:(NSButton*)closeButton;
|
||||
|
||||
@@ -76,10 +76,10 @@
|
||||
}
|
||||
@end
|
||||
|
||||
NSMutableAttributedString* CreateAttributedStringWithMarkedUpRanges (std::string const& in, std::vector< std::pair<size_t, size_t> > const& ranges, size_t offset)
|
||||
NSMutableAttributedString* CreateAttributedStringWithMarkedUpRanges (std::string const& in, std::vector< std::pair<size_t, size_t> > const& ranges, NSLineBreakMode lineBreakMode)
|
||||
{
|
||||
NSMutableParagraphStyle* paragraphStyle = [[NSMutableParagraphStyle alloc] init];
|
||||
[paragraphStyle setLineBreakMode:NSLineBreakByTruncatingMiddle];
|
||||
[paragraphStyle setLineBreakMode:lineBreakMode];
|
||||
|
||||
NSDictionary* baseAttributes = @{ NSParagraphStyleAttributeName : paragraphStyle };
|
||||
NSDictionary* highlightAttributes = @{ NSParagraphStyleAttributeName : paragraphStyle, NSUnderlineStyleAttributeName : @1 };
|
||||
@@ -89,9 +89,9 @@ NSMutableAttributedString* CreateAttributedStringWithMarkedUpRanges (std::string
|
||||
size_t from = 0;
|
||||
for(auto range : ranges)
|
||||
{
|
||||
[res appendAttributedString:[[NSAttributedString alloc] initWithString:[NSString stringWithCxxString:std::string(in.begin() + from, in.begin() + range.first + offset)] attributes:baseAttributes]];
|
||||
[res appendAttributedString:[[NSAttributedString alloc] initWithString:[NSString stringWithCxxString:std::string(in.begin() + range.first + offset, in.begin() + range.second + offset)] attributes:highlightAttributes]];
|
||||
from = range.second + offset;
|
||||
[res appendAttributedString:[[NSAttributedString alloc] initWithString:[NSString stringWithCxxString:std::string(in.begin() + from, in.begin() + range.first)] attributes:baseAttributes]];
|
||||
[res appendAttributedString:[[NSAttributedString alloc] initWithString:[NSString stringWithCxxString:std::string(in.begin() + range.first, in.begin() + range.second)] attributes:highlightAttributes]];
|
||||
from = range.second;
|
||||
}
|
||||
if(from < in.size())
|
||||
[res appendAttributedString:[[NSAttributedString alloc] initWithString:[NSString stringWithCxxString:in.substr(from)] attributes:baseAttributes]];
|
||||
|
||||
Reference in New Issue
Block a user