commit: c3c6ba532055f01cde10882b67aecda00abd01e1
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sat Jun 10 07:10:48 2023 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Jun 10 07:15:56 2023 +0000
URL:
https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=c3c6ba53
Fix the order of the arguments used to compose the CUP sequence
The CUP (ECMA-48 CSI) sequence expects for the row to come first, and
the column second. I could have just swapped the arguments but, instead,
I have adjusted the surrounding code so as to strictly adhere to this
convention (one that is also observed by stty size). This should
eliminate the possibility of any such mistake being made in the future.
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Fixes: 20bc15b5b1009149c4a3d531911d3c219dc55f3a
functions.sh.in | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/functions.sh.in b/functions.sh.in
index 0c3e7ba..9be9978 100644
--- a/functions.sh.in
+++ b/functions.sh.in
@@ -270,7 +270,7 @@ _eend()
fi
# Stash the last known terminal dimensions, if any.
- set -- "${genfun_cols}" "${genfun_rows}"
+ set -- "${genfun_rows}" "${genfun_cols}"
# Check whether STDOUT is a terminal, and how capable it is.
_update_tty_level <&1
@@ -304,9 +304,9 @@ _eend()
# Provided that the terminal has not since been resized, it may
# be possible to write the indicator on the same row as the
# last printed message, even if it were LF-terminated.
- if [ "${genfun_cols}" -eq "$1" ] && [ "${genfun_rows}" -eq "$2"
]; then
+ if [ "${genfun_rows}" -eq "$1" ] && [ "${genfun_cols}" -eq "$2"
]; then
# Stash the current position of the cursor.
- set -- "${genfun_x}" "${genfun_y}"
+ set -- "${genfun_y}" "${genfun_x}"
# Using the DECRC sequence, restore the cursor position
# to wherever it was just after the last message was
@@ -324,11 +324,11 @@ _eend()
# preceding row. If it did, assume that scrolling has
# occurred since printing the last message and move the
# cursor back to where it was with CUP (ECMA-48 CSI).
- offset=$(( $2 - genfun_y ))
+ offset=$(( $1 - genfun_y ))
if [ "${offset}" -lt 0 ] || [ "${offset}" -gt 1 ]; then
printf '\033[%d;%dH' "$1" "$2"
- genfun_x=$1
- genfun_y=$2
+ genfun_y=$1
+ genfun_x=$2
fi
fi