text-icu-0.8.0.5: Bindings to the ICU library

Copyright | (c) 2018 Ondrej Palkovsky
License | BSD-style
Maintainer | bos@serpentine.com
Stability | experimental
Portability | GHC
Safe Haskell | None
Language | Haskell98

Data.Text.ICU.BiDi

Contents

- Basic functions
- Set data
- Access the BiDi object
- Output text
- High-level functions

Description

Implementation of the Unicode Bidirectional Algorithm. See the documentation of the libicu library for additional details.

- - Note: this module is not thread safe. Do not call the functions on one BiDi object from more than one thread!

Synopsis

- data BiDi
- open :: IO BiDi
- openSized :: Int32 -> Int32 -> IO BiDi
- setPara :: BiDi -> Text -> Int32 -> IO ()
- setLine :: BiDi -> Int32 -> Int32 -> BiDi -> IO ()
- countParagraphs :: BiDi -> IO Int32
- getParagraphByIndex :: BiDi -> Int32 -> IO (Int32, Int32)
- getProcessedLength :: BiDi -> IO Int32
- writeReordered :: BiDi -> [WriteOption] -> IO Text
- data WriteOption
  - = DoMirroring
  - | InsertLrmForNumeric
  - | KeepBaseCombining
  - | OutputReverse
  - | RemoveBidiControls
- reorderParagraphs :: [WriteOption] -> Text -> [Text]

# Documentation

data BiDi Source #

BiDi object. Note: this structure is not thread safe. It is not safe to use value of this type simultaneously from multiple threads.

#### Instances

Instances details

Show BiDi Source # |
Instance details Defined in Data.Text.ICU.BiDi.Internal Methods showsPrec :: Int -> BiDi -> ShowS Source # show :: BiDi -> String Source # showList :: [BiDi] -> ShowS Source #
Eq BiDi Source # |
Instance details Defined in Data.Text.ICU.BiDi.Internal Methods (==) :: BiDi -> BiDi -> Bool Source # (/=) :: BiDi -> BiDi -> Bool Source #

## Basic functions

open :: IO BiDi Source #

Allocate a BiDi structure.

openSized Source #

Arguments

:: Int32 | is the maximum text or line length that internal memory will be preallocated for. An attempt to associate this object with a longer text will fail, unless this value is 0.
-> Int32 | is the maximum anticipated number of same-level runs that internal memory will be preallocated for. An attempt to access visual runs on an object that was not preallocated for as many runs as the text was actually resolved to will fail, unless this value is 0.
-> IO BiDi |

Allocate a BiDi structure with preallocated memory for internal structures.

## Set data

setPara Source #

Arguments

:: BiDi |
-> Text |
-> Int32 | specifies the default level for the text; it is typically 0 (LTR) or 1 (RTL)
-> IO () |

Perform the Unicode Bidi algorithm. It is defined in the Unicode Standard Annex #9, version 13, also described in The Unicode Standard, Version 4.0. This function takes a piece of plain text containing one or more paragraphs, with or without externally specified embedding levels from styled text and computes the left-right-directionality of each character.

setLine Source #

Arguments

:: BiDi | the parent paragraph object. It must have been set by a successful call to `setPara`.
-> Int32 | is the line's first index into the text
-> Int32 | is just behind the line's last index into the text (its last index +1).
-> BiDi | is the object that will now represent a line of the text
-> IO () |

Sets a BiDi to contain the reordering information, especially the resolved levels, for all the characters in a line of text

## Access the BiDi object

countParagraphs :: BiDi -> IO Int32 Source #

Get the number of paragraphs.

getParagraphByIndex Source #

Arguments

:: BiDi |
-> Int32 | is the number of the paragraph, in the range [0..ubidi_countParagraphs(pBiDi)-1].
-> IO (Int32, Int32) | index of the first character of the paragraph in the text and limit of the paragraph

Get a paragraph, given the index of this paragraph.

getProcessedLength :: BiDi -> IO Int32 Source #

Get the length of the source text processed by the last call to `setPara`.

## Output text

writeReordered :: BiDi -> [WriteOption] -> IO Text Source #

Take a BiDi object containing the reordering information for a piece of text (one or more paragraphs) set by `setPara` or for a line of text set by `setLine` and write a reordered string to the destination buffer.

data WriteOption Source #

Constructors

DoMirroring | replace characters with the "mirrored" property in RTL runs by their mirror-image mappings
InsertLrmForNumeric | surround the run with LRMs if necessary; this is part of the approximate "inverse Bidi" algorithm
KeepBaseCombining | keep combining characters after their base characters in RTL runs
OutputReverse | write the output in reverse order
RemoveBidiControls | remove Bidi control characters (this does not affect InsertLrmForNumeric)

#### Instances

Instances details

Show WriteOption Source # |
Instance details Defined in Data.Text.ICU.BiDi Methods showsPrec :: Int -> WriteOption -> ShowS Source # show :: WriteOption -> String Source # showList :: [WriteOption] -> ShowS Source #

## High-level functions

reorderParagraphs :: [WriteOption] -> Text -> [Text] Source #

Helper function to reorder a text to a series of paragraphs.