text-icu-0.8.0.1: Bindings to the ICU library
Copyright(c) 2018 Ondrej Palkovsky
LicenseBSD-style
Maintainerbos@serpentine.com
Stabilityexperimental
PortabilityGHC
Safe HaskellSafe-Inferred
LanguageHaskell98

Data.Text.ICU.BiDi

Description

Implementation of Unicode Bidirection algorithm. See 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

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 #

show :: BiDi -> String #

showList :: [BiDi] -> ShowS #

Eq BiDi Source # 
Instance details

Defined in Data.Text.ICU.BiDi.Internal

Methods

(==) :: BiDi -> BiDi -> Bool #

(/=) :: BiDi -> BiDi -> Bool #

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

High-level functions

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

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