Skip to content

Commit 92862ca

Browse files
authored
fakevim update (#2166, #2134)
* Remove fakevim submodule * Update FakeVim
1 parent 920fc3b commit 92862ca

34 files changed

+12906
-47
lines changed

.gitmodules

-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
[submodule "src/libraries/qtcsv"]
1414
path = src/libraries/qtcsv
1515
url = https://github.com/pbek/qtcsv.git
16-
[submodule "src/libraries/fakevim"]
17-
path = src/libraries/fakevim
18-
url = https://github.com/pbek/FakeVim.git
1916
[submodule "src/libraries/md4c"]
2017
path = src/libraries/md4c
2118
url = https://github.com/qownnotes/md4c

src/QOwnNotes.pro

+1-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ include(libraries/piwiktracker/piwiktracker.pri)
331331
include(libraries/botan/botan.pri)
332332
include(libraries/qkeysequencewidget/qkeysequencewidget/qkeysequencewidget.pri)
333333
include(libraries/qttoolbareditor/toolbar_editor.pri)
334-
include(libraries/fakevim/fakevim/fakevim.pri)
334+
include(libraries/fakevim/fakevim.pri)
335335
include(libraries/singleapplication/singleapplication.pri)
336336
include(libraries/sonnet/src/core/sonnet-core.pri)
337337
include(libraries/qhotkey/qhotkey.pri)

src/helpers/fakevimproxy.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void FakeVimProxy::highlightMatches(const QString &pattern) {
7373
updateExtraSelections();
7474
}
7575

76-
void FakeVimProxy::changeStatusMessage(const QString &contents, int cursorPos) {
76+
void FakeVimProxy::changeStatusMessage(const QString &contents, int cursorPos, int anchorPos, int messageLevel) {
7777
m_statusMessage =
7878
cursorPos == -1
7979
? contents
@@ -189,8 +189,7 @@ void FakeVimProxy::indentRegion(int beginBlock, int endBlock, QChar typedChar) {
189189
auto *ed = qobject_cast<QPlainTextEdit *>(m_widget);
190190
if (!ed) return;
191191

192-
const auto indentSize =
193-
theFakeVimSetting(FakeVim::Internal::ConfigShiftWidth)->value().toInt();
192+
const qint64 indentSize = FakeVim::Internal::fakeVimSettings()->shiftWidth.value();
194193

195194
QTextDocument *doc = ed->document();
196195
QTextBlock startBlock = doc->findBlockByNumber(beginBlock);
@@ -211,9 +210,9 @@ void FakeVimProxy::indentRegion(int beginBlock, int endBlock, QChar typedChar) {
211210
const auto previousLine =
212211
previousBlock.isValid() ? previousBlock.text() : QString();
213212

214-
int indent = firstNonSpace(previousLine);
213+
qint64 indent = firstNonSpace(previousLine);
215214
if (typedChar == '}')
216-
indent = std::max(0, indent - indentSize);
215+
indent = std::max(0, int(indent - indentSize));
217216
else if (previousLine.endsWith(QLatin1String("{")))
218217
indent += indentSize;
219218
const auto indentString = QStringLiteral(" ").repeated(indent);

src/helpers/fakevimproxy.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class FakeVimProxy : public QObject {
2626

2727
void highlightMatches(const QString &pattern);
2828

29-
void changeStatusMessage(const QString &contents, int cursorPos);
29+
void changeStatusMessage(const QString &contents, int cursorPos, int anchorPos, int messageLevel);
3030

3131
void changeExtraInformation(const QString &info);
3232

src/libraries/fakevim

-1
This file was deleted.

src/libraries/fakevim/CMakeLists.txt

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
cmake_minimum_required(VERSION 3.0)
2+
project(fakevim VERSION 0.0.1)
3+
4+
# Library name
5+
set(bin fakevim)
6+
7+
# Public headers
8+
set(${bin}_public_headers
9+
fakevim/fakevimactions.h
10+
fakevim/fakevimhandler.h
11+
)
12+
13+
# Source files common for all platforms
14+
set(${bin}_sources
15+
fakevim/fakevimactions.cpp
16+
fakevim/fakevimhandler.cpp
17+
fakevim/utils/hostosinfo.cpp
18+
fakevim/utils/osspecificaspects.h
19+
fakevim/utils/qtcassert.cpp
20+
${${bin}_public_headers}
21+
)
22+
23+
# Required pkg-config packages
24+
set(${bin}_pkg_config_requires)
25+
26+
include(cmake/cxx17.cmake)
27+
include(cmake/library.cmake)
28+
include(cmake/qt.cmake)
29+
include(cmake/pkg-config.cmake)
30+
31+
# Files with Q_OBJECT macros to pass to moc utility
32+
set(CMAKE_INCLUDE_CURRENT_DIR ON)
33+
qt5_wrap_cpp(${bin}_mocced "fakevim/fakevimhandler.h")
34+
target_sources(${bin} PRIVATE ${${bin}_mocced})
35+
36+
target_compile_definitions(${bin} PRIVATE
37+
QT_NO_CAST_TO_ASCII
38+
QT_RESTRICTED_CAST_FROM_ASCII
39+
QTCREATOR_UTILS_STATIC_LIB
40+
)
41+
42+
option(BUILD_TESTS "Build tests")
43+
if (BUILD_TESTS)
44+
message(STATUS "Building tests")
45+
46+
find_package(Qt5Test REQUIRED)
47+
48+
add_executable(fakevim_test
49+
tests/fakevim_test.cpp
50+
tests/fakevimplugin.h
51+
example/editor.cpp
52+
)
53+
set_property(TARGET fakevim_test PROPERTY AUTOMOC ON)
54+
target_link_libraries(fakevim_test fakevim Qt5::Widgets Qt5::Test)
55+
56+
target_include_directories(fakevim_test PRIVATE
57+
${CMAKE_SOURCE_DIR}/fakevim
58+
${CMAKE_SOURCE_DIR}
59+
)
60+
61+
add_test(fakevim_test fakevim_test)
62+
enable_testing()
63+
endif()
64+
65+
option(BUILD_EXAMPLE "Build example")
66+
if (BUILD_EXAMPLE)
67+
message(STATUS "Building example")
68+
69+
add_executable(fakevim_example example/main.cpp example/editor.cpp)
70+
set_property(TARGET fakevim_example PROPERTY AUTOMOC ON)
71+
72+
target_link_libraries(fakevim_example fakevim)
73+
target_link_libraries(fakevim_example Qt5::Widgets)
74+
endif()
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Digia Qt LGPL Exception version 1.1
2+
3+
As an additional permission to the GNU Lesser General Public License version
4+
2.1, the object code form of a "work that uses the Library" may incorporate
5+
material from a header file that is part of the Library. You may distribute
6+
such object code under terms of your choice, provided that:
7+
(i) the header files of the Library have not been modified; and
8+
(ii) the incorporated material is limited to numerical parameters, data
9+
structure layouts, accessors, macros, inline functions and
10+
templates; and
11+
(iii) you comply with the terms of Section 6 of the GNU Lesser General
12+
Public License version 2.1.
13+
14+
Moreover, you may apply this exception to a modified version of the Library,
15+
provided that such modification does not involve copying material from the
16+
Library into the modified Library's header files unless such material is
17+
limited to (i) numerical parameters; (ii) data structure layouts;
18+
(iii) accessors; and (iv) small macros, templates and inline functions of
19+
five lines or less in length.
20+
21+
Furthermore, you are not required to apply this additional permission to a
22+
modified version of the Library.

0 commit comments

Comments
 (0)