Many thanks for such prompt and helpful advice. A significant part of what makes Leo so great. I'm off to try Luka's and Edward's solutions. Sorry to be so slow tbp1, but how do I set up undo?
Thanks again from momentarily sunny Wales. IH On Friday, 4 November 2022 at 12:01:10 UTC [email protected] wrote: > Don't forget to set up for undo. > > On Friday, November 4, 2022 at 6:48:50 AM UTC-4 Edward K. Ream wrote: > >> On Fri, Nov 4, 2022 at 3:25 AM Luka <[email protected]> wrote: >> >> There are plenty of ways to do it in LEO but this is how I do it. >>> >>> Create a @button node with script, select text in body, and run: >>> >>> @language python >>> >>> #get selected text from body >>> w = c.frame.body.wrapper >>> s = w.getSelectedText() >>> start,end=w.getSelectionRange() >>> b=p.b >>> >>> #do something >>> s=s.replace('\n','\\\\\n') >>> >>> #insert edited text back >>> p.b=b[:start]+s+b[end:] >>> c.redraw() >>> >> >> Thanks, Luka, for this tip. >> >> Leo itself typically expands the selection to include entire lines. Like >> this (tested) code: >> >> w = c.frame.body.wrapper >> s = w.getAllText() >> i, j = w.getSelectionRange() >> start, junk = g.getLine(s, i) >> junk, end = g.getLine(s, j) >> >> Edward >> > -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/7c425f43-24a6-4cde-b907-b6cd3130456fn%40googlegroups.com.
