ftp.nice.ch/pub/next/tools/workspace/NewFile.2.0.s.tar.gz#/NewFile2-src/Help.m

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

/* Generated by Interface Builder */

#import "Help.h"
#import "Main.h"
#import "Server.h"
#import <appkit/NXBrowser.h>
#import <appkit/NXBrowserCell.h>
#import <appkit/ScrollView.h>
#import <appkit/Text.h>
#import <appkit/Panel.h>
#import <appkit/Matrix.h>
#import <appkit/Application.h>
#import <sys/file.h>
#import <sys/param.h>
#import <libc.h>

@implementation Help

// Is interface loaded?
// If more than one help instance, make this an instance var.
int loaded=0;

/* Bring up the interface.*/
- show:sender
{
	if (loaded==0)
	{
		[NXApp loadNibSection:"Help.nib" owner:self];
	}
	[panel makeKeyAndOrderFront:self];
	[browser displayColumn:0];
	return self;
}


/* Display the content of a file in the scrolling view.*/
- loadFile:(char *)name
{
	int	fd;
	NXStream *st;
	
	fd = open(name, O_RDONLY, 0);
	if (fd >= 0)
	{
		if ((st = NXOpenFile(fd, NX_READONLY)) != 0)
		{
			[text readRichText:st];
			[text sizeToFit];
			// Set the `cursor' to the start of the text.
			[text setSel:0:0];
			// Adjust the scroll position so that start of text is visible.
			[text scrollSelToVisible];
			NXClose(st);
		}
		close(fd);
	}
	return self;
}

/*
This message is called by the entries in the `sections' section to display the appropriate help file.
*/
- helpme:sender
{
	char title[100], name[MAXPATHLEN];
	// The name of the help file is the same as the title of the section.
	[sender getPath:title toColumn:1];
	sprintf(name, "%s/Help%s", [appDelegate appdir], title);
	[self loadFile:name];
	return self;
}

// Respond to the browser's query about whether the data has been loaded. 
- (BOOL)browser:sender columnIsValid:(int)column
{
	return loaded!=0;
}

// Add a help section to the list. 
- addTopic:(char *)title at:(int)pos in:matrix for:browser
{
	id cell;
	[matrix insertRowAt:pos];
	cell = [matrix cellAt:pos:0];
	[cell setStringValue:title];
	[cell setLoaded:YES];
	[cell setLeaf:YES];
	return self;
}

// Fill the list of help sections.
- (int)browser:sender fillMatrix:matrix inColumn:(int)column
{
	[self addTopic:"What is NewFile" at:0 in:matrix for:sender];
	[self addTopic:"General use" at:1 in:matrix for:sender];
	[self addTopic:"Current directory" at:2 in:matrix for:sender];
	[self addTopic:"Defining file types" at:3 in:matrix for:sender];
	[self addTopic:"Updating Services" at:4 in:matrix for:sender];
	[self addTopic:"Command keys" at:5 in:matrix for:sender];
	[self addTopic:"Things to do" at:6 in:matrix for:sender];
	[self addTopic:"Info" at:7 in:matrix for:sender];
	loaded++;
	// Return the number of sections.
	return 8;
}

// Intercept the scrolling view's initialization to get its doc view.
- setScrollingview:anObject
{
	scrollingview = anObject;
	text = [scrollingview docView];
	return self;
}

@end

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