From: Duncan C. <dun...@us...> - 2004-08-05 14:24:40
|
Update of /cvsroot/gtk2hs/gtk2hs/gtk/multiline In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1268/gtk/multiline Modified Files: TextTag.chs TextTagTable.chs TextView.chs Log Message: Add missing functions & fix typo bug in TreeView.chs. Add more ignored functions. Index: TextView.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/multiline/TextView.chs,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- TextView.chs 23 May 2004 16:09:08 -0000 1.11 +++ TextView.chs 5 Aug 2004 14:24:28 -0000 1.12 @@ -30,8 +30,6 @@ -- -- * If PangoTabArray is bound: do textViewSetTabs and textViewGetTabs -- --- * If TextTags are bound: do textViewGetDefaultAttributes --- module TextView( TextView, TextViewClass, @@ -47,6 +45,7 @@ textViewNew, textViewNewWithBuffer, textViewSetBuffer, + textViewGetBuffer, textViewScrollToMark, textViewScrollToIter, textViewScrollMarkOnscreen, @@ -67,6 +66,7 @@ textViewBackwardDisplayLineEnd, textViewForwardDisplayLineStart, textViewBackwardDisplayLineStart, + textViewStartsDisplayLine, textViewMoveVisually, textViewAddChildAtAnchor, textChildAnchorNew, @@ -94,6 +94,7 @@ textViewGetRightMargin, textViewSetIndent, textViewGetIndent, + textViewGetDefaultAttributes, onCopyClipboard, afterCopyClipboard, onCutClipboard, @@ -127,6 +128,7 @@ {#import Hierarchy#} {#import Signal#} {#import TextIter#} +{#import TextTag#} import Enums (TextWindowType(..), DeleteType(..), DirectionType(..), Justification(..), MovementStep(..), WrapMode(..)) import GList (fromGList) @@ -151,12 +153,17 @@ textViewNewWithBuffer tb = makeNewGObject mkTextView $ liftM castPtr $ {#call unsafe text_view_new_with_buffer#} tb --- | Set the 'TextBuffer' for a given --- 'TextView' widget. +-- | Set the 'TextBuffer' for a given 'TextView' widget. -- textViewSetBuffer :: TextViewClass tv => tv -> TextBuffer -> IO () textViewSetBuffer tv tb = - {#call unsafe text_view_set_buffer#} (toTextView tv) tb + {#call text_view_set_buffer#} (toTextView tv) tb + +-- | Returns the 'TextBuffer' being displayed by this text view. +-- +textViewGetBuffer :: TextViewClass tv => tv -> IO TextBuffer +textViewGetBuffer tv = makeNewGObject mkTextBuffer $ + {#call unsafe text_view_get_buffer#} (toTextView tv) -- | Scroll to the position of the supplied -- 'TextMark'. @@ -377,8 +384,7 @@ {#call unsafe text_view_get_border_window_size#} (toTextView tv) ((fromIntegral.fromEnum) wt) --- | Move the iterator forwards by one --- display line. +-- | Move the iterator forwards by one display line. -- -- * Moves the given 'TextIter' forward by one display (wrapped) -- line. A display line is different from a paragraph. Paragraphs are @@ -402,8 +408,7 @@ textViewBackwardDisplayLine tv ti = liftM toBool $ {#call unsafe text_view_backward_display_line#} (toTextView tv) ti --- | Move the iterator forwards and to --- the end. +-- | Move the iterator forwards and to the end. -- -- * Like 'textViewForwardDisplayLine' but moves to the end of -- the line as well. @@ -412,8 +417,7 @@ textViewForwardDisplayLineEnd ti tv = liftM toBool $ {#call unsafe text_view_forward_display_line_end#} (toTextView tv) ti --- | Move the iterator backwards and to --- the end. +-- | Move the iterator backwards and to the end. -- -- * See 'textViewForwardDisplayLineEnd'. -- @@ -421,8 +425,7 @@ textViewBackwardDisplayLineEnd tv ti = liftM toBool $ {#call unsafe text_view_backward_display_line_start#} (toTextView tv) ti --- | Move the iterator forwards and to --- the start. +-- | Move the iterator forwards and to the start. -- -- * Like 'textViewForwardDisplayLine' but moves to the start of -- the line as well. @@ -432,8 +435,7 @@ textViewForwardDisplayLineStart tv ti = liftM toBool $ {#call unsafe text_view_forward_display_line_end#} (toTextView tv) ti --- | Move the iterator backwards and --- to the start. +-- | Move the iterator backwards and to the start. -- -- * See 'textViewForwardDisplayLineStart'. -- @@ -442,11 +444,18 @@ textViewBackwardDisplayLineStart tv ti = liftM toBool $ {#call unsafe text_view_backward_display_line_start#} (toTextView tv) ti +-- | Determines whether the iter is at the start of a display line. +-- +-- * See 'textViewForwardDisplayLine' for an explanation of display lines vs. +-- paragraphs. +-- +textViewStartsDisplayLine :: TextViewClass tv => tv -> TextIter -> IO Bool +textViewStartsDisplayLine tv ti = liftM toBool $ + {#call unsafe text_view_starts_display_line#} (toTextView tv) ti -- | Move the iterator a number of lines. -- --- * @count@ is in display lines. See --- 'textViewForwardDisplayLine'. +-- * The @count@ is in display lines. See 'textViewForwardDisplayLine'. -- textViewMoveVisually :: TextViewClass tv => tv -> TextIter -> Int -> IO Bool textViewMoveVisually tv ti count = liftM toBool $ @@ -673,6 +682,17 @@ textViewGetIndent tv = liftM (fromIntegral) $ {#call unsafe text_view_get_indent#} (toTextView tv) +-- | Obtains a copy of the default text attributes. These are the attributes +-- used for text unless a tag overrides them. +-- +textViewGetDefaultAttributes :: TextViewClass tv => tv -> IO TextAttributes +textViewGetDefaultAttributes tv = + {#call gtk_text_view_get_default_attributes#} (toTextView tv) + >>= makeNewTextAttributes + + +-- Signals + -- | Copying to the clipboard. -- -- * This signal is emitted when a selection is copied to the clipboard. Index: TextTag.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/multiline/TextTag.chs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- TextTag.chs 23 May 2004 16:09:08 -0000 1.6 +++ TextTag.chs 5 Aug 2004 14:24:28 -0000 1.7 @@ -1,36 +1,47 @@ +{-# OPTIONS -cpp #-} -- -*-haskell-*- --- GIMP Toolkit (GTK) TextTag TextBuffer +-- GIMP Toolkit (GTK) Widget TextTag -- --- Author : Axel Simon --- --- Created: 24 February 2002 +-- Author : Duncan Coutts +-- Created: 4 August 2004 -- --- Version $Revision$ from $Date$ +-- Copyright (c) 2004 Duncan Coutts -- --- This file is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 2 of the License, or --- (at your option) any later version. +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Library General Public +-- License as published by the Free Software Foundation; either +-- version 2 of the License, or (at your option) any later version. -- --- This file is distributed in the hope that it will be useful, +-- 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 General Public License for more details. +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +-- Library General Public License for more details. -- -- | -- +-- A tag that can be applied to text in a "TextBuffer". +-- +-- TODO +-- +-- * accessor functions for TextAttributes module TextTag( TextTag, TextTagClass, castToTextTag, - TagName + TagName, + textTagNew, + textTagSetPriority, + textTagGetPriority, + TextAttributes(..), + textAttributesNew, + makeNewTextAttributes, --internal ) where import Monad (liftM) import FFI -import Object (makeNewObject) +import GObject (makeNewGObject) {#import Hierarchy#} {#import Signal#} @@ -38,5 +49,69 @@ type TagName = String --- methods +-- TextTag methods +-- | Creates a 'TextTag'. +-- +textTagNew :: TagName -> IO TextTag +textTagNew name = + withCString name $ \strPtr -> + makeNewGObject mkTextTag $ {#call unsafe text_tag_new#} strPtr + +-- | Get the tag priority. +-- +textTagGetPriority :: TextTagClass obj => obj -> IO Int +textTagGetPriority obj = liftM fromIntegral $ + {#call unsafe text_tag_get_priority#} (toTextTag obj) + +-- | 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) + + +-- TextAttributes methods + +{#pointer * TextAttributes foreign newtype#} + +-- | Creates a 'TextAttributes', which describes a set of properties on some +-- text. +-- +textAttributesNew :: IO TextAttributes +textAttributesNew = + {#call unsafe text_attributes_new#} >>= makeNewTextAttributes + +makeNewTextAttributes :: Ptr TextAttributes -> IO TextAttributes +makeNewTextAttributes ptr = + liftM TextAttributes $ newForeignPtr ptr (text_attributes_unref ptr) + +#if __GLASGOW_HASKELL__>=600 + +foreign import ccall unsafe ">k_text_attributes_unref" + text_attributes_unref' :: FinalizerPtr TextAttributes + +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 + text_attributes_unref :: Ptr TextAttributes -> IO () + +#endif Index: TextTagTable.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/multiline/TextTagTable.chs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- TextTagTable.chs 23 May 2004 16:09:08 -0000 1.6 +++ TextTagTable.chs 5 Aug 2004 14:24:28 -0000 1.7 @@ -1,42 +1,105 @@ +{-# OPTIONS -cpp #-} -- -*-haskell-*- --- GIMP Toolkit (GTK) TextTagTable TextBuffer +-- GIMP Toolkit (GTK) Widget TextTagTable -- --- Author : Axel Simon --- --- Created: 20 March 2002 +-- Author : Duncan Coutts +-- Created: 4 August 2004 -- --- Version $Revision$ from $Date$ +-- Copyright (c) 2004 Duncan Coutts -- --- This file is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 2 of the License, or --- (at your option) any later version. +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Library General Public +-- License as published by the Free Software Foundation; either +-- version 2 of the License, or (at your option) any later version. -- --- This file is distributed in the hope that it will be useful, +-- 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 General Public License for more details. +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +-- Library General Public License for more details. -- -- | -- --- TODO --- --- * Everything. --- -module TextTagTable( + +module TextTagTable ( TextTagTable, TextTagTableClass, castToTextTagTable, + textTagTableNew, + textTagTableAdd, + textTagTableRemove, + textTagTableLookup, + textTagTableForeach, + textTagTableGetSize ) where import Monad (liftM) import FFI -import Object (makeNewObject) +import GObject (makeNewGObject) {#import Hierarchy#} {#import Signal#} {# context lib="gtk" prefix="gtk" #} --- methods +-- | Creates a new 'TextTagTable'. The table contains no tags by default. +-- +textTagTableNew :: IO TextTagTable +textTagTableNew = + makeNewGObject mkTextTagTable $ + {#call unsafe text_tag_table_new#} +-- | Add a tag to the table. The tag is assigned the highest priority in the +-- table. +-- +-- 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 + +-- | Remove a tag from the table. +-- +textTagTableRemove :: TextTagTableClass obj => obj -> TextTag -> IO () +textTagTableRemove obj tag = + {#call text_tag_table_remove#} (toTextTagTable obj) 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) + +-- | Calls func on each tag in table. +-- +textTagTableForeach :: TextTagTableClass obj => obj + -> (TextTag -> IO ()) -> IO () +textTagTableForeach obj func = do + funcPtr <- mkTextTagTableForeach (\tagPtr _ -> do + tag <- makeNewGObject mkTextTag (return tagPtr) + func tag) + {#call text_tag_table_foreach#} (toTextTagTable obj) funcPtr nullPtr + +{#pointer TextTagTableForeach#} + +#if __GLASGOW_HASKELL__>=600 + +foreign import ccall "wrapper" mkTextTagTableForeach :: + (Ptr TextTag -> Ptr () -> IO ()) -> IO TextTagTableForeach + +#else + +foreign export dynamic mkTextTagTableForeach :: + (Ptr Widget -> Ptr () -> IO ()) -> IO TextTagTableForeach + +#endif + +-- | 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) |