private static CommandResult CmdClearScreen(ICommandTarget target) { TerminalDocument doc = TerminalCommandTarget.AsTerminalDocument(target); if (doc == null) { return(CommandResult.Ignored); } TerminalControl tc = TerminalCommandTarget.AsTerminalControl(target); lock (doc) { GLine l = doc.TopLine; int top_id = l.ID; int limit = l.ID + doc.TerminalHeight; while (l != null && l.ID < limit) { l.Clear(); l = l.NextLine; } doc.CurrentLineNumber = top_id; doc.CaretColumn = 0; doc.InvalidatedRegion.InvalidatedAll = true; if (tc != null) { tc.ITextSelection.Clear(); tc.Invalidate(); } } return(CommandResult.Succeeded); }
protected static void AsyncResultQuickHack(TerminalControl tc, IAsyncResult ar) { if (ar.AsyncWaitHandle.WaitOne(100, false)) //IntelliSenseと同様の理由で時間制限つきのWait { tc.EndInvoke(ar); } }
public void Init(AbstractTerminal terminal, IShellScheme scheme, string[] current_input, IntelliSenseMode mode, char append_char) { _ownerControl = terminal.TerminalHost.TerminalControl; Debug.Assert(_ownerControl != null); TerminalDocument doc = terminal.GetDocument(); _commandStartPoint = new Point(doc.CaretColumn + (append_char == '\0' ? 0 : 1), doc.CurrentLineNumber - doc.TopLineNumber); Debug.WriteLineIf(DebugOpt.IntelliSense, String.Format("IS CtxInit M={0} CaretC={1}", mode.ToString(), doc.CaretColumn)); _scheme = scheme; _currentInput = current_input; _intelliSenseMode = mode; Debug.Assert(_currentInput != null); _charQueue.LockedInit(append_char); _buffer.Remove(0, _buffer.Length); if (_intelliSenseMode == IntelliSenseMode.CharComplement) { string last_arg = current_input[current_input.Length - 1]; _buffer.Append(last_arg); _commandStartPoint.X -= last_arg.Length; } BuildCandidates(); }
public override void EndCommand(List <GLine> command_result) { StringBuilder bld = new StringBuilder(); foreach (GLine line in command_result) { line.WriteTo( delegate(char[] buff, int len) { bld.Append(buff, 0, len); }); if (line.EOLType != EOLType.Continue) { bld.Append("\r\n"); } } if (bld.Length > 0) { //コピーはメインスレッドでやらんと TerminalControl tc = _terminal.TerminalHost.TerminalControl; if (tc == null) { return; } Debug.Assert(tc.InvokeRequired); IAsyncResult ar = tc.BeginInvoke(new CopyToClipboardDelegate(CopyToClipboard), bld.ToString()); AsyncResultQuickHack(tc, ar); } }
public TerminalView(IPoderosaForm parent, TerminalControl control) { _parent = parent; _control = control; _copyCommand = TerminalSessionsPlugin.Instance.WindowManager.SelectionService.DefaultCopyCommand; _pasteCommand = TerminalSessionsPlugin.Instance.GetPasteCommand(); control.Tag = this; }
protected void SetDocumentCursor(Cursor cursor) { _documentCursor = cursor; TerminalControl terminalControl = GetTerminalControl(); if (terminalControl != null) { terminalControl.SetDocumentCursor(cursor); } }
protected void ResetDocumentCursor() { _documentCursor = null; TerminalControl terminalControl = GetTerminalControl(); if (terminalControl != null) { terminalControl.ResetDocumentCursor(); } }
public static CommandResult OpenShortcutFile(ICommandTarget target, string filename) { IPoderosaMainWindow window = CommandTargetUtil.AsWindow(target); if (window == null) { window = (IPoderosaMainWindow)CommandTargetUtil.AsViewOrLastActivatedView(target).ParentForm.GetAdapter(typeof(IPoderosaMainWindow)); } if (window == null) { return(CommandResult.Ignored); } if (!File.Exists(filename)) { window.Warning(String.Format("{0} is not a file", filename)); return(CommandResult.Failed); } ShortcutFileContent f = null; try { f = ShortcutFileContent.LoadFromXML(filename); } catch (Exception ex) { //変なファイルをドロップしたなどで例外は簡単に起こりうる window.Warning(String.Format("Failed to read {0}\n{1}", filename, ex.Message)); return(CommandResult.Failed); } try { //独立ウィンドウにポップアップさせるようなことは考えていない IContentReplaceableView rv = (IContentReplaceableView)target.GetAdapter(typeof(IContentReplaceableView)); if (rv == null) { rv = (IContentReplaceableView)window.ViewManager.GetCandidateViewForNewDocument().GetAdapter(typeof(IContentReplaceableView)); } Poderosa.Terminal.TerminalControl tc = (Poderosa.Terminal.TerminalControl)rv.GetCurrentContent().GetAdapter(typeof(Poderosa.Terminal.TerminalControl)); if (tc != null) //ターミナルコントロールがないときは無理に設定しにいかない { RenderProfile rp = f.TerminalSettings.UsingDefaultRenderProfile ? TerminalSessionsPlugin.Instance.TerminalEmulatorService.TerminalEmulatorOptions.CreateRenderProfile() : f.TerminalSettings.RenderProfile; Size sz = tc.CalcTerminalSize(rp); f.TerminalParameter.SetTerminalSize(sz.Width, sz.Height); } ITerminalSession s = TerminalSessionsPlugin.Instance.TerminalSessionStartCommand.StartTerminalSession(target, f.TerminalParameter, f.TerminalSettings); return(s != null ? CommandResult.Succeeded : CommandResult.Failed); } catch (Exception ex) { RuntimeUtil.ReportException(ex); return(CommandResult.Failed); } }
/// <summary> /// A method called when a TerminalControl has been attached to the session. /// </summary> /// <param name="terminalControl">TerminalControl which is being attached</param> public void Attached(TerminalControl terminalControl) { if (_documentCursor != null) { terminalControl.SetDocumentCursor(_documentCursor); } else { terminalControl.ResetDocumentCursor(); } }
public void InternalAttachView(IPoderosaDocument document, IPoderosaView view) { Debug.WriteLineIf(DebugOpt.ViewManagement, "ATTACH VIEW"); Debug.Assert(document == _terminal.IDocument); TerminalView tv = (TerminalView)view.GetAdapter(typeof(TerminalView)); Debug.Assert(tv != null); Poderosa.Terminal.TerminalControl tp = tv.TerminalControl; Debug.Assert(tp != null); tp.Attach(this); _terminalControl = tp; _terminal.Attached(tp); }
public void InternalDetachView(IPoderosaDocument document, IPoderosaView view) { Debug.WriteLineIf(DebugOpt.ViewManagement, "DETACH VIEW"); Debug.Assert(document == _terminal.IDocument); TerminalView tv = (TerminalView)view.GetAdapter(typeof(TerminalView)); Debug.Assert(tv != null); Poderosa.Terminal.TerminalControl tp = tv.TerminalControl; Debug.Assert(tp != null); //Detachするときにはこのビューになっている必要あり if (!tp.IsDisposed) { _terminal.Detach(tp); tp.Detach(); } _terminalControl = null; }
private void ShowMenu() { TerminalControl tc = _terminal.TerminalHost.TerminalControl; Debug.Assert(tc != null); TerminalDocument doc = _terminal.GetDocument(); SizeF pitch = tc.GetRenderProfile().Pitch; Point popup = new Point((int)(doc.CaretColumn * pitch.Width), (int)((doc.CurrentLineNumber - doc.TopLineNumber + 1) * pitch.Height)); IPoderosaForm f = tc.FindForm() as IPoderosaForm; Debug.Assert(f != null); //EXTPにしてもいいんだけど f.ShowContextMenu(new IPoderosaMenuGroup[] { new PoderosaMenuGroupImpl(CreatePopupMenuItems()) }, (ICommandTarget)tc.GetAdapter(typeof(ICommandTarget)), tc.PointToScreen(popup), ContextMenuFlags.SelectFirstItem); }
public AbstractTerminal(TerminalInitializeInfo info) { TerminalEmulatorPlugin.Instance.LaterInitialize(); _session = info.Session; //_invalidateParam = new InvalidateParam(); _document = new TerminalDocument(info.InitialWidth, info.InitialHeight); _document.SetOwner(_session.ISession); _afterExitLockActions = new List <AfterExitLockDelegate>(); _encodingProfile = EncodingProfile.Create(info.Session.TerminalSettings.Encoding); _decoder = new ISO2022CharDecoder(this, _encodingProfile); _unicodeCharConverter = _encodingProfile.CreateUnicodeCharConverter(); _terminalMode = TerminalMode.Normal; _currentdecoration = TextDecoration.Default; _manipulator = new GLineManipulator(); _scrollBarValues = new ScrollBarValues(); _logService = new LogService(info.TerminalParameter, _session.TerminalSettings); _promptRecognizer = new PromptRecognizer(this); _intelliSense = new IntelliSense(this); _commandResultRecognizer = new PopupStyleCommandResultRecognizer(this); if (info.Session.TerminalSettings.LogSettings != null) { _logService.ApplyLogSettings(_session.TerminalSettings.LogSettings, false); } //event handlers ITerminalSettings ts = info.Session.TerminalSettings; ts.ChangeEncoding += delegate(EncodingType t) { this.Reset(); }; ts.ChangeRenderProfile += delegate(RenderProfile prof) { TerminalControl tc = _session.TerminalControl; if (tc != null) { tc.ApplyRenderProfile(prof); } }; }
public override void EndCommand(List <GLine> command_result) { StringBuilder bld = new StringBuilder(); foreach (GLine line in command_result) { char[] text = line.Text; for (int i = 0; i < text.Length; i++) { char ch = text[i]; if (ch == '\0') { break; } if (ch != GLine.WIDECHAR_PAD) { bld.Append(ch); } } if (line.EOLType != EOLType.Continue) { bld.Append("\r\n"); } } if (bld.Length > 0) { //コピーはメインスレッドでやらんと TerminalControl tc = _terminal.TerminalHost.TerminalControl; if (tc == null) { return; } Debug.Assert(tc.InvokeRequired); IAsyncResult ar = tc.BeginInvoke(new CopyToClipboardDelegate(CopyToClipboard), bld.ToString()); AsyncResultQuickHack(tc, ar); } }
//必ずimportされるという前提なのでちょっと危険 public void OnPreferenceImport(IPreferenceFolder oldvalues, IPreferenceFolder newvalues) { ITerminalEmulatorOptions opt = (ITerminalEmulatorOptions)newvalues.QueryAdapter(typeof(ITerminalEmulatorOptions)); //DefaultRenderProfile GEnv.DefaultRenderProfile = opt.CreateRenderProfile(); //必要なTerminalSessionにApplyTerminalOptions ISessionManager sm = TerminalEmulatorPlugin.Instance.GetSessionManager(); foreach (ISession session in sm.AllSessions) { IAbstractTerminalHost ts = (IAbstractTerminalHost)session.GetAdapter(typeof(IAbstractTerminalHost)); if (ts != null) { TerminalControl tc = ts.TerminalControl; if (tc != null) { tc.ApplyTerminalOptions(opt); } } } //ASCIIWordBreakTable ASCIIWordBreakTable table = ASCIIWordBreakTable.Default; table.Reset(); foreach (char ch in opt.AdditionalWordElement) { table.Set(ch, ASCIIWordBreakTable.LETTER); } //キーバインド系をリセット TerminalEmulatorPlugin.Instance.CustomKeySettings.Reset(opt); //KeepAliveのリフレッシュ TerminalEmulatorPlugin.Instance.KeepAlive.Refresh(opt.KeepAliveInterval); _originalOptions.ResetParseKeyFlag(); }
public override void EndCommand(List <GLine> command_result) { CommandResultDocument doc = new CommandResultDocument(_executingCommand); foreach (GLine line in command_result) { doc.AddLine(line.Clone()); } TerminalControl tc = _terminal.TerminalHost.TerminalControl; if (tc == null) { return; } Debug.Assert(tc.InvokeRequired); IAsyncResult ar = tc.BeginInvoke(CommandResultSession.Start, _terminal, doc); AsyncResultQuickHack(tc, ar); }
private static CommandResult CmdClearBuffer(ICommandTarget target) { TerminalDocument doc = TerminalCommandTarget.AsTerminalDocument(target); if (doc == null) { return(CommandResult.Ignored); } ITerminalControlHost session = TerminalCommandTarget.AsTerminal(target); TerminalControl tc = TerminalCommandTarget.AsTerminalControl(target); lock (doc) { doc.Clear(); session.Terminal.AdjustTransientScrollBar(); if (tc != null) { tc.ITextSelection.Clear(); tc.Invalidate(); } } return(CommandResult.Succeeded); }
private static void SessionEntryPoint(AbstractTerminal terminal, CommandResultDocument document) { try { TerminalControl tc = terminal.TerminalHost.TerminalControl; Debug.Assert(tc != null); RenderProfile rp = (RenderProfile)tc.GetRenderProfile().Clone(); CommandResultSession session = new CommandResultSession(document, rp); //現在のRenderProfileを使ってセッションを作る TerminalDocument terminaldoc = terminal.GetDocument(); PopupViewCreationParam cp = new PopupViewCreationParam(_viewFactory); //結果のサイズに合わせる。ただし高さは20行を上限とする cp.InitialSize = new Size(tc.ClientSize.Width, (int)(RuntimeUtil.AdjustIntRange(document.Size, 0, 20) * rp.Pitch.Height) + 2); cp.OwnedByCommandTargetWindow = GEnv.Options.CommandPopupAlwaysOnTop; cp.ShowInTaskBar = GEnv.Options.CommandPopupInTaskBar; IWindowManager wm = TerminalEmulatorPlugin.Instance.GetWindowManager(); ISessionManager sm = TerminalEmulatorPlugin.Instance.GetSessionManager(); IPoderosaPopupWindow window = wm.CreatePopupView(cp); sm.StartNewSession(session, window.InternalView); sm.ActivateDocument(session.Document, ActivateReason.InternalAction); } catch (Exception ex) { RuntimeUtil.ReportException(ex); } }
protected void OnOK(object sender, EventArgs args) { this.DialogResult = DialogResult.None; _targetView = GetTargetView(); ITerminalParameter term = PrepareTerminalParameter(); if (term == null) { return; //設定に誤りがある場合 } Poderosa.Terminal.TerminalControl tc = (Poderosa.Terminal.TerminalControl)_targetView.GetAdapter(typeof(Poderosa.Terminal.TerminalControl)); Size sz = tc.CalcTerminalSize((_terminalSettings.RenderProfile == null) ? this.GetInitialRenderProfile() : _terminalSettings.RenderProfile); term.SetTerminalSize(sz.Width, sz.Height); _loginButton.Enabled = false; _cancelButton.Enabled = false; this.Cursor = Cursors.WaitCursor; _originalText = this.Text; this.Text = String.Format("{0} - {1}", _originalText, TEnv.Strings.GetString("Caption.HowToCancel")); StartConnection(); }
public void InternalDetachView(IPoderosaDocument document, IPoderosaView view) { Debug.WriteLineIf(DebugOpt.ViewManagement, "DETACH VIEW"); Debug.Assert(document == _terminal.IDocument); TerminalView tv = (TerminalView)view.GetAdapter(typeof(TerminalView)); Debug.Assert(tv != null); TerminalControl tp = tv.TerminalControl; Debug.Assert(tp != null); //Detachするときにはこのビューになっている必要あり if (!tp.IsDisposed) { _terminal.Detach(tp); tp.Detach(); } _terminalControl = null; }
public PasteToTerminalCommand(TerminalControl control) { _control = control; }
public PasteToTerminalCommand(Poderosa.Terminal.TerminalControl control) { _control = control; }
public MouseWheelHandler(TerminalControl control, VScrollBar scrollBar) : base("mousewheel") { _control = control; _scrollBar = scrollBar; }
public TerminalEmulatorMouseHandler(TerminalControl control) : base("terminal") { _control = control; }
/// <summary> /// A method called when a TerminalControl has been attached to the session. /// </summary> /// <param name="terminalControl">TerminalControl which is being attached</param> public void Attached(TerminalControl terminalControl) { if (_documentCursor != null) terminalControl.SetDocumentCursor(_documentCursor); else terminalControl.ResetDocumentCursor(); }
public MouseTrackingHandler(TerminalControl control) : base("mousetracking") { _control = control; #if DEBUG_MOUSETRACKING _instance = "MT[" + (++_instanceCounter).ToString() + "]"; #endif }
public void InternalAttachView(IPoderosaDocument document, IPoderosaView view) { Debug.WriteLineIf(DebugOpt.ViewManagement, "ATTACH VIEW"); Debug.Assert(document == _terminal.IDocument); TerminalView tv = (TerminalView)view.GetAdapter(typeof(TerminalView)); Debug.Assert(tv != null); TerminalControl tp = tv.TerminalControl; Debug.Assert(tp != null); tp.Attach(this); _terminalControl = tp; _terminal.Attached(tp); }
/// <summary> /// A method called when a TerminalControl is going to be detached from the session. /// </summary> /// <param name="terminalControl">TerminalControl which will be detached</param> public void Detach(TerminalControl terminalControl) { terminalControl.ResetDocumentCursor(); }
protected static void AsyncResultQuickHack(TerminalControl tc, IAsyncResult ar) { if (ar.AsyncWaitHandle.WaitOne(100, false)) //IntelliSenseと同様の理由で時間制限つきのWait tc.EndInvoke(ar); }
protected static void AsyncResultQuickHack(TerminalControl tc, IAsyncResult ar) { if (ar.AsyncWaitHandle.WaitOne(100, false)) //IntelliSense�Ɠ��l�̗��R�Ŏ��Ԑ�������Wait tc.EndInvoke(ar); }
private static TerminalControl CastOrCreateTerminalControl(IPoderosaView view) { TerminalControl c = CastTerminalControl(view); if(c!=null) return c; //キャストできればそれでOK。でなければ作る Debug.WriteLine("Creating New TerminalControl"); IContentReplaceableView rv = (IContentReplaceableView)view.GetAdapter(typeof(IContentReplaceableView)); TerminalControl tc = new TerminalControl(); rv.ReplaceContent(new TerminalView(view.ParentForm, tc)); return tc; }