Input Line Editing

Kazumasa Utashiro utashiro at sran84.sra.JUNET
Mon Jul 25 14:29:09 AEST 1988


In article <9666 at eddie.MIT.EDU> nessus at wonko.MIT.EDU (Doug Alan) writes:
>> In article <16456 at brl-adm.ARPA> rbj at nav.icst.nbs.gov (Root Boy Jim) writes:
>> 
>> > I suspect that the real place for line editing is either in the shell
>> > itsef (as in tcsh, ksh, (and brlsh?)) or in the kernel.
>> 
>> Putting line editing in the shell is wrong, because it should work in
>> all programs and be consistent.  Putting it in the kernal is gross.
>> Thus, the right place to put it is precisely where Bob Pendleton wants
>> to put it -- in a process which gets input from the user and feeds
>> edited input to the user's other programs.  If needed, mods to the
>> kernal and convention, however, should be made to make this as easy
>> and efficient as possible.

I have a program that provide input line editing function for any old
fashioned UNIX style commands. It is distributed as a free program in
JUNET (UNIX network in Japan), but I'm not sure that it is to be
distributed for world. So I include man page of this command and want
to hear about its function. It looks almost like newcsh except that it
works as a front-end for *any* program (even for vi :-). Note that
this command is not based on any great concept like user interface
should be something, but just a simple tool. Please don't talk to me
about where the line editing should be placed as a comment for this
program. If somebody want this program, I can post it to appropriate
news group. Thank you for reading my bad English.

Kazumasa Kayo Utashiro
Software Research Associates, Inc.
1-1-1 Hirakawa-cho, Chiyoda-ku, Tokyo 102, Japan
	UUCP:	kddlab!srava.sra.junet!utashiro
	ARPA:	utashiro%sra.junet at uunet.uu.net
	JUNET:	utashiro at sra.junet


NAME
     fep - general purpose front end processor

SYNOPSIS
     fep [-emacs|-vi] [-h history-length] UNIX-command

