From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 22-SEP-1990 07:06:41.41
To:	MRGATE::"ARISIA::EVERHART"
CC:	
Subj:	Re: Text Shift on A VAX text editor ?

Received:  by crdgw1.ge.com (5.57/GE 1.73)
	 id AA21515; Sat, 22 Sep 90 06:50:26 EDT
Received: From UCBVAX.BERKELEY.EDU by CRVAX.SRI.COM with TCP; Sat, 22 SEP 90 03:03:56 PDT
Received: by ucbvax.Berkeley.EDU (5.63/1.42)
	id AA22630; Sat, 22 Sep 90 02:50:05 -0700
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 21 Sep 90 16:13:15 GMT
From: bsu-cs!bsu-ucs!neubauer@iuvax.cs.indiana.edu  (Paul Neubauer)
Organization: Ball State University, Muncie, In - Univ. Computing Svc's
Subject: Re: Text Shift on A VAX text editor ?
Message-Id: <41706@bsu-ucs.uucp>
References: <9009211649.AA01449@ucbvax.Berkeley.EDU>, <DAVIS.90Sep21142304@pacific.mps.ohio-state.edu>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

In article <DAVIS.90Sep21142304@pacific.mps.ohio-state.edu>, davis@pacific.mps.ohio-state.edu ("John E. Davis") writes:
> In article <9009211649.AA01449@ucbvax.Berkeley.EDU> BILLUPKE@SNYPLAVA.BITNET (Ken Billups) writes:{      My question concerns the VAX editors EDT, LSE or EVE.
> 
>     >  Is there a command in EDT, LSE or EVE command that will shift a block of
>     >   'selected' (highlighted) text a specified number of spaces to the right
>     >   or left ?
> 
>     >   For example, this command would move this code block a few spaces to the
>     >   right ...
> 
>     >   IF VAR_A = 1
>     >     DO IT
>     >   END IF
> 
>     >   To look like this ...
> 
>     >        IF VAR_A = 1
>     >          DO IT
>     >        END-IF
> 
>     >   Without having to go the beginning of each line and pushing the line
>     >   to the right with the space bar.
> 
> Hi,
>     Try emacs.  Quite a few VMS systems have emacs and chances are your's does

Not likely here.  Emacs is just too expensive (freely available does not mean
cheap -- the resources to run emacs in an environment with a lot of users cost
money.)

> too. Emacs even has an EDT mode which emulates EDT.  Moreover, it is the only
> editor that runs on our VAX, all our UNIX workstations (DS3100, sun3/4),our
> cray and my pc (micro-emacs).

That is a worthwhile consideration if you have the resources you need.
 
> In addition to this function,  emacs has extensive rectangle support.  I have
> been told that eve can be extended to work with rectangles, however  unlike
> eve, emacs comes with everything you need right out of the box.

As for rectangles, I also have a good box-mode readily available (better than
the ones on the DECUS tapes, IMHO :-).  I will post if there is _sufficient_
demand or email if less, but nonzero demand.  Mine installs using EVE_BUILD and
obeys insert/overwrite modes as well as working correctly regardless of having
left margins set or tabs in lines.  It also puts an indicator on the status
line(s) and supports the mouse (at least for resetting to regular mode).

Here is a TPU procedure that does what was requested (a shift left is a trivial
exercise for the reader :-).  Note, that I have it set up to do 4 spaces at a
time, because that is what I usually use for tabbing increments in my own
programs.  (OOPS, I almost forgot to include the supporting procedures TAB_4
and MOD.  I spotted it in time.  They are included too.)  BTW, you may also
want to bind one or more of these to keys (e.g., tab_4 to the tab key).  As it
is, you would need to invoke them using a TPU command (i.e., not by pressing DO
and typing "indent_block", but by pressing DO and typing "tpu indent_block"),
since they are not nameed, e.g., "eve_indent_block".

!-----------------------------------

!	This procedure and the next will have the effect of adding or removing
!	a (4-space) tab before each line of a block that is highlighted
!	by SELECT, as for removal.
!
procedure indent_block

local this_position,		! Marker for current cursor position
      this_mode,                ! current mode of buffer
      indent_range;   		! Range being indented

this_position := mark (none);
if eve$x_select_position <> 0 then
    if get_info (eve$x_select_position, eve$kt_buffer) <> current_buffer then
	message ("Indent operation must be used in the same buffer as Select.");
    else
        this_mode := get_info (current_buffer, "mode");
        set (insert, current_buffer);
	indent_range := select_range;
	if indent_range = 0 then
	    message ("Nothing to indent.");
	    eve$x_select_position := 0;
	    return;
	endif;
        set (informational,off);
        set (success,off);
	position (eve$x_select_position);
	loop
            exitif mark (none) >= this_position;
            loop
                exitif index (eve$kt_whitespace,current_character) = 0;
        	eve_move_by_word;
            endloop;
            tab_4;
            position (line_begin);
            move_vertical (1);
        endloop;
        set (informational,on);
        set (success,on);
        set (this_mode, current_buffer);
        message ("Block indent completed.  Redo or press SELECT.");
    endif;
else
    message ("Use Select before block operation.");
endif;
eve$update_status_lines;
endprocedure;

!       mod is MOD function
!
PROCEDURE mod (number,modulus)
local   quotient;
quotient := number / modulus;
mod := number - (quotient * modulus); 
endprocedure;

!       replaces all tabs preceding position in current line by spaces
!
PROCEDURE tabs_to_spaces
local   start_position,                ! position at start of procedure
        this_mode,                     ! current mode -- insert or overstrike
        this_position;

    if current_offset > 0 then
        this_mode := get_info (current_buffer,"mode");
        set (insert,current_buffer);
        start_position := mark (none);          ! mark starting position
        move_horizontal (- current_offset);     ! go to beginning of line
        loop
                this_position := mark (none);
                if current_character = ascii(9) then    ! if tab
                       erase_character (1);             ! get rid of it
                       copy_text (" ");                 ! replace by spaces
                       loop
                         exitif mod (current_offset,8) = 0;
                         copy_text (" ");
                       endloop;
                endif;
                exitif this_position = start_position;
                move_horizontal (1);           ! and go on to next
        endloop;
        set (this_mode,current_buffer);
    endif;
endprocedure;


!
!       makes a tab worth (up to) 4 spaces instead of a single char that
!       is (up to) 8 spaces wide.
!
PROCEDURE tab_4            
local   this_mode;                     ! current mode -- insert or overstrike

        tabs_to_spaces;                ! eliminate preceding tabs from line
        copy_text (" ");
        this_mode := get_info (current_buffer,"mode");
        set (insert,current_buffer);
        loop
                exitif mod (current_offset,4) = 0;
                copy_text (" ");
        endloop;
        set (this_mode,current_buffer);
endprocedure;

!----------------------------------

====
    Paul Neubauer    00prneubauer@bsu-ucs.uucp  or  00PRNEUBAUER@BSUVAX1.BITNET
                     neubauer@bsu-cs.uucp
                     {backbones}!iuvax!bsu-cs!neubauer

