You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
698 B
29 lines
698 B
#!/usr/bin/env sh |
|
|
|
# This magical spell moves the cursor to the specified x and y coordinates in the terminal window, as if guided by an unseen hand. |
|
|
|
# Define the function to move the cursor |
|
move_cursor() { |
|
x=$1 |
|
y=$2 |
|
|
|
# Move the cursor to the specified position |
|
printf "\033[${y};${x}H" |
|
} |
|
|
|
# Unit test |
|
test_move_cursor() { |
|
. assertions |
|
initial_x=$(fathom-cursor -x) |
|
initial_y=$(fathom-cursor -y) |
|
move_cursor 3 4 |
|
final_position=$(fathom-cursor) |
|
assert_equal $final_position "3;4" |
|
move_cursor $initial_x $initial_y |
|
echo "All tests passed" |
|
} |
|
|
|
# Check if the script is being sourced, and run it if not |
|
if [ "${BASH_SOURCE[0]}" = "$0" ]; then |
|
move_cursor "$@" |
|
fi
|
|
|