{-# LANGUAGE OverloadedStrings #-}

{-# LINE 2 "./Graphics/Rendering/Pango/Layout.chs" #-}
-- -*-haskell-*-
-- GIMP Toolkit (GTK) Pango text layout functions
--
-- Author : Axel Simon
--
-- Created: 8 February 2003
--
-- Copyright (C) 1999-2005 Axel Simon
--
-- This library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License, or (at your option) any later version.
--
-- This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Lesser General Public License for more details.
--
-- Not bound:
--
-- - pango_layout_get_log_attrs : difficult since it returns an array, where
-- each element corresponds to a UTF8 character, conversion to wide
-- characters means we need to do some semantic merging
--
-- |
-- Maintainer : gtk2hs-users@lists.sourceforge.net
-- Stability : provisional
-- Portability : portable (depends on GHC)
--
-- Functions to run the rendering pipeline.
--
-- * The 'PangoLayout' object defined in this module contain a rendered
-- paragraph of text. This interface is the easiest way to render text into
-- a 'Graphics.UI.Gtk.Gdk.DrawWindow.DrawWindow' using Cairo.
--
module Graphics.Rendering.Pango.Layout (
  PangoRectangle(..),
  PangoLayout,
  layoutEmpty,
  layoutText,
  layoutCopy,
  layoutGetContext,
  layoutContextChanged,
  layoutSetText,
  layoutGetText,
  layoutSetMarkup,
  escapeMarkup,
  layoutSetMarkupWithAccel,
  layoutSetAttributes,
  layoutGetAttributes,
  layoutSetFontDescription,

  layoutGetFontDescription,

  layoutSetWidth,
  layoutGetWidth,
  LayoutWrapMode(..),
  layoutSetWrap,
  layoutGetWrap,

  EllipsizeMode(..),
  layoutSetEllipsize,
  layoutGetEllipsize,

  layoutSetIndent,
  layoutGetIndent,
  layoutSetSpacing,
  layoutGetSpacing,
  layoutSetJustify,
  layoutGetJustify,

  layoutSetAutoDir,
  layoutGetAutoDir,

  LayoutAlignment(..),
  layoutSetAlignment,
  layoutGetAlignment,
  TabAlign,
  TabPosition,
  layoutSetTabs,
  layoutResetTabs,
  layoutGetTabs,
  layoutSetSingleParagraphMode,
  layoutGetSingleParagraphMode,
  layoutXYToIndex,
  layoutIndexToPos,
  layoutGetCursorPos,
  CursorPos(..),
  layoutMoveCursorVisually,
  layoutGetExtents,
  layoutGetPixelExtents,
  layoutGetLineCount,
  layoutGetLine,
  layoutGetLines,
  LayoutIter,
  layoutGetIter,
  layoutIterNextItem,
  layoutIterNextChar,
  layoutIterNextCluster,
  layoutIterNextLine,
  layoutIterAtLastLine,
  layoutIterGetIndex,
  layoutIterGetBaseline,

  layoutIterGetItem,

  layoutIterGetLine,
  layoutIterGetCharExtents,
  layoutIterGetClusterExtents,
  layoutIterGetRunExtents,
  layoutIterGetLineYRange,
  layoutIterGetLineExtents,
  LayoutLine,
  layoutLineGetExtents,
  layoutLineGetPixelExtents,
  layoutLineIndexToX,
  layoutLineXToIndex,
  layoutLineGetXRanges
  ) where

import Control.Monad (liftM)
import Data.Char (ord, chr)
import Data.Text (Text)

import System.Glib.FFI
import System.Glib.UTFString
import System.Glib.GList (readGSList)
import System.Glib.GObject (wrapNewGObject, makeNewGObject)
import Graphics.Rendering.Pango.Structs
import Graphics.Rendering.Pango.BasicTypes
{-# LINE 133 "./Graphics/Rendering/Pango/Layout.chs" #-}
import Graphics.Rendering.Pango.Types

import Graphics.Rendering.Pango.Enums (EllipsizeMode(..))

import Graphics.Rendering.Pango.Rendering -- for haddock
import Graphics.Rendering.Pango.Attributes ( withAttrList, fromAttrList)
import Data.IORef
import Control.Exception (throwIO, ArrayException(IndexOutOfBounds))


{-# LINE 143 "./Graphics/Rendering/Pango/Layout.chs" #-}

-- | Create an empty 'Layout'.
--
layoutEmpty :: PangoContext -> IO PangoLayout
layoutEmpty :: PangoContext -> IO PangoLayout
layoutEmpty PangoContext
pc = do
  PangoLayoutRaw
pl <- (ForeignPtr PangoLayoutRaw -> PangoLayoutRaw,
 FinalizerPtr PangoLayoutRaw)
-> IO (Ptr PangoLayoutRaw) -> IO PangoLayoutRaw
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr PangoLayoutRaw -> PangoLayoutRaw,
 FinalizerPtr PangoLayoutRaw)
forall {a}.
(ForeignPtr PangoLayoutRaw -> PangoLayoutRaw, FinalizerPtr a)
mkPangoLayoutRaw
    ((\(PangoContext ForeignPtr PangoContext
arg1) -> ForeignPtr PangoContext
-> (Ptr PangoContext -> IO (Ptr PangoLayoutRaw))
-> IO (Ptr PangoLayoutRaw)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoContext
arg1 ((Ptr PangoContext -> IO (Ptr PangoLayoutRaw))
 -> IO (Ptr PangoLayoutRaw))
-> (Ptr PangoContext -> IO (Ptr PangoLayoutRaw))
-> IO (Ptr PangoLayoutRaw)
forall a b. (a -> b) -> a -> b
$ \Ptr PangoContext
argPtr1 ->Ptr PangoContext -> IO (Ptr PangoLayoutRaw)
pango_layout_new Ptr PangoContext
argPtr1) (PangoContext -> PangoContext
forall o. PangoContextClass o => o -> PangoContext
toPangoContext PangoContext
pc))
  PangoString
ps <- Text -> IO PangoString
forall string. GlibString string => string -> IO PangoString
makeNewPangoString (Text
"" :: Text)
  IORef PangoString
psRef <- PangoString -> IO (IORef PangoString)
forall a. a -> IO (IORef a)
newIORef PangoString
ps
  PangoLayout -> IO PangoLayout
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (IORef PangoString -> PangoLayoutRaw -> PangoLayout
PangoLayout IORef PangoString
psRef PangoLayoutRaw
pl)

-- | Create a new layout.
--
layoutText :: GlibString string => PangoContext -> string -> IO PangoLayout
layoutText :: forall string.
GlibString string =>
PangoContext -> string -> IO PangoLayout
layoutText PangoContext
pc string
txt = do
  PangoLayoutRaw
pl <- (ForeignPtr PangoLayoutRaw -> PangoLayoutRaw,
 FinalizerPtr PangoLayoutRaw)
-> IO (Ptr PangoLayoutRaw) -> IO PangoLayoutRaw
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr PangoLayoutRaw -> PangoLayoutRaw,
 FinalizerPtr PangoLayoutRaw)
forall {a}.
(ForeignPtr PangoLayoutRaw -> PangoLayoutRaw, FinalizerPtr a)
mkPangoLayoutRaw
    ((\(PangoContext ForeignPtr PangoContext
arg1) -> ForeignPtr PangoContext
-> (Ptr PangoContext -> IO (Ptr PangoLayoutRaw))
-> IO (Ptr PangoLayoutRaw)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoContext
arg1 ((Ptr PangoContext -> IO (Ptr PangoLayoutRaw))
 -> IO (Ptr PangoLayoutRaw))
-> (Ptr PangoContext -> IO (Ptr PangoLayoutRaw))
-> IO (Ptr PangoLayoutRaw)
forall a b. (a -> b) -> a -> b
$ \Ptr PangoContext
argPtr1 ->Ptr PangoContext -> IO (Ptr PangoLayoutRaw)
pango_layout_new Ptr PangoContext
argPtr1) (PangoContext -> PangoContext
forall o. PangoContextClass o => o -> PangoContext
toPangoContext PangoContext
pc))
  string -> (CStringLen -> IO ()) -> IO ()
forall a. string -> (CStringLen -> IO a) -> IO a
forall s a. GlibString s => s -> (CStringLen -> IO a) -> IO a
withUTFStringLen string
txt ((CStringLen -> IO ()) -> IO ()) -> (CStringLen -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \(Ptr CChar
strPtr,Int
len) ->
    (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) Ptr CChar
arg2 CInt
arg3 -> ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
-> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> Ptr CChar -> CInt -> IO ()
pango_layout_set_text Ptr PangoLayoutRaw
argPtr1 Ptr CChar
arg2 CInt
arg3) PangoLayoutRaw
pl Ptr CChar
strPtr (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
len)
  PangoString
ps <- string -> IO PangoString
forall string. GlibString string => string -> IO PangoString
makeNewPangoString string
txt
  IORef PangoString
psRef <- PangoString -> IO (IORef PangoString)
forall a. a -> IO (IORef a)
newIORef PangoString
ps
  PangoLayout -> IO PangoLayout
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (IORef PangoString -> PangoLayoutRaw -> PangoLayout
PangoLayout IORef PangoString
psRef PangoLayoutRaw
pl)

-- | Create a copy of the 'Layout'.
--
layoutCopy :: PangoLayout -> IO PangoLayout
layoutCopy :: PangoLayout -> IO PangoLayout
layoutCopy (PangoLayout IORef PangoString
uc PangoLayoutRaw
pl) = do
  PangoLayoutRaw
pl <- (ForeignPtr PangoLayoutRaw -> PangoLayoutRaw,
 FinalizerPtr PangoLayoutRaw)
-> IO (Ptr PangoLayoutRaw) -> IO PangoLayoutRaw
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr PangoLayoutRaw -> PangoLayoutRaw,
 FinalizerPtr PangoLayoutRaw)
forall {a}.
(ForeignPtr PangoLayoutRaw -> PangoLayoutRaw, FinalizerPtr a)
mkPangoLayoutRaw
    ((\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) -> ForeignPtr PangoLayoutRaw
-> (Ptr PangoLayoutRaw -> IO (Ptr PangoLayoutRaw))
-> IO (Ptr PangoLayoutRaw)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO (Ptr PangoLayoutRaw))
 -> IO (Ptr PangoLayoutRaw))
-> (Ptr PangoLayoutRaw -> IO (Ptr PangoLayoutRaw))
-> IO (Ptr PangoLayoutRaw)
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> IO (Ptr PangoLayoutRaw)
pango_layout_copy Ptr PangoLayoutRaw
argPtr1) PangoLayoutRaw
pl)
  PangoLayout -> IO PangoLayout
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (IORef PangoString -> PangoLayoutRaw -> PangoLayout
PangoLayout IORef PangoString
uc PangoLayoutRaw
pl)

-- | Retrieves the 'PangoContext' from this layout.
--
layoutGetContext :: PangoLayout -> IO PangoContext
layoutGetContext :: PangoLayout -> IO PangoContext
layoutGetContext (PangoLayout IORef PangoString
_ PangoLayoutRaw
pl) = (ForeignPtr PangoContext -> PangoContext,
 FinalizerPtr PangoContext)
-> IO (Ptr PangoContext) -> IO PangoContext
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
makeNewGObject (ForeignPtr PangoContext -> PangoContext,
 FinalizerPtr PangoContext)
forall {a}.
(ForeignPtr PangoContext -> PangoContext, FinalizerPtr a)
mkPangoContext (IO (Ptr PangoContext) -> IO PangoContext)
-> IO (Ptr PangoContext) -> IO PangoContext
forall a b. (a -> b) -> a -> b
$ do
  (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) -> ForeignPtr PangoLayoutRaw
-> (Ptr PangoLayoutRaw -> IO (Ptr PangoContext))
-> IO (Ptr PangoContext)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO (Ptr PangoContext))
 -> IO (Ptr PangoContext))
-> (Ptr PangoLayoutRaw -> IO (Ptr PangoContext))
-> IO (Ptr PangoContext)
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> IO (Ptr PangoContext)
pango_layout_get_context Ptr PangoLayoutRaw
argPtr1) PangoLayoutRaw
pl

-- | Signal a 'PangoContext' change.
--
-- * Forces recomputation of any state in the 'PangoLayout' that
-- might depend on the layout's context. This function should
-- be called if you make changes to the context subsequent
-- to creating the layout.
--
layoutContextChanged :: PangoLayout -> IO ()
layoutContextChanged :: PangoLayout -> IO ()
layoutContextChanged (PangoLayout IORef PangoString
_ PangoLayoutRaw
pl) =
  (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) -> ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
-> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> IO ()
pango_layout_context_changed Ptr PangoLayoutRaw
argPtr1) PangoLayoutRaw
pl

-- | Set the string in the layout.
--
layoutSetText :: GlibString string => PangoLayout -> string -> IO ()
layoutSetText :: forall string. GlibString string => PangoLayout -> string -> IO ()
layoutSetText (PangoLayout IORef PangoString
psRef PangoLayoutRaw
pl) string
txt = do
  string -> (CStringLen -> IO ()) -> IO ()
forall a. string -> (CStringLen -> IO a) -> IO a
forall s a. GlibString s => s -> (CStringLen -> IO a) -> IO a
withUTFStringLen string
txt ((CStringLen -> IO ()) -> IO ()) -> (CStringLen -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \(Ptr CChar
strPtr,Int
len) ->
    (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) Ptr CChar
arg2 CInt
arg3 -> ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
-> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> Ptr CChar -> CInt -> IO ()
pango_layout_set_text Ptr PangoLayoutRaw
argPtr1 Ptr CChar
arg2 CInt
arg3) PangoLayoutRaw
pl Ptr CChar
strPtr (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
len)
  PangoString
ps <- string -> IO PangoString
forall string. GlibString string => string -> IO PangoString
makeNewPangoString string
txt
  IORef PangoString -> PangoString -> IO ()
forall a. IORef a -> a -> IO ()
writeIORef IORef PangoString
psRef PangoString
ps

-- | Retrieve the string in the layout.
--
layoutGetText :: GlibString string => PangoLayout -> IO string
layoutGetText :: forall string. GlibString string => PangoLayout -> IO string
layoutGetText (PangoLayout IORef PangoString
_ PangoLayoutRaw
pl) =
  (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) -> ForeignPtr PangoLayoutRaw
-> (Ptr PangoLayoutRaw -> IO (Ptr CChar)) -> IO (Ptr CChar)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO (Ptr CChar)) -> IO (Ptr CChar))
-> (Ptr PangoLayoutRaw -> IO (Ptr CChar)) -> IO (Ptr CChar)
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> IO (Ptr CChar)
pango_layout_get_text Ptr PangoLayoutRaw
argPtr1) PangoLayoutRaw
pl IO (Ptr CChar) -> (Ptr CChar -> IO string) -> IO string
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Ptr CChar -> IO string
forall s. GlibString s => Ptr CChar -> IO s
peekUTFString

-- | Set the text of the layout, including attributes.
--
-- The string may include 'Markup'. To print markup characters like
-- @\'<\'@, or @\'-\'@, apply 'escapeMarkup' to the string first.
--
-- The function returns the text that is actually shown.
--
layoutSetMarkup :: (GlibString markup, GlibString string)
    => PangoLayout -> markup -> IO string
layoutSetMarkup :: forall markup string.
(GlibString markup, GlibString string) =>
PangoLayout -> markup -> IO string
layoutSetMarkup pl :: PangoLayout
pl@(PangoLayout IORef PangoString
psRef PangoLayoutRaw
plr) markup
txt = do
  markup -> (CStringLen -> IO ()) -> IO ()
forall a. markup -> (CStringLen -> IO a) -> IO a
forall s a. GlibString s => s -> (CStringLen -> IO a) -> IO a
withUTFStringLen markup
txt ((CStringLen -> IO ()) -> IO ()) -> (CStringLen -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \(Ptr CChar
strPtr,Int
len) ->
    (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) Ptr CChar
arg2 CInt
arg3 -> ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
-> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> Ptr CChar -> CInt -> IO ()
pango_layout_set_markup Ptr PangoLayoutRaw
argPtr1 Ptr CChar
arg2 CInt
arg3) PangoLayoutRaw
plr Ptr CChar
strPtr (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
len)
  string
txt' <- PangoLayout -> IO string
forall string. GlibString string => PangoLayout -> IO string
layoutGetText PangoLayout
pl
  PangoString
ps <- string -> IO PangoString
forall string. GlibString string => string -> IO PangoString
makeNewPangoString string
txt'
  IORef PangoString -> PangoString -> IO ()
forall a. IORef a -> a -> IO ()
writeIORef IORef PangoString
psRef PangoString
ps
  string -> IO string
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return string
txt'

