[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference vaxuum::document_ft

Title:DOCUMENT T1.0
Notice:**New notesfile (DOCUMENT.NOTE) now available (see note 897)**
Moderator:CLOSET::ADLER
Created:Mon Feb 09 1987
Last Modified:Thu Oct 31 1991
Last Successful Update:Fri Jun 06 1997
Number of topics:897
Total number of notes:4397

794.0. "TAB characters" by TREK::WATERS (Lester Waters) Tue Aug 11 1987 14:18

    I looked for a reference for TAB characters and found none.
    
    I have (a rather large) programming example to be included in
    a software specification.  I am using the <CODE_EXAMPLE> ...
    <ENDCODE_EXAMPLE> directives, which output the included text
    in a small monospaced font.  The problem is that I have TAB
    characters imbedded into the code example.  DOCUMENT is reducing
    these tab characters into single spaces.  In environments like
    <CODE_EXAMPLE>, TABs should be properly expanded.  This is easy
    to do, especially if monospaced fonts are involved.  The editing
    of such an example -- manually changing all tabs to spaces and
    lining up columns can be time-consuming, especially if the example
    is subject to change.  Editing an example also introduces the risk
    of accidentally changing something.
    
    Yes, perhaps there is an editor that does this for you, but in the
    customer world, people will be inclined to use their favorite editor
    (which is what I do).
    
    Is there ANY environment that doesn't squish tab characters?  How
    about having the <CODE_EXAMPLE> environment keep tabs as they are?
    Is it TEX that is incapable of handling TABs?
    
    
T.RTitleUserPersonal
Name
DateLines
794.1Tab => SpaceCLOSET::ANKLAMTue Aug 11 1987 14:3811
    
    We have had many discussions about this (most of them in the old
    DOCUMENT Notes file) and it is on the list to look at for a future
    release. For V1.0, all TAB characters are translated to individual
    space characters. 
    
    For your purposes, you may want to skim the old Notes file; some
    users had pointers to tools that will pre-process examples taken
    directly from source code.
    
    patti
794.2what are tab stop settings?VAXUUM::KOHLBRENNERTue Aug 11 1987 14:3916
    I think there is much sympathy here for doing something
    more intelligent with tabs than simply mapping them into 
    a single space.  What to do, and the cost to do it was
    not something that we could take on for V1.0.
    
    If we try to do an expansion of tabs to multiple spaces
    within <code_example>s, is it sufficient to default the
    tab stops to char positions 9, 17, 25, 33, etc, or must
    there be some kind of <tab_stop> tag that would set the
    desired tab stops?
    
    I suspect that we will never try to do more than we currently
    do for tabs that appear in areas other than <code_example>.
    
    bill
    
794.3AUTHOR::WELLCOMESteveTue Aug 11 1987 14:484
    I expect default 8-character tab stops are fine, at least for
    the work we do here at Digital.  Tabs are a real killer only
    in program examples, and as far as I know those all assume 
    8-character tab stops.  Tab support certainly would help!!!
794.4A YES Vote and an EVE ProcedureDICKNS::DENHAMJeff Denham, DTN 223-6770Wed Aug 12 1987 09:4867
    I agree that a default of 8 with the opportunity to
    <set_tabs>(4) would be a big help. 

    In the meantime, what follows is an EVEPLUS procedure to
    eliminate tabs. It replaces tabs with spaces based on
    the current tab setting. If you want 4-character tabs,
    you'd set them up in EVE with the command SET TABS EVERY 4. 

    For people unfamiliar with EVE, here's what to do:
    
    1. Fire up the EVE editor by typing EDIT/TPU YOUR_TABBED_FILE.SDML
    
    2. Press the DO key and enter GET FILE TABS.TPU
    
    3. Press DO and type EXTEND TPU * to compile the TPU code
    
    4. Press DO and type BUFFER YOUR_TABBED_FILE (or whatever)
    
    5. Press DO and type ELIMINATE TABS (no more tabs)
    
----------------------------- CUT HERE TABS.TPU -------------------------    
!
!       Edit History
!
!       Which   When            Who     What
!
!       X00-01  26-Dec-84       JLB     Created from MYSECINI.TPU
!	X00-02   4-Feb-87	JMD	De-EVEplus-ed; saves current pos.;
!					adjusts to whatever the current
!                                       tab setting in the buffer is
					
procedure eve_eliminate_tabs            ! Turn TABs to spaces

    local       target,
                old_mode,
                this_buffer,
                this_position,
		tabs_set,
                n;

on_error
        message('All tabs removed.');
endon_error;

this_buffer := mark(none) ;
this_position := mark(none) ;
old_mode := get_info(current_buffer, "mode");
set(INSERT, current_buffer);

tabs_set := get_info(current_buffer,"tab_stops") ;
        
position(beginning_of(current_buffer));

    loop
        target := search(ascii(9), FORWARD);
        exitif (target = 0);
        position(beginning_of(target));
        erase_character(1);       
        n := current_offset - (tabs_set * (current_offset / tabs_set));
        copy_text(substr("        ", 1, tabs_set - n));
    endloop;

position(this_buffer) ;
position(this_position) ;
set(old_mode, current_buffer);

endprocedure
794.5Substitute'emGNUVAX::SJONESFri Aug 14 1987 00:057
    
    Silly thought, but isn't this overkill?  You can use the EVE command
    REPLACE to substitute spaces for tab characters:
    
    Old string: <tab>
    New string: <sp><sp><sp><sp> 
                                                    
794.6Please engage BrainMATTER::COSCONNOLLYGerry with G not jerry with a JFri Aug 14 1987 04:458
    re .5
    
    WHAT               !!!!!!!!!!!!!!!!!!!!!!!!!!!
    
    Have you tried doing that on a formatted document !!!!!!!!!!!!!!!
    
    
    
794.7Brain engaged, wedding planned for JuneGNUVAX::SJONESFri Aug 14 1987 10:3315
    re .6
    
    I have never used EVE to edit a formatted document, and never would,
    if by "formatted document" you mean Document output.
    
    My comment describes the way I regularly remove tab characters from code
    examples in SDML source files, *before* I process those files. Note
    794.4 describes another way of doing that same task, a way I felt was
    unecessary given EVE's standard equipment... 
    
    As for my brain, I'm pleased to say that it is engaged and fully
    functional.  How's yours?  ;-)
    
    Scott
         
794.8glutton for punishment3D::BOYACKpithy...pithy...pithyFri Aug 14 1987 10:439
    Well.... having tried substituting spaces for tabs somw time ago,
    I maintain it doesn't work. Text entries at the tab stops consume
    only part of the nominal eight space tab, and following text, the
    tab can be anything from 1 to 8 spaces. Now toss all this into
    a six or seven column table formatted in plain text with tabs,
    and substitution leads to a complete mess, especially if you're
    editing someone else's document and don't have a hard copy. But
    don't take my word for it... try it.
    
794.9CRAYON::GENTParty gone out of bounds -- B52&#039;sFri Aug 14 1987 10:577
    There are quick ways around the 1-8 space replacement. I wrote
    a procedure for use with TPU that replaces tabs with the
    correct number of spaces to align the text as expected. It can
    be copied from BOOKIE::DOC$TOOLS:NOTABS.TPU. Instructions are
    in the comments at the beginning of the file.
    
    --Andrew
794.10Starting over with a Clean Slate (Tab-ula rasa?)GNUVAX::SJONESFri Aug 14 1987 11:1819
    
    Okay, it's time for me to bite the bullet and 
    
        1.) Admit I'm off base
    	2.) Qualify maddly
    
    You're absolutely right, tabs interspersed in lines of text are best
    not substituted using EVE's REPLACE command.  
    
    My experience is mainly with leading tabs used to indent levels of
    programming code in code examples. REPLACE substitutes leading tabs
    okay.  It's tabs that have text both to the right and to the left
    of them that cause problems.   
    
    Because you never know where tabs are going to show up in code
    examples, however, you should probably avoid using REPLACE altogether.
    Now, that done, I'm sheepishly going to go back over my old files... 
    
    Scott
