Patchwork hgweb: wrap long lines in file source

login
register
mail settings
Submitter Alexander Plavin
Date June 26, 2013, 8:44 a.m.
Message ID <0de0cddeac5c624189ab.1372236275@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/1750/
State Superseded
Headers show

Comments

Alexander Plavin - June 26, 2013, 8:44 a.m.
# HG changeset patch
# User Alexander Plavin <me@aplavin.ru>
# Date 1372236081 -14400
#      Wed Jun 26 12:41:21 2013 +0400
# Node ID 0de0cddeac5c624189ab8783de38d0a8b943d113
# Parent  f21a44fe66da3d66313b71015947456f5a3789cd
hgweb: wrap long lines in file source
Laurens Holst - June 26, 2013, 11:41 a.m.
Op 26-06-13 10:44, Alexander Plavin schreef:
> # HG changeset patch
> # User Alexander Plavin <me@aplavin.ru>
> # Date 1372236081 -14400
> #      Wed Jun 26 12:41:21 2013 +0400
> # Node ID 0de0cddeac5c624189ab8783de38d0a8b943d113
> # Parent  f21a44fe66da3d66313b71015947456f5a3789cd
> hgweb: wrap long lines in file source

Mmh, personally I’d prefer to see a horizontal scroll bar...

No editor does wrapping, either...

~Laurens
Laurens Holst - June 26, 2013, 12:52 p.m.
Op 26-06-13 14:17, Kevin Bullock schreef:
> On 26 Jun 2013, at 6:41 AM, Laurens Holst wrote:
>> Op 26-06-13 10:44, Alexander Plavin schreef:
>>> # HG changeset patch
>>> # User Alexander Plavin <me@aplavin.ru>
>>> # Date 1372236081 -14400
>>> #      Wed Jun 26 12:41:21 2013 +0400
>>> # Node ID 0de0cddeac5c624189ab8783de38d0a8b943d113
>>> # Parent  f21a44fe66da3d66313b71015947456f5a3789cd
>>> hgweb: wrap long lines in file source
>> Mmh, personally I’d prefer to see a horizontal scroll bar...
>>
>> No editor does wrapping, either...
> Emacs and Vim both do.

By default? For editing source code? And people actually have that enabled?

~Laurens
Jordi Gutiérrez Hermoso - June 26, 2013, 2:35 p.m.
On 26 June 2013 08:52, Laurens Holst <laurens.nospam@grauw.nl> wrote:
> By default? For editing source code? And people actually have that enabled?

Yes, yes, and yes.

- Jordi G. H.
Alexander Plavin - June 26, 2013, 2:43 p.m.
Would you really like to see smth like this:
http://aplavin.ru/2013-06-26-183449_626x1160_scrot.png, and more
important, with very inconvenient scrollbar at the very bottom of the
page? The first time I saw this it made me think about a bug in
displaying.

2013/6/26 Laurens Holst <laurens.nospam@grauw.nl>:
> Op 26-06-13 10:44, Alexander Plavin schreef:
>
>> # HG changeset patch
>> # User Alexander Plavin <me@aplavin.ru>
>> # Date 1372236081 -14400
>> #      Wed Jun 26 12:41:21 2013 +0400
>> # Node ID 0de0cddeac5c624189ab8783de38d0a8b943d113
>> # Parent  f21a44fe66da3d66313b71015947456f5a3789cd
>> hgweb: wrap long lines in file source
>
>
> Mmh, personally I’d prefer to see a horizontal scroll bar...
>
> No editor does wrapping, either...
>
> ~Laurens
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Laurens Holst - June 26, 2013, 5:07 p.m.
Op 26-06-13 16:43, Alexander Plavin schreef:
> Would you really like to see smth like this:
> http://aplavin.ru/2013-06-26-183449_626x1160_scrot.png

Of course that is not the alternative I was suggesting :).

If memory recalls, adding “overflow-x: auto” should cut off any 
exceeding text on the right, and make it horizontally scrollable.

(Ideally you would make the alternating bars span the entire scrollable 
width, but unfortunately that’s impossible without resorting to tables.)

> and more
> important, with very inconvenient scrollbar at the very bottom of the
> page? The first time I saw this it made me think about a bug in
> displaying.

Scrollbar at the bottom is a little inconvenient, sure, but you can also 
scroll horizontally with many mouse wheels, or by middle-clicking and 
moving the cursor to the right, or by moving two fingers to the right on 
a touch pad, or by selecting text and dragging to your right. The 
scrollbars are hardly ever being used any more nowadays.

