diff options
author | Kerin Millar <kfm@plushkava.net> | 2023-06-10 08:10:48 +0100 |
---|---|---|
committer | Kerin Millar <kfm@plushkava.net> | 2023-06-10 08:15:56 +0100 |
commit | c3c6ba532055f01cde10882b67aecda00abd01e1 (patch) | |
tree | fadbf33074c09914fcda4b7cde4c1baf91a56b65 | |
parent | Ensure that ebegin() appends a newline to the final message (diff) | |
download | gentoo-functions-c3c6ba532055f01cde10882b67aecda00abd01e1.tar.gz gentoo-functions-c3c6ba532055f01cde10882b67aecda00abd01e1.tar.bz2 gentoo-functions-c3c6ba532055f01cde10882b67aecda00abd01e1.zip |
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@plushkava.net>
Fixes: 20bc15b5b1009149c4a3d531911d3c219dc55f3a
-rw-r--r-- | functions.sh.in | 12 |
1 files 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 |