Skip to content

Commit e492c31

Browse files
committed
Fix header card rendering with hardcoded echo layout
- Replace broken printf/box_line dynamic padding with simple echo -e - Hardcode spacing for reliable rendering across all terminals - Use printf only for theme line (variable length, pure ASCII) - Eliminate all Unicode padding bugs in the header card
1 parent 05bf12a commit e492c31

1 file changed

Lines changed: 31 additions & 67 deletions

File tree

bin/kodra

Lines changed: 31 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -36,46 +36,6 @@ GREEN='\033[38;5;114m'
3636
NC='\033[0m'
3737
BOLD='\033[1m'
3838

39-
# Box drawing
40-
BT=''
41-
BB=''
42-
BH=''
43-
BV=''
44-
BTR=''
45-
BBR=''
46-
47-
# Header card width (fits 80-col terminals)
48-
HW=58
49-
50-
# Draw a horizontal border line
51-
draw_border_top() {
52-
if [ "$1" = "plain" ]; then
53-
printf " +"; printf '%0.s-' $(seq 1 $HW); echo "+"
54-
else
55-
printf " ${DIMMER}${BT}"; printf '%0.s─' $(seq 1 $HW); echo -e "${BTR}${NC}"
56-
fi
57-
}
58-
draw_border_bot() {
59-
if [ "$1" = "plain" ]; then
60-
printf " +"; printf '%0.s-' $(seq 1 $HW); echo "+"
61-
else
62-
printf " ${DIMMER}${BB}"; printf '%0.s─' $(seq 1 $HW); echo -e "${BBR}${NC}"
63-
fi
64-
}
65-
66-
# Print a padded line inside the box
67-
box_line() {
68-
local content="$1"
69-
local visible_len="$2"
70-
local pad=$((HW - visible_len - 2))
71-
[ $pad -lt 0 ] && pad=0
72-
if [ "$3" = "plain" ]; then
73-
printf " | %s%*s |\n" "$content" "$pad" ""
74-
else
75-
printf " ${DIMMER}${BV}${NC} %b%*s ${DIMMER}${BV}${NC}\n" "$content" "$pad" ""
76-
fi
77-
}
78-
7939
# Get current theme name
8040
get_current_theme() {
8141
if [ -f "$HOME/.config/kodra/theme" ]; then
@@ -98,20 +58,23 @@ show_help() {
9858

9959
if [ "$use_color" = true ]; then
10060
# ── Boxed header card ──
101-
draw_border_top
102-
box_line "" 0
103-
box_line "${C1}██╗ ██╗${C2} ██████╗ ${C3}██████╗ ${C4}██████╗ ${C5} █████╗${NC}" 40
104-
box_line "${C1}██║ ██╔╝${C2}██╔═══██╗${C3}██╔══██╗${C4}██╔══██╗${C5}██╔══██╗${NC}" 41
105-
box_line "${C1}█████╔╝ ${C2}██║ ██║${C3}██║ ██║${C4}██████╔╝${C5}███████║${NC}" 41
106-
box_line "${C1}██╔═██╗ ${C2}██║ ██║${C3}██║ ██║${C4}██╔══██╗${C5}██╔══██║${NC}" 41
107-
box_line "${C1}██║ ██╗${C2}╚██████╔╝${C3}██████╔╝${C4}██║ ██║${C5}██║ ██║${NC}" 41
108-
box_line "${C1}╚═╝ ╚═╝${C2} ╚═════╝ ${C3}╚═════╝ ${C4}╚═╝ ╚═╝${C5}╚═╝ ╚═╝${NC}" 41
109-
box_line "" 0
110-
box_line "${WHITE}v${VERSION}${NC} ${DIMMER}·${NC} ${DIM}A Code To Cloud Project${NC}" $((3 + ${#VERSION} + 3 + 23))
111-
box_line "${DIM}kodra.codetocloud.io${NC}" 20
112-
box_line "" 0
113-
box_line "${DIM}Theme:${NC} ${GREEN}${current_theme}${NC} ${DIMMER}·${NC} ${DIM}Install:${NC} ${DIM}${KODRA_DIR}${NC}" $((7 + ${#current_theme} + 3 + 10 + ${#KODRA_DIR}))
114-
draw_border_bot
61+
echo -e " ${DIMMER}╭──────────────────────────────────────────────────╮${NC}"
62+
echo -e " ${DIMMER}${NC} ${DIMMER}${NC}"
63+
echo -e " ${DIMMER}${NC} ${C1}██╗ ██╗${C2} ██████╗ ${C3}██████╗ ${C4}██████╗ ${C5} █████╗${NC} ${DIMMER}${NC}"
64+
echo -e " ${DIMMER}${NC} ${C1}██║ ██╔╝${C2}██╔═══██╗${C3}██╔══██╗${C4}██╔══██╗${C5}██╔══██╗${NC} ${DIMMER}${NC}"
65+
echo -e " ${DIMMER}${NC} ${C1}█████╔╝ ${C2}██║ ██║${C3}██║ ██║${C4}██████╔╝${C5}███████║${NC} ${DIMMER}${NC}"
66+
echo -e " ${DIMMER}${NC} ${C1}██╔═██╗ ${C2}██║ ██║${C3}██║ ██║${C4}██╔══██╗${C5}██╔══██║${NC} ${DIMMER}${NC}"
67+
echo -e " ${DIMMER}${NC} ${C1}██║ ██╗${C2}╚██████╔╝${C3}██████╔╝${C4}██║ ██║${C5}██║ ██║${NC} ${DIMMER}${NC}"
68+
echo -e " ${DIMMER}${NC} ${C1}╚═╝ ╚═╝${C2} ╚═════╝ ${C3}╚═════╝ ${C4}╚═╝ ╚═╝${C5}╚═╝ ╚═╝${NC} ${DIMMER}${NC}"
69+
echo -e " ${DIMMER}${NC} ${DIMMER}${NC}"
70+
echo -e " ${DIMMER}${NC} ${WHITE}v${VERSION}${NC} ${DIMMER}·${NC} ${DIM}A Code To Cloud Project${NC} ${DIMMER}${NC}"
71+
echo -e " ${DIMMER}${NC} ${DIM}kodra.codetocloud.io${NC} ${DIMMER}${NC}"
72+
echo -e " ${DIMMER}${NC} ${DIMMER}${NC}"
73+
local theme_text=" Theme: ${current_theme}"
74+
local theme_pad=$((50 - ${#theme_text}))
75+
[ $theme_pad -lt 1 ] && theme_pad=1
76+
printf " ${DIMMER}${NC} ${DIM}Theme:${NC} ${GREEN}${current_theme}${NC}%*s${DIMMER}${NC}\n" "$theme_pad" ""
77+
echo -e " ${DIMMER}╰──────────────────────────────────────────────────╯${NC}"
11578
echo ""
11679

11780
# ── Commands ──
@@ -170,19 +133,20 @@ show_help() {
170133
echo -e " ${DIM}→ Run ${WHITE}kodra doctor${DIM} if something feels off${NC}"
171134
else
172135
# ── Plain text fallback ──
173-
draw_border_top plain
174-
box_line "██╗ ██╗ ██████╗ ██████╗ ██████╗ █████╗" 40 plain
175-
box_line "██║ ██╔╝██╔═══██╗██╔══██╗██╔══██╗██╔══██╗" 41 plain
176-
box_line "█████╔╝ ██║ ██║██║ ██║██████╔╝███████║" 41 plain
177-
box_line "██╔═██╗ ██║ ██║██║ ██║██╔══██╗██╔══██║" 41 plain
178-
box_line "██║ ██╗╚██████╔╝██████╔╝██║ ██║██║ ██║" 41 plain
179-
box_line "╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝" 41 plain
180-
box_line "" 0 plain
181-
box_line "v${VERSION} · A Code To Cloud Project" $((3 + ${#VERSION} + 3 + 23)) plain
182-
box_line "kodra.codetocloud.io" 20 plain
183-
box_line "" 0 plain
184-
box_line "Theme: ${current_theme} · Install: ${KODRA_DIR}" $((7 + ${#current_theme} + 3 + 10 + ${#KODRA_DIR})) plain
185-
draw_border_bot plain
136+
echo " +--------------------------------------------------+"
137+
echo " | |"
138+
echo " | ██╗ ██╗ ██████╗ ██████╗ ██████╗ █████╗ |"
139+
echo " | ██║ ██╔╝██╔═══██╗██╔══██╗██╔══██╗██╔══██╗ |"
140+
echo " | █████╔╝ ██║ ██║██║ ██║██████╔╝███████║ |"
141+
echo " | ██╔═██╗ ██║ ██║██║ ██║██╔══██╗██╔══██║ |"
142+
echo " | ██║ ██╗╚██████╔╝██████╔╝██║ ██║██║ ██║ |"
143+
echo " | ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ |"
144+
echo " | |"
145+
echo " | v${VERSION} · A Code To Cloud Project |"
146+
echo " | kodra.codetocloud.io |"
147+
echo " | |"
148+
echo " | Theme: ${current_theme} |"
149+
echo " +--------------------------------------------------+"
186150
echo ""
187151
echo " Usage: kodra <command> [options]"
188152
echo ""

0 commit comments

Comments
 (0)