[texworks] Hard wrapping

Stefan Löffler st.loeffler at gmail.com
Thu May 7 07:34:19 CEST 2009


Hi!

Time for me to add my two cents ;).

On 2009-05-06 20:31, Jonathan Kew wrote:
> On 6 May 2009, at 10:42, Alain Delmotte wrote:
>
>> What was to "complex" in the patch of Stefan?
>> I think it was dealing with the problem submitted by Bruno.
>
> Yes, but the resulting dialog included more options. And it relied on
> adding visible "markers" to all the line-ends, which I think clutters
> the source file in a way that is not "friendly" to the average user.

In principle I have to agree that a simple user interface (at least at
first) is generally better than a complex one. As I pointed out
somewhere (I think at Google code) I wanted to have all but the most
important options hidden initially with a "More..." button (or something
comparable) that would enable the user to show/edit more options (and
otherwise use the defaults for those advanced options). I think this
would be the perfect solution for having a generally simple interface
but with the power of more advanced options just a few clicks away (for
those who can't/don't want to live with the defaults ;)).
Unfortunately I didn't succeed in implementing this show/hide behavior
in a consistent way (the dialog didn't expand/retract all the time, at
least on Linux).

As for the markers: my code didn't generally depend on them (i.e. you
could do wrapping with en empty marker, which should have given the same
result as the current code). It did rely on the markers for rewrapping,
however. If I understand this correctly this prevented the problems
reported in this thread so far (as rewrapping didn't take place at any
line break, but only at "specially marked" ones; btw: the marker was
chosen such that it effectively escapes/comments the hard-wrapped line
break for LaTeX). My working hypothesis was that while it is important
to give the user a simple interface, it is more important to respect the
user's wishes (i.e. input). So wherever there is a user-defined line
break, hard wrap doesn't mess with it (that was the reason for me not to
implement rewrap the way Jonathan did - by eating all (single) new lines
to construct a long line to wrap again).

BTW: A few minor issues I've found:
1) Wrapping at the current window size doesn't work properly (at least
on Linux). First of all it doesn't subtract the width of the scroll bar
(so the text is to wide if there is enough text so that a scrollbar is
shown), and secondly some lines are still too long. It's probably just a
few pixels, and may be related to the fact that on X the window
decoration (borders, etc.) happens asynchronously, IIRC. But it could
also be related to using the wrong rectangle (e.g. window rect instead
of client rect or something), but I didn't have time to look into the
code for that, yet.

2) (Also affects my original code) The "inverse" issue of the one
reported by Bruno Voisin. If you have a line like

Hello World % a long and useless comment
More Text

this may be wrapped to

Hello World % a long and useless
comment More Text

Which effectively adds the word "comment" to the output, although it's
supposed to be part of the comment. Unfortunately, there's no easy way
around that, however. The correct output would probably be

Hello World % a long and useless
% comment
More Text

BTW (a tiny little bit off-topic, but still related): Qt does have an
internal wrap-at-fixed-column mode, which could be implemented alongside
the wrap-at-widget soft-wrap mode. I know that this may be problematic
with the proportional fonts used in the editor, but it would give people
a way to easily arrange their code for the use with hard-wrap.

Stefan


More information about the texworks mailing list