Class GuideText

java.lang.Object
net.ixdarklord.folios.api.client.page.GuideText

public final class GuideText extends Object
Text written for a book, set out in lines to a width. It is a small part of Markdown, so long text reads well in a JSON file:
  • A line is a line; an empty line starts a new paragraph.
  • # Heading and ## Smaller heading; --- alone is a dividing rule.
  • - item (or * item) is a bullet, 1. item a numbered one; two spaces before nest it.
  • > text is set apart as a note.
  • **bold**, *italic* (or _italic_), __underlined__, ~~struck~~, `code`.
  • [label](target) links to an entry (entry:id, entry:id#anchor or the bare id), a category (category:id) or a web page (https://...).
  • {#FF8800}coloured{/} colours text; {key:key.jump} names the key bound to something.
  • A backslash keeps the next character as it is: \*.
Any text that is a translation key is translated first, so a book can keep its words in lang files.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    What a line is part of, which decides how it is drawn.
    static final record 
    One line, at (x, y) from the text's top left.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final String
    The insertion text of a link's characters starts with this; the rest is where it goes.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    draw(GuidePainter painter, int x, int y)
    Draws the text with its top left at (x, y), its links pressable.
    int
    From the top of the first line to the bottom of the last.
    static net.minecraft.network.chat.Component
    One line of marked-up text (a title or a label) as a component; block marks are kept as written.
    boolean
     
     
    static GuideText
    of(net.minecraft.client.gui.Font font, String raw, int width)
    Reads marked-up text and sets it out in lines no wider than width.
    static String
    Text without its marks, for searching.
    static String
    The text a raw string stands for: its translation if it is a translation key, otherwise itself.
    split(int firstHeight, int nextHeight)
    Splits the text into pieces that fit: the first firstHeight tall, the rest nextHeight.
    int
    The width it was set out to.
    int
    width(net.minecraft.client.gui.Font font)
    The widest line.

    Methods inherited from class Object

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

    • LINE_HEIGHT

      public static final int LINE_HEIGHT
      See Also:
  • Method Details

    • lines

      public List<GuideText.Line> lines()
    • height

      public int height()
      From the top of the first line to the bottom of the last.
    • width

      public int width()
      The width it was set out to.
    • isEmpty

      public boolean isEmpty()
    • resolve

      public static String resolve(String raw)
      The text a raw string stands for: its translation if it is a translation key, otherwise itself.
    • inline

      public static net.minecraft.network.chat.Component inline(String raw)
      One line of marked-up text (a title or a label) as a component; block marks are kept as written.
    • plain

      public static String plain(String raw)
      Text without its marks, for searching.
    • of

      public static GuideText of(net.minecraft.client.gui.Font font, String raw, int width)
      Reads marked-up text and sets it out in lines no wider than width.
    • split

      public List<GuideText> split(int firstHeight, int nextHeight)
      Splits the text into pieces that fit: the first firstHeight tall, the rest nextHeight. A heading is never left alone at the foot of a piece. Each piece's lines start again at y 0.
    • draw

      public void draw(GuidePainter painter, int x, int y)
      Draws the text with its top left at (x, y), its links pressable.
    • width

      public int width(net.minecraft.client.gui.Font font)
      The widest line.