I am not in favour of wrapping the source code, because that can 
visually disturb the indentation. It may not be so bad on desktop-sized 
displays, but especially on smaller screens like tablets or mobile 
phones this can render code virtually unreadable. In some languages 
(e.g. our beloved python) new lines can even significantly alter the 
meaning of code.

Emacs and vim aside, editors normally don’t wrap lines and people will 
be authoring code with this in mind. Programmers typically expect to 
exert control of where and how the lines wrap in the editor, and expect 
it to be displayed as such.

~Laurens
Alexander Plavin - June 26, 2013, 5:11 p.m.
2013/6/26 Laurens Holst <laurens.nospam@grauw.nl>:
> Op 26-06-13 16:43, Alexander Plavin schreef:
>
>> Would you really like to see smth like this:
>> http://aplavin.ru/2013-06-26-183449_626x1160_scrot.png
>
>
> Of course that is not the alternative I was suggesting :).
>
> If memory recalls, adding “overflow-x: auto” should cut off any exceeding
> text on the right, and make it horizontally scrollable.
>
> (Ideally you would make the alternating bars span the entire scrollable
> width, but unfortunately that’s impossible without resorting to tables.)
>
>
>> and more
>> important, with very inconvenient scrollbar at the very bottom of the
>> page? The first time I saw this it made me think about a bug in
>> displaying.
>
>
> Scrollbar at the bottom is a little inconvenient, sure, but you can also
> scroll horizontally with many mouse wheels, or by middle-clicking and moving
> the cursor to the right, or by moving two fingers to the right on a touch
> pad, or by selecting text and dragging to your right. The scrollbars are
> hardly ever being used any more nowadays.

I've not meant using the scrollbars, but just looking at them to see
that it's not the full width.

>
> I am not in favour of wrapping the source code, because that can visually
> disturb the indentation. It may not be so bad on desktop-sized displays, but
> especially on smaller screens like tablets or mobile phones this can render
> code virtually unreadable. In some languages (e.g. our beloved python) new
> lines can even significantly alter the meaning of code.

The line numbers and stripes help in this case :)

>
> Emacs and vim aside, editors normally don’t wrap lines and people will be
> authoring code with this in mind. Programmers typically expect to exert
> control of where and how the lines wrap in the editor, and expect it to be
> displayed as such.
>
> ~Laurens
>
Jordi Gutiérrez Hermoso - June 26, 2013, 5:21 p.m.
On 26 June 2013 13:07, Laurens Holst <laurens.nospam@grauw.nl> wrote:

> Scrollbar at the bottom is a little inconvenient, sure, but you can also
> scroll horizontally with many mouse wheels, or by middle-clicking and moving
> the cursor to the right, or by moving two fingers to the right on a touch
> pad, or by selecting text and dragging to your right. The scrollbars are
> hardly ever being used any more nowadays.

Do most users know this? If so, do we have evidence that most users
prefer this? If not, are you planning to educate them? Otherwise, do
we have any evidence that users prefer one thing or the other?

> I am not in favour of wrapping the source code, because that can visually
> disturb the indentation.

It's possible to wrap and maintain indentation; e.g. Kate does this,
as does this Emacs package:

     https://github.com/emacsmirror/adaptive-wrap-prefix/blob/elpa/adaptive-wrap-prefix.el

I'm not sure how feasible this is for a web interface.

> Emacs and vim aside, editors normally don’t wrap lines

Kate does it, gedit does it, textmate too, but apparently only
whatever editor you use doesn't.

- Jordi G. H.
Laurens Holst - June 26, 2013, 8:02 p.m.
Op 26-06-13 19:21, Jordi Gutiérrez Hermoso schreef:
> On 26 June 2013 13:07, Laurens Holst <laurens.nospam@grauw.nl> wrote:
>
>> Scrollbar at the bottom is a little inconvenient, sure, but you can also
>> scroll horizontally with many mouse wheels, or by middle-clicking and moving
>> the cursor to the right, or by moving two fingers to the right on a touch
>> pad, or by selecting text and dragging to your right. The scrollbars are
>> hardly ever being used any more nowadays.
> Do most users know this? If so, do we have evidence that most users
> prefer this? If not, are you planning to educate them?

I do not think any “special education” is needed to explain people how 
to scroll horizontally...

> Otherwise, do
> we have any evidence that users prefer one thing or the other?

No, but I tried to present arguments. Do you have evidence?

>> I am not in favour of wrapping the source code, because that can visually
>> disturb the indentation.
> It's possible to wrap and maintain indentation; e.g. Kate does this,
> as does this Emacs package:
>
>       https://github.com/emacsmirror/adaptive-wrap-prefix/blob/elpa/adaptive-wrap-prefix.el
>
> I'm not sure how feasible this is for a web interface.

