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);
152 , configKey(configId)
153 , commandName(command)
154 , defaultValue(defaultVal)
218 void finalizeConfigEntries();
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();
256 std::map<int, ConfigEntry> m_configEntries;
261 std::unique_ptr<QStringList> m_configKeys;
266 std::unique_ptr<QHash<QString, const ConfigEntry *>> m_configKeyToEntry;
272 int configSessionNumber = 0;
275class KTEXTEDITOR_EXPORT KateGlobalConfig :
public KateConfig
286 static KateGlobalConfig *global()
294 enum ConfigEntryTypes {
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
340 KateDocumentConfig();
348 inline static KateDocumentConfig *global()
356 enum ConfigEntryTypes {
380 ReplaceTabsWithSpaces,
420 StaticWordWrapColumn,
425 PageUpDownMovesCursor,
490 AllowEndOfLineDetection,
510 SwapFileSyncInterval,
543 AutoReloadIfStateIsInVersionControl
558 void updateConfig()
override;
563 return value(TabWidth).toInt();
566 void setTabWidth(
int tabWidth)
568 setValue(TabWidth,
QVariant(tabWidth));
571 int indentationWidth()
const
573 return value(IndentationWidth).toInt();
576 void setIndentationWidth(
int indentationWidth)
578 setValue(IndentationWidth,
QVariant(indentationWidth));
581 bool onTheFlySpellCheck()
const
583 return value(OnTheFlySpellCheck).toBool();
586 void setOnTheFlySpellCheck(
bool on)
588 setValue(OnTheFlySpellCheck,
QVariant(on));
591 bool indentPastedText()
const
593 return value(IndentOnTextPaste).toBool();
596 void setIndentPastedText(
bool on)
598 setValue(IndentOnTextPaste,
QVariant(on));
601 bool replaceTabsDyn()
const
603 return value(ReplaceTabsWithSpaces).toBool();
606 void setReplaceTabsDyn(
bool on)
608 setValue(ReplaceTabsWithSpaces,
QVariant(on));
611 bool backupOnSaveLocal()
const
613 return value(BackupOnSaveLocal).toBool();
616 void setBackupOnSaveLocal(
bool on)
618 setValue(BackupOnSaveLocal,
QVariant(on));
621 bool backupOnSaveRemote()
const
623 return value(BackupOnSaveRemote).toBool();
626 void setBackupOnSaveRemote(
bool on)
628 setValue(BackupOnSaveRemote,
QVariant(on));
633 return value(BackupOnSavePrefix).toString();
636 void setBackupPrefix(
const QString &prefix)
638 setValue(BackupOnSavePrefix,
QVariant(prefix));
643 return value(BackupOnSaveSuffix).toString();
646 void setBackupSuffix(
const QString &suffix)
648 setValue(BackupOnSaveSuffix,
QVariant(suffix));
651 QString indentationMode()
const
653 return value(IndentationMode).toString();
656 void setIndentationMode(
const QString &identationMode)
658 setValue(IndentationMode, identationMode);
667 enum WhitespaceRendering {
None, Trailing, All };
669 int tabHandling()
const
671 return value(TabHandlingMode).toInt();
674 void setTabHandling(
int tabHandling)
676 setValue(TabHandlingMode, tabHandling);
679 bool wordWrap()
const
681 return value(StaticWordWrap).toBool();
684 void setWordWrap(
bool on)
686 setValue(StaticWordWrap, on);
689 int wordWrapAt()
const
691 return value(StaticWordWrapColumn).toInt();
694 void setWordWrapAt(
int col)
696 setValue(StaticWordWrapColumn, col);
699 bool pageUpDownMovesCursor()
const
701 return value(PageUpDownMovesCursor).toBool();
704 void setPageUpDownMovesCursor(
bool on)
706 setValue(PageUpDownMovesCursor, on);
709 void setKeepExtraSpaces(
bool on)
711 setValue(KeepExtraSpaces, on);
714 bool keepExtraSpaces()
const
716 return value(KeepExtraSpaces).toBool();
719 void setBackspaceIndents(
bool on)
721 setValue(BackspaceIndents, on);
724 bool backspaceIndents()
const
726 return value(BackspaceIndents).toBool();
729 void setSmartHome(
bool on)
731 setValue(SmartHome, on);
734 bool smartHome()
const
736 return value(SmartHome).toBool();
739 void setShowTabs(
bool on)
741 setValue(ShowTabs, on);
744 bool showTabs()
const
746 return value(ShowTabs).toBool();
749 void setShowSpaces(WhitespaceRendering mode)
751 setValue(ShowSpacesMode, mode);
754 WhitespaceRendering showSpaces()
const
756 return WhitespaceRendering(value(ShowSpacesMode).toInt());
759 void setMarkerSize(
int markerSize)
761 setValue(TrailingMarkerSize, markerSize);
764 int markerSize()
const
766 return value(TrailingMarkerSize).toInt();
775 void setRemoveSpaces(
int triState)
777 setValue(RemoveSpacesMode, triState);
780 int removeSpaces()
const
782 return value(RemoveSpacesMode).toInt();
785 void setNewLineAtEof(
bool on)
787 setValue(NewlineAtEOF, on);
790 bool newLineAtEof()
const
792 return value(NewlineAtEOF).toBool();
797 setValue(OverwriteMode, on);
802 return value(OverwriteMode).toBool();
805 void setTabIndents(
bool on)
807 setValue(IndentOnTab, on);
810 bool tabIndentsEnabled()
const
812 return value(IndentOnTab).toBool();
817 return value(Encoding).toString();
820 bool setEncoding(
const QString &encoding)
822 return setValue(Encoding, encoding);
825 enum Eol { eolUnix = 0, eolDos = 1, eolMac = 2 };
829 return value(EndOfLine).toInt();
839 void setEol(
int mode)
841 setValue(EndOfLine, mode);
846 return value(ByteOrderMark).toBool();
849 void setBom(
bool bom)
851 setValue(ByteOrderMark, bom);
854 bool allowEolDetection()
const
856 return value(AllowEndOfLineDetection).toBool();
859 void setAllowEolDetection(
bool on)
861 setValue(AllowEndOfLineDetection, on);
866 return value(SwapFileDirectory).toString();
869 void setSwapDirectory(
const QString &directory)
871 setValue(SwapFileDirectory, directory);
874 enum SwapFileMode { DisableSwapFile = 0, EnableSwapFile, SwapFilePresetDirectory };
876 SwapFileMode swapFileMode()
const
878 return SwapFileMode(value(SwapFile).toInt());
881 void setSwapFileMode(
int mode)
883 setValue(SwapFile, mode);
886 int swapSyncInterval()
const
888 return value(SwapFileSyncInterval).toInt();
891 void setSwapSyncInterval(
int interval)
893 setValue(SwapFileSyncInterval, interval);
896 int lineLengthLimit()
const
898 return value(LineLengthLimit).toInt();
901 void setLineLengthLimit(
int limit)
903 setValue(LineLengthLimit, limit);
906 void setCamelCursor(
bool on)
908 setValue(CamelCursor, on);
911 bool camelCursor()
const
913 return value(CamelCursor).toBool();
916 void setAutoDetectIndent(
bool on)
918 setValue(AutoDetectIndent, on);
921 bool autoDetectIndent()
const
923 return value(AutoDetectIndent).toBool();
926 bool autoSave()
const
928 return value(AutoSave).toBool();
931 bool autoSaveOnFocusOut()
const
933 return value(AutoSaveOnFocusOut).toBool();
936 int autoSaveInterval()
const
938 return value(AutoSaveInteral).toInt();
942 static KateDocumentConfig *s_global;
946class KTEXTEDITOR_EXPORT KateViewConfig :
public KateConfig
954 KTEXTEDITOR_NO_EXPORT
961 explicit KateViewConfig(KTextEditor::ViewPrivate *view);
966 ~KateViewConfig()
override;
968 inline static KateViewConfig *global()
979 enum ConfigEntryTypes {
983 AutomaticCompletionInvocation,
984 AutomaticCompletionPreselectFirst,
985 BackspaceRemoveComposedCharacters,
987 CharsToEncloseSelection,
988 ClipboardHistoryEntries,
990 DynWordWrapAlignIndent,
991 DynWordWrapIndicators,
993 DynWrapAtStaticMarker,
995 EnterToInsertCompletion,
1000 MousePasteAtCursorPosition,
1001 PersistentSelection,
1002 ScrollBarMiniMapWidth,
1006 ShowBracketMatchPreview,
1011 ShowLineModification,
1014 ShowScrollBarMiniMap,
1015 ShowScrollBarMiniMapAll,
1016 ShowScrollBarPreview,
1021 UserSetsOfCharsToEncloseSelection,
1022 ViInputModeStealKeys,
1023 ViRelativeLineNumbers,
1025 WordCompletionMinimalWordLength,
1026 WordCompletionRemoveTail,
1027 ShowDocWithCompletion,
1028 MultiCursorModifier,
1029 ShowFoldingOnHoverOnly,
1030 ShowStatusbarLineColumn,
1031 ShowStatusbarDictionary,
1032 ShowStatusbarInputMode,
1033 ShowStatusbarHighlightingMode,
1034 ShowStatusbarTabSettings,
1035 ShowStatusbarFileEncoding,
1036 StatusbarLineColumnCompact,
1038 EnableAccessibility,
1053 void updateConfig()
override;
1056 bool dynWordWrap()
const
1058 return value(DynamicWordWrap).toBool();
1060 void setDynWordWrap(
bool on)
1062 setValue(DynamicWordWrap, on);
1064 bool dynWrapAnywhere()
const
1066 return value(DynWrapAnywhere).toBool();
1069 bool dynWrapAtStaticMarker()
const
1071 return value(DynWrapAtStaticMarker).toBool();
1074 int dynWordWrapIndicators()
const
1076 return value(DynWordWrapIndicators).toInt();
1079 int dynWordWrapAlignIndent()
const
1081 return value(DynWordWrapAlignIndent).toInt();
1084 bool lineNumbers()
const
1086 return value(ShowLineNumbers).toBool();
1089 bool scrollBarMarks()
const
1091 return value(ShowScrollBarMarks).toBool();
1094 bool scrollBarPreview()
const
1096 return value(ShowScrollBarPreview).toBool();
1099 bool scrollBarMiniMap()
const
1101 return value(ShowScrollBarMiniMap).toBool();
1104 bool scrollBarMiniMapAll()
const
1106 return value(ShowScrollBarMiniMapAll).toBool();
1109 int scrollBarMiniMapWidth()
const
1111 return value(ScrollBarMiniMapWidth).toInt();
1115 enum ScrollbarMode { AlwaysOn = 0, ShowWhenNeeded, AlwaysOff };
1117 int showScrollbars()
const
1119 return value(ShowScrollbars).toInt();
1122 bool showDocWithCompletion()
const
1124 return value(ShowDocWithCompletion).toBool();
1134 setValue(MultiCursorModifier, (
int)m);
1137 bool iconBar()
const
1139 return value(ShowIconBar).toBool();
1142 bool foldingBar()
const
1144 return value(ShowFoldingBar).toBool();
1147 bool foldingPreview()
const
1149 return value(ShowFoldingPreview).toBool();
1152 bool lineModification()
const
1154 return value(ShowLineModification).toBool();
1157 int bookmarkSort()
const
1159 return value(BookmarkSorting).toInt();
1162 int autoCenterLines()
const
1164 return value(AutoCenterLines).toInt();
1168 IncMatchCase = 1 << 0,
1169 IncHighlightAll = 1 << 1,
1170 IncFromCursor = 1 << 2,
1171 PowerMatchCase = 1 << 3,
1172 PowerHighlightAll = 1 << 4,
1173 PowerFromCursor = 1 << 5,
1175 PowerModePlainText = 1 << 7,
1176 PowerModeWholeWords = 1 << 8,
1177 PowerModeEscapeSequences = 1 << 9,
1178 PowerModeRegularExpression = 1 << 10,
1179 PowerUsePlaceholders = 1 << 11
1182 uint searchFlags()
const
1184 return value(SearchFlags).toUInt();
1186 void setSearchFlags(uint flags)
1188 setValue(SearchFlags, flags);
1191 int maxHistorySize()
const
1193 return value(MaxHistorySize).toInt();
1196 uint defaultMarkType()
const
1198 return value(DefaultMarkType).toUInt();
1201 bool allowMarkMenu()
const
1203 return value(AllowMarkMenu).toBool();
1206 bool persistentSelection()
const
1208 return value(PersistentSelection).toBool();
1216 bool viInputModeStealKeys()
const
1218 return value(ViInputModeStealKeys).toBool();
1221 bool viRelativeLineNumbers()
const
1223 return value(ViRelativeLineNumbers).toBool();
1227 enum TextToSearch { Nowhere = 0, SelectionOnly = 1, SelectionWord = 2, WordOnly = 3, WordSelection = 4 };
1229 bool automaticCompletionInvocation()
const
1231 return value(AutomaticCompletionInvocation).toBool();
1234 bool automaticCompletionPreselectFirst()
const
1236 return value(AutomaticCompletionPreselectFirst).toBool();
1239 bool tabCompletion()
const
1241 return value(TabCompletion).toBool();
1244 bool wordCompletion()
const
1246 return value(WordCompletion).toBool();
1249 bool keywordCompletion()
const
1251 return value(KeywordCompletion).toBool();
1254 int wordCompletionMinimalWordLength()
const
1256 return value(WordCompletionMinimalWordLength).toInt();
1259 bool wordCompletionRemoveTail()
const
1261 return value(WordCompletionRemoveTail).toBool();
1264 bool textDragAndDrop()
const
1266 return value(TextDragAndDrop).toBool();
1269 bool smartCopyCut()
const
1271 return value(SmartCopyCut).toBool();
1274 bool mousePasteAtCursorPosition()
const
1276 return value(MousePasteAtCursorPosition).toBool();
1279 int clipboardHistoryEntries()
const
1281 return value(ClipboardHistoryEntries).toInt();
1284 bool scrollPastEnd()
const
1286 return value(ScrollPastEnd).toBool();
1289 bool foldFirstLine()
const
1291 return value(FoldFirstLine).toBool();
1294 bool showWordCount()
const
1296 return value(ShowWordCount).toBool();
1298 void setShowWordCount(
bool on)
1300 setValue(ShowWordCount, on);
1303 bool showLineCount()
const
1305 return value(ShowLineCount).toBool();
1308 void setShowLineCount(
bool on)
1310 setValue(ShowLineCount, on);
1313 bool autoBrackets()
const
1315 return value(AutoBrackets).toBool();
1318 bool encloseSelectionInChars()
const
1320 return !value(CharsToEncloseSelection).toString().isEmpty();
1323 QString charsToEncloseSelection()
const
1325 return value(CharsToEncloseSelection).toString();
1328 bool backspaceRemoveComposed()
const
1330 return value(BackspaceRemoveComposedCharacters).toBool();
1333 bool showFoldingOnHoverOnly()
const
1335 return value(ShowFoldingOnHoverOnly).toBool();
1339 static KateViewConfig *s_global;
1340 KTextEditor::ViewPrivate *m_view =
nullptr;
1343class KTEXTEDITOR_EXPORT KateRendererConfig :
public KateConfig
1351 KTEXTEDITOR_NO_EXPORT
1352 KateRendererConfig();
1363 ~KateRendererConfig()
override;
1365 inline static KateRendererConfig *global()
1374 enum ConfigEntryTypes {
1378 AutoColorThemeSelection
1393 void updateConfig()
override;
1396 const QString &schema()
const;
1397 void setSchema(
QString schema);
1404 void reloadSchema();
1411 const QFont &baseFont()
const;
1413 void setFont(
const QFont &font);
1415 bool wordWrapMarker()
const;
1416 void setWordWrapMarker(
bool on);
1418 const QColor &backgroundColor()
const;
1419 void setBackgroundColor(
const QColor &col);
1421 const QColor &selectionColor()
const;
1422 void setSelectionColor(
const QColor &col);
1424 const QColor &highlightedLineColor()
const;
1425 void setHighlightedLineColor(
const QColor &col);
1429 const QColor &highlightedBracketColor()
const;
1430 void setHighlightedBracketColor(
const QColor &col);
1432 const QColor &wordWrapMarkerColor()
const;
1433 void setWordWrapMarkerColor(
const QColor &col);
1435 const QColor &tabMarkerColor()
const;
1436 void setTabMarkerColor(
const QColor &col);
1438 const QColor &indentationLineColor()
const;
1439 void setIndentationLineColor(
const QColor &col);
1441 const QColor &iconBarColor()
const;
1442 void setIconBarColor(
const QColor &col);
1444 const QColor &foldingColor()
const;
1445 void setFoldingColor(
const QColor &col);
1448 const QColor &lineNumberColor()
const;
1449 void setLineNumberColor(
const QColor &col);
1450 const QColor ¤tLineNumberColor()
const;
1451 void setCurrentLineNumberColor(
const QColor &col);
1454 const QColor &separatorColor()
const;
1455 void setSeparatorColor(
const QColor &col);
1457 const QColor &spellingMistakeLineColor()
const;
1458 void setSpellingMistakeLineColor(
const QColor &col);
1460 bool showIndentationLines()
const;
1461 void setShowIndentationLines(
bool on);
1463 bool showWholeBracketExpression()
const;
1464 void setShowWholeBracketExpression(
bool on);
1466 static bool animateBracketMatching();
1467 void setAnimateBracketMatching(
bool on);
1469 const QColor &templateBackgroundColor()
const;
1470 const QColor &templateEditablePlaceholderColor()
const;
1471 const QColor &templateFocusedEditablePlaceholderColor()
const;
1472 const QColor &templateNotEditablePlaceholderColor()
const;
1474 const QColor &modifiedLineColor()
const;
1475 void setModifiedLineColor(
const QColor &col);
1477 const QColor &savedLineColor()
const;
1478 void setSavedLineColor(
const QColor &col);
1480 const QColor &searchHighlightColor()
const;
1481 void setSearchHighlightColor(
const QColor &col);
1483 const QColor &replaceHighlightColor()
const;
1484 void setReplaceHighlightColor(
const QColor &col);
1486 void setLineHeightMultiplier(qreal value);
1488 qreal lineHeightMultiplier()
const
1490 return s_global->m_lineHeightMultiplier;
1497 KTEXTEDITOR_NO_EXPORT
1498 void setSchemaInternal(
const QString &schema);
1503 QColor m_backgroundColor;
1505 QColor m_highlightedLineColor;
1506 QColor m_highlightedBracketColor;
1507 QColor m_wordWrapMarkerColor;
1509 QColor m_indentationLineColor;
1512 QColor m_lineNumberColor;
1513 QColor m_currentLineNumberColor;
1515 QColor m_spellingMistakeLineColor;
1516 std::vector<QColor> m_lineMarkerColor;
1518 QColor m_templateBackgroundColor;
1519 QColor m_templateEditablePlaceholderColor;
1520 QColor m_templateFocusedEditablePlaceholderColor;
1521 QColor m_templateNotEditablePlaceholderColor;
1523 QColor m_modifiedLineColor;
1525 QColor m_searchHighlightColor;
1526 QColor m_replaceHighlightColor;
1528 qreal m_lineHeightMultiplier = 1.0;
1530 bool m_wordWrapMarker =
false;
1531 bool m_showIndentationLines =
false;
1532 bool m_showWholeBracketExpression =
false;
1533 bool m_animateBracketMatching =
false;
1535 bool m_schemaSet : 1;
1537 bool m_wordWrapMarkerSet : 1;
1538 bool m_showIndentationLinesSet : 1;
1539 bool m_showWholeBracketExpressionSet : 1;
1540 bool m_backgroundColorSet : 1;
1541 bool m_selectionColorSet : 1;
1542 bool m_highlightedLineColorSet : 1;
1543 bool m_highlightedBracketColorSet : 1;
1544 bool m_wordWrapMarkerColorSet : 1;
1545 bool m_tabMarkerColorSet : 1;
1546 bool m_indentationLineColorSet : 1;
1547 bool m_iconBarColorSet : 1;
1548 bool m_foldingColorSet : 1;
1549 bool m_lineNumberColorSet : 1;
1550 bool m_currentLineNumberColorSet : 1;
1551 bool m_separatorColorSet : 1;
1552 bool m_spellingMistakeLineColorSet : 1;
1553 bool m_templateColorsSet : 1;
1554 bool m_modifiedLineColorSet : 1;
1555 bool m_savedLineColorSet : 1;
1556 bool m_searchHighlightColorSet : 1;
1557 bool m_replaceHighlightColorSet : 1;
1561 static KateRendererConfig *s_global;
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?
virtual ~KateConfig()
Virtual Destructor.
QStringList configKeys() const
All known config keys.
virtual void updateConfig()=0
do the real update
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)