mirror of
https://github.com/pbek/QOwnNotes.git
synced 2025-06-28 12:59:52 +00:00
* Remove fakevim submodule * Update FakeVim
This commit is contained in:
parent
920fc3b350
commit
92862caf31
34 changed files with 12906 additions and 47 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -13,9 +13,6 @@
|
|||
[submodule "src/libraries/qtcsv"]
|
||||
path = src/libraries/qtcsv
|
||||
url = https://github.com/pbek/qtcsv.git
|
||||
[submodule "src/libraries/fakevim"]
|
||||
path = src/libraries/fakevim
|
||||
url = https://github.com/pbek/FakeVim.git
|
||||
[submodule "src/libraries/md4c"]
|
||||
path = src/libraries/md4c
|
||||
url = https://github.com/qownnotes/md4c
|
||||
|
|
|
@ -331,7 +331,7 @@ include(libraries/piwiktracker/piwiktracker.pri)
|
|||
include(libraries/botan/botan.pri)
|
||||
include(libraries/qkeysequencewidget/qkeysequencewidget/qkeysequencewidget.pri)
|
||||
include(libraries/qttoolbareditor/toolbar_editor.pri)
|
||||
include(libraries/fakevim/fakevim/fakevim.pri)
|
||||
include(libraries/fakevim/fakevim.pri)
|
||||
include(libraries/singleapplication/singleapplication.pri)
|
||||
include(libraries/sonnet/src/core/sonnet-core.pri)
|
||||
include(libraries/qhotkey/qhotkey.pri)
|
||||
|
|
|
@ -73,7 +73,7 @@ void FakeVimProxy::highlightMatches(const QString &pattern) {
|
|||
updateExtraSelections();
|
||||
}
|
||||
|
||||
void FakeVimProxy::changeStatusMessage(const QString &contents, int cursorPos) {
|
||||
void FakeVimProxy::changeStatusMessage(const QString &contents, int cursorPos, int anchorPos, int messageLevel) {
|
||||
m_statusMessage =
|
||||
cursorPos == -1
|
||||
? contents
|
||||
|
@ -189,8 +189,7 @@ void FakeVimProxy::indentRegion(int beginBlock, int endBlock, QChar typedChar) {
|
|||
auto *ed = qobject_cast<QPlainTextEdit *>(m_widget);
|
||||
if (!ed) return;
|
||||
|
||||
const auto indentSize =
|
||||
theFakeVimSetting(FakeVim::Internal::ConfigShiftWidth)->value().toInt();
|
||||
const qint64 indentSize = FakeVim::Internal::fakeVimSettings()->shiftWidth.value();
|
||||
|
||||
QTextDocument *doc = ed->document();
|
||||
QTextBlock startBlock = doc->findBlockByNumber(beginBlock);
|
||||
|
@ -211,9 +210,9 @@ void FakeVimProxy::indentRegion(int beginBlock, int endBlock, QChar typedChar) {
|
|||
const auto previousLine =
|
||||
previousBlock.isValid() ? previousBlock.text() : QString();
|
||||
|
||||
int indent = firstNonSpace(previousLine);
|
||||
qint64 indent = firstNonSpace(previousLine);
|
||||
if (typedChar == '}')
|
||||
indent = std::max(0, indent - indentSize);
|
||||
indent = std::max(0, int(indent - indentSize));
|
||||
else if (previousLine.endsWith(QLatin1String("{")))
|
||||
indent += indentSize;
|
||||
const auto indentString = QStringLiteral(" ").repeated(indent);
|
||||
|
|
|
@ -26,7 +26,7 @@ class FakeVimProxy : public QObject {
|
|||
|
||||
void highlightMatches(const QString &pattern);
|
||||
|
||||
void changeStatusMessage(const QString &contents, int cursorPos);
|
||||
void changeStatusMessage(const QString &contents, int cursorPos, int anchorPos, int messageLevel);
|
||||
|
||||
void changeExtraInformation(const QString &info);
|
||||
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 0f9f439a96f45fc31cd7656801450804ffdb52ca
|
74
src/libraries/fakevim/CMakeLists.txt
Normal file
74
src/libraries/fakevim/CMakeLists.txt
Normal file
|
@ -0,0 +1,74 @@
|
|||
cmake_minimum_required(VERSION 3.0)
|
||||
project(fakevim VERSION 0.0.1)
|
||||
|
||||
# Library name
|
||||
set(bin fakevim)
|
||||
|
||||
# Public headers
|
||||
set(${bin}_public_headers
|
||||
fakevim/fakevimactions.h
|
||||
fakevim/fakevimhandler.h
|
||||
)
|
||||
|
||||
# Source files common for all platforms
|
||||
set(${bin}_sources
|
||||
fakevim/fakevimactions.cpp
|
||||
fakevim/fakevimhandler.cpp
|
||||
fakevim/utils/hostosinfo.cpp
|
||||
fakevim/utils/osspecificaspects.h
|
||||
fakevim/utils/qtcassert.cpp
|
||||
${${bin}_public_headers}
|
||||
)
|
||||
|
||||
# Required pkg-config packages
|
||||
set(${bin}_pkg_config_requires)
|
||||
|
||||
include(cmake/cxx17.cmake)
|
||||
include(cmake/library.cmake)
|
||||
include(cmake/qt.cmake)
|
||||
include(cmake/pkg-config.cmake)
|
||||
|
||||
# Files with Q_OBJECT macros to pass to moc utility
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
qt5_wrap_cpp(${bin}_mocced "fakevim/fakevimhandler.h")
|
||||
target_sources(${bin} PRIVATE ${${bin}_mocced})
|
||||
|
||||
target_compile_definitions(${bin} PRIVATE
|
||||
QT_NO_CAST_TO_ASCII
|
||||
QT_RESTRICTED_CAST_FROM_ASCII
|
||||
QTCREATOR_UTILS_STATIC_LIB
|
||||
)
|
||||
|
||||
option(BUILD_TESTS "Build tests")
|
||||
if (BUILD_TESTS)
|
||||
message(STATUS "Building tests")
|
||||
|
||||
find_package(Qt5Test REQUIRED)
|
||||
|
||||
add_executable(fakevim_test
|
||||
tests/fakevim_test.cpp
|
||||
tests/fakevimplugin.h
|
||||
example/editor.cpp
|
||||
)
|
||||
set_property(TARGET fakevim_test PROPERTY AUTOMOC ON)
|
||||
target_link_libraries(fakevim_test fakevim Qt5::Widgets Qt5::Test)
|
||||
|
||||
target_include_directories(fakevim_test PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/fakevim
|
||||
${CMAKE_SOURCE_DIR}
|
||||
)
|
||||
|
||||
add_test(fakevim_test fakevim_test)
|
||||
enable_testing()
|
||||
endif()
|
||||
|
||||
option(BUILD_EXAMPLE "Build example")
|
||||
if (BUILD_EXAMPLE)
|
||||
message(STATUS "Building example")
|
||||
|
||||
add_executable(fakevim_example example/main.cpp example/editor.cpp)
|
||||
set_property(TARGET fakevim_example PROPERTY AUTOMOC ON)
|
||||
|
||||
target_link_libraries(fakevim_example fakevim)
|
||||
target_link_libraries(fakevim_example Qt5::Widgets)
|
||||
endif()
|
22
src/libraries/fakevim/LGPL_EXCEPTION.TXT
Normal file
22
src/libraries/fakevim/LGPL_EXCEPTION.TXT
Normal file
|
@ -0,0 +1,22 @@
|
|||
Digia Qt LGPL Exception version 1.1
|
||||
|
||||
As an additional permission to the GNU Lesser General Public License version
|
||||
2.1, the object code form of a "work that uses the Library" may incorporate
|
||||
material from a header file that is part of the Library. You may distribute
|
||||
such object code under terms of your choice, provided that:
|
||||
(i) the header files of the Library have not been modified; and
|
||||
(ii) the incorporated material is limited to numerical parameters, data
|
||||
structure layouts, accessors, macros, inline functions and
|
||||
templates; and
|
||||
(iii) you comply with the terms of Section 6 of the GNU Lesser General
|
||||
Public License version 2.1.
|
||||
|
||||
Moreover, you may apply this exception to a modified version of the Library,
|
||||
provided that such modification does not involve copying material from the
|
||||
Library into the modified Library's header files unless such material is
|
||||
limited to (i) numerical parameters; (ii) data structure layouts;
|
||||
(iii) accessors; and (iv) small macros, templates and inline functions of
|
||||
five lines or less in length.
|
||||
|
||||
Furthermore, you are not required to apply this additional permission to a
|
||||
modified version of the Library.
|
504
src/libraries/fakevim/LICENSE.LGPL
Normal file
504
src/libraries/fakevim/LICENSE.LGPL
Normal file
|
@ -0,0 +1,504 @@
|
|||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
||||
|
170
src/libraries/fakevim/README.md
Normal file
170
src/libraries/fakevim/README.md
Normal file
|
@ -0,0 +1,170 @@
|
|||
FakeVim
|
||||
=======
|
||||
|
||||
FakeVim is library to emulate Vim in QTextEdit, QPlainTextEdit and possibly other Qt widgets.
|
||||
|
||||
Build
|
||||
-----
|
||||
|
||||
To build the library and simple example editor (in `example` directory), run
|
||||
following commands:
|
||||
|
||||
cmake .
|
||||
make
|
||||
|
||||
Build and run **example with **CMake**:
|
||||
|
||||
cmake -DBUILD_EXAMPLE=1 .
|
||||
make
|
||||
./fakevim_example
|
||||
|
||||
Build and run **tests with CMake**:
|
||||
|
||||
cmake -DBUILD_TESTS=1 .
|
||||
make
|
||||
ctest
|
||||
|
||||
Supported Features
|
||||
------------------
|
||||
|
||||
Most of supported commands can be followed by motion command or executed in visual mode, work with registers or can be prefixed with number of repetitions.
|
||||
|
||||
Here is list of emulated commands with description where it can diverge from Vim in functionality.
|
||||
|
||||
### Modes
|
||||
* normal
|
||||
* insert and replace
|
||||
* visual
|
||||
* command line (`:`)
|
||||
|
||||
### Normal and Visual Modes
|
||||
* basic movement -- `h`/`j`/`k`/`l`, `<C-U>`, `<C-D>`, `<C-F>`, `<C-B>`, `gg`, `G`, `0`, `^`, `$` etc.
|
||||
* word movement -- `w`, `e`, `b` etc.
|
||||
* "inner/a" movement -- `ciw`, `3daw`, `ya{` etc.
|
||||
* `f`, `t` movement
|
||||
* `[`, `]` movement
|
||||
* `{`, `}` -- paragraph movement
|
||||
* delete/change/yank/paste with register
|
||||
* undo/redo
|
||||
* `<C-A>`, `<C-X>` -- increase or decrease number in decimal/octal/hexadecimal format (e.g. `128<C-A>` on or before "0x0ff" changes it to "0x17f")
|
||||
* `.` -- repeat last change
|
||||
* `/search`, `?search`, `*`, `#`, `n`, `N` -- most of regular expression syntax used in Vim except `\<` and `\>` just is the same as `\b` in QRegExp
|
||||
* `@`, `q` (macro recording, execution) -- special keys are saved as `<S-Left>`
|
||||
* marks
|
||||
* `gv` -- last visual selection; can differ if text is edited around it
|
||||
* indentation -- `=`, `<<`, `>>` etc. with movement, count and in visual mode
|
||||
* "to upper/lower" -- `~`, `gU`, `gu` etc.
|
||||
* `i`, `a`, `o`, `I`, `A`, `O` -- enter insert mode
|
||||
* scroll window -- `zt`, `zb`, `zz` etc.
|
||||
* wrap line movement -- `gj`, `gk`, `g0`, `g^`, `g$`
|
||||
|
||||
### Command Line Mode
|
||||
* `:map`, `:unmap`, `:inoremap` etc.
|
||||
* `:source` -- very basic line-by-line sourcing of vimrc files
|
||||
* `:substitute` -- substitute expression in range
|
||||
* `:'<,'>!cmd` -- filter through an external command (e.g. sort lines in file with `:%!sort`)
|
||||
* `:.!cmd` -- insert standard output of an external command
|
||||
* `:read`
|
||||
* `:yank`, `:delete`, `:change`
|
||||
* `:move`, `:join`
|
||||
* `:20` -- go to address
|
||||
* `:history`
|
||||
* `:registers`, `:display`
|
||||
* `:nohlsearch`
|
||||
* `:undo`, `:redo`
|
||||
* `:normal`
|
||||
* `:<`, `:>`
|
||||
|
||||
### Insert Mode
|
||||
* `<C-O>` -- execute single command and return to insert mode
|
||||
* `<C-V>` -- insert raw character
|
||||
* `<insert>` -- toggle replace mode
|
||||
|
||||
### Options (:set ...)
|
||||
* `autoindent`
|
||||
* `clipboard`
|
||||
* `backspace`
|
||||
* `expandtab`
|
||||
* `hlsearch`
|
||||
* `ignorecase`
|
||||
* `incsearch`
|
||||
* `indent`
|
||||
* `iskeyword`
|
||||
* `scrolloff`
|
||||
* `shiftwidth`
|
||||
* `showcmd`
|
||||
* `smartcase`
|
||||
* `smartindent`
|
||||
* `smarttab`
|
||||
* `startofline`
|
||||
* `tabstop`
|
||||
* `tildeop`
|
||||
* `wrapscan`
|
||||
|
||||
Example Vimrc
|
||||
-------------
|
||||
|
||||
" highlight matched
|
||||
set hlsearch
|
||||
" case insensitive search
|
||||
set ignorecase
|
||||
set smartcase
|
||||
" search while typing
|
||||
set incsearch
|
||||
" wrap-around when searching
|
||||
set wrapscan
|
||||
" show pressed keys in lower right corner
|
||||
set showcmd
|
||||
" tab -> spaces
|
||||
set expandtab
|
||||
set tabstop=4
|
||||
set shiftwidth=4
|
||||
" keep a 5 line buffer for the cursor from top/bottom of window
|
||||
set scrolloff=5
|
||||
" X11 clipboard
|
||||
set clipboard=unnamed
|
||||
" use ~ with movement
|
||||
set tildeop
|
||||
|
||||
" mappings
|
||||
nnoremap ; :
|
||||
inoremap jj <Esc>
|
||||
|
||||
" clear highlighted search term on space
|
||||
noremap <silent> <Space> :nohls<CR>
|
||||
|
||||
" reselect visual block after indent
|
||||
vnoremap < <gv
|
||||
vnoremap > >gv
|
||||
|
||||
" MOVE LINE/BLOCK
|
||||
nnoremap <C-S-J> :m+<CR>==
|
||||
nnoremap <C-S-K> :m-2<CR>==
|
||||
inoremap <C-S-J> <Esc>:m+<CR>==gi
|
||||
inoremap <C-S-K> <Esc>:m-2<CR>==gi
|
||||
vnoremap <C-S-J> :m'>+<CR>gv=gv
|
||||
vnoremap <C-S-K> :m-2<CR>gv=gv
|
||||
|
||||
Implementation
|
||||
--------------
|
||||
|
||||
There are appropriate signals emitted for command which has to be processed by the underlying editor widget (folds, windows, tabs, command line, messages etc.).
|
||||
See example in `example/` directory or implementation of FakeVim plugin in Qt Creator IDE.
|
||||
|
||||
Python Bindings
|
||||
---------------
|
||||
|
||||
To install Python bindings for FakeVim see "python/README.md" file.
|
||||
|
||||
Update from Upstream
|
||||
--------------------
|
||||
|
||||
The source code should be regularly updated from the Qt Creator.
|
||||
|
||||
To fetch Qt Creator source code:
|
||||
|
||||
git clone "https://codereview.qt-project.org/qt-creator/qt-creator" /path/to/qt-creator
|
||||
|
||||
To update FakeVim source code, run:
|
||||
|
||||
utils/update_from_qtc.sh /path/to/qt-creator
|
5
src/libraries/fakevim/cmake/cxx17.cmake
Normal file
5
src/libraries/fakevim/cmake/cxx17.cmake
Normal file
|
@ -0,0 +1,5 @@
|
|||
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
|
||||
endif()
|
1
src/libraries/fakevim/cmake/fakevimConfig.cmake
Normal file
1
src/libraries/fakevim/cmake/fakevimConfig.cmake
Normal file
|
@ -0,0 +1 @@
|
|||
include("${CMAKE_CURRENT_LIST_DIR}/fakevimTargets.cmake")
|
83
src/libraries/fakevim/cmake/library.cmake
Normal file
83
src/libraries/fakevim/cmake/library.cmake
Normal file
|
@ -0,0 +1,83 @@
|
|||
set(INSTALL_LIB_DIR "lib${LIB_SUFFIX}" CACHE PATH
|
||||
"Installation directory for libraries")
|
||||
set(INSTALL_BIN_DIR "bin" CACHE PATH
|
||||
"Installation directory for executables")
|
||||
set(INSTALL_INCLUDE_DIR "include/${bin}" CACHE PATH
|
||||
"Installation directory for header files")
|
||||
set(INSTALL_CMAKE_DIR "lib${LIB_SUFFIX}/cmake/${bin}" CACHE PATH
|
||||
"Installation directory for CMake files")
|
||||
|
||||
# Shared or static library
|
||||
option(CREATE_STATIC_LIBRARY "Create static library" OFF)
|
||||
if (CREATE_STATIC_LIBRARY)
|
||||
set(libtype STATIC)
|
||||
else()
|
||||
set(libtype SHARED)
|
||||
endif()
|
||||
|
||||
add_library(${bin} ${libtype} ${${bin}_sources})
|
||||
set_target_properties(${bin} PROPERTIES
|
||||
VERSION ${PROJECT_VERSION}
|
||||
SOVERSION ${PROJECT_VERSION_MAJOR}
|
||||
)
|
||||
|
||||
# Headers
|
||||
set(export_header "${CMAKE_CURRENT_BINARY_DIR}/private/${bin}_export.h")
|
||||
set_target_properties(${bin} PROPERTIES
|
||||
PUBLIC_HEADER "${${bin}_public_headers}"
|
||||
PRIVATE_HEADER "${export_header}")
|
||||
|
||||
target_include_directories(${bin}
|
||||
PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${bin}>
|
||||
INTERFACE $<INSTALL_INTERFACE:include/${bin}>
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS ${bin} EXPORT ${bin}Targets
|
||||
RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin
|
||||
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib
|
||||
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib
|
||||
PUBLIC_HEADER DESTINATION "${INSTALL_INCLUDE_DIR}" COMPONENT dev
|
||||
PRIVATE_HEADER DESTINATION "${INSTALL_INCLUDE_DIR}/private" COMPONENT dev
|
||||
)
|
||||
|
||||
# Generate and install CMake files for the library so `find_package(<Library>)` can be used with CMake.
|
||||
# For more info: https://cmake.org/cmake/help/v3.0/manual/cmake-packages.7.html#creating-packages
|
||||
include(GenerateExportHeader)
|
||||
generate_export_header(${bin} EXPORT_FILE_NAME "${export_header}")
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
write_basic_package_version_file(
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${bin}ConfigVersion.cmake"
|
||||
VERSION ${PROJECT_VERSION}
|
||||
COMPATIBILITY AnyNewerVersion
|
||||
)
|
||||
|
||||
export(
|
||||
EXPORT ${bin}Targets
|
||||
FILE "${CMAKE_CURRENT_BINARY_DIR}/${bin}Targets.cmake"
|
||||
)
|
||||
configure_file(
|
||||
cmake/${bin}Config.cmake
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${bin}Config.cmake"
|
||||
COPYONLY
|
||||
)
|
||||
|
||||
install(
|
||||
EXPORT ${bin}Targets
|
||||
FILE
|
||||
${bin}Targets.cmake
|
||||
DESTINATION
|
||||
"${INSTALL_CMAKE_DIR}"
|
||||
COMPONENT
|
||||
dev
|
||||
)
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${bin}Config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${bin}ConfigVersion.cmake"
|
||||
DESTINATION
|
||||
"${INSTALL_CMAKE_DIR}"
|
||||
COMPONENT
|
||||
dev
|
||||
)
|
22
src/libraries/fakevim/cmake/pkg-config.cmake
Normal file
22
src/libraries/fakevim/cmake/pkg-config.cmake
Normal file
|
@ -0,0 +1,22 @@
|
|||
set(PKG_CONFIG_REQUIRES "${${bin}_pkg_config_requires}")
|
||||
set(PKG_CONFIG_LIBDIR "\${prefix}/lib")
|
||||
set(PKG_CONFIG_INCLUDEDIR "\${prefix}/include/${bin}")
|
||||
set(PKG_CONFIG_LIBS "-L\${libdir} -l${bin}")
|
||||
set(PKG_CONFIG_CFLAGS "-I\${includedir}")
|
||||
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/pkg-config.pc.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${bin}.pc"
|
||||
)
|
||||
|
||||
set(INSTALL_PKG_CONFIG_DIR "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig"
|
||||
CACHE PATH "Installation directory for pkg-config files")
|
||||
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${bin}.pc"
|
||||
DESTINATION
|
||||
"${INSTALL_PKG_CONFIG_DIR}"
|
||||
COMPONENT
|
||||
dev
|
||||
)
|
6
src/libraries/fakevim/cmake/qt.cmake
Normal file
6
src/libraries/fakevim/cmake/qt.cmake
Normal file
|
@ -0,0 +1,6 @@
|
|||
find_package(Qt5Widgets REQUIRED)
|
||||
|
||||
include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS})
|
||||
target_link_libraries(${bin} Qt5::Widgets)
|
||||
|
||||
set(${bin}_pkg_config_requires ${${bin}_pkg_config_requires} Qt5::Widgets)
|
12
src/libraries/fakevim/fakevim.pri
Normal file
12
src/libraries/fakevim/fakevim.pri
Normal file
|
@ -0,0 +1,12 @@
|
|||
include($$PWD/fakevim/utils/utils.pri)
|
||||
|
||||
INCLUDEPATH += $$PWD
|
||||
|
||||
SOURCES += $$PWD/fakevim/fakevimhandler.cpp \
|
||||
$$PWD/fakevim/fakevimactions.cpp
|
||||
|
||||
HEADERS += $$PWD/fakevim/fakevimhandler.h \
|
||||
$$PWD/fakevim/fakevimactions.h
|
||||
|
||||
CONFIG += qt
|
||||
QT += widgets
|
3
src/libraries/fakevim/fakevim.pro
Normal file
3
src/libraries/fakevim/fakevim.pro
Normal file
|
@ -0,0 +1,3 @@
|
|||
TEMPLATE = subdirs
|
||||
SUBDIRS += fakevim \
|
||||
example
|
1046
src/libraries/fakevim/fakevim/3rdparty/optional/optional.hpp
vendored
Normal file
1046
src/libraries/fakevim/fakevim/3rdparty/optional/optional.hpp
vendored
Normal file
File diff suppressed because it is too large
Load diff
211
src/libraries/fakevim/fakevim/fakevimactions.cpp
Normal file
211
src/libraries/fakevim/fakevim/fakevimactions.cpp
Normal file
|
@ -0,0 +1,211 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "fakevimactions.h"
|
||||
#include "fakevimhandler.h"
|
||||
|
||||
// Please do not add any direct dependencies to other Qt Creator code here.
|
||||
// Instead emit signals and let the FakeVimPlugin channel the information to
|
||||
// Qt Creator. The idea is to keep this file here in a "clean" state that
|
||||
// allows easy reuse with any QTextEdit or QPlainTextEdit derived class.
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace FakeVim {
|
||||
namespace Internal {
|
||||
|
||||
#ifdef FAKEVIM_STANDALONE
|
||||
FvBaseAspect::FvBaseAspect()
|
||||
{
|
||||
}
|
||||
|
||||
void FvBaseAspect::setValue(const QVariant &value)
|
||||
{
|
||||
m_value = value;
|
||||
}
|
||||
|
||||
QVariant FvBaseAspect::value() const
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
void FvBaseAspect::setDefaultValue(const QVariant &value)
|
||||
{
|
||||
m_defaultValue = value;
|
||||
m_value = value;
|
||||
}
|
||||
|
||||
QVariant FvBaseAspect::defaultValue() const
|
||||
{
|
||||
return m_defaultValue;
|
||||
}
|
||||
|
||||
void FvBaseAspect::setSettingsKey(const QString &group, const QString &key)
|
||||
{
|
||||
m_settingsGroup = group;
|
||||
m_settingsKey = key;
|
||||
}
|
||||
|
||||
QString FvBaseAspect::settingsKey() const
|
||||
{
|
||||
return m_settingsKey;
|
||||
}
|
||||
#endif
|
||||
|
||||
FakeVimSettings::FakeVimSettings()
|
||||
{
|
||||
#ifndef FAKEVIM_STANDALONE
|
||||
setup(&useFakeVim, false, "UseFakeVim", {}, tr("Use FakeVim"));
|
||||
#endif
|
||||
// Specific FakeVim settings
|
||||
setup(&readVimRc, false, "ReadVimRc", {}, tr("Read .vimrc from location:"));
|
||||
setup(&vimRcPath, QString(), "VimRcPath", {}, {}); // tr("Path to .vimrc")
|
||||
setup(&showMarks, false, "ShowMarks", "sm", tr("Show position of text marks"));
|
||||
setup(&passControlKey, false, "PassControlKey", "pck", tr("Pass control keys"));
|
||||
setup(&passKeys, true, "PassKeys", "pk", tr("Pass keys in insert mode"));
|
||||
|
||||
// Emulated Vsetting
|
||||
setup(&startOfLine, true, "StartOfLine", "sol", tr("Start of line"));
|
||||
setup(&tabStop, 8, "TabStop", "ts", tr("Tabulator size:"));
|
||||
setup(&smartTab, false, "SmartTab", "sta", tr("Smart tabulators"));
|
||||
setup(&hlSearch, true, "HlSearch", "hls", tr("Highlight search results"));
|
||||
setup(&shiftWidth, 8, "ShiftWidth", "sw", tr("Shift width:"));
|
||||
setup(&expandTab, false, "ExpandTab", "et", tr("Expand tabulators"));
|
||||
setup(&autoIndent, false, "AutoIndent", "ai", tr("Automatic indentation"));
|
||||
setup(&smartIndent, false, "SmartIndent", "si", tr("Smart tabulators"));
|
||||
setup(&incSearch, true, "IncSearch", "is", tr("Incremental search"));
|
||||
setup(&useCoreSearch, false, "UseCoreSearch", "ucs", tr("Use search dialog"));
|
||||
setup(&smartCase, false, "SmartCase", "scs", tr("Use smartcase"));
|
||||
setup(&ignoreCase, false, "IgnoreCase", "ic", tr("Use ignorecase"));
|
||||
setup(&wrapScan, true, "WrapScan", "ws", tr("Use wrapscan"));
|
||||
setup(&tildeOp, false, "TildeOp", "top", tr("Use tildeop"));
|
||||
setup(&showCmd, true, "ShowCmd", "sc", tr("Show partial command"));
|
||||
setup(&relativeNumber, false, "RelativeNumber", "rnu", tr("Show line numbers relative to cursor"));
|
||||
setup(&blinkingCursor, false, "BlinkingCursor", "bc", tr("Blinking cursor"));
|
||||
setup(&scrollOff, 0, "ScrollOff", "so", tr("Scroll offset:"));
|
||||
setup(&backspace, "indent,eol,start",
|
||||
"Backspace", "bs", tr("Backspace:"));
|
||||
setup(&isKeyword, "@,48-57,_,192-255,a-z,A-Z",
|
||||
"IsKeyword", "isk", tr("Keyword characters:"));
|
||||
setup(&clipboard, {}, "Clipboard", "cb", tr(""));
|
||||
setup(&formatOptions, {}, "formatoptions", "fo", tr(""));
|
||||
|
||||
// Emulated plugins
|
||||
setup(&emulateVimCommentary, false, "commentary", {}, "vim-commentary");
|
||||
setup(&emulateReplaceWithRegister, false, "ReplaceWithRegister", {}, "ReplaceWithRegister");
|
||||
setup(&emulateExchange, false, "exchange", {}, "vim-exchange");
|
||||
setup(&emulateArgTextObj, false, "argtextobj", {}, "argtextobj.vim");
|
||||
setup(&emulateSurround, false, "surround", {}, "vim-surround");
|
||||
|
||||
// Some polish
|
||||
useFakeVim.setDisplayName(tr("Use Vim-style Editing"));
|
||||
|
||||
relativeNumber.setToolTip(tr("Displays line numbers relative to the line containing "
|
||||
"text cursor."));
|
||||
|
||||
passControlKey.setToolTip(tr("Does not interpret key sequences like Ctrl-S in FakeVim "
|
||||
"but handles them as regular shortcuts. This gives easier access to core functionality "
|
||||
"at the price of losing some features of FakeVim."));
|
||||
|
||||
passKeys.setToolTip(tr("Does not interpret some key presses in insert mode so that "
|
||||
"code can be properly completed and expanded."));
|
||||
|
||||
tabStop.setToolTip(tr("Vim tabstop option."));
|
||||
|
||||
#ifndef FAKEVIM_STANDALONE
|
||||
backspace.setDisplayStyle(FvStringAspect::LineEditDisplay);
|
||||
isKeyword.setDisplayStyle(FvStringAspect::LineEditDisplay);
|
||||
|
||||
const QString vimrcDefault = QLatin1String(HostOsInfo::isAnyUnixHost()
|
||||
? "$HOME/.vimrc" : "%USERPROFILE%\\_vimrc");
|
||||
vimRcPath.setExpectedKind(PathChooser::File);
|
||||
vimRcPath.setToolTip(tr("Keep empty to use the default path, i.e. "
|
||||
"%USERPROFILE%\\_vimrc on Windows, ~/.vimrc otherwise."));
|
||||
vimRcPath.setPlaceHolderText(tr("Default: %1").arg(vimrcDefault));
|
||||
vimRcPath.setDisplayStyle(FvStringAspect::PathChooserDisplay);
|
||||
#endif
|
||||
}
|
||||
|
||||
FakeVimSettings::~FakeVimSettings() = default;
|
||||
|
||||
FvBaseAspect *FakeVimSettings::item(const QString &name)
|
||||
{
|
||||
return m_nameToAspect.value(name, nullptr);
|
||||
}
|
||||
|
||||
QString FakeVimSettings::trySetValue(const QString &name, const QString &value)
|
||||
{
|
||||
FvBaseAspect *aspect = m_nameToAspect.value(name, nullptr);
|
||||
if (!aspect)
|
||||
return tr("Unknown option: %1").arg(name);
|
||||
if (aspect == &tabStop || aspect == &shiftWidth) {
|
||||
if (value.toInt() <= 0)
|
||||
return tr("Argument must be positive: %1=%2")
|
||||
.arg(name).arg(value);
|
||||
}
|
||||
aspect->setValue(value);
|
||||
return QString();
|
||||
}
|
||||
|
||||
void FakeVimSettings::setup(FvBaseAspect *aspect,
|
||||
const QVariant &value,
|
||||
const QString &settingsKey,
|
||||
const QString &shortName,
|
||||
const QString &labelText)
|
||||
{
|
||||
aspect->setSettingsKey("FakeVim", settingsKey);
|
||||
aspect->setDefaultValue(value);
|
||||
#ifndef FAKEVIM_STANDALONE
|
||||
aspect->setLabelText(labelText);
|
||||
aspect->setAutoApply(false);
|
||||
registerAspect(aspect);
|
||||
|
||||
if (auto boolAspect = dynamic_cast<FvBoolAspect *>(aspect))
|
||||
boolAspect->setLabelPlacement(FvBoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel);
|
||||
#else
|
||||
Q_UNUSED(labelText)
|
||||
#endif
|
||||
|
||||
const QString longName = settingsKey.toLower();
|
||||
if (!longName.isEmpty()) {
|
||||
m_nameToAspect[longName] = aspect;
|
||||
m_aspectToName[aspect] = longName;
|
||||
}
|
||||
if (!shortName.isEmpty())
|
||||
m_nameToAspect[shortName] = aspect;
|
||||
}
|
||||
|
||||
FakeVimSettings *fakeVimSettings()
|
||||
{
|
||||
static FakeVimSettings s;
|
||||
return &s;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace FakeVim
|
176
src/libraries/fakevim/fakevim/fakevimactions.h
Normal file
176
src/libraries/fakevim/fakevim/fakevimactions.h
Normal file
|
@ -0,0 +1,176 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define FAKEVIM_STANDALONE
|
||||
|
||||
#ifdef FAKEVIM_STANDALONE
|
||||
//# include "private/fakevim_export.h"
|
||||
#else
|
||||
# include <utils/savedaction.h>
|
||||
#endif
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QHash>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
|
||||
namespace FakeVim {
|
||||
namespace Internal {
|
||||
|
||||
#ifdef FAKEVIM_STANDALONE
|
||||
class FvBaseAspect
|
||||
{
|
||||
public:
|
||||
FvBaseAspect();
|
||||
virtual ~FvBaseAspect() {}
|
||||
|
||||
void setValue(const QVariant &value);
|
||||
QVariant value() const;
|
||||
void setDefaultValue(const QVariant &value);
|
||||
QVariant defaultValue() const;
|
||||
void setSettingsKey(const QString &group, const QString &key);
|
||||
QString settingsKey() const;
|
||||
void setCheckable(bool) {}
|
||||
void setDisplayName(const QString &) {}
|
||||
void setToolTip(const QString &) {}
|
||||
|
||||
private:
|
||||
QVariant m_value;
|
||||
QVariant m_defaultValue;
|
||||
QString m_settingsGroup;
|
||||
QString m_settingsKey;
|
||||
};
|
||||
|
||||
class FvBoolAspect : public FvBaseAspect
|
||||
{
|
||||
public:
|
||||
bool value() const { return FvBaseAspect::value().toBool(); }
|
||||
};
|
||||
|
||||
class FvIntegerAspect : public FvBaseAspect
|
||||
{
|
||||
public:
|
||||
qint64 value() const { return FvBaseAspect::value().toLongLong(); }
|
||||
};
|
||||
|
||||
class FvStringAspect : public FvBaseAspect
|
||||
{
|
||||
public:
|
||||
QString value() const { return FvBaseAspect::value().toString(); }
|
||||
};
|
||||
|
||||
class FvAspectContainer : public FvBaseAspect
|
||||
{
|
||||
public:
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
using FvAspectContainer = Utils::AspectContainer;
|
||||
using FvBaseAspect = Utils::BaseAspect;
|
||||
using FvBoolAspect = Utils::BoolAspect;
|
||||
using FvIntegerAspect = Utils::IntegerAspect;
|
||||
using FvStringAspect = Utils::StringAspect;
|
||||
|
||||
#endif
|
||||
|
||||
class FakeVimSettings final : public FvAspectContainer
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(FakeVim)
|
||||
|
||||
public:
|
||||
FakeVimSettings();
|
||||
~FakeVimSettings();
|
||||
|
||||
FvBaseAspect *item(const QString &name);
|
||||
QString trySetValue(const QString &name, const QString &value);
|
||||
|
||||
FvBoolAspect useFakeVim;
|
||||
FvBoolAspect readVimRc;
|
||||
FvStringAspect vimRcPath;
|
||||
|
||||
FvBoolAspect startOfLine;
|
||||
FvIntegerAspect tabStop;
|
||||
FvBoolAspect hlSearch;
|
||||
FvBoolAspect smartTab;
|
||||
FvIntegerAspect shiftWidth;
|
||||
FvBoolAspect expandTab;
|
||||
FvBoolAspect autoIndent;
|
||||
FvBoolAspect smartIndent;
|
||||
|
||||
FvBoolAspect incSearch;
|
||||
FvBoolAspect useCoreSearch;
|
||||
FvBoolAspect smartCase;
|
||||
FvBoolAspect ignoreCase;
|
||||
FvBoolAspect wrapScan;
|
||||
|
||||
// command ~ behaves as g~
|
||||
FvBoolAspect tildeOp;
|
||||
|
||||
// indent allow backspacing over autoindent
|
||||
// eol allow backspacing over line breaks (join lines)
|
||||
// start allow backspacing over the start of insert; CTRL-W and CTRL-U
|
||||
// stop once at the start of insert.
|
||||
FvStringAspect backspace;
|
||||
|
||||
// @,48-57,_,192-255
|
||||
FvStringAspect isKeyword;
|
||||
|
||||
// other actions
|
||||
FvBoolAspect showMarks;
|
||||
FvBoolAspect passControlKey;
|
||||
FvBoolAspect passKeys;
|
||||
FvStringAspect clipboard;
|
||||
FvBoolAspect showCmd;
|
||||
FvIntegerAspect scrollOff;
|
||||
FvBoolAspect relativeNumber;
|
||||
FvStringAspect formatOptions;
|
||||
|
||||
// Plugin emulation
|
||||
FvBoolAspect emulateVimCommentary;
|
||||
FvBoolAspect emulateReplaceWithRegister;
|
||||
FvBoolAspect emulateExchange;
|
||||
FvBoolAspect emulateArgTextObj;
|
||||
FvBoolAspect emulateSurround;
|
||||
|
||||
FvBoolAspect blinkingCursor;
|
||||
|
||||
private:
|
||||
void setup(FvBaseAspect *aspect, const QVariant &value,
|
||||
const QString &settingsKey,
|
||||
const QString &shortName,
|
||||
const QString &label);
|
||||
|
||||
QHash<QString, FvBaseAspect *> m_nameToAspect;
|
||||
QHash<FvBaseAspect *, QString> m_aspectToName;
|
||||
};
|
||||
|
||||
FakeVimSettings *fakeVimSettings();
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace FakeVim
|
9513
src/libraries/fakevim/fakevim/fakevimhandler.cpp
Normal file
9513
src/libraries/fakevim/fakevim/fakevimhandler.cpp
Normal file
File diff suppressed because it is too large
Load diff
199
src/libraries/fakevim/fakevim/fakevimhandler.h
Normal file
199
src/libraries/fakevim/fakevim/fakevimhandler.h
Normal file
|
@ -0,0 +1,199 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define FAKEVIM_STANDALONE
|
||||
|
||||
#ifdef FAKEVIM_STANDALONE
|
||||
//# include "private/fakevim_export.h"
|
||||
#endif
|
||||
|
||||
#include <QObject>
|
||||
#include <QTextEdit>
|
||||
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
namespace FakeVim {
|
||||
namespace Internal {
|
||||
|
||||
enum RangeMode
|
||||
{
|
||||
// Reordering first three enum items here will break
|
||||
// compatibility with clipboard format stored by Vim.
|
||||
RangeCharMode, // v
|
||||
RangeLineMode, // V
|
||||
RangeBlockMode, // Ctrl-v
|
||||
RangeLineModeExclusive,
|
||||
RangeBlockAndTailMode // Ctrl-v for D and X
|
||||
};
|
||||
|
||||
struct Range
|
||||
{
|
||||
Range() = default;
|
||||
Range(int b, int e, RangeMode m = RangeCharMode);
|
||||
QString toString() const;
|
||||
bool isValid() const;
|
||||
|
||||
int beginPos = -1;
|
||||
int endPos = -1;
|
||||
RangeMode rangemode = RangeCharMode;
|
||||
};
|
||||
|
||||
struct ExCommand
|
||||
{
|
||||
ExCommand() = default;
|
||||
ExCommand(const QString &cmd, const QString &args = QString(),
|
||||
const Range &range = Range());
|
||||
|
||||
bool matches(const QString &min, const QString &full) const;
|
||||
|
||||
QString cmd;
|
||||
bool hasBang = false;
|
||||
QString args;
|
||||
Range range;
|
||||
int count = 1;
|
||||
};
|
||||
|
||||
// message levels sorted by severity
|
||||
enum MessageLevel
|
||||
{
|
||||
MessageMode, // show current mode (format "-- %1 --")
|
||||
MessageCommand, // show last Ex command or search
|
||||
MessageInfo, // result of a command
|
||||
MessageWarning, // warning
|
||||
MessageError, // error
|
||||
MessageShowCmd // partial command
|
||||
};
|
||||
|
||||
template <typename Type>
|
||||
class Signal
|
||||
{
|
||||
public:
|
||||
using Callable = std::function<Type>;
|
||||
|
||||
void connect(const Callable &callable) { m_callables.push_back(callable); }
|
||||
|
||||
template <typename ...Args>
|
||||
void operator()(Args ...args) const
|
||||
{
|
||||
for (const Callable &callable : m_callables)
|
||||
callable(args...);
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<Callable> m_callables;
|
||||
};
|
||||
|
||||
class FakeVimHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FakeVimHandler(QWidget *widget, QObject *parent = nullptr);
|
||||
~FakeVimHandler() override;
|
||||
|
||||
QWidget *widget();
|
||||
|
||||
// call before widget is deleted
|
||||
void disconnectFromEditor();
|
||||
|
||||
static void updateGlobalMarksFilenames(const QString &oldFileName, const QString &newFileName);
|
||||
|
||||
public:
|
||||
void setCurrentFileName(const QString &fileName);
|
||||
QString currentFileName() const;
|
||||
|
||||
void showMessage(MessageLevel level, const QString &msg);
|
||||
|
||||
// This executes an "ex" style command taking context
|
||||
// information from the current widget.
|
||||
void handleCommand(const QString &cmd);
|
||||
void handleReplay(const QString &keys);
|
||||
void handleInput(const QString &keys);
|
||||
void enterCommandMode();
|
||||
|
||||
void installEventFilter();
|
||||
|
||||
// Convenience
|
||||
void setupWidget();
|
||||
void restoreWidget(int tabSize);
|
||||
|
||||
// Test only
|
||||
int physicalIndentation(const QString &line) const;
|
||||
int logicalIndentation(const QString &line) const;
|
||||
QString tabExpand(int n) const;
|
||||
|
||||
void miniBufferTextEdited(const QString &text, int cursorPos, int anchorPos);
|
||||
|
||||
// Set text cursor position. Keeps anchor if in visual mode.
|
||||
void setTextCursorPosition(int position);
|
||||
|
||||
QTextCursor textCursor() const;
|
||||
void setTextCursor(const QTextCursor &cursor);
|
||||
|
||||
bool jumpToLocalMark(QChar mark, bool backTickMode);
|
||||
|
||||
bool eventFilter(QObject *ob, QEvent *ev) override;
|
||||
|
||||
Signal<void(const QString &msg, int cursorPos, int anchorPos, int messageLevel)> commandBufferChanged;
|
||||
Signal<void(const QString &msg)> statusDataChanged;
|
||||
Signal<void(const QString &msg)> extraInformationChanged;
|
||||
Signal<void(const QList<QTextEdit::ExtraSelection> &selection)> selectionChanged;
|
||||
Signal<void(const QString &needle)> highlightMatches;
|
||||
Signal<void(bool *moved, bool *forward, QTextCursor *cursor)> moveToMatchingParenthesis;
|
||||
Signal<void(bool *result, QChar c)> checkForElectricCharacter;
|
||||
Signal<void(int beginLine, int endLine, QChar typedChar)> indentRegion;
|
||||
Signal<void(const QString &needle, bool forward)> simpleCompletionRequested;
|
||||
Signal<void(const QString &key, int count)> windowCommandRequested;
|
||||
Signal<void(bool reverse)> findRequested;
|
||||
Signal<void(bool reverse)> findNextRequested;
|
||||
Signal<void(bool *handled, const ExCommand &cmd)> handleExCommandRequested;
|
||||
Signal<void()> requestDisableBlockSelection;
|
||||
Signal<void(const QTextCursor &cursor)> requestSetBlockSelection;
|
||||
Signal<void(QTextCursor *cursor)> requestBlockSelection;
|
||||
Signal<void(bool *on)> requestHasBlockSelection;
|
||||
Signal<void(int depth)> foldToggle;
|
||||
Signal<void(bool fold)> foldAll;
|
||||
Signal<void(int depth, bool dofold)> fold;
|
||||
Signal<void(int count, bool current)> foldGoTo;
|
||||
Signal<void(QChar mark, bool backTickMode, const QString &fileName)> requestJumpToLocalMark;
|
||||
Signal<void(QChar mark, bool backTickMode, const QString &fileName)> requestJumpToGlobalMark;
|
||||
Signal<void()> completionRequested;
|
||||
Signal<void()> tabPreviousRequested;
|
||||
Signal<void()> tabNextRequested;
|
||||
|
||||
public:
|
||||
class Private;
|
||||
|
||||
private:
|
||||
Private *d;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace FakeVim
|
||||
|
||||
Q_DECLARE_METATYPE(FakeVim::Internal::ExCommand)
|
37
src/libraries/fakevim/fakevim/fakevimtr.h
Normal file
37
src/libraries/fakevim/fakevim/fakevimtr.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
namespace FakeVim {
|
||||
|
||||
struct Tr
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(FakeVim)
|
||||
};
|
||||
|
||||
} // namespace FakeVim
|
44
src/libraries/fakevim/fakevim/utils/hostosinfo.cpp
Normal file
44
src/libraries/fakevim/fakevim/utils/hostosinfo.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "hostosinfo.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
Qt::CaseSensitivity HostOsInfo::m_overrideFileNameCaseSensitivity = Qt::CaseSensitive;
|
||||
bool HostOsInfo::m_useOverrideFileNameCaseSensitivity = false;
|
||||
|
||||
void HostOsInfo::setOverrideFileNameCaseSensitivity(Qt::CaseSensitivity sensitivity)
|
||||
{
|
||||
m_useOverrideFileNameCaseSensitivity = true;
|
||||
m_overrideFileNameCaseSensitivity = sensitivity;
|
||||
}
|
||||
|
||||
void HostOsInfo::unsetOverrideFileNameCaseSensitivity()
|
||||
{
|
||||
m_useOverrideFileNameCaseSensitivity = false;
|
||||
}
|
100
src/libraries/fakevim/fakevim/utils/hostosinfo.h
Normal file
100
src/libraries/fakevim/fakevim/utils/hostosinfo.h
Normal file
|
@ -0,0 +1,100 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "osspecificaspects.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#define QTC_HOST_EXE_SUFFIX QTC_WIN_EXE_SUFFIX
|
||||
#else
|
||||
#define QTC_HOST_EXE_SUFFIX ""
|
||||
#endif // Q_OS_WIN
|
||||
|
||||
namespace Utils {
|
||||
|
||||
class HostOsInfo
|
||||
{
|
||||
public:
|
||||
static constexpr OsType hostOs()
|
||||
{
|
||||
#if defined(Q_OS_WIN)
|
||||
return OsTypeWindows;
|
||||
#elif defined(Q_OS_LINUX)
|
||||
return OsTypeLinux;
|
||||
#elif defined(Q_OS_MAC)
|
||||
return OsTypeMac;
|
||||
#elif defined(Q_OS_UNIX)
|
||||
return OsTypeOtherUnix;
|
||||
#else
|
||||
return OsTypeOther;
|
||||
#endif
|
||||
}
|
||||
|
||||
static constexpr bool isWindowsHost() { return hostOs() == OsTypeWindows; }
|
||||
static constexpr bool isLinuxHost() { return hostOs() == OsTypeLinux; }
|
||||
static constexpr bool isMacHost() { return hostOs() == OsTypeMac; }
|
||||
static constexpr bool isAnyUnixHost()
|
||||
{
|
||||
#ifdef Q_OS_UNIX
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
static QString withExecutableSuffix(const QString &executable)
|
||||
{
|
||||
return OsSpecificAspects::withExecutableSuffix(hostOs(), executable);
|
||||
}
|
||||
|
||||
static void setOverrideFileNameCaseSensitivity(Qt::CaseSensitivity sensitivity);
|
||||
static void unsetOverrideFileNameCaseSensitivity();
|
||||
|
||||
static Qt::CaseSensitivity fileNameCaseSensitivity()
|
||||
{
|
||||
return m_useOverrideFileNameCaseSensitivity
|
||||
? m_overrideFileNameCaseSensitivity
|
||||
: OsSpecificAspects::fileNameCaseSensitivity(hostOs());
|
||||
}
|
||||
|
||||
static QChar pathListSeparator()
|
||||
{
|
||||
return OsSpecificAspects::pathListSeparator(hostOs());
|
||||
}
|
||||
|
||||
static Qt::KeyboardModifier controlModifier()
|
||||
{
|
||||
return OsSpecificAspects::controlModifier(hostOs());
|
||||
}
|
||||
|
||||
private:
|
||||
static Qt::CaseSensitivity m_overrideFileNameCaseSensitivity;
|
||||
static bool m_useOverrideFileNameCaseSensitivity;
|
||||
};
|
||||
|
||||
} // namespace Utils
|
99
src/libraries/fakevim/fakevim/utils/optional.h
Normal file
99
src/libraries/fakevim/fakevim/utils/optional.h
Normal file
|
@ -0,0 +1,99 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
optional<T>
|
||||
make_optional(t)
|
||||
|
||||
See std(::experimental)::optional.
|
||||
*/
|
||||
|
||||
// std::optional from Apple's Clang supports methods that throw std::bad_optional_access only
|
||||
// with deployment target >= macOS 10.14
|
||||
// TODO: Use std::optional everywhere when we can require macOS 10.14
|
||||
// #if !defined(__apple_build_version__)
|
||||
//
|
||||
// #include <optional>
|
||||
//
|
||||
// namespace Utils {
|
||||
//
|
||||
// using std::optional;
|
||||
// using std::nullopt;
|
||||
// using std::nullopt_t;
|
||||
// using std::in_place;
|
||||
//
|
||||
// make_optional is a copy, since there is no sensible way to import functions in C++
|
||||
// template<class T>
|
||||
// constexpr optional<std::decay_t<T>> make_optional(T &&v)
|
||||
// {
|
||||
// return optional<std::decay_t<T>>(std::forward<T>(v));
|
||||
// }
|
||||
//
|
||||
// template<class T, class... Args>
|
||||
// optional<T> make_optional(Args &&... args)
|
||||
// {
|
||||
// return optional<T>(in_place, std::forward<Args>(args)...);
|
||||
// }
|
||||
//
|
||||
// template<class T, class Up, class... Args>
|
||||
// constexpr optional<T> make_optional(std::initializer_list<Up> il, Args &&... args)
|
||||
// {
|
||||
// return optional<T>(in_place, il, std::forward<Args>(args)...);
|
||||
// }
|
||||
//
|
||||
// } // namespace Utils
|
||||
//
|
||||
// #else
|
||||
|
||||
#include <3rdparty/optional/optional.hpp>
|
||||
|
||||
namespace Utils {
|
||||
|
||||
// --> Utils::optional
|
||||
using std::experimental::optional;
|
||||
// --> Utils::nullopt
|
||||
using std::experimental::nullopt;
|
||||
using std::experimental::nullopt_t;
|
||||
// --> Utils::in_place
|
||||
using std::experimental::in_place;
|
||||
|
||||
// TODO: make_optional is a copy, since there is no sensible way to import functions in C++
|
||||
template <class T>
|
||||
constexpr optional<typename std::decay<T>::type> make_optional(T&& v)
|
||||
{
|
||||
return optional<typename std::decay<T>::type>(std::experimental::constexpr_forward<T>(v));
|
||||
}
|
||||
|
||||
template <class X>
|
||||
constexpr optional<X&> make_optional(std::reference_wrapper<X> v)
|
||||
{
|
||||
return optional<X&>(v.get());
|
||||
}
|
||||
|
||||
} // Utils
|
||||
|
||||
//#endif
|
68
src/libraries/fakevim/fakevim/utils/osspecificaspects.h
Normal file
68
src/libraries/fakevim/fakevim/utils/osspecificaspects.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
|
||||
#define QTC_WIN_EXE_SUFFIX ".exe"
|
||||
|
||||
namespace Utils {
|
||||
|
||||
// Add more as needed.
|
||||
enum OsType { OsTypeWindows, OsTypeLinux, OsTypeMac, OsTypeOtherUnix, OsTypeOther };
|
||||
|
||||
namespace OsSpecificAspects {
|
||||
|
||||
inline QString withExecutableSuffix(OsType osType, const QString &executable)
|
||||
{
|
||||
QString finalName = executable;
|
||||
if (osType == OsTypeWindows)
|
||||
finalName += QLatin1String(QTC_WIN_EXE_SUFFIX);
|
||||
return finalName;
|
||||
}
|
||||
|
||||
inline Qt::CaseSensitivity fileNameCaseSensitivity(OsType osType)
|
||||
{
|
||||
return osType == OsTypeWindows || osType == OsTypeMac ? Qt::CaseInsensitive : Qt::CaseSensitive;
|
||||
}
|
||||
|
||||
inline Qt::CaseSensitivity envVarCaseSensitivity(OsType osType)
|
||||
{
|
||||
return fileNameCaseSensitivity(osType);
|
||||
}
|
||||
|
||||
inline QChar pathListSeparator(OsType osType)
|
||||
{
|
||||
return QLatin1Char(osType == OsTypeWindows ? ';' : ':');
|
||||
}
|
||||
|
||||
inline Qt::KeyboardModifier controlModifier(OsType osType)
|
||||
{
|
||||
return osType == OsTypeMac ? Qt::MetaModifier : Qt::ControlModifier;
|
||||
}
|
||||
|
||||
} // namespace OsSpecificAspects
|
||||
} // namespace Utils
|
41
src/libraries/fakevim/fakevim/utils/qtcassert.cpp
Normal file
41
src/libraries/fakevim/fakevim/utils/qtcassert.cpp
Normal file
|
@ -0,0 +1,41 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qtcassert.h"
|
||||
|
||||
#include <QByteArray>
|
||||
|
||||
namespace Utils {
|
||||
|
||||
void writeAssertLocation(const char *msg)
|
||||
{
|
||||
static bool goBoom = qEnvironmentVariableIsSet("QTC_FATAL_ASSERTS");
|
||||
if (goBoom)
|
||||
qFatal("SOFT ASSERT made fatal: %s", msg);
|
||||
else
|
||||
qDebug("SOFT ASSERT: %s", msg);
|
||||
}
|
||||
|
||||
} // namespace Utils
|
40
src/libraries/fakevim/fakevim/utils/qtcassert.h
Normal file
40
src/libraries/fakevim/fakevim/utils/qtcassert.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Utils { void writeAssertLocation(const char *msg); }
|
||||
|
||||
#define QTC_ASSERT_STRINGIFY_HELPER(x) #x
|
||||
#define QTC_ASSERT_STRINGIFY(x) QTC_ASSERT_STRINGIFY_HELPER(x)
|
||||
#define QTC_ASSERT_STRING(cond) ::Utils::writeAssertLocation(\
|
||||
"\"" cond"\" in file " __FILE__ ", line " QTC_ASSERT_STRINGIFY(__LINE__))
|
||||
|
||||
// The 'do {...} while (0)' idiom is not used for the main block here to be
|
||||
// able to use 'break' and 'continue' as 'actions'.
|
||||
|
||||
#define QTC_ASSERT(cond, action) if (Q_LIKELY(cond)) {} else { QTC_ASSERT_STRING(#cond); action; } do {} while (0)
|
||||
#define QTC_CHECK(cond) if (Q_LIKELY(cond)) {} else { QTC_ASSERT_STRING(#cond); } do {} while (0)
|
||||
#define QTC_GUARD(cond) ((Q_LIKELY(cond)) ? true : (QTC_ASSERT_STRING(#cond), false))
|
10
src/libraries/fakevim/fakevim/utils/utils.pri
Normal file
10
src/libraries/fakevim/fakevim/utils/utils.pri
Normal file
|
@ -0,0 +1,10 @@
|
|||
INCLUDEPATH += $$PWD
|
||||
INCLUDEPATH += $$PWD/../
|
||||
|
||||
SOURCES += $$PWD/qtcassert.cpp \
|
||||
$$PWD/hostosinfo.cpp
|
||||
|
||||
HEADERS += $$PWD/hostosinfo.h \
|
||||
$$PWD/optional.h \
|
||||
$$PWD/osspecificaspects.h \
|
||||
$$PWD/qtcassert.h
|
122
src/libraries/fakevim/utils/generate_fakevim_test.sh
Executable file
122
src/libraries/fakevim/utils/generate_fakevim_test.sh
Executable file
|
@ -0,0 +1,122 @@
|
|||
#!/bin/bash
|
||||
VIM=vim
|
||||
FAKEVIM=${FAKEVIM:-example/example}
|
||||
diff=meld
|
||||
cmdfile=fakevim_test_cmd.log
|
||||
INDENT=${INDENT:-' '}
|
||||
options="set smartindent|set autoindent|set nocindent"
|
||||
|
||||
print_help() {
|
||||
echo "USAGE: $0 FILE CMD..."
|
||||
echo " Run input in both Vim and FakeVim and compare result."
|
||||
echo " Results are stored in FILE.vim and FILE.fakevim."
|
||||
echo " Tests for FakeVim in Qt Creator are stored in \"$cmdfile\" file."
|
||||
}
|
||||
|
||||
print() {
|
||||
for arg in "$@"; do
|
||||
if [ "$arg" == "N" ]; then
|
||||
printf '\n'
|
||||
else
|
||||
printf "%s" "$arg"
|
||||
fi
|
||||
done >> "$cmdfile"
|
||||
}
|
||||
|
||||
print_content() {
|
||||
local file=$1
|
||||
sed \
|
||||
-e 's/"/\\"/g' \
|
||||
-e 's/^/'"$INDENT"'"/' \
|
||||
-e 's/$/" N/' "$file" \
|
||||
>> "$cmdfile"
|
||||
}
|
||||
|
||||
vim_exec() {
|
||||
for cmd in "$@"; do
|
||||
printf "%s" "|map \\X $cmd|normal \\X"
|
||||
done
|
||||
}
|
||||
|
||||
run_vim() {
|
||||
local file=$1
|
||||
shift
|
||||
"$VIM" \
|
||||
-c "$options" \
|
||||
-c "$(vim_exec "$@")" \
|
||||
-c "normal i|" \
|
||||
-c "wq" "$file"
|
||||
}
|
||||
|
||||
run_fakevim() {
|
||||
local file=$1
|
||||
shift
|
||||
find_fakevim
|
||||
"$FAKEVIM" "$file" \
|
||||
":$options|set nopasskeys|set nopasscontrolkey<CR>" \
|
||||
"$@" "<ESC><ESC>i|<ESC>" \
|
||||
":wq<CR>"
|
||||
}
|
||||
|
||||
find_fakevim() {
|
||||
if [ ! -x "$FAKEVIM" ]; then
|
||||
dir=$(dirname "$(readlink -f "$0")")
|
||||
FAKEVIM=$(find "$dir" -type f -executable -name test | head -1)
|
||||
fi
|
||||
}
|
||||
|
||||
print_test() {
|
||||
local header=$1
|
||||
local file=$2
|
||||
local footer=$3
|
||||
|
||||
print "$header" N
|
||||
print_content "$file"
|
||||
print "$footer" N
|
||||
}
|
||||
|
||||
same() {
|
||||
cmp "$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
main() {
|
||||
set -e
|
||||
|
||||
if [ "$#" -lt 2 ]; then
|
||||
print_help
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local file=$1
|
||||
shift # rest are commands
|
||||
|
||||
rm -f "$cmdfile"
|
||||
#cp ~/.vimrc fakevimrc
|
||||
|
||||
print_test 'data.setText(' "$file" ');'
|
||||
|
||||
# run command through Vim
|
||||
local vimoutfile=${file}.vim
|
||||
cp "$file" "$vimoutfile"
|
||||
run_vim "$vimoutfile" "$@"
|
||||
|
||||
print_test "KEYS(\"$*\"," "$vimoutfile" ');'
|
||||
|
||||
local fakevimoutfile=${file}.fakevim
|
||||
cp "$file" "$fakevimoutfile"
|
||||
run_fakevim "$fakevimoutfile" "$@"
|
||||
|
||||
if same "$fakevimoutfile" "$vimoutfile"; then
|
||||
echo OK, same result from Vim and FakeVim.
|
||||
else
|
||||
echo FAILED, different result from Vim and FakeVim.
|
||||
$diff "$fakevimoutfile" "$vimoutfile"
|
||||
fi
|
||||
|
||||
reset
|
||||
cat "$cmdfile"
|
||||
sed 's/^/ /' "$cmdfile" | xclip -i
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
From 7d2323e1d13d0e53832d65038e926266bc9d9af3 Mon Sep 17 00:00:00 2001
|
||||
From: Lukas Holecek <hluk@email.cz>
|
||||
Date: Wed, 3 Mar 2021 08:52:06 +0100
|
||||
Subject: [PATCH] Add patches for upstream
|
||||
|
||||
---
|
||||
fakevim/fakevimactions.h | 14 +++++++++-----
|
||||
fakevim/fakevimhandler.h | 12 +++++++++---
|
||||
2 files changed, 18 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/fakevim/fakevimactions.h b/fakevim/fakevimactions.h
|
||||
index 69131c7..c93cc6b 100644
|
||||
--- a/fakevim/fakevimactions.h
|
||||
+++ b/fakevim/fakevimactions.h
|
||||
@@ -25,8 +25,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
-#ifndef FAKEVIM_STANDALONE
|
||||
-# include <utils/aspects.h>
|
||||
+#define FAKEVIM_STANDALONE
|
||||
+
|
||||
+#ifdef FAKEVIM_STANDALONE
|
||||
+# include "private/fakevim_export.h"
|
||||
+#else
|
||||
+# include <utils/savedaction.h>
|
||||
#endif
|
||||
|
||||
#include <QCoreApplication>
|
||||
@@ -39,7 +43,7 @@ namespace FakeVim {
|
||||
namespace Internal {
|
||||
|
||||
#ifdef FAKEVIM_STANDALONE
|
||||
-class FvBaseAspect
|
||||
+class FAKEVIM_EXPORT FvBaseAspect
|
||||
{
|
||||
public:
|
||||
FvBaseAspect();
|
||||
@@ -95,7 +99,7 @@ using FvStringAspect = Utils::StringAspect;
|
||||
|
||||
#endif
|
||||
|
||||
-class FakeVimSettings final : public FvAspectContainer
|
||||
+class FAKEVIM_EXPORT FakeVimSettings final : public FvAspectContainer
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(FakeVim)
|
||||
|
||||
@@ -166,7 +170,7 @@ class FakeVimSettings final : public FvAspectContainer
|
||||
QHash<FvBaseAspect *, QString> m_aspectToName;
|
||||
};
|
||||
|
||||
-FakeVimSettings *fakeVimSettings();
|
||||
+FAKEVIM_EXPORT FakeVimSettings *fakeVimSettings();
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace FakeVim
|
||||
diff --git a/fakevim/fakevimhandler.h b/fakevim/fakevimhandler.h
|
||||
index 9ba321f..33a63f7 100644
|
||||
--- a/fakevim/fakevimhandler.h
|
||||
+++ b/fakevim/fakevimhandler.h
|
||||
@@ -25,6 +25,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
+#define FAKEVIM_STANDALONE
|
||||
+
|
||||
+#ifdef FAKEVIM_STANDALONE
|
||||
+# include "private/fakevim_export.h"
|
||||
+#endif
|
||||
+
|
||||
#include <QObject>
|
||||
#include <QTextEdit>
|
||||
|
||||
@@ -45,7 +51,7 @@ enum RangeMode
|
||||
RangeBlockAndTailMode // Ctrl-v for D and X
|
||||
};
|
||||
|
||||
-struct Range
|
||||
+struct FAKEVIM_EXPORT Range
|
||||
{
|
||||
Range() = default;
|
||||
Range(int b, int e, RangeMode m = RangeCharMode);
|
||||
@@ -57,7 +63,7 @@ struct Range
|
||||
RangeMode rangemode = RangeCharMode;
|
||||
};
|
||||
|
||||
-struct ExCommand
|
||||
+struct FAKEVIM_EXPORT ExCommand
|
||||
{
|
||||
ExCommand() = default;
|
||||
ExCommand(const QString &cmd, const QString &args = QString(),
|
||||
@@ -102,7 +108,7 @@ class Signal
|
||||
std::vector<Callable> m_callables;
|
||||
};
|
||||
|
||||
-class FakeVimHandler : public QObject
|
||||
+class FAKEVIM_EXPORT FakeVimHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
--
|
||||
2.29.2
|
||||
|
19
src/libraries/fakevim/utils/test.cpp
Normal file
19
src/libraries/fakevim/utils/test.cpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
class SomeClass {
|
||||
public:
|
||||
SomeClass(const std::string &var) : m_var(var) {}
|
||||
private:
|
||||
std::string m_var;
|
||||
};
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
using namespace std;
|
||||
cout << "TESTING...";
|
||||
cout << "1";
|
||||
cout << "2";
|
||||
cout << "3";
|
||||
return 0;
|
||||
}
|
56
src/libraries/fakevim/utils/update_from_qtc.sh
Executable file
56
src/libraries/fakevim/utils/update_from_qtc.sh
Executable file
|
@ -0,0 +1,56 @@
|
|||
#!/bin/bash
|
||||
files_to_update=(
|
||||
fakevimactions.cpp
|
||||
fakevimactions.h
|
||||
fakevimhandler.cpp
|
||||
fakevimhandler.h
|
||||
fakevimtr.h
|
||||
|
||||
utils/hostosinfo.h
|
||||
utils/optional.h
|
||||
utils/qtcassert.cpp
|
||||
utils/qtcassert.h
|
||||
utils/utils_global.h
|
||||
|
||||
3rdparty/optional/optional.hpp
|
||||
)
|
||||
|
||||
qtc_home=$1
|
||||
|
||||
script_dir=$(dirname "$(readlink -f "$0")")
|
||||
base_dir=$script_dir/..
|
||||
|
||||
die() {
|
||||
echo "$1" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
[ -n "$qtc_home" ] ||
|
||||
die "Usage: $0 PATH_TO_QT_CREATOR"
|
||||
|
||||
echo "--- Fetching latest development code for Qt Creator"
|
||||
cd "$qtc_home"
|
||||
git fetch origin master
|
||||
git checkout origin/master
|
||||
commit=$(git rev-parse --short HEAD)
|
||||
|
||||
echo "--- Updating source files"
|
||||
cd "$base_dir/fakevim"
|
||||
for file in "${files_to_update[@]}"; do
|
||||
echo "-- $file"
|
||||
if [[ "$file" == fakevim* ]]; then
|
||||
dir=plugins/fakevim
|
||||
else
|
||||
dir=libs
|
||||
fi
|
||||
rsync --mkpath -- "$qtc_home/src/$dir/$file" "$file"
|
||||
git add -- "$file"
|
||||
done
|
||||
|
||||
echo "--- Patching source files and creating commit"
|
||||
git commit -m "Update from Qt Creator (commit $commit)"
|
||||
git apply -- "$script_dir/patches/add-patches-for-upstream.patch"
|
||||
git add -- "${files_to_update[@]}"
|
||||
git commit --amend --no-edit --allow-empty
|
|
@ -64,6 +64,7 @@
|
|||
#include <QMessageBox>
|
||||
#include <QMimeData>
|
||||
#include <QPageSetupDialog>
|
||||
#include <QPointer>
|
||||
#include <QPrintDialog>
|
||||
#include <QPrinter>
|
||||
#include <QProcess>
|
||||
|
@ -656,46 +657,123 @@ void MainWindow::initFakeVim(QOwnNotesMarkdownTextEdit *noteTextEdit) {
|
|||
handler->installEventFilter();
|
||||
handler->setupWidget();
|
||||
|
||||
auto proxy = new FakeVimProxy(noteTextEdit, this, handler);
|
||||
QPointer<FakeVimProxy> proxy = new FakeVimProxy(noteTextEdit, this, handler);
|
||||
|
||||
using namespace FakeVim::Internal;
|
||||
|
||||
QSettings settings;
|
||||
bool setExpandTab = !settings.value(QStringLiteral("Editor/useTabIndent")).toBool();
|
||||
FakeVim::Internal::theFakeVimSettings()->item("et")->setValue(setExpandTab);
|
||||
FakeVim::Internal::theFakeVimSettings()->item("ts")->setValue(Utils::Misc::indentSize());
|
||||
FakeVim::Internal::theFakeVimSettings()->item("sw")->setValue(Utils::Misc::indentSize());
|
||||
fakeVimSettings()->item("et")->setValue(setExpandTab);
|
||||
fakeVimSettings()->item("ts")->setValue(Utils::Misc::indentSize());
|
||||
fakeVimSettings()->item("sw")->setValue(Utils::Misc::indentSize());
|
||||
|
||||
QObject::connect(handler,
|
||||
&FakeVim::Internal::FakeVimHandler::commandBufferChanged,
|
||||
proxy, &FakeVimProxy::changeStatusMessage);
|
||||
QObject::connect(
|
||||
handler, &FakeVim::Internal::FakeVimHandler::extraInformationChanged,
|
||||
proxy, &FakeVimProxy::changeExtraInformation);
|
||||
QObject::connect(handler,
|
||||
&FakeVim::Internal::FakeVimHandler::statusDataChanged,
|
||||
proxy, &FakeVimProxy::changeStatusData);
|
||||
QObject::connect(handler,
|
||||
&FakeVim::Internal::FakeVimHandler::highlightMatches,
|
||||
proxy, &FakeVimProxy::highlightMatches);
|
||||
QObject::connect(
|
||||
handler, &FakeVim::Internal::FakeVimHandler::handleExCommandRequested,
|
||||
proxy, &FakeVimProxy::handleExCommand);
|
||||
QObject::connect(
|
||||
handler, &FakeVim::Internal::FakeVimHandler::requestSetBlockSelection,
|
||||
proxy, &FakeVimProxy::requestSetBlockSelection);
|
||||
QObject::connect(
|
||||
handler,
|
||||
&FakeVim::Internal::FakeVimHandler::requestDisableBlockSelection, proxy,
|
||||
&FakeVimProxy::requestDisableBlockSelection);
|
||||
QObject::connect(
|
||||
handler, &FakeVim::Internal::FakeVimHandler::requestHasBlockSelection,
|
||||
proxy, &FakeVimProxy::requestHasBlockSelection);
|
||||
{
|
||||
auto h = [proxy](const QString &contents, int cursorPos, int anchorPos, int msgLvl) {
|
||||
if (!proxy) {
|
||||
return;
|
||||
}
|
||||
proxy->changeStatusMessage(contents, cursorPos, anchorPos, msgLvl);
|
||||
};
|
||||
handler->commandBufferChanged.connect(h);
|
||||
}
|
||||
|
||||
QObject::connect(handler, &FakeVim::Internal::FakeVimHandler::indentRegion,
|
||||
proxy, &FakeVimProxy::indentRegion);
|
||||
QObject::connect(
|
||||
handler, &FakeVim::Internal::FakeVimHandler::checkForElectricCharacter,
|
||||
proxy, &FakeVimProxy::checkForElectricCharacter);
|
||||
{
|
||||
auto h = [proxy](const QString &msg) {
|
||||
if (!proxy) {
|
||||
return;
|
||||
}
|
||||
proxy->changeExtraInformation(msg);
|
||||
};
|
||||
handler->extraInformationChanged.connect(h);
|
||||
}
|
||||
|
||||
{
|
||||
auto h = [proxy](const QString &msg) {
|
||||
if (!proxy) {
|
||||
return;
|
||||
}
|
||||
proxy->changeStatusData(msg);
|
||||
};
|
||||
handler->statusDataChanged.connect(h);
|
||||
}
|
||||
|
||||
{
|
||||
auto h = [proxy](const QString &msg) {
|
||||
if (!proxy) {
|
||||
return;
|
||||
}
|
||||
proxy->highlightMatches(msg);
|
||||
};
|
||||
handler->highlightMatches.connect(h);
|
||||
}
|
||||
|
||||
{
|
||||
auto h = [proxy](bool *handled, const ExCommand &cmd) {
|
||||
if (!proxy) {
|
||||
if (handled) {
|
||||
*handled = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
proxy->handleExCommand(handled, cmd);
|
||||
};
|
||||
handler->handleExCommandRequested.connect(h);
|
||||
}
|
||||
|
||||
{
|
||||
auto h = [proxy](const QTextCursor &cursor) {
|
||||
if (!proxy) {
|
||||
return;
|
||||
}
|
||||
proxy->requestSetBlockSelection(cursor);
|
||||
};
|
||||
handler->requestSetBlockSelection.connect(h);
|
||||
}
|
||||
|
||||
{
|
||||
auto h = [proxy]() {
|
||||
if (!proxy) {
|
||||
return;
|
||||
}
|
||||
proxy->requestDisableBlockSelection();
|
||||
};
|
||||
handler->requestDisableBlockSelection.connect(h);
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
auto h = [proxy](bool *on) {
|
||||
if (!proxy) {
|
||||
if (on)
|
||||
*on = false;
|
||||
return;
|
||||
}
|
||||
proxy->requestHasBlockSelection(on);
|
||||
};
|
||||
handler->requestHasBlockSelection.connect(h);
|
||||
}
|
||||
|
||||
{
|
||||
auto h = [proxy](int beginLine, int endLine, QChar typedChar) {
|
||||
if (!proxy) {
|
||||
return;
|
||||
}
|
||||
proxy->indentRegion(beginLine, endLine, typedChar);
|
||||
};
|
||||
handler->indentRegion.connect(h);
|
||||
}
|
||||
|
||||
{
|
||||
auto h = [proxy](bool *result, QChar c) {
|
||||
if (!proxy) {
|
||||
return;
|
||||
}
|
||||
proxy->checkForElectricCharacter(result, c);
|
||||
};
|
||||
handler->checkForElectricCharacter.connect(h);
|
||||
}
|
||||
|
||||
// regular signal
|
||||
QObject::connect(
|
||||
proxy, &FakeVimProxy::handleInput, handler,
|
||||
[handler](const QString &text) { handler->handleInput(text); });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue