Skip to content

Commit 8dea5e3

Browse files
committed
Working on Border for ezk menu
1 parent fad29ee commit 8dea5e3

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

EasyKey.git/git.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ git fetch --all --tags 2> /dev/null
1616
while ${continuemenu:=true}; do
1717
clear
1818
menuInit "EasyKey.git"
19+
echo
1920
submenuHead "Working with remotes:"
2021
menuItemClm a "Gently push current" pushActual b "Set remote origin repo" setRemoteOrigin
2122
menuItemClm e "Set upstream to current" setUpstream f "Administer remotes" adminRemotes

shellmenu.sh

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -467,10 +467,10 @@ generateMenu () {
467467
fi
468468
IFS="$delimiter" read -r key description action submenu menu column <<< "${menudatamap[index]}"
469469
IFS="$delimiter" read -r nextkey nextdescription nextaction nextsubmenu nextmenu nextcolumn <<< "${menudatamap[((index+1))]}"
470-
if [ "$index" -eq "0" ]; then generatedmenu+=$(printMenuHeading "$menu"); fi
470+
if [ "$index" -eq "0" ]; then generatedmenu+=$(printMenuHeading "$menu"); generatedmenu+=$(printf "\n\r"); fi
471471
if [ "$submenu" != "$previoussubmenu" ]; then
472472
if [ "$submenucount" -gt 0 ]; then generatedmenu+=$(printf "\n\r"); fi
473-
generatedmenu+=$(printSubmenuHeading "$submenu" && echo)
473+
generatedmenu+=$(printSubmenuHeading "$submenu")
474474
submenucount=$(( submenucount+1 ));
475475
fi
476476
if [ "$((nextcolumn))" -eq "$((column + 1))" ]; then
@@ -614,9 +614,9 @@ draw_rounded_square() {
614614

615615
# Menu title cache
616616
if [ "$formattedTop" != "" ]; then
617-
echo -e "$formattedTop"
618-
echo -e "$formattedMiddle"
619-
echo -e "$formattedBottom"
617+
printf "$formattedTop\n\r"
618+
printf "$formattedMiddle\n\r"
619+
printf "$formattedBottom\n\r"
620620
return
621621
fi
622622

@@ -652,7 +652,6 @@ draw_rounded_square() {
652652
formattedBottom=$(tput setaf $clrWhite)$(tput setab $clrBlue)$(tput bold)$border$(tput sgr0)
653653
printf "$formattedBottom\n\r"
654654

655-
printf "\n\r"
656655
}
657656

658657
######################################################
@@ -699,3 +698,32 @@ initConfig () {
699698
((i++))
700699
done <<< "$(echo -e "$configlines")"
701700
}
701+
702+
draw_border() {
703+
multiline_string="$1"
704+
705+
lines=()
706+
while IFS= read -r line; do
707+
lines+=("$line")
708+
done <<< "$multiline_string"
709+
710+
# Find the longest line length
711+
max_length=0
712+
for line in "${lines[@]}"; do
713+
length=${#line}
714+
if (( length > max_length )); then
715+
max_length=$length
716+
fi
717+
done
718+
719+
# Print the top line of the square
720+
echo "+"$(printf "%-${max_length}s" | tr ' ' '-')"+"
721+
722+
# Print the multiline string with side borders
723+
for line in "${lines[@]}"; do
724+
printf "| %-${max_length}s |\n" "$line"
725+
done
726+
727+
# Print the bottom line of the square
728+
echo "+"$(printf "%-${max_length}s" | tr ' ' '-')"+"
729+
}

0 commit comments

Comments
 (0)