Closed papajoker closed 8 years ago
For me it causes non distruptive but noticeable delay in preinting the menu - almost like a animation.
It also causes a weird typo in item 21. The last r from aur is cut off for some reason, don't know why, as it is present it the text to be printed.
Also, modifying WMENU variable does not alter widht of the menu cleanly. Any other value than 68 seems to break the frame of the menu.
I think it is good idea, but needs a bit more polishing. It makes code less legible for me, even though it is simpler in reality.
fix only pair for WMENU is good, a code test and inc if not pair. Add 2 temp options ONLY for tests (not align titles...)
./pacli -w 99 -t
./pacli -w 40 -t
-w : set WMENU -t : add a line with two longs items
with -t we can view that item is truncated for have always a good align (nice for translate) in my idea, WMENU is just changed by developers (or even for a translation?)
if menu items were in a table, we could even calculate WMENU based on the largest item ... no troncate, but size calculated by text items... for exemple :
declare -a MENUS=(
":┌─┐:"
"1:Update System"
"2:Clean System"
"3:Install Package:$RED"
":└─┘:"
":┌─┐:"
"21:Search + Install from AUR"
":└─┘:"
)
# calculate WMENU from items
item_long=0
for i in "${MENUS[@]}"; do
i=${i##*:}
l=${#i}
((l > item_long )) && item_long=$l
done
(( ww=(item_long+9)*2 )) # add number and spaces
echo "item max=$item_long and wmenu mini =$ww"
With my small pc (one proc with one core) AMD V140 2.3GHz and 2Mb ram the print sreen is fast and fluid as "old" version. Its also possible to have 2 functions : one at begining make_menu() save chars in $var and a second in the loop "while" for print this $var
yes it requires more code, but it is the only technical solution if you want translate menus. Then is very simple to make .po and .mo translation or upload files like cvs. And the day or you want change an item menu, the maneuver is simpler than the current one.
Okay, thanks for extended explanation!
rewrite menu in functions :