-
-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Major improvement in how and when the dashboard is drawn #268
Conversation
Nice! |
Two modifications were necessary:
|
a107871
to
7e8a510
Compare
db52018
to
6a02535
Compare
I tested it and it seems to work as expected. How are x and y offset supposed to work? Are they quantities a user has to supply or is it rather meant to automagically center the most suitable PADD variant on any given terminal (may it be as large as it wants). edit NVM, I found it is a manual process: setOffsets(){
# sets x/y-offsets (for shifting the Dashboard within the screen) if CLI arguments were passed
i=1;
j=$#;
while [ $i -le $j ]
do
case "$1" in
"-xoff" ) xOffset="$2";;
"-yoff" ) yOffset="$2";;
esac
i=$((i + 1));
shift 1;
done
} but how about the idea of the automatic centering? I could even imagine that this would be a nice by-default option with the possibility to specify |
@rdwebdesign has a follow up PR based on this one that will automatically center. |
I'm just waiting this PR to be approved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, after some further testing, I see another issue when defining offsets. When I specify an Y-offset that is would cause a reduction to the next smaller screen size, the offset is not (or only partially) acknowledged. I guess that's by design. (?)
However, the same does not work for X-offset. Given my terminal is wide enough for a given size, this size will be picked even if I have an X-offset resulting in wrapping to the next line and destroying the entire display.
Pictures
Initial terminal size is 83x30
Reduction in Y by 1 (83x29) removes the empty line at the bottom (okay):
Further reductions in Y (83x27 in this example) reduces the top offset (okay):
(back to initial size of 83x30)
Reduction in X by 1 (82x30) causes two additional linebreaks in FTL and SYSTEM causing the Y-offset to decrease:
Further reduction in X (81x30) finally causes destruction all over the place:
I can confirm with a different approach: Example: With a window of 85x30, there are 5 columns more than "mega" needs. If I start PADD with The same occurs with |
I think I got it. At the end of # Limit the offset to avoid breaks
xMaxOffset=$(($console_width - $width))
yMaxOffset=$(($console_height - $height))
if [ "$xOffset" -gt "$xMaxOffset" ]; then
xOffset="$xMaxOffset"
fi
if [ "$yOffset" -gt "$yMaxOffset" ]; then
yOffset="$yMaxOffset"
fi |
Temporarily converting to a draft until we've found a solution. @rdwebdesign's suggestion doesn't solve all cases. |
My solution only works for my new code (including the center function and all changes I made there). |
Try this code, please: SizeChecker(){
# adding a tiny delay here to to give the kernel a bit time to
# report new sizes correctly after a terminal resize
# this reduces "flickering" of GenerateSizeDependendOutput() items
# after a terminal re-size
sleep 0.1
console_height=$(stty size | awk '{ print $1 }')
console_width=$(stty size | awk '{ print $2 }')
# Below Pico. Gives you nothing...
if [ "$console_width" -lt "20" ] || [ "$console_height" -lt "10" ]; then
# Nothing is this small, sorry
printf "%b" "${check_box_bad} Error!\n PADD isn't\n for ants!\n"
exit 1
# Below Nano. Gives you Pico.
elif [ "$console_width" -lt "24" ] || [ "$console_height" -lt "12" ]; then
padd_size="pico"
width=20
height=10
# Below Micro, Gives you Nano.
elif [ "$console_width" -lt "30" ] || [ "$console_height" -lt "16" ]; then
padd_size="nano"
width=24
height=12
# Below Mini. Gives you Micro.
elif [ "$console_width" -lt "40" ] || [ "$console_height" -lt "18" ]; then
padd_size="micro"
width=30
height=16
# Below Tiny. Gives you Mini.
elif [ "$console_width" -lt "53" ] || [ "$console_height" -lt "20" ]; then
padd_size="mini"
width=40
height=18
# Below Slim. Gives you Tiny.
elif [ "$console_width" -lt "60" ] || [ "$console_height" -lt "21" ]; then
padd_size="tiny"
width=53
height=20
# Below Regular. Gives you Slim.
elif [ "$console_width" -lt "80" ] || [ "$console_height" -lt "22" ]; then
padd_size="slim"
width=60
height=21
# Below Mega. Gives you Regular.
elif [ "$console_width" -lt "80" ] || [ "$console_height" -lt "26" ]; then
padd_size="regular"
width=60
height=22
# Mega
else
padd_size="mega"
width=80
height=26
fi
# Limit the offset to avoid breaks
xMaxOffset=$(($console_width - $width))
yMaxOffset=$(($console_height - $height))
if [ "$xOffset" -gt "$xMaxOffset" ]; then
xOffset="$xMaxOffset"
fi
if [ "$yOffset" -gt "$yMaxOffset" ]; then
yOffset="$yMaxOffset"
fi
} |
@rdwebdesign Thanks, that surely improves the situation but it overwrites the offsets. Once the terminal got small enough, it won't add the offset if the terminal is made larger again. Surely this isn't an issue if we're dealing with displays with constant resolution, however, it feels strange when we have interactive terminals. This fix will be simple and I'll apply and push it (47d28c2). However, there is another issue. Assume no offsets are set (to make it easier):
My last commit (524ec8f) fixes this. |
Sorry that this comes piece-by-piece but there is just so much to test on this... I found a typo that broke There would be enough space in |
Signed-off-by: Christian König <ckoenig@posteo.de>
Signed-off-by: Christian König <ckoenig@posteo.de>
Signed-off-by: Christian König <ckoenig@posteo.de>
Signed-off-by: Christian König <ckoenig@posteo.de>
Signed-off-by: Christian König <ckoenig@posteo.de>
Signed-off-by: Christian König <ckoenig@posteo.de>
Signed-off-by: DL6ER <dl6er@dl6er.de>
…l is getting larger (after having been small before) Signed-off-by: DL6ER <dl6er@dl6er.de>
Signed-off-by: DL6ER <dl6er@dl6er.de>
Signed-off-by: DL6ER <dl6er@dl6er.de>
Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
Co-authored-by: RD WebDesign <github@rdwebdesign.com.br> Signed-off-by: yubiuser <ckoenig@posteo.de>
Thanks for your input. Works really nice now. I added rd's suggestion about removing the auxiliary variables and rebased on Ready for re-review |
Note: I think the issue will be fixed by #272 |
Yes. This should be addressed in #272 |
What does this PR aim to accomplish?:
Major improvement in how and when the dashboard is drawn.
xoff
andyoff
as offsets to move the dashboard within the terminal. Fixes Reinstate methods CleanPrintf and CleanEcho? (commit 2b406c1) #266How does this PR accomplish the above?:
WINCH
and executesTerminalResize()
tput
(which has a lot of overhead), making the script more portableGenerateSizeDependendOutput
)CleanExit
function to restore the terminal functions on exitP.S. Adding
y-offset
was easy, as it was simply moving the "cursor" y-times down. I tried implementingx-offset
withleft margin
functions (DECLRMM
,DECSLRM
andDECOM
). Unfortunately, those are not supported by most terminal emulators (got it working onxterm
), see https://terminalguide.namepad.de/mode/ So I needed to implement it on every line of the dasboard individually.By submitting this pull request, I confirm the following:
git rebase
)