Commit 6c85e5ec authored by hjk's avatar hjk

fakevim: let the "IncSearch" option toggle between using the Creator

core Find dialog and the "old" minibuffer based search.

A hot fix for the recent regression that 'n' and 'N' do not work and
the positioning of the cursor after the search is wrong.
parent 4350baee
......@@ -160,6 +160,12 @@ FakeVimSettings *theFakeVimSettings()
item->setCheckable(true);
instance->insertItem(ConfigAutoIndent, item, QLatin1String("autoindent"), QLatin1String("ai"));
item = new SavedAction(instance);
item->setDefaultValue(true);
item->setSettingsKey(group, QLatin1String("IncSearch"));
item->setCheckable(true);
instance->insertItem(ConfigIncSearch, item, QLatin1String("incsearch"), QLatin1String("is"));
item = new SavedAction(instance);
item->setDefaultValue(QLatin1String("indent,eol,start"));
item->setSettingsKey(group, QLatin1String("Backspace"));
......
......@@ -49,6 +49,7 @@ enum FakeVimSettingsCode
ConfigShiftWidth,
ConfigExpandTab,
ConfigAutoIndent,
ConfigIncSearch,
// indent allow backspacing over autoindent
// eol allow backspacing over line breaks (join lines)
......
......@@ -1018,7 +1018,19 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
m_commandHistoryIndex = m_commandHistory.size() - 1;
updateMiniBuffer();
} else if (key == '/' || key == '?') {
emit q->findRequested(key == '?');
if (hasConfig(ConfigIncSearch)) {
// re-use the core dialog.
emit q->findRequested(key == '?');
} else {
// FIXME: make core find dialog sufficiently flexible to
// produce the "default vi" behaviour too. For now, roll our own.
enterExMode(); // to get the cursor disabled
m_mode = (key == '/') ? SearchForwardMode : SearchBackwardMode;
m_commandBuffer.clear();
m_searchHistory.append(QString());
m_searchHistoryIndex = m_searchHistory.size() - 1;
updateMiniBuffer();
}
} else if (key == '`') {
m_subsubmode = BackTickSubSubMode;
} else if (key == '#' || key == '*') {
......@@ -1290,11 +1302,17 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
m_tc = EDITOR(cursorForPosition(QPoint(0, EDITOR(height()) / 2)));
handleStartOfLine();
finishMovement();
} else if (key == 'n') {
emit q->findNextRequested(false);
} else if (key == 'n') { // FIXME: see comment for '/'
if (hasConfig(ConfigIncSearch))
emit q->findNextRequested(false);
else
search(lastSearchString(), m_lastSearchForward);
recordJump();
} else if (key == 'N') {
emit q->findNextRequested(true);
if (hasConfig(ConfigIncSearch))
emit q->findNextRequested(true);
else
search(lastSearchString(), !m_lastSearchForward);
recordJump();
} else if (key == 'o' || key == 'O') {
setDotCommand("%1o", count());
......
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>358</width>
<width>394</width>
<height>322</height>
</rect>
</property>
......@@ -55,45 +55,45 @@
</property>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="labelShiftWidth">
<property name="text">
<string>Shift width:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<widget class="QLineEdit" name="lineEditShiftWidth"/>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="labelSmartTab">
<property name="text">
<string>Smart tabulators:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QCheckBox" name="checkBoxSmartTab">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="6" column="0">
<item row="7" column="0">
<widget class="QLabel" name="labelStartOfLine">
<property name="text">
<string>Start of line:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<item row="7" column="1">
<widget class="QCheckBox" name="checkBoxStartOfLine">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="QLabel" name="label_2">
<property name="toolTip">
<string>vim's &quot;tabstop&quot; option</string>
......@@ -103,17 +103,17 @@
</property>
</widget>
</item>
<item row="7" column="1">
<item row="8" column="1">
<widget class="QLineEdit" name="lineEditTabStop"/>
</item>
<item row="8" column="0">
<item row="9" column="0">
<widget class="QLabel" name="labelBackspace">
<property name="text">
<string>Backspace:</string>
</property>
</widget>
</item>
<item row="8" column="1">
<item row="9" column="1">
<widget class="QLineEdit" name="lineEditBackspace"/>
</item>
<item row="0" column="1">
......@@ -133,6 +133,20 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="labelIncSearch">
<property name="text">
<string>Incremental search:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="checkBoxIncSearch">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......
......@@ -158,6 +158,8 @@ QWidget *FakeVimOptionPage::createPage(QWidget *parent)
m_group.insert(theFakeVimSetting(ConfigAutoIndent),
m_ui.checkBoxAutoIndent);
m_group.insert(theFakeVimSetting(ConfigIncSearch),
m_ui.checkBoxIncSearch);
connect(m_ui.pushButtonCopyTextEditorSettings, SIGNAL(clicked()),
this, SLOT(copyTextEditorSettings()));
......@@ -179,6 +181,8 @@ void FakeVimOptionPage::copyTextEditorSettings()
m_ui.lineEditShiftWidth->setText(QString::number(ts.m_indentSize));
m_ui.checkBoxSmartTab->setChecked(ts.m_smartBackspace);
m_ui.checkBoxAutoIndent->setChecked(ts.m_autoIndent);
// FIXME: Not present in core
//m_ui.checkBoxIncSearch->setChecked(ts.m_incSearch);
}
void FakeVimOptionPage::setQtStyle()
......@@ -188,6 +192,7 @@ void FakeVimOptionPage::setQtStyle()
m_ui.lineEditShiftWidth->setText("4");
m_ui.checkBoxSmartTab->setChecked(true);
m_ui.checkBoxAutoIndent->setChecked(true);
m_ui.checkBoxIncSearch->setChecked(true);
m_ui.lineEditBackspace->setText("indent,eol,start");
}
......@@ -198,6 +203,7 @@ void FakeVimOptionPage::setPlainStyle()
m_ui.lineEditShiftWidth->setText("8");
m_ui.checkBoxSmartTab->setChecked(false);
m_ui.checkBoxAutoIndent->setChecked(false);
m_ui.checkBoxIncSearch->setChecked(false);
m_ui.lineEditBackspace->setText(QString());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment