0 votes
by (120 points)

With TerminalControl, when I set NewLineSequence to CR and LocalEcho On, the line I send is overwritten by the response. CR means carrige return, so this is kind of right, but my protocol uses CR only and I cannot add LF to the communication.

How can I add the missing LF to the local echo?

1 Answer

0 votes
by (15.2k points)

Hello, you can handle KeyPress event and write the LF to the terminal screen in that handler.

Here is how the code could look like:

// register KeyPress event handler, 
// probably in the constructor of the form
terminal.KeyPress += new KeyPressEventHandler(terminal_KeyPress);

void terminal_KeyPress(object sender, KeyPressEventArgs e)
    // if the pressed character is CR, write end of line
    // to the terminal screen
    if (e.KeyChar == '\r')

You can use KeyDown event in a similar way and use e.KeyCode to determine if the Enter was pressed.