Table of Contents

Class PlainTextEditor

Namespace
NanoByte.StructureEditor.EtoForms
Assembly
NanoByte.StructureEditor.EtoForms.dll

A plain monospaced text editor without syntax highlighting. Works on all platforms.

public class PlainTextEditor : ITextEditor
Inheritance
object
PlainTextEditor
Implements

Constructors

PlainTextEditor()

Creates a new plain text editor.

public PlainTextEditor()

Properties

Control

The control to display.

public Control Control { get; }

Property Value

Control

Text

The text currently in the editor.

public string Text { get; }

Property Value

string

Methods

ClearError()

Removes any marker set by ShowError(int, int, string).

public void ClearError()

GetOffset(string, int, int)

Converts a line and column number to a character offset.

public static int GetOffset(string text, int line, int column)

Parameters

text string

The text to navigate in.

line int

The 1-based line number.

column int

The 1-based column number.

Returns

int

The 0-based character offset. Clamped to the bounds of the line and text.

NavigateTo(int, int)

Moves the caret to a location in the text and gives the editor the input focus.

public void NavigateTo(int line, int column)

Parameters

line int

The 1-based line number.

column int

The 1-based column number.

SetContent(string, string)

Replaces the text in the editor.

public void SetContent(string text, string formatName)

Parameters

text string

The new text.

formatName string

The FormatName of the text (e.g., XML or JSON). May be used to determine syntax highlighting.

ShowError(int, int, string)

Marks a location in the text as erroneous, without moving the caret.

public void ShowError(int line, int column, string message)

Parameters

line int

The 1-based line number of the error.

column int

The 1-based column number of the error.

message string

A message describing the error.

Events

TextChanged

Raised when the Text has been changed.

public event EventHandler<EventArgs>? TextChanged

Event Type

EventHandler<EventArgs>