DESCRIPTION
     Fep is a general purpose front end processor applicable to
     most UNIX commands that features vi(1)- or emacs(1)-like
     line editing and a command history mechanism like that of
     csh(1).

     Choice of editing style is made by selecting either the
     emacs mode or the vi mode (named for the editors they emu-
     late), specified either by command line option or by setting
     a variable interactively or in the start-up file or environ-
     ment EDITMODE (see editmode variable).

     The default key bindings are shown below for both edit
     modes.  These can be customized using the fep-bind command.

     Emacs Bindings

     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 possi-
     ble.

	...

     Vi bindings

     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.

	...

     Built-in commands

     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.

        fep-bind function-name key-binding
             Change key bindings.  For example, to bind the func-
             tion list-file-name to the string "^X-^X", type the
             following:

                  fep-bind list-file-name "\^X\^X"

        fep-alias
        fep-alias name
        fep-alias name string
             The first form prints all aliases.  The second form
             prints the alias for name.  The last form set the
             alias for name to string.

             If you use fep without auto-tty-fix, following alias
             could be usefull.

                  if $command == sh
                       fep-alias more "fep-command more"
                       fep-alias vi "fep-command vi"
                  endif

        fep-unalias list
             Remove alias for each name in list.

        fep-set variable = value
             Set a variable of fep to some value.

        fep-unset variable
             Unset a variable.

        fep-cd [ directory ]
        fep-chdir [ directory ]
             Change directory.  It sometimes happens that a child
             process has changed directory, but fep is still in
             the old directory.  In such a case, neither list-
             file-name nor expand-file-name will function as
             expected.  This command allows you to change fep's
             current working directory (default = home direc-
             tory).

        fep-pwd
             Print fep's current working directory.

        fep-history [ number of line ]
             Show the history of commands under fep.

        fep-echo arguments
             Only print the arguments.  Variable names can be
             used prefixed by the "$" character.

        fep-source file
             Read the specified file and execute it.  The con-
             tents of the file are not sent to sub-processes.

        fep-save-history [ number of lines to save ] file
             Save the current history buffer in the specified
             file.

        fep-read-history  [ file ]
             Read in the command history from the specified file.
             The default file is the value of the history-file
             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 "./".

        fep-command command
        fep-! command
             Execute command.

        fep-exit
             Kill the sub-process and exit.

        fep-suspend
             Suspend fep itself.  In the unlikely possibility
             that fep falls into a dead-lock in which the sub-
             processes have stopped but fep is still running, use
             one of these commands to escape from the situation.

        fep-read-from-file file
        fep-< file
             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.

        fep-read-from-command command
        fep-<! command
             Send output of specified command to sub-process.

        fep-start-script [ script-file ]
        fep-script [ script-file ]
             Start to send input and output to a script file.  If
             script-file is specified, it is used.  If not the
             value of the variable script-file will be used.

        fep-stop-script
             Stop scripting.

        fep-show-bind
             Print current binding information.

     Control structures

        fep-if expression
        fep-elseif expression
        fep-else
        fep-endif
             Only four control structures are supported but that
             seems enough.  Expression allows only the two opera-
             tors "==" and "!=".
             Variables can be referenced by prefixing with the
             "$" character.

        Note:  The "fep-" prefix of the built-in functions and
        the above operators can be abbreviated in commands that
        fep executes from a file.

     Comment

     Lines starting with the character "#" are ignored by fep.
     If fep encounters a comment in interaction, it is sent to
     the sub-process.  In reading from a file, comments will
     merely be ignored.

     Variables

     Fep uses some variables.

        editmode                      default: emacs
             This variable defines the mode for command line
             editing.  Key bindings will be set for the appropri-
             ate defaults when this variable is changed.  Fep
             first looks at the environment variable EDITMODE,
             then looks at any command line arguments, and
             finally reads in the .feprc start-up file.

        expand-tilde                  default: on
             Fep expands "~" to the real home directory name by
             the expand-file-name function when this variable is
             set.

        ignore-empty-line             default: on
             If this variable is set, empty command lines are not
             saved in the history file.

        ignore-same-line              default: on
             If this variable is set, command lines identical to
             the previous command line are not saved to the his-
             tory file.

        alarm-on-eof                  default: on
             If this variable is set AND the function send-eof is
             not bound to the eof character AND the variable

             ignore-eof is not set, an alarm message will be
             displayed once the first time eof is encountered on
             an empty line.

        history                       default: 100
             Fep maintains a history file of the length specified
             by this variable.

        savehist                      default: off
             If savehist is set fep saves the number of history
             entries specified by value of this variable in the
             file named in the variable history-file on terminat-
             ing.

        history-file                  default: .fephistory
             Contains the name of the history file for reading
             from and writing to.  If the file described by this
             variable exists, fep will read the file into the
             history buffer on start up and then save the current
             session's history when it exits.

        showhist                      default: 20
             This variable specifies the number of history lines
             to be displayed by the show-history function.

        ignore-eof                    default: off
             Fep never worries about the eof character if this
             variable is set.

        noalias                       default: off
             If set, command aliasing won't be done.

        crt                           default: 24
             If set, more message is shown during printing the
             key bindings on each number of line specified by
             this variable.

        command                       default: command-name
             Fep set this variable to the command name of the
             sub-process when it starts up.

        shell                         default: /bin/sh
             Describe the command name to be invoked by invoke-
             shell.

        auto-tty-fix                  default: on
             If this variable is set, fep looks at the tty mode
             of the sub-command, and if the tty mode has changed,
             fep fixes the tty mode of standard out and sets the
             transparency flag according to the mode.  Since this
             tty mode check is done about a second after the last
             input, please wait just one second after entering

             cbreak mode.  If this variable is not set, the
             automatic tty mode check is not done, so you have to
             change the tty mode and transparency explicitly
             using the toggle-transparency function.

        tty-fix-bell                  default: off
             If this variable is set, fep rings the bell when the
             tty mode is changed.

        script-file                   default: fepscript
             This variable is used by the fep-start-script com-
             mand and by the start-script function.

        delimiters
             The contents of this variable are treated as delim-
             iting characters for file name expantion and file
             name list.

        prompt                        default: see below
             Fep outputs a prompt after executing built-in func-
             tions.  The default string is set to the NULL
             string, but there are some default prompt strings
             for some common commands such as sh, dbx, lpc, mail,
             sendmail -bt and calc. However, since fep doesn't
             care about what program is running, the same prompt
             is still output when you are executing bc from sh.
             You can change the value of prompt and other vari-
             ables in the start-up file as follows:

                  if $command == sh
                       set prompt = "$ "
                  endif

     Start-Up File

     Fep executes the file ".feprc" in the home directory of the
     user if it is found there when starting up.  It looks for
     arguments on the command line first, and only then reads the
     ".feprc" file, so the file has higher priority.

     Functions

          abort                       backward-character
          backward-word               beginning-of-line
          delete-line                 delete-next-character
          delete-next-word            delete-previous-character
          delete-previous-word        delete-to-kill-buffer
          end-of-line                 end-script
          expand-file-name            forward-character
          forward-to-end-of-word      forward-word
          ignore                      invoke-shell
          insert-and-flush            insert-tab

          kill-to-end-of-line         kill-to-top-of-line
          list-file-name              literal-next
          mark                        new-line
          next-history                previous-history
          reprint                     search-forward
          search-reverse              self-insert
          send-eof                    show-bindings
          show-history                start-script
          terminate                   toggle-transparency
          yank-from-kill-buffer
          vi-c                        vi-d
          vi-edit                     vi-ins-edit
          vi-motion                   vi-new-line
          vi-num

     Probably only the function name "toggle-transparency" is
     hard to understand.  This function is provided for entering
     non-line-oriented tools from a line-oriented tool using fep.
     Assume a situation where you are using sh(1) with fep, and
     then invoke vi(1).  Since fep intercepts all input for edit-
     ing, vi cannot work correctly.  You can escape from this
     annoying situation using the "toggle-transparency" function
     which is bound to the Control-^ key by default.  Of course
     it is also necessary to return to the normal mode after
     exiting vi.

     This tty mode fix can be done automatically.  If the auto-
     tty-fix variable is set, fep looks at the tty mode of the
     sub-command and fixes the tty mode of standard in accord-
     ingly.  This fix is done 0.5, 1, 5, 10, 60 seconds after the
     last input, so if you enter cbreak mode plase wait just one
     second.  Then you can use vi(1) or any other tool using the
     cbreak or raw mode.

OTHERS
     Fep can bandle SHIFT-JIS kanji code if compiled with the
     -DKANJI flag.

SEE ALSO
     newcsh(1)

AUTHOR
     K. Utashiro
     Software Research Associates, Inc., Japan.
          UUCP:   kddlab!srava.sra.junet!utashiro
          ARPA:   utashiro%sra.junet at uunet.uu.net
          JUNET:  utashiro at sra.junet

FILES
     ~/.feprc, ./.feprc      start-up file
     ~/.fephistory           default history file

BUGS
     While working on the program the author sometimes lost his
     mind, whereupon so did the program.



More information about the Comp.unix.wizards mailing list