Major improvements to the launch/debugger part

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@8602 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Robert Slover 2001-01-14 16:57:06 +00:00
parent f88603af5d
commit bfe24865bd
3 changed files with 81 additions and 51 deletions

View file

@ -403,7 +403,6 @@
RELEASE(readHandle); RELEASE(readHandle);
RELEASE(errorReadHandle); RELEASE(errorReadHandle);
AUTORELEASE(makeTask); AUTORELEASE(makeTask);
} }

View file

@ -32,14 +32,17 @@
{ {
NSBox *componentView; NSBox *componentView;
PCProject *currentProject; NSButton *runButton;
NSDictionary *currentOptions;
PCProject *currentProject; // Not retained!
NSDictionary *currentOptions; // Not retained!
NSTextView *stdOut; NSTextView *stdOut;
NSTextView *stdError; NSTextView *stdError;
NSFileHandle *readHandle; NSFileHandle *readHandle;
NSFileHandle *errorReadHandle; NSFileHandle *errorReadHandle;
NSTask *task;
} }
- (id)initWithProject:(PCProject *)aProject; - (id)initWithProject:(PCProject *)aProject;
@ -47,8 +50,11 @@
- (NSView *)componentView; - (NSView *)componentView;
- (void)debug:(id)sender;
- (void)run:(id)sender; - (void)run:(id)sender;
- (void)buildDidTerminate:(NSNotification *)aNotif;
- (void)logStdOut:(NSNotification *)aNotif; - (void)logStdOut:(NSNotification *)aNotif;
- (void)logErrOut:(NSNotification *)aNotif; - (void)logErrOut:(NSNotification *)aNotif;

View file

