# shellcheck shell=dash

xrc:mod:lib     screen   __runcmd   __app   __ls

___x_cmd_screen___main(){
    [ "$#" -gt 0 ] ||   set -- --app

    local op="$1";      shift
    case "$op" in
        -h|--help)      ___x_cmd_screen___help          "$@" ;;

        -l|--ls)        ___x_cmd_screen___ls            "$@" ;;

        --app)          ___x_cmd_screen___app           "$@" ;;
        --setup)        ___x_cmd_screen___setup         "$@" ;;
        --runmain)      ___x_cmd_screen___runmain       "$@" ;;
        *)              ___x_cmd_screen___runmain "$op" "$@" ;;
    esac
}

___x_cmd_screen___help(){
    ___x_cmd help -m screen         "$@"
    ___x_cmd_screen___runmain -h
    return 0
}

___x_cmd_screen___setup(){
    ___x_cmd rmrf "$___X_CMD_ROOT_DATA/screen/rc"
    ___x_cmd ensurefp "$___X_CMD_ROOT_DATA/screen"

    ___x_cmd_cmds cp -r     \
        "$___X_CMD_ROOT_MOD/screen/lib/rc"  \
        "$___X_CMD_ROOT_DATA/screen/" || return $?

    # ___x_cmd boot ensurerccodewithoutextra  \
    ___x_cmd boot initrcfile1   \
        'source "$HOME/.x-cmd.root/local/data/screen/rc/default"  # boot up x-cmd screen'    "$HOME/.screenrc"
}



___x_cmd_screen_isinside(){
    [ -n "$STY" ]
    # or [ "$TERM" = screen ]
}
