public CodeTextEditor() { Options = new TextEditorOptions { ConvertTabsToSpaces = true, AllowScrollBelowDocument = true, IndentationSize = 4, EnableEmailHyperlinks = false, }; ShowLineNumbers = true; MouseHover += OnMouseHover; MouseHoverStopped += OnMouseHoverStopped; TextArea.TextView.VisualLinesChanged += OnVisualLinesChanged; TextArea.TextEntering += OnTextEntering; TextArea.TextEntered += OnTextEntered; ToolTipService.SetInitialShowDelay(this, 0); SearchReplacePanel.Install(this); var commandBindings = TextArea.CommandBindings; var deleteLineCommand = commandBindings.OfType<CommandBinding>().FirstOrDefault(x => x.Command == AvalonEditCommands.DeleteLine); if (deleteLineCommand != null) { commandBindings.Remove(deleteLineCommand); } }
public CodeTextEditor() { Options = new TextEditorOptions { ConvertTabsToSpaces = true, AllowScrollBelowDocument = true, IndentationSize = 4, EnableEmailHyperlinks = false, }; // TODO: remove this after bug fix #if AVALONIA var lineMargin = new LineNumberMargin { Margin = new Thickness(0, 0, 10, 0) }; lineMargin[~TextBlock.ForegroundProperty] = this[~LineNumbersForegroundProperty]; TextArea.LeftMargins.Insert(0, lineMargin); #else ShowLineNumbers = true; #endif TextArea.TextView.VisualLinesChanged += OnVisualLinesChanged; TextArea.TextEntering += OnTextEntering; TextArea.TextEntered += OnTextEntered; #if AVALONIA PointerHover += OnMouseHover; PointerHoverStopped += OnMouseHoverStopped; #else MouseHover += OnMouseHover; MouseHoverStopped += OnMouseHoverStopped; ToolTipService.SetInitialShowDelay(this, 0); SearchReplacePanel.Install(this); #endif var commandBindings = TextArea.CommandBindings; var deleteLineCommand = commandBindings.OfType <CommandBinding>().FirstOrDefault(x => x.Command == AvalonEditCommands.DeleteLine); if (deleteLineCommand != null) { commandBindings.Remove(deleteLineCommand); } var contextMenu = new ContextMenu(); contextMenu.SetItems(new[] { new MenuItem { Command = ApplicationCommands.Cut }, new MenuItem { Command = ApplicationCommands.Copy }, new MenuItem { Command = ApplicationCommands.Paste } }); ContextMenu = contextMenu; }
partial void Initialize() { ShowLineNumbers = true; MouseHover += OnMouseHover; MouseHoverStopped += OnMouseHoverStopped; ToolTipService.SetInitialShowDelay(this, 0); SearchReplacePanel.Install(this); }
/// <summary> /// Creates a SearchReplacePanel and installs it to the TextArea. /// </summary> public new static SearchReplacePanel Install(TextArea textArea) { if (textArea == null) { throw new ArgumentNullException(nameof(textArea)); } var panel = new SearchReplacePanel { _textArea = textArea }; typeof(SearchPanel).GetMethod("AttachInternal", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(panel, new object[] { textArea }); panel.AttachInternal(); panel._handler = new SearchReplaceInputHandler(textArea, panel); textArea.DefaultInputHandler.NestedInputHandlers.Add(panel._handler); return(panel); }
internal SearchReplaceInputHandler(TextArea textArea, SearchReplacePanel panel) : base(textArea) { RegisterCommands(); _panel = panel; }