Typedefs | |
typedef MPlist *(*) | MTextPropSerializeFunc (void *val) |
Type of serializer functions. | |
typedef void *(*) | MTextPropDeserializeFunc (MPlist *plist) |
Type of deserializer functions. | |
typedef MTextProperty | MTextProperty |
Type of text properties. | |
Enumerations | |
enum | MTextPropertyControl { MTEXTPROP_FRONT_STICKY = 0x01, MTEXTPROP_REAR_STICKY = 0x02, MTEXTPROP_VOLATILE_WEAK = 0x04, MTEXTPROP_VOLATILE_STRONG = 0x08, MTEXTPROP_NO_MERGE = 0x10, MTEXTPROP_CONTROL_MAX = 0x1F } |
Flag bits to control text property. More... | |
Functions | |
void * | mtext_get_prop (MText *mt, int pos, MSymbol key) |
Get the value of the topmost text property. | |
int | mtext_get_prop_values (MText *mt, int pos, MSymbol key, void **values, int num) |
Get multiple values of a text property. | |
int | mtext_get_prop_keys (MText *mt, int pos, MSymbol **keys) |
Get a list of text property keys at a position of an M-text. | |
int | mtext_put_prop (MText *mt, int from, int to, MSymbol key, void *val) |
Set a text property. | |
int | mtext_put_prop_values (MText *mt, int from, int to, MSymbol key, void **values, int num) |
Set multiple text properties with the same key. | |
int | mtext_push_prop (MText *mt, int from, int to, MSymbol key, void *val) |
Push a text property. | |
int | mtext_pop_prop (MText *mt, int from, int to, MSymbol key) |
Pop a text property. | |
int | mtext_prop_range (MText *mt, MSymbol key, int pos, int *from, int *to, int deeper) |
Find the range where the value of a text property is the same. | |
MTextProperty * | mtext_property (MSymbol key, void *val, int control_bits) |
Create a text property. | |
MText * | mtext_property_mtext (MTextProperty *prop) |
Return the M-text of a text property. | |
MSymbol | mtext_property_key (MTextProperty *prop) |
Return the key of a text property. | |
void * | mtext_property_value (MTextProperty *prop) |
Return the value of a text property. | |
int | mtext_property_start (MTextProperty *prop) |
Return the start position of a text property. | |
int | mtext_property_end (MTextProperty *prop) |
Return the end position of a text property. | |
MTextProperty * | mtext_get_property (MText *mt, int pos, MSymbol key) |
Get the topmost text property. | |
int | mtext_get_properties (MText *mt, int pos, MSymbol key, MTextProperty **props, int num) |
Get multiple text properties. | |
int | mtext_attach_property (MText *mt, int from, int to, MTextProperty *prop) |
Attach a text property to an M-text. | |
int | mtext_detach_property (MTextProperty *prop) |
Detach a text property from an M-text. | |
int | mtext_push_property (MText *mt, int from, int to, MTextProperty *prop) |
Push a text property onto an M-text. | |
MText * | mtext_serialize (MText *mt, int from, int to, MPlist *property_list) |
Serialize text properties in an M-text. | |
MText * | mtext_deserialize (MText *mt) |
Deserialize text properties in an M-text. | |
Variables | |
MSymbol | Mtext_prop_serializer |
Symbol for specifying serializer functions. | |
MSymbol | Mtext_prop_deserializer |
Symbol for specifying deserializer functions. |
A text property consists of a key and values, where key is a symbol and values are anything that can be cast to (void *)
. Unlike other types of properties, a text property can have multiple values. "The text property whose key is K" may be shortened to "K property".
typedef MPlist*(*) MTextPropSerializeFunc(void *val) |
This is the type of serializer functions. If the key of a symbol property is Mtext_prop_serializer, the value must be of this type.
typedef void*(*) MTextPropDeserializeFunc(MPlist *plist) |
This is the type of deserializer functions. If the key of a symbol property is Mtext_prop_deserializer, the value must be of this type.
typedef struct MTextProperty MTextProperty |
The type MTextProperty is for a text property objects. Its internal structure is concealed from application programs.
enum MTextPropertyControl |
The mtext_property() function accepts logical OR of these flag bits as an argument. They control the behaviour of the created text property as described in the documentation of each flag bit.
The mtext_get_prop() function searches the character at pos in M-text mt for the text property whose key is key.
NULL
without changing the external variable merror_code.NULL
and assigns an error code to the external variable merror_code.
NULL
is returned without an error, there are two possibilities:NULL
.
MERROR_RANGE
, MERROR_SYMBOL
The mtext_get_prop_values() function searches the character at pos in M-text mt for the property whose key is key. If such a property is found, its values are stored in the memory area pointed to by values. num limits the maximum number of stored values.
MERROR_RANGE
, MERROR_SYMBOL
The mtext_get_prop_keys() function creates an array whose elements are the keys of text properties found at position pos in M-text mt, and sets *keys to the address of the created array. The user is responsible to free the memory allocated for the array.
MERROR_RANGE
The mtext_put_prop() function sets a text property to the characters between from (inclusive) and to (exclusive) in M-text mt. key and val specify the key and the value of the text property. With this function,
FROM TO M-text: |<------------|-------- MT ---------|------------>| PROP : <------------------ OLD_VAL -------------------->
becomes
FROM TO M-text: |<------------|-------- MT ---------|------------>| PROP : <-- OLD_VAL-><-------- VAL -------><-- OLD_VAL-->
MERROR_RANGE
, MERROR_SYMBOL
The mtext_put_prop_values() function sets a text property to the characters between from (inclusive) and to (exclusive) in M-text mt. key and values specify the key and the values of the text property. num specifies the number of property values to be set.
MERROR_RANGE
, MERROR_SYMBOL
The mtext_push_prop() function pushes a text property whose key is key and value is val to the characters between from (inclusive) and to (exclusive) in M-text mt. With this function,
FROM TO M-text: |<------------|-------- MT ---------|------------>| PROP : <------------------ OLD_VAL -------------------->
becomes
FROM TO M-text: |<------------|-------- MT ---------|------------>| PROP : <------------------- OLD_VAL -------------------> PROP : <-------- VAL ------->
MERROR_RANGE
, MERROR_SYMBOL
The mtext_pop_prop() function removes the topmost text property whose key is key from the characters between from (inclusive) and and to (exclusive) in mt.
This function does nothing if characters in the region have no such text property. With this function,
FROM TO M-text: |<------------|-------- MT ---------|------------>| PROP : <------------------ OLD_VAL -------------------->
becomes
FROM TO M-text: |<------------|-------- MT ---------|------------>| PROP : <--OLD_VAL-->| |<--OLD_VAL-->|
MERROR_RANGE
, MERROR_SYMBOL
The mtext_prop_range() function investigates the extent where all characters have the same value for a text property. It first finds the value of the property specified by key of the character at pos in M-text mt. Then it checks if adjacent characters have the same value for the property key. The beginning and the end of the found range are stored to the variable pointed to by from and to. The character position stored in from is inclusive but that in to is exclusive; this fashion is compatible with the range specification in the mtext_put_prop() function, etc.
If deeper is not 0, not only the topmost but also all the stacked properties whose key is key are compared.
If from is NULL
, the beginning of range is not searched for. If to is NULL
, the end of range is not searched for.
merror_code
.
MERROR_RANGE
, MERROR_SYMBOL
MTextProperty* mtext_property | ( | MSymbol | key, | |
void * | val, | |||
int | control_bits | |||
) |
The mtext_property() function returns a newly allocated text property whose key is key and value is val. The created text property is not attached to any M-text, i.e. it is detached.
control_bits must be 0 or logical OR of enum
MTextPropertyControl
.
MText* mtext_property_mtext | ( | MTextProperty * | prop | ) |
The mtext_property_mtext() function returns the M-text to which text property prop is attached. If prop is currently detached, NULL is returned.
MSymbol mtext_property_key | ( | MTextProperty * | prop | ) |
The mtext_property_key() function returns the key (symbol) of text property prop.
void* mtext_property_value | ( | MTextProperty * | prop | ) |
The mtext_property_value() function returns the value of text property prop.
int mtext_property_start | ( | MTextProperty * | prop | ) |
The mtext_property_start() function returns the start position of text property prop. The start position is a character position of an M-text where prop begins. If prop is detached, it returns -1.
int mtext_property_end | ( | MTextProperty * | prop | ) |
The mtext_property_end() function returns the end position of text property prop. The end position is a character position of an M-text where prop ends. If prop is detached, it returns -1.
MTextProperty* mtext_get_property | ( | MText * | mt, | |
int | pos, | |||
MSymbol | key | |||
) |
The mtext_get_property() function searches the character at position pos in M-text mt for a text property whose key is key.
NULL
without changing the external variable merror_code.NULL
and assigns an error code to the external variable merror_code.
int mtext_get_properties | ( | MText * | mt, | |
int | pos, | |||
MSymbol | key, | |||
MTextProperty ** | props, | |||
int | num | |||
) |
The mtext_get_properties() function searches the character at pos in M-text mt for properties whose key is key. If such properties are found, they are stored in the memory area pointed to by props. num limits the maximum number of stored properties.
int mtext_attach_property | ( | MText * | mt, | |
int | from, | |||
int | to, | |||
MTextProperty * | prop | |||
) |
The mtext_attach_property() function attaches text property prop to the range between from and to in M-text mt. If prop is already attached to an M-text, it is detached before attached to mt.
int mtext_detach_property | ( | MTextProperty * | prop | ) |
The mtext_detach_property() function makes text property prop detached.
int mtext_push_property | ( | MText * | mt, | |
int | from, | |||
int | to, | |||
MTextProperty * | prop | |||
) |
The mtext_push_property() function pushes text property prop to the characters between from (inclusive) and to (exclusive) in M-text mt.
The mtext_serialize() function serializes the text between from and to in M-text mt. The serialized result is an M-text in a form of XML. property_list limits the text properties to be serialized. Only those text properties whose key
The DTD of the generated XML is as follows:
<!DOCTYPE mtext [ <!ELEMENT mtext (property*,body+)> <!ELEMENT property EMPTY> <!ELEMENT body (#PCDATA)> <!ATTLIST property key CDATA #REQUIRED> <!ATTLIST property value CDATA #REQUIRED> <!ATTLIST property from CDATA #REQUIRED> <!ATTLIST property to CDATA #REQUIRED> <!ATTLIST property control CDATA #REQUIRED> ]>
This function depends on the libxml2 library. If the m17n library is configured without libxml2, this function always fails.
NULL
and assigns an error code to the external variable merror_code.The mtext_deserialize() function deserializes M-text mt. mt must be an XML having the following DTD.
<!DOCTYPE mtext [ <!ELEMENT mtext (property*,body+)> <!ELEMENT property EMPTY> <!ELEMENT body (#PCDATA)> <!ATTLIST property key CDATA #REQUIRED> <!ATTLIST property value CDATA #REQUIRED> <!ATTLIST property from CDATA #REQUIRED> <!ATTLIST property to CDATA #REQUIRED> <!ATTLIST property control CDATA #REQUIRED> ]>
This function depends on the libxml2 library. If the m17n library is configured without libxml2, this function always fail.
NULL
and assigns an error code to the external variable merror_code.
To serialize a text property, the user must supply a serializer function for that text property. This is done by giving a symbol property whose key is Mtext_prop_serializer and value is a pointer to an appropriate serializer function.
To deserialize a text property, the user must supply a deserializer function for that text property. This is done by giving a symbol property whose key is Mtext_prop_deserializer and value is a pointer to an appropriate deserializer function.