6.5 How PWB Handles Tabs

The following functions and switches control how PWB handles tabs:

Name Type Description

Realtabs Switch Determines if PWB translates white space on modified lines
Entab Switch The white space translation method
Tabalign Switch The alignment of the cursor within a tab field
Filetab Switch The width of a tab field
Tabdisp Switch The fill-character for displaying tab fields
Tab Function Moves the cursor to the next tab stop
Backtab Function Moves the cursor to the previous tab stop
Tabstops Switch Tab positions for Tab and Backtab

For detailed information on each function and switch, see Help or the “Programmer's WorkBench Reference.” For instructions on how to set a switch see “Changing Settings”. For instructions on how to assign a function to a key, see “Changing Key Assignments”.

To understand how PWB handles tabs, you need to know only a few facts:

The Tab (TAB) and Backtab (SHIFT+TAB) cursor-movement functions and the Tabstops switch have nothing to do with tab characters. They affect cursor movement, rather than the handling of tab characters, and are not discussed further here. For more information on these items, see the “Programmer's WorkBench Reference.”

PWB never changes any line in your file unless you explicitly modify it (lines longer than PWB's limit of 250 characters are the exception).

Some text editors translate white space (that is, entab or detab) when they read and write the file. PWB does not translate white space when it reads or writes a file. This is to be compatible with source-code control systems that would detect the translated lines as changed lines.

PWB translates white space according to the Entab switch only when you modify a line and Realtabs is set to no.

Tabalign has an effect only when Realtabs is set to yes.

A “tab break” occurs every Filetab columns.

When PWB displays a tab in the file, it fills from the tab character to the next tab break with the Tabdisp character.

Figure 6.1 illustrates how PWB displays tabs.

When translating white space, PWB preserves the exact spacing of text as it is displayed on screen.

To set the width of displayed tabs, change the setting of the Filetab switch.

To tell PWB to translate white space on lines that you modify, set the Realtabs switch to no and the Entab switch to a nonzero value, according to the translation method that you want to use. The Entab switch takes one of the following values:

Entab Translation Method

0 Translate white space to space characters
1 Translate white space outside of quotation-mark pairs to tabs
2 Translate white space to tabs

To preserve white space exactly as you type it, set the Realtabs switch to yes. This turns off the translation of white space on modified lines.

When Realtabs is yes, the Tabalign switch comes into effect. When Tabalign is set to yes, PWB automatically repositions the cursor onto the physical tab character in the file, similar to the way a word processor positions the cursor. When Tabalign is set to no, PWB allows the cursor to be anywhere in the tab field.

If you want the TAB key to type a tab character, assign the TAB key to the Graphic function. Note that when a dialog box is displayed, the TAB key always moves to the next option. You can always use the following method to type a tab character, whether you are in a dialog box or an editing window.

·To type a literal tab character in your text or in a dialog box:

1.Execute the Quote function (press CTRL+P).

2.Press TAB.

Examples

The following example sets up tabs so that they act the same as in other Microsoft editors, such as QuickC or Word:

realtabs:yes

tabalign:yes

graphic:tab

trailspace:yes

filetab:4

The Trailspace switch is needed so that the TAB key will have an effect on otherwise blank lines.

To save your file so that it does not include any actual tab characters (ASCII 9), use the following settings:

realtabs:no

entab:0

tabstops:3

The Tabstops value determines the number of spaces inserted for each press of the tab key.

Another example of a common tab configuration is one in which the TAB key inserts a tab in insert mode but moves over text to the next tab stop when the editor is in overtype mode.

First, use the following tab settings:

realtabs:yes

tabalign:yes

Then insert the following macro into the PWB section of your TOOLS.INI:

;Insert mode and overtype mode tabbing

TabIO:= Insertmode + Insertmode Arg Tab Sinsert Tab = \

:over Insertmode Tab

TabIO:TAB

For more information on PWB macros see “Writing PWB Macros”.