-- | Escape markup characters.
--
-- * Used to display characters that normally denote markup. Note that this
-- function is strict in that it forces all characters in the input string
-- as soon as a single output character is requested.
--
escapeMarkup :: GlibString string => string -> string
escapeMarkup :: forall string. GlibString string => string -> string
escapeMarkup string
str = IO string -> string
forall a. IO a -> a
unsafePerformIO (IO string -> string) -> IO string -> string
forall a b. (a -> b) -> a -> b
$ string -> (CStringLen -> IO string) -> IO string
forall a. string -> (CStringLen -> IO a) -> IO a
forall s a. GlibString s => s -> (CStringLen -> IO a) -> IO a
withUTFStringLen string
str ((CStringLen -> IO string) -> IO string)
-> (CStringLen -> IO string) -> IO string
forall a b. (a -> b) -> a -> b
$ \(Ptr CChar
strPtr,Int
l) -> do
  Ptr CChar
resPtr <- Ptr CChar -> CLong -> IO (Ptr CChar)
g_markup_escape_text Ptr CChar
strPtr (Int -> CLong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
l)
  string
res <- Ptr CChar -> IO string
forall s. GlibString s => Ptr CChar -> IO s
peekUTFString Ptr CChar
resPtr
  Ptr () -> IO ()
g_free (Ptr CChar -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr Ptr CChar
resPtr)
  string -> IO string
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return string
res

-- | Set the string in the layout.
--
-- * The string may include 'Markup'. Furthermore, any underscore
-- character indicates that the next character will be
-- marked as accelerator (i.e. underlined). A literal underscore character
-- can be produced by placing it twice in the string.
--
-- * The character which follows the underscore is
-- returned so it can be used to add the actual keyboard shortcut.
-- The second element is the string after parsing.
--
layoutSetMarkupWithAccel :: (GlibString markup, GlibString string)
    => PangoLayout -> markup -> IO (Char, string)
layoutSetMarkupWithAccel :: forall markup string.
(GlibString markup, GlibString string) =>
PangoLayout -> markup -> IO (Char, string)
layoutSetMarkupWithAccel pl :: PangoLayout
pl@(PangoLayout IORef PangoString
psRef PangoLayoutRaw
plr) markup
txt = do
  Char
modif <- (Ptr CUInt -> IO Char) -> IO Char
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CUInt -> IO Char) -> IO Char)
-> (Ptr CUInt -> IO Char) -> IO Char
forall a b. (a -> b) -> a -> b
$ \Ptr CUInt
chrPtr ->
    markup -> (CStringLen -> IO Char) -> IO Char
forall a. markup -> (CStringLen -> IO a) -> IO a
forall s a. GlibString s => s -> (CStringLen -> IO a) -> IO a
withUTFStringLen markup
txt ((CStringLen -> IO Char) -> IO Char)
-> (CStringLen -> IO Char) -> IO Char
forall a b. (a -> b) -> a -> b
$ \(Ptr CChar
strPtr,Int
len) -> do
      (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) Ptr CChar
arg2 CInt
arg3 CUInt
arg4 Ptr CUInt
arg5 -> ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
-> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw
-> Ptr CChar -> CInt -> CUInt -> Ptr CUInt -> IO ()
pango_layout_set_markup_with_accel Ptr PangoLayoutRaw
argPtr1 Ptr CChar
arg2 CInt
arg3 CUInt
arg4 Ptr CUInt
arg5) PangoLayoutRaw
plr Ptr CChar
strPtr
        (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
len) (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Char -> Int
ord Char
'_')) Ptr CUInt
chrPtr
      (CUInt -> Char) -> IO CUInt -> IO Char
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Int -> Char
chr(Int -> Char) -> (CUInt -> Int) -> CUInt -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
.CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) (IO CUInt -> IO Char) -> IO CUInt -> IO Char
forall a b. (a -> b) -> a -> b
$ Ptr CUInt -> IO CUInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CUInt
chrPtr
  string
txt' <- PangoLayout -> IO string
forall string. GlibString string => PangoLayout -> IO string
layoutGetText PangoLayout
pl
  PangoString
ps <- string -> IO PangoString
forall string. GlibString string => string -> IO PangoString
makeNewPangoString string
txt'
  IORef PangoString -> PangoString -> IO ()
forall a. IORef a -> a -> IO ()
writeIORef IORef PangoString
psRef PangoString
ps
  (Char, string) -> IO (Char, string)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Char
modif, string
txt')


-- | Set text attributes of the text in the layout.
--
-- * This function replaces any text attributes that this layout contained,
-- even those that were set by using 'layoutSetMarkup'.
--
layoutSetAttributes :: PangoLayout -> [PangoAttribute] -> IO ()
layoutSetAttributes :: PangoLayout -> [PangoAttribute] -> IO ()
layoutSetAttributes (PangoLayout IORef PangoString
psRef PangoLayoutRaw
plr) [PangoAttribute]
attrs = do
  PangoString
ps <- IORef PangoString -> IO PangoString
forall a. IORef a -> IO a
readIORef IORef PangoString
psRef
  PangoString -> [PangoAttribute] -> (Ptr () -> IO ()) -> IO ()
forall a.
PangoString -> [PangoAttribute] -> (Ptr () -> IO a) -> IO a
withAttrList PangoString
ps [PangoAttribute]
attrs ((Ptr () -> IO ()) -> IO ()) -> (Ptr () -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr ()
alPtr ->
    (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) Ptr ()
arg2 -> ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
-> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> Ptr () -> IO ()
pango_layout_set_attributes Ptr PangoLayoutRaw
argPtr1 Ptr ()
arg2) PangoLayoutRaw
plr Ptr ()
alPtr

-- | Gets the list of attributes of the layout, if any.
--
-- * The attribute list is a list of lists of attribute. Each list describes
-- the attributes for the same span.
--
layoutGetAttributes :: PangoLayout -> IO [[PangoAttribute]]
layoutGetAttributes :: PangoLayout -> IO [[PangoAttribute]]
layoutGetAttributes (PangoLayout IORef PangoString
psRef PangoLayoutRaw
plr) = do
  (PangoString UTFCorrection
correct CInt
_ ForeignPtr CChar
_) <- IORef PangoString -> IO PangoString
forall a. IORef a -> IO a
readIORef IORef PangoString
psRef
  Ptr ()
attrListPtr <- (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) -> ForeignPtr PangoLayoutRaw
-> (Ptr PangoLayoutRaw -> IO (Ptr ())) -> IO (Ptr ())
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO (Ptr ())) -> IO (Ptr ()))
-> (Ptr PangoLayoutRaw -> IO (Ptr ())) -> IO (Ptr ())
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> IO (Ptr ())
pango_layout_get_attributes Ptr PangoLayoutRaw
argPtr1) PangoLayoutRaw
plr
  UTFCorrection -> Ptr () -> IO [[PangoAttribute]]
fromAttrList UTFCorrection
correct Ptr ()
attrListPtr

-- | Set a specific font description for this layout.
--
-- * Specifying @Nothing@ will unset the current font description, that is,
-- the 'PangoLayout' will use the font description in the current
-- 'PangoContext'.
--
layoutSetFontDescription :: PangoLayout -> Maybe FontDescription -> IO ()
layoutSetFontDescription :: PangoLayout -> Maybe FontDescription -> IO ()
layoutSetFontDescription (PangoLayout IORef PangoString
_ PangoLayoutRaw
plr) (Just FontDescription
fd) =
  (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) (FontDescription ForeignPtr FontDescription
arg2) -> ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
-> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->ForeignPtr FontDescription
-> (Ptr FontDescription -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FontDescription
arg2 ((Ptr FontDescription -> IO ()) -> IO ())
-> (Ptr FontDescription -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr FontDescription
argPtr2 ->Ptr PangoLayoutRaw -> Ptr FontDescription -> IO ()
pango_layout_set_font_description Ptr PangoLayoutRaw
argPtr1 Ptr FontDescription
argPtr2) PangoLayoutRaw
plr FontDescription
fd
layoutSetFontDescription (PangoLayout IORef PangoString
_ (PangoLayoutRaw ForeignPtr PangoLayoutRaw
plr)) Maybe FontDescription
Nothing =
  ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
plr ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
-> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
plrPtr ->
  Ptr PangoLayoutRaw -> Ptr FontDescription -> IO ()
pango_layout_set_font_description Ptr PangoLayoutRaw
plrPtr Ptr FontDescription
forall a. Ptr a
nullPtr


-- | Ask for the specifically set font description of this layout.
--
-- * Returns @Nothing@ if this layout uses the font description in the
-- 'PangoContext' it was created in.
--
-- * Only available in Pango 1.8.0 or higher.
--
layoutGetFontDescription :: PangoLayout -> IO (Maybe FontDescription)
layoutGetFontDescription :: PangoLayout -> IO (Maybe FontDescription)
layoutGetFontDescription (PangoLayout IORef PangoString
_ PangoLayoutRaw
plr) = do
  Ptr FontDescription
fdPtr <- (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) -> ForeignPtr PangoLayoutRaw
-> (Ptr PangoLayoutRaw -> IO (Ptr FontDescription))
-> IO (Ptr FontDescription)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO (Ptr FontDescription))
 -> IO (Ptr FontDescription))
-> (Ptr PangoLayoutRaw -> IO (Ptr FontDescription))
-> IO (Ptr FontDescription)
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> IO (Ptr FontDescription)
pango_layout_get_font_description Ptr PangoLayoutRaw
argPtr1) PangoLayoutRaw
plr
  if Ptr FontDescription
fdPtrPtr FontDescription -> Ptr FontDescription -> Bool
forall a. Eq a => a -> a -> Bool
==Ptr FontDescription
forall a. Ptr a
nullPtr then Maybe FontDescription -> IO (Maybe FontDescription)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe FontDescription
forall a. Maybe a
Nothing else (FontDescription -> Maybe FontDescription)
-> IO FontDescription -> IO (Maybe FontDescription)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM FontDescription -> Maybe FontDescription
forall a. a -> Maybe a
Just (IO FontDescription -> IO (Maybe FontDescription))
-> IO FontDescription -> IO (Maybe FontDescription)
forall a b. (a -> b) -> a -> b
$ do
    Ptr FontDescription
fdPtr' <- Ptr FontDescription -> IO (Ptr FontDescription)
font_description_copy Ptr FontDescription
fdPtr
    Ptr FontDescription -> IO FontDescription
makeNewFontDescription Ptr FontDescription
fdPtr'

foreign import ccall unsafe "pango_font_description_copy"
  font_description_copy :: Ptr FontDescription -> IO (Ptr FontDescription)



-- | Set the width of this paragraph.
--
-- * Sets the width to which the lines of the 'PangoLayout'
-- should be wrapped.
--
-- * Pass in @Nothing@ to indicate that no wrapping is to be performed.
--
layoutSetWidth :: PangoLayout -> Maybe Double -> IO ()
layoutSetWidth :: PangoLayout -> Maybe Double -> IO ()
layoutSetWidth (PangoLayout IORef PangoString
_ PangoLayoutRaw
pl) Maybe Double
Nothing =
  (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) CInt
arg2 -> ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
-> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> CInt -> IO ()
pango_layout_set_width Ptr PangoLayoutRaw
argPtr1 CInt
arg2) PangoLayoutRaw
pl (-CInt
1)
layoutSetWidth (PangoLayout IORef PangoString
_ PangoLayoutRaw
pl) (Just Double
pu) =
  (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) CInt
arg2 -> ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
-> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> CInt -> IO ()
pango_layout_set_width Ptr PangoLayoutRaw
argPtr1 CInt
arg2) PangoLayoutRaw
pl (Double -> CInt
puToInt Double
pu)

-- | Gets the width of this paragraph.
--
-- * Gets the width to which the lines of the 'PangoLayout'
-- should be wrapped.
--
-- * Returns is the current width, or @Nothing@ to indicate that
-- no wrapping is performed.
--
layoutGetWidth :: PangoLayout -> IO (Maybe Double)
layoutGetWidth :: PangoLayout -> IO (Maybe Double)
layoutGetWidth (PangoLayout IORef PangoString
_ PangoLayoutRaw
pl) = do
  CInt
w <- (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) -> ForeignPtr PangoLayoutRaw
-> (Ptr PangoLayoutRaw -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO CInt) -> IO CInt)
-> (Ptr PangoLayoutRaw -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> IO CInt
pango_layout_get_width Ptr PangoLayoutRaw
argPtr1) PangoLayoutRaw
pl
  Maybe Double -> IO (Maybe Double)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (if CInt
wCInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
==(-CInt
1) then Maybe Double
forall a. Maybe a
Nothing else Double -> Maybe Double
forall a. a -> Maybe a
Just (CInt -> Double
intToPu CInt
w))

-- | Enumerates how a line can be wrapped.
--
-- [@WrapWholeWords@] Breaks lines only between words.
--
-- * This variant does not guarantee that the requested width is not
-- exceeded. A word that is longer than the paragraph width is not
-- split.
--
-- [@WrapAnywhere@] Break lines anywhere.
--
-- [@WrapPartialWords@] Wrap within a word if it is the only one on
-- this line.
--
-- * This option acts like 'WrapWholeWords' but will split
-- a word if it is the only one on this line and it exceeds the
-- specified width.
--
data LayoutWrapMode = WrapWholeWords
                    | WrapAnywhere
                    | WrapPartialWords
                    deriving (Int -> LayoutWrapMode
LayoutWrapMode -> Int
LayoutWrapMode -> [LayoutWrapMode]
LayoutWrapMode -> LayoutWrapMode
LayoutWrapMode -> LayoutWrapMode -> [LayoutWrapMode]
LayoutWrapMode
-> LayoutWrapMode -> LayoutWrapMode -> [LayoutWrapMode]
(LayoutWrapMode -> LayoutWrapMode)
-> (LayoutWrapMode -> LayoutWrapMode)
-> (Int -> LayoutWrapMode)
-> (LayoutWrapMode -> Int)
-> (LayoutWrapMode -> [LayoutWrapMode])
-> (LayoutWrapMode -> LayoutWrapMode -> [LayoutWrapMode])
-> (LayoutWrapMode -> LayoutWrapMode -> [LayoutWrapMode])
-> (LayoutWrapMode
    -> LayoutWrapMode -> LayoutWrapMode -> [LayoutWrapMode])
-> Enum LayoutWrapMode
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: LayoutWrapMode -> LayoutWrapMode
succ :: LayoutWrapMode -> LayoutWrapMode
$cpred :: LayoutWrapMode -> LayoutWrapMode
pred :: LayoutWrapMode -> LayoutWrapMode
$ctoEnum :: Int -> LayoutWrapMode
toEnum :: Int -> LayoutWrapMode
$cfromEnum :: LayoutWrapMode -> Int
fromEnum :: LayoutWrapMode -> Int
$cenumFrom :: LayoutWrapMode -> [LayoutWrapMode]
enumFrom :: LayoutWrapMode -> [LayoutWrapMode]
$cenumFromThen :: LayoutWrapMode -> LayoutWrapMode -> [LayoutWrapMode]
enumFromThen :: LayoutWrapMode -> LayoutWrapMode -> [LayoutWrapMode]
$cenumFromTo :: LayoutWrapMode -> LayoutWrapMode -> [LayoutWrapMode]
enumFromTo :: LayoutWrapMode -> LayoutWrapMode -> [LayoutWrapMode]
$cenumFromThenTo :: LayoutWrapMode
-> LayoutWrapMode -> LayoutWrapMode -> [LayoutWrapMode]
enumFromThenTo :: LayoutWrapMode
-> LayoutWrapMode -> LayoutWrapMode -> [LayoutWrapMode]
Enum)

{-# LINE 364 "./Graphics/Rendering/Pango/Layout.chs" #-}

-- | Set how this paragraph is wrapped.
--
-- * Sets the wrap style; the wrap style only has an effect if a width
-- is set on the layout with 'layoutSetWidth'. To turn off
-- wrapping, call 'layoutSetWidth' with @Nothing@.
--
layoutSetWrap :: PangoLayout -> LayoutWrapMode -> IO ()
layoutSetWrap :: PangoLayout -> LayoutWrapMode -> IO ()
layoutSetWrap (PangoLayout IORef PangoString
_ PangoLayoutRaw
pl) LayoutWrapMode
wm =
  (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) CInt
arg2 -> ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
-> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> CInt -> IO ()
pango_layout_set_wrap Ptr PangoLayoutRaw
argPtr1 CInt
arg2) PangoLayoutRaw
pl ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral(Int -> CInt) -> (LayoutWrapMode -> Int) -> LayoutWrapMode -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
.LayoutWrapMode -> Int
forall a. Enum a => a -> Int
fromEnum) LayoutWrapMode
wm)


