\chapter{Editor}

\label{chap:edit}
\index{editor}
\section{Basics}
	The editor integrated into Splot is a fully featured editor that is 
also available as a separate product. The editor is modeled after the E PC 
editor. This editor is however a functional superset of E with many useful 
additional features. The OS/2 epm editor is another editor with the same 
ancestors. Users of E or epm will quickly feel at home with this editor 
since operation is quite similar. 

	Highlights of this editor include unlimited undo of previous 
changes and corresponding step for step redo. Column editing features to 
allow movement of columns of text (allows easy change of indentation). 
Bracket matching of all sorts of brackets and C code comment delimiters. 
There is limited folding which displays either; only the lines starting in the 
first column to quickly locate the start of functions, only the changed 
lines or only the lines containing the search string. Furthermore, a whole 
ring of files can be loaded up at once allowing 
painless copying of text between files. One particularly nice feature is 
the ability to load up a set of files in a ring and rapidly cycle through 
them using then ctrl N and ctrl P key combinations. Text can be copied 
between these files by using the block and line mark commands. There are 
all also some features to facilitate carrying out complex repetitive 
editing tasks. In particular sequences of key strokes can be saved and 
assigned to a function key for subsequent reuse. Furthermore, any command 
including function key macros can be repeated a number of times 
automatically by entering a command multiplier. The editor is completely 
key configurable. A set of keystrokes can be mapped to an editor function 
simply by specifying the sequence in the auxiliary key map file. The 
combination of key mapping and key macros allow the editor to imitate the 
user interface of other editors or allow the construction of a custom user 
interface to the taste of the user. 

	The editor is extremely easy to use and largely self explanatory. 
Text is input by straight typing anywhere on the screen. Cursor movement is 
controlled by the arrow keys and auxiliary keypad keys as per their 
standard definitions as well as accelerated movement with CTRL 
combinations. The cursor position control keys are as 
follows:\index{cursor positioning} 


