Class PropertiesSyntaxHighlighter

java.lang.Object
io.github.zhengzhengyiyi.util.highlighter.PropertiesSyntaxHighlighter
All Implemented Interfaces:
HighLighter

public class PropertiesSyntaxHighlighter extends Object implements HighLighter
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    drawHighlightedText(net.minecraft.client.gui.DrawContext context, net.minecraft.client.font.TextRenderer textRenderer, String text, int x, int y, boolean editable)
    Draws syntax-highlighted text at the specified position.
    int
    getCharIndexFromTokens(net.minecraft.client.font.TextRenderer textRenderer, String line, int targetX)
    Finds the character index in the text that corresponds to the given x-coordinate.
    int
    getTextWidth(net.minecraft.client.font.TextRenderer textRenderer, String text)
    Calculates the total width of the syntax-highlighted text.
    int
    getTextWidthUpToChar(net.minecraft.client.font.TextRenderer textRenderer, String line, int charIndex)
    Calculates the text width from the beginning of the line up to the specified character index.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PropertiesSyntaxHighlighter

      public PropertiesSyntaxHighlighter()
  • Method Details

    • getCharIndexFromTokens

      public int getCharIndexFromTokens(net.minecraft.client.font.TextRenderer textRenderer, String line, int targetX)
      Description copied from interface: HighLighter
      Finds the character index in the text that corresponds to the given x-coordinate.
      Specified by:
      getCharIndexFromTokens in interface HighLighter
      Parameters:
      textRenderer - the text renderer for measuring text width
      line - the text line to search in
      targetX - the target x-coordinate in pixels
      Returns:
      the character index at or before the target x-coordinate
    • getTextWidthUpToChar

      public int getTextWidthUpToChar(net.minecraft.client.font.TextRenderer textRenderer, String line, int charIndex)
      Description copied from interface: HighLighter
      Calculates the text width from the beginning of the line up to the specified character index.
      Specified by:
      getTextWidthUpToChar in interface HighLighter
      Parameters:
      textRenderer - the text renderer for measuring text width
      line - the text line to measure
      charIndex - the character index to measure up to (exclusive)
      Returns:
      the width in pixels of the text from start to the specified character index
    • drawHighlightedText

      public void drawHighlightedText(net.minecraft.client.gui.DrawContext context, net.minecraft.client.font.TextRenderer textRenderer, String text, int x, int y, boolean editable)
      Description copied from interface: HighLighter
      Draws syntax-highlighted text at the specified position.
      Specified by:
      drawHighlightedText in interface HighLighter
      Parameters:
      context - the draw context used for rendering
      textRenderer - the text renderer for measuring and drawing text
      text - the text to be highlighted and drawn
      x - the x-coordinate of the starting position
      y - the y-coordinate of the starting position
      editable - whether the text is in an editable context, which may affect color scheme
    • getTextWidth

      public int getTextWidth(net.minecraft.client.font.TextRenderer textRenderer, String text)
      Description copied from interface: HighLighter
      Calculates the total width of the syntax-highlighted text.
      Specified by:
      getTextWidth in interface HighLighter
      Parameters:
      textRenderer - the text renderer for measuring text width
      text - the text to be measured
      Returns:
      the total width in pixels of the highlighted text