On Saturday, June 4, 2016 at 7:37:28 AM UTC+5:30, Conor White-Sullivan
wrote:
>
> I can now move the current node somewhere by doing this
>
> newnode = c.p.copy()
> dest = g.findNodeAnywhere(c,'A')
> newnode.moveToLastChildOf(dest)
> c.redraw()
>
> but what I want is to create a new node with the same values -- I don't
> think p is the answer for me here
>
>
> On Saturday, June 4, 2016 at 7:15:17 AM UTC+5:30, Conor White-Sullivan
> wrote:
>>
>> Hey all,
>>
>> I have a couple scripts I'd like to write -- I think they're pretty
>> simple, but I'm new to python and leo
>>
>> If anyone can help I'd appreciate it
>>
>> Script 1 : Creating Children of current based on selected text
>>
>> Goal: I'd like to
>>
>> 1. get the value of the text that is currently selected
>>
>> 2. create a new node, which has that text as both its headline and body
>> It was unclear from the tutorial how to just create a new node with
>> any arbitrary content
>>
>
To create a node with arbitrary content, it seems the best thing to do is
to use the MinibufferCommand
mb = c.executeMinibufferCommand
cp = c.currentPosition
t = "Here is some text to insert"
mb('insert-child')
cp().h = t
cp().b = t
>
>> 3. set that node be a child of the currently selected node
>> requires: getting the position of the current node
>>
>>
>> Bonus:
>>
>> 1. Trigger a little popup that lets me put in the value of what I'd like
>> to name this new child
>>
>> 2. remove the selected text and replace it with the value << 'whatever
>> I named the new child node in the prompt' >>
>>
>>
>>
>> -------- I've used the script below to create a clone and move it to a
>> specific place -- how do I just make a node
>>
>>
>>
>> p = c.p.clone()
>> dest = g.findNodeAnywhere(c,'A
>> ')
>> p.moveToLastChildOf(dest)
>> c.redraw()
>>
>> ----- Also, what is the best way to discover how to do these kind of
>> things without asking others?
>>
>>
--
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.