Class SnippetChunk

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class SnippetChunk extends InitiallyUnowned

A chunk of text within the source snippet.

The GtkSourceSnippetChunk represents a single chunk of text that may or may not be an edit point within the snippet. Chunks that are an edit point (also called a tab stop) have the SnippetChunk:focus-position property set.

  • Constructor Details

    • SnippetChunk

      public SnippetChunk(MemorySegment address)
      Create a SnippetChunk instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • SnippetChunk

      public SnippetChunk()
      Create a new SnippetChunk.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the SnippetChunk class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected SnippetChunk asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class InitiallyUnowned
      Returns:
      the instance as if it were its parent type
    • copy

      public SnippetChunk copy()
      Copies the source snippet.
      Returns:
      A GtkSourceSnippetChunk
    • getContext

      public SnippetContext getContext()
      Gets the context for the snippet insertion.
      Returns:
      A GtkSourceSnippetContext
    • getFocusPosition

      public int getFocusPosition()

      Gets the SnippetChunk:focus-position.

      The focus-position is used to determine how many tabs it takes for the snippet to advanced to this chunk.

      A focus-position of zero will be the last focus position of the snippet and snippet editing ends when it has been reached.

      A focus-position of -1 means the chunk cannot be focused by the user.

      Returns:
      the focus-position
    • getSpec

      public @Nullable String getSpec()

      Gets the specification for the chunk.

      The specification is evaluated for variables when other chunks are edited within the snippet context. If the user has changed the text, the SnippetChunk:text and SnippetChunk:text-set properties are updated.

      Returns:
      the specification, if any
    • getText

      public String getText()

      Gets the SnippetChunk:text property.

      The text property is updated when the user edits the text of the chunk. If it has not been edited, the SnippetChunk:spec property is returned.

      Returns:
      the text of the chunk
    • getTextSet

      public boolean getTextSet()

      Gets the SnippetChunk:text-set property.

      This is typically set when the user has edited a snippet chunk.

    • getTooltipText

      public String getTooltipText()
    • setContext

      public void setContext(SnippetContext context)
    • setFocusPosition

      public void setFocusPosition(int focusPosition)

      Sets the SnippetChunk:focus-position property.

      The focus-position is used to determine how many tabs it takes for the snippet to advanced to this chunk.

      A focus-position of zero will be the last focus position of the snippet and snippet editing ends when it has been reached.

      A focus-position of -1 means the chunk cannot be focused by the user.

      Parameters:
      focusPosition - the focus-position
    • setSpec

      public void setSpec(String spec)

      Sets the specification for the chunk.

      The specification is evaluated for variables when other chunks are edited within the snippet context. If the user has changed the text, the SnippetChunk:text and SnippetChunk:text-set properties are updated.

      Parameters:
      spec - the new specification for the chunk
    • setText

      public void setText(String text)

      Sets the text for the snippet chunk.

      This is usually used by the snippet engine to update the text, but may be useful when creating custom snippets to avoid expansion of any specification.

      Parameters:
      text - the text of the property
    • setTextSet

      public void setTextSet(boolean textSet)

      Sets the SnippetChunk:text-set property.

      This is typically set when the user has edited a snippet chunk by the snippet engine.

      Parameters:
      textSet - the property value
    • setTooltipText

      public void setTooltipText(String tooltipText)
    • builder

      public static SnippetChunk.Builder<? extends SnippetChunk.Builder> builder()
      A SnippetChunk.Builder object constructs a SnippetChunk with the specified properties. Use the various set...() methods to set properties, and finish construction with SnippetChunk.Builder.build().
      Returns:
      the builder object