Path: utzoo!utgpu!attcan!uunet!bbn.com!rsalz From: rsalz@uunet.uu.net (Rich Salz) Newsgroups: comp.sources.unix Subject: v16i065: Front end editor program, Part05/05 Message-ID: <1180@papaya.bbn.com> Date: 10 Nov 88 20:49:31 GMT Lines: 664 Approved: rsalz@uunet.UU.NET Submitted-by: Kazumasa Utashiro Posting-number: Volume 16, Issue 65 Archive-name: fep/part05 #!/bin/sh # to extract, remove the header and type "sh filename" if `test ! -s ./Makefile` then echo "writing ./Makefile" cat > ./Makefile << '\End\Of\File\' # # Copyright (c) 1987, 1988 by Software Research Associates, Inc. # # $Header: Makefile,v 4.0 88/08/05 20:24:19 utashiro Exp $ # # Options: # KANJI: SHIFT-JIS kanji code handling on ASCII KANJI UNIX # TARGET = fep HEADER = fep_defs.h fep_glob.h fep_funcs.h fep_stat.h SRC = fep_main.c fep_edit.c fep_hist.c fep_com.c fep_funcs.c fep_set.c \ fep_vi.c fep_util.c fep_alias.c OBJ = fep_main.o fep_edit.o fep_hist.o fep_com.o fep_funcs.o fep_set.o \ fep_vi.o fep_util.o fep_alias.o DISTRIBUTION\ = Makefile fep.1 $(HEADER) $(SRC) feprc.sample README INSTDIR = /usr/local/bin #STAT = -DSTAT# Delete # for statistic info #KANJI = -DKANJI# Delete # for KANJI handling CONFIG = $(STAT) $(KANJI) DEBUG = -g #DEBUG = -O CFLAGS = $(DEBUG) $(CONFIG) LDFLAGS = -ltermlib all: $(TARGET) $(TARGET): $(OBJ) $(CC) -o $(TARGET) $(CFLAGS) $(OBJ) $(LDFLAGS) argv: fep_com.c $(CC) -o argv -DMKARGDEBUG fep_util.c install: $(TARGET) install -s $(TARGET) $(INSTDIR) install -c fep.1 /usr/man/manl/fep.l README.jis: README jcat -IJ README > $@ # rogue-monster version shar shar: fep.shr1 TARGETSIZE=40000 fep.shr1: $(DISTRIBUTION) shar -f fep -m $(TARGETSIZE) $(DISTRIBUTION) # tektronix shar tshar: $(DISTRIBUTION) shar $(DISTRIBUTION) > fep.shar clean: rm -f *.o $(TARGET) distversion: $(DISTRIBUTION) @ident $(DISTRIBUTION) | grep Header fep_main.o: fep_defs.h fep_glob.h fep_funcs.h fep_stat.h fep_com.o: fep_defs.h fep_glob.h fep_funcs.h fep_edit.o: fep_defs.h fep_glob.h fep_funcs.h fep_funcs.o: fep_funcs.h fep_hist.o: fep_defs.h fep_glob.h fep_funcs.h fep_set.o: fep_defs.h fep_glob.h fep_util.o: fep_defs.h fep_vi.o: fep_defs.h fep_glob.h fep_funcs.h \End\Of\File\ else echo "will not over write ./Makefile" fi if `test ! -s ./fep.1` then echo "writing ./fep.1" cat > ./fep.1 << '\End\Of\File\' .\" Copyright (c) 1987, 1988 by Software Research Associates, Inc. .\" $Header: fep.1,v 4.0 88/08/05 20:22:31 utashiro Rel $ .TH FEP 1L "5 Aug 1988" "SRA Distribution" .SH NAME fep \(em general purpose front end processor .SH SYNOPSIS \fBfep\fR [\|-\fBemacs\fR\||\|-\fBvi\fR\|] \fI\s-1UNIX\s0-command\fR .SH DESCRIPTION .I Fep is a general purpose front end processor applicable to most UNIX commands that features \fIvi\fP\|(1)- or \fIemacs\fR\|(1)-like line editing and a command history mechanism like that of \fIcsh\fR\|(1). .PP Choice of editing style is made by selecting either the emacs mode or the vi mode (named for the editors they emulate), specified either by command line option or by setting a variable interactively or in the start-up file or environment EDITMODE (see editmode variable). .PP The default key bindings are shown below for both edit modes. These can be customized using the fep-bind command. .PP .B Emacs Bindings .PP Here follow the default key bindings for the emacs mode. Each function name should be self-explanatory. The function names are defined as similarly to Gosling's emacs as possible. .sp .RS .nf .ta 1.5i ^@ mark ^A beginning-of-line ^B backward-character ^D delete-next-character ^E end-of-line ^F forward-character ^I insert-tab ^J new-line ^K kill-to-end-of-line ^L clear-screen ^M new-line ^N next-history ^P previous-history ^T previous-history ^Y yank-from-kill-buffer ^^ toggle-transparency ^X-^B show-bindings ^X-^H show-history ^X-^C terminate ^X-^D send-eof ^X-^L repaint ^X-( start-script ^X-) end-script esc-b backward-word esc-B backward-word esc-d delete-next-word esc-D delete-next-word esc-f forward-word esc-F forward-word esc-h delete-previous-word esc-H delete-previous-word esc-l list-file-name esc-L list-file-name esc-esc expand-file-name esc-? help esc-_ invoke-shell esc-< search-reverse esc-> search-forward .if t .sp .3v /* Bindings inherited from the tty driver */ .if t .sp .3v erase delete-previous-character kill delete-line rprnt reprint werase delete-previous-word lnext literal-next .fi .RE .sp .B Vi bindings .PP The vi mode has two sub-modes, the command mode and the text insert mode. The commands of vi are emulated as correctly as possible. Here is a list of the default key bindings of the vi mode that differ from normal vi commands. The tty driver control characters are also inherited in this mode. .sp .RS .nf n search-reverse N search-forward ^A expand-file-name ^L list-file-name ^N next-history ^P previous-history ^R reprint ^^ toggle-transparency ^X-^B show-bindings ^X-^H show-history ^X-^L repaint ^X-^X expand-file-name ^X-^C terminate ^X-^D send-eof ^X-l list-file-name ^X-L list-file-name ^X-? help ^X-( start-script ^X-) end-script .fi .RE .sp .B Built-in commands .PP .I Fep has some built-in commands that are not passed to the child process but understood and processed by fep itself. These commands can be issued from the terminal or from the start-up file. .RS 3n .IP "\fBfep-bind \fIfunction-name key-binding\fR" Change key bindings. For example, to bind the function .I list-file-name to the string "^X-^X", type the following: .if t .sp 0.3v .if n .sp 1 \h'\w'MMMMM'u'fep-bind list-file-name "\\^X\\^X" .if t .sp 0.3v .if n .sp 1 .PP .nf \fBfep-alias\fP \fBfep-alias\fP \fIname\fP \fBfep-alias\fP \fIname string\fP .fi .RS The first form prints all aliases. The second form prints the alias for \fIname\fP. The last form set the alias for \fIname\fP to \fIstring\fP. .PP If you use .I fep without \fIauto-tty-fix\fP, following alias could be usefull. .if t .sp .3v .if n .sp 1 .nf \h'\w'MMMMM'u'if\ $command\ ==\ sh \h'\w'MMMMMMMMMM'u'fep-alias\ more\ "fep-command\ more" \h'\w'MMMMMMMMMM'u'fep-alias\ vi\ "fep-command\ vi" \h'\w'MMMMM'u'endif .fi .if t .sp .3v .if n .sp 1 .RE .IP "\fBfep-unalias\fP \fIlist\fP" Remove alias for each name in \fIlist\fP. .IP "\fBfep-set\fP \fIvariable = value\fR" Set a variable of \fIfep\fP to some value. .IP "\fBfep-unset\fP \fIvariable\fR" Unset a variable. .PP \fBfep-cd\fP [ \fIdirectory\fR ] .br \fBfep-chdir\fP [ \fIdirectory\fR ] .RS Change directory. It sometimes happens that a child process has changed directory, but .I fep is still in the old directory. In such a case, neither \fIlist-file-name\fR nor \fIexpand-file-name\fR will function as expected. This command allows you to change .IR fep 's current working directory (default = home directory). .RE .IP "\fBfep-pwd\fP" Print .IR fep 's current working directory. .IP "\fBfep-history\fP [ \fInumber of line\fR ]" Show the history of commands under .IR fep . .IP "\fBfep-echo\fP \fIarguments\fR" Only print the arguments. Variable names can be used prefixed by the "$" character. .IP "\fBfep-source\fP \fIfile\fR" Read the specified file and execute it. The contents of the file are not sent to sub-processes. .IP "\fBfep-save-history\fP [ \fInumber of lines to save\fR ] \fIfile\fR" Save the current history buffer in the specified file. .IP "\fBfep-read-history\fP [ \fIfile\fR ]" Read in the command history from the specified file. The default file is the value of the \fIhistory-file\fP variable. This file name is understood as a path relative to the home directory. If you want to specify the name relative to the current directory instead, prefix the path by "./". .PP .nf \fBfep-command\fP \fIcommand\fP \fBfep-!\fP \fIcommand\fP .fi .RS Execute \fIcommand\fP. .RE .IP "\fBquit-fep\fP" Kill the sub-process and exit. .PP .IP \fBfep-suspend\fP Suspend .I fep itself. In the unlikely possibility that .I fep falls into a dead-lock in which the sub-processes have stopped but .I fep is still running, use one of these commands to escape from the situation. .PP .nf \fBfep-read-from-file\fP \fIfile\fP \fBfep-<\fP \fIfile\fP .fi .RS Read data from specified file and send them to sub-process. The sub-process will read the data from the file as if they are typed at the keyboard. .RE .PP .nf \fBfep-read-from-command\fP \fIcommand\fP \fBfep-