794.11Vote for some kind of tab controlSTLSEE::USERGarrett Van SiclenFri Aug 14 1987 15:3914
    
    Well, I'd like to put in a vote for some general tab tag.  Make
    it a switch for the <LINE> tag maybe.  There is one place in my
    current document I want to do something like this:
    
    	Item:  Person		Group 		Title
    
    Of course I get this:
    
    	Item: Person Group Title                     
    
    I would prefer not to use <CODE_EXAMPLE> or <LINEART>.
    
    garrett
794.12MARTY::FRIEDMANFri Aug 14 1987 16:145
    re. .10
    
    Scott, you are hereby pardoned and absolved.
    
    
794.13Who's a heroMATTER::COSCONNOLLYGerry with G not jerry with a JMon Aug 17 1987 05:145
    re .10 and .12
    
    Scott, well done for owning up  !!!!!!!!!!!!!!
    
    	Regards Gerry
794.14AUTHOR::WELLCOMESteveFri Aug 21 1987 13:132
    For all you TECO fanatics out there, AUTHOR::USER:[RTINDEX]TABFIX.TEC
    substitutes spaces for tabs "correctly" (assuming 8-character tabstops).
794.15Do it right from DCL.GLORY::STREMICKIf it ain&#039;t broke, don&#039;t fix itFri Aug 21 1987 17:0258
!
! T A B S _ T O _ S P A C E S . T P U
!
! This procedure changes all TABS in the input file to SPACES.
!
! This is very helpfull when running a document through VAX Document
! that has TABS in it.  VAX Document treats TABS as SPACES, and therefore
! messes up formatted text.
!
! Use the following command to convert TABS to SPACES:
!
!   $ SPACES :== "EDIT/TPU/NOSECTION/NODISPLAY/COMMAND=tabs_to_spaces.tpu"
!   $ SPACES file-spec
!
! A new version of file-spec will be created that has SPACES instead of TABS.
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!
! This is the procedure that does all the work.  Look for a TAB and replace
! it with the correct number of spaces.
!
PROCEDURE change_tabs_to_spaces

