Skip to content

Commit

Permalink
Support forwarded UI options
Browse files Browse the repository at this point in the history
nvim 0.2.3 will start forwarding UI configuration options as redraw
events. This adds support for

- guifont
- linespace

and ignores the following

- guifontset
- guifontwide

a quick note about 'guifont' is that the options requires escaping
spaces e.g.

    :set guifont=DejaVu\ Sans\ Mono:h24

where the shim command did not.
  • Loading branch information
Rui Abreu Ferreira authored and equalsraf committed Jan 21, 2018
1 parent 6bf8e2e commit 2f86ab3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/gui/shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,10 @@ void Shell::handleRedraw(const QByteArray& name, const QVariantList& opargs)
}

emit neovimTablineUpdate(curtab, tabs);
} else if (name == "option_set") {
if (2 <= opargs.size()) {
handleSetOption(opargs.at(0).toString(), opargs.at(1));
}
} else {
qDebug() << "Received unknown redraw notification" << name << opargs;
}
Expand Down Expand Up @@ -582,6 +586,21 @@ void Shell::handleNeovimNotification(const QByteArray &name, const QVariantList&
}
}

void Shell::handleSetOption(const QString& name, const QVariant& value)
{
if (name == "guifont") {
setGuiFont(value.toString());
} else if (name == "guifontset") {
} else if (name == "guifontwide") {
} else if (name == "linespace") {
// The conversion to string and then to int happens because of http://doc.qt.io/qt-5/qvariant.html#toUInt
// toUint() fails to detect an overflow i.e. it converts to ulonglong and then returns a MAX UINT
setLineSpace(value.toString().toInt());
} else {
qDebug() << "Received unknown option" << name << value;
}
}

void Shell::paintEvent(QPaintEvent *ev)
{
if (!m_attached) {
Expand Down
1 change: 1 addition & 0 deletions src/gui/shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ protected slots:
virtual void handleSetTitle(const QVariantList& opargs);
virtual void handleSetScrollRegion(const QVariantList& opargs);
virtual void handleBusy(bool);
virtual void handleSetOption(const QString& name, const QVariant& value);

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

0 comments on commit 2f86ab3

Please sign in to comment.