After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 733606 - Line Numbers seems as part of the text editor content
Line Numbers seems as part of the text editor content
Status: RESOLVED FIXED
Product: gtksourceview
Classification: Platform
Component: General
3.13.x
Other Linux
: Normal normal
: ---
Assigned To: GTK Sourceview maintainers
GTK Sourceview maintainers
Depends on: 735368
Blocks:
 
 
Reported: 2014-07-23 15:00 UTC by alex diavatis
Modified: 2014-08-26 12:30 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Number lines seems as part of the text editor content (450.35 KB, image/png)
2014-07-23 15:00 UTC, alex diavatis
  Details
Left padding (440.45 KB, image/png)
2014-07-23 15:30 UTC, alex diavatis
  Details
Set line-numbers background for classic and tango (1.88 KB, patch)
2014-08-24 20:36 UTC, Sébastien Wilmet
none Details | Review

Description alex diavatis 2014-07-23 15:00:27 UTC
Created attachment 281484 [details]
Number lines seems as part of the text editor content

When you work in a script with gEdit you obviously want to enable the "Display Line Numbers" option.

The problem is that the numbers on the left side seem like normal content of your script, and that brings confusion. 

Some solution: Add a background color (eg a grey), make Number fonts different (eg color, size) and add some more padding from the normal content of the editor.

I'm not sure if this was the case in 3.12 as well :)
Comment 1 alex diavatis 2014-07-23 15:08:08 UTC
Some themes have a background in Line Number, but it doesn't totally solve the issue, because of the same font and the small padding.
Comment 2 Sébastien Wilmet 2014-07-23 15:15:39 UTC
We can add a background color for the classic and tango style schemes. I think the background is sufficient to know that the line numbers are not part of the contents.
Comment 3 Sébastien Wilmet 2014-07-23 15:20:36 UTC
The colors for classic and tango are actually taken from the gtk+ theme. So it should probably be fixed in Adwaita.
Comment 4 alex diavatis 2014-07-23 15:30:10 UTC
Created attachment 281485 [details]
Left padding

Even if you don't use the line numbering, I think that a small left padding would be still useful. 

I'm attaching Bracket's padding as an example.
Comment 5 Sébastien Wilmet 2014-07-23 15:43:16 UTC
Left padding without a background color is difficult to differentiate from indentation. In the Bracket's screenshot, we can think that all the code is indented with one space.
Comment 6 alex diavatis 2014-07-23 15:59:28 UTC
(In reply to comment #5)
> Left padding without a background color is difficult to differentiate from
> indentation. In the Bracket's screenshot, we can think that all the code is
> indented with one space.

Bijiben also uses a left padding, which I think it works okay. Mockups[1] show gEdit with left padding too. 

[1] https://github.com/gnome-design-team/gnome-mockups/tree/master/gedit
Comment 7 Sébastien Wilmet 2014-08-15 16:26:43 UTC
Here is an attempt to fix this bug:
https://git.gnome.org/browse/gtksourceview/log/?h=wip/gutter-style

The problem is that the classic and tango style schemes don't define the 'line-numbers' style (especially the background color).

classic and tango have already other gray colors defined, for example for 'current-line', 'draw-spaces', 'right-margin', etc. So defining 'line-numbers' too should not be a big problem. Or Adwaita could define all these colors, but it is specific to GtkSourceView.

The problem is that defining 'line-numbers' without defining 'text' is currently not possible. The problem is that the line-numbers style is applied to the whole GtkTextView with gtk_widget_override_color() and gtk_widget_override_background_color(). It relies on the 'text' style to be applied with CSS on the main GtkTextView region, which overrides the line-numbers style.

The small problem is that this hack has repercussions in the gutter renderers. To retrieve the foreground color, they call gtk_widget_get_style_context() on the text view, followed by gtk_style_context_get_color() (it is done at least in gtksourcegutterrenderertext.c).

A solution is to define a default value for the GtkSourceGutterRenderer:background-rgba property and create a :foreground-rgba property. The default value would be the 'line-numbers' style if set, or the text view style as a fallback. By doing this, a renderer can use those colors directly. (Currently :background-rgba is not set by default.)
Comment 8 Sébastien Wilmet 2014-08-24 20:36:58 UTC
Created attachment 284357 [details] [review]
Set line-numbers background for classic and tango

To better distinguish the text from the line numbers.

 #e5e5e0 seems a good value. A gray too dark is ugly, and a gray too
light is difficult to see. The blue component (e0) is a bit darker, like
for the other gray colors defined in classic.

Another possibility is to have a lighter gray background, with a
vertical line (same colors as the right margin). Or just a white
background with a vertical line.
Comment 9 Paolo Borelli 2014-08-25 09:53:15 UTC
bug #735368 has a gtk patch that tries to restore the old behavior
Comment 10 Sébastien Wilmet 2014-08-26 12:30:04 UTC
Fixed with CSS. It'll be available for GNOME 3.14.