Skip to content

Commit

Permalink
merge r84 (fixes)
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R-packages/trunk/Mac-GUI@5713 694ef91d-65df-0310-b7bb-92e67a308ead
  • Loading branch information
s-u committed Mar 15, 2011
1 parent 860d0c3 commit aad2210
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 27 deletions.
6 changes: 3 additions & 3 deletions PackageManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ - (void)dealloc {
#pragma mark TableView delegates

/* These two routines are needed to update the History TableView */
- (int)numberOfRowsInTableView: (NSTableView *)tableView
- (NSInteger)numberOfRowsInTableView: (NSTableView *)tableView
{
return packages;
}

- (id)tableView: (NSTableView *)tableView objectValueForTableColumn: (NSTableColumn *)tableColumn row: (int)row
- (id)tableView: (NSTableView *)tableView objectValueForTableColumn: (NSTableColumn *)tableColumn row: (NSInteger)row
{
if (row<packages) {
if([[tableColumn identifier] isEqualToString:@"status"])
Expand All @@ -85,7 +85,7 @@ - (id)tableView: (NSTableView *)tableView objectValueForTableColumn: (NSTableCol
- (void)tableView:(NSTableView *)tableView
setObjectValue:(id)object
forTableColumn:(NSTableColumn *)tableColumn
row:(int)row
row:(NSInteger)row
{
if (row>=packages) return;
if([[tableColumn identifier] isEqualToString:@"status"]){
Expand Down
26 changes: 22 additions & 4 deletions RController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1491,7 +1491,11 @@ - (void)sheetDidEnd:(id)sheet returnCode:(int)returnCode contextInfo:(NSString*)

if([contextInfo isEqualToString:@"saveAsRConsole"]) {
if(returnCode == NSOKButton) {
[[consoleTextView string] writeToFile:[sheet filename] atomically:YES];
NSError *writeError = nil;
[[consoleTextView string] writeToFile:[sheet filename] atomically:YES encoding:NSUTF8StringEncoding error:&writeError];
if(writeError != nil) {
NSBeginCriticalAlertSheet(NLS(@"Error"), NLS(@"OK"), nil, nil, RConsoleWindow, self, nil, nil, nil, [writeError localizedDescription]);
}
}
}

Expand Down Expand Up @@ -1571,28 +1575,42 @@ - (void) shouldCloseDidEnd:(NSWindow *)sheet returnCode:(int)returnCode
- (void)windowWillCloseNotifications:(NSNotification*) aNotification
{

// NSLog(@"%@:%@", [aNotification object], [[aNotification object] title]);
NSWindow *w = [aNotification object];

SLog(@"RController%@.windowWillCloseNotifications:%@", self, w);

if (w && (
[[(NSObject*)[w delegate] className] isEqualToString:@"RDocumentWinCtrl"]
|| [[(NSObject*)[w delegate] className] isEqualToString:@"QuartzCocoaView"])
)
{
SLog(@" - R source or Quartz windows will be handled by RDocumentController.windowWillCloseNotifications");
return;
}


// Get all windows
NSArray *appWindows = [NSApp orderedWindows];
int i;

// for NSPanels set focus to the first window; otherwise the first window is the to be
// closed window thus set focus to the next window
BOOL closingWindowFound = ([[aNotification object] isKindOfClass:[NSPanel class]]);
BOOL closingWindowFound = ([w isKindOfClass:[NSPanel class]]);

// loop through windows to find next window
// and make it the key window
for(i=0; i<[appWindows count]; i++) {
id win = [appWindows objectAtIndex:i];
if([win isVisible]) {
if(closingWindowFound) {
SLog(@" - next key window title: %@", [win title]);
[win makeKeyAndOrderFront:nil];
return;
}
closingWindowFound = YES;
}
}
SLog(@" - no window found; make RConsole key window");
[RConsoleWindow makeKeyAndOrderFront:nil];
}

Expand Down Expand Up @@ -1962,7 +1980,7 @@ - (BOOL)textView:(NSTextView *)textView shouldChangeTextInRange:(NSRange)affecte
return YES;
}

- (NSArray *)textView:(NSTextView *)textView completions:(NSArray *)words forPartialWordRange:(NSRange)charRange indexOfSelectedItem:(int *)index
- (NSArray *)textView:(NSTextView *)textView completions:(NSArray *)words forPartialWordRange:(NSRange)charRange indexOfSelectedItem:(NSInteger *)index
{

NSRange sr = [textView selectedRange];
Expand Down
5 changes: 3 additions & 2 deletions RDocumentController.m
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,17 @@ - (void)windowWillCloseNotifications:(NSNotification*) aNotification

// if document hasREditFlag set focus back to RConsole AND if sanety check fails
BOOL reditcheck = ([[self currentDocument] respondsToSelector:@selector(hasREditFlag)]);

if((!reditcheck || (reditcheck && ![[self currentDocument] hasREditFlag]))
&& nextWindow && nextWindow != w) {
SLog(@" - makeKeyWindow with title %@ and type %@", [nextWindow title], [d fileType]);
[nextWindow makeKeyAndOrderFront:nil];
} else {
SLog(@" - makeKeyWindow RConsole");
[[[RController sharedController] window] makeKeyAndOrderFront:nil];
nextWindow = [[RController sharedController] window];
}

[NSApp removeWindowsItem: w];
[nextWindow makeKeyAndOrderFront:nil];

}
}
Expand Down
25 changes: 18 additions & 7 deletions RDocumentWinCtrl.m
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,20 @@ - (void) replaceContentsWithRtf: (NSData*) rtfContents
[textView setSelectedRange:NSMakeRange(0,0)];
}

- (void)layoutTextView
{
[[textView layoutManager] ensureLayoutForCharacterRange:NSMakeRange(0, [[textView string] length])];
}

- (void) replaceContentsWithString: (NSString*) strContents
{
[[textView layoutManager] setAllowsNonContiguousLayout:YES];
[textView setString:strContents];

#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
[textView setSelectedRange:NSMakeRange(0,0)];
[textView performSelector:@selector(doSyntaxHighlighting) withObject:nil afterDelay:0.0];
[[textView layoutManager] setAllowsNonContiguousLayout:NO];
[self performSelector:@selector(layoutTextView) withObject:nil afterDelay:0.3];
#endif

}

- (NSData*) contentsAsRtf
Expand Down Expand Up @@ -670,7 +677,7 @@ - (BOOL)textView:(NSTextView *)textViewSrc doCommandBySelector:(SEL)commandSelec
return retval;
}

- (NSArray *)textView:(NSTextView *)aTextView completions:(NSArray *)words forPartialWordRange:(NSRange)charRange indexOfSelectedItem:(int *)index
- (NSArray *)textView:(NSTextView *)aTextView completions:(NSArray *)words forPartialWordRange:(NSRange)charRange indexOfSelectedItem:(NSInteger *)index
{

NSRange sr = [aTextView selectedRange];
Expand All @@ -693,13 +700,17 @@ - (NSArray *)textView:(NSTextView *)aTextView completions:(NSArray *)words forPa
- (void)textViewDidChangeSelection:(NSNotification *)aNotification
{

RTextView *tv = [aNotification object];

#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
[[tv layoutManager] setAllowsNonContiguousLayout:NO];
#endif

if(argsHints && ![[self document] hasREditFlag] && ![self plain]) {

// show functions hints due to current caret position or selection
SLog(@"RDocumentWinCtrl: textViewDidChangeSelection and calls currentFunctionHint");

RTextView *tv = [aNotification object];

// Cancel pending currentFunctionHint calls
[NSObject cancelPreviousPerformRequestsWithTarget:tv
selector:@selector(currentFunctionHint)
Expand Down Expand Up @@ -746,7 +757,7 @@ - (void)sheetDidEnd:(id)sheet returnCode:(int)returnCode contextInfo:(NSString *
}

// Make window at which the sheet was attached key window
[[self window] makeKeyWindow];
[[self window] makeKeyAndOrderFront:nil];

}

Expand Down
6 changes: 3 additions & 3 deletions REditor.m
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,14 @@ - (void)dealloc {
}

/* These two routines are needed to update the TableView */
- (int)numberOfRowsInTableView: (NSTableView *)tableView
- (NSInteger)numberOfRowsInTableView: (NSTableView *)tableView
{
return ymaxused;
}

- (id)tableView: (NSTableView *)tableView
objectValueForTableColumn: (NSTableColumn *)tableColumn
row: (int)row
row: (NSInteger)row
{
int i = [[tableColumn identifier] intValue];
if(i > xmaxused)
Expand All @@ -183,7 +183,7 @@ - (id)tableView: (NSTableView *)tableView
- (void)tableView:(NSTableView *)aTableView
setObjectValue:anObject
forTableColumn:(NSTableColumn *)tableColumn
row:(int)row
row:(NSInteger)row
{
int col;
if(row<0) return;
Expand Down
8 changes: 8 additions & 0 deletions RScriptEditorTextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ - (void)awakeFromNib

// Set self as delegate for the textView's textStorage to enable syntax highlighting,
[[self textStorage] setDelegate:self];
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
[[self layoutManager] setAllowsNonContiguousLayout:YES];
#endif


// Set defaults for general usage
braceHighlightInterval = [[Preferences stringForKey:highlightIntervalKey withDefault: @"0.2"] doubleValue];
Expand Down Expand Up @@ -492,6 +496,10 @@ - (void)doSyntaxHighlighting

NSRange textRange = NSMakeRange(start, end-start);

#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
[[self layoutManager] ensureLayoutForCharacterRange:textRange];
#endif

// only to be sure that nothing went wrongly
textRange = NSIntersectionRange(textRange, NSMakeRange(0, [theTextStorage length]));

Expand Down
2 changes: 2 additions & 0 deletions RScriptEditorTokens.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@
#define RPT_VARIABLE 8
#define RPT_WORD 9
#define RPT_OTHER 10
#define RPT_OPERATOR 11
#define RPT_DECLARATION 12
2 changes: 2 additions & 0 deletions RScriptEditorTokens.l
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ functions (if|f(or|unction)|while)
<equation>{ops} { BEGIN(INITIAL); return RPT_OTHER; } /* set operator after a numeric */
{numeric}/{alpha} { return RPT_WORD; } /* catch numeric followed by char */

{ops} { return RPT_OPERATOR; } /* all operators */
{decl} { return RPT_DECLARATION; } /* all declarations */
{s}+ { return RPT_WHITESPACE; } /* ignore spaces */

{numeric} { return RPT_NUMERIC; } /* single numeric value */
Expand Down
2 changes: 1 addition & 1 deletion RTextView.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extern BOOL RTextView_autoCloseBrackets;
@private
BOOL console;
NSCharacterSet *separatingTokensSet;
NSCharacterSet *commentTokensSet;
// NSCharacterSet *commentTokensSet;
}

- (void)setConsoleMode:(BOOL)isConsole;
Expand Down
12 changes: 9 additions & 3 deletions RTextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#import "HelpManager.h"
#import "RGUI.h"
#import "RegexKitLite.h"
#import "RController.h"

// linked character attributes
#define kTALinked @"RTVLinkedChar"
Expand Down Expand Up @@ -80,16 +81,18 @@ - (void)awakeFromNib
{
SLog(@"RTextView: awakeFromNib %@", self);
separatingTokensSet = [[NSCharacterSet characterSetWithCharactersInString: @"()'\"+-=/* ,\t[]{}^|&!:;<>?`\n"] retain];
commentTokensSet = [[NSCharacterSet characterSetWithCharactersInString: @"#"] retain];
// commentTokensSet = [[NSCharacterSet characterSetWithCharactersInString: @"#"] retain];
console = NO;
RTextView_autoCloseBrackets = YES;
SLog(@" - delegate: %@", [self delegate]);
// FIXME: this is a really ugly hack ... behavior should not depend on class names ...
isRConsole = [[(NSObject*)[self delegate] className] isEqualToString:@"RController"] ? YES : NO;
isRConsole = ([(NSObject*)[self delegate] isKindOfClass:[RController class]]) ? YES : NO;
}

- (void)dealloc
{
if(separatingTokensSet) [separatingTokensSet release];
// if(commentTokensSet) [commentTokensSet release];
[super dealloc];
}

Expand Down Expand Up @@ -351,6 +354,9 @@ - (NSRange)rangeForUserCompletion

if (context == pcComment) return NSMakeRange(NSNotFound,0); // no completion in comments

if(!separatingTokensSet)
separatingTokensSet = [[NSCharacterSet characterSetWithCharactersInString: @"()'\"+-=/* ,\t[]{}^|&!:;<>?`\n"] retain];

if (context == pcStringDQ || context == pcStringSQ) // we're in a string, hence file completion
// the beginning of the range doesn't matter, because we're guaranteed to find a string separator on the same line
userRange = [string rangeOfCharacterFromSet:[NSCharacterSet characterSetWithCharactersInString:(context == pcStringDQ) ? @"\" /" : @"' /"]
Expand Down Expand Up @@ -479,7 +485,7 @@ - (void)currentFunctionHint

if(helpString && ![helpString isMatchedByRegex:@"(?s)[^\\w\\d_\\.]"] && [[self delegate] respondsToSelector:@selector(hintForFunction:)]) {
SLog(@"RTextView: currentFunctionHint for '%@'", helpString);
[[self delegate] hintForFunction:helpString];
[(RController*)[self delegate] hintForFunction:helpString];
}

}
Expand Down
4 changes: 2 additions & 2 deletions SelectList.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ - (void)dealloc {
}

/* These two routines are needed to update the SelectList TableView */
- (int)numberOfRowsInTableView: (NSTableView *)tableView
- (NSInteger)numberOfRowsInTableView: (NSTableView *)tableView
{
return totalItems;
}

- (id)tableView: (NSTableView *)tableView objectValueForTableColumn: (NSTableColumn *)tableColumn row: (int)row
- (id)tableView: (NSTableView *)tableView objectValueForTableColumn: (NSTableColumn *)tableColumn row: (NSInteger)row
{
if (row<totalItems) {
if([[tableColumn identifier] isEqualToString:@"item"])
Expand Down
4 changes: 2 additions & 2 deletions WSBrowser.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ - (void)dealloc {
}

// required
- (id)outlineView:(NSOutlineView *)ov child:(int)index ofItem:(id)item
- (id)outlineView:(NSOutlineView *)ov child:(NSInteger)index ofItem:(id)item
{
// item is an NSDictionary...
GET_CHILDREN;
Expand All @@ -101,7 +101,7 @@ - (BOOL)outlineView:(NSOutlineView *)ov isItemExpandable:(id)item
return YES;
}

- (int)outlineView:(NSOutlineView *)ov numberOfChildrenOfItem:(id)item
- (NSInteger)outlineView:(NSOutlineView *)ov numberOfChildrenOfItem:(id)item
{
GET_CHILDREN;
return [children count];
Expand Down

0 comments on commit aad2210

Please sign in to comment.