stty RAW console in C

I'm trying to build my own console and I'm using the below statement to get RAW access so I can implement some advanced features such as implementing the auto suggest feature that's implemented in a BASH shell by pressing the TAB key.

system("/bin/stty raw")

When using this, the enter key (and others) doesn't behave normally and when I press enter, it displays ^M and doesn't go to the next line.

  • How do I set the RAW console to go to the next line when it receives ^M

  • Also can I set the Shell to NOT display the keys pressed so I can send the char back to the console with putchar() (so ^M doesn't display when pressed).

  • Thanks


    How do I set the RAW console to go to the next line when it receives ^M

    You write an appropriate control code to the console when you read an ^M. The whole point of raw mode is that the console does not do things like recognize line ends, backspaces, etc., etc., because you want to handle them yourself. Once you do that, you need to handle all those things.

    can I set the Shell to NOT display the keys pressed

    Sure. Turn off echo . With the stty command, you would use stty raw -echo but if you're doing this from a C program, you'd be much better off using the terminal API. See man tcsetattr

    链接地址: http://www.djcxy.com/p/25706.html

    上一篇: ^? 在stty输出意味着什么?

    下一篇: C中的stty RAW控制台