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);
}
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Region.Builder<B extends Region.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionRegion
(MemorySegment address) Create a Region proxy instance for the provided memory address.Region
(TextBuffer buffer) -
Method Summary
Modifier and TypeMethodDescriptionvoid
AddsregionToAdd
to this Region.void
addSubregion
(TextIter Start, TextIter End) Adds the subregion delimited byStart
andEnd
to this Region.protected Region
asParent()
Returns this instance as if it were its parent type.static Region.Builder
<? extends Region.Builder> builder()
ARegion.Builder
object constructs aRegion
with the specified properties.boolean
Gets thestart
andend
bounds of the this Region.static MemoryLayout
The memory layout of the native struct.void
getStartRegionIter
(RegionIter iter) Initializes aRegionIter
to the first subregion of this Region.static Type
getType()
Get the GType of the Region classintersectRegion
(@Nullable Region region2) Returns the intersection between this Region andregion2
.intersectSubregion
(TextIter Start, TextIter End) Returns the intersection between this Region and the subregion delimited byStart
andEnd
.boolean
isEmpty()
Returns whether the this Region is empty.void
subtractRegion
(@Nullable Region regionToSubtract) SubtractsregionToSubtract
from this Region.void
subtractSubregion
(TextIter Start, TextIter End) Subtracts the subregion delimited byStart
andEnd
from this Region.toString()
Gets a string represention of this Region, 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, 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, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.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
-
-
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 Javasuper
keyword, 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
AddsregionToAdd
to this Region.regionToAdd
is not modified.- Parameters:
regionToAdd
- theGtkSourceRegion
to add to this Region, ornull
.
-
addSubregion
-
getBounds
Gets thestart
andend
bounds of the this Region.- Parameters:
start
- iterator to initialize with the start of this Region, ornull
.end
- iterator to initialize with the end of this Region, ornull
.- Returns:
true
ifstart
andend
have been set successfully (if non-null
), orfalse
if the this Region is empty.
-
getBuffer
-
getStartRegionIter
Initializes aRegionIter
to the first subregion of this Region.If this Region is empty,
iter
will 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 byStart
andEnd
.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
null
this Region is considered empty.- Returns:
- whether the this Region is empty.
-
subtractRegion
SubtractsregionToSubtract
from this Region.regionToSubtract
is not modified.- Parameters:
regionToSubtract
- theGtkSourceRegion
to subtract from this Region, ornull
.
-
subtractSubregion
-
toString
Gets a string represention of this 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.
-
builder
ARegion.Builder
object constructs aRegion
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withRegion.Builder.build()
.
-