From d7142f2b1d4f65d5a4a04e79885f25a728b4311e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 10 Sep 2024 12:38:10 +0200 Subject: [PATCH] =?UTF-8?q?banner=20=E2=86=92=20bar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spcd/bootstrap.sh | 116 +++++++++++++++++++++++----------------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/spcd/bootstrap.sh b/spcd/bootstrap.sh index 17ffdce..747e02b 100644 --- a/spcd/bootstrap.sh +++ b/spcd/bootstrap.sh @@ -4,9 +4,9 @@ # │ __ = internal │ # ╰───────────────╯ -# __SPCD_BANNER_TOP -# __SPCD_BANNER_MIDDLE -# __SPCD_BANNER_BOTTOM +# __SPCD_BAR_TOP +# __SPCD_BAR_MIDDLE +# __SPCD_BAR_BOTTOM # __SPCD_STEP_LEVEL # __SPCD_STEP_level_INDEX @@ -36,35 +36,35 @@ _spcd_fill() { done } -# ╭───┬────────╮ -# │ _ │ banner │ -# ╰───┴────────╯ +# ╭───┬─────╮ +# │ _ │ bar │ +# ╰───┴─────╯ -_SPCD_BANNER_BOTTOM_LEFT="${_SPCD_BOX_UP_AND_RIGHT}" -_SPCD_BANNER_BOTTOM_MIDDLE="${_SPCD_BOX_UP_AND_HORIZONTAL}" -_SPCD_BANNER_BOTTOM_RIGHT="${_SPCD_BOX_UP_AND_LEFT}" -_SPCD_BANNER_HORIZONTAL="${_SPCD_BOX_HORIZONTAL}" -_SPCD_BANNER_TOP_LEFT="${_SPCD_BOX_DOWN_AND_RIGHT}" -_SPCD_BANNER_TOP_MIDDLE="${_SPCD_BOX_DOWN_AND_HORIZONTAL}" -_SPCD_BANNER_TOP_RIGHT="${_SPCD_BOX_DOWN_AND_LEFT}" -_SPCD_BANNER_VERTICAL="${_SPCD_BOX_VERTICAL}" +_SPCD_BAR_BOTTOM_LEFT="${_SPCD_BOX_UP_AND_RIGHT}" +_SPCD_BAR_BOTTOM_MIDDLE="${_SPCD_BOX_UP_AND_HORIZONTAL}" +_SPCD_BAR_BOTTOM_RIGHT="${_SPCD_BOX_UP_AND_LEFT}" +_SPCD_BAR_HORIZONTAL="${_SPCD_BOX_HORIZONTAL}" +_SPCD_BAR_TOP_LEFT="${_SPCD_BOX_DOWN_AND_RIGHT}" +_SPCD_BAR_TOP_MIDDLE="${_SPCD_BOX_DOWN_AND_HORIZONTAL}" +_SPCD_BAR_TOP_RIGHT="${_SPCD_BOX_DOWN_AND_LEFT}" +_SPCD_BAR_VERTICAL="${_SPCD_BOX_VERTICAL}" -_spcd_banner_add() { +_spcd_bar_add() { if [ -n "${1}" ]; then local text length filler text=" ${1} " length=${#text} - filler="$(_spcd_fill "${length}" "${_SPCD_BANNER_HORIZONTAL}")" - if [ -n "${__SPCD_BANNER_MIDDLE}" ]; then - _spcd_banner_split + filler="$(_spcd_fill "${length}" "${_SPCD_BAR_HORIZONTAL}")" + if [ -n "${__SPCD_BAR_MIDDLE}" ]; then + _spcd_bar_split else - _spcd_banner_open + _spcd_bar_open fi - _spcd_banner_append "${filler}" "${text}" "${filler}" + _spcd_bar_append "${filler}" "${text}" "${filler}" fi } -_spcd_banner_add_index() { +_spcd_bar_add_index() { local level value label while true; do level=$((level + 1)) @@ -76,68 +76,68 @@ _spcd_banner_add_index() { label="${value}" fi done - _spcd_banner_add "${label}" + _spcd_bar_add "${label}" } -_spcd_banner_append() { +_spcd_bar_append() { if [ -n "${3}" ]; then - __SPCD_BANNER_TOP="${__SPCD_BANNER_TOP}${1}" - __SPCD_BANNER_MIDDLE="${__SPCD_BANNER_MIDDLE}${2}" - __SPCD_BANNER_BOTTOM="${__SPCD_BANNER_BOTTOM}${3}" + __SPCD_BAR_TOP="${__SPCD_BAR_TOP}${1}" + __SPCD_BAR_MIDDLE="${__SPCD_BAR_MIDDLE}${2}" + __SPCD_BAR_BOTTOM="${__SPCD_BAR_BOTTOM}${3}" fi } -_spcd_banner_echo() { +_spcd_bar_echo() { echo "\ -${__SPCD_BANNER_TOP} -${__SPCD_BANNER_MIDDLE} -${__SPCD_BANNER_BOTTOM}" +${__SPCD_BAR_TOP} +${__SPCD_BAR_MIDDLE} +${__SPCD_BAR_BOTTOM}" } -_spcd_banner_open() { - _spcd_banner_append \ - "${_SPCD_BANNER_TOP_LEFT}" \ - "${_SPCD_BANNER_VERTICAL}" \ - "${_SPCD_BANNER_BOTTOM_LEFT}" +_spcd_bar_open() { + _spcd_bar_append \ + "${_SPCD_BAR_TOP_LEFT}" \ + "${_SPCD_BAR_VERTICAL}" \ + "${_SPCD_BAR_BOTTOM_LEFT}" } -_spcd_banner_render() { - _spcd_banner_wipe - _spcd_banner_add "S" - _spcd_banner_add_index +_spcd_bar_render() { + _spcd_bar_wipe + _spcd_bar_add "S" + _spcd_bar_add_index # local level value while true; do level=$((level + 1)) eval "value=\"\${__SPCD_STEP_${level}_LABEL}\"" [ -n "${value}" ] || break - _spcd_banner_add "${value}" + _spcd_bar_add "${value}" done # - _spcd_banner_shut - _spcd_banner_echo - _spcd_banner_wipe + _spcd_bar_shut + _spcd_bar_echo + _spcd_bar_wipe } -_spcd_banner_shut() { - _spcd_banner_append \ - "${_SPCD_BANNER_TOP_RIGHT}" \ - "${_SPCD_BANNER_VERTICAL}" \ - "${_SPCD_BANNER_BOTTOM_RIGHT}" +_spcd_bar_shut() { + _spcd_bar_append \ + "${_SPCD_BAR_TOP_RIGHT}" \ + "${_SPCD_BAR_VERTICAL}" \ + "${_SPCD_BAR_BOTTOM_RIGHT}" } -_spcd_banner_split() { - _spcd_banner_append \ - "${_SPCD_BANNER_TOP_MIDDLE}" \ - "${_SPCD_BANNER_VERTICAL}" \ - "${_SPCD_BANNER_BOTTOM_MIDDLE}" +_spcd_bar_split() { + _spcd_bar_append \ + "${_SPCD_BAR_TOP_MIDDLE}" \ + "${_SPCD_BAR_VERTICAL}" \ + "${_SPCD_BAR_BOTTOM_MIDDLE}" } -_spcd_banner_wipe() { +_spcd_bar_wipe() { unset \ - __SPCD_BANNER_TOP \ - __SPCD_BANNER_MIDDLE \ - __SPCD_BANNER_BOTTOM + __SPCD_BAR_TOP \ + __SPCD_BAR_MIDDLE \ + __SPCD_BAR_BOTTOM } # ╭───┬───────╮ @@ -320,7 +320,7 @@ spcd_step() { local index="${prefix}_INDEX" eval "${index}=\$((${index} + 1))" eval "${prefix}_LABEL=\"${1}\"" - _spcd_banner_render + _spcd_bar_render fi }