Changeset View
Changeset View
Standalone View
Standalone View
src/utils/kateconfig.cpp
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Line(s) | 71 | { | |||
---|---|---|---|---|---|
77 | /** | 77 | /** | ||
78 | * compute list of all config keys + register map from key => config entry | 78 | * compute list of all config keys + register map from key => config entry | ||
79 | * | 79 | * | ||
80 | * we skip entries without a command name, these config entries are not exposed ATM | 80 | * we skip entries without a command name, these config entries are not exposed ATM | ||
81 | * | 81 | * | ||
82 | */ | 82 | */ | ||
83 | for (const auto &entry : m_configEntries) { | 83 | for (const auto &entry : m_configEntries) { | ||
84 | if (!entry.second.commandName.isEmpty()) { | 84 | if (!entry.second.commandName.isEmpty()) { | ||
85 | Q_ASSERT_X(!m_configKeys->contains(entry.second.commandName), "finalizeConfigEntries", (QLatin1String("KEY NOT UNIQUE: ") + entry.second.commandName).toLocal8Bit().constData()); | ||||
85 | m_configKeys->append(entry.second.commandName); | 86 | m_configKeys->append(entry.second.commandName); | ||
86 | m_configKeyToEntry->insert(entry.second.commandName, &entry.second); | 87 | m_configKeyToEntry->insert(entry.second.commandName, &entry.second); | ||
87 | } | 88 | } | ||
88 | } | 89 | } | ||
89 | } | 90 | } | ||
90 | 91 | | |||
91 | void KateConfig::readConfigEntries(const KConfigGroup &config) | 92 | void KateConfig::readConfigEntries(const KConfigGroup &config) | ||
92 | { | 93 | { | ||
▲ Show 20 Lines • Show All 133 Lines • ▼ Show 20 Line(s) | 217 | { | |||
226 | /** | 227 | /** | ||
227 | * key known, dispatch to normal setValue() function with enum | 228 | * key known, dispatch to normal setValue() function with enum | ||
228 | */ | 229 | */ | ||
229 | return setValue(it.value()->enumKey, value); | 230 | return setValue(it.value()->enumKey, value); | ||
230 | } | 231 | } | ||
231 | 232 | | |||
232 | //END | 233 | //END | ||
233 | 234 | | |||
234 | //BEGIN KateDocumentConfig | 235 | //BEGIN HelperFunctions | ||
235 | KateGlobalConfig *KateGlobalConfig::s_global = nullptr; | 236 | KateGlobalConfig *KateGlobalConfig::s_global = nullptr; | ||
236 | KateDocumentConfig *KateDocumentConfig::s_global = nullptr; | 237 | KateDocumentConfig *KateDocumentConfig::s_global = nullptr; | ||
237 | KateViewConfig *KateViewConfig::s_global = nullptr; | 238 | KateViewConfig *KateViewConfig::s_global = nullptr; | ||
238 | KateRendererConfig *KateRendererConfig::s_global = nullptr; | 239 | KateRendererConfig *KateRendererConfig::s_global = nullptr; | ||
239 | 240 | | |||
240 | /** | 241 | /** | ||
241 | * validate if an encoding is ok | 242 | * validate if an encoding is ok | ||
242 | * @param name encoding name | 243 | * @param name encoding name | ||
243 | * @return encoding ok? | 244 | * @return encoding ok? | ||
244 | */ | 245 | */ | ||
245 | static bool isEncodingOk(const QString &name) | 246 | static bool isEncodingOk(const QString &name) | ||
246 | { | 247 | { | ||
247 | bool found = false; | 248 | bool found = false; | ||
248 | auto codec = KCharsets::charsets()->codecForName(name, found); | 249 | auto codec = KCharsets::charsets()->codecForName(name, found); | ||
249 | return found && codec; | 250 | return found && codec; | ||
250 | } | 251 | } | ||
251 | 252 | | |||
253 | static bool inBounds(const int min, const QVariant &value, const int max) | ||||
254 | { | ||||
255 | const int val = value.toInt(); | ||||
256 | return (val >= min) && (val <= max); | ||||
257 | } | ||||
258 | | ||||
259 | static bool isPositive(const QVariant &value) | ||||
260 | { | ||||
261 | bool ok; | ||||
262 | value.toUInt(&ok); | ||||
263 | return ok; | ||||
264 | } | ||||
265 | //END | ||||
266 | | ||||
267 | //BEGIN KateGlobalConfig | ||||
252 | KateGlobalConfig::KateGlobalConfig() | 268 | KateGlobalConfig::KateGlobalConfig() | ||
253 | { | 269 | { | ||
254 | /** | 270 | /** | ||
255 | * register this as our global instance | 271 | * register this as our global instance | ||
256 | */ | 272 | */ | ||
257 | Q_ASSERT(isGlobal()); | 273 | Q_ASSERT(isGlobal()); | ||
258 | s_global = this; | 274 | s_global = this; | ||
259 | 275 | | |||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 334 | if (encoding.isEmpty()) { | |||
319 | return QTextCodec::codecForName("ISO 8859-15"); | 335 | return QTextCodec::codecForName("ISO 8859-15"); | ||
320 | } | 336 | } | ||
321 | 337 | | |||
322 | /** | 338 | /** | ||
323 | * use configured encoding | 339 | * use configured encoding | ||
324 | */ | 340 | */ | ||
325 | return KCharsets::charsets()->codecForName(encoding); | 341 | return KCharsets::charsets()->codecForName(encoding); | ||
326 | } | 342 | } | ||
343 | //END | ||||
327 | 344 | | |||
345 | //BEGIN KateDocumentConfig | ||||
328 | KateDocumentConfig::KateDocumentConfig() | 346 | KateDocumentConfig::KateDocumentConfig() | ||
329 | { | 347 | { | ||
330 | /** | 348 | /** | ||
331 | * register this as our global instance | 349 | * register this as our global instance | ||
332 | */ | 350 | */ | ||
333 | Q_ASSERT(isGlobal()); | 351 | Q_ASSERT(isGlobal()); | ||
334 | s_global = this; | 352 | s_global = this; | ||
335 | 353 | | |||
▲ Show 20 Lines • Show All 152 Lines • ▼ Show 20 Line(s) | 499 | switch(eol()) { | |||
488 | default: | 506 | default: | ||
489 | return QStringLiteral("\n"); | 507 | return QStringLiteral("\n"); | ||
490 | } | 508 | } | ||
491 | } | 509 | } | ||
492 | //END | 510 | //END | ||
493 | 511 | | |||
494 | //BEGIN KateViewConfig | 512 | //BEGIN KateViewConfig | ||
495 | KateViewConfig::KateViewConfig() | 513 | KateViewConfig::KateViewConfig() | ||
496 | : m_dynWordWrapSet(false), | | |||
497 | m_dynWrapAtStaticMarkerSet(false), | | |||
498 | m_dynWordWrapIndicatorsSet(false), | | |||
499 | m_dynWordWrapAlignIndentSet(false), | | |||
500 | m_lineNumbersSet(false), | | |||
501 | m_scrollBarMarksSet(false), | | |||
502 | m_scrollBarPreviewSet(false), | | |||
503 | m_scrollBarMiniMapSet(false), | | |||
504 | m_scrollBarMiniMapAllSet(false), | | |||
505 | m_scrollBarMiniMapWidthSet(false), | | |||
506 | m_showScrollbarsSet(false), | | |||
507 | m_iconBarSet(false), | | |||
508 | m_foldingBarSet(false), | | |||
509 | m_foldingPreviewSet(false), | | |||
510 | m_lineModificationSet(false), | | |||
511 | m_bookmarkSortSet(false), | | |||
512 | m_autoCenterLinesSet(false), | | |||
513 | m_searchFlagsSet(false), | | |||
514 | m_defaultMarkTypeSet(false), | | |||
515 | m_persistentSelectionSet(false), | | |||
516 | m_inputModeSet(false), | | |||
517 | m_viInputModeStealKeysSet(false), | | |||
518 | m_viRelativeLineNumbersSet(false), | | |||
519 | m_automaticCompletionInvocationSet(false), | | |||
520 | m_wordCompletionSet(false), | | |||
521 | m_keywordCompletionSet(false), | | |||
522 | m_wordCompletionMinimalWordLengthSet(false), | | |||
523 | m_smartCopyCutSet(false), | | |||
524 | m_mousePasteAtCursorPositionSet(false), | | |||
525 | m_scrollPastEndSet(false), | | |||
526 | m_allowMarkMenu(true), | | |||
527 | m_wordCompletionRemoveTailSet(false), | | |||
528 | m_foldFirstLineSet(false), | | |||
529 | m_showWordCountSet(false), | | |||
530 | m_showLineCountSet(false), | | |||
531 | m_autoBracketsSet(false), | | |||
532 | m_backspaceRemoveComposedSet(false) | | |||
533 | | ||||
534 | { | 514 | { | ||
535 | s_global = this; | 515 | s_global = this; | ||
536 | 516 | | |||
517 | // Init all known config entries | ||||
518 | // NOTE: Ensure to keep the same order as listed in enum ConfigEntryTypes or it will later assert! | ||||
519 | // addConfigEntry(ConfigEntry(<EnumKey>, <ConfigKey>, <CommandName>, <DefaultValue>, [<ValidatorFunction>])) | ||||
520 | addConfigEntry(ConfigEntry(AllowMarkMenu, "Allow Mark Menu", QStringLiteral("allow-mark-menu"), true)); | ||||
521 | addConfigEntry(ConfigEntry(AutoBrackets, "Auto Brackets", QStringLiteral("auto-brackets"), false)); | ||||
522 | addConfigEntry(ConfigEntry(AutoCenterLines, "Auto Center Lines", QStringLiteral("auto-center-lines"), 0)); | ||||
523 | addConfigEntry(ConfigEntry(AutomaticCompletionInvocation, "Auto Completion", QString(), true)); | ||||
524 | addConfigEntry(ConfigEntry(BackspaceRemoveComposedCharacters, "Backspace Remove Composed Characters", QString(), false)); | ||||
525 | addConfigEntry(ConfigEntry(BookmarkSorting, "Bookmark Menu Sorting", QString(), 0)); | ||||
526 | addConfigEntry(ConfigEntry(CharsToEncloseSelection, "Chars To Enclose Selection", QString(), QString())); | ||||
527 | addConfigEntry(ConfigEntry(DefaultMarkType, "Default Mark Type", QStringLiteral("default-mark-type"), KTextEditor::MarkInterface::markType01, [](const QVariant &value) { return isPositive(value); })); | ||||
528 | addConfigEntry(ConfigEntry(DynWordWrapAlignIndent, "Dynamic Word Wrap Align Indent", QString(), 80, [](const QVariant &value) { return inBounds(1, value, 100); })); | ||||
529 | addConfigEntry(ConfigEntry(DynWordWrapIndicators, "Dynamic Word Wrap Indicators", QString(), 1, [](const QVariant &value) { return inBounds(1, value, 3); })); | ||||
530 | addConfigEntry(ConfigEntry(DynWrapAtStaticMarker, "Dynamic Word Wrap At Static Marker", QString(), false)); | ||||
531 | addConfigEntry(ConfigEntry(DynamicWordWrap, "Dynamic Word Wrap", QStringLiteral("dynamic-word-wrap"), true)); | ||||
532 | addConfigEntry(ConfigEntry(FoldFirstLine, "Fold First Line", QString(), false)); | ||||
533 | addConfigEntry(ConfigEntry(InputMode, "Input Mode", QString(), 0, [](const QVariant &value) { return isPositive(value); })); | ||||
534 | addConfigEntry(ConfigEntry(KeywordCompletion, "Keyword Completion", QStringLiteral("keyword-completion"), true)); | ||||
535 | addConfigEntry(ConfigEntry(MaxHistorySize, "Maximum Search History Size", QString(), 100, [](const QVariant &value) { return inBounds(0, value, 999); })); | ||||
536 | addConfigEntry(ConfigEntry(MousePasteAtCursorPosition, "Mouse Paste At Cursor Position", QString(), false)); | ||||
537 | addConfigEntry(ConfigEntry(PersistentSelection, "Persistent Selection", QStringLiteral("persistent-selectionq"), false)); | ||||
538 | addConfigEntry(ConfigEntry(ScrollBarMiniMapWidth, "Scroll Bar Mini Map Width", QString(), 60, [](const QVariant &value) { return inBounds(0, value, 999); })); | ||||
539 | addConfigEntry(ConfigEntry(ScrollPastEnd, "Scroll Past End", QString(), false)); | ||||
540 | addConfigEntry(ConfigEntry(SearchFlags, "Search/Replace Flags", QString(), IncFromCursor | PowerMatchCase | PowerModePlainText)); | ||||
541 | addConfigEntry(ConfigEntry(ShowFoldingBar, "Folding Bar", QStringLiteral("folding-bar"), true)); | ||||
542 | addConfigEntry(ConfigEntry(ShowFoldingPreview, "Folding Preview", QStringLiteral("folding-preview"), true)); | ||||
543 | addConfigEntry(ConfigEntry(ShowIconBar, "Icon Bar", QStringLiteral("icon-bar"), false)); | ||||
544 | addConfigEntry(ConfigEntry(ShowLineCount, "Show Line Count", QString(), false)); | ||||
545 | addConfigEntry(ConfigEntry(ShowLineModification, "Line Modification", QStringLiteral("modification-markers"), false)); | ||||
546 | addConfigEntry(ConfigEntry(ShowLineNumbers, "Line Numbers", QStringLiteral("line-numbers"), false)); | ||||
547 | addConfigEntry(ConfigEntry(ShowScrollBarMarks, "Scroll Bar Marks", QString(), false)); | ||||
548 | addConfigEntry(ConfigEntry(ShowScrollBarMiniMap, "Scroll Bar MiniMap", QStringLiteral("scrollbar-minimap"), true)); | ||||
549 | addConfigEntry(ConfigEntry(ShowScrollBarMiniMapAll, "Scroll Bar Mini Map All", QString(), true)); | ||||
550 | addConfigEntry(ConfigEntry(ShowScrollBarPreview, "Scroll Bar Preview", QStringLiteral("scrollbar-preview"), true)); | ||||
551 | addConfigEntry(ConfigEntry(ShowScrollbars, "Show Scrollbars", QString(), AlwaysOn, [](const QVariant &value) { return inBounds(0, value, 2); })); | ||||
552 | addConfigEntry(ConfigEntry(ShowWordCount, "Show Word Count", QString(), false)); | ||||
553 | addConfigEntry(ConfigEntry(SmartCopyCut, "Smart Copy Cut", QString(), false)); | ||||
554 | addConfigEntry(ConfigEntry(ViInputModeStealKeys, "Vi Input Mode Steal Keys", QString(), false)); | ||||
555 | addConfigEntry(ConfigEntry(ViRelativeLineNumbers, "Vi Relative Line Numbers", QString(), false)); | ||||
556 | addConfigEntry(ConfigEntry(WordCompletion, "Word Completion", QString(), true)); | ||||
557 | addConfigEntry(ConfigEntry(WordCompletionMinimalWordLength, "Word Completion Minimal Word Length", QString(), 3, [](const QVariant &value) { return inBounds(0, value, 99); })); | ||||
558 | addConfigEntry(ConfigEntry(WordCompletionRemoveTail, "Word Completion Remove Tail", QString(), true)); | ||||
559 | | ||||
560 | // Never forget to finalize or the <CommandName> becomes not available | ||||
561 | finalizeConfigEntries(); | ||||
562 | | ||||
537 | // init with defaults from config or really hardcoded ones | 563 | // init with defaults from config or really hardcoded ones | ||
538 | KConfigGroup config(KTextEditor::EditorPrivate::config(), "KTextEditor View"); | 564 | KConfigGroup config(KTextEditor::EditorPrivate::config(), "KTextEditor View"); | ||
539 | readConfig(config); | 565 | readConfig(config); | ||
540 | } | 566 | } | ||
541 | 567 | | |||
542 | KateViewConfig::KateViewConfig(KTextEditor::ViewPrivate *view) | 568 | KateViewConfig::KateViewConfig(KTextEditor::ViewPrivate *view) | ||
543 | : KateConfig(s_global), | 569 | : KateConfig(s_global) | ||
544 | m_searchFlags(PowerModePlainText), | 570 | , m_view(view) | ||
545 | m_maxHistorySize(100), | | |||
546 | m_showWordCount(false), | | |||
547 | m_dynWordWrapSet(false), | | |||
548 | m_dynWrapAtStaticMarkerSet(false), | | |||
549 | m_dynWordWrapIndicatorsSet(false), | | |||
550 | m_dynWordWrapAlignIndentSet(false), | | |||
551 | m_lineNumbersSet(false), | | |||
552 | m_scrollBarMarksSet(false), | | |||
553 | m_scrollBarPreviewSet(false), | | |||
554 | m_scrollBarMiniMapSet(false), | | |||
555 | m_scrollBarMiniMapAllSet(false), | | |||
556 | m_scrollBarMiniMapWidthSet(false), | | |||
557 | m_showScrollbarsSet(false), | | |||
558 | m_iconBarSet(false), | | |||
559 | m_foldingBarSet(false), | | |||
560 | m_foldingPreviewSet(false), | | |||
561 | m_lineModificationSet(false), | | |||
562 | m_bookmarkSortSet(false), | | |||
563 | m_autoCenterLinesSet(false), | | |||
564 | m_searchFlagsSet(false), | | |||
565 | m_defaultMarkTypeSet(false), | | |||
566 | m_persistentSelectionSet(false), | | |||
567 | m_inputModeSet(false), | | |||
568 | m_viInputModeStealKeysSet(false), | | |||
569 | m_viRelativeLineNumbersSet(false), | | |||
570 | m_automaticCompletionInvocationSet(false), | | |||
571 | m_wordCompletionSet(false), | | |||
572 | m_keywordCompletionSet(false), | | |||
573 | m_wordCompletionMinimalWordLengthSet(false), | | |||
574 | m_smartCopyCutSet(false), | | |||
575 | m_mousePasteAtCursorPositionSet(false), | | |||
576 | m_scrollPastEndSet(false), | | |||
577 | m_allowMarkMenu(true), | | |||
578 | m_wordCompletionRemoveTailSet(false), | | |||
579 | m_foldFirstLineSet(false), | | |||
580 | m_showWordCountSet(false), | | |||
581 | m_showLineCountSet(false), | | |||
582 | m_autoBracketsSet(false), | | |||
583 | m_backspaceRemoveComposedSet(false), | | |||
584 | m_view(view) | | |||
585 | { | 571 | { | ||
586 | } | 572 | } | ||
587 | 573 | | |||
588 | KateViewConfig::~KateViewConfig() | 574 | KateViewConfig::~KateViewConfig() | ||
589 | { | 575 | { | ||
590 | } | 576 | } | ||
591 | 577 | | |||
592 | namespace | | |||
593 | { | | |||
594 | const char KEY_SEARCH_REPLACE_FLAGS[] = "Search/Replace Flags"; | | |||
595 | const char KEY_DYN_WORD_WRAP[] = "Dynamic Word Wrap"; | | |||
596 | const char KEY_DYN_WORD_WRAP_AT_STATIC_MARKER[] = "Dynamic Word Wrap At Static Marker"; | | |||
597 | const char KEY_DYN_WORD_WRAP_INDICATORS[] = "Dynamic Word Wrap Indicators"; | | |||
598 | const char KEY_DYN_WORD_WRAP_ALIGN_INDENT[] = "Dynamic Word Wrap Align Indent"; | | |||
599 | const char KEY_LINE_NUMBERS[] = "Line Numbers"; | | |||
600 | const char KEY_SCROLL_BAR_MARKS[] = "Scroll Bar Marks"; | | |||
601 | const char KEY_SCROLL_BAR_PREVIEW[] = "Scroll Bar Preview"; | | |||
602 | const char KEY_SCROLL_BAR_MINI_MAP[] = "Scroll Bar MiniMap"; | | |||
603 | const char KEY_SCROLL_BAR_MINI_MAP_ALL[] = "Scroll Bar Mini Map All"; | | |||
604 | const char KEY_SCROLL_BAR_MINI_MAP_WIDTH[] = "Scroll Bar Mini Map Width"; | | |||
605 | const char KEY_SHOW_SCROLLBARS[] = "Show Scrollbars"; | | |||
606 | const char KEY_ICON_BAR[] = "Icon Bar"; | | |||
607 | const char KEY_FOLDING_BAR[] = "Folding Bar"; | | |||
608 | const char KEY_FOLDING_PREVIEW[] = "Folding Preview"; | | |||
609 | const char KEY_LINE_MODIFICATION[] = "Line Modification"; | | |||
610 | const char KEY_BOOKMARK_SORT[] = "Bookmark Menu Sorting"; | | |||
611 | const char KEY_AUTO_CENTER_LINES[] = "Auto Center Lines"; | | |||
612 | const char KEY_MAX_HISTORY_SIZE[] = "Maximum Search History Size"; | | |||
613 | const char KEY_DEFAULT_MARK_TYPE[] = "Default Mark Type"; | | |||
614 | const char KEY_ALLOW_MARK_MENU[] = "Allow Mark Menu"; | | |||
615 | const char KEY_PERSISTENT_SELECTION[] = "Persistent Selection"; | | |||
616 | const char KEY_INPUT_MODE[] = "Input Mode"; | | |||
617 | const char KEY_VI_INPUT_MODE_STEAL_KEYS[] = "Vi Input Mode Steal Keys"; | | |||
618 | const char KEY_VI_RELATIVE_LINE_NUMBERS[] = "Vi Relative Line Numbers"; | | |||
619 | const char KEY_AUTOMATIC_COMPLETION_INVOCATION[] = "Auto Completion"; | | |||
620 | const char KEY_WORD_COMPLETION[] = "Word Completion"; | | |||
621 | const char KEY_KEYWORD_COMPLETION[] = "Keyword Completion"; | | |||
622 | const char KEY_WORD_COMPLETION_MINIMAL_WORD_LENGTH[] = "Word Completion Minimal Word Length"; | | |||
623 | const char KEY_WORD_COMPLETION_REMOVE_TAIL[] = "Word Completion Remove Tail"; | | |||
624 | const char KEY_SMART_COPY_CUT[] = "Smart Copy Cut"; | | |||
625 | const char KEY_MOUSE_PASTE_AT_CURSOR_POSITION[] = "Mouse Paste At Cursor Position"; | | |||
626 | const char KEY_SCROLL_PAST_END[] = "Scroll Past End"; | | |||
627 | const char KEY_FOLD_FIRST_LINE[] = "Fold First Line"; | | |||
628 | const char KEY_SHOW_LINE_COUNT[] = "Show Line Count"; | | |||
629 | const char KEY_SHOW_WORD_COUNT[] = "Show Word Count"; | | |||
630 | const char KEY_AUTO_BRACKETS[] = "Auto Brackets"; | | |||
631 | const char KEY_BACKSPACE_REMOVE_COMPOSED[] = "Backspace Remove Composed Characters"; | | |||
632 | } | | |||
633 | | ||||
634 | void KateViewConfig::readConfig(const KConfigGroup &config) | 578 | void KateViewConfig::readConfig(const KConfigGroup &config) | ||
635 | { | 579 | { | ||
636 | configStart(); | 580 | configStart(); | ||
637 | 581 | | |||
638 | // read generic entries | 582 | // read generic entries | ||
639 | readConfigEntries(config); | 583 | readConfigEntries(config); | ||
640 | 584 | | |||
641 | // default on | | |||
642 | setDynWordWrap(config.readEntry(KEY_DYN_WORD_WRAP, true)); | | |||
643 | setDynWrapAtStaticMarker(config.readEntry(KEY_DYN_WORD_WRAP_AT_STATIC_MARKER, false)); | | |||
644 | setDynWordWrapIndicators(config.readEntry(KEY_DYN_WORD_WRAP_INDICATORS, 1)); | | |||
645 | setDynWordWrapAlignIndent(config.readEntry(KEY_DYN_WORD_WRAP_ALIGN_INDENT, 80)); | | |||
646 | | ||||
647 | setLineNumbers(config.readEntry(KEY_LINE_NUMBERS, false)); | | |||
648 | | ||||
649 | setScrollBarMarks(config.readEntry(KEY_SCROLL_BAR_MARKS, false)); | | |||
650 | | ||||
651 | setScrollBarPreview(config.readEntry(KEY_SCROLL_BAR_PREVIEW, true)); | | |||
652 | | ||||
653 | setScrollBarMiniMap(config.readEntry(KEY_SCROLL_BAR_MINI_MAP, true)); | | |||
654 | | ||||
655 | setScrollBarMiniMapAll(config.readEntry(KEY_SCROLL_BAR_MINI_MAP_ALL, false)); | | |||
656 | | ||||
657 | setScrollBarMiniMapWidth(config.readEntry(KEY_SCROLL_BAR_MINI_MAP_WIDTH, 60)); | | |||
658 | | ||||
659 | setShowScrollbars(config.readEntry(KEY_SHOW_SCROLLBARS, static_cast<int>(AlwaysOn))); | | |||
660 | | ||||
661 | setIconBar(config.readEntry(KEY_ICON_BAR, false)); | | |||
662 | | ||||
663 | setFoldingBar(config.readEntry(KEY_FOLDING_BAR, true)); | | |||
664 | | ||||
665 | setFoldingPreview(config.readEntry(KEY_FOLDING_PREVIEW, true)); | | |||
666 | | ||||
667 | setLineModification(config.readEntry(KEY_LINE_MODIFICATION, false)); | | |||
668 | | ||||
669 | setBookmarkSort(config.readEntry(KEY_BOOKMARK_SORT, 0)); | | |||
670 | | ||||
671 | setAutoCenterLines(config.readEntry(KEY_AUTO_CENTER_LINES, 0)); | | |||
672 | | ||||
673 | setSearchFlags(config.readEntry(KEY_SEARCH_REPLACE_FLAGS, | | |||
674 | IncFromCursor | PowerMatchCase | PowerModePlainText)); | | |||
675 | | ||||
676 | m_maxHistorySize = config.readEntry(KEY_MAX_HISTORY_SIZE, 100); | | |||
677 | | ||||
678 | setDefaultMarkType(config.readEntry(KEY_DEFAULT_MARK_TYPE, int(KTextEditor::MarkInterface::markType01))); | | |||
679 | setAllowMarkMenu(config.readEntry(KEY_ALLOW_MARK_MENU, true)); | | |||
680 | | ||||
681 | setPersistentSelection(config.readEntry(KEY_PERSISTENT_SELECTION, false)); | | |||
682 | | ||||
683 | setInputModeRaw(config.readEntry(KEY_INPUT_MODE, 0)); | | |||
684 | setViInputModeStealKeys(config.readEntry(KEY_VI_INPUT_MODE_STEAL_KEYS, false)); | | |||
685 | setViRelativeLineNumbers(config.readEntry(KEY_VI_RELATIVE_LINE_NUMBERS, false)); | | |||
686 | | ||||
687 | setAutomaticCompletionInvocation(config.readEntry(KEY_AUTOMATIC_COMPLETION_INVOCATION, true)); | | |||
688 | setWordCompletion(config.readEntry(KEY_WORD_COMPLETION, true)); | | |||
689 | setKeywordCompletion(config.readEntry(KEY_KEYWORD_COMPLETION, true)); | | |||
690 | setWordCompletionMinimalWordLength(config.readEntry(KEY_WORD_COMPLETION_MINIMAL_WORD_LENGTH, 3)); | | |||
691 | setWordCompletionRemoveTail(config.readEntry(KEY_WORD_COMPLETION_REMOVE_TAIL, true)); | | |||
692 | setSmartCopyCut(config.readEntry(KEY_SMART_COPY_CUT, false)); | | |||
693 | setMousePasteAtCursorPosition(config.readEntry(KEY_MOUSE_PASTE_AT_CURSOR_POSITION, false)); | | |||
694 | setScrollPastEnd(config.readEntry(KEY_SCROLL_PAST_END, false)); | | |||
695 | setFoldFirstLine(config.readEntry(KEY_FOLD_FIRST_LINE, false)); | | |||
696 | setShowLineCount(config.readEntry(KEY_SHOW_LINE_COUNT, false)); | | |||
697 | setShowWordCount(config.readEntry(KEY_SHOW_WORD_COUNT, false)); | | |||
698 | setAutoBrackets(config.readEntry(KEY_AUTO_BRACKETS, false)); | | |||
699 | | ||||
700 | setBackspaceRemoveComposed(config.readEntry(KEY_BACKSPACE_REMOVE_COMPOSED, false)); | | |||
701 | | ||||
702 | configEnd(); | 585 | configEnd(); | ||
703 | } | 586 | } | ||
704 | 587 | | |||
705 | void KateViewConfig::writeConfig(KConfigGroup &config) | 588 | void KateViewConfig::writeConfig(KConfigGroup &config) | ||
706 | { | 589 | { | ||
707 | // write generic entries | 590 | // write generic entries | ||
708 | writeConfigEntries(config); | 591 | writeConfigEntries(config); | ||
709 | | ||||
710 | config.writeEntry(KEY_DYN_WORD_WRAP, dynWordWrap()); | | |||
711 | config.writeEntry(KEY_DYN_WORD_WRAP_AT_STATIC_MARKER, dynWrapAtStaticMarker()); | | |||
712 | config.writeEntry(KEY_DYN_WORD_WRAP_INDICATORS, dynWordWrapIndicators()); | | |||
713 | config.writeEntry(KEY_DYN_WORD_WRAP_ALIGN_INDENT, dynWordWrapAlignIndent()); | | |||
714 | | ||||
715 | config.writeEntry(KEY_LINE_NUMBERS, lineNumbers()); | | |||
716 | | ||||
717 | config.writeEntry(KEY_SCROLL_BAR_MARKS, scrollBarMarks()); | | |||
718 | | ||||
719 | config.writeEntry(KEY_SCROLL_BAR_PREVIEW, scrollBarPreview()); | | |||
720 | | ||||
721 | config.writeEntry(KEY_SCROLL_BAR_MINI_MAP, scrollBarMiniMap()); | | |||
722 | | ||||
723 | config.writeEntry(KEY_SCROLL_BAR_MINI_MAP_ALL, scrollBarMiniMapAll()); | | |||
724 | | ||||
725 | config.writeEntry(KEY_SCROLL_BAR_MINI_MAP_WIDTH, scrollBarMiniMapWidth()); | | |||
726 | | ||||
727 | config.writeEntry(KEY_SHOW_SCROLLBARS, showScrollbars()); | | |||
728 | | ||||
729 | config.writeEntry(KEY_ICON_BAR, iconBar()); | | |||
730 | | ||||
731 | config.writeEntry(KEY_FOLDING_BAR, foldingBar()); | | |||
732 | | ||||
733 | config.writeEntry(KEY_FOLDING_PREVIEW, foldingPreview()); | | |||
734 | | ||||
735 | config.writeEntry(KEY_LINE_MODIFICATION, lineModification()); | | |||
736 | | ||||
737 | config.writeEntry(KEY_BOOKMARK_SORT, bookmarkSort()); | | |||
738 | | ||||
739 | config.writeEntry(KEY_AUTO_CENTER_LINES, autoCenterLines()); | | |||
740 | | ||||
741 | config.writeEntry(KEY_SEARCH_REPLACE_FLAGS, int(searchFlags())); | | |||
742 | | ||||
743 | config.writeEntry(KEY_MAX_HISTORY_SIZE, m_maxHistorySize); | | |||
744 | | ||||
745 | config.writeEntry(KEY_DEFAULT_MARK_TYPE, defaultMarkType()); | | |||
746 | | ||||
747 | config.writeEntry(KEY_ALLOW_MARK_MENU, allowMarkMenu()); | | |||
748 | | ||||
749 | config.writeEntry(KEY_PERSISTENT_SELECTION, persistentSelection()); | | |||
750 | | ||||
751 | config.writeEntry(KEY_AUTOMATIC_COMPLETION_INVOCATION, automaticCompletionInvocation()); | | |||
752 | config.writeEntry(KEY_WORD_COMPLETION, wordCompletion()); | | |||
753 | config.writeEntry(KEY_KEYWORD_COMPLETION, keywordCompletion()); | | |||
754 | config.writeEntry(KEY_WORD_COMPLETION_MINIMAL_WORD_LENGTH, wordCompletionMinimalWordLength()); | | |||
755 | config.writeEntry(KEY_WORD_COMPLETION_REMOVE_TAIL, wordCompletionRemoveTail()); | | |||
756 | | ||||
757 | config.writeEntry(KEY_SMART_COPY_CUT, smartCopyCut()); | | |||
758 | config.writeEntry(KEY_MOUSE_PASTE_AT_CURSOR_POSITION, mousePasteAtCursorPosition()); | | |||
759 | config.writeEntry(KEY_SCROLL_PAST_END, scrollPastEnd()); | | |||
760 | config.writeEntry(KEY_FOLD_FIRST_LINE, foldFirstLine()); | | |||
761 | | ||||
762 | config.writeEntry(KEY_INPUT_MODE, static_cast<int>(inputMode())); | | |||
763 | config.writeEntry(KEY_VI_INPUT_MODE_STEAL_KEYS, viInputModeStealKeys()); | | |||
764 | config.writeEntry(KEY_VI_RELATIVE_LINE_NUMBERS, viRelativeLineNumbers()); | | |||
765 | | ||||
766 | config.writeEntry(KEY_SHOW_LINE_COUNT, showLineCount()); | | |||
767 | config.writeEntry(KEY_SHOW_WORD_COUNT, showWordCount()); | | |||
768 | config.writeEntry(KEY_AUTO_BRACKETS, autoBrackets()); | | |||
769 | | ||||
770 | config.writeEntry(KEY_BACKSPACE_REMOVE_COMPOSED, backspaceRemoveComposed()); | | |||
771 | } | 592 | } | ||
772 | 593 | | |||
773 | void KateViewConfig::updateConfig() | 594 | void KateViewConfig::updateConfig() | ||
774 | { | 595 | { | ||
775 | if (m_view) { | 596 | if (m_view) { | ||
776 | m_view->updateConfig(); | 597 | m_view->updateConfig(); | ||
777 | return; | 598 | return; | ||
778 | } | 599 | } | ||
779 | 600 | | |||
780 | if (isGlobal()) { | 601 | if (isGlobal()) { | ||
781 | foreach (KTextEditor::ViewPrivate* view, KTextEditor::EditorPrivate::self()->views()) { | 602 | foreach (KTextEditor::ViewPrivate* view, KTextEditor::EditorPrivate::self()->views()) { | ||
782 | view->updateConfig(); | 603 | view->updateConfig(); | ||
783 | } | 604 | } | ||
784 | 605 | | |||
785 | // write config | 606 | // write config | ||
786 | KConfigGroup cg(KTextEditor::EditorPrivate::config(), "KTextEditor View"); | 607 | KConfigGroup cg(KTextEditor::EditorPrivate::config(), "KTextEditor View"); | ||
787 | writeConfig(cg); | 608 | writeConfig(cg); | ||
788 | KTextEditor::EditorPrivate::config()->sync(); | 609 | KTextEditor::EditorPrivate::config()->sync(); | ||
789 | } | 610 | } | ||
790 | } | 611 | } | ||
791 | 612 | | |||
792 | bool KateViewConfig::dynWordWrap() const | | |||
793 | { | | |||
794 | if (m_dynWordWrapSet || isGlobal()) { | | |||
795 | return m_dynWordWrap; | | |||
796 | } | | |||
797 | | ||||
798 | return s_global->dynWordWrap(); | | |||
799 | } | | |||
800 | | ||||
801 | void KateViewConfig::setDynWordWrap(bool wrap) | | |||
802 | { | | |||
803 | if (m_dynWordWrapSet && m_dynWordWrap == wrap) { | | |||
804 | return; | | |||
805 | } | | |||
806 | | ||||
807 | configStart(); | | |||
808 | | ||||
809 | m_dynWordWrapSet = true; | | |||
810 | m_dynWordWrap = wrap; | | |||
811 | | ||||
812 | configEnd(); | | |||
813 | } | | |||
814 | | ||||
815 | bool KateViewConfig::dynWrapAtStaticMarker() const | | |||
816 | { | | |||
817 | if (m_dynWrapAtStaticMarkerSet || isGlobal()) { | | |||
818 | return m_dynWrapAtStaticMarker; | | |||
819 | } | | |||
820 | | ||||
821 | return s_global->dynWrapAtStaticMarker(); | | |||
822 | } | | |||
823 | | ||||
824 | void KateViewConfig::setDynWrapAtStaticMarker(bool on) | | |||
825 | { | | |||
826 | if (m_dynWrapAtStaticMarkerSet && m_dynWrapAtStaticMarker == on) { | | |||
827 | return; | | |||
828 | } | | |||
829 | | ||||
830 | configStart(); | | |||
831 | | ||||
832 | m_dynWrapAtStaticMarkerSet = true; | | |||
833 | m_dynWrapAtStaticMarker = on; | | |||
834 | | ||||
835 | configEnd(); | | |||
836 | } | | |||
837 | | ||||
838 | int KateViewConfig::dynWordWrapIndicators() const | | |||
839 | { | | |||
840 | if (m_dynWordWrapIndicatorsSet || isGlobal()) { | | |||
841 | return m_dynWordWrapIndicators; | | |||
842 | } | | |||
843 | | ||||
844 | return s_global->dynWordWrapIndicators(); | | |||
845 | } | | |||
846 | | ||||
847 | void KateViewConfig::setDynWordWrapIndicators(int mode) | | |||
848 | { | | |||
849 | if (m_dynWordWrapIndicatorsSet && m_dynWordWrapIndicators == mode) { | | |||
850 | return; | | |||
851 | } | | |||
852 | | ||||
853 | configStart(); | | |||
854 | | ||||
855 | m_dynWordWrapIndicatorsSet = true; | | |||
856 | m_dynWordWrapIndicators = qBound(0, mode, 80); | | |||
857 | | ||||
858 | configEnd(); | | |||
859 | } | | |||
860 | | ||||
861 | int KateViewConfig::dynWordWrapAlignIndent() const | | |||
862 | { | | |||
863 | if (m_dynWordWrapAlignIndentSet || isGlobal()) { | | |||
864 | return m_dynWordWrapAlignIndent; | | |||
865 | } | | |||
866 | | ||||
867 | return s_global->dynWordWrapAlignIndent(); | | |||
868 | } | | |||
869 | | ||||
870 | void KateViewConfig::setDynWordWrapAlignIndent(int indent) | | |||
871 | { | | |||
872 | if (m_dynWordWrapAlignIndentSet && m_dynWordWrapAlignIndent == indent) { | | |||
873 | return; | | |||
874 | } | | |||
875 | | ||||
876 | configStart(); | | |||
877 | | ||||
878 | m_dynWordWrapAlignIndentSet = true; | | |||
879 | m_dynWordWrapAlignIndent = indent; | | |||
880 | | ||||
881 | configEnd(); | | |||
882 | } | | |||
883 | | ||||
884 | bool KateViewConfig::lineNumbers() const | | |||
885 | { | | |||
886 | if (m_lineNumbersSet || isGlobal()) { | | |||
887 | return m_lineNumbers; | | |||
888 | } | | |||
889 | | ||||
890 | return s_global->lineNumbers(); | | |||
891 | } | | |||
892 | | ||||
893 | void KateViewConfig::setLineNumbers(bool on) | | |||
894 | { | | |||
895 | if (m_lineNumbersSet && m_lineNumbers == on) { | | |||
896 | return; | | |||
897 | } | | |||
898 | | ||||
899 | configStart(); | | |||
900 | | ||||
901 | m_lineNumbersSet = true; | | |||
902 | m_lineNumbers = on; | | |||
903 | | ||||
904 | configEnd(); | | |||
905 | } | | |||
906 | | ||||
907 | bool KateViewConfig::scrollBarMarks() const | | |||
908 | { | | |||
909 | if (m_scrollBarMarksSet || isGlobal()) { | | |||
910 | return m_scrollBarMarks; | | |||
911 | } | | |||
912 | | ||||
913 | return s_global->scrollBarMarks(); | | |||
914 | } | | |||
915 | | ||||
916 | void KateViewConfig::setScrollBarMarks(bool on) | | |||
917 | { | | |||
918 | if (m_scrollBarMarksSet && m_scrollBarMarks == on) { | | |||
919 | return; | | |||
920 | } | | |||
921 | | ||||
922 | configStart(); | | |||
923 | | ||||
924 | m_scrollBarMarksSet = true; | | |||
925 | m_scrollBarMarks = on; | | |||
926 | | ||||
927 | configEnd(); | | |||
928 | } | | |||
929 | | ||||
930 | bool KateViewConfig::scrollBarPreview() const | | |||
931 | { | | |||
932 | if (m_scrollBarPreviewSet || isGlobal()) { | | |||
933 | return m_scrollBarPreview; | | |||
934 | } | | |||
935 | | ||||
936 | return s_global->scrollBarPreview(); | | |||
937 | } | | |||
938 | | ||||
939 | void KateViewConfig::setScrollBarPreview(bool on) | | |||
940 | { | | |||
941 | if (m_scrollBarPreviewSet && m_scrollBarPreview == on) { | | |||
942 | return; | | |||
943 | } | | |||
944 | | ||||
945 | configStart(); | | |||
946 | | ||||
947 | m_scrollBarPreviewSet = true; | | |||
948 | m_scrollBarPreview = on; | | |||
949 | | ||||
950 | configEnd(); | | |||
951 | } | | |||
952 | | ||||
953 | bool KateViewConfig::scrollBarMiniMap() const | | |||
954 | { | | |||
955 | if (m_scrollBarMiniMapSet || isGlobal()) { | | |||
956 | return m_scrollBarMiniMap; | | |||
957 | } | | |||
958 | | ||||
959 | return s_global->scrollBarMiniMap(); | | |||
960 | } | | |||
961 | | ||||
962 | void KateViewConfig::setScrollBarMiniMap(bool on) | | |||
963 | { | | |||
964 | if (m_scrollBarMiniMapSet && m_scrollBarMiniMap == on) { | | |||
965 | return; | | |||
966 | } | | |||
967 | | ||||
968 | configStart(); | | |||
969 | | ||||
970 | m_scrollBarMiniMapSet = true; | | |||
971 | m_scrollBarMiniMap = on; | | |||
972 | | ||||
973 | configEnd(); | | |||
974 | } | | |||
975 | | ||||
976 | bool KateViewConfig::scrollBarMiniMapAll() const | | |||
977 | { | | |||
978 | if (m_scrollBarMiniMapAllSet || isGlobal()) { | | |||
979 | return m_scrollBarMiniMapAll; | | |||
980 | } | | |||
981 | | ||||
982 | return s_global->scrollBarMiniMapAll(); | | |||
983 | } | | |||
984 | | ||||
985 | void KateViewConfig::setScrollBarMiniMapAll(bool on) | | |||
986 | { | | |||
987 | if (m_scrollBarMiniMapAllSet && m_scrollBarMiniMapAll == on) { | | |||
988 | return; | | |||
989 | } | | |||
990 | | ||||
991 | configStart(); | | |||
992 | | ||||
993 | m_scrollBarMiniMapAllSet = true; | | |||
994 | m_scrollBarMiniMapAll = on; | | |||
995 | | ||||
996 | configEnd(); | | |||
997 | } | | |||
998 | | ||||
999 | int KateViewConfig::scrollBarMiniMapWidth() const | | |||
1000 | { | | |||
1001 | if (m_scrollBarMiniMapWidthSet || isGlobal()) { | | |||
1002 | return m_scrollBarMiniMapWidth; | | |||
1003 | } | | |||
1004 | | ||||
1005 | return s_global->scrollBarMiniMapWidth(); | | |||
1006 | } | | |||
1007 | | ||||
1008 | void KateViewConfig::setScrollBarMiniMapWidth(int width) | | |||
1009 | { | | |||
1010 | if (m_scrollBarMiniMapWidthSet && m_scrollBarMiniMapWidth == width) { | | |||
1011 | return; | | |||
1012 | } | | |||
1013 | | ||||
1014 | configStart(); | | |||
1015 | | ||||
1016 | m_scrollBarMiniMapWidthSet = true; | | |||
1017 | m_scrollBarMiniMapWidth = width; | | |||
1018 | | ||||
1019 | configEnd(); | | |||
1020 | } | | |||
1021 | | ||||
1022 | int KateViewConfig::showScrollbars() const | | |||
1023 | { | | |||
1024 | if (m_showScrollbarsSet || isGlobal()) { | | |||
1025 | return m_showScrollbars; | | |||
1026 | } | | |||
1027 | | ||||
1028 | return s_global->showScrollbars(); | | |||
1029 | } | | |||
1030 | | ||||
1031 | void KateViewConfig::setShowScrollbars(int mode) | | |||
1032 | { | | |||
1033 | if (m_showScrollbarsSet && m_showScrollbars == mode) { | | |||
1034 | return; | | |||
1035 | } | | |||
1036 | | ||||
1037 | configStart(); | | |||
1038 | | ||||
1039 | m_showScrollbarsSet = true; | | |||
1040 | m_showScrollbars = qBound(0, mode, 80); | | |||
1041 | | ||||
1042 | configEnd(); | | |||
1043 | } | | |||
1044 | | ||||
1045 | bool KateViewConfig::autoBrackets() const | | |||
1046 | { | | |||
1047 | if (m_autoBracketsSet || isGlobal()) { | | |||
1048 | return m_autoBrackets; | | |||
1049 | } | | |||
1050 | | ||||
1051 | return s_global->autoBrackets(); | | |||
1052 | } | | |||
1053 | | ||||
1054 | void KateViewConfig::setAutoBrackets(bool on) | | |||
1055 | { | | |||
1056 | if (m_autoBracketsSet && m_autoBrackets == on) { | | |||
1057 | return; | | |||
1058 | } | | |||
1059 | | ||||
1060 | configStart(); | | |||
1061 | | ||||
1062 | m_autoBracketsSet = true; | | |||
1063 | m_autoBrackets = on; | | |||
1064 | | ||||
1065 | configEnd(); | | |||
1066 | } | | |||
1067 | | ||||
1068 | bool KateViewConfig::iconBar() const | | |||
1069 | { | | |||
1070 | if (m_iconBarSet || isGlobal()) { | | |||
1071 | return m_iconBar; | | |||
1072 | } | | |||
1073 | | ||||
1074 | return s_global->iconBar(); | | |||
1075 | } | | |||
1076 | | ||||
1077 | void KateViewConfig::setIconBar(bool on) | | |||
1078 | { | | |||
1079 | if (m_iconBarSet && m_iconBar == on) { | | |||
1080 | return; | | |||
1081 | } | | |||
1082 | | ||||
1083 | configStart(); | | |||
1084 | | ||||
1085 | m_iconBarSet = true; | | |||
1086 | m_iconBar = on; | | |||
1087 | | ||||
1088 | configEnd(); | | |||
1089 | } | | |||
1090 | | ||||
1091 | bool KateViewConfig::foldingBar() const | | |||
1092 | { | | |||
1093 | if (m_foldingBarSet || isGlobal()) { | | |||
1094 | return m_foldingBar; | | |||
1095 | } | | |||
1096 | | ||||
1097 | return s_global->foldingBar(); | | |||
1098 | } | | |||
1099 | | ||||
1100 | void KateViewConfig::setFoldingBar(bool on) | | |||
1101 | { | | |||
1102 | if (m_foldingBarSet && m_foldingBar == on) { | | |||
1103 | return; | | |||
1104 | } | | |||
1105 | | ||||
1106 | configStart(); | | |||
1107 | | ||||
1108 | m_foldingBarSet = true; | | |||
1109 | m_foldingBar = on; | | |||
1110 | | ||||
1111 | configEnd(); | | |||
1112 | } | | |||
1113 | | ||||
1114 | bool KateViewConfig::foldingPreview() const | | |||
1115 | { | | |||
1116 | if (m_foldingPreviewSet || isGlobal()) { | | |||
1117 | return m_foldingPreview; | | |||
1118 | } | | |||
1119 | | ||||
1120 | return s_global->foldingPreview(); | | |||
1121 | } | | |||
1122 | | ||||
1123 | void KateViewConfig::setFoldingPreview(bool on) | | |||
1124 | { | | |||
1125 | if (m_foldingPreviewSet && m_foldingPreview == on) { | | |||
1126 | return; | | |||
1127 | } | | |||
1128 | | ||||
1129 | configStart(); | | |||
1130 | | ||||
1131 | m_foldingPreviewSet = true; | | |||
1132 | m_foldingPreview = on; | | |||
1133 | | ||||
1134 | configEnd(); | | |||
1135 | } | | |||
1136 | | ||||
1137 | bool KateViewConfig::lineModification() const | | |||
1138 | { | | |||
1139 | if (m_lineModificationSet || isGlobal()) { | | |||
1140 | return m_lineModification; | | |||
1141 | } | | |||
1142 | | ||||
1143 | return s_global->lineModification(); | | |||
1144 | } | | |||
1145 | | ||||
1146 | void KateViewConfig::setLineModification(bool on) | | |||
1147 | { | | |||
1148 | if (m_lineModificationSet && m_lineModification == on) { | | |||
1149 | return; | | |||
1150 | } | | |||
1151 | | ||||
1152 | configStart(); | | |||
1153 | | ||||
1154 | m_lineModificationSet = true; | | |||
1155 | m_lineModification = on; | | |||
1156 | | ||||
1157 | configEnd(); | | |||
1158 | } | | |||
1159 | | ||||
1160 | int KateViewConfig::bookmarkSort() const | | |||
1161 | { | | |||
1162 | if (m_bookmarkSortSet || isGlobal()) { | | |||
1163 | return m_bookmarkSort; | | |||
1164 | } | | |||
1165 | | ||||
1166 | return s_global->bookmarkSort(); | | |||
1167 | } | | |||
1168 | | ||||
1169 | void KateViewConfig::setBookmarkSort(int mode) | | |||
1170 | { | | |||
1171 | if (m_bookmarkSortSet && m_bookmarkSort == mode) { | | |||
1172 | return; | | |||
1173 | } | | |||
1174 | | ||||
1175 | configStart(); | | |||
1176 | | ||||
1177 | m_bookmarkSortSet = true; | | |||
1178 | m_bookmarkSort = mode; | | |||
1179 | | ||||
1180 | configEnd(); | | |||
1181 | } | | |||
1182 | | ||||
1183 | int KateViewConfig::autoCenterLines() const | | |||
1184 | { | | |||
1185 | if (m_autoCenterLinesSet || isGlobal()) { | | |||
1186 | return m_autoCenterLines; | | |||
1187 | } | | |||
1188 | | ||||
1189 | return s_global->autoCenterLines(); | | |||
1190 | } | | |||
1191 | | ||||
1192 | void KateViewConfig::setAutoCenterLines(int lines) | | |||
1193 | { | | |||
1194 | if (lines < 0) { | | |||
1195 | return; | | |||
1196 | } | | |||
1197 | | ||||
1198 | if (m_autoCenterLinesSet && m_autoCenterLines == lines) { | | |||
1199 | return; | | |||
1200 | } | | |||
1201 | | ||||
1202 | configStart(); | | |||
1203 | | ||||
1204 | m_autoCenterLinesSet = true; | | |||
1205 | m_autoCenterLines = lines; | | |||
1206 | | ||||
1207 | configEnd(); | | |||
1208 | } | | |||
1209 | | ||||
1210 | long KateViewConfig::searchFlags() const | | |||
1211 | { | | |||
1212 | if (m_searchFlagsSet || isGlobal()) { | | |||
1213 | return m_searchFlags; | | |||
1214 | } | | |||
1215 | | ||||
1216 | return s_global->searchFlags(); | | |||
1217 | } | | |||
1218 | | ||||
1219 | void KateViewConfig::setSearchFlags(long flags) | | |||
1220 | { | | |||
1221 | if (m_searchFlagsSet && m_searchFlags == flags) { | | |||
1222 | return; | | |||
1223 | } | | |||
1224 | | ||||
1225 | configStart(); | | |||
1226 | | ||||
1227 | m_searchFlagsSet = true; | | |||
1228 | m_searchFlags = flags; | | |||
1229 | | ||||
1230 | configEnd(); | | |||
1231 | } | | |||
1232 | | ||||
1233 | int KateViewConfig::maxHistorySize() const | | |||
1234 | { | | |||
1235 | return m_maxHistorySize; | | |||
1236 | } | | |||
1237 | | ||||
1238 | uint KateViewConfig::defaultMarkType() const | | |||
1239 | { | | |||
1240 | if (m_defaultMarkTypeSet || isGlobal()) { | | |||
1241 | return m_defaultMarkType; | | |||
1242 | } | | |||
1243 | | ||||
1244 | return s_global->defaultMarkType(); | | |||
1245 | } | | |||
1246 | | ||||
1247 | void KateViewConfig::setDefaultMarkType(uint type) | | |||
1248 | { | | |||
1249 | if (m_defaultMarkTypeSet && m_defaultMarkType == type) { | | |||
1250 | return; | | |||
1251 | } | | |||
1252 | | ||||
1253 | configStart(); | | |||
1254 | | ||||
1255 | m_defaultMarkTypeSet = true; | | |||
1256 | m_defaultMarkType = type; | | |||
1257 | | ||||
1258 | configEnd(); | | |||
1259 | } | | |||
1260 | | ||||
1261 | bool KateViewConfig::allowMarkMenu() const | | |||
1262 | { | | |||
1263 | return m_allowMarkMenu; | | |||
1264 | } | | |||
1265 | | ||||
1266 | void KateViewConfig::setAllowMarkMenu(bool allow) | | |||
1267 | { | | |||
1268 | m_allowMarkMenu = allow; | | |||
1269 | } | | |||
1270 | | ||||
1271 | bool KateViewConfig::persistentSelection() const | | |||
1272 | { | | |||
1273 | if (m_persistentSelectionSet || isGlobal()) { | | |||
1274 | return m_persistentSelection; | | |||
1275 | } | | |||
1276 | | ||||
1277 | return s_global->persistentSelection(); | | |||
1278 | } | | |||
1279 | | ||||
1280 | void KateViewConfig::setPersistentSelection(bool on) | | |||
1281 | { | | |||
1282 | if (m_persistentSelectionSet && m_persistentSelection == on) { | | |||
1283 | return; | | |||
1284 | } | | |||
1285 | | ||||
1286 | configStart(); | | |||
1287 | | ||||
1288 | m_persistentSelectionSet = true; | | |||
1289 | m_persistentSelection = on; | | |||
1290 | | ||||
1291 | configEnd(); | | |||
1292 | } | | |||
1293 | | ||||
1294 | KTextEditor::View::InputMode KateViewConfig::inputMode() const | | |||
1295 | { | | |||
1296 | if (m_inputModeSet || isGlobal()) { | | |||
1297 | return m_inputMode; | | |||
1298 | } | | |||
1299 | | ||||
1300 | return s_global->inputMode(); | | |||
1301 | } | | |||
1302 | | ||||
1303 | void KateViewConfig::setInputMode(KTextEditor::View::InputMode mode) | | |||
1304 | { | | |||
1305 | if (m_inputModeSet && m_inputMode == mode) { | | |||
1306 | return; | | |||
1307 | } | | |||
1308 | | ||||
1309 | configStart(); | | |||
1310 | | ||||
1311 | m_inputModeSet = true; | | |||
1312 | m_inputMode = mode; | | |||
1313 | | ||||
1314 | configEnd(); | | |||
1315 | } | | |||
1316 | | ||||
1317 | void KateViewConfig::setInputModeRaw(int rawmode) | | |||
1318 | { | | |||
1319 | setInputMode(static_cast<KTextEditor::View::InputMode>(rawmode)); | | |||
1320 | } | | |||
1321 | | ||||
1322 | bool KateViewConfig::viInputModeStealKeys() const | | |||
1323 | { | | |||
1324 | if (m_viInputModeStealKeysSet || isGlobal()) { | | |||
1325 | return m_viInputModeStealKeys; | | |||
1326 | } | | |||
1327 | | ||||
1328 | return s_global->viInputModeStealKeys(); | | |||
1329 | } | | |||
1330 | | ||||
1331 | void KateViewConfig::setViInputModeStealKeys(bool on) | | |||
1332 | { | | |||
1333 | if (m_viInputModeStealKeysSet && m_viInputModeStealKeys == on) { | | |||
1334 | return; | | |||
1335 | } | | |||
1336 | | ||||
1337 | configStart(); | | |||
1338 | m_viInputModeStealKeysSet = true; | | |||
1339 | m_viInputModeStealKeys = on; | | |||
1340 | configEnd(); | | |||
1341 | } | | |||
1342 | | ||||
1343 | bool KateViewConfig::viRelativeLineNumbers() const | | |||
1344 | { | | |||
1345 | if (m_viRelativeLineNumbersSet || isGlobal()) { | | |||
1346 | return m_viRelativeLineNumbers; | | |||
1347 | } | | |||
1348 | | ||||
1349 | return s_global->viRelativeLineNumbers(); | | |||
1350 | } | | |||
1351 | | ||||
1352 | void KateViewConfig::setViRelativeLineNumbers(bool on) | | |||
1353 | { | | |||
1354 | if (m_viRelativeLineNumbersSet && m_viRelativeLineNumbers == on) { | | |||
1355 | return; | | |||
1356 | } | | |||
1357 | | ||||
1358 | configStart(); | | |||
1359 | m_viRelativeLineNumbersSet = true; | | |||
1360 | m_viRelativeLineNumbers = on; | | |||
1361 | configEnd(); | | |||
1362 | } | | |||
1363 | | ||||
1364 | bool KateViewConfig::automaticCompletionInvocation() const | | |||
1365 | { | | |||
1366 | if (m_automaticCompletionInvocationSet || isGlobal()) { | | |||
1367 | return m_automaticCompletionInvocation; | | |||
1368 | } | | |||
1369 | | ||||
1370 | return s_global->automaticCompletionInvocation(); | | |||
1371 | } | | |||
1372 | | ||||
1373 | void KateViewConfig::setAutomaticCompletionInvocation(bool on) | | |||
1374 | { | | |||
1375 | if (m_automaticCompletionInvocationSet && m_automaticCompletionInvocation == on) { | | |||
1376 | return; | | |||
1377 | } | | |||
1378 | | ||||
1379 | configStart(); | | |||
1380 | m_automaticCompletionInvocationSet = true; | | |||
1381 | m_automaticCompletionInvocation = on; | | |||
1382 | configEnd(); | | |||
1383 | } | | |||
1384 | | ||||
1385 | bool KateViewConfig::wordCompletion() const | | |||
1386 | { | | |||
1387 | if (m_wordCompletionSet || isGlobal()) { | | |||
1388 | return m_wordCompletion; | | |||
1389 | } | | |||
1390 | | ||||
1391 | return s_global->wordCompletion(); | | |||
1392 | } | | |||
1393 | | ||||
1394 | void KateViewConfig::setWordCompletion(bool on) | | |||
1395 | { | | |||
1396 | if (m_wordCompletionSet && m_wordCompletion == on) { | | |||
1397 | return; | | |||
1398 | } | | |||
1399 | | ||||
1400 | configStart(); | | |||
1401 | m_wordCompletionSet = true; | | |||
1402 | m_wordCompletion = on; | | |||
1403 | configEnd(); | | |||
1404 | } | | |||
1405 | | ||||
1406 | bool KateViewConfig::keywordCompletion() const | | |||
1407 | { | | |||
1408 | if (m_keywordCompletionSet || isGlobal()) | | |||
1409 | return m_keywordCompletion; | | |||
1410 | return s_global->keywordCompletion(); | | |||
1411 | } | | |||
1412 | | ||||
1413 | void KateViewConfig::setKeywordCompletion(bool on) | | |||
1414 | { | | |||
1415 | if (m_keywordCompletionSet && m_keywordCompletion == on) | | |||
1416 | return; | | |||
1417 | configStart(); | | |||
1418 | m_keywordCompletionSet = true; | | |||
1419 | m_keywordCompletion = on; | | |||
1420 | configEnd(); | | |||
1421 | } | | |||
1422 | | ||||
1423 | int KateViewConfig::wordCompletionMinimalWordLength() const | | |||
1424 | { | | |||
1425 | if (m_wordCompletionMinimalWordLengthSet || isGlobal()) { | | |||
1426 | return m_wordCompletionMinimalWordLength; | | |||
1427 | } | | |||
1428 | | ||||
1429 | return s_global->wordCompletionMinimalWordLength(); | | |||
1430 | } | | |||
1431 | | ||||
1432 | void KateViewConfig::setWordCompletionMinimalWordLength(int length) | | |||
1433 | { | | |||
1434 | if (m_wordCompletionMinimalWordLengthSet && m_wordCompletionMinimalWordLength == length) { | | |||
1435 | return; | | |||
1436 | } | | |||
1437 | | ||||
1438 | configStart(); | | |||
1439 | | ||||
1440 | m_wordCompletionMinimalWordLengthSet = true; | | |||
1441 | m_wordCompletionMinimalWordLength = length; | | |||
1442 | | ||||
1443 | configEnd(); | | |||
1444 | } | | |||
1445 | | ||||
1446 | bool KateViewConfig::wordCompletionRemoveTail() const | | |||
1447 | { | | |||
1448 | if (m_wordCompletionRemoveTailSet || isGlobal()) { | | |||
1449 | return m_wordCompletionRemoveTail; | | |||
1450 | } | | |||
1451 | | ||||
1452 | return s_global->wordCompletionRemoveTail(); | | |||
1453 | } | | |||
1454 | | ||||
1455 | void KateViewConfig::setWordCompletionRemoveTail(bool on) | | |||
1456 | { | | |||
1457 | if (m_wordCompletionRemoveTailSet && m_wordCompletionRemoveTail == on) { | | |||
1458 | return; | | |||
1459 | } | | |||
1460 | | ||||
1461 | configStart(); | | |||
1462 | m_wordCompletionRemoveTailSet = true; | | |||
1463 | m_wordCompletionRemoveTail = on; | | |||
1464 | configEnd(); | | |||
1465 | } | | |||
1466 | | ||||
1467 | bool KateViewConfig::smartCopyCut() const | | |||
1468 | { | | |||
1469 | if (m_smartCopyCutSet || isGlobal()) { | | |||
1470 | return m_smartCopyCut; | | |||
1471 | } | | |||
1472 | | ||||
1473 | return s_global->smartCopyCut(); | | |||
1474 | } | | |||
1475 | | ||||
1476 | void KateViewConfig::setSmartCopyCut(bool on) | | |||
1477 | { | | |||
1478 | if (m_smartCopyCutSet && m_smartCopyCut == on) { | | |||
1479 | return; | | |||
1480 | } | | |||
1481 | | ||||
1482 | configStart(); | | |||
1483 | | ||||
1484 | m_smartCopyCutSet = true; | | |||
1485 | m_smartCopyCut = on; | | |||
1486 | | ||||
1487 | configEnd(); | | |||
1488 | } | | |||
1489 | | ||||
1490 | bool KateViewConfig::mousePasteAtCursorPosition() const | | |||
1491 | { | | |||
1492 | if (m_mousePasteAtCursorPositionSet|| isGlobal()) { | | |||
1493 | return m_mousePasteAtCursorPosition; | | |||
1494 | } | | |||
1495 | | ||||
1496 | return s_global->mousePasteAtCursorPosition(); | | |||
1497 | } | | |||
1498 | | ||||
1499 | void KateViewConfig::setMousePasteAtCursorPosition(bool on) | | |||
1500 | { | | |||
1501 | if (m_mousePasteAtCursorPositionSet && m_mousePasteAtCursorPosition == on) { | | |||
1502 | return; | | |||
1503 | } | | |||
1504 | | ||||
1505 | configStart(); | | |||
1506 | | ||||
1507 | m_mousePasteAtCursorPositionSet = true; | | |||
1508 | m_mousePasteAtCursorPosition = on; | | |||
1509 | | ||||
1510 | configEnd(); | | |||
1511 | } | | |||
1512 | | ||||
1513 | bool KateViewConfig::scrollPastEnd() const | | |||
1514 | { | | |||
1515 | if (m_scrollPastEndSet || isGlobal()) { | | |||
1516 | return m_scrollPastEnd; | | |||
1517 | } | | |||
1518 | | ||||
1519 | return s_global->scrollPastEnd(); | | |||
1520 | } | | |||
1521 | | ||||
1522 | void KateViewConfig::setScrollPastEnd(bool on) | | |||
1523 | { | | |||
1524 | if (m_scrollPastEndSet && m_scrollPastEnd == on) { | | |||
1525 | return; | | |||
1526 | } | | |||
1527 | | ||||
1528 | configStart(); | | |||
1529 | | ||||
1530 | m_scrollPastEndSet = true; | | |||
1531 | m_scrollPastEnd = on; | | |||
1532 | | ||||
1533 | configEnd(); | | |||
1534 | } | | |||
1535 | | ||||
1536 | bool KateViewConfig::foldFirstLine() const | | |||
1537 | { | | |||
1538 | if (m_foldFirstLineSet || isGlobal()) { | | |||
1539 | return m_foldFirstLine; | | |||
1540 | } | | |||
1541 | | ||||
1542 | return s_global->foldFirstLine(); | | |||
1543 | } | | |||
1544 | | ||||
1545 | void KateViewConfig::setFoldFirstLine(bool on) | | |||
1546 | { | | |||
1547 | if (m_foldFirstLineSet && m_foldFirstLine == on) { | | |||
1548 | return; | | |||
1549 | } | | |||
1550 | | ||||
1551 | configStart(); | | |||
1552 | | ||||
1553 | m_foldFirstLineSet = true; | | |||
1554 | m_foldFirstLine = on; | | |||
1555 | | ||||
1556 | configEnd(); | | |||
1557 | } | | |||
1558 | | ||||
1559 | bool KateViewConfig::showWordCount() const | | |||
1560 | { | | |||
1561 | if (m_showWordCountSet || isGlobal()) { | | |||
1562 | return m_showWordCount; | | |||
1563 | } | | |||
1564 | | ||||
1565 | return s_global->showWordCount(); | | |||
1566 | } | | |||
1567 | | ||||
1568 | void KateViewConfig::setShowWordCount(bool on) | | |||
1569 | { | | |||
1570 | if (m_showWordCountSet && m_showWordCount == on) { | | |||
1571 | return; | | |||
1572 | } | | |||
1573 | | ||||
1574 | configStart(); | | |||
1575 | m_showWordCountSet = true; | | |||
1576 | m_showWordCount = on; | | |||
1577 | configEnd(); | | |||
1578 | } | | |||
1579 | | ||||
1580 | bool KateViewConfig::showLineCount() const | | |||
1581 | { | | |||
1582 | if (m_showLineCountSet || isGlobal()) { | | |||
1583 | return m_showLineCount; | | |||
1584 | } | | |||
1585 | | ||||
1586 | return s_global->showLineCount(); | | |||
1587 | } | | |||
1588 | | ||||
1589 | void KateViewConfig::setShowLineCount(bool on) | | |||
1590 | { | | |||
1591 | if (m_showLineCountSet && m_showLineCount == on) { | | |||
1592 | return; | | |||
1593 | } | | |||
1594 | | ||||
1595 | configStart(); | | |||
1596 | m_showLineCountSet = true; | | |||
1597 | m_showLineCount = on; | | |||
1598 | configEnd(); | | |||
1599 | } | | |||
1600 | | ||||
1601 | bool KateViewConfig::backspaceRemoveComposed() const | | |||
1602 | { | | |||
1603 | if (m_backspaceRemoveComposedSet || isGlobal()) { | | |||
1604 | return m_backspaceRemoveComposed; | | |||
1605 | } | | |||
1606 | | ||||
1607 | return s_global->backspaceRemoveComposed(); | | |||
1608 | } | | |||
1609 | | ||||
1610 | void KateViewConfig::setBackspaceRemoveComposed(bool on) | | |||
1611 | { | | |||
1612 | if (m_backspaceRemoveComposedSet && m_backspaceRemoveComposed == on) { | | |||
1613 | return; | | |||
1614 | } | | |||
1615 | | ||||
1616 | configStart(); | | |||
1617 | | ||||
1618 | m_backspaceRemoveComposedSet = true; | | |||
1619 | m_backspaceRemoveComposed = on; | | |||
1620 | | ||||
1621 | configEnd(); | | |||
1622 | } | | |||
1623 | | ||||
1624 | //END | 613 | //END | ||
1625 | 614 | | |||
1626 | //BEGIN KateRendererConfig | 615 | //BEGIN KateRendererConfig | ||
1627 | KateRendererConfig::KateRendererConfig() | 616 | KateRendererConfig::KateRendererConfig() | ||
1628 | : m_fontMetrics(QFont()), | 617 | : m_fontMetrics(QFont()), | ||
1629 | m_lineMarkerColor(KTextEditor::MarkInterface::reservedMarkersCount()), | 618 | m_lineMarkerColor(KTextEditor::MarkInterface::reservedMarkersCount()), | ||
1630 | 619 | | |||
1631 | m_schemaSet(false), | 620 | m_schemaSet(false), | ||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |