# shellcheck shell=dash

if [ -n "$ZSH_VERSION" ]; then
    xrc:mod co/lib/hotkey/bind.zsh
elif [ -n "$BASH_VERSION" ]; then
    xrc:mod co/lib/hotkey/bind.bash
fi

___x_cmd_co_hotkey(){
    local op="$1";
    case "$op" in
        --exec)  shift; ___x_cmd_co_hotkey_exec "$@"; return ;;
    esac

    # ctrl  + x z
    # alt   + e i j k m o r v

    local hotkey='\C-x' # '^X' # '\ee'
    co:info "Binding hotkey -> Ctrl+X"
    ___x_cmd_co_hotkey_bind "$hotkey"
}


___x_cmd_co_hotkey___reset_prompt_unit(){
    if [ -n "$___X_CMD_THEME_CURRENT_NAME" ]; then
        printf "%s\n" ""
        printf "\0337"
        local _lines; _lines="$(( ___x_cmd_theme_linecount_ps1 - ___x_cmd_theme_linecount_headline ))"
        while [ "$_lines" -gt 0 ]; do
            _lines=$((_lines - 1))
            printf "%s\n" ""
        done
    fi

    if [ -n "$ZSH_VERSION" ]; then
        { zle && zle .reset-prompt && zle -R; } 2>/dev/null
    fi
}

___x_cmd_co_hotkey_exec(){
    co:info --m:cmd "$*" "Executing"
    ___x_cmd co --exec "$@"
}
