I developed for my university a mini-shell. For parse the command line I use lex and yacc.
When I press up/down/left/right arrow the string "^[[A or B or C or D is displayed.
Is it possible to recognize this character for execute action when this key is pressed ? Maybe using the functions of ncurses library (I'm in Linux)?
I show, the bash use yacc grammar ( https://en.wikipedia.org/wiki/GNU_bison ) and we can use the arrow key. So I think is possible.
Thank you.
ncurses
does handle — or you may want to look at the GNU Readline library (which is closer to what is used by Bash, I believe). Note that different terminal types send different character sequences for up-arrow; you may need some of the facilities from termcap or terminfo to handle the terminal dependencies. – Jonathan Lefflerrlwrap ./my-mini-shell
to get the behavior without any change. – Rudi