2

When I press enter while my terminal program runs, a new line is added. How can I disable this? I don't want to use ncurses. I am on Ubuntu.

n. m. could be an AI
  • 112,515
  • 14
  • 128
  • 243
gartenriese
  • 4,131
  • 6
  • 36
  • 60

1 Answers1

1

Following up n.m's hint, I found this and came up with this:

static struct termios t;
tcgetattr( STDIN_FILENO, &t);
t.c_lflag &= ~ECHO;
tcsetattr( STDIN_FILENO, TCSANOW, &t);

This seems to block all input to the terminal.

Community
  • 1
  • 1
gartenriese
  • 4,131
  • 6
  • 36
  • 60
  • You *probably* also want to set either non-canonical mode, or "raw" mode, and echo all normal (non-control) characters yourself. See `man termios`. – n. m. could be an AI Jan 20 '14 at 10:08