\begin{tabbing} 
\=~~~~~~~~~~~~~~~~~~~~~~~~\= \\
\>   Cursor Motion Keys \> \\                        \\
\>  \> \\                                            \\
\> left arrow  \>  left one space                    \\
\> right arrow \>  right one space                   \\
\> up arrow    \>  up one line                       \\
\> down arrow  \>  down one line                     \\
\> end         \>  end of line                       \\
\> home        \>  beginning of line                 \\
\> PgDn        \>  scroll down one screen            \\
\> PgUp        \>  scroll up one screen              \\
\> Center Key  \>  fast motion toggle                \\
\> CTRL left   \>  left one word                     \\
\> CTRL right  \>  right one word                    \\
\> CTRL up     \>  scroll up five lines              \\
\> CTRL down   \>  scroll down five lines            \\
\> CTRL end    \>  end of file                       \\
\> CTRL PgDn   \>  end of file                       \\
\> CTRL home   \>  beginning of file                 \\
\> CTRL PgUp   \>  beginning of file                 \\
\>             \>                                    \\
\end{tabbing}
\index{editor, control keys}
\begin{tabbing} 
\=~~~~~~~~~~~~~~~~~~~~~~~~\= \\
\>   Editor Control Keys  \>         \\
\>  \>                                               \\
\> CTRL A \>  set place mark                         \\
\> CTRL B \>  bracket match \{, (, [, $<$, or /*     \\
\> CTRL C \>  change case                            \\
\> CTRL D \>  delete character                       \\
\> DEL    \>  delete character                       \\
\> CTRL E \>  delete to end of line                  \\
\> CTRL F \>  find next occur of search string       \\
\> CTRL G \>  go. Execute code                       \\
\> CTRL H \>  destructive backspace                  \\
\> CTRL I \>  tab                                    \\
\> CTRL J \>  join next line to current line         \\
\> CTRL K \>  cut current line at cursor             \\
\> CTRL L \>  return to previous set place mark      \\
\> CTRL M \>  insert new line                        \\
\> CTRL N \>  edit next file in ring                 \\
\> CTRL P \>  edit previ ous file in ring             \\
\> CTRL Q \>  quit without saving file               \\
\> CTRL R \>  redo previous undo                     \\
\> CTRL S \>  swap current and next character        \\
\> CTRL T \>  toggle insert/replace                  \\
\> CTRL 0 \>  toggle insert/replace                  \\
\> CTRL U \>  undo changes to last line              \\
\> CTRL V \>  toggle view function mode              \\
\> CTRL W \>  write file to disk                     \\
\> CTRL X \>  delete line                            \\
\> CTRL BACK \> delete line                          \\
\> CTRL Z \>  zap word                               \\
\> CTRL DEL \>zap word                               \\
\> ALT A  \>  alternate binary representation        \\
\> ALT E  \>  execute last macro                     \\
\> ALT I  \>  insert coordinates                     \\
\> ALT J  \>  join next line to current line         \\
\> ALT K  \>  enter next char literally              \\
\> ALT P  \>  position curs at prev location         \\
\> ALT Q  \>  restore a line from undo record        \\
\> ALT R  \>  re flow paragraph                      \\
\> ALT S  \>  split line at cursor                   \\
\> ALT T  \>  teach new macro                        \\
\> ALT V  \>  view only changed lines                \\
\> ALT W  \>  view lines containing search string    \\
\> ALT X  \>  enter control character                \\
\> ALT Z  \>  zero command multiplier                \\
\> ALT 0-9\>  enter command multiplier               \\
\>        \>                                         \\
\end{tabbing}

	The ALT P command is useful if the cursor was accidentally moved 
away from the region of interest with a CTRL Home or search for example. In 
these situations ALT P will restore the cursor to its previous location. 
This action is similar to using place marks except that unlike 
place marks these are automatically set by any command that causes the 
cursor to jump by more than one line. Only one previous location is 
remembered though. 

\section{Block manipulations}

	Block mark and line mark are somewhat different. Use line mark 
for\index{editor, block mark} moving, copying or deleting one or more whole 
lines and block mark for moving, copying, deleting, filling or overlaying 
columns of text. Note also that a block marked region can also be moved to 
the left with ctrl~$\wedge$ and to the right with ctrl~\_ but the behaviour 
is different than if the ALT arrow keys are used. ALT left and ALT right 
(or ctrl~\_ and ctrl~$\wedge$ ) are meaningless for line marked regions. 


\begin{tabbing} 
\=~~~~~~~~~~~~~~~~~~~~~~~~\= \\
\>     Block Manipulation Keys \>                    \\
\>        \>                                         \\
\> ALT B  \>  mark column block start, end           \\
\> ALT C  \>  copy marked block                      \\
\> ALT D  \>  delete marked block                    \\
\> ALT F  \>  fill B marked block with char          \\
\> ALT L  \>  mark LINE(s) start, end                \\
\> ALT M  \>  move marked block                      \\
\> ALT O  \>  overlay B marked block                 \\
\> ALT U  \>  unmark block                           \\
\> ALT Y  \>  yank back deleted block                \\
\> CTRL\_  \>  shift B marked block right             \\
\> CTRL$\wedge$  \>  shift B marked block left              \\
\>        \>                                         \\
\end{tabbing} 

\section{Macros}

	There is also a macro\index{editor, macros} capability for 
repetitive, complex editing tasks. The editor is taught a macro by hitting 
the ALT T combination. After this all subsequent keystrokes are stored as 
the macro definition until ALT T is hit again. There is a 128 keystroke 
limit on the length of a macro. A macro can consist of any keystrokes 
except ALT T and ALT E. At the end of the macro definition the macro can be 
bound to a function key by hitting the desired function key. Available 
function keys are F1 - F12 as well as shift F1 - F12. A bound macro is 
subsequently executed by hitting that function key. The predefined macro 
for that key will of course be lost. The last learned macro whether bound 
or unbound can be executed by hitting ALT E. If the macro involves a search 
and another item is not found the rest of the macro is not executed. If 
macros have been bound to function keys they will be written to the configuration file 
splot.cfg which will be created in the current directory so that the macros will 
 be preserved in between editing sessions. 

	A repeat factor for a keystroke can also be entered by prefixing 
the command with a multiplier which is input using the ALT number keys. The 
multiplier can be reset to zero during input using ALT Z. This feature 
also facilitates repetitive editing as an operation can be repeated several 
times. This is particularly powerful in conjunction with macros. 


\section{Command Line}
	Lastly, there are a small number of commands which require typed 
input on the command line\index{editor, command line}. The command line is 
reached by hitting ESC. This places the cursor at the beginning of the 
command line which is on the last row and ordinarily displays some status 
information. After ESC however text can be input here for the following 
functions: 

\begin{tabbing} 
\=~~~~~~~~~~~~~~~~~~~~~~~~\= \\
\>  Command Line Operations (requires   \>           \\
\>  text input so terminate line with a \>           \\
\>  return)  \>                                      \\
\>        \>                                         \\
\>  esc   \>        goto or leave command line       \\
\>        \>                                         \\
\>        \>Change current line                      \\
\> number \>     goto line number n                  \\
\> +number \>    down n lines                        \\
\> -number \>    up n lines                          \\
\>         \>                                        \\
\>        Change current column offset \>            \\
\> @number \>    start at column n                   \\
\> @+number\>    scroll left n columns               \\
\> @-number\>    scroll right n columns              \\
\>         \>                                        \\
\>        Search and Replace. \>                     \\
\>  find string str (/ actually any punct) \>        \\
\> /str[/-bclr] return \>                           \\
\>  replace str1 with str2 \>                        \\
\> c/str1/str2[/-bcl] return\>                       \\
\>         \>                                        \\
\>        The optional search suffixes are \>        \\
\> /-      \>    search up (down is default)         \\
\> /b      \>    search marked block only            \\
\> /c      \>    ignore case                         \\
\> /l      \>    loop through all files              \\
\> /r      \>    interpret as regular expression            \\
\>         \>                                        \\
\> For regular exp the following symbols \>          \\
\> have special meaning                  \>          \\
\> $\wedge$ start of line                       \>          \\
\> \$ end of line                         \>          \\
\> . any character                       \>          \\
\> \ quote next character                \>          \\
\> * match zero or more times            \>          \\
\> + match one or more times             \>          \\
\> [aei0-9] \>  match a,e,i and 0 through 9          \\
\> [$\wedge$aei0-9]\>  match anything but a,e,i and 0 through 9 \\
\> (  )     \>  sub expression                       \\
\> a(ab)*b  \>  matches ab aabb aababb aabababb etc. \\
\>          \>                                       \\
\>        Add other files to ring \>                 \\
\> e name1,name2,...[-r]            \>               \\
\>        The optional edit suffixes are \>          \\
\> -r     \>     read only                           \\
\>          \>                                       \\
\>  display directory and choose one to edit \>      \\
\>       \> e [*.*]                                  \\
\>  activate this help file                  \>      \\
\>       \> ?                                        \\
\>  insert named file at current location    \>      \\
\>       \> m name                                   \\
\>  rename current file to name              \>      \\
\>       \> r name                                   \\
\>  show and modify editor configuration  \>         \\
\>       \> configure                                \\
\>  exit without saving changes   \>                 \\
\>       \> quit                                     \\
\>  previous command line entered   \>               \\
\>       \> up arrow                                 \\
\>  next command line entered       \>               \\
\>       \> down arrow                               \\
\>  send command to operating system \>              \\
\>       \> os command                               \\
\>    also any unrecognized string   \>              \\      
\>                                  \>               \\
\end{tabbing}

\newpage
\section{configuration file}\label{sec:config}
 The startup file splot.cfg preserves the values selected
 from the configuration menu item between sessions. You can
 have multiple splot.cfg files in different directories since
 the current directory is searched before using the default 
 splot.cfg stored in the same directory as the executable. The 
 splot.cfg file is plain ASCII and can thus be edited with a text 
 editor as an alternative means of changing the settings or the 
 macro definitions. In particular, to change the text string 
 inserted in the text by chosing a draw menu item the splot.cfg 
 defined function macros should be edited.

 The macros are defined in plain text and thus in order to accommodate
 control and cursor keys as well each macro keystroke is defined by a pair 
 of letters using the following scheme.
 Starting in the first column of a definition must appear the key word 
 or function key identifying the macro. This is followed by the macro  
 body. Function keys may not appear in macro bodies.
 Keystroke and are encoded as follows with implied sequences in ASCII order. 

\begin{tabbing} 
\=~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\=~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\=\\

\> Ordinary characters       \>   prepend with \_  \>                                      \\
\> Control Keys              \>   prepend with $\wedge$  \>     $\wedge$M Return, $\wedge$[ esc  \\
\> Alt Keys                  \>   prepend with \%  \>                                      \\
\> Cursor keys               \>   prepend with \#  \>     \#. Del, \#0 Ins - \#9 PgUp      \\
\> Ctrl Cursor Keys          \>   prepend with \#  \>     \#N Del, \#P Ins - \#Y PgUp      \\
\> Alt Cursor Keys           \>   prepend with \#  \>     \#n Del, \#p Ins - \#y PgUp      \\
\> Function Keys             \>   prepend with \$  \>     \$1 - \$$<$                      \\
\> Shift Function Keys       \>   prepend with \$  \>     \$= - \$H                        \\
\end{tabbing}
