{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
A #PangoGlyphItemIter is an iterator over the clusters in a
#PangoGlyphItem. The forward direction of the
iterator is the logical direction of text. That is, with increasing
@start_index and @start_char values. If @glyph_item is right-to-left
(that is, if @glyph_item->item->analysis.level is odd),
then @start_glyph decreases as the iterator moves forward. Moreover,
in right-to-left cases, @start_glyph is greater than @end_glyph.
An iterator should be initialized using either of
pango_glyph_item_iter_init_start() and
pango_glyph_item_iter_init_end(), for forward and backward iteration
respectively, and walked over using any desired mixture of
pango_glyph_item_iter_next_cluster() and
pango_glyph_item_iter_prev_cluster(). A common idiom for doing a
forward iteration over the clusters is:
PangoGlyphItemIter cluster_iter;
gboolean have_cluster;
for (have_cluster = pango_glyph_item_iter_init_start (&cluster_iter,
glyph_item, text);
have_cluster;
have_cluster = pango_glyph_item_iter_next_cluster (&cluster_iter))
{
...
}
Note that @text is the start of the text for layout, which is then
indexed by @glyph_item->item->offset to get to the
text of @glyph_item. The @start_index and @end_index values can directly
index into @text. The @start_glyph, @end_glyph, @start_char, and @end_char
values however are zero-based for the @glyph_item. For each cluster, the
item pointed at by the start variables is included in the cluster while
the one pointed at by end variables is not.
None of the members of a #PangoGlyphItemIter should be modified manually.
-}
module GI.Pango.Structs.GlyphItemIter
(
-- * Exported types
GlyphItemIter(..) ,
noGlyphItemIter ,
-- * Methods
-- ** glyphItemIterCopy
glyphItemIterCopy ,
-- ** glyphItemIterFree
glyphItemIterFree ,
-- ** glyphItemIterInitEnd
glyphItemIterInitEnd ,
-- ** glyphItemIterInitStart
glyphItemIterInitStart ,
-- ** glyphItemIterNextCluster
glyphItemIterNextCluster ,
-- ** glyphItemIterPrevCluster
glyphItemIterPrevCluster ,
-- * Properties
-- ** EndChar
glyphItemIterReadEndChar ,
-- ** EndGlyph
glyphItemIterReadEndGlyph ,
-- ** EndIndex
glyphItemIterReadEndIndex ,
-- ** GlyphItem
glyphItemIterReadGlyphItem ,
-- ** StartChar
glyphItemIterReadStartChar ,
-- ** StartGlyph
glyphItemIterReadStartGlyph ,
-- ** StartIndex
glyphItemIterReadStartIndex ,
-- ** Text
glyphItemIterReadText ,
) where
import Prelude ()
import Data.GI.Base.ShortPrelude
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import GI.Pango.Types
import GI.Pango.Callbacks
newtype GlyphItemIter = GlyphItemIter (ForeignPtr GlyphItemIter)
foreign import ccall "pango_glyph_item_iter_get_type" c_pango_glyph_item_iter_get_type ::
IO GType
instance BoxedObject GlyphItemIter where
boxedType _ = c_pango_glyph_item_iter_get_type
noGlyphItemIter :: Maybe GlyphItemIter
noGlyphItemIter = Nothing
glyphItemIterReadGlyphItem :: GlyphItemIter -> IO GlyphItem
glyphItemIterReadGlyphItem s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 0) :: IO (Ptr GlyphItem)
val' <- (newBoxed GlyphItem) val
return val'
glyphItemIterReadText :: GlyphItemIter -> IO T.Text
glyphItemIterReadText s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 8) :: IO CString
val' <- cstringToText val
return val'
glyphItemIterReadStartGlyph :: GlyphItemIter -> IO Int32
glyphItemIterReadStartGlyph s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 16) :: IO Int32
return val
glyphItemIterReadStartIndex :: GlyphItemIter -> IO Int32
glyphItemIterReadStartIndex s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 20) :: IO Int32
return val
glyphItemIterReadStartChar :: GlyphItemIter -> IO Int32
glyphItemIterReadStartChar s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 24) :: IO Int32
return val
glyphItemIterReadEndGlyph :: GlyphItemIter -> IO Int32
glyphItemIterReadEndGlyph s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 28) :: IO Int32
return val
glyphItemIterReadEndIndex :: GlyphItemIter -> IO Int32
glyphItemIterReadEndIndex s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 32) :: IO Int32
return val
glyphItemIterReadEndChar :: GlyphItemIter -> IO Int32
glyphItemIterReadEndChar s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 36) :: IO Int32
return val
-- method GlyphItemIter::copy
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Pango" "GlyphItemIter", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Pango" "GlyphItemIter", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Pango" "GlyphItemIter"
-- throws : False
-- Skip return : False
foreign import ccall "pango_glyph_item_iter_copy" pango_glyph_item_iter_copy ::
Ptr GlyphItemIter -> -- _obj : TInterface "Pango" "GlyphItemIter"
IO (Ptr GlyphItemIter)
glyphItemIterCopy ::
(MonadIO m) =>
GlyphItemIter -> -- _obj
m GlyphItemIter
glyphItemIterCopy _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
result <- pango_glyph_item_iter_copy _obj'
checkUnexpectedReturnNULL "pango_glyph_item_iter_copy" result
result' <- (wrapBoxed GlyphItemIter) result
touchManagedPtr _obj
return result'
-- method GlyphItemIter::free
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Pango" "GlyphItemIter", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Pango" "GlyphItemIter", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "pango_glyph_item_iter_free" pango_glyph_item_iter_free ::
Ptr GlyphItemIter -> -- _obj : TInterface "Pango" "GlyphItemIter"
IO ()
glyphItemIterFree ::
(MonadIO m) =>
GlyphItemIter -> -- _obj
m ()
glyphItemIterFree _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
pango_glyph_item_iter_free _obj'
touchManagedPtr _obj
return ()
-- method GlyphItemIter::init_end
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Pango" "GlyphItemIter", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "glyph_item", argType = TInterface "Pango" "GlyphItem", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "text", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Pango" "GlyphItemIter", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "glyph_item", argType = TInterface "Pango" "GlyphItem", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "text", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False
foreign import ccall "pango_glyph_item_iter_init_end" pango_glyph_item_iter_init_end ::
Ptr GlyphItemIter -> -- _obj : TInterface "Pango" "GlyphItemIter"
Ptr GlyphItem -> -- glyph_item : TInterface "Pango" "GlyphItem"
CString -> -- text : TBasicType TUTF8
IO CInt
glyphItemIterInitEnd ::
(MonadIO m) =>
GlyphItemIter -> -- _obj
GlyphItem -> -- glyph_item
T.Text -> -- text
m Bool
glyphItemIterInitEnd _obj glyph_item text = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
let glyph_item' = unsafeManagedPtrGetPtr glyph_item
text' <- textToCString text
result <- pango_glyph_item_iter_init_end _obj' glyph_item' text'
let result' = (/= 0) result
touchManagedPtr _obj
touchManagedPtr glyph_item
freeMem text'
return result'
-- method GlyphItemIter::init_start
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Pango" "GlyphItemIter", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "glyph_item", argType = TInterface "Pango" "GlyphItem", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "text", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Pango" "GlyphItemIter", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "glyph_item", argType = TInterface "Pango" "GlyphItem", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "text", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False
foreign import ccall "pango_glyph_item_iter_init_start" pango_glyph_item_iter_init_start ::
Ptr GlyphItemIter -> -- _obj : TInterface "Pango" "GlyphItemIter"
Ptr GlyphItem -> -- glyph_item : TInterface "Pango" "GlyphItem"
CString -> -- text : TBasicType TUTF8
IO CInt
glyphItemIterInitStart ::
(MonadIO m) =>
GlyphItemIter -> -- _obj
GlyphItem -> -- glyph_item
T.Text -> -- text
m Bool
glyphItemIterInitStart _obj glyph_item text = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
let glyph_item' = unsafeManagedPtrGetPtr glyph_item
text' <- textToCString text
result <- pango_glyph_item_iter_init_start _obj' glyph_item' text'
let result' = (/= 0) result
touchManagedPtr _obj
touchManagedPtr glyph_item
freeMem text'
return result'
-- method GlyphItemIter::next_cluster
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Pango" "GlyphItemIter", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Pango" "GlyphItemIter", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False
foreign import ccall "pango_glyph_item_iter_next_cluster" pango_glyph_item_iter_next_cluster ::
Ptr GlyphItemIter -> -- _obj : TInterface "Pango" "GlyphItemIter"
IO CInt
glyphItemIterNextCluster ::
(MonadIO m) =>
GlyphItemIter -> -- _obj
m Bool
glyphItemIterNextCluster _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
result <- pango_glyph_item_iter_next_cluster _obj'
let result' = (/= 0) result
touchManagedPtr _obj
return result'
-- method GlyphItemIter::prev_cluster
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Pango" "GlyphItemIter", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Pango" "GlyphItemIter", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False
foreign import ccall "pango_glyph_item_iter_prev_cluster" pango_glyph_item_iter_prev_cluster ::
Ptr GlyphItemIter -> -- _obj : TInterface "Pango" "GlyphItemIter"
IO CInt
glyphItemIterPrevCluster ::
(MonadIO m) =>
GlyphItemIter -> -- _obj
m Bool
glyphItemIterPrevCluster _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
result <- pango_glyph_item_iter_prev_cluster _obj'
let result' = (/= 0) result
touchManagedPtr _obj
return result'