HText.h
上传用户:zlh9724
上传日期:2007-01-04
资源大小:1991k
文件大小:7k
源码类别:

浏览器

开发平台:

Unix_Linux

  1. /*                                                                      Rich Hypertext object
  2.                                   RICH HYPERTEXT OBJECT
  3.                                              
  4.  */
  5. /*
  6. **      (c) COPYRIGHT MIT 1995.
  7. **      Please first read the full copyright statement in the file COPYRIGH.
  8. */
  9. /*
  10.    This is the C interface to the Objective-C (or whatever) Style-oriented HyperText
  11.    class. It is used when a style-oriented text object is available or craeted in order to
  12.    display hypertext.
  13.    
  14.    This module is a part of the  W3C Reference Library. However, it is NOT implemented
  15.    anywhere in the library, as it is client (and often platform) specific code. Hence
  16.    these functions must be implemented in the client. The Line Mode Browser has the
  17.    implementation in the GridText module.
  18.    
  19.  */
  20. #ifndef HTEXT_H
  21. #define HTEXT_H
  22. #include "HTAnchor.h"
  23. #include "HTStyle.h"
  24. #include "HTStruct.h"
  25. #ifndef HyperText               /* Objective C version defined HyperText */
  26. typedef struct _HText HText;    /* Normal Library */
  27. #else
  28. @class HText;                   /* Objective C version for NeXTStep */
  29. #endif
  30. extern HText * HTMainText;              /* Pointer to current main text */
  31. extern HTParentAnchor * HTMainAnchor;   /* Pointer to current text's anchor */
  32. /*
  33. Creation and deletion
  34.   CREATE HYPERTEXT OBJECT
  35.   
  36.    There are several methods depending on how much you want to specify. The output stream
  37.    is used with objects which need to output the hypertext to a stream.  The structure is
  38.    for objects which need to refer to the structure which is kep by the creating stream.
  39.    
  40.  */
  41. extern HText *  HText_new       (HTRequest * request, HTParentAnchor * anchor);
  42. extern HText *  HText_new2      (HTRequest *            request,
  43.                                  HTParentAnchor *       anchor,
  44.                                  HTStream *             output_stream);
  45. extern HText *  HText_new3      (HTRequest *            request,
  46.                                  HTStream *             output_stream,
  47.                                  HTStructured *         structure);
  48. /*
  49.   FREE HYPERTEXT OBJECT
  50.   
  51.  */
  52. extern void     HText_free (HText * me);
  53. /*
  54. Object Building methods
  55.    These are used by a parser to build the text in an object HText_beginAppend must be
  56.    called, then any combination of other append calls, then HText_endAppend.  This allows
  57.    optimised handling using buffers and caches which are flushed at the end.
  58.    
  59.  */
  60. extern void HText_beginAppend (HText * text);
  61. extern void HText_endAppend (HText * text);
  62. /*
  63.   SET THE STYLE FOR FUTURE TEXT
  64.   
  65.  */
  66. extern void HText_setStyle (HText * text, HTStyle * style);
  67. /*
  68.   ADD ONE CHARACTER
  69.   
  70.  */
  71. extern void HText_appendCharacter (HText * text, char ch);
  72. /*
  73.   ADD A ZERO-TERMINATED STRING
  74.   
  75.  */
  76. extern void HText_appendText (HText * text, CONST char * str);
  77. /*
  78.   NEW PARAGRAPH
  79.   
  80.    and similar things
  81.    
  82.  */
  83. extern void HText_appendParagraph (HText * text);
  84. extern void HText_appendLineBreak (HText * text);
  85. extern void HText_appendHorizontalRule (HText * text);
  86. /*
  87.   START/END SENSITIVE TEXT
  88.   
  89.    The anchor object is created and passed to HText_beginAnchor. The senstive text is
  90.    added to the text object, and then HText_endAnchor is called. Anchors may not be
  91.    nested.
  92.    
  93.  */
  94. extern void HText_beginAnchor (HText * text, HTChildAnchor * anc);
  95. extern void HText_endAnchor (HText * text);
  96. /*
  97.   SET THE NEXT FREE IDENTIFIER
  98.   
  99.    The string must be of the form aaannnnn where aaa is the prefix for automatically
  100.    generated ids, normally "z", and nnnn is the next unused number.  If not present,
  101.    defaults to z0.  An editor should pick up both the a and n bits, and increment n when
  102.    generating ids. This ensures that old ids are not reused, even if the elements using
  103.    them have been deleted from the document.
  104.    
  105.  */
  106. extern void HText_setNextId (
  107.         HText *         text,
  108.         CONST char *    s);
  109. /*
  110.   APPEND AN INLINE IMAGE
  111.   
  112.    The image is handled by the creation of an anchor whose destination is the image
  113.    document to be included. The semantics is the intended inline display of the image.
  114.    
  115.    An alternative implementation could be, for example, to begin an anchor, append the
  116.    alternative text or "IMAGE", then end the anchor. This would simply generate some text
  117.    linked to the image itself as a separate document.
  118.    
  119.  */
  120. extern void HText_appendImage (
  121.         HText *         text,
  122.         HTChildAnchor * anc,
  123.         CONST char *    alternative_text,
  124.         CONST char *    alignment,
  125.         BOOL            isMap);
  126. /*
  127.   HTEXT_APPENDOBJECT:  APPEND AN OBJECT WHICH DOES ITS OWN WORK
  128.   
  129.    The SGML parameters are passed untouched. Currently this is only used for empty
  130.    elements.  Extensions could be (1) to pass CDATA contents as well as any attributes and
  131.    (2) to pass the whole structured stream until the compound object has parsed itself.
  132.    
  133.  */
  134. extern void HText_appendObject (
  135.         HText *                 text,
  136.         int                     element_number,
  137.         CONST BOOL *            present,
  138.         CONST char * CONST *    value);
  139. /*
  140.   HTEXT_UNIMPLEMENTED: WARN THAT OBJECT IS NOT COMPLETELY RENDERED.
  141.   
  142.    If the parser realises that it has incompletely parsed an object, then it can call this
  143.    to flag it to the object.  This will for example prevent editing or writing back.
  144.    
  145.  */
  146. extern void HText_unimplemented (
  147.         HText *         text);
  148. /*
  149. Utilities
  150.   DUMP DIAGNOSTICS TO STDERR
  151.   
  152.  */
  153. extern void HText_dump (HText * me);
  154. /*
  155.   RETURN THE ANCHOR ASSOCIATED WITH THIS NODE
  156.   
  157.  */
  158. extern HTParentAnchor * HText_nodeAnchor (HText * me);
  159. /*
  160. Browsing functions
  161.  */
  162. /*
  163.   BRING TO FRONT AND HIGHLIGHT IT
  164.   
  165.  */
  166. extern BOOL HText_select (HText * text);
  167. extern BOOL HText_selectAnchor (HText * text, HTChildAnchor* anchor);
  168. /*
  169. Editing functions
  170.    These are called from the application. There are many more functions not included here
  171.    from the orginal text object. These functions NEED NOT BE IMPLEMENTED in a browser
  172.    which cannot edit.
  173.    
  174.  */
  175. /*      Style handling:
  176. */
  177. /*      Apply this style to the selection
  178. */
  179. extern void HText_applyStyle (HText * me, HTStyle *style);
  180. /*      Update all text with changed style.
  181. */
  182. extern void HText_updateStyle (HText * me, HTStyle *style);
  183. /*      Return style of  selection
  184. */
  185. extern HTStyle * HText_selectionStyle (
  186.         HText * me,
  187.         HTStyleSheet* sheet);
  188. /*      Paste in styled text
  189. */
  190. extern void HText_replaceSel (HText * me,
  191.         CONST char *aString,
  192.         HTStyle* aStyle);
  193. /*      Apply this style to the selection and all similarly formatted text
  194. **      (style recovery only)
  195. */
  196. extern void HTextApplyToSimilar (HText * me, HTStyle *style);
  197. /*      Select the first unstyled run.
  198. **      (style recovery only)
  199. */
  200. extern void HTextSelectUnstyled (HText * me, HTStyleSheet *sheet);
  201. /*      Anchor handling:
  202. */
  203. extern void             HText_unlinkSelection (HText * me);
  204. extern HTAnchor *       HText_referenceSelected (HText * me);
  205. extern HTAnchor *       HText_linkSelTo (HText * me, HTAnchor* anchor);
  206. #endif /* HTEXT_H */
  207. /*
  208.    end */