TextEditor

Search for usage in LXR

TextEditor Class Reference
Inheritance diagram for TextEditor:

Properties

alias body
 
alias bold
 
alias canRedo
 
alias document
 
alias documentMenu
 
alias fileUrl
 
alias italic
 
alias scrollView
 
bool showFindBar
 
bool showLineNumbers
 
bool spellcheckEnabled
 
alias text
 
alias underline
 
alias uppercase
 
- Properties inherited from Page
listTAction actions
 
Flickable flickable
 
Item globalToolBarItem
 
int globalToolBarStyle
 
PActionIconGroup icon
 
bool isCurrentPage
 
alias overlay
 
var progress
 
Component titleDelegate
 

Public Member Functions

void forceActiveFocus ()
 
void goToLine (line)
 

Additional Inherited Members

- Signals inherited from Page
void backRequested (var event)
 

Detailed Description

Integrated text editor component.

Since
org.mauikit.texteditor 1.0

A text area for editing text with convinient functions. The Editor is controlled by the DocumentHandler which controls the files I/O, the syntax highlighting styles, and many more text editing properties.

Features

The TextEditor control comes with a set of built-in features, such as find & replace, syntax highlighting support, line number sidebar, I/O capabilities, file document alerts, and syntax corrector.

I/O

Opening a local text file is handle by the DocumentHandler via the fileUrl property. The document contents will be loaded by the FileLoader and made available to the TextEditor for drawing.

See also
DocumentHandler::fileUrl
Warning
Opening large contents will cause the app to freeze, since it is not optimized to dynamically allocate the contents by chunks and instead all of the content will be rendered at once. A solution with a different backend is being implemented.

Once an existing document is opened or created, it will also be watched for any external changes, such as modifications to its contents or its removal, those changes will be notified via the alert bars, exposing the avaliable options.

See also
DocumentHandler::autoReload

To save any changes made to an existing document or to save a new one manually use the exposed method DocumentHandler::saveAs, which will take as parameter the location where to save the file at, if you mean to save the changes to an already existing file, simply pass the DocumentHandler::fileUrl value. The changes made could be automatically saved every few seconds if the DocumentHandler::autoSave property is enabled.

ToolButton
{
icon.name: "folder-open"
onClicked: _editor.fileUrl = "file:///home/camiloh/nota/CMakeLists.txt"
}
...
TE.TextEditor
{
id: _editor
anchors.fill: parent
body.wrapMode: Text.NoWrap
document.enableSyntaxHighlighting: true
}
PActionIconGroup icon
alias document
Alias to access the DocumentHandler.
alias body
Access to the editor text area.

Syntax Highlighting

To enable the syntax highlighting enable the DocumentHandler::enableSyntaxHighlighting property.

Note
If the language is not detected automatically or if you desire to change it, use the showSyntaxHighlightingLanguages property to toggle the selection combobox to allow the user to select a custom language, and bind it to the DocumentHandler::formatName property.

There are different color schemes available, those can be set using the DocumentHandler::theme property. You can also use the ColorSchemesPage control which lists all the available options.

Others

The find & replace bars can be toggled using the showFindBar property.

See also
DocumentHandler::findWholeWords
DocumentHandler::findCaseSensitively

To enable the line number sidebar use the showLineNumbers property.

Spell checking can be anbled using the spellcheckEnabled property. For this Sonnet must be available.

Fonts & Colors

For tweaking the font properties and colors use the DocumentHandler::textColor and DocumentHandler::backgroundColor, etc.

For more details and properties check the own DocumentHandler properties.

Definition at line 76 of file TextEditor.qml.

Property Documentation

◆ body

alias TextEditor::body
read

Access to the editor text area.

Remarks
This property is read-only

Definition at line 96 of file TextEditor.qml.

◆ bold

alias TextEditor::bold
read
See also
DocumentHandler::bold

Definition at line 139 of file TextEditor.qml.

◆ canRedo

alias TextEditor::canRedo
read

Whether there are modifications to the document that can be redo.

Alias to the TextArea::canRedo

Definition at line 144 of file TextEditor.qml.

◆ document

alias TextEditor::document
read

Alias to access the DocumentHandler.

Remarks
This property is read-only

Definition at line 102 of file TextEditor.qml.

◆ documentMenu

alias TextEditor::documentMenu
read

Alias to the contextual menu.

Remarks
This property is read-only

This menu is loaded asynchronous.

Definition at line 114 of file TextEditor.qml.

◆ fileUrl

alias TextEditor::fileUrl
read

If a file url is provided the DocumentHandler will try to open its contents and display it.

See also
DocumentHandler::fileUrl

Definition at line 150 of file TextEditor.qml.

◆ italic

alias TextEditor::italic
read
See also
DocumentHandler::italic

Definition at line 134 of file TextEditor.qml.

◆ scrollView

alias TextEditor::scrollView
read

Alias to the ScrollView.

Remarks
This property is read-only

Definition at line 108 of file TextEditor.qml.

◆ showFindBar

bool TextEditor::showFindBar
read

Definition at line 85 of file TextEditor.qml.

◆ showLineNumbers

bool TextEditor::showLineNumbers
read

If a sidebar listing each line number should be visible.

By default this is set to false

Definition at line 155 of file TextEditor.qml.

◆ spellcheckEnabled

bool TextEditor::spellcheckEnabled
read

Whether to enable the spell checker.

By default this is set to false

Definition at line 160 of file TextEditor.qml.

◆ text

alias TextEditor::text
read

Alias to the text area text content.

Definition at line 119 of file TextEditor.qml.

◆ underline

alias TextEditor::underline
read
See also
DocumentHandler::underline

Definition at line 129 of file TextEditor.qml.

◆ uppercase

alias TextEditor::uppercase
read
See also
DocumentHandler::uppercase

Definition at line 124 of file TextEditor.qml.

Member Function Documentation

◆ forceActiveFocus()

void TextEditor::forceActiveFocus ( )

Force to focus the text area for input.

◆ goToLine()

void TextEditor::goToLine ( line )

Position the view and cursor at the given line number.

Parameters
linethe line number

The documentation for this class was generated from the following file:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:58:09 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.