[alt.sources] simped

jak@sactoh0.UUCP (Jay A. Konigsberg) (07/07/90)

simped.shar.01 / part 01 of 02

This is simped (the simple editor) version 2. Most of the changes are
bug fixes, other code cleanup and documentation updates, however, there
are two major modifications to basic operation.

simped now accepts two command line options. 

   -a Causes simped to always come up in append mode.
   -p compatability for postnews (see simped.doc)

With just a little bit of luck, this will be the last release.

Jay
--------------------------------- cut here ---------------------------------
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#	Makefile
#	addlines.c
#	allocate.c
#	cleanup.c
#	commands.c
#	deleteline.c
#	editline.c
#	getline.c
#	getlinenum.c
#	help.c
# This archive created: Fri Jul  6 17:52:50 1990
export PATH; PATH=/bin:/usr/bin:$PATH
echo shar: "extracting 'Makefile'" '(2044 characters)'
if test -f 'Makefile'
then
	echo shar: "will not over-write existing file 'Makefile'"
else
sed 's/^	X//' << \SHAR_EOF > 'Makefile'
	X# simped - a simple, easy to use (line oriented) editor.
	X#
	X# Copyright (C) 1990 by Jay Konigsberg:  (uucp: jak@sactoh0)
	X#                                        (paper mail not available)
	X#
	X# Permission to use, copy, modify, and distribute this  software  and  its
	X# documentation is hereby  granted,  provided  that  the  above  copyright
	X# notice appear in all copies  and that  both  the  copyright  notice  and
	X# this permission notice appear in supporting documentation. This software
	X# is provided "as is" without express or implied  warranty.  However,  the
	X# author retains all Copyright priviliges and rights  to  renumeration  if
	X# this software is sold.
	X
	X#
	X# LINELEN - The length of a line across the screen. This value must be
	X#           at least 5 characters less than the screen width to allow
	X#           for the line number prompt at the left. 6 in better.
	XLINELEN=74
	X
	X#
	X# PAUSE   - This is the number of lines that will be listed upon
	X#           entering the editor with an existing file, or when
	X#           the L)ist command is used. The H)elp command suggests
	X#           it will be "about a half a screen".
	XPAUSE=15
	X
	X#
	X# BELL    - Choose the bell character for your system, ascii is default.
	X#
	XBELL=\007
	X
	X#
	X# Complier - choose your C complier. gcc -O -traditional is preferred
	X
	XCC=cc -O
	X#CC=gcc -O -traditional
	X#CC=gcc -O -Wall -Wshadow -Wpointer-arith
	X#CC=cc -g
	X
	XCFLAGS=-DLINELEN=$(LINELEN) -DPAUSE=$(PAUSE) -DBELL=$(BELL)
	X
	X#EXEC=a.out
	XEXEC=simped
	X
	XOBJS=main.o cleanup.o getline.o listtext.o allocate.o commands.o\
	Xaddlines.o deleteline.o getlinenum.o savefile.o editline.o position.o\
	Xmodify.o help.o options.o
	X
	XFILES=main.c cleanup.c getline.c listtext.c allocate.c commands.c\
	Xaddlines.c deleteline.c getlinenum.c savefile.c editline.c position.c\
	Xmodify.c help.c options.c
	X
	X$(EXEC): $(OBJS)
	X	$(CC) $(CFLAGS) $(OBJS) -o $(EXEC)
	X
	X$(OBJS):
	X
	Xclean:
	X	rm -f $(OBJS) core MANIFEST simped?.ar
	X
	Xship: tar
	X	compress simped.tar
	X	echo simped.tar.Z created
	X
	Xtar:
	X	tar cvf simped.tar $(FILES) Makefile simped.doc one mod simped.h
SHAR_EOF
if test 2044 -ne "`wc -c < 'Makefile'`"
then
	echo shar: "error transmitting 'Makefile'" '(should have been 2044 characters)'
fi
fi
echo shar: "extracting 'addlines.c'" '(2131 characters)'
if test -f 'addlines.c'
then
	echo shar: "will not over-write existing file 'addlines.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'addlines.c'
	X
	X/*
	X * Copyright (C) 1990 by Jay Konigsberg. uucp: jak@sactoh0
	X *
	X * Permission to use, copy, modify, and distribute this  software  and  its
	X * documentation is hereby  granted,  provided  that  the  above  copyright
	X * notice appear in all copies  and that  both  the  copyright  notice  and
	X * this permission notice appear in supporting documentation. This software
	X * is provided "as is" without express or implied  warranty.  However,  the
	X * author retains all Copyright priviliges and rights  to  renumeration  if
	X * this software is sold.
	X */
	X
	X/*
	X * addlines - add text to the text buffer. This routine
	X * does double service reading from stdin or a file.
	X * and handeles inserts and appends.
	X */
	X
	X#include "simped.h"
	X
	Xchar **addlines(text, overflow, count, location, fd, newfile, postnews)
	Xchar **text;
	Xchar *overflow;
	Xint  *count;
	Xint  location;		/* the line number after which the add occures */
	XFILE *fd;
	Xint  newfile;		/* newfile flag to statt in insert mode */
	Xint  postnews;
	X{
	Xint	printf();
	X
	Xextern	char	*getline(),
	X		**allocate();
	X
	Xchar	buffer[LINELEN+2];
	X
	Xint	char_read_in=0,		/* characters read in from fd */
	X	text_entered=TRUE;	/* boolean to determin when to allocate
	X				   space AND the flag for EOF */
	X
	Xif (*count >= 0)
	X    ++(*count);
	Xfor(;;)
	X    {
	X    if (fd == stdin || newfile)
	X	{
	X	printf("%3d> ",location);
	X	overflow = getline(buffer, &text_entered, stdin, '\0', FALSE);
	X	}
	X    else
	X	{
	X	overflow = getline(buffer, &text_entered, fd, '\0', FALSE);
	X
	X	/* see if a blank line is being read in. if so, add 1 sp */
	X	if (text_entered != EOF && buffer[0] == '\n')
	X	    {
	X	    buffer[0]=' ';
	X	    buffer[1]='\n';
	X	    buffer[2]='\0';
	X	    text_entered=TRUE;
	X	    }
	X	}
	X    if (text_entered && text_entered != EOF)
	X	{
	X	text = allocate(text, buffer, overflow, location, *count);
	X	char_read_in += (strlen(buffer));
	X	(*count)++;
	X	location++;
	X	}
	X    else
	X	break;
	X    }
	Xif (postnews)
	X    {
	X    text = allocate(text, "--\n\0", overflow, *count, *count);
	X    ++(*count);
	X    }
	X
	Xif(fd != stdin && ! newfile)
	X    {
	X    printf("%d characters read in\n", char_read_in);
	X    }
	Xif (*count >= 1)
	X    --(*count);
	Xreturn(text);
	X}
SHAR_EOF
if test 2131 -ne "`wc -c < 'addlines.c'`"
then
	echo shar: "error transmitting 'addlines.c'" '(should have been 2131 characters)'
fi
fi
echo shar: "extracting 'allocate.c'" '(1854 characters)'
if test -f 'allocate.c'
then
	echo shar: "will not over-write existing file 'allocate.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'allocate.c'
	X
	X/*
	X * Copyright (C) 1990 by Jay Konigsberg. mail: jak@sactoh0
	X *
	X * Permission to use, copy, modify, and distribute this  software  and  its
	X * documentation is hereby  granted,  provided  that  the  above  copyright
	X * notice appear in all copies  and that  both  the  copyright  notice  and
	X * this permission notice appear in supporting documentation. This software
	X * is provided "as is" without express or implied  warranty.  However,  the
	X * author retains all Copyright priviliges and rights  to  renumeration  if
	X * this software is sold.
	X */
	X
	X/*
	X * allocate - makes room in the text buffer for whatever was just entered.
	X */
	X#include "simped.h"
	X
	Xchar **allocate(text, buffer, overflow, location, count)
	Xchar	**text;
	Xchar	buffer[];
	Xchar	*overflow;
	Xint	location;	/* where to allocate space for the buffer */
	Xint	count;		/* number of lines in the text area */
	X{
	Xint	fprintf(),
	X	cleanup();
	X
	Xextern char *malloc(),
	X	    *realloc();
	X
	Xint	linelen,	/* length of the input buffer */
	X	textinx;	/* text index for insert adjustment */
	X
	Xif ( ! (count % PTR_CHUNK) )
	X    {
	X    if ( (text = (char **)realloc((char *)text, (unsigned)
	X	((count+PTR_CHUNK) * sizeof(char *)))) == (char **)0)
	X	{
	X	fprintf(stderr, "realloc: error=%d\n", errno);
	X	cleanup(2);
	X	}
	X    }
	Xif (location < count) /* insert vs. append */
	X    {
	X    for(textinx=count; textinx >= location; --textinx)
	X	text[textinx]=text[textinx-1];
	X    }
	Xif (overflow)
	X    {
	X    linelen=strlen(buffer);
	X    if((text[location-1]=malloc((unsigned)(linelen+FUDGE))) == NULL)
	X	{
	X	fprintf(stderr, "malloc: error=%d\n", errno);
	X	cleanup(2);
	X	}
	X    text[location-1] = strcpy(text[location-1], buffer);
	X    text[location-1][linelen]='\n';
	X    text[location-1][linelen+1]='\0';
	X    /* text[location-1] = strcat(text[location-1], "\n"); */
	X    }
	Xelse
	X    {
	X    text[location-1] = strdup(buffer);
	X    }
	Xreturn(text);
	X}
SHAR_EOF
if test 1854 -ne "`wc -c < 'allocate.c'`"
then
	echo shar: "error transmitting 'allocate.c'" '(should have been 1854 characters)'
