From 489d91e6a5c3120f92bccd9de1f4a00bdd222a64 Mon Sep 17 00:00:00 2001 From: Yaraslau Tamashevich Date: Mon, 6 Mar 2023 19:40:06 +0200 Subject: [PATCH 001/112] add CMakeUserPresets.json in gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f696387fcf..0e3829e129 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ compile_commands.json # CMake (CTest) /Testing/ +CMakeUserPresets.json # This is a workspace-local sandbox directory with test files not to be included in Git. sandbox From 60d59643ad6d6d0a491327f9f6bfbeab8af9a5af Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Mon, 6 Mar 2023 20:22:20 +0100 Subject: [PATCH 002/112] Fixes terminfo `tsl` to how todays apps are using it (e.g. zsh) to simply set the window title. Signed-off-by: Christian Parpart --- metainfo.xml | 2 +- src/vtbackend/Capabilities.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/metainfo.xml b/metainfo.xml index fd47c5f88d..33f508a942 100644 --- a/metainfo.xml +++ b/metainfo.xml @@ -106,7 +106,7 @@
    -
  • ...
  • +
  • Fixes terminfo `tsl` to how todays apps are using it (e.g. zsh) to simply set the window title.
diff --git a/src/vtbackend/Capabilities.cpp b/src/vtbackend/Capabilities.cpp index a6582dc238..44c86daea3 100644 --- a/src/vtbackend/Capabilities.cpp +++ b/src/vtbackend/Capabilities.cpp @@ -211,8 +211,9 @@ namespace // tsl (to_status_line): // 1. DECSSDT 2 (show to host writable status line) // 2. DECSASD 1 (set host writable statusline as active target) - // 3. CUP 1;%d (move cursor to given column, defaulting to 1) - String { "ts"_tcap, "tsl"sv, "\033[2$~\033[1$}\033[1;%dH"sv }, // To status line (used to set window titles) + // 3. CUP (move cursor to top left) + // 4. ED 2 (clear screen) + String { "ts"_tcap, "tsl"sv, "\033[2$~\033[1$}\033[H\033[2J"sv }, // To status line (used to set window titles) // fsl (from_status_line): // 1. DECSASD (set main display as active display target again) From 76b91b362f838892ec94a25f405065818b34e319 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Tue, 7 Mar 2023 05:53:00 +0100 Subject: [PATCH 003/112] Adds `profiles.*.permissions.display_host_writable_statusline` to allow the user to intervene in `DECSSDT` VT sequence to show the host writable statusline even if the indicator statusline is currently active Signed-off-by: Christian Parpart --- metainfo.xml | 1 + src/contour/Config.cpp | 8 ++++++++ src/contour/Config.h | 1 + src/contour/TerminalSession.cpp | 18 +++++++++++++++++- src/contour/TerminalSession.h | 3 ++- src/contour/contour.yml | 3 +++ src/contour/display/TerminalWidget.cpp | 2 +- src/contour/display/TerminalWidget.h | 2 +- src/contour/helper.cpp | 8 ++++---- src/contour/helper.h | 2 +- src/vtbackend/Screen.cpp | 7 ++++++- src/vtbackend/Terminal.cpp | 5 +++++ src/vtbackend/Terminal.h | 2 ++ 13 files changed, 52 insertions(+), 10 deletions(-) diff --git a/metainfo.xml b/metainfo.xml index 33f508a942..1a40df8cf8 100644 --- a/metainfo.xml +++ b/metainfo.xml @@ -107,6 +107,7 @@
  • Fixes terminfo `tsl` to how todays apps are using it (e.g. zsh) to simply set the window title.
  • +
  • Adds `profiles.*.permissions.display_host_writable_statusline` to allow the user to intervene in `DECSSDT` VT sequence to show the host writable statusline even if the indicator statusline is currently active.
diff --git a/src/contour/Config.cpp b/src/contour/Config.cpp index dd5910cdfd..b93863d71d 100644 --- a/src/contour/Config.cpp +++ b/src/contour/Config.cpp @@ -1450,6 +1450,14 @@ namespace profile.permissions.changeFont = x.value(); } + strValue = "ask"; + if (tryLoadChildRelative( + _usedKeys, _profile, basePath, "permissions.display_host_writable_statusline", strValue)) + { + if (auto x = toPermission(strValue)) + profile.permissions.displayHostWritableStatusLine = x.value(); + } + if (tryLoadChildRelative(_usedKeys, _profile, basePath, "font.size", profile.fonts.size.pt)) { if (profile.fonts.size < MinimumFontSize) diff --git a/src/contour/Config.h b/src/contour/Config.h index 8709ae6609..00fccab0d3 100644 --- a/src/contour/Config.h +++ b/src/contour/Config.h @@ -171,6 +171,7 @@ struct TerminalProfile { Permission captureBuffer = Permission::Ask; Permission changeFont = Permission::Ask; + Permission displayHostWritableStatusLine = Permission::Ask; } permissions; bool drawBoldTextWithBrightColors = false; diff --git a/src/contour/TerminalSession.cpp b/src/contour/TerminalSession.cpp index 88fa6b0436..413a78c443 100644 --- a/src/contour/TerminalSession.cpp +++ b/src/contour/TerminalSession.cpp @@ -288,6 +288,22 @@ void TerminalSession::requestCaptureBuffer(LineCount lines, bool logical) }); } +void TerminalSession::requestShowHostWritableStatusLine() +{ + if (!display_) + return; + + display_->post([this]() { + if (display_->requestPermission(profile_.permissions.displayHostWritableStatusLine, + "display host writable statusline")) + { + terminal_.setStatusDisplay(terminal::StatusDisplayType::HostWritable); + DisplayLog()("requestCaptureBuffer: Finished. Waking up I/O thread."); + flushInput(); + } + }); +} + terminal::FontDef TerminalSession::getFontDef() { return display_->getFontDef(); @@ -1322,7 +1338,7 @@ void TerminalSession::followHyperlink(terminal::HyperlinkInfo const& _hyperlink) QDesktopServices::openUrl(QString::fromUtf8(_hyperlink.uri.c_str())); } -bool TerminalSession::requestPermission(config::Permission _allowedByConfig, string_view _topicText) +bool TerminalSession::requestPermission(config::Permission _allowedByConfig, string const& _topicText) { return display_->requestPermission(_allowedByConfig, _topicText); } diff --git a/src/contour/TerminalSession.h b/src/contour/TerminalSession.h index efe41d22eb..2a6de9dfdc 100644 --- a/src/contour/TerminalSession.h +++ b/src/contour/TerminalSession.h @@ -85,6 +85,7 @@ class TerminalSession: public QObject, public terminal::Terminal::Events // Terminal::Events // void requestCaptureBuffer(terminal::LineCount lineCount, bool logical) override; + void requestShowHostWritableStatusLine() override; void bell() override; void bufferChanged(terminal::ScreenType) override; void renderBufferUpdated() override; @@ -206,7 +207,7 @@ class TerminalSession: public QObject, public terminal::Terminal::Events bool reloadConfigWithProfile(std::string const& _profileName); bool resetConfig(); void followHyperlink(terminal::HyperlinkInfo const& _hyperlink); - bool requestPermission(config::Permission _allowedByConfig, std::string_view _topicText); + bool requestPermission(config::Permission _allowedByConfig, std::string const& _topicText); void setFontSize(text::font_size _size); void setDefaultCursor(); void configureTerminal(); diff --git a/src/contour/contour.yml b/src/contour/contour.yml index 3c7242f0f7..ee9f6b8930 100644 --- a/src/contour/contour.yml +++ b/src/contour/contour.yml @@ -241,6 +241,9 @@ profiles: # Allows capturing the screen buffer via `CSI > Pm ; Ps ; Pc ST`. # The response can be read from stdin as sequence `OSC 314 ; ST` capture_buffer: ask + # Allows displaying the "Host Writable Statusline" even when + # the indicator statusline is currently shown. + display_host_writable_statusline: ask # If enabled, and you double-click on a word in the primary screen, # all other words matching this word will be highlighted as well. diff --git a/src/contour/display/TerminalWidget.cpp b/src/contour/display/TerminalWidget.cpp index 0b99696063..de95f71c08 100644 --- a/src/contour/display/TerminalWidget.cpp +++ b/src/contour/display/TerminalWidget.cpp @@ -856,7 +856,7 @@ void TerminalWidget::post(std::function _fn) postToObject(this, std::move(_fn)); } -bool TerminalWidget::requestPermission(config::Permission _allowedByConfig, string_view _topicText) +bool TerminalWidget::requestPermission(config::Permission _allowedByConfig, string const& _topicText) { return contour::requestPermission(rememberedPermissions_, this, _allowedByConfig, _topicText); } diff --git a/src/contour/display/TerminalWidget.h b/src/contour/display/TerminalWidget.h index 4408040c8e..558634a41a 100644 --- a/src/contour/display/TerminalWidget.h +++ b/src/contour/display/TerminalWidget.h @@ -130,7 +130,7 @@ class TerminalWidget: public QOpenGLWidget, private QOpenGLExtraFunctions [[nodiscard]] terminal::ImageSize cellSize() const; // (user requested) actions - bool requestPermission(config::Permission _allowedByConfig, std::string_view _topicText); + bool requestPermission(config::Permission _allowedByConfig, std::string const& _topicText); terminal::FontDef getFontDef(); void bell(); void copyToClipboard(std::string_view /*_data*/); diff --git a/src/contour/helper.cpp b/src/contour/helper.cpp index 1686ccfd83..0c5ab69a20 100644 --- a/src/contour/helper.cpp +++ b/src/contour/helper.cpp @@ -337,7 +337,7 @@ void spawnNewTerminal(string const& _programPath, bool requestPermission(PermissionCache& _cache, QWidget* _parent, config::Permission _allowedByConfig, - std::string_view _topicText) + std::string const& _topicText) { switch (_allowedByConfig) { @@ -351,7 +351,7 @@ bool requestPermission(PermissionCache& _cache, } // Did we remember a last interactive question? - if (auto const i = _cache.find(string(_topicText)); i != _cache.end()) + if (auto const i = _cache.find(_topicText); i != _cache.end()) return i->second; SessionLog()("Permission for {} requires asking user.", _topicText); @@ -367,8 +367,8 @@ bool requestPermission(PermissionCache& _cache, switch (reply) { - case QMessageBox::StandardButton::NoToAll: _cache[string(_topicText)] = false; break; - case QMessageBox::StandardButton::YesToAll: _cache[string(_topicText)] = true; [[fallthrough]]; + case QMessageBox::StandardButton::NoToAll: _cache[_topicText] = false; break; + case QMessageBox::StandardButton::YesToAll: _cache[_topicText] = true; [[fallthrough]]; case QMessageBox::StandardButton::Yes: return true; default: break; } diff --git a/src/contour/helper.h b/src/contour/helper.h index b6cc982901..713473d552 100644 --- a/src/contour/helper.h +++ b/src/contour/helper.h @@ -167,7 +167,7 @@ using PermissionCache = std::map; bool requestPermission(PermissionCache& _cache, QWidget* _parent, config::Permission _allowedByConfig, - std::string_view _topicText); + std::string const& _topicText); terminal::FontDef getFontDefinition(terminal::rasterizer::Renderer& _renderer); diff --git a/src/vtbackend/Screen.cpp b/src/vtbackend/Screen.cpp index d689b76582..62ddb73cdf 100644 --- a/src/vtbackend/Screen.cpp +++ b/src/vtbackend/Screen.cpp @@ -3656,7 +3656,12 @@ ApplyResult Screen::apply(FunctionDefinition const& function, Sequence con { case 0: _terminal.setStatusDisplay(StatusDisplayType::None); break; case 1: _terminal.setStatusDisplay(StatusDisplayType::Indicator); break; - case 2: _terminal.setStatusDisplay(StatusDisplayType::HostWritable); break; + case 2: + if (_terminal.statusDisplayType() == StatusDisplayType::Indicator) + _terminal.requestShowHostWritableStatusLine(); + else + _terminal.setStatusDisplay(StatusDisplayType::HostWritable); + break; default: return ApplyResult::Invalid; } break; diff --git a/src/vtbackend/Terminal.cpp b/src/vtbackend/Terminal.cpp index 9d47ebc3b7..999c68993d 100644 --- a/src/vtbackend/Terminal.cpp +++ b/src/vtbackend/Terminal.cpp @@ -1249,6 +1249,11 @@ void Terminal::requestCaptureBuffer(LineCount lines, bool logical) return _eventListener.requestCaptureBuffer(lines, logical); } +void Terminal::requestShowHostWritableStatusLine() +{ + _eventListener.requestShowHostWritableStatusLine(); +} + void Terminal::bell() { _eventListener.bell(); diff --git a/src/vtbackend/Terminal.h b/src/vtbackend/Terminal.h index e5a493ef0d..1f4e1c81c9 100644 --- a/src/vtbackend/Terminal.h +++ b/src/vtbackend/Terminal.h @@ -125,6 +125,7 @@ class Terminal virtual void onSelectionCompleted() {} virtual void requestWindowResize(LineCount, ColumnCount) {} virtual void requestWindowResize(Width, Height) {} + virtual void requestShowHostWritableStatusLine() {} virtual void setWindowTitle(std::string_view /*title*/) {} virtual void setTerminalProfile(std::string const& /*configProfileName*/) {} virtual void discardImage(Image const&) {} @@ -582,6 +583,7 @@ class Terminal // Screen's EventListener implementation // void requestCaptureBuffer(LineCount lines, bool logical); + void requestShowHostWritableStatusLine(); void bell(); void bufferChanged(ScreenType); void scrollbackBufferCleared(); From 57a1a0a952d09cf65f2093ebcc73bea0d14af4c7 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Tue, 28 Mar 2023 10:59:47 +0200 Subject: [PATCH 004/112] Extends `ViNormalMode` to toggle between insert and normal mode rather than just entering normal mode. Signed-off-by: Christian Parpart --- metainfo.xml | 1 + src/contour/TerminalSession.cpp | 5 ++++- src/contour/contour.yml | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/metainfo.xml b/metainfo.xml index 1a40df8cf8..b1c5944cfd 100644 --- a/metainfo.xml +++ b/metainfo.xml @@ -108,6 +108,7 @@
  • Fixes terminfo `tsl` to how todays apps are using it (e.g. zsh) to simply set the window title.
  • Adds `profiles.*.permissions.display_host_writable_statusline` to allow the user to intervene in `DECSSDT` VT sequence to show the host writable statusline even if the indicator statusline is currently active.
  • +
  • Extends `ViNormalMode` to toggle between insert and normal mode rather than just entering normal mode.
