-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIXME Below description is not accurate anymore Adds a basic implementation of the external Neovim commandline. Utilizes basic Qt Widgets (QLineEdit, QTextEdit) to display a floating command prompt.
- Loading branch information
Showing
16 changed files
with
815 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
project(qcommandline) | ||
|
||
set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||
|
||
find_package(Qt5Widgets REQUIRED) | ||
|
||
|
||
if (WIN32 AND USE_STATIC_QT) | ||
add_definitions(-DUSE_STATIC_QT) | ||
endif () | ||
|
||
set(SOURCES | ||
blockdisplay.cpp | ||
extcmdlinewidget.cpp | ||
linemodel.cpp | ||
position.cpp | ||
) | ||
|
||
add_library(extcmdline STATIC ${SOURCES}) | ||
target_link_libraries(extcmdline Qt5::Widgets Qt5::Network) | ||
target_include_directories(extcmdline PUBLIC ../shellwidget) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "blockdisplay.h" | ||
|
||
#include <QList> | ||
#include <QDebug> | ||
#include <QStringList> | ||
|
||
namespace NeovimQt { namespace Cmdline { | ||
|
||
BlockDisplay::BlockDisplay() | ||
{ | ||
setVisible(false); | ||
setVerticalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAsNeeded); | ||
setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAlwaysOff); | ||
setReadOnly(true); | ||
setFocusPolicy(Qt::NoFocus); | ||
} | ||
|
||
QSize BlockDisplay::sizeHint() const | ||
{ | ||
QSize parentSizeHint = Super::sizeHint(); | ||
int padding = contentsMargins().top() + contentsMargins().bottom(); | ||
parentSizeHint.setHeight(document()->size().height() + padding); | ||
return parentSizeHint; | ||
} | ||
|
||
int BlockDisplay::GetMaxLineLength() const | ||
{ | ||
QStringList allLines = toPlainText().split('\n'); | ||
|
||
int maxChars = 0; | ||
for (const auto& line : allLines) { | ||
maxChars = qMax(line.size(), maxChars); | ||
} | ||
|
||
return maxChars; | ||
} | ||
|
||
} } // namespace NeovimQt::Cmdline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
|
||
#include <QTextEdit> | ||
|
||
namespace NeovimQt { namespace Cmdline { | ||
|
||
class BlockDisplay : public QTextEdit { | ||
using Super = QTextEdit; | ||
|
||
public: | ||
BlockDisplay(); | ||
|
||
virtual QSize sizeHint() const override; | ||
virtual int GetMaxLineLength() const; | ||
}; | ||
|
||
} } // namespace NeovimQt::Cmdline |
Oops, something went wrong.