public ConnectionTag(TerminalConnection c) { _connection = c; _pane = null; _invalidateParam = new InvalidateParam(); _tabButton = null; _document = new TerminalDocument(_connection); _receiver = new TerminalDataReceiver(this); _terminated = false; _timer = null; _windowTitle = ""; //nullのときはデフォルトプロファイルを使う _renderProfile = c.Param.RenderProfile; //VT100指定でもxtermシーケンスを送ってくるアプリケーションが後をたたないので //_terminal = new XTerm(this, new JapaneseCharDecoder(_connection)); if (c.Param.TerminalType == TerminalType.XTerm || c.Param.TerminalType == TerminalType.KTerm) { _terminal = new XTerm(this, new JapaneseCharDecoder(_connection)); } else { _terminal = new VT100Terminal(this, new JapaneseCharDecoder(_connection)); } GEnv.Connections.KeepAlive.SetTimerToConnectionTag(this); }
public SelectionKeyProcessor(TerminalPane owner, TerminalDocument doc, GLine line, int pos) { _owner = owner; _document = doc; Debug.Assert(line != null); _currentLine = line; _caretPos = pos; }
public override CommandResult SetConnectionLocation(ConnectionTag ct, TerminalPane pane) { if (ct.AttachedPane == pane) { return(CommandResult.Ignored); } _frame.PaneContainer.SetConnectionLocation(ct, pane); return(CommandResult.Success); }
public CommandResult ToggleFreeSelectionMode() { TerminalPane p = GEnv.Connections.FindTag(_connection).Pane; if (p == null) { return(CommandResult.Ignored); } p.ToggleFreeSelectionMode(); return(CommandResult.Success); }
public CommandResult Close() { try { _connection.Disconnect(); _connection.Close(); } catch (Exception ex) { //ここでエラーが発生しても処理は続行してアプリ自体は実行を継続 GUtil.Warning(GEnv.Frame, GEnv.Strings.GetString("Message.ConnectionCommandTarget.CloseError") + ex.Message); } bool active = _connection == GEnv.Connections.ActiveConnection; ConnectionTag ct = GEnv.Connections.FindTag(_connection); //Debug.WriteLine("ct==null? " + (ct==null)); if (ct == null) { return(CommandResult.Ignored); } TerminalPane pane = ct.AttachedPane; ct.IsTerminated = true; GEnv.Frame.RemoveConnection(ct); ConnectionTag next = GEnv.Connections.GetCandidateOfActivation(ct.PositionIndex, ct); GEnv.Connections.Remove(_connection); if (next != null) { if (pane != null) { pane.Attach(next); } if (active) { GEnv.Frame.ActivateConnection(next); //もともとアクティブでない接続が切れたときは変更しない } } else { if (pane != null) { pane.FakeVisible = false; pane.Detach(); } GEnv.Frame.RefreshConnection(null); } if (GEnv.Options.QuitAppWithLastPane && GEnv.Connections.Count == 0) { GEnv.Frame.AsForm().Close(); } return(CommandResult.Success); }
private void InitializeTerminalPane() { if (GApp._frame == null) { string[] args = new string[0]; GApp.Run(args); GApp._frame._multiPaneControl.InitUI(null, GApp.Options); GEnv.InterThreadUIService.MainFrameHandle = GApp._frame.Handle; } this._terminalPane = new TerminalPane(); this.TerminalPane.Dock = DockStyle.Fill; this.Controls.Add(this.TerminalPane); }
public void Clear() { if (_owner != null) { _owner.ExitTextSelection(); } _owner = null; _state = SelectionState.Empty; _pivotType = RangeType.Char; _forwardPivot.Clear(); _backwardPivot.Clear(); _forwardDestination.Clear(); _backwardDestination.Clear(); _disabledTemporary = false; }
internal void SelectAll(TerminalPane owner) { _disabledTemporary = false; Debug.Assert(owner != null); _owner = owner; _forwardPivot._line = _owner.Document.FirstLine.ID; _forwardPivot._position = 0; _backwardPivot = _forwardPivot; _forwardDestination._line = _owner.Document.LastLine.ID; _forwardDestination._position = _owner.Document.LastLine.CharLength - 1; _backwardDestination = _forwardDestination; _state = SelectionState.Fixed; _pivotType = RangeType.Char; }
public ConnectionTag(TerminalConnection c) { _connection = c; _pane = null; _invalidateParam = new InvalidateParam(); _tabButton = null; _document = new TerminalDocument(_connection); _receiver = new TerminalDataReceiver(this); _terminated = false; _timer = null; _windowTitle = ""; _renderProfile = c.Param.RenderProfile; _terminal = new XTerm(this, new JapaneseCharDecoder(_connection)); GEnv.Connections.KeepAlive.SetTimerToConnectionTag(this); }
private void MovePane(ConnectionTag ct, int destinationIndex) { //位置の変更 //移動先に表示 //Debug.WriteLine("--------"); //GEnv.Connections.Dump(); int originalPos = ct.PositionIndex; Debug.Assert(originalPos != destinationIndex); ct.PositionIndex = destinationIndex; TerminalPane pane = GetPane(destinationIndex); if (ct.AttachedPane != null) { ct.AttachedPane.Detach(); } if (pane.FakeVisible) { pane.Detach(); } pane.FakeVisible = true; pane.Attach(ct); pane.Focus(); GEnv.Frame.RefreshConnection(ct); //GEnv.Connections.Dump(); //ここでPreservedPositionIndexを設定 ct.PreservedPositionIndex = destinationIndex; //移動元に別の候補がいればそれを表示 ConnectionTag orig = GEnv.Connections.GetCandidateOfActivation(originalPos, ct); if (orig != null) { //orig.PaneType = CalcPaneType(orig); GetPane(originalPos).Attach(orig); GEnv.Frame.RefreshConnection(orig); } else { GetPane(originalPos).FakeVisible = false; } }
internal bool StartSelection(TerminalPane owner, GLine line, int position, RangeType type, int x, int y) { Debug.Assert(owner != null); Debug.Assert(position >= 0); line.ExpandBuffer(position + 1); _disabledTemporary = false; _owner = owner; _pivotType = type; _forwardPivot._line = line.ID; _backwardPivot._line = line.ID; _forwardDestination._line = line.ID; _forwardDestination._position = position; _backwardDestination._line = line.ID; _backwardDestination._position = position; switch (type) { case RangeType.Char: _forwardPivot._position = position; _backwardPivot._position = position; break; case RangeType.Word: _forwardPivot._position = line.FindPrevWordBreak(position) + 1; _backwardPivot._position = line.FindNextWordBreak(position); break; case RangeType.Line: _forwardPivot._position = 0; _backwardPivot._position = line.CharLength; break; } _state = SelectionState.Pivot; _startX = x; _startY = y; return(true); }
// public void ActivateConnection(ConnectionTag ct) { //ct.PaneType = CalcPaneType(ct); TerminalPane pane = GetPane(ct.PositionIndex); //既にコネクションがあればそれのUIをリフレッシュ if (pane.Connection != null) { ConnectionTag k = GEnv.Connections.FindTag(pane.Connection); if (k != null) //ここで既に閉じた接続が得られてしまうことがある。本当は接続を閉じるときに参照を解消すべきだが手抜き { pane.Detach(); GEnv.Frame.RefreshConnection(k); } } pane.FakeVisible = true; pane.Attach(ct); if (!pane.AsControl().Focused) { pane.AsControl().Focus(); } GEnv.Frame.RefreshConnection(ct); }
public void Connect() { // 先判断连接状态 if (IsConnected || _isConnecting) { return; } _isConnecting = true; if (statusText == null) { statusText = new Label(); statusText.Dock = DockStyle.Fill; statusText.BackColor = Color.White; statusText.ForeColor = Color.Black; statusText.Font = new Font("Microsoft YaHei", 10); statusText.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; } statusText.Text = "正在连接"; statusText.Visible = true; this.Invalidate(); this.Controls.Add(statusText); if (GApp._frame == null) { GApp.Run(new string[0]); GApp.Options.BGColor = this.BackColor; GApp.Options.TextColor = this.ForeColor; GApp.Options.RightButtonAction = RightButtonAction.Paste; GApp.Options.AutoCopyByLeftButton = true; //GApp.Options.WarningOption = WarningOption.Ignore; GApp.Options.Font = this.Font; GApp._frame._multiPaneControl.InitUI(null, GApp.Options); GEnv.InterThreadUIService.MainFrameHandle = GApp._frame.Handle; } try { //------------------------------------------------------------------------ SSHTerminalParam sshp = new SSHTerminalParam(Poderosa.ConnectionParam.ConnectionMethod.SSH2, this.Host, this.UserName, this.Password); sshp.AuthType = AuthType.Password; sshp.IdentityFile = string.Empty; sshp.Encoding = EncodingType.UTF8; sshp.Port = this._port; sshp.RenderProfile = new RenderProfile(); sshp.TerminalType = TerminalType.XTerm; CommunicationUtil.SilentClient s = new CommunicationUtil.SilentClient(); Size sz = this.Size; SocketWithTimeout swt = new SSHConnector(sshp, sz, sshp.Passphrase, null); swt.AsyncConnect(s, sshp.Host, sshp.Port, (ct, errorMessage) => { if (ct == null) { statusText.Invoke(new Action(() => { statusText.Text = "连接异常:" + errorMessage; })); return; } if (this._terminalPane == null) { this.Invoke(new Action(() => { this._terminalPane = new TerminalPane(); InitTerminalPane(ct); })); } else { this._terminalPane.Invoke(new Action(() => { this._terminalPane.Detach(); InitTerminalPane(ct); })); } }); } catch (Exception ex) { statusText.Text = "连接异常:" + ex.Message; return; } _isConnecting = false; }
public virtual CommandResult SetConnectionLocation(ConnectionTag ct, TerminalPane pane) { return(CommandResult.Ignored); }
public void InitUI(ContainerOptions prev, ContainerOptions opt) { ConnectionTag[] cons = new ConnectionTag[_panes.Length]; for (int i = 0; i < _panes.Length; i++) { cons[i] = (_panes[i] == null || !_panes[i].FakeVisible)? null : _panes[i].ConnectionTag; if (_panes[i] != null) { _panes[i].Detach(); } _panes[i] = null; } Controls.Clear(); GFrameStyle style = opt.FrameStyle; int pane_count = StyleToPaneCount(style); int prev_pane_count = prev == null? 1 : StyleToPaneCount(prev.FrameStyle); bool is_vertical = style == GFrameStyle.DivVertical || style == GFrameStyle.DivVertical3; //Controlの初期化 this.SuspendLayout(); for (int i = pane_count - 1; i >= 0; i--) { TerminalPane p = new TerminalPane(); _panes[i] = p; p.Visible = true; p.Dock = i == pane_count - 1? DockStyle.Fill : is_vertical? DockStyle.Left : DockStyle.Top; if (i < pane_count - 1) { int a = (int)((is_vertical? this.Width : this.Height) * (i == 0? 0 : _splitterRatio[pane_count - 2][i - 1])); int b = (int)((is_vertical? this.Width : this.Height) * (_splitterRatio[pane_count - 2][i] - (i == 0? 0 : _splitterRatio[pane_count - 2][i - 1]))); if (is_vertical) { p.Left = a; p.Width = b; } else { p.Top = a; p.Height = b; } } this.Controls.Add(p); if (i > 0) { Splitter s = new Splitter(); _splitters[i - 1] = s; s.SplitterMoving += new SplitterEventHandler(this.OnSplitterMoving); s.SplitterMoved += new SplitterEventHandler(this.OnSplitterMoved); s.Dock = is_vertical? DockStyle.Left : DockStyle.Top; s.BorderStyle = BorderStyle.Fixed3D; s.MinSize = 8; s.SplitPosition = (int)((is_vertical? this.Width : this.Height) * _splitterRatio[pane_count - 2][i - 1]); this.Controls.Add(s); } } this.ResumeLayout(true); //必要なものをAttach foreach (ConnectionTag ct in GEnv.Connections.OrderedConnections) { int pos = ct.PositionIndex; if (prev_pane_count < pane_count && ct.PreservedPositionIndex >= prev_pane_count) //増えたペインへの強制割り当て { pos = ct.PreservedPositionIndex; if (pos >= pane_count) { pos = pane_count - 1; } ct.PositionIndex = pos; if (_panes[pos].ConnectionTag == null) { _panes[pos].Attach(ct); _panes[pos].FakeVisible = true; GEnv.Frame.RefreshConnection(ct); } } else if (pos < pane_count) //平和な場合 { if (_panes[pos].ConnectionTag == null) { _panes[pos].Attach(ct); _panes[pos].FakeVisible = true; GEnv.Frame.RefreshConnection(ct); } } else //隠れる場合 { ct.PositionIndex = pane_count - 1; if (ct != null && _panes[pane_count - 1].ConnectionTag == null) { _panes[pane_count - 1].Attach(ct); _panes[pane_count - 1].FakeVisible = true; GEnv.Frame.RefreshConnection(ct); } } } }
public TextSelection() { _owner = null; }