diff --git a/src/contour/TerminalSession.cpp b/src/contour/TerminalSession.cpp index 413a78c443..db5bb9d675 100644 --- a/src/contour/TerminalSession.cpp +++ b/src/contour/TerminalSession.cpp @@ -1027,7 +1027,10 @@ bool TerminalSession::operator()(actions::TraceStep) bool TerminalSession::operator()(actions::ViNormalMode) { - terminal().inputHandler().setMode(ViMode::Normal); + if (terminal().inputHandler().mode() == ViMode::Insert) + terminal().inputHandler().setMode(ViMode::Normal); + else if (terminal().inputHandler().mode() == ViMode::Normal) + terminal().inputHandler().setMode(ViMode::Insert); return true; } diff --git a/src/contour/contour.yml b/src/contour/contour.yml index ee9f6b8930..00de2573df 100644 --- a/src/contour/contour.yml +++ b/src/contour/contour.yml @@ -683,7 +683,7 @@ color_schemes: # - TraceEnter Enables trace mode, suspending execution until explicitly requested to continue (See TraceLeave and TraceStep). # - TraceLeave Disables trace mode. Any pending VT sequence will be flushed out and normal execution will be resumed. # - TraceStep Executes a single VT sequence that is to be executed next. -# - ViNormalMode Enters Vi-like normal mode. The cursor can then be moved via h/j/k/l movements and text can be selected via v, yanked via y, and clipboard pasted via p. +# - ViNormalMode Enters/Leaves Vi-like normal mode. The cursor can then be moved via h/j/k/l movements in normal mode and text can be selected via v, yanked via y, and clipboard pasted via p. # - WriteScreen Writes VT sequence in `chars` member to the screen (bypassing the application). input_mapping: From 2d2e1c92e45365fc9a0f1580fb7b7bb527252056 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Fri, 31 Mar 2023 05:28:55 +0200 Subject: [PATCH 005/112] [Github CI] Update APT database again. Signed-off-by: Christian Parpart --- .github/workflows/build.yml | 4 ++++ .github/workflows/codechecker-analysis.yml | 2 ++ .github/workflows/external_tests.yml | 11 ++++++----- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0c5e9dc95c..6530928513 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -357,6 +357,8 @@ jobs: with: key: "ccache-ubuntu2204-${{ matrix.compiler }}-${{ matrix.cxx }}-${{ matrix.build_type }}" max-size: 256M + - name: "update APT database" + run: sudo apt -q update - name: Installing xmllint for ci-set-vars run: sudo apt -qy install libxml2-utils - name: set environment variables @@ -507,6 +509,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v3 + - name: "update APT database" + run: sudo apt -q update - name: Installing xmllint for ci-set-vars run: sudo apt -qy install libxml2-utils - name: set variables diff --git a/.github/workflows/codechecker-analysis.yml b/.github/workflows/codechecker-analysis.yml index f419e6036c..8193c5eb7c 100644 --- a/.github/workflows/codechecker-analysis.yml +++ b/.github/workflows/codechecker-analysis.yml @@ -34,6 +34,8 @@ jobs: steps: - name: "Check out repository" uses: actions/checkout@v3 + - name: "update APT database" + run: sudo apt -q update - name: Installing xmllint for ci-set-vars run: sudo apt -qy install libxml2-utils - name: "Set variables for Contour build-like CI" diff --git a/.github/workflows/external_tests.yml b/.github/workflows/external_tests.yml index b779d69a69..97397bca27 100644 --- a/.github/workflows/external_tests.yml +++ b/.github/workflows/external_tests.yml @@ -84,8 +84,8 @@ jobs: with: path: "**/cpm_modules" key: ${{github.workflow}}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }} - # - name: "update APT database" - # run: sudo apt -q update + - name: "update APT database" + run: sudo apt -q update - name: Installing xmllint for ci-set-vars run: sudo apt -qy install libxml2-utils - name: set environment variables @@ -133,10 +133,11 @@ jobs: name: "Build notcurses" runs-on: ubuntu-22.04 steps: + - name: "update APT database" + run: sudo apt -q update - name: "install dependencies" run: | set -ex - # sudo apt -q update sudo apt install -y \ build-essential \ cmake \ @@ -253,8 +254,8 @@ jobs: CONTOUR_PREFIX: "" # valgrind --leak-check=full --num-callers=64 --error-exitcode=112" steps: - uses: actions/checkout@v3 - # - name: "update APT database" - # run: sudo apt -q update + - name: "update APT database" + run: sudo apt -q update - name: Installing xmllint for ci-set-vars run: sudo apt -qy install libxml2-utils - name: set environment variables From 5728aa9d516e1a9a592934b42fd8c0f26557f879 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Fri, 31 Mar 2023 05:23:07 +0200 Subject: [PATCH 006/112] [vtbackend] Fixes selecting a single character not working easily (#1066) Signed-off-by: Christian Parpart --- metainfo.xml | 1 + src/vtbackend/InputGenerator.cpp | 4 ++++ src/vtbackend/Selector.cpp | 2 -- src/vtbackend/Terminal.cpp | 12 +++++------- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/metainfo.xml b/metainfo.xml index ac6360e2a6..116ee6cbaf 100644 --- a/metainfo.xml +++ b/metainfo.xml @@ -107,6 +107,7 @@
  • Fixes terminfo `tsl` to how todays apps are using it (e.g. zsh) to simply set the window title.
  • +
  • Fixes selecting a single character not working easily (#1066).
  • Adds `profiles.*.permissions.display_host_writable_statusline` to allow the user to intervene in `DECSSDT` VT sequence to show the host writable statusline even if the indicator statusline is currently active.
  • Extends `ViNormalMode` to toggle between insert and normal mode rather than just entering normal mode.
  • Modal mode: Adds Return key to also move the cursor down (like vim).
  • diff --git a/src/vtbackend/InputGenerator.cpp b/src/vtbackend/InputGenerator.cpp index 480445f6b8..2b6cc4ef12 100644 --- a/src/vtbackend/InputGenerator.cpp +++ b/src/vtbackend/InputGenerator.cpp @@ -788,6 +788,10 @@ bool InputGenerator::generateMouseMove(Modifier modifier, PixelCoordinate pixelPosition, bool uiHandled) { + if (pos == _currentMousePosition && _mouseTransport != MouseTransport::SGRPixels) + // Only generate a mouse move event if the coordinate of interest(!) has actually changed. + return false; + auto const logged = [&](bool success) -> bool { if (success) { diff --git a/src/vtbackend/Selector.cpp b/src/vtbackend/Selector.cpp index c5b9a21da6..0fc31b4062 100644 --- a/src/vtbackend/Selector.cpp +++ b/src/vtbackend/Selector.cpp @@ -52,8 +52,6 @@ bool Selection::extend(CellLocation to) { assert(_state != State::Complete && "In order extend a selection, the selector must be active (started)."); - if (_to == to) - return false; _state = State::InProgress; _to = to; _onSelectionUpdated(); diff --git a/src/vtbackend/Terminal.cpp b/src/vtbackend/Terminal.cpp index 999c68993d..c592a151c3 100644 --- a/src/vtbackend/Terminal.cpp +++ b/src/vtbackend/Terminal.cpp @@ -768,13 +768,11 @@ void Terminal::sendMouseMoveEvent(Modifier modifier, clearSelection(); } - // Only continue if he mouse position has changed to a new grid value or we're tracking pixel values. - if (newPosition == _currentMousePosition && !isModeEnabled(DECMode::MouseSGRPixels)) - return; - - _currentMousePosition = newPosition; - - updateCursorHoveringState(); + if (newPosition != _currentMousePosition) + { + _currentMousePosition = newPosition; + updateCursorHoveringState(); + } if (!_leftMouseButtonPressed) return; From fd254d0ac0d7aabc521af7d0ba5fe1c2c8e8d38d Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Fri, 31 Mar 2023 05:47:31 +0200 Subject: [PATCH 007/112] [vtbackend] Fixes cycling between different selection modes with mouse clicks Signed-off-by: Christian Parpart --- metainfo.xml | 1 + src/vtbackend/Terminal.cpp | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/metainfo.xml b/metainfo.xml index 116ee6cbaf..657cefa7ba 100644 --- a/metainfo.xml +++ b/metainfo.xml @@ -108,6 +108,7 @@
    • Fixes terminfo `tsl` to how todays apps are using it (e.g. zsh) to simply set the window title.
    • Fixes selecting a single character not working easily (#1066).
    • +
    • Fixes cycling between different selection modes (by speed-clicking) not properly working.
    • Adds `profiles.*.permissions.display_host_writable_statusline` to allow the user to intervene in `DECSSDT` VT sequence to show the host writable statusline even if the indicator statusline is currently active.
    • Extends `ViNormalMode` to toggle between insert and normal mode rather than just entering normal mode.
    • Modal mode: Adds Return key to also move the cursor down (like vim).
    • diff --git a/src/vtbackend/Terminal.cpp b/src/vtbackend/Terminal.cpp index c592a151c3..c3d8c2b30d 100644 --- a/src/vtbackend/Terminal.cpp +++ b/src/vtbackend/Terminal.cpp @@ -744,7 +744,6 @@ void Terminal::clearSelection() InputLog()("Clearing selection."); _selection.reset(); - _speedClicks = 0; onSelectionUpdated(); From f043b0cff2e03af641a92a4d6d730bb18a58893b Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Fri, 31 Mar 2023 17:14:41 +0200 Subject: [PATCH 008/112] [vtbackend] Adds Return key to also move the cursor down in normal mode. Signed-off-by: Christian Parpart --- metainfo.xml | 1 + src/vtbackend/ViInputHandler.cpp | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/metainfo.xml b/metainfo.xml index b1c5944cfd..ac6360e2a6 100644 --- a/metainfo.xml +++ b/metainfo.xml @@ -109,6 +109,7 @@
    • Fixes terminfo `tsl` to how todays apps are using it (e.g. zsh) to simply set the window title.
    • Adds `profiles.*.permissions.display_host_writable_statusline` to allow the user to intervene in `DECSSDT` VT sequence to show the host writable statusline even if the indicator statusline is currently active.
    • Extends `ViNormalMode` to toggle between insert and normal mode rather than just entering normal mode.
    • +
    • Modal mode: Adds Return key to also move the cursor down (like vim).
    diff --git a/src/vtbackend/ViInputHandler.cpp b/src/vtbackend/ViInputHandler.cpp index 3577b28e3e..8782f65172 100644 --- a/src/vtbackend/ViInputHandler.cpp +++ b/src/vtbackend/ViInputHandler.cpp @@ -82,12 +82,13 @@ void ViInputHandler::registerAllCommands() std::array, 2> { { std::pair { 'i', TextObjectScope::Inner }, std::pair { 'a', TextObjectScope::A } } }; - auto constexpr motionMappings = std::array, 40> { { + auto constexpr motionMappings = std::array, 41> { { // clang-format off { "$", ViMotion::LineEnd }, { "%", ViMotion::ParenthesisMatching }, { "0", ViMotion::LineBegin }, { "", ViMotion::CharLeft }, + { "", ViMotion::LineDown }, { "", ViMotion::LineDown }, { "", ViMotion::CharLeft }, { "", ViMotion::PageDown }, @@ -440,6 +441,8 @@ bool ViInputHandler::sendCharPressEvent(char32_t ch, Modifier modifier) _pendingInput += ""; else if (ch == '\b') _pendingInput += ""; + else if (ch == '\n' || ch == '\r') + _pendingInput += ""; else _pendingInput += unicode::convert_to(ch); From 4c2d533bb1ab64675efc10a2e7745ff5e44e4704 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Fri, 31 Mar 2023 22:17:23 +0200 Subject: [PATCH 009/112] Allow customizing the IME (input method editor) region Signed-off-by: Christian Parpart --- metainfo.xml | 3 ++- src/contour/Config.cpp | 4 ++++ src/contour/contour.yml | 7 +++++++ src/vtbackend/ColorPalette.h | 2 ++ src/vtbackend/RenderBufferBuilder.cpp | 5 +++-- 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/metainfo.xml b/metainfo.xml index e0866b09cd..becefba010 100644 --- a/metainfo.xml +++ b/metainfo.xml @@ -110,7 +110,8 @@
  • Fixes selecting a single character not working easily (#1066).
  • Fixes cycling between different selection modes (by speed-clicking) not properly working.
  • Adds `profiles.*.permissions.display_host_writable_statusline` to allow the user to intervene in `DECSSDT` VT sequence to show the host writable statusline even if the indicator statusline is currently active.
  • -
  • Adds `gui.shader` log option for the output of shader configuration procedure.
  • +
  • Adds config entry `input_method_editor` colorscheme key to allow customization of the IME (input method editor) region (#1058).
  • +
  • Adds `gui.shader` log option for the output of shader configuration procedure (#715).
  • Extends `ViNormalMode` to toggle between insert and normal mode rather than just entering normal mode.
  • Modal mode: Adds Return key to also move the cursor down (like vim).
diff --git a/src/contour/Config.cpp b/src/contour/Config.cpp index b93863d71d..0d8cc3e905 100644 --- a/src/contour/Config.cpp +++ b/src/contour/Config.cpp @@ -1028,6 +1028,10 @@ namespace colors.indicatorStatusLineInactive)) colors.indicatorStatusLineInactive = p.value(); + if (auto const p = parseRGBColorPair( + _usedKeys, _basePath, _node, "input_method_editor", colors.inputMethodEditor)) + colors.inputMethodEditor = p.value(); + if (auto cursor = _node["cursor"]; cursor) { _usedKeys.emplace(_basePath + ".cursor"); diff --git a/src/contour/contour.yml b/src/contour/contour.yml index 00de2573df..9169ef9cf3 100644 --- a/src/contour/contour.yml +++ b/src/contour/contour.yml @@ -559,6 +559,13 @@ color_schemes: # Default: default foreground background: '#000000' + # Colors for the IME (Input Method Editor) area. + input_method_editor: + # Default: default #FFFFFF + foreground: '#FFFFFF' + # Default: default #FF0000 + background: '#FF0000' + # Normal colors normal: black: '#000000' diff --git a/src/vtbackend/ColorPalette.h b/src/vtbackend/ColorPalette.h index 5108573a7c..c567b47bb6 100644 --- a/src/vtbackend/ColorPalette.h +++ b/src/vtbackend/ColorPalette.h @@ -118,6 +118,8 @@ struct ColorPalette RGBColor hover = 0xFF0000_rgb; } hyperlinkDecoration; + RGBColorPair inputMethodEditor = { 0xFFFFFF_rgb, 0xFF0000_rgb }; + std::shared_ptr backgroundImage; // clang-format off diff --git a/src/vtbackend/RenderBufferBuilder.cpp b/src/vtbackend/RenderBufferBuilder.cpp index 947def6a62..d5616760ff 100644 --- a/src/vtbackend/RenderBufferBuilder.cpp +++ b/src/vtbackend/RenderBufferBuilder.cpp @@ -584,9 +584,10 @@ bool RenderBufferBuilder::tryRenderInputMethodEditor(CellLocation screenPo // Render IME preeditString if available and screen position matches cursor position. if (_cursorPosition && gridPosition == *_cursorPosition && !_inputMethodData.preeditString.empty()) { + auto const inputMethodEditorStyles = _terminal.colorPalette().inputMethodEditor; auto textAttributes = GraphicsAttributes {}; - textAttributes.foregroundColor = RGBColor(0xFF, 0xFF, 0xFF); - textAttributes.backgroundColor = RGBColor(0xFF, 0x00, 0x00); + textAttributes.foregroundColor = inputMethodEditorStyles.foreground; + textAttributes.backgroundColor = inputMethodEditorStyles.background; textAttributes.flags |= CellFlags::Bold | CellFlags::Underline; if (!_output.cells.empty()) From bf5f1f2e8a19f2e236f209377f5fdc26332fea57 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Sat, 1 Apr 2023 01:46:28 +0200 Subject: [PATCH 010/112] [Github CI] external_tests: Install libavdevice-dev for notcurses Signed-off-by: Christian Parpart --- .github/workflows/external_tests.yml | 1 + scripts/ci/notcurses-install-deps.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/external_tests.yml b/.github/workflows/external_tests.yml index 97397bca27..79f710031b 100644 --- a/.github/workflows/external_tests.yml +++ b/.github/workflows/external_tests.yml @@ -144,6 +144,7 @@ jobs: doctest-dev \ ffmpeg \ libavcodec-dev \ + libavdevice-dev \ libavformat-dev \ libavutil-dev \ libdeflate-dev \ diff --git a/scripts/ci/notcurses-install-deps.sh b/scripts/ci/notcurses-install-deps.sh index e923d2f51b..fd9fa134d4 100755 --- a/scripts/ci/notcurses-install-deps.sh +++ b/scripts/ci/notcurses-install-deps.sh @@ -10,6 +10,7 @@ sudo apt install -y \ \ ffmpeg \ libavcodec58 \ + libavdevice58 \ libavformat58 \ libavutil56 \ libdeflate0 \ From 0c9e480646fed1eef5420285bb4980abb74c944d Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Fri, 31 Mar 2023 09:39:26 +0200 Subject: [PATCH 011/112] [Github CI] Revive packaging and uploading DMG package for OS/X. Signed-off-by: Christian Parpart --- .github/workflows/build.yml | 42 ++++++++++++++++++----------------- .github/workflows/release.yml | 6 +++-- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6530928513..eb4fedd493 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -203,7 +203,7 @@ jobs: ./build/src/vtbackend/vtbackend_test rm -rf _deps build - osx_qt6: + osx_qt5: name: "OS/X" runs-on: macos-11 steps: @@ -216,45 +216,47 @@ jobs: - name: ccache uses: hendrikmuhs/ccache-action@v1.2 with: - key: ccache-osx_qt6 + key: ccache-osx_qt5 max-size: 256M - name: "Install dependencies" run: | set -ex #brew update ./scripts/install-deps.sh - brew install qt6 openssl + brew install qt${QTVER} openssl + env: + QTVER: '5' - name: "Create build directory" run: mkdir build - name: "Generate build files" run: | cmake . \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DLIBTERMINAL_BUILD_BENCH_HEADLESS=ON \ - -DCONTOUR_BUILD_WITH_QT6=ON \ + -DQt5_DIR="$(brew --prefix qt5)/lib/cmake/Qt5" \ + -DCONTOUR_BUILD_WITH_QT6=OFF \ -B build/ - name: "Build" run: cmake --build build/ - - name: "test: libcrispy" + - name: "test: crispy" run: ./build/src/crispy/crispy_test - name: "test: vtparser" run: ./build/src/vtparser/vtparser_test - name: "test: libterminal" run: ./build/src/vtbackend/vtbackend_test - # - name: "Create Package(s)" - # run: | - # set -ex - # cd build - # sudo cpack -G "DragNDrop" - # ls -hl - # BASENAME="contour-${{ steps.set_vars.outputs.version }}-osx" - # mv -vf "Contour-${{ steps.set_vars.outputs.VERSION_STRING }}-Darwin.zip" "../${BASENAME}.zip" - # mv -vf "Contour-${{ steps.set_vars.outputs.VERSION_STRING }}-Darwin.dmg" "../${BASENAME}.dmg" - # - name: upload to artifact store (DMG) - # uses: actions/upload-artifact@v2 - # with: - # path: contour-${{ steps.set_vars.outputs.version }}-osx.dmg - # retention-days: 7 + - name: "Create Package(s)" + run: | + set -ex + cd build + sudo cpack -G "DragNDrop" + ls -hl + BASENAME="contour-${{ steps.set_vars.outputs.version }}-osx" + mv -vf "Contour-${{ steps.set_vars.outputs.VERSION_STRING }}-Darwin.dmg" "../${BASENAME}.dmg" + - name: upload to artifact store (DMG) + uses: actions/upload-artifact@v2 + with: + name: contour-${{ steps.set_vars.outputs.version }}-osx.dmg + path: contour-${{ steps.set_vars.outputs.version }}-osx.dmg + retention-days: 7 windows: name: "Windows" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c74cb6a4c4..18e95297b5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -137,9 +137,11 @@ jobs: -B build/ - name: "Build" run: cmake --build build/ - - name: "test: libcrispy" + - name: "test: crispy" run: ./build/src/crispy/crispy_test - - name: "test: libterminal" + - name: "test: vtparser" + run: ./build/src/vtparser/vtparser_test + - name: "test: vtbackend" run: ./build/src/vtbackend/vtbackend_test - name: inspect run: | From 06937079c25e0535f1592f758f1ca9be2cb9f0c6 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Sat, 1 Apr 2023 05:07:09 +0200 Subject: [PATCH 012/112] Changes `DECSSDT 2` permission check to always apply. Signed-off-by: Christian Parpart --- metainfo.xml | 2 +- src/contour/contour.yml | 3 +-- src/vtbackend/Screen.cpp | 4 +--- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/metainfo.xml b/metainfo.xml index becefba010..1b7b6b4375 100644 --- a/metainfo.xml +++ b/metainfo.xml @@ -109,7 +109,7 @@
  • Fixes terminfo `tsl` to how todays apps are using it (e.g. zsh) to simply set the window title.
  • Fixes selecting a single character not working easily (#1066).
  • Fixes cycling between different selection modes (by speed-clicking) not properly working.
  • -
  • Adds `profiles.*.permissions.display_host_writable_statusline` to allow the user to intervene in `DECSSDT` VT sequence to show the host writable statusline even if the indicator statusline is currently active.
  • +
  • Adds `profiles.*.permissions.display_host_writable_statusline` to allow the user to intervene in `DECSSDT 2` VT sequence to show the host writable statusline.
  • Adds config entry `input_method_editor` colorscheme key to allow customization of the IME (input method editor) region (#1058).
  • Adds `gui.shader` log option for the output of shader configuration procedure (#715).
  • Extends `ViNormalMode` to toggle between insert and normal mode rather than just entering normal mode.
  • diff --git a/src/contour/contour.yml b/src/contour/contour.yml index 9169ef9cf3..623ccf4d93 100644 --- a/src/contour/contour.yml +++ b/src/contour/contour.yml @@ -241,8 +241,7 @@ profiles: # Allows capturing the screen buffer via `CSI > Pm ; Ps ; Pc ST`. # The response can be read from stdin as sequence `OSC 314 ; ST` capture_buffer: ask - # Allows displaying the "Host Writable Statusline" even when - # the indicator statusline is currently shown. + # Allows displaying the "Host Writable Statusline" programmatically using `DECSSDT 2`. display_host_writable_statusline: ask # If enabled, and you double-click on a word in the primary screen, diff --git a/src/vtbackend/Screen.cpp b/src/vtbackend/Screen.cpp index 62ddb73cdf..348804690b 100644 --- a/src/vtbackend/Screen.cpp +++ b/src/vtbackend/Screen.cpp @@ -3657,10 +3657,8 @@ ApplyResult Screen::apply(FunctionDefinition const& function, Sequence con case 0: _terminal.setStatusDisplay(StatusDisplayType::None); break; case 1: _terminal.setStatusDisplay(StatusDisplayType::Indicator); break; case 2: - if (_terminal.statusDisplayType() == StatusDisplayType::Indicator) + if (_terminal.statusDisplayType() != StatusDisplayType::HostWritable) _terminal.requestShowHostWritableStatusLine(); - else - _terminal.setStatusDisplay(StatusDisplayType::HostWritable); break; default: return ApplyResult::Invalid; } From c06d4850a396161bf6a7f38a765507a899f6142c Mon Sep 17 00:00:00 2001 From: Yaraslau Tamashevich Date: Tue, 4 Apr 2023 10:40:06 +0300 Subject: [PATCH 013/112] Separate category for shader log --- src/contour/display/ShaderConfig.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/contour/display/ShaderConfig.cpp b/src/contour/display/ShaderConfig.cpp index 80014f0b8d..2ad27192a5 100644 --- a/src/contour/display/ShaderConfig.cpp +++ b/src/contour/display/ShaderConfig.cpp @@ -31,6 +31,8 @@ using namespace std::string_literals; namespace contour::display { +auto const ShaderLog = logstore::Category("shader", "Logs shader configuration"); + namespace { template @@ -135,7 +137,7 @@ std::unique_ptr createShader(ShaderConfig const& _shaderCo } if (auto const logString = shader->log().toStdString(); !logString.empty()) - errorlog()("Shader log: {}", logString); + ShaderLog()("Shader log: {}", logString); Guarantee(shader->isLinked()); return shader; From 5977c06f446a77171579b784fddec9a2bcf579ba Mon Sep 17 00:00:00 2001 From: Yaraslau <44506630+Yaraslaut@users.noreply.github.com> Date: Tue, 4 Apr 2023 14:24:41 +0300 Subject: [PATCH 014/112] Update src/contour/display/ShaderConfig.cpp Co-authored-by: Christian Parpart --- src/contour/display/ShaderConfig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/contour/display/ShaderConfig.cpp b/src/contour/display/ShaderConfig.cpp index 2ad27192a5..dd2c7de3db 100644 --- a/src/contour/display/ShaderConfig.cpp +++ b/src/contour/display/ShaderConfig.cpp @@ -137,7 +137,7 @@ std::unique_ptr createShader(ShaderConfig const& _shaderCo } if (auto const logString = shader->log().toStdString(); !logString.empty()) - ShaderLog()("Shader log: {}", logString); + ShaderLog()("{}", logString); Guarantee(shader->isLinked()); return shader; From cdf9e32054da5f255f6a19821db7ce138f66a5ee Mon Sep 17 00:00:00 2001 From: Yaraslau <44506630+Yaraslaut@users.noreply.github.com> Date: Tue, 4 Apr 2023 14:29:23 +0300 Subject: [PATCH 015/112] Update src/contour/display/ShaderConfig.cpp Co-authored-by: Christian Parpart --- src/contour/display/ShaderConfig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/contour/display/ShaderConfig.cpp b/src/contour/display/ShaderConfig.cpp index dd2c7de3db..a60be0c9f6 100644 --- a/src/contour/display/ShaderConfig.cpp +++ b/src/contour/display/ShaderConfig.cpp @@ -31,7 +31,7 @@ using namespace std::string_literals; namespace contour::display { -auto const ShaderLog = logstore::Category("shader", "Logs shader configuration"); +auto const ShaderLog = logstore::Category("gui.shader", "Logs shader configuration"); namespace { From 9daae6b75cc01244b0e268bc4e43048152422ff3 Mon Sep 17 00:00:00 2001 From: Yaraslau Tamashevich Date: Tue, 4 Apr 2023 14:32:24 +0300 Subject: [PATCH 016/112] update metainfo.xml --- metainfo.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/metainfo.xml b/metainfo.xml index 657cefa7ba..e0866b09cd 100644 --- a/metainfo.xml +++ b/metainfo.xml @@ -110,6 +110,7 @@
  • Fixes selecting a single character not working easily (#1066).
  • Fixes cycling between different selection modes (by speed-clicking) not properly working.
  • Adds `profiles.*.permissions.display_host_writable_statusline` to allow the user to intervene in `DECSSDT` VT sequence to show the host writable statusline even if the indicator statusline is currently active.
  • +
  • Adds `gui.shader` log option for the output of shader configuration procedure.
  • Extends `ViNormalMode` to toggle between insert and normal mode rather than just entering normal mode.
  • Modal mode: Adds Return key to also move the cursor down (like vim).
  • From a7381f6f5b9100ebc119d9843fc0bb8de5a2da2b Mon Sep 17 00:00:00 2001 From: Andrew Stevenson Date: Wed, 5 Apr 2023 17:16:57 +0200 Subject: [PATCH 017/112] Properly escape strings for tcsh --- src/contour/shell-integration/shell-integration.tcsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/contour/shell-integration/shell-integration.tcsh b/src/contour/shell-integration/shell-integration.tcsh index 9075a8efa2..d7fa45bd2a 100644 --- a/src/contour/shell-integration/shell-integration.tcsh +++ b/src/contour/shell-integration/shell-integration.tcsh @@ -1,2 +1,2 @@ -alias precmd 'echo -n "\033[?2028l\033[>M\033]7;$PWD\033\\";' -alias postcmd 'echo -n "\033[?2028h";' +alias precmd 'echo -n "\\e[?2028l\\e[>M\\e]7;$PWD\\e\\\\";' +alias postcmd 'echo -n "\\e[?2028h";' From f1eb02a582d83bd9ee9811b47ab8cefe7cca017f Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Sat, 1 Apr 2023 14:41:05 +0200 Subject: [PATCH 018/112] metainfo.xml: Add changelog entry for tcsh shell integration fix Signed-off-by: Christian Parpart --- metainfo.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/metainfo.xml b/metainfo.xml index 1b7b6b4375..c939752053 100644 --- a/metainfo.xml +++ b/metainfo.xml @@ -109,6 +109,7 @@
  • Fixes terminfo `tsl` to how todays apps are using it (e.g. zsh) to simply set the window title.
  • Fixes selecting a single character not working easily (#1066).
  • Fixes cycling between different selection modes (by speed-clicking) not properly working.
  • +
  • Fixes tcsh shell integration not working (#1074).
  • Adds `profiles.*.permissions.display_host_writable_statusline` to allow the user to intervene in `DECSSDT 2` VT sequence to show the host writable statusline.
  • Adds config entry `input_method_editor` colorscheme key to allow customization of the IME (input method editor) region (#1058).
  • Adds `gui.shader` log option for the output of shader configuration procedure (#715).
  • From ecd879bbce5332d7142de5af5e7d903dcbc8da0b Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Wed, 5 Apr 2023 23:37:50 +0200 Subject: [PATCH 019/112] [vtbackend] Improves mouse selection to be more natural extending into new grid cells Signed-off-by: Christian Parpart --- metainfo.xml | 1 + src/vtbackend/Terminal.cpp | 79 ++++++++++++++++++++++++++------------ src/vtbackend/Terminal.h | 10 ++++- 3 files changed, 65 insertions(+), 25 deletions(-) diff --git a/metainfo.xml b/metainfo.xml index c939752053..092b4d5ce4 100644 --- a/metainfo.xml +++ b/metainfo.xml @@ -110,6 +110,7 @@
  • Fixes selecting a single character not working easily (#1066).
  • Fixes cycling between different selection modes (by speed-clicking) not properly working.
  • Fixes tcsh shell integration not working (#1074).
  • +
  • Improves mouse selection to be more natural extending into new grid cells.
  • Adds `profiles.*.permissions.display_host_writable_statusline` to allow the user to intervene in `DECSSDT 2` VT sequence to show the host writable statusline.
  • Adds config entry `input_method_editor` colorscheme key to allow customization of the IME (input method editor) region (#1058).
  • Adds `gui.shader` log option for the output of shader configuration procedure (#715).
  • diff --git a/src/vtbackend/Terminal.cpp b/src/vtbackend/Terminal.cpp index c3d8c2b30d..ad82543181 100644 --- a/src/vtbackend/Terminal.cpp +++ b/src/vtbackend/Terminal.cpp @@ -650,6 +650,7 @@ bool Terminal::sendMousePressEvent(Modifier modifier, if (button == MouseButton::Left) { _leftMouseButtonPressed = true; + _lastMousePixelPositionOnLeftClick = pixelPosition; if (!allowPassMouseEventToApp(modifier)) uiHandledHint = handleMouseSelection(modifier) || uiHandledHint; } @@ -750,54 +751,84 @@ void Terminal::clearSelection() breakLoopAndRefreshRenderBuffer(); } +bool Terminal::shouldExtendSelectionByMouse(CellLocation newPosition, PixelCoordinate pixelPosition) const noexcept +{ + if (!selectionAvailable() || selector()->state() == Selection::State::Complete) + return false; + + auto selectionCorner = selector()->to(); + auto const cellPixelWidth = unbox(cellPixelSize().width); + if (selector()->state() == Selection::State::Waiting) + { + if (!(newPosition.line != selectionCorner.line + || abs(_lastMousePixelPositionOnLeftClick.x.value - pixelPosition.x.value) + / (cellPixelWidth / 2))) + return false; + } + else if (newPosition.line == selectionCorner.line) + { + auto const mod = pixelPosition.x.value % cellPixelWidth; + if (newPosition.column > selectionCorner.column) // selection to the right + { + if (mod < cellPixelWidth / 2) + return false; + } + else if (newPosition.column < selectionCorner.column) // selection to the left + { + if (mod > cellPixelWidth / 2) + return false; + } + } + + return true; +} + void Terminal::sendMouseMoveEvent(Modifier modifier, CellLocation newPosition, PixelCoordinate pixelPosition, bool uiHandledHint) { + // Updates the internal state to remember the current mouse' position. + // On top of that, a few more things are happening: + // - updates cursor hovering state (e.g. necessary for properly highlighting hyperlinks) + // - the internal speed-clicks counter (for tracking rapid multi click) is reset + // - grid text selection is extended verifyState(); - // Speed-clicks are only counted when not moving the mouse in between, so reset on mouse move here. - _speedClicks = 0; - - if (_leftMouseButtonPressed && isSelectionComplete()) - { - // Mouse is pressed but current selection is complete, which means, it's a new mouse-down event, - // and we clear the current selection before continueing to create a new one. - clearSelection(); - } - if (newPosition != _currentMousePosition) { + // Speed-clicks are only counted when not moving the mouse in between, so reset on mouse move here. + _speedClicks = 0; + _currentMousePosition = newPosition; - updateCursorHoveringState(); + updateHoveringHyperlinkState(); } if (!_leftMouseButtonPressed) return; - auto relativePos = _viewport.translateScreenToGridCoordinate(_currentMousePosition); - _state.viCommands.cursorPosition = relativePos; - _viewport.makeVisible(_state.viCommands.cursorPosition.line); + auto const shouldExtendSelection = shouldExtendSelectionByMouse(newPosition, pixelPosition); + + auto relativePos = _viewport.translateScreenToGridCoordinate(newPosition); + if (shouldExtendSelection) + { + _state.viCommands.cursorPosition = relativePos; + _viewport.makeVisible(_state.viCommands.cursorPosition.line); + } // Do not handle mouse-move events in sub-cell dimensions. if (allowPassMouseEventToApp(modifier) - && _state.inputGenerator.generateMouseMove(modifier, - relativePos, - pixelPosition, - uiHandledHint - || (_leftMouseButtonPressed && !selectionAvailable()))) + && _state.inputGenerator.generateMouseMove( + modifier, relativePos, pixelPosition, uiHandledHint || !selectionAvailable())) { flushInput(); if (!isModeEnabled(DECMode::MousePassiveTracking)) return; } - if (_leftMouseButtonPressed && !selectionAvailable()) + if (!selectionAvailable()) setSelector(make_unique(_selectionHelper, relativePos, selectionUpdatedHelper())); - - if (selectionAvailable() - && (selector()->state() != Selection::State::Complete && _leftMouseButtonPressed)) + else if (selector()->state() != Selection::State::Complete && shouldExtendSelection) { if (currentScreen().isCellEmpty(relativePos) && !currentScreen().compareCellTextAt(relativePos, 0x20)) relativePos.column = ColumnOffset { 0 } + *(_settings.pageSize.columns - 1); @@ -982,7 +1013,7 @@ void Terminal::updateCursorVisibilityState() const noexcept _cursorBlinkState = (_cursorBlinkState + 1) % 2; } -void Terminal::updateCursorHoveringState() +void Terminal::updateHoveringHyperlinkState() { auto const newState = _currentScreen.get().contains(_currentMousePosition) ? _currentScreen.get().hyperlinkIdAt( diff --git a/src/vtbackend/Terminal.h b/src/vtbackend/Terminal.h index 1f4e1c81c9..c83469e753 100644 --- a/src/vtbackend/Terminal.h +++ b/src/vtbackend/Terminal.h @@ -709,9 +709,16 @@ class Terminal void fillRenderBufferInternal(RenderBuffer& output, bool includeSelection); void updateIndicatorStatusLine(); void updateCursorVisibilityState() const noexcept; - void updateCursorHoveringState(); + void updateHoveringHyperlinkState(); bool handleMouseSelection(Modifier modifier); + /// Tests if the text selection should be extended by the given mouse position or not. + /// + /// @retval false if either no selection is available, selection is complete, or the new pixel position is + /// not enough into the next grid cell yet + /// @retval true otherwise + bool shouldExtendSelectionByMouse(CellLocation newPosition, PixelCoordinate pixelPosition) const noexcept; + // Tests if the App mouse protocol is explicitly being bypassed by the user, // by pressing a special bypass modifier (usualy Shift). bool allowBypassAppMouseGrabViaModifier(Modifier modifier) const noexcept @@ -770,6 +777,7 @@ class Terminal std::chrono::steady_clock::time_point _lastClick {}; unsigned int _speedClicks = 0; terminal::CellLocation _currentMousePosition {}; // current mouse position + terminal::PixelCoordinate _lastMousePixelPositionOnLeftClick {}; bool _leftMouseButtonPressed = false; // tracks left-mouse button pressed state (used for cell selection). bool _respectMouseProtocol = true; // shift-click can disable that, button release sets it back to true // }}} From 9e234ed53088d208d013c08e4db72fb93f4e1c3a Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Fri, 7 Apr 2023 22:16:23 +0200 Subject: [PATCH 020/112] Fixes assidental mouse selection creation when not intended to (from PR #1075) Signed-off-by: Christian Parpart --- src/vtbackend/Terminal.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/vtbackend/Terminal.cpp b/src/vtbackend/Terminal.cpp index ad82543181..a0437fac7e 100644 --- a/src/vtbackend/Terminal.cpp +++ b/src/vtbackend/Terminal.cpp @@ -817,11 +817,11 @@ void Terminal::sendMouseMoveEvent(Modifier modifier, } // Do not handle mouse-move events in sub-cell dimensions. - if (allowPassMouseEventToApp(modifier) - && _state.inputGenerator.generateMouseMove( - modifier, relativePos, pixelPosition, uiHandledHint || !selectionAvailable())) + if (allowPassMouseEventToApp(modifier)) { - flushInput(); + if (_state.inputGenerator.generateMouseMove( + modifier, relativePos, pixelPosition, uiHandledHint || !selectionAvailable())) + flushInput(); if (!isModeEnabled(DECMode::MousePassiveTracking)) return; } From 15feed68719966b651058bdb74d58189f3cb0eab Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Fri, 7 Apr 2023 23:05:17 +0200 Subject: [PATCH 021/112] [vtbackend] Refactor rendering around statusline a bit to make it more flexible. Signed-off-by: Christian Parpart --- src/vtbackend/RenderBufferBuilder.cpp | 3 +- src/vtbackend/Terminal.cpp | 42 +++++++++++++++++---------- src/vtbackend/Terminal.h | 1 + 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/vtbackend/RenderBufferBuilder.cpp b/src/vtbackend/RenderBufferBuilder.cpp index d5616760ff..8b29e84de1 100644 --- a/src/vtbackend/RenderBufferBuilder.cpp +++ b/src/vtbackend/RenderBufferBuilder.cpp @@ -151,7 +151,8 @@ optional RenderBufferBuilder::renderCursor() const auto const shape = _terminal.state().focused ? _terminal.cursorShape() : InactiveCursorShape; auto const cursorScreenPosition = - CellLocation { _cursorPosition->line + boxed_cast(_terminal.viewport().scrollOffset()), + CellLocation { _baseLine + _cursorPosition->line + + boxed_cast(_terminal.viewport().scrollOffset()), _cursorPosition->column }; auto const cellWidth = _terminal.currentScreen().cellWidthAt(*_cursorPosition); diff --git a/src/vtbackend/Terminal.cpp b/src/vtbackend/Terminal.cpp index a0437fac7e..b6664ec198 100644 --- a/src/vtbackend/Terminal.cpp +++ b/src/vtbackend/Terminal.cpp @@ -22,6 +22,7 @@ #include +#include #include #include #include @@ -433,6 +434,8 @@ void Terminal::fillRenderBufferInternal(RenderBuffer& output, bool includeSelect TerminalLog()("{}: Refreshing render buffer.\n", _lastFrameID.load()); #endif + auto baseLine = LineOffset(0); + auto const hoveringHyperlinkGuard = ScopedHyperlinkHover { *this, _currentScreen }; auto const mainDisplayReverseVideo = isModeEnabled(terminal::DECMode::ReverseVideo); auto const highlightSearchMatches = @@ -449,7 +452,7 @@ void Terminal::fillRenderBufferInternal(RenderBuffer& output, bool includeSelect _lastRenderPassHints = _primaryScreen.render(RenderBufferBuilder { *this, output, - LineOffset(0), + baseLine, mainDisplayReverseVideo, HighlightSearchMatches::Yes, _inputMethodData, @@ -461,7 +464,7 @@ void Terminal::fillRenderBufferInternal(RenderBuffer& output, bool includeSelect _lastRenderPassHints = _alternateScreen.render(RenderBufferBuilder { *this, output, - LineOffset(0), + baseLine, mainDisplayReverseVideo, HighlightSearchMatches::Yes, _inputMethodData, @@ -469,38 +472,45 @@ void Terminal::fillRenderBufferInternal(RenderBuffer& output, bool includeSelect includeSelection }, _viewport.scrollOffset(), highlightSearchMatches); + baseLine += _primaryScreen.pageSize().lines.as(); + + fillRenderBufferStatusLine(output, includeSelection, baseLine); +} +LineCount Terminal::fillRenderBufferStatusLine(RenderBuffer& output, bool includeSelection, LineOffset base) +{ + auto const mainDisplayReverseVideo = isModeEnabled(terminal::DECMode::ReverseVideo); switch (_state.statusDisplayType) { case StatusDisplayType::None: //. - break; + return LineCount(0); case StatusDisplayType::Indicator: updateIndicatorStatusLine(); - _indicatorStatusScreen.render( - RenderBufferBuilder { *this, - output, - pageSize().lines.as(), - !mainDisplayReverseVideo, - HighlightSearchMatches::No, - InputMethodData {}, - nullopt, - includeSelection }, - ScrollOffset(0)); - break; + _indicatorStatusScreen.render(RenderBufferBuilder { *this, + output, + base, + !mainDisplayReverseVideo, + HighlightSearchMatches::No, + InputMethodData {}, + nullopt, + includeSelection }, + ScrollOffset(0)); + return _indicatorStatusScreen.pageSize().lines; case StatusDisplayType::HostWritable: _hostWritableStatusLineScreen.render( RenderBufferBuilder { *this, output, - pageSize().lines.as(), + base, !mainDisplayReverseVideo, HighlightSearchMatches::No, InputMethodData {}, nullopt, includeSelection }, ScrollOffset(0)); - break; + return _hostWritableStatusLineScreen.pageSize().lines; } + crispy::unreachable(); } // }}} diff --git a/src/vtbackend/Terminal.h b/src/vtbackend/Terminal.h index c83469e753..b003a6302f 100644 --- a/src/vtbackend/Terminal.h +++ b/src/vtbackend/Terminal.h @@ -707,6 +707,7 @@ class Terminal private: void mainLoop(); void fillRenderBufferInternal(RenderBuffer& output, bool includeSelection); + LineCount fillRenderBufferStatusLine(RenderBuffer& output, bool includeSelection, LineOffset base); void updateIndicatorStatusLine(); void updateCursorVisibilityState() const noexcept; void updateHoveringHyperlinkState(); From 9eb5e562774913a9a60ab6df2df1f35f151278bf Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Fri, 7 Apr 2023 23:36:27 +0200 Subject: [PATCH 022/112] Adds config entry `profiles.*.status_line.position` to change statusline position to be either bottom (default) or top Signed-off-by: Christian Parpart --- metainfo.xml | 1 + src/contour/Config.cpp | 12 ++++++++++++ src/contour/Config.h | 1 + src/contour/TerminalSession.cpp | 1 + src/contour/contour.yml | 5 +++++ src/vtbackend/Settings.h | 1 + src/vtbackend/Terminal.cpp | 10 ++++++++-- src/vtbackend/primitives.h | 10 ++++++++++ 8 files changed, 39 insertions(+), 2 deletions(-) diff --git a/metainfo.xml b/metainfo.xml index 092b4d5ce4..a9a3527338 100644 --- a/metainfo.xml +++ b/metainfo.xml @@ -114,6 +114,7 @@
  • Adds `profiles.*.permissions.display_host_writable_statusline` to allow the user to intervene in `DECSSDT 2` VT sequence to show the host writable statusline.
  • Adds config entry `input_method_editor` colorscheme key to allow customization of the IME (input method editor) region (#1058).
  • Adds `gui.shader` log option for the output of shader configuration procedure (#715).
  • +
  • Adds config entry `profiles.*.status_line.position` to change statusline position to be either bottom (default) or top.
  • Extends `ViNormalMode` to toggle between insert and normal mode rather than just entering normal mode.
  • Modal mode: Adds Return key to also move the cursor down (like vim).
  • diff --git a/src/contour/Config.cpp b/src/contour/Config.cpp index 0d8cc3e905..5a5b5dcaef 100644 --- a/src/contour/Config.cpp +++ b/src/contour/Config.cpp @@ -44,6 +44,7 @@ #include #include "contour/Actions.h" +#include "vtbackend/primitives.h" #if defined(_WIN32) #include @@ -1705,6 +1706,17 @@ namespace else errorlog()("Invalid value for config entry {}: {}", "status_line.display", strValue); + if (tryLoadChildRelative(_usedKeys, _profile, basePath, "status_line.position", strValue)) + { + auto const literal = toLower(strValue); + if (literal == "bottom") + profile.statusDisplayPosition = terminal::StatusDisplayPosition::Bottom; + else if (literal == "top") + profile.statusDisplayPosition = terminal::StatusDisplayPosition::Top; + else + errorlog()("Invalid value for config entry {}: {}", "status_line.position", strValue); + } + return profile; } diff --git a/src/contour/Config.h b/src/contour/Config.h index 00fccab0d3..463855b7b7 100644 --- a/src/contour/Config.h +++ b/src/contour/Config.h @@ -161,6 +161,7 @@ struct TerminalProfile terminal::MaxHistoryLineCount maxHistoryLineCount; terminal::LineCount historyScrollMultiplier = terminal::LineCount(3); ScrollBarPosition scrollbarPosition = ScrollBarPosition::Right; + terminal::StatusDisplayPosition statusDisplayPosition = terminal::StatusDisplayPosition::Bottom; bool hideScrollbarInAltScreen = true; bool autoScrollOnUpdate; diff --git a/src/contour/TerminalSession.cpp b/src/contour/TerminalSession.cpp index db5bb9d675..f6f437f2fb 100644 --- a/src/contour/TerminalSession.cpp +++ b/src/contour/TerminalSession.cpp @@ -123,6 +123,7 @@ namespace settings.maxImageSize = config.maxImageSize; settings.maxImageRegisterCount = config.maxImageColorRegisters; settings.statusDisplayType = profile.initialStatusDisplayType; + settings.statusDisplayPosition = profile.statusDisplayPosition; settings.colorPalette = profile.colors; settings.refreshRate = profile.refreshRate; settings.primaryScreen.allowReflowOnResize = config.reflowOnResize; diff --git a/src/contour/contour.yml b/src/contour/contour.yml index 623ccf4d93..4d95a0c88b 100644 --- a/src/contour/contour.yml +++ b/src/contour/contour.yml @@ -393,6 +393,11 @@ profiles: # be changed at any time during runtime by the user or by an application. display: none + # Position to place the status line to, if it is to be shown. + # This can be either value `top` or value `bottom`. + # Default: bottom + position: bottom + # Background configuration background: # Background opacity to use. A value of 1.0 means fully opaque whereas 0.0 means fully diff --git a/src/vtbackend/Settings.h b/src/vtbackend/Settings.h index 610c5de6c3..079f5193ad 100644 --- a/src/vtbackend/Settings.h +++ b/src/vtbackend/Settings.h @@ -37,6 +37,7 @@ struct Settings ImageSize maxImageSize { Width(800), Height(600) }; unsigned maxImageRegisterCount = 256; StatusDisplayType statusDisplayType = StatusDisplayType::None; + StatusDisplayPosition statusDisplayPosition = StatusDisplayPosition::Bottom; CursorDisplay cursorDisplay = CursorDisplay::Steady; CursorShape cursorShape = CursorShape::Block; diff --git a/src/vtbackend/Terminal.cpp b/src/vtbackend/Terminal.cpp index b6664ec198..2392719771 100644 --- a/src/vtbackend/Terminal.cpp +++ b/src/vtbackend/Terminal.cpp @@ -436,6 +436,9 @@ void Terminal::fillRenderBufferInternal(RenderBuffer& output, bool includeSelect auto baseLine = LineOffset(0); + if (_settings.statusDisplayPosition == StatusDisplayPosition::Top) + baseLine += fillRenderBufferStatusLine(output, includeSelection, baseLine).as(); + auto const hoveringHyperlinkGuard = ScopedHyperlinkHover { *this, _currentScreen }; auto const mainDisplayReverseVideo = isModeEnabled(terminal::DECMode::ReverseVideo); auto const highlightSearchMatches = @@ -472,9 +475,12 @@ void Terminal::fillRenderBufferInternal(RenderBuffer& output, bool includeSelect includeSelection }, _viewport.scrollOffset(), highlightSearchMatches); - baseLine += _primaryScreen.pageSize().lines.as(); - fillRenderBufferStatusLine(output, includeSelection, baseLine); + if (_settings.statusDisplayPosition == StatusDisplayPosition::Bottom) + { + baseLine += _primaryScreen.pageSize().lines.as(); + fillRenderBufferStatusLine(output, includeSelection, baseLine); + } } LineCount Terminal::fillRenderBufferStatusLine(RenderBuffer& output, bool includeSelection, LineOffset base) diff --git a/src/vtbackend/primitives.h b/src/vtbackend/primitives.h index c6d204d22b..cbc9e45876 100644 --- a/src/vtbackend/primitives.h +++ b/src/vtbackend/primitives.h @@ -565,6 +565,16 @@ enum class StatusDisplayType HostWritable, }; +// Mandates the position to show the statusline at. +enum class StatusDisplayPosition +{ + // The status line is classically shown at the bottom of the render target. + Bottom, + + // The status line is shown at the top of the render target + Top, +}; + // Selects whether the terminal sends data to the main display or the status line. enum class ActiveStatusDisplay { From 5c4c52814eb91e30cd0c74e06ca6665d6f983f36 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Sat, 8 Apr 2023 04:33:46 +0200 Subject: [PATCH 023/112] Adds config entry `profiles.*.status_line.sync_to_window_title` to synchronize the window title with the host writable statusline (if it was denied to be shown) Signed-off-by: Christian Parpart --- metainfo.xml | 1 + src/contour/Config.cpp | 5 +++++ src/contour/Config.h | 1 + src/contour/TerminalSession.cpp | 5 +++++ src/contour/contour.yml | 5 +++++ src/vtbackend/Screen.cpp | 12 +++++++++++- src/vtbackend/Settings.h | 1 + src/vtbackend/TerminalState.h | 1 + 8 files changed, 30 insertions(+), 1 deletion(-) diff --git a/metainfo.xml b/metainfo.xml index a9a3527338..2c2807845a 100644 --- a/metainfo.xml +++ b/metainfo.xml @@ -115,6 +115,7 @@
  • Adds config entry `input_method_editor` colorscheme key to allow customization of the IME (input method editor) region (#1058).
  • Adds `gui.shader` log option for the output of shader configuration procedure (#715).
  • Adds config entry `profiles.*.status_line.position` to change statusline position to be either bottom (default) or top.
  • +
  • Adds config entry `profiles.*.status_line.sync_to_window_title` to synchronize the window title with the host writable statusline (if it was denied to be shown).
  • Extends `ViNormalMode` to toggle between insert and normal mode rather than just entering normal mode.
  • Modal mode: Adds Return key to also move the cursor down (like vim).
  • diff --git a/src/contour/Config.cpp b/src/contour/Config.cpp index 5a5b5dcaef..a1854765a7 100644 --- a/src/contour/Config.cpp +++ b/src/contour/Config.cpp @@ -1717,6 +1717,11 @@ namespace errorlog()("Invalid value for config entry {}: {}", "status_line.position", strValue); } + bool boolValue = false; + if (tryLoadChildRelative( + _usedKeys, _profile, basePath, "status_line.sync_to_window_title", boolValue)) + profile.syncWindowTitleWithHostWritableStatusDisplay = boolValue; + return profile; } diff --git a/src/contour/Config.h b/src/contour/Config.h index 463855b7b7..27b585f837 100644 --- a/src/contour/Config.h +++ b/src/contour/Config.h @@ -162,6 +162,7 @@ struct TerminalProfile terminal::LineCount historyScrollMultiplier = terminal::LineCount(3); ScrollBarPosition scrollbarPosition = ScrollBarPosition::Right; terminal::StatusDisplayPosition statusDisplayPosition = terminal::StatusDisplayPosition::Bottom; + bool syncWindowTitleWithHostWritableStatusDisplay = false; bool hideScrollbarInAltScreen = true; bool autoScrollOnUpdate; diff --git a/src/contour/TerminalSession.cpp b/src/contour/TerminalSession.cpp index f6f437f2fb..89154bc8c9 100644 --- a/src/contour/TerminalSession.cpp +++ b/src/contour/TerminalSession.cpp @@ -124,6 +124,7 @@ namespace settings.maxImageRegisterCount = config.maxImageColorRegisters; settings.statusDisplayType = profile.initialStatusDisplayType; settings.statusDisplayPosition = profile.statusDisplayPosition; + settings.syncWindowTitleWithHostWritableStatusDisplay = profile.syncWindowTitleWithHostWritableStatusDisplay; settings.colorPalette = profile.colors; settings.refreshRate = profile.refreshRate; settings.primaryScreen.allowReflowOnResize = config.reflowOnResize; @@ -301,7 +302,11 @@ void TerminalSession::requestShowHostWritableStatusLine() terminal_.setStatusDisplay(terminal::StatusDisplayType::HostWritable); DisplayLog()("requestCaptureBuffer: Finished. Waking up I/O thread."); flushInput(); + terminal_.state().syncWindowTitleWithHostWritableStatusDisplay = false; } + else + terminal_.state().syncWindowTitleWithHostWritableStatusDisplay = + terminal_.settings().syncWindowTitleWithHostWritableStatusDisplay; }); } diff --git a/src/contour/contour.yml b/src/contour/contour.yml index 4d95a0c88b..f651909a1e 100644 --- a/src/contour/contour.yml +++ b/src/contour/contour.yml @@ -398,6 +398,11 @@ profiles: # Default: bottom position: bottom + # Synchronize the window title with the Host Writable status_line if + # and only if the host writable status line was denied to be shown. + # Default: false + sync_to_window_title: false + # Background configuration background: # Background opacity to use. A value of 1.0 means fully opaque whereas 0.0 means fully diff --git a/src/vtbackend/Screen.cpp b/src/vtbackend/Screen.cpp index 348804690b..b42ece5006 100644 --- a/src/vtbackend/Screen.cpp +++ b/src/vtbackend/Screen.cpp @@ -3668,7 +3668,17 @@ ApplyResult Screen::apply(FunctionDefinition const& function, Sequence con // Selects whether the terminal sends data to the main display or the status line. switch (seq.param_or(0, 0)) { - case 0: _terminal.setActiveStatusDisplay(ActiveStatusDisplay::Main); break; + case 0: + if (_state.activeStatusDisplay == ActiveStatusDisplay::StatusLine + && _state.syncWindowTitleWithHostWritableStatusDisplay) + { + _terminal.setWindowTitle(crispy::trimRight( + _terminal.hostWritableStatusLineDisplay().grid().lineText(LineOffset(0)))); + _state.syncWindowTitleWithHostWritableStatusDisplay = false; + } + _terminal.setActiveStatusDisplay(ActiveStatusDisplay::Main); + break; + case 1: _terminal.setActiveStatusDisplay(ActiveStatusDisplay::StatusLine); break; default: return ApplyResult::Invalid; } diff --git a/src/vtbackend/Settings.h b/src/vtbackend/Settings.h index 079f5193ad..aaa76c771a 100644 --- a/src/vtbackend/Settings.h +++ b/src/vtbackend/Settings.h @@ -38,6 +38,7 @@ struct Settings unsigned maxImageRegisterCount = 256; StatusDisplayType statusDisplayType = StatusDisplayType::None; StatusDisplayPosition statusDisplayPosition = StatusDisplayPosition::Bottom; + bool syncWindowTitleWithHostWritableStatusDisplay = true; CursorDisplay cursorDisplay = CursorDisplay::Steady; CursorShape cursorShape = CursorShape::Block; diff --git a/src/vtbackend/TerminalState.h b/src/vtbackend/TerminalState.h index 5036ddc750..0872e57f29 100644 --- a/src/vtbackend/TerminalState.h +++ b/src/vtbackend/TerminalState.h @@ -186,6 +186,7 @@ struct TerminalState ScreenType screenType = ScreenType::Primary; StatusDisplayType statusDisplayType = StatusDisplayType::None; + bool syncWindowTitleWithHostWritableStatusDisplay = false; std::optional savedStatusDisplayType = std::nullopt; ActiveStatusDisplay activeStatusDisplay = ActiveStatusDisplay::Main; From 141c850cb693ca3a26f661f623eb33be5388e308 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Tue, 11 Apr 2023 05:22:47 +0200 Subject: [PATCH 024/112] Apply clang-format fixups Signed-off-by: Christian Parpart --- src/contour/TerminalSession.cpp | 3 ++- src/vtbackend/Terminal.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/contour/TerminalSession.cpp b/src/contour/TerminalSession.cpp index 89154bc8c9..6e78c9925d 100644 --- a/src/contour/TerminalSession.cpp +++ b/src/contour/TerminalSession.cpp @@ -124,7 +124,8 @@ namespace settings.maxImageRegisterCount = config.maxImageColorRegisters; settings.statusDisplayType = profile.initialStatusDisplayType; settings.statusDisplayPosition = profile.statusDisplayPosition; - settings.syncWindowTitleWithHostWritableStatusDisplay = profile.syncWindowTitleWithHostWritableStatusDisplay; + settings.syncWindowTitleWithHostWritableStatusDisplay = + profile.syncWindowTitleWithHostWritableStatusDisplay; settings.colorPalette = profile.colors; settings.refreshRate = profile.refreshRate; settings.primaryScreen.allowReflowOnResize = config.reflowOnResize; diff --git a/src/vtbackend/Terminal.cpp b/src/vtbackend/Terminal.cpp index 2392719771..74459ba2f2 100644 --- a/src/vtbackend/Terminal.cpp +++ b/src/vtbackend/Terminal.cpp @@ -767,7 +767,8 @@ void Terminal::clearSelection() breakLoopAndRefreshRenderBuffer(); } -bool Terminal::shouldExtendSelectionByMouse(CellLocation newPosition, PixelCoordinate pixelPosition) const noexcept +bool Terminal::shouldExtendSelectionByMouse(CellLocation newPosition, + PixelCoordinate pixelPosition) const noexcept { if (!selectionAvailable() || selector()->state() == Selection::State::Complete) return false; From 076dc7ba85d303d1e808e4ccc299e74994c76c92 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Tue, 11 Apr 2023 02:20:44 +0200 Subject: [PATCH 025/112] [vtbackend] Fixes `[count]w` ignoring the `[count]` parameter in modal mode Signed-off-by: Christian Parpart --- metainfo.xml | 1 + src/vtbackend/ViCommands.cpp | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/metainfo.xml b/metainfo.xml index 2c2807845a..25c123fdec 100644 --- a/metainfo.xml +++ b/metainfo.xml @@ -110,6 +110,7 @@
  • Fixes selecting a single character not working easily (#1066).
  • Fixes cycling between different selection modes (by speed-clicking) not properly working.
  • Fixes tcsh shell integration not working (#1074).
  • +
  • Fixes `[count]w` ignoring the `[count]` parameter in modal mode.
  • Improves mouse selection to be more natural extending into new grid cells.
  • Adds `profiles.*.permissions.display_host_writable_statusline` to allow the user to intervene in `DECSSDT 2` VT sequence to show the host writable statusline.
  • Adds config entry `input_method_editor` colorscheme key to allow customization of the IME (input method editor) region (#1058).
  • diff --git a/src/vtbackend/ViCommands.cpp b/src/vtbackend/ViCommands.cpp index af20486d81..9fc1c13285 100644 --- a/src/vtbackend/ViCommands.cpp +++ b/src/vtbackend/ViCommands.cpp @@ -991,13 +991,17 @@ CellLocation ViCommands::translateToCellLocation(ViMotion motion, unsigned count auto const lastAddressableLocation = CellLocation { LineOffset::cast_from(_terminal.pageSize().lines - 1), ColumnOffset::cast_from(_terminal.pageSize().columns - 1) }; - auto initialClass = wordSkipClass(_terminal.currentScreen().cellTextAt(cursorPosition)); - auto result = next(cursorPosition); - - while (result != lastAddressableLocation - && shouldSkipForUntilWordBegin(wordSkipClass(_terminal.currentScreen().cellTextAt(result)), - initialClass)) + auto result = cursorPosition; + while (count > 0) + { + auto initialClass = wordSkipClass(_terminal.currentScreen().cellTextAt(result)); result = next(result); + while (result != lastAddressableLocation + && shouldSkipForUntilWordBegin( + wordSkipClass(_terminal.currentScreen().cellTextAt(result)), initialClass)) + result = next(result); + --count; + } return result; } From be15b1d1e4778d3ce317c802bf4b3afdcaa6bae9 Mon Sep 17 00:00:00 2001 From: Yaraslau Tamashevich Date: Tue, 11 Apr 2023 12:30:05 +0300 Subject: [PATCH 026/112] add installation section and move requierements and configuration sections higher --- README.md | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 14b534cbe7..3a6d811a49 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,26 @@ for everyday use. It is aiming for power users with a modern feature mindset. - ✅ VT320 Host-programmable and Indicator status line support. - ✅ and much more ... +## Installation + +`contour` is packaged and available for installation on multiple distributions. + - `Fedora` use official [package](https://packages.fedoraproject.org/pkgs/contour-terminal/contour-terminal/) + +```sh +sudo dnf install contour-terminal +``` + + - `Arch` use AUR [package](https://aur.archlinux.org/packages/contour-git) + +## Requirements + +- **operating system**: A *recent* operating system (OS/X 12, Windows 10+, an up-to-date Linux, or FreeBSD) +- **GPU**: driver must support at least OpenGL 3.3 hardware accelerated or as software rasterizer. +- **CPU**: x86-64 AMD or Intel with AES-NI instruction set or ARMv8 with crypto extensions. + +## Configuration + +In order to set up Contour, it is necessary to modify the configuration file `contour.yml`, which is initially generated in the `$HOME/.config/contour` directory. ## Installing from source @@ -91,18 +111,6 @@ Click the following button install Contour from the Flathub store. - [Install from Flathub](#install-from-flathub) - [Install from GitHub release](https://github.com/contour-terminal/contour/releases) - -## Configuration - - -In order to set up Contour, it is necessary to modify the configuration file `contour.yml`, which is initially generated in the `$HOME/.config/contour` directory. - -## Requirements - -- **operating system**: A *recent* operating system (OS/X 12, Windows 10+, an up-to-date Linux, or FreeBSD) -- **GPU**: driver must support at least OpenGL 3.3 hardware accelerated or as software rasterizer. -- **CPU**: x86-64 AMD or Intel with AES-NI instruction set or ARMv8 with crypto extensions. - ## CLI - Command Line Interface ```txt From ed674772dbe1d3b7b00fc73b1bdef8bd5f2b94d2 Mon Sep 17 00:00:00 2001 From: Yaraslau Tamashevich Date: Tue, 11 Apr 2023 22:20:04 +0300 Subject: [PATCH 027/112] Move installation via Flatpak subsection into installation section --- README.md | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 3a6d811a49..fb2a0d87aa 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,23 @@ sudo dnf install contour-terminal - `Arch` use AUR [package](https://aur.archlinux.org/packages/contour-git) +### Installing via Flatpak + +#### Install from Flathub + +Click the following button install Contour from the Flathub store. + +[![Get it on Flathub](https://raw.githubusercontent.com/flatpak-design-team/flathub-mockups/master/assets/download-button/download.svg?sanitize=true)](https://flathub.org/apps/details/org.contourterminal.Contour) + + +#### Prerequisites + +- Make sure you have flatpak installed in your system ([here is a tutorial on how to install it](https://flatpak.org/getting.html)), and make sure that the version is >= 0.10 (check it using this command: `flatpak --version`) +- Add the [flathub](https://flathub.org) repository using the following command: `flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo`. +- Proceed with one of the following options: + - [Install from Flathub](#install-from-flathub) + - [Install from GitHub release](https://github.com/contour-terminal/contour/releases) + ## Requirements - **operating system**: A *recent* operating system (OS/X 12, Windows 10+, an up-to-date Linux, or FreeBSD) @@ -94,22 +111,6 @@ cmake --build build/ cmake --build build/ --target install ``` -### Installing via Flatpak - -#### Install from Flathub - -Click the following button install Contour from the Flathub store. - -[![Get it on Flathub](https://raw.githubusercontent.com/flatpak-design-team/flathub-mockups/master/assets/download-button/download.svg?sanitize=true)](https://flathub.org/apps/details/org.contourterminal.Contour) - - -#### Prerequisites - -- Make sure you have flatpak installed in your system ([here is a tutorial on how to install it](https://flatpak.org/getting.html)), and make sure that the version is >= 0.10 (check it using this command: `flatpak --version`) -- Add the [flathub](https://flathub.org) repository using the following command: `flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo`. -- Proceed with one of the following options: - - [Install from Flathub](#install-from-flathub) - - [Install from GitHub release](https://github.com/contour-terminal/contour/releases) ## CLI - Command Line Interface From 9d3ca4df1f22cf7a87490e8dc12ae0476e6b3dd6 Mon Sep 17 00:00:00 2001 From: Bence Ferdinandy Date: Fri, 14 Apr 2023 20:33:23 +0200 Subject: [PATCH 028/112] readme: mention shell integration at configuration The shell integration was previously hidden in the CLI options. Add an explicit mention of them at the configuration part. --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fb2a0d87aa..89748b4092 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,10 @@ Click the following button install Contour from the Flathub store. ## Configuration -In order to set up Contour, it is necessary to modify the configuration file `contour.yml`, which is initially generated in the `$HOME/.config/contour` directory. +In order to set up Contour, it is necessary to modify the configuration file +`contour.yml`, which is initially generated in the `$HOME/.config/contour` +directory. Some features also require shell integration. These can be generated +via the CLI (see below), these currently exist for zsh, fish and tcsh. ## Installing from source From d91459c052ac253d539622ce23acbc7062d6a1bf Mon Sep 17 00:00:00 2001 From: Bence Ferdinandy Date: Fri, 14 Apr 2023 20:47:40 +0200 Subject: [PATCH 029/112] readme: update compilation instructions Compiling on Windows is not possible based on the current instructions. Add additional instructions regarding prerequisites that need to be manually installed and the necessary flags for the build tools so these are also found during compilation. Restructure the installing from source part to separate the two different type of instructions (i.e. Windows from everything else with more sane development environment). --- README.md | 46 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 89748b4092..fe42abd3fc 100644 --- a/README.md +++ b/README.md @@ -83,10 +83,12 @@ via the CLI (see below), these currently exist for zsh, fish and tcsh. ## Installing from source -It's best installed from supported package managers, but if you want -to build from source, it is recommended to execute the `scripts/install-deps.sh` script. +Contour is best installed from supported package managers, but you can build +from source by following the instruction below. -### Prerequisites UNIX-like systems (Linux, FreeBSD, OS/X) +### UNIX-like systems (Linux, FreeBSD, OS/X) + +#### Prerequisites ```sh ./scripts/install-deps.sh @@ -95,19 +97,45 @@ to build from source, it is recommended to execute the `scripts/install-deps.sh` This script *might* ask you for the administrator password if a package dependency can be insalled via the system package manager. -### Prerequisites Windows 10 or newer +#### Compile + +```sh +cmake -S . -B build -G Ninja +cmake --build build/ + +# Optionally, if you want to install from source +cmake --build build/ --target install +``` + +#### Windows 10 or newer + +#### Prerequisites For Windows, you must have Windows 10, 2018 Fall Creators Update, and Visual Studio 2019, installed. It will neither build nor run on any prior Windows OS, due to libterminal making use of [ConPTY API](https://devblogs.microsoft.com/commandline/windows-command-line-introducing-the-windows-pseudo-console-conpty/). -```psh -.\scripts\install-deps.ps1 +1. Set up [vcpkg](https://vcpkg.io/en/getting-started.html), preferably somewhere high up in the folder hierarchy, and add the folder to your `PATH`. + +``` +cd C:\ +git clone git clone https://github.com/Microsoft/vcpkg.git +.\vcpkg\bootstrap-vcpkg.bat ``` -### Compile +2. Install Visual Studio Build Tools (make sure to select the CLI tools for + C++, which you might need to do in the separate components tab). +3. Install Qt6 (i.e. to C:\Qt) +4. Open the _developer_ version of Powershell. +5. In the `contour` source folder execute `.\scripts\install-deps.ps1`. This step may take a _very_ long time. -```sh -cmake -S . -B build -G Ninja + +#### Compile + +In the _developer_ version of Powershell: + +```psh +# change paths accordingly if you installed QT and vcpkg to somewhere else +cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake -DCMAKE_PREFIX_PATH=C:\Qt\6.5.0\msvc2019_64\lib\cmake cmake --build build/ # Optionally, if you want to install from source From 47598e1f45725d073d33a22f6187f4cfb2146b5b Mon Sep 17 00:00:00 2001 From: Yaraslau Tamashevich Date: Sat, 15 Apr 2023 10:18:28 +0300 Subject: [PATCH 030/112] move Ubuntu 18.04 packaging to docker --- .github/ubuntu18/Dockerfile | 39 ++++++++++++++++ .github/workflows/build.yml | 88 +++++++++++++++++++++++++++-------- .github/workflows/release.yml | 64 +++++++++++++++++++++++++ README.md | 51 ++++++++++++++++---- 4 files changed, 213 insertions(+), 29 deletions(-) create mode 100644 .github/ubuntu18/Dockerfile diff --git a/.github/ubuntu18/Dockerfile b/.github/ubuntu18/Dockerfile new file mode 100644 index 0000000000..6d7c232337 --- /dev/null +++ b/.github/ubuntu18/Dockerfile @@ -0,0 +1,39 @@ +FROM ubuntu:18.04 + +# Install updates to base image +RUN \ + apt-get update \ + && apt-get install -y \ + git \ + wget \ + sudo \ + ninja-build \ + software-properties-common + +RUN add-apt-repository ppa:ubuntu-toolchain-r/test +RUN apt-get update +RUN apt-get install -y g++-10 + +RUN apt-get purge -y --auto-remove cmake +RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null +RUN apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' +RUN apt-get install -y cmake + +WORKDIR /home/docker + +RUN git clone --depth=1 https://github.com/contour-terminal/contour.git +WORKDIR /home/docker/contour +RUN SYSDEP_ASSUME_YES=ON ./scripts/install-deps.sh +RUN cmake --version +RUN g++-10 --version +RUN cmake -S . -B build -G Ninja \ + -D CMAKE_CXX_STANDARD=20 \ + -D CMAKE_CXX_COMPILER=g++-10 + +RUN cmake --build build -- -j3 +RUN ./build/src/crispy/crispy_test +RUN ./build/src/vtparser/vtparser_test +RUN ./build/src/vtbackend/vtbackend_test +RUN cd build && cpack -G DEB -V . +RUN mv build/*.deb package.deb +RUN mv build/*.ddeb package.ddeb diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eb4fedd493..5122199d4c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -78,6 +78,69 @@ jobs: if-no-files-found: error retention-days: 7 + ubuntu18: + strategy: + matrix: + arch: + [ + "linux/amd64 x86_64" + ] + name: "Packaging for Ubuntu 18.04" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: all + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + with: + version: latest + - name: Read info + id: tags + shell: bash + run: | + arch="${{ matrix.arch }}" + echo "PLATFORM=${arch%% *}" >> "$GITHUB_OUTPUT" + echo "ARCH=${arch##* }" >> "$GITHUB_OUTPUT" + - name: Installing xmllint for ci-set-vars + run: sudo apt -qy install libxml2-utils + - name: set environment variables + id: set_vars + run: ./scripts/ci-set-vars.sh + env: + REPOSITORY: ${{ github.event.repository.name }} + - name: Build ${{ matrix.arch }} release + shell: bash + run: | + docker buildx build --platform ${{ steps.tags.outputs.PLATFORM }} \ + --tag contour:${{ steps.tags.outputs.ARCH }} \ + -f .github/ubuntu18/Dockerfile \ + --load \ + . + docker create --name contour-${{ steps.tags.outputs.ARCH }} contour:${{ steps.tags.outputs.ARCH }} + docker cp contour-${{ steps.tags.outputs.ARCH }}:/home/docker/contour/package.deb \ + "contour-${{ steps.set_vars.outputs.VERSION_STRING }}-ubuntu18.04-amd64.deb" + docker cp contour-${{ steps.tags.outputs.ARCH }}:/home/docker/contour/package.ddeb \ + "contour-dbgsym-${{ steps.set_vars.outputs.VERSION_STRING }}-ubuntu18.04-amd64.ddeb" + docker container rm contour-${{ steps.tags.outputs.ARCH }} + - name: "Uploading artifact .deb package" + uses: actions/upload-artifact@v3 + with: + name: "contour-${{ steps.set_vars.outputs.VERSION_STRING }}-ubuntu18.04-amd64.deb" + path: "contour-${{ steps.set_vars.outputs.VERSION_STRING }}-ubuntu18.04-amd64.deb" + if-no-files-found: error + retention-days: 7 + - name: "Uploading artifact .ddeb package (debugging symbols)" + uses: actions/upload-artifact@v3 + with: + name: "contour-dbgsym-${{ steps.set_vars.outputs.VERSION_STRING }}-ubuntu18.04-amd64.ddeb" + path: "contour-dbgsym-${{ steps.set_vars.outputs.VERSION_STRING }}-ubuntu18.04-amd64.ddeb" + if-no-files-found: error + retention-days: 7 + fedora: strategy: matrix: @@ -170,7 +233,6 @@ jobs: path: "contour-debugsource-${{ steps.set_vars.outputs.VERSION }}-1.fc${{ matrix.os_version }}.${{ steps.tags.outputs.ARCH }}.rpm" if-no-files-found: error retention-days: 7 - freebsd: runs-on: macos-12 name: FreeBSD 13 @@ -427,21 +489,17 @@ jobs: test/images retention-days: 1 - # Create AppImage (Using Ubuntu 18.04 as base). + # Create AppImage (Using Ubuntu 20.04 as base). package_for_AppImage: name: "Packaging for AppImage" - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 - name: ccache uses: hendrikmuhs/ccache-action@v1.2 with: - key: "ccache-ubuntu1804-AppImage" + key: "ccache-ubuntu2004-AppImage" max-size: 256M - - name: Remove GCC-11 to not mess with AppImage on stock Ubuntu 18.04 - run: | - sudo apt-get autoremove -y libgcc-9-dev gcc-9 libgcc-10-dev gcc-10 libgcc-11-dev gcc-11 - sudo apt-get install --allow-downgrades --no-remove --reinstall -y libstdc++6=8.4.0-1ubuntu1~18.04 - name: Installing xmllint for ci-set-vars run: sudo apt -qy install libxml2-utils - name: "set environment variables" @@ -459,15 +517,13 @@ jobs: run: sudo ./scripts/install-deps.sh - name: "Post-fix embedded dependency permissions." run: sudo find _deps/sources -exec chown $UID {} \; - - name: "install Clang++-10" - run: sudo apt install clang++-10 - name: CMake version run: cmake --version - name: "cmake" run: | mkdir build BUILD_DIR="build" \ - CXX="g++-8" \ + CXX="g++-10" \ CMAKE_BUILD_TYPE=RelWithDebInfo \ EXTRA_CMAKE_FLAGS="$EXTRA_CMAKE_FLAGS \ -DCMAKE_INSTALL_PREFIX="/usr" \ @@ -506,7 +562,7 @@ jobs: strategy: fail-fast: false matrix: - os_version: ['18.04', '20.04', '22.04'] + os_version: ['20.04', '22.04'] runs-on: ubuntu-${{ matrix.os_version }} steps: - name: Checkout code @@ -537,9 +593,6 @@ jobs: run: sudo env QTVER="${{ steps.set_qtver.outputs.QTVER }}" ./scripts/install-deps.sh - name: "Post-fix embedded dependency permissions." run: sudo find _deps/sources -exec chown $UID {} \; - - name: "install GCC 10" - if: ${{ startsWith(matrix.os_version, '18.04') }} - run: sudo apt install g++-10 - name: "create build directory" run: mkdir build - name: CMake version @@ -548,10 +601,7 @@ jobs: run: | # TODO: turn on -Werror again, that requires some code changes. CMAKE_CXX_STANDARD=20 - if [[ "${{ matrix.os_version }}" = "18.04" ]]; then - # CMAKE_CXX_STANDARD=17 - export CXX="g++-10" - elif [[ "${{ matrix.os_version }}" = "22.04" ]]; then + if [[ "${{ matrix.os_version }}" = "22.04" ]]; then EXTRA_CMAKE_FLAGS="$EXTRA_CMAKE_FLAGS -DCONTOUR_BUILD_WITH_QT6=OFF" fi BUILD_DIR="build" \ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 18e95297b5..e6a2faccc6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -222,6 +222,70 @@ jobs: if-no-files-found: error retention-days: 7 + ubuntu18: + strategy: + matrix: + arch: + [ + "linux/amd64 x86_64" + ] + name: "Packaging for Ubuntu 18.04" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: all + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + with: + version: latest + - name: Read info + id: tags + shell: bash + run: | + arch="${{ matrix.arch }}" + echo "PLATFORM=${arch%% *}" >> "$GITHUB_OUTPUT" + echo "ARCH=${arch##* }" >> "$GITHUB_OUTPUT" + - name: Installing xmllint for ci-set-vars + run: sudo apt -qy install libxml2-utils + - name: set environment variables + id: set_vars + run: ./scripts/ci-set-vars.sh + env: + REPOSITORY: ${{ github.event.repository.name }} + - name: Build ${{ matrix.arch }} release + shell: bash + run: | + docker buildx build --platform ${{ steps.tags.outputs.PLATFORM }} \ + --tag contour:${{ steps.tags.outputs.ARCH }} \ + -f .github/ubuntu18/Dockerfile \ + --load \ + . + docker create --name contour-${{ steps.tags.outputs.ARCH }} contour:${{ steps.tags.outputs.ARCH }} + docker cp contour-${{ steps.tags.outputs.ARCH }}:/home/docker/contour/package.deb \ + "contour-${{ steps.set_vars.outputs.VERSION_STRING }}-ubuntu18.04-amd64.deb" + docker cp contour-${{ steps.tags.outputs.ARCH }}:/home/docker/contour/package.ddeb \ + "contour-dbgsym-${{ steps.set_vars.outputs.VERSION_STRING }}-ubuntu18.04-amd64.ddeb" + docker container rm contour-${{ steps.tags.outputs.ARCH }} + - name: "Uploading artifact .deb package" + uses: actions/upload-artifact@v3 + with: + name: "contour-${{ steps.set_vars.outputs.VERSION_STRING }}-ubuntu18.04-amd64.deb" + path: "contour-${{ steps.set_vars.outputs.VERSION_STRING }}-ubuntu18.04-amd64.deb" + if-no-files-found: error + retention-days: 7 + - name: "Uploading artifact .ddeb package (debugging symbols)" + uses: actions/upload-artifact@v3 + with: + name: "contour-dbgsym-${{ steps.set_vars.outputs.VERSION_STRING }}-ubuntu18.04-amd64.ddeb" + path: "contour-dbgsym-${{ steps.set_vars.outputs.VERSION_STRING }}-ubuntu18.04-amd64.ddeb" + if-no-files-found: error + retention-days: 7 + + build_fedora: strategy: matrix: diff --git a/README.md b/README.md index fb2a0d87aa..fe42abd3fc 100644 --- a/README.md +++ b/README.md @@ -76,14 +76,19 @@ Click the following button install Contour from the Flathub store. ## Configuration -In order to set up Contour, it is necessary to modify the configuration file `contour.yml`, which is initially generated in the `$HOME/.config/contour` directory. +In order to set up Contour, it is necessary to modify the configuration file +`contour.yml`, which is initially generated in the `$HOME/.config/contour` +directory. Some features also require shell integration. These can be generated +via the CLI (see below), these currently exist for zsh, fish and tcsh. ## Installing from source -It's best installed from supported package managers, but if you want -to build from source, it is recommended to execute the `scripts/install-deps.sh` script. +Contour is best installed from supported package managers, but you can build +from source by following the instruction below. -### Prerequisites UNIX-like systems (Linux, FreeBSD, OS/X) +### UNIX-like systems (Linux, FreeBSD, OS/X) + +#### Prerequisites ```sh ./scripts/install-deps.sh @@ -92,19 +97,45 @@ to build from source, it is recommended to execute the `scripts/install-deps.sh` This script *might* ask you for the administrator password if a package dependency can be insalled via the system package manager. -### Prerequisites Windows 10 or newer +#### Compile + +```sh +cmake -S . -B build -G Ninja +cmake --build build/ + +# Optionally, if you want to install from source +cmake --build build/ --target install +``` + +#### Windows 10 or newer + +#### Prerequisites For Windows, you must have Windows 10, 2018 Fall Creators Update, and Visual Studio 2019, installed. It will neither build nor run on any prior Windows OS, due to libterminal making use of [ConPTY API](https://devblogs.microsoft.com/commandline/windows-command-line-introducing-the-windows-pseudo-console-conpty/). -```psh -.\scripts\install-deps.ps1 +1. Set up [vcpkg](https://vcpkg.io/en/getting-started.html), preferably somewhere high up in the folder hierarchy, and add the folder to your `PATH`. + +``` +cd C:\ +git clone git clone https://github.com/Microsoft/vcpkg.git +.\vcpkg\bootstrap-vcpkg.bat ``` -### Compile +2. Install Visual Studio Build Tools (make sure to select the CLI tools for + C++, which you might need to do in the separate components tab). +3. Install Qt6 (i.e. to C:\Qt) +4. Open the _developer_ version of Powershell. +5. In the `contour` source folder execute `.\scripts\install-deps.ps1`. This step may take a _very_ long time. -```sh -cmake -S . -B build -G Ninja + +#### Compile + +In the _developer_ version of Powershell: + +```psh +# change paths accordingly if you installed QT and vcpkg to somewhere else +cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake -DCMAKE_PREFIX_PATH=C:\Qt\6.5.0\msvc2019_64\lib\cmake cmake --build build/ # Optionally, if you want to install from source From c6ebe2c52252fbee2d68450cad79a36b9fc9b8dc Mon Sep 17 00:00:00 2001 From: Yaraslau Tamashevich Date: Tue, 18 Apr 2023 21:38:14 +0300 Subject: [PATCH 031/112] Fix int to unsigned conversion --- src/vtrasterizer/DecorationRenderer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vtrasterizer/DecorationRenderer.cpp b/src/vtrasterizer/DecorationRenderer.cpp index 3bba904d27..ec4beba80d 100644 --- a/src/vtrasterizer/DecorationRenderer.cpp +++ b/src/vtrasterizer/DecorationRenderer.cpp @@ -153,7 +153,7 @@ auto DecorationRenderer::createTileData(Decorator decoration, atlas::TileLocatio case Decorator::Underline: { auto const thickness_half = max(1u, unsigned(ceil(underlineThickness() / 2.0))); auto const thickness = thickness_half * 2; - auto const y0 = max(0u, unsigned(underlinePosition()) - thickness_half); + auto const y0 = max(0, (underlinePosition() - static_cast(thickness_half))); auto const height = Height(y0 + thickness); auto const imageSize = ImageSize { width, height }; return create(imageSize, [&]() -> atlas::Buffer { @@ -235,7 +235,7 @@ auto DecorationRenderer::createTileData(Decorator decoration, atlas::TileLocatio // whereas the middle one is being skipped. auto const thickness_half = max(1u, unsigned(ceil(underlineThickness() / 2.0))); auto const thickness = max(1u, thickness_half * 2); - auto const y0 = max(0u, unsigned(underlinePosition()) - thickness_half); + auto const y0 = max(0, underlinePosition() - static_cast(thickness_half)); auto const height = Height(y0 + thickness); auto const imageSize = ImageSize { width, height }; return create(imageSize, [&]() -> atlas::Buffer { From 528a31f31e30b3ffba5bbbebf4d2243900a514fa Mon Sep 17 00:00:00 2001 From: Yaraslau Tamashevich Date: Thu, 20 Apr 2023 15:27:02 +0200 Subject: [PATCH 032/112] Fix qt6 build on windows and add CONTOUR_QT_VERSION --- .github/fedora/contour.spec | 2 +- .github/workflows/build.yml | 6 +++--- .github/workflows/release.yml | 4 ++-- CMakeLists.txt | 11 ++++++++++- autogen.sh | 4 ++-- cmake/DeployQt.cmake | 3 ++- src/contour/CMakeLists.txt | 24 ++++++++++-------------- src/contour/display/CMakeLists.txt | 6 +++--- 8 files changed, 33 insertions(+), 27 deletions(-) diff --git a/.github/fedora/contour.spec b/.github/fedora/contour.spec index 898f44445f..e94c606d6b 100644 --- a/.github/fedora/contour.spec +++ b/.github/fedora/contour.spec @@ -50,7 +50,7 @@ for everyday use. It is aiming for power users with a modern feature mindset. cmake . \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_INSTALL_PREFIX=/usr \ - -DCONTOUR_BUILD_WITH_QT6=ON \ + -DCONTOUR_QT_VERSION=6 \ -DPEDANTIC_COMPILER=ON \ -DPEDANTIC_COMPILER_WERROR=ON \ -B build \ diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eb4fedd493..5593988954 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -233,7 +233,7 @@ jobs: cmake . \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DQt5_DIR="$(brew --prefix qt5)/lib/cmake/Qt5" \ - -DCONTOUR_BUILD_WITH_QT6=OFF \ + -DCONTOUR_QT_VERSION=5 \ -B build/ - name: "Build" run: cmake --build build/ @@ -296,7 +296,7 @@ jobs: New-Item -ItemType Directory -Force -Path build } - name: "Generate build files" - run: cmake -DCMAKE_BUILD_TYPE=Release -DCONTOUR_BUILD_WITH_QT6=OFF -DLIBTERMINAL_BUILD_BENCH_HEADLESS=ON -DCMAKE_CXX_STANDARD=17 -DCMAKE_TOOLCHAIN_FILE="${{ runner.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x64-windows -DLIBTERMINAL_TESTING=ON -DLIBUNICODE_TESTING=ON -B build . + run: cmake -DCMAKE_BUILD_TYPE=Release -DCONTOUR_QT_VERSION=5 -DLIBTERMINAL_BUILD_BENCH_HEADLESS=ON -DCMAKE_CXX_STANDARD=17 -DCMAKE_TOOLCHAIN_FILE="${{ runner.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x64-windows -DLIBTERMINAL_TESTING=ON -DLIBUNICODE_TESTING=ON -B build . - name: "Build" run: cmake --build build/ --config Release - name: "test: crispy" @@ -552,7 +552,7 @@ jobs: # CMAKE_CXX_STANDARD=17 export CXX="g++-10" elif [[ "${{ matrix.os_version }}" = "22.04" ]]; then - EXTRA_CMAKE_FLAGS="$EXTRA_CMAKE_FLAGS -DCONTOUR_BUILD_WITH_QT6=OFF" + EXTRA_CMAKE_FLAGS="$EXTRA_CMAKE_FLAGS -DCONTOUR_QT_VERSION=5" fi BUILD_DIR="build" \ CMAKE_BUILD_TYPE=RelWithDebInfo \ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 18e95297b5..1c0281160d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -79,7 +79,7 @@ jobs: - name: "create build directory" run: mkdir build - name: "Generate build files" - run: cmake -DCMAKE_BUILD_TYPE=Release -DCONTOUR_BUILD_WITH_QT6=OFF -DCMAKE_CXX_STANDARD=17 -DCMAKE_TOOLCHAIN_FILE="${{ runner.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x64-windows -DLIBTERMINAL_TESTING=OFF -DLIBUNICODE_TESTING=OFF -B build . + run: cmake -DCMAKE_BUILD_TYPE=Release -DCONTOUR_QT_VERSION=5 -DCMAKE_CXX_STANDARD=17 -DCMAKE_TOOLCHAIN_FILE="${{ runner.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x64-windows -DLIBTERMINAL_TESTING=OFF -DLIBUNICODE_TESTING=OFF -B build . - name: "Build" run: cmake --build build/ --config Release - name: "Create Package(s)" @@ -133,7 +133,7 @@ jobs: cmake . \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DQt5_DIR="$(brew --prefix qt5)/lib/cmake/Qt5" \ - -DCONTOUR_BUILD_WITH_QT6=OFF \ + -DCONTOUR_QT_VERSION=5 \ -B build/ - name: "Build" run: cmake --build build/ diff --git a/CMakeLists.txt b/CMakeLists.txt index fb2d5d7c8e..a1e4c8db65 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,15 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +set(QT_VERSION_DEFAULT "5") +if(APPLE OR WIN32 OR FREEBSD) + set(QT_VERSION_DEFAULT "6") +endif() + +if(NOT CONTOUR_QT_VERSION) + set(CONTOUR_QT_VERSION "${QT_VERSION_DEFAULT}") +endif() + if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")) set(CMAKE_CXX_FLAGS_DEBUG "-Og -g") endif() @@ -120,7 +129,7 @@ macro(ContourConfigurationSummary) message(STATUS "Build unit tests: ${CONTOUR_TESTING}") message(STATUS "Enable with code coverage: ${CONTOUR_CODE_COVERAGE_ENABLED}") message(STATUS "Build contour frontend GUI: ${CONTOUR_FRONTEND_GUI}") - message(STATUS "Build contour using Qt 6: ${CONTOUR_BUILD_WITH_QT6}") + message(STATUS "Build contour using Qt : ${CONTOUR_QT_VERSION}") message(STATUS "Build contour using mimalloc: ${CONTOUR_BUILD_WITH_MIMALLOC}") message(STATUS "Clang Tidy: ${USING_TIDY_STRING}") message(STATUS "|> Enable performance metrics: ${CONTOUR_PERF_STATS}") diff --git a/autogen.sh b/autogen.sh index 6d9ff8b890..2b64669de5 100755 --- a/autogen.sh +++ b/autogen.sh @@ -27,9 +27,9 @@ BUILD_DIR="${ROOTDIR}/target/$(uname -m)-$(uname -s)-${CXX_NAME}-${BUILD_TYPE}" EXTRA_CMAKE_FLAGS="$EXTRA_CMAKE_FLAGS -DLIBUNICODE_UCD_BASE_DIR=$ROOTDIR/_ucd" if test v$QTVER = v6; then - EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DCONTOUR_BUILD_WITH_QT6=ON" + EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DCONTOUR_QT_VERSION=6" else - EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DCONTOUR_BUILD_WITH_QT6=OFF" + EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DCONTOUR_QT_VERSION=5" fi case "$OSTYPE" in diff --git a/cmake/DeployQt.cmake b/cmake/DeployQt.cmake index 21ca11da9d..30f9a245ab 100644 --- a/cmake/DeployQt.cmake +++ b/cmake/DeployQt.cmake @@ -22,7 +22,8 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -set(DEPLOY_QT_VERSION 5) + +set(DEPLOY_QT_VERSION ${CONTOUR_QT_VERSION}) find_package(Qt${DEPLOY_QT_VERSION}Core REQUIRED) diff --git a/src/contour/CMakeLists.txt b/src/contour/CMakeLists.txt index d036add387..b310eb6036 100644 --- a/src/contour/CMakeLists.txt +++ b/src/contour/CMakeLists.txt @@ -1,3 +1,4 @@ + include(FilesystemResolver) set(AppId "org.contourterminal.Contour") @@ -6,23 +7,17 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") set(FREEBSD TRUE) endif() -set(QT6_DEFAULT OFF) -if(APPLE OR WIN32 OR FREEBSD) - set(QT6_DEFAULT ON) -endif() - option(CONTOUR_PERF_STATS "Enables debug printing some performance stats." OFF) option(CONTOUR_VT_METRICS "Enables collecting and exit-printing some VT usage metrics." OFF) option(CONTOUR_SCROLLBAR "Enables scrollbar in GUI frontend." ON) -option(CONTOUR_BUILD_WITH_QT6 "Use Qt 6" ${QT6_DEFAULT}) set(QtX11Extras) -if(NOT(WIN32) AND NOT(APPLE) AND NOT(CONTOUR_BUILD_WITH_QT6)) +if(NOT(WIN32) AND NOT(APPLE) AND (CONTOUR_QT_VERSION EQUAL "5")) set(QtX11Extras X11Extras) endif() -message(STATUS "Build contour using Qt 6: ${CONTOUR_BUILD_WITH_QT6}") -if(CONTOUR_BUILD_WITH_QT6) +message(STATUS "Build contour using Qt : ${CONTOUR_QT_VERSION}") +if(CONTOUR_QT_VERSION EQUAL "6") find_package(Qt6 COMPONENTS Core Gui Network OpenGL OpenGLWidgets Widgets Multimedia ${QtX11Extras} REQUIRED) else() find_package(Qt5 COMPONENTS Gui Network Widgets Multimedia ${QtX11Extras} REQUIRED) # apt install qtbase5-dev libqt5gui5 @@ -56,7 +51,7 @@ endif() set(QT_RESOURCES resources.qrc) -if(NOT(CONTOUR_BUILD_WITH_QT6)) +if(CONTOUR_QT_VERSION EQUAL "5") qt5_add_resources(QT_RESOURCES ${QT_RESOURCES}) endif() @@ -129,14 +124,14 @@ if(Boost_FILESYSTEM_FOUND) endif() if(CONTOUR_FRONTEND_GUI) - if(CONTOUR_BUILD_WITH_QT6) + if(CONTOUR_QT_VERSION EQUAL "6") target_link_libraries(contour ContourTerminalDisplay vtrasterizer Qt6::Core Qt6::Network Qt6::OpenGL Qt6::OpenGLWidgets Qt6::Widgets Qt6::Multimedia) if(NOT(WIN32) AND NOT(APPLE)) target_link_libraries(contour xcb) endif() else() target_link_libraries(contour crispy::core ContourTerminalDisplay vtrasterizer Qt5::Gui Qt5::Network Qt5::Widgets Qt5::Multimedia) - if(NOT(WIN32) AND NOT(APPLE) AND NOT(CONTOUR_BUILD_WITH_QT6)) + if(NOT(WIN32) AND NOT(APPLE) AND NOT(CONTOUR_QT_VERSION EQUAL "6")) target_link_libraries(contour Qt5::X11Extras xcb) endif() endif() @@ -227,7 +222,7 @@ elseif(APPLE) set(INSTALL_RUNTIME_DIR "${App_Contents}/MacOS") set(INSTALL_CMAKE_DIR "${App_Contents}/Resources") - if(NOT CONTOUR_BUILD_WITH_QT6) + if(CONTOUR_QT_VERSION EQUAL "5") # based on code from CMake's QtDialog/CMakeLists.txt macro(install_qt5_plugin _qt_plugin_name _qt_plugins_var _prefix) get_target_property(_qt_plugin_path "${_qt_plugin_name}" LOCATION) @@ -301,7 +296,8 @@ else() set(DEPENDS_EXTRA ", libyaml-cpp0.6") endif() - if(CONTOUR_BUILD_WITH_QT6) + + if(CONTOUR_QT_VERSION EQUAL "6") set(DEPENDS_EXTRA "${DEPENDS_EXTRA}, libqt6core6, libqt6opengl6, libqt6widgets6, libqt6openglwidgets6, qt6-qpa-plugins, libqt6multimedia6") else() set(DEPENDS_EXTRA "${DEPENDS_EXTRA}, libqt5core5a, libqt5gui5, libqt5network5, libqt5multimedia5, libqt5x11extras5") # Qt 5 diff --git a/src/contour/display/CMakeLists.txt b/src/contour/display/CMakeLists.txt index 95e9da3078..e2e9768cdd 100644 --- a/src/contour/display/CMakeLists.txt +++ b/src/contour/display/CMakeLists.txt @@ -1,11 +1,11 @@ -if(CONTOUR_BUILD_WITH_QT6) +if(CONTOUR_QT_VERSION EQUAL "6") find_package(Qt6 COMPONENTS Core Gui OpenGLWidgets Widgets REQUIRED) else() find_package(Qt5 COMPONENTS Gui Widgets REQUIRED) # apt install qtbase5-dev libqt5gui5 endif() set(QT_RESOURCES DisplayResources.qrc) -if(NOT(CONTOUR_BUILD_WITH_QT6)) +if(CONTOUR_QT_VERSION EQUAL "5") qt5_add_resources(QT_RESOURCES ${QT_RESOURCES}) endif() @@ -30,7 +30,7 @@ endif() target_include_directories(ContourTerminalDisplay PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/../..") target_link_libraries(ContourTerminalDisplay vtrasterizer) -if(CONTOUR_BUILD_WITH_QT6) +if(CONTOUR_QT_VERSION EQUAL "6") target_link_libraries(ContourTerminalDisplay Qt6::Core Qt6::Gui Qt6::OpenGL Qt6::OpenGLWidgets Qt6::Widgets) else() target_link_libraries(ContourTerminalDisplay Qt5::Gui Qt5::Widgets) From d669d48a11311ffaf438d70b2554d7e6ed0d95cc Mon Sep 17 00:00:00 2001 From: Yaraslau Tamashevich Date: Mon, 1 May 2023 15:40:50 +0300 Subject: [PATCH 033/112] better formating for the output message --- src/vtpty/Process_unix.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/vtpty/Process_unix.cpp b/src/vtpty/Process_unix.cpp index 03795ddc79..87ec9380f0 100644 --- a/src/vtpty/Process_unix.cpp +++ b/src/vtpty/Process_unix.cpp @@ -239,9 +239,8 @@ void Process::start() // Fallback: Try login shell. auto theLoginShell = loginShell(_d->escapeSandbox); fprintf(stdout, - "\r\n\033[31;1mFailed to spawn \"%s\". %s\033[m\r\nTrying login shell: %s\n", + "\r\n\033[31;1mFailed to spawn \%s\033[m\r\nTrying login shell: %s\n", argv[0], - strerror(errno), crispy::joinHumanReadableQuoted(theLoginShell, ' ').c_str()); fflush(stdout); if (!theLoginShell.empty()) From 18072d45eca7bbfd929a6cba60f40c2a68d829d7 Mon Sep 17 00:00:00 2001 From: Yaraslau Tamashevich Date: Mon, 1 May 2023 19:34:13 +0200 Subject: [PATCH 034/112] fall back to standart shell if can not spawn process --- src/vtpty/Process_win32.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/vtpty/Process_win32.cpp b/src/vtpty/Process_win32.cpp index 51c31608a7..43b9c09bbd 100644 --- a/src/vtpty/Process_win32.cpp +++ b/src/vtpty/Process_win32.cpp @@ -233,8 +233,25 @@ void Process::start() const_cast(cwdPtr), // Use parent's starting directory &_d->startupInfo.StartupInfo, // Pointer to STARTUPINFO &_d->processInfo); // Pointer to PROCESS_INFORMATION + if (!success) + { + success = CreateProcess(nullptr, // No module name - use Command Line + const_cast((this->loginShell(false)[0]).c_str()), // Command Line + nullptr, // Process handle not inheritable + nullptr, // Thread handle not inheritable + FALSE, // Inherit handles + EXTENDED_STARTUPINFO_PRESENT, // Creation flags + nullptr, // Use parent's environment block + const_cast(cwdPtr), // Use parent's starting directory + &_d->startupInfo.StartupInfo, // Pointer to STARTUPINFO + &_d->processInfo); // Pointer to PROCESS_INFORMATION + } + + if (!success) + { throw runtime_error { "Could not create process. "s + getLastErrorAsString() }; + } _d->exitWatcher = std::thread([this]() { (void) wait(); From 3f05f913412d831d2b9588ed7202618999d74a8c Mon Sep 17 00:00:00 2001 From: Utkarsh khambra Date: Sat, 22 Apr 2023 10:24:36 +0530 Subject: [PATCH 035/112] If there is no URI with the given ID in cache then add one with the given ID. --- metainfo.xml | 1 + src/vtbackend/Screen.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/metainfo.xml b/metainfo.xml index 25c123fdec..50985e5434 100644 --- a/metainfo.xml +++ b/metainfo.xml @@ -119,6 +119,7 @@
  • Adds config entry `profiles.*.status_line.sync_to_window_title` to synchronize the window title with the host writable statusline (if it was denied to be shown).
  • Extends `ViNormalMode` to toggle between insert and normal mode rather than just entering normal mode.
  • Modal mode: Adds Return key to also move the cursor down (like vim).
  • +
  • Fixes hyperlinks with IDs (#1088)
  • diff --git a/src/vtbackend/Screen.cpp b/src/vtbackend/Screen.cpp index b42ece5006..176d451064 100644 --- a/src/vtbackend/Screen.cpp +++ b/src/vtbackend/Screen.cpp @@ -1367,10 +1367,14 @@ void Screen::hyperlink(string id, string uri) { if (uri.empty()) _cursor.hyperlink = {}; - else if (!id.empty()) - _cursor.hyperlink = _state.hyperlinks.hyperlinkIdByUserId(id); else { + if (!id.empty()) + { + _cursor.hyperlink = _state.hyperlinks.hyperlinkIdByUserId(id); + if (_cursor.hyperlink != HyperlinkId {}) + return; + } _cursor.hyperlink = _state.hyperlinks.nextHyperlinkId++; _state.hyperlinks.cache.emplace( _cursor.hyperlink, make_shared(HyperlinkInfo { std::move(id), std::move(uri) })); From fd70506d9f691a89219c176d4c60f85df3e00ae1 Mon Sep 17 00:00:00 2001 From: Yaraslau Date: Fri, 12 May 2023 14:05:47 +0300 Subject: [PATCH 036/112] Update src/vtpty/Process_unix.cpp Co-authored-by: Christian Parpart --- src/vtpty/Process_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vtpty/Process_unix.cpp b/src/vtpty/Process_unix.cpp index 87ec9380f0..8f6f81b85d 100644 --- a/src/vtpty/Process_unix.cpp +++ b/src/vtpty/Process_unix.cpp @@ -239,7 +239,7 @@ void Process::start() // Fallback: Try login shell. auto theLoginShell = loginShell(_d->escapeSandbox); fprintf(stdout, - "\r\n\033[31;1mFailed to spawn \%s\033[m\r\nTrying login shell: %s\n", + "\r\n\033[31;1mFailed to spawn %s\033[m\r\nTrying login shell: %s\n", argv[0], crispy::joinHumanReadableQuoted(theLoginShell, ' ').c_str()); fflush(stdout); From 433918c3dd2f05efe6c8f3e0e6e91bf5641e7bf5 Mon Sep 17 00:00:00 2001 From: Yaraslau Tamashevich Date: Fri, 12 May 2023 15:36:29 +0300 Subject: [PATCH 037/112] FreeBSD qt6 in github actions --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eec9fec72a..76d6608f7a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -258,7 +258,7 @@ jobs: freebsd-version QTVER=6 SYSDEP_ASSUME_YES=ON ./scripts/install-deps.sh mkdir build - cmake -DCMAKE_BUILD_TYPE=Debug -DLIBTERMINAL_BUILD_BENCH_HEADLESS=ON -S . -B build + cmake -DCMAKE_BUILD_TYPE=Debug -DLIBTERMINAL_BUILD_BENCH_HEADLESS=ON DCONTOUR_QT_VERSION=6 -S . -B build cmake --build build/ -j2 ./build/src/crispy/crispy_test ./build/src/vtparser/vtparser_test From a9d2f0be73147802b8611f3a2901476b59aad7e2 Mon Sep 17 00:00:00 2001 From: Yaraslau Tamashevich Date: Fri, 12 May 2023 15:37:34 +0300 Subject: [PATCH 038/112] Typo fix --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 76d6608f7a..e95541267f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -258,7 +258,7 @@ jobs: freebsd-version QTVER=6 SYSDEP_ASSUME_YES=ON ./scripts/install-deps.sh mkdir build - cmake -DCMAKE_BUILD_TYPE=Debug -DLIBTERMINAL_BUILD_BENCH_HEADLESS=ON DCONTOUR_QT_VERSION=6 -S . -B build + cmake -DCMAKE_BUILD_TYPE=Debug -DLIBTERMINAL_BUILD_BENCH_HEADLESS=ON -DCONTOUR_QT_VERSION=6 -S . -B build cmake --build build/ -j2 ./build/src/crispy/crispy_test ./build/src/vtparser/vtparser_test From 6aad52c30f9463db26881709b9ec93d7f42cf70f Mon Sep 17 00:00:00 2001 From: Utkarsh khambra Date: Sat, 22 Apr 2023 15:14:10 +0530 Subject: [PATCH 039/112] When updating hovering state, only renderBuffer should be redrawn. --- metainfo.xml | 1 + src/vtbackend/Terminal.cpp | 17 ++++++++++++++++- src/vtbackend/Terminal.h | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/metainfo.xml b/metainfo.xml index 50985e5434..a9da9917eb 100644 --- a/metainfo.xml +++ b/metainfo.xml @@ -120,6 +120,7 @@
  • Extends `ViNormalMode` to toggle between insert and normal mode rather than just entering normal mode.
  • Modal mode: Adds Return key to also move the cursor down (like vim).
  • Fixes hyperlinks with IDs (#1088)
  • +
  • Fixes hyperlink highlight when screen has been scrolled (#1084)
  • diff --git a/src/vtbackend/Terminal.cpp b/src/vtbackend/Terminal.cpp index 74459ba2f2..f641067954 100644 --- a/src/vtbackend/Terminal.cpp +++ b/src/vtbackend/Terminal.cpp @@ -1040,7 +1040,7 @@ void Terminal::updateHoveringHyperlinkState() auto const oldState = _hoveringHyperlinkId.exchange(newState); if (newState != oldState) - screenUpdated(); + renderBufferUpdated(); } optional Terminal::nextRender() const @@ -1333,6 +1333,21 @@ void Terminal::screenUpdated() _eventListener.screenUpdated(); } +void Terminal::renderBufferUpdated() +{ + if (!_renderBufferUpdateEnabled) + return; + + if (_renderBuffer.state == RenderBufferState::TrySwapBuffers) + { + _renderBuffer.swapBuffers(_renderBuffer.lastUpdate); + return; + } + + _screenDirty = true; + _eventListener.renderBufferUpdated(); +} + FontDef Terminal::getFontDef() { return _eventListener.getFontDef(); diff --git a/src/vtbackend/Terminal.h b/src/vtbackend/Terminal.h index b003a6302f..f9d4138de7 100644 --- a/src/vtbackend/Terminal.h +++ b/src/vtbackend/Terminal.h @@ -588,6 +588,7 @@ class Terminal void bufferChanged(ScreenType); void scrollbackBufferCleared(); void screenUpdated(); + void renderBufferUpdated(); [[nodiscard]] FontDef getFontDef(); void setFontDef(FontDef const& fontDef); void copyToClipboard(std::string_view data); From af151a984823bee878be91917300b18fd35f4715 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Fri, 12 May 2023 15:53:18 +0200 Subject: [PATCH 040/112] Update VCPKG to latest release (currently used one yields 404 on some packages) Signed-off-by: Christian Parpart --- .github/workflows/build.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e95541267f..c699de0f5e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -348,7 +348,7 @@ jobs: with: vcpkgArguments: catch2 fmt freetype fontconfig harfbuzz yaml-cpp range-v3 vcpkgDirectory: ${{ runner.workspace }}/vcpkg/ - vcpkgGitCommitId: e69dd972ba64840955f46704ecce6241bf607c0f + vcpkgGitCommitId: 2023.04.15 vcpkgTriplet: x64-windows - name: "create build directory" shell: powershell diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 16d1a1fa87..6deb6e2390 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -61,7 +61,7 @@ jobs: with: vcpkgArguments: catch2 fmt freetype fontconfig harfbuzz yaml-cpp range-v3 vcpkgDirectory: ${{ runner.workspace }}/vcpkg/ - vcpkgGitCommitId: e69dd972ba64840955f46704ecce6241bf607c0f + vcpkgGitCommitId: 2023.04.15 vcpkgTriplet: x64-windows - name: Cache Qt id: cache-qt From c8c16d37bbb2a01e4b63befbca91c40d260580cb Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Fri, 12 May 2023 17:17:29 +0200 Subject: [PATCH 041/112] whitespace-fix Signed-off-by: Christian Parpart --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a1e4c8db65..c961aa319c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -129,7 +129,7 @@ macro(ContourConfigurationSummary) message(STATUS "Build unit tests: ${CONTOUR_TESTING}") message(STATUS "Enable with code coverage: ${CONTOUR_CODE_COVERAGE_ENABLED}") message(STATUS "Build contour frontend GUI: ${CONTOUR_FRONTEND_GUI}") - message(STATUS "Build contour using Qt : ${CONTOUR_QT_VERSION}") + message(STATUS "Build contour using Qt: ${CONTOUR_QT_VERSION}") message(STATUS "Build contour using mimalloc: ${CONTOUR_BUILD_WITH_MIMALLOC}") message(STATUS "Clang Tidy: ${USING_TIDY_STRING}") message(STATUS "|> Enable performance metrics: ${CONTOUR_PERF_STATS}") From 56db0cbf2c5be2cb4ee76b76845b4e550ee8b6cf Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Fri, 12 May 2023 22:22:49 +0200 Subject: [PATCH 042/112] [vtbackend] Fixes statusline being misplaced after resize when being in alt screen (#1091) Signed-off-by: Christian Parpart --- metainfo.xml | 1 + src/vtbackend/Terminal.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/metainfo.xml b/metainfo.xml index a9da9917eb..fe1693116a 100644 --- a/metainfo.xml +++ b/metainfo.xml @@ -111,6 +111,7 @@
  • Fixes cycling between different selection modes (by speed-clicking) not properly working.
  • Fixes tcsh shell integration not working (#1074).
  • Fixes `[count]w` ignoring the `[count]` parameter in modal mode.
  • +
  • Fixes statusline being misplaced after resize when being in alt screen (#1091).
  • Improves mouse selection to be more natural extending into new grid cells.
  • Adds `profiles.*.permissions.display_host_writable_statusline` to allow the user to intervene in `DECSSDT 2` VT sequence to show the host writable statusline.
  • Adds config entry `input_method_editor` colorscheme key to allow customization of the IME (input method editor) region (#1058).
  • diff --git a/src/vtbackend/Terminal.cpp b/src/vtbackend/Terminal.cpp index f641067954..6e361223c3 100644 --- a/src/vtbackend/Terminal.cpp +++ b/src/vtbackend/Terminal.cpp @@ -478,7 +478,7 @@ void Terminal::fillRenderBufferInternal(RenderBuffer& output, bool includeSelect if (_settings.statusDisplayPosition == StatusDisplayPosition::Bottom) { - baseLine += _primaryScreen.pageSize().lines.as(); + baseLine += pageSize().lines.as(); fillRenderBufferStatusLine(output, includeSelection, baseLine); } } From 200197a0369580b7598b081527677caf489c47bc Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Fri, 12 May 2023 22:38:32 +0200 Subject: [PATCH 043/112] metainfo.xml: Move fixes lines in changelog together Signed-off-by: Christian Parpart --- metainfo.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/metainfo.xml b/metainfo.xml index fe1693116a..a1072a661e 100644 --- a/metainfo.xml +++ b/metainfo.xml @@ -112,6 +112,8 @@
  • Fixes tcsh shell integration not working (#1074).
  • Fixes `[count]w` ignoring the `[count]` parameter in modal mode.
  • Fixes statusline being misplaced after resize when being in alt screen (#1091).
  • +
  • Fixes hyperlinks with IDs (#1088)
  • +
  • Fixes hyperlink highlight when screen has been scrolled (#1084)
  • Improves mouse selection to be more natural extending into new grid cells.
  • Adds `profiles.*.permissions.display_host_writable_statusline` to allow the user to intervene in `DECSSDT 2` VT sequence to show the host writable statusline.
  • Adds config entry `input_method_editor` colorscheme key to allow customization of the IME (input method editor) region (#1058).
  • @@ -120,8 +122,6 @@
  • Adds config entry `profiles.*.status_line.sync_to_window_title` to synchronize the window title with the host writable statusline (if it was denied to be shown).
  • Extends `ViNormalMode` to toggle between insert and normal mode rather than just entering normal mode.
  • Modal mode: Adds Return key to also move the cursor down (like vim).
  • -
  • Fixes hyperlinks with IDs (#1088)
  • -
  • Fixes hyperlink highlight when screen has been scrolled (#1084)
  • From 9bda14f7e33739b4624703eed35e294786e72d87 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Fri, 12 May 2023 23:11:55 +0200 Subject: [PATCH 044/112] [vtbackend] Model mode: Adds text object `im` and `am` to select the range between two line marks Signed-off-by: Christian Parpart --- metainfo.xml | 1 + src/vtbackend/ViCommands.cpp | 19 +++++++++++++++++++ src/vtbackend/ViInputHandler.cpp | 3 ++- src/vtbackend/ViInputHandler.h | 2 ++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/metainfo.xml b/metainfo.xml index a1072a661e..1e69b13a5f 100644 --- a/metainfo.xml +++ b/metainfo.xml @@ -122,6 +122,7 @@
  • Adds config entry `profiles.*.status_line.sync_to_window_title` to synchronize the window title with the host writable statusline (if it was denied to be shown).
  • Extends `ViNormalMode` to toggle between insert and normal mode rather than just entering normal mode.
  • Modal mode: Adds Return key to also move the cursor down (like vim).
  • +
  • Model mode: Adds text object `im` and `am` to select the range between two line marks.
  • diff --git a/src/vtbackend/ViCommands.cpp b/src/vtbackend/ViCommands.cpp index 9fc1c13285..af478086d1 100644 --- a/src/vtbackend/ViCommands.cpp +++ b/src/vtbackend/ViCommands.cpp @@ -597,6 +597,25 @@ CellLocationRange ViCommands::translateToCellRange(TextObjectScope scope, case TextObject::BackQuotes: return expandMatchingPair(scope, '`', '`'); case TextObject::CurlyBrackets: return expandMatchingPair(scope, '{', '}'); case TextObject::DoubleQuotes: return expandMatchingPair(scope, '"', '"'); + case TextObject::LineMark: + // Walk the line upwards until we find a marked line. + while ( + a.line > gridTop + && !(unsigned(_terminal.currentScreen().lineFlagsAt(a.line)) & unsigned(LineFlags::Marked))) + --a.line; + if (scope == TextObjectScope::Inner && a != cursorPosition) + ++a.line; + // Walk the line downwards until we find a marked line. + while ( + b.line < gridBottom + && !(unsigned(_terminal.currentScreen().lineFlagsAt(b.line)) & unsigned(LineFlags::Marked))) + ++b.line; + if (scope == TextObjectScope::Inner && b != cursorPosition) + --b.line; + // Span the range from left most column to right most column. + a.column = ColumnOffset(0); + b.column = rightMargin; + break; case TextObject::Paragraph: while (a.line > gridTop && !_terminal.currentScreen().isLineEmpty(a.line - 1)) --a.line; diff --git a/src/vtbackend/ViInputHandler.cpp b/src/vtbackend/ViInputHandler.cpp index 8782f65172..57d9363e10 100644 --- a/src/vtbackend/ViInputHandler.cpp +++ b/src/vtbackend/ViInputHandler.cpp @@ -128,8 +128,9 @@ void ViInputHandler::registerAllCommands() // clang-format on } }; - auto constexpr textObjectMappings = std::array, 14> { { + auto constexpr textObjectMappings = std::array, 15> { { { '"', TextObject::DoubleQuotes }, + { 'm', TextObject::LineMark }, { '(', TextObject::RoundBrackets }, { ')', TextObject::RoundBrackets }, { '<', TextObject::AngleBrackets }, diff --git a/src/vtbackend/ViInputHandler.h b/src/vtbackend/ViInputHandler.h index b144d14bbc..ff812fe458 100644 --- a/src/vtbackend/ViInputHandler.h +++ b/src/vtbackend/ViInputHandler.h @@ -125,6 +125,7 @@ enum class TextObject AngleBrackets = '<', // i< a< CurlyBrackets = '{', // i{ a{ DoubleQuotes = '"', // i" a" + LineMark = 'm', // im am Paragraph = 'p', // ip ap RoundBrackets = '(', // i( a( SingleQuotes = '\'', // i' a' @@ -308,6 +309,7 @@ struct formatter case TextObject::BackQuotes: return fmt::format_to(ctx.out(), "BackQuotes"); case TextObject::CurlyBrackets: return fmt::format_to(ctx.out(), "CurlyBrackets"); case TextObject::DoubleQuotes: return fmt::format_to(ctx.out(), "DoubleQuotes"); + case TextObject::LineMark: return fmt::format_to(ctx.out(), "LineMark"); case TextObject::Paragraph: return fmt::format_to(ctx.out(), "Paragraph"); case TextObject::RoundBrackets: return fmt::format_to(ctx.out(), "RoundBrackets"); case TextObject::SingleQuotes: return fmt::format_to(ctx.out(), "SingleQuotes"); From 600b40f55a950a3875b4f814be0e818f4f2cf786 Mon Sep 17 00:00:00 2001 From: Yaraslau Tamashevich Date: Mon, 15 May 2023 13:42:56 +0300 Subject: [PATCH 045/112] Get rid of HB_FEATURE_GLOBAL_END --- src/text_shaper/open_shaper.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/text_shaper/open_shaper.cpp b/src/text_shaper/open_shaper.cpp index 713f8277cc..2870910c9e 100644 --- a/src/text_shaper/open_shaper.cpp +++ b/src/text_shaper/open_shaper.cpp @@ -23,6 +23,8 @@ #include #include +#include + #include #include @@ -72,11 +74,6 @@ using std::vector; using namespace std::string_literals; using namespace std::string_view_literals; -#if !defined(HB_FEATURE_GLOBAL_END) - // Ubuntu 18.04 has a too old harfbuzz that doesn't provide this definition yet. - #define HB_FEATURE_GLOBAL_END ((size_t) -1) -#endif - namespace { @@ -355,7 +352,7 @@ namespace hbFeature.tag = HB_TAG(feature.name[0], feature.name[1], feature.name[2], feature.name[3]); hbFeature.value = feature.enabled ? 1 : 0; hbFeature.start = 0; - hbFeature.end = HB_FEATURE_GLOBAL_END; + hbFeature.end = std::numeric_limits::max(); hbFeatures.emplace_back(hbFeature); } From 2413e6aea8694eaa1cb5e73a68c0009b02c65781 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Thu, 18 May 2023 20:35:25 +0200 Subject: [PATCH 046/112] Model mode: Adds handling of `Home` and `End` keys (#1098) Signed-off-by: Christian Parpart --- metainfo.xml | 1 + src/vtbackend/ViInputHandler.cpp | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/metainfo.xml b/metainfo.xml index 1e69b13a5f..5bf16c7d2a 100644 --- a/metainfo.xml +++ b/metainfo.xml @@ -123,6 +123,7 @@
  • Extends `ViNormalMode` to toggle between insert and normal mode rather than just entering normal mode.
  • Modal mode: Adds Return key to also move the cursor down (like vim).
  • Model mode: Adds text object `im` and `am` to select the range between two line marks.
  • +
  • Model mode: Adds handling of `Home` and `End` keys (#1098).
  • diff --git a/src/vtbackend/ViInputHandler.cpp b/src/vtbackend/ViInputHandler.cpp index 57d9363e10..a505852f19 100644 --- a/src/vtbackend/ViInputHandler.cpp +++ b/src/vtbackend/ViInputHandler.cpp @@ -82,7 +82,7 @@ void ViInputHandler::registerAllCommands() std::array, 2> { { std::pair { 'i', TextObjectScope::Inner }, std::pair { 'a', TextObjectScope::A } } }; - auto constexpr motionMappings = std::array, 41> { { + auto constexpr motionMappings = std::array, 43> { { // clang-format off { "$", ViMotion::LineEnd }, { "%", ViMotion::ParenthesisMatching }, @@ -90,6 +90,8 @@ void ViInputHandler::registerAllCommands() { "", ViMotion::CharLeft }, { "", ViMotion::LineDown }, { "", ViMotion::LineDown }, + { "", ViMotion::LineEnd }, + { "", ViMotion::LineBegin }, { "", ViMotion::CharLeft }, { "", ViMotion::PageDown }, { "", ViMotion::PageUp }, From 0942e8bc309c585861da2a373002918dc90b9921 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Mon, 22 May 2023 15:02:04 +0200 Subject: [PATCH 047/112] [vtbackend] Screen: Add convenience method isLineFlagEnabledAt(line, flag) to make calling code more readable Signed-off-by: Christian Parpart --- src/vtbackend/Screen.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/vtbackend/Screen.h b/src/vtbackend/Screen.h index fc04039030..384f2bc43a 100644 --- a/src/vtbackend/Screen.h +++ b/src/vtbackend/Screen.h @@ -76,6 +76,7 @@ class ScreenBase: public SequenceHandler [[nodiscard]] virtual std::string cellTextAt(CellLocation position) const noexcept = 0; [[nodiscard]] virtual LineFlags lineFlagsAt(LineOffset line) const noexcept = 0; virtual void enableLineFlags(LineOffset lineOffset, LineFlags flags, bool enable) noexcept = 0; + [[nodiscard]] virtual bool isLineFlagEnabledAt(LineOffset line, LineFlags flags) const noexcept = 0; [[nodiscard]] virtual std::string lineTextAt(LineOffset line, bool stripLeadingSpaces = true, bool stripTrailingSpaces = true) const noexcept = 0; @@ -540,6 +541,11 @@ class Screen final: public ScreenBase, public capabilities::StaticDatabase _grid.lineAt(lineOffset).setFlag(flags, enable); } + [[nodiscard]] bool isLineFlagEnabledAt(LineOffset line, LineFlags flags) const noexcept override + { + return _grid.lineAt(line).isFlagEnabled(flags); + } + [[nodiscard]] std::string lineTextAt(LineOffset line, bool stripLeadingSpaces, bool stripTrailingSpaces) const noexcept override From 09a7fb67938b747f3689fc9962dbb969faf3839a Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Mon, 22 May 2023 15:02:12 +0200 Subject: [PATCH 048/112] Modal mode: Improves how `[m` jumps from the current prompt to the next prompt above it. Signed-off-by: Christian Parpart --- metainfo.xml | 1 + src/vtbackend/ViCommands.cpp | 13 +++++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/metainfo.xml b/metainfo.xml index 5bf16c7d2a..e6946a0fe6 100644 --- a/metainfo.xml +++ b/metainfo.xml @@ -115,6 +115,7 @@
  • Fixes hyperlinks with IDs (#1088)
  • Fixes hyperlink highlight when screen has been scrolled (#1084)
  • Improves mouse selection to be more natural extending into new grid cells.
  • +
  • Modal mode: Improves how `[m` jumps from the current prompt to the next prompt above it.
  • Adds `profiles.*.permissions.display_host_writable_statusline` to allow the user to intervene in `DECSSDT 2` VT sequence to show the host writable statusline.
  • Adds config entry `input_method_editor` colorscheme key to allow customization of the IME (input method editor) region (#1058).
  • Adds `gui.shader` log option for the output of shader configuration procedure (#715).
  • diff --git a/src/vtbackend/ViCommands.cpp b/src/vtbackend/ViCommands.cpp index af478086d1..0c6f149863 100644 --- a/src/vtbackend/ViCommands.cpp +++ b/src/vtbackend/ViCommands.cpp @@ -858,19 +858,16 @@ CellLocation ViCommands::translateToCellLocation(ViMotion motion, unsigned count return globalCharDown(cursorPosition, '}', count); case ViMotion::LineMarkUp: // [m { - auto const pageTop = -_terminal.currentScreen().historyLineCount().as(); + auto const gridTop = -_terminal.currentScreen().historyLineCount().as(); auto result = CellLocation { cursorPosition.line, ColumnOffset(0) }; while (count > 0) { - if (cursorPosition.column == ColumnOffset(0) && result.line > pageTop) + if (result.line > gridTop + && _terminal.currentScreen().isLineFlagEnabledAt(result.line, LineFlags::Marked)) --result.line; - while (result.line > pageTop) - { - if (unsigned(_terminal.currentScreen().lineFlagsAt(result.line)) - & unsigned(LineFlags::Marked)) - break; + while (result.line > gridTop + && !_terminal.currentScreen().isLineFlagEnabledAt(result.line, LineFlags::Marked)) --result.line; - } --count; } return result; From 311c59c9d6fcc96b97c0bb6aecd522b02104e55f Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Mon, 22 May 2023 21:43:49 +0200 Subject: [PATCH 049/112] Rework pre-commit hook wrt. clang-format-diff Signed-off-by: Christian Parpart --- .../git-hooks/pre-commit.git-clang-format.sh | 59 +++++-------------- 1 file changed, 15 insertions(+), 44 deletions(-) diff --git a/scripts/git-hooks/pre-commit.git-clang-format.sh b/scripts/git-hooks/pre-commit.git-clang-format.sh index df62a7c10c..aa1c1d0e06 100755 --- a/scripts/git-hooks/pre-commit.git-clang-format.sh +++ b/scripts/git-hooks/pre-commit.git-clang-format.sh @@ -3,56 +3,27 @@ # Runs "clang-format" on the commit before committing and prohibits commit if # changes happened. -command -v clang-format &>/dev/null -if [[ $? -ne 0 ]] -then - echo "'clang-format' binary not found in PATH..." >&2 - exit 2 -fi - -command -v git-clang-format &>/dev/null -if [[ $? -ne 0 ]] -then - echo "'git-clang-format' script not found in PATH..." >&2 - exit 2 -fi +dir_list="$PWD" # Add the directories you want here +cmd="git diff -U0 --no-color --staged HEAD -- $dir_list | clang-format-diff -p1" -STATUS_CMD="git status --porcelain=1 --untracked-files=no --ignored=no" +echo "" +echo "Running clang-format on this commit" +echo "" -FILES_ADDED_IN_INDEX=$(${STATUS_CMD} | grep "^[MARC]" | awk '{ print $2; }') - -STATUS=$(${STATUS_CMD}) - -git-clang-format ${FILES_ADDED_IN_INDEX} +diff=$(eval "$cmd") if [[ $? -ne 0 ]] then - exit 3 + echo "Command failed to execute." + exit 1 fi -STATUS_AFTER=$(${STATUS_CMD}) - -# Calculate the difference git-clang-format's call made, and then cut to the -# the new (inserted) lines only. Also remove the insertion marker "+". -DIFF=$(diff -U 0 <(echo "${STATUS}") <(echo "${STATUS_AFTER}") | - grep -v "^+++ \|^--- \|^@@" | - grep "^\+" | - cut -c2-) - -# Get the second status character from the changes. -# First letter would be the index status, second letter is the workdir->index -# diff. The latter one interests us. -LETTERS=$(echo "${DIFF}" | - awk -F='\n' '{ print substr($0,0,2); }' | - cut -c2) - -echo "${LETTERS}" | grep "M" >/dev/null -if [[ $? -ne 0 ]] +if [[ -z "$diff" ]] then - # grep did not match any locally modified files in the diff, this means - # clang-format did not modify anything. - exit 0 + echo "Everything is clean" + exit 0 else - echo "Modified files were detected after clang-format." - echo "Please either add the changes, or unstage them." - exit 1 + echo 1>&2 "$diff" + echo 1>&2 "" + echo 1>&2 "Commit aborted due to code format inconsistencies." + exit 1 fi From 26ce1eabb66bf394db09bc139d6847489086dfb8 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Thu, 25 May 2023 23:02:36 +0200 Subject: [PATCH 050/112] [Github CI] Add updatin APT database to some more CI jobs Signed-off-by: Christian Parpart --- .github/workflows/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c699de0f5e..4b91a7e68d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -663,6 +663,8 @@ jobs: uses: actions/download-artifact@v3 with: name: contour-ubuntu2204-tests + - name: "update APT database" + run: sudo apt -q update - name: "fix unit test permissions" run: | find . -name '*_test' -exec chmod 0755 {} \; @@ -707,6 +709,8 @@ jobs: uses: actions/download-artifact@v3 with: name: contour-ubuntu2204-tests + - name: "update APT database" + run: sudo apt -q update - name: "fix unit test permissions" run: | find . -name '*_test' -exec chmod 0755 {} \; From ef07f1989e1677492e318182fc42b17bfc5cfc2c Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Thu, 25 May 2023 08:37:23 +0200 Subject: [PATCH 051/112] Properly handle dependency installation on Fedora 38+ Signed-off-by: Christian Parpart --- .github/workflows/build.yml | 9 ++++++++- .github/workflows/release.yml | 2 +- scripts/install-deps.sh | 19 ++++++++++++++----- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4b91a7e68d..78d26c89a4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -143,8 +143,9 @@ jobs: fedora: strategy: + fail-fast: false matrix: - os_version: [37, 36] + os_version: [38, 37, 36] arch: [ "linux/amd64 x86_64" @@ -188,6 +189,12 @@ jobs: mkdir -p ${DISTDIR} cp -rvp . ${DISTDIR} tar czpf ${PKGNAME}.tar.gz -C "/tmp/dist" . + - name: disable pedantic compiler if broken GCC + if: ${{ matrix.os_version == 38 }} + run: | + set -ex + sed -i -e "s/PEDANTIC_COMPILER=ON/PEDANTIC_COMPILER=OFF/" .github/fedora/contour.spec + sed -i -e "s/PEDANTIC_COMPILER_WERROR=ON/PEDANTIC_COMPILER_WERROR=OFF/" .github/fedora/contour.spec - name: Build ${{ matrix.arch }} release shell: bash run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6deb6e2390..3a4e3ea99f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -289,7 +289,7 @@ jobs: build_fedora: strategy: matrix: - os_version: [36, 37] + os_version: [36, 37, 38] arch: [ "linux/amd64 x86_64" diff --git a/scripts/install-deps.sh b/scripts/install-deps.sh index 61cc713166..f485fd25b1 100755 --- a/scripts/install-deps.sh +++ b/scripts/install-deps.sh @@ -374,13 +374,9 @@ install_deps_suse() install_deps_fedora() { - fetch_and_unpack_libunicode - fetch_and_unpack_gsl - fetch_and_unpack_fmtlib - [ x$PREPARE_ONLY_EMBEDS = xON ] && return + local os_version=`grep VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '"'` local packages=" - catch-devel cmake extra-cmake-modules fontconfig-devel @@ -394,6 +390,19 @@ install_deps_fedora() yaml-cpp-devel " + fetch_and_unpack_libunicode + fetch_and_unpack_gsl + fetch_and_unpack_fmtlib + + # catch-devel on Fedora 38 is too new, so we need to use the one we downloaded. + if test "$os_version" -lt 38; then + packages="$packages catch-devel" + else + fetch_and_unpack_Catch2 + fi + + [ x$PREPARE_ONLY_EMBEDS = xON ] && return + if test x$QTVER = x6; then packages="$packages qt6-qtbase-devel From eb86bda300c093a3798c025e31507cada2a0e47c Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Thu, 25 May 2023 11:43:56 +0200 Subject: [PATCH 052/112] Linux: Adds support for writing to utmp/wtmp Signed-off-by: Christian Parpart --- .github/workflows/build.yml | 1 - metainfo.xml | 1 + scripts/ci/notcurses-install-deps.sh | 3 ++- scripts/install-deps.sh | 5 +++++ src/contour/CMakeLists.txt | 8 ++++++++ src/vtpty/CMakeLists.txt | 1 + src/vtpty/LinuxPty.cpp | 5 ++++- 7 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 78d26c89a4..91fc6f5eec 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -610,7 +610,6 @@ jobs: CMAKE_CXX_STANDARD=20 if [[ "${{ matrix.os_version }}" = "22.04" ]]; then EXTRA_CMAKE_FLAGS="$EXTRA_CMAKE_FLAGS -DCONTOUR_QT_VERSION=5" - fi BUILD_DIR="build" \ CMAKE_BUILD_TYPE=RelWithDebInfo \ diff --git a/metainfo.xml b/metainfo.xml index e6946a0fe6..1f20807bb9 100644 --- a/metainfo.xml +++ b/metainfo.xml @@ -121,6 +121,7 @@
  • Adds `gui.shader` log option for the output of shader configuration procedure (#715).
  • Adds config entry `profiles.*.status_line.position` to change statusline position to be either bottom (default) or top.
  • Adds config entry `profiles.*.status_line.sync_to_window_title` to synchronize the window title with the host writable statusline (if it was denied to be shown).
  • +
  • Linux: Adds support for writing to utmp/wtmp.
  • Extends `ViNormalMode` to toggle between insert and normal mode rather than just entering normal mode.
  • Modal mode: Adds Return key to also move the cursor down (like vim).
  • Model mode: Adds text object `im` and `am` to select the range between two line marks.
  • diff --git a/scripts/ci/notcurses-install-deps.sh b/scripts/ci/notcurses-install-deps.sh index fd9fa134d4..dcc908f1bb 100755 --- a/scripts/ci/notcurses-install-deps.sh +++ b/scripts/ci/notcurses-install-deps.sh @@ -24,7 +24,8 @@ sudo apt install -y \ libharfbuzz0b \ libqt5core5a \ libqt5gui5 \ - libqt5network5 \ libqt5multimedia5 \ + libqt5network5 \ libqt5x11extras5 \ + libutempter0 \ libyaml-cpp0.7 diff --git a/scripts/install-deps.sh b/scripts/install-deps.sh index f485fd25b1..eb1fcb0f8d 100755 --- a/scripts/install-deps.sh +++ b/scripts/install-deps.sh @@ -169,6 +169,7 @@ install_deps_popos() libqt5gui5 libqt5opengl5-dev libqt5x11extras5-dev + libutempter-dev libx11-xcb-dev libyaml-cpp-dev make @@ -209,6 +210,7 @@ install_deps_ubuntu() libfontconfig1-dev libfreetype6-dev libharfbuzz-dev + libutempter-dev libx11-xcb-dev libyaml-cpp-dev make @@ -317,6 +319,7 @@ install_deps_arch() ninja \ pkg-config \ range-v3 \ + libutempter \ yaml-cpp \ " @@ -361,6 +364,7 @@ install_deps_suse() libqt5-qtbase-devel libqt5-qtmultimedia-devel libqt5-qtx11extras-devel + libutempter-devel libxcb-devel ncurses-devel ninja @@ -387,6 +391,7 @@ install_deps_fedora() ninja-build pkgconf range-v3-devel + libutempter-devel yaml-cpp-devel " diff --git a/src/contour/CMakeLists.txt b/src/contour/CMakeLists.txt index b310eb6036..0eebd585fd 100644 --- a/src/contour/CMakeLists.txt +++ b/src/contour/CMakeLists.txt @@ -7,6 +7,10 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") set(FREEBSD TRUE) endif() +if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + set(LINUX TRUE) +endif() + option(CONTOUR_PERF_STATS "Enables debug printing some performance stats." OFF) option(CONTOUR_VT_METRICS "Enables collecting and exit-printing some VT usage metrics." OFF) option(CONTOUR_SCROLLBAR "Enables scrollbar in GUI frontend." ON) @@ -296,6 +300,10 @@ else() set(DEPENDS_EXTRA ", libyaml-cpp0.6") endif() + if(LINUX) + set(DEPENDS_EXTRA ", libutempter0") + endif() + if(CONTOUR_QT_VERSION EQUAL "6") set(DEPENDS_EXTRA "${DEPENDS_EXTRA}, libqt6core6, libqt6opengl6, libqt6widgets6, libqt6openglwidgets6, qt6-qpa-plugins, libqt6multimedia6") diff --git a/src/vtpty/CMakeLists.txt b/src/vtpty/CMakeLists.txt index 88b6b40a50..46eccf227c 100644 --- a/src/vtpty/CMakeLists.txt +++ b/src/vtpty/CMakeLists.txt @@ -29,6 +29,7 @@ set(vtpty_HEADERS if(LINUX) set(vtpty_HEADERS ${vtpty_HEADERS} LinuxPty.h) set(vtpty_SOURCES ${vtpty_SOURCES} LinuxPty.cpp) + set(vtpty_LIBRARIES ${vtpty_LIBRARIES} utempter) endif() if(UNIX) diff --git a/src/vtpty/LinuxPty.cpp b/src/vtpty/LinuxPty.cpp index 29ff7ddb0d..cb8b0713bc 100644 --- a/src/vtpty/LinuxPty.cpp +++ b/src/vtpty/LinuxPty.cpp @@ -39,7 +39,7 @@ #include #include #include -#include +#include using std::array; using std::max; @@ -218,11 +218,14 @@ void LinuxPty::start() ev.data.fd = _stdoutFastPipe.reader(); if (epoll_ctl(_epollFd, EPOLL_CTL_ADD, _stdoutFastPipe.reader(), &ev) < 0) throw runtime_error { "epoll setup failed to add stdout-fastpipe. "s + strerror(errno) }; + + utempter_add_record(_masterFd, getenv("DISPLAY")); } LinuxPty::~LinuxPty() { PtyLog()("PTY destroying master (file descriptor {}).", _masterFd); + utempter_remove_record(_masterFd); detail::saveClose(&_eventFd); detail::saveClose(&_epollFd); detail::saveClose(&_masterFd); From 049f21dc6a062ea859f61fbbc8a3c47d117abf45 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Fri, 26 May 2023 19:17:03 +0200 Subject: [PATCH 053/112] LinuxPty: also respect WAYLAND_DISPLAY for utmp as hostname info Signed-off-by: Christian Parpart --- src/vtpty/LinuxPty.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/vtpty/LinuxPty.cpp b/src/vtpty/LinuxPty.cpp index cb8b0713bc..5ad7defd46 100644 --- a/src/vtpty/LinuxPty.cpp +++ b/src/vtpty/LinuxPty.cpp @@ -87,6 +87,15 @@ namespace return { PtyMasterHandle::cast_from(masterFd), PtySlaveHandle::cast_from(slaveFd) }; } + char const* hostnameForUtmp() + { + for (auto const* env: { "DISPLAY", "WAYLAND_DISPLAY" }) + if (auto const* value = std::getenv(env)) + return value; + + return nullptr; + } + } // namespace // {{{ LinuxPty::Slave @@ -219,7 +228,7 @@ void LinuxPty::start() if (epoll_ctl(_epollFd, EPOLL_CTL_ADD, _stdoutFastPipe.reader(), &ev) < 0) throw runtime_error { "epoll setup failed to add stdout-fastpipe. "s + strerror(errno) }; - utempter_add_record(_masterFd, getenv("DISPLAY")); + utempter_add_record(_masterFd, hostnameForUtmp()); } LinuxPty::~LinuxPty() From 9c0cedc940603232dde21469e517f1dada7aa858 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Fri, 26 May 2023 20:48:06 +0200 Subject: [PATCH 054/112] [contour] tiny code quality improvement, avoid passing copies Signed-off-by: Christian Parpart --- src/contour/Config.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/contour/Config.cpp b/src/contour/Config.cpp index a1854765a7..8305aa51fb 100644 --- a/src/contour/Config.cpp +++ b/src/contour/Config.cpp @@ -620,9 +620,9 @@ namespace return nullopt; } - optional parseCursorConfig(YAML::Node rootNode, + optional parseCursorConfig(YAML::Node const& rootNode, UsedKeys& usedKeys, - std::string basePath) + std::string const& basePath) { if (!rootNode) return nullopt; From 8bfdbece4ac095c2de3aee84d1d5a8bf3a32a31f Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Fri, 26 May 2023 20:50:18 +0200 Subject: [PATCH 055/112] [contour] Ensure cursor change is instantly visible when cursor is being reconfigured Signed-off-by: Christian Parpart --- src/contour/TerminalSession.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/contour/TerminalSession.cpp b/src/contour/TerminalSession.cpp index 6e78c9925d..b435f6f089 100644 --- a/src/contour/TerminalSession.cpp +++ b/src/contour/TerminalSession.cpp @@ -1190,6 +1190,10 @@ void TerminalSession::configureCursor(config::CursorConfig const& cursorConfig) terminal_.setCursorBlinkingInterval(cursorConfig.cursorBlinkInterval); terminal_.setCursorDisplay(cursorConfig.cursorDisplay); terminal_.setCursorShape(cursorConfig.cursorShape); + + // Force a redraw of the screen + // to ensure the correct cursor shape is displayed. + scheduleRedraw(); } void TerminalSession::configureDisplay() From ae4bae3c97d2f443899e3c56ddeda300138766b0 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Fri, 26 May 2023 20:52:14 +0200 Subject: [PATCH 056/112] [contour] Fixes cursor shape changes when entering vi-like normal mode or visual mode Signed-off-by: Christian Parpart --- metainfo.xml | 1 + src/contour/Config.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/metainfo.xml b/metainfo.xml index 1f20807bb9..54280be6e5 100644 --- a/metainfo.xml +++ b/metainfo.xml @@ -114,6 +114,7 @@
  • Fixes statusline being misplaced after resize when being in alt screen (#1091).
  • Fixes hyperlinks with IDs (#1088)
  • Fixes hyperlink highlight when screen has been scrolled (#1084)
  • +
  • Fixes cursor shape changes when entering vi-like normal mode or visual mode.
  • Improves mouse selection to be more natural extending into new grid cells.
  • Modal mode: Improves how `[m` jumps from the current prompt to the next prompt above it.
  • Adds `profiles.*.permissions.display_host_writable_statusline` to allow the user to intervene in `DECSSDT 2` VT sequence to show the host writable statusline.
  • diff --git a/src/contour/Config.cpp b/src/contour/Config.cpp index 8305aa51fb..f2dfee9e2d 100644 --- a/src/contour/Config.cpp +++ b/src/contour/Config.cpp @@ -1693,7 +1693,7 @@ namespace parseCursorConfig(visualModeNode["cursor"], _usedKeys, basePath + ".visual_mode.cursor")) { _usedKeys.emplace(basePath + ".visual_mode.cursor"); - profile.inputModes.normal.cursor = cursorOpt.value(); + profile.inputModes.visual.cursor = cursorOpt.value(); } } From fc7fa84f97e4ca70d16b799ff2e1872bca0a4123 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Mon, 29 May 2023 23:05:39 +0200 Subject: [PATCH 057/112] Prepare for release 0.3.12 Signed-off-by: Christian Parpart --- metainfo.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metainfo.xml b/metainfo.xml index 54280be6e5..48ce9b05df 100644 --- a/metainfo.xml +++ b/metainfo.xml @@ -103,7 +103,7 @@ --> - +