Reputation: 4293
I am working on a terminal style application in c (on eclipse running on fedora), and I want to use the direction keys to navigate around the program. Does anyone know how to do this while keeping a line in place for the user to enter still text, but have the key presses do other things?
Upvotes: 0
Views: 111
Reputation: 112366
Yes, but it quickly gets ugly coding it. However, pick up the package ncurses and all will become clear.
Basically, the trick is that you must set the terminal device to "raw" mode so you can get the special key sequences directly in your program, then have to interpret them -- they tend to be things like "<ESC>33;5A
". Then you need to emit the control sequences that move you around on the screen, and all of these things are device dependent so xterm may differ from gterm and so on.
ncurses(3) already hides all that stuff.
See here for the software home page, and here for a tutorial.
Upvotes: 4