/// <summary> /// Creates a data object containing the selection's text. /// </summary> public virtual DataObject CreateDataObject(TextArea textArea) { DataObject data = new DataObject(); // Ensure we use the appropriate newline sequence for the OS string text = TextUtilities.NormalizeNewLines(GetText(), Environment.NewLine); // Enable drag/drop to Word, Notepad++ and others if (EditingCommandHandler.ConfirmDataFormat(textArea, data, DataFormats.UnicodeText)) { data.SetText(text); } // Enable drag/drop to SciTe: // We cannot use SetText, thus we need to use typeof(string).FullName as data format. // new DataObject(object) calls SetData(object), which in turn calls SetData(Type, data), // which then uses Type.FullName as format. // We immitate that behavior here as well: if (EditingCommandHandler.ConfirmDataFormat(textArea, data, typeof(string).FullName)) { data.SetData(typeof(string).FullName, text); } // Also copy text in HTML format to clipboard - good for pasting text into Word // or to the SharpDevelop forums. if (EditingCommandHandler.ConfirmDataFormat(textArea, data, DataFormats.Html)) { HtmlClipboard.SetHtml(data, CreateHtmlFragment(new HtmlOptions(textArea.Options))); } return(data); }
/// <summary> /// Creates a new TextAreaDefaultInputHandler instance. /// </summary> public TextAreaDefaultInputHandler(TextArea textArea) : base(textArea) { this.NestedInputHandlers.Add(CaretNavigation = CaretNavigationCommandHandler.Create(textArea)); this.NestedInputHandlers.Add(Editing = EditingCommandHandler.Create(textArea)); this.NestedInputHandlers.Add(MouseSelection = new SelectionMouseHandler(textArea)); this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Undo, ExecuteUndo, CanExecuteUndo)); this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Redo, ExecuteRedo, CanExecuteRedo)); }
/// <inheritdoc/> public override System.Windows.DataObject CreateDataObject(TextArea textArea) { var data = base.CreateDataObject(textArea); if (EditingCommandHandler.ConfirmDataFormat(textArea, data, RectangularSelectionDataType)) { MemoryStream isRectangle = new MemoryStream(1); isRectangle.WriteByte(1); data.SetData(RectangularSelectionDataType, isRectangle, false); } return(data); }