home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / Connectivity / GateKeeper-2.1 / CommandScroll.m < prev    next >
Encoding:
Text File  |  1997-05-06  |  4.1 KB  |  136 lines

  1. //************************************************************************
  2. //
  3. //    Most of this code is from the CommandScroll object.  
  4. //    Numerous additions, deletions, changes and any bugs courtesy of:
  5. //
  6. //        Felipe A. Rodriguez        
  7. //
  8. //    Portions of this file were derived from:
  9. //    
  10. //            CommandScroll.m
  11. //            by Joe Freeman
  12. //            Subprocess Example, Release 2.0
  13. //            NeXT Computer, Inc.
  14. //
  15. //    This code is supplied "as is" the author makes no warranty as to its 
  16. //    suitability for any purpose.  This code is free and may be distributed 
  17. //    in accordance with the terms of the:
  18. //        
  19. //            GNU GENERAL PUBLIC LICENSE
  20. //            Version 2, June 1991
  21. //            copyright (C) 1989, 1991 Free Software Foundation, Inc.
  22. //             675 Mass Ave, Cambridge, MA 02139, USA
  23. //
  24. //************************************************************************
  25.  
  26. #import "CommandScroll.h"
  27. #import <appkit/Application.h>
  28. #import <appkit/nextstd.h>
  29. #import <defaults/defaults.h>
  30. #import <appkit/appkit.h>
  31. #import <appkit/Font.h>
  32. #import <appkit/Text.h>
  33.  
  34. @implementation CommandScroll
  35.  
  36. - initFrame:(const NXRect *)frameRect
  37. {    
  38.     [super initFrame:frameRect];
  39.     [self setVertScrollerRequired: YES];
  40.     [self setBackgroundGray: NX_WHITE];
  41.     [self awake];
  42.  
  43.     return self;
  44. }
  45.  
  46. - awake
  47.     // these initializations implemented here so that this object can be
  48.     // made an IB palatte more easily 
  49. {    
  50. NXRect textRect;
  51. id theText;
  52.     
  53.     textRect.origin.x = textRect.origin.y = 0.0;
  54.     [self getContentSize: &(textRect.size)];
  55.     theText = [[Text alloc]                            // create TEXT object 
  56.                      initFrame:&textRect text:NULL alignment: NX_LEFTALIGNED];
  57.     [theText notifyAncestorWhenFrameChanged:YES];
  58.     [theText setHorizResizable:NO];
  59.     [theText setVertResizable:YES];
  60.     [theText setEditable:NO];
  61.    
  62.     textRect.size.width = 0.0;
  63.     [theText setMinSize:&(textRect.size)];
  64.     [self getContentSize: &(textRect.size)];
  65.     textRect.size.height = 1000000;
  66.     [theText setMaxSize:&(textRect.size)];
  67.     
  68.     [[theText superview] setAutoresizeSubviews:YES];
  69.     [[theText superview] setAutosizing: NX_HEIGHTSIZABLE | NX_WIDTHSIZABLE];
  70.     
  71.     [theText setCharFilter: NXFieldFilter];
  72.     [theText setMonoFont:FALSE];
  73.     [self setDocView: theText];
  74.     machineFont = [Font newFont:"Ohlfs" size:10];
  75.     helvFont = [Font newFont:"Helvetica" size:12];
  76.  
  77.     return self;
  78. }
  79.  
  80. - setDocView:anObject
  81. {
  82.     [super setDocView:anObject];        //set anObject as the doc view of our 
  83.     docView = anObject;                    //scrollview. 
  84.     [docView setDelegate:self];        
  85.     
  86.     return self;
  87. }
  88.  
  89. //*****************************************************************************
  90. //
  91. //         append the buffer to the end of the text object
  92. //
  93. //*****************************************************************************
  94.  
  95. - appendString:(const char *)buffer
  96. {
  97.     if([docView textLength] > 500000)                //if the textobject exceeds
  98.         {                                            //500000 chars, then delete
  99.         [docView setSel:0 :[docView textLength]];    //all chars
  100.         [docView delete:self];
  101.         }
  102.     [docView setSel:[docView textLength] :0];        // set selection at end of 
  103.                                                     // text 
  104.     [docView setSelFont:helvFont];                    // set font of sel'td text
  105.     [docView replaceSel:buffer];                    // add buffer at selection
  106.     [docView scrollSelToVisible];                    // point and scroll to vis
  107.     lastTextCount = [docView textLength];
  108.     
  109.     return self;
  110. }
  111. //*****************************************************************************
  112. //
  113. //         append the buffer to the end of the text object, use a fixed font
  114. //            -- used by pppstats for proper formatting
  115. //
  116. //*****************************************************************************
  117.  
  118. - appendStringUseFixedFont:(const char *)buffer
  119. {
  120.     if([docView textLength] > 500000)                //if the textobject exceeds
  121.         {                                            //500000 chars, then delete
  122.         [docView setSel:0 :[docView textLength]];    //all chars
  123.         [docView delete:self];
  124.         }
  125.     [docView setSel:[docView textLength] :0];    //set selection at end of 
  126.                                                 //text 
  127.     [docView setSelFont:machineFont];            // set font of sel'td text
  128.     [docView replaceSel:buffer];                //add buffer at selection
  129.     [docView scrollSelToVisible];                //point and scroll to vis
  130.     lastTextCount = [docView textLength];
  131.     
  132.     return self;
  133. }
  134.  
  135. @end
  136.