-- | Get the wrap mode for the layout.
--
layoutGetWrap :: PangoLayout -> IO LayoutWrapMode
layoutGetWrap :: PangoLayout -> IO LayoutWrapMode
layoutGetWrap (PangoLayout IORef PangoString
_ PangoLayoutRaw
pl) = (CInt -> LayoutWrapMode) -> IO CInt -> IO LayoutWrapMode
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Int -> LayoutWrapMode
forall a. Enum a => Int -> a
toEnum(Int -> LayoutWrapMode) -> (CInt -> Int) -> CInt -> LayoutWrapMode
forall b c a. (b -> c) -> (a -> b) -> a -> c
.CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) (IO CInt -> IO LayoutWrapMode) -> IO CInt -> IO LayoutWrapMode
forall a b. (a -> b) -> a -> b
$
  (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) -> ForeignPtr PangoLayoutRaw
-> (Ptr PangoLayoutRaw -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO CInt) -> IO CInt)
-> (Ptr PangoLayoutRaw -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> IO CInt
pango_layout_get_wrap Ptr PangoLayoutRaw
argPtr1) PangoLayoutRaw
pl


-- | Set how long lines should be abbreviated.
--
layoutSetEllipsize :: PangoLayout -> EllipsizeMode -> IO ()
layoutSetEllipsize :: PangoLayout -> EllipsizeMode -> IO ()
layoutSetEllipsize (PangoLayout IORef PangoString
_ PangoLayoutRaw
pl) EllipsizeMode
em =
  (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) CInt
arg2 -> ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
-> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> CInt -> IO ()
pango_layout_set_ellipsize Ptr PangoLayoutRaw
argPtr1 CInt
arg2) PangoLayoutRaw
pl ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral(Int -> CInt) -> (EllipsizeMode -> Int) -> EllipsizeMode -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
.EllipsizeMode -> Int
forall a. Enum a => a -> Int
fromEnum) EllipsizeMode
em)

-- | Get the ellipsize mode for this layout.
--
layoutGetEllipsize :: PangoLayout -> IO EllipsizeMode
layoutGetEllipsize :: PangoLayout -> IO EllipsizeMode
layoutGetEllipsize (PangoLayout IORef PangoString
_ PangoLayoutRaw
pl) = (CInt -> EllipsizeMode) -> IO CInt -> IO EllipsizeMode
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Int -> EllipsizeMode
forall a. Enum a => Int -> a
toEnum(Int -> EllipsizeMode) -> (CInt -> Int) -> CInt -> EllipsizeMode
forall b c a. (b -> c) -> (a -> b) -> a -> c
.CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) (IO CInt -> IO EllipsizeMode) -> IO CInt -> IO EllipsizeMode
forall a b. (a -> b) -> a -> b
$
  (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) -> ForeignPtr PangoLayoutRaw
-> (Ptr PangoLayoutRaw -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO CInt) -> IO CInt)
-> (Ptr PangoLayoutRaw -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> IO CInt
pango_layout_get_ellipsize Ptr PangoLayoutRaw
argPtr1) PangoLayoutRaw
pl


-- | Set the indentation of this paragraph.
--
-- * Sets the amount by which the first line should
-- be indented. A negative value will produce a hanging indent, that is,
-- all subsequent lines will be indented while the first line has full
-- width.
--
layoutSetIndent :: PangoLayout -> Double -> IO ()
layoutSetIndent :: PangoLayout -> Double -> IO ()
layoutSetIndent (PangoLayout IORef PangoString
_ PangoLayoutRaw
pl) Double
indent =
  (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) CInt
arg2 -> ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
-> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> CInt -> IO ()
pango_layout_set_indent Ptr PangoLayoutRaw
argPtr1 CInt
arg2) PangoLayoutRaw
pl (Double -> CInt
puToInt Double
indent)

-- | Gets the indentation of this paragraph.
--
-- * Gets the amount by which the first line or the rest of the paragraph
-- is indented.
--
layoutGetIndent :: PangoLayout -> IO Double
layoutGetIndent :: PangoLayout -> IO Double
layoutGetIndent (PangoLayout IORef PangoString
_ PangoLayoutRaw
pl) =
  (CInt -> Double) -> IO CInt -> IO Double
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Double
intToPu (IO CInt -> IO Double) -> IO CInt -> IO Double
forall a b. (a -> b) -> a -> b
$ (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) -> ForeignPtr PangoLayoutRaw
-> (Ptr PangoLayoutRaw -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO CInt) -> IO CInt)
-> (Ptr PangoLayoutRaw -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> IO CInt
pango_layout_get_indent Ptr PangoLayoutRaw
argPtr1) PangoLayoutRaw
pl


-- | Set the spacing between lines of this paragraph.
--
layoutSetSpacing :: PangoLayout -> Double -> IO ()
layoutSetSpacing :: PangoLayout -> Double -> IO ()
layoutSetSpacing (PangoLayout IORef PangoString
_ PangoLayoutRaw
pl) Double
spacing =
  (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) CInt
arg2 -> ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
-> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> CInt -> IO ()
pango_layout_set_spacing Ptr PangoLayoutRaw
argPtr1 CInt
arg2) PangoLayoutRaw
pl (Double -> CInt
puToInt Double
spacing)

-- | Gets the spacing between the lines.
--
layoutGetSpacing :: PangoLayout -> IO Double
layoutGetSpacing :: PangoLayout -> IO Double
layoutGetSpacing (PangoLayout IORef PangoString
_ PangoLayoutRaw
pl) =
  (CInt -> Double) -> IO CInt -> IO Double
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Double
intToPu (IO CInt -> IO Double) -> IO CInt -> IO Double
forall a b. (a -> b) -> a -> b
$ (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) -> ForeignPtr PangoLayoutRaw
-> (Ptr PangoLayoutRaw -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO CInt) -> IO CInt)
-> (Ptr PangoLayoutRaw -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> IO CInt
pango_layout_get_spacing Ptr PangoLayoutRaw
argPtr1) PangoLayoutRaw
pl

-- | Set if text should be stretched to fit width.
--
-- * Sets whether or not each complete line should be stretched to
-- fill the entire width of the layout. This stretching is typically
-- done by adding whitespace, but for some scripts (such as Arabic),
-- the justification is done by extending the characters.
--
-- * Note that as of Pango 1.4, this functionality is not yet implemented.
--
layoutSetJustify :: PangoLayout -> Bool -> IO ()
layoutSetJustify :: PangoLayout -> Bool -> IO ()
layoutSetJustify (PangoLayout IORef PangoString
_ PangoLayoutRaw
pl) Bool
j =
  (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) CInt
arg2 -> ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
-> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> CInt -> IO ()
pango_layout_set_justify Ptr PangoLayoutRaw
argPtr1 CInt
arg2) PangoLayoutRaw
pl (Bool -> CInt
forall a. Num a => Bool -> a
fromBool Bool
j)

-- | Retrieve the justification flag.
--
-- * See 'layoutSetJustify'.
--
layoutGetJustify :: PangoLayout -> IO Bool
layoutGetJustify :: PangoLayout -> IO Bool
layoutGetJustify (PangoLayout IORef PangoString
_ PangoLayoutRaw
pl) =
  (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$ (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) -> ForeignPtr PangoLayoutRaw
-> (Ptr PangoLayoutRaw -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO CInt) -> IO CInt)
-> (Ptr PangoLayoutRaw -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> IO CInt
pango_layout_get_justify Ptr PangoLayoutRaw
argPtr1) PangoLayoutRaw
pl


-- | Set if the base text direction should be overridden.
--
-- * Sets whether to calculate the bidirectional base direction for the
-- layout according to the contents of the layout; when this flag is on
-- (the default), then paragraphs in layout that begin with strong
-- right-to-left characters (Arabic and Hebrew principally), will have
-- right-to-left layout, paragraphs with letters from other scripts will
-- have left-to-right layout. Paragraphs with only neutral characters get
-- their direction from the surrounding paragraphs.
--
-- * When @False@, the choice between left-to-right and right-to-left
-- layout is done by according to the base direction of the layout's
-- 'PangoContext'. (See 'Graphics.Rendering.Pango.Context.contextSetTextDir').
--
-- * When the auto-computed direction or a paragraph differs from the base
-- direction of the context, then the interpretation of
-- 'AlignLeft' and 'AlignRight' are swapped.
--
layoutSetAutoDir :: PangoLayout -> Bool -> IO ()
layoutSetAutoDir :: PangoLayout -> Bool -> IO ()
layoutSetAutoDir (PangoLayout IORef PangoString
_ PangoLayoutRaw
pl) Bool
j =
  (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) CInt
arg2 -> ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
-> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> CInt -> IO ()
pango_layout_set_auto_dir Ptr PangoLayoutRaw
argPtr1 CInt
arg2) PangoLayoutRaw
pl (Bool -> CInt
forall a. Num a => Bool -> a
fromBool Bool
j)

-- | Retrieve the auto direction flag.
--
-- * See 'layoutSetAutoDir'.
--
layoutGetAutoDir :: PangoLayout -> IO Bool
layoutGetAutoDir :: PangoLayout -> IO Bool
layoutGetAutoDir (PangoLayout IORef PangoString
_ PangoLayoutRaw
pl) =
  (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$ (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) -> ForeignPtr PangoLayoutRaw
-> (Ptr PangoLayoutRaw -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO CInt) -> IO CInt)
-> (Ptr PangoLayoutRaw -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> IO CInt
pango_layout_get_auto_dir Ptr PangoLayoutRaw
argPtr1) PangoLayoutRaw
pl



-- | Enumerate to which side incomplete lines are flushed.
--
data LayoutAlignment = AlignLeft
                     | AlignCenter
                     | AlignRight
                     deriving (Int -> LayoutAlignment
LayoutAlignment -> Int
LayoutAlignment -> [LayoutAlignment]
LayoutAlignment -> LayoutAlignment
LayoutAlignment -> LayoutAlignment -> [LayoutAlignment]
LayoutAlignment
-> LayoutAlignment -> LayoutAlignment -> [LayoutAlignment]
(LayoutAlignment -> LayoutAlignment)
-> (LayoutAlignment -> LayoutAlignment)
-> (Int -> LayoutAlignment)
-> (LayoutAlignment -> Int)
-> (LayoutAlignment -> [LayoutAlignment])
-> (LayoutAlignment -> LayoutAlignment -> [LayoutAlignment])
-> (LayoutAlignment -> LayoutAlignment -> [LayoutAlignment])
-> (LayoutAlignment
    -> LayoutAlignment -> LayoutAlignment -> [LayoutAlignment])
-> Enum LayoutAlignment
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: LayoutAlignment -> LayoutAlignment
succ :: LayoutAlignment -> LayoutAlignment
$cpred :: LayoutAlignment -> LayoutAlignment
pred :: LayoutAlignment -> LayoutAlignment
$ctoEnum :: Int -> LayoutAlignment
toEnum :: Int -> LayoutAlignment
$cfromEnum :: LayoutAlignment -> Int
fromEnum :: LayoutAlignment -> Int
$cenumFrom :: LayoutAlignment -> [LayoutAlignment]
enumFrom :: LayoutAlignment -> [LayoutAlignment]
$cenumFromThen :: LayoutAlignment -> LayoutAlignment -> [LayoutAlignment]
enumFromThen :: LayoutAlignment -> LayoutAlignment -> [LayoutAlignment]
$cenumFromTo :: LayoutAlignment -> LayoutAlignment -> [LayoutAlignment]
enumFromTo :: LayoutAlignment -> LayoutAlignment -> [LayoutAlignment]
$cenumFromThenTo :: LayoutAlignment
-> LayoutAlignment -> LayoutAlignment -> [LayoutAlignment]
enumFromThenTo :: LayoutAlignment
-> LayoutAlignment -> LayoutAlignment -> [LayoutAlignment]
Enum)

{-# LINE 486 "./Graphics/Rendering/Pango/Layout.chs" #-}

-- | Set how this paragraph is aligned.
--
-- * Sets the alignment for the layout (how partial lines are
-- positioned within the horizontal space available.)
--
layoutSetAlignment :: PangoLayout -> LayoutAlignment -> IO ()
layoutSetAlignment :: PangoLayout -> LayoutAlignment -> IO ()
layoutSetAlignment (PangoLayout IORef PangoString
_ PangoLayoutRaw
pl) LayoutAlignment
am =
  (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) CInt
arg2 -> ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
-> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> CInt -> IO ()
pango_layout_set_alignment Ptr PangoLayoutRaw
argPtr1 CInt
arg2) PangoLayoutRaw
pl ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral(Int -> CInt)
-> (LayoutAlignment -> Int) -> LayoutAlignment -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
.LayoutAlignment -> Int
forall a. Enum a => a -> Int
fromEnum) LayoutAlignment
am)


-- | Get the alignment for the layout.
--
layoutGetAlignment :: PangoLayout -> IO LayoutAlignment
layoutGetAlignment :: PangoLayout -> IO LayoutAlignment
layoutGetAlignment (PangoLayout IORef PangoString
_ PangoLayoutRaw
pl) = (CInt -> LayoutAlignment) -> IO CInt -> IO LayoutAlignment
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Int -> LayoutAlignment
forall a. Enum a => Int -> a
toEnum(Int -> LayoutAlignment)
-> (CInt -> Int) -> CInt -> LayoutAlignment
forall b c a. (b -> c) -> (a -> b) -> a -> c
.CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) (IO CInt -> IO LayoutAlignment) -> IO CInt -> IO LayoutAlignment
forall a b. (a -> b) -> a -> b
$
  (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) -> ForeignPtr PangoLayoutRaw
-> (Ptr PangoLayoutRaw -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO CInt) -> IO CInt)
-> (Ptr PangoLayoutRaw -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> IO CInt
pango_layout_get_alignment Ptr PangoLayoutRaw
argPtr1) PangoLayoutRaw
pl

-- | Specify where the Tab stop appears relative to the text.
--
-- * Only Tab stops that align text to the left are supported right now.
--
data TabAlign = TabLeft
              | TabRight
              | TabCenter
              | TabDecimal
              deriving (Int -> TabAlign
TabAlign -> Int
TabAlign -> [TabAlign]
TabAlign -> TabAlign
TabAlign -> TabAlign -> [TabAlign]
TabAlign -> TabAlign -> TabAlign -> [TabAlign]
(TabAlign -> TabAlign)
-> (TabAlign -> TabAlign)
-> (Int -> TabAlign)
-> (TabAlign -> Int)
-> (TabAlign -> [TabAlign])
-> (TabAlign -> TabAlign -> [TabAlign])
-> (TabAlign -> TabAlign -> [TabAlign])
-> (TabAlign -> TabAlign -> TabAlign -> [TabAlign])
-> Enum TabAlign
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: TabAlign -> TabAlign
succ :: TabAlign -> TabAlign
$cpred :: TabAlign -> TabAlign
pred :: TabAlign -> TabAlign
$ctoEnum :: Int -> TabAlign
toEnum :: Int -> TabAlign
$cfromEnum :: TabAlign -> Int
fromEnum :: TabAlign -> Int
$cenumFrom :: TabAlign -> [TabAlign]
enumFrom :: TabAlign -> [TabAlign]
$cenumFromThen :: TabAlign -> TabAlign -> [TabAlign]
enumFromThen :: TabAlign -> TabAlign -> [TabAlign]
$cenumFromTo :: TabAlign -> TabAlign -> [TabAlign]
enumFromTo :: TabAlign -> TabAlign -> [TabAlign]
$cenumFromThenTo :: TabAlign -> TabAlign -> TabAlign -> [TabAlign]
enumFromThenTo :: TabAlign -> TabAlign -> TabAlign -> [TabAlign]
Enum)

{-# LINE 508 "./Graphics/Rendering/Pango/Layout.chs" #-}

-- | A Tab position.
--
type TabPosition = (Double, TabAlign)

-- | Set a list of Tab positions.
--
layoutSetTabs :: PangoLayout -> [TabPosition] -> IO ()
layoutSetTabs :: PangoLayout -> [TabPosition] -> IO ()
layoutSetTabs (PangoLayout IORef PangoString
_ PangoLayoutRaw
pl) [TabPosition]
tabs = do
  let len :: CInt
len = Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral ([TabPosition] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [TabPosition]
tabs)
  Ptr ()
tabPtr <- CInt -> CInt -> IO (Ptr ())
pango_tab_array_new CInt
len (Bool -> CInt
forall a. Num a => Bool -> a
fromBool Bool
False)
  ((CInt, TabPosition) -> IO ()) -> [(CInt, TabPosition)] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (\(CInt
idx, (Double
pos, TabAlign
align)) ->
         Ptr () -> CInt -> CInt -> CInt -> IO ()
pango_tab_array_set_tab Ptr ()
tabPtr CInt
idx
            (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (TabAlign -> Int
forall a. Enum a => a -> Int
fromEnum TabAlign
align)) (Double -> CInt
puToInt Double
pos)) ([CInt] -> [TabPosition] -> [(CInt, TabPosition)]
forall a b. [a] -> [b] -> [(a, b)]
zip [CInt
0..] [TabPosition]
tabs)
  (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) Ptr ()
arg2 -> ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
-> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> Ptr () -> IO ()
pango_layout_set_tabs Ptr PangoLayoutRaw
argPtr1 Ptr ()
arg2) PangoLayoutRaw
pl Ptr ()
tabPtr
  Ptr () -> IO ()