fi
fi
echo shar: "extracting 'cleanup.c'" '(1315 characters)'
if test -f 'cleanup.c'
then
	echo shar: "will not over-write existing file 'cleanup.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'cleanup.c'
	X
	X/*
	X * Copyright (C) 1990 by Jay Konigsberg. mail: jak@sactoh0
	X *
	X * Permission to use, copy, modify, and distribute this  software  and  its
	X * documentation is hereby  granted,  provided  that  the  above  copyright
	X * notice appear in all copies  and that  both  the  copyright  notice  and
	X * this permission notice appear in supporting documentation. This software
	X * is provided "as is" without express or implied  warranty.  However,  the
	X * author retains all Copyright priviliges and rights  to  renumeration  if
	X * this software is sold.
	X */
	X
	X/*
	X * cleanup - resets port settings to what they were before entering
	X * raw mode.
	X */
	X
	X#include "simped.h"
	X
	X/* Global for interrupt routine: cleanup() */
	Xextern	struct	  termio  ttyset;	/* terminal settings */
	Xextern	unsigned  short   c_lflag_hold;	/* hold original values for reset */
	Xextern	unsigned  char    VEOF_hold;	/* hold original value for reset */
	X
	Xint cleanup(sig_caught) /* Signal trap for SIGINT */
	Xint	sig_caught;
	X{
	Xvoid	exit();
	X
	Xint	ioctl(),
	X	fprintf();
	X
	X/* reset terminal charastics */
	Xttyset.c_lflag = c_lflag_hold;
	Xttyset.c_cc[4] = VEOF_hold;
	Xif ( ioctl(0, TCSETAW, &ttyset) == -1) {
	X    fprintf(stderr, "ioctl: error=%d\n", errno);
	X    exit(2);
	X}
	Xif (sig_caught)
	X    {
	X    fprintf(stderr,"\nMessage aborted.\n");
	X    }
	Xexit(2);
	Xreturn(0);
	X}
SHAR_EOF
if test 1315 -ne "`wc -c < 'cleanup.c'`"
then
	echo shar: "error transmitting 'cleanup.c'" '(should have been 1315 characters)'
fi
fi
echo shar: "extracting 'commands.c'" '(7412 characters)'
if test -f 'commands.c'
then
	echo shar: "will not over-write existing file 'commands.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'commands.c'
	X
	X/*
	X * Copyright (C) 1990 by Jay Konigsberg. mail: jak@sactoh0
	X *
	X * Permission to use, copy, modify, and distribute this  software  and  its
	X * documentation is hereby  granted,  provided  that  the  above  copyright
	X * notice appear in all copies  and that  both  the  copyright  notice  and
	X * this permission notice appear in supporting documentation. This software
	X * is provided "as is" without express or implied  warranty.  However,  the
	X * author retains all Copyright priviliges and rights  to  renumeration  if
	X * this software is sold.
	X */
	X
	X/*
	X * commands - main command loop
	X */
	X
	X/* global to replace \b */
	Xextern unsigned char bs_char;	/* BS char picked up from termio */
	X
	X#include "simped.h"
	X#include "sys/stat.h"
	X
	Xvoid commands(editfile, newfile, fd, postnews, append)
	Xchar *editfile;		/* the name of the file being edited, NULL
	X			 * if no file name was specified. Aslo,
	X			 * 'newfile' will be TRUE
	X			 */
	Xint  *newfile;		/* boolean TRUE if a file is created, FALSE
	X			 * if the file was read in.
	X			 */
	XFILE *fd;
	Xint  postnews;
	Xint append;
	X{
	Xextern char *malloc();
	X
	Xint	printf(),
	X	fprintf(),
	X	fflush(),
	X	getlinenum(),
	X	fputs(),
	X	puts(),
	X	stat(),
	X	unlink(),
	X	free(),
	X	cleanup();
	X
	Xchar 	**addlines(),		/* add lines to the text area */
	X	**allocate(),		/* make space in buffer for text */
	X	**editline(),		/* edit a line (subsutite) command */
	X	**deleteline(),		/* delete a line in the text buffer */
	X	**modify();		/* modify a line of text */
	X
	Xvoid	listtext(),
	X	savefile(),
	X	help();
	X
	Xstruct  stat  *buf;		/* check for 0 len file when A)bort */
	X
	Xchar	**text,			/* text entered in the editor */
	X	*overflow=NULL,		/* pointer for autowrap */
	X	*delimiter=NULL,	/* passed back from getlinenum for edit */
	X	inpchar;		/* command input character */
	X
	Xint	count=0,		/* line count */
	X	startlist,		/* line number to start a listing */
	X	abort=1,		/* command aborted - don't print menu */
	X	linenum=0,		/* line number for insert */
	X	valid_command=FALSE;	/* boolean for command loop */
	X
	X/*
	Xinitilize the text buffer area
	X*/
	Xif ( (text = (char **)malloc(PTR_CHUNK * sizeof(char *)+1)) == (char **)0 )
	X    {
	X    fprintf(stderr, "malloc: error=%d\n", errno);
	X    cleanup(2);
	X    }
	X
	X/*
	X * Copyright
	X */
	Xputs("\nSimped version 2, Copyright (C) 1990 - Jay Konigsberg (jak@sactoh0)\n");
	X
	Xif (fd != stdin)
	X    {
	X    printf("%s: ", editfile);
	X    }
	Xif (*newfile)
	X    {
	X    puts("New file.\n");
	X    puts("Please enter your text now. The text will automatically wrap");
	X    puts("around to the next line when a line is full. Enter a Carriage");
	X    puts("Return on a new line to end.\n");
	X    }
	Xtext = addlines(text, overflow, &count, 1, fd, *newfile, postnews);
	X
	Xif (fd != stdin && ! *newfile)
	X    {
	X    if (count >= PAUSE)
	X	{
	X	startlist = count - PAUSE + 1;
	X	printf("\nThe last %d lines read in:\n", PAUSE);
	X	}
	X    else
	X	{
	X	startlist = 1;
	X	}
	X    listtext(text, count, startlist);
	X    }
	X
	Xif (append)
	X    text = addlines(text, overflow, &count, count+1, stdin, FALSE, FALSE);
	X
	Xwhile (! valid_command)
	X    {
	X    /*
	X     * abort will be 0 when returning from a function via a bs,
	X     * thus the strange looking test.
	X     */
	X    if (abort)
	X	{
	X   puts("\nOptions: S)ave and quit, A)bort/cancel, L)ist message, E)dit line,");
	X   puts("         I)nsert line, D)elete line, C)ontinue, M)odify, H)elp\n");
	X   fputs("Command? ", stdout);
	X	}
	X
	X    abort=1;
	X    fflush(stdout);
	X    valid_command=FALSE;
	X    inpchar = getchar();
	X    putchar(inpchar);
	X    fflush(stdout);
	X
	X    switch (inpchar)
	X	{
	X	case 'S': /* save the file and quit */
	X	case 's':
	X	    for (;;)
	X		{
	X		if ( (inpchar=getchar()) == bs_char )
	X		    {
	X		    putchar(inpchar);
	X		    putchar(' ');
	X		    putchar(inpchar);
	X		    abort=0;
	X		    break;
	X		    }
	X		else if ( inpchar == '\n' )
	X		    {
	X		    savefile(editfile, newfile, fd, text, count);
	X		    break;
	X		    }
	X		else
	X		    putchar(BELL);
	X		}
	X	    break;
	X	case 'A': /* abort editing session */
	X	case 'a':
	X	    for (;;)
	X		{
	X		if ( (inpchar=getchar()) == bs_char )
	X		    {
	X		    putchar(inpchar);
	X		    putchar(' ');
	X		    putchar(inpchar);
	X		    abort=0;
	X		    break;
	X		    }
	X		else if ( inpchar == '\n' )
	X		    {
	X		    fputs("\nQuit without saving (return=n/Y)? ", stdout);
	X		    if ( (inpchar=getchar()) == 'Y' || inpchar == 'y' )
	X			{
	X			putchar(inpchar);
	X			fflush(stdout);
	X			buf = (struct stat *)malloc(sizeof(buf));
	X			/* remove file if its empty - note: the errors are
	X			ignored intentionally */
	X			if ( stat(editfile, buf) == 0 )
	X			    {
	X			    if (buf->st_size == (off_t)0 )
	X				{
	X				unlink(editfile);
	X				}
	X			    }
	X			cleanup(2);
	X			break;
	X			}
	X		    else
	X			{
	X			putchar(inpchar);
	X			fflush(stdout);
	X			puts("");
	X			break;
	X			}
	X		    }
	X		}
	X	    break;
	X	case 'Q': /* because q to quit is so common */
	X	case 'q':
	X	    cleanup(2);
	X	    break;
	X	case 'L': /* list the file */
	X	case 'l':
	X	    if ( (linenum=getlinenum(count, "cr=1", "")) != -1 )
	X		{
	X		if ( linenum != 0 )
	X		    {
	X		    puts("");
	X		    listtext(text, count, linenum);
	X		    }
	X		else
	X		    abort=0;
	X		}
	X	    break;
	X	case 'E': /* edit a line - sudsutite command */
	X	case 'e':
	X	    if (delimiter)
	X		{
	X		free(delimiter);
	X		}
	X	    else
	X		{
	X		if ( (delimiter=malloc(2)) == NULL )
	X		    {
	X		    fprintf(stderr, "malloc: error=%d\n", errno);
	X		    cleanup(2);
	X		    }
	X		*delimiter='\0';
	X		}
	X
	X	    if ((linenum=getlinenum(count, "/?=cr", delimiter)) != -1)
	X		{
	X		if ( linenum != 0 )
	X		    {
	X		    if ( ! *delimiter )
	X			puts("");
	X		    text = editline(text, linenum, *delimiter);
	X		    }
	X		else
	X		    abort=0;
	X		}
	X	    break;
	X	case 'I': /* insert a line */
	X	case 'i':
	X	    if ( (linenum=getlinenum(count, "", "")) != -1)
	X		{
	X		if ( linenum != 0 )
	X		  {
	X		  puts("");
	X		  text=addlines(text,overflow,&count,linenum,stdin,FALSE,FALSE);
	X		  }
	X		else
	X		    abort=0;
	X		}
	X	    break;
	X	case 'D': /* delete a line */
	X	case 'd':
	X	    if ( (linenum=getlinenum(count, "", "")) != -1)
	X		{
	X		if (linenum != 0)
	X		    {
	X		    puts("");
	X		    text=deleteline(text, &count, linenum);
	X		    }
	X		else
	X		    abort=0;
	X		}
	X	    break;
	X	case 'C': /* continue editing at EOF */
	X	case 'c':
	X	    for (;;)
	X		{
	X		if ( (inpchar=getchar()) == bs_char )
	X		{
	X		    putchar(inpchar);
	X		    putchar(' ');
	X		    putchar(inpchar);
	X		    abort=0;
	X		    break;
	X		}
	X		else if ( inpchar == '\n' )
	X		  {
	X		  puts("");
	X		  text=addlines(text,overflow,&count,count+1,stdin,FALSE,FALSE);
	X		  break;
	X		  }
	X		else
	X		    putchar(BELL);
	X		}
	X	    break;
	X	case 'M': /* modify - multi use line editing */
	X	case 'm':
	X	    if ( (linenum=getlinenum(count, "", "")) != -1 )
	X		{
	X		if ( linenum != 0 )
	X		    {
	X		    puts("");
	X		    text=modify(text, linenum);
	X		    }
	X		else
	X		    abort=0;
	X		}
	X	    break;
	X	case '\n':
	X	    fputs("Command? ", stdout);
	X	    abort=0; /* do not print menu again */
	X	    break;
	X	case 'H':
	X	case 'h':
	X	    for (;;)
	X		{
	X		if ( (inpchar=getchar()) == bs_char )
	X		    {
	X		    putchar(inpchar);
	X		    putchar(' ');
	X		    putchar(inpchar);
	X		    abort=0;
	X		    break;
	X		    }
	X		else if ( inpchar == '\n' )
	X		    {
	X		    help();
	X		    break;
	X		    }
	X		else
	X		    putchar(BELL);
	X		}
	X	    break;
	X	case 'j':
	X	    puts("\n\nAuthor   : Jay Konigsberg\n");
	X	    puts("Copyright: June 1990");
	X	    puts("Date     : June 1990\n");
	X	    puts("uucp     : jak@sactoh0\n");
	X	    break;
	X	default :
	X	    if (inpchar == (int)bs_char)
	X		{
	X		putchar(' ');
	X		putchar(BELL);
	X		fflush(stdout);
	X		abort=0; /* do not print menu again */
	X		}
	X	    else
	X		printf("%c: not a valid command.\n", inpchar);
	X	}
	X    }
	X}
