Yes you can.
If you don't want to write your own code you can use a library like
ncurses[
^] (see also the
NCURSES Programming HOWTO[
^]).
If you want to write your own code, you may have a look at the
ncurses sources to see how it can be implemented.