sombok  2.3.0
utils

Callback functions used by linebreak. More...

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 ofprep_data'' member can be used to modify behavior.

Parameters
[in]objlinebreak object.
[in]dataan item of prep_data correspondig to callback.
[in,out]substrpointer to Unicode string.
[in]textwhole 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]objlinebreak object.
[in]lenNumber of columns of preceding grapheme cluster string.
[in]prePreceding grapheme cluster string.
[in]spcTrailing spaces of preceding string.
[in]strAppended 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]objlinebreak object.
[in]statestate.
[in]gcstrtext 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]objlinebreak object.
[in]strtext 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)
 

Detailed Description

Callback functions used by linebreak.

Function Documentation

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

Built-in formatting callback

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

Built-in formatting callback

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

Built-in formatting callback

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

Built-in preprocessing callback

Built-in preprocessing callback to break or not to break URLs according to some rules by Chicago Manual of Style 15th ed. If data is NULL, prohibit break. Otherwise, allow break by rule above.

double linebreak_sizing_UAX11 ( linebreak_t obj,
double  len,
gcstring_t pre,
gcstring_t spc,
gcstring_t str 
)

Built-in Sizing callback

Built-in Sizing callback based on UAX #11.

gcstring_t* linebreak_urgent_ABORT ( linebreak_t lbobj,
gcstring_t str 
)

Built-in urgent brealing callback

Abort processing. lbobj->errnum is set to LINEBREAK_ELONG.

gcstring_t* linebreak_urgent_FORCE ( linebreak_t lbobj,
gcstring_t str 
)

Built-in urgent brealing callback

Force breaking lines.