Annotation of Examples/UNIX/Subprocess/Coordinator.m, revision 1.1.1.1

1.1       root        1: /*
                      2:        Coordinator.m
                      3:        by Joe Freeman, David LaVallee
                      4:        Subprocess Example, Release 2.0
                      5:        NeXT Computer, Inc.
                      6: 
                      7:        You may freely copy, distribute and reuse the code in this example.
                      8:        NeXT disclaims any warranty of any kind, expressed or implied, as to
                      9:        its fitness for any particular use.
                     10: */
                     11: 
                     12: #import "Coordinator.h"
                     13: #import "CommandScroll.h"
                     14: #import "Subprocess.h"
                     15: #import <appkit/nextstd.h>
                     16: #import <appkit/Application.h>
                     17: #import <appkit/Panel.h>
                     18: #import <objc/NXStringTable.h>
                     19: 
                     20: @implementation Coordinator
                     21: 
                     22: - showInfo:sender
                     23: {
                     24:     if (!infoPanel)
                     25:     {
                     26:        infoPanel =
                     27:            [NXApp loadNibSection:"InfoPanel.nib" owner:NXApp withNames:NO];
                     28:     }
                     29:     [infoPanel orderFront:self];
                     30:     return self;
                     31: }
                     32: 
                     33: /*==========================================================
                     34:  *
                     35:  * Subprocess Delegation
                     36:  *
                     37:  *==========================================================*/
                     38:  
                     39: - subprocessOutput:(char *)buffer
                     40: {
                     41:     [commandView appendString:buffer];
                     42:     return self;
                     43: }
                     44: 
                     45: - subprocessDone
                     46: {
                     47:     [NXApp terminate:self];
                     48:     return self;
                     49: }
                     50: 
                     51: - subprocessError:(const char *)errorString
                     52:     // uses stringTable to localize error messages as appropriate,
                     53:     // and then displays the message in an alert panel
                     54: {
                     55:     const char *returnedString;
                     56:     
                     57:     if ((returnedString = [stringTable valueForStringKey:errorString]))
                     58:     {
                     59:        NXRunAlertPanel(0, returnedString, 0, 0, 0);
                     60:     }
                     61:     else
                     62:     {
                     63:        NXRunAlertPanel(0, errorString, 0, 0, 0);
                     64:     }
                     65:     return self;
                     66: }
                     67: 
                     68: /*==========================================================
                     69:  *
                     70:  * CommandScroll Delegation
                     71:  *
                     72:  *==========================================================*/
                     73:  
                     74: - userEntered:(char *)buffer
                     75: {
                     76:     [theSubprocess send:buffer withNewline:NO];
                     77:     return self;
                     78: }
                     79: 
                     80: /*==========================================================
                     81:  *
                     82:  * Application Object Delegation
                     83:  *
                     84:  *==========================================================*/
                     85: 
                     86: - appDidInit:sender
                     87: {
                     88:     theSubprocess =
                     89:        [[Subprocess alloc]
                     90:            init:"/bin/sh" withDelegate:self andPtySupport:YES andStdErr:YES];
                     91:     return self;
                     92: }
                     93: 
                     94: - appWillTerminate:sender
                     95: {
                     96:     [theSubprocess terminate:sender];
                     97:     return self;
                     98: }
                     99: 
                    100: @end

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.