Click here to Skip to main content
15,885,182 members
Articles / Desktop Programming / Windows Forms

Terminal Control Library (C# VT100/ANSI/XTERM SSH Telnet)

Rate me:
Please Sign up or sign in to vote.
4.59/5 (27 votes)
2 Jan 2009CPOL3 min read 349.2K   13.3K   72   106
This is based on Poderosa Project http://sourceforge.net/projects/poderosa/

Introduction

My original project can be found here.

I've been trying for a while to come up with a .NET control that would handle VT100/ANSI formatting and connect to SSH2 servers.

I've been through the commercial ones and still haven't found one that suited me.

My last project was based on Granados SSH library (open source SSH .NET implementation) and AckTerm (open source partially completed VT100 control).

Background

This library is an attempt at creating a library based on the "Poderosa" project which can be found here.

Poderosa IMO is the best terminal emulator. It's open source, and is better than the commercial clients. Go check it out for yourself, it's worth it. You can find the original Poderosa CSV source there.

I tried for a couple of weeks to encapsulate components of Poderosa, but the code comments are all in Japanese and I couldn't find any good docs that described the source code. The developer community for Poderosa also appears to be all Japanese, so I felt pretty much on my own.

Using the Code

What I pretty much did here was encapsulate the entire Poderosa application into a library. Then I exposed certain elements so an application developer can simply drop the "Terminal Control.dll" into his/her app and have a control that acts like you would expect any .NET control to act.

This code was written using Visual Studio .NET 2005 Professional and requires .NET Framework 2.0.

Points of Interest

The Poderosa solution is made up of 5 projects:

  1. Container - This is the actual Poderosa application
  2. Terminal - A library providing Telnet capabilities as well as the Terminal Emulation
  3. Common - Code that is shared between the Poderosa application and the Port Forwarding Tool
  4. Granados - SSH library that supports just about every feature of SSH
  5. Portforwarding - A standalone application (uses Terminal, Common, and Granados libraries) that provides SSH portforwarding functionality

First Step

What I've done with my library, was to change "Container" into a Library output, and implement a public class based on System.Windows.Forms.Control.

Second Step

The first time my class ("WalburySoftware.TerminalControl") is instanced, it runs Poderosa code:

C#
GApp.Run(args); GApp._frame._multiPaneControl.InitUI(null, GApp.Options);
GEnv.InterThreadUIService.MainFrameHandle = GApp._frame.Handle; 

Poderosa has lots and lots and lots of static variables. Until I can get the time and motivation to go through them and make the appropriate changes, these variables will need to be initialized before you can use any of Poderosa's classes.

Third Step

If you look at the method Poderosa.ConnectionCommandTarget.Resize, you'll see the line:

C#
if(GEnv.Connections.FindTag(_connection).ModalTerminalTask!=null) 
	return CommandResult.Denied 

This throws an exception. I took it out because it doesn't do anything for my library. I'm not sure what the ModalTerminalTask variable is used for. If you include that line, the terminal will not resize properly.

Final Step

Now we are free to create and use TerminalPanes as we need.

You'll see the steps in WalburySoftware.TerminalControl.Connect() that connect the TerminalPane to an SSH2 connection.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionI Love this control Pin
Member 1487243431-Jul-22 22:57
Member 1487243431-Jul-22 22:57 
QuestionSometimes Keyexchange error Pin
Win32nipuh30-Sep-17 20:42
professionalWin32nipuh30-Sep-17 20:42 
QuestionAbout Midnight commander Pin
Win32nipuh30-Sep-17 2:55
professionalWin32nipuh30-Sep-17 2:55 
QuestionVery Nice Pin
khalid kalyar9-Aug-16 21:22
khalid kalyar9-Aug-16 21:22 
QuestionDivide(/) key and NumLock key issue - not able to send the correct keycodes Pin
Priyanka Lalchandani19-May-16 23:37
Priyanka Lalchandani19-May-16 23:37 
QuestionVI doesn't seem to work Pin
denson3-May-16 8:41
denson3-May-16 8:41 
Question!!! http://dj9okeyxktdvd.cloudfront.net/script/Forums/Images/smiley_smile.gif !!! Pin
Member 1147611928-Feb-15 8:33
Member 1147611928-Feb-15 8:33 
QuestionHas anyone tried to implement this to serial port? Pin
ElectroMonster18-Dec-14 11:47
ElectroMonster18-Dec-14 11:47 
QuestionMy vote of 5 Pin
eceprabhu15-Dec-14 23:36
eceprabhu15-Dec-14 23:36 
QuestionHTOP Fails? Pin
Taylor 1123666316-Nov-14 10:37
Taylor 1123666316-Nov-14 10:37 
QuestionQuestions: cant paste & errors Pin
sandaasu27-Jul-14 2:32
sandaasu27-Jul-14 2:32 
AnswerRe: Questions: cant paste & errors Pin
Prashant. B. Chavan3-Aug-14 0:20
Prashant. B. Chavan3-Aug-14 0:20 
GeneralRe: Questions: cant paste & errors Pin
sandaasu11-Aug-14 0:50
sandaasu11-Aug-14 0:50 
SuggestionRe: Questions: cant paste & errors Pin
Prashant. B. Chavan16-Aug-14 0:22
Prashant. B. Chavan16-Aug-14 0:22 
GeneralRe: Questions: cant paste & errors Pin
sandaasu11-Aug-14 8:30
sandaasu11-Aug-14 8:30 
GeneralRe: Questions: cant paste & errors Pin
Prashant. B. Chavan16-Aug-14 0:39
Prashant. B. Chavan16-Aug-14 0:39 
GeneralRe: Questions: cant paste & errors Pin
sandaasu6-Oct-14 9:38
sandaasu6-Oct-14 9:38 
GeneralRe: Questions: cant paste & errors Pin
Prashant. B. Chavan8-Oct-14 9:54
Prashant. B. Chavan8-Oct-14 9:54 
Questionproblem in getting text from terminalemulator Pin
maulik2915-Jul-14 19:25
maulik2915-Jul-14 19:25 
QuestionSSH PORT Pin
cavalin xucro29-Mar-14 7:31
cavalin xucro29-Mar-14 7:31 
AnswerRe: SSH PORT Pin
Prashant. B. Chavan11-Apr-14 23:00
Prashant. B. Chavan11-Apr-14 23:00 
SuggestionSending an ArrowKey Press Pin
John Mansell28-Dec-13 7:38
John Mansell28-Dec-13 7:38 
QuestionThis application in asp.net(Web Application) Pin
amitcs19903-Dec-13 4:10
professionalamitcs19903-Dec-13 4:10 
AnswerRe: This application in asp.net(Web Application) Pin
Prashant. B. Chavan2-Aug-14 23:58
Prashant. B. Chavan2-Aug-14 23:58 
Questionvi editor in Telnet mode Pin
lucaal14-Oct-13 20:58
lucaal14-Oct-13 20:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.