pango_tab_array_free Ptr ()
tabPtr

-- | Reset the original set of Tab positions.
--
-- * Restore the default which is a Tab stop every eight characters.
--
layoutResetTabs :: PangoLayout -> IO ()
layoutResetTabs :: PangoLayout -> IO ()
layoutResetTabs (PangoLayout IORef PangoString
_ PangoLayoutRaw
pl) = (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) Ptr ()
arg2 -> ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
-> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> Ptr () -> IO ()
pango_layout_set_tabs Ptr PangoLayoutRaw
argPtr1 Ptr ()
arg2) PangoLayoutRaw
pl Ptr ()
forall a. Ptr a
nullPtr

-- | Retrieve the list of current Tab positions.
--
-- * If no Tab position where set, @Nothing@ is returned. In this case, Tab
-- positions are implicit at every eight characters.
--
layoutGetTabs :: PangoLayout -> IO (Maybe [TabPosition])
layoutGetTabs :: PangoLayout -> IO (Maybe [TabPosition])
layoutGetTabs (PangoLayout IORef PangoString
_ PangoLayoutRaw
pl) = do
  Ptr ()
tabPtr <- (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) -> ForeignPtr PangoLayoutRaw
-> (Ptr PangoLayoutRaw -> IO (Ptr ())) -> IO (Ptr ())
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO (Ptr ())) -> IO (Ptr ()))
-> (Ptr PangoLayoutRaw -> IO (Ptr ())) -> IO (Ptr ())
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> IO (Ptr ())
pango_layout_get_tabs Ptr PangoLayoutRaw
argPtr1) PangoLayoutRaw
pl
  if Ptr ()
tabPtr Ptr () -> Ptr () -> Bool
forall a. Eq a => a -> a -> Bool
== Ptr ()
forall a. Ptr a
nullPtr then Maybe [TabPosition] -> IO (Maybe [TabPosition])
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe [TabPosition]
forall a. Maybe a
Nothing else ([TabPosition] -> Maybe [TabPosition])
-> IO [TabPosition] -> IO (Maybe [TabPosition])
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM [TabPosition] -> Maybe [TabPosition]
forall a. a -> Maybe a
Just (IO [TabPosition] -> IO (Maybe [TabPosition]))
-> IO [TabPosition] -> IO (Maybe [TabPosition])
forall a b. (a -> b) -> a -> b
$ do
    CInt
len <- Ptr () -> IO CInt
pango_tab_array_get_size Ptr ()
tabPtr
    (CInt -> IO TabPosition) -> [CInt] -> IO [TabPosition]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (\CInt
idx -> (Ptr CInt -> IO TabPosition) -> IO TabPosition
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CInt -> IO TabPosition) -> IO TabPosition)
-> (Ptr CInt -> IO TabPosition) -> IO TabPosition
forall a b. (a -> b) -> a -> b
$ \Ptr CInt
posPtr -> (Ptr CInt -> IO TabPosition) -> IO TabPosition
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CInt -> IO TabPosition) -> IO TabPosition)
-> (Ptr CInt -> IO TabPosition) -> IO TabPosition
forall a b. (a -> b) -> a -> b
$ \Ptr CInt
alignPtr -> do
          Ptr () -> CInt -> Ptr CInt -> Ptr CInt -> IO ()
pango_tab_array_get_tab Ptr ()
tabPtr CInt
idx Ptr CInt
alignPtr Ptr CInt
posPtr
          CInt
align <- Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
alignPtr
          CInt
pos <- Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
posPtr
          TabPosition -> IO TabPosition
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CInt -> Double
intToPu CInt
pos, Int -> TabAlign
forall a. Enum a => Int -> a
toEnum (CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
align))) [CInt
0..CInt
lenCInt -> CInt -> CInt
forall a. Num a => a -> a -> a
-CInt
1]

-- | Honor newlines or not.
--
-- * If @honor@ is @True@, do not treat newlines and
-- similar characters as paragraph separators; instead, keep all text in
-- a single paragraph, and display a glyph for paragraph separator
-- characters. Used when you want to allow editing of newlines on a
-- single text line.
--
layoutSetSingleParagraphMode :: PangoLayout -> Bool -> IO ()
layoutSetSingleParagraphMode :: PangoLayout -> Bool -> IO ()
layoutSetSingleParagraphMode (PangoLayout IORef PangoString
_ PangoLayoutRaw
pl) Bool
honor =
  (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) CInt
arg2 -> ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
-> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> CInt -> IO ()
pango_layout_set_single_paragraph_mode Ptr PangoLayoutRaw
argPtr1 CInt
arg2) PangoLayoutRaw
pl (Bool -> CInt
forall a. Num a => Bool -> a
fromBool Bool
honor)

-- | Retrieve if newlines are honored.
--
-- * See 'layoutSetSingleParagraphMode'.
--
layoutGetSingleParagraphMode :: PangoLayout -> IO Bool
layoutGetSingleParagraphMode :: PangoLayout -> IO Bool
layoutGetSingleParagraphMode (PangoLayout IORef PangoString
_ PangoLayoutRaw
pl) =
  (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$ (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) -> ForeignPtr PangoLayoutRaw
-> (Ptr PangoLayoutRaw -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO CInt) -> IO CInt)
-> (Ptr PangoLayoutRaw -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> IO CInt
pango_layout_get_single_paragraph_mode Ptr PangoLayoutRaw
argPtr1) PangoLayoutRaw
pl

-- a function is missing here

-- | Converts a device unit to a character index.
--
-- * Converts from @x@ and @y@ position within a layout to the index of
-- the closest character. If the @y@ position is not inside the layout,
-- the closest position is chosen (the position will be clamped inside
-- the layout). If the @x@ position is not within the layout, then the
-- start or the end of the line is chosen. If either the @x@ or @y@
-- positions were not inside the layout, then the function returns @False@;
-- on an exact hit, it returns @True@.
--
-- * The function returns the flag for the exact hit and the index into
-- the string. The third value is zero if the character corresponds to
-- one grapheme. If the grapheme is the result of a cluster, this value
-- may be greater than one, indicating where in the grapheme the position
-- lies. Zero represents the trailing edge on the grapheme.
--
layoutXYToIndex :: PangoLayout -> Double -- ^ the @x@ position
                -> Double -- ^ the @y@ position
                -> IO (Bool, Int, Int)
layoutXYToIndex :: PangoLayout -> Double -> Double -> IO (Bool, Int, Int)
layoutXYToIndex (PangoLayout IORef PangoString
psRef PangoLayoutRaw
pl) Double
x Double
y =
  (Ptr CInt -> IO (Bool, Int, Int)) -> IO (Bool, Int, Int)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CInt -> IO (Bool, Int, Int)) -> IO (Bool, Int, Int))
-> (Ptr CInt -> IO (Bool, Int, Int)) -> IO (Bool, Int, Int)
forall a b. (a -> b) -> a -> b
$ \Ptr CInt
idxPtr -> (Ptr CInt -> IO (Bool, Int, Int)) -> IO (Bool, Int, Int)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CInt -> IO (Bool, Int, Int)) -> IO (Bool, Int, Int))
-> (Ptr CInt -> IO (Bool, Int, Int)) -> IO (Bool, Int, Int)
forall a b. (a -> b) -> a -> b
$ \Ptr CInt
trailPtr -> do
    CInt
res <- (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) CInt
arg2 CInt
arg3 Ptr CInt
arg4 Ptr CInt
arg5 -> ForeignPtr PangoLayoutRaw
-> (Ptr PangoLayoutRaw -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO CInt) -> IO CInt)
-> (Ptr PangoLayoutRaw -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw
-> CInt -> CInt -> Ptr CInt -> Ptr CInt -> IO CInt
pango_layout_xy_to_index Ptr PangoLayoutRaw
argPtr1 CInt
arg2 CInt
arg3 Ptr CInt
arg4 Ptr CInt
arg5) PangoLayoutRaw
pl (Double -> CInt
puToInt Double
x) (Double -> CInt
puToInt Double
y)
      Ptr CInt
idxPtr Ptr CInt
trailPtr
    CInt
idx <- Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
idxPtr
    CInt
trail <- Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
trailPtr
    (PangoString UTFCorrection
uc CInt
_ ForeignPtr CChar
_) <- IORef PangoString -> IO PangoString
forall a. IORef a -> IO a
readIORef IORef PangoString
psRef
    (Bool, Int, Int) -> IO (Bool, Int, Int)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool CInt
res,
            Int -> UTFCorrection -> Int
ofsFromUTF (CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
idx) UTFCorrection
uc,
            Int -> UTFCorrection -> Int
ofsFromUTF (CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
trail) UTFCorrection
uc)

-- | Return the rectangle of the glyph at the given index.
--
-- * Converts from an index within a 'PangoLayout' to the onscreen position
-- corresponding to the grapheme at that index, which is represented as
-- rectangle. Note that, given a @PangoRectangle x y width height@, @x@
-- is always the leading edge of the grapheme and @x + width@ the
-- trailing edge of the grapheme. If the directionality of the grapheme
-- is right-to-left, then @width@ will be negative.
--
layoutIndexToPos :: PangoLayout -> Int -> IO PangoRectangle
layoutIndexToPos :: PangoLayout -> Int -> IO PangoRectangle
layoutIndexToPos (PangoLayout IORef PangoString
psRef PangoLayoutRaw
plr) Int
pos = do
  (PangoString UTFCorrection
uc CInt
_ ForeignPtr CChar
_) <- IORef PangoString -> IO PangoString
forall a. IORef a -> IO a
readIORef IORef PangoString
psRef
  (Ptr PangoRectangle -> IO PangoRectangle) -> IO PangoRectangle
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr PangoRectangle -> IO PangoRectangle) -> IO PangoRectangle)
-> (Ptr PangoRectangle -> IO PangoRectangle) -> IO PangoRectangle
forall a b. (a -> b) -> a -> b
$ \Ptr PangoRectangle
rectPtr -> do
    (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) CInt
arg2 Ptr ()
arg3 -> ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
-> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> CInt -> Ptr () -> IO ()
pango_layout_index_to_pos Ptr PangoLayoutRaw
argPtr1 CInt
arg2 Ptr ()
arg3) PangoLayoutRaw
plr (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> UTFCorrection -> Int
ofsToUTF Int
pos UTFCorrection
uc))
                                            (Ptr PangoRectangle -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr Ptr PangoRectangle
rectPtr)
    Ptr PangoRectangle -> IO PangoRectangle
forall a. Storable a => Ptr a -> IO a
peek Ptr PangoRectangle
rectPtr

twoRect :: (Ptr () -> Ptr () -> IO ()) ->
           IO (PangoRectangle, PangoRectangle)
twoRect :: (Ptr () -> Ptr () -> IO ()) -> IO (PangoRectangle, PangoRectangle)
twoRect Ptr () -> Ptr () -> IO ()
f =
  (Ptr PangoRectangle -> IO (PangoRectangle, PangoRectangle))
-> IO (PangoRectangle, PangoRectangle)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr PangoRectangle -> IO (PangoRectangle, PangoRectangle))
 -> IO (PangoRectangle, PangoRectangle))
-> (Ptr PangoRectangle -> IO (PangoRectangle, PangoRectangle))
-> IO (PangoRectangle, PangoRectangle)
forall a b. (a -> b) -> a -> b
$ \Ptr PangoRectangle
inkPtr -> (Ptr PangoRectangle -> IO (PangoRectangle, PangoRectangle))
-> IO (PangoRectangle, PangoRectangle)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr PangoRectangle -> IO (PangoRectangle, PangoRectangle))
 -> IO (PangoRectangle, PangoRectangle))
-> (Ptr PangoRectangle -> IO (PangoRectangle, PangoRectangle))
-> IO (PangoRectangle, PangoRectangle)
forall a b. (a -> b) -> a -> b
$ \Ptr PangoRectangle
logPtr -> do
  Ptr () -> Ptr () -> IO ()
f (Ptr PangoRectangle -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr Ptr PangoRectangle
inkPtr) (Ptr PangoRectangle -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr Ptr PangoRectangle
logPtr)
  PangoRectangle
ink <- Ptr PangoRectangle -> IO PangoRectangle
forall a. Storable a => Ptr a -> IO a
peek Ptr PangoRectangle
inkPtr
  PangoRectangle
log <- Ptr PangoRectangle -> IO PangoRectangle
forall a. Storable a => Ptr a -> IO a
peek Ptr PangoRectangle
logPtr
  (PangoRectangle, PangoRectangle)
-> IO (PangoRectangle, PangoRectangle)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (PangoRectangle
ink, PangoRectangle
log)

-- | Return a cursor position.
--
-- * Given an index within a layout, determines the positions that of the
-- strong and weak cursors if the insertion point is at that index.
-- The position of each cursor is stored as a zero-width rectangle.
-- The strong cursor location is the location where characters of the
-- directionality equal to the base direction of the layout are inserted.
-- The weak cursor location is the location where characters of the
-- directionality opposite to the base direction of the layout are
-- inserted. The first element of the tuple is the strong position,
-- the second the weak.
--
layoutGetCursorPos :: PangoLayout -> Int ->
                      IO (PangoRectangle, PangoRectangle) -- ^ @(strong, weak)@
layoutGetCursorPos :: PangoLayout -> Int -> IO (PangoRectangle, PangoRectangle)
layoutGetCursorPos (PangoLayout IORef PangoString
psRef PangoLayoutRaw
plr) Int
pos = do
  (PangoString UTFCorrection
uc CInt
_ ForeignPtr CChar
_) <- IORef PangoString -> IO PangoString
forall a. IORef a -> IO a
readIORef IORef PangoString
psRef
  (Ptr () -> Ptr () -> IO ()) -> IO (PangoRectangle, PangoRectangle)
twoRect ((Ptr () -> Ptr () -> IO ())
 -> IO (PangoRectangle, PangoRectangle))
-> (Ptr () -> Ptr () -> IO ())
-> IO (PangoRectangle, PangoRectangle)
forall a b. (a -> b) -> a -> b
$ (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) CInt
arg2 Ptr ()
arg3 Ptr ()
arg4 -> ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
-> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> CInt -> Ptr () -> Ptr () -> IO ()
pango_layout_get_cursor_pos Ptr PangoLayoutRaw
argPtr1 CInt
arg2 Ptr ()
arg3 Ptr ()
arg4) PangoLayoutRaw
plr (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> UTFCorrection -> Int
ofsToUTF Int
pos UTFCorrection
uc))

-- | A new cursor position.
--
-- See 'layoutMoveCursorVisually'.
--
data CursorPos
  = CursorPosPrevPara -- ^ The cursor should move to the previous paragraph.
  | CursorPos Int Int -- ^ The sum of the indices is the new cursor position.
  | CursorPosNextPara -- ^ The cursor should advance to the next paragraph.

-- | Move a cursor visually.
--
-- * Compute a new cursor position from a previous cursor position. A value
-- of @True@ for the direction will move it to the right, independent of
-- the underlying direction. Hence the cursor position might jump if
-- left-to-right text is mixed with right-to-left text.
--
-- * The first flag should be @True@ if this cursor is the strong cursor.
-- The strong cursor is the cursor of the base direction of the current
-- layout (see 'layoutSetAutoDir'). The weak cursor is that of the
-- opposite direction.
--
-- * The previous cursor position is given by @idx@. If this text at this
-- position is a cluster, the cursor will only move to the end or
-- beginning of the cluster as opposed to past the next character.
-- The return value is either 'CursorPosNextPara' if the cursor moved
-- beyond this paragraph, it is 'CursorPosPrevPara' if the cursor moved
-- in front of this paragraph and it is 'CursorPos' @idx@ @trail@ to denote
-- the new cursor position @idx@. Note that @idx@ will always denote an
-- insertion point, that is, @idx@ will never point into the middle of
-- a cluster. The @trail@ value can contain a positive
-- value if the current cursor position is at the end of the current line.
-- In this case, @idx@ points past the last character of this line while
-- @trail@ contains the number of characters that are responsible for the
-- line break such as newlines. The actual cursor position is always
-- @idx+trail@ where the visual cursor should be shown.
--
layoutMoveCursorVisually :: PangoLayout
                         -> Bool -- ^ @True@ to create a strong cursor.
                         -> Int -- ^ The previous position.
                         -> Bool -- ^ @True@ if the cursor should move right.
                         -> IO CursorPos
