public override UIHandleResult OnMouseUp(MouseEventArgs args) { if (!_control.EnabledEx) { return(UIHandleResult.Pass); } if (args.Button == MouseButtons.Right || args.Button == MouseButtons.Middle) { ITerminalEmulatorOptions opt = TerminalEmulatorPlugin.Instance.TerminalEmulatorOptions; MouseButtonAction act = args.Button == MouseButtons.Right? opt.RightButtonAction : opt.MiddleButtonAction; if (act != MouseButtonAction.None) { if (Control.ModifierKeys == Keys.Shift ^ act == MouseButtonAction.ContextMenu) //シフトキーで動作反転 { ShowContextMenu(new Point(args.X, args.Y)); } else //Paste { IGeneralViewCommands vc = (IGeneralViewCommands)_control.GetAdapter(typeof(IGeneralViewCommands)); TerminalEmulatorPlugin.Instance.GetCommandManager().Execute(vc.Paste, (ICommandTarget)vc.GetAdapter(typeof(ICommandTarget))); //ペースト後はフォーカス if (!_control.Focused) { _control.Focus(); } } return(UIHandleResult.Stop); } } return(UIHandleResult.Pass); }
public CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args) { if (!CanExecute(target)) { return(CommandResult.Ignored); } TerminalTransmission output = GetSession().TerminalTransmission; string data = Clipboard.GetDataObject().GetData("Text") as string; if (data == null) { return(CommandResult.Ignored); } ITerminalEmulatorOptions options = TerminalSessionsPlugin.Instance.TerminalEmulatorService.TerminalEmulatorOptions; if (options.AlertOnPasteNewLineChar) { // Data will be split by CR, LF, CRLF or Environment.NewLine by TextReader.ReadLine, // So we check the data about CR, LF and Environment.NewLine. if (data.IndexOfAny(new char[] { '\r', '\n' }) >= 0 || data.Contains(Environment.NewLine)) { IPoderosaView view = (IPoderosaView)_control.GetAdapter(typeof(IPoderosaView)); IPoderosaForm form = view.ParentForm; if (form != null) { DialogResult res = form.AskUserYesNo(TEnv.Strings.GetString("Message.AskPasteNewLineChar")); if (res != DialogResult.Yes) { return(CommandResult.Ignored); } } } } //TODO 長文のときにダイアログを出して中途キャンセル可能に StringReader reader = new StringReader(data); output.SendTextStream(reader, data[data.Length - 1] == '\n'); return(CommandResult.Succeeded); }
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); }