| 1 |
/* |
| 2 |
* $LynxId: HText.h,v 1.19 2025/06/19 19:51:32 Eric.Lindblad Exp $ |
| 3 |
* Rich Hypertext object for libWWW |
| 4 |
* RICH HYPERTEXT OBJECT |
| 5 |
* |
| 6 |
* This is the C interface to the Objective-C (or whatever) Style-oriented |
| 7 |
* HyperText class. It is used when a style-oriented text object is available |
| 8 |
* or created in order to display hypertext. |
| 9 |
*/ |
| 10 |
#ifndef HTEXT_H |
| 11 |
#define HTEXT_H |
| 12 |
|
| 13 |
#include <HTAnchor.h> |
| 14 |
#include <HTStyle.h> |
| 15 |
#include <HTStream.h> |
| 16 |
#include <SGML.h> |
| 17 |
|
| 18 |
#ifdef __cplusplus |
| 19 |
extern "C" { |
| 20 |
#endif |
| 21 |
#ifndef THINK_C |
| 22 |
#ifndef HyperText /* Objective C version defined HyperText */ |
| 23 |
typedef struct _HText HText; /* Normal Library */ |
| 24 |
#endif |
| 25 |
#else |
| 26 |
class CHyperText; /* Mac Think-C browser hook */ |
| 27 |
typedef CHyperText HText; |
| 28 |
#endif |
| 29 |
|
| 30 |
extern HText *HTMainText; /* Pointer to current main text */ |
| 31 |
extern HTParentAnchor *HTMainAnchor; /* Pointer to current text's anchor */ |
| 32 |
|
| 33 |
extern const char *HTAppName; /* Application name */ |
| 34 |
extern const char *HTAppVersion; /* Application version */ |
| 35 |
|
| 36 |
/* |
| 37 |
|
| 38 |
Creation and deletion |
| 39 |
|
| 40 |
HTEXT_NEW: CREATE HYPERTEXT OBJECT |
| 41 |
|
| 42 |
There are several methods depending on how much you want to specify. The |
| 43 |
output stream is used with objects which need to output the hypertext to a |
| 44 |
stream. The structure is for objects which need to refer to the structure |
| 45 |
which is kep by the creating stream. |
| 46 |
|
| 47 |
*/ |
| 48 |
extern HText *HText_new(HTParentAnchor *anchor); |
| 49 |
|
| 50 |
extern HText *HText_new2(HTParentAnchor *anchor, |
| 51 |
HTStream *output_stream); |
| 52 |
|
| 53 |
extern HText *HText_new3(HTParentAnchor *anchor, |
| 54 |
HTStream *output_stream, |
| 55 |
HTStructured * structure); |
| 56 |
|
| 57 |
/* |
| 58 |
|
| 59 |
FREE HYPERTEXT OBJECT |
| 60 |
|
| 61 |
*/ |
| 62 |
extern void HText_free(HText *me); |
| 63 |
|
| 64 |
/* |
| 65 |
|
| 66 |
Object Building methods |
| 67 |
|
| 68 |
These are used by a parser to build the text in an object HText_beginAppend |
| 69 |
must be called, then any combination of other append calls, then |
| 70 |
HText_endAppend. This allows optimised handling using buffers and caches |
| 71 |
which are flushed at the end. |
| 72 |
|
| 73 |
*/ |
| 74 |
extern void HText_beginAppend(HText *text); |
| 75 |
|
| 76 |
extern void HText_endAppend(HText *text); |
| 77 |
|
| 78 |
/* |
| 79 |
|
| 80 |
SET THE STYLE FOR FUTURE TEXT |
| 81 |
|
| 82 |
*/ |
| 83 |
|
| 84 |
extern void HText_setStyle(HText *text, HTStyle *style); |
| 85 |
|
| 86 |
/* |
| 87 |
|
| 88 |
ADD ONE CHARACTER |
| 89 |
|
| 90 |
*/ |
| 91 |
extern void HText_appendCharacter(HText *text, int ch); |
| 92 |
|
| 93 |
/* |
| 94 |
|
| 95 |
ADD A ZERO-TERMINATED STRING |
| 96 |
|
| 97 |
*/ |
| 98 |
|
| 99 |
extern void HText_appendText(HText *text, const char *str); |
| 100 |
|
| 101 |
/* |
| 102 |
|
| 103 |
NEW PARAGRAPH |
| 104 |
|
| 105 |
and similar things |
| 106 |
|
| 107 |
*/ |
| 108 |
extern void HText_appendParagraph(HText *text); |
| 109 |
|
| 110 |
extern void HText_appendLineBreak(HText *text); |
| 111 |
|
| 112 |
extern void HText_appendHorizontalRule(HText *text); |
| 113 |
|
| 114 |
/* |
| 115 |
|
| 116 |
START/END SENSITIVE TEXT |
| 117 |
|
| 118 |
*/ |
| 119 |
|
| 120 |
/* |
| 121 |
|
| 122 |
The anchor object is created and passed to HText_beginAnchor. The sensitive |
| 123 |
text is added to the text object, and then HText_endAnchor is called. |
| 124 |
Anchors may not be nested. |
| 125 |
|
| 126 |
*/ |
| 127 |
extern int HText_beginAnchor(HText *text, int underline, |
| 128 |
HTChildAnchor *anc); |
| 129 |
extern void HText_endAnchor(HText *text, int number); |
| 130 |
extern BOOL HText_isAnchorBlank(HText *text, int number); |
| 131 |
|
| 132 |
/* |
| 133 |
|
| 134 |
APPEND AN INLINE IMAGE |
| 135 |
|
| 136 |
The image is handled by the creation of an anchor whose destination is the |
| 137 |
image document to be included. The semantics is the intended inline display |
| 138 |
of the image. |
| 139 |
|
| 140 |
An alternative implementation could be, for example, to begin an anchor, |
| 141 |
append the alternative text or "IMAGE", then end the anchor. This would |
| 142 |
simply generate some text linked to the image itself as a separate document. |
| 143 |
|
| 144 |
*/ |
| 145 |
extern void HText_appendImage(HText *text, HTChildAnchor *anc, |
| 146 |
const char *alternative_text, |
| 147 |
int alignment, |
| 148 |
int isMap); |
| 149 |
|
| 150 |
/* |
| 151 |
|
| 152 |
RETURN THE ANCHOR ASSOCIATED WITH THIS NODE |
| 153 |
|
| 154 |
*/ |
| 155 |
extern HTParentAnchor *HText_nodeAnchor(HText *me); |
| 156 |
|
| 157 |
/* |
| 158 |
|
| 159 |
Browsing functions |
| 160 |
|
| 161 |
*/ |
| 162 |
|
| 163 |
/* |
| 164 |
|
| 165 |
BRING TO FRONT AND HIGHLIGHT IT |
| 166 |
|
| 167 |
*/ |
| 168 |
|
| 169 |
extern BOOL HText_select(HText *text); |
| 170 |
extern BOOL HText_selectAnchor(HText *text, HTChildAnchor *anchor); |
| 171 |
|
| 172 |
/* |
| 173 |
|
| 174 |
Editing functions |
| 175 |
|
| 176 |
These are called from the application. There are many more functions not |
| 177 |
included here from the original text object. These functions NEED NOT BE |
| 178 |
IMPLEMENTED in a browser which cannot edit. |
| 179 |
|
| 180 |
*/ |
| 181 |
/* Style handling: |
| 182 |
*/ |
| 183 |
/* Apply this style to the selection |
| 184 |
*/ |
| 185 |
extern void HText_applyStyle(HText *me, HTStyle *style); |
| 186 |
|
| 187 |
/* Update all text with changed style. |
| 188 |
*/ |
| 189 |
extern void HText_updateStyle(HText *me, HTStyle *style); |
| 190 |
|
| 191 |
/* Return style of selection |
| 192 |
*/ |
| 193 |
extern HTStyle *HText_selectionStyle(HText *me, HTStyleSheet *sheet); |
| 194 |
|
| 195 |
/* Paste in styled text |
| 196 |
*/ |
| 197 |
extern void HText_replaceSel(HText *me, const char *aString, |
| 198 |
HTStyle *aStyle); |
| 199 |
|
| 200 |
/* Apply this style to the selection and all similarly formatted text |
| 201 |
* (style recovery only) |
| 202 |
*/ |
| 203 |
extern void HTextApplyToSimilar(HText *me, HTStyle *style); |
| 204 |
|
| 205 |
/* Select the first unstyled run. |
| 206 |
* (style recovery only) |
| 207 |
*/ |
| 208 |
extern void HTextSelectUnstyled(HText *me, HTStyleSheet *sheet); |
| 209 |
|
| 210 |
/* Anchor handling: |
| 211 |
*/ |
| 212 |
extern void HText_unlinkSelection(HText *me); |
| 213 |
extern HTAnchor *HText_referenceSelected(HText *me); |
| 214 |
extern HTAnchor *HText_linkSelTo(HText *me, HTAnchor * anchor); |
| 215 |
|
| 216 |
#ifdef __cplusplus |
| 217 |
} |
| 218 |
#endif |
| 219 |
#endif /* HTEXT_H */ |