# Cursor-color in a Gtk::TextView

**URL:** <https://www.ruby-forum.com/t/cursor-color-in-a-gtk-textview/82432>\
**Category:** Ruby-Gnome 2\
**Created:** [January 19, 2007, 4:30pm UTC](https://www.ruby-forum.com/t/cursor-color-in-a-gtk-textview/82432 "2007-01-19T16:30:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mac\_Tuitui](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47774/32.png) [@Mac\_Tuitui](https://www.ruby-forum.com/u/Mac_Tuitui)\
**Post date:** [January 19, 2007, 4:30pm UTC](https://www.ruby-forum.com/t/cursor-color-in-a-gtk-textview/82432/1 "2007-01-19T16:30:21Z")

</div>

Hello everyone,

My name is Alexis Andre, and I have been using ruby-gnome2 to develop  
simple apps. The only one that I made public can be found at  
[http://duby.rubyforge.org](http://duby.rubyforge.org) . It is a clone of filelight.

I tried to post the following yesterday but it was refused without a  
reason, so I hope I am doing the right thing in subscribing to the list.  
If not, please forgive my stubbornness.

I am using a TextView widget in a really simple text editor, and I  
changed the background to black, and the text to green. The problem is  
that the cursor stays black, so I can not see it anymore!

I could not find a method to specify the cursor-color neither in  
Gtk::Widget nor in Gtk::TextView.  
In gtkwidget.c, however, the possibility to change the cursor-color is  
available. What have I done wrong? Am I missing a method?

Thanks in advance.

Here is a sample:

require ‘gtk2’  
Gtk.init  
window = Gtk::Window.new(“Editor”)  
window.set\_default\_size(400,400)  
window.signal\_connect(“destroy”) do Gtk.main\_quit end

view = Gtk::TextView.new  
view.wrap\_mode=Gtk::TextTag::WRAP\_WORD  
sw = Gtk::ScrolledWindow.new(nil, nil)  
sw.set\_policy(Gtk::POLICY\_AUTOMATIC,Gtk::POLICY\_AUTOMATIC)  
window.add(sw)  
sw.add(view)  
view.modify\_base(Gtk::STATE\_NORMAL,Gdk::Color.new(0,0,0))  
view.modify\_text(Gtk::STATE\_NORMAL,Gdk::Color.new(0,65535,0))  
window.show\_all  
Gtk.main

########  
Andre Alexis

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Mac\_Tuitui](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47774/32.png) [@Mac\_Tuitui](https://www.ruby-forum.com/u/Mac_Tuitui)\
**Post date:** [January 19, 2007, 5:34pm UTC](https://www.ruby-forum.com/t/cursor-color-in-a-gtk-textview/82432/2 "2007-01-19T17:34:19Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“[ruby-gnome2-devel-en] cursor-color in a Gtk::TextView” on Sun, 14  
Jan 2007 15:08:32 +0900,  
“Mac Tuitui” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I could not find a method to specify the cursor-color neither in  
> Gtk::Widget nor in Gtk::TextView.  
> In gtkwidget.c, however, the possibility to change the cursor-color is  
> available. What have I done wrong? Am I missing a method?

You need to modify style property by RC. Add the following  
code to your script before Gtk::TextView.new:

Gtk::RC.parse\_string(\<\<-EOR)  
style “green-cursor” {  
GtkTextView::cursor-color = “green”  
}  
class “GtkWidget” style “green-cursor”  
EOR

## Thanks,

kou

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)