SHAR_EOF
if test 7412 -ne "`wc -c < 'commands.c'`"
then
	echo shar: "error transmitting 'commands.c'" '(should have been 7412 characters)'
fi
fi
echo shar: "extracting 'deleteline.c'" '(1346 characters)'
if test -f 'deleteline.c'
then
	echo shar: "will not over-write existing file 'deleteline.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'deleteline.c'
	X
	X/*
	X * Copyright (C) 1990 by Jay Konigsberg. mail: jak@sactoh0
	X *
	X * Permission to use, copy, modify, and distribute this  software  and  its
	X * documentation is hereby  granted,  provided  that  the  above  copyright
	X * notice appear in all copies  and that  both  the  copyright  notice  and
	X * this permission notice appear in supporting documentation. This software
	X * is provided "as is" without express or implied  warranty.  However,  the
	X * author retains all Copyright priviliges and rights  to  renumeration  if
	X * this software is sold.
	X */
	X
	X/*
	X * deleteline - delete a line from the text buffer
	X */
	X
	X#include "simped.h"
	X
	Xchar **deleteline(text, count, delline)
	Xchar **text;
	Xint  *count;
	Xint  delline;		/* returns the line number deleted or 0 */
	X{
	Xint	printf(),
	X	fflush(),
	X	puts(),
	X	fputs();
	X
	Xvoid	free();
	X
	Xint	inpchar=0,
	X	loop;
	X
	Xif(delline > 0)
	X    {
	X    printf("\n%3d> ",delline);
	X    fputs(text[delline-1], stdout);
	X    fputs("Delete this line (Return=n/y): ", stdout);
	X    fflush(stdout);
	X    inpchar=getchar();
	X    putchar(inpchar);
	X    }
	X
	Xif (inpchar == 'y' || inpchar == 'Y')
	X    {
	X    free(text[delline-1]);
	X    for(loop=delline-1; loop < *count-1; ++loop)
	X	{
	X	text[loop] = text[loop+1];
	X	}
	X    text[loop]=NULL;
	X    --*count;
	X    puts("\nLine deleted.");
	X    }
	Xelse
	X    {
	X    puts("\nLine NOT deleted.");
	X    }
	Xreturn(text);
	X}
SHAR_EOF
if test 1346 -ne "`wc -c < 'deleteline.c'`"
then
	echo shar: "error transmitting 'deleteline.c'" '(should have been 1346 characters)'
fi
fi
echo shar: "extracting 'editline.c'" '(5118 characters)'
if test -f 'editline.c'
then
	echo shar: "will not over-write existing file 'editline.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'editline.c'
	X
	X/*
	X * Copyright (C) 1990 by Jay Konigsberg. mail: jak@sactoh0
	X *
	X * Permission to use, copy, modify, and distribute this  software  and  its
	X * documentation is hereby  granted,  provided  that  the  above  copyright
	X * notice appear in all copies  and that  both  the  copyright  notice  and
	X * this permission notice appear in supporting documentation. This software
	X * is provided "as is" without express or implied  warranty.  However,  the
	X * author retains all Copyright priviliges and rights  to  renumeration  if
	X * this software is sold.
	X */
	X
	X/*
	X * editline - edit a line in the text buffer. e.g. e/old/new
	X */
	X
	X#include "simped.h"
	X
	Xchar **editline(text, linenum, delimiter)
	Xchar **text;
	Xint  linenum;
	Xchar delimiter;
	X{
	Xint	position(),		/* where is oldtext in text[], -1 if err */
	X	cleanup(),
	X	puts(),
	X	fputs(),
	X	fflush(),
	X	printf(),
	X	fprintf();
	X
	Xchar	*realloc(),
	X	*getline();
	X
	X
	Xchar	*oldtext,
	X	*newtext,
	X	buffer[LINELEN+2];
	X
	Xint	text_entered,		/* boolean to tell if something was entered */
	X	textinx=0,		/* index for the subsitutation */
	X	textlen,		/* length of the original string */
	X	newlen,			/* length of new text */
	X	oldlen,			/* length of old text */
	X	point=0;		/* subscript of text[] where oldtext begins */
	X
	Xtextlen=strlen(text[linenum-1]);
	Xif ( ! delimiter )
	X    {
	X    printf("%3d> ", linenum);
	X    fputs(text[linenum-1], stdout);
	X    puts("Return by itself to insert at the beginning.");
	X    }
	X    for(;;)
	X    {
	X    if ( ! delimiter)
	X	{
	X	fputs("Old text: ", stdout);
	X	fflush(stdout);
	X	}
	X    if (getline(buffer, &text_entered, stdin, delimiter, TRUE))
	X	{
	X	if ( ! delimiter)
	X	    {
	X	    printf("Max line is %d characters, continuing...\n", LINELEN);
	X	    }
	X	else
	X	    {
	X	    /* printf("%c%c", delimiter, BELL); */
	X	    }
	X	buffer[LINELEN+1]='\n';
	X	buffer[LINELEN+2]='\0';
	X	}
	X    fflush(stdout);
	X    /* if (text_entered == FALSE) */
	X    if ( strlen(buffer) == 1) /* a single '\n' was entered */
	X	{
	X	/* setup to insert at the begining of the line */
	X	oldlen=0;
	X	break;
	X	}
	X    else
	X	{
	X	buffer[strlen(buffer)-1]='\0';
	X	oldtext=strdup(buffer);
	X	oldlen=strlen(oldtext);
	X	if( (point=position(oldtext, text[linenum-1])) == -1)
	X	    {
	X	    printf("\nstring: %s, not found in line %d\n", oldtext, linenum);
	X	    delimiter='\0';
	X	    }
	X	else
	X	    {
	X	    break;
	X	    }
	X	}
	X    }
	Xif ( ! delimiter )
	X    {
	X    fputs("New text: ", stdout);
	X    fflush(stdout);
	X    }
	Xif(getline(buffer, &text_entered, stdin, delimiter, TRUE))
	X    {
	X    if ( ! delimiter )
	X	    {
	X	    printf("Max line is %d characters, continuing...\n", LINELEN);
	X	    }
	X	else
	X	    {
	X	    /* printf("%c%c", delimiter, BELL); */
	X	    fflush(stdout);
	X	    }
	X    buffer[LINELEN+1]='\n';
	X    buffer[LINELEN+2]='\0';
	X    }
	X/* if (text_entered == FALSE && oldlen == 0) */
	Xif (strlen(buffer) == 1 && oldlen == 0) /* a singal '\n' was entered */
	X    {
	X    /* nothing entered, exit */
	X    puts("\nNo change...");
	X    return(text);
	X    }
	Xif (text_entered == FALSE)
	X    {
	X    buffer[0]='\0';
	X    }
	Xelse
	X    {
	X    buffer[strlen(buffer)-1]='\0';
	X    }
	Xnewtext=strdup(buffer);
	Xnewlen=strlen(newtext);
	X/* Conditions to handle
	X *
	X *				* no realloc
	X * 1) oldlen == newlen		- strings are same length
	X *				* relloc after change so no text is lost
	X * 2) newlen == 0 & oldlen > 1	- remove some text
	X * 3) newlen <  oldlen		- downsize text[]
	X *				* realloc before change so there is
	X *				  room for more characters
	X * 4) oldlen == 0 & newlen > 1	- insert at beginning of line
	X * 5) newlen >  oldlen		- increase size-of text[]
	X */
	Xif (newlen == oldlen) /* case 1, same length */
	X    {
	X    for (textinx=point; textinx < point+newlen; ++textinx)
	X	{
	X	text[linenum-1][textinx] = newtext[textinx-point];
	X	}
	X    }
	Xelse
	X    {
	X    if (newlen < oldlen) /* case 2 & 3 - have extra space */
	X	{
	X	/* copy over old text - non-op if new=0 */
	X	for (textinx=point; textinx < point+newlen; ++textinx)
	X	    {
	X	    text[linenum-1][textinx] = newtext[textinx-point];
	X	    }
	X	/* roll remaining text back over the oldtext */
	X	point=textinx;
	X	for (textinx=point; textinx < textlen; ++textinx)
	X	    {
	X	    text[linenum-1][textinx]=text[linenum-1][textinx+oldlen-newlen];
	X	    }
	X	text[linenum-1][textlen+newlen-oldlen]='\0';
	X	if((text[linenum-1]=realloc(text[linenum-1],
	X	    (unsigned int)(textinx+FUDGE)))==NULL)
	X	    {
	X	    fprintf(stderr, "realloc: error=%d\n", errno);
	X	    cleanup(2);
	X	    }
	X	}
	X    else /* case 4 & 5 - more space is needed */
	X	{
	X	if((text[linenum-1]=realloc(text[linenum-1],
	X		(unsigned int)(textlen+newlen-oldlen+FUDGE)))==NULL)
	X	    {
	X	    fprintf(stderr, "realloc: error=%d\n", errno);
	X	    cleanup(2);
	X	    }
	X	/* roll out char to make room for insert */
	X	
	X	for (textinx=textlen+newlen-oldlen;
	X	    textinx >= point+newlen-oldlen; --textinx)
	X	    {
	X	    text[linenum-1][textinx]=text[linenum-1][textinx-newlen+oldlen];
	X	    }
	X	/* place newtext in the text area */
	X	for (textinx=point; textinx < point+newlen; ++textinx)
	X	    {
	X	    text[linenum-1][textinx] = newtext[textinx-point];
	X	    }
	X	text[linenum-1][textlen+newlen-oldlen-1]='\n';
	X	text[linenum-1][textlen+newlen-oldlen]='\0';
	X	}
	X    }
	Xprintf("\n%3d> ", linenum);
	Xfputs(text[linenum-1], stdout);
	Xreturn(text);
	X}
SHAR_EOF
if test 5118 -ne "`wc -c < 'editline.c'`"
then
	echo shar: "error transmitting 'editline.c'" '(should have been 5118 characters)'
fi
fi
echo shar: "extracting 'getline.c'" '(4037 characters)'
if test -f 'getline.c'
then
	echo shar: "will not over-write existing file 'getline.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'getline.c'
	X
	X/*
	X * Copyright (C) 1990 by Jay Konigsberg. mail: jak@sactoh0
	X *
	X * Permission to use, copy, modify, and distribute this  software  and  its
	X * documentation is hereby  granted,  provided  that  the  above  copyright
	X * notice appear in all copies  and that  both  the  copyright  notice  and
	X * this permission notice appear in supporting documentation. This software
	X * is provided "as is" without express or implied  warranty.  However,  the
	X * author retains all Copyright priviliges and rights  to  renumeration  if
	X * this software is sold.
	X */
	X
	X/*
	X * getline - gets a line of text from the fd: in_file. If the line of
	X * text is longer than the allowed length (LINELEN) it strips off the
	X * last word if there is whitespace, or the last char if not. The
	X * overflow is saved, unless the dumpoverflow flag is set.
	X *
	X * The overflow is returned to the caller and maintained in static
	X * space.
	X */
	X
	X#include "simped.h"
	X
	X/* global to replace \b char in input */
	Xextern unsigned char bs_char;
	X
	Xchar *getline(buffer, text_entered, in_file, delimiter, dumpoverflow)
	Xchar buffer[];		/* input buffer to be passed out */
	Xint  *text_entered;	/* flag that something was entered */
	XFILE *in_file;		/* stdin, or the fd of a file */
	Xchar delimiter;		/* if set, will return like a return will */
	Xint  dumpoverflow;	/* boolean */
	X{
	Xint	fflush(),
	X	fputs(),
	X	puts();
	X
	Xstatic	char *overflow;
	Xstatic	char extrachar = '\0';	/* autowrap char when there is no whitespace */
	X
	X
	Xint	blankchar,		/* location of blanking during autowrap */
	X	inpchar,		/* char read in for procesing into buffer */
	X	curchar=0,		/* input buffer pointer */
	X	whitespace,		/* location of autowrap cut */
	X	have_nl=FALSE;		/* newline flag */
	X
	X*text_entered = FALSE;
	Xhave_nl = FALSE;
	Xfflush(stdout);
	X
	Xfor (curchar=0; (curchar<=LINELEN && (! have_nl)); ++curchar)
	X    {
	X    if (overflow)
	X	{
	X	curchar = strlen(overflow);
	X	if (in_file == stdin)
	X	    {
	X	    fputs(overflow, stdout);
	X	    fflush(stdout);
	X	    }
	X	buffer[0]='\0';
	X	strcat(buffer, overflow);
	X	overflow = NULL;
	X	}
	X    else
	X	{
	X	if (extrachar)
	X	    {
	X	    curchar = 1;
	X	    if (in_file == stdin)
	X		{
	X		putchar(extrachar);
	X		}
	X	    buffer[0]=extrachar;
	X	    buffer[1]=extrachar='\0';
	X	    }
	X	}
	X    inpchar = getc(in_file);
	X    if (inpchar == EOF)
	X	{
	X	*text_entered = EOF;
	X	break;
	X	}
	X    if( inpchar == bs_char )
	X	{
	X	if ( curchar > 0)
	X	    {
	X	    if (in_file == stdin)
	X		{
	X		fputs("\b \b", stdout);
	X		}
	X	    curchar -= 2; /* one will be added back in the for loop */
	X	    }
	X	else
	X	    {
	X	    putchar(BELL);
	X	    curchar--;
	X	    }
	X	buffer[curchar+1]='\0';
	X	}
	X    else 
	X	{
	X	if ( inpchar == '\t' )
	X	    {
	X	    inpchar = ' ';
	X	    }
	X	else
	X	    {
	X	    if ( inpchar == '\n' )
	X		{
	X		have_nl = TRUE;
	X		}
	X	    }
	X	if ( delimiter == inpchar )
	X	    {
	X	    putchar(delimiter);
	X	    buffer[curchar]='\n';
	X	    buffer[curchar+1]='\0';
	X	    break;
	X	    }
	X	if (inpchar != EOF)
	X	    {
	X	    buffer[curchar] = inpchar; 
	X	    buffer[curchar+1] = '\0'; 
	X	    if (in_file == stdin)
	X		{
	X		putchar(inpchar);
	X		}
	X	    }
	X	}
	X    fflush(stdout);
	X    }
	X/* At least 1 char & a CR */
	Xif ( curchar >= 2 || ( curchar > 1 && delimiter != '0') )
	X    {
	X	*text_entered = TRUE;
	X    }
	X/* If the line overflowed - do an autowrap */
	Xif (curchar == LINELEN+1 && ! have_nl)
	X    {
	X    /* look for the last whitespace */
	X    for (whitespace=curchar-1; whitespace >= 0; --whitespace)
	X	{
	X	    if ( buffer[whitespace] == ' ' )
	X		{
	X		break;
	X		}
	X	}
	X    if (whitespace > 0)
	X	{
	X	for(blankchar=LINELEN; blankchar>whitespace; --blankchar)
	X		{
	X		if (in_file == stdin)
	X		    {
	X		    fputs("\b \b", stdout);
	X		    }
	X		}
	X	if (in_file == stdin)
	X	    {
	X	    puts("");
	X	    }
	X	overflow=(char *)&buffer[whitespace+1];
	X	buffer[whitespace] = '\0';
	X	}
	X    else /* No whitespace, put the last char in overflow */
	X	{
	X	if (in_file == stdin)
	X	    {
	X	    fputs("\b \b", stdout);
	X	    puts("");
	X	    }
	X	extrachar = buffer[LINELEN];
	X	buffer[LINELEN] = '\n';
	X	buffer[LINELEN+1] = '\0';
	X	}
	X    }
	Xif (dumpoverflow)
	X    {
	X    overflow=NULL;
	X    extrachar='\0';
	X    return('\0');
	X    }
	Xreturn(overflow);
	X}
SHAR_EOF
if test 4037 -ne "`wc -c < 'getline.c'`"
then
	echo shar: "error transmitting 'getline.c'" '(should have been 4037 characters)'
fi
fi
echo shar: "extracting 'getlinenum.c'" '(3031 characters)'
if test -f 'getlinenum.c'
then
	echo shar: "will not over-write existing file 'getlinenum.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'getlinenum.c'
	X
	X/*
	X * Copyright (C) 1990 by Jay Konigsberg. mail: jak@sactoh0
	X *
	X * Permission to use, copy, modify, and distribute this  software  and  its
	X * documentation is hereby  granted,  provided  that  the  above  copyright
	X * notice appear in all copies  and that  both  the  copyright  notice  and
	X * this permission notice appear in supporting documentation. This software
	X * is provided "as is" without express or implied  warranty.  However,  the
	X * author retains all Copyright priviliges and rights  to  renumeration  if
	X * this software is sold.
	X */
	X
	X/*
	X * getlinenum - gets a line number for use with other editor commands.
	X *
	X * arg 2 is a flag for special return. 
	X * "cr=1"  will return 1 if nothing entered. Mainly for list.
	X * "/?=cr" will return on / or ? instead of cr. Mainly for editline.
	X *	   This will return ? or / in *delimiter. (arg 3), otherwise,
	X *	   agr 3 will be null.
	X * ""      (null) is the default and will ask for a "Line number:" if
	X *         one isn't entered.
	X */
	X
	X/* global to replace \b char in input */
	Xextern unsigned char bs_char;
	X
	X#include "simped.h"
	X#define	PLACES	3	/* 3 mantissa places [0], [1], [2], [3]=NULL*/
	X
	Xint getlinenum(count, flag, delimiter)
	Xint  count;
	Xchar *flag;
	Xchar *delimiter;
	X{
	Xint	printf(),
	X	fflush(),
	X	puts(),
	X	fputs(),
	X	atoi();
	X
	Xchar	linenum[PLACES],/* the line number before atoi */
	X	inpdigit;	/* each digit as it is read in */
	X
	Xint	theline,	/* returns the line number, 0 if the screen
	X			 * hasnt changed or -1 on error */
	X	linenuminx=0,	/* an index to line */
	X	creturn=FALSE;	/* flag that "theline" may not equal zero */
	X
	X
	Xdo
	X    {
	X    if ((inpdigit=getchar()) == '\n' && linenuminx == 0)
	X	{
	X	if (creturn)
	X	    {
	X	    return(theline = -1);
	X	    }
	X	else
	X	    {
	X	    if ( ! strcmp(flag, "cr=1") )
	X		{
	X		return(theline = 1);
	X		}
	X	    else
	X		{
	X		fputs("\nLine number: ", stdout);
	X		fflush(stdout);
	X		creturn = TRUE;
	X		inpdigit=' ';
	X		}
	X	    }
	X	}
	X    else
	X	{
	X	if(inpdigit == bs_char)
	X	    {
	X	    fputs("\b \b", stdout);
	X	    fflush(stdout);
	X	    if ( --linenuminx >= 0 )
	X		linenum[linenuminx] = '\0';
	X	    if (linenuminx == -1)
	X		{
	X		if (creturn)
	X		    {
	X		    return(theline = -1);
	X		    }
	X		else /* returning from the function via bs, no screen change */
	X		    {
	X		    return(theline = 0);
	X		    }
	X		}
	X	    }
	X	else
	X	    {
	X	    if (linenuminx < PLACES && inpdigit >= '0' &&
	X		inpdigit <= '9' && inpdigit != '\n')
	X		{
	X		putchar(inpdigit);
	X		fflush(stdout);
	X		linenum[linenuminx++]=inpdigit;
	X		linenum[linenuminx]='\0';
	X		}
	X	    else
	X		{
	X		if (inpdigit != '\n')
	X		    {
	X		    if ( ! strcmp(flag, "/?=cr") )
	X			{
	X			putchar(inpdigit);
	X			fflush(stdout);
	X			*delimiter=(char)inpdigit;
	X			inpdigit=(int)'\0';
	X			break;
	X			}
	X		    else
	X			{
	X			putchar(BELL);
	X			fflush(stdout);
	X			}
	X		    }
	X		}
	X	    }
	X	}
	X    }
	Xwhile (inpdigit != '\n');
	X
	Xtheline=atoi(linenum);
	Xif(theline > count)
	X    {
	X    printf("\nThere are only %d lines.\n", count);
	X    theline = -1;
	X    }
	Xelse
	X    if (theline == 0)
	X	{
	X	puts("\nThere is no line 0.");
	X	theline = -1;
	X	}
	Xfflush(stdout);
	Xreturn(theline);
	X}
