KTextEditor

kateglobal.cpp
1/*
2 SPDX-FileCopyrightText: 2001-2010 Christoph Cullmann <cullmann@kde.org>
3 SPDX-FileCopyrightText: 2009 Erlend Hamberg <ehamberg@gmail.com>
4
5 For the addScrollablePage original
6 SPDX-FileCopyrightText: 2003 Benjamin C Meyer <ben+kdelibs at meyerhome dot net>
7 SPDX-FileCopyrightText: 2003 Waldo Bastian <bastian@kde.org>
8 SPDX-FileCopyrightText: 2004 Michael Brade <brade@kde.org>
9 SPDX-FileCopyrightText: 2021 Ahmad Samir <a.samirh78@gmail.com>
10
11 SPDX-License-Identifier: LGPL-2.0-or-later
12*/
13
14#include "kateglobal.h"
15
16#include <ktexteditor_version.h>
17
18#include "katebuffer.h"
19#include "katecmd.h"
20#include "katecmds.h"
21#include "kateconfig.h"
22#include "katedialogs.h"
23#include "katedocument.h"
24#include "katehighlightingcmds.h"
25#include "katekeywordcompletion.h"
26#include "katemodemanager.h"
27#include "katescriptmanager.h"
28#include "katesedcmd.h"
29#include "katesyntaxmanager.h"
30#include "katethemeconfig.h"
31#include "katevariableexpansionmanager.h"
32#include "kateview.h"
33#include "katewordcompletion.h"
34#include "spellcheck/spellcheck.h"
35
36#include "katenormalinputmodefactory.h"
37#include "kateviinputmodefactory.h"
38
39#include <KConfigGroup>
40#include <KDirWatch>
41#include <KLocalizedString>
42#include <KPageDialog>
43
44#include <QApplication>
45#include <QBoxLayout>
46#include <QClipboard>
47#include <QFrame>
48#include <QPushButton>
49#include <QScreen>
50#include <QScrollArea>
51#include <QScrollBar>
52#include <QStringListModel>
53#include <QTextToSpeech>
54#include <QTimer>
55
56KTextEditor::EditorPrivate::EditorPrivate(QPointer<KTextEditor::EditorPrivate> &staticInstance)
57 : KTextEditor::Editor(this)
58 , m_aboutData(QStringLiteral("katepart"),
59 i18n("Kate Part"),
60 QStringLiteral(KTEXTEDITOR_VERSION_STRING),
61 i18n("Embeddable editor component"),
62 KAboutLicense::LGPL_V2,
63 i18n("(c) 2000-2022 The Kate Authors"),
64 QString(),
65 QStringLiteral("https://kate-editor.org"))
66 , m_dummyApplication(nullptr)
67 , m_application(&m_dummyApplication)
68 , m_dummyMainWindow(nullptr)
69 , m_searchHistoryModel(nullptr)
70 , m_replaceHistoryModel(nullptr)
71{
72 // remember this
73 staticInstance = this;
74
75 // register some datatypes
76 qRegisterMetaType<KTextEditor::Cursor>("KTextEditor::Cursor");
77 qRegisterMetaType<KTextEditor::Document *>("KTextEditor::Document*");
78 qRegisterMetaType<KTextEditor::View *>("KTextEditor::View*");
79
80 //
81 // fill about data
82 //
83 m_aboutData.addAuthor(i18n("Christoph Cullmann"), i18n("Maintainer"), QStringLiteral("cullmann@kde.org"), QStringLiteral("https://cullmann.io"));
84 m_aboutData.addAuthor(i18n("Dominik Haumann"), i18n("Core Developer"), QStringLiteral("dhaumann@kde.org"));
85 m_aboutData.addAuthor(i18n("Milian Wolff"), i18n("Core Developer"), QStringLiteral("mail@milianw.de"), QStringLiteral("https://milianw.de/"));
86 m_aboutData.addAuthor(i18n("Joseph Wenninger"),
87 i18n("Core Developer"),
88 QStringLiteral("jowenn@kde.org"),
89 QStringLiteral("http://stud3.tuwien.ac.at/~e9925371"));
90 m_aboutData.addAuthor(i18n("Erlend Hamberg"), i18n("Vi Input Mode"), QStringLiteral("ehamberg@gmail.com"), QStringLiteral("https://hamberg.no/erlend"));
91 m_aboutData.addAuthor(i18n("Bernhard Beschow"),
92 i18n("Developer"),
93 QStringLiteral("bbeschow@cs.tu-berlin.de"),
94 QStringLiteral("https://user.cs.tu-berlin.de/~bbeschow"));
95 m_aboutData.addAuthor(i18n("Anders Lund"), i18n("Core Developer"), QStringLiteral("anders@alweb.dk"), QStringLiteral("https://alweb.dk"));
96 m_aboutData.addAuthor(i18n("Michel Ludwig"), i18n("On-the-fly spell checking"), QStringLiteral("michel.ludwig@kdemail.net"));
97 m_aboutData.addAuthor(i18n("Pascal Létourneau"), i18n("Large scale bug fixing"), QStringLiteral("pascal.letourneau@gmail.com"));
98 m_aboutData.addAuthor(i18n("Hamish Rodda"), i18n("Core Developer"), QStringLiteral("rodda@kde.org"));
99 m_aboutData.addAuthor(i18n("Waldo Bastian"), i18n("The cool buffersystem"), QStringLiteral("bastian@kde.org"));
100 m_aboutData.addAuthor(i18n("Charles Samuels"), i18n("The Editing Commands"), QStringLiteral("charles@kde.org"));
101 m_aboutData.addAuthor(i18n("Matt Newell"), i18n("Testing, ..."), QStringLiteral("newellm@proaxis.com"));
102 m_aboutData.addAuthor(i18n("Michael Bartl"), i18n("Former Core Developer"), QStringLiteral("michael.bartl1@chello.at"));
103 m_aboutData.addAuthor(i18n("Michael McCallum"), i18n("Core Developer"), QStringLiteral("gholam@xtra.co.nz"));
104 m_aboutData.addAuthor(i18n("Michael Koch"), i18n("KWrite port to KParts"), QStringLiteral("koch@kde.org"));
105 m_aboutData.addAuthor(i18n("Christian Gebauer"), QString(), QStringLiteral("gebauer@kde.org"));
106 m_aboutData.addAuthor(i18n("Simon Hausmann"), QString(), QStringLiteral("hausmann@kde.org"));
107 m_aboutData.addAuthor(i18n("Glen Parker"), i18n("KWrite Undo History, Kspell integration"), QStringLiteral("glenebob@nwlink.com"));
108 m_aboutData.addAuthor(i18n("Scott Manson"), i18n("KWrite XML Syntax highlighting support"), QStringLiteral("sdmanson@alltel.net"));
109 m_aboutData.addAuthor(i18n("John Firebaugh"), i18n("Patches and more"), QStringLiteral("jfirebaugh@kde.org"));
110 m_aboutData.addAuthor(i18n("Andreas Kling"), i18n("Developer"), QStringLiteral("kling@impul.se"));
111 m_aboutData.addAuthor(i18n("Mirko Stocker"), i18n("Various bugfixes"), QStringLiteral("me@misto.ch"), QStringLiteral("https://misto.ch/"));
112 m_aboutData.addAuthor(i18n("Matthew Woehlke"), i18n("Selection, KColorScheme integration"), QStringLiteral("mw_triad@users.sourceforge.net"));
113 m_aboutData.addAuthor(i18n("Sebastian Pipping"),
114 i18n("Search bar back- and front-end"),
115 QStringLiteral("webmaster@hartwork.org"),
116 QStringLiteral("https://hartwork.org/"));
117 m_aboutData.addAuthor(i18n("Jochen Wilhelmy"), i18n("Original KWrite Author"), QStringLiteral("digisnap@cs.tu-berlin.de"));
118 m_aboutData.addAuthor(i18n("Gerald Senarclens de Grancy"),
119 i18n("QA and Scripting"),
120 QStringLiteral("oss@senarclens.eu"),
121 QStringLiteral("http://find-santa.eu/"));
122
123 m_aboutData.addCredit(i18n("Matteo Merli"), i18n("Highlighting for RPM Spec-Files, Perl, Diff and more"), QStringLiteral("merlim@libero.it"));
124 m_aboutData.addCredit(i18n("Rocky Scaletta"), i18n("Highlighting for VHDL"), QStringLiteral("rocky@purdue.edu"));
125 m_aboutData.addCredit(i18n("Yury Lebedev"), i18n("Highlighting for SQL"), QString());
126 m_aboutData.addCredit(i18n("Chris Ross"), i18n("Highlighting for Ferite"), QString());
127 m_aboutData.addCredit(i18n("Nick Roux"), i18n("Highlighting for ILERPG"), QString());
128 m_aboutData.addCredit(i18n("Carsten Niehaus"), i18n("Highlighting for LaTeX"), QString());
129 m_aboutData.addCredit(i18n("Per Wigren"), i18n("Highlighting for Makefiles, Python"), QString());
130 m_aboutData.addCredit(i18n("Jan Fritz"), i18n("Highlighting for Python"), QString());
131 m_aboutData.addCredit(i18n("Daniel Naber"));
132 m_aboutData.addCredit(i18n("Roland Pabel"), i18n("Highlighting for Scheme"), QString());
133 m_aboutData.addCredit(i18n("Cristi Dumitrescu"), i18n("PHP Keyword/Datatype list"), QString());
134 m_aboutData.addCredit(i18n("Carsten Pfeiffer"), i18n("Very nice help"), QString());
135 m_aboutData.addCredit(i18n("Bruno Massa"), i18n("Highlighting for Lua"), QStringLiteral("brmassa@gmail.com"));
136
137 m_aboutData.addCredit(i18n("All people who have contributed and I have forgotten to mention"));
138
139 m_aboutData.setTranslator(i18nc("NAME OF TRANSLATORS", "Your names"), i18nc("EMAIL OF TRANSLATORS", "Your emails"));
140
141 // set proper Kate icon for our about dialog
142 m_aboutData.setProgramLogo(QIcon(QStringLiteral(":/ktexteditor/kate.svg")));
143
144 //
145 // dir watch
146 //
147 m_dirWatch = new KDirWatch();
148
149 //
150 // command manager
151 //
152 m_cmdManager = new KateCmd();
153
154 //
155 // variable expansion manager
156 //
157 m_variableExpansionManager = new KateVariableExpansionManager(this);
158
159 //
160 // hl manager
161 //
162 m_hlManager = new KateHlManager();
163
164 //
165 // mode man
166 //
167 m_modeManager = new KateModeManager();
168
169 //
170 // input mode factories
171 //
172 Q_ASSERT(m_inputModeFactories.size() == KTextEditor::View::ViInputMode + 1);
173 m_inputModeFactories[KTextEditor::View::NormalInputMode].reset(new KateNormalInputModeFactory());
174 m_inputModeFactories[KTextEditor::View::ViInputMode].reset(new KateViInputModeFactory());
175
176 //
177 // spell check manager
178 //
179 m_spellCheckManager = new KateSpellCheckManager();
180
181 // config objects
182 m_globalConfig = new KateGlobalConfig();
183 m_documentConfig = new KateDocumentConfig();
184 m_viewConfig = new KateViewConfig();
185 m_rendererConfig = new KateRendererConfig();
186
187 // create script manager (search scripts)
188 m_scriptManager = KateScriptManager::self();
189
190 //
191 // init the cmds
192 //
193 m_cmds = {
194 KateCommands::CoreCommands::self(),
195 KateCommands::Character::self(),
196 KateCommands::Date::self(),
197 KateCommands::SedReplace::self(),
198 KateCommands::Highlighting::self(),
199 };
200
201 // global word completion model
202 m_wordCompletionModel = new KateWordCompletionModel(this);
203
204 // global keyword completion model
205 m_keywordCompletionModel = new KateKeywordCompletionModel(this);
206
207 // tap to QApplication object for color palette changes
208 qApp->installEventFilter(this);
209}
210
212{
213 delete m_globalConfig;
214 delete m_documentConfig;
215 delete m_viewConfig;
216 delete m_rendererConfig;
217
218 delete m_modeManager;
219
220 delete m_dirWatch;
221
222 // cu managers
223 delete m_scriptManager;
224 delete m_hlManager;
225
226 delete m_spellCheckManager;
227
228 // cu model
229 delete m_wordCompletionModel;
230
231 // delete variable expansion manager
232 delete m_variableExpansionManager;
233 m_variableExpansionManager = nullptr;
234
235 // delete the commands before we delete the cmd manager
236 qDeleteAll(m_cmds);
237 delete m_cmdManager;
238}
239
241{
242 KTextEditor::DocumentPrivate *doc = new KTextEditor::DocumentPrivate(false, false, nullptr, parent);
243
244 Q_EMIT documentCreated(this, doc);
245
246 return doc;
247}
248
249// END KTextEditor::Editor config stuff
250
251// config dialog with improved sizing and that allows scrolling
252class KTextEditorConfigDialog : public KPageDialog
253{
254public:
255 std::vector<KTextEditor::ConfigPage *> editorPages;
256
257 KTextEditorConfigDialog(KTextEditor::EditorPrivate *editor, QWidget *parent)
258 : KPageDialog(parent)
259 {
260 setWindowTitle(i18n("Configure"));
261 setFaceType(KPageDialog::List);
263
264 // create pages already in construct to have proper layout for sizeHint
265 editorPages.reserve(editor->configPages());
266 for (int i = 0; i < editor->configPages(); ++i) {
267 KTextEditor::ConfigPage *page = editor->configPage(i, this);
268 KPageWidgetItem *item = addScrollablePage(page, page->name());
269 item->setHeader(page->fullName());
270 item->setIcon(page->icon());
271
273 editorPages.push_back(page);
274 }
275 }
276
277 QSize sizeHint() const override
278 {
279 // start with a bit enlarged default size hint to minimize changes of useless scrollbars
280 QSize size = KPageDialog::sizeHint() * 1.3;
281
282 // enlarge it to half of the main window size, if that is larger
283 if (parentWidget() && parentWidget()->window()) {
284 size = size.expandedTo(parentWidget()->window()->size() * 0.5);
285 }
286
287 // return bounded size to available real screen space
288 return size.boundedTo(screen()->availableSize() * 0.9);
289 }
290
291 KPageWidgetItem *addScrollablePage(QWidget *page, const QString &itemName)
292 {
293 // inspired by KPageWidgetItem *KConfigDialogPrivate::addPageInternal(QWidget *page, const QString &itemName, const QString &pixmapName, const QString
294 // &header)
295 QWidget *frame = new QWidget;
296 QVBoxLayout *boxLayout = new QVBoxLayout(frame);
297 boxLayout->setContentsMargins(0, 0, 0, 0);
298 boxLayout->setContentsMargins(0, 0, 0, 0);
299
300 QScrollArea *scroll = new QScrollArea;
304 scroll->setWidget(page);
305 scroll->setWidgetResizable(true);
307
308 if (page->minimumSizeHint().height() > scroll->sizeHint().height() - 2) {
309 if (page->sizeHint().width() < scroll->sizeHint().width() + 2) {
310 // QScrollArea is planning only a vertical scroll bar,
311 // try to avoid the horizontal one by reserving space for the vertical one.
312 // Currently KPageViewPrivate::_k_modelChanged() queries the minimumSizeHint().
313 // We can only set the minimumSize(), so this approach relies on QStackedWidget size calculation.
314 scroll->setMinimumWidth(scroll->sizeHint().width() + qBound(0, scroll->verticalScrollBar()->sizeHint().width(), 200) + 4);
315 }
316 }
317
318 boxLayout->addWidget(scroll);
319 return addPage(frame, itemName);
320 }
321};
322
324{
325 QPointer<KTextEditorConfigDialog> kd = new KTextEditorConfigDialog(this, parent);
326 if (kd->exec() && kd) {
327 KateGlobalConfig::global()->configStart();
328 KateDocumentConfig::global()->configStart();
329 KateViewConfig::global()->configStart();
330 KateRendererConfig::global()->configStart();
331
332 for (auto *page : kd->editorPages) {
333 page->apply();
334 }
335
336 KateGlobalConfig::global()->configEnd();
337 KateDocumentConfig::global()->configEnd();
338 KateViewConfig::global()->configEnd();
339 KateRendererConfig::global()->configEnd();
340 }
341 delete kd;
342}
343
345{
346 return 4;
347}
348
350{
351 switch (number) {
352 case 0:
353 return new KateViewDefaultsConfig(parent);
354
355 case 1:
356 return new KateThemeConfigPage(parent);
357
358 case 2:
359 return new KateEditConfigTab(parent);
360
361 case 3:
362 return new KateSaveConfigTab(parent);
363
364 default:
365 break;
366 }
367
368 return nullptr;
369}
370
371/**
372 * Cleanup the KTextEditor::EditorPrivate during QCoreApplication shutdown
373 */
374static void cleanupGlobal()
375{
376 // delete if there
378}
379
381{
382 // remember the static instance in a QPointer
383 static bool inited = false;
384 static QPointer<KTextEditor::EditorPrivate> staticInstance;
385
386 // just return it, if already inited
387 if (inited) {
388 return staticInstance.data();
389 }
390
391 // start init process
392 inited = true;
393
394 // now create the object and store it
395 new KTextEditor::EditorPrivate(staticInstance);
396
397 // register cleanup
398 // let use be deleted during QCoreApplication shutdown
399 qAddPostRoutine(cleanupGlobal);
400
401 // return instance
402 return staticInstance.data();
403}
404
405void KTextEditor::EditorPrivate::registerDocument(KTextEditor::DocumentPrivate *doc)
406{
407 Q_ASSERT(!m_documents.contains(doc));
408 m_documents.push_back(doc);
409}
410
411void KTextEditor::EditorPrivate::deregisterDocument(KTextEditor::DocumentPrivate *doc)
412{
413 int i = m_documents.indexOf(doc);
414 Q_ASSERT(i != -1);
415 m_documents.removeAt(i);
416}
417
418void KTextEditor::EditorPrivate::registerView(KTextEditor::ViewPrivate *view)
419{
420 Q_ASSERT(std::find(m_views.begin(), m_views.end(), view) == m_views.end());
421 m_views.push_back(view);
422}
423
424void KTextEditor::EditorPrivate::deregisterView(KTextEditor::ViewPrivate *view)
425{
426 auto it = std::find(m_views.begin(), m_views.end(), view);
427 Q_ASSERT(it != m_views.end());
428 m_views.erase(it);
429}
430
432{
433 return m_cmdManager->queryCommand(cmd);
434}
435
437{
438 return m_cmdManager->commands();
439}
440
442{
443 return m_cmdManager->commandList();
444}
445
450
451void KTextEditor::EditorPrivate::updateColorPalette()
452{
453 // reload the global schema (triggers reload for every view as well)
454 // might trigger selection of better matching theme for new palette
455 m_rendererConfig->reloadSchema();
456
457 // force full update of all view caches and colors
458 m_rendererConfig->updateConfig();
459}
460
462{
463 // empty => nop
464 if (text.isEmpty()) {
465 return;
466 }
467
468 // move to clipboard
470
471 // LRU, kill potential duplicated, move new entry to top
472 // cut after X entries
473 auto entry = ClipboardEntry{.text=text, .fileName=fileName};
474 m_clipboardHistory.removeOne(entry);
475 m_clipboardHistory.prepend(entry);
476 if (m_clipboardHistory.size() > m_viewConfig->clipboardHistoryEntries()) {
477 m_clipboardHistory.removeLast();
478 }
479
480 // notify about change
481 Q_EMIT clipboardHistoryChanged();
482}
483
484bool KTextEditor::EditorPrivate::eventFilter(QObject *obj, QEvent *event)
485{
486 if (obj == qApp && event->type() == QEvent::ApplicationPaletteChange) {
487 // only update the color once for the event that belongs to the qApp
488 updateColorPalette();
489 }
490
491 return false; // always continue processing
492}
493
495{
496 if (!m_searchHistoryModel) {
497 KConfigGroup cg(KSharedConfig::openConfig(), QStringLiteral("KTextEditor::Search"));
498 const QStringList history = cg.readEntry(QStringLiteral("Search History"), QStringList());
499 m_searchHistoryModel = new QStringListModel(history, this);
500 }
501 return m_searchHistoryModel;
502}
503
505{
506 if (!m_replaceHistoryModel) {
507 KConfigGroup cg(KSharedConfig::openConfig(), QStringLiteral("KTextEditor::Search"));
508 const QStringList history = cg.readEntry(QStringLiteral("Replace History"), QStringList());
509 m_replaceHistoryModel = new QStringListModel(history, this);
510 }
511 return m_replaceHistoryModel;
512}
513
515{
516 KConfigGroup cg(KSharedConfig::openConfig(), QStringLiteral("KTextEditor::Search"));
517 if (m_searchHistoryModel) {
518 cg.writeEntry(QStringLiteral("Search History"), m_searchHistoryModel->stringList());
519 }
520 if (m_replaceHistoryModel) {
521 cg.writeEntry(QStringLiteral("Replace History"), m_replaceHistoryModel->stringList());
522 }
523}
524
526{
527 // use dummy config for unit tests!
528 if (QStandardPaths::isTestModeEnabled()) {
529 return KSharedConfig::openConfig(QStringLiteral("katepartrc-unittest"), KConfig::SimpleConfig, QStandardPaths::TempLocation);
530 }
531
532 // else: use application configuration, but try to transfer global settings on first use
533 auto applicationConfig = KSharedConfig::openConfig();
534 if (!KConfigGroup(applicationConfig, QStringLiteral("KTextEditor Editor")).exists()) {
535 auto globalConfig = KSharedConfig::openConfig(QStringLiteral("katepartrc"));
536 for (const auto &group : {QStringLiteral("Editor"), QStringLiteral("Document"), QStringLiteral("View"), QStringLiteral("Renderer")}) {
537 KConfigGroup origin(globalConfig, group);
538 KConfigGroup destination(applicationConfig, QStringLiteral("KTextEditor ") + group);
539 origin.copyTo(&destination);
540 }
541 }
542 return applicationConfig;
543}
544
546{
547 // trigger delayed emission, will collapse multiple events to one signal emission
548 m_configWasChanged = true;
549 QTimer::singleShot(0, this, &KTextEditor::EditorPrivate::emitConfigChanged);
550}
551
552void KTextEditor::EditorPrivate::emitConfigChanged()
553{
554 // emit only once, if still needed
555 if (m_configWasChanged) {
556 m_configWasChanged = false;
557 Q_EMIT configChanged(this);
558 }
559}
560
561void KTextEditor::EditorPrivate::copyToMulticursorClipboard(const QStringList &texts)
562{
563 if (texts.size() == 1) {
564 qWarning() << "Unexpected size 1 of multicursorClipboard. It should either be empty or greater than 1";
565 m_multicursorClipboard = QStringList();
566 Q_ASSERT(false);
567 return;
568 }
569 m_multicursorClipboard = texts;
570}
571
572QStringList KTextEditor::EditorPrivate::multicursorClipboard() const
573{
574 return m_multicursorClipboard;
575}
576
577QTextToSpeech *KTextEditor::EditorPrivate::speechEngine(KTextEditor::ViewPrivate *view)
578{
579 Q_ASSERT(view);
580 if (!m_speechEngine) {
581 m_speechEngine = new QTextToSpeech(this);
582
583 // error handler for errors happening during speech output
584 connect(m_speechEngine, &QTextToSpeech::errorOccurred, this, [this](QTextToSpeech::ErrorReason, const QString &errorString) {
585 if (m_speechEngineLastUser) {
586 speechError(m_speechEngineLastUser, errorString);
587 }
588 });
589
590 // handle init errors, that will not emit errorOccurred later
591 if (m_speechEngine->errorReason() != QTextToSpeech::ErrorReason::NoError) {
592 speechError(view, m_speechEngine->errorString());
593 }
594 }
595
596 // register current view, handle error output and stopping of the speaking
597 if (view != m_speechEngineLastUser) {
598 if (m_speechEngineLastUser) {
599 disconnect(m_speechEngineLastUser, &QObject::destroyed, this, &KTextEditor::EditorPrivate::speechEngineUserDestoyed);
600 }
601 m_speechEngineLastUser = view;
602 connect(m_speechEngineLastUser, &QObject::destroyed, this, &KTextEditor::EditorPrivate::speechEngineUserDestoyed);
603 }
604
605 return m_speechEngine;
606}
607
608void KTextEditor::EditorPrivate::speechEngineUserDestoyed()
609{
610 Q_ASSERT(m_speechEngine);
611 m_speechEngine->stop();
612}
613
614void KTextEditor::EditorPrivate::speechError(KTextEditor::ViewPrivate *view, const QString &errorString)
615{
616 Q_ASSERT(view);
617 auto message = new KTextEditor::Message(errorString, Message::Error);
618 message->setPosition(KTextEditor::Message::TopInView);
619 message->setView(view);
620 view->document()->postMessage(message);
621}
622
623#include "moc_kateglobal.cpp"
void writeEntry(const char *key, const char *value, WriteConfigFlags pFlags=Normal)
QString readEntry(const char *key, const char *aDefault=nullptr) const
void copyTo(KConfigBase *other, WriteConfigFlags pFlags=Normal) const
void setIcon(const QIcon &icon)
void setHeader(const QString &header)
static KSharedConfig::Ptr openConfig(const QString &fileName=QString(), OpenFlags mode=FullConfig, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation)
An Editor command line command.
Config page interface for the Editor and Plugins.
Definition configpage.h:44
virtual QString fullName() const
Get a readable full name for the config page.
virtual QIcon icon() const
Get an icon for the config page.
virtual void apply()=0
This slot is called whenever the button Apply or OK was clicked.
virtual QString name() const =0
Get a readable name for the config page.
A KParts derived class representing a text document.
Definition document.h:284
virtual bool postMessage(Message *message)=0
Post message to the Document and its Views.
KTextEditor::EditorPrivate One instance of this class is hold alive during a kate part session,...
Definition kateglobal.h:65
void copyToClipboard(const QString &text, const QString &fileName)
Copy text to clipboard an remember it in the history.
void saveSearchReplaceHistoryModels()
Call this function to store the history models to the application config.
KTextEditor::ConfigPage * configPage(int number, QWidget *parent) override
returns config page with the given number, config pages from 0 to configPages()-1 are available if co...
QStringListModel * replaceHistoryModel()
Replace pattern history shared among simple/power search instances.
void deregisterDocument(KTextEditor::DocumentPrivate *doc)
unregister document at the factory
KTextEditor::Command * queryCommand(const QString &cmd) const override
query for command
KTextEditor::Document * createDocument(QObject *parent) override
Create a new document object.
int configPages() const override
Number of available config pages If the editor returns a number < 1, it doesn't support this and the ...
void deregisterView(KTextEditor::ViewPrivate *view)
unregister view at the factory
static KSharedConfigPtr config()
The global configuration of katepart, e.g.
QTextToSpeech * speechEngine(KTextEditor::ViewPrivate *view)
text to speech engine to be use by the view actions, constructed on demand.
void triggerConfigChanged()
Trigger delayed emission of config changed.
QStringList commandList() const override
Get a list of available commandline strings.
void registerDocument(KTextEditor::DocumentPrivate *doc)
register document at the factory this allows us to loop over all docs for example on config changes
void configDialog(QWidget *parent) override
Configuration management.
QStringListModel * searchHistoryModel()
Search pattern history shared among simple/power search instances.
void registerView(KTextEditor::ViewPrivate *view)
register view at the factory this allows us to loop over all views for example on config changes
static KTextEditor::EditorPrivate * self()
Kate Part Internal stuff ;)
QList< KTextEditor::Command * > commands() const override
Get a list of all registered commands.
KateVariableExpansionManager * variableExpansionManager()
Returns the variable expansion manager.
~EditorPrivate() override
Destructor.
This class holds a Message to display in Views.
Definition message.h:94
@ TopInView
show message as view overlay in the top right corner.
Definition message.h:123
@ Error
error message type
Definition message.h:110
@ ViInputMode
Vi mode.
Definition view.h:288
@ NormalInputMode
Normal Mode.
Definition view.h:287
void configEnd()
End a config change transaction, update the concerned KateDocumentConfig/KateDocumentConfig/KateDocum...
void configStart()
Start some config changes.
Highlighting-file based keyword completion for the editor.
Manager class for variable expansion.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
KGUIADDONS_EXPORT QWindow * window(QObject *job)
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
void clicked(bool checked)
void setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy)
QScrollBar * verticalScrollBar() const const
void setVerticalScrollBarPolicy(Qt::ScrollBarPolicy)
void addWidget(QWidget *widget, int stretch, Qt::Alignment alignment)
void setText(const QString &text, Mode mode)
ApplicationPaletteChange
void setFrameShape(Shape)
QClipboard * clipboard()
void setContentsMargins(const QMargins &margins)
iterator begin()
iterator end()
iterator erase(const_iterator begin, const_iterator end)
void push_back(parameter_type value)
qsizetype size() const const
void destroyed(QObject *obj)
T * data() const const
void setWidget(QWidget *widget)
virtual QSize sizeHint() const const override
void setWidgetResizable(bool resizable)
virtual QSize sizeHint() const const override
QSize boundedTo(const QSize &otherSize) const const
QSize expandedTo(const QSize &otherSize) const const
int height() const const
int width() const const
bool isEmpty() const const
QString & prepend(QChar ch)
QString & removeLast()
ScrollBarAsNeeded
void setMinimumWidth(int minw)
void setSizePolicy(QSizePolicy)
A clipboard entry stores the copied text and the filename of the copied text.
Definition kateglobal.h:344
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:56:22 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.