I’ve been looking into writing an text translator (.rtf specifically), but I’ve encounter some problems. The crux of the problem is this: The default media format for text is plain ASCII.
This seems to limit the usefulness of text translators because all of the fancy formatting information of most document formats will be lost. Any application that wants to support the extra formatting information will have to support the document format directly since the default media format doesn’t. It seems to me that pretty much defeats the purpose of a translator.
I guess my question is whether I’m missing something here, or if maybe we should consider picking a new (or perhaps another) default media format for text. If I haven’t made myself clear or you have any questions feel free to ask.
First off, let me just say that I am far from being an expert on this stuff. My understanding is translators didn’t really get used for much except media type stuff (I remeber Jace saying that he had been looking text translators and couldn’t really find any examples). That would lead me to believe that the current design may be a bit underdeveloped (i.e. you might not be missing anything). Perhaps the translator should return some sort of html-like format.
Ideally whatever new format we decide to use would support everything that each format we have a translator for supports. Since this isn’t practical, what do people think would be a good choice for a default (unofficial maybe?) media format?
If we use something that already exists it seems that it should be something that is well defined and open. HTML was mentioned, that seems like it might be a reasonable choice. I haven’t looked at the specs for very many formats, what do people think of Abiword or OpenOffice formats?
The other option would be to create our own, which gives us the advantage of being able to support any features we want, it does however seem like it’s maybe more work than it’s worth.
Anyway, what does everybody think about this? Text translators could be an incredibly useful tool, especially with a BFancyTextView or something to support all of the formatting.
The default text translator format is BeOS’s styled text format (B_STYLED_TEXT_FORMAT):
- UTF8 encoded text
- simple style runs (font family, style, size, shear and face + color), which is optional.
This format is native to the BTextView widget…
Not as powerfull as you (and me!) may want, but at least it’s better than just plain text or, worst, plain ASCII text
And should allow some simple but good html/rtf/whatever text format translators.
Check your /boot/develop/headers/be/translation/TranslatorFormats.h file for more detailed info about TranslatorStyledText* structs defined there.