GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Changing Specific Text Colour - Please Help Me!!!!

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
angel face
Familiar Face


Joined: 11 Feb 2008
Posts: 15

PostPosted: Tue Mar 11, 2008 1:33 am    Post subject: Changing Specific Text Colour - Please Help Me!!!! Reply with quote

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:

Code: (Plaintext)
1
2
3
4
5

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
:)
Back to top
caracal
GTK+ Geek


Joined: 21 Jun 2007
Posts: 75
Location: Wilkes Barre Pa

PostPosted: Tue Mar 11, 2008 3:48 am    Post subject: Reply with quote

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.

http://library.gnome.org/devel/pango/stable/PangoMarkupFormat.html
http://library.gnome.org/devel/gtk/stable/TextWidgetObjects.html

You could also look at the gtkdemos theres a rtf example or see here for some tutorials.
http://www.gtkforums.com/viewtopic.php?t=988
Back to top
carlos
Familiar Face


Joined: 25 Mar 2008
Posts: 7

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

Check the Examples section, I just posted an example showing how to insert text with colors, styles to a GtkTextview widget
Carlos
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP