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 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_t * | linebreak_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_t * | linebreak_format_SIMPLE (linebreak_t *lbobj, linebreak_state_t state, gcstring_t *gcstr)
gcstring_t * | linebreak_format_NEWLINE (linebreak_t *lbobj, linebreak_state_t state, gcstring_t *gcstr)
gcstring_t * | linebreak_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_t * | linebreak_urgent_ABORT (linebreak_t *lbobj, gcstring_t *str)
gcstring_t * | linebreak_urgent_FORCE (linebreak_t *lbobj, gcstring_t *str)

## Detailed Description

Callback functions used by linebreak.

## Function Documentation

## linebreak_format_NEWLINE()

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

Built-in formatting callback

## linebreak_format_SIMPLE()

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

Built-in formatting callback

## linebreak_format_TRIM()

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

Built-in formatting callback

## linebreak_prep_URIBREAK()

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.

## linebreak_sizing_UAX11()

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.

## linebreak_urgent_ABORT()

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.

## linebreak_urgent_FORCE()

gcstring_t * linebreak_urgent_FORCE | ( | linebreak_t * | lbobj,
|  | gcstring_t * | str )

Built-in urgent brealing callback

Force breaking lines.