12b9638eb488622dd574777c546460bdb74b57e4
[m17n/m17n-lib.git] / src / textprop.h
1 /* textproc.h -- header file for the text property module.
2    Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
3      National Institute of Advanced Industrial Science and Technology (AIST)
4      Registration Number H15PRO112
5
6    This file is part of the m17n library.
7
8    The m17n library is free software; you can redistribute it and/or
9    modify it under the terms of the GNU Lesser General Public License
10    as published by the Free Software Foundation; either version 2.1 of
11    the License, or (at your option) any later version.
12
13    The m17n library is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16    Lesser General Public License for more details.
17
18    You should have received a copy of the GNU Lesser General Public
19    License along with the m17n library; if not, write to the Free
20    Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21    02111-1307, USA.  */
22
23 #ifndef _M17N_TEXTPROP_H_
24 #define _M17N_TEXTPROP_H_
25
26 /** MTextProperty is the structure for a text property object.  While
27     attached, it is stored in the stacks of intervals covering the
28     range from MTextProperty->start to MTextProperty->end.  */
29
30 struct MTextProperty
31 {
32   /** Common header for a managed object.  */
33   M17NObject control;
34
35   /** Number of intervals the property is attached.  When it becomes
36       zero, the property is detached.  */
37   unsigned attach_count;
38
39   /** M-text to which the property is attaced.  The value NULL means
40       that the property is detached.  */
41   MText *mt;
42
43   /** Region of <mt> if the property is attached to it.  */
44   int start, end;
45
46   /** Key of the property.  */
47   MSymbol key;
48
49   /** Value of the property.  */
50   void *val;
51 };
52
53 #define MTEXTPROP_START(prop) (prop)->start
54 #define MTEXTPROP_END(prop) (prop)->end
55 #define MTEXTPROP_KEY(prop) (prop)->key
56 #define MTEXTPROP_VAL(prop) (prop)->val
57
58 extern struct MTextPlist *mtext__copy_plist (struct MTextPlist *, 
59                                              int from, int to,
60                                              MText *mt, int pos);
61
62 extern void mtext__free_plist (MText *mt);
63
64 extern void mtext__adjust_plist_for_delete (MText *, int, int);
65
66 extern void mtext__adjust_plist_for_insert (MText *, int, int,
67                                             struct MTextPlist *);
68
69 extern void mtext__adjust_plist_for_change (MText *mt, int pos,
70                                             int len1, int len2);
71
72 extern void dump_textplist (struct MTextPlist *plist, int indent);
73
74 #endif /* _M17N_TEXTPROP_H_ */