I have created an SSH client in WinForms (C#) using Rebex.TerminalEmulation.TerminalControl. I am able to successfully connect, execute commands from the terminal and intercept SSH shell commands when the user presses the ENTER key on the control. This works correctly for single-line commands. However, I need a way to capture the complete command when it spans multiple lines and the user presses ENTER.

For example, in the first case (Green), the command “curl -v telnet://google.com:443” is a single-line command. It can be successfully captured as the last line on the TerminalControl using the Screen.GetRegionText() function.
However, in the second case (Red), the command spans two lines. When intercepted using Screen.GetRegionText(), it only captures “:443” instead of the complete command curl -v “telnet://abc.xyz.google.com:443”.
In many scenarios, user may enter commands that span 3, 4, 5, or even more lines in the terminal. Is there a way to properly capture or intercept the full multi-line command instead of just the last line?