LOOP
   target := SEARCH(ascii(9), FORWARD);
   EXITIF (target = 0);
   POSITION(BEGINNING_OF(target));
   ERASE_CHARACTER(1);
   n := CURRENT_OFFSET - (8 * (CURRENT_OFFSET / 8));
   COPY_TEXT(SUBSTR("        ", 1, 8- n));
ENDLOOP;

ENDPROCEDURE;


!========================================================================
! Get the name of the input file and bring it into a buffer.
!

	input_file := GET_INFO(COMMAND_LINE, 'file_name');
	main_buffer := CREATE_BUFFER('main', input_file);


!========================================================================
! Go to the beginning of the document and then change TABS to SPACES.
!

	POSITION(BEGINNING_OF(main_buffer));
	change_tabs_to_spaces;


!========================================================================
! Write the file out, now with SPACES instead of TABS.
!

	WRITE_FILE(main_buffer, input_file);
	QUIT;
794.16An Enhancement for DCL Version?DICKNS::DENHAMJeff Denham, DTN 223-6770Thu Aug 27 1987 14:395
    The advantage to the procedure in .4 is that it allows you to
    choose the size of a tab stop before inserting the hard spaces.
    I suppose the use-it-from-DCL TPU procedure could use an optional
    parameter, n, that allows the user to specify the size of the
    tabs. Otherwise, the usual size, 8, would be used.