Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ set(${bin}_sources
# 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")
qt6_wrap_cpp(${bin}_mocced "fakevim/fakevimhandler.h")
target_sources(${bin} PRIVATE ${${bin}_mocced})

target_compile_definitions(${bin} PRIVATE
Expand All @@ -40,15 +39,15 @@ option(BUILD_TESTS "Build tests")
if (BUILD_TESTS)
message(STATUS "Building tests")

find_package(Qt5Test REQUIRED)
find_package(Qt6Test 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_link_libraries(fakevim_test fakevim Qt6::Widgets Qt6::Test)

target_include_directories(fakevim_test PRIVATE
${CMAKE_SOURCE_DIR}/fakevim
Expand All @@ -67,5 +66,5 @@ if (BUILD_EXAMPLE)
set_property(TARGET fakevim_example PROPERTY AUTOMOC ON)

target_link_libraries(fakevim_example fakevim)
target_link_libraries(fakevim_example Qt5::Widgets)
target_link_libraries(fakevim_example Qt6::Widgets)
endif()
5 changes: 0 additions & 5 deletions cmake/cxx17.cmake

This file was deleted.

1 change: 1 addition & 0 deletions cmake/library.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ else()
endif()

add_library(${bin} ${libtype} ${${bin}_sources})
target_compile_features(${bin} PUBLIC cxx_std_20)
set_target_properties(${bin} PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
Expand Down
8 changes: 4 additions & 4 deletions cmake/qt.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
find_package(Qt5Widgets REQUIRED)
find_package(Qt6Widgets REQUIRED)

include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS})
target_link_libraries(${bin} Qt5::Widgets)
include_directories(${Qt6Gui_PRIVATE_INCLUDE_DIRS})
target_link_libraries(${bin} Qt6::Widgets)

set(${bin}_pkg_config_requires ${${bin}_pkg_config_requires} Qt5Widgets)
set(${bin}_pkg_config_requires ${${bin}_pkg_config_requires} Qt6Widgets)
6 changes: 3 additions & 3 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ cmake_minimum_required(VERSION 2.8.8)
project(fakevim_example)

find_package(fakevim REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt6Widgets REQUIRED)

set(bin fakevim_example)
add_executable(${bin} main.cpp editor.cpp)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
qt5_generate_moc("editor.cpp" "editor.moc")
qt6_generate_moc("editor.cpp" "editor.moc")
target_sources(${bin} PRIVATE "editor.moc")

target_link_libraries(${bin} fakevim)
target_link_libraries(${bin} Qt5::Widgets)
target_link_libraries(${bin} Qt6::Widgets)
23 changes: 12 additions & 11 deletions example/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <QMessageBox>
#include <QPainter>
#include <QPlainTextEdit>
#include <QRegularExpression>
#include <QStatusBar>
#include <QTextBlock>
#include <QTextEdit>
Expand Down Expand Up @@ -149,35 +150,35 @@ Proxy *connectSignals(FakeVimHandler *handler, QMainWindow *mainWindow, QWidget
Proxy *proxy = new Proxy(editor, mainWindow, handler);

handler->commandBufferChanged
.connect([proxy](const QString &contents, int cursorPos, int /*anchorPos*/, int /*messageLevel*/) {
.set([proxy](const QString &contents, int cursorPos, int /*anchorPos*/, int /*messageLevel*/) {
proxy->changeStatusMessage(contents, cursorPos);
});
handler->extraInformationChanged.connect([proxy](const QString &text) {
handler->extraInformationChanged.set([proxy](const QString &text) {
proxy->changeExtraInformation(text);
});
handler->statusDataChanged.connect([proxy](const QString &text) {
handler->statusDataChanged.set([proxy](const QString &text) {
proxy->changeStatusData(text);
});
handler->highlightMatches.connect([proxy](const QString &needle) {
handler->highlightMatches.set([proxy](const QString &needle) {
proxy->highlightMatches(needle);
});
handler->handleExCommandRequested.connect([proxy](bool *handled, const ExCommand &cmd) {
handler->handleExCommandRequested.set([proxy](bool *handled, const ExCommand &cmd) {
proxy->handleExCommand(handled, cmd);
});
handler->requestSetBlockSelection.connect([proxy](const QTextCursor &cursor) {
handler->requestSetBlockSelection.set([proxy](const QTextCursor &cursor) {
proxy->requestSetBlockSelection(cursor);
});
handler->requestDisableBlockSelection.connect([proxy] {
handler->requestDisableBlockSelection.set([proxy] {
proxy->requestDisableBlockSelection();
});
handler->requestHasBlockSelection.connect([proxy](bool *on) {
handler->requestHasBlockSelection.set([proxy](bool *on) {
proxy->requestHasBlockSelection(on);
});

handler->indentRegion.connect([proxy](int beginBlock, int endBlock, QChar typedChar) {
handler->indentRegion.set([proxy](int beginBlock, int endBlock, QChar typedChar) {
proxy->indentRegion(beginBlock, endBlock, typedChar);
});
handler->checkForElectricCharacter.connect([proxy](bool *result, QChar c) {
handler->checkForElectricCharacter.set([proxy](bool *result, QChar c) {
proxy->checkForElectricCharacter(result, c);
});

Expand Down Expand Up @@ -222,7 +223,7 @@ void Proxy::highlightMatches(const QString &pattern)
selection.format.setForeground(Qt::black);

// Highlight matches.
QRegExp re(pattern);
QRegularExpression re(pattern);
QTextCursor cur = doc->find(re);

m_searchSelection.clear();
Expand Down
83 changes: 42 additions & 41 deletions fakevim/fakevimactions.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#include "fakevimactions.h"
#include "fakevimhandler.h"
#include "fakevimtr.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
Expand Down Expand Up @@ -58,40 +59,40 @@ FakeVimSettings::FakeVimSettings()
setAutoApply(false);

#ifndef FAKEVIM_STANDALONE
setup(&useFakeVim, false, "UseFakeVim", {}, tr("Use FakeVim"));
setup(&useFakeVim, false, "UseFakeVim", {}, Tr::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"));
setup(&readVimRc, false, "ReadVimRc", {}, Tr::tr("Read .vimrc from location:"));
setup(&vimRcPath, QString(), "VimRcPath", {}, {}); // Tr::tr("Path to .vimrc")
setup(&showMarks, false, "ShowMarks", "sm", Tr::tr("Show position of text marks"));
setup(&passControlKey, false, "PassControlKey", "pck", Tr::tr("Pass control keys"));
setup(&passKeys, true, "PassKeys", "pk", Tr::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 indentation"));
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(&startOfLine, true, "StartOfLine", "sol", Tr::tr("Start of line"));
setup(&tabStop, 8, "TabStop", "ts", Tr::tr("Tabulator size:"));
setup(&smartTab, false, "SmartTab", "sta", Tr::tr("Smart tabulators"));
setup(&hlSearch, true, "HlSearch", "hls", Tr::tr("Highlight search results"));
setup(&shiftWidth, 8, "ShiftWidth", "sw", Tr::tr("Shift width:"));
setup(&expandTab, false, "ExpandTab", "et", Tr::tr("Expand tabulators"));
setup(&autoIndent, false, "AutoIndent", "ai", Tr::tr("Automatic indentation"));
setup(&smartIndent, false, "SmartIndent", "si", Tr::tr("Smart indentation"));
setup(&incSearch, true, "IncSearch", "is", Tr::tr("Incremental search"));
setup(&useCoreSearch, false, "UseCoreSearch", "ucs", Tr::tr("Use search dialog"));
setup(&smartCase, false, "SmartCase", "scs", Tr::tr("Use smartcase"));
setup(&ignoreCase, false, "IgnoreCase", "ic", Tr::tr("Use ignorecase"));
setup(&wrapScan, true, "WrapScan", "ws", Tr::tr("Use wrapscan"));
setup(&tildeOp, false, "TildeOp", "top", Tr::tr("Use tildeop"));
setup(&showCmd, true, "ShowCmd", "sc", Tr::tr("Show partial command"));
setup(&relativeNumber, false, "RelativeNumber", "rnu", Tr::tr("Show line numbers relative to cursor"));
setup(&blinkingCursor, false, "BlinkingCursor", "bc", Tr::tr("Blinking cursor"));
setup(&scrollOff, 0, "ScrollOff", "so", Tr::tr("Scroll offset:"));
setup(&backspace, "indent,eol,start",
"Backspace", "bs", tr("Backspace:"));
"Backspace", "bs", Tr::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(""));
"IsKeyword", "isk", Tr::tr("Keyword characters:"));
setup(&clipboard, {}, "Clipboard", "cb", Tr::tr(""));
setup(&formatOptions, {}, "formatoptions", "fo", Tr::tr(""));

// Emulated plugins
setup(&emulateVimCommentary, false, "commentary", {}, "vim-commentary");
Expand All @@ -101,35 +102,35 @@ FakeVimSettings::FakeVimSettings()
setup(&emulateSurround, false, "surround", {}, "vim-surround");

// Some polish
useFakeVim.setDisplayName(tr("Use Vim-style Editing"));
useFakeVim.setDisplayName(Tr::tr("Use Vim-style Editing"));

relativeNumber.setToolTip(tr("Displays line numbers relative to the line containing "
relativeNumber.setToolTip(Tr::tr("Displays line numbers relative to the line containing "
"text cursor."));

passControlKey.setToolTip(tr("Does not interpret key sequences like Ctrl-S in FakeVim "
passControlKey.setToolTip(Tr::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 "
passKeys.setToolTip(Tr::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."));
tabStop.setToolTip(Tr::tr("Vim tabstop option."));

#ifndef FAKEVIM_STANDALONE
backspace.setDisplayStyle(FvStringAspect::LineEditDisplay);
isKeyword.setDisplayStyle(FvStringAspect::LineEditDisplay);

const QString vimrcDefault = QLatin1String(
#ifdef Q_OS_UNIX
"$HOME/.vimrc"
"$HOME/.vimrc"
#else
"%USERPROFILE%\\_vimrc"
"%USERPROFILE%\\_vimrc"
#endif
)
);
vimRcPath.setExpectedKind(PathChooser::File);
vimRcPath.setToolTip(tr("Keep empty to use the default path, i.e. "
vimRcPath.setToolTip(Tr::tr("Keep empty to use the default path, i.e. "
"%USERPROFILE%\\_vimrc on Windows, ~/.vimrc otherwise."));
vimRcPath.setPlaceHolderText(tr("Default: %1").arg(vimrcDefault));
vimRcPath.setPlaceHolderText(Tr::tr("Default: %1").arg(vimrcDefault));
vimRcPath.setDisplayStyle(FvStringAspect::PathChooserDisplay);
#endif
}
Expand All @@ -145,10 +146,10 @@ 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);
return Tr::tr("Unknown option: %1").arg(name);
if (aspect == &tabStop || aspect == &shiftWidth) {
if (value.toInt() <= 0)
return tr("Argument must be positive: %1=%2")
return Tr::tr("Argument must be positive: %1=%2")
.arg(name).arg(value);
}
aspect->setValue(value);
Expand Down
6 changes: 3 additions & 3 deletions fakevim/fakevimactions.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#ifndef FAKEVIM_STANDALONE
#define FAKEVIM_STANDALONE
#endif

#ifdef FAKEVIM_STANDALONE
# include "private/fakevim_export.h"
Expand Down Expand Up @@ -79,8 +81,6 @@ using FvStringAspect = Utils::StringAspect;

class FAKEVIM_EXPORT FakeVimSettings final : public FvAspectContainer
{
Q_DECLARE_TR_FUNCTIONS(FakeVim)

public:
FakeVimSettings();
~FakeVimSettings();
Expand Down
Loading