Skip to content

Commit

Permalink
• type casted [self delegate]s to minimize compiler warnings
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R-packages/trunk/Mac-GUI@6248 694ef91d-65df-0310-b7bb-92e67a308ead
  • Loading branch information
Hans-Jörg Bibiko committed Aug 28, 2012
1 parent 6a7085b commit 988e78c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
2 changes: 2 additions & 0 deletions RScriptEditorTextStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
NSInteger foldedRanges[R_MAX_FOLDED_ITEMS][3];
NSInteger foldedCounter;
NSInteger currentMaxFoldedIndex;

id selfDelegate;

IMP _getImp;
IMP _setImp;
Expand Down
16 changes: 9 additions & 7 deletions RScriptEditorTextStorage.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ - (id)init
_editImp = [self methodForSelector:_editSel];
_getlImp = [_attributedString methodForSelector:_getlSel];

selfDelegate = (RScriptEditorTextView*)[self delegate];

foldedCounter = 0;
currentMaxFoldedIndex = -1;

Expand Down Expand Up @@ -161,7 +163,7 @@ - (NSInteger)registerFoldedRange:(NSRange)range
{


[[[self delegate] undoManager] disableUndoRegistration];
[[selfDelegate undoManager] disableUndoRegistration];

NSInteger index = -1;
for(NSInteger i = 0; i < R_MAX_FOLDED_ITEMS; i++) {
Expand All @@ -177,7 +179,7 @@ - (NSInteger)registerFoldedRange:(NSRange)range
}
}

[[[self delegate] undoManager] enableUndoRegistration];
[[selfDelegate undoManager] enableUndoRegistration];

return(index);

Expand All @@ -204,7 +206,7 @@ - (BOOL)removeFoldedRangeWithIndex:(NSInteger)index
return NO;
}

[[[self delegate] undoManager] disableUndoRegistration];
[[selfDelegate undoManager] disableUndoRegistration];

range = NSIntersectionRange(NSMakeRange(0, [[_attributedString string] length]), range);
if(range.length) {
Expand All @@ -228,11 +230,11 @@ - (BOOL)removeFoldedRangeWithIndex:(NSInteger)index
foldedRanges[j][0] = -1;
foldedRanges[j][1] = 0;
foldedRanges[j][2] = 0;
[[self delegate] refoldLinesInRange:r];
[selfDelegate refoldLinesInRange:r];
}
}

[[[self delegate] undoManager] enableUndoRegistration];
[[selfDelegate undoManager] enableUndoRegistration];

// update currentMaxFoldedIndex
NSInteger maxCount = -1;
Expand All @@ -250,7 +252,7 @@ - (BOOL)removeFoldedRangeWithIndex:(NSInteger)index
- (void)removeAllFoldedRanges
{

[[[self delegate] undoManager] disableUndoRegistration];
[[selfDelegate undoManager] disableUndoRegistration];

for(NSInteger i = 0; i < R_MAX_FOLDED_ITEMS; i++) {
foldedRanges[i][0] = -1;
Expand All @@ -264,7 +266,7 @@ - (void)removeAllFoldedRanges
foldedCounter = 0;
currentMaxFoldedIndex = -1;

[[[self delegate] undoManager] enableUndoRegistration];
[[selfDelegate undoManager] enableUndoRegistration];

}

Expand Down
4 changes: 4 additions & 0 deletions RScriptEditorTextView.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#import "REditorToolbar.h"
#import "RdEditorToolbar.h"
#import "RScriptEditorTextStorage.h"
#import "RDocumentWinCtrl.h"


#define R_TEXT_SIZE_TRIGGER_FOR_PARSING_PARTLY 10000
Expand Down Expand Up @@ -70,6 +71,8 @@
NSColor *shColorBackground;
NSColor *shColorCurrentLine;

RDocumentWinCtrl *selfDelegate;

id editorToolbar;

BOOL lineNumberingEnabled;
Expand All @@ -87,6 +90,7 @@
RScriptEditorTextStorage *theTextStorage;

NSDictionary *highlightColorAttr;


IMP _foldedImp;

Expand Down
16 changes: 9 additions & 7 deletions RScriptEditorTextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ - (void)awakeFromNib

SLog(@"RScriptEditorTextView: awakeFromNib <%@>", self);

selfDelegate = (RDocumentWinCtrl*)[self delegate];

breakSyntaxHighlighting = 0;
_foldedSel = @selector(foldedAtIndex:);

Expand Down Expand Up @@ -179,10 +181,10 @@ - (void)awakeFromNib
// For now replaced selectedTextBackgroundColor by redColor
highlightColorAttr = [[NSDictionary alloc] initWithObjectsAndKeys:[NSColor redColor], NSBackgroundColorAttributeName, nil];

if([[self delegate] isRdDocument])
editorToolbar = [[RdEditorToolbar alloc] initWithEditor:[self delegate]];
if([selfDelegate isRdDocument])
editorToolbar = [[RdEditorToolbar alloc] initWithEditor:selfDelegate];
else
editorToolbar = [[REditorToolbar alloc] initWithEditor:[self delegate]];
editorToolbar = [[REditorToolbar alloc] initWithEditor:selfDelegate];

[self setAllowsDocumentBackgroundColorChange:YES];
[self setContinuousSpellCheckingEnabled:NO];
Expand Down Expand Up @@ -485,7 +487,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
} else if ([keyPath isEqualToString:prefShowArgsHints]) {
argsHints = [[change objectForKey:NSKeyValueChangeNewKey] boolValue];
if(!argsHints) {
[[self delegate] setStatusLineText:@""];
[selfDelegate setStatusLineText:@""];
} else {
[self currentFunctionHint];
}
Expand Down Expand Up @@ -721,7 +723,7 @@ - (void)doSyntaxHighlighting
if(!syntaxHighlightingEnabled)
breakSyntaxHighlighting = 0;

if (!syntaxHighlightingEnabled || [[self delegate] plain]) return;
if (!syntaxHighlightingEnabled || [selfDelegate plain]) return;

isSyntaxHighlighting = YES;

Expand Down Expand Up @@ -794,7 +796,7 @@ - (void)doSyntaxHighlighting

BOOL hasFoldedItems = [theTextStorage hasFoldedItems];

if([[self delegate] isRdDocument]) {
if([selfDelegate isRdDocument]) {

rd_switch_to_buffer(rd_scan_string(NSStringUTF8String([selfstr substringWithRange:textRange])));

Expand Down Expand Up @@ -1424,7 +1426,7 @@ - (NSInteger)foldStatusAtIndex:(NSInteger)index
NSString *selfStr = [self string];
unichar c;

BOOL isRd = [[self delegate] isRdDocument];
BOOL isRd = [selfDelegate isRdDocument];

unichar commentSign = (isRd) ? '%' : '#';

Expand Down

0 comments on commit 988e78c

Please sign in to comment.