Click here to Skip to main content
15,890,506 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.9K   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

 
GeneralVI error message. Pin
WMBWMB5-Feb-09 7:21
WMBWMB5-Feb-09 7:21 
GeneralVI editor via this Terminal Control Pin
WMBWMB5-Feb-09 3:31
WMBWMB5-Feb-09 3:31 
QuestionNullReferenceException while running C-Sharp Example Pin
gvcrash3-Feb-09 3:13
gvcrash3-Feb-09 3:13 
AnswerRe: NullReferenceException while running C-Sharp Example Pin
jbeersm10-Feb-09 6:46
jbeersm10-Feb-09 6:46 
AnswerRe: NullReferenceException while running C-Sharp Example Pin
gvcrash19-Feb-09 23:15
gvcrash19-Feb-09 23:15 
QuestionRe: NullReferenceException while running C-Sharp Example Pin
PCBuilder8-Mar-09 17:19
PCBuilder8-Mar-09 17:19 
QuestionFont Pin
Scotty Couturier21-Oct-08 9:31
Scotty Couturier21-Oct-08 9:31 
AnswerRe: Font Pin
Columbus-MCSD26-Dec-08 4:54
Columbus-MCSD26-Dec-08 4:54 
AnswerRe: Font Pin
Columbus-MCSD2-Jan-09 1:55
Columbus-MCSD2-Jan-09 1:55 
QuestionVT100 or 3270 App to do some tests Pin
Manuel Escobar8-Jul-08 22:51
Manuel Escobar8-Jul-08 22:51 
AnswerRe: VT100 or 3270 App to do some tests Pin
Columbus-MCSD26-Dec-08 4:50
Columbus-MCSD26-Dec-08 4:50 
GeneralPonderosa version 4.0.2 Pin
WMBWMB12-Jun-08 6:37
WMBWMB12-Jun-08 6:37 
GeneralRe: Ponderosa version 4.0.2 Pin
Columbus-MCSD26-Dec-08 5:01
Columbus-MCSD26-Dec-08 5:01 
GeneralWait for reply from Server Pin
code300530-May-08 7:33
code300530-May-08 7:33 
GeneralRe: Wait for reply from Server Pin
Kevin James17-Sep-08 6:28
Kevin James17-Sep-08 6:28 
GeneralRe: Wait for reply from Server Pin
Columbus-MCSD26-Dec-08 4:46
Columbus-MCSD26-Dec-08 4:46 
GeneralRe: Wait for reply from Server Pin
carlsiy13-Sep-09 2:05
carlsiy13-Sep-09 2:05 
Generalholy crapskees, you are the man! Pin
waffle2725-Apr-08 7:27
waffle2725-Apr-08 7:27 
GeneralRe: holy crapskees, you are the man! Pin
Columbus-MCSD26-Dec-08 4:43
Columbus-MCSD26-Dec-08 4:43 
QuestionDo you have a version for Visual Studio 2008? Pin
Karl Tarbet24-Jan-08 10:20
Karl Tarbet24-Jan-08 10:20 
AnswerRe: Do you have a version for Visual Studio 2008? Pin
Columbus-MCSD26-Dec-08 4:41
Columbus-MCSD26-Dec-08 4:41 
GeneralA note about string resources Pin
Columbus-MCSD18-Oct-07 17:45
Columbus-MCSD18-Oct-07 17:45 
Generalplease help Pin
SuperAbdo198011-Oct-07 4:23
SuperAbdo198011-Oct-07 4:23 
GeneralRe: please help [modified] Pin
Columbus-MCSD11-Oct-07 18:40
Columbus-MCSD11-Oct-07 18:40 
GeneralRe: please help Pin
SuperAbdo198016-Oct-07 0:53
SuperAbdo198016-Oct-07 0:53 

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.