views:

68

answers:

4

Hi,

I am writing a commandline calculator in C, and it would be very useful if it had the ability to move the cursor each time you close (for example) a parenthesis highlighting the previous one, like in emacs, etc.

For example, if you launch emacs, and type:

(blah)

then for a while after you type the closing parenthesis, the first one is highlighted.

I've tried some googling, but I don't really know what to search for.

Is there a simple and multiplatform (at the very least it's fine if it'd work on Linux, but I'd like it to work at least on Windows as well) way to move the cursor in this way?

+1  A: 

The things you should search for are 'termcap', 'terminfo' or 'curses.'

nsayer
A curses implementation is what you want. There's not really termcap or terminfo for windows, however.
Thanatos
+1  A: 

ncurses should be able to do what you're asking for.

You
+1  A: 

If you want better control over the console, take a look at the ncurses library.

The Linux console can also be controlled through console codes. No libraries needed, just printf the appropriate codes to stdout.

bta
+1  A: 

Check out ANSI escape codes. They are pretty basic, but a good place to start. The upshot is that they work for most terminals (Linux and Windows).

zdav