Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-05 - decus/20-0145/ve.ae
There is 1 other file named ve.ae in the archive. Click here to see a list.
!	VE is an ANTE macro that supports simple two-dimensional editing.
VE fundamentally does no more than execute common ANTE commands while
maintaining a correct image of the edited text.
	Unlike some other video editors, VE is normally in command mode rather
than insert or replace mode -- commands are normal characters and inserts are
ended with escapes.  VE is thus of the serial keystroke (as opposed to parallel
keystroke) school.  It is meant for people who prefer hitting a few keys in a
row rather than a few keys all at once.

  ANTE commands that are unchanged in VE
	+-c
	+-d
	i...
	+-k
	0k
	:k
	+-n
	+-o
	+-r...
	+-s...
	#v (if an argument is given it becomes the default window size)
	#<backspace> (-l) (takes a numeric argument)
	#<linefeed> (l) (takes a numeric argument)
	#<control-l> (-n) (takes a numeric argument)
	#<control-n> (n) (takes a numeric argument)
  ANTE commands that are modified in VE
	g	get text saved by p and x
	m...	execute string as a macro
	p	save text last deleted, adding to other saved text
	q	jump to saved .
	t	redisplay current line
	u	save .
	x	save text last deleted, replacing other saved text
	[	0l
	]	:l
	\	0j and v
	/	zj and v
  display commands
	+-w	adjust window up/down without moving cursor
	#<	-(5)l and v
	#>	(5)l and v
	#~	move backward in window lengths, and v
	#+	move forward in window lengths, and v
  other commands
	a...	0li<cr><lf>$-li...
	#b	-c
	e	exit from VE
	+-f	execute last r or s command again
	y	delete text from saved . to current .
	'	delete, X, G (a prefix to deletion commands)
  notes
	commands may be in either upper or lower case
	+- indicates a positive or negative numeric argument
	# indicates a positive numeric argument
	... indicates a string argument
	After the macro given to the M command is executed, VE pauses to allow
	 inspection of possible output.  VE continues after any character is
	 typed.  If a space is typed VE will attempt to return to the old
	 window; otherwise VE will execute a v command.
	The <control-p> switch is used in input mode to switch back and forth
	 between regular input and prose input.


	The VE macro is divided up into five main parts.  The main loop,
occupying a qreg chosen by the user, inputs commands and dispatches to the
appropriate command macro.  The command macros reside in four qregs.
V contains the display macro (T, V, W), J contains the movement macro
(B, C, H, J, L, N), I contains the text input macro (used by A, I, M, R, S),
and C contains all other commands.  V is referenced by C, I, and J;  I and J
are referenced by C.  There are no interdependencies between commands other
than these, except for R, which uses D and G in turn.
	The major reason for VEs relative simplicity is in its not keeping
