GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Mon Aug 29, 2016 8:51 am

All times are UTC

Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Changing Specific Text Colour - Please Help Me!!!!
PostPosted: Tue Mar 11, 2008 1:33 am 
Familiar Face

Joined: Mon Feb 11, 2008 12:28 pm
Posts: 15
Hey guys.

Im trying to figure out how to change the color of only specific text
within a textview. kinda like syntax highlighting.

e.g "hello world?!"
does anyone know how to, lets say for example purposes, only change the colour of "?!" of the above text.

i know how to change the colour of the all text within the textview:

GdkColor color;
gdk_color_parse ("orange", &color);
gtk_widget_modify_text (textview, GTK_STATE_NORMAL, &color);

but this is not what i want and i cant seem to find anything that helps me.

id appreciate any feedback ASAP. i need this working in two days

Thanks a mill

 Post subject:
PostPosted: Tue Mar 11, 2008 3:48 am 
GTK+ Guru

Joined: Thu Jun 21, 2007 1:52 pm
Posts: 198
Location: Wilkes Barre Pa
What you want to do is use pango for this now i am not exactly sure what functions you could use to make this easier but ill give a general idea how you could do this.

Write some c code to open a file then iterate threw the file applying your text style on each character, word, etc until you receive a EOF signal then send the text with your text style applied to your textwidget.

Or while the file is loaded in a textview you could select a character, word or words with your mouse have a button that would apply a style. ... ormat.html ... jects.html

You could also look at the gtkdemos theres a rtf example or see here for some tutorials.

 Post subject: Inserting text on a GtkTextview with colors, styles
PostPosted: Tue Mar 25, 2008 10:46 pm 
Familiar Face

Joined: Tue Mar 25, 2008 9:41 pm
Posts: 7
Check the Examples section, I just posted an example showing how to insert text with colors, styles to a GtkTextview widget

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC

Who is online

Users browsing this forum: Yahoo [Bot] and 5 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group