event for changing the order of nodes

41 views
Skip to first unread message

Xu Wang

unread,
Feb 22, 2020, 1:13:41 PM2/22/20
to leo-e...@googlegroups.com
Dear Leo Developer,

If I have a node with 5 subnodes, the child #1 is focused, I clicked SHIFT-DOWN, child #1 and child #2 will swap position.  Is there an event for the position swap?

I checked here
but was not able to find a related one.

Best Regards,
Austin

Xu Wang

unread,
Feb 22, 2020, 3:27:41 PM2/22/20
to leo-e...@googlegroups.com
As an alternative solution, I'm thinking to create two new user defined commands, @key=Move_up_key and @key=Move_down_key for moving current node UP and DOWN.

Would you please share me where I can find of Leo code for moving node UP and DOWN for reference?

Thanks,
Austin

Xu Wang <xu4...@gmail.com> 于2020年2月23日周日 上午1:13写道:

Edward K. Ream

unread,
Feb 24, 2020, 4:41:24 AM2/24/20
to leo-editor
On Saturday, February 22, 2020 at 12:13:41 PM UTC-6, Austin(Xu) Wang wrote:
Dear Leo Developer,

If I have a node with 5 subnodes, the child #1 is focused, I clicked SHIFT-DOWN, child #1 and child #2 will swap position.  Is there an event for the position swap?

I have just created #1508 for this. The new code is in devel at rev c76e91.

This adds c.command_function and c.command_name ivars for use by event handlers.  For example:

def command1_handler(tag, keys):
    c
= keys.get('c')
    p
= keys.get('p')
   
print(f"command1: {c.command_name:>30} {p and p.h}")

g
.registerHandler('command1', command1_handler)

I have closed this issue. Please reopen if there are problems.

Edward

Edward K. Ream

unread,
Feb 24, 2020, 4:48:13 AM2/24/20
to leo-editor
On Saturday, February 22, 2020 at 2:27:41 PM UTC-6, Austin(Xu) Wang wrote:

Would you please share me where I can find of Leo code for moving node UP and DOWN for reference?

See the nodes c_oc.moveOutlineDown and c_oc.moveOutlineUp in @file ../commands/commanderOutlineCommands.py.

I almost always search for commands by searching for single-quote<command-name>.

For example: cff for 'move- will 'move-outline-down', 'move-outline-up', etc.

Edward

Xu Wang

unread,
Feb 24, 2020, 9:42:48 AM2/24/20
to leo-e...@googlegroups.com
Thanks Edward, I am drafting some script to manipulate todo.txt file inside Leo, will share it here when it's working.

BR,Austin

Edward K. Ream <edre...@gmail.com> 于2020年2月24日周一 下午4:41写道:
--
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 leo-editor+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/9550fb79-bbdf-4306-b840-4b1f72ce136e%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages