Class Region
- All Implemented Interfaces:
Proxy
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 Gtk.TextBuffer::insert-text and
Gtk.TextBuffer::delete-range signals to update the GtkSourceRegion
accordingly.
To iterate through the subregions, you need to use a RegionIter,
for example:
GtkSourceRegion *region;
GtkSourceRegionIter region_iter;
gtk_source_region_get_start_region_iter (region, ®ion_iter);
while (!gtk_source_region_iter_is_end (®ion_iter))
{
GtkTextIter subregion_start;
GtkTextIter subregion_end;
if (!gtk_source_region_iter_get_subregion (®ion_iter,
&subregion_start,
&subregion_end))
{
break;
}
// Do something useful with the subregion.
gtk_source_region_iter_next (®ion_iter);
}
buffer: GtkSource.Buffer = GtkSource.Buffer()
region: GtkSource.Region = GtkSource.Region(buffer=buffer)
region_iter = region.get_start_region_iter()
while not region_iter.is_end():
success, start, end = region_iter.get_subregion()
if not success:
break
# Do something useful with the subregion
region_iter.next()
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRegion.Builder<B extends Region.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classNested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionRegion()Creates a new Region.Region(MemorySegment address) Create a Region proxy instance for the provided memory address.Region(TextBuffer buffer) -
Method Summary
Modifier and TypeMethodDescriptionvoidAddsregionToAddtoregion.voidaddSubregion(TextIter _start, TextIter _end) Adds the subregion delimited by_startand_endtoregion.protected RegionasParent()Returns this instance as if it were its parent type.static Region.Builder<? extends Region.Builder> builder()ARegion.Builderobject constructs aRegionwith the specified properties.booleanGets thestartandendbounds of theregion.@Nullable TextBufferstatic MemoryLayoutThe memory layout of the native struct.voidgetStartRegionIter(RegionIter iter) Initializes aRegionIterto the first subregion ofregion.static @Nullable TypegetType()Get the GType of the Region class@Nullable RegionintersectRegion(@Nullable Region region2) Returns the intersection between this Region andregion2.@Nullable RegionintersectSubregion(TextIter _start, TextIter _end) Returns the intersection between this Region and the subregion delimited by_startand_end.booleanisEmpty()Returns whether the this Region is empty.voidsubtractRegion(@Nullable Region regionToSubtract) SubtractsregionToSubtractfromregion.voidsubtractSubregion(TextIter _start, TextIter _end) Subtracts the subregion delimited by_startand_endfromregion.@Nullable StringtoString()Gets a string represention ofregion,for debugging purposes.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Region
Create a Region proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
Region
-
Region
public Region()Creates a new Region.
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName(). This will call the native function pointer of this virtual method in the typeclass of the parent type. -
addRegion
AddsregionToAddtoregion.regionToAddis not modified.- Parameters:
regionToAdd- theGtkSourceRegionto add toregion,ornull.
-
addSubregion
-
getBounds
Gets thestartandendbounds of theregion.- Parameters:
start- iterator to initialize with the start ofregion,ornull.end- iterator to initialize with the end ofregion,ornull.- Returns:
trueifstartandendhave been set successfully (if non-null), orfalseif the this Region is empty.
-
getBuffer
-
getStartRegionIter
Initializes aRegionIterto the first subregion ofregion.If this Region is empty,
iterwill be initialized to the end iterator.- Parameters:
iter- iterator to initialize to the first subregion.
-
intersectRegion
-
intersectSubregion
Returns the intersection between this Region and the subregion delimited by_startand_end.this Region is not modified.
- Parameters:
_start- the start of the subregion._end- the end of the subregion.- Returns:
- the intersection as a new
GtkSourceRegion.
-
isEmpty
public boolean isEmpty()Returns whether the this Region is empty.A
nullthis Region is considered empty.- Returns:
- whether the this Region is empty.
-
subtractRegion
SubtractsregionToSubtractfromregion.regionToSubtractis not modified.- Parameters:
regionToSubtract- theGtkSourceRegionto subtract fromregion,ornull.
-
subtractSubregion
-
toString
Gets a string represention ofregion,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.
-
builder
ARegion.Builderobject constructs aRegionwith the specified properties. Use the variousset...()methods to set properties, and finish construction withRegion.Builder.build().- Returns:
- the builder object
-