line-height CSS attribute

849 views
Skip to first unread message

David McNab

unread,
Oct 21, 2013, 11:26:53 PM10/21/13
to leo-e...@googlegroups.com
Hi,

I'm wanting to use Leo for writing university essays, reports, case studies etc. But to make this practical, when editing works of thousands of words, I really need to increase the line spacing to support easier reading and focus.

I tried setting the "line-height" CSS attribute within the Leo CSS for the body pane, but it seems to be getting completely ignored. Other settings like font-family and font-size do take effect, however.

I understand more recent versions of Qt support the line-height attribute, at least unofficially. Can anyone suggest how I might get leo working with fresh Qt? Do I have to build Qt, then PyQt, then PyScintilla from source? Or is there a less painful alternative.

All I want to do is double-space some of the body text nodes.
Thanks in advance for any help.

Cheers
David

Terry Brown

unread,
Oct 22, 2013, 9:12:47 AM10/22/13
to leo-e...@googlegroups.com
On Mon, 21 Oct 2013 20:26:53 -0700 (PDT)
David McNab <davidm...@gmail.com> wrote:

> Hi,
>
> I'm wanting to use Leo for writing university essays, reports, case studies
> etc. But to make this practical, when editing works of thousands of words,
> I really need to increase the line spacing to support easier reading and
> focus.
>
> I tried setting the "line-height" CSS attribute within the Leo CSS for the
> body pane, but it seems to be getting completely ignored. Other settings
> like font-family and font-size do take effect, however.

I'm not sure that Qt supports line-height. I see no mention of it here:
http://qt-project.org/doc/qt-4.8/stylesheet-reference.html#list-of-properties

Seems like Qt quick had a lineHeight method but that doesn't seem to
have made it into QTextEdit even in 5.1...

> I understand more recent versions of Qt support the line-height attribute,
> at least unofficially. Can anyone suggest how I might get leo working with
> fresh Qt? Do I have to build Qt, then PyQt, then PyScintilla from source?
> Or is there a less painful alternative.

I don't think we support qt 5.x at the moment, but even if we did, it's
not clear it would help - I think more googling / mailing list
inquiries to get a definite answer might be the most efficient route.

If you just want to read in double space, there'd be options to make
viewrendered or something display double spacing.

Cheers -Terry

Jacob Peck

unread,
Oct 22, 2013, 9:22:14 AM10/22/13
to leo-e...@googlegroups.com
There's an ugly hack at the end of this thread:
http://www.qtforum.org/article/32901/double-spacing-changing-line-height-in-qtextedit.html

I doubt that would work well in Leo, but it could be attached to a
'select' event on @doublespaced nodes?

-->Jake

Edward K. Ream

unread,
Oct 22, 2013, 9:29:25 AM10/22/13
to leo-editor
On Tue, Oct 22, 2013 at 8:12 AM, Terry Brown <terry_...@yahoo.com> wrote:

I'm not sure that Qt supports line-height.  I see no mention of it here:
http://qt-project.org/doc/qt-4.8/stylesheet-reference.html#list-of-properties

​Thanks, Terry, for this and the rest of your response.

There *might* be a workaround using rST and/or sphinx.​ For example, Leo's documentation uses the following docutils(?) markup that effectively inserts a <br> element:

.. |br| raw:: html

   <br />

True, this is html, not css, but there may be similar way to hack css.  One place to start: http://docutils.sourceforge.net/docs/ref/rst/directives.html#raw-data-pass-through

And as I write this, I remember that docutils uses several .css files.  It may be that they are (or can be) copied to the html in some way.

If no solution presents itself, please make sure you ask the docutils people for help.

HTH.

Edward

Edward K. Ream

unread,
Oct 22, 2013, 9:35:15 AM10/22/13
to leo-e...@googlegroups.com

On Tuesday, October 22, 2013 8:29:25 AM UTC-5, Edward K. Ream wrote:

> Leo's documentation uses the following docutils(?) markup that effectively inserts a <br> element:

.. |br| raw:: html

   <br />

Oops.  I misspoke.  This does *not* insert a <br>.  It defines |br| so you can use |br| later to insert <br>.  Big difference.

EKR

David McNab

unread,
Oct 24, 2013, 5:28:49 AM10/24/13
to leo-e...@googlegroups.com
Thanks for replies, folks.

However, I might not have expressed myself clearly enough.

What I want is to see the text in the body pane double-spaced, not the text
that gets generated. I'm writing the text in Leo, then tangling to a text
file, then importing to OpenOffice for final formatting.

University professors demand double-spaced text, even in this age of reading
on screen, because it's less mentally taxing to read. The same applies when
writing and editing text.

Leo's single-spacing makes it harder to focus on dry academic text when one
is mentally tired. It's a huge shame that even after 11 years of people
requesting it, OpenOffice still doesn't do outlining.

Is there any way to get Leo to show its body pane text double-spaced,
wrapping long lines automatically?

Cheers
David


Terry Brown

unread,
Oct 24, 2013, 8:16:23 AM10/24/13
to leo-e...@googlegroups.com
On Thu, 24 Oct 2013 09:28:49 +0000 (UTC)
David McNab <davidm...@gmail.com> wrote:

> Edward K. Ream <edreamleo@...> writes:
>
> > On Tuesday, October 22, 2013 8:29:25 AM UTC-5, Edward K. Ream wrote:>
> Leo's documentation uses the following docutils(?) markup that effectively
> inserts a <br> element:
> > .. |br| raw:: html   <br />
> >
> > Oops.  I misspoke.  This does *not* insert a <br>.  It defines |br| so you
> can use |br| later to insert <br>.  Big difference.EKR
>
> Thanks for replies, folks.
>
> However, I might not have expressed myself clearly enough.
>
> What I want is to see the text in the body pane double-spaced, not the text
> that gets generated.