SHAR_EOF
if test 3031 -ne "`wc -c < 'getlinenum.c'`"
then
	echo shar: "error transmitting 'getlinenum.c'" '(should have been 3031 characters)'
fi
fi
echo shar: "extracting 'help.c'" '(5821 characters)'
if test -f 'help.c'
then
	echo shar: "will not over-write existing file 'help.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'help.c'
	X
	X/*
	X * Copyright (C) 1990 by Jay Konigsberg. mail: jak@sactoh0
	X *
	X * Permission to use, copy, modify, and distribute this  software  and  its
	X * documentation is hereby  granted,  provided  that  the  above  copyright
	X * notice appear in all copies  and that  both  the  copyright  notice  and
	X * this permission notice appear in supporting documentation. This software
	X * is provided "as is" without express or implied  warranty.  However,  the
	X * author retains all Copyright priviliges and rights  to  renumeration  if
	X * this software is sold.
	X */
	X
	X/*
	X * help - on-line help information.
	X */
	X
	X/* global to replace \b in input */
	Xextern unsigned char bs_char;
	X
	X#include "simped.h"
	X#define MARKER "--------------------------------------------------------"
	X
	Xvoid help()
	X{
	Xint	puts(),
	X	fputs(),
	X	fflush();
	X
	Xint	inpchar,
	X	getcr;		/* get a return to go */
	X
	Xputs("");
	Xputs("Help - S)ave");
	Xputs("       A)bort");
	Xputs("       L)ist");
	Xputs("       E)dit");
	Xputs("       I)nsert");
	Xputs("       D)elete");
	Xputs("       C)ontinue");
	Xputs("       M)odify");
	Xputs("");
	Xfputs ("Enter the command you want help with? ", stdout);
	Xfor(;;)
	X    {
	X    inpchar=getchar();
	X    putchar(inpchar);
	X    if ( (getcr=getchar()) == '\n')
	X	{
	X	putchar(getcr);
	X	break;
	X	}
	X    else
	X	if (getcr == bs_char)
	X	    fputs("\b \b", stdout);
	X    }
	Xputs(MARKER);
	Xswitch(inpchar)
	X    {
	X    case 'S':
	X    case 's':
	X	puts("\n* S)ave and quit\n");
	X	puts("Saves the file and quits the editor.\n");
	X	puts("No options.");
	X	break;
	X    case 'A':
	X    case 'a':
	X	puts("\n* A)bort/cancel\n");
	X	puts("Verifies that no save is to be done and then abandons any");
	X	puts("editing that was done.\n");
	X	puts("No options.");
	X	break;
	X    case 'L':
	X    case 'l':
	X	puts("\n* List text\n");
	X	puts("Lists the text entered, pausing every half page or so. The");
	X	puts("number of lines listed is set at compile time.\n");
	X	puts("Options: A starting line number may be entered. A return");
	X	puts("         will start listing at line 1.");
	X	break;
	X    case 'E':
	X    case 'e':
	X	puts("\n* Edit line\n");
	X	puts("Substitute old text for new text on a line.\n");
	X	puts("Example 1:\n");
	X	puts("Command? e <RETURN>");
	X	puts("Line number: 1 <RETURN>\n");
	X	puts("  1> A line of text\n");
	X	puts("Old text: f t <RETURN>");
	X	puts("New text: f modified t <RETURN>\n");
	X	puts("  1> A line of modified text\n");
	X	puts("(returns to the command prompt)\n\n");
	X	fputs("Touch any key to continue: ", stdout);
	X	fflush(stdout);
	X	inpchar=getchar();
	X	puts("\n\nExample 2:\n");
	X	puts("Command? e1/f t/f modified t/\n");
	X	puts("  1> A line of modified text\n");
	X	puts("(returns to the command prompt)\n");
	X	puts("To insert characters at the beginning of a line, enter");
	X	puts("nothing for the \"Old text:\" and the characters to be");
	X	puts("inserted for the \"New text:\".\n");
	X	puts("To delete characters, enter them in the \"Old text:\" and");
	X	puts("nothing in the new text.\n");
	X	puts("Entering nothing in both \"Old text:\" and \"New text:\" will");
	X	puts("result in no change.");
	X	break;
	X    case 'I':
	X    case 'i':
	X	puts("\n* Insert line\n");
	X	puts("Insert lines of text BEFORE the line number specified. The");
	X	puts("user is dropped into 'insert mode'.\n");
	X	puts("Option: The line number you want the inserted text to");
	X	puts("        appear BEFORE.");
	X	break;
	X    case 'D':
	X    case 'd':
	X	puts("\n* Delete line\n");
	X	puts("Delete a line. The line will be printed and you must enter");
	X	puts("a 'y' for the line to be deleted.\n");
	X	puts("Option: The line number you want deleted.");
	X	break;
	X    case 'C':
	X    case 'c':
	X	puts("\n* Continue\n");
	X	puts("Continue entry. Drops the user into input mode AFTER the");
	X	puts("last line in the file.\n");
	X	puts("No options.");
	X	break;
	X    case 'M':
	X    case 'm':
	X	puts("\n* Modify\n");
	X	puts("This is a multi-use editing function added in a effort");
	X	puts("to regain some of the flexibility lost in making this");
	X	puts("editor simple.\n");
	X	puts("Option: The line number you want to modify.\n");
	X	puts("This command can:\n");
	X	puts("  - replace text");
	X	puts("  - put blanks in place of characters");
	X	puts("  - delete text");
	X	puts("  - insert text\n");
	X	puts("The line is printed and and the cursor is placed under the");
	X	puts("first character on the next line. Changes are made by placing");
	X	puts("one or more of the available options below the portion of");
	X	puts("the line.\n");
	X	fputs("Touch any key to continue: ", stdout);
	X	fflush(stdout);
	X	inpchar=getchar();
	X	puts("\n\nOPTION              EXPLANATION");
	X	puts("------              -----------");
	X	puts("^text#              Inserts the characters between the '^'");
	X	puts("                    and the '#' BEFORE the character");
	X	puts("                    pointed to by the '^'. Inside the '^'");
	X	puts("                    and the '#', both the '&' and the '^'");
	X	puts("                    are treated as regular characters.\n");
	X	puts("  ^#                Inserts a # before ^ (special case)\n");
	X	puts("   #                (When not the first character after a");
	X	puts("                    '^') causes the character above it to");
	X	puts("                    be deleted and the space closed.\n");
	X	puts("   &                Replaces the character above it with a");
	X	puts("                    blank space.\n");
	X	puts("(space)             No effect.\n");
	X	puts("ANY OTHER CHARACTER WILL REPLACE THE CHARACTER ABOVE IT!");
	X	puts("========================================================\n");
	X	fputs("Touch any key to continue: ", stdout);
	X	fflush(stdout);
	X	inpchar=getchar();
	X	puts("\n\nExample:\n");
	X	puts("Command? m1 <RETURN>\n");
	X	puts("   1> Thos sentence isstoobbe mortifd");
	X	puts("edit>   i  ^is the ####  #&     d   ^ie#\n");
	X	puts("   1> This is the sentence to be modified\n");
	X	puts("Command? _");
	X	break;
	X    default :
	X	puts("\nNo such command");
	X	break;
	X    }
	Xputs(MARKER);
	X}
SHAR_EOF
if test 5821 -ne "`wc -c < 'help.c'`"
then
	echo shar: "error transmitting 'help.c'" '(should have been 5821 characters)'
fi
fi
exit 0
#	End of shell archive
-- 
-------------------------------------------------------------
Jay @ SAC-UNIX, Sacramento, Ca.   UUCP=...pacbell!sactoh0!jak
If something is worth doing, its worth doing correctly.

jak@sactoh0.UUCP (Jay A. Konigsberg) (07/07/90)

simped.shar.02 / part02 of 02

