Bravo File Format1Filename:Bravo-File-Format.pressThis memo describes the file format for documents produced by Bravo (notBravoX). It is applicable to Bravo versions 6.0 through 8.6, although much of thediscussion applies to other versions of Bravo as well.INTRODUCTIONFrom time to time, someone will ask about documentation concerning the file formatgenerated by Bravo. As far as I know (I haven't researched the subject), two principalpapers exist, and both are difficult to find. They were written several years ago by GregKusnick, a member of the Bravo programming team headed by Charles Simonyi.At the time, Greg was addressing a single recipient, Dan DeSantis. Dan & I were developinga program to translate Bravo documents into a form accepted by the ill-fated Diamond editor.Greg's first paper, written about September 1976, described the essentials of Bravo's fileformat. The second paper, written in October 1976, concentrated on the format for tabsettings.This memo is largely a re-hash of Kusnick's work, with a few additions bringing it up to date.For the most part the additions result from deductions I made after experimenting with Bravo7.5. Not being a Bravo expert, I may have overlooked or misunderstood some things. Ifsuch matters are brought to my attention, I'll be happy to revise the memo.Bill MayburyMay 30, 1981OVERVIEWEach Bravo document is stored as a single textual file. There are also support files, for fontsand user profile (in User.Cm), but these are considered independent of the document. Notethat the same document may have significantly different renderings if different support filesare used. (E.g. Greek letters can become arrowheads if the user profile is altered a little...orplain English can become Greek gibberish.)Bravo files have no End-of-File marker; Bravo relies on the file system for length information.The maximum length for a Bravo file is 65,536 bytes. Actually, a limit of 60K is morerealistic; beyond that Bravo is likely to complain. A length of zero is okay.Bravo is quite willing to accept a file containing simple text, i.e. no control information. Suchfiles represent "vanilla" documents having no paragraphs (in the Bravo sense). At present,Laurel and most Mesa Utilities produce vanilla documents. When rendered by Bravo, thesedocuments have default formatting, subject to User.Cm.Except for vanilla documents, Bravo files contain a sequence of paragraphs, where eachparagraph consists of its text, if any, followed by a "trailer" specifying control information.The trailer begins on a special character, control-z (^z), optionally followed by formattingdata. The trailer terminates on a carriage return (CR).#gpXGf _q \1p)FM[R\1 ZIZfH X6 Rr O=s7 Mr(/ K-- IJ FkF D2* B? A N ?A ;+3 :\ 89K 6oK/3r < - *rsrs7 (T &G %S #G* R  G @N Z *rs. 9X n6  L 2@ gJ 8 U>]Bravo File Format2A trailer's formatting data indicates two things: how the paragraph as a whole is to look andhow its runs of characters are to look. The first part is sometimes called the "par-look"section while the second is called the "char-look" section. The char-look section begins ona special character, the backslash (\). Both sections are optional.The following BNF description summarizes the overall makeup of a Bravo document file:BravoDoc::=VanillaDoc | SeqOfParsVanillaDoc::={character}0-- i.e. zero or more ASCII charactersSeqOfPars::={Paragraph}1-- i.e. one or more ParagraphsParagraph::={character}0 TrailerTrailer::=^z ParLooks0 CharLooks0 CR-- i.e. ParLooks & CharLooks are optionalParLooks::={parLook}1-- par-look details are discussed nextCharLooks::=\ {charLook}1-- char-look details are discussed laterPARAGRAPH LOOKS (PAR-LOOKS)Except for tab-settings, the presence of a given par-look strictly depends on whether thecorresponding property differs from the norm or not. Thus, the "z" (right-margin) par-lookdoesn't occur for a paragraph having the default right margin,. And, the "d" (line1-margin)par-look doesn't occur for a paragraph whose first line has the same left margin as the restof its lines. But, the "c" (centered) par-look occurs for every paragraph which is centered.Tab-settings propagate (unless overridden by new tab-settings). That is, if a given tab-setting is specified for paragraph n, the setting remains in effect for paragraphs n+1, n+2,etc. Tab-setting par-looks are always parenthesized and appear after any other par-looks.The other par-looks begin on a small letter. The letter alone is sufficient for the Booleanpar-looks (doc-profile, justified, centered, hardcopy). The others have a CARDINAL value aftertheir letter. In the case of margins, the value is in mica units; otherwise, it's in point units.(There are 2540 micas or 72 points per inch.) The table below covers all par-looks whichmay precede a tab-setting (if any). They are given in Bravo's preferred order.Table of par-looks (except for tab-settings):par-lookletterunitsremarksright-marginzmicasdefault = 527 pts unless overridden by User.Cmleft-marginlmicasdefault = 85 pts unless overridden by User.Cmline1-margindmicas1st line's left margin differs from that of other linesvertical-tabyptsdefault = -1 (i.e. no vertical tabbing)line-leadingxptsdefault = 1 pt unless overridden by User.Cmpar-leadingeptsdefault = 0 pts unless overridden by User.Cmdoc-profileq----justifiedj----centeredc----hardcopyw----keepkptsdefault = 0 pts unless overridden by User.Cm#gpX f _sN ]'3 \\ ZCD VFT3ZXQ ZpsRq2 QtF%OsZ PWq2 OtMsZpsN"qMsXKaZps KqKas KqKasp2 tF)I-sZIq2 I-t&FsZpsX Gq2 FtF& A r =sY ;'4 :\ 89S 6o .rs 2C 12\ /h&4 +> *+8qs (`U &2' $O !Yr-dIs dDkd&Od( @%&O#  @ &O- @ &O+ ' @ &Ors\ @ &O+ @ &O, @ @ 2@  g@  @ &O, " U>]Bravo File Format3Bravo understands two types of tabs: named & plain. Consequently, there are two forms ofpar-looks for tab-settings: tab-stop & tab-interval. The two are mutually exclusive.However, if extra tabs occur in a paragraph having tab-stops, a default interval is automatically appliedby Bravo. This default may be specified in User.Cm; if it isn't, Bravo assumes a 60 pt interval.The tab-interval par-look is simply a parenthesized CARDINAL value:(interval)where interval is in mica units. This par-look is generated when the user executes Bravo's"Look TAB =" command. It also results by default when applicable. For example, the tab-interval par-look is almost always present in a document's initial paragraph (not if thatparagraph uses tab-stops, of course). The interval effectively partitions paragraph lines intoequal-sized units starting at the paragraph's left margin. Consider the example,(2540)which specifies a tab-interval of one inch. If the paragraph's left margin is at 85 pts, therewill be effective tab stops every inch (72 pts) to the right, i.e. at:157 pts, 229 pts, 301 pts, 373 pts, etc.A tab-stop par-look consists of a parenthesized pair of CARDINAL values separated by acomma; no blank follows the comma:(name,tabStop)TabStop is in mica units. The name is a value in the range [0..13], corresponding to n IN{1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e}, respectively, for "Look TAB n" commands. There maybe a sequence of tab-stops; in which case they occur in name order. Consider thisexample:(0,5080)(1,12700)(10,7620)Tab-1 is set 2 inches from the left edge of the page's (not paragraph's) left margin; tab-2 isset at 5 inches, and tab-b is set at 3 inches, i.e. between tabs 1 & 2. Bravo accepts uselesssettings, by the way, i.e. tab-stops outside the paragraph's margins.Tab-stops can be cleared as well as set. The special tabStop, 65535, denotes this. For example, thepar-look (0,65536) clears tab-1.CHARACTER LOOKS (CHAR-LOOKS)Char-looks describe the properties of a run of text in a paragraph. Here's an oversimplifiedrule:Char-looks contain a property-change description followed by a run-length.The property-change description tells how properties of the new run differ from those of thepreceding run (if any) in the paragraph. (If there is no preceding run in the paragraph, thedescription tells how properties differ from defaults.) The run-length tells how manycharacters occur in the new run.So much for oversimplification; there are two exceptions to the above rule:A paragraph's first char-look may or may not have a property-change description. Ifonly the run-length is present, Bravo applies default properties to the run. Aparagraph's last char-look (possibly its only one) has no run-length. Bravo appliesthe property-change description to all remaining characters in the paragraph.#gpXGf _sH ]U[qMZCa Vs4qsU*p S_sps< QqsG O*/ M*ps, L5QJj HN FFE ( A!qs ?">p <8sps %rsq :nsDqsrs 8 +ps 65 3C0rs( 1yB /E-q6uq, &Or "s"; !trJ sI  @ AE v Kf rs#G rs) M & =]o6Bravo File Format4One obvious technicality should be mentioned: If a paragaraph has no char-looks, all of itscharacters have default properties.Property-change descriptions consist of one or more "looks" (character-propertyspecifications). Looks have two basic forms. The most common form is merely a letter, e.g.i for italic, b for bold, and u for underlined. Note that these are small letters; their capitalsreverse the property.The other basic form consists of a small letter immediately followed by a CARDINAL. (A blankis appended for separation in cases where run-length follows the look.) This form of look isused for specifying changes in font-number, offset, color, or tab name. For example,switching to font 1 results in the look f1.The following table covers all character looks. It is given in what seems to be Bravo'spreferred order. (The ordering of looks in a char-look is probably unimportant, however.)Table of character looks:lookletterdefaultremarksfont-numberf0values IN [0..9]offseto0values IN [0..255], discussed nexttab-or-colort0values IN [0..14], discussed laterunderlineduFALSE(U means non-underlined)boldbFALSE(B means non-bold)italiciFALSE(I means non-italic)graphicgFALSE(G means non-graphic)visiblevFALSE(V means non-visible)overstrikesFALSE(S means non-overstrike) the look is no longer in usevanishednFALSE(N means non-vanished) the look is no longer in useOffset values are interpreted as 8-bit INTEGERs. For example, the look o249 represents anegative offset of 7 points.The tab-or-color look has a dual use, representing color or a named tab. Color is simple:t0 for Black (used to revert back to uncolored text)t1 for Cyant2 for Greent3 for Magentat4 for Redt5 for Violett6 for Yellow(Regarding highlighting: If a character is "underlined" and also has a color other than Black, Bravo assumesthe character is to be drawn non-underlined but on a colored background.)Analysis is needed to distinguish named-tab looks from color looks. (Note that t1 may mean"named-tab-1" or "Cyan color.") For TAB characters, named-tab is the reasonable choice.For other characters, color is the reasonable choice...if they have looks t0, t1, t2, t3, t4, t5, ort6. If they have looks t7, t8, t9, t10, t11, t12, t13, or t14, the characters are named "tabs."(Peculiarly enough, Bravo allows any character to have the named-tab property.)#gpX f _sCrs ]# Zf$+ XO VS U Q/qs O)4 MB L5+ HM F"8 Cr@@s @D@k@b@&O@(@> @!&Oqs<@!&Oqs; @!&Oqs9T @q&Os7@q&Os5@q&Os3@q&Os2)@q&Os0_ @q&Osq .s@q&Osq +"s'qs )W %R$4"P    & [ q+B 0I s+0 %qs( LI 2. !rs+ > p>\sBravo File Format5Except for t0, named-tab looks correspond in straightforward fashion to the tabs they name:looktablooktablooktablooktabt44t88t12ct11t55t99t13dt22t66t10at14et33t77t11bNamed-tab look t0 un-names the next "tab." I.e. it causes the run to revert to un-named orplain tab property. Typically, a t0 look appears shortly after each named-tab look.EXAMPLESThe five examples below contrast the normal appearance of a paragraph with its file-formatappearance...as rendered by Bravo's Unformatted-Get command. (To improve readability,the paragraph trailer's control-z character has been replaced by ^z, and a CR has beeninserted before the trailer's carriage-return.) The examples are fairly self-explanatory. Thefirst one illustrates an "empty" italicized paragraph having no par-looks.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -^z\iCR- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*** CENTERED & BOLD ****** CENTERED & BOLD ***^zc\bCR- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*** NAMED-TAB-1 at 4":, COLOR: Cyan ****** NAMED-TAB-1 at 4":, COLOR: Cyan ***^z(0,10160)\22t1 1t0 8t1 5t0CR- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*** ITALICS UNDERLINED FONT-1 ALL-OF-THOSE MIX & MATCH OFFSET 9 pts ****** ITALICS UNDERLINED FONT-1 ALL-OF-THOSE MIX & MATCH OFFSET 9 pts***^z\4i7I3u10U3f1 6f0 3f1ui12f0UI3ui3I3f1 5f0U3o9 12o0CR- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*** RIGHT-MARGIN 7" LEFT-MARGIN 2" LINE-1-MARGIN 1.5" LINE-LEADING4 pts PARAGRAPH-LEADING 19 pts JUSTIFIED KEEP 8 pts TAB-INTERVAL 1"TAB:TAB:TAB:TAB:****** RIGHT-MARGIN 7" LEFT-MARGIN 2" LINE-1-MARGIN 1.5" LINE-LEADING 4 ptsPARAGRAPH-LEADING 19 pts JUSTIFIED KEEP 8 pts TAB-INTERVAL 1"TAB:TAB:TAB:TAB:***^zz17780l5080d3810x4e19jk8(2540)CR#gpXGf _s[\]`\]`\] \]& \]*\]0\]5\]Z &+126KY0 &+126KW;0 &s+126KUp0 &s+ R*1 QT Kr Fs; E I C@!8fB`C@?BC@ AuB ?J <8S 8`90<890 5S$-4:pX 12s0`12!012 -S ,<X'x )4 - (`)4>()4 %S #$Xrs"#$ qs#"#$t s,"s#$r/ "#$s0"#$qs$a #$ M A`20A &SH; )z3f=R XN DC  '* i` A i  y=] HELVETICA  HELVETICA HELVETICA  HELVETICA  HELVETICA HELVETICAZ1%j/(&@Bravo-File-Format.bravo Maybury * * *May 30, 1981 3:16 PM