def load_sidebar_bindings(python_input):
    """
    Load bindings for the navigation in the sidebar.
    """
    bindings = KeyBindings()

    handle = bindings.add
    sidebar_visible = Condition(lambda: python_input.show_sidebar)

    @handle('up', filter=sidebar_visible)
    @handle('c-p', filter=sidebar_visible)
    @handle('k', filter=sidebar_visible)
    def _(event):
        " Go to previous option. "
        python_input.selected_option_index = (
            (python_input.selected_option_index - 1) % python_input.option_count)

    @handle('down', filter=sidebar_visible)
    @handle('c-n', filter=sidebar_visible)
    @handle('j', filter=sidebar_visible)
    def _(event):
        " Go to next option. "
        python_input.selected_option_index = (
            (python_input.selected_option_index + 1) % python_input.option_count)

    @handle('right', filter=sidebar_visible)
    @handle('l', filter=sidebar_visible)
    @handle(' ', filter=sidebar_visible)
    def _(event):
        " Select next value for current option. "
        option = python_input.selected_option
        option.activate_next()

    @handle('left', filter=sidebar_visible)
    @handle('h', filter=sidebar_visible)
    def _(event):
        " Select previous value for current option. "
        option = python_input.selected_option
        option.activate_previous()

    @handle('c-c', filter=sidebar_visible)
    @handle('c-d', filter=sidebar_visible)
    @handle('c-d', filter=sidebar_visible)
    @handle('enter', filter=sidebar_visible)
    @handle('escape', filter=sidebar_visible)
    def _(event):
        " Hide sidebar. "
        python_input.show_sidebar = False
        event.app.layout.focus_last()

    return bindings
def load_sidebar_bindings ( python_input ) : bindings = KeyBindings ( ) handle = bindings . add sidebar_visible = Condition ( lambda : python_input . show_sidebar ) @ handle ( 'up' , filter = sidebar_visible ) @ handle ( 'c-p' , filter = sidebar_visible ) @ handle ( 'k' , filter = sidebar_visible ) def _ ( event ) : python_input . selected_option_index = ( ( python_input . selected_option_index - 1 ) % python_input . option_count ) @ handle ( 'down' , filter = sidebar_visible ) @ handle ( 'c-n' , filter = sidebar_visible ) @ handle ( 'j' , filter = sidebar_visible ) def _ ( event ) : python_input . selected_option_index = ( ( python_input . selected_option_index + 1 ) % python_input . option_count ) @ handle ( 'right' , filter = sidebar_visible ) @ handle ( 'l' , filter = sidebar_visible ) @ handle ( ' ' , filter = sidebar_visible ) def _ ( event ) : option = python_input . selected_option option . activate_next ( ) @ handle ( 'left' , filter = sidebar_visible ) @ handle ( 'h' , filter = sidebar_visible ) def _ ( event ) : option = python_input . selected_option option . activate_previous ( ) @ handle ( 'c-c' , filter = sidebar_visible ) @ handle ( 'c-d' , filter = sidebar_visible ) @ handle ( 'c-d' , filter = sidebar_visible ) @ handle ( 'enter' , filter = sidebar_visible ) @ handle ( 'escape' , filter = sidebar_visible ) def _ ( event ) : python_input . show_sidebar = False event . app . layout . focus_last ( ) return bindings
Load bindings for the navigation in the sidebar.