-------------------------------- cut here ------------------------------
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#	listtext.c
#	main.c
#	mod
#	modify.c
#	one
#	options.c
#	position.c
#	savefile.c
#	simped.doc
#	simped.h
# This archive created: Fri Jul  6 17:53:12 1990
export PATH; PATH=/bin:/usr/bin:$PATH
echo shar: "extracting 'listtext.c'" '(1557 characters)'
if test -f 'listtext.c'
then
	echo shar: "will not over-write existing file 'listtext.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'listtext.c'
	X
	X/*
	X * Copyright (C) 1990 by Jay Konigsberg. mail: jak@sactoh0
	X *
	X * Permission to use, copy, modify, and distribute this  software  and  its
	X * documentation is hereby  granted,  provided  that  the  above  copyright
	X * notice appear in all copies  and that  both  the  copyright  notice  and
	X * this permission notice appear in supporting documentation. This software
	X * is provided "as is" without express or implied  warranty.  However,  the
	X * author retains all Copyright priviliges and rights  to  renumeration  if
	X * this software is sold.
	X */
	X
	X/*
	X * listtext - display the text buffer area starting at 'start' line
	X * number and pausing every PAUSE lines.
	X */
	X
	X#include "simped.h"
	X#define BS "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
	X#define SP "                 "
	X
	Xvoid listtext(text, count, start)
	Xchar	**text;		/* the text buffer area */
	Xint	count;		/* lines in text area */
	Xint	start;		/* the line to start the listing at */
	X{
	Xint	puts(),
	X	fputs(),
	X	printf();
	X
	Xint	loop,		/* loop var */
	X	inpchar;	/* input char for pause */
	X
	Xputs("");
	Xif (! count)
	X    {
	X    puts("There is no text.");
	X    }
	Xelse
	X    {
	X    for(loop=start-1; loop < count; ++loop)
	X	{
	X	if ( !((loop+start-1) % PAUSE) && loop && loop != count-1
	X	    && loop != start-1 && count - start > PAUSE)
	X	    {
	X	    fputs ("[Press q to quit]", stdout);
	X	    if ( (inpchar = getchar()) == 'q' || inpchar == 'Q')
	X		{
	X		puts("q");
	X		return;
	X		}
	X	    else
	X		{
	X		fputs(BS, stdout);
	X		fputs(SP, stdout);
	X		fputs(BS, stdout);
	X		}
	X	    }
	X	printf("%3d> ", loop+1);
	X	fputs(text[loop], stdout);
	X	}
	X    }
	X}
SHAR_EOF
if test 1557 -ne "`wc -c < 'listtext.c'`"
then
	echo shar: "error transmitting 'listtext.c'" '(should have been 1557 characters)'
fi
fi
echo shar: "extracting 'main.c'" '(2336 characters)'
if test -f 'main.c'
then
	echo shar: "will not over-write existing file 'main.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'main.c'
	X
	X/*
	X * Copyright (C) 1990 by Jay Konigsberg. mail: jak@sactoh0
	X *
	X * Permission to use, copy, modify, and distribute this  software  and  its
	X * documentation is hereby  granted,  provided  that  the  above  copyright
	X * notice appear in all copies  and that  both  the  copyright  notice  and
	X * this permission notice appear in supporting documentation. This software
	X * is provided "as is" without express or implied  warranty.  However,  the
	X * author retains all Copyright priviliges and rights  to  renumeration  if
	X * this software is sold.
	X */
	X
	X/*
	X * main - general setup and signal functions. Its life's work is to make
	X * the bed for commands().
	X */
	X
	X#include "simped.h"
	X
	X/*
	XGlobal for interrupt routine: cleanup()
	X*/
	Xstruct		termio	ttyset;		/* terminal settings */
	Xunsigned	short	c_lflag_hold;	/* hold original values for reset */
	Xunsigned	char	VEOF_hold;	/* hold original value for reset */
	X
	X/* global to replace \b in input */
	Xunsigned char bs_char;
	X
	Xvoid main(argc, argv)
	Xint	argc;
	Xchar	**argv;
	X{
	Xint	fprintf(),
	X	ioctl();
	X
	Xvoid	commands(),
	X	exit();
	X
	Xextern	int	cleanup();
	X
	Xchar	*options();		/* command line options - returns filename */
	X
	Xchar	*editfile=NULL;		/* The file being edited */
	X
	Xint	newfile=FALSE,		/* new or existing file */
	X	postnews=FALSE,		/* flag for postnews compatability */
	X	append=FALSE;		/* flag to always come up in append mode */
	X
	XFILE	*fopen(),
	X	*fd=stdin;		/* file descriptor for command line */
	X
	X/*
	X * was a filename was entered on the command line?
	X */
	X
	Xeditfile = options(argc, argv, &postnews, &append, editfile);
	Xif (editfile)
	X    {
	X    if ((fd = fopen(editfile, "r+")) == NULL)
	X	{
	X	newfile = TRUE;
	X	if ((fd = fopen(editfile, "a")) == NULL)
	X	    {
	X	    fprintf(stderr,"fopen failed: error=%d\n", errno);
	X	    exit(2);
	X	    }
	X	}
	X    }
	Xelse
	X    {
	X    newfile = TRUE;
	X    editfile = NULL;
	X    fd = stdin;
	X    }
	X
	X/*
	Xenter raw mode
	X*/
	Xif ( ioctl(0, TCGETA, &ttyset) == -1 )
	X    {
	X    fprintf(stderr, "ioctl: error=%d\n", errno);
	X    exit(2);
	X    }
	Xc_lflag_hold=ttyset.c_lflag;
	XVEOF_hold = ttyset.c_cc[4];
	Xbs_char = ttyset.c_cc[2];
	Xttyset.c_cc[4] = (unsigned char)1;
	Xttyset.c_lflag &= ~(ICANON | ECHO);
	X
	Xif ( ioctl(0, TCSETAW, &ttyset) == -1 )
	X    {
	X    fprintf(stderr, "ioctl: error=%d\n",errno);
	X    }
	Xsignal(SIGINT, cleanup);
	X
	Xcommands(editfile, &newfile, fd, postnews, append);
	X/*NOTREACHED*/
	X}
SHAR_EOF
if test 2336 -ne "`wc -c < 'main.c'`"
then
	echo shar: "error transmitting 'main.c'" '(should have been 2336 characters)'
fi
fi
echo shar: "extracting 'mod'" '(32 characters)'
if test -f 'mod'
then
	echo shar: "will not over-write existing file 'mod'"
else
sed 's/^	X//' << \SHAR_EOF > 'mod'
	XThos sentence isstoobbe mortifd
SHAR_EOF
if test 32 -ne "`wc -c < 'mod'`"
then
	echo shar: "error transmitting 'mod'" '(should have been 32 characters)'
fi
fi
echo shar: "extracting 'modify.c'" '(4096 characters)'
if test -f 'modify.c'
then
	echo shar: "will not over-write existing file 'modify.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'modify.c'
	X
	X/*
	X * Copyright (C) 1990 by Jay Konigsberg. mail: jak@sactoh0
	X *
	X * Permission to use, copy, modify, and distribute this  software  and  its
	X * documentation is hereby  granted,  provided  that  the  above  copyright
	X * notice appear in all copies  and that  both  the  copyright  notice  and
	X * this permission notice appear in supporting documentation. This software
	X * is provided "as is" without express or implied  warranty.  However,  the
	X * author retains all Copyright priviliges and rights  to  renumeration  if
	X * this software is sold.
	X */
	X
	X/*
	X * modify - a multi-capability line editing function.
	X */
	X
	X#include "simped.h"
	X
	Xchar **modify(text, linenum)
	Xchar **text;
	Xint  linenum;
	X{
	Xextern	char	*realloc();
	X
	Xchar	*getline();
	X
	Xint	printf(),
	X	fprintf(),
	X	fputs(),
	X	puts(),
	X	cleanup();
	X
	Xint	modifylen,	/* length of the modify directive string */
	X	modifyinx,	/* pointer inside the directive string */
	X	loopinx,	/* for inserts and deletes */
	X	newlen,		/* length of the new text */
	X	newinx,		/* index for newtext */
	X	adjust=0,	/* ins & del change text[], so text ref must adjust
	X			   Note: adjust may be positive *or* negitive */
	X	text_entered=0;
	X
	Xchar	modifybuf[LINELEN+2],	/* the modify directives */
	X	*newtext;		/* a pointer into modifybuf for inserts */
	X
	Xprintf("%3d> ", linenum);
	Xfputs(text[linenum-1], stdout);
	Xprintf("edit>");
	Xif (getline(modifybuf, &text_entered, stdin, '\0', TRUE))
	X    {
	X    puts("\nWarning: modify directive overflow, continuing");
	X    }
	X
	X/* remove the trailing '\n' */
	Xmodifylen=strlen(modifybuf);
	Xmodifybuf[--modifylen]='\0';
	X
	X/* now parse modify's buffer for the changes to text[linenum-1] */
	Xfor(modifyinx=0; modifyinx < modifylen; ++modifyinx)
	X    {
	X    if (modifybuf[modifyinx] == ' ')
	X        {
	X        /* do nothing */
	X        }
	X/*    else if ((modifybuf[modifyinx] >= 'a' && modifybuf[modifyinx] <= 'z' ||
	X	      modifybuf[modifyinx] >= 'A' && modifybuf[modifyinx] <= 'Z')&&
	X	      modifyinx+adjust != strlen(text[linenum-1])-1)
	X	{
	X	* replace that char in text[] *
	X	text[linenum-1][modifyinx + adjust]=modifybuf[modifyinx];
	X	}
	X*/
	X    else if (modifybuf[modifyinx] == '&')
	X	{
	X	/* replace char with a sp */
	X	text[linenum-1][modifyinx+adjust]=' ';
	X	}
	X    else if (modifybuf[modifyinx] == '#')
	X	{
	X	if (modifyinx+adjust != strlen(text[linenum-1])-1)
	X	    {
	X	    /* delete char - requires roll back. Note: adjust may be negitive */
	X	    for (loopinx=modifyinx+adjust; loopinx <= strlen(text[linenum-1]);
	X		++loopinx)
	X		{
	X		text[linenum-1][loopinx]=text[linenum-1][loopinx+1];
	X		}
	X	    --adjust;
	X	    }
	X	}
	X    else if (modifybuf[modifyinx] == '^' ||
	X	modifyinx+adjust == strlen(text[linenum-1])-1)
	X	{
	X	/* insert char(s) - requires a roll out and maybe a realloc */
	X	if (modifyinx+adjust != strlen(text[linenum-1])-1)
	X	    newtext=(char *)&modifybuf[modifyinx+1];
	X	else
	X	    {
	X	    newtext=(char *)&modifybuf[modifyinx];
	X	    }
	X	if (newtext[0]=='#') /* insert a # */
	X	    {
	X	    newlen=1;
	X	    }
	X	else
	X	    {
	X	    for (newlen=0; newtext[newlen] != '#'; ++newlen)
	X		{
	X		if (newtext[newlen] == '\0')
	X		    break;
	X		}
	X	    }
	X	/* create the space needed */
	X	if((text[linenum-1]=realloc(text[linenum-1],
	X	    (unsigned int)(strlen(text[linenum-1])+newlen+adjust)))==NULL)
	X	    {
	X	    fprintf(stderr, "realloc: error=%d\n", errno);
	X	    cleanup(2);
	X	    }
	X	/* do the roll out */
	X	for (loopinx=strlen(text[linenum-1])+newlen;
	X	    loopinx >= modifyinx-1+newlen; --loopinx)
	X	    {
	X	    text[linenum-1][loopinx]=text[linenum-1][loopinx-newlen];
	X	    }
	X	/* copy in the new text */
	X	newinx=0;
	X	for (loopinx=modifyinx+adjust;loopinx<modifyinx+adjust+newlen;++loopinx)
	X	    {
	X	    text[linenum-1][loopinx]=newtext[newinx++];
	X	    }
	X	/* adjust the modifyinx pointer to skip insert command */
	X	if (newtext[0] == '#')
	X	    ++modifyinx; /* special case, inserting a # */
	X	else
	X	    modifyinx += newlen + 1; /* one more will be added on the for */
	X	adjust += newlen;
	X	}
	X    else /* replace that character directly into the text */
	X	{
	X	text[linenum-1][modifyinx + adjust]=modifybuf[modifyinx];
	X	}
	X    }
	Xprintf("\n%3d> ", linenum);
	Xfputs(text[linenum-1], stdout);
	Xreturn (text);
	X}
