Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - GUI: Implement external cmdline #351

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions src/gui/shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ void Shell::init()
if (m_options.enable_ext_popupmenu) {
options.insert("ext_popupmenu", true);
}
if (m_options.enable_ext_cmdline) {
options.insert("ext_cmdline", true);
}
options.insert("rgb", true);

MsgpackRequest *req;
Expand Down Expand Up @@ -498,6 +501,98 @@ void Shell::handleRedraw(const QByteArray& name, const QVariantList& opargs)
handlePopupMenuSelect(opargs.at(0).toLongLong());
} else if (name == "popupmenu_hide") {
m_pum.hide();
} else if (name == "cmdline_show") {
if (opargs.size() < 6) {
qWarning() << "Unexpected argument for cmdline_show:" << opargs;
return;
}

QVariantList content = opargs.at(0).toList();

if (!opargs.at(1).canConvert<int64_t>()) {
qWarning() << "Invalid type for cmdline_show pos:" << opargs.at(1);
return;
}
int64_t pos = opargs.at(1).toInt();

if (!opargs.at(2).canConvert<QString>()) {
qWarning() << "Invalid type for cmdline_show firstc:" << opargs.at(2);
return;
}
QString firstc = opargs.at(2).toString();

if (!opargs.at(3).canConvert<QString>()) {
qWarning() << "Invalid type for cmdline_show prompt:" << opargs.at(3);
return;
}
QString prompt = opargs.at(3).toString();

if (!opargs.at(4).canConvert<int64_t>()) {
qWarning() << "Invalid type for cmdline_show indent:" << opargs.at(4);
return;
}
int64_t indent = opargs.at(4).toInt();

if (!opargs.at(5).canConvert<int64_t>()) {
qWarning() << "Invalid type for cmdline_show level:" << opargs.at(5);
return;
}
int64_t level = opargs.at(5).toInt();

handleCmdlineShow(content, pos, firstc, prompt, indent, level);
} else if (name == "cmdline_pos") {
if (opargs.size() < 2 || !opargs.at(0).canConvert<int64_t>()
|| !opargs.at(1).canConvert<int64_t>()) {
qWarning() << "Unexpected argument for cmdline_pos:" << opargs;
return;
}
int64_t pos = opargs.at(0).toInt();
int64_t level = opargs.at(1).toInt();
qDebug() << name << pos << level;
} else if (name == "cmdline_special_char") {
if (opargs.size() < 3) {
qWarning() << "Unexpected argument for cmdline_special_char:" << opargs;
return;
}

if (!opargs.at(0).canConvert<QString>()) {
qWarning() << "Invalid type for cmdline_special_char c:" << opargs.at(0);
return;
}
QString c = opargs.at(0).toString();

if (!opargs.at(1).canConvert<bool>()) {
qWarning() << "Invalid type for cmdline_special_char shift:" << opargs.at(1);
return;
}
bool shift = opargs.at(1).toBool();

if (!opargs.at(2).canConvert<int64_t>()) {
qWarning() << "Invalid type for cmdline_special_char level:" << opargs.at(2);
return;
}
int64_t level = opargs.at(2).toInt();
qDebug() << name << c << shift << level;
} else if (name == "cmdline_hide") {
qDebug() << name;
//handleCmdlineHide();
} else if (name == "cmdline_block_show") {
if (opargs.size() < 1) {
qWarning() << "Unexpected argument for cmdline_block_show:" << opargs;
return;
}
// - lines
qDebug() << "cmdline_block_show" << opargs;
} else if (name == "cmdline_block_append") {
if (opargs.size() < 1) {
qWarning() << "Unexpected argument for cmdline_block_append:" << opargs;
return;
}
qDebug() << "cmdline_block_append" << opargs;
// - line
} else if (name == "cmdline_block_hide") {
qDebug() << name;
//handleCmdlineBlockHide();
} else {
qDebug() << "Received unknown redraw notification" << name << opargs;
}
Expand Down Expand Up @@ -1226,4 +1321,13 @@ void Shell::openFiles(QList<QUrl> urls)
}
}

void Shell::handleCmdlineShow(QVariantList content, int64_t pos, QString firstc,
QString prompt, int64_t indent, int64_t level)
{
foreach(QVariant piece, content) {
qDebug() << piece.toList();
}
qDebug() << prompt << firstc;
}

} // Namespace
4 changes: 4 additions & 0 deletions src/gui/shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ class ShellOptions {
ShellOptions() {
enable_ext_tabline = true;
enable_ext_popupmenu = true;
enable_ext_cmdline = true;
nvim_show_tabline = 1;
}
bool enable_ext_tabline;
int nvim_show_tabline;
bool enable_ext_popupmenu;
bool enable_ext_cmdline;
};

class Shell: public ShellWidget
Expand Down Expand Up @@ -128,6 +130,8 @@ protected slots:
virtual void handlePopupMenuShow(const QVariantList& items, int64_t selected,
int64_t row, int64_t col);
void handlePopupMenuSelect(int64_t selected);
virtual void handleCmdlineShow(QVariantList content, int64_t pos, QString firstc,
QString prompt, int64_t indent, int64_t level);

void neovimMouseEvent(QMouseEvent *ev);
virtual void mousePressEvent(QMouseEvent *ev) Q_DECL_OVERRIDE;
Expand Down