mmartin has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I'm doing a "Help Topics" type menu in my Gtk2 script... I created a plain text file containing all the help data I wanted to include.
But after reading all the documentation I could find for applying "TextTags" to text data to create rich formatted text, it seems to be
somewhat complicated and "wordy" (*if that makes sense)...

By having to do the following to just create, say a bold Title, seems like a bit much... And since my "Help" txt file has about 120 lines
this looks like it will get a bit bloated after a bit.
# Already created: Window, ScrolledWindow, TextView, TextBuffer, etc.. # Create a Large Bold Title for the TextView using a tag: $buffer->create_tag( "main-heading", weight => "900", size => 15 * PANGO_SCALE ); $help_buffer->insert_with_tags_by_name($iter, "\t\t$Program_Name\n\n", + "main-heading");
So I was thinking to have to do the above for every few lines when the type of 'style' changes seems overly "wordy" and might take up more
lines then the actual text file itself. The Text File is somewhat like a Multi-Level Bulleted list with new headings every so often, and italic
text for comments, etc...

Does anyone know if this is possible for me to do inside a TXT file and have it displayed in a TextView widget which would include the Marked-up text..?

If anyone any can help with this, that would be great...
I'm really hoping to avoid having to use LOTS of "insert_with_tags_by_name()" Function calls.


Thanks in Advance,
Matt

  • Comment on Perl Gtk2, Possible to use TextTags/Markup within a Txt File Itself?
  • Download Code

Replies are listed 'Best First'.
Re: Perl Gtk2, Possible to use TextTags/Markup within a Txt File Itself?
by mmartin (Monk) on Aug 26, 2013 at 21:19 UTC
    While I was waiting to see if the answer to my question was possible, I decided to just start doing it the "regular" way
    just in-case you guys came back saying that it wasn't possible...

    And right about now I'm just finishing up with this...
    It ended up being about 120+ extra lines of code to implement this but now that I'm done with this I think I'll just keep
    it the way it is, no matter what the answer would be...


    Thanks Anyways...

    Thanks,
    Matt