| 
									
										
										
										
											1998-08-10 19:42:37 +00:00
										 |  |  | \section{\module{formatter} --- | 
					
						
							| 
									
										
										
										
											1999-02-19 23:48:05 +00:00
										 |  |  |          Generic output formatting} | 
					
						
							| 
									
										
										
										
											1998-07-23 17:59:49 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1999-02-19 23:48:05 +00:00
										 |  |  | \declaremodule{standard}{formatter} | 
					
						
							| 
									
										
										
										
											1998-07-23 17:59:49 +00:00
										 |  |  | \modulesynopsis{Generic output formatter and device interface.} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-07-16 19:01:10 +00:00
										 |  |  | This module supports two interface definitions, each with multiple | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | implementations.  The \emph{formatter} interface is used by the | 
					
						
							| 
									
										
										
										
											1999-04-22 21:23:22 +00:00
										 |  |  | \class{HTMLParser} class of the \refmodule{htmllib} module, and the | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | \emph{writer} interface is required by the formatter interface. | 
					
						
							| 
									
										
										
										
											1998-04-04 06:25:27 +00:00
										 |  |  | \withsubitem{(class in htmllib)}{\ttindex{HTMLParser}} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | Formatter objects transform an abstract flow of formatting events into | 
					
						
							|  |  |  | specific output events on writer objects.  Formatters manage several | 
					
						
							|  |  |  | stack structures to allow various properties of a writer object to be | 
					
						
							|  |  |  | changed and restored; writers need not be able to handle relative | 
					
						
							|  |  |  | changes nor any sort of ``change back'' operation.  Specific writer | 
					
						
							|  |  |  | properties which may be controlled via formatter objects are | 
					
						
							|  |  |  | horizontal alignment, font, and left margin indentations.  A mechanism | 
					
						
							|  |  |  | is provided which supports providing arbitrary, non-exclusive style | 
					
						
							|  |  |  | settings to a writer as well.  Additional interfaces facilitate | 
					
						
							|  |  |  | formatting events which are not reversible, such as paragraph | 
					
						
							|  |  |  | separation. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Writer objects encapsulate device interfaces.  Abstract devices, such | 
					
						
							|  |  |  | as file formats, are supported as well as physical devices.  The | 
					
						
							|  |  |  | provided implementations all work with abstract devices.  The | 
					
						
							|  |  |  | interface makes available mechanisms for setting the properties which | 
					
						
							|  |  |  | formatter objects manage and inserting data into the output. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1999-02-19 23:48:05 +00:00
										 |  |  | \subsection{The Formatter Interface \label{formatter-interface}} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | Interfaces to create formatters are dependent on the specific | 
					
						
							|  |  |  | formatter class being instantiated.  The interfaces described below | 
					
						
							|  |  |  | are the required interfaces which all formatters must support once | 
					
						
							|  |  |  | initialized. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | One data element is defined at the module level: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | \begin{datadesc}{AS_IS} | 
					
						
							|  |  |  | Value which can be used in the font specification passed to the | 
					
						
							|  |  |  | \code{push_font()} method described below, or as the new value to any | 
					
						
							|  |  |  | other \code{push_\var{property}()} method.  Pushing the \code{AS_IS} | 
					
						
							|  |  |  | value allows the corresponding \code{pop_\var{property}()} method to | 
					
						
							|  |  |  | be called without having to track whether the property was changed. | 
					
						
							|  |  |  | \end{datadesc} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The following attributes are defined for formatter instance objects: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1996-10-09 16:13:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{memberdesc}[formatter]{writer} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | The writer instance with which the formatter interacts. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{memberdesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1996-10-09 16:13:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[formatter]{end_paragraph}{blanklines} | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | Close any open paragraphs and insert at least \var{blanklines} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | before the next paragraph. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[formatter]{add_line_break}{} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | Add a hard line break if one does not already exist.  This does not | 
					
						
							|  |  |  | break the logical paragraph. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[formatter]{add_hor_rule}{*args, **kw} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | Insert a horizontal rule in the output.  A hard break is inserted if | 
					
						
							|  |  |  | there is data in the current paragraph, but the logical paragraph is | 
					
						
							|  |  |  | not broken.  The arguments and keywords are passed on to the writer's | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | \method{send_line_break()} method. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[formatter]{add_flowing_data}{data} | 
					
						
							| 
									
										
										
										
											2000-07-16 19:01:10 +00:00
										 |  |  | Provide data which should be formatted with collapsed whitespace. | 
					
						
							|  |  |  | Whitespace from preceding and successive calls to | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | \method{add_flowing_data()} is considered as well when the whitespace | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | collapse is performed.  The data which is passed to this method is | 
					
						
							|  |  |  | expected to be word-wrapped by the output device.  Note that any | 
					
						
							|  |  |  | word-wrapping still must be performed by the writer object due to the | 
					
						
							|  |  |  | need to rely on device and font information. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[formatter]{add_literal_data}{data} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | Provide data which should be passed to the writer unchanged. | 
					
						
							|  |  |  | Whitespace, including newline and tab characters, are considered legal | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | in the value of \var{data}.   | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[formatter]{add_label_data}{format, counter} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | Insert a label which should be placed to the left of the current left | 
					
						
							|  |  |  | margin.  This should be used for constructing bulleted or numbered | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | lists.  If the \var{format} value is a string, it is interpreted as a | 
					
						
							|  |  |  | format specification for \var{counter}, which should be an integer. | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | The result of this formatting becomes the value of the label; if | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | \var{format} is not a string it is used as the label value directly. | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | The label value is passed as the only argument to the writer's | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | \method{send_label_data()} method.  Interpretation of non-string label | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | values is dependent on the associated writer. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Format specifications are strings which, in combination with a counter | 
					
						
							|  |  |  | value, are used to compute label values.  Each character in the format | 
					
						
							|  |  |  | string is copied to the label value, with some characters recognized | 
					
						
							|  |  |  | to indicate a transform on the counter value.  Specifically, the | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | character \character{1} represents the counter value formatter as an | 
					
						
							| 
									
										
										
										
											2000-07-16 19:01:10 +00:00
										 |  |  | Arabic number, the characters \character{A} and \character{a} | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | represent alphabetic representations of the counter value in upper and | 
					
						
							|  |  |  | lower case, respectively, and \character{I} and \character{i} | 
					
						
							|  |  |  | represent the counter value in Roman numerals, in upper and lower | 
					
						
							|  |  |  | case.  Note that the alphabetic and roman transforms require that the | 
					
						
							|  |  |  | counter value be greater than zero. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[formatter]{flush_softspace}{} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | Send any pending whitespace buffered from a previous call to | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | \method{add_flowing_data()} to the associated writer object.  This | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | should be called before any direct manipulation of the writer object. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[formatter]{push_alignment}{align} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | Push a new alignment setting onto the alignment stack.  This may be | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | \constant{AS_IS} if no change is desired.  If the alignment value is | 
					
						
							|  |  |  | changed from the previous setting, the writer's \method{new_alignment()} | 
					
						
							|  |  |  | method is called with the \var{align} value. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[formatter]{pop_alignment}{} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | Restore the previous alignment. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[formatter]{push_font}{\code{(}size, italic, bold, teletype\code{)}} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | Change some or all font properties of the writer object.  Properties | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | which are not set to \constant{AS_IS} are set to the values passed in | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | while others are maintained at their current settings.  The writer's | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | \method{new_font()} method is called with the fully resolved font | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | specification. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[formatter]{pop_font}{} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | Restore the previous font. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[formatter]{push_margin}{margin} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | Increase the number of left margin indentations by one, associating | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | the logical tag \var{margin} with the new indentation.  The initial | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | margin level is \code{0}.  Changed values of the logical tag must be | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | true values; false values other than \constant{AS_IS} are not | 
					
						
							|  |  |  | sufficient to change the margin. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[formatter]{pop_margin}{} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | Restore the previous margin. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[formatter]{push_style}{*styles} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | Push any number of arbitrary style specifications.  All styles are | 
					
						
							|  |  |  | pushed onto the styles stack in order.  A tuple representing the | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | entire stack, including \constant{AS_IS} values, is passed to the | 
					
						
							|  |  |  | writer's \method{new_styles()} method. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[formatter]{pop_style}{\optional{n\code{ = 1}}} | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | Pop the last \var{n} style specifications passed to | 
					
						
							|  |  |  | \method{push_style()}.  A tuple representing the revised stack, | 
					
						
							|  |  |  | including \constant{AS_IS} values, is passed to the writer's | 
					
						
							|  |  |  | \method{new_styles()} method. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[formatter]{set_spacing}{spacing} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | Set the spacing style for the writer. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[formatter]{assert_line_data}{\optional{flag\code{ = 1}}} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | Inform the formatter that data has been added to the current paragraph | 
					
						
							|  |  |  | out-of-band.  This should be used when the writer has been manipulated | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | directly.  The optional \var{flag} argument can be set to false if | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | the writer manipulations produced a hard line break at the end of the | 
					
						
							|  |  |  | output. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1999-02-19 23:48:05 +00:00
										 |  |  | \subsection{Formatter Implementations \label{formatter-impls}} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1996-10-09 16:13:22 +00:00
										 |  |  | Two implementations of formatter objects are provided by this module. | 
					
						
							|  |  |  | Most applications may use one of these classes without modification or | 
					
						
							|  |  |  | subclassing. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | \begin{classdesc}{NullFormatter}{\optional{writer}} | 
					
						
							|  |  |  | A formatter which does nothing.  If \var{writer} is omitted, a | 
					
						
							|  |  |  | \class{NullWriter} instance is created.  No methods of the writer are | 
					
						
							|  |  |  | called by \class{NullFormatter} instances.  Implementations should | 
					
						
							|  |  |  | inherit from this class if implementing a writer interface but don't | 
					
						
							|  |  |  | need to inherit any implementation. | 
					
						
							|  |  |  | \end{classdesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | \begin{classdesc}{AbstractFormatter}{writer} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | The standard formatter.  This implementation has demonstrated wide | 
					
						
							|  |  |  | applicability to many writers, and may be used directly in most | 
					
						
							| 
									
										
										
										
											1996-10-09 16:13:22 +00:00
										 |  |  | circumstances.  It has been used to implement a full-featured | 
					
						
							|  |  |  | world-wide web browser. | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | \end{classdesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1999-02-19 23:48:05 +00:00
										 |  |  | \subsection{The Writer Interface \label{writer-interface}} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | Interfaces to create writers are dependent on the specific writer | 
					
						
							|  |  |  | class being instantiated.  The interfaces described below are the | 
					
						
							|  |  |  | required interfaces which all writers must support once initialized. | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | Note that while most applications can use the | 
					
						
							|  |  |  | \class{AbstractFormatter} class as a formatter, the writer must | 
					
						
							|  |  |  | typically be provided by the application. | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1996-10-09 16:13:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[writer]{flush}{} | 
					
						
							| 
									
										
										
										
											1996-12-31 20:51:42 +00:00
										 |  |  | Flush any buffered output or device control events. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-12-31 20:51:42 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[writer]{new_alignment}{align} | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | Set the alignment style.  The \var{align} value can be any object, | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | but by convention is a string or \code{None}, where \code{None} | 
					
						
							|  |  |  | indicates that the writer's ``preferred'' alignment should be used. | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | Conventional \var{align} values are \code{'left'}, \code{'center'}, | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | \code{'right'}, and \code{'justify'}. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[writer]{new_font}{font} | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | Set the font style.  The value of \var{font} will be \code{None}, | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | indicating that the device's default font should be used, or a tuple | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | of the form \code{(}\var{size}, \var{italic}, \var{bold}, | 
					
						
							|  |  |  | \var{teletype}\code{)}.  Size will be a string indicating the size of | 
					
						
							|  |  |  | font that should be used; specific strings and their interpretation | 
					
						
							|  |  |  | must be defined by the application.  The \var{italic}, \var{bold}, and | 
					
						
							|  |  |  | \var{teletype} values are boolean indicators specifying which of those | 
					
						
							|  |  |  | font attributes should be used. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[writer]{new_margin}{margin, level} | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | Set the margin level to the integer \var{level} and the logical tag | 
					
						
							|  |  |  | to \var{margin}.  Interpretation of the logical tag is at the | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | writer's discretion; the only restriction on the value of the logical | 
					
						
							|  |  |  | tag is that it not be a false value for non-zero values of | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | \var{level}. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[writer]{new_spacing}{spacing} | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | Set the spacing style to \var{spacing}. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[writer]{new_styles}{styles} | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | Set additional styles.  The \var{styles} value is a tuple of | 
					
						
							|  |  |  | arbitrary values; the value \constant{AS_IS} should be ignored.  The | 
					
						
							|  |  |  | \var{styles} tuple may be interpreted either as a set or as a stack | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | depending on the requirements of the application and writer | 
					
						
							|  |  |  | implementation. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[writer]{send_line_break}{} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | Break the current line. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[writer]{send_paragraph}{blankline} | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | Produce a paragraph separation of at least \var{blankline} blank | 
					
						
							| 
									
										
										
										
											2000-07-16 19:01:10 +00:00
										 |  |  | lines, or the equivalent.  The \var{blankline} value will be an | 
					
						
							| 
									
										
										
										
											1999-01-12 18:33:47 +00:00
										 |  |  | integer.  Note that the implementation will receive a call to | 
					
						
							|  |  |  | \method{send_line_break()} before this call if a line break is needed;  | 
					
						
							|  |  |  | this method should not include ending the last line of the paragraph. | 
					
						
							|  |  |  | It is only responsible for vertical spacing between paragraphs. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[writer]{send_hor_rule}{*args, **kw} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | Display a horizontal rule on the output device.  The arguments to this | 
					
						
							|  |  |  | method are entirely application- and writer-specific, and should be | 
					
						
							|  |  |  | interpreted with care.  The method implementation may assume that a | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | line break has already been issued via \method{send_line_break()}. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[writer]{send_flowing_data}{data} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | Output character data which may be word-wrapped and re-flowed as | 
					
						
							|  |  |  | needed.  Within any sequence of calls to this method, the writer may | 
					
						
							|  |  |  | assume that spans of multiple whitespace characters have been | 
					
						
							|  |  |  | collapsed to single space characters. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[writer]{send_literal_data}{data} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | Output character data which has already been formatted | 
					
						
							|  |  |  | for display.  Generally, this should be interpreted to mean that line | 
					
						
							|  |  |  | breaks indicated by newline characters should be preserved and no new | 
					
						
							|  |  |  | line breaks should be introduced.  The data may contain embedded | 
					
						
							|  |  |  | newline and tab characters, unlike data provided to the | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | \method{send_formatted_data()} interface. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \begin{methoddesc}[writer]{send_label_data}{data} | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | Set \var{data} to the left of the current left margin, if possible. | 
					
						
							|  |  |  | The value of \var{data} is not restricted; treatment of non-string | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | values is entirely application- and writer-dependent.  This method | 
					
						
							|  |  |  | will only be called at the beginning of a line. | 
					
						
							| 
									
										
										
										
											1998-03-27 05:27:08 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1999-02-22 14:14:48 +00:00
										 |  |  | \subsection{Writer Implementations \label{writer-impls}} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1996-10-09 16:13:22 +00:00
										 |  |  | Three implementations of the writer object interface are provided as | 
					
						
							|  |  |  | examples by this module.  Most applications will need to derive new | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | writer classes from the \class{NullWriter} class. | 
					
						
							| 
									
										
										
										
											1996-10-09 16:13:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-16 05:07:04 +00:00
										 |  |  | \begin{classdesc}{NullWriter}{} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | A writer which only provides the interface definition; no actions are | 
					
						
							|  |  |  | taken on any methods.  This should be the base class for all writers | 
					
						
							|  |  |  | which do not need to inherit any implementation methods. | 
					
						
							| 
									
										
										
										
											1998-03-16 05:07:04 +00:00
										 |  |  | \end{classdesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-16 05:07:04 +00:00
										 |  |  | \begin{classdesc}{AbstractWriter}{} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | A writer which can be used in debugging formatters, but not much | 
					
						
							| 
									
										
										
										
											1998-01-15 05:49:00 +00:00
										 |  |  | else.  Each method simply announces itself by printing its name and | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | arguments on standard output. | 
					
						
							| 
									
										
										
										
											1998-03-16 05:07:04 +00:00
										 |  |  | \end{classdesc} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-17 06:33:25 +00:00
										 |  |  | \begin{classdesc}{DumbWriter}{\optional{file\optional{, maxcol\code{ = 72}}}} | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | Simple writer class which writes output on the file object passed in | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | as \var{file} or, if \var{file} is omitted, on standard output.  The | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | output is simply word-wrapped to the number of columns specified by | 
					
						
							| 
									
										
										
										
											1998-03-12 15:33:05 +00:00
										 |  |  | \var{maxcol}.  This class is suitable for reflowing a sequence of | 
					
						
							| 
									
										
										
										
											1996-10-08 21:53:33 +00:00
										 |  |  | paragraphs. | 
					
						
							| 
									
										
										
										
											1998-03-16 05:07:04 +00:00
										 |  |  | \end{classdesc} |