File:  [Public] / libwww / Library / src / HText.html
Revision 2.23: download - view: text, annotated - select for diffs
Mon Nov 20 00:15:40 1995 UTC (28 years, 6 months ago) by frystyk
Branches: MAIN
CVS tags: v4/0pre6, v4/0, HEAD
Merged Error and Dialog system

<HTML>
<HEAD>
<TITLE>Rich Hypertext object</TITLE>
<!-- Changed by: Henrik Frystyk Nielsen, 19-Nov-1995 -->
</HEAD>
<BODY>

<H1>Rich HyperText Object</H1>

<PRE>
/*
**	(c) COPYRIGHT MIT 1995.
**	Please first read the full copyright statement in the file COPYRIGH.
*/
</PRE>

This is the C interface to the Objective-C (or whatever)
Style-oriented HyperText class. It is used when a style-oriented text
object is available or craeted in order to display hypertext. <P>

This module is a part of the <A
HREF="http://www.w3.org/pub/WWW/Library/">
W3C Reference Library</A>. However, it is <B>NOT</B> implemented
anywhere in the library, as it is client (and often platform) specific
code. Hence these functions <EM>must</EM> be implemented in the
client. The <A
HREF="http://www.w3.org/pub/WWW/LineMode/">Line Mode
Browser</A> has the implementation in the <A
HREF="http://www.w3.org/pub/WWW/LineMode/Implementation/GridText.html">
GridText</A> module.

<PRE>
#ifndef HTEXT_H
#define HTEXT_H

#include "HTAnchor.h"
#include "HTStyle.h"
#include "HTStruct.h"

#ifndef HyperText		/* Objective C version defined HyperText */
typedef struct _HText HText;	/* Normal Library */
#else
@class HText;			/* Objective C version for NeXTStep */
#endif

extern HText * HTMainText;		/* Pointer to current main text */
extern HTParentAnchor * HTMainAnchor;	/* Pointer to current text's anchor */
</PRE>

<H2>Creation and deletion</H2>

<A NAME="z0"><H3>Create hypertext object</H3></A>

There are several methods depending on how much you want to specify.
The output stream is used with objects which need to output the
hypertext to a stream.  The structure is for objects which need to
refer to the structure which is kep by the creating stream.

<PRE>
extern HText *	HText_new	(HTParentAnchor *anchor);

extern HText *	HText_new2	(HTParentAnchor *anchor,
					HTStream * 	output_stream);

extern HText *	HText_new3	(HTRequest *	request,
					HTStream *	output_stream,
					HTStructured *	structure);
</PRE>

<H3>Free hypertext object</H3>

<PRE>
extern void 	HText_free (HText * me);
</PRE>

<H2>Object Building methods</H2>

These are used by a parser to build the text in an object
HText_beginAppend must be called, then any combination of other append
calls, then HText_endAppend.  This allows optimised handling using
buffers and caches which are flushed at the end.

<PRE>
extern void HText_beginAppend (HText * text);

extern void HText_endAppend (HText * text);
</PRE>

<H3>Set the style for future text</H3>

<PRE>
extern void HText_setStyle (HText * text, HTStyle * style);

</PRE>
<H3>Add one character</H3>
<PRE>extern void HText_appendCharacter (HText * text, char ch);

</PRE>
<H3>Add a zero-terminated string</H3>
<PRE>
extern void HText_appendText (HText * text, CONST char * str);

</PRE>

<H3>New Paragraph</H3>

and similar things

<PRE>
extern void HText_appendParagraph (HText * text);

extern void HText_appendLineBreak (HText * text);

extern void HText_appendHorizontalRule (HText * text);
</PRE>

<H3>Start/end sensitive text</H3>

The anchor object is created and passed to HText_beginAnchor. The
senstive text is added to the text object, and then HText_endAnchor is
called. Anchors may not be nested.

<PRE>extern void HText_beginAnchor (HText * text, HTChildAnchor * anc);
extern void HText_endAnchor (HText * text);


</PRE>
<h3>Set the next free identifier</h3>
The string must be of the form aaannnnn where aaa is the prefix
for automatically generated ids, normally "z", and nnnn is the
next unused number.  If not present, defaults to z0.  An
editor should pick up both the a and n bits, and increment n
when generating ids. This ensures that old ids are not reused,
even if the elements using them have been deleted from the document.
<pre>
extern void HText_setNextId (
	HText *		text,
	CONST char *    s);

</pre>
<H3>Append an inline image</H3>The image is handled by the creation
of an anchor whose destination is
the image document to be included.
The semantics is the intended inline
display of the image.<P>
An alternative implementation could
be, for example, to begin an anchor,
append the alternative text or "IMAGE",
then end the anchor. This would simply
generate some text linked to the
image itself as a separate document.
<H2></H2>
<PRE>extern void HText_appendImage (
	HText * 	text,
	HTChildAnchor * anc,
	CONST char * 	alternative_text,
	CONST char *	alignment,
	BOOL		isMap);

</PRE>
<H3>HText_appendObject:  Append an object
which does its own work</H3>The SGML parameters are passed untouched.
Currently this is only used for empty
elements.  Extensions could be (1)
to pass CDATA contents as well as
any attributes and (2) to pass the
whole structured stream until the
compound object has parsed itself.
<PRE>extern void HText_appendObject (
	HText * 		text,
	int			element_number,
	CONST BOOL *		present,
	CONST char * CONST * 	value);

</PRE>
<H3>HText_unimplemented: Warn that object
is not completely rendered.</H3>If the parser realises that it has
incompletely parsed an object, then
it can call this to flag it to the
object.  This will for example prevent
editing or writing back.
<PRE>extern void HText_unimplemented (
	HText *		text);


</PRE>
<H2>Utilities</H2>
<H3>Dump diagnostics to stderr</H3>
<PRE>
extern void HText_dump (HText * me);	

</PRE>
<H3>Return the anchor associated with
this node</H3>
<PRE>extern HTParentAnchor * HText_nodeAnchor (HText * me);


</PRE>
<H2>Browsing functions</H2>
<PRE>

</PRE>
<H3>Bring to front and highlight it</H3>
<PRE>

extern BOOL HText_select (HText * text); 
extern BOOL HText_selectAnchor (HText * text, HTChildAnchor* anchor); 

</PRE>
<H2>Editing functions</H2>These are called from the application.
There are many more functions not
included here from the orginal text
object. These functions NEED NOT
BE IMPLEMENTED in a browser which
cannot edit.
<PRE>/*	Style handling:
*/
/*	Apply this style to the selection
*/
extern void HText_applyStyle (HText * me, HTStyle *style);

/*	Update all text with changed style.
*/
extern void HText_updateStyle (HText * me, HTStyle *style);

/*	Return style of  selection
*/
extern HTStyle * HText_selectionStyle (
	HText * me,
	HTStyleSheet* sheet);

/*	Paste in styled text
*/
extern void HText_replaceSel (HText * me,
	CONST char *aString, 
	HTStyle* aStyle);

/*	Apply this style to the selection and all similarly formatted text
**	(style recovery only)
*/
extern void HTextApplyToSimilar (HText * me, HTStyle *style);
 
/*	Select the first unstyled run.
**	(style recovery only)
*/
extern void HTextSelectUnstyled (HText * me, HTStyleSheet *sheet);


/*	Anchor handling:
*/
extern void		HText_unlinkSelection (HText * me);
extern HTAnchor *	HText_referenceSelected (HText * me);
extern HTAnchor *	HText_linkSelTo (HText * me, HTAnchor* anchor);


#endif /* HTEXT_H */
</PRE>end</A></BODY>
</HTML>

Webmaster