Skip to content

Commit

Permalink
Fix ViTextStorage references.
Browse files Browse the repository at this point in the history
Because NSTextView’s textStorage is now a property, we
can’t override the accessor with one of return type
ViTextStorage * without triggering a compiler warning.
Instead, we provide viTextStorage, which provides access to
the appropriate type, and call that when we need a true
ViTextStorage instance.
  • Loading branch information
Shadowfiend committed Oct 30, 2014
1 parent 22cbec0 commit b4a1c74
Show file tree
Hide file tree
Showing 12 changed files with 177 additions and 177 deletions.
2 changes: 1 addition & 1 deletion app/ViBundle.m
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ + (void)setupEnvironment:(NSMutableDictionary *)env
/* Text-view related variables.
*/
if (textView) {
ViTextStorage *ts = [textView textStorage];
ViTextStorage *ts = [textView viTextStorage];

NSString *line = [ts lineAtLocation:[textView caret]];
if (line)
Expand Down
2 changes: 1 addition & 1 deletion app/ViFoldMarginView.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ - (void)drawFoldsInRect:(NSRect)aRect visibleRect:(NSRect)visibleRect

layoutManager = _textView.layoutManager;
container = _textView.textContainer;
textStorage = _textView.textStorage;
textStorage = _textView.viTextStorage;
document = _textView.document;
yinset = _textView.textContainerInset.height;

Expand Down
6 changes: 3 additions & 3 deletions app/ViLineNumberView.m
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ - (CGFloat)requiredThickness
{
NSUInteger lineCount, digits;

lineCount = _textView.textStorage.lineCount;
lineCount = _textView.viTextStorage.lineCount;
digits = (unsigned)log10(lineCount) + 1;
return ceilf(MAX(DEFAULT_THICKNESS, _digitSize.width * digits + LINE_NUMBER_MARGIN * 2));
}
Expand Down Expand Up @@ -217,7 +217,7 @@ - (NSInteger)logicalLineForLine:(NSUInteger)line location:(NSUInteger)location
__block NSInteger logicalLine = line;

if (location > 0) {
ViTextStorage *textStorage = _textView.textStorage;
ViTextStorage *textStorage = _textView.viTextStorage;
[textStorage enumerateAttribute:ViFoldedAttributeName
inRange:NSMakeRange(0u, location)
options:NULL
Expand Down Expand Up @@ -256,7 +256,7 @@ - (void)drawLineNumbersInRect:(NSRect)aRect visibleRect:(NSRect)visibleRect

layoutManager = _textView.layoutManager;
container = _textView.textContainer;
textStorage = _textView.textStorage;
textStorage = _textView.viTextStorage;
yinset = _textView.textContainerInset.height;

if (layoutManager == nil)
Expand Down
2 changes: 1 addition & 1 deletion app/ViProject.m
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ - (NSDictionary *)structureOfSplit:(NSSplitView *)split viewControllers:(NSArray
dimensionValue = [NSNumber numberWithFloat:[view bounds].size.height];
}

ViTextStorage *storage = [textView textStorage];
ViTextStorage *storage = [textView viTextStorage];
NSUInteger caret = [textView caret];
NSDictionary *viewProperties =
@{
Expand Down
2 changes: 1 addition & 1 deletion app/ViTextView-bundle_commands.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ - (NSString *)inputOfType:(NSString *)type
*envRangePtr = *rangePtr;
inputText = [[[self textStorage] string] substringWithRange:*rangePtr];
} else if ([type isEqualToString:@"word"]) {
inputText = [[self textStorage] wordAtLocation:[self caret] range:rangePtr acceptAfter:YES];
inputText = [[self viTextStorage] wordAtLocation:[self caret] range:rangePtr acceptAfter:YES];
*envRangePtr = *rangePtr;
} else if ([type isEqualToString:@"line"]) {
NSUInteger bol, eol;
Expand Down
2 changes: 1 addition & 1 deletion app/ViTextView-cursor.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ - (void)updateFont
- (void)invalidateCaretRect
{
NSLayoutManager *lm = [self layoutManager];
ViTextStorage *ts = [self textStorage];
ViTextStorage *ts = [self viTextStorage];
NSUInteger length = [ts length];
int len = 1;

Expand Down
30 changes: 15 additions & 15 deletions app/ViTextView-ex_commands.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ - (NSInteger)resolveExAddress:(ExAddress *)addr
error:(NSError **)outError
{
ViMark *m = nil;
ViTextStorage *storage = [self textStorage];
ViTextStorage *storage = [self viTextStorage];
NSInteger line = -1;

switch (addr.type) {
Expand Down Expand Up @@ -167,7 +167,7 @@ - (NSRange)characterRangeForLineRange:(NSRange)lineRange
if (lineRange.location == NSNotFound)
return lineRange;

ViTextStorage *storage = [self textStorage];
ViTextStorage *storage = [self viTextStorage];
NSUInteger beg = [storage locationForStartOfLine:lineRange.location];
NSUInteger end = [storage locationForStartOfLine:NSMaxRange(lineRange)];

Expand Down Expand Up @@ -206,7 +206,7 @@ - (id)ex_bang:(ExCommand *)command

- (id)ex_eval:(ExCommand *)command
{
NSString *script = [[[self textStorage] string] substringWithRange:command.range];
NSString *script = [[[self viTextStorage] string] substringWithRange:command.range];
NSError *error = nil;
[(ViAppController *)[NSApp delegate] eval:script
withParser:nil
Expand Down Expand Up @@ -252,7 +252,7 @@ - (id)ex_substitute:(ExCommand *)command

[[ViRegisterManager sharedManager] setContent:pattern ofRegister:'/'];

ViTextStorage *storage = [self textStorage];
ViTextStorage *storage = [self viTextStorage];
ViTransformer *transform = [[ViTransformer alloc] init];

NSInteger startLocation = [storage locationForStartOfLine:exRange.location];
Expand Down Expand Up @@ -308,7 +308,7 @@ - (id)ex_goto:(ExCommand *)command
{
// XXX: What if two address given?
[self pushCurrentLocationOnJumpList];
command.caret = [[self textStorage] firstNonBlankForLineAtLocation:command.range.location];
command.caret = [[self viTextStorage] firstNonBlankForLineAtLocation:command.range.location];
return nil;
}

Expand All @@ -321,7 +321,7 @@ - (id)ex_yank:(ExCommand *)command
- (id)ex_delete:(ExCommand *)command
{
[self cutToRegister:command.reg range:command.range];
command.caret = [[self textStorage] firstNonBlankForLineAtLocation:command.range.location];
command.caret = [[self viTextStorage] firstNonBlankForLineAtLocation:command.range.location];
return nil;
}

Expand All @@ -331,13 +331,13 @@ - (id)ex_copy:(ExCommand *)command
if (destline > 0)
++destline;

NSString *content = [[[self textStorage] string] substringWithRange:command.range];
NSInteger destloc = [[self textStorage] locationForStartOfLine:destline];
NSString *content = [[[self viTextStorage] string] substringWithRange:command.range];
NSInteger destloc = [[self viTextStorage] locationForStartOfLine:destline];
if (destloc == -1)
destloc = [[self textStorage] length];
destloc = [[self viTextStorage] length];
[self insertString:content atLocation:destloc];

command.caret = [[self textStorage] firstNonBlankForLineAtLocation:destloc + [content length]];
command.caret = [[self viTextStorage] firstNonBlankForLineAtLocation:destloc + [content length]];
return nil;
}

Expand All @@ -351,19 +351,19 @@ - (id)ex_move:(ExCommand *)command
if (destline > 0)
++destline;

NSString *content = [[[self textStorage] string] substringWithRange:command.range];
NSInteger destloc = [[self textStorage] locationForStartOfLine:destline];
NSString *content = [[[self viTextStorage] string] substringWithRange:command.range];
NSInteger destloc = [[self viTextStorage] locationForStartOfLine:destline];
if (destloc == -1)
destloc = [[self textStorage] length];
destloc = [[self viTextStorage] length];

if (destloc > command.range.location) {
[self insertString:content atLocation:destloc];
[self deleteRange:command.range];
command.caret = [[self textStorage] firstNonBlankForLineAtLocation:destloc - 1];
command.caret = [[self viTextStorage] firstNonBlankForLineAtLocation:destloc - 1];
} else {
[self deleteRange:command.range];
[self insertString:content atLocation:destloc];
command.caret = [[self textStorage] firstNonBlankForLineAtLocation:destloc + command.range.length - 1];
command.caret = [[self viTextStorage] firstNonBlankForLineAtLocation:destloc + command.range.length - 1];
}

return nil;
Expand Down
2 changes: 1 addition & 1 deletion app/ViTextView-snippets.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ - (ViSnippet *)insertSnippet:(NSString *)snippetString
NSString *expandedSnippetString = snippetString;
if (indent) {
// prepend leading whitespace to all newlines in the snippet string
NSString *leadingWhiteSpace = [[self textStorage] leadingWhitespaceForLineAtLocation:aRange.location];
NSString *leadingWhiteSpace = [[self viTextStorage] leadingWhitespaceForLineAtLocation:aRange.location];
NSString *indentedNewline = [@"\n" stringByAppendingString:leadingWhiteSpace];
NSString *indentedSnippetString = [snippetString stringByReplacingOccurrencesOfString:@"\n"
withString:indentedNewline
Expand Down
Loading

0 comments on commit b4a1c74

Please sign in to comment.