lists.geany.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
List overview
Plugins-Commits
May 2023
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
plugins-commits@lists.geany.org
1 participants
22 discussions
Start a n
N
ew thread
[geany/geany-plugins] 5b8bf6: Merge pull request #1252 from eht16/fix_cppcheck_warnings_v2
by Jiří Techet
23 May '23
23 May '23
Branch: refs/heads/master Author: Jiří Techet <techet(a)gmail.com> Committer: GitHub <noreply(a)github.com> Date: Tue, 23 May 2023 18:40:37 UTC Commit: 5b8bf656d90260779eb98933c0489c77681439e7
https://github.com/geany/geany-plugins/commit/5b8bf656d90260779eb98933c0489…
Log Message: ----------- Merge pull request #1252 from eht16/fix_cppcheck_warnings_v2 ProjectOrganizer: Initialise "is_header" variable Modified Paths: -------------- projectorganizer/src/prjorg-utils.c Modified: projectorganizer/src/prjorg-utils.c 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -294,7 +294,7 @@ gchar *find_header_source(GeanyDocument *doc) { GSList *header_patterns, *source_patterns; gboolean known_type = TRUE; - gboolean is_header; + gboolean is_header = FALSE; gchar *found_name = NULL; if (!doc || !doc->file_name) -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany-plugins] 6e697f: ProjectOrganizer: Initialise "is_header" variable
by Enrico Tröger
22 May '23
22 May '23
Branch: refs/heads/master Author: Enrico Tröger <enrico.troeger(a)uvena.de> Committer: Enrico Tröger <enrico.troeger(a)uvena.de> Date: Mon, 22 May 2023 21:07:55 UTC Commit: 6e697f2582b03db6749b91da2f247c6e60b016e2
https://github.com/geany/geany-plugins/commit/6e697f2582b03db6749b91da2f247…
Log Message: ----------- ProjectOrganizer: Initialise "is_header" variable Older cppcheck versions (e.g. 1.90) complain about this while newer versions (e.g. 2.10) do not. Modified Paths: -------------- projectorganizer/src/prjorg-utils.c Modified: projectorganizer/src/prjorg-utils.c 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -294,7 +294,7 @@ gchar *find_header_source(GeanyDocument *doc) { GSList *header_patterns, *source_patterns; gboolean known_type = TRUE; - gboolean is_header; + gboolean is_header = FALSE; gchar *found_name = NULL; if (!doc || !doc->file_name) -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany-plugins] ccce45: CI: Add Windows build
by Enrico Tröger
21 May '23
21 May '23
Branch: refs/heads/master Author: Enrico Tröger <enrico.troeger(a)uvena.de> Committer: Enrico Tröger <enrico.troeger(a)uvena.de> Date: Sun, 07 May 2023 13:01:10 UTC Commit: ccce45fba7bcd956edf5e087e8cc34b292fb18f7
https://github.com/geany/geany-plugins/commit/ccce45fba7bcd956edf5e087e8cc3…
Log Message: ----------- CI: Add Windows build Modified Paths: -------------- .github/workflows/build.yml build/ci_mingw64_geany_plugins.sh build/gtk-bundle-from-msys2.sh Modified: .github/workflows/build.yml 131 lines changed, 123 insertions(+), 8 deletions(-) =================================================================== @@ -11,6 +11,7 @@ on: pull_request: branches: - master + workflow_dispatch: # cancel already running builds of the same branch or pull request concurrency: @@ -30,7 +31,7 @@ env: jobs: linux: name: Linux Build - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 env: CC: ccache gcc @@ -43,10 +44,10 @@ jobs: steps: - name: Checkout Geany-Plugins - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Checkout Geany - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: geany/geany path: ${{ env.GEANY_SOURCE_PATH }} @@ -58,10 +59,10 @@ jobs: # the creation of the cache item at the end) in combination with "restore-keys" as fallback - name: Prepare ccache timestamp id: ccache_cache_timestamp - run: echo "::set-output name=timestamp::$(date +%Y-%m-%d-%H-%M)" + run: echo "timestamp=$(date +%Y-%m-%d-%H-%M)" >> $GITHUB_OUTPUT - name: Configure ccache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ${{ env.CCACHE_DIR }} key: ${{ runner.os }}-${{ github.job }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} @@ -70,11 +71,11 @@ jobs: - name: Prepare Geany Cache Key id: prepare_geany_cache_key working-directory: ${{ env.GEANY_SOURCE_PATH }} - run: echo "::set-output name=commit_hash::$(git rev-parse HEAD)" + run: echo "commit_hash=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - name: Configure Geany Cache id: geany_cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ${{ env.GEANY_CACHE_PATH }} key: ${{ runner.os }}-${{ github.job }}-geany-cache-${{ steps.prepare_geany_cache_key.outputs.commit_hash }} @@ -120,7 +121,7 @@ jobs: # markdown libmarkdown2-dev # markdown/webhelper - libwebkitgtk-3.0-dev + libwebkit2gtk-4.0-dev # pretty-printer libxml2-dev # spellcheck @@ -164,3 +165,117 @@ jobs: - name: ccache statistics if: ${{ env.DEBUG == '1' }} run: ccache --show-stats + + mingw64: + name: Mingw-w64 Build (Windows) + runs-on: ubuntu-20.04 + + env: + GEANY_SOURCE_PATH: ${{ github.workspace }}/.geany_source + GEANY_CACHE_PATH: ${{ github.workspace }}/.geany_cache + INFRASTRUCTURE_PATH: ${{ github.workspace }}/.infrastructure + BUILDER_PATH: ${{ github.workspace }}/.infrastructure/builders + DOCKER_REGISTRY: "ghcr.io" + DOCKER_IMAGE_NAME: "geany-mingw64-ci" + DOCKER_IMAGE_TAG: "ghcr.io/geany/geany-mingw64-ci:latest" + + steps: + - name: Checkout Geany-Plugins + uses: actions/checkout@v3 + + - name: Checkout Geany + uses: actions/checkout@v3 + with: + repository: geany/geany + path: ${{ env.GEANY_SOURCE_PATH }} + token: ${{ github.token }} + + - name: Checkout Build Scripts + uses: actions/checkout@v3 + with: + ref: master + repository: geany/infrastructure + path: ${{ env.INFRASTRUCTURE_PATH }} + token: ${{ github.token }} + + - uses: jwalton/gh-find-current-pr@v1 + id: find_pull_request + with: + state: open + + - name: Define environment variables + run: | + echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV + echo "GITHUB_PULL_REQUEST=${GITHUB_PULL_REQUEST}" >> $GITHUB_ENV + echo "GITHUB_PULL_REQUEST_OR_REF=${GITHUB_PULL_REQUEST:-${{ github.ref_name }}}" | tr '/' '-' >> $GITHUB_ENV + env: + GITHUB_PULL_REQUEST: ${{ steps.find_pull_request.outputs.pr }} + + - name: Prepare Geany Cache Key + id: prepare_geany_cache_key + working-directory: ${{ env.GEANY_SOURCE_PATH }} + run: echo "commit_hash=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT + + - name: Configure Geany Cache + id: geany_cache + uses: actions/cache@v3 + with: + path: ${{ env.GEANY_CACHE_PATH }} + key: ${{ runner.os }}-${{ github.job }}-geany-mingw64-cache-${{ steps.prepare_geany_cache_key.outputs.commit_hash }} + + - name: Show Environment + if: ${{ env.DEBUG == '1' }} + run: | + env | sort + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.DOCKER_REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Pull Or Build Docker Image + working-directory: ${{ env.BUILDER_PATH }} + run: | + docker_image_created= + docker pull ${{ env.DOCKER_IMAGE_TAG }} || true + if $(docker image inspect ${{ env.DOCKER_IMAGE_TAG }} --format="ignored" >/dev/null 2>&1); then + docker tag ${{ env.DOCKER_IMAGE_TAG }} ${{ env.DOCKER_IMAGE_NAME }} + docker_image_created=$(docker image inspect ${{ env.DOCKER_IMAGE_NAME }} --format='{{ index .Config.Labels "org.opencontainers.image.created" }}') + echo "Docker image built on: ${docker_image_created}" + fi + + bash start_build.sh --log-to-stdout --mingw64 --rebuild-images + docker_image_created_new=$(docker image inspect ${{ env.DOCKER_IMAGE_NAME }} --format='{{ index .Config.Labels "org.opencontainers.image.created" }}') + # tag the image + if [ "${docker_image_created}" != "${docker_image_created_new}" ]; then + docker tag ${{ env.DOCKER_IMAGE_NAME }} ${{ env.DOCKER_IMAGE_TAG }} + fi + + - name: Copy Geany Installer From Cache + if: steps.geany_cache.outputs.cache-hit == 'true' + run: | + cp ${{ env.GEANY_CACHE_PATH }}/geany-*.exe ${{ env.BUILDER_PATH }}/output/mingw64/ + + - name: Build Geany + if: steps.geany_cache.outputs.cache-hit != 'true' + working-directory: ${{ env.BUILDER_PATH }} + run: | + bash start_build.sh --log-to-stdout --mingw64 --geany --geany-source "${{ env.GEANY_SOURCE_PATH }}" + mkdir -p "${{ env.GEANY_CACHE_PATH }}" + cp ${{ env.BUILDER_PATH }}/output/mingw64/geany-*.exe ${{ env.GEANY_CACHE_PATH }} + + - name: Build Geany-Plugins + working-directory: ${{ env.BUILDER_PATH }} + run: | + bash start_build.sh --log-to-stdout --mingw64 --geany-plugins --geany-plugins-source "${{ github.workspace }}" + + - name: Archive Geany-Plugins Installer + uses: actions/upload-artifact@v3 + with: + name: geany-plugins-installer-ci-${{ env.SHORT_SHA }}-pr${{ env.GITHUB_PULL_REQUEST_OR_REF }} + retention-days: 30 + path: | + ${{ env.BUILDER_PATH }}/output/mingw64/geany-*.exe + ${{ env.BUILDER_PATH }}/output/mingw64/geany-*.zip Modified: build/ci_mingw64_geany_plugins.sh 328 lines changed, 328 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,328 @@ +#!/bin/bash +# +# Copyright 2022 The Geany contributors +# License: GPLv2 +# +# Helper script to build Geany-Plugins for Windows in a Docker container. +# The following steps are performed: +# - clone Geany-Plugins repository if necessary (i.e. if it is not bind-mounted into the container) +# - cross-compile Geany-Plugins for Windows 64bit and GTK3 +# - sign all binaries and installer (if /certificates exist and contains cert.pem and key.pem) +# - create bundle with all dependencies +# - create the NSIS installer in ${OUTPUT_DIRECTORY} +# - test the created NSIS installer +# - test uninstaller and check there is nothing unexpected left after uninstalling +# +# This script has to be executed within the Docker container +# (
https://github.com/geany/infrastructure/blob/master/builders/Dockerfile.min…
). +# The Docker container should have a bind-mount for ${OUTPUT_DIRECTORY} +# where the resulting installer binary is stored. +# +# To test the installer "wine" is used. +# Please note that we need to use wine32 as the created installer and uninstaller +# binaries are 32bit. +# + +GEANY_PLUGINS_VERSION= # will be set below from configure.ac +GEANY_PLUGINS_GIT_REVISION= # will be set below +OUTPUT_DIRECTORY="/output" +GEANY_PLUGINS_GIT_REPOSITORY="
https://github.com/geany/geany-plugins.git
" + +# rather static values, unlikely to be changed +DEPENDENCY_BUNDLE_DIR="/build/dependencies-bundle" +GEANY_PLUGINS_SOURCE_DIR="/geany-plugins-source" +GEANY_PLUGINS_BUILD_DIR="/build/geany-plugins-build" +GEANY_PLUGINS_RELEASE_DIR="/build/geany-plugins-release" +GEANY_PLUGINS_INSTALLER_FILENAME= # will be set below +GEANY_PLUGINS_INSTALLATION_DIR_WIN="C:\\geany_plugins_install" +GEANY_PLUGINS_INSTALLATION_DIR=$(winepath --unix ${GEANY_PLUGINS_INSTALLATION_DIR_WIN}) +GEANY_PLUGINS_RELEASE_BINARY_PATTERNS=( + "${GEANY_PLUGINS_RELEASE_DIR}/lib/geany/*.dll" + "${GEANY_PLUGINS_RELEASE_DIR}/lib/geany-plugins/geanylua/libgeanylua.dll" + "${GEANY_PLUGINS_RELEASE_DIR}/bin/libgeanypluginutils*.dll" +) + +GEANY_INSTALLATION_DIR="/root/.wine/drive_c/geany_install" +GEANY_INSTALLATION_DIR_WIN=$(winepath --windows ${GEANY_INSTALLATION_DIR}) +GEANY_INSTALLER_EXECUTABLE=$(ls ${OUTPUT_DIRECTORY}/geany-*_setup.exe) + +# CI CFLAGS +CFLAGS="\ + -Wall \ + -Wextra \ + -O2 \ + -Wunused \ + -Wno-unused-parameter \ + -Wunreachable-code \ + -Wformat=2 \ + -Wundef \ + -Wpointer-arith \ + -Wwrite-strings \ + -Waggregate-return \ + -Wmissing-prototypes \ + -Wmissing-declarations \ + -Wmissing-noreturn \ + -Wmissing-format-attribute \ + -Wredundant-decls \ + -Wnested-externs \ + -Wno-deprecated-declarations" + +# cross-compilation environment +ARCH="x86_64" +MINGW_ARCH="mingw64" +HOST="x86_64-w64-mingw32" +export LDFLAGS="-static-libgcc ${LDFLAGS}" +export PKG_CONFIG_SYSROOT_DIR="/windows" +export PKG_CONFIG_PATH="/windows/${MINGW_ARCH}/lib/pkgconfig/" +export NOCONFIGURE=1 +export JOBS=${JOBS:-1} +export lt_cv_deplibs_check_method='pass_all' + +# stop on errors +set -e + + +log() { + echo "=========== $(date '+%Y-%m-%d %H:%M:%S %Z') $* ===========" +} + + +git_clone_geany_plugins_if_necessary() { + if [ -d ${GEANY_PLUGINS_SOURCE_DIR} ]; then + log "Copying Geany-Plugins source" + cp --archive ${GEANY_PLUGINS_SOURCE_DIR}/ ${GEANY_PLUGINS_BUILD_DIR}/ + chown --recursive $(id -u):$(id -g) ${GEANY_PLUGINS_BUILD_DIR}/ + else + log "Cloning Geany-Plugins repository from ${GEANY_PLUGINS_GIT_REPOSITORY}" + git clone --depth 1 ${GEANY_PLUGINS_GIT_REPOSITORY} ${GEANY_PLUGINS_BUILD_DIR} + fi +} + + +parse_geany_plugins_version() { + GEANY_PLUGINS_VERSION=$(sed -n -E -e 's/^AC_INIT.\[geany-plugins\], \[(.+)\]./\1/p' ${GEANY_PLUGINS_BUILD_DIR}/configure.ac) + GEANY_PLUGINS_GIT_REVISION=$(cd ${GEANY_PLUGINS_BUILD_DIR} && git rev-parse --short --revs-only HEAD 2>/dev/null || true) + TIMESTAMP=$(date +%Y%m%d%H%M%S) + # add pull request number if this is a CI and a PR build + if [ "${GITHUB_PULL_REQUEST}" ]; then + GEANY_PLUGINS_VERSION="${GEANY_PLUGINS_VERSION}_ci_${TIMESTAMP}_${GEANY_PLUGINS_GIT_REVISION}_pr${GITHUB_PULL_REQUEST}" + elif [ "${CI}" -a "${GEANY_PLUGINS_GIT_REVISION}" ]; then + GEANY_PLUGINS_VERSION="${GEANY_PLUGINS_VERSION}_ci_${TIMESTAMP}_${GEANY_PLUGINS_GIT_REVISION}" + elif [ "${GEANY_PLUGINS_GIT_REVISION}" ]; then + GEANY_PLUGINS_VERSION="${GEANY_PLUGINS_VERSION}_git_${TIMESTAMP}_${GEANY_PLUGINS_GIT_REVISION}" + fi + GEANY_PLUGINS_INSTALLER_FILENAME="geany-plugins-${GEANY_PLUGINS_VERSION}_setup.exe" +} + + +log_environment() { + log "Using environment" + CONFIGURE_OPTIONS="--disable-silent-rules --host=${HOST} --prefix=${GEANY_PLUGINS_RELEASE_DIR} --with-geany-libdir=${GEANY_PLUGINS_RELEASE_DIR}/lib" + echo "Geany-Plugins version : ${GEANY_PLUGINS_VERSION}" + echo "Geany-Plugins GIT revision : ${GEANY_PLUGINS_GIT_REVISION}" + echo "Geany installer : ${GEANY_INSTALLER_EXECUTABLE}" + echo "PATH : ${PATH}" + echo "HOST : ${HOST}" + echo "CC : ${CC}" + echo "CFLAGS : ${CFLAGS}" + echo "Configure : ${CONFIGURE_OPTIONS}" +} + + +patch_version_information() { + log "Patching version information" + + if [ -z "${GEANY_PLUGINS_GIT_REVISION}" ]; then + return + fi + + # parse version string and decrement the patch and/or minor levels to keep nightly build + # versions below the next release version + regex='^([0-9]*)[.]([0-9]*)([.]([0-9]*))?' + if [[ ${GEANY_PLUGINS_VERSION} =~ $regex ]]; then + MAJOR="${BASH_REMATCH[1]}" + MINOR="${BASH_REMATCH[2]}" + PATCH="${BASH_REMATCH[4]}" + if [ -z "${PATCH}" ] || [ "${PATCH}" = "0" ]; then + MINOR="$((MINOR-1))" + PATCH="90" + else + PATCH="$((PATCH-1))" + fi + else + echo "Could not extract or parse version tag" >&2 + exit 1 + fi + # replace version information in configure.ac and for Windows binaries + sed -i -E "s/^AC_INIT.\[geany-plugins\], \[(.+)\],/AC_INIT(\[geany-plugins\], \[${GEANY_PLUGINS_VERSION}\],/" ${GEANY_PLUGINS_BUILD_DIR}/configure.ac + sed -i -E "s/^!define PRODUCT_VERSION \"(.+)\"/!define PRODUCT_VERSION \"${GEANY_PLUGINS_VERSION}\"/" ${GEANY_PLUGINS_BUILD_DIR}/build/geany-plugins.nsi + sed -i -E "s/^!define PRODUCT_VERSION_ID \"(.+)\"/!define PRODUCT_VERSION_ID \"${MAJOR}.${MINOR}.${PATCH}.90\"/" ${GEANY_PLUGINS_BUILD_DIR}/build/geany-plugins.nsi + sed -i -E "s/^!define REQUIRED_GEANY_VERSION \"(.+)\"/!define REQUIRED_GEANY_VERSION \"${MAJOR}.${MINOR}\"/" ${GEANY_PLUGINS_BUILD_DIR}/build/geany-plugins.nsi +} + + +install_dependencies() { + log "Installing build dependencies" + pacman --noconfirm -Syu + pacman --noconfirm -S \ + mingw-w64-${ARCH}-check \ + mingw-w64-${ARCH}-cppcheck \ + mingw-w64-${ARCH}-ctpl-git \ + mingw-w64-${ARCH}-enchant \ + mingw-w64-${ARCH}-gpgme \ + mingw-w64-${ARCH}-gtkspell3 \ + mingw-w64-${ARCH}-libgit2 \ + mingw-w64-${ARCH}-libsoup \ + mingw-w64-${ARCH}-lua51 +} + + +install_geany() { + log "Installing Geany (using wine)" + if [ -z "${GEANY_INSTALLER_EXECUTABLE}" -o ! -f "${GEANY_INSTALLER_EXECUTABLE}" ]; then + echo "No Geany installer found" + exit 1 + fi + mingw-w64-i686-wine ${GEANY_INSTALLER_EXECUTABLE} /S /D=${GEANY_INSTALLATION_DIR_WIN} + + # TODO the following steps are way too hacky: installing Geany from the installer is basically + # what we want for CI tests but the installed "geany.pc" file isn't really suitable + # for cross-compiling + + # add the Geany installation directory to the PKG_CONFIG_PATH + export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:${GEANY_INSTALLATION_DIR}/lib/pkgconfig/" + # patch Geany pkg-config prefix: pkg-config always prepend "/windows" to the "prefix" variable, so we + # need to add ../ to get out of the hardcoded "/windows" path element + sed -i "s%^\(prefix=\).*$%\1/..${GEANY_INSTALLATION_DIR}%" ${GEANY_INSTALLATION_DIR}/lib/pkgconfig/geany.pc + sed -i "s%^\(exec_prefix=\).*$%\1/..${GEANY_INSTALLATION_DIR}%" ${GEANY_INSTALLATION_DIR}/lib/pkgconfig/geany.pc + # we need "${exec_prefix}/bin" additionally for libgeany-0.dll which is installed into bin/ and replace -lgeany by -lgeany-0 + sed -i "s%^Libs: -L\${libdir} -lgeany$%Libs: -L\${libdir} -L\${exec_prefix}/bin -lgeany-0%" ${GEANY_INSTALLATION_DIR}/lib/pkgconfig/geany.pc +} + + +build_geany_plugins() { + cd ${GEANY_PLUGINS_BUILD_DIR} + log "Running autogen.sh" + ./autogen.sh + log "Running configure" + ./configure ${CONFIGURE_OPTIONS} + log "Running make" + make -j ${JOBS} + log "Running install-strip" + make install-strip +} + + +sign_file() { + echo "Sign file $1" + if [ -f /certificates/cert.pem ] && [ -f /certificates/key.pem ]; then + osslsigncode sign \ + -certs /certificates/cert.pem \ + -key /certificates/key.pem \ + -n "Geany-Plugins Binary" \ + -i "
https://www.geany.org/
" \ + -ts
http://zeitstempel.dfn.de/
\ + -h sha512 \ + -in ${1} \ + -out ${1}-signed + mv ${1}-signed ${1} + else + echo "Skip signing due to missing certificate" + fi +} + + +sign_geany_plugins_binaries() { + log "Signing Geany-Plugins binary files" + for binary_file_pattern in ${GEANY_PLUGINS_RELEASE_BINARY_PATTERNS[@]}; do + for binary_file in $(ls ${binary_file_pattern}); do + sign_file ${binary_file} + done + done +} + + +create_dependencies_bundle() { + log "Creating Geany-Plugins dependencies bundle" + mkdir ${DEPENDENCY_BUNDLE_DIR} + cd ${DEPENDENCY_BUNDLE_DIR} + bash ${GEANY_PLUGINS_BUILD_DIR}/build/gtk-bundle-from-msys2.sh -x -3 +} + + +create_installer() { + log "Creating NSIS installer" + makensis \ + -V3 \ + -WX \ + -DGEANY_PLUGINS_INSTALLER_NAME="${GEANY_PLUGINS_INSTALLER_FILENAME}" \ + -DGEANY_PLUGINS_RELEASE_DIR=${GEANY_PLUGINS_RELEASE_DIR} \ + -DDEPENDENCY_BUNDLE_DIR=${DEPENDENCY_BUNDLE_DIR} \ + ${GEANY_PLUGINS_BUILD_DIR}/build/geany-plugins.nsi +} + + +sign_installer() { + log "Signing NSIS installer" + sign_file ${GEANY_PLUGINS_BUILD_DIR}/build/${GEANY_PLUGINS_INSTALLER_FILENAME} +} + + +test_installer() { + log "Test NSIS installer" + # perform a silent install and check for installed files + exiftool -FileName -FileType -FileVersion -FileVersionNumber ${GEANY_PLUGINS_BUILD_DIR}/build/${GEANY_PLUGINS_INSTALLER_FILENAME} + # install Geany-Plugins + mingw-w64-i686-wine ${GEANY_PLUGINS_BUILD_DIR}/build/${GEANY_PLUGINS_INSTALLER_FILENAME} /S /D=${GEANY_PLUGINS_INSTALLATION_DIR_WIN} + # check if we have something installed + ls -l ${GEANY_PLUGINS_INSTALLATION_DIR}/uninst-plugins.exe || exit 1 + ls -l ${GEANY_PLUGINS_INSTALLATION_DIR}/lib/geany/addons.dll || exit 1 +} + + +test_uninstaller() { + log "Test NSIS uninstaller" + # uninstall Geany-Plugins and test if everything is clean + mingw-w64-i686-wine ${GEANY_PLUGINS_INSTALLATION_DIR}/uninst-plugins.exe /S + sleep 15 # it seems the uninstaller returns earlier than the files are actually removed, so wait a moment + rest=$(find ${GEANY_PLUGINS_INSTALLATION_DIR} \( -path '*share/locale' -o -path '*share/licenses' \) -prune -false -o -true -printf '%P ') + if [ "${rest}" != " share share/locale share/licenses " ]; then + # do not treat this as error, it might happen if upstream dependencies have been updated, + # the list of files to be removed needs to be updated only before releases + echo "WARNING: Uninstaller failed to uninstall the following files files: ${rest}" + fi +} + + +copy_installer_and_bundle() { + log "Copying NSIS installer and dependencies bundle" + cp ${GEANY_PLUGINS_BUILD_DIR}/build/${GEANY_PLUGINS_INSTALLER_FILENAME} ${OUTPUT_DIRECTORY} + cd ${DEPENDENCY_BUNDLE_DIR} + zip --quiet --recurse-paths ${OUTPUT_DIRECTORY}/geany_plugins_dependencies_bundle_$(date '+%Y%m%dT%H%M%S').zip * +} + + +main() { + git_clone_geany_plugins_if_necessary + + parse_geany_plugins_version + log_environment + patch_version_information + install_dependencies + install_geany + build_geany_plugins + sign_geany_plugins_binaries + + create_dependencies_bundle + create_installer + sign_installer + copy_installer_and_bundle + + test_installer + test_uninstaller + + log "Done." +} + + +main Modified: build/gtk-bundle-from-msys2.sh 1 lines changed, 0 insertions(+), 1 deletions(-) =================================================================== @@ -292,7 +292,6 @@ Following is a list of all included binary packages with their full download URL as used to create this installation. EOF echo -e "${package_urls}" >> "${filename}" - unix2dos "${filename}" } create_zip_archive() { -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany-plugins] 1c64b3: Merge pull request #1201 from eht16/ci_add_windows_build
by Enrico Tröger
21 May '23
21 May '23
Branch: refs/heads/master Author: Enrico Tröger <enrico.troeger(a)uvena.de> Committer: GitHub <noreply(a)github.com> Date: Sun, 21 May 2023 17:28:11 UTC Commit: 1c64b329d5d0aecf6486276a0b7701a4a8a40bd4
https://github.com/geany/geany-plugins/commit/1c64b329d5d0aecf6486276a0b770…
Log Message: ----------- Merge pull request #1201 from eht16/ci_add_windows_build Add mingw-w64 (Windows) CI build Modified Paths: -------------- .github/workflows/build.yml build/ci_mingw64_geany_plugins.sh build/gtk-bundle-from-msys2.sh Modified: .github/workflows/build.yml 131 lines changed, 123 insertions(+), 8 deletions(-) =================================================================== @@ -11,6 +11,7 @@ on: pull_request: branches: - master + workflow_dispatch: # cancel already running builds of the same branch or pull request concurrency: @@ -30,7 +31,7 @@ env: jobs: linux: name: Linux Build - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 env: CC: ccache gcc @@ -43,10 +44,10 @@ jobs: steps: - name: Checkout Geany-Plugins - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Checkout Geany - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: geany/geany path: ${{ env.GEANY_SOURCE_PATH }} @@ -58,10 +59,10 @@ jobs: # the creation of the cache item at the end) in combination with "restore-keys" as fallback - name: Prepare ccache timestamp id: ccache_cache_timestamp - run: echo "::set-output name=timestamp::$(date +%Y-%m-%d-%H-%M)" + run: echo "timestamp=$(date +%Y-%m-%d-%H-%M)" >> $GITHUB_OUTPUT - name: Configure ccache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ${{ env.CCACHE_DIR }} key: ${{ runner.os }}-${{ github.job }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} @@ -70,11 +71,11 @@ jobs: - name: Prepare Geany Cache Key id: prepare_geany_cache_key working-directory: ${{ env.GEANY_SOURCE_PATH }} - run: echo "::set-output name=commit_hash::$(git rev-parse HEAD)" + run: echo "commit_hash=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - name: Configure Geany Cache id: geany_cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ${{ env.GEANY_CACHE_PATH }} key: ${{ runner.os }}-${{ github.job }}-geany-cache-${{ steps.prepare_geany_cache_key.outputs.commit_hash }} @@ -120,7 +121,7 @@ jobs: # markdown libmarkdown2-dev # markdown/webhelper - libwebkitgtk-3.0-dev + libwebkit2gtk-4.0-dev # pretty-printer libxml2-dev # spellcheck @@ -164,3 +165,117 @@ jobs: - name: ccache statistics if: ${{ env.DEBUG == '1' }} run: ccache --show-stats + + mingw64: + name: Mingw-w64 Build (Windows) + runs-on: ubuntu-20.04 + + env: + GEANY_SOURCE_PATH: ${{ github.workspace }}/.geany_source + GEANY_CACHE_PATH: ${{ github.workspace }}/.geany_cache + INFRASTRUCTURE_PATH: ${{ github.workspace }}/.infrastructure + BUILDER_PATH: ${{ github.workspace }}/.infrastructure/builders + DOCKER_REGISTRY: "ghcr.io" + DOCKER_IMAGE_NAME: "geany-mingw64-ci" + DOCKER_IMAGE_TAG: "ghcr.io/geany/geany-mingw64-ci:latest" + + steps: + - name: Checkout Geany-Plugins + uses: actions/checkout@v3 + + - name: Checkout Geany + uses: actions/checkout@v3 + with: + repository: geany/geany + path: ${{ env.GEANY_SOURCE_PATH }} + token: ${{ github.token }} + + - name: Checkout Build Scripts + uses: actions/checkout@v3 + with: + ref: master + repository: geany/infrastructure + path: ${{ env.INFRASTRUCTURE_PATH }} + token: ${{ github.token }} + + - uses: jwalton/gh-find-current-pr@v1 + id: find_pull_request + with: + state: open + + - name: Define environment variables + run: | + echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV + echo "GITHUB_PULL_REQUEST=${GITHUB_PULL_REQUEST}" >> $GITHUB_ENV + echo "GITHUB_PULL_REQUEST_OR_REF=${GITHUB_PULL_REQUEST:-${{ github.ref_name }}}" | tr '/' '-' >> $GITHUB_ENV + env: + GITHUB_PULL_REQUEST: ${{ steps.find_pull_request.outputs.pr }} + + - name: Prepare Geany Cache Key + id: prepare_geany_cache_key + working-directory: ${{ env.GEANY_SOURCE_PATH }} + run: echo "commit_hash=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT + + - name: Configure Geany Cache + id: geany_cache + uses: actions/cache@v3 + with: + path: ${{ env.GEANY_CACHE_PATH }} + key: ${{ runner.os }}-${{ github.job }}-geany-mingw64-cache-${{ steps.prepare_geany_cache_key.outputs.commit_hash }} + + - name: Show Environment + if: ${{ env.DEBUG == '1' }} + run: | + env | sort + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.DOCKER_REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Pull Or Build Docker Image + working-directory: ${{ env.BUILDER_PATH }} + run: | + docker_image_created= + docker pull ${{ env.DOCKER_IMAGE_TAG }} || true + if $(docker image inspect ${{ env.DOCKER_IMAGE_TAG }} --format="ignored" >/dev/null 2>&1); then + docker tag ${{ env.DOCKER_IMAGE_TAG }} ${{ env.DOCKER_IMAGE_NAME }} + docker_image_created=$(docker image inspect ${{ env.DOCKER_IMAGE_NAME }} --format='{{ index .Config.Labels "org.opencontainers.image.created" }}') + echo "Docker image built on: ${docker_image_created}" + fi + + bash start_build.sh --log-to-stdout --mingw64 --rebuild-images + docker_image_created_new=$(docker image inspect ${{ env.DOCKER_IMAGE_NAME }} --format='{{ index .Config.Labels "org.opencontainers.image.created" }}') + # tag the image + if [ "${docker_image_created}" != "${docker_image_created_new}" ]; then + docker tag ${{ env.DOCKER_IMAGE_NAME }} ${{ env.DOCKER_IMAGE_TAG }} + fi + + - name: Copy Geany Installer From Cache + if: steps.geany_cache.outputs.cache-hit == 'true' + run: | + cp ${{ env.GEANY_CACHE_PATH }}/geany-*.exe ${{ env.BUILDER_PATH }}/output/mingw64/ + + - name: Build Geany + if: steps.geany_cache.outputs.cache-hit != 'true' + working-directory: ${{ env.BUILDER_PATH }} + run: | + bash start_build.sh --log-to-stdout --mingw64 --geany --geany-source "${{ env.GEANY_SOURCE_PATH }}" + mkdir -p "${{ env.GEANY_CACHE_PATH }}" + cp ${{ env.BUILDER_PATH }}/output/mingw64/geany-*.exe ${{ env.GEANY_CACHE_PATH }} + + - name: Build Geany-Plugins + working-directory: ${{ env.BUILDER_PATH }} + run: | + bash start_build.sh --log-to-stdout --mingw64 --geany-plugins --geany-plugins-source "${{ github.workspace }}" + + - name: Archive Geany-Plugins Installer + uses: actions/upload-artifact@v3 + with: + name: geany-plugins-installer-ci-${{ env.SHORT_SHA }}-pr${{ env.GITHUB_PULL_REQUEST_OR_REF }} + retention-days: 30 + path: | + ${{ env.BUILDER_PATH }}/output/mingw64/geany-*.exe + ${{ env.BUILDER_PATH }}/output/mingw64/geany-*.zip Modified: build/ci_mingw64_geany_plugins.sh 328 lines changed, 328 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,328 @@ +#!/bin/bash +# +# Copyright 2022 The Geany contributors +# License: GPLv2 +# +# Helper script to build Geany-Plugins for Windows in a Docker container. +# The following steps are performed: +# - clone Geany-Plugins repository if necessary (i.e. if it is not bind-mounted into the container) +# - cross-compile Geany-Plugins for Windows 64bit and GTK3 +# - sign all binaries and installer (if /certificates exist and contains cert.pem and key.pem) +# - create bundle with all dependencies +# - create the NSIS installer in ${OUTPUT_DIRECTORY} +# - test the created NSIS installer +# - test uninstaller and check there is nothing unexpected left after uninstalling +# +# This script has to be executed within the Docker container +# (
https://github.com/geany/infrastructure/blob/master/builders/Dockerfile.min…
). +# The Docker container should have a bind-mount for ${OUTPUT_DIRECTORY} +# where the resulting installer binary is stored. +# +# To test the installer "wine" is used. +# Please note that we need to use wine32 as the created installer and uninstaller +# binaries are 32bit. +# + +GEANY_PLUGINS_VERSION= # will be set below from configure.ac +GEANY_PLUGINS_GIT_REVISION= # will be set below +OUTPUT_DIRECTORY="/output" +GEANY_PLUGINS_GIT_REPOSITORY="
https://github.com/geany/geany-plugins.git
" + +# rather static values, unlikely to be changed +DEPENDENCY_BUNDLE_DIR="/build/dependencies-bundle" +GEANY_PLUGINS_SOURCE_DIR="/geany-plugins-source" +GEANY_PLUGINS_BUILD_DIR="/build/geany-plugins-build" +GEANY_PLUGINS_RELEASE_DIR="/build/geany-plugins-release" +GEANY_PLUGINS_INSTALLER_FILENAME= # will be set below +GEANY_PLUGINS_INSTALLATION_DIR_WIN="C:\\geany_plugins_install" +GEANY_PLUGINS_INSTALLATION_DIR=$(winepath --unix ${GEANY_PLUGINS_INSTALLATION_DIR_WIN}) +GEANY_PLUGINS_RELEASE_BINARY_PATTERNS=( + "${GEANY_PLUGINS_RELEASE_DIR}/lib/geany/*.dll" + "${GEANY_PLUGINS_RELEASE_DIR}/lib/geany-plugins/geanylua/libgeanylua.dll" + "${GEANY_PLUGINS_RELEASE_DIR}/bin/libgeanypluginutils*.dll" +) + +GEANY_INSTALLATION_DIR="/root/.wine/drive_c/geany_install" +GEANY_INSTALLATION_DIR_WIN=$(winepath --windows ${GEANY_INSTALLATION_DIR}) +GEANY_INSTALLER_EXECUTABLE=$(ls ${OUTPUT_DIRECTORY}/geany-*_setup.exe) + +# CI CFLAGS +CFLAGS="\ + -Wall \ + -Wextra \ + -O2 \ + -Wunused \ + -Wno-unused-parameter \ + -Wunreachable-code \ + -Wformat=2 \ + -Wundef \ + -Wpointer-arith \ + -Wwrite-strings \ + -Waggregate-return \ + -Wmissing-prototypes \ + -Wmissing-declarations \ + -Wmissing-noreturn \ + -Wmissing-format-attribute \ + -Wredundant-decls \ + -Wnested-externs \ + -Wno-deprecated-declarations" + +# cross-compilation environment +ARCH="x86_64" +MINGW_ARCH="mingw64" +HOST="x86_64-w64-mingw32" +export LDFLAGS="-static-libgcc ${LDFLAGS}" +export PKG_CONFIG_SYSROOT_DIR="/windows" +export PKG_CONFIG_PATH="/windows/${MINGW_ARCH}/lib/pkgconfig/" +export NOCONFIGURE=1 +export JOBS=${JOBS:-1} +export lt_cv_deplibs_check_method='pass_all' + +# stop on errors +set -e + + +log() { + echo "=========== $(date '+%Y-%m-%d %H:%M:%S %Z') $* ===========" +} + + +git_clone_geany_plugins_if_necessary() { + if [ -d ${GEANY_PLUGINS_SOURCE_DIR} ]; then + log "Copying Geany-Plugins source" + cp --archive ${GEANY_PLUGINS_SOURCE_DIR}/ ${GEANY_PLUGINS_BUILD_DIR}/ + chown --recursive $(id -u):$(id -g) ${GEANY_PLUGINS_BUILD_DIR}/ + else + log "Cloning Geany-Plugins repository from ${GEANY_PLUGINS_GIT_REPOSITORY}" + git clone --depth 1 ${GEANY_PLUGINS_GIT_REPOSITORY} ${GEANY_PLUGINS_BUILD_DIR} + fi +} + + +parse_geany_plugins_version() { + GEANY_PLUGINS_VERSION=$(sed -n -E -e 's/^AC_INIT.\[geany-plugins\], \[(.+)\]./\1/p' ${GEANY_PLUGINS_BUILD_DIR}/configure.ac) + GEANY_PLUGINS_GIT_REVISION=$(cd ${GEANY_PLUGINS_BUILD_DIR} && git rev-parse --short --revs-only HEAD 2>/dev/null || true) + TIMESTAMP=$(date +%Y%m%d%H%M%S) + # add pull request number if this is a CI and a PR build + if [ "${GITHUB_PULL_REQUEST}" ]; then + GEANY_PLUGINS_VERSION="${GEANY_PLUGINS_VERSION}_ci_${TIMESTAMP}_${GEANY_PLUGINS_GIT_REVISION}_pr${GITHUB_PULL_REQUEST}" + elif [ "${CI}" -a "${GEANY_PLUGINS_GIT_REVISION}" ]; then + GEANY_PLUGINS_VERSION="${GEANY_PLUGINS_VERSION}_ci_${TIMESTAMP}_${GEANY_PLUGINS_GIT_REVISION}" + elif [ "${GEANY_PLUGINS_GIT_REVISION}" ]; then + GEANY_PLUGINS_VERSION="${GEANY_PLUGINS_VERSION}_git_${TIMESTAMP}_${GEANY_PLUGINS_GIT_REVISION}" + fi + GEANY_PLUGINS_INSTALLER_FILENAME="geany-plugins-${GEANY_PLUGINS_VERSION}_setup.exe" +} + + +log_environment() { + log "Using environment" + CONFIGURE_OPTIONS="--disable-silent-rules --host=${HOST} --prefix=${GEANY_PLUGINS_RELEASE_DIR} --with-geany-libdir=${GEANY_PLUGINS_RELEASE_DIR}/lib" + echo "Geany-Plugins version : ${GEANY_PLUGINS_VERSION}" + echo "Geany-Plugins GIT revision : ${GEANY_PLUGINS_GIT_REVISION}" + echo "Geany installer : ${GEANY_INSTALLER_EXECUTABLE}" + echo "PATH : ${PATH}" + echo "HOST : ${HOST}" + echo "CC : ${CC}" + echo "CFLAGS : ${CFLAGS}" + echo "Configure : ${CONFIGURE_OPTIONS}" +} + + +patch_version_information() { + log "Patching version information" + + if [ -z "${GEANY_PLUGINS_GIT_REVISION}" ]; then + return + fi + + # parse version string and decrement the patch and/or minor levels to keep nightly build + # versions below the next release version + regex='^([0-9]*)[.]([0-9]*)([.]([0-9]*))?' + if [[ ${GEANY_PLUGINS_VERSION} =~ $regex ]]; then + MAJOR="${BASH_REMATCH[1]}" + MINOR="${BASH_REMATCH[2]}" + PATCH="${BASH_REMATCH[4]}" + if [ -z "${PATCH}" ] || [ "${PATCH}" = "0" ]; then + MINOR="$((MINOR-1))" + PATCH="90" + else + PATCH="$((PATCH-1))" + fi + else + echo "Could not extract or parse version tag" >&2 + exit 1 + fi + # replace version information in configure.ac and for Windows binaries + sed -i -E "s/^AC_INIT.\[geany-plugins\], \[(.+)\],/AC_INIT(\[geany-plugins\], \[${GEANY_PLUGINS_VERSION}\],/" ${GEANY_PLUGINS_BUILD_DIR}/configure.ac + sed -i -E "s/^!define PRODUCT_VERSION \"(.+)\"/!define PRODUCT_VERSION \"${GEANY_PLUGINS_VERSION}\"/" ${GEANY_PLUGINS_BUILD_DIR}/build/geany-plugins.nsi + sed -i -E "s/^!define PRODUCT_VERSION_ID \"(.+)\"/!define PRODUCT_VERSION_ID \"${MAJOR}.${MINOR}.${PATCH}.90\"/" ${GEANY_PLUGINS_BUILD_DIR}/build/geany-plugins.nsi + sed -i -E "s/^!define REQUIRED_GEANY_VERSION \"(.+)\"/!define REQUIRED_GEANY_VERSION \"${MAJOR}.${MINOR}\"/" ${GEANY_PLUGINS_BUILD_DIR}/build/geany-plugins.nsi +} + + +install_dependencies() { + log "Installing build dependencies" + pacman --noconfirm -Syu + pacman --noconfirm -S \ + mingw-w64-${ARCH}-check \ + mingw-w64-${ARCH}-cppcheck \ + mingw-w64-${ARCH}-ctpl-git \ + mingw-w64-${ARCH}-enchant \ + mingw-w64-${ARCH}-gpgme \ + mingw-w64-${ARCH}-gtkspell3 \ + mingw-w64-${ARCH}-libgit2 \ + mingw-w64-${ARCH}-libsoup \ + mingw-w64-${ARCH}-lua51 +} + + +install_geany() { + log "Installing Geany (using wine)" + if [ -z "${GEANY_INSTALLER_EXECUTABLE}" -o ! -f "${GEANY_INSTALLER_EXECUTABLE}" ]; then + echo "No Geany installer found" + exit 1 + fi + mingw-w64-i686-wine ${GEANY_INSTALLER_EXECUTABLE} /S /D=${GEANY_INSTALLATION_DIR_WIN} + + # TODO the following steps are way too hacky: installing Geany from the installer is basically + # what we want for CI tests but the installed "geany.pc" file isn't really suitable + # for cross-compiling + + # add the Geany installation directory to the PKG_CONFIG_PATH + export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:${GEANY_INSTALLATION_DIR}/lib/pkgconfig/" + # patch Geany pkg-config prefix: pkg-config always prepend "/windows" to the "prefix" variable, so we + # need to add ../ to get out of the hardcoded "/windows" path element + sed -i "s%^\(prefix=\).*$%\1/..${GEANY_INSTALLATION_DIR}%" ${GEANY_INSTALLATION_DIR}/lib/pkgconfig/geany.pc + sed -i "s%^\(exec_prefix=\).*$%\1/..${GEANY_INSTALLATION_DIR}%" ${GEANY_INSTALLATION_DIR}/lib/pkgconfig/geany.pc + # we need "${exec_prefix}/bin" additionally for libgeany-0.dll which is installed into bin/ and replace -lgeany by -lgeany-0 + sed -i "s%^Libs: -L\${libdir} -lgeany$%Libs: -L\${libdir} -L\${exec_prefix}/bin -lgeany-0%" ${GEANY_INSTALLATION_DIR}/lib/pkgconfig/geany.pc +} + + +build_geany_plugins() { + cd ${GEANY_PLUGINS_BUILD_DIR} + log "Running autogen.sh" + ./autogen.sh + log "Running configure" + ./configure ${CONFIGURE_OPTIONS} + log "Running make" + make -j ${JOBS} + log "Running install-strip" + make install-strip +} + + +sign_file() { + echo "Sign file $1" + if [ -f /certificates/cert.pem ] && [ -f /certificates/key.pem ]; then + osslsigncode sign \ + -certs /certificates/cert.pem \ + -key /certificates/key.pem \ + -n "Geany-Plugins Binary" \ + -i "
https://www.geany.org/
" \ + -ts
http://zeitstempel.dfn.de/
\ + -h sha512 \ + -in ${1} \ + -out ${1}-signed + mv ${1}-signed ${1} + else + echo "Skip signing due to missing certificate" + fi +} + + +sign_geany_plugins_binaries() { + log "Signing Geany-Plugins binary files" + for binary_file_pattern in ${GEANY_PLUGINS_RELEASE_BINARY_PATTERNS[@]}; do + for binary_file in $(ls ${binary_file_pattern}); do + sign_file ${binary_file} + done + done +} + + +create_dependencies_bundle() { + log "Creating Geany-Plugins dependencies bundle" + mkdir ${DEPENDENCY_BUNDLE_DIR} + cd ${DEPENDENCY_BUNDLE_DIR} + bash ${GEANY_PLUGINS_BUILD_DIR}/build/gtk-bundle-from-msys2.sh -x -3 +} + + +create_installer() { + log "Creating NSIS installer" + makensis \ + -V3 \ + -WX \ + -DGEANY_PLUGINS_INSTALLER_NAME="${GEANY_PLUGINS_INSTALLER_FILENAME}" \ + -DGEANY_PLUGINS_RELEASE_DIR=${GEANY_PLUGINS_RELEASE_DIR} \ + -DDEPENDENCY_BUNDLE_DIR=${DEPENDENCY_BUNDLE_DIR} \ + ${GEANY_PLUGINS_BUILD_DIR}/build/geany-plugins.nsi +} + + +sign_installer() { + log "Signing NSIS installer" + sign_file ${GEANY_PLUGINS_BUILD_DIR}/build/${GEANY_PLUGINS_INSTALLER_FILENAME} +} + + +test_installer() { + log "Test NSIS installer" + # perform a silent install and check for installed files + exiftool -FileName -FileType -FileVersion -FileVersionNumber ${GEANY_PLUGINS_BUILD_DIR}/build/${GEANY_PLUGINS_INSTALLER_FILENAME} + # install Geany-Plugins + mingw-w64-i686-wine ${GEANY_PLUGINS_BUILD_DIR}/build/${GEANY_PLUGINS_INSTALLER_FILENAME} /S /D=${GEANY_PLUGINS_INSTALLATION_DIR_WIN} + # check if we have something installed + ls -l ${GEANY_PLUGINS_INSTALLATION_DIR}/uninst-plugins.exe || exit 1 + ls -l ${GEANY_PLUGINS_INSTALLATION_DIR}/lib/geany/addons.dll || exit 1 +} + + +test_uninstaller() { + log "Test NSIS uninstaller" + # uninstall Geany-Plugins and test if everything is clean + mingw-w64-i686-wine ${GEANY_PLUGINS_INSTALLATION_DIR}/uninst-plugins.exe /S + sleep 15 # it seems the uninstaller returns earlier than the files are actually removed, so wait a moment + rest=$(find ${GEANY_PLUGINS_INSTALLATION_DIR} \( -path '*share/locale' -o -path '*share/licenses' \) -prune -false -o -true -printf '%P ') + if [ "${rest}" != " share share/locale share/licenses " ]; then + # do not treat this as error, it might happen if upstream dependencies have been updated, + # the list of files to be removed needs to be updated only before releases + echo "WARNING: Uninstaller failed to uninstall the following files files: ${rest}" + fi +} + + +copy_installer_and_bundle() { + log "Copying NSIS installer and dependencies bundle" + cp ${GEANY_PLUGINS_BUILD_DIR}/build/${GEANY_PLUGINS_INSTALLER_FILENAME} ${OUTPUT_DIRECTORY} + cd ${DEPENDENCY_BUNDLE_DIR} + zip --quiet --recurse-paths ${OUTPUT_DIRECTORY}/geany_plugins_dependencies_bundle_$(date '+%Y%m%dT%H%M%S').zip * +} + + +main() { + git_clone_geany_plugins_if_necessary + + parse_geany_plugins_version + log_environment + patch_version_information + install_dependencies + install_geany + build_geany_plugins + sign_geany_plugins_binaries + + create_dependencies_bundle + create_installer + sign_installer + copy_installer_and_bundle + + test_installer + test_uninstaller + + log "Done." +} + + +main Modified: build/gtk-bundle-from-msys2.sh 1 lines changed, 0 insertions(+), 1 deletions(-) =================================================================== @@ -292,7 +292,6 @@ Following is a list of all included binary packages with their full download URL as used to create this installation. EOF echo -e "${package_urls}" >> "${filename}" - unix2dos "${filename}" } create_zip_archive() { -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany-plugins] cec202: vimode: Refactor motion-word.c so the motion commands can be reused
by Jiří Techet
08 May '23
08 May '23
Branch: refs/heads/master Author: Jiří Techet <techet(a)gmail.com> Committer: Jiří Techet <techet(a)gmail.com> Date: Fri, 10 Mar 2023 19:58:20 UTC Commit: cec20265a32d9db837914320317ae0ad9533d461
https://github.com/geany/geany-plugins/commit/cec20265a32d9db837914320317ae…
Log Message: ----------- vimode: Refactor motion-word.c so the motion commands can be reused This is a preparation for implementation of "iw", "ow", "iW" and "oW" text objects. Modified Paths: -------------- vimode/src/cmds/motion-word.c Modified: vimode/src/cmds/motion-word.c 233 lines changed, 133 insertions(+), 100 deletions(-) =================================================================== @@ -21,13 +21,6 @@ typedef gboolean (*CharacterPredicate)(gchar c); -static void get_current(ScintillaObject *sci, gchar *ch, gint *pos) -{ - *pos = SSM(sci, SCI_GETCURRENTPOS, 0, 0); - *ch = SSM(sci, SCI_GETCHARAT, *pos, 0); -} - - static void move_left(ScintillaObject *sci, gchar *ch, gint *pos) { *pos = PREV(sci, *pos); @@ -90,177 +83,217 @@ static gboolean skip_to_right(CharacterPredicate is_in_group, ScintillaObject *s } -void cmd_goto_next_word(CmdContext *c, CmdParams *p) +static gint find_next_word(ScintillaObject *sci, gint pos, gint num) { gint i; - gint len = SSM(p->sci, SCI_GETLENGTH, 0, 0); + gint len = SSM(sci, SCI_GETLENGTH, 0, 0); - for (i = 0; i < p->num; i++) + for (i = 0; i < num; i++) { - gint pos; - gchar ch; + gchar ch = SSM(sci, SCI_GETCHARAT, pos, 0); - get_current(p->sci, &ch, &pos); + if (!skip_to_right(is_wordchar, sci, &ch, &pos, len)) + skip_to_right(is_nonwordchar, sci, &ch, &pos, len); + skip_to_right(is_space, sci, &ch, &pos, len); + } + return pos; +} - if (!skip_to_right(is_wordchar, p->sci, &ch, &pos, len)) - skip_to_right(is_nonwordchar, p->sci, &ch, &pos, len); - skip_to_right(is_space, p->sci, &ch, &pos, len); - if (!is_space(ch)) - SET_POS(p->sci, pos, TRUE); - } +void cmd_goto_next_word(CmdContext *c, CmdParams *p) +{ + gint pos = SSM(p->sci, SCI_GETCURRENTPOS, 0, 0); + pos = find_next_word(p->sci, pos, p->num); + SET_POS(p->sci, pos, TRUE); } -void cmd_goto_previous_word(CmdContext *c, CmdParams *p) +static gint find_previous_word(ScintillaObject *sci, gint pos, gint num) { gint i; - for (i = 0; i < p->num; i++) + for (i = 0; i < num; i++) { - gint pos; - gchar ch; + gchar ch = SSM(sci, SCI_GETCHARAT, pos, 0); - get_current(p->sci, &ch, &pos); - move_left(p->sci, &ch, &pos); + move_left(sci, &ch, &pos); - skip_to_left(is_space, p->sci, &ch, &pos); - if (!skip_to_left(is_wordchar, p->sci, &ch, &pos)) - skip_to_left(is_nonwordchar, p->sci, &ch, &pos); + skip_to_left(is_space, sci, &ch, &pos); + if (!skip_to_left(is_wordchar, sci, &ch, &pos)) + skip_to_left(is_nonwordchar, sci, &ch, &pos); if (pos != 0 || is_space(ch)) - move_right(p->sci, &ch, &pos); - if (!is_space(ch)) - SET_POS(p->sci, pos, TRUE); + move_right(sci, &ch, &pos); } + return pos; } -void cmd_goto_next_word_end(CmdContext *c, CmdParams *p) +void cmd_goto_previous_word(CmdContext *c, CmdParams *p) +{ + gint pos = SSM(p->sci, SCI_GETCURRENTPOS, 0, 0); + pos = find_previous_word(p->sci, pos, p->num); + SET_POS(p->sci, pos, TRUE); +} + + +static gint find_next_word_end(ScintillaObject *sci, gint pos, gint num, gboolean include_last) { gint i; - gint len = SSM(p->sci, SCI_GETLENGTH, 0, 0); + gint len = SSM(sci, SCI_GETLENGTH, 0, 0); - for (i = 0; i < p->num; i++) + for (i = 0; i < num; i++) { - gint pos; - gchar ch; + gchar ch = SSM(sci, SCI_GETCHARAT, pos, 0); - get_current(p->sci, &ch, &pos); - move_right(p->sci, &ch, &pos); + move_right(sci, &ch, &pos); - skip_to_right(is_space, p->sci, &ch, &pos, len); - if (!skip_to_right(is_wordchar, p->sci, &ch, &pos, len)) - skip_to_right(is_nonwordchar, p->sci, &ch, &pos, len); + skip_to_right(is_space, sci, &ch, &pos, len); + if (!skip_to_right(is_wordchar, sci, &ch, &pos, len)) + skip_to_right(is_nonwordchar, sci, &ch, &pos, len); - if (pos < len - 1 || is_space(ch)) - move_left(p->sci, &ch, &pos); - if (!is_space(ch)) - SET_POS(p->sci, pos, TRUE); + if (!include_last) + { + if (pos < len - 1 || is_space(ch)) + move_left(sci, &ch, &pos); + } } + return pos; } -void cmd_goto_previous_word_end(CmdContext *c, CmdParams *p) +void cmd_goto_next_word_end(CmdContext *c, CmdParams *p) +{ + gint pos = SSM(p->sci, SCI_GETCURRENTPOS, 0, 0); + pos = find_next_word_end(p->sci, pos, p->num, FALSE); + SET_POS(p->sci, pos, TRUE); +} + + +static gint find_previous_word_end(ScintillaObject *sci, gint pos, gint num) { gint i; - for (i = 0; i < p->num; i++) + for (i = 0; i < num; i++) { - gint pos; - gchar ch; + gchar ch = SSM(sci, SCI_GETCHARAT, pos, 0); - get_current(p->sci, &ch, &pos); + if (!skip_to_left(is_wordchar, sci, &ch, &pos)) + skip_to_left(is_nonwordchar, sci, &ch, &pos); + skip_to_left(is_space, sci, &ch, &pos); + } + return pos; +} - if (!skip_to_left(is_wordchar, p->sci, &ch, &pos)) - skip_to_left(is_nonwordchar, p->sci, &ch, &pos); - skip_to_left(is_space, p->sci, &ch, &pos); - if (!is_space(ch)) - SET_POS(p->sci, pos, TRUE); - } +void cmd_goto_previous_word_end(CmdContext *c, CmdParams *p) +{ + gint pos = SSM(p->sci, SCI_GETCURRENTPOS, 0, 0); + pos = find_previous_word_end(p->sci, pos, p->num); + SET_POS(p->sci, pos, TRUE); } -void cmd_goto_next_word_space(CmdContext *c, CmdParams *p) +static gint find_next_word_space(ScintillaObject *sci, gint pos, gint num) { gint i; - gint len = SSM(p->sci, SCI_GETLENGTH, 0, 0); + gint len = SSM(sci, SCI_GETLENGTH, 0, 0); - for (i = 0; i < p->num; i++) + for (i = 0; i < num; i++) { - gint pos; - gchar ch; + gchar ch = SSM(sci, SCI_GETCHARAT, pos, 0); - get_current(p->sci, &ch, &pos); + skip_to_right(is_nonspace, sci, &ch, &pos, len); + skip_to_right(is_space, sci, &ch, &pos, len); + } + return pos; +} - skip_to_right(is_nonspace, p->sci, &ch, &pos, len); - skip_to_right(is_space, p->sci, &ch, &pos, len); - if (!is_space(ch)) - SET_POS(p->sci, pos, TRUE); - } +void cmd_goto_next_word_space(CmdContext *c, CmdParams *p) +{ + gint pos = SSM(p->sci, SCI_GETCURRENTPOS, 0, 0); + pos = find_next_word_space(p->sci, pos, p->num); + SET_POS(p->sci, pos, TRUE); } -void cmd_goto_previous_word_space(CmdContext *c, CmdParams *p) +static gint find_previous_word_space(ScintillaObject *sci, gint pos, gint num) { gint i; - for (i = 0; i < p->num; i++) + for (i = 0; i < num; i++) { - gint pos; - gchar ch; + gchar ch = SSM(sci, SCI_GETCHARAT, pos, 0); - get_current(p->sci, &ch, &pos); - move_left(p->sci, &ch, &pos); + move_left(sci, &ch, &pos); - skip_to_left(is_space, p->sci, &ch, &pos); - skip_to_left(is_nonspace, p->sci, &ch, &pos); + skip_to_left(is_space, sci, &ch, &pos); + skip_to_left(is_nonspace, sci, &ch, &pos); if (pos != 0 || is_space(ch)) - move_right(p->sci, &ch, &pos); - if (!is_space(ch)) - SET_POS(p->sci, pos, TRUE); + move_right(sci, &ch, &pos); } + return pos; } -void cmd_goto_next_word_end_space(CmdContext *c, CmdParams *p) +void cmd_goto_previous_word_space(CmdContext *c, CmdParams *p) +{ + gint pos = SSM(p->sci, SCI_GETCURRENTPOS, 0, 0); + pos = find_previous_word_space(p->sci, pos, p->num); + SET_POS(p->sci, pos, TRUE); +} + + +static gint find_next_word_end_space(ScintillaObject *sci, gint pos, gint num, gboolean include_last) { gint i; - gint len = SSM(p->sci, SCI_GETLENGTH, 0, 0); + gint len = SSM(sci, SCI_GETLENGTH, 0, 0); - for (i = 0; i < p->num; i++) + for (i = 0; i < num; i++) { - gint pos; - gchar ch; + gchar ch = SSM(sci, SCI_GETCHARAT, pos, 0); - get_current(p->sci, &ch, &pos); - move_right(p->sci, &ch, &pos); + move_right(sci, &ch, &pos); - skip_to_right(is_space, p->sci, &ch, &pos, len); - skip_to_right(is_nonspace, p->sci, &ch, &pos, len); + skip_to_right(is_space, sci, &ch, &pos, len); + skip_to_right(is_nonspace, sci, &ch, &pos, len); - if (pos < len - 1 || is_space(ch)) - move_left(p->sci, &ch, &pos); - if (!is_space(ch)) - SET_POS(p->sci, pos, TRUE); + if (!include_last) + { + if (pos < len - 1 || is_space(ch)) + move_left(sci, &ch, &pos); + } } + return pos; } -void cmd_goto_previous_word_end_space(CmdContext *c, CmdParams *p) +void cmd_goto_next_word_end_space(CmdContext *c, CmdParams *p) +{ + gint pos = SSM(p->sci, SCI_GETCURRENTPOS, 0, 0); + pos = find_next_word_end_space(p->sci, pos, p->num, FALSE); + SET_POS(p->sci, pos, TRUE); +} + + +static gint find_previous_word_end_space(ScintillaObject *sci, gint pos, gint num) { gint i; - for (i = 0; i < p->num; i++) + for (i = 0; i < num; i++) { - gint pos; - gchar ch; + gchar ch = SSM(sci, SCI_GETCHARAT, pos, 0); - get_current(p->sci, &ch, &pos); + skip_to_left(is_nonspace, sci, &ch, &pos); + skip_to_left(is_space, sci, &ch, &pos); + } + return pos; +} - skip_to_left(is_nonspace, p->sci, &ch, &pos); - skip_to_left(is_space, p->sci, &ch, &pos); - if (!is_space(ch)) - SET_POS(p->sci, pos, TRUE); +void cmd_goto_previous_word_end_space(CmdContext *c, CmdParams *p) +{ + gint pos = SSM(p->sci, SCI_GETCURRENTPOS, 0, 0); + pos = find_previous_word_end_space(p->sci, pos, p->num); + SET_POS(p->sci, pos, TRUE); +} } } -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany-plugins] e045c7: vimode: implement "iw", "ow", "iW" and "oW" text objects
by Jiří Techet
08 May '23
08 May '23
Branch: refs/heads/master Author: Jiří Techet <techet(a)gmail.com> Committer: Jiří Techet <techet(a)gmail.com> Date: Fri, 10 Mar 2023 20:41:52 UTC Commit: e045c740f50a278fa3a8621ac139273e5d8c26c9
https://github.com/geany/geany-plugins/commit/e045c740f50a278fa3a8621ac1392…
Log Message: ----------- vimode: implement "iw", "ow", "iW" and "oW" text objects This enables a family of word-related text object commands such as: "ciw", "diw", "viw" etc. Fixes #1155. Modified Paths: -------------- vimode/README vimode/src/cmd-runner.c vimode/src/cmds/motion-word.c vimode/src/cmds/motion-word.h vimode/src/cmds/txtobjs.c vimode/src/cmds/txtobjs.h Modified: vimode/README 4 lines changed, 4 insertions(+), 0 deletions(-) =================================================================== @@ -448,10 +448,12 @@ a new command, please do not forget to update the table below.:: v_a< a< "a <>" from '<' to the matching '>' v_a> a> same as a< v_aB aB "a Block" from "[{" to "]}" (with brackets) + v_aW aW "a WORD" (with white space) v_a[ a[ "a []" from '[' to the matching ']' v_a] a] same as a[ v_a` a` string in backticks v_ab ab "a block" from "[(" to "])" (with braces) + v_aw aw "a word" (with white space) v_a{ a{ same as aB v_a} a} same as aB v_iquote i" double quoted string without the quotes @@ -461,10 +463,12 @@ a new command, please do not forget to update the table below.:: v_i< i< "inner <>" from '<' to the matching '>' v_i> i> same as i< v_iB iB "inner Block" from "[{" and "]}" + v_iW iW "inner WORD" v_i[ i[ "inner []" from '[' to the matching ']' v_i] i] same as i[ v_i` i` string in backticks without the backticks v_ib ib "inner block" from "[(" to "])" + v_iw iw "inner word" v_i{ i{ same as iB v_i} i} same as iB Modified: vimode/src/cmd-runner.c 4 lines changed, 4 insertions(+), 0 deletions(-) =================================================================== @@ -222,6 +222,8 @@ CmdDef operator_cmds[] = { {cmd_select_less, GDK_KEY_a, GDK_KEY_greater, 0, 0, FALSE, FALSE}, \ {cmd_select_bracket, GDK_KEY_a, GDK_KEY_bracketleft, 0, 0, FALSE, FALSE}, \ {cmd_select_bracket, GDK_KEY_a, GDK_KEY_bracketright, 0, 0, FALSE, FALSE}, \ + {cmd_select_word, GDK_KEY_a, GDK_KEY_w, 0, 0, FALSE, FALSE}, \ + {cmd_select_word_space, GDK_KEY_a, GDK_KEY_W, 0, 0, FALSE, FALSE}, \ /* inner */ \ {cmd_select_quotedbl_inner, GDK_KEY_i, GDK_KEY_quotedbl, 0, 0, FALSE, FALSE}, \ {cmd_select_quoteleft_inner, GDK_KEY_i, GDK_KEY_quoteleft, 0, 0, FALSE, FALSE}, \ @@ -236,6 +238,8 @@ CmdDef operator_cmds[] = { {cmd_select_less_inner, GDK_KEY_i, GDK_KEY_greater, 0, 0, FALSE, FALSE}, \ {cmd_select_bracket_inner, GDK_KEY_i, GDK_KEY_bracketleft, 0, 0, FALSE, FALSE}, \ {cmd_select_bracket_inner, GDK_KEY_i, GDK_KEY_bracketright, 0, 0, FALSE, FALSE}, \ + {cmd_select_word_inner, GDK_KEY_i, GDK_KEY_w, 0, 0, FALSE, FALSE}, \ + {cmd_select_word_space_inner, GDK_KEY_i, GDK_KEY_W, 0, 0, FALSE, FALSE}, \ /* END */ Modified: vimode/src/cmds/motion-word.c 90 lines changed, 90 insertions(+), 0 deletions(-) =================================================================== @@ -295,5 +295,95 @@ void cmd_goto_previous_word_end_space(CmdContext *c, CmdParams *p) pos = find_previous_word_end_space(p->sci, pos, p->num); SET_POS(p->sci, pos, TRUE); } + + +void get_word_range(ScintillaObject *sci, gboolean word_space, gboolean inner, + gint pos, gint num, gint *sel_start, gint *sel_len) +{ + guint i; + gint start_pos = pos; + gint end_pos; + gchar ch = SSM(sci, SCI_GETCHARAT, pos, 0); + gchar prev_ch = SSM(sci, SCI_GETCHARAT, PREV(sci, pos), 0); + gchar next_ch = SSM(sci, SCI_GETCHARAT, NEXT(sci, pos), 0); + + if (word_space) + { + if (is_space(prev_ch) && !is_space(ch)) + ; // already there + else if (is_space(ch) && !is_space(prev_ch)) + ; // already there + else if (is_space(ch)) + start_pos = NEXT(sci, find_previous_word_end_space(sci, pos, 1)); + else if (!is_space(ch)) + start_pos = find_previous_word_space(sci, pos, 1); + + if (inner && !is_space(ch) && is_space(next_ch)) + { + num--; // already there once + pos = NEXT(sci, pos); + } + + for (i = 0; i < num; i++) + { + if (is_space(ch)) + { + if (inner) + pos = find_next_word_space(sci, pos, 1); + else + pos = find_next_word_end_space(sci, pos, 1, TRUE); + } + else if (!is_space(ch)) + { + if (inner) + pos = find_next_word_end_space(sci, pos, 1, TRUE); + else + pos = find_next_word_space(sci, pos, 1); + } + } + + end_pos = pos; } + else + { + if ((is_space(prev_ch) || is_nonwordchar(prev_ch)) && is_wordchar(ch)) + ; // already there + else if ((is_wordchar(prev_ch) || is_nonwordchar(prev_ch)) && is_space(ch)) + ; // already there + else if ((is_space(prev_ch) || is_wordchar(prev_ch)) && is_nonwordchar(ch)) + ; // already there + else if (is_space(ch) || is_nonwordchar(ch)) + start_pos = NEXT(sci, find_previous_word_end(sci, pos, 1)); + else if (is_wordchar(ch)) + start_pos = find_previous_word(sci, pos, 1); + + if (inner && (is_space(next_ch) || is_nonwordchar(next_ch)) && is_wordchar(ch)) + { + num--; // already there once + pos = NEXT(sci, pos); + } + + for (i = 0; i < num; i++) + { + if (is_space(ch) || is_nonwordchar(ch)) + { + if (inner) + pos = find_next_word(sci, pos, 1); + else + pos = find_next_word_end(sci, pos, 1, TRUE); + } + else if (is_wordchar(ch)) + { + if (inner) + pos = find_next_word_end(sci, pos, 1, TRUE); + else + pos = find_next_word(sci, pos, 1); + } + } + + end_pos = pos; + } + + *sel_start = start_pos; + *sel_len = end_pos - start_pos; } Modified: vimode/src/cmds/motion-word.h 3 lines changed, 3 insertions(+), 0 deletions(-) =================================================================== @@ -31,4 +31,7 @@ void cmd_goto_previous_word_space(CmdContext *c, CmdParams *p); void cmd_goto_next_word_end_space(CmdContext *c, CmdParams *p); void cmd_goto_previous_word_end_space(CmdContext *c, CmdParams *p); +void get_word_range(ScintillaObject *sci, gboolean word_space, gboolean inner, + gint pos, gint num, gint *sel_start, gint *sel_len); + #endif Modified: vimode/src/cmds/txtobjs.c 44 lines changed, 44 insertions(+), 0 deletions(-) =================================================================== @@ -17,6 +17,7 @@ */ #include "cmds/txtobjs.h" +#include "cmds/motion-word.h" static gint find_upper_level_brace(ScintillaObject *sci, gint pos, gint open_brace, gint close_brace) @@ -188,3 +189,46 @@ void cmd_select_bracket_inner(CmdContext *c, CmdParams *p) { select_brace(c, p, '[', ']', TRUE); } + + +static void select_word(CmdContext *c, CmdParams *p, gboolean word_space, gboolean inner) +{ + gint sel_start, sel_len; + + get_word_range(p->sci, word_space, inner, p->pos, p->num, &sel_start, &sel_len); + + if (VI_IS_VISUAL(vi_get_mode())) + { + c->sel_anchor = sel_start; + SET_POS(p->sci, sel_start + sel_len, TRUE); + } + else + { + p->sel_start = sel_start; + p->sel_len = sel_len; + } +} + + +void cmd_select_word(CmdContext *c, CmdParams *p) +{ + select_word(c, p, FALSE, FALSE); +} + + +void cmd_select_word_space(CmdContext *c, CmdParams *p) +{ + select_word(c, p, TRUE, FALSE); +} + + +void cmd_select_word_inner(CmdContext *c, CmdParams *p) +{ + select_word(c, p, FALSE, TRUE); +} + + +void cmd_select_word_space_inner(CmdContext *c, CmdParams *p) +{ + select_word(c, p, TRUE, TRUE); +} Modified: vimode/src/cmds/txtobjs.h 4 lines changed, 4 insertions(+), 0 deletions(-) =================================================================== @@ -29,6 +29,8 @@ void cmd_select_brace(CmdContext *c, CmdParams *p); void cmd_select_paren(CmdContext *c, CmdParams *p); void cmd_select_less(CmdContext *c, CmdParams *p); void cmd_select_bracket(CmdContext *c, CmdParams *p); +void cmd_select_word(CmdContext *c, CmdParams *p); +void cmd_select_word_space(CmdContext *c, CmdParams *p); void cmd_select_quotedbl_inner(CmdContext *c, CmdParams *p); void cmd_select_quoteleft_inner(CmdContext *c, CmdParams *p); @@ -37,5 +39,7 @@ void cmd_select_brace_inner(CmdContext *c, CmdParams *p); void cmd_select_paren_inner(CmdContext *c, CmdParams *p); void cmd_select_less_inner(CmdContext *c, CmdParams *p); void cmd_select_bracket_inner(CmdContext *c, CmdParams *p); +void cmd_select_word_inner(CmdContext *c, CmdParams *p); +void cmd_select_word_space_inner(CmdContext *c, CmdParams *p); #endif -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany-plugins] 9c06cc: Merge pull request #1240 from techee/vim_iw
by Jiří Techet
08 May '23
08 May '23
Branch: refs/heads/master Author: Jiří Techet <techet(a)gmail.com> Committer: GitHub <noreply(a)github.com> Date: Mon, 08 May 2023 12:24:05 UTC Commit: 9c06cc5ed79618b15673f6f0b0a4bf1df8eafce8
https://github.com/geany/geany-plugins/commit/9c06cc5ed79618b15673f6f0b0a4b…
Log Message: ----------- Merge pull request #1240 from techee/vim_iw vimode: implement "iw", "ow", "iW" and "oW" text objects Modified Paths: -------------- vimode/README vimode/src/cmd-runner.c vimode/src/cmds/motion-word.c vimode/src/cmds/motion-word.h vimode/src/cmds/txtobjs.c vimode/src/cmds/txtobjs.h Modified: vimode/README 4 lines changed, 4 insertions(+), 0 deletions(-) =================================================================== @@ -448,10 +448,12 @@ a new command, please do not forget to update the table below.:: v_a< a< "a <>" from '<' to the matching '>' v_a> a> same as a< v_aB aB "a Block" from "[{" to "]}" (with brackets) + v_aW aW "a WORD" (with white space) v_a[ a[ "a []" from '[' to the matching ']' v_a] a] same as a[ v_a` a` string in backticks v_ab ab "a block" from "[(" to "])" (with braces) + v_aw aw "a word" (with white space) v_a{ a{ same as aB v_a} a} same as aB v_iquote i" double quoted string without the quotes @@ -461,10 +463,12 @@ a new command, please do not forget to update the table below.:: v_i< i< "inner <>" from '<' to the matching '>' v_i> i> same as i< v_iB iB "inner Block" from "[{" and "]}" + v_iW iW "inner WORD" v_i[ i[ "inner []" from '[' to the matching ']' v_i] i] same as i[ v_i` i` string in backticks without the backticks v_ib ib "inner block" from "[(" to "])" + v_iw iw "inner word" v_i{ i{ same as iB v_i} i} same as iB Modified: vimode/src/cmd-runner.c 4 lines changed, 4 insertions(+), 0 deletions(-) =================================================================== @@ -222,6 +222,8 @@ CmdDef operator_cmds[] = { {cmd_select_less, GDK_KEY_a, GDK_KEY_greater, 0, 0, FALSE, FALSE}, \ {cmd_select_bracket, GDK_KEY_a, GDK_KEY_bracketleft, 0, 0, FALSE, FALSE}, \ {cmd_select_bracket, GDK_KEY_a, GDK_KEY_bracketright, 0, 0, FALSE, FALSE}, \ + {cmd_select_word, GDK_KEY_a, GDK_KEY_w, 0, 0, FALSE, FALSE}, \ + {cmd_select_word_space, GDK_KEY_a, GDK_KEY_W, 0, 0, FALSE, FALSE}, \ /* inner */ \ {cmd_select_quotedbl_inner, GDK_KEY_i, GDK_KEY_quotedbl, 0, 0, FALSE, FALSE}, \ {cmd_select_quoteleft_inner, GDK_KEY_i, GDK_KEY_quoteleft, 0, 0, FALSE, FALSE}, \ @@ -236,6 +238,8 @@ CmdDef operator_cmds[] = { {cmd_select_less_inner, GDK_KEY_i, GDK_KEY_greater, 0, 0, FALSE, FALSE}, \ {cmd_select_bracket_inner, GDK_KEY_i, GDK_KEY_bracketleft, 0, 0, FALSE, FALSE}, \ {cmd_select_bracket_inner, GDK_KEY_i, GDK_KEY_bracketright, 0, 0, FALSE, FALSE}, \ + {cmd_select_word_inner, GDK_KEY_i, GDK_KEY_w, 0, 0, FALSE, FALSE}, \ + {cmd_select_word_space_inner, GDK_KEY_i, GDK_KEY_W, 0, 0, FALSE, FALSE}, \ /* END */ Modified: vimode/src/cmds/motion-word.c 323 lines changed, 223 insertions(+), 100 deletions(-) =================================================================== @@ -21,13 +21,6 @@ typedef gboolean (*CharacterPredicate)(gchar c); -static void get_current(ScintillaObject *sci, gchar *ch, gint *pos) -{ - *pos = SSM(sci, SCI_GETCURRENTPOS, 0, 0); - *ch = SSM(sci, SCI_GETCHARAT, *pos, 0); -} - - static void move_left(ScintillaObject *sci, gchar *ch, gint *pos) { *pos = PREV(sci, *pos); @@ -90,177 +83,307 @@ static gboolean skip_to_right(CharacterPredicate is_in_group, ScintillaObject *s } -void cmd_goto_next_word(CmdContext *c, CmdParams *p) +static gint find_next_word(ScintillaObject *sci, gint pos, gint num) { gint i; - gint len = SSM(p->sci, SCI_GETLENGTH, 0, 0); + gint len = SSM(sci, SCI_GETLENGTH, 0, 0); - for (i = 0; i < p->num; i++) + for (i = 0; i < num; i++) { - gint pos; - gchar ch; + gchar ch = SSM(sci, SCI_GETCHARAT, pos, 0); - get_current(p->sci, &ch, &pos); + if (!skip_to_right(is_wordchar, sci, &ch, &pos, len)) + skip_to_right(is_nonwordchar, sci, &ch, &pos, len); + skip_to_right(is_space, sci, &ch, &pos, len); + } + return pos; +} - if (!skip_to_right(is_wordchar, p->sci, &ch, &pos, len)) - skip_to_right(is_nonwordchar, p->sci, &ch, &pos, len); - skip_to_right(is_space, p->sci, &ch, &pos, len); - if (!is_space(ch)) - SET_POS(p->sci, pos, TRUE); - } +void cmd_goto_next_word(CmdContext *c, CmdParams *p) +{ + gint pos = SSM(p->sci, SCI_GETCURRENTPOS, 0, 0); + pos = find_next_word(p->sci, pos, p->num); + SET_POS(p->sci, pos, TRUE); } -void cmd_goto_previous_word(CmdContext *c, CmdParams *p) +static gint find_previous_word(ScintillaObject *sci, gint pos, gint num) { gint i; - for (i = 0; i < p->num; i++) + for (i = 0; i < num; i++) { - gint pos; - gchar ch; + gchar ch = SSM(sci, SCI_GETCHARAT, pos, 0); - get_current(p->sci, &ch, &pos); - move_left(p->sci, &ch, &pos); + move_left(sci, &ch, &pos); - skip_to_left(is_space, p->sci, &ch, &pos); - if (!skip_to_left(is_wordchar, p->sci, &ch, &pos)) - skip_to_left(is_nonwordchar, p->sci, &ch, &pos); + skip_to_left(is_space, sci, &ch, &pos); + if (!skip_to_left(is_wordchar, sci, &ch, &pos)) + skip_to_left(is_nonwordchar, sci, &ch, &pos); if (pos != 0 || is_space(ch)) - move_right(p->sci, &ch, &pos); - if (!is_space(ch)) - SET_POS(p->sci, pos, TRUE); + move_right(sci, &ch, &pos); } + return pos; } -void cmd_goto_next_word_end(CmdContext *c, CmdParams *p) +void cmd_goto_previous_word(CmdContext *c, CmdParams *p) +{ + gint pos = SSM(p->sci, SCI_GETCURRENTPOS, 0, 0); + pos = find_previous_word(p->sci, pos, p->num); + SET_POS(p->sci, pos, TRUE); +} + + +static gint find_next_word_end(ScintillaObject *sci, gint pos, gint num, gboolean include_last) { gint i; - gint len = SSM(p->sci, SCI_GETLENGTH, 0, 0); + gint len = SSM(sci, SCI_GETLENGTH, 0, 0); - for (i = 0; i < p->num; i++) + for (i = 0; i < num; i++) { - gint pos; - gchar ch; + gchar ch = SSM(sci, SCI_GETCHARAT, pos, 0); - get_current(p->sci, &ch, &pos); - move_right(p->sci, &ch, &pos); + move_right(sci, &ch, &pos); - skip_to_right(is_space, p->sci, &ch, &pos, len); - if (!skip_to_right(is_wordchar, p->sci, &ch, &pos, len)) - skip_to_right(is_nonwordchar, p->sci, &ch, &pos, len); + skip_to_right(is_space, sci, &ch, &pos, len); + if (!skip_to_right(is_wordchar, sci, &ch, &pos, len)) + skip_to_right(is_nonwordchar, sci, &ch, &pos, len); - if (pos < len - 1 || is_space(ch)) - move_left(p->sci, &ch, &pos); - if (!is_space(ch)) - SET_POS(p->sci, pos, TRUE); + if (!include_last) + { + if (pos < len - 1 || is_space(ch)) + move_left(sci, &ch, &pos); + } } + return pos; } -void cmd_goto_previous_word_end(CmdContext *c, CmdParams *p) +void cmd_goto_next_word_end(CmdContext *c, CmdParams *p) +{ + gint pos = SSM(p->sci, SCI_GETCURRENTPOS, 0, 0); + pos = find_next_word_end(p->sci, pos, p->num, FALSE); + SET_POS(p->sci, pos, TRUE); +} + + +static gint find_previous_word_end(ScintillaObject *sci, gint pos, gint num) { gint i; - for (i = 0; i < p->num; i++) + for (i = 0; i < num; i++) { - gint pos; - gchar ch; + gchar ch = SSM(sci, SCI_GETCHARAT, pos, 0); - get_current(p->sci, &ch, &pos); + if (!skip_to_left(is_wordchar, sci, &ch, &pos)) + skip_to_left(is_nonwordchar, sci, &ch, &pos); + skip_to_left(is_space, sci, &ch, &pos); + } + return pos; +} - if (!skip_to_left(is_wordchar, p->sci, &ch, &pos)) - skip_to_left(is_nonwordchar, p->sci, &ch, &pos); - skip_to_left(is_space, p->sci, &ch, &pos); - if (!is_space(ch)) - SET_POS(p->sci, pos, TRUE); - } +void cmd_goto_previous_word_end(CmdContext *c, CmdParams *p) +{ + gint pos = SSM(p->sci, SCI_GETCURRENTPOS, 0, 0); + pos = find_previous_word_end(p->sci, pos, p->num); + SET_POS(p->sci, pos, TRUE); } -void cmd_goto_next_word_space(CmdContext *c, CmdParams *p) +static gint find_next_word_space(ScintillaObject *sci, gint pos, gint num) { gint i; - gint len = SSM(p->sci, SCI_GETLENGTH, 0, 0); + gint len = SSM(sci, SCI_GETLENGTH, 0, 0); - for (i = 0; i < p->num; i++) + for (i = 0; i < num; i++) { - gint pos; - gchar ch; + gchar ch = SSM(sci, SCI_GETCHARAT, pos, 0); - get_current(p->sci, &ch, &pos); + skip_to_right(is_nonspace, sci, &ch, &pos, len); + skip_to_right(is_space, sci, &ch, &pos, len); + } + return pos; +} - skip_to_right(is_nonspace, p->sci, &ch, &pos, len); - skip_to_right(is_space, p->sci, &ch, &pos, len); - if (!is_space(ch)) - SET_POS(p->sci, pos, TRUE); - } +void cmd_goto_next_word_space(CmdContext *c, CmdParams *p) +{ + gint pos = SSM(p->sci, SCI_GETCURRENTPOS, 0, 0); + pos = find_next_word_space(p->sci, pos, p->num); + SET_POS(p->sci, pos, TRUE); } -void cmd_goto_previous_word_space(CmdContext *c, CmdParams *p) +static gint find_previous_word_space(ScintillaObject *sci, gint pos, gint num) { gint i; - for (i = 0; i < p->num; i++) + for (i = 0; i < num; i++) { - gint pos; - gchar ch; + gchar ch = SSM(sci, SCI_GETCHARAT, pos, 0); - get_current(p->sci, &ch, &pos); - move_left(p->sci, &ch, &pos); + move_left(sci, &ch, &pos); - skip_to_left(is_space, p->sci, &ch, &pos); - skip_to_left(is_nonspace, p->sci, &ch, &pos); + skip_to_left(is_space, sci, &ch, &pos); + skip_to_left(is_nonspace, sci, &ch, &pos); if (pos != 0 || is_space(ch)) - move_right(p->sci, &ch, &pos); - if (!is_space(ch)) - SET_POS(p->sci, pos, TRUE); + move_right(sci, &ch, &pos); } + return pos; } -void cmd_goto_next_word_end_space(CmdContext *c, CmdParams *p) +void cmd_goto_previous_word_space(CmdContext *c, CmdParams *p) +{ + gint pos = SSM(p->sci, SCI_GETCURRENTPOS, 0, 0); + pos = find_previous_word_space(p->sci, pos, p->num); + SET_POS(p->sci, pos, TRUE); +} + + +static gint find_next_word_end_space(ScintillaObject *sci, gint pos, gint num, gboolean include_last) { gint i; - gint len = SSM(p->sci, SCI_GETLENGTH, 0, 0); + gint len = SSM(sci, SCI_GETLENGTH, 0, 0); - for (i = 0; i < p->num; i++) + for (i = 0; i < num; i++) { - gint pos; - gchar ch; + gchar ch = SSM(sci, SCI_GETCHARAT, pos, 0); - get_current(p->sci, &ch, &pos); - move_right(p->sci, &ch, &pos); + move_right(sci, &ch, &pos); - skip_to_right(is_space, p->sci, &ch, &pos, len); - skip_to_right(is_nonspace, p->sci, &ch, &pos, len); + skip_to_right(is_space, sci, &ch, &pos, len); + skip_to_right(is_nonspace, sci, &ch, &pos, len); - if (pos < len - 1 || is_space(ch)) - move_left(p->sci, &ch, &pos); - if (!is_space(ch)) - SET_POS(p->sci, pos, TRUE); + if (!include_last) + { + if (pos < len - 1 || is_space(ch)) + move_left(sci, &ch, &pos); + } } + return pos; } -void cmd_goto_previous_word_end_space(CmdContext *c, CmdParams *p) +void cmd_goto_next_word_end_space(CmdContext *c, CmdParams *p) +{ + gint pos = SSM(p->sci, SCI_GETCURRENTPOS, 0, 0); + pos = find_next_word_end_space(p->sci, pos, p->num, FALSE); + SET_POS(p->sci, pos, TRUE); +} + + +static gint find_previous_word_end_space(ScintillaObject *sci, gint pos, gint num) { gint i; - for (i = 0; i < p->num; i++) + for (i = 0; i < num; i++) { - gint pos; - gchar ch; + gchar ch = SSM(sci, SCI_GETCHARAT, pos, 0); - get_current(p->sci, &ch, &pos); + skip_to_left(is_nonspace, sci, &ch, &pos); + skip_to_left(is_space, sci, &ch, &pos); + } + return pos; +} - skip_to_left(is_nonspace, p->sci, &ch, &pos); - skip_to_left(is_space, p->sci, &ch, &pos); - if (!is_space(ch)) - SET_POS(p->sci, pos, TRUE); +void cmd_goto_previous_word_end_space(CmdContext *c, CmdParams *p) +{ + gint pos = SSM(p->sci, SCI_GETCURRENTPOS, 0, 0); + pos = find_previous_word_end_space(p->sci, pos, p->num); + SET_POS(p->sci, pos, TRUE); +} + + +void get_word_range(ScintillaObject *sci, gboolean word_space, gboolean inner, + gint pos, gint num, gint *sel_start, gint *sel_len) +{ + guint i; + gint start_pos = pos; + gint end_pos; + gchar ch = SSM(sci, SCI_GETCHARAT, pos, 0); + gchar prev_ch = SSM(sci, SCI_GETCHARAT, PREV(sci, pos), 0); + gchar next_ch = SSM(sci, SCI_GETCHARAT, NEXT(sci, pos), 0); + + if (word_space) + { + if (is_space(prev_ch) && !is_space(ch)) + ; // already there + else if (is_space(ch) && !is_space(prev_ch)) + ; // already there + else if (is_space(ch)) + start_pos = NEXT(sci, find_previous_word_end_space(sci, pos, 1)); + else if (!is_space(ch)) + start_pos = find_previous_word_space(sci, pos, 1); + + if (inner && !is_space(ch) && is_space(next_ch)) + { + num--; // already there once + pos = NEXT(sci, pos); + } + + for (i = 0; i < num; i++) + { + if (is_space(ch)) + { + if (inner) + pos = find_next_word_space(sci, pos, 1); + else + pos = find_next_word_end_space(sci, pos, 1, TRUE); + } + else if (!is_space(ch)) + { + if (inner) + pos = find_next_word_end_space(sci, pos, 1, TRUE); + else + pos = find_next_word_space(sci, pos, 1); + } + } + + end_pos = pos; } + else + { + if ((is_space(prev_ch) || is_nonwordchar(prev_ch)) && is_wordchar(ch)) + ; // already there + else if ((is_wordchar(prev_ch) || is_nonwordchar(prev_ch)) && is_space(ch)) + ; // already there + else if ((is_space(prev_ch) || is_wordchar(prev_ch)) && is_nonwordchar(ch)) + ; // already there + else if (is_space(ch) || is_nonwordchar(ch)) + start_pos = NEXT(sci, find_previous_word_end(sci, pos, 1)); + else if (is_wordchar(ch)) + start_pos = find_previous_word(sci, pos, 1); + + if (inner && (is_space(next_ch) || is_nonwordchar(next_ch)) && is_wordchar(ch)) + { + num--; // already there once + pos = NEXT(sci, pos); + } + + for (i = 0; i < num; i++) + { + if (is_space(ch) || is_nonwordchar(ch)) + { + if (inner) + pos = find_next_word(sci, pos, 1); + else + pos = find_next_word_end(sci, pos, 1, TRUE); + } + else if (is_wordchar(ch)) + { + if (inner) + pos = find_next_word_end(sci, pos, 1, TRUE); + else + pos = find_next_word(sci, pos, 1); + } + } + + end_pos = pos; + } + + *sel_start = start_pos; + *sel_len = end_pos - start_pos; } Modified: vimode/src/cmds/motion-word.h 3 lines changed, 3 insertions(+), 0 deletions(-) =================================================================== @@ -31,4 +31,7 @@ void cmd_goto_previous_word_space(CmdContext *c, CmdParams *p); void cmd_goto_next_word_end_space(CmdContext *c, CmdParams *p); void cmd_goto_previous_word_end_space(CmdContext *c, CmdParams *p); +void get_word_range(ScintillaObject *sci, gboolean word_space, gboolean inner, + gint pos, gint num, gint *sel_start, gint *sel_len); + #endif Modified: vimode/src/cmds/txtobjs.c 44 lines changed, 44 insertions(+), 0 deletions(-) =================================================================== @@ -17,6 +17,7 @@ */ #include "cmds/txtobjs.h" +#include "cmds/motion-word.h" static gint find_upper_level_brace(ScintillaObject *sci, gint pos, gint open_brace, gint close_brace) @@ -188,3 +189,46 @@ void cmd_select_bracket_inner(CmdContext *c, CmdParams *p) { select_brace(c, p, '[', ']', TRUE); } + + +static void select_word(CmdContext *c, CmdParams *p, gboolean word_space, gboolean inner) +{ + gint sel_start, sel_len; + + get_word_range(p->sci, word_space, inner, p->pos, p->num, &sel_start, &sel_len); + + if (VI_IS_VISUAL(vi_get_mode())) + { + c->sel_anchor = sel_start; + SET_POS(p->sci, sel_start + sel_len, TRUE); + } + else + { + p->sel_start = sel_start; + p->sel_len = sel_len; + } +} + + +void cmd_select_word(CmdContext *c, CmdParams *p) +{ + select_word(c, p, FALSE, FALSE); +} + + +void cmd_select_word_space(CmdContext *c, CmdParams *p) +{ + select_word(c, p, TRUE, FALSE); +} + + +void cmd_select_word_inner(CmdContext *c, CmdParams *p) +{ + select_word(c, p, FALSE, TRUE); +} + + +void cmd_select_word_space_inner(CmdContext *c, CmdParams *p) +{ + select_word(c, p, TRUE, TRUE); +} Modified: vimode/src/cmds/txtobjs.h 4 lines changed, 4 insertions(+), 0 deletions(-) =================================================================== @@ -29,6 +29,8 @@ void cmd_select_brace(CmdContext *c, CmdParams *p); void cmd_select_paren(CmdContext *c, CmdParams *p); void cmd_select_less(CmdContext *c, CmdParams *p); void cmd_select_bracket(CmdContext *c, CmdParams *p); +void cmd_select_word(CmdContext *c, CmdParams *p); +void cmd_select_word_space(CmdContext *c, CmdParams *p); void cmd_select_quotedbl_inner(CmdContext *c, CmdParams *p); void cmd_select_quoteleft_inner(CmdContext *c, CmdParams *p); @@ -37,5 +39,7 @@ void cmd_select_brace_inner(CmdContext *c, CmdParams *p); void cmd_select_paren_inner(CmdContext *c, CmdParams *p); void cmd_select_less_inner(CmdContext *c, CmdParams *p); void cmd_select_bracket_inner(CmdContext *c, CmdParams *p); +void cmd_select_word_inner(CmdContext *c, CmdParams *p); +void cmd_select_word_space_inner(CmdContext *c, CmdParams *p); #endif -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany-plugins] 64a68a: Merge pull request #1144 from techee/expand_remember
by Jiří Techet
07 May '23
07 May '23
Branch: refs/heads/master Author: Jiří Techet <techet(a)gmail.com> Committer: GitHub <noreply(a)github.com> Date: Sun, 07 May 2023 21:38:38 UTC Commit: 64a68aff27e9df388389ba8e0c7fb0d42be20de1
https://github.com/geany/geany-plugins/commit/64a68aff27e9df388389ba8e0c7fb…
Log Message: ----------- Merge pull request #1144 from techee/expand_remember projectorganizer: Restore tree state in the sidebar Modified Paths: -------------- projectorganizer/src/prjorg-main.c projectorganizer/src/prjorg-project.c projectorganizer/src/prjorg-project.h projectorganizer/src/prjorg-sidebar.c projectorganizer/src/prjorg-sidebar.h Modified: projectorganizer/src/prjorg-main.c 4 lines changed, 3 insertions(+), 1 deletions(-) =================================================================== @@ -130,8 +130,10 @@ static void on_project_open(G_GNUC_UNUSED GObject * obj, GKeyFile * config, { if (!prj_org) { + gchar **arr = prjorg_project_load_expanded_paths(config); + prjorg_project_open(config); - prjorg_sidebar_update(TRUE); + prjorg_sidebar_update_full(TRUE, arr); prjorg_sidebar_activate(TRUE); prjorg_menu_activate_menu_items(TRUE); } Modified: projectorganizer/src/prjorg-project.c 19 lines changed, 19 insertions(+), 0 deletions(-) =================================================================== @@ -27,6 +27,7 @@ #include "prjorg-utils.h" #include "prjorg-project.h" +#include "prjorg-sidebar.h" extern GeanyPlugin *geany_plugin; extern GeanyData *geany_data; @@ -377,6 +378,16 @@ static void update_project( } +static void save_expanded_paths(GKeyFile * key_file) +{ + gchar **expanded_paths = prjorg_sidebar_get_expanded_paths(); + + g_key_file_set_string_list(key_file, "prjorg", "expanded_paths", + (const gchar**) expanded_paths, g_strv_length(expanded_paths)); + g_strfreev(expanded_paths); +} + + void prjorg_project_save(GKeyFile * key_file) { GPtrArray *array; @@ -385,6 +396,8 @@ void prjorg_project_save(GKeyFile * key_file) if (!prj_org) return; + save_expanded_paths(key_file); + g_key_file_set_string_list(key_file, "prjorg", "source_patterns", (const gchar**) prj_org->source_patterns, g_strv_length(prj_org->source_patterns)); g_key_file_set_string_list(key_file, "prjorg", "header_patterns", @@ -478,6 +491,12 @@ void prjorg_project_remove_external_dir(const gchar *utf8_dirname) } +gchar **prjorg_project_load_expanded_paths(GKeyFile * key_file) +{ + return g_key_file_get_string_list(key_file, "prjorg", "expanded_paths", NULL, NULL); +} + + void prjorg_project_open(GKeyFile * key_file) { gchar **source_patterns, **header_patterns, **ignored_dirs_patterns, **ignored_file_patterns, **external_dirs, **dir_ptr, *last_name; Modified: projectorganizer/src/prjorg-project.h 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -52,6 +52,7 @@ typedef struct extern PrjOrg *prj_org; void prjorg_project_open(GKeyFile * key_file); +gchar **prjorg_project_load_expanded_paths(GKeyFile * key_file); GtkWidget *prjorg_project_add_properties_tab(GtkWidget *notebook); Modified: projectorganizer/src/prjorg-sidebar.c 56 lines changed, 44 insertions(+), 12 deletions(-) =================================================================== @@ -51,7 +51,8 @@ typedef enum typedef struct { GeanyProject *project; - GPtrArray *expanded_paths; + gchar **expanded_paths; + gchar *selected_path; } ExpandData; @@ -1487,24 +1488,30 @@ static gboolean expand_path(gchar *utf8_expanded_path, gboolean select) static gboolean expand_on_idle(ExpandData *expand_data) { GeanyDocument *doc = document_get_current(); + gboolean selected = FALSE; if (!prj_org) return FALSE; if (geany_data->app->project == expand_data->project && expand_data->expanded_paths) { - gchar *item; - guint i; + gchar **item; + foreach_strv(item, expand_data->expanded_paths) + expand_path(*item, FALSE); + g_strfreev(expand_data->expanded_paths); + } - foreach_ptr_array(item, i, expand_data->expanded_paths) - expand_path(item, FALSE); - g_ptr_array_free(expand_data->expanded_paths, TRUE); + if (expand_data->selected_path) + { + expand_path(expand_data->selected_path, TRUE); + g_free(expand_data->selected_path); + selected = TRUE; } g_free(expand_data); - if (!s_follow_editor || !doc || !doc->file_name) + if (selected || !s_follow_editor || !doc || !doc->file_name) return FALSE; expand_path(doc->file_name, TRUE); @@ -1547,26 +1554,45 @@ static void on_map_expanded(GtkTreeView *tree_view, GtkTreePath *tree_path, GPtr } -static GPtrArray *get_expanded_paths(void) +gchar **prjorg_sidebar_get_expanded_paths(void) { - GPtrArray *expanded_paths = g_ptr_array_new_with_free_func(g_free); + GPtrArray *expanded_paths = g_ptr_array_new(); gtk_tree_view_map_expanded_rows(GTK_TREE_VIEW(s_file_view), (GtkTreeViewMappingFunc)on_map_expanded, expanded_paths); + g_ptr_array_add(expanded_paths, NULL); - return expanded_paths; + return g_ptr_array_free(expanded_paths, FALSE); } -void prjorg_sidebar_update(gboolean reload) +static gchar *get_selected_path(void) +{ + GtkTreeSelection *treesel; + GtkTreeIter iter; + GtkTreeModel *model; + + treesel = gtk_tree_view_get_selection(GTK_TREE_VIEW(s_file_view)); + if (gtk_tree_selection_get_selected(treesel, &model, &iter)) + return build_path(&iter); + return NULL; +} + + +void prjorg_sidebar_update_full(gboolean reload, gchar **expanded_paths) { ExpandData *expand_data = g_new0(ExpandData, 1); expand_data->project = geany_data->app->project; if (reload) { - expand_data->expanded_paths = get_expanded_paths(); + GtkTreeSelection *treesel; + GtkTreeIter iter; + GtkTreeModel *model; + + expand_data->expanded_paths = expanded_paths != NULL ? expanded_paths : prjorg_sidebar_get_expanded_paths(); + expand_data->selected_path = get_selected_path(); load_project(); /* we get color information only after the sidebar is realized - @@ -1580,6 +1606,12 @@ void prjorg_sidebar_update(gboolean reload) } +void prjorg_sidebar_update(gboolean reload) +{ + prjorg_sidebar_update_full(reload, NULL); +} + + void prjorg_sidebar_find_file_in_active(void) { find_file(NULL); Modified: projectorganizer/src/prjorg-sidebar.h 3 lines changed, 3 insertions(+), 0 deletions(-) =================================================================== @@ -28,9 +28,12 @@ void prjorg_sidebar_find_file_in_active(void); void prjorg_sidebar_find_tag_in_active(void); void prjorg_sidebar_update(gboolean reload); +void prjorg_sidebar_update_full(gboolean reload, gchar **expanded_paths); void prjorg_sidebar_focus_project_tab(void); +gchar **prjorg_sidebar_get_expanded_paths(void); + void on_open_file_manager(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer user_data); void on_open_terminal(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer user_data); -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany-plugins] f822e6: projectorganizer: Use gchar** instead of GPtrArray to simplify code
by Jiří Techet
07 May '23
07 May '23
Branch: refs/heads/master Author: Jiří Techet <techet(a)gmail.com> Committer: Jiří Techet <techet(a)gmail.com> Date: Sun, 07 May 2023 21:27:13 UTC Commit: f822e69395f88a9c7df7139e2ced19d8486011ca
https://github.com/geany/geany-plugins/commit/f822e69395f88a9c7df7139e2ced1…
Log Message: ----------- projectorganizer: Use gchar** instead of GPtrArray to simplify code Modified Paths: -------------- projectorganizer/src/prjorg-main.c projectorganizer/src/prjorg-project.c projectorganizer/src/prjorg-sidebar.c projectorganizer/src/prjorg-sidebar.h Modified: projectorganizer/src/prjorg-main.c 1 lines changed, 0 insertions(+), 1 deletions(-) =================================================================== @@ -136,7 +136,6 @@ static void on_project_open(G_GNUC_UNUSED GObject * obj, GKeyFile * config, prjorg_sidebar_update_full(TRUE, arr); prjorg_sidebar_activate(TRUE); prjorg_menu_activate_menu_items(TRUE); - g_strfreev(arr); } } Modified: projectorganizer/src/prjorg-project.c 12 lines changed, 3 insertions(+), 9 deletions(-) =================================================================== @@ -380,17 +380,11 @@ static void update_project( static void save_expanded_paths(GKeyFile * key_file) { - GPtrArray *expanded_paths = prjorg_sidebar_get_expanded_paths(); - gchar **expanded_paths_v = g_new (gchar *, expanded_paths->len + 1); - guint i; + gchar **expanded_paths = prjorg_sidebar_get_expanded_paths(); - for (i = 0; i < expanded_paths->len; i++) - expanded_paths_v[i] = expanded_paths->pdata[i]; - expanded_paths_v[expanded_paths->len] = NULL; g_key_file_set_string_list(key_file, "prjorg", "expanded_paths", - (const gchar**) expanded_paths_v, g_strv_length(expanded_paths_v)); - g_free(expanded_paths_v); - g_ptr_array_free(expanded_paths, TRUE); + (const gchar**) expanded_paths, g_strv_length(expanded_paths)); + g_strfreev(expanded_paths); } Modified: projectorganizer/src/prjorg-sidebar.c 28 lines changed, 10 insertions(+), 18 deletions(-) =================================================================== @@ -51,7 +51,7 @@ typedef enum typedef struct { GeanyProject *project; - GPtrArray *expanded_paths; + gchar **expanded_paths; gchar *selected_path; } ExpandData; @@ -1496,12 +1496,10 @@ static gboolean expand_on_idle(ExpandData *expand_data) if (geany_data->app->project == expand_data->project && expand_data->expanded_paths) { - gchar *item; - guint i; - - foreach_ptr_array(item, i, expand_data->expanded_paths) - expand_path(item, FALSE); - g_ptr_array_free(expand_data->expanded_paths, TRUE); + gchar **item; + foreach_strv(item, expand_data->expanded_paths) + expand_path(*item, FALSE); + g_strfreev(expand_data->expanded_paths); } if (expand_data->selected_path) @@ -1556,14 +1554,15 @@ static void on_map_expanded(GtkTreeView *tree_view, GtkTreePath *tree_path, GPtr } -GPtrArray *prjorg_sidebar_get_expanded_paths(void) +gchar **prjorg_sidebar_get_expanded_paths(void) { - GPtrArray *expanded_paths = g_ptr_array_new_with_free_func(g_free); + GPtrArray *expanded_paths = g_ptr_array_new(); gtk_tree_view_map_expanded_rows(GTK_TREE_VIEW(s_file_view), (GtkTreeViewMappingFunc)on_map_expanded, expanded_paths); + g_ptr_array_add(expanded_paths, NULL); - return expanded_paths; + return g_ptr_array_free(expanded_paths, FALSE); } @@ -1591,15 +1590,8 @@ void prjorg_sidebar_update_full(gboolean reload, gchar **expanded_paths) GtkTreeSelection *treesel; GtkTreeIter iter; GtkTreeModel *model; - gchar **path; - GPtrArray *exp_paths_arr = g_ptr_array_new(); - - foreach_strv (path, expanded_paths) - { - g_ptr_array_add(exp_paths_arr, g_strdup(*path)); - } - expand_data->expanded_paths = expanded_paths != NULL ? exp_paths_arr : prjorg_sidebar_get_expanded_paths(); + expand_data->expanded_paths = expanded_paths != NULL ? expanded_paths : prjorg_sidebar_get_expanded_paths(); expand_data->selected_path = get_selected_path(); load_project(); Modified: projectorganizer/src/prjorg-sidebar.h 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -32,7 +32,7 @@ void prjorg_sidebar_update_full(gboolean reload, gchar **expanded_paths); void prjorg_sidebar_focus_project_tab(void); -GPtrArray *prjorg_sidebar_get_expanded_paths(void); +gchar **prjorg_sidebar_get_expanded_paths(void); void on_open_file_manager(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer user_data); void on_open_terminal(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer user_data); -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany-plugins] 6130bb: projectorganizer: Store/load expanded paths in the sidebar to project file
by Jiří Techet
07 May '23
07 May '23
Branch: refs/heads/master Author: Jiří Techet <techet(a)gmail.com> Committer: Jiří Techet <techet(a)gmail.com> Date: Sun, 07 May 2023 21:27:00 UTC Commit: 6130bbe379e645b1a142bbcb67577db25568e422
https://github.com/geany/geany-plugins/commit/6130bbe379e645b1a142bbcb67577…
Log Message: ----------- projectorganizer: Store/load expanded paths in the sidebar to project file This allows us to restore expansion points on project open. Modified Paths: -------------- projectorganizer/src/prjorg-main.c projectorganizer/src/prjorg-project.c projectorganizer/src/prjorg-project.h projectorganizer/src/prjorg-sidebar.c projectorganizer/src/prjorg-sidebar.h Modified: projectorganizer/src/prjorg-main.c 5 lines changed, 4 insertions(+), 1 deletions(-) =================================================================== @@ -130,10 +130,13 @@ static void on_project_open(G_GNUC_UNUSED GObject * obj, GKeyFile * config, { if (!prj_org) { + gchar **arr = prjorg_project_load_expanded_paths(config); + prjorg_project_open(config); - prjorg_sidebar_update(TRUE); + prjorg_sidebar_update_full(TRUE, arr); prjorg_sidebar_activate(TRUE); prjorg_menu_activate_menu_items(TRUE); + g_strfreev(arr); } } Modified: projectorganizer/src/prjorg-project.c 25 lines changed, 25 insertions(+), 0 deletions(-) =================================================================== @@ -27,6 +27,7 @@ #include "prjorg-utils.h" #include "prjorg-project.h" +#include "prjorg-sidebar.h" extern GeanyPlugin *geany_plugin; extern GeanyData *geany_data; @@ -377,6 +378,22 @@ static void update_project( } +static void save_expanded_paths(GKeyFile * key_file) +{ + GPtrArray *expanded_paths = prjorg_sidebar_get_expanded_paths(); + gchar **expanded_paths_v = g_new (gchar *, expanded_paths->len + 1); + guint i; + + for (i = 0; i < expanded_paths->len; i++) + expanded_paths_v[i] = expanded_paths->pdata[i]; + expanded_paths_v[expanded_paths->len] = NULL; + g_key_file_set_string_list(key_file, "prjorg", "expanded_paths", + (const gchar**) expanded_paths_v, g_strv_length(expanded_paths_v)); + g_free(expanded_paths_v); + g_ptr_array_free(expanded_paths, TRUE); +} + + void prjorg_project_save(GKeyFile * key_file) { GPtrArray *array; @@ -385,6 +402,8 @@ void prjorg_project_save(GKeyFile * key_file) if (!prj_org) return; + save_expanded_paths(key_file); + g_key_file_set_string_list(key_file, "prjorg", "source_patterns", (const gchar**) prj_org->source_patterns, g_strv_length(prj_org->source_patterns)); g_key_file_set_string_list(key_file, "prjorg", "header_patterns", @@ -478,6 +497,12 @@ void prjorg_project_remove_external_dir(const gchar *utf8_dirname) } +gchar **prjorg_project_load_expanded_paths(GKeyFile * key_file) +{ + return g_key_file_get_string_list(key_file, "prjorg", "expanded_paths", NULL, NULL); +} + + void prjorg_project_open(GKeyFile * key_file) { gchar **source_patterns, **header_patterns, **ignored_dirs_patterns, **ignored_file_patterns, **external_dirs, **dir_ptr, *last_name; Modified: projectorganizer/src/prjorg-project.h 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -52,6 +52,7 @@ typedef struct extern PrjOrg *prj_org; void prjorg_project_open(GKeyFile * key_file); +gchar **prjorg_project_load_expanded_paths(GKeyFile * key_file); GtkWidget *prjorg_project_add_properties_tab(GtkWidget *notebook); Modified: projectorganizer/src/prjorg-sidebar.c 19 lines changed, 16 insertions(+), 3 deletions(-) =================================================================== @@ -1556,7 +1556,7 @@ static void on_map_expanded(GtkTreeView *tree_view, GtkTreePath *tree_path, GPtr } -static GPtrArray *get_expanded_paths(void) +GPtrArray *prjorg_sidebar_get_expanded_paths(void) { GPtrArray *expanded_paths = g_ptr_array_new_with_free_func(g_free); @@ -1580,7 +1580,7 @@ static gchar *get_selected_path(void) } -void prjorg_sidebar_update(gboolean reload) +void prjorg_sidebar_update_full(gboolean reload, gchar **expanded_paths) { ExpandData *expand_data = g_new0(ExpandData, 1); @@ -1591,8 +1591,15 @@ void prjorg_sidebar_update(gboolean reload) GtkTreeSelection *treesel; GtkTreeIter iter; GtkTreeModel *model; + gchar **path; + GPtrArray *exp_paths_arr = g_ptr_array_new(); - expand_data->expanded_paths = get_expanded_paths(); + foreach_strv (path, expanded_paths) + { + g_ptr_array_add(exp_paths_arr, g_strdup(*path)); + } + + expand_data->expanded_paths = expanded_paths != NULL ? exp_paths_arr : prjorg_sidebar_get_expanded_paths(); expand_data->selected_path = get_selected_path(); load_project(); @@ -1607,6 +1614,12 @@ void prjorg_sidebar_update(gboolean reload) } +void prjorg_sidebar_update(gboolean reload) +{ + prjorg_sidebar_update_full(reload, NULL); +} + + void prjorg_sidebar_find_file_in_active(void) { find_file(NULL); Modified: projectorganizer/src/prjorg-sidebar.h 3 lines changed, 3 insertions(+), 0 deletions(-) =================================================================== @@ -28,9 +28,12 @@ void prjorg_sidebar_find_file_in_active(void); void prjorg_sidebar_find_tag_in_active(void); void prjorg_sidebar_update(gboolean reload); +void prjorg_sidebar_update_full(gboolean reload, gchar **expanded_paths); void prjorg_sidebar_focus_project_tab(void); +GPtrArray *prjorg_sidebar_get_expanded_paths(void); + void on_open_file_manager(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer user_data); void on_open_terminal(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer user_data); -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
← Newer
1
2
3
Older →
Jump to page:
1
2
3
Results per page:
10
25
50
100
200