Releases now being kept at https://github.com/demonnic/fText/releases.
I'm keeping the xml package for this on my github at https://github.com/demonnic/MiscMudlet under the name fText.xml .
I've moved the documentation to the wiki. Updating the forum post is a pain in the butt, and I just feel more comfortable trying to document and give examples for this sort of thing on the wiki. So, for documentation, go here: https://github.com/demonnic/fText/wiki
Some of you may be familiar with this thing I made a while back for formatting text. I named it 'align' and wrote it completely in the global namespace which, looking back, I regret. Someone recently asked about some updates to it, and I looked over the code, and I was embarrassed. So I rewrote the whole thing, and included word wrapping of a sort.
It also has a reusable formatter object, which keeps internal track of its formatting options so you can use it to format any text the same way over and over.
It now also has a tablemaker, allowing you to make spreedsheat like tables to display information in a miniconsole or in your main console.
Now! It has some limitations. You shouldn't try to control the color inside of the string you're formatting if you're going to do wordwrapping yet. I intend to do that eventually but right now it just isn't going to work very well. I provide options for coloring the caps, spacers, and text in the meantime. And I'm only stripping the c| form of hex coloring from strings for the purposes of determining the string's actual length... I haven't figured out the pattern for doing that and # both yet. I imagine that will go in around the same time as I handle maintaining color instructions inside the string being passed for formatting.
And now, some pictures just generally showing what it can do.
fText, the text formatting library
Re: fText(), the next iteration of align()
I have updated this, though I have not really changed the underlying functionality. I have however now included a reusable TextFormatter object. You create it using demonnic.TextFormatter:new(tableOfOptions) . In this case, the tableOfOptions should be the same as the second argument to the align/fText line of functions, and will be reused for formatting. You then use the format(stringToFormat) function of the newly created object to get back a formatted message. So for instance, the code
produces the following:
If you were to then do
You would get:
I have included functions to set all the valid options for the align/ftext functions. You can also view or set the options of the formatter directly in the options table it holds, for example:
However, I recommend using the set functions which provide type checking and more error handling.
Re: fText(), the next iteration of align()
I have updated this. It now also include a table maker!
Check it out here: https://github.com/demonnic/fText/wiki/ ... r-examples
Check it out here: https://github.com/demonnic/fText/wiki/ ... r-examples
Re: fText, the text formatting library
New update, adds setCell for the TableMaker, and deleteRow/deleteColumn.
It also allows you to use functions for cell entries, so long as those functions return cells.
Also, I do not deepcopy the tables added via TableMaker:addRow(), which means if you update the original table, the value in the TableMaker will change. IE
It also allows you to use functions for cell entries, so long as those functions return cells.
Also, I do not deepcopy the tables added via TableMaker:addRow(), which means if you update the original table, the value in the TableMaker will change. IE
Re: fText, the text formatting library
New Update! This one won't work unless you use the latest development snapshot from https://make.mudlet.org/snapshots or wait for Mudlet 4.1 for the new functions I'm relying on for the functionality, but now you can embed echoLink and echoPopup output in the table, allowing for the easier creation of interactive miniconsole interfaces. Brief demo video: https://youtu.be/_XnaJlkI7WM
The code that makes the first plaintext table is:
The code that makes the first plaintext table is:
And the code to turn it into the popup/link version in the second part of the video:
So if you want to use an echoLink, you pass a table for the row instead of a string. {"this is the message", [[send("sit")]], "sit"} . You construct the table the same way you would the parameters to echoLink. Same with if you want to use a popup, {"this is the message", {[[send("sit")]], [[send("stand")]]}, {"sit", "stand"}}
Re: fText, the text formatting library
This looks awesome.
Thanks!
Thanks!
Re: fText, the text formatting library
New release located at https://github.com/demonnic/fText/releases/latest
I was writing tests for fText to test my LuaUnit hacks and discovered a major bug in fText with left/right aligned text being 1 character too short.
This and future released of fText will have to pass the unit tests before they make it out to you fine folks. Sorry to anyone who'd been tripped up by this error on my part!
I was writing tests for fText to test my LuaUnit hacks and discovered a major bug in fText with left/right aligned text being 1 character too short.
This and future released of fText will have to pass the unit tests before they make it out to you fine folks. Sorry to anyone who'd been tripped up by this error on my part!
Re: fText, the text formatting library
Thanks for this, it looks awesome. I'm new to Lua programming.
I tried to change the color using a hex string:
I tried to change the color using a hex string:
But it didn't change the color. Is there a way to specify CAP color in fText via hex strings?
Re: fText, the text formatting library
if you set formatType to 'h' then it should be setup for hex colors then