Sponge pagination service - format text into table-like structure


#1

Does sponge support this feature?

Lets say i would like to display a "text table" where "columns" will adjust width according to logest string in any row.

Since its a bit hard to explain lets have a simple example.

Table 1

text1 text2 tttext3
text1 a b

Formated Table

text1 text2 tttext3
text1 a     b

#2

Whether it's tabled or not will entirely depend on what font is being used. Even if it's the default one, the letters are not monowidth, and therefore it is difficult to perfectly line up text, and involves special space characters which may not display on all systems.


#3

This looks promising: https://forums.spongepowered.org/t/chat-ui-a-ui-toolkit-for-the-vanilla-chat-box/10109


#4

And supports Unicode? :slight_smile:


#5

If it's ingame it's completely possible unless a mod or resource pack is changing the font.


#6

As @RandomByte suggested, my ChatUI plugin should be able to render a table like you wanted.

The 'force unicode' option currently breaks the plugin but I am working to improve support.

Edit:
I just made a quick example.
It renders outside of the framework i.e. creates a standalone Text object instead of drawing to a Tab

TableModel model = new SimpleTableModel(new Object[][] {
        {"text1", "text2", "tttext3"},
        {"text1", "a", "b"}
});
TableRenderer renderer = new BorderlessTableRenderer();
TableUI table = new TableUI(model, renderer);
// Hard coded because we're rendering outside of the framework
PlayerContext ctx = new PlayerContext(this.player, 320, 10, false);
this.player.sendMessage(table.draw(ctx));