layoutMoveCursorVisually :: PangoLayout -> Bool -> Int -> Bool -> IO CursorPos
layoutMoveCursorVisually (PangoLayout IORef PangoString
psRef PangoLayoutRaw
plr) Bool
strong Int
index Bool
dir = do
  (PangoString UTFCorrection
uc CInt
_ ForeignPtr CChar
_) <- IORef PangoString -> IO PangoString
forall a. IORef a -> IO a
readIORef IORef PangoString
psRef
  (Ptr CInt -> IO CursorPos) -> IO CursorPos
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CInt -> IO CursorPos) -> IO CursorPos)
-> (Ptr CInt -> IO CursorPos) -> IO CursorPos
forall a b. (a -> b) -> a -> b
$ \Ptr CInt
idxPtr -> (Ptr CInt -> IO CursorPos) -> IO CursorPos
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CInt -> IO CursorPos) -> IO CursorPos)
-> (Ptr CInt -> IO CursorPos) -> IO CursorPos
forall a b. (a -> b) -> a -> b
$ \Ptr CInt
trailPtr -> do
    (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) CInt
arg2 CInt
arg3 CInt
arg4 CInt
arg5 Ptr CInt
arg6 Ptr CInt
arg7 -> ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
-> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw
-> CInt -> CInt -> CInt -> CInt -> Ptr CInt -> Ptr CInt -> IO ()
pango_layout_move_cursor_visually Ptr PangoLayoutRaw
argPtr1 CInt
arg2 CInt
arg3 CInt
arg4 CInt
arg5 Ptr CInt
arg6 Ptr CInt
arg7) PangoLayoutRaw
plr (Bool -> CInt
forall a. Num a => Bool -> a
fromBool Bool
strong)
      (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> UTFCorrection -> Int
ofsToUTF Int
index UTFCorrection
uc)) CInt
0
      (if Bool
dir then CInt
1 else (-CInt
1)) Ptr CInt
idxPtr Ptr CInt
trailPtr
    CInt
idx <- Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
idxPtr
    CInt
trail <- Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
trailPtr
    CursorPos -> IO CursorPos
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (if CInt
idxCInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
==(-CInt
1) then CursorPos
CursorPosPrevPara else
            if CInt
idxCInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
==CInt
forall a. Bounded a => a
maxBound then CursorPos
CursorPosNextPara else
            Int -> Int -> CursorPos
CursorPos (Int -> UTFCorrection -> Int
ofsFromUTF (CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
idx) UTFCorrection
uc) (CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
trail))

-- | Computes the logical and ink extents of the 'PangoLayout'.
--
-- Logical extents are usually what you want for positioning things. Note that
-- both extents may have non-zero x and y. You may want to use those to offset
-- where you render the layout. Not doing that is a very typical bug that
-- shows up as right-to-left layouts not being correctly positioned in a
-- layout with a set width.
--
-- Layout coordinates begin at the top left corner of the layout.
--
layoutGetExtents :: PangoLayout
                 -> IO (PangoRectangle, PangoRectangle) -- ^ @(ink, logical)@
layoutGetExtents :: PangoLayout -> IO (PangoRectangle, PangoRectangle)
layoutGetExtents (PangoLayout IORef PangoString
_ PangoLayoutRaw
pl) =
  (Ptr () -> Ptr () -> IO ()) -> IO (PangoRectangle, PangoRectangle)
twoRect ((Ptr () -> Ptr () -> IO ())
 -> IO (PangoRectangle, PangoRectangle))
-> (Ptr () -> Ptr () -> IO ())
-> IO (PangoRectangle, PangoRectangle)
forall a b. (a -> b) -> a -> b
$ (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) Ptr ()
arg2 Ptr ()
arg3 -> ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
-> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> Ptr () -> Ptr () -> IO ()
pango_layout_get_extents Ptr PangoLayoutRaw
argPtr1 Ptr ()
arg2 Ptr ()
arg3) PangoLayoutRaw
pl

-- | Compute the physical size of the layout.
--
-- * Computes the ink and the logical size of the 'Layout' in device units,
-- that is, pixels for a screen. Identical to 'layoutGetExtents' and
-- converting the 'Double's in the 'PangoRectangle' to integers.
--
layoutGetPixelExtents :: PangoLayout -> IO (Rectangle, Rectangle) -- ^ @(ink, logical)@
layoutGetPixelExtents :: PangoLayout -> IO (Rectangle, Rectangle)
layoutGetPixelExtents (PangoLayout IORef PangoString
_ PangoLayoutRaw
pl) =
  (Ptr PangoRectangle -> IO (Rectangle, Rectangle))
-> IO (Rectangle, Rectangle)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr PangoRectangle -> IO (Rectangle, Rectangle))
 -> IO (Rectangle, Rectangle))
-> (Ptr PangoRectangle -> IO (Rectangle, Rectangle))
-> IO (Rectangle, Rectangle)
forall a b. (a -> b) -> a -> b
$ \Ptr PangoRectangle
inkPtr -> (Ptr PangoRectangle -> IO (Rectangle, Rectangle))
-> IO (Rectangle, Rectangle)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr PangoRectangle -> IO (Rectangle, Rectangle))
 -> IO (Rectangle, Rectangle))
-> (Ptr PangoRectangle -> IO (Rectangle, Rectangle))
-> IO (Rectangle, Rectangle)
forall a b. (a -> b) -> a -> b
$ \Ptr PangoRectangle
logPtr -> do
  (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) Ptr ()
arg2 Ptr ()
arg3 -> ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
-> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> Ptr () -> Ptr () -> IO ()
pango_layout_get_pixel_extents Ptr PangoLayoutRaw
argPtr1 Ptr ()
arg2 Ptr ()
arg3) PangoLayoutRaw
pl (Ptr PangoRectangle -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr Ptr PangoRectangle
inkPtr) (Ptr PangoRectangle -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr Ptr PangoRectangle
logPtr)
  Rectangle
ink <- Ptr PangoRectangle -> IO Rectangle
peekIntPangoRectangle Ptr PangoRectangle
inkPtr
  Rectangle
log <- Ptr PangoRectangle -> IO Rectangle
peekIntPangoRectangle Ptr PangoRectangle
logPtr
  (Rectangle, Rectangle) -> IO (Rectangle, Rectangle)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Rectangle
ink,Rectangle
log)

-- | Ask for the number of lines in this layout.
--
layoutGetLineCount :: PangoLayout -> IO Int
layoutGetLineCount :: PangoLayout -> IO Int
layoutGetLineCount (PangoLayout IORef PangoString
_ PangoLayoutRaw
pl) = (CInt -> Int) -> IO CInt -> IO Int
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (IO CInt -> IO Int) -> IO CInt -> IO Int
forall a b. (a -> b) -> a -> b
$
  (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) -> ForeignPtr PangoLayoutRaw
-> (Ptr PangoLayoutRaw -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO CInt) -> IO CInt)
-> (Ptr PangoLayoutRaw -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> IO CInt
pango_layout_get_line_count Ptr PangoLayoutRaw
argPtr1) PangoLayoutRaw
pl

-- | Extract a single lines of the layout.
--
-- * The given index starts from 0. The function throws an
-- 'ArrayException' if the index is out of bounds.
--
-- * The lines of each layout are regenerated if any attribute changes.
-- Thus the returned list does not reflect the current state of lines
-- after a change has been made.
--
layoutGetLine :: PangoLayout -> Int -> IO LayoutLine
layoutGetLine :: PangoLayout -> Int -> IO LayoutLine
layoutGetLine (PangoLayout IORef PangoString
psRef PangoLayoutRaw
pl) Int
idx = do
  Ptr LayoutLineRaw
llPtr <-

    -- use the optimised read-only version if available
    (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) CInt
arg2 -> ForeignPtr PangoLayoutRaw
-> (Ptr PangoLayoutRaw -> IO (Ptr LayoutLineRaw))
-> IO (Ptr LayoutLineRaw)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO (Ptr LayoutLineRaw))
 -> IO (Ptr LayoutLineRaw))
