Cogent Core Docs

0%

Loading...

Static preview:

Text editor

A text editor is a widget for editing complex text. It supports advanced code editing features, like syntax highlighting, completion, undo and redo, copy and paste, rectangular selection, and word, line, and page based navigation, selection, and deletion.

Text editors should mainly be used for editing code and other multiline syntactic data like markdown and JSON. For simpler use cases, consider using a text field instead.

Properties

You can make a text editor without any custom options:

You can set the text of a text editor:

You can set the highlighting language of a text editor:

You can set the text of a text editor from an embedded file:

You can also set the text of a text editor directly from the system filesystem, but this is not recommended for files built into your app, since they will end up in a different location on different platforms:

You can make multiple text editors that edit the same underlying text buffer:

Events

You can detect when the user changes the content of a text editor and then exits it:

You can detect when the user makes any changes to the content of a text editor as they type (input):