From: Peter g. <pg...@co...> - 2009-01-11 15:50:49
|
Thu Jan 8 12:03:24 EST 2009 Hamish Mackenzie <ha...@fi...> * Add SourceMark to gtksourceview2 hunk ./Makefile.am 1383 + gtksourceview2/Graphics/UI/Gtk/SourceView/SourceMark.chs \ hunk ./gtksourceview2/Graphics/UI/Gtk/SourceView/SourceBuffer.chs 48 + sourceBufferCreateSourceMark, hunk ./gtksourceview2/Graphics/UI/Gtk/SourceView/SourceBuffer.chs 74 +import Graphics.UI.Gtk.SourceView.SourceMark + hunk ./gtksourceview2/Graphics/UI/Gtk/SourceView/SourceBuffer.chs 191 +-- | Creates a marker in the buffer of the given type. +-- +-- * A marker is +-- semantically very similar to a 'Graphics.UI.Gtk.Multiline.TextMark', +-- except it has a type +-- which is used by the 'SourceView' displaying the buffer to show a +-- pixmap on the left margin, at the line the marker is in. Because +-- of this, a marker is generally associated to a line and not a +-- character position. Markers are also accessible through a position +-- or range in the buffer. +-- +-- * Markers are implemented using 'Graphics.UI.Gtk.Multiline.TextMark', +-- so all characteristics +-- and restrictions to marks apply to markers too. These includes +-- life cycle issues and 'Graphics.UI.Gtk.Multiline.TextMark.onMarkSet' +-- and 'Graphics.UI.Gtk.Multiline.TextMark.onMarkDeleted' signal +-- emissions. +-- +-- * Like a 'Graphics.UI.Gtk.Multiline.TextMark', a 'SourceMarker' +-- can be anonymous if the +-- passed name is @Nothing@. Also, the buffer owns the markers so you +-- shouldn't unreference it. + +sourceBufferCreateSourceMark :: SourceBuffer -- the buffer + -> Maybe String -- the name of the mark + -> String -- the category of the mark + -> TextIter -> IO SourceMark +sourceBufferCreateSourceMark sb name category iter = + makeNewGObject mkSourceMark $ + maybeWith withCString name $ \strPtr1 -> + withCString category $ \strPtr2 -> + {#call source_buffer_create_source_mark#} sb strPtr1 strPtr2 iter + addfile ./gtksourceview2/Graphics/UI/Gtk/SourceView/SourceMark.chs hunk ./gtksourceview2/Graphics/UI/Gtk/SourceView/SourceMark.chs 1 +-- -*-haskell-*- +-- GIMP Toolkit (GTK) SourceMark +-- +-- Author : Duncan Coutts +-- derived from GtkTextView bindings by Axel Simon +-- +-- Created: 26 October 2003 +-- +-- Copyright (C) 2003-2005 Duncan Coutts, 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. +-- +-- | +-- Maintainer : gtk...@li... +-- Stability : provisional +-- Portability : portable (depends on GHC) +-- +module Graphics.UI.Gtk.SourceView.SourceMark ( + SourceMark, + castToSourceMark, + sourceMarkGetCategory, + sourceMarkNext, + sourceMarkPrev +) where + +import Control.Monad (liftM) + +import System.Glib.FFI +import System.Glib.UTFString +import System.Glib.GObject (makeNewGObject) +{#import Graphics.UI.Gtk.Types#} +{#import Graphics.UI.Gtk.SourceView.Types#} + +{# context lib="gtk" prefix="gtk" #} + +-- methods + +-- | [_$_] +-- [_$_] +sourceMarkGetCategory :: SourceMark -> IO String +sourceMarkGetCategory mark = do + strPtr <- {#call unsafe source_mark_get_category#} mark + markType <- peekUTFString strPtr + {#call unsafe g_free#} (castPtr strPtr) + return markType + +-- | [_$_] +-- [_$_] +sourceMarkNext :: SourceMark -> String -> IO SourceMark +sourceMarkNext mark category = makeNewGObject mkSourceMark $ + withUTFString category $ {#call unsafe source_mark_next#} mark + +-- | [_$_] +-- [_$_] +sourceMarkPrev :: SourceMark -> String -> IO SourceMark +sourceMarkPrev mark category = makeNewGObject mkSourceMark $ + withUTFString category $ {#call unsafe source_mark_prev#} mark + hunk ./gtksourceview2/Graphics/UI/Gtk/SourceView/SourceView.chs 45 + sourceViewSetShowLineMarks, + sourceViewGetShowLineMarks, hunk ./gtksourceview2/Graphics/UI/Gtk/SourceView/SourceView.chs 55 + sourceViewSetMarkCategoryPixbuf, + sourceViewGetMarkCategoryPixbuf, hunk ./gtksourceview2/Graphics/UI/Gtk/SourceView/SourceView.chs 172 +sourceViewSetShowLineMarks :: SourceViewClass sv => sv -> Bool -> IO () +sourceViewSetShowLineMarks sv newVal = + {#call source_view_set_show_line_marks#} (toSourceView sv) (fromBool newVal) + [_$_] +-- | [_$_] +-- +sourceViewGetShowLineMarks :: SourceViewClass sv => sv -> IO Bool [_$_] +sourceViewGetShowLineMarks sv = liftM toBool $ + {#call unsafe source_view_get_show_line_marks#} (toSourceView sv) + +--- | [_$_] +-- hunk ./gtksourceview2/Graphics/UI/Gtk/SourceView/SourceView.chs 230 +-- | +-- +sourceViewSetMarkCategoryPriority :: SourceViewClass sv => sv -> String -> Int -> IO () +sourceViewSetMarkCategoryPriority sv markerType priority = withCString markerType $ \strPtr -> + {#call source_view_set_mark_category_priority#} (toSourceView sv) strPtr (fromIntegral priority) + +-- | +-- +sourceViewGetMarkCategoryPriority :: SourceViewClass sv => sv -> String -> IO Int +sourceViewGetMarkCategoryPriority sv markerType = withCString markerType $ \strPtr -> + liftM fromIntegral $ + {#call unsafe source_view_get_mark_category_priority#} (toSourceView sv) strPtr + +--- | +-- +sourceViewSetMarkCategoryPixbuf :: SourceViewClass sv => sv -> String -> Pixbuf -> IO () +sourceViewSetMarkCategoryPixbuf sv markerType marker = withCString markerType $ \strPtr -> + {#call source_view_set_mark_category_pixbuf#} (toSourceView sv) strPtr marker + +-- | +-- +sourceViewGetMarkCategoryPixbuf :: SourceViewClass sv => sv -> String -> IO Pixbuf +sourceViewGetMarkCategoryPixbuf sv markerType = withCString markerType $ \strPtr -> + constructNewGObject mkPixbuf $ + {#call unsafe source_view_get_mark_category_pixbuf#} (toSourceView sv) strPtr + |