track of the contents of the screen (how many and which lines are displayed,
where the cursor is).  When it needs such knowledge it uses the read XY feature
of the terminal to determine the cursor position and assumes a full screen of
text (M, R-S, ~, +, display macro).

  storage usage
	c value -- command character
	c text -- main command macro
	d value -- deletion flag (for ' and replace-add)
	d text -- text deleted with the last deletion sequence
	g value -- u-saved position
	g text -- p-x-saved deleted text
	i value -- i macro temporary
	i text -- input macro
	j value -- i macro temporary
	j text -- movement macro
	k value -- i macro temporary
	k text -- batch input text
	n value -- numeric argument to command
	r value -- regular/prose input flag
	r text -- replace string
	s value -- last r/s command
	s text -- search string
	u value -- saved argument to j and v macros
	u text -- text deleted with the last deletion command
	v value -- window size
	v text -- diplay macro
	w value -- window offset
	9, 8, 7 -- general temporaries
  Teleray controls output by VE
	$A		cursor up
	$B		cursor down
	$H		home up
	$J		clear eop
	$K		clear eol
	$L		insert line
	$M		delete line
	$P		insert char
	$Q		delete char
	$R		set text mode
	$Y		set X Y
	$a		read X Y
  prune macro -- the next 5 lines produce a compressed VE
    j a9 hk 033fi fa < /s/!/ .-1u9 @s9 q9,.k > /fts/comments.../
    j a9 hk 015fi 012fi fa < @fd9 > /fts/lines.../
    j a9 hk 040fi 033fi fa a8 hk 0fi fa < @r98 > /fts/nullsin.../
    j a9 hk 040fi fa < @fd9 > /fts/spaces.../
    j a9 hk 040fi 033fi fa < @r89 > /fts/nullsout.../ 015fto 012fto

0fte 0ud 0ur 0us 012uv 0uw #Vuc 1un
!** commands ** ac hk /i^
    [
      [ !F and R and S [ qc-#Ffce qc-#Rfce qc-#Sfce 2fe ]
        a9 hk -1/fts/a/ /i/Y/ fti fi fti fi fa
        ! get arguments
        [ qc-#Rfcn -1/fts/Y3 J RDReplace R@/ 012fto 015fto
          as hx8 mi fa -1/fts/RDwith R@/ 012fto 015fto
          ar hk mi fa -1/fts/RD$ R@Y3 J/ ]
        [ qc-#Sfcn -1/fts/Y3 J RDSearch R@/ 012fto 015fto
          as hx8 mi fa -1/fts/RD$ R@Y3 J/ ]
        [ qc-#Ffcn [ qsfcn 07,-1fto 4fe ] qsuc ] qcus
        ! search
        [ .u9 1u7
          [ fzsfcn fz8,2fce fm8s ]
          qn@fns u7 ]
        ! position cursor
        [ q7fce [ .-q9fcn -1@fts9 ] [ .-q9fce 0mv ] 07,-1fto 3fe ]
        .u8 a9 0j 2c fo-037u7 fa q9j
        [ [ !backwards
            qnfcg -q7+1l q8-.fcl
            q9j -1@fts9
            0u7 q9-q8< -c [ fo-012fcn %7 ] >
            q7< -1/fts/A/ > 015fto 0t 2fe ]
          [ !forwards
            qnfcl 2,qvf*-1-q7l :l .-q8fcl
            q9j -1@fts9
            0u7 q8-q9< [ fo-012fcn %7 ] c >
            q7< -1/fts/B/ > 015fto 0t 2fe ]
          q8j 0mv ]
        qc-#S,2fce fzsun #Bmj ]
      [ !:K qc-#:fcn :xu -1/fts/K/ 2fe ]
      [ !A qc-#Afcn
        -1/fts/L/ 0l 015fi 015fto 012fi 012fto -l -1/fts/A/ #Iuc ]
      [ !D and O and R
        [ qc-#Dfce qc-#Ofce qc-#Rfce 2fe ]
        [ ! negative deletion -- move back and delete forward
          qnfcg -qnun
          [ qc-#Dfcn #Bmj ]
          [ qc-#Ofcn .u9 #Lmj #Duc q9-.un ] ]
        .u9
        [ [ qc-#Dfce qc-#Rfce 2fe ] qnc fo-012fcn -c fou8 c q8-015fcn c ]
        [ qc-#Ofcn qnn ]
        [ .u8 q9j :l
          [ .-q8+1fcg
            q8j < -1/fts/M/ -l .-q9-1fcl > q9j q9,q8xu #vmv 2fe ]
          [ .-q9< -c fo-011,2fce > q9,q8xu q8-q9<-1/fts/Q/> 2fe ]
          q9j q9,q8xu #vmv ]
        qc-#R,2fcn ]
      [ !G and R [ qc-#Gfce qc-#Rfce 2fe ]
        .u9
        [ qc-#Gfcn fzg,2fce gg ]
        [ qc-#Rfcn fzr,3fce gr ]
        .u8 q9j 0l .u9 0u7 q8-q9< [ fo-012fcn %7 ] c >
        [ q7-012fcg q7< -1/fts/L/ 044fu > 015fto q9,q8t #vmv 3fe ]
        0mv 2fe ]
      [ !I qc-#Ifcn
        [ z-.-010000fcg mi 3fe ]
        .u9 fkk 0fxk q9-.u9 fxk ak q9j mi
        .u9 fa q9+.u9 [ fzkfce gk ] q9j 2fe ]
      [ !K qc-#Kfcn
        fku
        [ ! negative deletion -- move back and delete forward
          qnfcg -qnun 0xu 015fto -1/fts/K/ :t 015fto -1%n qn,3fce #Hmj ]
        qn< fxu -1/fts/M/ 066fu > #vmv 2fe ]
      [ !M qc-#Mfcn
        a9 hk -1/fts/a/ /i/Y/ fti fi fti fi fa
        -1/fts/Y3 J RDMacro R@/ 012fto 015fto
        .u9 zu8 a8 hk < .u7 mi 033fi .-q7-1fce #$fto > fa -1/fts/RD$ R@/
        m8; ftiu7 -1/fts/Y3 J/
        [ ! use old display if . and z are unchanged and user confirms
          q9-.fcn q8-zfcn q7-040fcn -1@fts9 3fe ]
        0mv 2fe ]
      [ !P and X [ qc-#Pfce qc-#Xfce 2fe ]
        fzdfce ag [ qc-#Xfcn hk ] gd fa 2fe ]
      [ !Q qc-#Qfcn qgfce qgj 0mv 2fe ]
      [ !T qc-#Tfcn #vmv 2fe ]
      [ !U qc-#Ufcn .ug 2fe ]
      [ !V qc-#Vfcn [ qn-2fcl qnuv ] 0mv 2fe ]
      [ !W qc-#Wfcn qn+qwmv 2fe ]
      [ !Y qc-#Yfcn
        [ .-qgfcg .,qgxu ] [ qg-.fcg qg,.xu ] 0mv 2fe ]
      [ !< [ qc-#<fce qc-#,fce 2fe ] [ qn-1fcg 5un ] -qnl 0mv 2fe ]
      [ !> [ qc-#>fce qc-#.fce 2fe ] [ qn-1fcg 5un ] qnl 0mv 2fe ]
      [ !~ [ qc-#~fce qc-#`fce 2fe ]
        -2,qv-1f*u9 -1/fts/a/ fti-037u8 fti; q9-q8+qvl qn-1<q9l> 0mv 2fe ]
      [ !+ [ qc-#+fce qc-#=fce 2fe ]
        2,qv-1f*u9 -1/fts/a/ fti-037u8 fti; q9-q8+qvl qn-1<q9l> 0mv 2fe ]
      [ ![ [ qc-#[fce qc-#{fce 2fe ] 0l 015fto 2fe ]
      [ !] [ qc-#]fce qc-#}fce 2fe ] :l 015fto 0t 2fe ]
      [ !\ [ qc-#\fce qc-#|fce 2fe ] 0j 0mv 2fe ]
      [ !/ [ qc-#/fce qc-#?fce 2fe ] zj 0mv 2fe ]
      07,-1fto ]
^ fa
!** input ** ai hk /i^
    [ .ui 0uj :l .-qi< -c fo-011,2fce > 1uj ] 0l qi-.uk qij
    < ftiui qi-033,2fce
      [ [ ! prose input qrfce
          [ qi-040fcn qk,3fce [ qk-0100fcl 012ui ] 2fe ]
          [ [ qi-#,fce qi-#.fce 3fe ]
            [ qi-#,fcn qk-060fcg 3fe ]
            qifi -1/fts/P/ qifto 012ui ] ]
        [ !<A> and <H> and <rubout>
          [ qi-01fce qi-010fce qi-0177fce 2fe ]
          [ .fcn 07,-1fto 3fe ]
          -c foui c
          [ qi-012fcn -d -c foui c [ qi-015fcn -d ] -1/fts/AM/
            .ui 0l qi-.uk qij 022ui 2fe ]
          -d -1%k 015fto 0t
          [ [ qi-011fce qjfce 2fe ] :t -1/fts/K/ 015fto 0t 3fe ]
          -1/fts/Q/ 2fe ]
        [ !<P> qi-020fcn -1,qrf*ur qr+1ur 2fe ]
        [ !<R> qi-022fcn #vmv 2fe ]
        [ !<U> qi-025fcn 0l 015fto :k 0uk -1/fts/K/ 2fe ]
        [ !<V> qi-026fcn ftiui 1%k ]
        [ !<tab> qi-011fcn 011fi 1%k #vmv 2fe ]
        [ !<linefeed> qi-012fcn -1/fts/K/ 015fi 015fto 012fi 012fto 0uk
          -1/fts/L/ 011fto 015fto :t 015fto 2fe ]
        qi-015fce qifi 1%k
        [ ! tab in remainder of line requires redisplay of line
          qjfcn qifto :t 015fto 0t 2fe ]
        -1/fts/P/ qifto ] >
^ fa
!** movement ** aj hk /i^
 uu [
      [ !B and L
        [ qu-#Bfce qu-#Lfce 2fe ]
        .u9
        [ qu-#Bfcn -qnc fo-012fcn -c fo-015fce c ]
        [ qu-#Lfcn -qnn ]
        .u8 q9j 0u7 q9-q8< -c [ fo-012fcn %7 ] > q7< -1/fts/A/ >
        015fto 0t 2fe ]
      [ !C and N [ qu-#Cfce qu-#Nfce 2fe ]
        .u9
        [ qu-#Cfcn qnc fo-012fcn -c fou8 c q8-015fcn c ]
        [ qu-#Nfcn qnn ]
        q9,.t 2fe ]
      [ !H qu-#Hfcn qn< 0l .u9 -l [ q9-.fce -1/fts/A/ ] 015fto > 2fe ]
      [ !J qu-#Jfcn qn< :l .u9 l 015fto [ .-q9fce 012fto] > 2fe ]
    ]
^ fa
!** display ** av hk /i^
   uu [ qu-#vfce
        quuw [ qufcn [ .fcn qv-1uu ] [ z-.fcn -qvuu ] ]
        -1/fts/HJ/ zfce 011fto 015fto
        -qv+qu+1t a9 hk -1/fts/a/ /i/Y/ fti fi fti fi fa
        qv+qut -1/fts/RF/ -1@fts9 ]
      015fto 0t :t -1/fts/K/ 015fto 0t
^ fa
!** main loop **
  <
    [ ! command execution
      [ !B qc-#Bfcn #Bmj 2fe ]
      [ !C qc-#Cfcn #Cmj 2fe ]
      [ !E qc-#E,3fce ]
      [ !H qc-#Hfcn #Hmj 2fe ]
      [ !J qc-#Jfcn #Jmj 2fe ]
      [ !L qc-#Lfcn #Lmj 2fe ]
      [ !N qc-#Nfcn #Nmj 2fe ]
      mc ]
    ! deletion
    [ [ qc-#:fce qc-#Dfce qc-#Ofce qc-#Kfce qc-#Yfce 0ud 2fe ]
      [ ad [ qdfcl hk ] [ fzufce gu ] fa ]
      [ qdfce 2+qdfce qcud #Xuc mc #Guc mc qduc -1ud ]
      -2ud ]
    ! command input
    0un 0u9
    [ ftiuc
      [ !' [ qc-#'fce qc-#"fce 2fe ] qd+1ud ftiuc ]
      [ !:K and 0K [ qc-#:fce qc-#;fce qc-#0fce 2fe ]
        ftiu8
        [ q8-#Kfce q8-#kfce 040uc 2fe ]
        [ qc-#;fcn #:uc ]
        qc-#:fce #Kuc -1un ! 0K is -1K, -nK is -(n+1)K ]
      [ !minus flag qc-#-fcn 1u9 ftiuc ]
      < !numeric argument qc-#0fcl qc-#9fcg qn,012f*un qc-#0%n ftiuc >
      [ !<cr> qc-015fcn #[uc ]
      [ !control char translation qc-032fcg qc+0100uc ]
      [ !lower case translation qc-#afcl qc-#zfcg qc-040uc ] ]
    [ ! cursor and edit keys qc-033fcn < qc-033fcn ftiuc > 040uc ]
    [ ! default argument qnfcn qc-#Wfce 1un ]
    [ ! negative argument q9fce
      [ qc-#Cfcn #Buc 2fe ]
      [ qc-#Nfcn #Luc 2fe ]
      [ qc-#Kfcn -qn-1un 2fe ]
      [ [ qc-#Dfce qc-#Ffce qc-#Ofce qc-#Kfce qc-#Rfce qc-#Sfce qc-#Wfce
          040uc 3fe ] -qnun ] ]
   >
015fto v -1/fts/Y7 K/ fh