Not very, I think.

Also, line breaks still have significance in some languages, this 
wouldn’t solve that.

>> Emacs and vim aside, editors normally don’t wrap lines
> Kate does it, gedit does it, textmate too, but apparently only
> whatever editor you use doesn't.

Pretty much every one of them? Eclipse, IntelliJ, Visual Studio, 
MonoDevelop, Netbeans, XCode, you name it... Even my old colleague who 
used to use Vim for sure didn’t have it set to line wrap.

I mean it makes sense for plain text documents, and I guess the editors 
you named are intended as generic text editors, but not for source code. 
If you’d be editing source code in them you’d be turning off the wrap 
option in a jiffy.

Also, fwiw, Github doesn’t wrap either, nor does Stack Overflow, nor 
does the Android documentation. Nor will anything else on the web that 
shows source code. I dare you to find a place ;P.

~Laurens
Laurens Holst - June 26, 2013, 8:08 p.m.
Op 26-06-13 19:11, Alexander Plavin schreef:
> 2013/6/26 Laurens Holst <laurens.nospam@grauw.nl>:
>>> and more
>>> important, with very inconvenient scrollbar at the very bottom of the
>>> page? The first time I saw this it made me think about a bug in
>>> displaying.
>>
>> Scrollbar at the bottom is a little inconvenient, sure, but you can also
>> scroll horizontally with many mouse wheels, or by middle-clicking and moving
>> the cursor to the right, or by moving two fingers to the right on a touch
>> pad, or by selecting text and dragging to your right. The scrollbars are
>> hardly ever being used any more nowadays.
> I've not meant using the scrollbars, but just looking at them to see
> that it's not the full width.

I see. Usually you can see this from the content, because half of a 
letter or a word is missing, or a statement isn’t complete.

But I agree it’s not 100% ideal. It would be nicer if we could get the 
background to match the overflow, so that we can use the horizontal 
scrollbar on the window without the overflow rendering. But... CSS can 
be fussy about controlling the horizontal width.

>> I am not in favour of wrapping the source code, because that can visually
>> disturb the indentation. It may not be so bad on desktop-sized displays, but
>> especially on smaller screens like tablets or mobile phones this can render
>> code virtually unreadable. In some languages (e.g. our beloved python) new
>> lines can even significantly alter the meaning of code.
> The line numbers and stripes help in this case :)

Somewhat. :)

Not enough in my opinion. I’d rather have the source presented to me 
exactly the way it is.

~Laurens
Jordi Gutiérrez Hermoso - June 26, 2013, 8:32 p.m.
On 26 June 2013 16:02, Laurens Holst <laurens.nospam@grauw.nl> wrote:

> I do not think any “special education” is needed to explain people how to
> scroll horizontally...

Of course there is. People typically don't know that a mouse wheel is
a middle click. I've had to teach this to several people. Not all
touchpads allow two-finger swipes, and on those that do, not all
people know that this is possible.

> Op 26-06-13 19:21, Jordi Gutiérrez Hermoso schreef:

>> Otherwise, do we have any evidence that users prefer one thing or
>> the other?
>
>
> No, but I tried to present arguments. Do you have evidence?

There is old research against it:

    http://www.usability.gov/pdfs/chapter8.pdf

Ten years later, there is still some flak against it:

    http://ux.stackexchange.com/questions/30623/have-the-attitude-changed-the-last-ten-years-on-horizontal-scrolling-on-web-site

    http://www.experiencesolutions.co.uk/blog/2011/12/12/a-ux-perspective-on-horizontal-scrolling/

> Also, line breaks still have significance in some languages, this wouldn’t
> solve that.

There can be clear indication of line numbers on the left side of the
display that shows that there isn't an actual hard newline here. It's
just a convenience of presentation.

>>> Emacs and vim aside, editors normally don’t wrap lines
>>
>> Kate does it, gedit does it, textmate too, but apparently only
>> whatever editor you use doesn't.
>
> Pretty much every one of them? Eclipse, IntelliJ, Visual Studio,
> MonoDevelop, Netbeans, XCode,

Ah, the IDEs scroll horizontally, the text editors don't. I see why
we're coming from different perspectives here.

> If you’d be editing source code in them you’d be turning off the
> wrap option in a jiffy.

No, I leave it on.

> Also, fwiw, Github doesn’t wrap either, nor does Stack Overflow, nor
> does the Android documentation. Nor will anything else on the web
> that shows source code. I dare you to find a place ;P.

