@@ -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