###############################################################################
#    Disable Byobu's f-key keybindings, define a set using Screen's escape
#    sequence.
#
#    Copyright (C) 2009-2014  Dustin Kirkland <kirkland@byobu.org>
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, version 3 of the License.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
###############################################################################

# This file disables the f-key bindings, but retains the
# keybindings that use Screen's built-in escape sequence

# Default Screen escape
escape ^Aa
register x "^A"

# Use the following sequences for byobu functionality
# SEQUENCE      ACTION                          F-Key equivalent
# ctrl-a-c      Create a new window             F2
# ctrl-a-p      Previous window                 F3
# ctrl-a-n      Next window                     F4
# ctrl-a-R      Reload profile                  F5
register r ":source $BYOBU_CONFIG_DIR/profile^M"
bind R eval 'process x' 'process r'
# ctrl-a-d      Detach from this session        F6
# ctrl-a-[      Enter copy/scrollback mode      F7
# ctrl-a-A      Re-title a window               F8
# ctrl-a-@      Configuration                   F9
bind @ $BYOBU_BACKEND -t config 0 byobu-config
# ctrl-a-$      Show detailed status
bind $ $BYOBU_BACKEND -t status 0 byobu-status-detail
# ctrl-a-!	Toggle f-key keybindings on
register e ":source $BYOBU_PREFIX/share/byobu/keybindings/f-keys.screen^M"
bind ! eval 'process x' 'process e' 'backtick 111 9999999 9999999 byobu-status menu'

# Disable the f-key bindings
bindkey -k k1
bindkey "^[O1;2P"
bindkey -k k2
bindkey "^[O1;5Q"
bindkey "^[O1;2Q"
bindkey -k k3
bindkey -k k4
bindkey "^[[1;3D"
bindkey "^[[1;3C"
bindkey "^[O1;2R"
bindkey "^[O1;2S"
bindkey "^[[1;2A"
bindkey "^[[1;2B"
bindkey "^[[1;2D"
bindkey "^[[1;2C"
bindkey "^[[1;4A"
bindkey "^[[1;4B"
bindkey "^[[1;4D"
bindkey "^[[1;4C"
bindkey -k k5
bindkey "^[[15;5~"
bindkey "^[[15;6~"
bindkey "^[[15;2~"
bindkey "^[[31~"
bindkey -k k6
bindkey "^[[17;2~"
bindkey "^[[32~"
bindkey "^[[17;5~"
bindkey -k k7
bindkey "^[[18;2~"
bindkey "^[[5;3~"
bindkey "^[[6;3~"
bindkey -k k8
bindkey "^[[19;5~"
bindkey -k k9
bindkey -k F2
