Go to file
luzhiping 849191464e update info 2022-08-22 16:47:11 +08:00
LICENSES Import Upstream version 5.92.0 2022-05-16 16:03:08 +08:00
autotests Import Upstream version 5.92.0 2022-05-16 16:03:08 +08:00
cmake Import Upstream version 5.92.0 2022-05-16 16:03:08 +08:00
debian update info 2022-08-22 16:47:11 +08:00
docs Import Upstream version 5.92.0 2022-05-16 16:03:08 +08:00
po Import Upstream version 5.92.0 2022-05-16 16:03:08 +08:00
src Use the underscore.js available in libraries 2022-05-16 16:03:18 +08:00
templates Import Upstream version 5.92.0 2022-05-16 16:03:08 +08:00
.git-blame-ignore-revs Import Upstream version 5.92.0 2022-05-16 16:03:08 +08:00
.gitignore Import Upstream version 5.92.0 2022-05-16 16:03:08 +08:00
.gitlab-ci.yml Import Upstream version 5.92.0 2022-05-16 16:03:08 +08:00
.kateconfig Import Upstream version 5.92.0 2022-05-16 16:03:08 +08:00
.kateproject Import Upstream version 5.92.0 2022-05-16 16:03:08 +08:00
.kde-ci.yml Import Upstream version 5.92.0 2022-05-16 16:03:08 +08:00
CMakeLists.txt Import Upstream version 5.92.0 2022-05-16 16:03:08 +08:00
ExtraDesktop.sh Import Upstream version 5.92.0 2022-05-16 16:03:08 +08:00
KF5TextEditorConfig.cmake.in Import Upstream version 5.92.0 2022-05-16 16:03:08 +08:00
README.md Import Upstream version 5.92.0 2022-05-16 16:03:08 +08:00
config.h.cmake Import Upstream version 5.92.0 2022-05-16 16:03:08 +08:00
metainfo.yaml Import Upstream version 5.92.0 2022-05-16 16:03:08 +08:00

README.md

KTextEditor

Full text editor component

Introduction

KTextEditor provides a powerful text editor component that you can embed in your application, either as a KPart or using the KF5::TextEditor library (if you need more control).

The text editor component contains many useful features, from syntax highlighting and automatic indentation to advanced scripting support, making it suitable for everything from a simple embedded text-file editor to an advanced IDE.

Usage

KPart

As with other KParts, you should use KParts::MainWindow as your main window. You can directly request "katepart", as in

KService::Ptr service = KService::serviceByDesktopName("katepart");
if (service) {
    m_part = service->createInstance<KParts::ReadWritePart>();
}

See the KParts documentation for more information on using KParts.

Library

If you are using CMake, you need to have

find_package(KF5TextEditor)

(or similar) in your CMakeLists.txt file, and you need to link to KF5::TextEditor.

After that, you can use KTextEditor::Editor to create an editor instance, and use that to manage KTextEditor::Document instances.

#include <KTextEditor/Document>
#include <KTextEditor/Editor>
#include <KTextEditor/View>

KTextEditor::Editor *editor = KTextEditor::Editor::instance();
// create a new document
KTextEditor::Document *doc = editor->createDocument(this);
// create a widget to display the document
KTextEditor::View *view = doc->createView(containerWidget);

See the documentation for these classes for more information.

Licensing

Contributions to KTextEditor shall be licensed under LGPLv2+.

All files shall contain a proper "SPDX-License-Identifier: LGPL-2.0-or-later" identifier inside a header like:

/*
    SPDX-FileCopyrightText: 2021 Christoph Cullmann <cullmann@kde.org>

    SPDX-License-Identifier: LGPL-2.0-or-later
*/

Further Documentation

  • @ref kte_design
  • @ref kte_port_to_5
  • @ref kte_guidelines