GNOME Bugzilla – Bug 119922
cursor color should change when foreground & background color do
Last modified: 2005-01-14 17:49:11 UTC
Description of Problem: When I change the background color to BLACK, and the foreground color to whatever color (like red), then I can't navigate my text because the cursor has merged with background because the cursor color is always black. I did that configuration so gedit looked like a terminal,and I could rest my eyes ;). PROBLEM: Cursor color is ALWAYS BLACK, so if I change my background color to black, then I have no cursor. SOLUTION: The cursor MUST take automatically the color of the currently foreground color. Another bigger solution is to let the user choose the cursor color (like back and foreground),but I prefer better the first and lightweight solution. Steps to reproduce the problem: 1.change background color to Black (prefer->Editor->color) 2.change foreground color to whatever color,like red... 3.Try navigate text,,it's very difficult since you don't know what exactly the cursor is. Actual Results: Cursor stays in black color so it's merged with background. Expected Results: Cursor gets the foreground color. How often does this happen? Always you reproduce it. Additional Information: I have Gedit 2.0.2
The solution is "obvious," in the sense of being well documented, but it isn't "pretty," in the sense of being good. Currently the only way to do this is to create a mini-rc file inside the source and modify the "cursor-color" style attribute therewith on-the-fly. Nasty stuff, but it's pretty common and not incredibly expensive. In my preliminary implementation, the transition between common ("Use system colors" checked) and user-defined (unchecked) is rough. For long-term use, however, the implementation may be adequate.
Created attachment 19239 [details] [review] preliminary patch to address cursor color changes
Adding PATCH keyword and setting priority to high because of the patch.
*** Bug 116915 has been marked as a duplicate of this bug. ***
Eric: as I told you on IRC, I don't like this patch very much. We will be able to solve this problem when gtk+ will provide a function to change the color of the cursor. There is already a bug report against gtk+ requesting such new function.
Removing PATCH keyword and setting priority to Normal
Eric: since this bug is still not fixed in gtk+, I'm changing my mind about your patch (for gedit 2.5.x). May you please rewrite it by creating a function void gedit_view_modify_cursor_color (GeditView *view, GdkColor *color); with a big /* FIXME: this is a workaround waiting for bug #XXXX. Please, rewrite it when the bug will be finally fixed in gtk+ */ Thanks, Paolo
Eric: giving a look to you patch I have seen a problem. You should be able to change the color of the cursor on a per-view basis. You cannot do it with your patch. I think the only solution is to write a patch for GtkTextView. I have given a look at the code, it should not be too difficult.
From bug #79585: ------- Additional Comments From Owen Taylor 2004-02-29 11:34 ------- You *can* manage to change the cursor color by setting a name on the widget and using gtk_rc_parse_string(). Not nice at all though.
Created attachment 29587 [details] [review] Semi-working patch This patch seems to work quite well, but for some weird reason does not change the color of the cursor of the first document. Before committing the patch we should change it so that it modifies the cursor-secondary-color too.
*** Bug 151409 has been marked as a duplicate of this bug. ***
This appears to be fixed now: I'm using a black-background theme and the cursor comes up in a sort of yellow-ish colour (as it does in GtkEntrys).
What GTK+ version are you on? regs, Chris
*** Bug 156049 has been marked as a duplicate of this bug. ***
This has been requested in Debian too, this is Debian bug <http://bugs.debian.org/283158>.
Paolo, the patch you have proposed does not change cursor color for first document because: when gedit_view_modify_cursor_color() is called to modify the cursor color, for first document its just picking the color that was previously set. However, call to gtk_rc_parse_string sets curosr color, which is used by subsequent documents. Base-line is: First document always lags behind with the current changes. I could not figure out why gtk_rc_parse_string is not changing the cursor color for the first time itself. I have a fix, though it looks quite nascent. I am looking at ways to improve this fix. Even call to gtk_rc_parse_string() twice is not doing the job, thats what is annoying me. I am looking if there is any gtk function which would make all widgets use the recent changes in their properties, something like refresh to reflect recent changes.
Created attachment 34857 [details] [review] Patch to change the cursor color of first document.
Created attachment 36011 [details] [review] updated patch this is an updated versions of paolo's patch: it applies ceanly to current cvs HEAD, has some minor cleanups and most importantly adds gtk_widget_reset_rc_styles (GTK_WIDGET (view->priv->text_view)) to the gedit_view_modify_cursor_color(), so that the cursor color is updated also for the first view[1]. [1]: don't ask me why, but it does work :)
fixed in cvs head