ftp.nice.ch/pub/next/connectivity/protocol/GateKeeper.2.2.s.tar.gz#/GateKeeper.2.2.s/CommandScroll.m

This is CommandScroll.m in view mode; [Download] [Up]

//************************************************************************
//
//	Most of this code is from the CommandScroll object.  
//	Numerous additions, deletions, changes and any bugs courtesy of:
//
//		Felipe A. Rodriguez		
//
//	Portions of this file were derived from:
//	
//			CommandScroll.m
//			by Joe Freeman
//			Subprocess Example, Release 2.0
//			NeXT Computer, Inc.
//
//	This code is supplied "as is" the author makes no warranty as to its 
//	suitability for any purpose.  This code is free and may be distributed 
//	in accordance with the terms of the:
//		
//			GNU GENERAL PUBLIC LICENSE
//			Version 2, June 1991
//			copyright (C) 1989, 1991 Free Software Foundation, Inc.
// 			675 Mass Ave, Cambridge, MA 02139, USA
//
//************************************************************************

#import "CommandScroll.h"
#import <appkit/Application.h>
#import <appkit/nextstd.h>
#import <defaults/defaults.h>
#import <appkit/appkit.h>
#import <appkit/Font.h>
#import <appkit/Text.h>

@implementation CommandScroll

- initFrame:(const NXRect *)frameRect
{	
    [super initFrame:frameRect];
    [self setVertScrollerRequired: YES];
    [self setBackgroundGray: NX_WHITE];
    [self awake];

    return self;
}

- awake
    // these initializations implemented here so that this object can be
    // made an IB palatte more easily 
{    
NXRect textRect;
id theText;
    
    textRect.origin.x = textRect.origin.y = 0.0;
    [self getContentSize: &(textRect.size)];
    theText = [[Text alloc]							// create TEXT object 
		 			initFrame:&textRect text:NULL alignment: NX_LEFTALIGNED];
    [theText notifyAncestorWhenFrameChanged:YES];
    [theText setHorizResizable:NO];
    [theText setVertResizable:YES];
    [theText setEditable:NO];
   
    textRect.size.width = 0.0;
    [theText setMinSize:&(textRect.size)];
    [self getContentSize: &(textRect.size)];
    textRect.size.height = 1000000;
    [theText setMaxSize:&(textRect.size)];
    
    [[theText superview] setAutoresizeSubviews:YES];
    [[theText superview] setAutosizing: NX_HEIGHTSIZABLE | NX_WIDTHSIZABLE];
    
    [theText setCharFilter: NXFieldFilter];
    [theText setMonoFont:FALSE];
    [self setDocView: theText];
    machineFont = [Font newFont:"Ohlfs" size:10];
    helvFont = [Font newFont:"Helvetica" size:12];

    return self;
}

- setDocView:anObject
{
    [super setDocView:anObject];		//set anObject as the doc view of our 
    docView = anObject;					//scrollview. 
    [docView setDelegate:self];		
	
    return self;
}

//*****************************************************************************
//
// 		append the buffer to the end of the text object
//
//*****************************************************************************
 
- appendString:(const char *)buffer
{
	if([docView textLength] > 500000)				//if the textobject exceeds
		{											//500000 chars, then delete
		[docView setSel:0 :[docView textLength]];	//all chars
		[docView delete:self];
		}
	[docView setSel:[docView textLength] :0];		// set selection at end of 
													// text 
	[docView setSelFont:helvFont];					// set font of sel'td text
	[docView replaceSel:buffer];					// add buffer at selection
	[docView scrollSelToVisible];					// point and scroll to vis
	lastTextCount = [docView textLength];
	
	return self;
}
//*****************************************************************************
//
// 		append the buffer to the end of the text object, use a fixed font
//			-- used by pppstats for proper formatting
//
//*****************************************************************************

- appendStringUseFixedFont:(const char *)buffer
{
	if([docView textLength] > 500000)				//if the textobject exceeds
		{											//500000 chars, then delete
		[docView setSel:0 :[docView textLength]];	//all chars
		[docView delete:self];
		}
	[docView setSel:[docView textLength] :0];	//set selection at end of 
												//text 
	[docView setSelFont:machineFont];			// set font of sel'td text
	[docView replaceSel:buffer];				//add buffer at selection
	[docView scrollSelToVisible];				//point and scroll to vis
	lastTextCount = [docView textLength];
	
	return self;
}

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.