@ -98,7 +98,7 @@
[scrollView2 setBorderType: NSBezelBorder]; [scrollView2 setBorderType: NSBezelBorder];
[scrollView2 setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; [scrollView2 setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
stdError = [[NSTextView alloc] initWithFrame:[[scrollView2 contentView] frame]]; stdError=[[NSTextView alloc] initWithFrame:[[scrollView2 contentView]frame]];
[stdError setRichText:NO]; [stdError setRichText:NO];
[stdError setEditable:NO]; [stdError setEditable:NO];
@ -134,24 +134,26 @@
[matrix setSelectionByRect:YES]; [matrix setSelectionByRect:YES];
[matrix setAutoresizingMask: (NSViewMaxXMargin | NSViewMinYMargin)]; [matrix setAutoresizingMask: (NSViewMaxXMargin | NSViewMinYMargin)];
[matrix setTarget:self]; [matrix setTarget:self];
[matrix setAction:@selector(run:)];
[componentView addSubview:matrix]; [componentView addSubview:matrix];
RELEASE(matrix); RELEASE(matrix);
button = [matrix cellAtRow:0 column:0]; runButton = [matrix cellAtRow:0 column:0];
[button setTag:0]; [runButton setTag:0];
[button setImagePosition:NSImageOnly]; [runButton setImagePosition:NSImageOnly];
[button setImage:IMAGE(@"ProjectCenter_run")]; [runButton setImage:IMAGE(@"ProjectCenter_run")];
[button setButtonType:NSMomentaryPushButton]; [runButton setAlternateImage:IMAGE(@"ProjectCenter_run")];
[button setTitle:@"Run"]; [runButton setButtonType:NSOnOffButton];
[runButton setTitle:@"Run"];
[runButton setAction:@selector(run:)];
button = [matrix cellAtRow:0 column:1]; button = [matrix cellAtRow:0 column:1];
[button setTag:1]; [button setTag:1];
[button setImagePosition:NSImageOnly]; [button setImagePosition:NSImageOnly];
//[button setImage:IMAGE(@"ProjectCenter_clean")]; [button setImage:IMAGE(@"ProjectCenter_debug")];
[button setButtonType:NSMomentaryPushButton]; [button setButtonType:NSMomentaryPushButton];
[button setTitle:@"Clean"]; [button setTitle:@"Clean"];
[button setAction:@selector(debug:)];
} }
@end @end
@ -170,11 +172,14 @@
- (void)dealloc - (void)dealloc
{ {
[componentView release]; RELEASE(componentView);
RELEASE(stdOut); RELEASE(stdOut);
RELEASE(stdError); RELEASE(stdError);
if (readHandle) RELEASE(readHandle);
if (errorReadHandle) RELEASE(errorReadHandle);
[super dealloc]; [super dealloc];
} }
@ -187,22 +192,30 @@
return componentView; return componentView;
} }
- (void)debug:(id)sender
{
NSRunAlertPanel(@"Attention!",@"Integrated debugging is not yet available...",@"OK",nil,nil);
}
- (void)run:(id)sender - (void)run:(id)sender
{ {
NSTask *makeTask;
NSMutableArray *args; NSMutableArray *args;
NSPipe *logPipe; NSPipe *logPipe;
NSPipe *errorPipe; NSPipe *errorPipe;
NSString *openPath; NSString *openPath;
logPipe = [NSPipe pipe]; logPipe = [NSPipe pipe];
RELEASE(readHandle);
readHandle = [[logPipe fileHandleForReading] retain]; readHandle = [[logPipe fileHandleForReading] retain];
errorPipe = [NSPipe pipe]; errorPipe = [NSPipe pipe];
RELEASE(errorReadHandle);
errorReadHandle = [[errorPipe fileHandleForReading] retain]; errorReadHandle = [[errorPipe fileHandleForReading] retain];
makeTask = [[NSTask alloc] init]; RELEASE(task);
args = [NSMutableArray array]; task = [[NSTask alloc] init];
args = [[NSMutableArray alloc] init];
/* /*
* Ugly hack! We should ask the porject itself about the req. information! * Ugly hack! We should ask the porject itself about the req. information!
@ -225,15 +238,6 @@
return; return;
} }
/*
* Debugging, running, ...
*/
switch ([[sender selectedCell] tag]) {
case 0:
break;
}
/* /*
* Setting everything up * Setting everything up
*/ */
@ -247,13 +251,20 @@
selector:@selector(logErrOut:) selector:@selector(logErrOut:)
name:NSFileHandleDataAvailableNotification name:NSFileHandleDataAvailableNotification
object:errorReadHandle]; object:errorReadHandle];
[NOTIFICATION_CENTER addObserver:self
selector: @selector(buildDidTerminate:)
name: NSTaskDidTerminateNotification
object:task];
[makeTask setArguments:args]; [task setArguments:args];
[makeTask setCurrentDirectoryPath:[currentProject projectPath]]; RELEASE(args);
[makeTask setLaunchPath:openPath];
[task setCurrentDirectoryPath:[currentProject projectPath]];
[task setLaunchPath:openPath];
[makeTask setStandardOutput:logPipe]; [task setStandardOutput:logPipe];
[makeTask setStandardError:errorPipe]; [task setStandardError:errorPipe];
[stdOut setString:@""]; [stdOut setString:@""];
[readHandle waitForDataInBackgroundAndNotify]; [readHandle waitForDataInBackgroundAndNotify];
@ -265,26 +276,37 @@
* Go! Later on this will be handled much more optimised! * Go! Later on this will be handled much more optimised!
* *
*/ */
[makeTask launch];
[makeTask waitUntilExit];
/* [task launch];
* Clean up... }
*
*/
[NOTIFICATION_CENTER removeObserver:self - (void)buildDidTerminate:(NSNotification *)aNotif
name:NSFileHandleDataAvailableNotification {
object:readHandle]; if ([aNotif object] == task) {
[NOTIFICATION_CENTER removeObserver:self /*
name:NSFileHandleDataAvailableNotification * Clean up...
object:errorReadHandle]; *
*/
RELEASE(readHandle);
RELEASE(errorReadHandle); [NOTIFICATION_CENTER removeObserver:self
RELEASE(makeTask); name:NSFileHandleDataAvailableNotification
object:readHandle];
[NOTIFICATION_CENTER removeObserver:self
name:NSFileHandleDataAvailableNotification
object:errorReadHandle];
[NOTIFICATION_CENTER removeObserver:self
name:NSTaskDidTerminateNotification
object:task];
RELEASE(task);
task = nil;
[runButton setNextState];
[componentView display];
}
} }
- (void)logStdOut:(NSNotification *)aNotif - (void)logStdOut:(NSNotification *)aNotif
@ -322,13 +344,16 @@
{ {
NSTextView *out = (yn)?stdError:stdOut; NSTextView *out = (yn)?stdError:stdOut;
[out replaceCharactersInRange:NSMakeRange([[out string] length],0) withString:str]; [out replaceCharactersInRange:NSMakeRange([[out string] length],0)
withString:str];
if (newLine) { if (newLine) {
[out replaceCharactersInRange:NSMakeRange([[out string] length], 0) withString:@"\n"]; [out replaceCharactersInRange:NSMakeRange([[out string] length], 0)
withString:@"\n"];
} }
else { else {
[out replaceCharactersInRange:NSMakeRange([[out string] length], 0) withString:@" "]; [out replaceCharactersInRange:NSMakeRange([[out string] length], 0)
withString:@" "];
} }
[out scrollRangeToVisible:NSMakeRange([[out string] length], 0)]; [out scrollRangeToVisible:NSMakeRange([[out string] length], 0)];