gibertoni
gibertoni

Reputation: 1378

Handle keyboard input on shell

I am developing a custom shell like bash (in C). I am working right now on the events triggered by the arrows and the tab key. However, those special keys should be handled correctly.

What I want is to capture those keys and not let the CLI draw them on screen. What happens is that when the up arrow is pressed, for example, it draws the following symbol: '^[[A'

How can I stop it from happening? And what is the best way to read and map those keys?

Upvotes: 0

Views: 368

Answers (1)

Intrepidd
Intrepidd

Reputation: 20868

It's kind of old, but some shells use terminal capabilities (termcaps) to block output and move the cursor.

You can also use the lib ncurses that is a cool wrapper for termcaps.

Upvotes: 1

Related Questions