Re: tab stops in different positions on different lines with GtkSourceView (or GtkTextView)
Stéphan Kochen <[email protected]>
| Newsgroups | gmane.comp.gnome.devtools |
|---|---|
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Adam Tertial schreef: > --- Stéphan Kochen <[email protected]> wrote: >> Adam Tertial schreef: >>> --- Paolo Borelli <[email protected]> wrote: >>>> On mar, 2007-01-09 at 22:37 +0000, Adam Tertial >>>> wrote: >>>>> Hi >>>>> >>>>> I want to do something a little unusual with >>>>> GtkSourceView (or failing that GtkTextView) - >> have >>>> tab >>>>> stops in different positions on different lines >>>>> ("paragraphs"). An example might be to have the >>>> first >>>>> line have tab stops at 4, 7, 13, 16 while the >>>> second >>>>> line has tab stops at 5, 10, 14, 17. >>>>> >>>>> Is this possible in any way? - I can't see >>>> anything >>>>> apart from gtk_source_view_set_tabs_width(), and >>>> that >>>>> only takes a pointer to the control and one >> guint. >>>>> gtk_text_view_set_tabs () >>>> >From the API docs of GtkTextView: >>>> >>>> "void gtk_text_view_set_tabs >>>> (GtkTextView *text_view, >>>> >>>> PangoTabArray *tabs); >>>> >>>> Sets the default tab stops for paragraphs in >>>> text_view. Tags in the >>>> buffer may override the default." >>>> >>>> So it seems to imply that it is possible to do >> what >>>> you want with >>>> tags... dunno the details though :) >>> Yeah, I saw that, but can this be applied to a >>> GtkSourceView control somehow? >> I believe GtkSourceView is a subclass of >> GtkTextView. So it'd simply be: >> gtk_text_view_set_tabs (GTK_TEXT_VIEW >> (yoursourceview), yourtabs); > > Perfect! :) > >> However, this only sets the default tabs. > > What do you mean by "default tabs" and why would that > be a problem? It sets the tab spacing for the entire TextView. So if the TextBuffer doesn't have any TextTags overriding the tab spacing, it falls back to that default. It's not really a problem, but it's not what you were aiming for either. If you want specific regions to have different tab spacing, you have to use TextTags. >> According to the documentation, you can create a >> tag, and set the "tabs" >> and "tabs-set" properties on it: >> > http://developer.gnome.org/doc/API/2.0/gtk/GtkTextTag.html#GtkTextTag--tabs >> Then just apply it to a region in the buffer. > > Ahh, good stuff - thanks for the info! Anytime. :) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFFper9cFUq0gzqDwQRApK9AKDf494XX4d2Ne2m8ggMvuhYNGR/YwCeJKan ilWMj7mD7rXgpHhPPm/tnvU= =Hu5V -----END PGP SIGNATURE-----