



















                                     EDT

                                   A Small

                               General Purpose

                                 Text Editor















                      Copyright 1983-2008 Dave Dunfield
                             All rights Reserved



                               EDT Text Editor

                              TABLE OF CONTENTS


                                                                        Page

    1. Introduction                                                        1


    2. Line mode operation                                                 2

       2.1 Line ranges                                                     2
       2.2 Line mode commands                                              3

    3. Visual mode operation                                               7

       3.1 Entering text                                                   7
       3.2 Positioning the cursor                                          7
       3.3 Visual mode function keys                                       8

    4. Additional Information                                             11

       4.1 History                                                        11
       4.2 Source code                                                    12
       4.3 *nix Notes                                                     14
   EDT Text Editor                                                  Page: 1


   1. Introduction

      EDT is a small  and  simple  text  editor,  suitable  for  entry  and
      modification of any ASCII  source  file.  It  operates  in  either  a
      line-by-line,  or a visual  (what you see is  what  you  get)  screen
      format.

      EDT is invoked with the command 'EDT  <filename>'.  If the named file
      already exists, EDT will load and edit it,  otherwise a blank file is
      presented. The following command line options may also be specified:

           -V          = inhibit Visual mode (start in line-by-line)
           B=size      = preallocate edit buffer of sizeK.
           C=command   = auto-execute Command at beginning
           H=height    = set Height (in lines) of screen           [25]
           W=width     = set Width (in columns) of screen          [80]

      The C=command option is most commonly used to position the editor  to
      a a line,  for example,  to start the editor with the cursor at  line
      100, use: EDT myfile C=100

      The B=, H= and W= options are only available on the *nix editor.  The
      DOS editor assumes a 50k buffer and a 24x80 screen.

      If no B= option is given, the *nix editor allocates an edit buffer of
      (size_of_file+32k) or 64k whichever is larger.

               eg:     edt thefile.dat         <- Visual mode
                       edt myfile.dat -v       <- Line by Line

      Dunfield Development Services  (DDS)  offers  software  and  firmware
      development   services   specializing   in   systems   and   embedded
      applications. For more information, visit: http://www.dunfield.com
   EDT Text Editor                                                  Page: 2


   2. Line mode operation

      2.1 Line ranges

         Most  commands  accept  a  "line-range"  which  is   an   optional
         specification controlling the range of lines for which the command
         has  effect.  Unless  otherwise  stated,  the  default  line-range
         assumed for each command is the "current" line (*).

         The "current"  line is the line at which EDT is positioned in line
         by line mode,  and is  also  the  line  on  which  the  cursor  is
         positioned in visual mode.

         The following are the valid line range formats:

                  *        - The "current" line
                  /        - The entire file
                  =        - The tagged lines
                  0        - The end of the file
                  <n>      - Line number <n>, (<n> >= 1)
                  <r>,<r>  - Range between beginning of two other ranges.

         The  '+'  and  '-'  characters may be used to add  or  subtract  a
         constant value from a line range.

                   eg: '0-12' <- 12 lines from end of file

         If '+'  or '-'  is used but no range is specified,  an offset from
         the current line is assumed.

                 eg: '+12' <- 12 lines from the current line.

         The line range specification is entered immediately preceding  the
         command name.

                        ie: '<r><command> <operands>'
   EDT Text Editor                                                  Page: 3


      2.2 Line mode commands

         C - Copy lines

            The  'C'opy command performs a copy  of  the  active  range  of
            lines, placing the copy directly ahead of the current line.

            Examples:

                   C               - Duplicate current line
                   1,10C           - Copy lines 1 to 10 inclusive
                   =C              - Copy tagged lines
                   /C              - Duplicate entire file (must be at end)

         D - Delete lines

            The 'D'elete command deletes the active range of lines.

            Examples:

                   D               - Delete current line
                   -5,+5D          - Delete 11 lines -5 to +5 from current
                   /D              - Delete entire file

         F - File information

            This command displays information about the file being  edited,
            includes the filename,  the size  of  the  file  in  lines  and
            characters,  and the size and position of  the  specified  line
            range.

            Examples:

                   F               - Display file & current line information
                   =F              - Display file & tagged lines information

         H - Display help screen

            Displays a brief summary of commands and options.

         <n>H - Set horizontal tab spacing

            This command sets the display spacing of horizontal tabs to the
            value specified (by the preceding number).

         I - Insert new text

            The  'I'nsert command prompts for  'Input:',  and  inserts  all
            lines typed directly ahead of the active range.  Enter  a  null
            line to exit.

            Examples:

                   I               - Insert ahead of current line
                   /I              - Insert at start of file
                   0I              - Insert at end of file
   EDT Text Editor                                                  Page: 4


         L - List text in simple form

            The  'L'ist command displays the active  range  of  lines.  The
            display does not include line numbers or special indications.

            Examples:

                   L               - List current line
                   /L              - List entire file
                   -10,+10L        - List 21 lines, centered on current

         M - Move lines

            The  'M'ove command moves the active  range  of  lines  to  the
            location directly ahead of the current line.

            Examples:

                   =M              - Move tagged lines
                   +1M             - Interchange active & next line

         P - Print text (Enhanced 'L'ist)

            The  'P'rint command displays the active range of  lines.  This
            display includes the line number which may  be  preceded  by  a
            special indication flag  ('*' for current line,  '=' for tagged
            lines).

            Examples:

                   P               - Display current line
                   /P              - Display entire file

         Q - Quit (exit) editor

            The  'Q'uit command exits the editor.  This  command  will  not
            allow an exit if unsaved changes are present in the file.

            Examples:

                   Q               - Quit editor

         QQ - Unconditional 'Q'uit

            The 'QQ'uit command exits the editor unconditionally.

            Examples:

                   QQ              - Quit unconditionally.
   EDT Text Editor                                                  Page: 5


         R<filename> - Read file

            The  'R'ead command reads the entire contents of the  specified
            file, and inserts it directly ahead of the active range.

            Examples:

                   Rabc            - Insert file 'abc' at current
                   /Rabc           - Insert file 'abc' at start
                   0Rabc           - Append file 'abc' at end

         S<dc><search><dc><replace> - Substitute

            The  'S'ubstitute command searches the active range  of  lines,
            and replaces all occurrences of the string  <search>  with  the
            string  <replace>.  The  <dc>  delimiter character may  be  any
            character not contained within the <search> string.

            Examples:

                   S'abc'def       - Change 'abc' to 'def' in current
                   /S"abc"def      - Change 'abc' to 'def' in entire file
                   =S/abc/def      - Change 'abc' to 'def' in tagged lines

         T - Tag lines

            The 'T'ag command tags the active range of lines, allowing them
            to be referred to by '=' in a subsequent command range.

            Examples:

                   T               - Tag current line
                   1,10T           - Tag lines 1 to 10
                   *,+5T           - Tag six lines starting at current

         V - Switch Visual Mode

            The 'V' command causes EDT to switch visual modes.  This enters
            visual mode if EDT was previously in line  by  line  mode,  and
            enters line by line mode if previously in visual mode.

            Examples:

                   V               - Switch visual modes
   EDT Text Editor                                                  Page: 6


         W[filename] - Write to file

            The  'W'  command writes the active range of lines to the named
            file,  or to the original file edited if no name is  specified.
            Use of this command also resets the FILE CHANGED flag, allowing
            exit via 'q'.

            The default line range assumed for 'W'rite is the entire file.

            Examples:

                   W               - Write entire file
                   *W              - Write current line
                   Wabc            - Write entire file to 'abc'
                   =Wabc           - Write tagged lines to 'abc'

         X[filename] - Write file and eXit

            This command behaves exactly as the  'W'rite command,  followed
            immediately by a 'Q'uit command. It provides a shorthand way of
            saving your file and leaving the editor.

            Examples:

                   X               - Write file & exit
                   Xabc            - Write to 'abc' and exit

         ?<text> - Search for text

            The  '?'  command moves the active line to the first occurrence
            of the specified string within the active range.

            The default range assumed for  '?'  is one character  past  the
            current cursor position (in visual mode) or the first character
            of the active line  (In line by line mode),  through to the end
            of the file.

            Examples:

                   ?string         - Find next occurrence of "string"
                   /?string        - Find first occurrence of "string"

         $<command> - Execute system command

            The '$' command executes the specified system command.

            Examples:

                   $               - Invoke shell
                   $dir            - Execute 'dir' command
   EDT Text Editor                                                  Page: 7


         <no command> - Goto line

            If a line range is given without a command, EDT will reposition
            the "current" line to the beginning of that range.

            Examples:

                   100             - Move to line 100
                   /               - Move to start of file
                   0               - Move to end of file
                   =               - Move to tagged line(s)

   3. Visual mode operation

      When in VISUAL mode,  EDT presents a window on  the  terminal  screen
      which displays the contents of a section of the file.  Editing of the
      file may be performed directly on the  screen  via  special  function
      keys,  and the screen is updated so that you see your changes as they
      are being performed.

      Any control characters which exist in the file will be  displayed  as
      the corresponding printable character in reverse video.

      If the end of the file is within the area shown on  the  screen,  the
      message '*EOF*' is displayed in reverse video.

      3.1 Entering text

         Text may be entered into the file being edited,  simply by  typing
         it at the terminal keyboard.  EDT automatically places the text in
         the file, and updates the screen to reflect the new contents.  The
         position of the terminal cursor indicates the  position  at  which
         the text will be entered.

      3.2 Positioning the cursor

         The arrow keys on the terminal may be  used  to  move  the  cursor
         around the displayed image. Moving beyond the bottom of the screen
         causes EDT to scroll forward one line,  and shift the  screen  up.
         Moving beyond the top of the screen causes EDT to scroll  backward
         one half screen, and redisplay the text.

         EDT will perform sideways scrolling of the display  to  allow  the
         cursor to access the entire width of lines which are  larger  than
         80 columns.
   EDT Text Editor                                                  Page: 8


      3.3 Visual mode function keys

         The following keys on the IBM PC keyboard have special meaning  to
         EDT:

         **NOTE** These key descriptions assume the  DOS  key  assignments.
         There are some differences in  the  keys  available  on  the  *nix
         keyboards. Please refer to "*nix Notes" later in this document.

         Right arrow

            Moves the cursor forward one character position in the file, if
            at the end of a line,  the cursor will  advance  to  the  first
            position of the next line.

         Left arrow

            Moves the cursor backward one character position in  the  file,
            if at the beginning of a line,  the cursor will backup  to  the
            last position of the previous line.

         Up arrow

            Moves the cursor up one line.  If at the top of the screen, the
            display will scroll backward by one half a screen page.

         Down arrow

            Moves the cursor down one line. If at the bottom of the screen,
            the display will scroll forward by one line.

            The cursor may appear to jump back and forth as it is moved  up
            and down,  if it encounters lines which are  shorter  than  the
            current character position within  the  line,  or  lines  which
            contain tabs.  This is because whenever possible, the cursor is
            returned to the same number of  physical  characters  from  the
            start of the line as is was on the first line from which the UP
            or DOWN arrow was pressed.

         Page up

            This key pages backward one screen. (Top line becomes bottom)

         Page down

            This key pages forward one screen. (Bottom line becomes top)

         Home

            Moves the cursor to the beginning of the line. If it is already
            at the beginning of a line, it is moved to the beginning of the
            previous line.
   EDT Text Editor                                                  Page: 9


         End

            Moves the cursor to the end of the line.  If already at the end
            of a line, it is moved to the end of the next line.

         CTRL-PgUp

            This key moves the cursor to the beginning of the first line in
            the file.

         CTRL-PgDn

            This key moves the cursor to the end of the file.

         CTRL-Right Arrow

            Moves the cursor to the beginning of the next word.

         CTRL-Left Arrow

            Moves the cursor to the beginning of the previous word.

         Ins

            Toggles between character INSERT and OVERWRITE mode.  In INSERT
            mode,  all characters typed at the terminal are  inserted  into
            the text.  In OVERWRITE mode,  only the NEWLINE  character  and
            data entered at the end  of  a  line  is  inserted,  all  other
            characters will overwrite the existing text.

         Delete

            Deletes the character under  the  cursor,  without  moving  the
            cursor.

         Backspace

            Moves the cursor  backward  to  the  previous  character,  then
            deletes that character.

         F1

            Toggles ON/OFF the display of NEWLINE characters at the end  of
            each line of text.

         F2

            Displays the current cursor position,  including the actual and
            character offsets from the start of line.

         F3

            Brings the line the cursor is on to the top of the screen.
   EDT Text Editor                                                  Page: 10


         F4

            Tags one or more lines for a later operation.  The tagged lines
            are displayed in special video if  the  terminal  supports  it.
            Once one line is tagged,  pressing this  key  on  another  line
            causes all lines between them to be tagged.  Pressing it  again
            on the first line of the tagged range removes the tags.

         F5

            Deletes from the  cursor  position  to  the  end  of  the  line
            (inclusive).

         F6

            Deletes from the  cursor  position  to  the  end  of  the  line
            (exclusive).

         F7

            Inserts the deleted line text  (From Function key 8 or Function
            key 9) at the current cursor position.

         F8 or CTRL-Home

            Redraws the screen image of the file.  This is normally used in
            the case of the screen being  corrupted  by  data  transmission
            errors,  or asynchronous messages from the operating system  or
            its users.

         F10 or Keypad '+'

            Prompts for a line mode  command,  and  executes  it.  See  the
            section on line mode operation. Press F10 (or Keypad '+') again
            to execute the command.

         F9 or Keypad '-'

            Re-executes the last line mode command entered.
   EDT Text Editor                                                  Page: 11


   4. Additional Information

      4.1 History

         In the mid 1970s, I homebuilt my first 8080 based computer,  using
         tape storage.  At this time I wrote "EDIT",  a tiny editor in 8080
         assembly language which operated  line-by-line  using  hexidecimal
         line numbers with a maximum of 256 lines.

         Later I moved to an Altair 8800 with  64K  and  floppy  disks  and
         updated the editor to allow files up to the size  of  memory,  use
         decimal line numbers, and with additional edit commands.  Sometime
         later I added a rudimentary "visual" mode.

         Early 80s,  I began working on a VAX mainframe,  cross  developing
         for a 6809 based microcomputer.  At  this  time  I  transcoded  my
         editor into 6809 assembly language and  refined  the  visual  mode
         with influence from the main VAX editor which  was  called  "EDT".
         Although the official way to invoke EDT was the command  EDIT/EDT,
         like many VAX installations we had a local alias to a simple "EDT"
         - To make moving back and forth between the two systems easier,  I
         renamed my editor to "EDT" - same edit command in both places.

         Later I acquired my first home computer with a hard disk - a  Nabu
         1600 running the QNX operating system.  This machine  also  had  a
         pre-ANSI (K&R) C compiler.  Transcribing the 6809 assembly version
         into C resulted in the first "portable" version of my editor which
         became my main editor on the Nabu.

         Later I ported the C version to PC/DOS and *nix,  where I continue
         to use it as my primary editor to this day.  Although it is  small
         and simple,  it is sufficiently powerful for my needs,  and having
         the same editor on all the platforms where I work is makes  moving
         between them very easy.
   EDT Text Editor                                                  Page: 12


      4.2 Source code

         EDT was transcribed to C from 6809 assembly language in the  early
         80s using a non-ANSI (K&R)  compiler.  It was also one of my first
         'C' projects, and is therefore not code I'm particularily proud of
         - it has however proven to be a very reliable editor,  and I  have
         resisted the urge to "fix" it's appearance.

         I've  included  the  original  EDT.ASM  file  from  the  6809  for
         interests sake.  This assembles and runs under my CUBIX  system  -
         for more information on CUBIX and my homebuilt 6809 system, please
         visit my classic computer website: www.classiccmp.org/dunfield

         The DOS version of EDT was compiled  using  Borlands  TURBO-C  2.0
         compiler. Due to DOS not having a defined way to access the screen
         and keyboard other than as a  "dumb TTY",  I  have  also  included
         VIDEO.ASM,  a  set  of  functions  to  provide  "smart   terminal"
         capabilities.  To compile EDT under DOS,  make sure  the  "#define
         UNIX"  line near the beginning is removed or  commented  out,  and
         issue the command:

                           TCC -ms edt.c video.asm

         This will result in EDT.EXE, the DOS version of EDT.  NOTE: Due to
         it's origins as an  in-memory  editor,  and  DOS  being  a  16-bit
         environment,  the DOS version of EDT is limited to files of  about
         51k in size. To accomodate larger files, I have provided a utility
         called EB  (Edit Big)  - EB will automatically split larger  files
         into smaller files for editing, and recombine them afterward.

         The *nix version of EDT is compiled with gcc,  and should  compile
         on most unix/posix systems with little difficulty.  To compile EDT
         under *nix,  make sure the "#define UNIX"  line near the beginning
         is NOT commented out, and issue the command:

                               gcc edt.c -o edt
   EDT Text Editor                                                  Page: 13


         This will result in an executable file  'EDT'  which is  the  *nix
         version of EDT.  NOTE:  I tested  EDT  under  OS-X  (mac),  Fedora
         release 7,  Slackware 10 using the default gcc options -  if  your
         gcc has additional errors/warnings enabled  it  may  not  compile.
         Here is the verbose output of the two Linux compilers I used:

           ; Fedora release 7 (moonshine)
           # gcc -v
           Using built-in specs.
           Target: i386-redhat-linux
           Configured with: ../configure
            --prefix=/usr
            --mandir=/usr/share/man
            --infodir=/usr/share/info
            --enable-shared
            --enable-threads=posix
            --enable-checking=release
            --with-system-zlib
            --enable-__cxa_atexit
            --disable-libunwind-exceptions
            --enable-languages=c,c++,objc,obj-c++,java,fortran,ada
            --enable-java-awt=gtk
            --disable-dssi
            --enable-plugin
            --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
            --enable-libgcj-multifile
            --enable-java-maintainer-mode
            --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
            --with-cpu=generic
            --host=i386-redhat-linux
           Thread model: posix
           gcc version 4.1.2 20070502 (Red Hat 4.1.2-12)

           ; Slackware 10
           # gcc -v
           Reading specs from /usr/lib/gcc/i486-slackware-linux/3.4.6/specs
           Configured with: ../gcc-3.4.6/configure
            --prefix=/usr
            --enable-shared
            --enable-threads=posix
            --enable-__cxa_atexit
            --disable-checking
            --with-gnu-ld
            --verbose
            --target=i486-slackware-linux
            --host=i486-slackware-linux
           Thread model: posix
           gcc version 3.4.6
   EDT Text Editor                                                  Page: 14


      4.3 *nix Notes

         The *nix version of EDT relies on the ANSI/VT-100 compatibility of
         the console  for  cursor  positioning,  character  attributes  and
         keycode detection.  There are slight differences  in  the  keycode
         reporting under various versions of *nix consoles  -  the  ones  I
         most often use are OS-X (mac), "Fedora 7" and "Slackware 10".

         Under *nix,  most  "special"  keys  are  reported  as  proprietary
         ANSI-like sequences, however some key combinations used in the DOS
         version of EDT are not available,  and some of the  key  sequences
         differ between the versions of *nix that  I  use,  and  also  when
         operating in a terminal under X-windows.

         The following table depicts the keys used by EDT,  and the keycode
         values are are returned by the various *nix systems when each  key
         is pressed. Note: 'e' refers to the ESCAPE (0x1B) character:

       Key        Fedora        Slackware        X-win         OS-X
       ---------------------------------------------------------------
       BkSp        0x7F            0x7F          0x7F/^H       0x7F
       Up          e[A             e[A             e[A         e[A
       Down        e[B             e[B             e[B         e[B
       Right       e[C             e[C             e[C         e[C
       Left        e[D             e[D             e[D         e[D
       Home        e[1~            e[1~            e[H         e[H *1
       Insert      e[2~            e[2~            e[2~        n/a
       Delete      e[3~            e[3~            e[3~        e[3~
       End         e[4~            e[4~            e[F         e[F *1
       PgUp        e[5~            e[5~            e[5~        e[5 *1
       PgDn        e[6~            e[6~            e[6~        e[6 *1
       F1          e[[A            e[[A            eOP         eOP
       F2          e[[B            e[[B            eOQ         eOQ
       F3          e[[C            e[[C            eOR         eOR
       F4          e[[D            e[[D            eOS         eOS
       F5          e[[E            e[[E            e[15~       e[15~
       F6          e[17~           e[17~           e[17~       e[17~
       F7          e[18~           e[18~           e[18~       e[18~
       F8          e[19~           e[19~           e[19~       e[19~
       F9          e[20~           e[20~           e[20~       e[20~ *2
       F10         e[21~           e[21~           e[21~       e[21~ *2
       F11         e[23~           e[23~           e[23~       e[23~ *2
       F12         e[24~           e[24~           e[24~       e[24~ *2
       shift-F1    e[25~           e[23~           eO2P
       shift-F2    e[26~           e[24~           eO2Q
       shift-F3    e[28~           e[25~           eO2R
       shift-F4    e[29~           e[26~           eO2S
       shift-Tab                                               e[Z
       ctrl-Left                                               e[5D
       ctrl-Right                                              e[5C

       *1  Default mapping of OS-X terminal as these functions on shift
           of Home/End/PgUp/PgDn (unshifted perform terminal scrolling).

       *2  You may have to disable function keys in "expose" to obtain
           access to them under OS-X.
   EDT Text Editor                                                  Page: 15


         As a result of these differences in reported  keycodes,  the  keys
         used under *nix differ slightly from  the  DOS/windows  keys,  and
         also from one version of *nix to another.

         The following table depicts the keys used under my *nix systems to
         activate each EDT function:

       Function        DOS       Fedora     Slackware    X-win        OS-X
       -------------------------------------------------------------------
       Delete char     DEL         DEL         DEL         DEL         DEL
       Delete prev.    BS          BS          BS          BS          BS
       Toggle insert   INS         INS         INS         INS         sTab
       Page Fwd        PgDn        PgDn        PgDn        PgUp        PgUp
       Page Back       PgUp        PgUp        PgUp        PgUp        PgDn
       Start of file   ^PgUp       F11         F11/sF1     F11         F11
       End of file     ^PgDn       F12         F12/sF2     F12         F12
       Start of line   Home        Home        Home        Home        Home
       End of line     End         End         End         End         End
       EOL display     F1          F1          F1          F1          F1
       Cursor report   F2          F2          F2          F2          F2
       Current->top    F3          F3          F3          F3          F3
       Tag line(s)     F4          F4          F4          F4          F4
       Delete line     F5          F5          F5          F5          F5
       Delete to end   F6          F6          F6          F6          F6
       Insert deleted  F7          F7          F7          F7          F7
       Redraw screen   F8/^Ho      F8          F8          F8          F8
       Re-command      F9/Kp-      F9          F9          F9          F9
       Command         F10/Kp+     F10         F10         F10         F10
       Word left       ^Left       sF1/sF3     sF3         sF1/sF3     ^Left
       Word right      ^Right      sF2/sF4     sF4         sF2/sF4     ^Right

         Other *nix systems  may  use  yet-different  key  sequences  -  If
         necessary,  you can modify the v_getc()  function near the end  of
         EDT.C to accomodate the key sequences used on your system.  I have
         provided a small utility "showkey.c"  which you can use to see the
         sequences generated by each key.
