Reset the terminal control data

0 votes
asked Jun 9, 2014 by Rebex KB (8,190 points)
edited Jul 16, 2014

I want to clear the data which is entered in Terminal Control, I've used ResetText() and Screen.Clear() methods to do so, but they couldn't help me out. Could you please suggest me the possibilities.

2 Answers

0 votes
answered Jun 9, 2014 by Tomas Knopp (58,890 points)
edited Jun 9, 2014

Hello,

I have checked it with the latest 2014R1 version of Rebex Terminal Emulation component and the ITerminal.Screen.Clear(bool) method should work and it should clear the terminal console as well as history (if you specify 'true' in the argument) as in the example below:

terminal.Screen.Clear(true);

where terminal is an instance of VirtualTerminal (GUI-less terminal control) or TerminalControl (a GUI windows forms control).

However, if you plan to do terminal scripting in your application, then we suggest you to try our latest trial beta of Rebex Virtual Terminal component which will be released as part of 2014R2. It adds a brand new Scripting class with a new and much more comfortable API for scripting. Here is a short sample of how the Scripting API is to be used in combination with existing TerminalControl / VirtualTerminal classes if you use the beta build:

        string username = "user";
        string password = "password";

        var terminal = new TerminalControl();

        this.Controls.Add(terminal);

        // connect to the server and bind TerminalControl
        Ssh client = new Ssh();
        client.Connect("SshServer");
        client.Login(username, password);
        terminal.Bind(client);

        // the rest of this code can be safely called from a background thread

        // disable automated response processing
        terminal.SetDataProcessingMode(DataProcessingMode.None);

        // get the scripting object
        Scripting scripting = terminal.Scripting;

        // wait for "Last login:" prompt
        scripting.WaitFor(ScriptEvent.FromString("Last login:"));

        // detect prompt
        scripting.DetectPrompt();

        // clear the screen
        terminal.Screen.Clear(true);

        // send some command
        scripting.SendCommand("some-command");
        // if wait is needed, uncomment next line and specify a delay
        //scripting.WaitFor(ScriptEvent.Delay(200));

        // send an 'exit' command to close the connection
        scripting.SendCommand("exit");
0 votes
answered Jul 16, 2014 by Pavel Matyska (12,440 points)
edited Jul 16, 2014

The new Scripting API is released as 2014-R2 release.

...