lib/utils.c File Reference

Functions

Preprocessing callback

gcstring_t *callback(linebreak_t *lbobj, void *data, unistr_t *str, unistr_t *text)

Preprocessing behaviors specified by item of ``prep_func'' member of linebreak_t. Corresponding item of ``prep_data'' member can be used to modify behavior.

Parameters:
[in] obj linebreak object.
[in] data an item of prep_data correspondig to callback.
[in,out] substr pointer to Unicode string.
[in] text whole text to be broken, or NULL.
Returns:
This callback is past twice by each substring of text:

On the first pass, when text is not NULL, it should return the first occurrance in substr matching its criteria, update substr->str to be matching position and substr->len to be length. Otherwise, should set NULL to substr->str. Return value shall be discarded.

On the second pass, when text is NULL, it should return new grapheme cluster string created from substr. Return value should not share Unicode buffer with substr (i.e. use gcstring_newcopy()).

If error occurred, callback must set lbobj->errnum nonzero then return NULL.

gcstring_tlinebreak_prep_URIBREAK (linebreak_t *lbobj, void *data, unistr_t *str, unistr_t *text)
Sizing callback

double callback(linebreak_t *obj, double len, gcstring_t *pre, gcstring_t *spc, gcstring_t *str)

Sizing behavior specified by ``sizing_func'' member of linebreak_t. ``sizing_data'' member can be used to modify behavior.

Parameters:
[in] obj linebreak object.
[in] len Number of columns of preceding grapheme cluster string.
[in] pre Preceding grapheme cluster string.
[in] spc Trailing spaces of preceding string.
[in] str Appended grapheme cluster string.
Returns:
number of columns of pre+spc+str. If error occurred, callback must set lbobj->errnum nonzero then return NULL.
double linebreak_sizing_UAX11 (linebreak_t *obj, double len, gcstring_t *pre, gcstring_t *spc, gcstring_t *str)
Formatting callback

gcstring_t *callback(linebreak_t *lbobj, linebreak_state_t state, gcstring_t *gcstr)

Formatting behaviors specified by ``format_func'' member of linebreak_t. ``formt_data'' member can be used to modify behavior.

Parameters:
[in] obj linebreak object.
[in] state state.
[in] gcstr text fragment.
Returns:
new text fragment or, if no modification needed, NULL. If error occurred, callback must set lbobj->errnum nonzero then return NULL.

Following table describes behavior of built-in format callbacks.

 * state| SIMPLE          | NEWLINE           | TRIM
 * -----+-----------------+-------------------+-------------------
 * SOT  |
 * SOP  |                       not modify
 * SOL  |
 * LINE |
 * EOL  | append newline  | replace by newline| replace by newline
 * EOP  | not modify      | replace by newline| remove SPACEs
 * EOT  | not modify      | replace by newline| remove SPACEs
 * ----------------------------------------------------------------
 * 
gcstring_tlinebreak_format_SIMPLE (linebreak_t *lbobj, linebreak_state_t state, gcstring_t *gcstr)
gcstring_tlinebreak_format_NEWLINE (linebreak_t *lbobj, linebreak_state_t state, gcstring_t *gcstr)
gcstring_tlinebreak_format_TRIM (linebreak_t *lbobj, linebreak_state_t state, gcstring_t *gcstr)
Urgent breaking callbacks

gcstring_t *callback(linebreak_t *lbobj, gcstring_t *str)

Urgent breaking behaviors specified by ``urgent_func'' member of linebreak_t. ``urgent_data'' member can be used to modify behavior.

Parameters:
[in] obj linebreak object.
[in] str text to be broken.
Returns:
new text or, if no modification needed, NULL. If error occurred, callback must set lbobj->errnum nonzero then return NULL.

There are two built-in urgent breaking callbacks.

gcstring_tlinebreak_urgent_ABORT (linebreak_t *lbobj, gcstring_t *str)
gcstring_tlinebreak_urgent_FORCE (linebreak_t *lbobj, gcstring_t *str)
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator