# shellcheck shell=dash disable=SC2034,SC2059
###
  # @description: set up style color
  # @example: ___x_cmd_theme_style fg-red bold hello world
###
___x_cmd_theme_style(){
    local x_=""
    ___x_cmd_theme_style_ "$@" || return
    printf "%s" "$x_"
}

___x_cmd_theme_style_() {
    x_=""

    local IFS=" "
    case "$1" in
        %*%)
                local op="${1#\%}";  shift
                local msg="$*"
                eval set -- "${op%\%}" "--" "\"\$msg\""
        ;;
    esac

    if [ -n "$___X_CMD_THEME_PS1_OUTSIDE" ]; then
        local ___X_CMD_COLOR_PRE=
        local ___X_CMD_COLOR_SUF=
    fi

    local color_code
    while [ $# -gt 0 ]; do
        case "$1" in
            bold)           x_="${x_}${___X_CMD_COLOR_PRE}${___X_CMD_UNSEENCHAR_033}[1m${___X_CMD_COLOR_SUF}"                             ;;
            dim)            x_="${x_}${___X_CMD_COLOR_PRE}${___X_CMD_UNSEENCHAR_033}[2m${___X_CMD_COLOR_SUF}"                             ;;
            reverse)        x_="${x_}${___X_CMD_COLOR_PRE}${___X_CMD_UNSEENCHAR_033}[7m${___X_CMD_COLOR_SUF}"                             ;;
            underline)      x_="${x_}${___X_CMD_COLOR_PRE}${___X_CMD_UNSEENCHAR_033}[4m${___X_CMD_COLOR_SUF}"                             ;;
            black|red|green|yellow|blue|magenta|cyan|white)
                            ___x_cmd_theme_set___color_code "${1}";                 x_="${x_}${___X_CMD_COLOR_PRE}${___X_CMD_UNSEENCHAR_033}[3${color_code}m${___X_CMD_COLOR_SUF}"              ;;
            fg-[0-9]*)      x_="${x_}${___X_CMD_COLOR_PRE}${___X_CMD_UNSEENCHAR_033}[38;5;${1#fg-}m${___X_CMD_COLOR_SUF}"                 ;;
            fg-*)           ___x_cmd_theme_set___color_code "${1#fg-}";             x_="${x_}${___X_CMD_COLOR_PRE}${___X_CMD_UNSEENCHAR_033}[3${color_code}m${___X_CMD_COLOR_SUF}"              ;;
            bfg-*)          ___x_cmd_theme_set___color_code "${1#bfg-}";            x_="${x_}${___X_CMD_COLOR_PRE}${___X_CMD_UNSEENCHAR_033}[1;3${color_code}m${___X_CMD_COLOR_SUF}"            ;;
            hfg-*)          ___x_cmd_theme_set___color_code "${1#hfg-}";            x_="${x_}${___X_CMD_COLOR_PRE}${___X_CMD_UNSEENCHAR_033}[9${color_code}m${___X_CMD_COLOR_SUF}"              ;;
            dfg-*)          ___x_cmd_theme_set___color_code "${1#dfg-}";            x_="${x_}${___X_CMD_COLOR_PRE}${___X_CMD_UNSEENCHAR_033}[2;3${color_code}m${___X_CMD_COLOR_SUF}"            ;;
            colourfg-*)     x_="${x_}${___X_CMD_COLOR_PRE}${___X_CMD_UNSEENCHAR_033}[38;5;${1#colourfg-}m${___X_CMD_COLOR_SUF}"           ;;
            rgbfg-*)        ___x_cmd_theme_set___rgb_color_code "${1#rgbfg-}";      x_="${x_}${___X_CMD_COLOR_PRE}${___X_CMD_UNSEENCHAR_033}[38;2;${color_code}m${___X_CMD_COLOR_SUF}"          ;;

            bg-[0-9]*)      x_="${x_}${___X_CMD_COLOR_PRE}${___X_CMD_UNSEENCHAR_033}[48;5;${1#bg-}m${___X_CMD_COLOR_SUF}"                 ;;
            bg-*)           ___x_cmd_theme_set___color_code "${1#bg-}";             x_="${x_}${___X_CMD_COLOR_PRE}${___X_CMD_UNSEENCHAR_033}[4${color_code}m${___X_CMD_COLOR_SUF}"              ;;
            bbg-*)          ___x_cmd_theme_set___color_code "${1#bbg-}";            x_="${x_}${___X_CMD_COLOR_PRE}${___X_CMD_UNSEENCHAR_033}[1;4${color_code}m${___X_CMD_COLOR_SUF}"            ;;
            hbg-*)          ___x_cmd_theme_set___color_code "${1#hbg-}";            x_="${x_}${___X_CMD_COLOR_PRE}${___X_CMD_UNSEENCHAR_033}[10${color_code}m${___X_CMD_COLOR_SUF}"             ;;
            dbg-*)          ___x_cmd_theme_set___color_code "${1#dbg-}";            x_="${x_}${___X_CMD_COLOR_PRE}${___X_CMD_UNSEENCHAR_033}[2;4${color_code}m${___X_CMD_COLOR_SUF}"            ;;
            colourbg-*)     x_="${x_}${___X_CMD_COLOR_PRE}${___X_CMD_UNSEENCHAR_033}[48;5;${1#colourbg-}m${___X_CMD_COLOR_SUF}"           ;;
            rgbbg-*)        ___x_cmd_theme_set___rgb_color_code "${1#rgbbg-}";      x_="${x_}${___X_CMD_COLOR_PRE}${___X_CMD_UNSEENCHAR_033}[48;2;${color_code}m${___X_CMD_COLOR_SUF}"          ;;
            reset)          x_="${x_}${___X_CMD_COLOR_PRE}${___X_CMD_UNSEENCHAR_033}[0m${___X_CMD_COLOR_SUF}"                             ;;
            --)             shift;
                            x_="${x_}$*${___X_CMD_COLOR_PRE}${___X_CMD_UNSEENCHAR_033}[0m${___X_CMD_COLOR_SUF}"; return ;;
            *)              x_="${x_}$*${___X_CMD_COLOR_PRE}${___X_CMD_UNSEENCHAR_033}[0m${___X_CMD_COLOR_SUF}"; return ;;
        esac
        shift
    done
}

# bash... complete hightlight
_______x_cmd_theme_set_complete_color() {
    :
}

# Removed in the future
# ___x_cmd_theme_style() {
#     while [ $# -gt 0 ]; do
#         case "$1" in
#             bold)                                                   printf "${___X_CMD_COLOR_PRE}\033[1m${___X_CMD_COLOR_SUF}"                             ;;
#             underline)                                              printf "${___X_CMD_COLOR_PRE}\033[4m${___X_CMD_COLOR_SUF}"                             ;;
#             black|red|green|yellow|blue|magenta|cyan|white)         local color_code; ___x_cmd_theme_set___color_code "${1}"; printf "${___X_CMD_COLOR_PRE}\033[3${color_code}m${___X_CMD_COLOR_SUF}"                   ;;
#             fg-*)                                                   local color_code; ___x_cmd_theme_set___color_code "${1#fg-}"; printf "${___X_CMD_COLOR_PRE}\033[3${color_code}m${___X_CMD_COLOR_SUF}"               ;;
#             bfg-*)                                                  local color_code; ___x_cmd_theme_set___color_code "${1#bfg-}"; printf "${___X_CMD_COLOR_PRE}\033[1;3${color_code}m${___X_CMD_COLOR_SUF}"            ;;
#             hfg-*)                                                  local color_code; ___x_cmd_theme_set___color_code "${1#hfg-}"; printf "${___X_CMD_COLOR_PRE}\033[9${color_code}m${___X_CMD_COLOR_SUF}"              ;;
#             dfg-*)                                                  local color_code; ___x_cmd_theme_set___color_code "${1#dfg-}"; printf "${___X_CMD_COLOR_PRE}\033[2;3${color_code}m${___X_CMD_COLOR_SUF}"            ;;
#             colourfg-*)                                             printf "${___X_CMD_COLOR_PRE}\033[38;5;${1#colourfg-}m${___X_CMD_COLOR_SUF}"           ;;
#             rgbfg-*)                                                local color_code; ___x_cmd_theme_set___rgb_color_code "${1#rgbfg-}"; printf "${___X_CMD_COLOR_PRE}\033[38;2;${color_code}m${___X_CMD_COLOR_SUF}"    ;;
#             bg-*)                                                   local color_code; ___x_cmd_theme_set___color_code "${1#bg-}"; printf "${___X_CMD_COLOR_PRE}\033[4${color_code}m${___X_CMD_COLOR_SUF}"               ;;
#             bbg-*)                                                  local color_code; ___x_cmd_theme_set___color_code "${1#bbg-}"; printf "${___X_CMD_COLOR_PRE}\033[1;4${color_code}m${___X_CMD_COLOR_SUF}"            ;;
#             hbg-*)                                                  local color_code; ___x_cmd_theme_set___color_code "${1#hbg-}"; printf "${___X_CMD_COLOR_PRE}\033[10${color_code}m${___X_CMD_COLOR_SUF}"             ;;
#             dbg-*)                                                  local color_code; ___x_cmd_theme_set___color_code "${1#dbg-}"; printf "${___X_CMD_COLOR_PRE}\033[2;4${color_code}m${___X_CMD_COLOR_SUF}"            ;;
#             colourbg-*)                                             printf "${___X_CMD_COLOR_PRE}\033[48;5;${1#colourbg-}m${___X_CMD_COLOR_SUF}"           ;;
#             rgbbg-*)                                                local color_code; ___x_cmd_theme_set___rgb_color_code "${1#rgbbg-}"; printf "${___X_CMD_COLOR_PRE}\033[48;2;${color_code}m${___X_CMD_COLOR_SUF}"    ;;
#             reset)                                                  printf "${___X_CMD_COLOR_PRE}\033[0m${___X_CMD_COLOR_SUF}"                             ;;
#             --)                                                     shift; printf "%s${___X_CMD_COLOR_PRE}\033[0m${___X_CMD_COLOR_SUF}" "$*"; return       ;;
#             *)                                                      printf "%s${___X_CMD_COLOR_PRE}\033[0m${___X_CMD_COLOR_SUF}" "$*"; return
#         esac
#         shift
#     done
# }
