RadSyntaxEditor
A control for editing source code with syntax highlighting and advanced text editing capabilities.
Definition
Namespace:Telerik.WinControls.UI
Assembly:Telerik.WinControls.SyntaxEditor.dll
Syntax:
[TelerikToolboxCategory("Editors")]
[Docking(DockingBehavior.Ask)]
public class RadSyntaxEditor : RadControl, IDropTarget, ISynchronizeInvoke, IWin32Window, IBindableComponent, IComponent, IDisposable, INotifyPropertyChanged, ISupportInitializeNotification, ISupportInitialize, IComponentTreeHandler, ILayoutHandler, IAnalyticsProvider
Inheritance: objectMarshalByRefObjectComponentControlScrollableControlRadControlRadSyntaxEditor...
Implements:
Inherited Members
Constructors
public RadSyntaxEditor()
Properties
Gets or sets a value indicating whether text scaling is allowed in the editor.
[Browsable(true)]
public bool AllowScaling { get; set; }
Gets or sets the color of the text cursor (caret) in the editor.
[Browsable(true)]
public Color CaretColor { get; set; }
Gets or sets the display mode of the text cursor (caret), determining its appearance in the editor.
[Browsable(true)]
public CaretDisplayMode CaretDisplayMode { get; set; }
Gets or sets the width of the text cursor (caret) when the CaretDisplayMode is set to Normal.
[Browsable(true)]
public double CaretWidth { get; set; }
Gets the collection of commands that can be executed in the syntax editor.
[Browsable(false)]
public SyntaxEditorCommands Commands { get; }
Gets the default size of the control when it is initially placed on a design surface.
protected override Size DefaultSize { get; }
A Size object representing the default size of the control.
Overrides:
Gets the dispatcher object that manages the execution of operations on the UI thread.
[Browsable(false)]
public Dispatcher Dispatcher { get; }
Gets or sets the text document that contains the content displayed and edited in the control.
[Browsable(false)]
public TextDocument Document { get; set; }
Gets or sets the font size of the text displayed in the editor.
[Browsable(true)]
public double EditorFontSize { get; set; }
Gets or sets the component which is responsible for handling the keyboard and mouse input of the RadSyntaxEditor.
public SyntaxEditorInputBehavior InputHandler { get; set; }
Gets or sets a value indicating whether the text cursor (caret) is visible in the editor.
[Browsable(true)]
public bool IsCaretVisible { get; set; }
Gets or sets a value indicating whether text selection is enabled in the editor.
[Browsable(true)]
public bool IsSelectionEnabled { get; set; }
Gets or sets a value indicating whether word wrapping is enabled in the editor.
[Browsable(true)]
public bool IsWordWrapEnabled { get; set; }
Gets or sets the color palette that defines the appearance of syntax elements in the editor.
[Browsable(false)]
public SyntaxEditorPalette Palette { get; set; }
Gets or sets the scale factor that determines the size of text and UI elements in the editor.
[Browsable(true)]
public double ScaleFactor { get; set; }
Gets or sets a value indicating whether the entire line should be processed by the syntax taggers instead of just the modified region.
[Browsable(true)]
public bool ShouldTaggersProcessEntireLines { get; set; }
Gets or sets a value indicating whether the line numbers are shown.
[Browsable(true)]
public bool ShowLineNumbers { get; set; }
true if the line numbers are shown; otherwise, false.
Gets the RadSyntaxEditorElement which is the main element in the control.
[Browsable(false)]
public RadSyntaxEditorElement SyntaxEditorElement { get; }
Gets the registry of taggers that provide syntax highlighting and other text analysis features.
[Browsable(false)]
public TaggersRegistry TaggersRegistry { get; }
Gets the stack of text format definitions that determine how different elements of text are displayed.
[Browsable(false)]
public TextFormatDefinitionStack TextFormatDefinitions { get; }
Gets or sets a value indicating whether the Shift key must be used to extend text selection.
[Browsable(true)]
public bool UseShiftKeyInSelection { get; set; }
Methods
Copies the current text selection to the clipboard.
public void Copy()
Creates the accessibility object for this control to support screen readers and other assistive technologies.
protected override AccessibleObject CreateAccessibilityInstance()
An AccessibleObject that represents the control for accessibility purposes.
Overrides:
Creates the input behavior component for the RadSyntaxEditor.
protected override ComponentInputBehavior CreateBehavior()
A new instance of RadSyntaxEditorComponentInputBehavior for handling input in this control.
Overrides:
Creates the child elements of the RadSyntaxEditor control.
protected override void CreateChildItems(RadElement parent)
The parent element to which child elements will be added.
Overrides:
Converts a text caret position to a point in the editor's coordinate system.
public Point GetPointFromPosition(CaretPosition position)
The caret position to convert.
Returns:A Point representing the visual position of the caret.
Converts a point in the control's coordinate system to a text caret position.
public CaretPosition GetPositionFromControlPoint(Point point)
The point relative to the control's top-left corner.
Returns:A CaretPosition representing the text position at the specified point.
Scrolls the editor to position the current line at the top of the viewport.
public void MoveCurrentLineToTop()
Handles the key down event by delegating it to the input handler.
protected override void OnKeyDown(KeyEventArgs e)
The event data containing information about the key.
Overrides:
Handles the key press event by delegating it to the input handler.
protected override void OnKeyPress(KeyPressEventArgs e)
The event data containing information about the pressed key.
Overrides:
Handles the key up event by delegating it to the input handler.
protected override void OnKeyUp(KeyEventArgs e)
The event data containing information about the released key.
Overrides:
Called when the control is loaded to initialize the editor element.
protected override void OnLoad(Size desiredSize)
The desired size of the control.
Overrides:
Called when the control's theme changes to update visual elements accordingly.
protected override void OnThemeChanged()
Overrides:
Scrolls the editor content down by one page (viewport height).
public void PageDown()
Scrolls the editor content up by one page (viewport height).
public void PageUp()
Scales the control and its child elements according to the specified scaling factor.
protected override void ScaleControl(SizeF factor, BoundsSpecified specified)
The scaling factor to apply.
specifiedBoundsSpecifiedA value indicating which bounds of the control to scale.
Overrides:
Selects all text in the editor.
public void SelectAll()
Refreshes the visual representation of the current text selection in the editor.
public void UpdateSelection()
Increases the zoom level (scale factor) of the editor by one step.
public void ZoomIn()
Decreases the zoom level (scale factor) of the editor by one step.
public void ZoomOut()
Sets the editor to a specific zoom level (scale factor). The minimum supported zoom level is 0.2 and the maximum supported is 4.
public void ZoomTo(double zoomLevel)
The scale factor to be applied to the editor content.
Exceptions:Thrown when the zoomLevel parameter is negative.
Events
Occurs when a command execution results in an error.
public event EventHandler<CommandErrorEventArgs> CommandError
Occurs after a command has been successfully executed.
public event EventHandler<CommandExecutedEventArgs> CommandExecuted
Occurs before a command is executed, allowing you to cancel or modify the command execution.
public event EventHandler<CommandExecutingEventArgs> CommandExecuting
Occurs after the document has been changed, such as when a new document is loaded or created.
public event EventHandler DocumentChanged
Occurs before the document is changed, allowing you to perform actions before a new document is loaded.
public event EventHandler DocumentChanging
Occurs after the text content of the document has been modified, providing information about the changes made.
public event EventHandler<TextContentChangedEventArgs> DocumentContentChanged
Occurs before the text content of the document is modified, allowing you to cancel or modify the changes.
public event EventHandler<TextContentChangingEventArgs> DocumentContentChanging
Occurs when the read-only state of the editor changes.
public event EventHandler IsReadOnlyChanged
Occurs when the layout properties of the editor change, affecting how text is displayed.
public event EventHandler LayoutPropertiesChanged
Occurs before text input is processed by the syntax editor, allowing you to intercept and modify the input.
public event EventHandler<PreviewSyntaxEditorInputEventArgs> PreviewSyntaxEditorInput
Occurs before a key down event is processed by the syntax editor, allowing you to intercept and handle keyboard input.
public event EventHandler<PreviewSyntaxEditorKeyEventArgs> PreviewSyntaxEditorKeyDown
Occurs before a key up event is processed by the syntax editor, allowing you to intercept and handle keyboard input.
public event EventHandler<PreviewSyntaxEditorKeyEventArgs> PreviewSyntaxEditorKeyUp
Occurs before a mouse left button down event is processed by the syntax editor, allowing you to intercept and handle mouse input.
public event EventHandler<PreviewSyntaxEditorMouseButtonEventArgs> PreviewSyntaxEditorMouseLeftButtonDown
Occurs before a mouse right button down event is processed by the syntax editor, allowing you to intercept and handle context menu actions.
public event EventHandler<PreviewSyntaxEditorMouseButtonEventArgs> PreviewSyntaxEditorMouseRightButtonDown
Occurs when the scaling factor of the editor changes, affecting the size of text and UI elements.
public event EventHandler ScaleFactorChanged
Occurs when the text selection in the editor changes, either by user interaction or programmatically.
public event EventHandler SelectionChanged
Occurs when the visible area (viewport) of the editor changes, such as during scrolling or resizing.
public event EventHandler ViewportChanged