gi-gtksource-5.0.0: GtkSource bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.GtkSource.Objects.Region

Description

Region utility.

A GtkSourceRegion permits to store a group of subregions of a TextBuffer. GtkSourceRegion stores the subregions with pairs of TextMark's, so the region is still valid after insertions and deletions in the TextBuffer.

The TextMark for the start of a subregion has a left gravity, while the TextMark for the end of a subregion has a right gravity.

The typical use-case of GtkSourceRegion is to scan a TextBuffer chunk by chunk, not the whole buffer at once to not block the user interface. The GtkSourceRegion represents in that case the remaining region to scan. You can listen to the TextBuffer::insertText and TextBuffer::deleteRange signals to update the GtkSourceRegion accordingly.

To iterate through the subregions, you need to use a [structregionIter], for example:

c code

GtkSourceRegion *region;
GtkSourceRegionIter region_iter;

gtk_source_region_get_start_region_iter (region, &region_iter);

while (!gtk_source_region_iter_is_end (&region_iter))
{
        GtkTextIter subregion_start;
        GtkTextIter subregion_end;

        if (!gtk_source_region_iter_get_subregion (&region_iter,
                                                   &subregion_start,
                                                   &subregion_end))
        {
                break;
        }

        // Do something useful with the subregion.

        gtk_source_region_iter_next (&region_iter);
}
Synopsis

Exported types

newtype Region Source #

Memory-managed wrapper type.

Constructors

Region (ManagedPtr Region) 

Instances

Instances details
Eq Region Source # 
Instance details

Defined in GI.GtkSource.Objects.Region

Methods

(==) :: Region -> Region -> Bool #

(/=) :: Region -> Region -> Bool #

GObject Region Source # 
Instance details

Defined in GI.GtkSource.Objects.Region

ManagedPtrNewtype Region Source # 
Instance details

Defined in GI.GtkSource.Objects.Region

Methods

toManagedPtr :: Region -> ManagedPtr Region

TypedObject Region Source # 
Instance details

Defined in GI.GtkSource.Objects.Region

Methods

glibType :: IO GType

HasParentTypes Region Source # 
Instance details

Defined in GI.GtkSource.Objects.Region

IsGValue (Maybe Region) Source #

Convert Region to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.GtkSource.Objects.Region

Methods

gvalueGType_ :: IO GType

gvalueSet_ :: Ptr GValue -> Maybe Region -> IO ()

gvalueGet_ :: Ptr GValue -> IO (Maybe Region)

type ParentTypes Region Source # 
Instance details

Defined in GI.GtkSource.Objects.Region

type ParentTypes Region = '[Object]

class (GObject o, IsDescendantOf Region o) => IsRegion o Source #

Type class for types which can be safely cast to Region, for instance with toRegion.

Instances

Instances details
(GObject o, IsDescendantOf Region o) => IsRegion o Source # 
Instance details

Defined in GI.GtkSource.Objects.Region

toRegion :: (MonadIO m, IsRegion o) => o -> m Region Source #

Cast to Region, for types for which this is known to be safe. For general casts, use castTo.

Methods

addRegion

regionAddRegion Source #

Arguments

:: (HasCallStack, MonadIO m, IsRegion a, IsRegion b) 
=> a

region: a Region.

-> Maybe b

regionToAdd: the Region to add to region, or Nothing.

-> m () 

Adds regionToAdd to region.

regionToAdd is not modified.

addSubregion

regionAddSubregion Source #

Arguments

:: (HasCallStack, MonadIO m, IsRegion a) 
=> a

region: a Region.

-> TextIter

start_: the start of the subregion.

-> TextIter

end_: the end of the subregion.

-> m () 

Adds the subregion delimited by start_ and end_ to region.

getBounds

regionGetBounds Source #

Arguments

:: (HasCallStack, MonadIO m, IsRegion a) 
=> a

region: a Region.

-> m (Bool, TextIter, TextIter)

Returns: True if start and end have been set successfully (if non-Nothing), or False if the region is empty.

Gets the start and end bounds of the region.

getBuffer

regionGetBuffer Source #

Arguments

:: (HasCallStack, MonadIO m, IsRegion a) 
=> a

region: a Region.

-> m (Maybe TextBuffer)

Returns: the TextBuffer.

No description available in the introspection data.

getStartRegionIter

regionGetStartRegionIter Source #

Arguments

:: (HasCallStack, MonadIO m, IsRegion a) 
=> a

region: a Region.

-> m RegionIter 

Initializes a [structregionIter] to the first subregion of region.

If region is empty, iter will be initialized to the end iterator.

intersectRegion

regionIntersectRegion Source #

Arguments

:: (HasCallStack, MonadIO m, IsRegion a, IsRegion b) 
=> a

region1: a Region, or Nothing.

-> Maybe b

region2: a Region, or Nothing.

-> m (Maybe Region)

Returns: the intersection as a Region object.

Returns the intersection between region1 and region2.

region1 and region2 are not modified.

intersectSubregion

regionIntersectSubregion Source #

Arguments

:: (HasCallStack, MonadIO m, IsRegion a) 
=> a

region: a Region.

-> TextIter

start_: the start of the subregion.

-> TextIter

end_: the end of the subregion.

-> m (Maybe Region)

Returns: the intersection as a new Region.

Returns the intersection between region and the subregion delimited by start_ and end_.

region is not modified.

isEmpty

regionIsEmpty Source #

Arguments

:: (HasCallStack, MonadIO m, IsRegion a) 
=> a

region: a Region, or Nothing.

-> m Bool

Returns: whether the region is empty.

Returns whether the region is empty.

A Nothing region is considered empty.

new

regionNew Source #

Arguments

:: (HasCallStack, MonadIO m, IsTextBuffer a) 
=> a

buffer: a TextBuffer.

-> m Region

Returns: a new Region object for buffer.

No description available in the introspection data.

subtractRegion

regionSubtractRegion Source #

Arguments

:: (HasCallStack, MonadIO m, IsRegion a, IsRegion b) 
=> a

region: a Region.

-> Maybe b

regionToSubtract: the Region to subtract from region, or Nothing.

-> m () 

Subtracts regionToSubtract from region.

regionToSubtract is not modified.

subtractSubregion

regionSubtractSubregion Source #

Arguments

:: (HasCallStack, MonadIO m, IsRegion a) 
=> a

region: a Region.

-> TextIter

start_: the start of the subregion.

-> TextIter

end_: the end of the subregion.

-> m () 

Subtracts the subregion delimited by start_ and end_ from region.

toString

regionToString Source #

Arguments

:: (HasCallStack, MonadIO m, IsRegion a) 
=> a

region: a Region.

-> m (Maybe Text)

Returns: a string represention of region. Free with free when no longer needed.

Gets a string represention of region, for debugging purposes.

The returned string contains the character offsets of the subregions. It doesn't include a newline character at the end of the string.

Properties

buffer

The TextBuffer. The Region has a weak reference to the buffer.

constructRegionBuffer :: (IsRegion o, MonadIO m, IsTextBuffer a) => a -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “buffer” property. This is rarely needed directly, but it is used by new.

getRegionBuffer :: (MonadIO m, IsRegion o) => o -> m (Maybe TextBuffer) Source #

Get the value of the “buffer” property. When overloading is enabled, this is equivalent to

get region #buffer