Updated September 2024
Syntax One
//TEXTRECTANGLE, left, top, right, bottom
bla bla bla bla bla bla bla bling
bla bla bla bla bla bla
//TEXTRECTANGLE
TEXTRECTANGLE is similar to the TEXTINDENT directive, both in what it is used for and also in the fact that it consists of a starting and ending directive (the ending directive has no arguments), with any number of lines of text in between the two.
TEXTRECTANGLE formats the text to fit within the rectangular coordinates provided, applying word wrap to the lines as needed. Note that any existing CRLF line terminators will be respected; in the example above, the word "bling" will mark the end of a line, no matter how the rest of it formats.
If the text does not all fit in the rectangle, the last word will be printed with an ellipsis (...) following it. See MX_GDICALC for information on calculating in advance how much text will fit.
TEXTRECTANGLE supports rotated multi-line text, with autowrap. Support is limited; it doesn't clip to the rectangle if there are too many lines to fit.
TEXTRECTANGLE also supports embedded entity references. In earlier versions of A-Shell, these were only processed by TEXTOUT and for raw text.
Some text rotation options are also supported; see History, below.
See MMOGDI in EXLIB:[908,37] for an example.
Syntax Two
//TEXTRECTANGLE, left, top, right, bottom, flags, text
This variation (identified by more than four parameters) is both simpler to use than the traditional multi-part TEXTRECTANGLE sequence, and offers some additional features such as multi-line horizontal and vertical centering.
flags may be any sensible combination of the following:
Flag |
Value |
Meaning |
---|---|---|
TRF_TOP |
&h00000000 |
top justification |
TRF_LEFT |
&h00000000 |
left justification |
TRF_HCENTER |
&h00000001 |
horizontal centering |
TRF_RIGHT |
&h00000002 |
right justification |
TRF_VCENTER |
&h00000004 |
vertical centering |
TRF_BOTTOM |
&h00000008 |
bottom justification |
TRF_WORDBREAK |
&h00000010 |
wrap the text onto multiple lines |
TRF_SINGLELINE |
&h00000020 |
output text as a single line |
TRF_EXPANDTABS |
&h00000040 |
expand tabs (8 spaces each) |
TRF_NOCLIP |
&h00000100 |
no clipping |
TRF_EXTERNALLEADING |
&h00000200 |
incl. ext. leading in spacing |
TRF_CALCRECT |
&h00000400 |
calc only (use with MX_GDICALC) |
TRF_PATH_ELLIPSIS |
&h00004000 |
path ellipsis |
TRF_END_ELLIPSIS |
&h00008000 |
end ellipsis |
TRF_WORD_ELLIPSIS |
&h00040000 |
word ellipsis |
As with other GDI printer directives, the flags can be specified as a decimal value, hex value, or using the symbol names.
text may be any string, up to 16K characters for the entire directive line. It may include "^M" symbol(s) to indicate hard CRLF(s). You may split the text argument over multiple lines (similar to the Syntax One case) by appending a backslash to each line to be continued; see History below. Quoting the entire string is optional; embedded commas are treated as literal characters rather than syntax delimiters in either case. Note that quoting will defeat the special meaning of the trailing backslash, causing it to be printed as an ordinary character. As with other text output, embedded symbols are supported; see Printing Special Symbols.
Note that if the text parameter is missing—i.e., only 5 parameters are specified—it is treated like "" , which creates no output.
History
2024 September, A-Shell 7.0.1762: Add support for special handling of trailing backslash in //TEXTxxx directives. Previously it was only recognized as a special character in plain text outside of GDI directives.
2014 June, A-Shell 1387: Single-line TEXTRECTANGLE now supports character wrap in the 90, 180, -90 and -180 rotations. Previously only word wrap was supported and if any lines were too long, the output was way out of position.
2013 December, A-Shell 1370: An unmatched leading quote is now treated as a literal character. Previously it was stripped.
2012 November, A-Shell 6.0.1263: TEXTRECTANGLE now supports rotated multi-line text, with autowrap; that support is limited, it doesn't clip to the rectangle if there are too many lines to fit. TEXTRECTANGLE also supports embedded entity references; previously these were only processed by TEXTOUT and for raw text.
2012 October, A-Shell 6.0.1261:
• | TEXTRECTANGLE (syntax one, with multiple lines) now adds an ellipsis "..." to the right of the last line in the case where the last visible line is not truncated, but there are additional lines of text (with hard line breaks) that did not fit into the box. |
• | New SETOPTION flag "TEXTRECT-CONSERVATIVE-VERT" improves vertical spacing control. |
• | New SETOPTION flag "TEXTRECT-NOWRAP" disables wrap within TEXTRECTANGLE. This may be useful in situations where you have multiple lines of text that already have hard line breaks and and you would prefer to truncate the lines that are too long rather than cause a wrap and end up losing some of the text at the bottom. |
2011 October, A-Shell 5.1.1235: TEXTRECTANGLE now supports limited rotation options (TRF_SINGLELINE with 90, -90, or 180 degree rotation only). Note that the rectangle itself is not rotated, nor is the interpretation of the alignment options (TRF_LEFT, TRF_TOP, etc. remain relative to the rectangle in the standard orientation of the page. Only the text is rotated. See the sample GDI text file textrectr.txt in SOSLIB:[908,37] for examples.
2011 August, A-Shell 5.1.1230: Added Syntax Two
2007 April, A-Shell 4.9.986: Increased the maximum paragraph length supported by the TEXTRECTANGLE directive to 16K from 2K. This is considerably longer than can fit on a page, which is the effective limit for what a single TEXTRECTANGLE can handle anyway. Larger paragraphs can still be analyzed by MX_GDICALC, it would inevitably break them up into rectangles (or entire pages) that were individually less than 16K (unless perhaps you used 2 point type in an effort to cram 16K of unreadable text on a page).
An error message box will be displayed if any single line of the printfile exceeds the 16K limit.
Note that neither MX_GDICALC nor TEXTRECTANGLE support the line continuation character (\) so unless you want to insert your own line breaks, the entire paragraph has to be output as a single line (with the only CRLF being at the end).
2005 May, A-Shell 4.9.986: Routine added to A-Shell