Click here to Skip to main content
Licence CPOL
First Posted 6 Oct 2007
Views 106,711
Downloads 2,116
Bookmarked 50 times

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

By Columbus-MCSD | 2 Jan 2009
This is based on Poderosa Project http://sourceforge.net/projects/poderosa/
1 vote, 6.3%
1

2
3 votes, 18.8%
3
3 votes, 18.8%
4
9 votes, 56.3%
5
4.34/5 - 16 votes
1 removed
μ 4.15, σa 2.08 [?]

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:

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:

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)

About the Author

Columbus-MCSD



United States United States

Member


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
AnswerRe: Capture command response PinmemberAmbru19:40 6 Dec '09  
GeneralRe: Capture command response [modified] Pinmembersilversurfer019:16 28 Feb '10  
GeneralRe: Capture command response Pinmemberinder11:04 31 Mar '10  
GeneralRe: Capture command response PinmemberColumbus-MCSD1:36 2 Sep '11  
GeneralRe: Capture command response Pinmembermario9945718:40 5 Apr '10  
GeneralRe: Capture command response PinmemberColumbus-MCSD6:27 16 Sep '11  
GeneralUnable to connect to SSH session Pinmemberagohil23:57 11 Oct '09  
Sardaan,
 
I need to replace existing Dart components (in one of our product) by some other open source terminal emulator.
We come across Poderosa and went through its code base. I had a same experience with the code and their documentation that u faced. I googled for some components based on Poderosa and i found yours.
I downloaded your demo project and made a build and ran it but i could not connect to the SSH terminal session.
 
I have made chnages to the code to use port 57 for SSH instead of 22 in the code. No other changes were made.
 
I have debugged the same and identified the spot where the issue happens.
 
In fact MakeConnection() ensures that the Socket is opened and SSH session is enabled. But after that when Negotiate() is called , SSH session gets disconnected somehow. I have narrowed it town to observe that as soon as it returns from r.OpenShell() , SSH session gets disconnected.
 
Please can you narrowed it down further or let me know the root cause of this ?
 
Thanks in advance
Ajay
QuestionHow to get the information in the terminal into a strin PinmemberMember 338263812:38 4 Sep '09  
QuestionVT100 - PF1 to PF4 key PinmemberJean-Christophe GOFFIN23:39 31 Aug '09  
AnswerRe: VT100 - PF1 to PF4 key PinmemberColumbus-MCSD6:30 16 Sep '11  
Generalcontrol graphic with terminal Pinmemberparabole3:41 3 Aug '09  
QuestionRun Command Without UI Pinmembermahdavi5:40 26 Jun '09  
QuestionHow export content to file Pinmemberprcjunior19:44 14 Jun '09  
GeneralRead output from the terminal Pinmembernamalpk11:03 10 Jun '09  
GeneralRe: Read output from the terminal Pinmemberjtlutgen11:57 9 Sep '10  
GeneralRe: Read output from the terminal Pinmemberpbs-jm10:00 12 Sep '10  
GeneralVI error message. PinmemberWMBWMB8:21 5 Feb '09  
GeneralVI editor via this Terminal Control PinmemberWMBWMB4:31 5 Feb '09  
QuestionNullReferenceException while running C-Sharp Example Pinmembergvcrash4:13 3 Feb '09  
AnswerRe: NullReferenceException while running C-Sharp Example Pinmemberjbeersm7:46 10 Feb '09  
AnswerRe: NullReferenceException while running C-Sharp Example Pinmembergvcrash0:15 20 Feb '09  
QuestionRe: NullReferenceException while running C-Sharp Example PinmemberPCBuilder18:19 8 Mar '09  
QuestionFont PinmemberScotty Couturier10:31 21 Oct '08  
AnswerRe: Font PinmemberSardaan Frostreaver5:54 26 Dec '08  
AnswerRe: Font PinmemberSardaan Frostreaver2:55 2 Jan '09  

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

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

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120210.1 | Last Updated 2 Jan 2009
Article Copyright 2007 by Columbus-MCSD
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid