Commit 05f0b60f authored by hjk's avatar hjk
Browse files

fakevim: fix split window

parent cd14b9f1
......@@ -125,15 +125,16 @@ enum Mode
enum SubMode
{
NoSubMode,
RegisterSubMode, // used for "
ChangeSubMode, // used for c
DeleteSubMode, // used for d
FilterSubMode, // used for !
IndentSubMode, // used for =
RegisterSubMode, // used for "
ReplaceSubMode, // used for R and r
YankSubMode, // used for y
ShiftLeftSubMode, // used for <
ShiftRightSubMode, // used for >
IndentSubMode, // used for =
WindowSubMode, // used for Ctrl-w
YankSubMode, // used for y
ZSubMode,
};
......@@ -809,7 +810,10 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
{
EventResult handled = EventHandled;
if (m_submode == RegisterSubMode) {
if (m_submode == WindowSubMode) {
emit q->windowCommandRequested(key);
m_submode = NoSubMode;
} else if (m_submode == RegisterSubMode) {
m_register = key;
m_submode = NoSubMode;
} else if (m_submode == ChangeSubMode && key == 'c') {
......@@ -1326,6 +1330,8 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
m_moveType = MoveExclusive;
}
finishMovement("W");
} else if (key == control('w')) {
m_submode = WindowSubMode;
} else if (key == 'x' && m_visualMode == NoVisualMode) { // = "dl"
m_moveType = MoveExclusive;
if (atEndOfLine())
......
......@@ -72,6 +72,7 @@ signals:
void moveToMatchingParenthesis(bool *moved, bool *forward, QTextCursor *cursor);
void indentRegion(int *amount, int beginLine, int endLine, QChar typedChar);
void completionRequested();
void windowCommandRequested(int key);
public:
class Private;
......
......@@ -231,6 +231,7 @@ private slots:
void setUseFakeVim(const QVariant &value);
void quitFakeVim();
void triggerCompletions();
void windowCommand(int key);
void showSettingsDialog();
void showCommandBuffer(const QString &contents);
......@@ -309,6 +310,46 @@ void FakeVimPluginPrivate::showSettingsDialog()
Core::ICore::instance()->showOptionsDialog("FakeVim", "General");
}
void FakeVimPluginPrivate::windowCommand(int key)
{
#define control(n) (256 + n)
QString code;
switch (key) {
case 'c': case 'C': case control('c'):
code = Core::Constants::CLOSE;
break;
case 'n': case 'N': case control('n'):
code = Core::Constants::GOTONEXT;
break;
case 'o': case 'O': case control('o'):
code = Core::Constants::REMOVE_ALL_SPLITS;
code = Core::Constants::REMOVE_CURRENT_SPLIT;
break;
case 'p': case 'P': case control('p'):
code = Core::Constants::GOTOPREV;
break;
case 's': case 'S': case control('s'):
code = Core::Constants::SPLIT;
break;
case 'w': case 'W': case control('w'):
code = Core::Constants::GOTO_OTHER_SPLIT;
break;
}
#undef control
qDebug() << "RUNNING WINDOW COMMAND: " << key << code;
if (code.isEmpty()) {
qDebug() << "UNKNOWN WINDOWS COMMAND: " << key;
return;
}
Core::ActionManager *am = Core::ICore::instance()->actionManager();
QTC_ASSERT(am, return);
Core::Command *cmd = am->command(code);
QTC_ASSERT(cmd, return);
QAction *action = cmd->action();
QTC_ASSERT(action, return);
action->trigger();
}
void FakeVimPluginPrivate::editorOpened(Core::IEditor *editor)
{
if (!editor)
......@@ -344,6 +385,8 @@ void FakeVimPluginPrivate::editorOpened(Core::IEditor *editor)
this, SLOT(indentRegion(int*,int,int,QChar)));
connect(handler, SIGNAL(completionRequested()),
this, SLOT(triggerCompletions()));
connect(handler, SIGNAL(windowCommandRequested(int)),
this, SLOT(windowCommand(int)));
handler->setCurrentFileName(editor->file()->fileName());
handler->installEventFilter();
......
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