#@+leo
#@+node:0::@file plugins/mod_arrows.py
#@+body
"""rebind up/down arrow keys"""

from leoPlugins import *
from leoGlobals import *


#@+others
#@+node:1::onOpen
#@+body
# Warning: the bindings created this way conflict with shift-arrow keys.

def onOpen (tag,keywords):

	c = keywords.get("new_c")
	body = c.frame.body
	tree = c.frame.tree

	# Add "hard" bindings to have up/down arrows move by visual lines.
	old_binding = body.bind("<Up>")
	if len(old_binding) == 0:
		body.bind("<Up>",tree.OnUpKey)

	old_binding = body.bind("<Down>")
	if len(old_binding) == 0:
		body.bind("<Down>",tree.OnDownKey)

#@-body
#@-node:1::onOpen
#@-others


if 1: # Register the handlers...
	registerHandler("open2", onOpen)
	
	import mod_arrows
	es("...rebind arrow keys v1.1: " + plugin_date(mod_arrows))

#@-body
#@-node:0::@file plugins/mod_arrows.py
#@-leo
