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.
26 lines
596 B
26 lines
596 B
#!/usr/bin/env bash |
|
|
|
# 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" |
|
} |
|
|
|
move_cursor "$@" |