From: Duncan C. <dun...@us...> - 2005-04-04 01:24:19
|
Update of /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Multiline In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19314/gtk/Graphics/UI/Gtk/Multiline Modified Files: TextBuffer.chs TextMark.chs TextTag.chs.pp TextTagTable.chs TextView.chs Log Message: Large merge from generated modules. Changed code formatting and documentation. In one or two places fix minor bugs. Remove two non-exsistant functions from TextView module. Index: TextView.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Multiline/TextView.chs,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- TextView.chs 13 Mar 2005 19:34:36 -0000 1.5 +++ TextView.chs 4 Apr 2005 01:24:10 -0000 1.6 @@ -31,18 +31,17 @@ -- Widget that displays a 'TextBuffer' -- module Graphics.UI.Gtk.Multiline.TextView ( --- * Description +-- * Detail -- -- | You may wish to begin by reading the text widget conceptual overview -- which gives an overview of all the objects and data types related to the -- text widget and how they work together. -- --- * Throughout we distinguish between buffer coordinates which are pixels [...1379 lines suppressed...] - TextViewClass tv => tv -> (Adjustment -> Adjustment -> IO ()) -> - IO (ConnectId tv) +onSetScrollAdjustments, afterSetScrollAdjustments :: TextViewClass self => self + -> (Adjustment -> Adjustment -> IO ()) + -> IO (ConnectId self) onSetScrollAdjustments = connect_OBJECT_OBJECT__NONE "set_scroll_adjustments" False afterSetScrollAdjustments = @@ -1009,8 +1170,8 @@ -- * The action itself happens when the 'TextView' processes this -- signal. -- -onToggleOverwrite, afterToggleOverwrite :: TextViewClass tv => tv -> IO () -> - IO (ConnectId tv) +onToggleOverwrite, afterToggleOverwrite :: TextViewClass self => self + -> IO () + -> IO (ConnectId self) onToggleOverwrite = connect_NONE__NONE "toggle_overwrite" False afterToggleOverwrite = connect_NONE__NONE "toggle_overwrite" True - Index: TextMark.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Multiline/TextMark.chs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- TextMark.chs 13 Mar 2005 19:34:36 -0000 1.4 +++ TextMark.chs 4 Apr 2005 01:24:10 -0000 1.5 @@ -27,7 +27,7 @@ -- A position in the buffer preserved across buffer modifications -- module Graphics.UI.Gtk.Multiline.TextMark ( --- * Description +-- * Detail -- -- | You may wish to begin by reading the text widget conceptual overview -- which gives an overview of all the objects and data types related to the @@ -92,60 +92,68 @@ -------------------- -- Methods --- | Set the visibility of a 'TextMark'. +-- | Sets the visibility of @mark@; the insertion point is normally visible, +-- i.e. you can see it as a vertical bar. Also, the text widget uses a visible +-- mark to indicate where a drop will occur when dragging-and-dropping text. +-- Most other marks are not visible. Marks are not visible by default. -- -textMarkSetVisible :: TextMarkClass tm => tm -> Bool -> IO () -textMarkSetVisible tm vis = - {#call unsafe text_mark_set_visible#} (toTextMark tm) (fromBool vis) - +textMarkSetVisible :: TextMarkClass self => self -> Bool -> IO () +textMarkSetVisible self setting = + {# call unsafe text_mark_set_visible #} + (toTextMark self) + (fromBool setting) --- | Get the visibility of a 'TextMark'. +-- | Returns @True@ if the mark is visible (i.e. a cursor is displayed for it) -- -textMarkGetVisible :: TextMarkClass tm => tm -> IO Bool -textMarkGetVisible tm = liftM toBool $ - {#call unsafe text_mark_get_visible#} (toTextMark tm) +textMarkGetVisible :: TextMarkClass self => self -> IO Bool +textMarkGetVisible self = + liftM toBool $ + {# call unsafe text_mark_get_visible #} + (toTextMark self) --- | Query if a 'TextMark' is still valid. +-- | Returns @True@ if the mark has been removed from its buffer with +-- 'textBufferDeleteMark'. Marks can't be used once deleted. -- -textMarkGetDeleted :: TextMarkClass tm => tm -> IO Bool -textMarkGetDeleted tm = liftM toBool $ - {#call unsafe text_mark_get_deleted#} (toTextMark tm) +textMarkGetDeleted :: TextMarkClass self => self -> IO Bool +textMarkGetDeleted self = + liftM toBool $ + {# call unsafe text_mark_get_deleted #} + (toTextMark self) --- | Get the name of a 'TextMark'. --- --- * Returns Nothing, if the mark is anonymous. +-- | Returns the mark name; returns @Nothing@ for anonymous marks. -- -textMarkGetName :: TextMarkClass tm => tm -> IO (Maybe String) -textMarkGetName tm = do - strPtr <- {#call unsafe text_mark_get_name#} (toTextMark tm) - if strPtr==nullPtr then return Nothing else liftM Just $ peekUTFString strPtr +textMarkGetName :: TextMarkClass self => self -> IO (Maybe MarkName) +textMarkGetName self = + {# call unsafe text_mark_get_name #} + (toTextMark self) + >>= maybePeek peekUTFString --- | Extract the 'TextBuffer' of the mark. --- --- * Returns Nothing if the mark was deleted. +-- | Gets the buffer this mark is located inside, or @Nothing@ if the mark is +-- deleted. -- -textMarkGetBuffer :: TextMarkClass tm => tm -> IO (Maybe TextBuffer) -textMarkGetBuffer tm = do - bufPtr <- {#call unsafe text_mark_get_buffer#} (toTextMark tm) - if bufPtr==nullPtr then return Nothing else liftM Just $ - makeNewGObject mkTextBuffer (return $ castPtr bufPtr) +textMarkGetBuffer :: TextMarkClass self => self -> IO (Maybe TextBuffer) +textMarkGetBuffer self = + maybeNull (makeNewGObject mkTextBuffer) $ + {# call unsafe text_mark_get_buffer #} + (toTextMark self) --- | Determine whether the mark has gravity --- towards the beginning of a line. +-- | Determines whether the mark has left gravity. -- --- * The name is misleading as Arabic, Hebrew and some other languages have --- the beginning of a line towards the right. +-- The name is misleading as Arabic, Hebrew and some other languages have the +-- beginning of a line towards the right. -- -textMarkGetLeftGravity :: TextMarkClass tm => tm -> IO Bool -textMarkGetLeftGravity tm = liftM toBool $ - {#call unsafe text_mark_get_left_gravity#} (toTextMark tm) +textMarkGetLeftGravity :: TextMarkClass self => self -> IO Bool +textMarkGetLeftGravity self = + liftM toBool $ + {# call unsafe text_mark_get_left_gravity #} + (toTextMark self) -------------------- -- Properties -- | \'visible\' property. See 'textMarkGetVisible' and 'textMarkSetVisible' -- -textMarkVisible :: Attr TextMark Bool +textMarkVisible :: TextMarkClass self => Attr self Bool textMarkVisible = Attr textMarkGetVisible textMarkSetVisible Index: TextTag.chs.pp =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Multiline/TextTag.chs.pp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- TextTag.chs.pp 13 Mar 2005 19:34:36 -0000 1.5 +++ TextTag.chs.pp 4 Apr 2005 01:24:10 -0000 1.6 @@ -28,10 +28,10 @@ -- Stability : provisional -- Portability : portable (depends on GHC) -- --- A tag that can be applied to text in a 'TextBuffer'. +-- A tag that can be applied to text in a 'TextBuffer' -- module Graphics.UI.Gtk.Multiline.TextTag ( --- * Description +-- * Detail -- -- | You may wish to begin by reading the text widget conceptual overview -- which gives an overview of all the objects and data types related to the @@ -91,34 +91,38 @@ -- textTagNew :: TagName -> IO TextTag textTagNew name = - withCString name $ \strPtr -> - makeNewGObject mkTextTag $ {#call unsafe text_tag_new#} strPtr + makeNewGObject mkTextTag $ + withCString name $ \namePtr -> + {# call unsafe text_tag_new #} + namePtr -------------------- -- Methods -- | Get the tag priority. -- -textTagGetPriority :: TextTagClass obj => obj -> IO Int -textTagGetPriority obj = liftM fromIntegral $ - {#call unsafe text_tag_get_priority#} (toTextTag obj) +textTagGetPriority :: TextTagClass self => self -> IO Int +textTagGetPriority self = + liftM fromIntegral $ + {# call unsafe text_tag_get_priority #} + (toTextTag self) --- | Sets the priority of a 'TextTag'. --- --- Valid priorities are start at 0 and go to one less than --- 'textTagTableGetSize'. Each tag in a table has a unique priority; setting the --- priority of one tag shifts the priorities of all the other tags in the table --- to maintain a unique priority for each tag. Higher priority tags \"win\" if --- two tags both set the same text attribute. When adding a tag to a tag table, --- it will be assigned the highest priority in the table by default; so normally --- the precedence of a set of tags is the order in which they were added to the --- table, or created with 'textBufferCreateTag', which adds the tag to the --- buffer's table automatically. +-- | Sets the priority of a 'TextTag'. Valid priorities are start at 0 and go +-- to one less than 'textTagTableGetSize'. Each tag in a table has a unique +-- priority; setting the priority of one tag shifts the priorities of all the +-- other tags in the table to maintain a unique priority for each tag. Higher +-- priority tags \"win\" if two tags both set the same text attribute. When +-- adding a tag to a tag table, it will be assigned the highest priority in the +-- table by default; so normally the precedence of a set of tags is the order +-- in which they were added to the table, or created with +-- 'textBufferCreateTag', which adds the tag to the buffer's table +-- automatically. -- -textTagSetPriority :: TextTagClass obj => obj -> Int -> IO () -textTagSetPriority obj priority = - {#call text_tag_set_priority#} (toTextTag obj) (fromIntegral priority) - +textTagSetPriority :: TextTagClass self => self -> Int -> IO () +textTagSetPriority self priority = + {# call text_tag_set_priority #} + (toTextTag self) + (fromIntegral priority) -- TextAttributes methods @@ -143,14 +147,9 @@ text_attributes_unref :: Ptr TextAttributes -> FinalizerPtr TextAttributes text_attributes_unref _ = text_attributes_unref' -#elif __GLASGOW_HASKELL__>=504 - -foreign import ccall unsafe "gtk_text_attributes_unref" - text_attributes_unref :: Ptr TextAttributes -> IO () - #else -foreign import ccall "gtk_text_attributes_unref" unsafe +foreign import ccall unsafe "gtk_text_attributes_unref" text_attributes_unref :: Ptr TextAttributes -> IO () #endif @@ -160,7 +159,7 @@ -- | \'priority\' property. See 'textTagGetPriority' and 'textTagSetPriority' -- -textTagPriority :: Attr TextTag Int +textTagPriority :: TextTagClass self => Attr self Int textTagPriority = Attr textTagGetPriority textTagSetPriority Index: TextTagTable.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Multiline/TextTagTable.chs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- TextTagTable.chs 25 Feb 2005 01:11:36 -0000 1.3 +++ TextTagTable.chs 4 Apr 2005 01:24:10 -0000 1.4 @@ -27,7 +27,7 @@ -- Collection of tags that can be used together -- module Graphics.UI.Gtk.Multiline.TextTagTable ( --- * Description +-- * Detail -- -- | You may wish to begin by reading the text widget conceptual overview -- which gives an overview of all the objects and data types related to the @@ -72,8 +72,8 @@ -- textTagTableNew :: IO TextTagTable textTagTableNew = - makeNewGObject mkTextTagTable $ - {#call unsafe text_tag_table_new#} + makeNewGObject mkTextTagTable $ + {# call unsafe text_tag_table_new #} -------------------- -- Methods @@ -84,35 +84,46 @@ -- The tag must not be in a tag table already, and may not have the same name as -- an already-added tag. -- -textTagTableAdd :: TextTagTableClass obj => obj -> TextTag -> IO () -textTagTableAdd obj tag = - {#call text_tag_table_add#} (toTextTagTable obj) tag +textTagTableAdd :: (TextTagTableClass self, TextTagClass tag) => self -> tag -> IO () +textTagTableAdd self tag = + {# call text_tag_table_add #} + (toTextTagTable self) + (toTextTag tag) -- | Remove a tag from the table. -- -textTagTableRemove :: TextTagTableClass obj => obj -> TextTag -> IO () -textTagTableRemove obj tag = - {#call text_tag_table_remove#} (toTextTagTable obj) tag +textTagTableRemove :: (TextTagTableClass self, TextTagClass tag) => self -> tag -> IO () +textTagTableRemove self tag = + {# call text_tag_table_remove #} + (toTextTagTable self) + (toTextTag tag) -- | Look up a named tag. -- -textTagTableLookup :: TextTagTableClass obj => obj - -> String -> IO (Maybe TextTag) -textTagTableLookup obj name = - withCString name $ \strPtr -> do - tagPtr <- {#call unsafe text_tag_table_lookup#} (toTextTagTable obj) strPtr - if tagPtr == nullPtr then return Nothing else liftM Just $ - makeNewGObject mkTextTag (return tagPtr) +textTagTableLookup :: TextTagTableClass self => self + -> String -- ^ @name@ - name of a tag + -> IO (Maybe TextTag) -- ^ returns The tag, or @Nothing@ if none by that name + -- is in the table. +textTagTableLookup self name = + maybeNull (makeNewGObject mkTextTag) $ + withCString name $ \namePtr -> + {# call unsafe text_tag_table_lookup #} + (toTextTagTable self) + namePtr --- | Calls func on each tag in table. +-- | Maps over each tag in the table. -- -textTagTableForeach :: TextTagTableClass obj => obj - -> (TextTag -> IO ()) -> IO () -textTagTableForeach obj func = do +textTagTableForeach :: TextTagTableClass self => self + -> (TextTag -> IO ()) + -> IO () +textTagTableForeach self func = do funcPtr <- mkTextTagTableForeach (\tagPtr _ -> do tag <- makeNewGObject mkTextTag (return tagPtr) func tag) - {#call text_tag_table_foreach#} (toTextTagTable obj) funcPtr nullPtr + {# call text_tag_table_foreach #} + (toTextTagTable self) + funcPtr + nullPtr {#pointer TextTagTableForeach#} @@ -121,6 +132,8 @@ -- | Returns the size of the table (the number of tags). -- -textTagTableGetSize :: TextTagTableClass obj => obj -> IO Int -textTagTableGetSize obj = liftM fromIntegral $ - {#call unsafe text_tag_table_get_size#} (toTextTagTable obj) +textTagTableGetSize :: TextTagTableClass self => self -> IO Int +textTagTableGetSize self = + liftM fromIntegral $ + {# call unsafe text_tag_table_get_size #} + (toTextTagTable self) Index: TextBuffer.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Multiline/TextBuffer.chs,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- TextBuffer.chs 13 Mar 2005 19:34:35 -0000 1.5 +++ TextBuffer.chs 4 Apr 2005 01:24:09 -0000 1.6 @@ -176,433 +176,643 @@ -------------------- -- Constructors --- | Create a new text buffer, possibly taking a --- table of 'TextTag'. +-- | Creates a new text buffer. -- -textBufferNew :: Maybe TextTagTable -> IO TextBuffer -textBufferNew tt = makeNewGObject mkTextBuffer $ liftM castPtr $ - {#call unsafe text_buffer_new#} - (fromMaybe (mkTextTagTable nullForeignPtr) tt) [...1091 lines suppressed...] -- -onModifiedChanged, afterModifiedChanged :: TextBufferClass tb => tb -> IO () -> - IO (ConnectId tb) +onModifiedChanged, afterModifiedChanged :: TextBufferClass self => self + -> IO () + -> IO (ConnectId self) onModifiedChanged = connect_NONE__NONE "modified_changed" False afterModifiedChanged = connect_NONE__NONE "modified_changed" True -- | A 'TextTag' was removed. -- -onRemoveTag, afterRemoveTag :: TextBufferClass tb => tb -> - (TextTag -> TextIter -> TextIter -> IO ()) -> - IO (ConnectId tb) +onRemoveTag, afterRemoveTag :: TextBufferClass self => self + -> (TextTag -> TextIter -> TextIter -> IO ()) + -> IO (ConnectId self) onRemoveTag = connect_OBJECT_BOXED_BOXED__NONE "remove_tag" mkTextIter mkTextIter False afterRemoveTag = connect_OBJECT_BOXED_BOXED__NONE "remove_tag" |