diff --git a/functions b/functions index d2a5056..94a9a51 100644 --- a/functions +++ b/functions @@ -56,20 +56,20 @@ if [[ "$TERM" != "linux" ]] ; then lyl="${ESC}[38;5;228m" # light yellow lrd="${ESC}[38;5;196m" # light red gry="${ESC}[38;5;240m" # Grey - norm=$"${ESC}[39m" # default/normal + norm="${ESC}[39m" # default/normal # bld="${ESC}[1m" # bold unb="${ESC}[21m" # un-bold dim="${ESC}[2m" # dim und="${ESC}[22m" # un-dim unl="${ESC}[4m" # underline - nln="${ESC}[24" # not-underline - blk="${ESC}[5" # blinking - unbl="${ESC}[25" # stop blinking + nln="${ESC}[24m" # not-underline + blk="${ESC}[5m" # blinking + unbl="${ESC}[25m" # stop blinking inv="${ESC}[7m" # invert - rsinv="${ESC}[27" # reset http://www.endmemo.com/unicode/unicodeconverter.phpnvert - hid="${ESC}[8" # hidden - unh="${ESC}[28" # unhide + rsinv="${ESC}[27m" # reset invert + hid="${ESC}[8m" # hidden + unh="${ESC}[28m" # unhide dfl="${ESC}[0m" # restore default fi @@ -98,7 +98,8 @@ box_chars_simple() { set_box_chars() { if check_unicode_support; then - case "$OSTYPE" in + unicode_supported=true + case "$OSTYPE" in linux-gnu*|cygwin|msys) return_arrow=$(echo -e "\u2BAC") enter_arrow=$(echo -e "\u21B5") @@ -139,6 +140,7 @@ set_box_chars() { esac else # ASCII fallbacks + unicode_supported=false return_arrow=">" enter_arrow="<" green_check="+" @@ -258,28 +260,34 @@ set-boxtype() { # Ensure characters are defined set_box_chars update_terminal_width - + + # box-norm/double/heavy/light/rounded all draw with hardcoded Unicode corner + # glyphs; on a terminal without Unicode support, box_chars_simple() (called + # from set_box_chars above) already set full ASCII borders/corners, so skip + # the style dispatch entirely rather than clobbering them. + if [[ "$unicode_supported" != true && "$style" != "char" ]]; then + return + fi + # Set the box style - case $style in + case $style in norm) box-norm ;; double) box-double ;; heavy) box-heavy ;; light) box-light ;; rounded) box-rounded ;; char) box-singlechar ;; - *) + *) # Handle unknown box types by falling back to normal echo "Warning: Unknown box type '$style', falling back to 'norm'" >&2 boxtype="norm" - box-norm + if [[ "$unicode_supported" == true ]]; then + box-norm + fi ;; esac } - box-singlechar(){ - set_borders "$borderchar" "$borderchar" "$borderchar" "$borderchar" "$borderchar" "$borderchar" "$borderchar" "$borderchar" "-" -} - format_boxborder() { local alignment="left" local box_type="norm"