Commit 70aa0002 authored by hluk's avatar hluk Committed by hjk
Browse files

FakeVim: Macros with <S-left> and other key combinations



Change-Id: Ie1cc1b290cae271098dd4e82d3ae285ac7013562
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 5217539a
......@@ -2925,4 +2925,16 @@ void FakeVimPlugin::test_macros()
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("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());
}
bool isControl() const
{
return m_modifiers & HostOsInfo::controlModifier();
}
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);
}
bool isShift() const
{
return m_modifiers & Qt::ShiftModifier;
}
bool isShift(int c) const
{
return m_modifiers == Qt::ShiftModifier && m_xkey == c;
return isShift() && m_xkey == c;
}
bool operator<(const Input &a) const
......@@ -953,13 +963,23 @@ public:
QString toString() const
{
bool hasCtrl = m_modifiers & int(HostOsInfo::controlModifier());
QString key = vimKeyNames().key(m_key);
if (key.isEmpty())
key = QChar(m_xkey);
else
key = QLatin1Char('<') + key + QLatin1Char('>');
return (hasCtrl ? QString::fromLatin1("^") : QString()) + key;
if (key.isEmpty()) {
if (m_xkey == '<')
key = _("<LT>");
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
......@@ -4538,7 +4558,7 @@ bool FakeVimHandler::Private::startRecording(const Input &input)
void FakeVimHandler::Private::record(const Input &input)
{
if ( !g.recording.isNull() )
g.recording.append(input.raw());
g.recording.append(input.toString());
}
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
// used when a mapping is active.
// According to Vim, register is executed like mapping.
prependMapping(Inputs(registerContents(reg)));
prependMapping(Inputs(registerContents(reg), false, false));
return true;
}
......
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