On Sat, 3 Nov 2012 09:21:19 +0800
HaveF <[email protected]> wrote:

> If there is possible to make leo has the possibility to auto linewrap in
> headlines?

Running the code below (in a @script node or whatever) seems to make
Leo wrap headlines.  Please TEST THOROUGHLY ON A BACKUP of your working
file, once run this code causes Leo to wrap every headline as you
unselect it (move to another headline), and that can be quite
destructive on an outline not intended for wrapping.

from textwrap import wrap
hook = 'unselect1'
width = 12

if hasattr(c, '_wrapper'):
    g.unregisterHandler(hook, c._wrapper)

def wrapper(tag, kwds, this_c=c):
    if not kwds.get('c') == this_c:
        return
    old_p = kwds.get('old_p')
    old_p.h = '\n'.join(wrap(c.p.h, width=width, break_long_words=False))

c._wrapper = wrapper
g.registerHandler(hook, c._wrapper)

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.

Reply via email to