SHAR_EOF
if test 4096 -ne "`wc -c < 'modify.c'`"
then
	echo shar: "error transmitting 'modify.c'" '(should have been 4096 characters)'
fi
fi
echo shar: "extracting 'one'" '(83 characters)'
if test -f 'one'
then
	echo shar: "will not over-write existing file 'one'"
else
sed 's/^	X//' << \SHAR_EOF > 'one'
	XNow is the time
	Xfor all good
	Xmen to come to
	Xthe aid of
	Xtheir party.
	XAdding num six
SHAR_EOF
if test 83 -ne "`wc -c < 'one'`"
then
	echo shar: "error transmitting 'one'" '(should have been 83 characters)'
fi
fi
echo shar: "extracting 'options.c'" '(1547 characters)'
if test -f 'options.c'
then
	echo shar: "will not over-write existing file 'options.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'options.c'
	X
	X/*
	X * Copyright (C) 1990 by Jay Konigsberg. mail: jak@sactoh0
	X *
	X * Permission to use, copy, modify, and distribute this  software  and  its
	X * documentation is hereby  granted,  provided  that  the  above  copyright
	X * notice appear in all copies  and that  both  the  copyright  notice  and
	X * this permission notice appear in supporting documentation. This software
	X * is provided "as is" without express or implied  warranty.  However,  the
	X * author retains all Copyright priviliges and rights  to  renumeration  if
	X * this software is sold.
	X */
	X
	X/*
	X * get options for simped. -p postnews, -a append mode.
	X */
	X
	X#include	"simped.h"
	X
	Xchar *options (argc, argv, postnews, append, editfile)
	Xint	argc;
	Xchar	**argv,
	X	*postnews,	/* flag to add a '--' line to file */
	X	*append,	/* always come up in append mode */
	X	*editfile;
	X{
	X/* system calls and library functions */
	Xint	getopt(),
	X	fprintf(),
	X	exit();
	X
	X/* variables */
	X/* extern char *optarg; UNUSED */
	Xextern int optind;
	X
	Xint	option,			/* getopt variable */
	X	error=FALSE;		/* error checking the options */
	X
	Xwhile ((option = getopt(argc, argv, "pa")) != -1)
	X    {
	X    switch (option)
	X	{
	X	case 'p':
	X	    *postnews=TRUE;
	X	    break;
	X	case 'a':
	X	    *append=TRUE;
	X	    break;
	X	case '?':
	X	    error=TRUE;
	X	    break;
	X	}
	X    }
	Xif ( argc > optind+1 )
	X    {
	X    fprintf(stderr, "Max one filename on command line.\n");
	X    error=TRUE;
	X    }
	Xelse
	X    {
	X    editfile=argv[optind];
	X    }
	X
	Xif (error)
	X    {
	X    fprintf(stderr,
	X    "usage: simped [-p] [-a] filename\n");
	X    exit(2);
	X    }
	Xreturn(editfile);
	X}
SHAR_EOF
if test 1547 -ne "`wc -c < 'options.c'`"
then
	echo shar: "error transmitting 'options.c'" '(should have been 1547 characters)'
fi
fi
echo shar: "extracting 'position.c'" '(1237 characters)'
if test -f 'position.c'
then
	echo shar: "will not over-write existing file 'position.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'position.c'
	X
	X/*
	X * Copyright (C) 1990 by Jay Konigsberg. mail: jak@sactoh0
	X *
	X * Permission to use, copy, modify, and distribute this  software  and  its
	X * documentation is hereby  granted,  provided  that  the  above  copyright
	X * notice appear in all copies  and that  both  the  copyright  notice  and
	X * this permission notice appear in supporting documentation. This software
	X * is provided "as is" without express or implied  warranty.  However,  the
	X * author retains all Copyright priviliges and rights  to  renumeration  if
	X * this software is sold.
	X */
	X
	X/*
	X * position - locate the first occurence of substr in string and
	X * return the subscript
	X */
	X
	X#include "simped.h"
	X
	Xint position(substr, string)
	Xchar substr[];
	Xchar string[];
	X{
	Xint	strinx,		/* index for string */
	X	subinx,		/* index for substr */
	X	sublen,		/* length of substr */
	X	found=FALSE;	/* boolean - is a match found? */
	X
	Xsublen=strlen(substr);
	Xfor(strinx=0; strinx < strlen(string); ++strinx)
	X    {
	X    for (subinx=0; subinx < sublen; ++subinx)
	X	{
	X	if (substr[subinx] == string[strinx+subinx])
	X	    {
	X	    found=TRUE;
	X	    }
	X	else
	X	    {
	X	    found=FALSE;
	X	    break;
	X	    }
	X	}
	X    if (subinx == sublen && found)
	X	break;
	X    }
	Xif (! found)
	X    strinx = -1;
	Xreturn(strinx);
	X}
SHAR_EOF
if test 1237 -ne "`wc -c < 'position.c'`"
then
	echo shar: "error transmitting 'position.c'" '(should have been 1237 characters)'
fi
fi
echo shar: "extracting 'savefile.c'" '(2238 characters)'
if test -f 'savefile.c'
then
	echo shar: "will not over-write existing file 'savefile.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'savefile.c'
	X
	X/*
	X * Copyright (C) 1990 by Jay Konigsberg. mail: jak@sactoh0
	X *
	X * Permission to use, copy, modify, and distribute this  software  and  its
	X * documentation is hereby  granted,  provided  that  the  above  copyright
	X * notice appear in all copies  and that  both  the  copyright  notice  and
	X * this permission notice appear in supporting documentation. This software
	X * is provided "as is" without express or implied  warranty.  However,  the
	X * author retains all Copyright priviliges and rights  to  renumeration  if
	X * this software is sold.
	X */
	X
	X/*
	X * savefile - save the text buffer to a file.
	X */
	X
	X#include "simped.h"
	X
	Xvoid savefile(editfile, newfile, fd, text, count)
	Xchar	*editfile;
	Xint	*newfile;
	XFILE	*fd;
	Xchar	**text;
	Xint	count;
	X{
	XFILE	*fopen();
	X
	Xint	fclose(),
	X	fprintf(),
	X	printf(),
	X	fputs(),
	X	puts(),
	X	unlink(),
	X	cleanup();
	X
	Xchar	*getline();
	X
	Xint	textinx,		/* index for the text buffer */
	X	text_entered=0,		/* was something entered */
	X	ch=0;			/* characters read in */
	X
	Xchar	buffer[LINELEN+2];	/* buffer for filename entry */
	X
	Xputs("");
	Xif (! editfile)
	X    {
	X    for(;;)
	X	{
	X	fputs("\nPlease enter a filename: ", stdout);
	X	if (getline(buffer, &text_entered, stdin, '\0', TRUE))
	X	    {
	X	    puts("Too many characters.");
	X	    return;
	X	    }
	X	if( ! text_entered ) /* a return by itself was entered */
	X	    return;
	X	buffer[strlen(buffer)-1]='\0';
	X	editfile = buffer;
	X	if ( (fd=fopen(editfile, "r")) == NULL)
	X	    {
	X	    break;
	X	    }
	X	printf("%s: file exists! return to exit.\n", editfile);
	X	}
	X    fclose(fd);
	X    if( (fd=fopen(editfile, "w")) == NULL )
	X	{
	X	fprintf(stderr,"Can't open %s, probably an illegal filename",editfile);
	X	return;
	X	}
	X    }
	X
	Xif ( ! *newfile )
	X    {
	X    fclose(fd);
	X    if( (fd=fopen(editfile, "w")) == NULL )
	X	{
	X	fprintf(stderr,"fopen for write failed.\n");
	X	cleanup(2);
	X	}
	X    }
	Xelse
	X    {
	X    rewind(fd);
	X    }
	Xfor (textinx=0; textinx < count; ++textinx)
	X    {
	X    ch += strlen(text[textinx]);
	X    fputs(text[textinx], fd);
	X    }
	Xif (ch > 0)
	X    {
	X    printf("\n%s: written, %d lines, %d characters\n", editfile, count, ch);
	X    }
	Xelse
	X    {
	X    if ( unlink(editfile) == -1 )
	X	{
	X	fprintf(stderr,"unlink failed: error=%d", errno);
	X	}
	X    else
	X	{
	X	puts("Empty file - no action");
	X	}
	X    }
	Xcleanup(0);
	X}
SHAR_EOF
if test 2238 -ne "`wc -c < 'savefile.c'`"
then
	echo shar: "error transmitting 'savefile.c'" '(should have been 2238 characters)'
fi
fi
echo shar: "extracting 'simped.doc'" '(8932 characters)'
if test -f 'simped.doc'
then
	echo shar: "will not over-write existing file 'simped.doc'"
