forked from qt-creator/qt-creator
FakeVim: Macros with <S-left> and other key combinations
Change-Id: Ie1cc1b290cae271098dd4e82d3ae285ac7013562 Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -2925,4 +2925,16 @@ void FakeVimPlugin::test_macros()
|
|||||||
data.setText(" 1 2 3" N " 4 5 6" N " 7 8 9");
|
data.setText(" 1 2 3" N " 4 5 6" N " 7 8 9");
|
||||||
KEYS("qx" "wrXj" "q", " X 2 3" N " 4 5 6" N " 7 8 9");
|
KEYS("qx" "wrXj" "q", " X 2 3" N " 4 5 6" N " 7 8 9");
|
||||||
KEYS("2@x", " X 2 3" N " 4 X 6" N " 7 8 X");
|
KEYS("2@x", " X 2 3" N " 4 X 6" N " 7 8 X");
|
||||||
|
|
||||||
|
data.setText("abc" N "def");
|
||||||
|
KEYS("qx<right>i<right> xyz <esc>q", "ab xyz" X " c" N "def");
|
||||||
|
KEYS("j0@x", "ab xyz c" N "de xyz" X " f");
|
||||||
|
|
||||||
|
data.setText("abc" N "def");
|
||||||
|
data.doCommand("unmap <S-down>");
|
||||||
|
KEYS("qx<S-down><esc>q", X "abc" N "def");
|
||||||
|
data.doCommand("noremap <S-down> ddp");
|
||||||
|
KEYS("@x", "def" N X "abc");
|
||||||
|
KEYS("gg@x", "abc" N X "def");
|
||||||
|
data.doCommand("unmap <S-down>");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -901,15 +901,25 @@ public:
|
|||||||
return m_xkey == c && m_modifiers != int(HostOsInfo::controlModifier());
|
return m_xkey == c && m_modifiers != int(HostOsInfo::controlModifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isControl() const
|
||||||
|
{
|
||||||
|
return m_modifiers & HostOsInfo::controlModifier();
|
||||||
|
}
|
||||||
|
|
||||||
bool isControl(int c) const
|
bool isControl(int c) const
|
||||||
{
|
{
|
||||||
return m_modifiers == int(HostOsInfo::controlModifier())
|
return isControl()
|
||||||
&& (m_xkey == c || m_xkey + 32 == c || m_xkey + 64 == c || m_xkey + 96 == c);
|
&& (m_xkey == c || m_xkey + 32 == c || m_xkey + 64 == c || m_xkey + 96 == c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isShift() const
|
||||||
|
{
|
||||||
|
return m_modifiers & Qt::ShiftModifier;
|
||||||
|
}
|
||||||
|
|
||||||
bool isShift(int c) const
|
bool isShift(int c) const
|
||||||
{
|
{
|
||||||
return m_modifiers == Qt::ShiftModifier && m_xkey == c;
|
return isShift() && m_xkey == c;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator<(const Input &a) const
|
bool operator<(const Input &a) const
|
||||||
@@ -953,13 +963,23 @@ public:
|
|||||||
|
|
||||||
QString toString() const
|
QString toString() const
|
||||||
{
|
{
|
||||||
bool hasCtrl = m_modifiers & int(HostOsInfo::controlModifier());
|
|
||||||
QString key = vimKeyNames().key(m_key);
|
QString key = vimKeyNames().key(m_key);
|
||||||
if (key.isEmpty())
|
|
||||||
key = QChar(m_xkey);
|
if (key.isEmpty()) {
|
||||||
else
|
if (m_xkey == '<')
|
||||||
key = QLatin1Char('<') + key + QLatin1Char('>');
|
key = _("<LT>");
|
||||||
return (hasCtrl ? QString::fromLatin1("^") : QString()) + key;
|
else
|
||||||
|
key = QChar(m_xkey);
|
||||||
|
} else {
|
||||||
|
if (isShift())
|
||||||
|
key.prepend(_("S-"));
|
||||||
|
if (isControl())
|
||||||
|
key.prepend(_("C-"));
|
||||||
|
key.prepend(QLatin1Char('<'));
|
||||||
|
key.append(QLatin1Char('>'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDebug dump(QDebug ts) const
|
QDebug dump(QDebug ts) const
|
||||||
@@ -4538,7 +4558,7 @@ bool FakeVimHandler::Private::startRecording(const Input &input)
|
|||||||
void FakeVimHandler::Private::record(const Input &input)
|
void FakeVimHandler::Private::record(const Input &input)
|
||||||
{
|
{
|
||||||
if ( !g.recording.isNull() )
|
if ( !g.recording.isNull() )
|
||||||
g.recording.append(input.raw());
|
g.recording.append(input.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimHandler::Private::stopRecording()
|
void FakeVimHandler::Private::stopRecording()
|
||||||
@@ -4566,7 +4586,7 @@ bool FakeVimHandler::Private::executeRegister(int reg)
|
|||||||
// One solution may be to call QApplication::processEvents() and check if <C-c> was
|
// One solution may be to call QApplication::processEvents() and check if <C-c> was
|
||||||
// used when a mapping is active.
|
// used when a mapping is active.
|
||||||
// According to Vim, register is executed like mapping.
|
// According to Vim, register is executed like mapping.
|
||||||
prependMapping(Inputs(registerContents(reg)));
|
prependMapping(Inputs(registerContents(reg), false, false));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user