 -- 
 -- This is a potentially slow operation and should be used only when you need to make sure that some
 -- text not currently visible is highlighted, for instance before printing.
-sourceBufferEnsureHighlight :: SourceBuffer 
+sourceBufferEnsureHighlight :: SourceBufferClass buffer => buffer 
                             -> TextIter  -- ^ @start@  start of the area to highlight. 
                             -> TextIter  -- ^ @end@    end of the area to highlight.   
                             -> IO ()
 sourceBufferEnsureHighlight sb start end =
-    {#call source_buffer_ensure_highlight#} sb start end
+    {#call source_buffer_ensure_highlight#} (toSourceBuffer sb) start end
 
 -- | Whether Redo operation is possible.
 -- 
 -- Default value: 'False'
 -- 
-sourceBufferCanRedo :: ReadAttr SourceBuffer Bool
+sourceBufferCanRedo :: SourceBufferClass buffer => ReadAttr buffer Bool
 sourceBufferCanRedo = readAttrFromBoolProperty "can-redo"
 
 -- | Whether Undo operation is possible.
 -- 
 -- Default value: 'False'
-sourceBufferCanUndo :: ReadAttr SourceBuffer Bool
+sourceBufferCanUndo :: SourceBufferClass buffer => ReadAttr buffer Bool
 sourceBufferCanUndo = readAttrFromBoolProperty "can-undo"
 
 -- | Whether to highlight matching brackets in the buffer.
 -- 
 -- Default value: 'True'
 --
-sourceBufferHighlightMatchingBrackets :: Attr SourceBuffer Bool
+sourceBufferHighlightMatchingBrackets :: SourceBufferClass buffer => Attr buffer Bool
 sourceBufferHighlightMatchingBrackets = newAttrFromBoolProperty "highlight-matching-brackets"
 
 -- | Whether to highlight syntax in the buffer.
 -- 
 -- Default value: 'True'
 --
-sourceBufferHighlightSyntax :: Attr SourceBuffer Bool
+sourceBufferHighlightSyntax :: SourceBufferClass buffer => Attr buffer Bool
 sourceBufferHighlightSyntax = newAttrFromBoolProperty "highlight-matching-brackets"
 
 -- | Language object to get highlighting patterns from.
 -- 
-sourceBufferLanguage :: Attr SourceBuffer (Maybe SourceLanguage)
+sourceBufferLanguage :: SourceBufferClass buffer => Attr buffer (Maybe SourceLanguage)
 sourceBufferLanguage = newAttrFromMaybeObjectProperty "language" gTypeSourceLanguage
 
 -- | Number of undo levels for the buffer. -1 means no limit. This property will only affect the default

  makeNewGObject mkSourceMark $
  maybeWith withCString name       $ \strPtr1 ->
  withCString category $ \strPtr2 ->
  {#call source_buffer_create_source_mark#} sb strPtr1 strPtr2 iter

-- | Returns the list of marks of the given category at line. If category is empty, all marks at line are
-- returned.
sourceBufferGetSourceMarksAtLine :: SourceBuffer  -- ^ @buffer@   a 'SourceBuffer'.             
                                 -> Int -- ^ @line@     a line number.                 
                                 -> String -- ^ @category@ category to search for or empty 
                                 -> IO [SourceMark]
sourceBufferGetSourceMarksAtLine buffer line category = 
  withCString category $ \categoryPtr ->
  {#call gtk_source_buffer_get_source_marks_at_line #}
    buffer 
    (fromIntegral line)
    categoryPtr
  >>= readGSList

-- 'sourceBufferSetLanguage'. If highlight is 'False', syntax highlighting is disabled and all the
-- 'TextTag' objects that have been added by the syntax highlighting engine are removed from the
-- buffer.
sourceBufferSetHighlightSyntax :: SourceBufferClass buffer => buffer  -- ^ @buffer@    a 'SourceBuffer'.                                       
                               -> Bool  -- ^ @highlight@ 'True' to enable syntax highlighting, 'False' to disable it. 
                               -> IO ()
sourceBufferSetHighlightSyntax sb newVal =
  {#call unsafe source_buffer_set_highlight_syntax#} 
    (toSourceBuffer sb) 
    (fromBool newVal)
  
-- | Determines whether syntax highlighting is activated in the source buffer.
sourceBufferGetHighlightSyntax :: SourceBufferClass buffer => buffer 
                               -> IO Bool  -- ^ returns 'True' if syntax highlighting is enabled, 'False' otherwise. 
sourceBufferGetHighlightSyntax sb = liftM toBool $
  {#call unsafe source_buffer_get_highlight_syntax#} 
    (toSourceBuffer sb)

-- | Associate a 'SourceLanguage' with the source buffer. If language is not-'Nothing' and syntax
-- highlighting is enabled (see 'sourceBufferSetHighlightSyntax', the syntax patterns defined
-- in language will be used to highlight the text contained in the buffer. If language is 'Nothing', the
-- text contained in the buffer is not highlighted.
sourceBufferSetLanguage :: SourceBufferClass buffer => buffer 
                        -> Maybe SourceLanguage  -- ^ @language@ a 'SourceLanguage' to set, or 'Nothing'. 
                        -> IO ()
sourceBufferSetLanguage sb lang =
  {#call unsafe source_buffer_set_language#} 
    (toSourceBuffer sb) 
    (fromMaybe (SourceLanguage nullForeignPtr) lang)
  
-- | Returns the 'SourceLanguage' associated with the buffer, see 'sourceBufferSetLanguage'. 
sourceBufferGetLanguage :: SourceBufferClass buffer => buffer 
                        -> IO (Maybe SourceLanguage) -- ^ returns 'SourceLanguage' associated with the buffer, or 'Nothing'. 
sourceBufferGetLanguage sb = 
  maybeNull (makeNewGObject mkSourceLanguage) $
  {#call unsafe source_buffer_get_language#} (toSourceBuffer sb)

-- | Controls the bracket match highlighting function in the buffer. If activated, when you position your
-- cursor over a bracket character (a parenthesis, a square bracket, etc.) the matching opening or
-- closing bracket character will be highlighted. You can specify the style with the
-- 'sourceBufferSetBracketMatchStyle' function.
sourceBufferSetHighlightMatchingBrackets :: SourceBufferClass buffer => buffer 
                                         -> Bool  -- ^ @highlight@ 'True' if you want matching brackets highlighted. 
                                         -> IO ()
sourceBufferSetHighlightMatchingBrackets sb newVal =
  {#call unsafe source_buffer_set_highlight_matching_brackets#} (toSourceBuffer sb) (fromBool newVal)
  
-- | Determines whether bracket match highlighting is activated for the source buffer.
sourceBufferGetHighlightMatchingBrackets :: SourceBufferClass buffer => buffer 
                                         -> IO Bool  -- ^ returns 'True' if the source buffer will highlight matching brackets. 
sourceBufferGetHighlightMatchingBrackets sb = liftM toBool $
  {#call unsafe source_buffer_get_highlight_matching_brackets#} (toSourceBuffer sb)

-- | Sets style scheme used by the buffer. If scheme is 'Nothing' no style scheme is used.
sourceBufferSetStyleScheme :: SourceBufferClass buffer => buffer 
                           -> Maybe SourceStyleScheme  -- ^ @scheme@ style scheme.      
                           -> IO ()
sourceBufferSetStyleScheme sb scheme =
    {#call unsafe source_buffer_set_style_scheme#} 
      (toSourceBuffer sb)  
      (fromMaybe (SourceStyleScheme nullForeignPtr) scheme)

-- | Returns the 'SourceStyleScheme' currently used in buffer.
sourceBufferGetStyleScheme :: SourceBufferClass buffer => buffer 
                           -> IO (Maybe SourceStyleScheme) -- ^ returns the 'SourceStyleScheme' set by 'sourceBufferSetStyleScheme', or 'Nothing'.
sourceBufferGetStyleScheme sb = 
    maybeNull (makeNewGObject mkSourceStyleScheme) $
    {#call unsafe source_buffer_get_style_scheme#} (toSourceBuffer sb)

-- | Sets the number of undo levels for user actions the buffer will track. If the number of user actions
-- exceeds the limit set by this function, older actions will be discarded.
