10#include <ktexteditor_export.h>
12#include <ktexteditor/document.h>
13#include <ktexteditor/view.h>
78 return m_parent ? m_parent->configKeys() : *m_configKeys.get();
88 return m_configEntries.find(key) != m_configEntries.end();
106 bool setValue(
const int key,
const QVariant &value);
230 const std::map<int, ConfigEntry> &fullConfigEntries()
const
232 return m_parent ? m_parent->fullConfigEntries() : m_configEntries;
240 return m_parent ? m_parent->fullConfigKeyToEntry() : *m_configKeyToEntry.get();
247 const KateConfig *
const m_parent =
nullptr;
256 std::map<int, ConfigEntry> m_configEntries;
261 std::unique_ptr<QStringList> m_configKeys;
266 std::unique_ptr<QHash<QString, const ConfigEntry *>> m_configKeyToEntry;
275class KTEXTEDITOR_EXPORT KateGlobalConfig :
public KateConfig
286 static KateGlobalConfig *global()
294 enum ConfigEntryTypes {
310 void readConfig(
const KConfigGroup &config);
315 void writeConfig(KConfigGroup &config);
318 void updateConfig()
override;
321 QString fallbackEncoding()
const
323 return value(FallbackEncoding).toString();
326 bool setFallbackEncoding(
const QString &encoding)
328 return setValue(FallbackEncoding, encoding);
332 static KateGlobalConfig *s_global;
335class KTEXTEDITOR_EXPORT KateDocumentConfig :
public KateConfig
338 friend class KTextEditor::EditorPrivate;
340 KateDocumentConfig();
346 explicit KateDocumentConfig(KTextEditor::DocumentPrivate *doc);
348 inline static KateDocumentConfig *global()
356 enum ConfigEntryTypes {
380 ReplaceTabsWithSpaces,
420 StaticWordWrapColumn,
425 PageUpDownMovesCursor,
490 AllowEndOfLineDetection,
510 SwapFileSyncInterval,
543 AutoReloadIfStateIsInVersionControl,
555 void readConfig(
const KConfigGroup &config);
560 void writeConfig(KConfigGroup &config);
563 void updateConfig()
override;
568 return value(TabWidth).toInt();
571 void setTabWidth(
int tabWidth)
573 setValue(TabWidth, QVariant(tabWidth));
576 int indentationWidth()
const
578 return value(IndentationWidth).toInt();
581 void setIndentationWidth(
int indentationWidth)
583 setValue(IndentationWidth, QVariant(indentationWidth));
586 bool onTheFlySpellCheck()
const
588 return value(OnTheFlySpellCheck).toBool();
591 void setOnTheFlySpellCheck(
bool on)
593 setValue(OnTheFlySpellCheck, QVariant(on));
596 bool indentPastedText()
const
598 return value(IndentOnTextPaste).toBool();
601 void setIndentPastedText(
bool on)
603 setValue(IndentOnTextPaste, QVariant(on));
606 bool replaceTabsDyn()
const
608 return value(ReplaceTabsWithSpaces).toBool();
611 void setReplaceTabsDyn(
bool on)
613 setValue(ReplaceTabsWithSpaces, QVariant(on));
616 bool backupOnSaveLocal()
const
618 return value(BackupOnSaveLocal).toBool();
621 void setBackupOnSaveLocal(
bool on)
623 setValue(BackupOnSaveLocal, QVariant(on));
626 bool backupOnSaveRemote()
const
628 return value(BackupOnSaveRemote).toBool();
631 void setBackupOnSaveRemote(
bool on)
633 setValue(BackupOnSaveRemote, QVariant(on));
636 QString backupPrefix()
const
638 return value(BackupOnSavePrefix).toString();
641 void setBackupPrefix(
const QString &prefix)
643 setValue(BackupOnSavePrefix, QVariant(prefix));
646 QString backupSuffix()
const
648 return value(BackupOnSaveSuffix).toString();
651 void setBackupSuffix(
const QString &suffix)
653 setValue(BackupOnSaveSuffix, QVariant(suffix));
656 QString indentationMode()
const
658 return value(IndentationMode).toString();
661 void setIndentationMode(
const QString &identationMode)
663 setValue(IndentationMode, identationMode);
672 enum WhitespaceRendering {
678 int tabHandling()
const
680 return value(TabHandlingMode).toInt();
683 void setTabHandling(
int tabHandling)
685 setValue(TabHandlingMode, tabHandling);
688 bool wordWrap()
const
690 return value(StaticWordWrap).toBool();
693 void setWordWrap(
bool on)
695 setValue(StaticWordWrap, on);
698 int wordWrapAt()
const
700 return value(StaticWordWrapColumn).toInt();
703 void setWordWrapAt(
int col)
705 setValue(StaticWordWrapColumn, col);
708 bool pageUpDownMovesCursor()
const
710 return value(PageUpDownMovesCursor).toBool();
713 void setPageUpDownMovesCursor(
bool on)
715 setValue(PageUpDownMovesCursor, on);
718 void setKeepExtraSpaces(
bool on)
720 setValue(KeepExtraSpaces, on);
723 bool keepExtraSpaces()
const
725 return value(KeepExtraSpaces).toBool();
728 void setBackspaceIndents(
bool on)
730 setValue(BackspaceIndents, on);
733 bool backspaceIndents()
const
735 return value(BackspaceIndents).toBool();
738 void setSmartHome(
bool on)
740 setValue(SmartHome, on);
743 bool smartHome()
const
745 return value(SmartHome).toBool();
748 void setShowTabs(
bool on)
750 setValue(ShowTabs, on);
753 bool showTabs()
const
755 return value(ShowTabs).toBool();
758 void setShowSpaces(WhitespaceRendering mode)
760 setValue(ShowSpacesMode, mode);
763 WhitespaceRendering showSpaces()
const
765 return WhitespaceRendering(value(ShowSpacesMode).toInt());
768 void setMarkerSize(
int markerSize)
770 setValue(TrailingMarkerSize, markerSize);
773 int markerSize()
const
775 return value(TrailingMarkerSize).toInt();
784 void setRemoveSpaces(
int triState)
786 setValue(RemoveSpacesMode, triState);
789 int removeSpaces()
const
791 return value(RemoveSpacesMode).toInt();
794 void setNewLineAtEof(
bool on)
796 setValue(NewlineAtEOF, on);
799 bool newLineAtEof()
const
801 return value(NewlineAtEOF).toBool();
806 setValue(OverwriteMode, on);
811 return value(OverwriteMode).toBool();
814 void setTabIndents(
bool on)
816 setValue(IndentOnTab, on);
819 bool tabIndentsEnabled()
const
821 return value(IndentOnTab).toBool();
824 QString encoding()
const
826 return value(Encoding).toString();
829 bool setEncoding(
const QString &encoding)
831 return setValue(Encoding, encoding);
842 return value(EndOfLine).toInt();
850 QString eolString()
const;
852 void setEol(
int mode)
854 setValue(EndOfLine, mode);
859 return value(ByteOrderMark).toBool();
862 void setBom(
bool bom)
864 setValue(ByteOrderMark, bom);
867 bool allowEolDetection()
const
869 return value(AllowEndOfLineDetection).toBool();
872 void setAllowEolDetection(
bool on)
874 setValue(AllowEndOfLineDetection, on);
877 QString swapDirectory()
const
879 return value(SwapFileDirectory).toString();
882 void setSwapDirectory(
const QString &directory)
884 setValue(SwapFileDirectory, directory);
890 SwapFilePresetDirectory
893 SwapFileMode swapFileMode()
const
895 return SwapFileMode(value(SwapFile).toInt());
898 void setSwapFileMode(
int mode)
900 setValue(SwapFile, mode);
903 int swapSyncInterval()
const
905 return value(SwapFileSyncInterval).toInt();
908 void setSwapSyncInterval(
int interval)
910 setValue(SwapFileSyncInterval, interval);
913 int lineLengthLimit()
const
915 return value(LineLengthLimit).toInt();
918 void setLineLengthLimit(
int limit)
920 setValue(LineLengthLimit, limit);
923 void setCamelCursor(
bool on)
925 setValue(CamelCursor, on);
928 bool camelCursor()
const
930 return value(CamelCursor).toBool();
933 void setAutoDetectIndent(
bool on)
935 setValue(AutoDetectIndent, on);
938 bool autoDetectIndent()
const
940 return value(AutoDetectIndent).toBool();
943 bool autoSave()
const
945 return value(AutoSave).toBool();
948 bool autoSaveOnFocusOut()
const
950 return value(AutoSaveOnFocusOut).toBool();
953 int autoSaveInterval()
const
955 return value(AutoSaveInteral).toInt();
959 static KateDocumentConfig *s_global;
960 KTextEditor::DocumentPrivate *m_doc =
nullptr;
963class KTEXTEDITOR_EXPORT KateViewConfig :
public KateConfig
966 friend class KTextEditor::EditorPrivate;
971 KTEXTEDITOR_NO_EXPORT
978 explicit KateViewConfig(KTextEditor::ViewPrivate *view);
983 ~KateViewConfig()
override;
985 inline static KateViewConfig *global()
996 enum ConfigEntryTypes {
1000 AutomaticCompletionInvocation,
1001 AutomaticCompletionPreselectFirst,
1002 BackspaceRemoveComposedCharacters,
1004 CharsToEncloseSelection,
1005 ClipboardHistoryEntries,
1007 DynWordWrapAlignIndent,
1008 DynWordWrapIndicators,
1010 DynWrapAtStaticMarker,
1012 EnterToInsertCompletion,
1017 MousePasteAtCursorPosition,
1018 PersistentSelection,
1019 ScrollBarMiniMapWidth,
1023 ShowBracketMatchPreview,
1028 ShowLineModification,
1031 ShowScrollBarMiniMap,
1032 ShowScrollBarMiniMapAll,
1033 ShowScrollBarPreview,
1038 UserSetsOfCharsToEncloseSelection,
1039 ViInputModeStealKeys,
1040 ViRelativeLineNumbers,
1042 WordCompletionMinimalWordLength,
1043 WordCompletionRemoveTail,
1044 ShowDocWithCompletion,
1045 MultiCursorModifier,
1046 ShowFoldingOnHoverOnly,
1047 ShowStatusbarLineColumn,
1048 ShowStatusbarDictionary,
1049 ShowStatusbarInputMode,
1050 ShowStatusbarHighlightingMode,
1051 ShowStatusbarTabSettings,
1052 ShowStatusbarFileEncoding,
1053 StatusbarLineColumnCompact,
1055 EnableAccessibility,
1056 CycleThroughBookmarks,
1063 void readConfig(
const KConfigGroup &config);
1068 void writeConfig(KConfigGroup &config);
1071 void updateConfig()
override;
1074 bool dynWordWrap()
const
1076 return value(DynamicWordWrap).toBool();
1078 void setDynWordWrap(
bool on)
1080 setValue(DynamicWordWrap, on);
1082 bool dynWrapAnywhere()
const
1084 return value(DynWrapAnywhere).toBool();
1087 bool dynWrapAtStaticMarker()
const
1089 return value(DynWrapAtStaticMarker).toBool();
1092 int dynWordWrapIndicators()
const
1094 return value(DynWordWrapIndicators).toInt();
1097 int dynWordWrapAlignIndent()
const
1099 return value(DynWordWrapAlignIndent).toInt();
1102 bool lineNumbers()
const
1104 return value(ShowLineNumbers).toBool();
1107 bool scrollBarMarks()
const
1109 return value(ShowScrollBarMarks).toBool();
1112 bool scrollBarPreview()
const
1114 return value(ShowScrollBarPreview).toBool();
1117 bool scrollBarMiniMap()
const
1119 return value(ShowScrollBarMiniMap).toBool();
1122 bool scrollBarMiniMapAll()
const
1124 return value(ShowScrollBarMiniMapAll).toBool();
1127 int scrollBarMiniMapWidth()
const
1129 return value(ScrollBarMiniMapWidth).toInt();
1133 enum ScrollbarMode {
1139 int showScrollbars()
const
1141 return value(ShowScrollbars).toInt();
1144 bool showDocWithCompletion()
const
1146 return value(ShowDocWithCompletion).toBool();
1156 setValue(MultiCursorModifier, (
int)m);
1159 bool iconBar()
const
1161 return value(ShowIconBar).toBool();
1164 bool foldingBar()
const
1166 return value(ShowFoldingBar).toBool();
1169 bool foldingPreview()
const
1171 return value(ShowFoldingPreview).toBool();
1174 bool lineModification()
const
1176 return value(ShowLineModification).toBool();
1179 int bookmarkSort()
const
1181 return value(BookmarkSorting).toInt();
1184 int autoCenterLines()
const
1186 return value(AutoCenterLines).toInt();
1190 IncMatchCase = 1 << 0,
1191 IncHighlightAll = 1 << 1,
1192 IncFromCursor = 1 << 2,
1193 PowerMatchCase = 1 << 3,
1194 PowerHighlightAll = 1 << 4,
1195 PowerFromCursor = 1 << 5,
1197 PowerModePlainText = 1 << 7,
1198 PowerModeWholeWords = 1 << 8,
1199 PowerModeEscapeSequences = 1 << 9,
1200 PowerModeRegularExpression = 1 << 10,
1201 PowerUsePlaceholders = 1 << 11
1204 uint searchFlags()
const
1206 return value(SearchFlags).toUInt();
1208 void setSearchFlags(uint flags)
1210 setValue(SearchFlags, flags);
1213 int maxHistorySize()
const
1215 return value(MaxHistorySize).toInt();
1218 uint defaultMarkType()
const
1220 return value(DefaultMarkType).toUInt();
1223 bool allowMarkMenu()
const
1225 return value(AllowMarkMenu).toBool();
1228 bool persistentSelection()
const
1230 return value(PersistentSelection).toBool();
1238 bool viInputModeStealKeys()
const
1240 return value(ViInputModeStealKeys).toBool();
1243 bool viRelativeLineNumbers()
const
1245 return value(ViRelativeLineNumbers).toBool();
1257 bool automaticCompletionInvocation()
const
1259 return value(AutomaticCompletionInvocation).toBool();
1262 bool automaticCompletionPreselectFirst()
const
1264 return value(AutomaticCompletionPreselectFirst).toBool();
1267 bool tabCompletion()
const
1269 return value(TabCompletion).toBool();
1272 bool wordCompletion()
const
1274 return value(WordCompletion).toBool();
1277 bool keywordCompletion()
const
1279 return value(KeywordCompletion).toBool();
1282 int wordCompletionMinimalWordLength()
const
1284 return value(WordCompletionMinimalWordLength).toInt();
1287 bool wordCompletionRemoveTail()
const
1289 return value(WordCompletionRemoveTail).toBool();
1292 bool textDragAndDrop()
const
1294 return value(TextDragAndDrop).toBool();
1297 bool smartCopyCut()
const
1299 return value(SmartCopyCut).toBool();
1302 bool mousePasteAtCursorPosition()
const
1304 return value(MousePasteAtCursorPosition).toBool();
1307 int clipboardHistoryEntries()
const
1309 return value(ClipboardHistoryEntries).toInt();
1312 bool scrollPastEnd()
const
1314 return value(ScrollPastEnd).toBool();
1317 bool foldFirstLine()
const
1319 return value(FoldFirstLine).toBool();
1322 bool showWordCount()
const
1324 return value(ShowWordCount).toBool();
1326 void setShowWordCount(
bool on)
1328 setValue(ShowWordCount, on);
1331 bool showLineCount()
const
1333 return value(ShowLineCount).toBool();
1336 void setShowLineCount(
bool on)
1338 setValue(ShowLineCount, on);
1341 bool autoBrackets()
const
1343 return value(AutoBrackets).toBool();
1346 bool encloseSelectionInChars()
const
1348 return !value(CharsToEncloseSelection).toString().isEmpty();
1351 QString charsToEncloseSelection()
const
1353 return value(CharsToEncloseSelection).toString();
1356 bool backspaceRemoveComposed()
const
1358 return value(BackspaceRemoveComposedCharacters).toBool();
1361 bool showFoldingOnHoverOnly()
const
1363 return value(ShowFoldingOnHoverOnly).toBool();
1367 static KateViewConfig *s_global;
1368 KTextEditor::ViewPrivate *m_view =
nullptr;
1371class KTEXTEDITOR_EXPORT KateRendererConfig :
public KateConfig
1374 friend class KTextEditor::EditorPrivate;
1379 KTEXTEDITOR_NO_EXPORT
1380 KateRendererConfig();
1386 explicit KateRendererConfig(KateRenderer *renderer);
1391 ~KateRendererConfig()
override;
1393 inline static KateRendererConfig *global()
1402 enum ConfigEntryTypes {
1406 AutoColorThemeSelection
1413 void readConfig(
const KConfigGroup &config);
1418 void writeConfig(KConfigGroup &config);
1421 void updateConfig()
override;
1424 const QString &schema()
const;
1425 void setSchema(QString schema);
1432 void reloadSchema();
1439 const QFont &baseFont()
const;
1441 void setFont(
const QFont &font);
1443 bool wordWrapMarker()
const;
1444 void setWordWrapMarker(
bool on);
1446 const QColor &backgroundColor()
const;
1447 void setBackgroundColor(
const QColor &col);
1449 const QColor &selectionColor()
const;
1450 void setSelectionColor(
const QColor &col);
1452 const QColor &highlightedLineColor()
const;
1453 void setHighlightedLineColor(
const QColor &col);
1457 const QColor &highlightedBracketColor()
const;
1458 void setHighlightedBracketColor(
const QColor &col);
1460 const QColor &wordWrapMarkerColor()
const;
1461 void setWordWrapMarkerColor(
const QColor &col);
1463 const QColor &tabMarkerColor()
const;
1464 void setTabMarkerColor(
const QColor &col);
1466 const QColor &indentationLineColor()
const;
1467 void setIndentationLineColor(
const QColor &col);
1469 const QColor &iconBarColor()
const;
1470 void setIconBarColor(
const QColor &col);
1472 const QColor &foldingColor()
const;
1473 void setFoldingColor(
const QColor &col);
1476 const QColor &lineNumberColor()
const;
1477 void setLineNumberColor(
const QColor &col);
1478 const QColor ¤tLineNumberColor()
const;
1479 void setCurrentLineNumberColor(
const QColor &col);
1482 const QColor &separatorColor()
const;
1483 void setSeparatorColor(
const QColor &col);
1485 const QColor &spellingMistakeLineColor()
const;
1486 void setSpellingMistakeLineColor(
const QColor &col);
1488 bool showIndentationLines()
const;
1489 void setShowIndentationLines(
bool on);
1491 bool showWholeBracketExpression()
const;
1492 void setShowWholeBracketExpression(
bool on);
1494 static bool animateBracketMatching();
1495 void setAnimateBracketMatching(
bool on);
1497 const QColor &templateBackgroundColor()
const;
1498 const QColor &templateEditablePlaceholderColor()
const;
1499 const QColor &templateFocusedEditablePlaceholderColor()
const;
1500 const QColor &templateNotEditablePlaceholderColor()
const;
1502 const QColor &modifiedLineColor()
const;
1503 void setModifiedLineColor(
const QColor &col);
1505 const QColor &savedLineColor()
const;
1506 void setSavedLineColor(
const QColor &col);
1508 const QColor &searchHighlightColor()
const;
1509 void setSearchHighlightColor(
const QColor &col);
1511 const QColor &replaceHighlightColor()
const;
1512 void setReplaceHighlightColor(
const QColor &col);
1514 void setLineHeightMultiplier(qreal value);
1516 qreal lineHeightMultiplier()
const
1518 return s_global->m_lineHeightMultiplier;
1525 KTEXTEDITOR_NO_EXPORT
1526 void setSchemaInternal(
const QString &schema);
1531 QColor m_backgroundColor;
1532 QColor m_selectionColor;
1533 QColor m_highlightedLineColor;
1534 QColor m_highlightedBracketColor;
1535 QColor m_wordWrapMarkerColor;
1536 QColor m_tabMarkerColor;
1537 QColor m_indentationLineColor;
1538 QColor m_iconBarColor;
1539 QColor m_foldingColor;
1540 QColor m_lineNumberColor;
1541 QColor m_currentLineNumberColor;
1542 QColor m_separatorColor;
1543 QColor m_spellingMistakeLineColor;
1544 std::vector<QColor> m_lineMarkerColor;
1546 QColor m_templateBackgroundColor;
1547 QColor m_templateEditablePlaceholderColor;
1548 QColor m_templateFocusedEditablePlaceholderColor;
1549 QColor m_templateNotEditablePlaceholderColor;
1551 QColor m_modifiedLineColor;
1552 QColor m_savedLineColor;
1553 QColor m_searchHighlightColor;
1554 QColor m_replaceHighlightColor;
1556 qreal m_lineHeightMultiplier = 1.0;
1558 bool m_wordWrapMarker =
false;
1559 bool m_showIndentationLines =
false;
1560 bool m_showWholeBracketExpression =
false;
1561 bool m_animateBracketMatching =
false;
1563 bool m_schemaSet : 1;
1565 bool m_wordWrapMarkerSet : 1;
1566 bool m_showIndentationLinesSet : 1;
1567 bool m_showWholeBracketExpressionSet : 1;
1568 bool m_backgroundColorSet : 1;
1569 bool m_selectionColorSet : 1;
1570 bool m_highlightedLineColorSet : 1;
1571 bool m_highlightedBracketColorSet : 1;
1572 bool m_wordWrapMarkerColorSet : 1;
1573 bool m_tabMarkerColorSet : 1;
1574 bool m_indentationLineColorSet : 1;
1575 bool m_iconBarColorSet : 1;
1576 bool m_foldingColorSet : 1;
1577 bool m_lineNumberColorSet : 1;
1578 bool m_currentLineNumberColorSet : 1;
1579 bool m_separatorColorSet : 1;
1580 bool m_spellingMistakeLineColorSet : 1;
1581 bool m_templateColorsSet : 1;
1582 bool m_modifiedLineColorSet : 1;
1583 bool m_savedLineColorSet : 1;
1584 bool m_searchHighlightColorSet : 1;
1585 bool m_replaceHighlightColorSet : 1;
1586 QBitArray m_lineMarkerColorSet;
1589 static KateRendererConfig *s_global;
1590 KateRenderer *m_renderer =
nullptr;
Backend of KTextEditor::Document related public KTextEditor interfaces.
MarkTypes
Predefined mark types.
KTextEditor::EditorPrivate One instance of this class is hold alive during a kate part session,...
InputMode
Possible input modes.
const QString commandName
Command name as used in e.g.
const char *const configKey
KConfig entry key for this config entry, shall be unique in its group e.g.
const int enumKey
Enum key for this config entry, shall be unique.
std::function< bool(const QVariant &)> validator
An optional validator function, only when these returns true we accept a given new value.
QVariant value
The concrete value, per default == defaultValue.
const QVariant defaultValue
Default value if nothing special was configured.
ConfigEntry(int enumId, const char *configId, QString command, QVariant defaultVal, std::function< bool(const QVariant &)> valid=nullptr)
Construct one config entry.
Base Class for the Kate Config Classes Current childs are KateDocumentConfig/KateDocumentConfig/KateD...
bool isGlobal() const
Is this a global config object?
bool isSet(const int key) const
Is given key set in this config object?
KateConfig(const KateConfig *parent=nullptr)
Construct a KateConfig.
virtual ~KateConfig()
Virtual Destructor.
int configSessionNumber
recursion depth
QStringList configKeys() const
All known config keys.
void writeConfigEntries(KConfigGroup &config) const
Write all config entries to given config group.
void configEnd()
End a config change transaction, update the concerned KateDocumentConfig/KateDocumentConfig/KateDocum...
void readConfigEntries(const KConfigGroup &config)
Read all config entries from given config group.
void finalizeConfigEntries()
Finalize the config entries.
void configStart()
Start some config changes.
virtual void updateConfig()=0
do the real update
void addConfigEntry(ConfigEntry &&entry)
Register a new config entry.
Handles all of the work of rendering the text (used for the views and printing)
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
typedef KeyboardModifiers
QTextStream & bom(QTextStream &stream)