Tools: MPW
Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Support

MPW Command Reference


Format

Built-in

SYNTAX

Format [window1] [window2]… [[-a attributes] [-f fontName]
[-l language] [-s fontSize] [-t tabSize]] | [-x formatting]

DESCRIPTION

The Format command allows you to set the format of one or more windows. It is the scriptable form of the Format menu item in the Edit menu. As such, its options, which control such things as font and tab size, correspond to the items in the Format menu item's dialog.

Note
The Format command and the Format menu item modify the format of an existing window. Format-related variables such as {Tab} and {Font} initialize the format of a new window. •

In addition to setting its format, you can use this command to view a window's current format setting. See the Output section for a description of this.

INPUT

None

OUTPUT

None, unless you do not specify any options (except -x). In this case, the format settings of the current window are written to standard output. Note that these format settings normally appear in the form of Format commands that can be selected and executed. If you specify -x, these settings appear as fields of values instead.

ALIAS RESOLUTION

This command resolves Finder aliases that are part of a partial or complete pathname substituted for the window name. The resolved pathname must specify the name of an open window. Note that using a shell variable to designate a window is usually faster than requiring MPW to resolve a Finder alias.

STATUS

Format can return the following status codes:

0

no errors

1

syntax error (parameter error)

2

all other errors

PARAMETERS

window1 [window2]…

Specifies one or more windows to be formatted. If you do not specify any windows, Format uses the target window.

OPTIONS

-a attributes

Sets or clears the auto-indent, invisibles, and auto-scrolling states. The attributes parameter is a string composed of the characters in the following list. Any attribute that is not listed remains unchanged.

A | a

Sets or clears the auto-indent state.

I | i

Shows or hides invisibles.

L | l

Locks or unlocks auto-scrolling.

Note that uppercase letters turn on the attribute and lowercase letters turn it off.

-f fontName

Changes the font in the specified windows to fontName.

-l language

Sets the syntax colorization in the specified windows to language. The language must be specified as a string that matches those displayed in the list in the Format dialog, which are based on the resource names of the 'Sods' resources contained in the shell. The "official" language specifications currently recognized are:

Default
None
68k Asm
C/C++/Objective-C
Fortran
HTML
Inform
Interfacer
Java
Magic Cap
Modula-2
Oberon
Pascal
Perl
Postscript
PPCAsm
Rez
MPW Shell Script
IDL
Tcl
Yacc
Lex
Z80/Z180 Asm

There is also a translation resource ('STR#'(256)) that can be used to supply language "aliases" for ease of use. The individual entries in the resource must be formatted as:

alias=OfficialName

The default set of supplied aliases are:

"Asm=68k Asm"
"C=C/C++/Objective-C"
"C++=C/C++/Objective-C"
"CPlus=C/C++/Objective-C"
"Objective-C=C/C++/Objective-C"
"MagicCap=Magic Cap"
"Modula=Modula-2"
"MPW=MPW Shell Script"
"Shell=MPW Shell Script"
"Script=MPW Shell Script"
"Z80=Z80/Z180 Asm"
"Z180=Z80/Z180 Asm"

To "unset" a language for a window (that is, allow the logic in the shell to determine the syntax colorization to use based on the filename), use the Default language argument to the -l option. To disable syntax colorization for a file, use the None language argument to the -l option.

-s fontSize

Changes the font size in the specified windows to fontSize.

-t tabSize

Changes the tab size in the specified windows to tabSize.

-x formatting

Displays the current format settings in fields, where formatting determines the order in which the fields appear. Normally Format displays settings in the form of Format commands when no other options are specified.

The formatting parameter is a string composed of the following letters in any order. In the output, fields are placed in the order specified, separated by spaces.

a

Auto-indent, show invisibles, and auto-scrolling state

f

Font name

l

Language

s

Font size

t

Tab size

Note that an error message occurs if you specify any other option in conjunction with this option.

EXAMPLES

The following command line sets the auto-indent, font, and tab size in the target window. The font size and invisible settings are not changed.

Format "{target}" -a A -f Monaco -t 8

This example changes the font size in MyWindow to 12 point:

Format -s 12 MyWindow

A Format statement with no options, such as

Format "{Target}"

displays the current format of the window. The output appears as follows:

Format -f Monaco -s 9 -t 4 -a Ail 'HD:Sources:Test.c'

Using -x, the command line

Format -x tsf

displays only the values of the specified options:

8 9 Monaco

 
 


Last Updated July 2000