-> (Ptr PangoLayoutRaw -> IO (Ptr LayoutLineRaw))
-> IO (Ptr LayoutLineRaw)
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> CInt -> IO (Ptr LayoutLineRaw)
pango_layout_get_line_readonly Ptr PangoLayoutRaw
argPtr1 CInt
arg2)
{-# LINE 747 "./Graphics/Rendering/Pango/Layout.chs" #-}



      PangoLayoutRaw
pl (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
idx)
  if Ptr LayoutLineRaw
llPtrPtr LayoutLineRaw -> Ptr LayoutLineRaw -> Bool
forall a. Eq a => a -> a -> Bool
==Ptr LayoutLineRaw
forall a. Ptr a
nullPtr then
     ArrayException -> IO LayoutLine
forall e a. Exception e => e -> IO a
throwIO ([Char] -> ArrayException
IndexOutOfBounds
      ([Char]
"Graphics.Rendering.Pango.Layout.layoutGetLine: "[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++
       [Char]
"no line at index "[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++Int -> [Char]
forall a. Show a => a -> [Char]
show Int
idx)) else do
  LayoutLineRaw
ll <- Ptr LayoutLineRaw -> IO LayoutLineRaw
makeNewLayoutLineRaw Ptr LayoutLineRaw
llPtr
  (\(LayoutLineRaw ForeignPtr LayoutLineRaw
arg1) -> ForeignPtr LayoutLineRaw
-> (Ptr LayoutLineRaw -> IO (Ptr LayoutLineRaw))
-> IO (Ptr LayoutLineRaw)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr LayoutLineRaw
arg1 ((Ptr LayoutLineRaw -> IO (Ptr LayoutLineRaw))
 -> IO (Ptr LayoutLineRaw))
-> (Ptr LayoutLineRaw -> IO (Ptr LayoutLineRaw))
-> IO (Ptr LayoutLineRaw)
forall a b. (a -> b) -> a -> b
$ \Ptr LayoutLineRaw
argPtr1 ->Ptr LayoutLineRaw -> IO (Ptr LayoutLineRaw)
pango_layout_line_ref Ptr LayoutLineRaw
argPtr1) LayoutLineRaw
ll
  LayoutLine -> IO LayoutLine
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (IORef PangoString -> LayoutLineRaw -> LayoutLine
LayoutLine IORef PangoString
psRef LayoutLineRaw
ll)

-- | Extract the lines of the layout.
--
-- * The lines of each layout are regenerated if any attribute changes.
-- Thus the returned list does not reflect the current state of lines
-- after a change has been made.
--
layoutGetLines :: PangoLayout -> IO [LayoutLine]
layoutGetLines :: PangoLayout -> IO [LayoutLine]
layoutGetLines (PangoLayout IORef PangoString
psRef PangoLayoutRaw
pl) = do
  Ptr ()
listPtr <-

    -- use the optimised read-only version if available
    (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) -> ForeignPtr PangoLayoutRaw
-> (Ptr PangoLayoutRaw -> IO (Ptr ())) -> IO (Ptr ())
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO (Ptr ())) -> IO (Ptr ()))
-> (Ptr PangoLayoutRaw -> IO (Ptr ())) -> IO (Ptr ())
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> IO (Ptr ())
pango_layout_get_lines_readonly Ptr PangoLayoutRaw
argPtr1)
{-# LINE 771 "./Graphics/Rendering/Pango/Layout.chs" #-}



    PangoLayoutRaw
pl
  [Ptr LayoutLineRaw]
list <- Ptr () -> IO [Ptr LayoutLineRaw]
forall a. Ptr () -> IO [Ptr a]
readGSList Ptr ()
listPtr
  [LayoutLineRaw]
pls <- (Ptr LayoutLineRaw -> IO LayoutLineRaw)
-> [Ptr LayoutLineRaw] -> IO [LayoutLineRaw]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM Ptr LayoutLineRaw -> IO LayoutLineRaw
makeNewLayoutLineRaw [Ptr LayoutLineRaw]
list
  (LayoutLineRaw -> IO (Ptr LayoutLineRaw))
-> [LayoutLineRaw] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (\(LayoutLineRaw ForeignPtr LayoutLineRaw
arg1) -> ForeignPtr LayoutLineRaw
-> (Ptr LayoutLineRaw -> IO (Ptr LayoutLineRaw))
-> IO (Ptr LayoutLineRaw)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr LayoutLineRaw
arg1 ((Ptr LayoutLineRaw -> IO (Ptr LayoutLineRaw))
 -> IO (Ptr LayoutLineRaw))
-> (Ptr LayoutLineRaw -> IO (Ptr LayoutLineRaw))
-> IO (Ptr LayoutLineRaw)
forall a b. (a -> b) -> a -> b
$ \Ptr LayoutLineRaw
argPtr1 ->Ptr LayoutLineRaw -> IO (Ptr LayoutLineRaw)
pango_layout_line_ref Ptr LayoutLineRaw
argPtr1) [LayoutLineRaw]
pls
  [LayoutLine] -> IO [LayoutLine]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ((LayoutLineRaw -> LayoutLine) -> [LayoutLineRaw] -> [LayoutLine]
forall a b. (a -> b) -> [a] -> [b]
map (IORef PangoString -> LayoutLineRaw -> LayoutLine
LayoutLine IORef PangoString
psRef) [LayoutLineRaw]
pls)

-- | Create an iterator to examine a layout.
--
layoutGetIter :: PangoLayout -> IO LayoutIter
layoutGetIter :: PangoLayout -> IO LayoutIter
layoutGetIter (PangoLayout IORef PangoString
psRef PangoLayoutRaw
pl) = do
  Ptr LayoutIterRaw
iterPtr <- (\(PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg1) -> ForeignPtr PangoLayoutRaw
-> (Ptr PangoLayoutRaw -> IO (Ptr LayoutIterRaw))
-> IO (Ptr LayoutIterRaw)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg1 ((Ptr PangoLayoutRaw -> IO (Ptr LayoutIterRaw))
 -> IO (Ptr LayoutIterRaw))
-> (Ptr PangoLayoutRaw -> IO (Ptr LayoutIterRaw))
-> IO (Ptr LayoutIterRaw)
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr1 ->Ptr PangoLayoutRaw -> IO (Ptr LayoutIterRaw)
pango_layout_get_iter Ptr PangoLayoutRaw
argPtr1) PangoLayoutRaw
pl
  (LayoutIterRaw -> LayoutIter) -> IO LayoutIterRaw -> IO LayoutIter
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (IORef PangoString -> LayoutIterRaw -> LayoutIter
LayoutIter IORef PangoString
psRef) (IO LayoutIterRaw -> IO LayoutIter)
-> IO LayoutIterRaw -> IO LayoutIter
forall a b. (a -> b) -> a -> b
$ Ptr LayoutIterRaw -> IO LayoutIterRaw
makeNewLayoutIterRaw Ptr LayoutIterRaw
iterPtr

-- | Move to the next 'GlyphItem'.
--
-- * Returns @False@ if this was the last item in the layout.
--
layoutIterNextItem :: LayoutIter -> IO Bool
layoutIterNextItem :: LayoutIter -> IO Bool
layoutIterNextItem (LayoutIter IORef PangoString
_ LayoutIterRaw
li) =
  (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$ (\(LayoutIterRaw ForeignPtr LayoutIterRaw
arg1) -> ForeignPtr LayoutIterRaw
-> (Ptr LayoutIterRaw -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr LayoutIterRaw
arg1 ((Ptr LayoutIterRaw -> IO CInt) -> IO CInt)
-> (Ptr LayoutIterRaw -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr LayoutIterRaw
argPtr1 ->Ptr LayoutIterRaw -> IO CInt
pango_layout_iter_next_run Ptr LayoutIterRaw
argPtr1) LayoutIterRaw
li

-- | Move to the next char.
--
-- * Returns @False@ if this was the last char in the layout.
--
layoutIterNextChar :: LayoutIter -> IO Bool
layoutIterNextChar :: LayoutIter -> IO Bool
layoutIterNextChar (LayoutIter IORef PangoString
_ LayoutIterRaw
li) =
  (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$ (\(LayoutIterRaw ForeignPtr LayoutIterRaw
arg1) -> ForeignPtr LayoutIterRaw
-> (Ptr LayoutIterRaw -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr LayoutIterRaw
arg1 ((Ptr LayoutIterRaw -> IO CInt) -> IO CInt)
-> (Ptr LayoutIterRaw -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr LayoutIterRaw
argPtr1 ->Ptr LayoutIterRaw -> IO CInt
pango_layout_iter_next_char Ptr LayoutIterRaw
argPtr1) LayoutIterRaw
li

-- | Move to the next cluster.
--
-- * Returns @False@ if this was the last cluster in the layout.
--
layoutIterNextCluster :: LayoutIter -> IO Bool
layoutIterNextCluster :: LayoutIter -> IO Bool
layoutIterNextCluster (LayoutIter IORef PangoString
_ LayoutIterRaw
li) =
  (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$ (\(LayoutIterRaw ForeignPtr LayoutIterRaw
arg1) -> ForeignPtr LayoutIterRaw
-> (Ptr LayoutIterRaw -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr LayoutIterRaw
arg1 ((Ptr LayoutIterRaw -> IO CInt) -> IO CInt)
-> (Ptr LayoutIterRaw -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr LayoutIterRaw
argPtr1 ->Ptr LayoutIterRaw -> IO CInt
pango_layout_iter_next_cluster Ptr LayoutIterRaw
argPtr1) LayoutIterRaw
li

-- | Move to the next line.
--
-- * Returns @False@ if this was the last line in the layout.
--
layoutIterNextLine :: LayoutIter -> IO Bool
layoutIterNextLine :: LayoutIter -> IO Bool
layoutIterNextLine (LayoutIter IORef PangoString
_ LayoutIterRaw
li) =
  (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$ (\(LayoutIterRaw ForeignPtr LayoutIterRaw
arg1) -> ForeignPtr LayoutIterRaw
-> (Ptr LayoutIterRaw -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr LayoutIterRaw
arg1 ((Ptr LayoutIterRaw -> IO CInt) -> IO CInt)
-> (Ptr LayoutIterRaw -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr LayoutIterRaw
argPtr1 ->Ptr LayoutIterRaw -> IO CInt
pango_layout_iter_next_line Ptr LayoutIterRaw
argPtr1) LayoutIterRaw
li

-- | Check if the iterator is on the last line.
--
-- * Returns @True@ if the iterator is on the last line of this
-- paragraph.
--
layoutIterAtLastLine :: LayoutIter -> IO Bool
layoutIterAtLastLine :: LayoutIter -> IO Bool
layoutIterAtLastLine (LayoutIter IORef PangoString
_ LayoutIterRaw
li) =
  (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$ (\(LayoutIterRaw ForeignPtr LayoutIterRaw
arg1) -> ForeignPtr LayoutIterRaw
-> (Ptr LayoutIterRaw -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr LayoutIterRaw
arg1 ((Ptr LayoutIterRaw -> IO CInt) -> IO CInt)
-> (Ptr LayoutIterRaw -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr LayoutIterRaw
argPtr1 ->Ptr LayoutIterRaw -> IO CInt
pango_layout_iter_at_last_line Ptr LayoutIterRaw
argPtr1) LayoutIterRaw
li

-- | Get the character index.
--
-- * Note that iterating forward by char moves in visual order, not
-- logical order, so indexes may not be sequential. Also, the index
-- may be equal to the length of the text in the layout.
--
layoutIterGetIndex :: LayoutIter -> IO Int
layoutIterGetIndex :: LayoutIter -> IO Int
layoutIterGetIndex (LayoutIter IORef PangoString
psRef LayoutIterRaw
li) = do
  (PangoString UTFCorrection
uc CInt
_ ForeignPtr CChar
_) <- IORef PangoString -> IO PangoString
forall a. IORef a -> IO a
readIORef IORef PangoString
psRef
  CInt
idx <- (\(LayoutIterRaw ForeignPtr LayoutIterRaw
arg1) -> ForeignPtr LayoutIterRaw
-> (Ptr LayoutIterRaw -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr LayoutIterRaw
arg1 ((Ptr LayoutIterRaw -> IO CInt) -> IO CInt)
-> (Ptr LayoutIterRaw -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr LayoutIterRaw
argPtr1 ->Ptr LayoutIterRaw -> IO CInt
pango_layout_iter_get_index Ptr LayoutIterRaw
argPtr1) LayoutIterRaw
li
  Int -> IO Int
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Int -> UTFCorrection -> Int
ofsFromUTF (CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
idx) UTFCorrection
uc)

-- | Query the vertical position within the layout.
--
-- * Gets the y position of the current line's baseline (origin at top
-- left of the entire layout).
--
layoutIterGetBaseline :: LayoutIter -> IO Double
layoutIterGetBaseline :: LayoutIter -> IO Double
layoutIterGetBaseline (LayoutIter IORef PangoString
_ LayoutIterRaw
li) =
  (CInt -> Double) -> IO CInt -> IO Double
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Double
intToPu (IO CInt -> IO Double) -> IO CInt -> IO Double
forall a b. (a -> b) -> a -> b
$ (\(LayoutIterRaw ForeignPtr LayoutIterRaw
arg1) -> ForeignPtr LayoutIterRaw
-> (Ptr LayoutIterRaw -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr LayoutIterRaw
arg1 ((Ptr LayoutIterRaw -> IO CInt) -> IO CInt)
-> (Ptr LayoutIterRaw -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr LayoutIterRaw
argPtr1 ->Ptr LayoutIterRaw -> IO CInt
pango_layout_iter_get_baseline Ptr LayoutIterRaw
argPtr1) LayoutIterRaw
li


-- | Retrieve the current 'GlyphItem' under the iterator.
--
-- * Each 'LayoutLine' contains a list of 'GlyphItem's. This function
-- returns the 'GlyphItem' under the current iterator. If the iterator
-- is positioned past the last character of the paragraph, the function
-- returns @Nothing@.
--
layoutIterGetItem :: LayoutIter -> IO (Maybe GlyphItem)
layoutIterGetItem :: LayoutIter -> IO (Maybe GlyphItem)
layoutIterGetItem (LayoutIter IORef PangoString
psRef LayoutIterRaw
li) = do
  Ptr ()
giPtr <- (\(LayoutIterRaw ForeignPtr LayoutIterRaw
arg1) -> ForeignPtr LayoutIterRaw
-> (Ptr LayoutIterRaw -> IO (Ptr ())) -> IO (Ptr ())
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr LayoutIterRaw
arg1 ((Ptr LayoutIterRaw -> IO (Ptr ())) -> IO (Ptr ()))
-> (Ptr LayoutIterRaw -> IO (Ptr ())) -> IO (Ptr ())
forall a b. (a -> b) -> a -> b
$ \Ptr LayoutIterRaw
argPtr1 ->Ptr LayoutIterRaw -> IO (Ptr ())
pango_layout_iter_get_run Ptr LayoutIterRaw
argPtr1) LayoutIterRaw
li
  if Ptr ()
giPtrPtr () -> Ptr () -> Bool
forall a. Eq a => a -> a -> Bool
==Ptr ()
forall a. Ptr a
nullPtr then Maybe GlyphItem -> IO (Maybe GlyphItem)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe GlyphItem
forall a. Maybe a
Nothing else (GlyphItem -> Maybe GlyphItem)
-> IO GlyphItem -> IO (Maybe GlyphItem)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM GlyphItem -> Maybe GlyphItem
forall a. a -> Maybe a
Just (IO GlyphItem -> IO (Maybe GlyphItem))
-> IO GlyphItem -> IO (Maybe GlyphItem)
forall a b. (a -> b) -> a -> b
$ do
    (PangoString UTFCorrection
uc CInt
_ ForeignPtr CChar
_) <- IORef PangoString -> IO PangoString
forall a. IORef a -> IO a
readIORef IORef PangoString
psRef
    Ptr PangoItemRaw
pirPtr <- (\Ptr ()
ptr -> do {Ptr () -> Int -> IO (Ptr PangoItemRaw)
forall b. Ptr b -> Int -> IO (Ptr PangoItemRaw)
forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr ()
ptr Int
0 ::IO (Ptr PangoItemRaw)}) Ptr ()
giPtr
    Ptr GlyphStringRaw
gsrPtr <- (\Ptr ()
ptr -> do {Ptr () -> Int -> IO (Ptr GlyphStringRaw)
forall b. Ptr b -> Int -> IO (Ptr GlyphStringRaw)
forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr ()
ptr Int
8 ::IO (Ptr GlyphStringRaw)}) Ptr ()
giPtr
    let dummy :: PangoItemRaw -> IO (Ptr PangoItemRaw)
dummy = (\(PangoItemRaw ForeignPtr PangoItemRaw
arg1) -> ForeignPtr PangoItemRaw
-> (Ptr PangoItemRaw -> IO (Ptr PangoItemRaw))
-> IO (Ptr PangoItemRaw)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoItemRaw
arg1 ((Ptr PangoItemRaw -> IO (Ptr PangoItemRaw))
 -> IO (Ptr PangoItemRaw))
-> (Ptr PangoItemRaw -> IO (Ptr PangoItemRaw))
-> IO (Ptr PangoItemRaw)
forall a b. (a -> b) -> a -> b
$ \Ptr PangoItemRaw
argPtr1 ->Ptr PangoItemRaw -> IO (Ptr PangoItemRaw)
pango_item_copy Ptr PangoItemRaw
argPtr1)
{-# LINE 865 "./Graphics/Rendering/Pango/Layout.chs" #-}
    let dummy = (\(GlyphStringRaw arg1) -> withForeignPtr arg1 $ \argPtr1 ->pango_glyph_string_copy argPtr1)
{-# LINE 866 "./Graphics/Rendering/Pango/Layout.chs" #-}
    pirPtr' <- pango_item_copy pirPtr
    Ptr GlyphStringRaw
gsrPtr' <- Ptr GlyphStringRaw -> IO (Ptr GlyphStringRaw)
pango_glyph_string_copy Ptr GlyphStringRaw
gsrPtr
    PangoItemRaw
pir <- Ptr PangoItemRaw -> IO PangoItemRaw
makeNewPangoItemRaw Ptr PangoItemRaw
pirPtr'
    GlyphStringRaw
gsr <- Ptr GlyphStringRaw -> IO GlyphStringRaw
makeNewGlyphStringRaw Ptr GlyphStringRaw
gsrPtr'
    PangoString
ps <- IORef PangoString -> IO PangoString
forall a. IORef a -> IO a
readIORef IORef PangoString
psRef
    GlyphItem -> IO GlyphItem
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (PangoItem -> GlyphStringRaw -> GlyphItem
GlyphItem (PangoString -> PangoItemRaw -> PangoItem
PangoItem PangoString
ps PangoItemRaw
pir) GlyphStringRaw
gsr)


-- | Extract the line under the iterator.
--
layoutIterGetLine :: LayoutIter -> IO (Maybe LayoutLine)
layoutIterGetLine :: LayoutIter -> IO (Maybe LayoutLine)
layoutIterGetLine (LayoutIter IORef PangoString
psRef LayoutIterRaw
li) = do
  Ptr LayoutLineRaw
llPtr <- (Ptr LayoutLineRaw -> Ptr LayoutLineRaw)
-> IO (Ptr LayoutLineRaw) -> IO (Ptr LayoutLineRaw)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Ptr LayoutLineRaw -> Ptr LayoutLineRaw
forall a b. Ptr a -> Ptr b
castPtr (IO (Ptr LayoutLineRaw) -> IO (Ptr LayoutLineRaw))
-> IO (Ptr LayoutLineRaw) -> IO (Ptr LayoutLineRaw)
forall a b. (a -> b) -> a -> b
$ (\(LayoutIterRaw ForeignPtr LayoutIterRaw
arg1) -> ForeignPtr LayoutIterRaw
-> (Ptr LayoutIterRaw -> IO (Ptr LayoutLineRaw))
-> IO (Ptr LayoutLineRaw)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr LayoutIterRaw
arg1 ((Ptr LayoutIterRaw -> IO (Ptr LayoutLineRaw))
 -> IO (Ptr LayoutLineRaw))
-> (Ptr LayoutIterRaw -> IO (Ptr LayoutLineRaw))
-> IO (Ptr LayoutLineRaw)
forall a b. (a -> b) -> a -> b
$ \Ptr LayoutIterRaw
argPtr1 ->Ptr LayoutIterRaw -> IO (Ptr LayoutLineRaw)
pango_layout_iter_get_line Ptr LayoutIterRaw
argPtr1) LayoutIterRaw
li
  if (Ptr LayoutLineRaw
llPtrPtr LayoutLineRaw -> Ptr LayoutLineRaw -> Bool
forall a. Eq a => a -> a -> Bool
==Ptr LayoutLineRaw
forall a. Ptr a
nullPtr) then Maybe LayoutLine -> IO (Maybe LayoutLine)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe LayoutLine
forall a. Maybe a
Nothing else do
    LayoutLineRaw
ll <- Ptr LayoutLineRaw -> IO LayoutLineRaw
makeNewLayoutLineRaw Ptr LayoutLineRaw
llPtr
    (\(LayoutLineRaw ForeignPtr LayoutLineRaw
arg1) -> ForeignPtr LayoutLineRaw
-> (Ptr LayoutLineRaw -> IO (Ptr LayoutLineRaw))
-> IO (Ptr LayoutLineRaw)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr LayoutLineRaw
arg1 ((Ptr LayoutLineRaw -> IO (Ptr LayoutLineRaw))
 -> IO (Ptr LayoutLineRaw))
-> (Ptr LayoutLineRaw -> IO (Ptr LayoutLineRaw))
-> IO (Ptr LayoutLineRaw)
forall a b. (a -> b) -> a -> b
$ \Ptr LayoutLineRaw
argPtr1 ->Ptr LayoutLineRaw -> IO (Ptr LayoutLineRaw)
pango_layout_line_ref Ptr LayoutLineRaw
argPtr1) LayoutLineRaw
ll
    Maybe LayoutLine -> IO (Maybe LayoutLine)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (LayoutLine -> Maybe LayoutLine
forall a. a -> Maybe a
Just (IORef PangoString -> LayoutLineRaw -> LayoutLine
LayoutLine IORef PangoString
psRef LayoutLineRaw
ll))

-- | Retrieve a rectangle surrounding a character.
--
-- * Get the extents of the current character
-- (origin is the top left of the entire layout). Only logical extents
-- can sensibly be obtained for characters; ink extents make sense only
-- down to the level of clusters.
--
layoutIterGetCharExtents :: LayoutIter -> IO PangoRectangle
layoutIterGetCharExtents :: LayoutIter -> IO PangoRectangle
layoutIterGetCharExtents (LayoutIter IORef PangoString
_ LayoutIterRaw
li) = (Ptr PangoRectangle -> IO PangoRectangle) -> IO PangoRectangle
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr PangoRectangle -> IO PangoRectangle) -> IO PangoRectangle)
-> (Ptr PangoRectangle -> IO PangoRectangle) -> IO PangoRectangle
forall a b. (a -> b) -> a -> b
$ \Ptr PangoRectangle
logPtr ->
  (\(LayoutIterRaw ForeignPtr LayoutIterRaw
arg1) Ptr ()
arg2 -> ForeignPtr LayoutIterRaw -> (Ptr LayoutIterRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr LayoutIterRaw
arg1 ((Ptr LayoutIterRaw -> IO ()) -> IO ())
-> (Ptr LayoutIterRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr LayoutIterRaw
argPtr1 ->Ptr LayoutIterRaw -> Ptr () -> IO ()
pango_layout_iter_get_char_extents Ptr LayoutIterRaw
argPtr1 Ptr ()
arg2) LayoutIterRaw
li (Ptr PangoRectangle -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr Ptr PangoRectangle
logPtr) IO () -> IO PangoRectangle -> IO PangoRectangle
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Ptr PangoRectangle -> IO PangoRectangle
forall a. Storable a => Ptr a -> IO a
peek Ptr PangoRectangle
logPtr

-- | Compute the physical size of the cluster.
--
-- * Computes the ink and the logical size of the cluster pointed to by
-- 'LayoutIter'.
--
layoutIterGetClusterExtents :: LayoutIter -> IO (PangoRectangle, PangoRectangle) -- ^ @(ink, logical)@
layoutIterGetClusterExtents :: LayoutIter -> IO (PangoRectangle, PangoRectangle)
layoutIterGetClusterExtents (LayoutIter IORef PangoString
_ LayoutIterRaw
li) =
  (Ptr () -> Ptr () -> IO ()) -> IO (PangoRectangle, PangoRectangle)
twoRect ((Ptr () -> Ptr () -> IO ())
 -> IO (PangoRectangle, PangoRectangle))
-> (Ptr () -> Ptr () -> IO ())
-> IO (PangoRectangle, PangoRectangle)
forall a b. (a -> b) -> a -> b
$ (\(LayoutIterRaw ForeignPtr LayoutIterRaw
arg1) Ptr ()
arg2 Ptr ()
arg3 -> ForeignPtr LayoutIterRaw -> (Ptr LayoutIterRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr LayoutIterRaw
arg1 ((Ptr LayoutIterRaw -> IO ()) -> IO ())
-> (Ptr LayoutIterRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr LayoutIterRaw
argPtr1 ->Ptr LayoutIterRaw -> Ptr () -> Ptr () -> IO ()
pango_layout_iter_get_cluster_extents Ptr LayoutIterRaw
argPtr1 Ptr ()
arg2 Ptr ()
arg3) LayoutIterRaw
li

-- | Compute the physical size of the run.
--
-- * Computes the ink and the logical size of the run pointed to by
-- 'LayoutIter'.
--
layoutIterGetRunExtents :: LayoutIter -> IO (PangoRectangle, PangoRectangle)
layoutIterGetRunExtents :: LayoutIter -> IO (PangoRectangle, PangoRectangle)
layoutIterGetRunExtents (LayoutIter IORef PangoString
_ LayoutIterRaw
li) =
  (Ptr () -> Ptr () -> IO ()) -> IO (PangoRectangle, PangoRectangle)
twoRect ((Ptr () -> Ptr () -> IO ())
 -> IO (PangoRectangle, PangoRectangle))
-> (Ptr () -> Ptr () -> IO ())
-> IO (PangoRectangle, PangoRectangle)
forall a b. (a -> b) -> a -> b
$ (\(LayoutIterRaw ForeignPtr LayoutIterRaw
arg1) Ptr ()
arg2 Ptr ()
arg3 -> ForeignPtr LayoutIterRaw -> (Ptr LayoutIterRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr LayoutIterRaw
arg1 ((Ptr LayoutIterRaw -> IO ()) -> IO ())
-> (Ptr LayoutIterRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr LayoutIterRaw
argPtr1 ->Ptr LayoutIterRaw -> Ptr () -> Ptr () -> IO ()
pango_layout_iter_get_run_extents Ptr LayoutIterRaw
argPtr1 Ptr ()
arg2 Ptr ()
arg3) LayoutIterRaw
li

-- | Retrieve vertical extent of this line.
--
-- * Divides the vertical space in the 'PangoLayout' being
-- iterated over between the lines in the layout, and returns the
-- space belonging to the current line. A line's range includes the
-- line's logical extents, plus half of the spacing above and below
-- the line, if 'layoutSetSpacing' has been called
-- to set layout spacing. The y positions are in layout coordinates
-- (origin at top left of the entire layout).
--
-- * The first element in the returned tuple is the start, the second is
-- the end of this line.
--
layoutIterGetLineYRange :: LayoutIter -> IO (Double, Double)
layoutIterGetLineYRange :: LayoutIter -> IO (Double, Double)
layoutIterGetLineYRange (LayoutIter IORef PangoString
_ LayoutIterRaw
li) =
  (Ptr CInt -> IO (Double, Double)) -> IO (Double, Double)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CInt -> IO (Double, Double)) -> IO (Double, Double))
-> (Ptr CInt -> IO (Double, Double)) -> IO (Double, Double)
forall a b. (a -> b) -> a -> b
$ \Ptr CInt
sPtr -> (Ptr CInt -> IO (Double, Double)) -> IO (Double, Double)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CInt -> IO (Double, Double)) -> IO (Double, Double))
-> (Ptr CInt -> IO (Double, Double)) -> IO (Double, Double)
forall a b. (a -> b) -> a -> b
$ \Ptr CInt
ePtr -> do
  (\(LayoutIterRaw ForeignPtr LayoutIterRaw
arg1) Ptr ()
arg2 Ptr ()
arg3 -> ForeignPtr LayoutIterRaw -> (Ptr LayoutIterRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr LayoutIterRaw
arg1 ((Ptr LayoutIterRaw -> IO ()) -> IO ())
-> (Ptr LayoutIterRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr LayoutIterRaw
argPtr1 ->Ptr LayoutIterRaw -> Ptr () -> Ptr () -> IO ()
pango_layout_iter_get_line_extents Ptr LayoutIterRaw
argPtr1 Ptr ()
arg2 Ptr ()
arg3) LayoutIterRaw
li (Ptr CInt -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr Ptr CInt
sPtr) (Ptr CInt -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr Ptr CInt
ePtr)
  CInt
start <- Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
sPtr
  CInt
end <- Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
ePtr
  (Double, Double) -> IO (Double, Double)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CInt -> Double
intToPu CInt
start, CInt -> Double
intToPu CInt
end)

-- | Compute the physical size of the line.
--
-- * Computes the ink and the logical size of the line pointed to by
-- 'LayoutIter'. See 'layoutGetExtents'.
--
-- * Extents are in layout coordinates (origin is the top-left corner
-- of the entire 'PangoLayout'). Thus the extents returned
-- by this function will be the same width\/height but not at the
-- same x\/y as the extents returned from
-- 'layoutLineGetExtents'.
--
layoutIterGetLineExtents :: LayoutIter -> IO (PangoRectangle, PangoRectangle)
layoutIterGetLineExtents :: LayoutIter -> IO (PangoRectangle, PangoRectangle)
layoutIterGetLineExtents (LayoutIter IORef PangoString
_ LayoutIterRaw
li) =
  (Ptr () -> Ptr () -> IO ()) -> IO (PangoRectangle, PangoRectangle)
twoRect ((Ptr () -> Ptr () -> IO ())
 -> IO (PangoRectangle, PangoRectangle))
-> (Ptr () -> Ptr () -> IO ())
-> IO (PangoRectangle, PangoRectangle)
forall a b. (a -> b) -> a -> b
$ (\(LayoutIterRaw ForeignPtr LayoutIterRaw
arg1) Ptr ()
arg2 Ptr ()
arg3 -> ForeignPtr LayoutIterRaw -> (Ptr LayoutIterRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr LayoutIterRaw
arg1 ((Ptr LayoutIterRaw -> IO ()) -> IO ())
-> (Ptr LayoutIterRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr LayoutIterRaw
argPtr1 ->Ptr LayoutIterRaw -> Ptr () -> Ptr () -> IO ()
pango_layout_iter_get_line_extents Ptr LayoutIterRaw
argPtr1 Ptr ()
arg2 Ptr ()
arg3) LayoutIterRaw
li

-- | Compute the physical size of the line.
--
-- * Computes the ink and the logical size of the 'LayoutLine'.
-- See 'layoutGetExtents'.
--
layoutLineGetExtents :: LayoutLine -> IO (PangoRectangle, PangoRectangle)
layoutLineGetExtents :: LayoutLine -> IO (PangoRectangle, PangoRectangle)
layoutLineGetExtents (LayoutLine IORef PangoString
_ LayoutLineRaw
ll) =
  (Ptr () -> Ptr () -> IO ()) -> IO (PangoRectangle, PangoRectangle)
twoRect ((Ptr () -> Ptr () -> IO ())
 -> IO (PangoRectangle, PangoRectangle))
-> (Ptr () -> Ptr () -> IO ())
-> IO (PangoRectangle, PangoRectangle)
forall a b. (a -> b) -> a -> b
$ (\(LayoutLineRaw ForeignPtr LayoutLineRaw
arg1) Ptr ()
arg2 Ptr ()
arg3 -> ForeignPtr LayoutLineRaw -> (Ptr LayoutLineRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr LayoutLineRaw
arg1 ((Ptr LayoutLineRaw -> IO ()) -> IO ())
-> (Ptr LayoutLineRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr LayoutLineRaw
argPtr1 ->Ptr LayoutLineRaw -> Ptr () -> Ptr () -> IO ()
pango_layout_line_get_extents Ptr LayoutLineRaw
argPtr1 Ptr ()
arg2 Ptr ()
arg3) LayoutLineRaw
ll

-- | Compute the physical size of the line.
--
-- * Computes the ink and the logical size of the 'LayoutLine'.
-- See 'layoutGetExtents'. The returned values are in device units, that
-- is, pixels for the screen and points for printers.
--
layoutLineGetPixelExtents :: LayoutLine -> IO (Rectangle, Rectangle) -- ^ (ink, logical)
layoutLineGetPixelExtents :: LayoutLine -> IO (Rectangle, Rectangle)
layoutLineGetPixelExtents (LayoutLine IORef PangoString
_ LayoutLineRaw
ll) =
  (Ptr PangoRectangle -> IO (Rectangle, Rectangle))
-> IO (Rectangle, Rectangle)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr PangoRectangle -> IO (Rectangle, Rectangle))
 -> IO (Rectangle, Rectangle))
-> (Ptr PangoRectangle -> IO (Rectangle, Rectangle))
-> IO (Rectangle, Rectangle)
forall a b. (a -> b) -> a -> b
$ \Ptr PangoRectangle
inkPtr -> (Ptr PangoRectangle -> IO (Rectangle, Rectangle))
-> IO (Rectangle, Rectangle)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr PangoRectangle -> IO (Rectangle, Rectangle))
 -> IO (Rectangle, Rectangle))
-> (Ptr PangoRectangle -> IO (Rectangle, Rectangle))
-> IO (Rectangle, Rectangle)
forall a b. (a -> b) -> a -> b
$ \Ptr PangoRectangle
logPtr -> do
  (\(LayoutLineRaw ForeignPtr LayoutLineRaw
arg1) Ptr ()
arg2 Ptr ()
arg3 -> ForeignPtr LayoutLineRaw -> (Ptr LayoutLineRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr LayoutLineRaw
arg1 ((Ptr LayoutLineRaw -> IO ()) -> IO ())
-> (Ptr LayoutLineRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr LayoutLineRaw
argPtr1 ->Ptr LayoutLineRaw -> Ptr () -> Ptr () -> IO ()
pango_layout_line_get_pixel_extents Ptr LayoutLineRaw
argPtr1 Ptr ()
arg2 Ptr ()
arg3) LayoutLineRaw
ll (Ptr PangoRectangle -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr Ptr PangoRectangle
inkPtr) (Ptr PangoRectangle -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr Ptr PangoRectangle
logPtr)
  Rectangle
ink <- Ptr PangoRectangle -> IO Rectangle
peekIntPangoRectangle Ptr PangoRectangle
inkPtr
  Rectangle
log <- Ptr PangoRectangle -> IO Rectangle
peekIntPangoRectangle Ptr PangoRectangle
logPtr
  (Rectangle, Rectangle) -> IO (Rectangle, Rectangle)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Rectangle
ink,Rectangle
log)

-- | Request the horizontal position of a character.
--
layoutLineIndexToX :: LayoutLine
                   -> Int -- ^ the index into the string
                   -> Bool -- ^ return the beginning (@False@) or the end
                            -- of the character
                   -> IO Double
layoutLineIndexToX :: LayoutLine -> Int -> Bool -> IO Double
layoutLineIndexToX (LayoutLine IORef PangoString
psRef LayoutLineRaw
ll) Int
pos Bool
beg =
  (Ptr CInt -> IO Double) -> IO Double
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CInt -> IO Double) -> IO Double)
-> (Ptr CInt -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr CInt
intPtr -> do
    (PangoString UTFCorrection
uc CInt
_ ForeignPtr CChar
_) <- IORef PangoString -> IO PangoString
forall a. IORef a -> IO a
readIORef IORef PangoString
psRef
    (\(LayoutLineRaw ForeignPtr LayoutLineRaw
arg1) CInt
arg2 CInt
arg3 Ptr CInt
arg4 -> ForeignPtr LayoutLineRaw -> (Ptr LayoutLineRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr LayoutLineRaw
arg1 ((Ptr LayoutLineRaw -> IO ()) -> IO ())
-> (Ptr LayoutLineRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr LayoutLineRaw
argPtr1 ->Ptr LayoutLineRaw -> CInt -> CInt -> Ptr CInt -> IO ()
pango_layout_line_index_to_x Ptr LayoutLineRaw
argPtr1 CInt
arg2 CInt
arg3 Ptr CInt
arg4) LayoutLineRaw
ll (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> UTFCorrection -> Int
ofsToUTF Int
pos UTFCorrection
uc))
      (Bool -> CInt
forall a. Num a => Bool -> a
fromBool Bool
beg) Ptr CInt
intPtr
    (CInt -> Double) -> IO CInt -> IO Double
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Double
intToPu (IO CInt -> IO Double) -> IO CInt -> IO Double
forall a b. (a -> b) -> a -> b
$ Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
intPtr


-- | Request the character index of a given horizontal position.
--
-- * Converts from an x offset to the index of the corresponding
-- character within the text of the layout. If the @x@ parameter is
-- outside the line, a triple @(False, index, trailing)@ is returned
-- where @index@ and @trailing@ will point to the very
-- first or very last position in the line. This notion of first and last
-- position is based on the direction of the paragraph; for example,
-- if the direction is right-to-left, then an @x@ position to the
-- right of the line results in 0 being returned for @index@ and
-- @trailing@. An @x@ position to the left of the line results in
-- @index@ pointing to the (logical) last grapheme in the line and
-- trailing pointing to the number of characters in that grapheme.
-- The reverse is true for a left-to-right line. If the boolean flag in
-- the result is @True@ then @x@ was within the layout line and
-- @trailing@ indicates where in a cluster the @x@ position lay. It is
-- 0 for the trailing edge of the cluster.
--
layoutLineXToIndex :: LayoutLine
                   -> Double -- ^ The @x@ position.
                   -> IO (Bool, Int, Int)
layoutLineXToIndex :: LayoutLine -> Double -> IO (Bool, Int, Int)
layoutLineXToIndex (LayoutLine IORef PangoString
psRef LayoutLineRaw
ll) Double
pos =
  (Ptr CInt -> IO (Bool, Int, Int)) -> IO (Bool, Int, Int)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CInt -> IO (Bool, Int, Int)) -> IO (Bool, Int, Int))
-> (Ptr CInt -> IO (Bool, Int, Int)) -> IO (Bool, Int, Int)
forall a b. (a -> b) -> a -> b
$ \Ptr CInt
idxPtr -> (Ptr CInt -> IO (Bool, Int, Int)) -> IO (Bool, Int, Int)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CInt -> IO (Bool, Int, Int)) -> IO (Bool, Int, Int))
-> (Ptr CInt -> IO (Bool, Int, Int)) -> IO (Bool, Int, Int)
forall a b. (a -> b) -> a -> b
$ \Ptr CInt
trailPtr -> do
    (PangoString UTFCorrection
uc CInt
_ ForeignPtr CChar
_) <- IORef PangoString -> IO PangoString
forall a. IORef a -> IO a
readIORef IORef PangoString
psRef
    CInt
inside <- (\(LayoutLineRaw ForeignPtr LayoutLineRaw
arg1) CInt
arg2 Ptr CInt
arg3 Ptr CInt
arg4 -> ForeignPtr LayoutLineRaw
-> (Ptr LayoutLineRaw -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr LayoutLineRaw
arg1 ((Ptr LayoutLineRaw -> IO CInt) -> IO CInt)
-> (Ptr LayoutLineRaw -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr LayoutLineRaw
argPtr1 ->Ptr LayoutLineRaw -> CInt -> Ptr CInt -> Ptr CInt -> IO CInt
pango_layout_line_x_to_index Ptr LayoutLineRaw
argPtr1 CInt
arg2 Ptr CInt
arg3 Ptr CInt
arg4) LayoutLineRaw
ll
      (Double -> CInt
puToInt Double
pos) Ptr CInt
idxPtr Ptr CInt
trailPtr
    CInt
idx <- Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
idxPtr
    CInt
trail <- Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
trailPtr
    (Bool, Int, Int) -> IO (Bool, Int, Int)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool CInt
inside, Int -> UTFCorrection -> Int
ofsFromUTF (CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
idx) UTFCorrection
uc,
            CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
trail)

-- | Retrieve bounding boxes for a given piece of text contained in this
-- 'LayoutLine'.
--
-- * The result is a list to accommodate for mixed left-to-right and
-- right-to-left text. Even if the text is not mixed, several
-- ranges might be returned that are adjacent. The ranges are always
-- sorted from left to right. The values are with respect to the left
-- edge of the entire layout, not with respect to the line (which might
-- be indented or not left aligned).
--
layoutLineGetXRanges :: LayoutLine -- ^ The line of interest.
                     -> Int -- ^ The index of the start character
                            -- (counting from 0). If this value is
                            -- less than the start index for the line,
                            -- then the first range will extend all the
                            -- way to the leading edge of the layout.
                            -- Otherwise it will start at the leading
                            -- edge of the first character.
                     -> Int -- ^ The index after the last character.
                            -- If this value is greater than the end
                            -- index for the line, then the last range
                            -- will extend all the way to the trailing
                            -- edge of the layout. Otherwise, it will end
                            -- at the trailing edge of the last
                            -- character.
                     -> IO [(Double, Double)]
layoutLineGetXRanges :: LayoutLine -> Int -> Int -> IO [(Double, Double)]
layoutLineGetXRanges (LayoutLine IORef PangoString
psRef LayoutLineRaw
ll) Int
start Int
end = do
  PangoString UTFCorrection
uc CInt
_ ForeignPtr CChar
_ <- IORef PangoString -> IO PangoString
forall a. IORef a -> IO a
readIORef IORef PangoString
psRef
  (Ptr (Ptr CInt) -> IO [(Double, Double)]) -> IO [(Double, Double)]
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr (Ptr CInt) -> IO [(Double, Double)])
 -> IO [(Double, Double)])
-> (Ptr (Ptr CInt) -> IO [(Double, Double)])
-> IO [(Double, Double)]
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CInt)
arrPtr -> (Ptr CInt -> IO [(Double, Double)]) -> IO [(Double, Double)]
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CInt -> IO [(Double, Double)]) -> IO [(Double, Double)])
-> (Ptr CInt -> IO [(Double, Double)]) -> IO [(Double, Double)]
forall a b. (a -> b) -> a -> b
$ \Ptr CInt
szPtr -> do
    (\(LayoutLineRaw ForeignPtr LayoutLineRaw
arg1) CInt
arg2 CInt
arg3 Ptr (Ptr CInt)
arg4 Ptr CInt
arg5 -> ForeignPtr LayoutLineRaw -> (Ptr LayoutLineRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr LayoutLineRaw
arg1 ((Ptr LayoutLineRaw -> IO ()) -> IO ())
-> (Ptr LayoutLineRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr LayoutLineRaw
argPtr1 ->Ptr LayoutLineRaw
-> CInt -> CInt -> Ptr (Ptr CInt) -> Ptr CInt -> IO ()
pango_layout_line_get_x_ranges Ptr LayoutLineRaw
argPtr1 CInt
arg2 CInt
arg3 Ptr (Ptr CInt)
arg4 Ptr CInt
arg5) LayoutLineRaw
ll
      (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> UTFCorrection -> Int
ofsToUTF Int
start UTFCorrection
uc))
      (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> UTFCorrection -> Int
ofsToUTF Int
end UTFCorrection
uc))
      Ptr (Ptr CInt)
arrPtr Ptr CInt
szPtr
    CInt
sz <- Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
szPtr
    Ptr CInt
arr <- Ptr (Ptr CInt) -> IO (Ptr CInt)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr CInt)
arrPtr
    [CInt]
elems <- Int -> Ptr CInt -> IO [CInt]
forall a. Storable a => Int -> Ptr a -> IO [a]
peekArray (Int
2Int -> Int -> Int
forall a. Num a => a -> a -> a
*CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
sz) (Ptr CInt -> Ptr CInt
forall a b. Ptr a -> Ptr b
castPtr Ptr CInt
arr:: Ptr (CInt))
    Ptr () -> IO ()
g_free (Ptr CInt -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr Ptr CInt
arr)
    let toRange :: [CInt] -> [(Double, Double)]
toRange (CInt
s:CInt
e:[CInt]
rs) = (CInt -> Double
intToPu CInt
s, CInt -> Double
intToPu CInt
e)(Double, Double) -> [(Double, Double)] -> [(Double, Double)]
forall a. a -> [a] -> [a]
:[CInt] -> [(Double, Double)]
toRange [CInt]
rs
        toRange [] = []
    [(Double, Double)] -> IO [(Double, Double)]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ([CInt] -> [(Double, Double)]
toRange [CInt]
elems)

foreign import ccall unsafe "pango_layout_new"
  pango_layout_new :: ((Ptr PangoContext) -> (IO (Ptr PangoLayoutRaw)))

foreign import ccall unsafe "pango_layout_set_text"
  pango_layout_set_text :: ((Ptr PangoLayoutRaw) -> ((Ptr CChar) -> (CInt -> (IO ()))))

foreign import ccall unsafe "pango_layout_copy"
  pango_layout_copy :: ((Ptr PangoLayoutRaw) -> (IO (Ptr PangoLayoutRaw)))

foreign import ccall unsafe "pango_layout_get_context"
  pango_layout_get_context :: ((Ptr PangoLayoutRaw) -> (IO (Ptr PangoContext)))

foreign import ccall unsafe "pango_layout_context_changed"
  pango_layout_context_changed :: ((Ptr PangoLayoutRaw) -> (IO ()))

foreign import ccall unsafe "pango_layout_get_text"
  pango_layout_get_text :: ((Ptr PangoLayoutRaw) -> (IO (Ptr CChar)))

foreign import ccall unsafe "pango_layout_set_markup"
  pango_layout_set_markup :: ((Ptr PangoLayoutRaw) -> ((Ptr CChar) -> (CInt -> (IO ()))))

foreign import ccall unsafe "g_markup_escape_text"
  g_markup_escape_text :: ((Ptr CChar) -> (CLong -> (IO (Ptr CChar))))

foreign import ccall unsafe "g_free"
  g_free :: ((Ptr ()) -> (IO ()))

foreign import ccall unsafe "pango_layout_set_markup_with_accel"
  pango_layout_set_markup_with_accel :: ((Ptr PangoLayoutRaw) -> ((Ptr CChar) -> (CInt -> (CUInt -> ((Ptr CUInt) -> (IO ()))))))

foreign import ccall unsafe "pango_layout_set_attributes"
  pango_layout_set_attributes :: ((Ptr PangoLayoutRaw) -> ((Ptr ()) -> (IO ())))

foreign import ccall unsafe "pango_layout_get_attributes"
  pango_layout_get_attributes :: ((Ptr PangoLayoutRaw) -> (IO (Ptr ())))

foreign import ccall unsafe "pango_layout_set_font_description"
  pango_layout_set_font_description :: ((Ptr PangoLayoutRaw) -> ((Ptr FontDescription) -> (IO ())))

foreign import ccall unsafe "pango_layout_get_font_description"
  pango_layout_get_font_description :: ((Ptr PangoLayoutRaw) -> (IO (Ptr FontDescription)))

foreign import ccall unsafe "pango_layout_set_width"
  pango_layout_set_width :: ((Ptr PangoLayoutRaw) -> (CInt -> (IO ())))

foreign import ccall unsafe "pango_layout_get_width"
  pango_layout_get_width :: ((Ptr PangoLayoutRaw) -> (IO CInt))

foreign import ccall unsafe "pango_layout_set_wrap"
  pango_layout_set_wrap :: ((Ptr PangoLayoutRaw) -> (CInt -> (IO ())))

foreign import ccall unsafe "pango_layout_get_wrap"
  pango_layout_get_wrap :: ((Ptr PangoLayoutRaw) -> (IO CInt))

foreign import ccall unsafe "pango_layout_set_ellipsize"
  pango_layout_set_ellipsize :: ((Ptr PangoLayoutRaw) -> (CInt -> (IO ())))

foreign import ccall unsafe "pango_layout_get_ellipsize"
  pango_layout_get_ellipsize :: ((Ptr PangoLayoutRaw) -> (IO CInt))

foreign import ccall unsafe "pango_layout_set_indent"
  pango_layout_set_indent :: ((Ptr PangoLayoutRaw) -> (CInt -> (IO ())))

foreign import ccall unsafe "pango_layout_get_indent"
  pango_layout_get_indent :: ((Ptr PangoLayoutRaw) -> (IO CInt))

foreign import ccall unsafe "pango_layout_set_spacing"
  pango_layout_set_spacing :: ((Ptr PangoLayoutRaw) -> (CInt -> (IO ())))

foreign import ccall unsafe "pango_layout_get_spacing"
  pango_layout_get_spacing :: ((Ptr PangoLayoutRaw) -> (IO CInt))

foreign import ccall unsafe "pango_layout_set_justify"
  pango_layout_set_justify :: ((Ptr PangoLayoutRaw) -> (CInt -> (IO ())))

foreign import ccall unsafe "pango_layout_get_justify"
  pango_layout_get_justify :: ((Ptr PangoLayoutRaw) -> (IO CInt))

foreign import ccall unsafe "pango_layout_set_auto_dir"
  pango_layout_set_auto_dir :: ((Ptr PangoLayoutRaw) -> (CInt -> (IO ())))

foreign import ccall unsafe "pango_layout_get_auto_dir"
  pango_layout_get_auto_dir :: ((Ptr PangoLayoutRaw) -> (IO CInt))

foreign import ccall unsafe "pango_layout_set_alignment"
  pango_layout_set_alignment :: ((Ptr PangoLayoutRaw) -> (CInt -> (IO ())))

foreign import ccall unsafe "pango_layout_get_alignment"
  pango_layout_get_alignment :: ((Ptr PangoLayoutRaw) -> (IO CInt))

foreign import ccall unsafe "pango_tab_array_new"
  pango_tab_array_new :: (CInt -> (CInt -> (IO (Ptr ()))))

foreign import ccall unsafe "pango_tab_array_set_tab"
  pango_tab_array_set_tab :: ((Ptr ()) -> (CInt -> (CInt -> (CInt -> (IO ())))))

foreign import ccall unsafe "pango_layout_set_tabs"
  pango_layout_set_tabs :: ((Ptr PangoLayoutRaw) -> ((Ptr ()) -> (IO ())))

foreign import ccall unsafe "pango_tab_array_free"
  pango_tab_array_free :: ((Ptr ()) -> (IO ()))

foreign import ccall unsafe "pango_layout_get_tabs"
  pango_layout_get_tabs :: ((Ptr PangoLayoutRaw) -> (IO (Ptr ())))

foreign import ccall unsafe "pango_tab_array_get_size"
  pango_tab_array_get_size :: ((Ptr ()) -> (IO CInt))

foreign import ccall unsafe "pango_tab_array_get_tab"
  pango_tab_array_get_tab :: ((Ptr ()) -> (CInt -> ((Ptr CInt) -> ((Ptr CInt) -> (IO ())))))

foreign import ccall unsafe "pango_layout_set_single_paragraph_mode"
  pango_layout_set_single_paragraph_mode :: ((Ptr PangoLayoutRaw) -> (CInt -> (IO ())))

foreign import ccall unsafe "pango_layout_get_single_paragraph_mode"
  pango_layout_get_single_paragraph_mode :: ((Ptr PangoLayoutRaw) -> (IO CInt))

foreign import ccall unsafe "pango_layout_xy_to_index"
  pango_layout_xy_to_index :: ((Ptr PangoLayoutRaw) -> (CInt -> (CInt -> ((Ptr CInt) -> ((Ptr CInt) -> (IO CInt))))))

foreign import ccall unsafe "pango_layout_index_to_pos"
  pango_layout_index_to_pos :: ((Ptr PangoLayoutRaw) -> (CInt -> ((Ptr ()) -> (IO ()))))

foreign import ccall unsafe "pango_layout_get_cursor_pos"
  pango_layout_get_cursor_pos :: ((Ptr PangoLayoutRaw) -> (CInt -> ((Ptr ()) -> ((Ptr ()) -> (IO ())))))

foreign import ccall unsafe "pango_layout_move_cursor_visually"
  pango_layout_move_cursor_visually :: ((Ptr PangoLayoutRaw) -> (CInt -> (CInt -> (CInt -> (CInt -> ((Ptr CInt) -> ((Ptr CInt) -> (IO ()))))))))

foreign import ccall unsafe "pango_layout_get_extents"
  pango_layout_get_extents :: ((Ptr PangoLayoutRaw) -> ((Ptr ()) -> ((Ptr ()) -> (IO ()))))

foreign import ccall unsafe "pango_layout_get_pixel_extents"
  pango_layout_get_pixel_extents :: ((Ptr PangoLayoutRaw) -> ((Ptr ()) -> ((Ptr ()) -> (IO ()))))

foreign import ccall unsafe "pango_layout_get_line_count"
  pango_layout_get_line_count :: ((Ptr PangoLayoutRaw) -> (IO CInt))

foreign import ccall unsafe "pango_layout_get_line_readonly"
  pango_layout_get_line_readonly :: ((Ptr PangoLayoutRaw) -> (CInt -> (IO (Ptr LayoutLineRaw))))

foreign import ccall unsafe "pango_layout_line_ref"
  pango_layout_line_ref :: ((Ptr LayoutLineRaw) -> (IO (Ptr LayoutLineRaw)))

foreign import ccall unsafe "pango_layout_get_lines_readonly"
  pango_layout_get_lines_readonly :: ((Ptr PangoLayoutRaw) -> (IO (Ptr ())))

foreign import ccall unsafe "pango_layout_get_iter"
  pango_layout_get_iter :: ((Ptr PangoLayoutRaw) -> (IO (Ptr LayoutIterRaw)))

foreign import ccall unsafe "pango_layout_iter_next_run"
  pango_layout_iter_next_run :: ((Ptr LayoutIterRaw) -> (IO CInt))

foreign import ccall unsafe "pango_layout_iter_next_char"
  pango_layout_iter_next_char :: ((Ptr LayoutIterRaw) -> (IO CInt))

foreign import ccall unsafe "pango_layout_iter_next_cluster"
  pango_layout_iter_next_cluster :: ((Ptr LayoutIterRaw) -> (IO CInt))

foreign import ccall unsafe "pango_layout_iter_next_line"
  pango_layout_iter_next_line :: ((Ptr LayoutIterRaw) -> (IO CInt))

foreign import ccall unsafe "pango_layout_iter_at_last_line"
  pango_layout_iter_at_last_line :: ((Ptr LayoutIterRaw) -> (IO CInt))

foreign import ccall unsafe "pango_layout_iter_get_index"
  pango_layout_iter_get_index :: ((Ptr LayoutIterRaw) -> (IO CInt))

foreign import ccall unsafe "pango_layout_iter_get_baseline"
  pango_layout_iter_get_baseline :: ((Ptr LayoutIterRaw) -> (IO CInt))

foreign import ccall unsafe "pango_layout_iter_get_run"
  pango_layout_iter_get_run :: ((Ptr LayoutIterRaw) -> (IO (Ptr ())))

foreign import ccall unsafe "pango_item_copy"
  pango_item_copy :: ((Ptr PangoItemRaw) -> (IO (Ptr PangoItemRaw)))

foreign import ccall unsafe "pango_glyph_string_copy"
  pango_glyph_string_copy :: ((Ptr GlyphStringRaw) -> (IO (Ptr GlyphStringRaw)))

foreign import ccall unsafe "pango_layout_iter_get_line"
  pango_layout_iter_get_line :: ((Ptr LayoutIterRaw) -> (IO (Ptr LayoutLineRaw)))

foreign import ccall unsafe "pango_layout_iter_get_char_extents"
  pango_layout_iter_get_char_extents :: ((Ptr LayoutIterRaw) -> ((Ptr ()) -> (IO ())))

foreign import ccall unsafe "pango_layout_iter_get_cluster_extents"
  pango_layout_iter_get_cluster_extents :: ((Ptr LayoutIterRaw) -> ((Ptr ()) -> ((Ptr ()) -> (IO ()))))

foreign import ccall unsafe "pango_layout_iter_get_run_extents"
  pango_layout_iter_get_run_extents :: ((Ptr LayoutIterRaw) -> ((Ptr ()) -> ((Ptr ()) -> (IO ()))))

foreign import ccall unsafe "pango_layout_iter_get_line_extents"
  pango_layout_iter_get_line_extents :: ((Ptr LayoutIterRaw) -> ((Ptr ()) -> ((Ptr ()) -> (IO ()))))

foreign import ccall unsafe "pango_layout_line_get_extents"
  pango_layout_line_get_extents :: ((Ptr LayoutLineRaw) -> ((Ptr ()) -> ((Ptr ()) -> (IO ()))))

foreign import ccall unsafe "pango_layout_line_get_pixel_extents"
  pango_layout_line_get_pixel_extents :: ((Ptr LayoutLineRaw) -> ((Ptr ()) -> ((Ptr ()) -> (IO ()))))

foreign import ccall unsafe "pango_layout_line_index_to_x"
  pango_layout_line_index_to_x :: ((Ptr LayoutLineRaw) -> (CInt -> (CInt -> ((Ptr CInt) -> (IO ())))))

foreign import ccall unsafe "pango_layout_line_x_to_index"
  pango_layout_line_x_to_index :: ((Ptr LayoutLineRaw) -> (CInt -> ((Ptr CInt) -> ((Ptr CInt) -> (IO CInt)))))

foreign import ccall unsafe "pango_layout_line_get_x_ranges"
  pango_layout_line_get_x_ranges :: ((Ptr LayoutLineRaw) -> (CInt -> (CInt -> ((Ptr (Ptr CInt)) -> ((Ptr CInt) -> (IO ()))))))