aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2023-06-01 12:02:13 +0200
committerhjk <hjk@qt.io>2023-06-01 15:33:59 +0000
commitdb4dd91caf7e72566b2d6f4e829a9b7cd8d1b514 (patch)
tree9b72ec57781776ab171438c19470ce54c8b9e0a4
parent629e6ab945da5afeed1fff9c203cd15f6634016f (diff)
FakeVim: Streamline settings handling a bit
Change-Id: I6ab2c1643a5236525515ded296cd854933584603 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
-rw-r--r--src/plugins/fakevim/fakevimactions.cpp10
-rw-r--r--src/plugins/fakevim/fakevimactions.h8
-rw-r--r--src/plugins/fakevim/fakevimhandler.cpp84
-rw-r--r--src/plugins/fakevim/fakevimplugin.cpp50
4 files changed, 66 insertions, 86 deletions
diff --git a/src/plugins/fakevim/fakevimactions.cpp b/src/plugins/fakevim/fakevimactions.cpp
index b753939c05..916fea1609 100644
--- a/src/plugins/fakevim/fakevimactions.cpp
+++ b/src/plugins/fakevim/fakevimactions.cpp
@@ -25,8 +25,7 @@
using namespace Utils;
-namespace FakeVim {
-namespace Internal {
+namespace FakeVim::Internal {
#ifdef FAKEVIM_STANDALONE
FvBaseAspect::FvBaseAspect()
@@ -72,9 +71,9 @@ void setAutoApply(bool ) {}
static FakeVimSettings *s_settings;
-FakeVimSettings *fakeVimSettings()
+FakeVimSettings &settings()
{
- return s_settings;
+ return *s_settings;
}
FakeVimSettings::FakeVimSettings()
@@ -327,5 +326,4 @@ void FakeVimSettings::setup(FvBaseAspect *aspect,
m_nameToAspect[shortName] = aspect;
}
-} // namespace Internal
-} // namespace FakeVim
+} // FakeVim::Internal
diff --git a/src/plugins/fakevim/fakevimactions.h b/src/plugins/fakevim/fakevimactions.h
index 2f3f72f695..e3b14b0d47 100644
--- a/src/plugins/fakevim/fakevimactions.h
+++ b/src/plugins/fakevim/fakevimactions.h
@@ -13,8 +13,7 @@
#include <QString>
#include <QVariant>
-namespace FakeVim {
-namespace Internal {
+namespace FakeVim::Internal {
#ifdef FAKEVIM_STANDALONE
class FvBaseAspect
@@ -145,7 +144,6 @@ private:
QHash<FvBaseAspect *, QString> m_aspectToName;
};
-FakeVimSettings *fakeVimSettings();
+FakeVimSettings &settings();
-} // namespace Internal
-} // namespace FakeVim
+} // FakeVim::Internal
diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp
index 2eb052432c..edfa315af9 100644
--- a/src/plugins/fakevim/fakevimhandler.cpp
+++ b/src/plugins/fakevim/fakevimhandler.cpp
@@ -408,9 +408,8 @@ static QRegularExpression vimPatternToQtPattern(const QString &needle)
*/
// FIXME: Option smartcase should be used only if search was typed by user.
- const bool ignoreCaseOption = fakeVimSettings()->ignoreCase.value();
- const bool smartCaseOption = fakeVimSettings()->smartCase.value();
- const bool initialIgnoreCase = ignoreCaseOption
+ const bool smartCaseOption = settings().smartCase();
+ const bool initialIgnoreCase = settings().ignoreCase()
&& !(smartCaseOption && needle.contains(QRegularExpression("[A-Z]")));
bool ignorecase = initialIgnoreCase;
@@ -2373,7 +2372,7 @@ public:
QString surroundFunction; // Used for storing the function name provided to ys{motion}f
} g;
- FakeVimSettings &s = *fakeVimSettings();
+ FakeVimSettings &s = settings();
};
static void initSingleShotTimer(QTimer *timer,
@@ -2527,7 +2526,7 @@ void FakeVimHandler::Private::leaveFakeVim(bool needUpdate)
// The command might have destroyed the editor.
if (m_textedit || m_plaintextedit) {
- if (s.showMarks.value())
+ if (s.showMarks())
updateSelection();
updateMiniBuffer();
@@ -2576,7 +2575,7 @@ bool FakeVimHandler::Private::wantsOverride(QKeyEvent *ev)
// We are interested in overriding most Ctrl key combinations.
if (isOnlyControlModifier(mods)
- && !s.passControlKey.value()
+ && !s.passControlKey()
&& ((key >= Key_A && key <= Key_Z && key != Key_K)
|| key == Key_BracketLeft || key == Key_BracketRight)) {
// Ctrl-K is special as it is the Core's default notion of Locator
@@ -3059,7 +3058,7 @@ void FakeVimHandler::Private::stopIncrementalFind()
void FakeVimHandler::Private::updateFind(bool isComplete)
{
- if (!isComplete && !s.incSearch.value())
+ if (!isComplete && !s.incSearch())
return;
g.currentMessage.clear();
@@ -3161,7 +3160,7 @@ void FakeVimHandler::Private::pushUndoState(bool overwrite)
pos = firstPositionInLine(lineForPosition(pos));
else if (isVisualBlockMode())
pos = blockAt(pos).position() + qMin(columnAt(anchor()), columnAt(position()));
- } else if (g.movetype == MoveLineWise && s.startOfLine.value()) {
+ } else if (g.movetype == MoveLineWise && s.startOfLine()) {
QTextCursor tc = m_cursor;
if (g.submode == ShiftLeftSubMode || g.submode == ShiftRightSubMode
|| g.submode == IndentSubMode) {
@@ -3621,7 +3620,7 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommandMovement)
return;
} else if (g.submode == ExchangeSubMode) {
exchangeRange(currentRange());
- } else if (g.submode == ReplaceWithRegisterSubMode && s.emulateReplaceWithRegister.value()) {
+ } else if (g.submode == ReplaceWithRegisterSubMode && s.emulateReplaceWithRegister()) {
pushUndoState(false);
beginEditBlock();
replaceWithRegister(currentRange());
@@ -3734,7 +3733,7 @@ void FakeVimHandler::Private::clearCurrentMode()
void FakeVimHandler::Private::updateSelection()
{
QList<QTextEdit::ExtraSelection> selections = m_extraSelections;
- if (s.showMarks.value()) {
+ if (s.showMarks()) {
for (auto it = m_buffer->marks.cbegin(), end = m_buffer->marks.cend(); it != end; ++it) {
QTextEdit::ExtraSelection sel;
sel.cursor = m_cursor;
@@ -3753,7 +3752,7 @@ void FakeVimHandler::Private::updateSelection()
void FakeVimHandler::Private::updateHighlights()
{
- if (s.useCoreSearch.value() || !s.hlSearch.value() || g.highlightsCleared) {
+ if (s.useCoreSearch() || !s.hlSearch() || g.highlightsCleared) {
if (m_highlighted.isEmpty())
return;
m_highlighted.clear();
@@ -3800,7 +3799,7 @@ void FakeVimHandler::Private::updateMiniBuffer()
} else if (!g.mapStates.isEmpty() && !g.mapStates.last().silent) {
// Do not reset previous message when after running a mapped command.
return;
- } else if (g.mode == CommandMode && !g.currentCommand.isEmpty() && s.showCmd.value()) {
+ } else if (g.mode == CommandMode && !g.currentCommand.isEmpty() && s.showCmd()) {
msg = g.currentCommand;
messageLevel = MessageShowCmd;
} else if (g.mode == CommandMode && isVisualMode()) {
@@ -3907,7 +3906,7 @@ bool FakeVimHandler::Private::handleCommandSubSubMode(const Input &input)
handled = selectBlockTextObject(g.subsubdata.is('i'), '{', '}');
else if (input.is('"') || input.is('\'') || input.is('`'))
handled = selectQuotedStringTextObject(g.subsubdata.is('i'), input.asChar());
- else if (input.is('a') && s.emulateArgTextObj.value())
+ else if (input.is('a') && s.emulateArgTextObj())
handled = selectArgumentTextObject(g.subsubdata.is('i'));
else
handled = false;
@@ -4050,7 +4049,7 @@ bool FakeVimHandler::Private::handleMovement(const Input &input)
g.subsubmode = NoSubSubMode;
} else if (input.is('/') || input.is('?')) {
g.lastSearchForward = input.is('/');
- if (s.useCoreSearch.value()) {
+ if (s.useCoreSearch()) {
// re-use the core dialog.
g.findPending = true;
m_findStartPosition = position();
@@ -4225,7 +4224,7 @@ bool FakeVimHandler::Private::handleMovement(const Input &input)
m_cursor = EDITOR(cursorForPosition(QPoint(0, EDITOR(height()) / 2)));
handleStartOfLine();
} else if (input.is('n') || input.is('N')) {
- if (s.useCoreSearch.value()) {
+ if (s.useCoreSearch()) {
bool forward = (input.is('n')) ? g.lastSearchForward : !g.lastSearchForward;
int pos = position();
q->findNextRequested(!forward);
@@ -4314,7 +4313,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(const Input &input)
handled = handleNoSubMode(input);
} else if (g.submode == ExchangeSubMode) {
handled = handleExchangeSubMode(input);
- } else if (g.submode == ChangeSubMode && input.is('x') && s.emulateExchange.value()) {
+ } else if (g.submode == ChangeSubMode && input.is('x') && s.emulateExchange()) {
// Exchange submode is "cx", so we need to switch over from ChangeSubMode here
g.submode = ExchangeSubMode;
handled = true;
@@ -4324,15 +4323,15 @@ EventResult FakeVimHandler::Private::handleCommandMode(const Input &input)
} else if (g.submode == AddSurroundingSubMode) {
handled = handleAddSurroundingSubMode(input);
} else if (g.submode == ChangeSubMode && (input.is('s') || input.is('S'))
- && s.emulateSurround.value()) {
+ && s.emulateSurround()) {
g.submode = ChangeSurroundingSubMode;
g.surroundUpperCaseS = input.is('S');
handled = true;
- } else if (g.submode == DeleteSubMode && input.is('s') && s.emulateSurround.value()) {
+ } else if (g.submode == DeleteSubMode && input.is('s') && s.emulateSurround()) {
g.submode = DeleteSurroundingSubMode;
handled = true;
} else if (g.submode == YankSubMode && (input.is('s') || input.is('S'))
- && s.emulateSurround.value()) {
+ && s.emulateSurround()) {
g.submode = AddSurroundingSubMode;
g.movetype = MoveInclusive;
g.surroundUpperCaseS = input.is('S');
@@ -4341,10 +4340,9 @@ EventResult FakeVimHandler::Private::handleCommandMode(const Input &input)
|| g.submode == DeleteSubMode
|| g.submode == YankSubMode) {
handled = handleChangeDeleteYankSubModes(input);
- } else if (g.submode == CommentSubMode && s.emulateVimCommentary.value()) {
+ } else if (g.submode == CommentSubMode && s.emulateVimCommentary()) {
handled = handleCommentSubMode(input);
- } else if (g.submode == ReplaceWithRegisterSubMode
- && s.emulateReplaceWithRegister.value()) {
+ } else if (g.submode == ReplaceWithRegisterSubMode && s.emulateReplaceWithRegister()) {
handled = handleReplaceWithRegisterSubMode(input);
} else if (g.submode == ReplaceSubMode) {
handled = handleReplaceSubMode(input);
@@ -4487,7 +4485,7 @@ bool FakeVimHandler::Private::handleNoSubMode(const Input &input)
setTargetColumn();
} else if (input.isControl('a')) {
changeNumberTextObject(count());
- } else if (g.gflag && input.is('c') && s.emulateVimCommentary.value()) {
+ } else if (g.gflag && input.is('c') && s.emulateVimCommentary()) {
if (isVisualMode()) {
pushUndoState();
@@ -4512,7 +4510,7 @@ bool FakeVimHandler::Private::handleNoSubMode(const Input &input)
pushUndoState();
setAnchor();
}
- } else if (g.gflag && input.is('r') && s.emulateReplaceWithRegister.value()) {
+ } else if (g.gflag && input.is('r') && s.emulateReplaceWithRegister()) {
g.submode = ReplaceWithRegisterSubMode;
if (isVisualMode()) {
dotCommand = visualDotCommand() + QString::number(count()) + "gr";
@@ -4671,7 +4669,7 @@ bool FakeVimHandler::Private::handleNoSubMode(const Input &input)
int repeat = count();
while (--repeat >= 0)
redo();
- } else if (input.is('S') && isVisualMode() && s.emulateSurround.value()) {
+ } else if (input.is('S') && isVisualMode() && s.emulateSurround()) {
g.submode = AddSurroundingSubMode;
g.subsubmode = SurroundSubSubMode;
} else if (input.is('s')) {
@@ -4756,7 +4754,7 @@ bool FakeVimHandler::Private::handleNoSubMode(const Input &input)
if (isVisualMode()) {
leaveVisualMode();
finishMovement();
- } else if (g.gflag || (g.submode == InvertCaseSubMode && s.tildeOp.value())) {
+ } else if (g.gflag || (g.submode == InvertCaseSubMode && s.tildeOp())) {
if (atEndOfLine())
moveLeft();
setAnchor();
@@ -5404,8 +5402,8 @@ void FakeVimHandler::Private::handleInsertMode(const Input &input)
if (!handleInsertInEditor(Input(Qt::Key_Backspace, Qt::NoModifier))) {
joinPreviousEditBlock();
if (!m_buffer->lastInsertion.isEmpty()
- || s.backspace.value().contains("start")
- || s.backspace.value().contains("2")) {
+ || s.backspace().contains("start")
+ || s.backspace().contains("2")) {
const int line = cursorLine() + 1;
const Column col = cursorColumn();
QString data = lineContents(line);
@@ -5438,7 +5436,7 @@ void FakeVimHandler::Private::handleInsertMode(const Input &input)
} else if (input.isKey(Key_Tab)) {
if (q->tabPressedInInsertMode()) {
m_buffer->insertState.insertingSpaces = true;
- if (s.expandTab.value()) {
+ if (s.expandTab()) {
const int ts = s.tabStop();
const int col = logicalCursorColumn();
QString str = QString(ts - col % ts, ' ');
@@ -5494,7 +5492,7 @@ void FakeVimHandler::Private::insertInInsertMode(const QString &text)
{
joinPreviousEditBlock();
insertText(text);
- if (s.smartIndent.value() && isElectricCharacter(text.at(0))) {
+ if (s.smartIndent() && isElectricCharacter(text.at(0))) {
const QString leftText = block().text()
.left(position() - 1 - block().position());
if (leftText.simplified().isEmpty()) {
@@ -6265,7 +6263,7 @@ bool FakeVimHandler::Private::handleExMoveCommand(const ExCommand &cmd)
if (!insertAtEnd)
moveUp(1);
- if (s.startOfLine.value())
+ if (s.startOfLine())
moveToFirstNonBlankOnLine();
if (lastAnchor.line >= startLine && lastAnchor.line <= endLine)
@@ -6794,7 +6792,7 @@ QTextCursor FakeVimHandler::Private::search(const SearchData &sd, int startPos,
}
if (tc.isNull()) {
- if (s.wrapScan.value()) {
+ if (s.wrapScan()) {
tc = QTextCursor(document());
tc.movePosition(sd.forward ? StartOfDocument : EndOfDocument);
if (sd.forward)
@@ -6954,7 +6952,7 @@ void FakeVimHandler::Private::shiftRegionRight(int repeat)
std::swap(beginLine, endLine);
targetPos = position();
}
- if (s.startOfLine.value())
+ if (s.startOfLine())
targetPos = firstPositionInLine(beginLine);
const int sw = s.shiftWidth();
@@ -7106,7 +7104,7 @@ void FakeVimHandler::Private::setupCharClass()
const QChar c = QLatin1Char(i);
m_charClass[i] = c.isSpace() ? 0 : 1;
}
- const QString conf = s.isKeyword.value();
+ const QString conf = s.isKeyword();
for (const QString &part : conf.split(',')) {
if (part.contains('-')) {
const int from = someInt(part.section('-', 0, 0));
@@ -7594,7 +7592,7 @@ void FakeVimHandler::Private::transformText(const Range &range, const Transforma
void FakeVimHandler::Private::insertText(QTextCursor &tc, const QString &text)
{
- if (s.passKeys.value()) {
+ if (s.passKeys()) {
if (tc.hasSelection() && text.isEmpty()) {
QKeyEvent event(QEvent::KeyPress, Qt::Key_Delete, Qt::NoModifier, QString());
passEventToEditor(event, tc);
@@ -7937,7 +7935,7 @@ void FakeVimHandler::Private::joinLines(int count, bool preserveSpace)
moveRight();
// If the line we started from is a comment, remove the comment string from the next line
- if (startingLineIsComment && s.formatOptions.value().contains('f')) {
+ if (startingLineIsComment && s.formatOptions().contains('f')) {
if (characterAtCursor() == '/' && characterAt(position() + 1) == '/')
moveRight(2);
else if (characterAtCursor() == '*' || characterAtCursor() == '#')
@@ -7955,7 +7953,7 @@ void FakeVimHandler::Private::joinLines(int count, bool preserveSpace)
void FakeVimHandler::Private::insertNewLine()
{
- if (m_buffer->editBlockLevel <= 1 && s.passKeys.value()) {
+ if (m_buffer->editBlockLevel <= 1 && s.passKeys()) {
QKeyEvent event(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "\n");
if (passEventToEditor(event, m_cursor))
return;
@@ -7967,7 +7965,7 @@ void FakeVimHandler::Private::insertNewLine()
bool FakeVimHandler::Private::handleInsertInEditor(const Input &input)
{
- if (m_buffer->editBlockLevel > 0 || !s.passKeys.value())
+ if (m_buffer->editBlockLevel > 0 || !s.passKeys())
return false;
joinPreviousEditBlock();
@@ -8712,10 +8710,10 @@ QString FakeVimHandler::Private::tabExpand(int n) const
void FakeVimHandler::Private::insertAutomaticIndentation(bool goingDown, bool forceAutoIndent)
{
- if (!forceAutoIndent && !s.autoIndent.value() && !s.smartIndent.value())
+ if (!forceAutoIndent && !s.autoIndent() && !s.smartIndent())
return;
- if (s.smartIndent.value()) {
+ if (s.smartIndent()) {
QTextBlock bl = block();
Range range(bl.position(), bl.position());
indentText(range, '\n');
@@ -8734,7 +8732,7 @@ void FakeVimHandler::Private::insertAutomaticIndentation(bool goingDown, bool fo
void FakeVimHandler::Private::handleStartOfLine()
{
- if (s.startOfLine.value())
+ if (s.startOfLine())
moveToFirstNonBlankOnLine();
}
@@ -9331,7 +9329,7 @@ void FakeVimHandler::Private::getRegisterType(int *reg, bool *isClipboard, bool
*reg = c.toLower().unicode();
if (c == '"') {
- QStringList list = s.clipboard.value().split(',');
+ QStringList list = s.clipboard().split(',');
clipboard = list.contains("unnamedplus");
selection = list.contains("unnamed");
} else if (c == '+') {
@@ -9385,7 +9383,7 @@ void FakeVimHandler::updateGlobalMarksFilenames(const QString &oldFileName, cons
bool FakeVimHandler::eventFilter(QObject *ob, QEvent *ev)
{
#ifndef FAKEVIM_STANDALONE
- if (!fakeVimSettings()->useFakeVim.value())
+ if (!settings().useFakeVim())
return QObject::eventFilter(ob, ev);
#endif
diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp
index c0e908ed57..54ae4ca93f 100644
--- a/src/plugins/fakevim/fakevimplugin.cpp
+++ b/src/plugins/fakevim/fakevimplugin.cpp
@@ -379,7 +379,6 @@ public:
int cursorPos, int anchorPos, int messageLevel);
void handleExCommand(FakeVimHandler *handler, bool *handled, const ExCommand &cmd);
- void writeSettings();
void readSettings();
void handleDelayedQuitAll(bool forced);
@@ -1051,7 +1050,7 @@ void FakeVimPluginPrivate::initialize()
Command *cmd = nullptr;
- cmd = ActionManager::registerAction(fakeVimSettings()->useFakeVim.action(),
+ cmd = ActionManager::registerAction(settings().useFakeVim.action(),
INSTALL_HANDLER, Context(Core::Constants::C_GLOBAL), true);
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? Tr::tr("Meta+Shift+Y,Meta+Shift+Y")
: Tr::tr("Alt+Y,Alt+Y")));
@@ -1089,7 +1088,7 @@ void FakeVimPluginPrivate::initialize()
connect(DocumentManager::instance(), &DocumentManager::documentRenamed,
this, &FakeVimPluginPrivate::documentRenamed);
- FakeVimSettings &s = *fakeVimSettings();
+ FakeVimSettings &s = settings();
connect(&s.useFakeVim, &FvBoolAspect::valueChanged,
this, &FakeVimPluginPrivate::setUseFakeVim);
connect(&s.readVimRc, &FvBaseAspect::changed,
@@ -1107,7 +1106,7 @@ void FakeVimPluginPrivate::initialize()
connect(this, &FakeVimPluginPrivate::delayedQuitAllRequested,
this, &FakeVimPluginPrivate::handleDelayedQuitAll, Qt::QueuedConnection);
- setCursorBlinking(s.blinkingCursor.value());
+ setCursorBlinking(s.blinkingCursor());
}
void FakeVimPluginPrivate::userActionTriggered(int key)
@@ -1116,7 +1115,7 @@ void FakeVimPluginPrivate::userActionTriggered(int key)
FakeVimHandler *handler = m_editorToHandler[editor].handler;
if (handler) {
// If disabled, enable FakeVim mode just for single user command.
- bool enableFakeVim = !fakeVimSettings()->useFakeVim.value();
+ bool enableFakeVim = !settings().useFakeVim();
if (enableFakeVim)
setUseFakeVimInternal(true);
@@ -1142,26 +1141,18 @@ void FakeVimPluginPrivate::createRelativeNumberWidget(IEditor *editor)
{
if (auto textEditor = TextEditorWidget::fromEditor(editor)) {
auto relativeNumbers = new RelativeNumbersColumn(textEditor);
- connect(&fakeVimSettings()->relativeNumber, &FvBaseAspect::changed,
+ connect(&settings().relativeNumber, &FvBaseAspect::changed,
relativeNumbers, &QObject::deleteLater);
- connect(&fakeVimSettings()->useFakeVim, &FvBaseAspect::changed,
+ connect(&settings().useFakeVim, &FvBaseAspect::changed,
relativeNumbers, &QObject::deleteLater);
relativeNumbers->show();
}
}
-void FakeVimPluginPrivate::writeSettings()
-{
- QSettings *settings = ICore::settings();
- fakeVimSettings()->writeSettings(settings);
-}
-
void FakeVimPluginPrivate::readSettings()
{
QSettings *settings = ICore::settings();
- fakeVimSettings()->readSettings(settings);
-
m_exCommandMap = m_defaultExCommandMap;
int size = settings->beginReadArray(exCommandMapGroup);
for (int i = 0; i < size; ++i) {
@@ -1190,9 +1181,9 @@ void FakeVimPluginPrivate::maybeReadVimRc()
//qDebug() << theFakeVimSetting(ConfigReadVimRc)
// << theFakeVimSetting(ConfigReadVimRc)->value();
//qDebug() << theFakeVimSetting(ConfigShiftWidth)->value();
- if (!fakeVimSettings()->readVimRc.value())
+ if (!settings().readVimRc())
return;
- QString fileName = fakeVimSettings()->vimRcPath.value();
+ QString fileName = settings().vimRcPath();
if (fileName.isEmpty()) {
fileName = QStandardPaths::writableLocation(QStandardPaths::HomeLocation)
+ QLatin1String(HostOsInfo::isWindowsHost() ? "/_vimrc" : "/.vimrc");
@@ -1202,7 +1193,6 @@ void FakeVimPluginPrivate::maybeReadVimRc()
QPlainTextEdit editor;
FakeVimHandler handler(&editor);
handler.handleCommand("source " + fileName);
- //writeSettings();
//qDebug() << theFakeVimSetting(ConfigShiftWidth)->value();
}
@@ -1531,9 +1521,9 @@ void FakeVimPluginPrivate::editorOpened(IEditor *editor)
return;
TabSettings tabSettings;
- tabSettings.m_indentSize = fakeVimSettings()->shiftWidth();
- tabSettings.m_tabSize = fakeVimSettings()->tabStop();
- tabSettings.m_tabPolicy = fakeVimSettings()->expandTab()
+ tabSettings.m_indentSize = settings().shiftWidth();
+ tabSettings.m_tabSize = settings().tabStop();
+ tabSettings.m_tabPolicy = settings().expandTab()
? TabSettings::SpacesOnlyTabPolicy : TabSettings::TabsOnlyTabPolicy;
tabSettings.m_continuationAlignBehavior =
tew->textDocument()->tabSettings().m_continuationAlignBehavior;
@@ -1757,19 +1747,15 @@ void FakeVimPluginPrivate::editorOpened(IEditor *editor)
*output = proc.cleanedStdOut();
});
- connect(ICore::instance(), &ICore::saveSettingsRequested,
- this, &FakeVimPluginPrivate::writeSettings);
-
-
handler->setCurrentFileName(editor->document()->filePath().toString());
handler->installEventFilter();
// pop up the bar
- if (fakeVimSettings()->useFakeVim.value()) {
+ if (settings().useFakeVim()) {
resetCommandBuffer();
handler->setupWidget();
- if (fakeVimSettings()->relativeNumber.value())
+ if (settings().relativeNumber())
createRelativeNumberWidget(editor);
}
}
@@ -1811,8 +1797,8 @@ void FakeVimPluginPrivate::setUseFakeVim(bool on)
//qDebug() << "SET USE FAKEVIM" << on;
Find::setUseFakeVim(on);
setUseFakeVimInternal(on);
- setShowRelativeLineNumbers(fakeVimSettings()->relativeNumber.value());
- setCursorBlinking(fakeVimSettings()->blinkingCursor.value());
+ setShowRelativeLineNumbers(settings().relativeNumber());
+ setCursorBlinking(settings().blinkingCursor());
}
void FakeVimPluginPrivate::setUseFakeVimInternal(bool on)
@@ -1840,7 +1826,7 @@ void FakeVimPluginPrivate::setUseFakeVimInternal(bool on)
void FakeVimPluginPrivate::setShowRelativeLineNumbers(bool on)
{
- if (on && fakeVimSettings()->useFakeVim.value()) {
+ if (on && settings().useFakeVim()) {
for (auto it = m_editorToHandler.constBegin(); it != m_editorToHandler.constEnd(); ++it)
createRelativeNumberWidget(it.key());
}
@@ -1851,7 +1837,7 @@ void FakeVimPluginPrivate::setCursorBlinking(bool on)
if (m_savedCursorFlashTime == 0)
m_savedCursorFlashTime = QGuiApplication::styleHints()->cursorFlashTime();
- const bool blink = on || !fakeVimSettings()->useFakeVim.value();
+ const bool blink = on || !settings().useFakeVim();
QGuiApplication::styleHints()->setCursorFlashTime(blink ? m_savedCursorFlashTime : 0);
}
@@ -1995,7 +1981,7 @@ void FakeVimPluginPrivate::handleDelayedQuitAll(bool forced)
void FakeVimPluginPrivate::quitFakeVim()
{
- fakeVimSettings()->useFakeVim.setValue(false);
+ settings().useFakeVim.setValue(false);
}
void FakeVimPluginPrivate::resetCommandBuffer()