kText

by Keeth
A text handling library to replace/supplement Deadron.TextHandling. [More]
To download this library for your Linux/Mac installation, enter this on your command line:

DreamDownload byond://Keeth.kText##version=15

Emulator users, in the BYOND pager go to File | Open Location and enter this URL:

byond://Keeth.kText##version=15

290 downloads
Version 1.09
Date added: Aug 4 2011
Last updated: Jul 15 2012
4 fans
This library was originally meant to be vastly superior, faster, so on, to Deadron's TextHandling library. Unfortunately, in general usage, any kind of minor optimization I could do would just result in milliseconds of saved processing time. The end result was that this library provided what Deadron's does, optimized slightly (or in copytext's case, you might call it significant), and then a little bit more.

The full documentation can be found here and within the library.



r1

  • trimWhitespace was not trimming the end of the supplied string.

r2

  • Rewrote matchKeys and updated the comments for it.

r3

  • Accidently left in reference to the global kText object when rewriting matchKeys.

r4

  • autoComplete() was not searching in lists properly.

r5

  • Renamed findTextOccurrence to findWhich, which is infinitely more intuitive.

r6

  • Completely rewrote the documentation again.
  • Finished all the functions to replicate Deadron's library.
  • Library is mostly complete.

r8

  • * Removed unused code again...

r9

  • Added "find last" option to findWhich(). Supplying -1 to the "which" argument will search for the last occurrence of the substring.

    I need to include this in the readme, still... I'm lazy.




Comparison of similar functions

Deadron.TextHandling Keeth.kText Notes
dd_file2list kText.file2list Usage is 100% the same..
<no equivalent> kText.file2listCase Case-sensitive file2list.
dd_replacetext kText.replaceText Usage is 100% the same.
dd_replaceText kText.replaceTextCase Case-sensitive replace text.
Usage is 100% the same.
dd_hasprefix kText.hasPrefix Usage is 100% the same.
dd_hasPrefix kText.hasPrefixCase Case-sensitive prefix check.
Usage is 100% the same.
dd_hassuffix kText.hasSuffix Usage is 100% the same.
dd_hasSuffix kText.hasSuffixCase Case-sensitive suffix check.
Usage is 100% the same.
dd_text2list kText.text2list Usage is 100% the same.
dd_text2List kText.text2listCase Case-sensitive text to list.
Usage is 100% the same.
dd_list2text kText.list2text Usage is 100% the same.
dd_centertext kText.padText kText.padText supports centering text using the PAD_BOTH option.

The syntax is kText.padText(string, length, PAD_BOTH, " "), compared to dd_centertext(string, length).

dd_centertext cuts off any text longer than the given length, which kText.padText does not, since I don't believe that is consistent with the intent behind an attempt to center/pad text.
dd_limittext kText.limitText Usage is 100% the same.

Comments

Zaltron: (Apr 19 2012, 7:31 am)
I'll check this out and give some feedback when school gets out at the beginning of May.
Keeth: (Apr 15 2012, 3:48 am)
Rewrote the hub and documentation for the library.
If anyone has any suggestions for ways to improve it, I'm all ears.
I'd also love to see some feedback on the library itself.