diff --git a/README.md b/README.md --- a/README.md +++ b/README.md @@ -20,34 +20,40 @@ As with other KParts, you should use KParts::MainWindow as your main window. You can directly request "katepart", as in - KService::Ptr service = KService::serviceByDesktopPath("katepart"); - if (service) { - m_part = service->createInstance(0); - } +```cpp +KService::Ptr service = KService::serviceByDesktopName("katepart"); +if (service) { + m_part = service->createInstance(); +} +``` See the KParts documentation for more information on using KParts. ### Library If you are using CMake, you need to have - find_package(KF5TextEditor NO_MODULE) +```cmake +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 - #include - #include +```cpp +#include +#include +#include - 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); +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. @@ -57,6 +63,7 @@ All files shall contain a proper "SPDX-License-Identifier: LGPL-2.0-or-later" identifier inside a header like: +```cpp /* SPDX-License-Identifier: LGPL-2.0-or-later Copyright (C) 2019 Christoph Cullmann @@ -76,6 +83,7 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +``` ## Further Documentation