Caleb Waggoner
Caleb Waggoner

Reputation: 147

How can output be directed to specific coordinates in the linux terminal?

To be more specific, I am looking for an equivalent to the Windows API function: WriteConsoleOutputCharacter. I know this style of direct output is possible, as I have seen the behaviour used before in the time that I have used Linux. However, I am still a baby when it comes to Linux specific C libraries, and have not been able to ascertain any clues as to where I may find such functionality. Any assistance would be appreciated.

Upvotes: 1

Views: 1809

Answers (3)

aanatoly
aanatoly

Reputation: 19

This line will put a clock in right upper conner of a terminal (from commandlinefu.com)

while sleep 1;do tput sc;tput cup 0 $(($(tput cols)-29));date;tput rc;done

Upvotes: -1

aanatoly
aanatoly

Reputation: 19

You can use the ANSI control sequence

Say, following will print 'ddd' string 3 lines above the prompt in bash

echo -e "\e[3Addd"

Upvotes: 2

Ari
Ari

Reputation: 3127

Check out ncurses library.

It allows you to create some text-based UI in terminal. It is more than you asked, but if you need more than only this one function it may be best option for you.

Upvotes: 3

Related Questions