I am programming a very simple text editor component for a personal project. It supports bold, italic, underline, righ, center, left and fill justification... so far so god. Using TextControl.Buffer.ApplyTag( tag, start, end )
, you press the button once, and the selected text portion becomes bold or whatever. If you press the button again, the bold format should disappear.
The problem is to detect tags 开发者_开发百科and then remove them, so the format disappears. I know I can use TextControl.Buffer.RemoveAllTags( start, end );
in order to remove all tags, and this.TextControl.Buffer.RemoveTag( tag, start, end );
in order to remove a specific tag. But I am looking for a function such as:
TextTag[] GetTags(TextIter start, TextIter end);
... so I can detect which tags have been applied to a specific selection, but I am not finding that function in the documentation of Gtk.TextView nor anywhere else. Does anybody know about this?
You want the TextIter.Tags
read-only property. It gives you a list of tags the apply to a single point, not a range. A range is more complicated, since a tag might apply to only half of a range. You'll probably have to write that yourself if you want it.
精彩评论