I understood what you meant. My take, after some Googling around, was
that QTextEdit doesn't offer any simple way to do it. What would be
simple enough would be to have the viewrendered window display double
line spacing (I assume), for reading purposes. That window's updated
in real time, you'd still have to edit the text in the single spaced
body window, but if it's useful to at least be able to read it double
spaced that's an option.

... or not - sorry, I just tried this piece of code:

splitter = c.free_layout.get_top_splitter()
a = splitter.root.windows[0]
a.setStyleSheet("* {color: brown; line-height: 300%;}")

which will apply the given style to the viewrendered window, assuming
you opened it by right clicking a pane separator and selecting Open
window -> Viewrendered. The text turns brown, but line-height doesn't
change - doh, I guess viewrendered is implemented with a QTextEdit, it
would have to be implemented with a QWebView or something instead.

Still, if a read only view of double spaced text was useful, it
wouldn't be too hard to make a new window which views the current
node's text as a web page - if that's not useful, I don't think there's
an easy way to get there - too bad Qt doesn't seem to support it in a
straight forward way.

Cheers -Terry

Edward K. Ream

unread,
Oct 24, 2013, 11:45:21 AM10/24/13
to leo-editor
On Thu, Oct 24, 2013 at 7:16 AM, Terry Brown <terry_...@yahoo.com> wrote:

 
​> ​
QTextEdit doesn't offer any simple way to
​ ​
[
​double space].
​[snip]

> viewrendered is implemented with a QTextEdit, it would have to be implemented with a QWebView or something instead.

​It shouldn't be be too hard to use QWebView instead of QTextEdit, or even to switch between the two classes. Indeed, update_rst and update_html already generate html from the body text, so very little needs to be done.

I am well aware of the tricky nature of this code, but surely using QWebView must be feasible.

EKR

Terry Brown

unread,
Oct 24, 2013, 12:13:21 PM10/24/13
to leo-e...@googlegroups.com
Feasible, but viewrendered has lots of cases where it assumes
self.text_class is QTextEditor. Probably easiest to somehow define a
new content type.

Cheers -Terry

Edward K. Ream

unread,
Oct 24, 2013, 2:51:33 PM10/24/13
to leo-editor
On Thu, Oct 24, 2013 at 11:13 AM, Terry Brown <terry_...@yahoo.com> wrote:

​...viewrendered has lots of cases where it assumes
self.text_class is QTextEditor.  Probably easiest to somehow define a
new content type.

​In that case, the code would need an ensure_webview_widget method, similar to ensure_text_widget.  That's one of the trickier methods, but once it is place the html and rst views should be straightforward.

EKR

Terry Brown

unread,
Feb 24, 2014, 1:12:49 PM2/24/14
to leo-e...@googlegroups.com
On Mon, 21 Oct 2013 20:26:53 -0700 (PDT)
David McNab <davidm...@gmail.com> wrote:

> I'm wanting to use Leo for writing university essays, reports, case
> studies etc. But to make this practical, when editing works of
> thousands of words, I really need to increase the line spacing to
> support easier reading and focus.

As of Qt 4.8, the following script can be executed to set line spacing
to 190% for the given outline for the current session.

from PyQt4 import QtGui
def hook(tag, kwds, c=c):

if kwds['c'] != c:
return

bodyWidget = c.frame.body.bodyCtrl.widget
doc = bodyWidget.document()
for i in range(doc.blockCount()):
block = doc.findBlockByNumber(i)
curs = QtGui.QTextCursor(block)
fmt = block.blockFormat()
fmt.setLineHeight(190, QtGui.QTextBlockFormat.ProportionalHeight)
curs.setBlockFormat(fmt)

g.registerHandler("select3", hook)

Cheers -Terry

Edward K. Ream

unread,
Mar 12, 2014, 4:00:58 PM3/12/14
to leo-editor
On Mon, Feb 24, 2014 at 12:12 PM, Terry Brown <terry_...@yahoo.com> wrote:

As of Qt 4.8, the following script can be executed to set line spacing
to 190% for the given outline for the current session.
​[snip]

Thanks for this.  I've just placed it in leo/scripts/scripts.leo.

I wasn't able to do a test for qt 4.8 programmatically: not sure whether it is possible to call the qt_version_check from pyqt.

EKR

Bob Gnow

unread,
Mar 30, 2019, 8:43:33 AM3/30/19
to leo-editor
It is not working for the PyQt5 or later. I also want to change the line spacing, but no luck to do so. Could someone give a step by step solution. Thank you a lot.

在 2014年3月13日星期四 UTC+8上午4:00:58,Edward K. Ream写道:

Edward K. Ream

unread,
Apr 3, 2019, 12:31:21 PM4/3/19
to leo-editor
On Thu, Oct 24, 2013 at 4:50 AM David McNab <davidm...@gmail.com> wrote:

What I want is to see the text in the body pane double-spaced, not the text
that gets generated. I'm writing the text in Leo, then tangling to a text
file, then importing to OpenOffice for final formatting.

After all this talk about Qt, it seems to me that what you want is to have the tangled text be double spaced.  Right?

I've pretty much forgotten about Leo's Tangle command.  Instead, perhaps you could convert a smallish test file to use @file.  Now all you need is to output the file double spaced.  This can probably be done with a script of about 10 lines.

Or one could define a double-space command that would double space all lines in a node or tree, and then use @clean to write the file.

Does either of these suggestions make sense to you?

Edward
Reply all
Reply to author
Forward
0 new messages