void IAnsiDecoderClient.Characters(IAnsiDecoder _sender, char[] _chars) { if (Characters != null) { Characters(this, _chars); } }
void IAnsiDecoderClient.Characters ( IAnsiDecoder _sender, char[] _chars ) { if ( Characters != null ) { Characters ( this, _chars ); } }
void IAnsiDecoderClient.MoveCursorToColumn(IAnsiDecoder _sender, int _columnNumber) { if (CheckColumnRow(_columnNumber, m_cursorPosition.Y)) { CursorPosition = new Point(_columnNumber, m_cursorPosition.Y); } }
void IAnsiDecoderClient.MoveCursorTo(IAnsiDecoder _sender, Point _position) { if (CheckColumnRow(_position.X, _position.Y)) { CursorPosition = _position; } }
void IAnsiDecoderClient.ClearLine(IAnsiDecoder _sender, ClearDirection _direction) { switch (_direction) { case ClearDirection.Forward: for (int x = m_cursorPosition.X; x < Width; ++x) { this[x, m_cursorPosition.Y].Char = ' '; } break; case ClearDirection.Backward: for (int x = m_cursorPosition.X; x >= 0; --x) { this[x, m_cursorPosition.Y].Char = ' '; } break; case ClearDirection.Both: for (int x = 0; x < Width; ++x) { this[x, m_cursorPosition.Y].Char = ' '; } break; } }
Point IAnsiDecoderClient.GetCursorPosition ( IAnsiDecoder _sender ) { if ( GetCursorPosition != null ) { return GetCursorPosition(this); } return Point.Empty; }
Size IAnsiDecoderClient.GetSize ( IAnsiDecoder _sender ) { if ( GetSize != null ) { return GetSize(this); } return Size.Empty; }
Size IAnsiDecoderClient.GetSize(IAnsiDecoder _sender) { if (GetSize != null) { return(GetSize(this)); } return(Size.Empty); }
Point IAnsiDecoderClient.GetCursorPosition(IAnsiDecoder _sender) { if (GetCursorPosition != null) { return(GetCursorPosition(this)); } return(Point.Empty); }
void IAnsiDecoderClient.MoveCursorToBeginningOfLineAbove(IAnsiDecoder _sender, int _lineNumberRelativeToCurrentLine) { m_cursorPosition.X = 0; while (_lineNumberRelativeToCurrentLine > 0) { CursorUp(); _lineNumberRelativeToCurrentLine--; } }
void IAnsiDecoderClient.MoveCursorToBeginningOfLineBelow(IAnsiDecoder _sender, int _lineNumberRelativeToCurrentLine, bool scroll) { m_cursorPosition.X = 0; while (_lineNumberRelativeToCurrentLine > 0) { CursorDown(scroll); _lineNumberRelativeToCurrentLine--; } }
public void TearDown() { m_vt100.Output -= new DecoderOutputDelegate(m_vt100_Output); m_vt100.UnSubscribe(this); m_vt100.Dispose(); m_chars = null; m_output = null; m_vt100 = null; m_chars = null; }
public void TearDown () { m_vt100.Output -= new DecoderOutputDelegate(m_vt100_Output); m_vt100.UnSubscribe ( this ); m_vt100.Dispose(); m_chars = null; m_output = null; m_vt100 = null; m_chars = null; }
public void ClearTab(IAnsiDecoder _sender, bool ClearAll) { if (ClearAll) { ClearTabStops(); } else { SetTabStop(CursorPosition.Y, false); } }
private OutputParser() { m_readers = new List <OutputCollectingReader>(); vt = new AnsiDecoder(); client = new AnsiDecoderClient(); sb = new StringBuilder(); vt.Subscribe(client); client.Characters += new libVT100.AnsiDecoderClient.CharactersDelegate(VT100CharactersReceived); }
void IAnsiDecoderClient.ModeChanged(IAnsiDecoder _sender, AnsiMode _mode) { switch (_mode) { case AnsiMode.HideCursor: m_showCursor = false; break; case AnsiMode.ShowCursor: m_showCursor = true; break; } }
public void SetUp () { Reset (); m_cursorPosition = new Point(0,0); m_size = new Size(10,10); m_vt100 = new AnsiDecoder (); m_chars = new List<char[]>(); m_output = new List<byte[]>(); m_vt100.Subscribe ( this ); m_vt100.Output += new DecoderOutputDelegate(m_vt100_Output); }
public void SetUp() { Reset(); m_cursorPosition = new Point(0, 0); m_size = new Size(10, 10); m_vt100 = new AnsiDecoder(); m_chars = new List <char[]>(); m_output = new List <byte[]>(); m_vt100.Subscribe(this); m_vt100.Output += new DecoderOutputDelegate(m_vt100_Output); }
public void Characters(IAnsiDecoder _sender, char[] _chars) { if (null == currentForegroundColor) { currentForegroundColor = ForeColor; } if (null == currentBackgroundColor) { currentBackgroundColor = BackColor; } SelectionStart = TextLength; SelectionLength = 0; SelectionColor = currentForegroundColor.GetValueOrDefault(); SelectionBackColor = currentBackgroundColor.GetValueOrDefault(); base.AppendText(new string(_chars)); }
void IAnsiDecoderClient.ModeChanged(IAnsiDecoder _sender, AnsiMode _mode) { Size cur; switch (_mode) { case AnsiMode.HideCursor: m_showCursor = false; new UIAction_CursorMoved(m_cursorPosition.X, m_cursorPosition.Y, m_showCursor); break; case AnsiMode.ShowCursor: m_showCursor = true; new UIAction_CursorMoved(m_cursorPosition.X, m_cursorPosition.Y, m_showCursor); break; case AnsiMode.SwitchToMainBuffer: if (screenBufferIsPrimary) { return; } alternateScreenBuffer = currentScreenBuffer; saveAlternativeCursor = m_cursorPosition; cur = Size; currentScreenBuffer = primaryScreenBuffer; m_cursorPosition = savePrimaryCursor; Size = cur; DoRefresh(true); screenBufferIsPrimary = true; break; case AnsiMode.SwitchToAlternateBuffer: if (!screenBufferIsPrimary) { return; } primaryScreenBuffer = currentScreenBuffer; savePrimaryCursor = m_cursorPosition; cur = Size; currentScreenBuffer = primaryScreenBuffer; m_cursorPosition = savePrimaryCursor; Size = cur; DoRefresh(true); screenBufferIsPrimary = false; break; } }
void IAnsiDecoderClient.Characters(IAnsiDecoder _sender, char[] _chars) { foreach (char ch in _chars) { if (ch >= 32) { this[CursorPosition] = new Glyph(ch, m_currentAttributes);; CursorForward(); return; } switch (ch) { case '\n': // Linefeed, FF, VT (this as IAnsiDecoderClient).MoveCursorToBeginningOfLineBelow(_sender, 1, true); return; case '\r': // Return (this as IAnsiDecoderClient).MoveCursorToColumn(_sender, 0); return; case '\x08': // Backspace CursorBackward(); return; case '\t': // Tab // Need real tab stops var nextT = NextTabStop(CursorPosition.X, Width); for (var i = 0; i < nextT; i++) { this[CursorPosition] = new Glyph(ch, m_currentAttributes);; CursorForward(); } return; case '\x07': // BEL return; // SI // SO // ENQ // BEL } } }
void IAnsiDecoderClient.Characters(IAnsiDecoder _sender, char[] _chars) { foreach (char ch in _chars) { if (ch == '\n') { (this as IAnsiDecoderClient).MoveCursorToBeginningOfLineBelow(_sender, 1); } else if (ch == '\r') { //(this as IVT100DecoderClient).MoveCursorToBeginningOfLineBelow ( _sender, 1 ); } else { this[CursorPosition].Char = ch; this[CursorPosition].Attributes = m_currentAttributes; CursorForward(); } } }
void IAnsiDecoderClient.MoveCursor(IAnsiDecoder _sender, Direction _direction, int _amount) { switch (_direction) { case Direction.Up: while (_amount > 0) { CursorUp(); _amount--; } break; case Direction.Down: while (_amount > 0) { CursorDown(); _amount--; } break; case Direction.Forward: while (_amount > 0) { CursorForward(); _amount--; } break; case Direction.Backward: while (_amount > 0) { CursorBackward(); _amount--; } break; } }
void IAnsiDecoderClient.ScrollPageUpwards(IAnsiDecoder _sender, int _linesToScroll) { m_scrollPageUpwards = _linesToScroll; }
void IAnsiDecoderClient.MoveCursor ( IAnsiDecoder _sender, Direction _direction, int _amount ) { }
void IAnsiDecoderClient.ClearLine(IAnsiDecoder _sender, ClearDirection _direction) { m_clearLine = _direction; }
Size IAnsiDecoderClient.GetSize(IAnsiDecoder _sender) { return(Size); }
void IAnsiDecoderClient.SaveCursor ( IAnsiDecoder _sernder ) { m_saveCursor = true; }
void IAnsiDecoderClient.RestoreCursor ( IAnsiDecoder _sender ) { }
void IAnsiDecoderClient.SaveCursor(IAnsiDecoder _sernder) { m_savedCursorPosition = m_cursorPosition; }
void IAnsiDecoderClient.ScrollPageDownwards ( IAnsiDecoder _sender, int _linesToScroll ) { m_scrollPageDownwards = _linesToScroll; }
void IAnsiDecoderClient.ModeChanged( IAnsiDecoder _sender, AnsiMode _mode ) { switch ( _mode ) { case AnsiMode.HideCursor: m_hideCursor = true; break; case AnsiMode.ShowCursor: m_showCursor = true; break; } }
void IAnsiDecoderClient.ClearScreen ( IAnsiDecoder _sender, ClearDirection _direction ) { m_clearScreen = _direction; }
void IAnsiDecoderClient.ClearLine ( IAnsiDecoder _sender, ClearDirection _direction ) { m_clearLine = _direction; }
void IAnsiDecoderClient.ModeChanged( IAnsiDecoder _sender, AnsiMode _mode ) { }
void IAnsiDecoderClient.SetGraphicRendition(IAnsiDecoder _sender, GraphicRendition[] _commands) { //foreach ( GraphicRendition command in _commands ) for (var i = 0; i < _commands.Length; i++) { switch (_commands[i]) { case GraphicRendition.Reset: m_currentAttributes.Reset(); break; case GraphicRendition.Bold: m_currentAttributes.Bold = true; break; case GraphicRendition.Faint: m_currentAttributes.Faint = true; break; case GraphicRendition.Italic: m_currentAttributes.Italic = true; break; case GraphicRendition.Underline: m_currentAttributes.Underline = Underline.Single; break; case GraphicRendition.BlinkSlow: m_currentAttributes.Blink = Blink.Slow; break; case GraphicRendition.BlinkRapid: m_currentAttributes.Blink = Blink.Rapid; break; case GraphicRendition.Positive: case GraphicRendition.Inverse: { TextColor tmp = m_currentAttributes.Foreground; m_currentAttributes.Foreground = m_currentAttributes.Background; m_currentAttributes.Background = tmp; } break; case GraphicRendition.Conceal: m_currentAttributes.Conceal = true; break; case GraphicRendition.UnderlineDouble: m_currentAttributes.Underline = Underline.Double; break; case GraphicRendition.NormalIntensity: m_currentAttributes.Bold = false; m_currentAttributes.Faint = false; break; case GraphicRendition.NoUnderline: m_currentAttributes.Underline = Underline.None; break; case GraphicRendition.NoBlink: m_currentAttributes.Blink = Blink.None; break; case GraphicRendition.Reveal: m_currentAttributes.Conceal = false; break; case GraphicRendition.ForegroundNormalBlack: m_currentAttributes.Foreground = TextColor.Black; break; case GraphicRendition.ForegroundNormalRed: m_currentAttributes.Foreground = TextColor.Red; break; case GraphicRendition.ForegroundNormalGreen: m_currentAttributes.Foreground = TextColor.Green; break; case GraphicRendition.ForegroundNormalYellow: m_currentAttributes.Foreground = TextColor.Yellow; break; case GraphicRendition.ForegroundNormalBlue: m_currentAttributes.Foreground = TextColor.Blue; break; case GraphicRendition.ForegroundNormalMagenta: m_currentAttributes.Foreground = TextColor.Magenta; break; case GraphicRendition.ForegroundNormalCyan: m_currentAttributes.Foreground = TextColor.Cyan; break; case GraphicRendition.ForegroundNormalWhite: m_currentAttributes.Foreground = TextColor.White; break; case GraphicRendition.ForegroundNormalReset: m_currentAttributes.Foreground = TextColor.White; break; case GraphicRendition.BackgroundNormalBlack: m_currentAttributes.Background = TextColor.Black; break; case GraphicRendition.BackgroundNormalRed: m_currentAttributes.Background = TextColor.Red; break; case GraphicRendition.BackgroundNormalGreen: m_currentAttributes.Background = TextColor.Green; break; case GraphicRendition.BackgroundNormalYellow: m_currentAttributes.Background = TextColor.Yellow; break; case GraphicRendition.BackgroundNormalBlue: m_currentAttributes.Background = TextColor.Blue; break; case GraphicRendition.BackgroundNormalMagenta: m_currentAttributes.Background = TextColor.Magenta; break; case GraphicRendition.BackgroundNormalCyan: m_currentAttributes.Background = TextColor.Cyan; break; case GraphicRendition.BackgroundNormalWhite: m_currentAttributes.Background = TextColor.White; break; case GraphicRendition.BackgroundNormalReset: m_currentAttributes.Background = TextColor.Black; break; case GraphicRendition.ForegroundBrightBlack: m_currentAttributes.Foreground = TextColor.BrightBlack; break; case GraphicRendition.ForegroundBrightRed: m_currentAttributes.Foreground = TextColor.BrightRed; break; case GraphicRendition.ForegroundBrightGreen: m_currentAttributes.Foreground = TextColor.BrightGreen; break; case GraphicRendition.ForegroundBrightYellow: m_currentAttributes.Foreground = TextColor.BrightYellow; break; case GraphicRendition.ForegroundBrightBlue: m_currentAttributes.Foreground = TextColor.BrightBlue; break; case GraphicRendition.ForegroundBrightMagenta: m_currentAttributes.Foreground = TextColor.BrightMagenta; break; case GraphicRendition.ForegroundBrightCyan: m_currentAttributes.Foreground = TextColor.BrightCyan; break; case GraphicRendition.ForegroundBrightWhite: m_currentAttributes.Foreground = TextColor.BrightWhite; break; case GraphicRendition.ForegroundBrightReset: m_currentAttributes.Foreground = TextColor.White; break; case GraphicRendition.BackgroundBrightBlack: m_currentAttributes.Background = TextColor.BrightBlack; break; case GraphicRendition.BackgroundBrightRed: m_currentAttributes.Background = TextColor.BrightRed; break; case GraphicRendition.BackgroundBrightGreen: m_currentAttributes.Background = TextColor.BrightGreen; break; case GraphicRendition.BackgroundBrightYellow: m_currentAttributes.Background = TextColor.BrightYellow; break; case GraphicRendition.BackgroundBrightBlue: m_currentAttributes.Background = TextColor.BrightBlue; break; case GraphicRendition.BackgroundBrightMagenta: m_currentAttributes.Background = TextColor.BrightMagenta; break; case GraphicRendition.BackgroundBrightCyan: m_currentAttributes.Background = TextColor.BrightCyan; break; case GraphicRendition.BackgroundBrightWhite: m_currentAttributes.Background = TextColor.BrightWhite; break; case GraphicRendition.BackgroundBrightReset: m_currentAttributes.Background = TextColor.Black; break; case GraphicRendition.Font1: break; case GraphicRendition.ForegroundColor: // ESC[ 38;2;⟨r⟩;⟨g⟩;⟨b⟩ m Select RGB foreground color /// Next arguments are 5;n or 2;r;g;b, see colors /// _commands is [38, 2, r, g, b, ...] m_currentAttributes.ForegroundColor = Color.FromArgb((int)_commands[2], (int)_commands[3], (int)_commands[4]); i += 4; break; case GraphicRendition.BackgroundColor: // ESC[ 48;2;⟨r⟩;⟨g⟩;⟨b⟩ m Select RGB background color /// Next arguments are 5;n or 2;r;g;b, see colors /// _commands is [38, 2, r, g, b, ...] m_currentAttributes.BackgroundColor = Color.FromArgb((int)_commands[2], (int)_commands[3], (int)_commands[4]); i += 4; break; default: throw new Exception("Unknown rendition command"); } } }
void IAnsiDecoderClient.Characters ( IAnsiDecoder _sender, char[] _chars ) { m_chars.Add ( _chars ); }
Point IAnsiDecoderClient.GetCursorPosition(IAnsiDecoder _sender) { return(m_cursorPosition); }
Point IAnsiDecoderClient.GetCursorPosition ( IAnsiDecoder _sender ) { return m_cursorPosition; }
void IAnsiDecoderClient.SetGraphicRendition(IAnsiDecoder _sender, GraphicRendition[] _commands) { }
void IAnsiDecoderClient.SetGraphicRendition ( IAnsiDecoder _sender, GraphicRendition[] _commands ) { }
void IAnsiDecoderClient.SaveCursor ( IAnsiDecoder _sernder ) { }
void IAnsiDecoderClient.ScrollPageUpwards ( IAnsiDecoder _sender, int _linesToScroll ) { }
void IAnsiDecoderClient.RestoreCursor(IAnsiDecoder _sender) { CursorPosition = m_savedCursorPosition; }
void IAnsiDecoderClient.MoveCursorToBeginningOfLineBelow ( IAnsiDecoder _sender, int _lineNumberRelativeToCurrentLine ) { }
Size IAnsiDecoderClient.GetSize ( IAnsiDecoder _sender ) { return m_size; }
void IAnsiDecoderClient.RestoreCursor ( IAnsiDecoder _sender ) { m_restoreCursor = true; }
void IAnsiDecoderClient.ClearScreen(IAnsiDecoder _sender, ClearDirection _direction) { }
void IAnsiDecoderClient.MoveCursor ( IAnsiDecoder _sender, Direction _direction, int _amount ) { m_moveCursorDirection = _direction; m_moveCursorAmount = _amount; }
void IAnsiDecoderClient.ScrollPageDownwards(IAnsiDecoder _sender, int _linesToScroll) { }
void IAnsiDecoderClient.MoveCursorToBeginningOfLineAbove ( IAnsiDecoder _sender, int _lineNumberRelativeToCurrentLine ) { m_moveCursorToBeginningOfLineAbove = _lineNumberRelativeToCurrentLine; }
Point IAnsiDecoderClient.GetCursorPosition(IAnsiDecoder _sender) { return(new Point(m_cursorPosition.X + 1, m_cursorPosition.Y + 1)); }
void IAnsiDecoderClient.MoveCursorToColumn ( IAnsiDecoder _sender, int _columnNumber ) { m_moveCursorToColumn = _columnNumber; }
/* * 6.7. Window Dimension Change Message * * When the window (terminal) size changes on the client side, it MAY * send a message to the other side to inform it of the new dimensions. * * byte SSH_MSG_CHANNEL_REQUEST * uint32 recipient channel * string "window-change" * boolean FALSE * uint32 terminal width, columns * uint32 terminal height, rows * uint32 terminal width, pixels * uint32 terminal height, pixels */ private void connectButton_Click(object sender, EventArgs e) { if (client != null && client.IsConnected) { return; } if (client != null) { client.Dispose(); } host_textbox.Enabled = user_textbox.Enabled = pass_textbox.Enabled = false; client = new SshClient(host_textbox.Text, user_textbox.Text, pass_textbox.Text) { KeepAliveInterval = new TimeSpan(0, 2, 0) }; client.HostKeyReceived += Client_HostKeyReceived; client.ErrorOccurred += Client_ErrorOccurred; keyboardStream = new KeyboardStream(); var screenS = new ScreenStream(); var tSize = terminalFrameBuffer.EstimateScreenSize(); screen = new libVT100.TerminalFrameBuffer(tSize.X, tSize.Y); terminalFrameBuffer.BoundScreen = screen; terminalFrameBuffer.LegendLabel = terminalLegend; terminalFrameBuffer.Init(); vt100 = new AnsiDecoder(); vt100.Output += Vt100_Output; screenS.InjectTo = vt100; vt100.Encoding = new UTF8Encoding(); // Encoding.GetEncoding("utf8"); vt100.Subscribe(screen); try { client.Connect(); } catch (Exception ex) { MessageBox.Show(this, "Connect: " + ex.Message, "Connect Error", MessageBoxButtons.OK); client.Dispose(); client = null; return; } checkLoginState(); if (terminalFrameBuffer.CanFocus) { terminalFrameBuffer.Focus(); } var termModes = new Dictionary <Renci.SshNet.Common.TerminalModes, uint>(); var shell = client.CreateShell(keyboardStream, screenS, screenS, "VRTerm", (uint)tSize.X, (uint)tSize.Y, (uint)terminalFrameBuffer.Width, (uint)terminalFrameBuffer.Height, termModes); shell.Start(); }
void IAnsiDecoderClient.MoveCursorTo ( IAnsiDecoder _sender, Point _position ) { m_moveCursorTo = _position; }