简体   繁体   中英

How to detect a tag applied to a text in Gtk# TextView's?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM