Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an ANSI control sequence which moves the cursor to the end of line?

Tags:

ansi-escape

I know of \33[nC which moves the cursor n columns forward; the problem is, I don't know how many characters the particular line consists of.

like image 518
bart2287 Avatar asked Oct 28 '25 00:10

bart2287


2 Answers

There is nothing explicit, however screens are "small", and you could use any of the cursor-movement commands to move to an arbitrarily far destination and the terminal will limit the movement by the screen's size.

For instance, the cursor-forward (in terminfo, cuf) control uses a repeat-count, and horizontal position absolute (in terminfo, hpa) control uses a column value. Either of these should work for you:

tput cuf 999
tput hpa 999

(assuming that your screen has fewer than a thousand columns). There are others which may be implemented in your terminal (emulator...), but those are fairly common.

By the way, for hardcoding, cuf is the same as the example in the question. That's columns, not lines which are moved. To move the cursor by lines, you would use cud (escape> [nB).

like image 105
Thomas Dickey Avatar answered Oct 30 '25 21:10

Thomas Dickey


No, there is no such ANSI control sequence.

like image 31
erip Avatar answered Oct 30 '25 22:10

erip



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!