Pastebin does:

    http://pastebin.com/fBVpnY9Q

So does Google code (line 10):

    https://code.google.com/r/darcymason-refactor/source/browse/pydicom/fileio/testfind.py?spec=svn61b7b2ba465756cc22bbc8583ddd3da67c19df58&r=61b7b2ba465756cc22bbc8583ddd3da67c19df58

- Jordi G. H.
Laurens Holst - June 26, 2013, 9:57 p.m.
Op 26-6-2013 22:32, Jordi Gutiérrez Hermoso schreef:
>> I do not think any “special education” is needed to explain people how to
>> scroll horizontally...
> Of course there is. People typically don't know that a mouse wheel is
> a middle click. I've had to teach this to several people. Not all
> touchpads allow two-finger swipes, and on those that do, not all
> people know that this is possible.

We’re talking programmers here :). It’s source control management.

>>> Otherwise, do we have any evidence that users prefer one thing or
>>> the other?
>>
>> No, but I tried to present arguments. Do you have evidence?
> There is old research against it:
>
>      http://www.usability.gov/pdfs/chapter8.pdf
>
> Ten years later, there is still some flak against it:
>
>      http://ux.stackexchange.com/questions/30623/have-the-attitude-changed-the-last-ten-years-on-horizontal-scrolling-on-web-site
>
>      http://www.experiencesolutions.co.uk/blog/2011/12/12/a-ux-perspective-on-horizontal-scrolling/

That is about horizontal scrolling in general, not with the specific 
requirements of source code in mind.

If this was plain text I would have no qualms about it.

>> Also, line breaks still have significance in some languages, this wouldn’t
>> solve that.
> There can be clear indication of line numbers on the left side of the
> display that shows that there isn't an actual hard newline here. It's
> just a convenience of presentation.

Personally I don’t think that’s sufficient.

>>>> Emacs and vim aside, editors normally don’t wrap lines
>>> Kate does it, gedit does it, textmate too, but apparently only
>>> whatever editor you use doesn't.
>> Pretty much every one of them? Eclipse, IntelliJ, Visual Studio,
>> MonoDevelop, Netbeans, XCode,
> Ah, the IDEs scroll horizontally, the text editors don't. I see why
> we're coming from different perspectives here.

Maybe yes :). I would like to emphasise that SCM’s primary target is to 
manage source code. You wouldn’t show source code in a 
proportional-width font either (that’s the default mode for OS X’s 
TextEdit ;)). In HTML, <blockquote> and <pre> don’t have different 
presentations for no reason.

>> If you’d be editing source code in them you’d be turning off the
>> wrap option in a jiffy.
> No, I leave it on.
>
>> Also, fwiw, Github doesn’t wrap either, nor does Stack Overflow, nor
>> does the Android documentation. Nor will anything else on the web
>> that shows source code. I dare you to find a place ;P.
> Pastebin does:
>
>      http://pastebin.com/fBVpnY9Q
>
> So does Google code (line 10):
>
>      https://code.google.com/r/darcymason-refactor/source/browse/pydicom/fileio/testfind.py?spec=svn61b7b2ba465756cc22bbc8583ddd3da67c19df58&r=61b7b2ba465756cc22bbc8583ddd3da67c19df58

Ok, that challenge was asking to be beaten :). I raise you Bitbucket, 
MSDN and docs.python.org!

That Google Code example actually kinda shows what sucks about it; that 
string doesn’t look right. It would be worse if that particular line was 
indented; you can see it in a number of other files there. Now multiply 
this by about every other line for a worst case (hard to emulate here 
cause Google Code has a minimum width set). The structure would get 
completely lost in the wrapping noise.

I’d still like to mention that Github and Stack Overflow aren’t the 
lowest among mortals, and that they employ visual and UX designers and 
receive tons of user feedback putting these things into practice every 
day. Same applies to all those IDEs out there.

But by now I think I’ve said about all I can on the topic.

~Laurens

Patch

diff -r f21a44fe66da -r 0de0cddeac5c mercurial/templates/static/style-paper.css
--- a/mercurial/templates/static/style-paper.css	Tue Jun 25 21:02:22 2013 +0400
+++ b/mercurial/templates/static/style-paper.css	Wed Jun 26 12:41:21 2013 +0400
@@ -200,8 +200,8 @@ 
 
 .source, .sourcefirst, .sourcelast {
   font-family: monospace;
-  white-space: pre;
   padding: 1px 4px;
+  white-space: pre-wrap;
   font-size: 90%;
 }
 .sourcefirst { border-bottom: 1px solid #999; font-weight: bold; }