1 /************************************************************************/
2 /*									*/
3 /*  Manage the particules and lines in a paragraph.			*/
4 /*									*/
5 /************************************************************************/
6 
7 #   ifndef	DOC_PARA_PARICULES_H
8 #   define	DOC_PARA_PARICULES_H
9 
10 #   include	"docBuf.h"
11 #   include	<docTextParticule.h>
12 #   include	<docTextLine.h>
13 #   include	"docTreeNode.h"
14 
15 		/**
16 		  * Find the first particule that containd this position
17 		  */
18 #   define	PARAfindFIRST	0
19 		/**
20 		  * Find the last particule that containd this position
21 		  */
22 #   define	PARAfindLAST	1
23 		/**
24 		  * Find the last particule that contains this position
25 		  * Or.. If it is the last position in the paragraph,
26 		  * return the position past the last particule.
27 		  */
28 #   define	PARAfindPAST	2
29 
30 /************************************************************************/
31 
32 			/**
33 			 *  The position is at the head of the particule.
34 			 */
35 #   define	POSflagPART_HEAD	0x01
36 			/**
37 			 *  The position is at the tail of the particule.
38 			 */
39 #   define	POSflagPART_TAIL	0x02
40 			/**
41 			 *  The position is immediately after a line or page
42 			 *  break.
43 			 */
44 #   define	POSflagPART_AFTER_BREAK	0x04
45 
46 			/**
47 			 *  The position is at the head of the line.
48 			 */
49 #   define	POSflagLINE_HEAD	0x08
50 			/**
51 			 *  The position is at the tail of the line.
52 			 */
53 #   define	POSflagLINE_TAIL	0x10
54 
55 			/**
56 			 *  The position is at the head of the paragraph.
57 			 */
58 #   define	POSflagPARA_HEAD	0x20
59 			/**
60 			 *  The position is at the tail of the paragraph.
61 			 */
62 #   define	POSflagPARA_TAIL	0x40
63 
64 			/**
65 			 *  Used when a position is compared to a selection.
66 			 *  The flag is set if the position is in the selection.
67 			 */
68 #   define	POSflagPARA_FOUND	0x80
69 
70 /************************************************************************/
71 /*									*/
72 /*  Routine declarations.						*/
73 /*									*/
74 /************************************************************************/
75 
76 extern int docFindParticuleOfPosition(
77 				int *				pPart,
78 				int *				pFlags,
79 				const DocumentPosition *	dp,
80 				int				lastOne );
81 
82 extern int docFindLineOfPosition( int *				pLine,
83 				int *				pFlags,
84 				const DocumentPosition *	dp,
85 				int				lastOne );
86 
87 extern void docInitParaNode(	BufferItem *			paraBi );
88 extern int docDeleteEmptySpan(	BufferItem *			paraBi );
89 
90 extern void docCleanParaNode(	BufferDocument *		bd,
91 				DocumentTree *			dt,
92 				BufferItem *			paraBi );
93 
94 extern TextParticule *	docInsertParticules(	BufferItem *	paraBi,
95 						int		part,
96 						int		count );
97 
98 extern void docDeleteParticules(	BufferItem *	bi,
99 					int		first,
100 					int		count );
101 
102 extern int docInsertAdminParticule(	BufferDocument *	bd,
103 					BufferItem *		paraBi,
104 					int			n,
105 					int			off,
106 					int			objectNumber,
107 					int			kind,
108 					const TextAttribute *	ta );
109 
110 extern TextParticule *	docInsertTextParticule(	BufferItem *	bi,
111 						int		n,
112 						int		off,
113 						int		len,
114 						int		kind,
115 						int		textAttrNr );
116 
117 extern TextParticule * docMakeSpecialParticule(
118 				BufferItem *			paraBi,
119 				int				n,
120 				int				stroff,
121 				int				kind,
122 				int				textAttrNr );
123 
124 extern int docSaveSpecialParticule(	BufferDocument *	bd,
125 					BufferItem *		paraBi,
126 					const TextAttribute *	ta,
127 					int			kind );
128 
129 extern int docShiftParticuleOffsets(	BufferDocument *	bd,
130 					BufferItem *		paraBi,
131 					int			partFrom,
132 					int			partUpto,
133 					int			stroffShift );
134 
135 extern int docSplitTextParticule( TextParticule **		pTpPart,
136 				TextParticule **		pTpNext,
137 				BufferItem *			paraBi,
138 				int				part,
139 				int				stroff );
140 
141 extern TextLine * docInsertTextLine(	BufferItem *	bi,
142 					int		line );
143 
144 extern TextParticule *	docAppendObject(	BufferDocument *	bd,
145 						BufferItem *		paraNode,
146 						const TextAttribute *	ta );
147 
148 extern void docCleanParticuleObject(	BufferDocument *	bd,
149 					TextParticule *		tp );
150 
151 extern int docIntersectSelectionWithParagraph(
152 				    DocumentSelection *		dsPara,
153 				    int *			pPartFrom,
154 				    int *			pPartUpto,
155 				    int *			pHeadFlags,
156 				    int *			pTailFlags,
157 				    const BufferItem *		paraNode,
158 				    const DocumentSelection *	ds );
159 
160 #   endif		/*  DOC_PARA_PARICULES_H	*/
161