From 38349805d3173b339a5d256f868d745c0cefdcd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Tue, 1 Oct 2024 20:30:30 -0300 Subject: [PATCH] Fix word selection match not being visible with word wrap. Try to improve ecode nightly yml. --- .github/workflows/ecode-nightly.yml | 72 +++++++++++++++---- .github/workflows/eepp-linux-build-check.yml | 2 +- .github/workflows/eepp-macos-build-check.yml | 2 +- .../workflows/eepp-windows-build-check.yml | 2 +- include/eepp/ui/uicodeeditor.hpp | 15 ++-- premake5.lua | 8 +-- projects/linux/scripts/install_sdl2.sh | 43 +++++++++++ src/eepp/ui/uicodeeditor.cpp | 7 +- 8 files changed, 123 insertions(+), 28 deletions(-) create mode 100644 projects/linux/scripts/install_sdl2.sh diff --git a/.github/workflows/ecode-nightly.yml b/.github/workflows/ecode-nightly.yml index fa7a93ca8..3e80aebf7 100644 --- a/.github/workflows/ecode-nightly.yml +++ b/.github/workflows/ecode-nightly.yml @@ -43,7 +43,7 @@ jobs: Builds that include most recent changes as they happen. For stable releases check the whole list of [releases](https://github.com/SpartanJ/ecode/releases). build_linux: - name: Linux + name: Linux Nightly needs: release strategy: matrix: @@ -93,9 +93,8 @@ jobs: fi - name: Install dependencies run: | - sudo apt-get install -y ccache premake4 libfuse2 fuse + sudo apt-get install -y premake4 libfuse2 fuse if [[ $(uname -m) = "x86_64" ]]; then - sudo apt-get install -y mingw-w64 wget https://github.com/premake/premake-core/releases/download/v5.0.0-beta2/premake-5.0.0-beta2-linux.tar.gz tar xvzf premake-5.0.0-beta2-linux.tar.gz fi @@ -112,15 +111,13 @@ jobs: else sudo apt-get install -y libsdl2-dev:arm64 libsdl2-2.0-0:arm64 fi + bash projects/linux/scripts/install_sdl2.sh - name: Install Cross Compiler if: ${{ matrix.config.compiler != 'default' }} run: sudo apt-get install -y ${{ matrix.config.compiler }} - name: Build ecode run: | bash projects/linux/ecode/build.app.sh --version ${{ env.INSTALL_REF }} --arch ${{ matrix.config.arch }} - if [[ $(uname -m) = "x86_64" ]]; then - bash projects/mingw32/ecode/build.app.sh --version ${{ env.INSTALL_REF }} - fi - name: Upload Files uses: softprops/action-gh-release@v2 with: @@ -130,10 +127,61 @@ jobs: files: | projects/linux/ecode/ecode-linux-${{ env.INSTALL_REF }}-${{ env.RARCH }}.AppImage projects/linux/ecode/ecode-linux-${{ env.INSTALL_REF }}-${{ env.RARCH }}.tar.gz + + build_windows_cross: + name: Windows x86_64 Nightly + needs: release + strategy: + matrix: + config: + - compiler: default + arch: x86_64 + container: ubuntu-22.04 + runs-on: ${{ matrix.config.container }} + env: + CC: gcc + CXX: g++ + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: { fetch-depth: 0, submodules: 'recursive' } + - name: Set Environment Variables + run: | + echo "$HOME/.local/bin" >> "$GITHUB_PATH" + echo "INSTALL_REF=${{ needs.release.outputs.version }}" >> "$GITHUB_ENV" + echo "RARCH=$(uname -m)" >> "$GITHUB_ENV" + - name: Update Packages + run: | + sudo add-apt-repository -y universe + sudo add-apt-repository -y multiverse + sudo apt-get update + - name: Install dependencies + run: | + sudo apt-get install -y premake4 libfuse2 fuse mingw-w64 gcc-12 g++-12 + wget https://github.com/premake/premake-core/releases/download/v5.0.0-beta2/premake-5.0.0-beta2-linux.tar.gz + tar xvzf premake-5.0.0-beta2-linux.tar.gz + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 10 + sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 10 + sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30 + sudo update-alternatives --set cc /usr/bin/gcc + sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30 + sudo update-alternatives --set c++ /usr/bin/g++ + sudo update-alternatives --config gcc + sudo update-alternatives --config g++ + - name: Build ecode + run: | + bash projects/mingw32/ecode/build.app.sh --version ${{ env.INSTALL_REF }} + - name: Upload Files + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ needs.release.outputs.version }} + draft: false + prerelease: true + files: | projects/mingw32/ecode/ecode-windows-${{ env.INSTALL_REF }}-${{ env.RARCH }}.zip build_macos: - name: macOS + name: macOS arm64 Nightly needs: release runs-on: macos-14 strategy: @@ -160,8 +208,8 @@ jobs: - name: Install Dependencies run: | brew install bash sdl2 create-dmg premake p7zip - curl -OL https://github.com/libsdl-org/SDL/releases/download/release-2.30.7/SDL2-2.30.7.dmg - 7z x SDL2-2.30.7.dmg + curl -OL https://github.com/libsdl-org/SDL/releases/download/release-2.30.8/SDL2-2.30.8.dmg + 7z x SDL2-2.30.8.dmg cp -r ./SDL2/SDL2.framework src/thirdparty/ - name: Build run: | @@ -179,7 +227,7 @@ jobs: projects/macos/ecode/ecode-macos-${{ env.INSTALL_REF }}-arm64.dmg build_macos_cross: - name: macOS_cross_build + name: macOS x86_64 Nightly needs: release runs-on: macos-14 strategy: @@ -206,8 +254,8 @@ jobs: - name: Install Dependencies run: | brew install bash sdl2 create-dmg premake p7zip - curl -OL https://github.com/libsdl-org/SDL/releases/download/release-2.30.7/SDL2-2.30.7.dmg - hdiutil attach SDL2-2.30.7.dmg + curl -OL https://github.com/libsdl-org/SDL/releases/download/release-2.30.8/SDL2-2.30.8.dmg + hdiutil attach SDL2-2.30.8.dmg sudo cp -r /Volumes/SDL2/SDL2.framework /Library/Frameworks/ hdiutil detach /Volumes/SDL2 - name: Build diff --git a/.github/workflows/eepp-linux-build-check.yml b/.github/workflows/eepp-linux-build-check.yml index cf4d3cdfa..e34a23bc6 100644 --- a/.github/workflows/eepp-linux-build-check.yml +++ b/.github/workflows/eepp-linux-build-check.yml @@ -32,7 +32,7 @@ jobs: tar xvzf premake-5.0.0-beta2-linux.tar.gz - name: Build run: | - ./premake5 --with-text-shaper gmake2 + ./premake5 --with-text-shaper --disable-static-build gmake2 cd make/linux make all -j$(nproc) -e config=release_x86_64 - name: Unit Tests diff --git a/.github/workflows/eepp-macos-build-check.yml b/.github/workflows/eepp-macos-build-check.yml index 613ddd456..93640ec6d 100644 --- a/.github/workflows/eepp-macos-build-check.yml +++ b/.github/workflows/eepp-macos-build-check.yml @@ -19,7 +19,7 @@ jobs: brew install wget SDL2 premake - name: Build run: | - premake5 --with-text-shaper gmake2 + premake5 --with-text-shaper --disable-static-build gmake2 make -C make/macosx/ -e config=release_arm64 - name: Unit Tests run: | diff --git a/.github/workflows/eepp-windows-build-check.yml b/.github/workflows/eepp-windows-build-check.yml index 102e1e0c5..dc90c916c 100644 --- a/.github/workflows/eepp-windows-build-check.yml +++ b/.github/workflows/eepp-windows-build-check.yml @@ -28,7 +28,7 @@ jobs: - name: Create project shell: powershell run: | - ./premake5.exe --windows-vc-build --with-text-shaper vs2022 + ./premake5.exe --windows-vc-build --with-text-shaper --disable-static-build vs2022 - name: Build shell: cmd run: | diff --git a/include/eepp/ui/uicodeeditor.hpp b/include/eepp/ui/uicodeeditor.hpp index e272181b3..91dbdfeaa 100644 --- a/include/eepp/ui/uicodeeditor.hpp +++ b/include/eepp/ui/uicodeeditor.hpp @@ -507,11 +507,13 @@ class EE_API UICodeEditor : public UIWidget, public TextDocument::Client { virtual Int64 getColFromXOffset( VisibleIndex visibleIndex, const Float& x ) const; - std::vector getTextRangeRectangles( - const TextRange& range, const Vector2f& startScroll, - std::optional lineRange = {}, std::optional lineHeight = {}, - std::optional visibleLineRange = - {} /* if passed it will clip rectangles against the visual line range */ ); + std::vector + getTextRangeRectangles( const TextRange& range, const Vector2f& startScroll, + std::optional lineRange = {}, + std::optional lineHeight = {}, + /* if passed it will clip rectangles against the visual line range */ + std::optional visibleLineRange = + std::optional() ); virtual Float getLineWidth( const Int64& docLine ); @@ -968,7 +970,8 @@ class EE_API UICodeEditor : public UIWidget, public TextDocument::Client { const DocumentViewLineRange& visibleLineRange ); virtual void drawSelectionMatch( const DocumentLineRange& lineRange, - const Vector2f& startScroll, const Float& lineHeight ); + const Vector2f& startScroll, const Float& lineHeight, + const DocumentViewLineRange& visibleLineRange ); virtual void drawWordMatch( const String& text, const DocumentLineRange& lineRange, const Vector2f& startScroll, const Float& lineHeight, diff --git a/premake5.lua b/premake5.lua index c2a925824..3ab9dc25a 100644 --- a/premake5.lua +++ b/premake5.lua @@ -142,10 +142,10 @@ os_links = { } backends = { } static_backends = { } backend_selected = false -remote_sdl2_version = "SDL2-2.30.3" -remote_sdl2_devel_src_url = "https://libsdl.org/release/SDL2-2.30.3.zip" -remote_sdl2_devel_vc_url = "https://www.libsdl.org/release/SDL2-devel-2.30.3-VC.zip" -remote_sdl2_devel_mingw_url = "https://www.libsdl.org/release/SDL2-devel-2.30.3-mingw.zip" +remote_sdl2_version = "SDL2-2.30.8" +remote_sdl2_devel_src_url = "https://libsdl.org/release/SDL2-2.30.8.zip" +remote_sdl2_devel_vc_url = "https://www.libsdl.org/release/SDL2-devel-2.30.8-VC.zip" +remote_sdl2_devel_mingw_url = "https://www.libsdl.org/release/SDL2-devel-2.30.8-mingw.zip" function incdirs( dirs ) if is_xcode() then diff --git a/projects/linux/scripts/install_sdl2.sh b/projects/linux/scripts/install_sdl2.sh new file mode 100644 index 000000000..043ae780e --- /dev/null +++ b/projects/linux/scripts/install_sdl2.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# Define SDL version and download URL +SDL_VERSION="2.30.8" +SDL_URL="https://libsdl.org/release/SDL2-${SDL_VERSION}.zip" + +# Install necessary dependencies +sudo apt-get update +sudo apt-get install -y build-essential unzip wget libasound2-dev libpulse-dev libudev-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libxss-dev libxkbcommon-dev + +# Create a temporary directory for the SDL2 build +mkdir -p ./sdl2_build +cd ./sdl2_build || exit + +# Download SDL2 source code +echo "Downloading SDL2 version ${SDL_VERSION}..." +wget "${SDL_URL}" -O SDL2.zip || exit + +# Unzip the SDL2 source code +echo "Extracting SDL2..." +unzip SDL2.zip || exit + +# Enter the SDL2 directory +cd "SDL2-${SDL_VERSION}" || exit + +# Configure, build, and install SDL2 +echo "Configuring SDL2..." +./configure || exit + +echo "Building SDL2..." +make -j"$(nproc)" || exit + +echo "Installing SDL2..." +sudo make install || exit + +# Clean up +echo "Cleaning up..." +rm -rf ./sdl2_build + +# Update shared library cache +sudo ldconfig + +echo "SDL2 version ${SDL_VERSION} installed successfully!" diff --git a/src/eepp/ui/uicodeeditor.cpp b/src/eepp/ui/uicodeeditor.cpp index 85ef250dc..f9164d465 100644 --- a/src/eepp/ui/uicodeeditor.cpp +++ b/src/eepp/ui/uicodeeditor.cpp @@ -302,7 +302,7 @@ void UICodeEditor::draw() { } if ( mHighlightSelectionMatch && mDoc->hasSelection() && mDoc->getSelection().inSameLine() ) { - drawSelectionMatch( lineRange, startScroll, lineHeight ); + drawSelectionMatch( lineRange, startScroll, lineHeight, visibleLineRange ); } if ( mDoc->hasSelection() ) { @@ -3384,7 +3384,8 @@ void UICodeEditor::drawMatchingBrackets( const Vector2f& startScroll, const Floa } void UICodeEditor::drawSelectionMatch( const DocumentLineRange& lineRange, - const Vector2f& startScroll, const Float& lineHeight ) { + const Vector2f& startScroll, const Float& lineHeight, + const DocumentViewLineRange& visibleLineRange ) { static const String notSpaceStr = "\t "; if ( !mDoc->hasSelection() ) return; @@ -3396,7 +3397,7 @@ void UICodeEditor::drawSelectionMatch( const DocumentLineRange& lineRange, String text( selectionLine.substr( selection.start().column(), selection.end().column() - selection.start().column() ) ); if ( !text.empty() && text.find_first_not_of( notSpaceStr.view() ) != String::InvalidPos ) - drawWordMatch( text, lineRange, startScroll, lineHeight, true ); + drawWordMatch( text, lineRange, startScroll, lineHeight, true, visibleLineRange ); } }