Class EntryBuffer
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
PasswordEntryBuffer
GtkEntryBuffer
hold the text displayed in a GtkText
widget.
A single GtkEntryBuffer
object can be shared by multiple widgets
which will then share the same text content, but not the cursor
position, visibility attributes, icon etc.
GtkEntryBuffer
may be derived from. Such a derived class might allow
text to be stored in an alternate location, such as non-pageable memory,
useful in the case of important passwords. Or a derived class could
integrate with an application’s concept of undo/redo.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
EntryBuffer.Builder<B extends EntryBuffer.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theDeletedTextCallback
callback.static class
static interface
Functional interface declaration of theInsertedTextCallback
callback.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionEntryBuffer
(@Nullable String initialChars, int nInitialChars) Create a newGtkEntryBuffer
object.EntryBuffer
(MemorySegment address) Create a EntryBuffer proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected EntryBuffer
asParent()
Returns this instance as if it were its parent type.static EntryBuffer.Builder
<? extends EntryBuffer.Builder> builder()
AEntryBuffer.Builder
object constructs aEntryBuffer
with the specified properties.protected void
deletedText
(int position, int nChars) int
deleteText
(int position, int nChars) Deletes a sequence of characters from the buffer.void
emitDeletedText
(int position, int nChars) Used when subclassingGtkEntryBuffer
.void
emitInsertedText
(int position, String chars, int nChars) Used when subclassingGtkEntryBuffer
.long
getBytes()
Retrieves the length in bytes of the buffer.int
Retrieves the length in characters of the buffer.int
Retrieves the maximum allowed length of the text in this EntryBuffer.static MemoryLayout
The memory layout of the native struct.getText()
Retrieves the contents of the buffer.protected String
getText
(MemorySegment nBytes) static Type
getType()
Get the GType of the EntryBuffer classprotected void
insertedText
(int position, String chars, int nChars) int
insertText
(int position, String chars, int nChars) InsertsnChars
characters ofchars
into the contents of the buffer, at positionposition
.The text is altered in the default handler for this signal.This signal is emitted after text is inserted into the buffer.void
setMaxLength
(int maxLength) Sets the maximum allowed length of the contents of the buffer.void
Sets the text in the buffer.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
-
EntryBuffer
Create a EntryBuffer proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
EntryBuffer
Create a newGtkEntryBuffer
object.Optionally, specify initial text to set in the buffer.
- Parameters:
initialChars
- initial buffer textnInitialChars
- number of characters ininitialChars
, or -1
-
-
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. -
deleteText
public int deleteText(int position, int nChars) Deletes a sequence of characters from the buffer.nChars
characters are deleted starting atposition
. IfnChars
is negative, then all characters until the end of the text are deleted.If
position
ornChars
are out of bounds, then they are coerced to sane values.Note that the positions are specified in characters, not bytes.
- Parameters:
position
- position at which to delete textnChars
- number of characters to delete- Returns:
- The number of characters deleted.
-
emitDeletedText
public void emitDeletedText(int position, int nChars) Used when subclassingGtkEntryBuffer
.- Parameters:
position
- position at which text was deletednChars
- number of characters deleted
-
emitInsertedText
Used when subclassingGtkEntryBuffer
.- Parameters:
position
- position at which text was insertedchars
- text that was insertednChars
- number of characters inserted
-
getBytes
public long getBytes()Retrieves the length in bytes of the buffer.See
getLength()
.- Returns:
- The byte length of the buffer.
-
getLength
public int getLength()Retrieves the length in characters of the buffer.- Returns:
- The number of characters in the buffer.
-
getMaxLength
public int getMaxLength()Retrieves the maximum allowed length of the text in this EntryBuffer.- Returns:
- the maximum allowed number of characters
in
GtkEntryBuffer
, or 0 if there is no maximum.
-
getText
Retrieves the contents of the buffer.The memory pointer returned by this call will not change unless this object emits a signal, or is finalized.
- Returns:
- a pointer to the contents of the widget as a string. This string points to internally allocated storage in the buffer and must not be freed, modified or stored.
-
insertText
InsertsnChars
characters ofchars
into the contents of the buffer, at positionposition
.If
nChars
is negative, then characters from chars will be inserted until a null-terminator is found. Ifposition
ornChars
are out of bounds, or the maximum buffer text length is exceeded, then they are coerced to sane values.Note that the position and length are in characters, not in bytes.
- Parameters:
position
- the position at which to insert text.chars
- the text to insert into the buffer.nChars
- the length of the text in characters, or -1- Returns:
- The number of characters actually inserted.
-
setMaxLength
public void setMaxLength(int maxLength) Sets the maximum allowed length of the contents of the buffer.If the current contents are longer than the given length, then they will be truncated to fit.
- Parameters:
maxLength
- the maximum length of the entry buffer, or 0 for no maximum. (other than the maximum length of entries.) The value passed in will be clamped to the range 0-65536.
-
setText
Sets the text in the buffer.This is roughly equivalent to calling
deleteText(int, int)
andinsertText(int, java.lang.String, int)
.Note that
nChars
is in characters, not in bytes.- Parameters:
chars
- the new textnChars
- the number of characters intext
, or -1
-
deletedText
protected void deletedText(int position, int nChars) -
getText
-
insertedText
-
onDeletedText
public SignalConnection<EntryBuffer.DeletedTextCallback> onDeletedText(EntryBuffer.DeletedTextCallback handler) The text is altered in the default handler for this signal.If you want access to the text after the text has been modified, use
ConnectFlags.AFTER
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
onInsertedText
public SignalConnection<EntryBuffer.InsertedTextCallback> onInsertedText(EntryBuffer.InsertedTextCallback handler) This signal is emitted after text is inserted into the buffer.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
builder
AEntryBuffer.Builder
object constructs aEntryBuffer
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withEntryBuffer.Builder.build()
.
-