Displaying top
Displaying top
- Subject: Displaying top
- From: Tim Anderson <email@hidden>
- Date: Tue, 14 May 2002 00:02:52 -0500
Hi, I've followed Apple's Moriarty example to get a GUI wrapped around a
unix tool. While experimenting, I could get just about everything working,
such as wget, ls, vm_stat, etc. The one I'm having trouble with is top.
At this point, I'm trying to build a small app that will display the running
processes in an NSTextView and be able to kill processes by inputting a
process ID and clicking a button. Since I can only have one NSTask running,
I'll let top run until the button is clicked, stop the top NSTask, create
the new NSTask for kill, and then start top again.
The problem is that I can't get top to display. I've stripped out everything
except the top-relevant code and it doesn't work. When I run the following
code, all I get to display in textview is the string "can't get terminal
attributes."
- (void)applicationDidFinishLaunching:(NSNotification*)notification {
top=[[TaskWrapper alloc] initWithController:self arguments:[NSArray
arrayWithObjects:@"/usr/bin/top",nil]];
[top startProcess];
}
- (void)appendOutput:(NSString *)output
{
[[textview textStorage] appendAttributedString: [[[NSAttributedString
alloc] initWithString: output] autorelease]];
[self performSelector:@selector(scrollToVisible:) withObject:nil
afterDelay:0.0];
}
- (void)scrollToVisible:(id)ignore {
[textview scrollRangeToVisible:NSMakeRange([[textview string] length],
0)];
}
I'd appreciate any help on why this doesn't work, and what I can do to
correct it. Thanks!
Tim
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.