else
sed 's/^	X//' << \SHAR_EOF > 'simped.doc'
	X 
	X 
	X 
	X     simped()                    Unix SysV                       simped()
	X 
	X 
	X 
	X     Name
	X          simped - a simple, bbs style editor.
	X 
	X 
	X     Syntax
	X          simped [-a] [-p] [filename]
	X          (Note: only one file may be specified at a time)
	X
	X	  -a Causes the editor to always come up in append mode. This
	X	  fits nicely with the first 15 lines listed on entry. (Note:
	X	  the number of lines listed is configurable).
	X
	X          -p Compatibility for postnews/inews. Because of the way
	X	  blank lines are stored by simped, inews deletes the first
	X	  line of text. This option will add a line with two dashes
	X	  "--" at the end of the header provided by postnews.
	X
	X          Example for calling simped from a menu:
	X
	X	  EDITOR="/.../simped -p"; export EDITOR
	X	  postnews
	X	  EDITOR=".../simped"; export EDITOR
	X 
	X     Description
	X          simped is a simple line oriented editor for use by people
	X          who don't want to spend time learning a more flexible
	X          editor like ed, ex or vi. It was designed with the intent
	X          that useful work could be done immediately and without
	X          reading this manual page or any of the online help.
	X 
	X          In keeping it simple much flexibility is lost. In an effort
	X          to recover some of this and allow simped to act as a bridge
	X          to more flexible editors, some commands may be wholly or 
	X          partially entered on a single line instead of a separate
	X          line for each portion of a command.
	X 
	X          For example: those commands that require line numbers may
	X          be entered one of two ways:
	X 
	X          Command? d <RETURN>            (delete a line)
	X          Line number: 1 <RETURN>
	X          -or-
	X          Command? d1 <RETURN>
	X 
	X          Also an extra editing command (Modify) has been added which
	X          (once learned) makes editing much easier. Though there is
	X          no complement to this command in any Unix editor, it does
	X          regain some editing flexibility.
	X 
	X     Program entry
	X          If no file is named on the command line, or the file is a
	X          new file, an introductory message is printed and the user
	X          is placed directly into input mode with the prompt:
	X 
	X            1> _
	X 
	X     simped   64                      Page 1                       simped
	X 
	X 
	X 
	X     simped()                    Unix SysV                       simped()
	X 
	X 
	X          If the file exists, the last half page of text is listed
	X          and the:
	X 
	X          Options: S)ave and quit, A)bort/cancel, L)ist text, E)dit line,
	X                   I)nsert line, D)elete line, C)ontinue, M)odify, H)elp
	X 
	X          Command? _
	X 
	X          prompt is displayed, unless the -a option is specified, then
	X	  the user is dropped directly into C)ontinue mode.
	X 
	X          The number of lines listed is set at compile time by the
	X          #define'd value PAUSE.
	X 
	X     Input mode
	X          While in input mode characters typed in are placed in a
	X          buffer. If the text being typed in spills over the end of
	X          the line, it is automatically moved to the next line and 
	X          typing continues uninterrupted.
	X 
	X          Entering a <RETURN> on a line by itself will exit input
	X          mode and display the command prompt.
	X 
	X          If you want a blank line, enter a space and <RETURN>.
	X 
	X          The length of the lines is set at compile time by the
	X          #define'd value LINELEN.
	X 
	X     Command options:
	X 
	X          * S)ave and quit 
	X 
	X            Saves the file and quits the editor.
	X            No options.
	X 
	X          * A)bort/cancel
	X 
	X            Verifies that no save is to be done and then abandons any
	X            editing that was done.
	X            No options.
	X 
	X          * List text
	X 
	X            Lists the text entered, pausing every half page or so. The
	X            number of lines listed is set at compile time.
	X 
	X            Options: A starting line number may be entered. A return
	X                     will start listing at line 1.
	X 
	X 
	X 
	X
	X
	X
	X
	X
	X
	X
	X
	X     simped   130                     Page 2                       simped
	X 
	X 
	X 
	X     simped()                    Unix SysV                       simped()
	X 
	X 
	X          * Edit line
	X 
	X            Substitute old text for new text on a line. 
	X 
	X            Example 1:
	X 
	X            Command? e <RETURN>
	X            Line number: 1 <RETURN>
	X 
	X              1> A line of text
	X 
	X            Old text: f t <RETURN>
	X            New text: f modified t <RETURN>
	X 
	X              1> A line of modified text
	X 
	X            (returns to the command prompt)
	X 
	X 
	X            Example 2:
	X 
	X            Command? e1/f t/f modified t/
	X 
	X              1> A line of modified text
	X 
	X            (returns to the command prompt)
	X 
	X            To insert characters at the beginning of a line, enter
	X            nothing for the "Old text:" and the characters to be
	X            inserted for the "New text:".
	X 
	X            To delete characters, enter them in the "Old text:" and
	X            nothing in the new text.
	X 
	X            Entering nothing in both "Old text:" and "New text:" will
	X            result in no change.
	X          
	X          * Insert line
	X 
	X            Insert lines of text BEFORE the line number specified. The
	X            user is dropped into 'insert mode'.
	X 
	X            Option: The line number you want the inserted text to
	X                    appear BEFORE.
	X 
	X          * Delete line
	X           
	X            Delete a line. The line will be printed and you must enter
	X            a 'y' for the line to be deleted.
	X 
	X            Option: The line number you want deleted.
	X 
	X 
	X
	X
	X
	X
	X
	X
	X     simped   196                     Page 3                       simped
	X
	X
	X
	X     simped()                    Unix SysV                       simped()
	X
	X
	X
	X          * Continue
	X 
	X            Continue entry. Drops the user into input mode AFTER the
	X            last line in the file.
	X 
	X            No options.
	X
	X          * Help
	X 
	X            An online source of information about commands.
	X 
	X          * Modify
	X 
	X            This is a multi-use editing function added in a effort
	X            to regain some of the flexibility lost in making this
	X            editor simple.
	X            
	X            Option: The line number you want to modify.
	X 
	X            This command can:
	X 
	X              - replace text
	X              - put blanks in place of characters
	X              - delete text
	X              - insert text
	X 
	X            The line is printed and and the cursor is placed under the
	X            first character on the next line. Changes are made by placing
	X            one or more of the available options below the portion of
	X            the line.
	X 
	X            OPTION              EXPLANATION
	X            ------              -----------
	X            ^text#              Inserts the characters between the '^'
	X                                and the '#' BEFORE the character
	X                                pointed to by the '^'. Inside the '^'
	X                                and the '#', both the '&' and the '^'
	X                                are treated as regular characters.
	X
	X	      ^#                Inserts a # before the ^ (special case)
	X 
	X               #                (When not the first character after a
	X                                '^') causes the character above it to
	X                                be deleted and the space closed.
	X 
	X               &                Replaces the character above it with a
	X                                blank space.
	X 
	X            (space)             No effect.
	X 
	X            ANY OTHER CHARACTER WILL REPLACE THE CHARACTER ABOVE IT!
	X            ========================================================
	X 
	X
	X
	X
	X
	X
	X     simped   262                     Page 4                       simped
	X
	X
	X
	X     simped()                    Unix SysV                       simped()
	X
	X
	X            Example:
	X 
	X            Command? m1 <RETURN>
	X 
	X               1> Thos sentence isstoobbe mortifd
	X            edit>   i  ^is the ####  #&     d   ^ie#
	X 
	X               1> This is the sentence to be modified
	X 
	X            Command? _
	X 
	X
	X
	X     Bugs
	X
	X     If the terminal erase character is set to something other than
	X     ^H (\010) like DEL, hitting a BS will place a ^H in the text.
	X
	X
	X/*
	X * Copyright (C) 1990 by Jay Konigsberg.
	X *
	X * Permission to use, copy, modify, and distribute this  software  and  its
	X * documentation is hereby  granted,  provided  that  the  above  copyright
	X * notice appear in all copies  and that  both  the  copyright  notice  and
	X * this permission notice appear in supporting documentation. This software
	X * is provided "as is" without express or implied  warranty.  However,  the
	X * author retains all Copyright priviliges and rights  to  renumeration  if
	X * this software is sold.
	X */
	X
	X(Translation: you may use this software freely, but if you sell it, I get
	Xsome money. The amount depends on the selling price).
	X
	X
	X
	X
	X
	X
	X
	X
	X
	X
	X
	X
	X
	X
	X
	X
	X
	X
	X
	X
	X
	X
	X
	X
	X
	X
	X     simped   328                     Page 5                       simped
SHAR_EOF
if test 8932 -ne "`wc -c < 'simped.doc'`"
then
	echo shar: "error transmitting 'simped.doc'" '(should have been 8932 characters)'
fi
fi
echo shar: "extracting 'simped.h'" '(878 characters)'
if test -f 'simped.h'
then
	echo shar: "will not over-write existing file 'simped.h'"
else
sed 's/^	X//' << \SHAR_EOF > 'simped.h'
	X
	X/*
	X * Copyright (C) 1990 by Jay Konigsberg. mail: jak@sactoh0
	X *
	X * Permission to use, copy, modify, and distribute this  software  and  its
	X * documentation is hereby  granted,  provided  that  the  above  copyright
	X * notice appear in all copies  and that  both  the  copyright  notice  and
	X * this permission notice appear in supporting documentation. This software
	X * is provided "as is" without express or implied  warranty.  However,  the
	X * author retains all Copyright priviliges and rights  to  renumeration  if
	X * this software is sold.
	X */
	X
	X/*
	X * simped.h - just a header file, nothing special
	X */
	X
	X#include	<stdio.h>
	X#include	<fcntl.h>
	X#include	<termio.h>
	X#include	<signal.h>
	X#include	<string.h>
	X#include	<sys/types.h>
	X#include	<errno.h>
	X
	X#define		PTR_CHUNK	50
	X#define		MAXNAMESIZ	14
	X#define		TRUE		1
	X#define		FALSE		0
	X#define		FUDGE		3
	X
	Xint	_filbuf(),
	X	_flsbuf();
SHAR_EOF
if test 878 -ne "`wc -c < 'simped.h'`"
then
	echo shar: "error transmitting 'simped.h'" '(should have been 878 characters)'
fi
fi
exit 0
#	End of shell archive
-- 
-------------------------------------------------------------
Jay @ SAC-UNIX, Sacramento, Ca.   UUCP=...pacbell!sactoh0!jak
If something is worth doing, its worth doing correctly.