diff --git a/.cirrus.yml b/.cirrus.yml index de20a0c9..a03dfcf4 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,6 +1,7 @@ # See: https://cirrus-ci.org/guide/quick-start/ # env: + MAKE: gmake CIRRUS_CLONE_DEPTH: 3 WITH_FEATURES: @@ -12,11 +13,17 @@ freebsd_task: image_family: freebsd-14-1 timeout_in: 20m install_script: - - pkg install -y gettext + + - pkg install -y bash gmake perl5 autoconf automake libtool pkgconf + - pkg install -y flex bison wget asciidoc + - pkg install -y gettext libiconv libarchive curl ncurses expat liblz4 lzo2 zstd +# - /usr/local/bin/curl-config --configure +# - /usr/local/bin/curl-config --cflags +# - find /usr -mount -name '*ncurses.h*' 2>/dev/null build_script: - NPROC=$(getconf _NPROCESSORS_ONLN) - ./configure ${WITH_FEATURES} - - make -j${NPROC} release + - cat acdefines.h + - gmake release clean_script: - - make release clean - + - gmake release clean diff --git a/.cvsignore b/.cvsignore index 55ff101b..a44541b7 100644 --- a/.cvsignore +++ b/.cvsignore @@ -3,6 +3,7 @@ defunct/ EXTRA/ win32/Autoupdater/ CoreUtils/ +libfltk/ acdefines.h config.sub config.guess diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml new file mode 100644 index 00000000..b0a5cb6c --- /dev/null +++ b/.github/workflows/bsd.yml @@ -0,0 +1,71 @@ +# CI-*BSD platforms +# +# References: +# https://github.com/vmactions/freebsd-vm +# https://github.com/vmactions/openbsd-vm +# https://github.com/vmactions/netbsd-vm +# + +name: "FreeOpenNetBSD builds" +on: [push, pull_request] + +#https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/control-the-concurrency-of-workflows-and-jobs +concurrency: + group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.sha || '' }} + cancel-in-progress: true + +jobs: +# freebsd: +# runs-on: ubuntu-22.04 +# steps: +# - uses: actions/checkout@v4 +# - name: FreeBSD +# uses: vmactions/freebsd-vm@v1 +# with: +# usesh: true +# prepare: | +# pkg install -y bash gmake perl5 autoconf automake libtool pkgconf flex bison wget +# pkg install -y gettext libiconv libarchive curl ncurses expat liblz4 lzo2 zstd +# run: | +# ./configure +# cat acdefines.h +# gmake release + +# Packages: see: https://cdn.openbsd.org/pub/OpenBSD/7.5/packages/amd64/ +# openbsd: +# runs-on: ubuntu-22.04 +# steps: +# - uses: actions/checkout@v4 +# - name: OpenBSD +# uses: vmactions/openbsd-vm@v1 +# with: +# usesh: true +# prepare: | +# pkg_add bash gmake libtool pkgconf bison wget curl unzip-6.0p17 +# pkg_add libiconv libarchive lz4 lzo2 zstd +# run: | +# ./configure +# cat acdefines.h +# gmake release + +# Packages: see: https://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/pkgtools/index.html + netbsd: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - name: NetBSD + uses: vmactions/netbsd-vm@v1 + with: + usesh: true + prepare: | + /usr/sbin/pkg_add -v pkgin + pkgin update + pkgin -y install perl gcc11-* + pkgin -y install bash gmake libtool pkgconf bison byacc flex wget curl unzip + pkgin -y install ncurses libiconv libarchive enchant2 file enca lzma lz4 zstd + run: | + ./configure + cat acdefines.h + gmake release + +#end diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 7bf1f581..70065a66 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -10,7 +10,6 @@ # supported CodeQL languages. # name: "CodeQL" - on: push: branches: [ master ] @@ -20,6 +19,11 @@ on: schedule: - cron: '38 8 * * 2' +#https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/control-the-concurrency-of-workflows-and-jobs +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: analyze: name: Analyze diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 00000000..dd2232d7 --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,194 @@ +name: "Linux builds" +on: [push] + +#https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/control-the-concurrency-of-workflows-and-jobs +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + name: ${{ matrix.config.name }} + runs-on: ${{ matrix.config.os }} + strategy: + fail-fast: false + matrix: + config: +# - { +# name: "Windows Latest MSVC", +# os: windows-latest, +# toolchain: vc2022, +# toollabel: vs170, +# package: win32-vs22 +# } +# - { +# name: "Windows Latest MinGW", +# os: windows-latest, +# toolchain: mingw64, +# toollabel: mingw64, +# package: win32-w64 +# } +# - { +# name: "Windows Latest OWC", +# os: windows-latest, +# toolchain: owc20, +# toollabel: owc20, +# package: win32-owc +# } + - { + name: "Ubuntu Latest GCC", + os: ubuntu-latest, + toolchain: gcc, + toollabel: gcc, + package: ubuntu-gcc + } +# - { +# name: "MacOS Latest GCC", +# os: macos-latest, +# toolchain: gcc, +# toollabel: gcc, +# package: macos-gcc +# } + + steps: + + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Snapshot Source + if: startsWith(matrix.config.name, 'Ubuntu Latest') + shell: bash + run: | + mkdir .snapshot + tar --exclude-vcs --exclude='./.snapshot' --exclude='./win32' --exclude='./contrib' --exclude='./support/*.bat' --exclude='./defunct' -cf .snapshot/source-snapshot.tar . + tar --exclude-vcs -cf .snapshot/contrib-snapshot.tar ./contrib + + - name: Source Snapshot Publish + if: startsWith(matrix.config.name, 'Ubuntu Latest') + uses: actions/upload-artifact@v4 + with: + name: source-snapshot + path: .snapshot/source-snapshot.tar + compression-level: 9 + + - name: Contrib Snapshot Publish + if: startsWith(matrix.config.name, 'Ubuntu Latest') + uses: actions/upload-artifact@v4 + with: + name: contrib-snapshot + path: .snapshot/contrib-snapshot.tar + compression-level: 9 + + - name: Checkout submodules + run: | + git submodule update --init --recursive + + - name: MSVC setup + uses: ilammy/msvc-dev-cmd@v1 + if: startsWith(matrix.config.name, 'Windows Latest MSVC') + with: + arch: x86 + + - name: MinGW64 setup + if: startsWith(matrix.config.name, 'Windows Latest MinGW') + shell: cmd + run: | + c:\msys64\usr\bin\pacman --noconfirm -S base-devel + c:\msys64\usr\bin\pacman --noconfirm -S mingw-w64-x86_64-gcc + c:\msys64\usr\bin\pacman --noconfirm -S mingw-w64-i686-gcc + + - name: OpenWatcom setup + uses: open-watcom/setup-watcom@v0 + if: startsWith(matrix.config.name, 'Windows Latest OWC') + with: + version: "2.0" + location: "C:\\Watcom" + + - name: Ubuntu, setup + if: startsWith(matrix.config.name, 'Ubuntu Latest') + shell: bash + run: | + sudo apt-get install -y libncurses-dev + sudo apt-get install -y libncursesw5-dev + sudo apt-get install -y libenchant-2-dev + sudo apt-get install -y libaspell-dev + sudo apt-get install -y libhunspell-dev + sudo apt-get install -y libenca-dev + sudo apt-get install -y libguess-dev + sudo apt-get install -y libexplain-dev + sudo apt-get install -y libarchive-dev + + - name: MacOS, setup + if: startsWith(matrix.config.name, 'MacOS Latest') + shell: bash + run: | + brew install pkg-config + brew install ncurses + brew link ncurses + brew install enchant + brew install libspelling + brew install hunspell + brew install libarchive + brew install wget + + - name: Windows, generate + if: startsWith(matrix.config.name, 'Windows Latest') + shell: cmd + run: | + @if "${{ matrix.config.toolchain }}"=="mingw32" set PATH=c:\msys64\mingw32\bin;%PATH% + @if "${{ matrix.config.toolchain }}"=="mingw64" set PATH=c:\msys64\mingw64\bin;%PATH% + @if "${{ matrix.config.toolchain }}"=="owc20" call .\support\owc20setenv.bat C:\Watcom + @if NOT "${{ matrix.config.toolchain }}"=="mingw64" c:\msys64\usr\bin\pacman --noconfirm -S bison + @set PERL=c:/Strawberry/perl/bin/perl + c:/Strawberry/perl/bin/perl makelib.pl --perlpath=c:/Strawberry/perl/bin --busybox=./win32/busybox --wget=./win32/wget --bison=c:/msys64/usr/bin/bison --flex=./bin.${{ matrix.config.toollabel }}/release/flex "${{ matrix.config.toolchain }}" + + - name: Windows, compile + if: startsWith(matrix.config.name, 'Windows Latest') + shell: cmd + run: | + @if "${{ matrix.config.toolchain }}"=="mingw32" set PATH=c:\msys64\mingw32\bin;%PATH% + @if "${{ matrix.config.toolchain }}"=="mingw64" set PATH=c:\msys64\mingw64\bin;%PATH% + @if "${{ matrix.config.toolchain }}"=="owc20" call .\support\owc20setenv.bat C:\Watcom + @set PERL=c:/Strawberry/perl/bin/perl + .\win32\gmake-42 release contrib + .\win32\gmake-42 release + + - name: Ubuntu, generate + if: startsWith(matrix.config.name, 'Ubuntu Latest') + shell: bash + run: | + chmod +x configure + ./support/config_withncurses + + - name: Ubuntu, compile + if: startsWith(matrix.config.name, 'Ubuntu Latest') + shell: bash + run: | + make release + + - name: MacOS, generate + if: startsWith(matrix.config.name, 'MacOS Latest') + shell: bash + run: | + export CPATH=$(brew --prefix libarchive)/include:/usr/local/include:$CPATH + export CPPPATH=$(brew --prefix libarchive)/include:/usr/local/include:$CPATH + export LIBRARY_PATH=$(brew --prefix libarchive)/lib:/usr/local/lib:$LIBRARY_PATH + export LD_LIBRARY_PATH=$(brew --prefix libarchive)/lib:/usr/local/lib:$LD_LIBRARY_PATH + chmod +x configure + ./support/config_withncurses + + - name: MacOS, compile + if: startsWith(matrix.config.name, 'MacOS Latest') + shell: bash + run: | + export CPATH=$(brew --prefix libarchive)/include:/usr/local/include:$CPATH + export CPPPATH=$(brew --prefix libarchive)/include:/usr/local/include:$CPATH + export LIBRARY_PATH=$(brew --prefix libarchive)/lib:/usr/local/lib:$LIBRARY_PATH + export LD_LIBRARY_PATH=$(brew --prefix libarchive)/lib:/usr/local/lib:$LD_LIBRARY_PATH + make release + + - name: Package + uses: actions/upload-artifact@v4 + with: + name: package-${{ matrix.config.package }} + path: ./bin.${{ matrix.config.toollabel }}/release/* diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 00000000..8b0b3bd4 --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,194 @@ +name: "MacOS builds" +on: [push] + +#https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/control-the-concurrency-of-workflows-and-jobs +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + name: ${{ matrix.config.name }} + runs-on: ${{ matrix.config.os }} + strategy: + fail-fast: false + matrix: + config: +# - { +# name: "Windows Latest MSVC", +# os: windows-latest, +# toolchain: vc2022, +# toollabel: vs170, +# package: win32-vs22 +# } +# - { +# name: "Windows Latest MinGW", +# os: windows-latest, +# toolchain: mingw64, +# toollabel: mingw64, +# package: win32-w64 +# } +# - { +# name: "Windows Latest OWC", +# os: windows-latest, +# toolchain: owc20, +# toollabel: owc20, +# package: win32-owc +# } +# - { +# name: "Ubuntu Latest GCC", +# os: ubuntu-latest, +# toolchain: gcc, +# toollabel: gcc, +# package: ubuntu-gcc +# } + - { + name: "MacOS Latest GCC", + os: macos-latest, + toolchain: gcc, + toollabel: gcc, + package: macos-gcc + } + + steps: + + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Snapshot Source + if: startsWith(matrix.config.name, 'Ubuntu Latest') + shell: bash + run: | + mkdir .snapshot + tar --exclude-vcs --exclude='./.snapshot' --exclude='./win32' --exclude='./contrib' --exclude='./support/*.bat' --exclude='./defunct' -cf .snapshot/source-snapshot.tar . + tar --exclude-vcs -cf .snapshot/contrib-snapshot.tar ./contrib + + - name: Source Snapshot Publish + if: startsWith(matrix.config.name, 'Ubuntu Latest') + uses: actions/upload-artifact@v4 + with: + name: source-snapshot + path: .snapshot/source-snapshot.tar + compression-level: 9 + + - name: Contrib Snapshot Publish + if: startsWith(matrix.config.name, 'Ubuntu Latest') + uses: actions/upload-artifact@v4 + with: + name: contrib-snapshot + path: .snapshot/contrib-snapshot.tar + compression-level: 9 + + - name: Checkout submodules + run: | + git submodule update --init --recursive + + - name: MSVC setup + uses: ilammy/msvc-dev-cmd@v1 + if: startsWith(matrix.config.name, 'Windows Latest MSVC') + with: + arch: x86 + + - name: MinGW64 setup + if: startsWith(matrix.config.name, 'Windows Latest MinGW') + shell: cmd + run: | + c:\msys64\usr\bin\pacman --noconfirm -S base-devel + c:\msys64\usr\bin\pacman --noconfirm -S mingw-w64-x86_64-gcc + c:\msys64\usr\bin\pacman --noconfirm -S mingw-w64-i686-gcc + + - name: OpenWatcom setup + uses: open-watcom/setup-watcom@v0 + if: startsWith(matrix.config.name, 'Windows Latest OWC') + with: + version: "2.0" + location: "C:\\Watcom" + + - name: Ubuntu, setup + if: startsWith(matrix.config.name, 'Ubuntu Latest') + shell: bash + run: | + sudo apt-get install -y libncurses-dev + sudo apt-get install -y libncursesw5-dev + sudo apt-get install -y libenchant-2-dev + sudo apt-get install -y libaspell-dev + sudo apt-get install -y libhunspell-dev + sudo apt-get install -y libenca-dev + sudo apt-get install -y libguess-dev + sudo apt-get install -y libexplain-dev + sudo apt-get install -y libarchive-dev + + - name: MacOS, setup + if: startsWith(matrix.config.name, 'MacOS Latest') + shell: bash + run: | + brew install pkg-config + brew install ncurses + brew link ncurses + brew install enchant + brew install libspelling + brew install hunspell + brew install libarchive + brew install wget + + - name: Windows, generate + if: startsWith(matrix.config.name, 'Windows Latest') + shell: cmd + run: | + @if "${{ matrix.config.toolchain }}"=="mingw32" set PATH=c:\msys64\mingw32\bin;%PATH% + @if "${{ matrix.config.toolchain }}"=="mingw64" set PATH=c:\msys64\mingw64\bin;%PATH% + @if "${{ matrix.config.toolchain }}"=="owc20" call .\support\owc20setenv.bat C:\Watcom + @if NOT "${{ matrix.config.toolchain }}"=="mingw64" c:\msys64\usr\bin\pacman --noconfirm -S bison + @set PERL=c:/Strawberry/perl/bin/perl + c:/Strawberry/perl/bin/perl makelib.pl --perlpath=c:/Strawberry/perl/bin --busybox=./win32/busybox --wget=./win32/wget --bison=c:/msys64/usr/bin/bison --flex=./bin.${{ matrix.config.toollabel }}/release/flex "${{ matrix.config.toolchain }}" + + - name: Windows, compile + if: startsWith(matrix.config.name, 'Windows Latest') + shell: cmd + run: | + @if "${{ matrix.config.toolchain }}"=="mingw32" set PATH=c:\msys64\mingw32\bin;%PATH% + @if "${{ matrix.config.toolchain }}"=="mingw64" set PATH=c:\msys64\mingw64\bin;%PATH% + @if "${{ matrix.config.toolchain }}"=="owc20" call .\support\owc20setenv.bat C:\Watcom + @set PERL=c:/Strawberry/perl/bin/perl + .\win32\gmake-42 release contrib + .\win32\gmake-42 release + + - name: Ubuntu, generate + if: startsWith(matrix.config.name, 'Ubuntu Latest') + shell: bash + run: | + chmod +x configure + ./support/config_withncurses + + - name: Ubuntu, compile + if: startsWith(matrix.config.name, 'Ubuntu Latest') + shell: bash + run: | + make release + + - name: MacOS, generate + if: startsWith(matrix.config.name, 'MacOS Latest') + shell: bash + run: | + export CPATH=$(brew --prefix libarchive)/include:/usr/local/include:$CPATH + export CPPPATH=$(brew --prefix libarchive)/include:/usr/local/include:$CPATH + export LIBRARY_PATH=$(brew --prefix libarchive)/lib:/usr/local/lib:$LIBRARY_PATH + export LD_LIBRARY_PATH=$(brew --prefix libarchive)/lib:/usr/local/lib:$LD_LIBRARY_PATH + chmod +x configure + ./support/config_withncurses + + - name: MacOS, compile + if: startsWith(matrix.config.name, 'MacOS Latest') + shell: bash + run: | + export CPATH=$(brew --prefix libarchive)/include:/usr/local/include:$CPATH + export CPPPATH=$(brew --prefix libarchive)/include:/usr/local/include:$CPATH + export LIBRARY_PATH=$(brew --prefix libarchive)/lib:/usr/local/lib:$LIBRARY_PATH + export LD_LIBRARY_PATH=$(brew --prefix libarchive)/lib:/usr/local/lib:$LD_LIBRARY_PATH + make release + + - name: Package + uses: actions/upload-artifact@v4 + with: + name: package-${{ matrix.config.package }} + path: ./bin.${{ matrix.config.toollabel }}/release/* diff --git a/.github/workflows/solaris.yml b/.github/workflows/solaris.yml new file mode 100644 index 00000000..50900ff2 --- /dev/null +++ b/.github/workflows/solaris.yml @@ -0,0 +1,62 @@ +name: "Solaris builds" +on: [push] + +#https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/control-the-concurrency-of-workflows-and-jobs +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Solaris 11.4 + uses: vmactions/solaris-vm@v1.0.2 + with: + usesh: true + mem: 6144 + prepare: | + export LC_ALL=C + export LANG=C + pkg publisher solaris + beadm list + pkg info entire + pkg list -af entire + echo ===== Installed packages + pkg list '*' + echo ===== Available developer/library packages + pkg list -a 'developer/*' + pkg list -a 'library/*' + echo ===== Packages requirements + pkg install -v system/locale system/header + pkg install -v --accept \ + developer/gcc-7@7.3.0-11.4.0.0.1.14.0 \ + developer/build/gnu-make \ + developer/build/make \ + developer/build/autoconf \ + developer/build/autoconf \ + developer/build/libtool \ + developer/build/pkg-config \ + developer/lexer/flex \ + developer/parser/bison \ + library/ncurses + + run: | + export LC_ALL=C + export LANG=C + uname -a + whoami + pwd + cat /etc/release + export PATH=/opt/csw/bin:$PATH:/usr/sfw/bin + export CFLAGS="-std=gnu11 -D_XOPEN_SOURCE=500 -D__EXTENSIONS__=1" + ./configure --prefix=/usr + gmake release build + +## References: +## https://github.com/oracle/solaris-userland/blob/master/make-rules/shared-macros.mk +## https://docs.oracle.com/cd/E86824_01/html/E54772/intro-3.html#REFMAN3Fintro-3 +## +## "-std=gnu11 -D_XOPEN_SOURCE=500 -D__EXTENSIONS__=1" +## diff --git a/.github/workflows/build.yml b/.github/workflows/windows.yml similarity index 91% rename from .github/workflows/build.yml rename to .github/workflows/windows.yml index 8ddbc27c..d1f1f4e0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/windows.yml @@ -1,5 +1,11 @@ -name: build +name: "Windows builds" on: [push] + +#https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/control-the-concurrency-of-workflows-and-jobs +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: build: name: ${{ matrix.config.name }} @@ -29,20 +35,20 @@ jobs: toollabel: owc20, package: win32-owc } - - { - name: "Ubuntu Latest GCC", - os: ubuntu-latest, - toolchain: gcc, - toollabel: gcc, - package: ubuntu-gcc - } - - { - name: "MacOS Latest GCC", - os: macos-latest, - toolchain: gcc, - toollabel: gcc, - package: macos-gcc - } +# - { +# name: "Ubuntu Latest GCC", +# os: ubuntu-latest, +# toolchain: gcc, +# toollabel: gcc, +# package: ubuntu-gcc +# } +# - { +# name: "MacOS Latest GCC", +# os: macos-latest, +# toolchain: gcc, +# toollabel: gcc, +# package: macos-gcc +# } steps: diff --git a/.gitignore b/.gitignore index ee20b3ef..656c89b4 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ defunct/ contrib/include/ win32/Autoupdater/ EXTRA/ +libfltk/ bin bin.*/ lib.*/ diff --git a/Changes b/Changes index 82ff8e9e..69951eb5 100644 --- a/Changes +++ b/Changes @@ -1,9 +1,53 @@ -*- encoding: utf-8; -*- - * BUILD 24, version: 3.2.3 +Mon Sep 9 00:10:31 2024 adamy + + * Tickets + + - grunch crash, on an invalid switch case; #83 + - portability improvements; non Linux/WIN32 builds; #78 + - dark/light background detection; #76 + - directory open; prompt file(s) to open; #73 + - oniguruma upgrade; #67 + - binutils, backward lib; #61 + - configure enhancements; #60 + - bison/flex option; #59 + + * Keyboard/interface extensions + + - mouse + - command line option (xterm, xterm2 and sgr). + - key events cleanup. + - mouse actions + - popup menu + + - key event. + - FocusIn/FosusOut events. + - key_trace macro. + + * CI Pipelines + + - Solaris + - FreeBSD/OpenBSD and NetBSD + +Sun Jun 16 12:09:22 2024 adamy + + * configure upgrades + + * libtrie-3.9.9 + + * libtre-0.8.1 + + * FLTK-1.3.9 import; experimental only + +Sun Jun 16 12:09:22 2024 adamy + + * BUILD 26, maintenance release, version: 3.2.3 Tue May 28 19:08:00 2024 adamy + * BUILD 25, version: 3.2.3 + * configure upgrades * documentation/install diff --git a/INSTALL.md b/INSTALL.md index 7ae7dcf4..ab5090de 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -19,12 +19,13 @@ The following environments and toolchains are supported. * Not recently tested, yet builds. * OS/X 10.4+ + * Solaris (gcc) + * FreeBSD 14.1 (gcc) * Not recently tested, yet *should* build; with minimal effort. + * NetBSD/OpenBSD (gcc) * HP/UX (gcc) - * Solaris (gcc) - * BSD Net/Free/Open (gcc) * AIX (gcc) * Defunct yet previously supported; development effort assumed. @@ -271,4 +272,4 @@ Note: *Some* of this information is obsolete yet should be hints to resolve term Last updated: _May/24_ --end- \ No newline at end of file +-end- diff --git a/Makefile.in b/Makefile.in index 35aae165..fbed78b2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,5 +1,5 @@ # -*- mode: mak; -*- -# $Id: Makefile.in,v 1.73 2024/05/27 12:56:36 cvsuser Exp $ +# $Id: Makefile.in,v 1.74 2024/06/14 16:40:51 cvsuser Exp $ # GRIEF - top level makefile. # # Copyright (c) 1998 - 2024, Adam Young. @@ -239,6 +239,7 @@ CXX= @CXX@ AR= @AR@ RANLIB= @RANLIB@ RM= @RM@ +MKDIR_P= @MKDIR_P@ RMDIR= @RMDIR@ CP= @CP@ RC= @RC@ @@ -409,7 +410,7 @@ directories: $(DIRECTORIES) artifacts: buildinfo %/.created: - -@$(PERL) ./win32/mkdir_p.pl $(@D) + -@$(MKDIR_P) $(@D) @echo "++ do not delete, managed content ++" > $@ .PHONY: import @@ -418,12 +419,12 @@ import: $(IMPORT) BUSYBOXEXE= $(addsuffix .exe, $(basename $(BUSYBOX))) $(D_BIN)/grbusybox.exe: $(BUSYBOXEXE) @echo importing $(BUSYBOXEXE) - @$(CP) -f $^ $@ + @$(CP) $^ $@ ifeq ("wcl386","$(CC)") $(D_BIN)/$(CLBRNAME).dll: $(LIBCLBRPATH) @echo importing $(LIBCLBRPATH) - @$(CP) -f $(subst /,\,$^) $@ + @$(CP) $(subst /,\,$^) $@ $(D_BIN)/$(MT7RNAME).dll: $(LIBMT7RPATH) @echo importing $(LIBMT7RPATH) diff --git a/README.md b/README.md index ff9aea64..4f280e23 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,12 @@ [![Website](https://img.shields.io/badge/View-Website-blue)](https://sourceforge.net/projects/grief/) -[![GitHub release](https://img.shields.io/github/release/Naereen/StrapDown.js.svg)](https://GitHub.com/adamyg/grief/releases/) -[![Workflow](https://github.com/adamyg/grief/actions/workflows/build.yml/badge.svg)](https://github.com/adamyg/grief/actions) + +[![GitHub release](https://img.shields.io/github/release/Naereen/StrapDown.js.svg)](https://gitHub.com/adamyg/grief/releases/) + +[![GitHub Windows](https://github.com/adamyg/grief/actions/workflows/windows.yml/badge.svg)](https://github.com/adamyg/grief/actions/workflows/windows.yml) +[![Linux](https://github.com/adamyg/grief/actions/workflows/linux.yml/badge.svg)](https://github.com/adamyg/grief/actions/workflows/linux.yml) +[![MacOS](https://github.com/adamyg/grief/actions/workflows/macos.yml/badge.svg)](https://github.com/adamyg/grief/actions/workflows/macos.yml) +[![Solaris](https://github.com/adamyg/grief/actions/workflows/solaris.yml/badge.svg)](https://github.com/adamyg/grief/actions/workflows/linux.yml) +[![BSD](https://github.com/adamyg/grief/actions/workflows/bsd.yml/badge.svg)](https://github.com/adamyg/grief/actions/workflows/bsd.yml) [![Build status](https://ci.appveyor.com/api/projects/status/3tx1vwwclydfp1t6?svg=true&passingText=Ubuntu%20Passing&failingText=Ubuntu%20Failing&pendingText=Ubuntu%20Pending)](https://ci.appveyor.com/project/adamyg/grief-ubuntu) [![Build status](https://ci.appveyor.com/api/projects/status/k63ggto1v8t1c28d?svg=true&passingText=MacOS%20Passing&failingText=MacOS%20Failing&pendingText=MacOS%20Pending)](https://ci.appveyor.com/project/adamyg/grief-macos) @@ -8,6 +14,8 @@ [![Build status](https://ci.appveyor.com/api/projects/status/3h8sweuo36r8q28t?svg=true&passingText=Cygwin32%20Passing&failingText=Cygwin32%20Failing&pendingText=Cygwin32%20Pending)](https://ci.appveyor.com/project/adamyg/grief-cygwin32) [![Build status](https://ci.appveyor.com/api/projects/status/8jk4qx55d4bql3l1?svg=true&passingText=MinGW32%20Passing&failingText=MinGW32%20Failing&pendingText=MinGW32%20Pending)](https://ci.appveyor.com/project/adamyg/grief-mingw) +[![Cirrus FreBSD](https://api.cirrus-ci.com/github/adamyg/grief.svg)](https://cirrus-ci.com/github/adamyg/grief) + # GRIEF - BRIEF clone ## Introduction: diff --git a/auto/aclocal.m4 b/auto/aclocal.m4 index 1c013c09..8a2954bc 100644 --- a/auto/aclocal.m4 +++ b/auto/aclocal.m4 @@ -1,10 +1,55 @@ -# $Id: aclocal.m4,v 1.19 2024/05/02 14:34:12 cvsuser Exp $ +# $Id: aclocal.m4,v 1.21 2024/07/12 18:22:36 cvsuser Exp $ # -*- mode: Autoconf; tabs: 8; -*- # local packages # +### + +m4_include([cf/CF_ADD_CFLAGS]) +m4_include([cf/CF_ADD_LIBS]) + +m4_include([cf/CF_FUNC_MEMMOVE]) +m4_include([cf/CF_FUNC_VASPRINTF]) +m4_include([cf/CF_FUNC_NANOSLEEP]) + +m4_include([cf/CF_C_INLINE]) +m4_include([cf/CF_C11_NORETURN]) +m4_include([cf/CF_VA_COPY]) + +m4_include([cf/CF_CLANG_COMPILER]) +m4_include([cf/CF_INTEL_COMPILER]) + +m4_include([cf/CF_GCC_ATTRIBUTES]) +m4_include([cf/CF_GCC_VERSION]) +m4_include([cf/CF_GCC_WARNINGS]) +m4_include([cf/CF_GNU_SOURCE]) + +m4_include([cf/CF_LARGEFILE]) +m4_include([cf/CF_TYPE_SIGACTION]) +m4_include([cf/CF_MIXEDCASE_FILENAMES]) +m4_include([cf/CF_PATHSEP]) + +m4_include([cf/CF_APPEND_TEXT]) +m4_include([cf/CF_ARG_DISABLE]) +m4_include([cf/CF_ARG_ENABLE]) +m4_include([cf/CF_ARG_OPTION]) +m4_include([cf/CF_ARG_WITH]) +m4_include([cf/CF_CONST_X_STRING]) +m4_include([cf/CF_MSG_LOG]) +m4_include([cf/CF_REMOVE_CFLAGS]) +m4_include([cf/CF_REMOVE_DEFINE]) +m4_include([cf/CF_REMOVE_LIB]) +m4_include([cf/CF_RESTORE_XTRA_FLAGS]) +m4_include([cf/CF_SAVE_XTRA_FLAGS]) +m4_include([cf/CF_UPPER]) +m4_include([cf/CF_VERBOSE]) + +### + m4_include([m4/environ.m4]) m4_include([m4/acx_nanosleep.m4]) +m4_include([m4/ax_compiler_vendor.m4]) +m4_include([m4/ax_compiler_version.m4]) m4_include([m4/ax_check_compile_flag.m4]) m4_include([m4/ax_check_link_flag.m4]) m4_include([m4/ax_check_openssl.m4]) @@ -39,5 +84,6 @@ m4_include([m4/longlong.m4]) m4_include([m4/ssize_t.m4]) m4_include([m4/string.m4]) m4_include([m4/misc.m4]) +m4_include([m4/iswin32.m4]) # diff --git a/auto/aclocal.sh b/auto/aclocal.sh index 9fb7f376..f68d6574 100644 --- a/auto/aclocal.sh +++ b/auto/aclocal.sh @@ -2,4 +2,4 @@ # # rebuild aclocal.m4 # -aclocal -I m4 --install --verbose >aclocal.out 2>&1 \ No newline at end of file +aclocal -I cf -I m4 --install --verbose >aclocal.out 2>&1 diff --git a/auto/cf/CF_ADD_CFLAGS b/auto/cf/CF_ADD_CFLAGS new file mode 100644 index 00000000..e6f350ea --- /dev/null +++ b/auto/cf/CF_ADD_CFLAGS @@ -0,0 +1,88 @@ +dnl CF_ADD_CFLAGS version: 15 updated: 2020/12/31 10:54:15 +dnl ------------- +dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS +dnl $1 = flags to add +dnl $2 = if given makes this macro verbose. +dnl +dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS, +dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily +dnl confused by the quotes (which require backslashes to keep them usable). +AC_DEFUN([CF_ADD_CFLAGS], +[ +cf_fix_cppflags=no +cf_new_cflags= +cf_new_cppflags= +cf_new_extra_cppflags= + +for cf_add_cflags in $1 +do +case "$cf_fix_cppflags" in +(no) + case "$cf_add_cflags" in + (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) + case "$cf_add_cflags" in + (-D*) + cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'` + + test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ + && test -z "${cf_tst_cflags}" \ + && cf_fix_cppflags=yes + + if test "$cf_fix_cppflags" = yes ; then + CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags) + continue + elif test "${cf_tst_cflags}" = "\"'" ; then + CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags) + continue + fi + ;; + esac + case "$CPPFLAGS" in + (*$cf_add_cflags) + ;; + (*) + case "$cf_add_cflags" in + (-D*) + cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'` + CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags) + ;; + esac + CF_APPEND_TEXT(cf_new_cppflags,$cf_add_cflags) + ;; + esac + ;; + (*) + CF_APPEND_TEXT(cf_new_cflags,$cf_add_cflags) + ;; + esac + ;; +(yes) + CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags) + + cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[[^"]]*"'\''//'` + + test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ + && test -z "${cf_tst_cflags}" \ + && cf_fix_cppflags=no + ;; +esac +done + +if test -n "$cf_new_cflags" ; then + ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)]) + CF_APPEND_TEXT(CFLAGS,$cf_new_cflags) +fi + +if test -n "$cf_new_cppflags" ; then + ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)]) + CF_APPEND_TEXT(CPPFLAGS,$cf_new_cppflags) +fi + +if test -n "$cf_new_extra_cppflags" ; then + ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)]) + CF_APPEND_TEXT(EXTRA_CPPFLAGS,$cf_new_extra_cppflags) +fi + +AC_SUBST(EXTRA_CPPFLAGS) + +])dnl diff --git a/auto/cf/CF_ADD_CXXFLAGS b/auto/cf/CF_ADD_CXXFLAGS new file mode 100644 index 00000000..1586982b --- /dev/null +++ b/auto/cf/CF_ADD_CXXFLAGS @@ -0,0 +1,16 @@ +dnl CF_ADD_CXXFLAGS version: 1 updated: 2020/04/04 16:16:13 +dnl --------------- +dnl Copy non-preprocessor flags to $CXXFLAGS, preprocessor flags to $CPPFLAGS +dnl The second parameter if given makes this macro verbose. +dnl +dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS, +dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily +dnl confused by the quotes (which require backslashes to keep them usable). +AC_DEFUN([CF_ADD_CXXFLAGS], +[ +cf_save_CXXFLAGS="$CFLAGS" +CFLAGS="$CXXFLAGS" +CF_ADD_CFLAGS($1 ifelse($2,,,[,$2])) +CXXFLAGS="$CFLAGS" +CFLAGS="$cf_save_CXXFLAGS" +])dnl diff --git a/auto/cf/CF_ADD_LIBS b/auto/cf/CF_ADD_LIBS new file mode 100644 index 00000000..7907fc49 --- /dev/null +++ b/auto/cf/CF_ADD_LIBS @@ -0,0 +1,25 @@ +dnl CF_ADD_LIBS version: 3 updated: 2019/11/02 16:47:33 +dnl ----------- +dnl Add one or more libraries, used to enforce consistency. Libraries are +dnl prepended to an existing list, since their dependencies are assumed to +dnl already exist in the list. +dnl +dnl $1 = libraries to add, with the "-l", etc. +dnl $2 = variable to update (default $LIBS) +AC_DEFUN([CF_ADD_LIBS],[ +cf_add_libs="[$]ifelse($2,,LIBS,[$2])" +# reverse order +cf_add_0lib= +for cf_add_1lib in $1; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done +# filter duplicates +for cf_add_1lib in $cf_add_0lib; do + for cf_add_2lib in $cf_add_libs; do + if test "x$cf_add_1lib" = "x$cf_add_2lib"; then + cf_add_1lib= + break + fi + done + test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs" +done +ifelse($2,,LIBS,[$2])="$cf_add_libs" +])dnl diff --git a/auto/cf/CF_APPEND_TEXT b/auto/cf/CF_APPEND_TEXT new file mode 100644 index 00000000..f6bb752f --- /dev/null +++ b/auto/cf/CF_APPEND_TEXT @@ -0,0 +1,9 @@ +dnl CF_APPEND_TEXT version: 1 updated: 2017/02/25 18:58:55 +dnl -------------- +dnl use this macro for appending text without introducing an extra blank at +dnl the beginning +define([CF_APPEND_TEXT], +[ + test -n "[$]$1" && $1="[$]$1 " + $1="[$]{$1}$2" +])dnl diff --git a/auto/cf/CF_ARG_DISABLE b/auto/cf/CF_ARG_DISABLE new file mode 100644 index 00000000..2f7c7c54 --- /dev/null +++ b/auto/cf/CF_ARG_DISABLE @@ -0,0 +1,5 @@ +dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31 +dnl -------------- +dnl Allow user to disable a normally-on option. +AC_DEFUN([CF_ARG_DISABLE], +[CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl diff --git a/auto/cf/CF_ARG_ENABLE b/auto/cf/CF_ARG_ENABLE new file mode 100644 index 00000000..3fbef802 --- /dev/null +++ b/auto/cf/CF_ARG_ENABLE @@ -0,0 +1,5 @@ +dnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31 +dnl ------------- +dnl Allow user to enable a normally-off option. +AC_DEFUN([CF_ARG_ENABLE], +[CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl diff --git a/auto/cf/CF_ARG_OPTION b/auto/cf/CF_ARG_OPTION new file mode 100644 index 00000000..67c8e59a --- /dev/null +++ b/auto/cf/CF_ARG_OPTION @@ -0,0 +1,22 @@ +dnl CF_ARG_OPTION version: 5 updated: 2015/05/10 19:52:14 +dnl ------------- +dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus +dnl values. +dnl +dnl Parameters: +dnl $1 = option name +dnl $2 = help-string +dnl $3 = action to perform if option is not default +dnl $4 = action if perform if option is default +dnl $5 = default option value (either 'yes' or 'no') +AC_DEFUN([CF_ARG_OPTION], +[AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes) + if test "$enableval" != "$5" ; then +ifelse([$3],,[ :]dnl +,[ $3]) ifelse([$4],,,[ + else + $4]) + fi],[enableval=$5 ifelse([$4],,,[ + $4 +])dnl +])])dnl diff --git a/auto/cf/CF_ARG_WITH b/auto/cf/CF_ARG_WITH new file mode 100644 index 00000000..6e7b82f6 --- /dev/null +++ b/auto/cf/CF_ARG_WITH @@ -0,0 +1,23 @@ +dnl CF_ARG_WITH version: 4 updated: 2008/03/23 14:48:54 +dnl ----------- +dnl Restricted form of AC_ARG_WITH that requires user to specify a value +dnl $1 = option name +dnl $2 = help message +dnl $3 = variable to set with the --with value +dnl $4 = default value, if any, must be constant. +dnl $5 = default value shown for --help if $4 is empty. +AC_DEFUN([CF_ARG_WITH], +[AC_ARG_WITH($1,[$2 ](default: ifelse($4,,ifelse($5,,empty,$5),$4)),, +ifelse($4,,[withval="${$3}"],[withval="${$3-$4}"]))dnl +ifelse($4,,[test -n "$withval" && \ +],[test -z "$withval" && withval=no +])dnl +case "$withval" in #(vi +yes) + AC_MSG_ERROR(expected a value for --with-$1) + ;; #(vi +no) withval="" + ;; +esac +$3="$withval" +])dnl diff --git a/auto/cf/CF_C11_NORETURN b/auto/cf/CF_C11_NORETURN new file mode 100644 index 00000000..7c0835d6 --- /dev/null +++ b/auto/cf/CF_C11_NORETURN @@ -0,0 +1,34 @@ +dnl CF_C11_NORETURN version: 4 updated: 2023/02/18 17:41:25 +dnl --------------- +AC_DEFUN([CF_C11_NORETURN], +[ +AC_MSG_CHECKING(if you want to use C11 _Noreturn feature) +CF_ARG_ENABLE(stdnoreturn, + [ --enable-stdnoreturn enable C11 _Noreturn feature for diagnostics], + [enable_stdnoreturn=yes], + [enable_stdnoreturn=no]) +AC_MSG_RESULT($enable_stdnoreturn) + +if test $enable_stdnoreturn = yes; then +AC_CACHE_CHECK([for C11 _Noreturn feature], cf_cv_c11_noreturn, + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +$ac_includes_default +#include +static _Noreturn void giveup(void) { exit(0); } + ]], [[if (feof(stdin)) giveup()]])],[cf_cv_c11_noreturn=yes],[cf_cv_c11_noreturn=no]) + ]) +else + cf_cv_c11_noreturn=no, +fi + +if test "$cf_cv_c11_noreturn" = yes; then + AC_DEFINE(HAVE_STDNORETURN_H, 1,[Define if header is available and working]) + AC_DEFINE_UNQUOTED(STDC_NORETURN,_Noreturn,[Define if C11 _Noreturn keyword is supported]) + HAVE_STDNORETURN_H=1 +else + HAVE_STDNORETURN_H=0 +fi + +AC_SUBST(HAVE_STDNORETURN_H) +AC_SUBST(STDC_NORETURN) +])dnl diff --git a/auto/cf/CF_CLANG_COMPILER b/auto/cf/CF_CLANG_COMPILER new file mode 100644 index 00000000..b3086afe --- /dev/null +++ b/auto/cf/CF_CLANG_COMPILER @@ -0,0 +1,67 @@ +dnl CF_CLANG_COMPILER version: 9 updated: 2023/02/18 17:41:25 +dnl ----------------- +dnl Check if the given compiler is really clang. clang's C driver defines +dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does +dnl not ignore some gcc options. +dnl +dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to +dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from +dnl the wrappers for gcc and g++ warnings. +dnl +dnl $1 = GCC (default) or GXX +dnl $2 = CLANG_COMPILER (default) +dnl $3 = CFLAGS (default) or CXXFLAGS +AC_DEFUN([CF_CLANG_COMPILER],[ +ifelse([$2],,CLANG_COMPILER,[$2])=no + +if test "$ifelse([$1],,[$1],GCC)" = yes ; then + AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler) + cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ +#ifdef __clang__ +#else +#error __clang__ is not defined +#endif +]])],[ifelse([$2],,CLANG_COMPILER,[$2])=yes +],[]) + ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS" + AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2])) +fi + +CLANG_VERSION=none + +if test "x$ifelse([$2],,CLANG_COMPILER,[$2])" = "xyes" ; then + case "$CC" in + (c[[1-9]][[0-9]]|*/c[[1-9]][[0-9]]) + AC_MSG_WARN(replacing broken compiler alias $CC) + CFLAGS="$CFLAGS -std=`echo "$CC" | sed -e 's%.*/%%'`" + CC=clang + ;; + esac + + AC_MSG_CHECKING(version of $CC) + CLANG_VERSION="`$CC --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(CLANG[[^)]]*) //' -e 's/^.*(Debian[[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`" + test -z "$CLANG_VERSION" && CLANG_VERSION=unknown + AC_MSG_RESULT($CLANG_VERSION) + + for cf_clang_opt in \ + -Qunused-arguments \ + -Wno-error=implicit-function-declaration + do + AC_MSG_CHECKING(if option $cf_clang_opt works) + cf_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $cf_clang_opt" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + #include ]], [[ + printf("hello!\\n");]])],[ + cf_clang_optok=yes],[ + cf_clang_optok=no]) + AC_MSG_RESULT($cf_clang_optok) + CFLAGS="$cf_save_CFLAGS" + if test "$cf_clang_optok" = yes; then + CF_VERBOSE(adding option $cf_clang_opt) + CF_APPEND_TEXT(CFLAGS,$cf_clang_opt) + fi + done +fi +]) diff --git a/auto/cf/CF_CONST_X_STRING b/auto/cf/CF_CONST_X_STRING new file mode 100644 index 00000000..090ed3cc --- /dev/null +++ b/auto/cf/CF_CONST_X_STRING @@ -0,0 +1,59 @@ +dnl CF_CONST_X_STRING version: 7 updated: 2021/06/07 17:39:17 +dnl ----------------- +dnl The X11R4-X11R6 Xt specification uses an ambiguous String type for most +dnl character-strings. +dnl +dnl It is ambiguous because the specification accommodated the pre-ANSI +dnl compilers bundled by more than one vendor in lieu of providing a standard C +dnl compiler other than by costly add-ons. Because of this, the specification +dnl did not take into account the use of const for telling the compiler that +dnl string literals would be in readonly memory. +dnl +dnl As a workaround, one could (starting with X11R5) define XTSTRINGDEFINES, to +dnl let the compiler decide how to represent Xt's strings which were #define'd. +dnl That does not solve the problem of using the block of Xt's strings which +dnl are compiled into the library (and is less efficient than one might want). +dnl +dnl Xt specification 7 introduces the _CONST_X_STRING symbol which is used both +dnl when compiling the library and compiling using the library, to tell the +dnl compiler that String is const. +AC_DEFUN([CF_CONST_X_STRING], +[ +AC_REQUIRE([AC_PATH_XTRA]) + +CF_SAVE_XTRA_FLAGS([CF_CONST_X_STRING]) + +AC_TRY_COMPILE( +[ +#include +#include +], +[String foo = malloc(1); free((void*)foo)],[ + +AC_CACHE_CHECK(for X11/Xt const-feature,cf_cv_const_x_string,[ + AC_TRY_COMPILE( + [ +#define _CONST_X_STRING /* X11R7.8 (perhaps) */ +#undef XTSTRINGDEFINES /* X11R5 and later */ +#include +#include + ],[String foo = malloc(1); *foo = 0],[ + cf_cv_const_x_string=no + ],[ + cf_cv_const_x_string=yes + ]) +]) + +CF_RESTORE_XTRA_FLAGS([CF_CONST_X_STRING]) + +case "$cf_cv_const_x_string" in +(no) + CF_APPEND_TEXT(CPPFLAGS,-DXTSTRINGDEFINES) + ;; +(*) + CF_APPEND_TEXT(CPPFLAGS,-D_CONST_X_STRING) + ;; +esac + +]) +])dnl diff --git a/auto/cf/CF_C_INLINE b/auto/cf/CF_C_INLINE new file mode 100644 index 00000000..b063db73 --- /dev/null +++ b/auto/cf/CF_C_INLINE @@ -0,0 +1,32 @@ +dnl CF_C_INLINE version: 6 updated: 2019/09/07 13:38:36 +dnl ----------- +dnl Check if the C compiler supports "inline". +dnl $1 is the name of a shell variable to set if inline is supported +dnl $2 is the threshold for gcc 4.x's option controlling maximum inline size +AC_DEFUN([CF_C_INLINE],[ +AC_REQUIRE([CF_GCC_VERSION]) +AC_C_INLINE +$1= +if test "$ac_cv_c_inline" != no ; then + $1=inline + if test "$INTEL_COMPILER" = yes + then + : + elif test "$CLANG_COMPILER" = yes + then + : + elif test "$GCC" = yes + then + AC_CACHE_CHECK(if $CC supports options to tune inlining,cf_cv_gcc_inline,[ + cf_save_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS --param max-inline-insns-single=$2" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[inline int foo(void) { return 1; }]], [[${cf_cv_main_return:-return} foo()]])],[cf_cv_gcc_inline=yes],[cf_cv_gcc_inline=no]) + CFLAGS=$cf_save_CFLAGS + ]) + if test "$cf_cv_gcc_inline" = yes ; then + CF_ADD_CFLAGS([--param max-inline-insns-single=$2]) + fi + fi +fi +AC_SUBST($1) +])dnl diff --git a/auto/cf/CF_FUNC_MEMMOVE b/auto/cf/CF_FUNC_MEMMOVE new file mode 100644 index 00000000..05289e0d --- /dev/null +++ b/auto/cf/CF_FUNC_MEMMOVE @@ -0,0 +1,29 @@ +dnl CF_FUNC_MEMMOVE version: 10 updated: 2023/01/05 18:51:28 +dnl --------------- +dnl Check for memmove, or a bcopy that can handle overlapping copy. If neither +dnl is found, add our own version of memmove to the list of objects. +AC_DEFUN([CF_FUNC_MEMMOVE], +[ +AC_CHECK_FUNC(memmove,,[ +AC_CHECK_FUNC(bcopy,[ + AC_CACHE_CHECK(if bcopy does overlapping moves,cf_cv_good_bcopy,[ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ +$ac_includes_default + +int main(void) { + static char data[] = "abcdefghijklmnopqrstuwwxyz"; + char temp[40]; + bcopy(data, temp, sizeof(data)); + bcopy(temp+10, temp, 15); + bcopy(temp+5, temp+15, 10); + ${cf_cv_main_return:-return} (strcmp(temp, "klmnopqrstuwwxypqrstuwwxyz")); +} + ]])],[cf_cv_good_bcopy=yes],[cf_cv_good_bcopy=no],[cf_cv_good_bcopy=unknown]) + ]) + ],[cf_cv_good_bcopy=no]) + if test "$cf_cv_good_bcopy" = yes ; then + AC_DEFINE(USE_OK_BCOPY,1,[Define to 1 to use bcopy when memmove is unavailable]) + else + AC_DEFINE(USE_MY_MEMMOVE,1,[Define to 1 to use replacement function when memmove is unavailable]) + fi +])])dnl diff --git a/auto/cf/CF_FUNC_NANOSLEEP b/auto/cf/CF_FUNC_NANOSLEEP new file mode 100644 index 00000000..bd28036e --- /dev/null +++ b/auto/cf/CF_FUNC_NANOSLEEP @@ -0,0 +1,34 @@ +dnl CF_FUNC_NANOSLEEP version: 6 updated: 2023/01/05 18:51:33 +dnl ----------------- +dnl Check for existence of workable nanosleep() function. Some systems, e.g., +dnl AIX 4.x, provide a non-working version. +AC_DEFUN([CF_FUNC_NANOSLEEP],[ +AC_CACHE_CHECK(if nanosleep really works,cf_cv_func_nanosleep,[ +AC_TRY_RUN([ +$ac_includes_default + +#include +#include + +#ifdef HAVE_SYS_TIME_H +#include +#endif + +int main(void) { + struct timespec ts1, ts2; + int code; + ts1.tv_sec = 0; + ts1.tv_nsec = 750000000; + ts2.tv_sec = 0; + ts2.tv_nsec = 0; + errno = 0; + code = nanosleep(&ts1, &ts2); /* on failure errno is ENOSYS. */ + ${cf_cv_main_return:-return}(code != 0); +} +], + [cf_cv_func_nanosleep=yes], + [cf_cv_func_nanosleep=no], + [cf_cv_func_nanosleep=unknown])]) + +test "$cf_cv_func_nanosleep" = "yes" && AC_DEFINE(HAVE_NANOSLEEP,1,[Define to 1 if we have nanosleep()]) +]) diff --git a/auto/cf/CF_FUNC_VASPRINTF b/auto/cf/CF_FUNC_VASPRINTF new file mode 100644 index 00000000..37ff780a --- /dev/null +++ b/auto/cf/CF_FUNC_VASPRINTF @@ -0,0 +1,32 @@ +dnl CF_FUNC_VASPRINTF version: 2 updated: 2019/12/31 10:27:03 +dnl ----------------- +dnl Check if vasprintf is available, and if it is (or can be) declared. + +AC_DEFUN([CF_FUNC_VASPRINTF],[ +AC_REQUIRE([CF_GNU_SOURCE]) +AC_CHECK_FUNC(vasprintf,[ + AC_DEFINE(HAVE_VASPRINTF,1,[Define to 1 if we have vasprintf]) + AC_MSG_CHECKING(if vasprintf requires workaround) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + ]], [[ + void *p = (void *)vasprintf; return (p != 0) + ]])],[ + AC_MSG_RESULT(no) + ],[ + AC_TRY_COMPILE([ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#include +#endif + ],[ + void *p = (void *)vasprintf; return (p != 0) + ],[ + AC_MSG_RESULT(yes) + CF_APPEND_TEXT(CPPFLAGS,-D_GNU_SOURCE) + ],[ + AC_MSG_RESULT(unknown) + ]) + ]) +]) +])dnl diff --git a/auto/cf/CF_GCC_ATTRIBUTES b/auto/cf/CF_GCC_ATTRIBUTES new file mode 100644 index 00000000..9d83dc93 --- /dev/null +++ b/auto/cf/CF_GCC_ATTRIBUTES @@ -0,0 +1,112 @@ +dnl CF_GCC_ATTRIBUTES version: 24 updated: 2021/03/20 12:00:25 +dnl ----------------- +dnl Test for availability of useful gcc __attribute__ directives to quiet +dnl compiler warnings. Though useful, not all are supported -- and contrary +dnl to documentation, unrecognized directives cause older compilers to barf. +AC_DEFUN([CF_GCC_ATTRIBUTES], +[AC_REQUIRE([AC_PROG_FGREP])dnl +AC_REQUIRE([CF_C11_NORETURN])dnl + +if test "$GCC" = yes || test "$GXX" = yes +then +cat > conftest.i < "conftest.$ac_ext" < +#include "confdefs.h" +#include "conftest.h" +#include "conftest.i" +#if GCC_PRINTF +#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var))) +#else +#define GCC_PRINTFLIKE(fmt,var) /*nothing*/ +#endif +#if GCC_SCANF +#define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var))) +#else +#define GCC_SCANFLIKE(fmt,var) /*nothing*/ +#endif +extern void wow(char *,...) GCC_SCANFLIKE(1,2); +extern GCC_NORETURN void oops(char *,...) GCC_PRINTFLIKE(1,2); +extern GCC_NORETURN void foo(void); +int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { (void)argc; (void)argv; return 0; } +EOF + cf_printf_attribute=no + cf_scanf_attribute=no + for cf_attribute in scanf printf unused noreturn + do + CF_UPPER(cf_ATTRIBUTE,$cf_attribute) + cf_directive="__attribute__(($cf_attribute))" + echo "checking for $CC $cf_directive" 1>&AS_MESSAGE_LOG_FD + + case "$cf_attribute" in + (printf) + cf_printf_attribute=yes + cat >conftest.h <conftest.h <conftest.h <>confdefs.h + case "$cf_attribute" in + (noreturn) + AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc]) + ;; + (printf) + cf_value='/* nothing */' + if test "$cf_printf_attribute" != no ; then + cf_value='__attribute__((format(printf,fmt,var)))' + AC_DEFINE(GCC_PRINTF,1,[Define to 1 if the compiler supports gcc-like printf attribute.]) + fi + AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc]) + ;; + (scanf) + cf_value='/* nothing */' + if test "$cf_scanf_attribute" != no ; then + cf_value='__attribute__((format(scanf,fmt,var)))' + AC_DEFINE(GCC_SCANF,1,[Define to 1 if the compiler supports gcc-like scanf attribute.]) + fi + AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc]) + ;; + (unused) + AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc]) + ;; + esac + fi + done +else + ${FGREP-fgrep} define conftest.i >>confdefs.h +fi +rm -rf ./conftest* +fi +])dnl diff --git a/auto/cf/CF_GCC_VERSION b/auto/cf/CF_GCC_VERSION new file mode 100644 index 00000000..2b4c54e8 --- /dev/null +++ b/auto/cf/CF_GCC_VERSION @@ -0,0 +1,16 @@ +dnl CF_GCC_VERSION version: 9 updated: 2023/03/05 14:30:13 +dnl -------------- +dnl Find version of gcc, and (because icc/clang pretend to be gcc without being +dnl compatible), attempt to determine if icc/clang is actually used. +AC_DEFUN([CF_GCC_VERSION],[ +AC_REQUIRE([AC_PROG_CC]) +GCC_VERSION=none +if test "$GCC" = yes ; then + AC_MSG_CHECKING(version of $CC) + GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^[[^(]]*([[^)]][[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`" + test -z "$GCC_VERSION" && GCC_VERSION=unknown + AC_MSG_RESULT($GCC_VERSION) +fi +CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS) +CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS) +])dnl diff --git a/auto/cf/CF_GCC_WARNINGS b/auto/cf/CF_GCC_WARNINGS new file mode 100644 index 00000000..a31f39a0 --- /dev/null +++ b/auto/cf/CF_GCC_WARNINGS @@ -0,0 +1,113 @@ +dnl CF_GCC_WARNINGS version: 41 updated: 2021/01/01 16:53:59 +dnl --------------- +dnl Check if the compiler supports useful warning options. There's a few that +dnl we don't use, simply because they're too noisy: +dnl +dnl -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x) +dnl -Winline (usually not worthwhile) +dnl -Wredundant-decls (system headers make this too noisy) +dnl -Wtraditional (combines too many unrelated messages, only a few useful) +dnl -Wwrite-strings (too noisy, but should review occasionally). This +dnl is enabled for ncurses using "--enable-const". +dnl -pedantic +dnl +dnl Parameter: +dnl $1 is an optional list of gcc warning flags that a particular +dnl application might want to use, e.g., "no-unused" for +dnl -Wno-unused +dnl Special: +dnl If $with_ext_const is "yes", add a check for -Wwrite-strings +dnl +AC_DEFUN([CF_GCC_WARNINGS], +[ +AC_REQUIRE([CF_GCC_VERSION]) +if test "x$have_x" = xyes; then CF_CONST_X_STRING fi +cat > "conftest.$ac_ext" <]], [[ + #if __GLIBC__ > 0 && __GLIBC_MINOR__ >= 0 + return 0; + #elif __NEWLIB__ > 0 && __NEWLIB_MINOR__ >= 0 + return 0; + #else + #error not GNU C library + #endif]])],[cf_cv_gnu_library=yes],[cf_cv_gnu_library=no]) +]) + +if test x$cf_cv_gnu_library = xyes; then + + # With glibc 2.19 (13 years after this check was begun), _DEFAULT_SOURCE + # was changed to help a little. newlib incorporated the change about 4 + # years later. + AC_CACHE_CHECK(if _DEFAULT_SOURCE can be used as a basis,cf_cv_gnu_library_219,[ + cf_save="$CPPFLAGS" + CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ +#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 19) || (__GLIBC__ > 2) + return 0; +#elif (__NEWLIB__ == 2 && __NEWLIB_MINOR__ >= 4) || (__GLIBC__ > 3) + return 0; +#else +#error GNU C library __GLIBC__.__GLIBC_MINOR__ is too old +#endif]])],[cf_cv_gnu_library_219=yes],[cf_cv_gnu_library_219=no]) + CPPFLAGS="$cf_save" + ]) + + if test "x$cf_cv_gnu_library_219" = xyes; then + cf_save="$CPPFLAGS" + AC_CACHE_CHECK(if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE,cf_cv_gnu_dftsrc_219,[ + CF_ADD_CFLAGS(-D_DEFAULT_SOURCE -D_XOPEN_SOURCE=$cf_gnu_xopen_source) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + #include + ]], [[ +#if (_XOPEN_SOURCE >= $cf_gnu_xopen_source) && (MB_LEN_MAX > 1) + return 0; +#else +#error GNU C library is too old +#endif]])],[cf_cv_gnu_dftsrc_219=yes],[cf_cv_gnu_dftsrc_219=no]) + ]) + test "x$cf_cv_gnu_dftsrc_219" = "xyes" || CPPFLAGS="$cf_save" + else + cf_cv_gnu_dftsrc_219=maybe + fi + + if test "x$cf_cv_gnu_dftsrc_219" != xyes; then + + AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ +#ifndef _XOPEN_SOURCE +#error expected _XOPEN_SOURCE to be defined +#endif]])],[cf_cv_gnu_source=no],[cf_save="$CPPFLAGS" + CF_ADD_CFLAGS(-D_GNU_SOURCE) + AC_TRY_COMPILE([#include ],[ +#ifdef _XOPEN_SOURCE +#error expected _XOPEN_SOURCE to be undefined +#endif], + [cf_cv_gnu_source=no], + [cf_cv_gnu_source=yes]) + CPPFLAGS="$cf_save" + ]) + ]) + + if test "$cf_cv_gnu_source" = yes + then + AC_CACHE_CHECK(if we should also define _DEFAULT_SOURCE,cf_cv_default_source,[ + CF_APPEND_TEXT(CPPFLAGS,-D_GNU_SOURCE) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ +#ifdef _DEFAULT_SOURCE +#error expected _DEFAULT_SOURCE to be undefined +#endif]])],[cf_cv_default_source=no],[cf_cv_default_source=yes]) + ]) + if test "$cf_cv_default_source" = yes + then + CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE) + fi + fi + fi + +fi +])dnl diff --git a/auto/cf/CF_INTEL_COMPILER b/auto/cf/CF_INTEL_COMPILER new file mode 100644 index 00000000..d025b9f4 --- /dev/null +++ b/auto/cf/CF_INTEL_COMPILER @@ -0,0 +1,37 @@ +dnl CF_INTEL_COMPILER version: 9 updated: 2023/02/18 17:41:25 +dnl ----------------- +dnl Check if the given compiler is really the Intel compiler for Linux. It +dnl tries to imitate gcc, but does not return an error when it finds a mismatch +dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK. +dnl +dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to +dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from +dnl the wrappers for gcc and g++ warnings. +dnl +dnl $1 = GCC (default) or GXX +dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS +dnl $3 = CFLAGS (default) or CXXFLAGS +AC_DEFUN([CF_INTEL_COMPILER],[ +AC_REQUIRE([AC_CANONICAL_HOST]) +ifelse([$2],,INTEL_COMPILER,[$2])=no + +if test "$ifelse([$1],,[$1],GCC)" = yes ; then + case "$host_os" in + (linux*|gnu*) + AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler) + cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])" + ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ +#ifdef __INTEL_COMPILER +#else +#error __INTEL_COMPILER is not defined +#endif +]])],[ifelse([$2],,INTEL_COMPILER,[$2])=yes +cf_save_CFLAGS="$cf_save_CFLAGS -we147" +],[]) + ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS" + AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2])) + ;; + esac +fi +])dnl diff --git a/auto/cf/CF_LARGEFILE b/auto/cf/CF_LARGEFILE new file mode 100644 index 00000000..1b7cd937 --- /dev/null +++ b/auto/cf/CF_LARGEFILE @@ -0,0 +1,49 @@ +dnl CF_LARGEFILE version: 12 updated: 2020/03/19 20:23:48 +dnl ------------ +dnl Add checks for large file support. +AC_DEFUN([CF_LARGEFILE],[ +ifdef([AC_FUNC_FSEEKO],[ + AC_SYS_LARGEFILE + if test "$enable_largefile" != no ; then + AC_FUNC_FSEEKO + + # Normally we would collect these definitions in the config.h, + # but (like _XOPEN_SOURCE), some environments rely on having these + # defined before any of the system headers are included. Another + # case comes up with C++, e.g., on AIX the compiler compiles the + # header files by themselves before looking at the body files it is + # told to compile. For ncurses, those header files do not include + # the config.h + if test "$ac_cv_sys_large_files" != no + then + CF_APPEND_TEXT(CPPFLAGS,-D_LARGE_FILES) + fi + if test "$ac_cv_sys_largefile_source" != no + then + CF_APPEND_TEXT(CPPFLAGS,-D_LARGEFILE_SOURCE) + fi + if test "$ac_cv_sys_file_offset_bits" != no + then + CF_APPEND_TEXT(CPPFLAGS,-D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits) + fi + + AC_CACHE_CHECK(whether to use struct dirent64, cf_cv_struct_dirent64,[ + AC_TRY_COMPILE([ +#pragma GCC diagnostic error "-Wincompatible-pointer-types" +#include +#include + ],[ + /* if transitional largefile support is setup, this is true */ + extern struct dirent64 * readdir(DIR *); + struct dirent64 *x = readdir((DIR *)0); + struct dirent *y = readdir((DIR *)0); + int z = x - y; + (void)z; + ], + [cf_cv_struct_dirent64=yes], + [cf_cv_struct_dirent64=no]) + ]) + test "$cf_cv_struct_dirent64" = yes && AC_DEFINE(HAVE_STRUCT_DIRENT64,1,[Define to 1 if we have struct dirent64]) + fi +]) +]) diff --git a/auto/cf/CF_MAWK_PROG_GCC b/auto/cf/CF_MAWK_PROG_GCC new file mode 100644 index 00000000..30b8c1b2 --- /dev/null +++ b/auto/cf/CF_MAWK_PROG_GCC @@ -0,0 +1,23 @@ +dnl CF_MAWK_PROG_GCC version: 3 updated: 2010/10/23 15:52:32 +dnl ---------------- +dnl AC_PROG_CC with default -g to cflags +AC_DEFUN([CF_MAWK_PROG_GCC], +[AC_BEFORE([$0], [AC_PROG_CPP])dnl +AC_CHECK_PROG(CC, gcc, gcc, cc) +dnl +AC_MSG_CHECKING(whether we are using GNU C) +AC_CACHE_VAL(ac_cv_prog_gcc, +[dnl The semicolon is to pacify NeXT's syntax-checking cpp. +cat > conftest.c <&AC_FD_CC | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gcc=yes +else + ac_cv_prog_gcc=no +fi])dnl +AC_MSG_RESULT($ac_cv_prog_gcc) +rm -rf conftest* +])dnl diff --git a/auto/cf/CF_MIXEDCASE_FILENAMES b/auto/cf/CF_MIXEDCASE_FILENAMES new file mode 100644 index 00000000..8475c860 --- /dev/null +++ b/auto/cf/CF_MIXEDCASE_FILENAMES @@ -0,0 +1,29 @@ +dnl CF_MIXEDCASE_FILENAMES version: 9 updated: 2021/01/01 16:53:59 +dnl ---------------------- +dnl Check if the file-system supports mixed-case filenames. If we're able to +dnl create a lowercase name and see it as uppercase, it doesn't support that. +AC_DEFUN([CF_MIXEDCASE_FILENAMES], +[ +AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[ +if test "$cross_compiling" = yes ; then + case "$target_alias" in + (*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*|darwin*) + cf_cv_mixedcase=no + ;; + (*) + cf_cv_mixedcase=yes + ;; + esac +else + rm -f conftest CONFTEST + echo test >conftest + if test -f CONFTEST ; then + cf_cv_mixedcase=no + else + cf_cv_mixedcase=yes + fi + rm -f conftest CONFTEST +fi +]) +test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.]) +])dnl diff --git a/auto/cf/CF_MSG_LOG b/auto/cf/CF_MSG_LOG new file mode 100644 index 00000000..15f7aaf7 --- /dev/null +++ b/auto/cf/CF_MSG_LOG @@ -0,0 +1,7 @@ +dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32 +dnl ---------- +dnl Write a debug message to config.log, along with the line number in the +dnl configure script. +AC_DEFUN([CF_MSG_LOG],[ +echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AS_MESSAGE_LOG_FD +])dnl diff --git a/auto/cf/CF_NL_LANGINFO_1STDAY b/auto/cf/CF_NL_LANGINFO_1STDAY new file mode 100644 index 00000000..6c721a60 --- /dev/null +++ b/auto/cf/CF_NL_LANGINFO_1STDAY @@ -0,0 +1,21 @@ +dnl CF_NL_LANGINFO_1STDAY version: 3 updated: 2020/03/19 20:23:48 +dnl --------------------- +dnl glibc locale support has runtime extensions which might be implemented in +dnl other systems. +AC_DEFUN([CF_NL_LANGINFO_1STDAY],[ +AC_CACHE_CHECK(if runtime has nl_langinfo support for first weekday, + cf_nl_langinfo_1stday,[ + AC_TRY_COMPILE([ +#include +#include +],[ + int first_weekday = nl_langinfo (_NL_TIME_FIRST_WEEKDAY)[0]; + long week_1stday_l = (long) nl_langinfo (_NL_TIME_WEEK_1STDAY); + (void) first_weekday; + (void) week_1stday_l; +],[cf_nl_langinfo_1stday=yes +],[cf_nl_langinfo_1stday=no +]) +]) +test "x$cf_nl_langinfo_1stday" = xyes && AC_DEFINE(HAVE_NL_LANGINFO_1STDAY,1,[Define to 1 if runtime has nl_langinfo support for first weekday]) +])dnl diff --git a/auto/cf/CF_PATHSEP b/auto/cf/CF_PATHSEP new file mode 100644 index 00000000..c19b2363 --- /dev/null +++ b/auto/cf/CF_PATHSEP @@ -0,0 +1,15 @@ +dnl CF_PATHSEP version: 8 updated: 2021/01/01 13:31:04 +dnl ---------- +dnl Provide a value for the $PATH and similar separator (or amend the value +dnl as provided in autoconf 2.5x). +AC_DEFUN([CF_PATHSEP], +[ + AC_MSG_CHECKING(for PATH separator) + case "$cf_cv_system_name" in + (os2*) PATH_SEPARATOR=';' ;; + (*) ${PATH_SEPARATOR:=':'} ;; + esac +ifelse([$1],,,[$1=$PATH_SEPARATOR]) + AC_SUBST(PATH_SEPARATOR) + AC_MSG_RESULT($PATH_SEPARATOR) +])dnl diff --git a/auto/cf/CF_POSIX_SAVED_IDS b/auto/cf/CF_POSIX_SAVED_IDS new file mode 100644 index 00000000..b6b2bb12 --- /dev/null +++ b/auto/cf/CF_POSIX_SAVED_IDS @@ -0,0 +1,51 @@ +dnl CF_POSIX_SAVED_IDS version: 10 updated: 2023/01/05 17:53:42 +dnl ------------------ +dnl +dnl Check first if saved-ids are always supported. Some systems +dnl may require runtime checks. +AC_DEFUN([CF_POSIX_SAVED_IDS], +[ +AC_CHECK_HEADERS( \ +sys/param.h \ +) + +AC_CACHE_CHECK(if POSIX saved-ids are supported,cf_cv_posix_saved_ids,[ +AC_TRY_LINK( +[ +#include +#ifdef HAVE_SYS_PARAM_H +#include /* this may define "BSD" */ +#endif +],[ +#if defined(_POSIX_SAVED_IDS) && (_POSIX_SAVED_IDS > 0) + void *p = (void *) seteuid; + int x = seteuid(geteuid()); + (void)p; + (void)x; +#elif defined(BSD) && (BSD >= 199103) +/* The BSD's may implement the runtime check - and it fails. + * However, saved-ids work almost like POSIX (close enough for most uses). + */ +#else +make an error +#endif +],[cf_cv_posix_saved_ids=yes +],[ +AC_TRY_RUN([ +$ac_includes_default + +int main(void) +{ + void *p = (void *) seteuid; + long code = sysconf(_SC_SAVED_IDS); + (void)p; + ${cf_cv_main_return:-return} ((code > 0) ? 0 : 1); +}], + cf_cv_posix_saved_ids=yes, + cf_cv_posix_saved_ids=no, + cf_cv_posix_saved_ids=unknown) +]) +]) + +test "$cf_cv_posix_saved_ids" = yes && AC_DEFINE(HAVE_POSIX_SAVED_IDS,1,[Define to 1 if POSIX saved-ids are supported]) +]) diff --git a/auto/cf/CF_REMOVE_CFLAGS b/auto/cf/CF_REMOVE_CFLAGS new file mode 100644 index 00000000..2db4e039 --- /dev/null +++ b/auto/cf/CF_REMOVE_CFLAGS @@ -0,0 +1,17 @@ +dnl CF_REMOVE_CFLAGS version: 3 updated: 2021/09/05 17:25:40 +dnl ---------------- +dnl Remove a given option from CFLAGS/CPPFLAGS +dnl $1 = option to remove +dnl $2 = variable to update +dnl $3 = nonempty to allow verbose message +define([CF_REMOVE_CFLAGS], +[ +cf_tmp_cflag=`echo "x$1" | sed -e 's/^.//' -e 's/=.*//'` +while true +do + cf_old_cflag=`echo "x[$]$2" | sed -e 's/^.//' -e 's/[[ ]][[ ]]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[[^ ]][[^ ]]*\\)\?%%" -e 's/^[[ ]]*//' -e 's%[[ ]][[ ]]*-D% -D%g' -e 's%[[ ]][[ ]]*-I% -I%g'` + test "[$]$2" != "$cf_old_cflag" || break + ifelse([$3],,,[CF_VERBOSE(removing old option $1 from $2)]) + $2="$cf_old_cflag" +done +])dnl diff --git a/auto/cf/CF_REMOVE_DEFINE b/auto/cf/CF_REMOVE_DEFINE new file mode 100644 index 00000000..c00026a1 --- /dev/null +++ b/auto/cf/CF_REMOVE_DEFINE @@ -0,0 +1,16 @@ +dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50 +dnl ---------------- +dnl Remove all -U and -D options that refer to the given symbol from a list +dnl of C compiler options. This works around the problem that not all +dnl compilers process -U and -D options from left-to-right, so a -U option +dnl cannot be used to cancel the effect of a preceding -D option. +dnl +dnl $1 = target (which could be the same as the source variable) +dnl $2 = source (including '$') +dnl $3 = symbol to remove +define([CF_REMOVE_DEFINE], +[ +$1=`echo "$2" | \ + sed -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[[ ]]/ /g' \ + -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[$]//g'` +])dnl diff --git a/auto/cf/CF_REMOVE_LIB b/auto/cf/CF_REMOVE_LIB new file mode 100644 index 00000000..113f043d --- /dev/null +++ b/auto/cf/CF_REMOVE_LIB @@ -0,0 +1,12 @@ +dnl CF_REMOVE_LIB version: 1 updated: 2007/02/17 14:11:52 +dnl ------------- +dnl Remove the given library from the symbol +dnl +dnl $1 = target (which could be the same as the source variable) +dnl $2 = source (including '$') +dnl $3 = library to remove +define([CF_REMOVE_LIB], +[ +# remove $3 library from $2 +$1=`echo "$2" | sed -e 's/-l$3[[ ]]//g' -e 's/-l$3[$]//'` +])dnl diff --git a/auto/cf/CF_RESTORE_XTRA_FLAGS b/auto/cf/CF_RESTORE_XTRA_FLAGS new file mode 100644 index 00000000..118eee24 --- /dev/null +++ b/auto/cf/CF_RESTORE_XTRA_FLAGS @@ -0,0 +1,10 @@ +dnl CF_RESTORE_XTRA_FLAGS version: 1 updated: 2020/01/11 16:47:45 +dnl --------------------- +dnl Restore flags saved in CF_SAVE_XTRA_FLAGS +dnl $1 = name of current macro +define([CF_RESTORE_XTRA_FLAGS], +[ +LIBS="$cf_save_LIBS_$1" +CFLAGS="$cf_save_CFLAGS_$1" +CPPFLAGS="$cf_save_CPPFLAGS_$1" +])dnl diff --git a/auto/cf/CF_SAVE_XTRA_FLAGS b/auto/cf/CF_SAVE_XTRA_FLAGS new file mode 100644 index 00000000..c6d45509 --- /dev/null +++ b/auto/cf/CF_SAVE_XTRA_FLAGS @@ -0,0 +1,24 @@ +dnl CF_SAVE_XTRA_FLAGS version: 1 updated: 2020/01/11 16:46:44 +dnl ------------------ +dnl Use this macro to save CFLAGS/CPPFLAGS/LIBS before checks against X headers +dnl and libraries which do not update those variables. +dnl +dnl $1 = name of current macro +define([CF_SAVE_XTRA_FLAGS], +[ +cf_save_LIBS_$1="$LIBS" +cf_save_CFLAGS_$1="$CFLAGS" +cf_save_CPPFLAGS_$1="$CPPFLAGS" +LIBS="$LIBS ${X_PRE_LIBS} ${X_LIBS} ${X_EXTRA_LIBS}" +for cf_X_CFLAGS in $X_CFLAGS +do + case "x$cf_X_CFLAGS" in + x-[[IUD]]*) + CPPFLAGS="$CPPFLAGS $cf_X_CFLAGS" + ;; + *) + CFLAGS="$CFLAGS $cf_X_CFLAGS" + ;; + esac +done +])dnl diff --git a/auto/cf/CF_TYPE_SIGACTION b/auto/cf/CF_TYPE_SIGACTION new file mode 100644 index 00000000..acb8a35f --- /dev/null +++ b/auto/cf/CF_TYPE_SIGACTION @@ -0,0 +1,12 @@ +dnl CF_TYPE_SIGACTION version: 4 updated: 2012/10/06 17:56:13 +dnl ----------------- +dnl +AC_DEFUN([CF_TYPE_SIGACTION], +[ +AC_MSG_CHECKING([for type sigaction_t]) +AC_CACHE_VAL(cf_cv_type_sigaction,[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include ]], [[sigaction_t x]])],[cf_cv_type_sigaction=yes],[cf_cv_type_sigaction=no])]) +AC_MSG_RESULT($cf_cv_type_sigaction) +test "$cf_cv_type_sigaction" = yes && AC_DEFINE(HAVE_TYPE_SIGACTION,1,[Define to 1 if we have the sigaction_t type]) +])dnl diff --git a/auto/cf/CF_UPPER b/auto/cf/CF_UPPER new file mode 100644 index 00000000..de7d9825 --- /dev/null +++ b/auto/cf/CF_UPPER @@ -0,0 +1,8 @@ +dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59 +dnl -------- +dnl Make an uppercase version of a variable +dnl $1=uppercase($2) +AC_DEFUN([CF_UPPER], +[ +$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%` +])dnl diff --git a/auto/cf/CF_VA_COPY b/auto/cf/CF_VA_COPY new file mode 100644 index 00000000..bc35318e --- /dev/null +++ b/auto/cf/CF_VA_COPY @@ -0,0 +1,74 @@ +dnl CF_VA_COPY version: 6 updated: 2018/12/04 18:14:25 +dnl ---------- +dnl check for va_copy, part of stdarg.h starting with ISO C 1999. +dnl Also, workaround for glibc's __va_copy, by checking for both. +dnl Finally, try to accommodate pre-ISO C 1999 headers. +AC_DEFUN([CF_VA_COPY],[ +AC_CACHE_CHECK(for va_copy, cf_cv_have_va_copy,[ +AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#include +]], [[ + static va_list dst; + static va_list src; + va_copy(dst, src)]])],[cf_cv_have_va_copy=yes],[cf_cv_have_va_copy=no])]) + +if test "$cf_cv_have_va_copy" = yes; +then + AC_DEFINE(HAVE_VA_COPY,1,[Define to 1 if we have va_copy]) +else # !cf_cv_have_va_copy + +AC_CACHE_CHECK(for __va_copy, cf_cv_have___va_copy,[ +AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#include +]], [[ + static va_list dst; + static va_list src; + __va_copy(dst, src)]])],[cf_cv_have___va_copy=yes],[cf_cv_have___va_copy=no])]) + +if test "$cf_cv_have___va_copy" = yes +then + AC_DEFINE(HAVE___VA_COPY,1,[Define to 1 if we have __va_copy]) +else # !cf_cv_have___va_copy + +AC_CACHE_CHECK(for __builtin_va_copy, cf_cv_have___builtin_va_copy,[ +AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#include +]], [[ + static va_list dst; + static va_list src; + __builtin_va_copy(dst, src)]])],[cf_cv_have___builtin_va_copy=yes],[cf_cv_have___builtin_va_copy=no])]) + +test "$cf_cv_have___builtin_va_copy" = yes && + AC_DEFINE(HAVE___BUILTIN_VA_COPY,1,[Define to 1 if we have __builtin_va_copy]) + +fi # cf_cv_have___va_copy + +fi # cf_cv_have_va_copy + +case "${cf_cv_have_va_copy}${cf_cv_have___va_copy}${cf_cv_have___builtin_va_copy}" in +(*yes*) + ;; + +(*) + AC_CACHE_CHECK(if we can simply copy va_list, cf_cv_pointer_va_list,[ +AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#include +]], [[ + va_list dst; + va_list src; + dst = src]])],[cf_cv_pointer_va_list=yes],[cf_cv_pointer_va_list=no])]) + + if test "$cf_cv_pointer_va_list" = no + then + AC_CACHE_CHECK(if we can copy va_list indirectly, cf_cv_array_va_list,[ +AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#include +]], [[ + va_list dst; + va_list src; + *dst = *src]])],[cf_cv_array_va_list=yes],[cf_cv_array_va_list=no])]) + test "$cf_cv_array_va_list" = yes && AC_DEFINE(ARRAY_VA_LIST,1,[Define to 1 if we can copy va_list indirectly]) + fi + ;; +esac +]) diff --git a/auto/cf/CF_VERBOSE b/auto/cf/CF_VERBOSE new file mode 100644 index 00000000..bffa4af4 --- /dev/null +++ b/auto/cf/CF_VERBOSE @@ -0,0 +1,7 @@ +dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12 +dnl ---------- +dnl Use AC_MSG_RESULT w/o the warnings +AC_DEFUN([CF_VERBOSE], +[test -n "$verbose" && echo " $1" 1>&AS_MESSAGE_FD +CF_MSG_LOG([$1]) +])dnl diff --git a/auto/cf/COPYING b/auto/cf/COPYING new file mode 100644 index 00000000..329618da --- /dev/null +++ b/auto/cf/COPYING @@ -0,0 +1,25 @@ +Copyright 1997-2022,2023 Thomas E. Dickey + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, distribute with modifications, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR +THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name(s) of the above copyright +holders shall not be used in advertising or otherwise to promote the +sale, use or other dealings in this Software without prior written +authorization. diff --git a/auto/cf/README b/auto/cf/README new file mode 100644 index 00000000..c187e962 --- /dev/null +++ b/auto/cf/README @@ -0,0 +1,27 @@ +-- $Id: README,v 1.1 2024/06/14 16:41:42 cvsuser Exp $ + +The organization of this archive is determined by the tools which I +use for updating scripts and macros in configure-scripts. + +The scripts in the top-level directory are stable- or improved versions of +scripts needed for autoconf. + +The COPYING file applies to the contents of the AcSplit directory. + +The files in AcSplit are the autoconf macros which I use for maintaining +several programs, including ncurses, xterm, lynx, vile. They are +maintained in a split form, one macro per file. I wrote utilities to +split/join these (acsplit/acmerge) in August 1997, and much later (April +2003) wrote a checkin-script which provides the version numbers in each +file. + +The files are named according to the macro they contain. A few are +customized or improved versions from other packages. All of the ones +which I wrote are named using a "CF_" prefix. A few macros are useful +only for specific programs; most are useful building blocks for the +configure scripts which I maintain. + +As an aside, one may note CF_CHECK_DECL, etc., from 1997. Those were +plagiarized by one of the autoconf maintainers in 1999. + +-- Thomas E. Dickey diff --git a/auto/configure b/auto/configure index 133f6782..e632fe4e 100755 --- a/auto/configure +++ b/auto/configure @@ -1,9 +1,9 @@ #! /bin/sh -# From configure.in Revision: 1.83 . +# From configure.in Revision: 1.98 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.72 for GriefEdit 3.2.3. # -# Report bugs to . +# Report bugs to . # # # Copyright (C) 1992-1996, 1998-2017, 2020-2023 Free Software Foundation, @@ -280,10 +280,10 @@ then : printf "%s\n" "$0: be upgraded to zsh 4.3.4 or later." else printf "%s\n" "$0: Please tell bug-autoconf@gnu.org and -$0: griefedit@gmail.com about your system, including any -$0: error possibly output before this message. Then install -$0: a modern shell, or manually run the script under such a -$0: shell if you do have one." +$0: https://github.com/adamyg/grief about your system, +$0: including any error possibly output before this +$0: message. Then install a modern shell, or manually run +$0: the script under such a shell if you do have one." fi exit 1 fi ;; @@ -617,7 +617,7 @@ PACKAGE_NAME='GriefEdit' PACKAGE_TARNAME='griefedit' PACKAGE_VERSION='3.2.3' PACKAGE_STRING='GriefEdit 3.2.3' -PACKAGE_BUGREPORT='griefedit@gmail.com' +PACKAGE_BUGREPORT='https://github.com/adamyg/grief' PACKAGE_URL='' ac_unique_file="include/edheaders.h" @@ -679,7 +679,7 @@ YACC LEXLIB LEX_OUTPUT_ROOT LEX -MKDIR_P +PERL_CHECK INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM @@ -700,7 +700,9 @@ LIBOPENSSL OPENSSL_LDFLAGS OPENSSL_LIBS OPENSSL_INCLUDES -PKG_CONFIG +HAVE_BFD_SECTION_VMA +HAVE_BFD_SECTION_SIZE +HAVE_BFD_SECTION_FLAGS LIBMAGIC LIBENCA LIBICONV @@ -711,17 +713,22 @@ LIBICU_VERSION ICU_CONFIG LIBSPELL LIBMALLOC +ALLOCA +PKG_CONFIG TERMLIB +CURSES_LDFLAGS +CURSES_CFLAGS LIBBZ2 LIBLZMA LIBZ LIBREGEX -PATHSEP +BUILD_LIBFLTK BUILD_CONTRIB LDMAPFILE -HAVE___INLINE -HAVE_INLINE +yes EXTRA_CPPFLAGS +STDC_NORETURN +HAVE_STDNORETURN_H TOOLCHAINEXT TOOLCHAIN EXTRALIBS @@ -738,7 +745,11 @@ TROFF NROFF PERL TAR +MKDIR_P +RMDIR RM +MV +CP ABS_ROOT CPPDEP CPP @@ -776,14 +787,8 @@ OBJDUMP DLLTOOL AS SET_MAKE +ISWIN32 RC -OBJEXT -EXEEXT -ac_ct_CC -CPPFLAGS -LDFLAGS -CFLAGS -CC target_os target_vendor target_cpu @@ -796,6 +801,13 @@ build_os build_vendor build_cpu build +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC target_alias host_alias build_alias @@ -849,9 +861,11 @@ with_sysroot enable_libtool_lock with_gcc with_warnings +enable_stdnoreturn with_8bit with_floating with_contrib +with_libfltk enable_largefile with_regex with_zlib @@ -865,7 +879,6 @@ with_bz2_h with_bz2_lib with_ncurses with_ncursesw -with_pdcurses with_tinfo with_curses with_termcap @@ -928,6 +941,8 @@ CCC CXXCPP CPP CWARN +CURSES_CFLAGS +CURSES_LDFLAGS YACC YFLAGS' @@ -1558,6 +1573,7 @@ Optional Features: --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) + --enable-stdnoreturn enable C11 _Noreturn feature for diagnostics --disable-largefile omit support for large files --disable-libclang disable use of libclang. --enable-year2038 support timestamps after 2038 @@ -1578,6 +1594,7 @@ Optional Packages: --with-8bit enable full 8bit display --with-float enable floating point macro support (default=yes) --with-contrib enable contrib components (default=$with_contribdefault) + --with-libfltk enable libfltk support (default=no) --with-regex use libregex --with-zlib enable zlib use (default=yes) --with-zlib-h=DIR zlib header location @@ -1590,7 +1607,6 @@ Optional Packages: --with-bz2-lib=DIR libbz2 library location --with-ncurses use ncurses library --with-ncursesw use ncursesw library - --with-pdcurses use pdcurses library --with-tinfo use tinfo library --with-curses use curses library --with-termcap use termcap library @@ -1626,7 +1642,7 @@ Optional Packages: --with-libclang enable libclang use (default=yes) --with-clang-h=DIR libclang header location --with-clang-lib=DIR libclang library location - --with-mouse enable mouse support + --without-mouse disable mouse support --with-gpm use gpm mouse library --without-debug compile without debugging information --with-gdbdebug compile with GDB debugging information @@ -1655,6 +1671,10 @@ Some influential environment variables: CXXCPP C++ preprocessor CPP C preprocessor CWARN define to compilation flags for generating extra warnings + CURSES_CFLAGS + preprocessor flags for Curses, e.g. -I/usr/include/ncursesw + CURSES_LDFLAGS + linker flags for Curses, e.g. -L/usr/pkg/lib YACC The 'Yet Another Compiler Compiler' implementation to use. Defaults to the first program found out of: 'bison -y', 'byacc', 'yacc'. @@ -1665,7 +1685,7 @@ Some influential environment variables: Use these variables to override the choices made by 'configure' or to help it to find libraries and programs with nonstandard names/locations. -Report bugs to . +Report bugs to . _ACEOF ac_status=$? fi @@ -2057,6 +2077,245 @@ fi } # ac_fn_cxx_try_link +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to run conftest.$ac_ext, and return whether this succeeded. Assumes that +# executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } +then : + ac_retval=0 +else case e in #( + e) printf "%s\n" "$as_me: program exited with status $ac_status" >&5 + printf "%s\n" "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status ;; +esac +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + +# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES +# -------------------------------------------- +# Tries to find the compile-time value of EXPR in a program that includes +# INCLUDES, setting VAR accordingly. Returns whether the value could be +# computed +ac_fn_c_compute_int () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main (void) +{ +static int test_array [1 - 2 * !(($2) >= 0)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_lo=0 ac_mid=0 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main (void) +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_hi=$ac_mid; break +else case e in #( + e) as_fn_arith $ac_mid + 1 && ac_lo=$as_val + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + done +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main (void) +{ +static int test_array [1 - 2 * !(($2) < 0)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_hi=-1 ac_mid=-1 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main (void) +{ +static int test_array [1 - 2 * !(($2) >= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_lo=$ac_mid; break +else case e in #( + e) as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + done +else case e in #( + e) ac_lo= ac_hi= ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main (void) +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_hi=$ac_mid +else case e in #( + e) as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +done +case $ac_lo in #(( +?*) eval "$3=\$ac_lo"; ac_retval=0 ;; +'') ac_retval=1 ;; +esac + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +static long int longval (void) { return $2; } +static unsigned long int ulongval (void) { return $2; } +#include +#include +int +main (void) +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (($2) < 0) + { + long int i = longval (); + if (i != ($2)) + return 1; + fprintf (f, "%ld", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ($2)) + return 1; + fprintf (f, "%lu", i); + } + /* Do not output a trailing newline, as this causes \r\n confusion + on some platforms. */ + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO" +then : + echo >>conftest.val; read $3 &5 - (eval "$ac_link") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; } -then : - ac_retval=0 -else case e in #( - e) printf "%s\n" "$as_me: program exited with status $ac_status" >&5 - printf "%s\n" "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=$ac_status ;; -esac -fi - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_run - -# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES -# -------------------------------------------- -# Tries to find the compile-time value of EXPR in a program that includes -# INCLUDES, setting VAR accordingly. Returns whether the value could be -# computed -ac_fn_c_compute_int () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if test "$cross_compiling" = yes; then - # Depending upon the size, compute the lo and hi bounds. -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main (void) -{ -static int test_array [1 - 2 * !(($2) >= 0)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_lo=0 ac_mid=0 - while :; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main (void) -{ -static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_hi=$ac_mid; break -else case e in #( - e) as_fn_arith $ac_mid + 1 && ac_lo=$as_val - if test $ac_lo -le $ac_mid; then - ac_lo= ac_hi= - break - fi - as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - done -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main (void) -{ -static int test_array [1 - 2 * !(($2) < 0)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_hi=-1 ac_mid=-1 - while :; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main (void) -{ -static int test_array [1 - 2 * !(($2) >= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_lo=$ac_mid; break -else case e in #( - e) as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val - if test $ac_mid -le $ac_hi; then - ac_lo= ac_hi= - break - fi - as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - done -else case e in #( - e) ac_lo= ac_hi= ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext -# Binary search between lo and hi bounds. -while test "x$ac_lo" != "x$ac_hi"; do - as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main (void) -{ -static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_hi=$ac_mid -else case e in #( - e) as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext -done -case $ac_lo in #(( -?*) eval "$3=\$ac_lo"; ac_retval=0 ;; -'') ac_retval=1 ;; -esac - else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -static long int longval (void) { return $2; } -static unsigned long int ulongval (void) { return $2; } -#include -#include -int -main (void) -{ - - FILE *f = fopen ("conftest.val", "w"); - if (! f) - return 1; - if (($2) < 0) - { - long int i = longval (); - if (i != ($2)) - return 1; - fprintf (f, "%ld", i); - } - else - { - unsigned long int i = ulongval (); - if (i != ($2)) - return 1; - fprintf (f, "%lu", i); - } - /* Do not output a trailing newline, as this causes \r\n confusion - on some platforms. */ - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO" -then : - echo >>conftest.val; read $3 &6;} >$cache_file fi +as_fn_append ac_header_c_list " stdio.h stdio_h HAVE_STDIO_H" # Test code for whether the C compiler supports C89 (global declarations) ac_c_conftest_c89_globals=' /* Does the compiler advertise C89 conformance? @@ -3272,7 +3293,6 @@ main (int argc, char **argv) } " -as_fn_append ac_header_c_list " stdio.h stdio_h HAVE_STDIO_H" as_fn_append ac_header_c_list " stdlib.h stdlib_h HAVE_STDLIB_H" as_fn_append ac_header_c_list " string.h string_h HAVE_STRING_H" as_fn_append ac_header_c_list " inttypes.h inttypes_h HAVE_INTTYPES_H" @@ -3281,6 +3301,8 @@ as_fn_append ac_header_c_list " strings.h strings_h HAVE_STRINGS_H" as_fn_append ac_header_c_list " sys/stat.h sys_stat_h HAVE_SYS_STAT_H" as_fn_append ac_header_c_list " sys/types.h sys_types_h HAVE_SYS_TYPES_H" as_fn_append ac_header_c_list " unistd.h unistd_h HAVE_UNISTD_H" +as_fn_append ac_header_c_list " wchar.h wchar_h HAVE_WCHAR_H" +as_fn_append ac_header_c_list " minix/config.h minix_config_h HAVE_MINIX_CONFIG_H" # Test code for whether the C++ compiler supports C++98 (global declarations) ac_cxx_conftest_cxx98_globals=' // Does the compiler advertise C++98 conformance? @@ -3689,126 +3711,6 @@ printf "%s\n" "-" >&6; } - # Make sure we can run config.sub. -$SHELL "${ac_aux_dir}config.sub" sun4 >/dev/null 2>&1 || - as_fn_error $? "cannot run $SHELL ${ac_aux_dir}config.sub" "$LINENO" 5 - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 -printf %s "checking build system type... " >&6; } -if test ${ac_cv_build+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) ac_build_alias=$build_alias -test "x$ac_build_alias" = x && - ac_build_alias=`$SHELL "${ac_aux_dir}config.guess"` -test "x$ac_build_alias" = x && - as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 -ac_cv_build=`$SHELL "${ac_aux_dir}config.sub" $ac_build_alias` || - as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $ac_build_alias failed" "$LINENO" 5 - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 -printf "%s\n" "$ac_cv_build" >&6; } -case $ac_cv_build in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; -esac -build=$ac_cv_build -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_build -shift -build_cpu=$1 -build_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -build_os=$* -IFS=$ac_save_IFS -case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac - - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 -printf %s "checking host system type... " >&6; } -if test ${ac_cv_host+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) if test "x$host_alias" = x; then - ac_cv_host=$ac_cv_build -else - ac_cv_host=`$SHELL "${ac_aux_dir}config.sub" $host_alias` || - as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $host_alias failed" "$LINENO" 5 -fi - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 -printf "%s\n" "$ac_cv_host" >&6; } -case $ac_cv_host in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; -esac -host=$ac_cv_host -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_host -shift -host_cpu=$1 -host_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -host_os=$* -IFS=$ac_save_IFS -case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac - - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 -printf %s "checking target system type... " >&6; } -if test ${ac_cv_target+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) if test "x$target_alias" = x; then - ac_cv_target=$ac_cv_host -else - ac_cv_target=`$SHELL "${ac_aux_dir}config.sub" $target_alias` || - as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $target_alias failed" "$LINENO" 5 -fi - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5 -printf "%s\n" "$ac_cv_target" >&6; } -case $ac_cv_target in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;; -esac -target=$ac_cv_target -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_target -shift -target_cpu=$1 -target_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -target_os=$* -IFS=$ac_save_IFS -case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac - - -# The aliases save the names the user supplied, while $host etc. -# will get canonicalized. -test -n "$target_alias" && - test "$program_prefix$program_suffix$program_transform_name" = \ - NONENONEs,x,x, && - program_prefix=${target_alias}- - - - - @@ -4864,6 +4766,275 @@ fi + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5 +printf %s "checking whether it is safe to define __EXTENSIONS__... " >&6; } +if test ${ac_cv_safe_to_define___extensions__+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +# define __EXTENSIONS__ 1 + $ac_includes_default +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_safe_to_define___extensions__=yes +else case e in #( + e) ac_cv_safe_to_define___extensions__=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5 +printf "%s\n" "$ac_cv_safe_to_define___extensions__" >&6; } + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether _XOPEN_SOURCE should be defined" >&5 +printf %s "checking whether _XOPEN_SOURCE should be defined... " >&6; } +if test ${ac_cv_should_define__xopen_source+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_cv_should_define__xopen_source=no + if test $ac_cv_header_wchar_h = yes +then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + mbstate_t x; +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #define _XOPEN_SOURCE 500 + #include + mbstate_t x; +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_should_define__xopen_source=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +fi ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_should_define__xopen_source" >&5 +printf "%s\n" "$ac_cv_should_define__xopen_source" >&6; } + + printf "%s\n" "#define _ALL_SOURCE 1" >>confdefs.h + + printf "%s\n" "#define _DARWIN_C_SOURCE 1" >>confdefs.h + + printf "%s\n" "#define _GNU_SOURCE 1" >>confdefs.h + + printf "%s\n" "#define _HPUX_ALT_XOPEN_SOCKET_API 1" >>confdefs.h + + printf "%s\n" "#define _NETBSD_SOURCE 1" >>confdefs.h + + printf "%s\n" "#define _OPENBSD_SOURCE 1" >>confdefs.h + + printf "%s\n" "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h + + printf "%s\n" "#define __STDC_WANT_IEC_60559_ATTRIBS_EXT__ 1" >>confdefs.h + + printf "%s\n" "#define __STDC_WANT_IEC_60559_BFP_EXT__ 1" >>confdefs.h + + printf "%s\n" "#define __STDC_WANT_IEC_60559_DFP_EXT__ 1" >>confdefs.h + + printf "%s\n" "#define __STDC_WANT_IEC_60559_EXT__ 1" >>confdefs.h + + printf "%s\n" "#define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1" >>confdefs.h + + printf "%s\n" "#define __STDC_WANT_IEC_60559_TYPES_EXT__ 1" >>confdefs.h + + printf "%s\n" "#define __STDC_WANT_LIB_EXT2__ 1" >>confdefs.h + + printf "%s\n" "#define __STDC_WANT_MATH_SPEC_FUNCS__ 1" >>confdefs.h + + printf "%s\n" "#define _TANDEM_SOURCE 1" >>confdefs.h + + if test $ac_cv_header_minix_config_h = yes +then : + MINIX=yes + printf "%s\n" "#define _MINIX 1" >>confdefs.h + + printf "%s\n" "#define _POSIX_SOURCE 1" >>confdefs.h + + printf "%s\n" "#define _POSIX_1_SOURCE 2" >>confdefs.h + +else case e in #( + e) MINIX= ;; +esac +fi + if test $ac_cv_safe_to_define___extensions__ = yes +then : + printf "%s\n" "#define __EXTENSIONS__ 1" >>confdefs.h + +fi + if test $ac_cv_should_define__xopen_source = yes +then : + printf "%s\n" "#define _XOPEN_SOURCE 500" >>confdefs.h + +fi + + + + + + # Make sure we can run config.sub. +$SHELL "${ac_aux_dir}config.sub" sun4 >/dev/null 2>&1 || + as_fn_error $? "cannot run $SHELL ${ac_aux_dir}config.sub" "$LINENO" 5 + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 +printf %s "checking build system type... " >&6; } +if test ${ac_cv_build+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "${ac_aux_dir}config.guess"` +test "x$ac_build_alias" = x && + as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 +ac_cv_build=`$SHELL "${ac_aux_dir}config.sub" $ac_build_alias` || + as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $ac_build_alias failed" "$LINENO" 5 + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 +printf "%s\n" "$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 +printf %s "checking host system type... " >&6; } +if test ${ac_cv_host+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "${ac_aux_dir}config.sub" $host_alias` || + as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $host_alias failed" "$LINENO" 5 +fi + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 +printf "%s\n" "$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; +esac +host=$ac_cv_host +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 +printf %s "checking target system type... " >&6; } +if test ${ac_cv_target+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if test "x$target_alias" = x; then + ac_cv_target=$ac_cv_host +else + ac_cv_target=`$SHELL "${ac_aux_dir}config.sub" $target_alias` || + as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $target_alias failed" "$LINENO" 5 +fi + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5 +printf "%s\n" "$ac_cv_target" >&6; } +case $ac_cv_target in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;; +esac +target=$ac_cv_target +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_target +shift +target_cpu=$1 +target_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +target_os=$* +IFS=$ac_save_IFS +case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac + + +# The aliases save the names the user supplied, while $host etc. +# will get canonicalized. +test -n "$target_alias" && + test "$program_prefix$program_suffix$program_transform_name" = \ + NONENONEs,x,x, && + program_prefix=${target_alias}- + + + + case $host_os in mingw*) ac_fn_c_check_header_compile "$LINENO" "windows.h" "ac_cv_header_windows_h" "$ac_includes_default" @@ -4920,6 +5091,26 @@ fi ;; esac + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for win32-target" >&5 +printf %s "checking for win32-target... " >&6; } + case "$host_os" in + *cygwin*) + ISWIN32=yes + ;; + *mingw*) + ISWIN32=yes + ;; + *) + ISWIN32=no + ;; + esac + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ISWIN32" >&5 +printf "%s\n" "$ISWIN32" >&6; } + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 printf %s "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} @@ -13523,20 +13714,19 @@ CC=$lt_save_CC - LT_OBJDIR="$lt_cv_objdir" -LIBTOOL='/bin/bash $(top_builddir)/libtool' +LIBTOOL='/bin/sh $(top_builddir)/libtool' + + -## Stop AC_PROG_CC() assigning defaults. -CFLAGS="" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then - for ac_prog in gcc cc clang c1 egcs + for ac_prog in gcc cc clang do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 @@ -13586,7 +13776,7 @@ fi fi if test -z "$CC"; then ac_ct_CC=$CC - for ac_prog in gcc cc clang c1 egcs + for ac_prog in gcc cc clang do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 @@ -13977,7 +14167,7 @@ if test -z "$CXX"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then - for ac_prog in g++ CC clang++ + for ac_prog in g++ CC c++ clang++ do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 @@ -14027,7 +14217,7 @@ fi fi if test -z "$CXX"; then ac_ct_CXX=$CXX - for ac_prog in g++ CC clang++ + for ac_prog in g++ CC c++ clang++ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 @@ -17695,267 +17885,1651 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu -## AC_PROG_GCC_TRADITIONAL + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler vendor" >&5 +printf %s "checking for C compiler vendor... " >&6; } +if test ${ax_cv_c_compiler_vendor+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) + vendors=" + intel: __ICC,__ECC,__INTEL_COMPILER + ibm: __xlc__,__xlC__,__IBMC__,__IBMCPP__,__ibmxl__ + pathscale: __PATHCC__,__PATHSCALE__ + clang: __clang__ + cray: _CRAYC + fujitsu: __FUJITSU + sdcc: SDCC,__SDCC + sx: _SX + nvhpc: __NVCOMPILER + portland: __PGI + gnu: __GNUC__ + sun: __SUNPRO_C,__SUNPRO_CC,__SUNPRO_F90,__SUNPRO_F95 + hp: __HP_cc,__HP_aCC + dec: __DECC,__DECCXX,__DECC_VER,__DECCXX_VER + borland: __BORLANDC__,__CODEGEARC__,__TURBOC__ + comeau: __COMO__ + kai: __KCC + lcc: __LCC__ + sgi: __sgi,sgi + microsoft: _MSC_VER + metrowerks: __MWERKS__ + watcom: __WATCOMC__ + tcc: __TINYC__ + unknown: UNKNOWN + " + for ventest in $vendors; do + case $ventest in + *:) + vendor=$ventest + continue + ;; + *) + vencpp="defined("`echo $ventest | sed 's/,/) || defined(/g'`")" + ;; + esac + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ -#TODO -#AX_COMPILER_VENDOR -#AX_COMPILER_VERSION -#AX_CHECK_COMPILE_FLAG([-std=c11], -# [AX_APPEND_FLAG([-std=c11])], -# [AC_MSG_WARN([-std=c11 not supported, you may have to set CFLAGS to enable C11 support.]) -# ]) +int +main (void) +{ -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 -printf %s "checking how to run the C preprocessor... " >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= +#if !($vencpp) + thisisanerror; +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + break fi -if test -z "$CPP"; then - if test ${ac_cv_prog_CPP+y} +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + done + + ax_cv_c_compiler_vendor=`echo $vendor | cut -d: -f1` + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_c_compiler_vendor" >&5 +printf "%s\n" "$ax_cv_c_compiler_vendor" >&6; } + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +printf %s "checking for C compiler version... " >&6; } +if test ${ax_cv_c_compiler_version+y} then : printf %s "(cached) " >&6 else case e in #( - e) # Double quotes because $CC needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" cpp /lib/cpp - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO" + e) case $ax_cv_c_compiler_vendor in #( + intel) : + if ac_fn_c_compute_int "$LINENO" "__INTEL_COMPILER/100" "_ax_c_compiler_version_major" "" then : else case e in #( - e) # Broken: fails on valid input. -continue ;; + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_INTEL unknown intel compiler version +See 'config.log' for more details" "$LINENO" 5; } ;; esac fi -rm -f conftest.err conftest.i conftest.$ac_ext - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO" + if ac_fn_c_compute_int "$LINENO" "(__INTEL_COMPILER%100)/10" "_ax_c_compiler_version_minor" "" then : - # Broken: success on invalid input. -continue + else case e in #( - e) # Passes both tests. -ac_preproc_ok=: -break ;; + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_INTEL unknown intel compiler version +See 'config.log' for more details" "$LINENO" 5; } ;; esac fi -rm -f conftest.err conftest.i conftest.$ac_ext -done -# Because of 'break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok + if ac_fn_c_compute_int "$LINENO" "(__INTEL_COMPILER%10)" "_ax_c_compiler_version_patch" "" then : - break -fi - done - ac_cv_prog_CPP=$CPP - ;; +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_INTEL unknown intel compiler version +See 'config.log' for more details" "$LINENO" 5; } ;; esac fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 -printf "%s\n" "$CPP" >&6; } -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + + ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch" + ;; #( + ibm) : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include - Syntax error + + +int +main (void) +{ + + #if defined(__COMPILER_VER__) + choke me; + #endif + + ; + return 0; +} _ACEOF -if ac_fn_c_try_cpp "$LINENO" +if ac_fn_c_try_compile "$LINENO" +then : + + if ac_fn_c_compute_int "$LINENO" "__xlC__/100" "_ax_c_compiler_version_major" "" then : else case e in #( - e) # Broken: fails on valid input. -continue ;; + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_IBM unknown IBM compiler major version +See 'config.log' for more details" "$LINENO" 5; } ;; esac fi -rm -f conftest.err conftest.i conftest.$ac_ext - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO" + if ac_fn_c_compute_int "$LINENO" "__xlC__%100" "_ax_c_compiler_version_minor" "" then : - # Broken: success on invalid input. -continue + else case e in #( - e) # Passes both tests. -ac_preproc_ok=: -break ;; + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_IBM unknown IBM compiler minor version +See 'config.log' for more details" "$LINENO" 5; } ;; esac fi -rm -f conftest.err conftest.i conftest.$ac_ext -done -# Because of 'break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok + if ac_fn_c_compute_int "$LINENO" "__xlC_ver__/0x100" "_ax_c_compiler_version_patch" "" then : else case e in #( e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} -as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +as_fn_error $? "_AX_COMPILER_VERSION_IBM unknown IBM compiler patch version See 'config.log' for more details" "$LINENO" 5; } ;; esac fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu + if ac_fn_c_compute_int "$LINENO" "__xlC_ver__%0x100" "_ax_c_compiler_version_build" "" +then : +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_IBM unknown IBM compiler build version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi -CPPDEP=${CPPDEP-"gcc -MM"} + ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch.$_ax_c_compiler_version_build" +else case e in #( + e) + if ac_fn_c_compute_int "$LINENO" "__xlC__%1000" "_ax_c_compiler_version_patch" "" +then : -ABS_ROOT="`pwd`/" +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_IBM unknown IBM compiler patch version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi -# Extract the first word of "rm", so it can be a program name with args. -set dummy rm; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_path_RM+y} + if ac_fn_c_compute_int "$LINENO" "(__xlC__/10000)%10" "_ax_c_compiler_version_minor" "" then : - printf %s "(cached) " >&6 -else case e in #( - e) case $RM in - [\\/]* | ?:[\\/]*) - ac_cv_path_RM="$RM" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_path_RM="$as_dir$ac_word$ac_exec_ext" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - test -z "$ac_cv_path_RM" && ac_cv_path_RM="rm" - ;; -esac ;; +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_IBM unknown IBM compiler minor version +See 'config.log' for more details" "$LINENO" 5; } ;; esac fi -RM=$ac_cv_path_RM -if test -n "$RM"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $RM" >&5 -printf "%s\n" "$RM" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi - -# Extract the first word of "sed", so it can be a program name with args. -set dummy sed; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_path_SED+y} + if ac_fn_c_compute_int "$LINENO" "(__xlC__/100000)%10" "_ax_c_compiler_version_major" "" then : - printf %s "(cached) " >&6 -else case e in #( - e) case $SED in - [\\/]* | ?:[\\/]*) - ac_cv_path_SED="$SED" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_path_SED="$as_dir$ac_word$ac_exec_ext" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - test -z "$ac_cv_path_SED" && ac_cv_path_SED="sed" - ;; -esac ;; +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_IBM unknown IBM compiler major version +See 'config.log' for more details" "$LINENO" 5; } ;; esac fi -SED=$ac_cv_path_SED -if test -n "$SED"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $SED" >&5 -printf "%s\n" "$SED" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi + ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch" + ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; #( + pathscale) : -# Extract the first word of "tar", so it can be a program name with args. -set dummy tar; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_path_TAR+y} + if ac_fn_c_compute_int "$LINENO" "__PATHCC__" "_ax_c_compiler_version_major" "" then : - printf %s "(cached) " >&6 + else case e in #( - e) case $TAR in - [\\/]* | ?:[\\/]*) - ac_cv_path_TAR="$TAR" # Let the user override the test with a path. - ;; - *) + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_PATHSCALE unknown pathscale major +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "__PATHCC_MINOR__" "_ax_c_compiler_version_minor" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_PATHSCALE unknown pathscale minor +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "__PATHCC_PATCHLEVEL__" "_ax_c_compiler_version_patch" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_PATHSCALE unknown pathscale patch level +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch" + ;; #( + clang) : + + if ac_fn_c_compute_int "$LINENO" "__clang_major__" "_ax_c_compiler_version_major" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_CLANG unknown clang major +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "__clang_minor__" "_ax_c_compiler_version_minor" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_CLANG unknown clang minor +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "__clang_patchlevel__" "_ax_c_compiler_version_patch" "" +then : + +else case e in #( + e) 0 ;; +esac +fi + + ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch" + ;; #( + cray) : + + if ac_fn_c_compute_int "$LINENO" "_RELEASE" "_ax_c_compiler_version_major" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_CRAY unknown crayc release +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "_RELEASE_MINOR" "_ax_c_compiler_version_minor" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_CRAY unknown crayc minor +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor" + ;; #( + fujitsu) : + + if ac_fn_c_compute_int "$LINENO" "__FCC_VERSION" "ax_cv_c_compiler_version" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_FUJITSUunknown fujitsu release +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + ;; #( + gnu) : + + if ac_fn_c_compute_int "$LINENO" "__GNUC__" "_ax_c_compiler_version_major" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_GNU unknown gcc major +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "__GNUC_MINOR__" "_ax_c_compiler_version_minor" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_GNU unknown gcc minor +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "__GNUC_PATCHLEVEL__" "_ax_c_compiler_version_patch" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_GNU unknown gcc patch level +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch" + ;; #( + sun) : + + + if ac_fn_c_compute_int "$LINENO" "!!( + #if defined(__SUNPRO_CC) + __SUNPRO_CC + #else + __SUNPRO_C + #endif + < 0x1000)" "_ax_c_compiler_version_until59" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_SUN unknown sun release version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if test "X$_ax_c_compiler_version_until59" = X1 +then : + if ac_fn_c_compute_int "$LINENO" " + #if defined(__SUNPRO_CC) + __SUNPRO_CC + #else + __SUNPRO_C + #endif + % 0x10" "_ax_c_compiler_version_patch" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_SUN unknown sun patch version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "( + #if defined(__SUNPRO_CC) + __SUNPRO_CC + #else + __SUNPRO_C + #endif + / 0x10) % 0x10" "_ax_c_compiler_version_minor" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_SUN unknown sun minor version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "( + #if defined(__SUNPRO_CC) + __SUNPRO_CC + #else + __SUNPRO_C + #endif + / 0x100)" "_ax_c_compiler_version_major" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_SUN unknown sun major version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + +else case e in #( + e) if ac_fn_c_compute_int "$LINENO" " + #if defined(__SUNPRO_CC) + __SUNPRO_CC + #else + __SUNPRO_C + #endif + % 0x10" "_ax_c_compiler_version_patch" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_SUN unknown sun patch version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "( + #if defined(__SUNPRO_CC) + __SUNPRO_CC + #else + __SUNPRO_C + #endif + / 0x100) % 0x100" "_ax_c_compiler_version_minor" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_SUN unknown sun minor version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "( + #if defined(__SUNPRO_CC) + __SUNPRO_CC + #else + __SUNPRO_C + #endif + / 0x1000)" "_ax_c_compiler_version_major" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_SUN unknown sun major version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + ;; +esac +fi + ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch" + ;; #( + hp) : + + + if ac_fn_c_compute_int "$LINENO" "!!( + #if defined(__HP_cc) + __HP_cc + #else + __HP_aCC + #endif + <= 1)" "_ax_c_compiler_version_untilA0121" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_HP unknown hp release version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if test "X$_ax_c_compiler_version_untilA0121" = X1 +then : + ax_cv_c_compiler_version="01.21.00" + +else case e in #( + e) if ac_fn_c_compute_int "$LINENO" "( + #if defined(__HP_cc) + __HP_cc + #else + __HP_aCC + #endif + % 100)" "_ax_c_compiler_version_patch" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_HP unknown hp release version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "(( + #if defined(__HP_cc) + __HP_cc + #else + __HP_aCC + #endif + / 100)%100)" "_ax_c_compiler_version_minor" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_HP unknown hp minor version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "(( + #if defined(__HP_cc) + __HP_cc + #else + __HP_aCC + #endif + / 10000)%100)" "_ax_c_compiler_version_major" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_HP unknown hp major version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch" + ;; +esac +fi + ;; #( + dec) : + + if ac_fn_c_compute_int "$LINENO" "( + #if defined(__DECC_VER) + __DECC_VER + #else + __DECCXX_VER + #endif + % 10000)" "_ax_c_compiler_version_patch" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_DEC unknown dec release version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "(( + #if defined(__DECC_VER) + __DECC_VER + #else + __DECCXX_VER + #endif + / 100000UL)%100)" "_ax_c_compiler_version_minor" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_DEC unknown dec minor version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "(( + #if defined(__DECC_VER) + __DECC_VER + #else + __DECCXX_VER + #endif + / 10000000UL)%100)" "_ax_c_compiler_version_major" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_DEC unknown dec major version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch" + ;; #( + borland) : + + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + #if defined(__TURBOC__) + __TURBOC__ + #else + choke me + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + if ac_fn_c_compute_int "$LINENO" " + #if defined(__TURBOC__) + __TURBOC__ + #else + choke me + #endif + " "_ax_c_compiler_version_turboc_raw" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_BORLAND unknown turboc version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if test $_ax_c_compiler_version_turboc_raw -lt 661 || test $_ax_c_compiler_version_turboc_raw -gt 1023 +then : + if ac_fn_c_compute_int "$LINENO" " + #if defined(__TURBOC__) + __TURBOC__ + #else + choke me + #endif + % 0x100" "_ax_c_compiler_version_minor" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_BORLAND unknown turboc minor version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "( + #if defined(__TURBOC__) + __TURBOC__ + #else + choke me + #endif + /0x100)%0x100" "_ax_c_compiler_version_major" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_BORLAND unknown turboc major version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + ax_cv_c_compiler_version="0turboc:$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor" +else case e in #( + e) case $_ax_c_compiler_version_turboc_raw in #( + 661) : + ax_cv_c_compiler_version="0turboc:1.00" ;; #( + 662) : + ax_cv_c_compiler_version="0turboc:1.01" ;; #( + 663) : + ax_cv_c_compiler_version="0turboc:2.00" ;; #( + *) : + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: [_AX_COMPILER_VERSION_BORLAND] unknown turboc version between 0x295 and 0x400 please report bug" >&5 +printf "%s\n" "$as_me: WARNING: [_AX_COMPILER_VERSION_BORLAND] unknown turboc version between 0x295 and 0x400 please report bug" >&2;} + ax_cv_c_compiler_version="" + ;; +esac + ;; +esac +fi + +else case e in #( + e) # borlandc + + if ac_fn_c_compute_int "$LINENO" " + #if defined(__BORLANDC__) + __BORLANDC__ + #else + __CODEGEARC__ + #endif + " "_ax_c_compiler_version_borlandc_raw" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_BORLAND unknown borlandc version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + case $_ax_c_compiler_version_borlandc_raw in #( + 512 ) : + ax_cv_c_compiler_version="1borlanc:2.00" ;; #( + 1024) : + ax_cv_c_compiler_version="1borlanc:3.00" ;; #( + 1024) : + ax_cv_c_compiler_version="1borlanc:3.00" ;; #( + 1040) : + ax_cv_c_compiler_version="1borlanc:3.1" ;; #( + 1106) : + ax_cv_c_compiler_version="1borlanc:4.0" ;; #( + 1280) : + ax_cv_c_compiler_version="1borlanc:5.0" ;; #( + 1312) : + ax_cv_c_compiler_version="1borlanc:5.02" ;; #( + 1328) : + ax_cv_c_compiler_version="2cppbuilder:3.0" ;; #( + 1344) : + ax_cv_c_compiler_version="2cppbuilder:4.0" ;; #( + 1360) : + ax_cv_c_compiler_version="3borlancpp:5.5" ;; #( + 1361) : + ax_cv_c_compiler_version="3borlancpp:5.51" ;; #( + 1378) : + ax_cv_c_compiler_version="3borlancpp:5.6.4" ;; #( + 1392) : + ax_cv_c_compiler_version="4cppbuilder:2006" ;; #( + 1424) : + ax_cv_c_compiler_version="4cppbuilder:2007" ;; #( + 1555) : + ax_cv_c_compiler_version="4cppbuilder:2009" ;; #( + 1569) : + ax_cv_c_compiler_version="4cppbuilder:2010" ;; #( + 1584) : + ax_cv_c_compiler_version="5xe" ;; #( + 1600) : + ax_cv_c_compiler_version="5xe:2" ;; #( + 1616) : + ax_cv_c_compiler_version="5xe:3" ;; #( + 1632) : + ax_cv_c_compiler_version="5xe:4" ;; #( + *) : + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: [_AX_COMPILER_VERSION_BORLAND] Unknown borlandc compiler version $_ax_c_compiler_version_borlandc_raw please report bug" >&5 +printf "%s\n" "$as_me: WARNING: [_AX_COMPILER_VERSION_BORLAND] Unknown borlandc compiler version $_ax_c_compiler_version_borlandc_raw please report bug" >&2;} + ;; +esac + ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; #( + comeau) : + if ac_fn_c_compute_int "$LINENO" "__COMO_VERSION__%100" "_ax_c_compiler_version_minor" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_COMEAU unknown comeau compiler minor version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "(__COMO_VERSION__/100)%10" "_ax_c_compiler_version_major" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_COMEAU unknown comeau compiler major version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor" + ;; #( + kai) : + + if ac_fn_c_compute_int "$LINENO" "__KCC_VERSION%100" "_ax_c_compiler_version_patch" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_KAI unknown kay compiler patch version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "(__KCC_VERSION/100)%10" "_ax_c_compiler_version_minor" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_KAI unknown kay compiler minor version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "(__KCC_VERSION/1000)%10" "_ax_c_compiler_version_major" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_KAI unknown kay compiler major version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch" + ;; #( + sgi) : + + + if ac_fn_c_compute_int "$LINENO" " + #if defined(_COMPILER_VERSION) + _COMPILER_VERSION + #else + _SGI_COMPILER_VERSION + #endif + %10" "_ax_c_compiler_version_patch" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_SGI unknown SGI compiler patch version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "( + #if defined(_COMPILER_VERSION) + _COMPILER_VERSION + #else + _SGI_COMPILER_VERSION + #endif + /10)%10" "_ax_c_compiler_version_minor" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_SGI unknown SGI compiler minor version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "( + #if defined(_COMPILER_VERSION) + _COMPILER_VERSION + #else + _SGI_COMPILER_VERSION + #endif + /100)%10" "_ax_c_compiler_version_major" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_SGI unknown SGI compiler major version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch" + ;; #( + microsoft) : + + if ac_fn_c_compute_int "$LINENO" "_MSC_VER%100" "_ax_c_compiler_version_minor" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_MICROSOFT unknown microsoft compiler minor version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "(_MSC_VER/100)%100" "_ax_c_compiler_version_major" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_MICROSOFT unknown microsoft compiler major version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + _ax_c_compiler_version_patch=0 + _ax_c_compiler_version_build=0 + # special case for version 6 + if test "X$_ax_c_compiler_version_major" = "X12" +then : + if ac_fn_c_compute_int "$LINENO" "_MSC_FULL_VER%1000" "_ax_c_compiler_version_patch" "" +then : + +else case e in #( + e) _ax_c_compiler_version_patch=0 ;; +esac +fi + +fi + # for version 7 + if test "X$_ax_c_compiler_version_major" = "X13" +then : + if ac_fn_c_compute_int "$LINENO" "_MSC_FULL_VER%1000" "_ax_c_compiler_version_patch" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_MICROSOFT unknown microsoft compiler patch version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + +fi + # for version > 8 + if test $_ax_c_compiler_version_major -ge 14 +then : + if ac_fn_c_compute_int "$LINENO" "_MSC_FULL_VER%10000" "_ax_c_compiler_version_patch" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_MICROSOFT unknown microsoft compiler patch version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + +fi + if test $_ax_c_compiler_version_major -ge 15 +then : + if ac_fn_c_compute_int "$LINENO" "_MSC_BUILD" "_ax_c_compiler_version_build" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_MICROSOFT unknown microsoft compiler build version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + +fi + ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch.$_ax_c_compiler_version_build" + ;; #( + metrowerks) : + if ac_fn_c_compute_int "$LINENO" "__MWERKS__%0x100" "_ax_c_compiler_version_patch" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_METROWERKS unknown metrowerks compiler patch version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "(__MWERKS__/0x100)%0x10" "_ax_c_compiler_version_minor" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_METROWERKS unknown metrowerks compiler minor version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "(__MWERKS__/0x1000)%0x10" "_ax_c_compiler_version_major" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_METROWERKS unknown metrowerks compiler major version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch" + ;; #( + watcom) : + if ac_fn_c_compute_int "$LINENO" "__WATCOMC__%100" "_ax_c_compiler_version_minor" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_WATCOM unknown watcom compiler minor version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "(__WATCOMC__/100)%100" "_ax_c_compiler_version_major" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_WATCOM unknown watcom compiler major version +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor" + ;; #( + nvhpc) : + + if ac_fn_c_compute_int "$LINENO" "__NVCOMPILER_MAJOR__" "_ax_c_compiler_version_major" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_NVHPC unknown nvhpc major +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "__NVCOMPILER_MINOR__" "_ax_c_compiler_version_minor" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_NVHPC unknown nvhpc minor +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "__NVCOMPILER_PATCHLEVEL__" "_ax_c_compiler_version_patch" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_NVHPC unknown nvhpc patch level +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch" + ;; #( + portland) : + + if ac_fn_c_compute_int "$LINENO" "__PGIC__" "_ax_c_compiler_version_major" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_PORTLAND unknown pgi major +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "__PGIC_MINOR__" "_ax_c_compiler_version_minor" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_PORTLAND unknown pgi minor +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "__PGIC_PATCHLEVEL__" "_ax_c_compiler_version_patch" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_PORTLAND unknown pgi patch level +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch" + ;; #( + tcc) : + + ax_cv_c_compiler_version=`tcc -v | $SED 's/^[ ]*tcc[ ]\+version[ ]\+\([0-9.]\+\).*/\1/g'` + ;; #( + sdcc) : + + if ac_fn_c_compute_int "$LINENO" "/* avoid parse error with comments */ + #if(defined(__SDCC_VERSION_MAJOR)) + __SDCC_VERSION_MAJOR + #else + SDCC/100 + #endif + " "_ax_c_compiler_version_major" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_SDCC unknown sdcc major +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" "/* avoid parse error with comments */ + #if(defined(__SDCC_VERSION_MINOR)) + __SDCC_VERSION_MINOR + #else + (SDCC%100)/10 + #endif + " "_ax_c_compiler_version_minor" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_SDCC unknown sdcc minor +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + if ac_fn_c_compute_int "$LINENO" " + /* avoid parse error with comments */ + #if(defined(__SDCC_VERSION_PATCH)) + __SDCC_VERSION_PATCH + #elsif(defined(_SDCC_VERSION_PATCHLEVEL)) + __SDCC_VERSION_PATCHLEVEL + #else + SDCC%10 + #endif + " "_ax_c_compiler_version_patch" "" +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "_AX_COMPILER_VERSION_SDCC unknown sdcc patch level +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + + ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch" + ;; #( + *) : + ax_cv_c_compiler_version="" ;; +esac + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_c_compiler_version" >&5 +printf "%s\n" "$ax_cv_c_compiler_version" >&6; } + +CFLAGS=${ac_env_CFLAGS_value} +CXXFLAGS=${ac_env_CXXFLAGS_value} + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +printf %s "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test ${ac_cv_prog_CPP+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) # Double quotes because $CC needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" cpp /lib/cpp + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO" +then : + +else case e in #( + e) # Broken: fails on valid input. +continue ;; +esac +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO" +then : + # Broken: success on invalid input. +continue +else case e in #( + e) # Passes both tests. +ac_preproc_ok=: +break ;; +esac +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of 'break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok +then : + break +fi + + done + ac_cv_prog_CPP=$CPP + ;; +esac +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +printf "%s\n" "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO" +then : + +else case e in #( + e) # Broken: fails on valid input. +continue ;; +esac +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO" +then : + # Broken: success on invalid input. +continue +else case e in #( + e) # Passes both tests. +ac_preproc_ok=: +break ;; +esac +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of 'break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok +then : + +else case e in #( + e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See 'config.log' for more details" "$LINENO" 5; } ;; +esac +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +CPPDEP=${CPPDEP-"gcc -MM"} + + +ABS_ROOT="`pwd`/" + +# Extract the first word of "cp", so it can be a program name with args. +set dummy cp; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_CP+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if test -n "$CP"; then + ac_cv_prog_CP="$CP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_CP="cp" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi ;; +esac +fi +CP=$ac_cv_prog_CP +if test -n "$CP"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CP" >&5 +printf "%s\n" "$CP" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +# Extract the first word of "mv", so it can be a program name with args. +set dummy mv; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_MV+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if test -n "$MV"; then + ac_cv_prog_MV="$MV" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_MV="mv" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi ;; +esac +fi +MV=$ac_cv_prog_MV +if test -n "$MV"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MV" >&5 +printf "%s\n" "$MV" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +# Extract the first word of "rm", so it can be a program name with args. +set dummy rm; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_RM+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if test -n "$RM"; then + ac_cv_prog_RM="$RM" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_RM="rm" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi ;; +esac +fi +RM=$ac_cv_prog_RM +if test -n "$RM"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $RM" >&5 +printf "%s\n" "$RM" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +# Extract the first word of "rmdir", so it can be a program name with args. +set dummy rmdir; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_RMDIR+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if test -n "$RMDIR"; then + ac_cv_prog_RMDIR="$RMDIR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_RMDIR="rmdir" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi ;; +esac +fi +RMDIR=$ac_cv_prog_RMDIR +if test -n "$RMDIR"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $RMDIR" >&5 +printf "%s\n" "$RMDIR" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a race-free mkdir -p" >&5 +printf %s "checking for a race-free mkdir -p... " >&6; } +if test -z "$MKDIR_P"; then + if test ${ac_cv_path_mkdir+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_prog in mkdir gmkdir; do + for ac_exec_ext in '' $ac_executable_extensions; do + as_fn_executable_p "$as_dir$ac_prog$ac_exec_ext" || continue + case `"$as_dir$ac_prog$ac_exec_ext" --version 2>&1` in #( + 'mkdir ('*'coreutils) '* | \ + *'BusyBox '* | \ + 'mkdir (fileutils) '4.1*) + ac_cv_path_mkdir=$as_dir$ac_prog$ac_exec_ext + break 3;; + esac + done + done + done +IFS=$as_save_IFS + ;; +esac +fi + + test -d ./--version && rmdir ./--version + if test ${ac_cv_path_mkdir+y}; then + MKDIR_P="$ac_cv_path_mkdir -p" + else + # As a last resort, use plain mkdir -p, + # in the hope it doesn't have the bugs of ancient mkdir. + MKDIR_P='mkdir -p' + fi +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 +printf "%s\n" "$MKDIR_P" >&6; } + + +# Extract the first word of "sed", so it can be a program name with args. +set dummy sed; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_path_SED+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) case $SED in + [\\/]* | ?:[\\/]*) + ac_cv_path_SED="$SED" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_path_SED="$as_dir$ac_word$ac_exec_ext" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_path_SED" && ac_cv_path_SED="sed" + ;; +esac ;; +esac +fi +SED=$ac_cv_path_SED +if test -n "$SED"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $SED" >&5 +printf "%s\n" "$SED" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +# Extract the first word of "tar", so it can be a program name with args. +set dummy tar; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_path_TAR+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) case $TAR in + [\\/]* | ?:[\\/]*) + ac_cv_path_TAR="$TAR" # Let the user override the test with a path. + ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do @@ -19357,20 +20931,239 @@ fi - GCC_VERSION=none - if test "$GCC" = yes ; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking version of $CC" >&5 +GCC_VERSION=none +if test "$GCC" = yes ; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking version of $CC" >&5 printf %s "checking version of $CC... " >&6; } - GCC_VERSION="`${CC} --version| sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[^0-9.]*//' -e 's/[^0-9.].*//'`" - test -z "$GCC_VERSION" && GCC_VERSION=unknown - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $GCC_VERSION" >&5 + GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^[^(]*([^)][^)]*) //' -e 's/^[^0-9.]*//' -e 's/[^0-9.].*//'`" + test -z "$GCC_VERSION" && GCC_VERSION=unknown + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $GCC_VERSION" >&5 printf "%s\n" "$GCC_VERSION" >&6; } +fi + + +INTEL_COMPILER=no + +if test "$GCC" = yes ; then + case "$host_os" in + (linux*|gnu*) + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if this is really Intel C compiler" >&5 +printf %s "checking if this is really Intel C compiler... " >&6; } + cf_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -no-gcc" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + +#ifdef __INTEL_COMPILER +#else +#error __INTEL_COMPILER is not defined +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + INTEL_COMPILER=yes +cf_save_CFLAGS="$cf_save_CFLAGS -we147" + +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + CFLAGS="$cf_save_CFLAGS" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $INTEL_COMPILER" >&5 +printf "%s\n" "$INTEL_COMPILER" >&6; } + ;; + esac +fi + + +CLANG_COMPILER=no + +if test "$GCC" = yes ; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if this is really Clang C compiler" >&5 +printf %s "checking if this is really Clang C compiler... " >&6; } + cf_save_CFLAGS="$CFLAGS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + +#ifdef __clang__ +#else +#error __clang__ is not defined +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + CLANG_COMPILER=yes + +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + CFLAGS="$cf_save_CFLAGS" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CLANG_COMPILER" >&5 +printf "%s\n" "$CLANG_COMPILER" >&6; } +fi + +CLANG_VERSION=none + +if test "x$CLANG_COMPILER" = "xyes" ; then + case "$CC" in + (c[1-9][0-9]|*/c[1-9][0-9]) + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: replacing broken compiler alias $CC" >&5 +printf "%s\n" "$as_me: WARNING: replacing broken compiler alias $CC" >&2;} + CFLAGS="$CFLAGS -std=`echo "$CC" | sed -e 's%.*/%%'`" + CC=clang + ;; + esac + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking version of $CC" >&5 +printf %s "checking version of $CC... " >&6; } + CLANG_VERSION="`$CC --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(CLANG[^)]*) //' -e 's/^.*(Debian[^)]*) //' -e 's/^[^0-9.]*//' -e 's/[^0-9.].*//'`" + test -z "$CLANG_VERSION" && CLANG_VERSION=unknown + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CLANG_VERSION" >&5 +printf "%s\n" "$CLANG_VERSION" >&6; } + + for cf_clang_opt in \ + -Qunused-arguments \ + -Wno-error=implicit-function-declaration + do + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if option $cf_clang_opt works" >&5 +printf %s "checking if option $cf_clang_opt works... " >&6; } + cf_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $cf_clang_opt" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include +int +main (void) +{ + + printf("hello!\\n"); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + + cf_clang_optok=yes +else case e in #( + e) + cf_clang_optok=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cf_clang_optok" >&5 +printf "%s\n" "$cf_clang_optok" >&6; } + CFLAGS="$cf_save_CFLAGS" + if test "$cf_clang_optok" = yes; then + test -n "$verbose" && echo " adding option $cf_clang_opt" 1>&6 + +echo "${as_me:-configure}:21075: testing adding option $cf_clang_opt ..." 1>&5 + + + + test -n "$CFLAGS" && CFLAGS="$CFLAGS " + CFLAGS="${CFLAGS}$cf_clang_opt" + + fi + done +fi + + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if you want to use C11 _Noreturn feature" >&5 +printf %s "checking if you want to use C11 _Noreturn feature... " >&6; } +# Check whether --enable-stdnoreturn was given. +if test ${enable_stdnoreturn+y} +then : + enableval=$enable_stdnoreturn; test "$enableval" != yes && enableval=no + if test "$enableval" != "no" ; then + enable_stdnoreturn=yes + else + enable_stdnoreturn=no fi +else case e in #( + e) enableval=no + enable_stdnoreturn=no + ;; +esac +fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_stdnoreturn" >&5 +printf "%s\n" "$enable_stdnoreturn" >&6; } + +if test $enable_stdnoreturn = yes; then +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C11 _Noreturn feature" >&5 +printf %s "checking for C11 _Noreturn feature... " >&6; } +if test ${cf_cv_c11_noreturn+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +$ac_includes_default +#include +static _Noreturn void giveup(void) { exit(0); } + +int +main (void) +{ +if (feof(stdin)) giveup() + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + cf_cv_c11_noreturn=yes +else case e in #( + e) cf_cv_c11_noreturn=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cf_cv_c11_noreturn" >&5 +printf "%s\n" "$cf_cv_c11_noreturn" >&6; } +else + cf_cv_c11_noreturn=no, +fi + +if test "$cf_cv_c11_noreturn" = yes; then + +printf "%s\n" "#define HAVE_STDNORETURN_H 1" >>confdefs.h + + +printf "%s\n" "#define STDC_NORETURN _Noreturn" >>confdefs.h + + HAVE_STDNORETURN_H=1 +else + HAVE_STDNORETURN_H=0 +fi + - if test "$GCC" = yes; then - cat > conftest.i < conftest.i <&6; } #define GCC_UNUSED /* nothing */ #endif EOF - - if test "$GCC" = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: for $CC __attribute__ directives" >&5 -printf "%s\n" "$as_me: for $CC __attribute__ directives" >&6;} - cat > conftest.$ac_ext <&5 +printf "%s\n" "$as_me: checking for $CC __attribute__ directives..." >&6;} +cat > "conftest.$ac_ext" < #include "confdefs.h" #include "conftest.h" #include "conftest.i" -#if GCC_PRINTF +#if GCC_PRINTF #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var))) #else #define GCC_PRINTFLIKE(fmt,var) /*nothing*/ #endif -#if GCC_SCANF +#if GCC_SCANF #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var))) #else #define GCC_SCANFLIKE(fmt,var) /*nothing*/ #endif -extern void wow(char *,...) GCC_SCANFLIKE(1,2); -extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN; -extern void foo(void) GCC_NORETURN; -int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED) { return 0; } +extern void wow(char *,...) GCC_SCANFLIKE(1,2); +extern GCC_NORETURN void oops(char *,...) GCC_PRINTFLIKE(1,2); +extern GCC_NORETURN void foo(void); +int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED) { (void)argc; (void)argv; return 0; } EOF + cf_printf_attribute=no + cf_scanf_attribute=no + for cf_attribute in scanf printf unused noreturn + do - cf_printf_attribute=no - cf_scanf_attribute=no - - for cf_attribute in scanf printf unused noreturn; do - - cf_ATTRIBUTE=`echo "$cf_attribute" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%` +cf_ATTRIBUTE=`echo "$cf_attribute" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%` - cf_directive="__attribute__(($cf_attribute))" - echo "checking for $CC $cf_directive" 1>&5 + cf_directive="__attribute__(($cf_attribute))" + echo "checking for $CC $cf_directive" 1>&5 - case $cf_attribute in #(vi - printf) #(vi - cf_printf_attribute=yes - cat >conftest.h <conftest.h <conftest.h <conftest.h <conftest.h <conftest.h <&5 + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - test -n "$verbose" && { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ... $cf_attribute" >&5 + test -n "$verbose" && { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ... $cf_attribute" >&5 printf "%s\n" "... $cf_attribute" >&6; } - cat conftest.h >>confdefs.h - case $cf_attribute in #(vi - printf) #(vi - if test "$cf_printf_attribute" = no ; then - cat >>confdefs.h <>confdefs.h <>confdefs.h <>confdefs.h <>confdefs.h + case "$cf_attribute" in + (noreturn) + +printf "%s\n" "#define GCC_NORETURN $cf_directive" >>confdefs.h + + ;; + (printf) + cf_value='/* nothing */' + if test "$cf_printf_attribute" != no ; then + cf_value='__attribute__((format(printf,fmt,var)))' + +printf "%s\n" "#define GCC_PRINTF 1" >>confdefs.h + fi - done - else - fgrep define conftest.i >>confdefs.h + +printf "%s\n" "#define GCC_PRINTFLIKE(fmt,var) $cf_value" >>confdefs.h + + ;; + (scanf) + cf_value='/* nothing */' + if test "$cf_scanf_attribute" != no ; then + cf_value='__attribute__((format(scanf,fmt,var)))' + +printf "%s\n" "#define GCC_SCANF 1" >>confdefs.h + + fi + +printf "%s\n" "#define GCC_SCANFLIKE(fmt,var) $cf_value" >>confdefs.h + + ;; + (unused) + +printf "%s\n" "#define GCC_UNUSED $cf_directive" >>confdefs.h + + ;; + esac fi - rm -rf conftest* - fi + done +else + ${FGREP-fgrep} define conftest.i >>confdefs.h +fi +rm -rf ./conftest* +fi + - cf_c_inline_define=yes - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 printf %s "checking for inline... " >&6; } if test ${ac_cv_c_inline+y} then : @@ -19526,25 +21331,28 @@ _ACEOF ;; esac - if test "$ac_cv_c_inline" != no ; then - yes=inline - if test "$INTEL_COMPILER" = yes - then - : - elif test "$GCC" = yes - then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if gcc supports options to tune inlining" >&5 -printf %s "checking if gcc supports options to tune inlining... " >&6; } +yes= +if test "$ac_cv_c_inline" != no ; then + yes=inline + if test "$INTEL_COMPILER" = yes + then + : + elif test "$CLANG_COMPILER" = yes + then + : + elif test "$GCC" = yes + then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC supports options to tune inlining" >&5 +printf %s "checking if $CC supports options to tune inlining... " >&6; } if test ${cf_cv_gcc_inline+y} then : printf %s "(cached) " >&6 else case e in #( e) - cf_save_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS --param max-inline-insns-single=1200" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cf_save_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS --param max-inline-insns-single=1200" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - inline int foo(void) { return 1; } int main (void) @@ -19562,122 +21370,123 @@ else case e in #( esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - CFLAGS=$cf_save_CFLAGS - ;; + CFLAGS=$cf_save_CFLAGS + ;; esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cf_cv_gcc_inline" >&5 printf "%s\n" "$cf_cv_gcc_inline" >&6; } - if test "$cf_cv_gcc_inline" = yes ; then + if test "$cf_cv_gcc_inline" = yes ; then - cf_fix_cppflags=no - cf_new_cflags= - cf_new_cppflags= - cf_new_extra_cppflags= +cf_fix_cppflags=no +cf_new_cflags= +cf_new_cppflags= +cf_new_extra_cppflags= - for cf_add_cflags in --param max-inline-insns-single=1200 - do - case $cf_fix_cppflags in - no) - case $cf_add_cflags in #(vi - -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi - case $cf_add_cflags in - -D*) - cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'` - - test "${cf_add_cflags}" != "${cf_tst_cflags}" \ +for cf_add_cflags in --param max-inline-insns-single=1200 +do +case "$cf_fix_cppflags" in +(no) + case "$cf_add_cflags" in + (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) + case "$cf_add_cflags" in + (-D*) + cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'` + + test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=yes - if test $cf_fix_cppflags = yes ; then - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" - continue - elif test "${cf_tst_cflags}" = "\"'" ; then - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" - continue - fi - ;; - esac - case "$CPPFLAGS" in - *$cf_add_cflags) #(vi - ;; - *) #(vi - cf_new_cppflags="$cf_new_cppflags $cf_add_cflags" + if test "$cf_fix_cppflags" = yes ; then + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + + continue + elif test "${cf_tst_cflags}" = "\"'" ; then + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + + continue + fi + ;; + esac + case "$CPPFLAGS" in + (*$cf_add_cflags) + ;; + (*) + case "$cf_add_cflags" in + (-D*) + cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'` + +CPPFLAGS=`echo "$CPPFLAGS" | \ + sed -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?[ ]/ /g' \ + -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?$//g'` + ;; esac - ;; - *) - cf_new_cflags="$cf_new_cflags $cf_add_cflags" + + test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags " + cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags" + ;; esac ;; - yes) - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" + (*) - cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'` + test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags " + cf_new_cflags="${cf_new_cflags}$cf_add_cflags" - test "${cf_add_cflags}" != "${cf_tst_cflags}" \ - && test -z "${cf_tst_cflags}" \ - && cf_fix_cppflags=no ;; esac - done + ;; +(yes) - if test -n "$cf_new_cflags" ; then + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" - CFLAGS="$CFLAGS $cf_new_cflags" - fi - if test -n "$cf_new_cppflags" ; then + cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'` - CPPFLAGS="$cf_new_cppflags $CPPFLAGS" - fi + test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ + && test -z "${cf_tst_cflags}" \ + && cf_fix_cppflags=no + ;; +esac +done - if test -n "$cf_new_extra_cppflags" ; then +if test -n "$cf_new_cflags" ; then - EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS" - fi + test -n "$CFLAGS" && CFLAGS="$CFLAGS " + CFLAGS="${CFLAGS}$cf_new_cflags" - fi - fi - fi +fi - if test "$cf_c_inline_define" = yes ; then - if test "$ac_cv_c_inline" != no ; then +if test -n "$cf_new_cppflags" ; then -printf "%s\n" "#define HAVE_INLINE 1" >>confdefs.h + test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " + CPPFLAGS="${CPPFLAGS}$cf_new_cppflags" - else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ +fi + +if test -n "$cf_new_extra_cppflags" ; then + + + test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS " + EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags" -__inline int foo(void) { return 1; } -int -main (void) -{ -${cf_cv_main_return:-return} foo() - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - cf_cv_c_inline=yes -else case e in #( - e) cf_cv_c_inline=no ;; -esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - if test "$ac_cv_c_inline" != no ; then -printf "%s\n" "#define HAVE___INLINE 1" >>confdefs.h - fi + fi fi +fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if the compiler supports -Wno-unused-result" >&5 @@ -19840,8 +21649,26 @@ else case e in #( esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_floating" >&5 -printf "%s\n" "$with_floating" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_contrib" >&5 +printf "%s\n" "$with_contrib" >&6; } + +BUILD_LIBFLTK=0 + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to enable libfltk support" >&5 +printf %s "checking whether to enable libfltk support... " >&6; } + +# Check whether --with-libfltk was given. +if test ${with_libfltk+y} +then : + withval=$with_libfltk; with_libfltk=$withval +else case e in #( + e) with_libfltk=no ;; +esac +fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_libfltk" >&5 +printf "%s\n" "$with_libfltk" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for long long int" >&5 @@ -20007,17 +21834,43 @@ printf "%s\n" "#define HAVE_UNSIGNED_LONG_LONG_INT 1" >>confdefs.h fi + for ac_header in unistd.h +do : + ac_fn_c_check_header_compile "$LINENO" "unistd.h" "ac_cv_header_unistd_h" "$ac_includes_default" +if test "x$ac_cv_header_unistd_h" = xyes +then : + printf "%s\n" "#define HAVE_UNISTD_H 1" >>confdefs.h + +else case e in #( + e) as_fn_error $? "system headers not found; unable to continue" "$LINENO" 5 ;; +esac +fi + +done + ac_fn_c_check_header_compile "$LINENO" "endian.h" "ac_cv_header_endian_h" "$ac_includes_default" if test "x$ac_cv_header_endian_h" = xyes then : printf "%s\n" "#define HAVE_ENDIAN_H 1" >>confdefs.h +fi +ac_fn_c_check_header_compile "$LINENO" "sys/endian.h" "ac_cv_header_sys_endian_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_endian_h" = xyes +then : + printf "%s\n" "#define HAVE_SYS_ENDIAN_H 1" >>confdefs.h + fi ac_fn_c_check_header_compile "$LINENO" "machine/endian.h" "ac_cv_header_machine_endian_h" "$ac_includes_default" if test "x$ac_cv_header_machine_endian_h" = xyes then : printf "%s\n" "#define HAVE_MACHINE_ENDIAN_H 1" >>confdefs.h +fi +ac_fn_c_check_header_compile "$LINENO" "sys/byteorder.h" "ac_cv_header_sys_byteorder_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_byteorder_h" = xyes +then : + printf "%s\n" "#define HAVE_SYS_BYTEORDER_H 1" >>confdefs.h + fi ac_fn_c_check_header_compile "$LINENO" "arpa/nameser_compat.h" "ac_cv_header_arpa_nameser_compat_h" "$ac_includes_default" if test "x$ac_cv_header_arpa_nameser_compat_h" = xyes @@ -20026,6 +21879,7 @@ then : fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 printf %s "checking whether byte ordering is bigendian... " >&6; } if test ${ac_cv_c_bigendian+y} @@ -20854,38 +22708,52 @@ printf "%s\n" "#define HAVE_LONG_FILE_NAMES 1" >>confdefs.h fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if filesystem supports mixed case filenames" >&5 -printf %s "checking if filesystem supports mixed case filenames... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if filesystem supports mixed-case filenames" >&5 +printf %s "checking if filesystem supports mixed-case filenames... " >&6; } if test ${cf_cv_mixedcase+y} then : printf %s "(cached) " >&6 else case e in #( e) - rm -f conftest CONFTEST - echo test >conftest - if test -f CONFTEST ; then - cf_cv_mixedcase=no - else - cf_cv_mixedcase=yes - fi - rm -f conftest CONFTEST - ;; +if test "$cross_compiling" = yes ; then + case "$target_alias" in + (*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*|darwin*) + cf_cv_mixedcase=no + ;; + (*) + cf_cv_mixedcase=yes + ;; + esac +else + rm -f conftest CONFTEST + echo test >conftest + if test -f CONFTEST ; then + cf_cv_mixedcase=no + else + cf_cv_mixedcase=yes + fi + rm -f conftest CONFTEST +fi + ;; esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cf_cv_mixedcase" >&5 printf "%s\n" "$cf_cv_mixedcase" >&6; } - test "$cf_cv_mixedcase" = yes && \ - +test "$cf_cv_mixedcase" = yes && printf "%s\n" "#define MIXEDCASE_FILENAMES 1" >>confdefs.h - case $cf_cv_system_name in - os2*) PATHSEP=';' ;; - *) PATHSEP=':' ;; + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for PATH separator" >&5 +printf %s "checking for PATH separator... " >&6; } + case "$cf_cv_system_name" in + (os2*) PATH_SEPARATOR=';' ;; + (*) ${PATH_SEPARATOR:=':'} ;; esac + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PATH_SEPARATOR" >&5 +printf "%s\n" "$PATH_SEPARATOR" >&6; } ac_fn_c_check_header_compile "$LINENO" "sys/sendfile.h" "ac_cv_header_sys_sendfile_h" "$ac_includes_default" @@ -21545,154 +23413,576 @@ esac fi ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP_TRADITIONAL" >&5 -printf "%s\n" "$ac_cv_path_EGREP_TRADITIONAL" >&6; } - EGREP_TRADITIONAL=$ac_cv_path_EGREP_TRADITIONAL +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP_TRADITIONAL" >&5 +printf "%s\n" "$ac_cv_path_EGREP_TRADITIONAL" >&6; } + EGREP_TRADITIONAL=$ac_cv_path_EGREP_TRADITIONAL + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: determining term lib, --with-termlib options ncursesw, ncurses, tinfo, curses, termcap, termlib" >&5 +printf "%s\n" "determining term lib, --with-termlib options ncursesw, ncurses, tinfo, curses, termcap, termlib" >&6; } + + + +# Check whether --with-ncurses was given. +if test ${with_ncurses+y} +then : + withval=$with_ncurses; with_termlib=ncurses +fi + + + +# Check whether --with-ncursesw was given. +if test ${with_ncursesw+y} +then : + withval=$with_ncursesw; with_termlib=ncursesw +fi + + + +# Check whether --with-tinfo was given. +if test ${with_tinfo+y} +then : + withval=$with_tinfo; with_termlib=tinfo +fi + + + +# Check whether --with-curses was given. +if test ${with_curses+y} +then : + withval=$with_curses; with_termlib=curses +fi + + + +# Check whether --with-termcap was given. +if test ${with_termcap+y} +then : + withval=$with_termcap; with_termlib=termcap +fi + + + +# Check whether --with-termlib was given. +if test ${with_termlib+y} +then : + withval=$with_termlib; +fi + + + + cf_save_CFLAGS="$CFLAGS" + + + cf_save_LIBS="$LIBS" + cf_libterm_name="" + cf_libterm_cv_headers="" + cf_libterm_cv_terminfo=no + cf_libterm_cv_termcap=no + cf_libterm_cv_features=no + cf_result="" + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. +set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_PKG_CONFIG+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if test -n "$PKG_CONFIG"; then + ac_cv_prog_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_PKG_CONFIG="${ac_tool_prefix}pkg-config" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi ;; +esac +fi +PKG_CONFIG=$ac_cv_prog_PKG_CONFIG +if test -n "$PKG_CONFIG"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 +printf "%s\n" "$PKG_CONFIG" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_PKG_CONFIG"; then + ac_ct_PKG_CONFIG=$PKG_CONFIG + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_PKG_CONFIG+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if test -n "$ac_ct_PKG_CONFIG"; then + ac_cv_prog_ac_ct_PKG_CONFIG="$ac_ct_PKG_CONFIG" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_PKG_CONFIG="pkg-config" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi ;; +esac +fi +ac_ct_PKG_CONFIG=$ac_cv_prog_ac_ct_PKG_CONFIG +if test -n "$ac_ct_PKG_CONFIG"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_PKG_CONFIG" >&5 +printf "%s\n" "$ac_ct_PKG_CONFIG" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_PKG_CONFIG" = x; then + PKG_CONFIG="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + PKG_CONFIG=$ac_ct_PKG_CONFIG + fi +else + PKG_CONFIG="$ac_cv_prog_PKG_CONFIG" +fi + + ac_fn_c_check_header_compile "$LINENO" "curses.h" "ac_cv_header_curses_h" "$ac_includes_default" +if test "x$ac_cv_header_curses_h" = xyes +then : + printf "%s\n" "#define HAVE_CURSES_H 1" >>confdefs.h + +fi + ac_fn_c_check_header_compile "$LINENO" "termcap.h" "ac_cv_header_termcap_h" "$ac_includes_default" +if test "x$ac_cv_header_termcap_h" = xyes +then : + printf "%s\n" "#define HAVE_TERMCAP_H 1" >>confdefs.h +fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: determining term lib, --with-termlib options ncursesw, ncurses, pdcurses, tinfo, curses, termcap, termlib" >&5 -printf "%s\n" "determining term lib, --with-termlib options ncursesw, ncurses, pdcurses, tinfo, curses, termcap, termlib" >&6; } + ac_fn_c_check_header_compile "$LINENO" "term.h" "ac_cv_header_term_h" " +#if HAVE_CURSES_H +#include +#endif +#if HAVE_TERMCAP_H +#include +#endif +#include -# Check whether --with-ncurses was given. -if test ${with_ncurses+y} +" +if test "x$ac_cv_header_term_h" = xyes then : - withval=$with_ncurses; with_termlib=ncurses + printf "%s\n" "#define HAVE_TERM_H 1" >>confdefs.h + fi + CFLAGS="$cf_saved_CFLAGS $CURSES_CFLAGS" + if test -n "$with_termlib"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: explicit termlib option, checking if a suitable terminal library" >&5 +printf "%s\n" "explicit termlib option, checking if a suitable terminal library" >&6; } + termlibs="${with_termlib}" + else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no termlib options, checking for suitable terminal library" >&5 +printf "%s\n" "no termlib options, checking for suitable terminal library" >&6; } -# Check whether --with-ncursesw was given. -if test ${with_ncursesw+y} -then : - withval=$with_ncursesw; with_termlib=ncursesw -fi + case "`uname -s 2>/dev/null`" in + OSF1|SCO_SV) termlibs="ncursesw ncurses tinfo curses termlib termcap";; + *) termlibs="ncursesw ncurses tinfo termlib curses termcap";; + esac + fi + CFLAGS="$cf_saved_CFLAGS $CURSES_CFLAGS" + TERMLIB="" + cf_check_LIBS="$cf_save_LIBS" + if test -n "$CURSES_LDFLAGS"; then + test -n "$cf_check_LIBS" && cf_check_LIBS="$cf_check_LIBS " + cf_check_LIBS="${cf_check_LIBS}$CURSES_LDFLAGS" -# Check whether --with-pdcurses was given. -if test ${with_pdcurses+y} -then : - withval=$with_pdcurses; with_termlib=pdcurses -fi + fi + for libname in $termlibs; do + LIBS="$cf_check_LIBS" -# Check whether --with-tinfo was given. -if test ${with_tinfo+y} + if test "$libname" = "ncursesw" || test "$libname" = "ncurses"; then + as_ac_Lib=`printf "%s\n" "ac_cv_lib_$libname""_setupterm" | sed "$as_sed_sh"` +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for setupterm in -l$libname" >&5 +printf %s "checking for setupterm in -l$libname... " >&6; } +if eval test \${$as_ac_Lib+y} then : - withval=$with_tinfo; with_termlib=tinfo + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-l$libname $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char setupterm (void); +int +main (void) +{ +return setupterm (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + eval "$as_ac_Lib=yes" +else case e in #( + e) eval "$as_ac_Lib=no" ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac fi +eval ac_res=\$$as_ac_Lib + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes" +then : + cat >>confdefs.h <<_ACEOF +#define `printf "%s\n" "HAVE_LIB$libname" | sed "$as_sed_cpp"` 1 +_ACEOF + LIBS="-l$libname $LIBS" +fi -# Check whether --with-curses was given. -if test ${with_curses+y} + if test "x$cf_check_LIBS" = "x$LIBS"; then + if test -z "$CURSES_LDFLAGS" && test -n "$PKG_CONFIG"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether pkg-config information available" >&5 +printf %s "checking whether pkg-config information available... " >&6; } + cf_pkg_config=`$PKG_CONFIG $libname --libs-only-L --libs-only-other 2>/dev/null` + if test $? = 0 && test -n "$cf_pkg_config"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cf_pkg_config" >&5 +printf "%s\n" "$cf_pkg_config" >&6; } + LIBS="${cf_check_LIBS} ${cf_pkg_config}" + { eval ac_cv_lib_${libname}_setupterm=; unset ac_cv_lib_${libname}_setupterm;} + as_ac_Lib=`printf "%s\n" "ac_cv_lib_$libname""_setupterm" | sed "$as_sed_sh"` +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for setupterm in -l$libname" >&5 +printf %s "checking for setupterm in -l$libname... " >&6; } +if eval test \${$as_ac_Lib+y} then : - withval=$with_curses; with_termlib=curses -fi + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-l$libname $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char setupterm (void); +int +main (void) +{ +return setupterm (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + eval "$as_ac_Lib=yes" +else case e in #( + e) eval "$as_ac_Lib=no" ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac +fi +eval ac_res=\$$as_ac_Lib + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes" +then : + cat >>confdefs.h <<_ACEOF +#define `printf "%s\n" "HAVE_LIB$libname" | sed "$as_sed_cpp"` 1 +_ACEOF + LIBS="-l$libname $LIBS" -# Check whether --with-termcap was given. -if test ${with_termcap+y} -then : - withval=$with_termcap; with_termlib=termcap +else case e in #( + e) LIBS="$cf_check_LIBS" ;; +esac fi + if test "x$cf_check_LIBS" != "x$LIBS"; then + TERMLIB="${cf_pkg_config} -l${libname}" + fi + else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none" >&5 +printf "%s\n" "none" >&6; } + fi + fi + fi + if test "x$cf_check_LIBS" != "x$LIBS"; then -# Check whether --with-termlib was given. -if test ${with_termlib+y} -then : - withval=$with_termlib; -fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for terminfo setupterm(), tigetxxx() and tparm()" >&5 +printf %s "checking for terminfo setupterm(), tigetxxx() and tparm()... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +extern int setupterm(char *, int, int *); +extern int tigetflag(char *); +extern int tigetnum(char *); +extern char *tigetstr(char *); +extern char *tparm(const char *str, ...); +int +main (void) +{ - cf_save_LIBS="$LIBS" - termlib_name="" - termlib_cv_terminfo=no - termlib_cv_termcap=no + int err = 0; + setupterm((char *)"nonexistentterminal",1,(int *)&err); + tigetflag((char *)"flg"); + tigetnum((char *)"num"); + tigetstr((char *)"str"); + tparm("%p1%d", 1, (void *)0); - ac_fn_c_check_header_compile "$LINENO" "curses.h" "ac_cv_header_curses_h" "$ac_includes_default" -if test "x$ac_cv_header_curses_h" = xyes + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" then : - printf "%s\n" "#define HAVE_CURSES_H 1" >>confdefs.h - + cf_result=yes +else case e in #( + e) cf_result=no ;; +esac fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext - ac_fn_c_check_header_compile "$LINENO" "termcap.h" "ac_cv_header_termcap_h" "$ac_includes_default" -if test "x$ac_cv_header_termcap_h" = xyes + if test "$cf_result" = "yes"; then + if test "$cross_compiling" = yes then : - printf "%s\n" "#define HAVE_TERMCAP_H 1" >>confdefs.h + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "cannot run test program while cross compiling +See 'config.log' for more details" "$LINENO" 5; } +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +extern const char *curses_version(void); +int +main (void) +{ + + /*routine specific to ncurses*/ + const char *v = curses_version(); + if (v) printf("%s... ", v); + return (v == 0); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO" +then : + cf_result=yes +else case e in #( + e) cf_result=no ;; +esac +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac fi - ac_fn_c_check_header_compile "$LINENO" "term.h" "ac_cv_header_term_h" " -#if HAVE_CURSES_H -#include -#endif -#if HAVE_TERMCAP_H -#include -#endif -#include + fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cf_result" >&5 +printf "%s\n" "$cf_result" >&6; } + fi + LIBS="$cf_save_LIBS" + if test "$cf_result" = "yes"; then + cf_libterm_cv_terminfo=yes + cf_libterm_name=$libname + break + fi -" -if test "x$ac_cv_header_term_h" = xyes + else if test "$libname" = "tinfo"; then + as_ac_Lib=`printf "%s\n" "ac_cv_lib_$libname""_setupterm" | sed "$as_sed_sh"` +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for setupterm in -l$libname" >&5 +printf %s "checking for setupterm in -l$libname... " >&6; } +if eval test \${$as_ac_Lib+y} then : - printf "%s\n" "#define HAVE_TERM_H 1" >>confdefs.h + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-l$libname $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char setupterm (void); +int +main (void) +{ +return setupterm (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + eval "$as_ac_Lib=yes" +else case e in #( + e) eval "$as_ac_Lib=no" ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac +fi +eval ac_res=\$$as_ac_Lib + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes" +then : + cat >>confdefs.h <<_ACEOF +#define `printf "%s\n" "HAVE_LIB$libname" | sed "$as_sed_cpp"` 1 +_ACEOF + + LIBS="-l$libname $LIBS" fi + if test "x$cf_check_LIBS" != "x$LIBS"; then - if test -n "$with_termlib"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: termcap library ... $with_termlib" >&5 -printf "%s\n" "termcap library ... $with_termlib" >&6; } - termlib_name=$with_termlib - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for linking with $with_termlib library" >&5 -printf %s "checking for linking with $with_termlib library... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for terminfo setupterm(), tigetxxx() and tparm()" >&5 +printf %s "checking for terminfo setupterm(), tigetxxx() and tparm()... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +extern int setupterm(char *, int, int *); +extern int tigetflag(char *); +extern int tigetnum(char *); +extern char *tigetstr(char *); +extern char *tparm(const char *str, ...); + int main (void) { + int err = 0; + setupterm((char *)"nonexistentterminal",1,(int *)&err); + tigetflag((char *)"flg"); + tigetnum((char *)"num"); + tigetstr((char *)"str"); + tparm("%p1%d", 1, (void *)0); + ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: OK" >&5 -printf "%s\n" "OK" >&6; } + cf_result=yes else case e in #( - e) as_fn_error $? "FAILED" "$LINENO" 5 ;; + e) cf_result=no ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext - else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no termlib options, checking for suitable terminal library" >&5 -printf "%s\n" "no termlib options, checking for suitable terminal library" >&6; } - - case "`uname -s 2>/dev/null`" in - OSF1|SCO_SV) termlibs="ncursesw ncurses tinfo curses termlib termcap";; - *) termlibs="ncursesw ncurses tinfo termlib termcap curses";; - esac + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cf_result" >&5 +printf "%s\n" "$cf_result" >&6; } + fi + LIBS="$cf_save_LIBS" + if test "$cf_result" = "yes"; then + cf_libterm_cv_terminfo=yes + cf_libterm_name=$libname + break + fi - for libname in $termlibs; do - as_ac_Lib=`printf "%s\n" "ac_cv_lib_${libname}""_tgetent" | sed "$as_sed_sh"` -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tgetent in -l${libname}" >&5 -printf %s "checking for tgetent in -l${libname}... " >&6; } + else + as_ac_Lib=`printf "%s\n" "ac_cv_lib_$libname""_tgetent" | sed "$as_sed_sh"` +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tgetent in -l$libname" >&5 +printf %s "checking for tgetent in -l$libname... " >&6; } if eval test \${$as_ac_Lib+y} then : printf %s "(cached) " >&6 else case e in #( e) ac_check_lib_save_LIBS=$LIBS -LIBS="-l${libname} $LIBS" +LIBS="-l$libname $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -21732,46 +24022,92 @@ printf "%s\n" "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes" then : cat >>confdefs.h <<_ACEOF -#define `printf "%s\n" "HAVE_LIB${libname}" | sed "$as_sed_cpp"` 1 +#define `printf "%s\n" "HAVE_LIB$libname" | sed "$as_sed_cpp"` 1 _ACEOF - LIBS="-l${libname} $LIBS" + LIBS="-l$libname $LIBS" fi - if test "x$cf_save_LIBS" != "x$LIBS"; then - if test "$cross_compiling" = yes + if test "x$cf_check_LIBS" = "x$LIBS" && test "$libname" = "curses"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we need both curses and termcap libraries" >&5 +printf %s "checking if we need both curses and termcap libraries... " >&6; } + LIBS="$cf_check_LIBS -lcurses -ltermcap" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +extern int tgetent(char *, const char *); + +int +main (void) +{ + + char buffer[1024 * 2]; + tgetent(buffer, "nonexistentterminal"); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + cf_result=yes; TERMLIB="$CURSES_LDFLAGS -lcurses -ltermcap"; { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } +else case e in #( + e) cf_result=no; LIBS="$cf_check_LIBS"; { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + fi + if test "x$cf_check_LIBS" != "x$LIBS"; then + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for termcap tgetxxx() and tgoto()" >&5 +printf %s "checking for termcap tgetxxx() and tgoto()... " >&6; } + if test "$cross_compiling" = yes then : - res="FAIL" + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "cannot run test program while cross compiling +See 'config.log' for more details" "$LINENO" 5; } else case e in #( e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +#ifdef HAVE_CURSES_H +#include +#endif #ifdef HAVE_TERMCAP_H -# include +#include #endif #ifdef HAVE_TERM_H -# include -#endif -#if STDC_HEADERS -# include -# include +#include #endif + int main (void) { - char *s; s=(char *)tgoto("%p1%d", 0, 1); - return 0; + char buffer[1024 * 2]; + char *str = (char *)0; + tgetent(buffer, "nonexistentterminal"); + tgetflag((char *)"FF"); + tgetnum((char *)"NN"); + tgetstr((char *)"SS", &str); + tgoto("%p1%d", 0, 1); + ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO" then : - res="OK" + cf_result=yes else case e in #( - e) res="FAIL" ;; + e) cf_result=no ;; esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ @@ -21779,120 +24115,166 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ esac fi - LIBS="$cf_save_LIBS" - if test "$res" = "OK"; then - termlib_name=$libname - break - fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libname library is not usable" >&5 -printf "%s\n" "$libname library is not usable" >&6; } + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cf_result" >&5 +printf "%s\n" "$cf_result" >&6; } fi - done + LIBS="$cf_save_LIBS" + if test "$cf_result" = "yes"; then + cf_libterm_cv_termcap=yes + cf_libterm_name=$libname + break + fi + fi; fi + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libname library is not usable" >&5 +printf "%s\n" "$libname library is not usable" >&6; } + done + + if test -n "$cf_libterm_name"; then + if test -z "$TERMLIB"; then + TERMLIB="$CURSES_LDFLAGS" + + test -n "$TERMLIB" && TERMLIB="$TERMLIB " + TERMLIB="${TERMLIB}"-l${cf_libterm_name}"" - if test -z "$termlib_name"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no terminal library found" >&5 -printf "%s\n" "no terminal library found" >&6; } fi + LIBS="$LIBS $TERMLIB" + else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no terminal library found" >&5 +printf "%s\n" "no terminal library found" >&6; } fi - if test -n "$termlib_name"; then - if test "x$termlib_name" = "xtermlib"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: using internal terminal interface library" >&5 -printf "%s\n" "$as_me: using internal terminal interface library" >&6;} - - elif test "x$termlib_name" = "xyes"; then + if test -n "$cf_libterm_name"; then + if test "x$cf_libterm_name" = "xtermlib" || test "x$cf_libterm_name" = "xyes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: using internal terminal interface library" >&5 printf "%s\n" "$as_me: using internal terminal interface library" >&6;} else - TERMLIB="-l$termlib_name" - LIBS="$LIBS $TERMLIB" + if test "$cf_libterm_cv_terminfo" != "yes"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for setupterm and tigetxxx()" >&5 -printf %s "checking for setupterm and tigetxxx()... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for terminfo setupterm(), tigetxxx() and tparm()" >&5 +printf %s "checking for terminfo setupterm(), tigetxxx() and tparm()... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#ifdef HAVE_CURSES_H -#include -#endif -#ifdef HAVE_TERM_H -#include -#endif +extern int setupterm(char *, int, int *); +extern int tigetflag(char *); +extern int tigetnum(char *); +extern char *tigetstr(char *); +extern char *tparm(const char *str, ...); + int main (void) { -setupterm("terminalwontexist",0,0); tigetstr("str"); tigetnum("num"); tigetflag("flag"); + + int err = 0; + setupterm((char *)"nonexistentterminal",1,(int *)&err); + tigetflag((char *)"flg"); + tigetnum((char *)"num"); + tigetstr((char *)"str"); + tparm("%p1%d", 1, (void *)0); + ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : - termlib_cv_terminfo=yes; { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + cf_result=yes else case e in #( - e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } ;; + e) cf_result=no ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tgetent() and tgetxxx()" >&5 -printf %s "checking for tgetent() and tgetxxx()... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cf_result" >&5 +printf "%s\n" "$cf_result" >&6; } + cf_libterm_cv_terminfo=$cf_result + fi + + if test "$cf_libterm_cv_termcap" != "yes"; then + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for termcap tgetxxx() and tgoto()" >&5 +printf %s "checking for termcap tgetxxx() and tgoto()... " >&6; } + if test "$cross_compiling" = yes +then : + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "cannot run test program while cross compiling +See 'config.log' for more details" "$LINENO" 5; } +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_CURSES_H #include #endif +#ifdef HAVE_TERMCAP_H +#include +#endif #ifdef HAVE_TERM_H #include #endif + int main (void) { -char buffer[10000]; char *area = (char *)0; -int res = tgetent(buffer, "terminalwontexist"); tgetstr("str", &area); tgetnum("num"); tgetflag("flag"); + + char buffer[1024 * 2]; + char *str = (char *)0; + tgetent(buffer, "nonexistentterminal"); + tgetflag((char *)"FF"); + tgetnum((char *)"NN"); + tgetstr((char *)"SS", &str); + tgoto("%p1%d", 0, 1); + ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" +if ac_fn_c_try_run "$LINENO" then : - termlib_cv_termcap=yes; { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + cf_result=yes else case e in #( - e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } ;; + e) cf_result=no ;; +esac +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext - if test "$termlib_cv_terminfo" != "yes"; then - if test "$termlib_cv_termcap" != "yes"; then + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cf_result" >&5 +printf "%s\n" "$cf_result" >&6; } + cf_libterm_cv_termcap=$cf_result + fi + + if test "$cf_libterm_cv_terminfo" != "yes"; then + if test "$cf_libterm_cv_termcap" != "yes"; then as_fn_error $? " You need to install a suitable terminal library; for example ncurses. alternatively specify the name of the library with --with-termlib=." "$LINENO" 5 fi fi fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: using terminal library... $TERMLIB" >&5 +printf "%s\n" "using terminal library... $TERMLIB" >&6; } fi - TERMLIB="-l$termlib_name" - if test "$termlib_cv_terminfo" = "no"; then + if test "$cf_libterm_cv_terminfo" = "no"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we talk terminfo" >&5 printf %s "checking whether we talk terminfo... " >&6; } -if test ${termlib_cv_terminfo+y} +if test ${cf_libterm_cv_terminfo+y} then : printf %s "(cached) " >&6 else case e in #( e) if test "$cross_compiling" = yes then : - as_fn_error $? "cross-compiling: please set 'termlib_cv_terminfo'" "$LINENO" 5 + as_fn_error $? "cross-compiling: please set 'cf_libterm_cv_terminfo'" "$LINENO" 5 else case e in #( e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -21911,9 +24293,8 @@ int main (void) { - char *s; s=(char *)tgoto("%p1%d", 0, 1); - exit(!strcmp(s==0 ? "" : s, "1")); - return 0; + char *s = (char *)tgoto("%p1%d", 0, 1); + return (0 == strcmp(s == 0 ? "" : s, "1")); ; return 0; @@ -21921,9 +24302,9 @@ main (void) _ACEOF if ac_fn_c_try_run "$LINENO" then : - termlib_cv_terminfo=no + cf_libterm_cv_terminfo=no else case e in #( - e) termlib_cv_terminfo=yes ;; + e) cf_libterm_cv_terminfo=yes ;; esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ @@ -21933,103 +24314,25 @@ fi ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $termlib_cv_terminfo" >&5 -printf "%s\n" "$termlib_cv_terminfo" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cf_libterm_cv_terminfo" >&5 +printf "%s\n" "$cf_libterm_cv_terminfo" >&6; } fi - if test "x$termlib_cv_terminfo" = "xyes"; then + if test "x$cf_libterm_cv_terminfo" = "xyes"; then printf "%s\n" "#define HAVE_TERMINFO 1" >>confdefs.h fi - if test "x$termlib_cv_termcap" = "xyes"; then + if test "x$cf_libterm_cv_termcap" = "xyes"; then printf "%s\n" "#define HAVE_TERMCAP 1" >>confdefs.h fi - if test "x$termlib_name" = "xncursesw"; then + if test "x$cf_libterm_name" = "xncursesw"; then printf "%s\n" "#define HAVE_LIBNCURSESW 1" >>confdefs.h - ac_fn_c_check_header_compile "$LINENO" "nc_alloc.h" "ac_cv_header_nc_alloc_h" "$ac_includes_default" -if test "x$ac_cv_header_nc_alloc_h" = xyes -then : - printf "%s\n" "#define HAVE_NC_ALLOC_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "ncursesw/nc_alloc.h" "ac_cv_header_ncursesw_nc_alloc_h" "$ac_includes_default" -if test "x$ac_cv_header_ncursesw_nc_alloc_h" = xyes -then : - printf "%s\n" "#define HAVE_NCURSESW_NC_ALLOC_H 1" >>confdefs.h - -fi - - ac_fn_c_check_header_compile "$LINENO" "nomacros.h" "ac_cv_header_nomacros_h" "$ac_includes_default" -if test "x$ac_cv_header_nomacros_h" = xyes -then : - printf "%s\n" "#define HAVE_NOMACROS_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "ncursesw/nomacros.h" "ac_cv_header_ncursesw_nomacros_h" "$ac_includes_default" -if test "x$ac_cv_header_ncursesw_nomacros_h" = xyes -then : - printf "%s\n" "#define HAVE_NCURSESW_NOMACROS_H 1" >>confdefs.h - -fi - - ac_fn_c_check_header_compile "$LINENO" "ncursesw.h" "ac_cv_header_ncursesw_h" "$ac_includes_default" -if test "x$ac_cv_header_ncursesw_h" = xyes -then : - printf "%s\n" "#define HAVE_NCURSESW_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "ncursesw/ncursesw.h" "ac_cv_header_ncursesw_ncursesw_h" "$ac_includes_default" -if test "x$ac_cv_header_ncursesw_ncursesw_h" = xyes -then : - printf "%s\n" "#define HAVE_NCURSESW_NCURSESW_H 1" >>confdefs.h - -fi - - ac_fn_c_check_header_compile "$LINENO" "curses.h" "ac_cv_header_curses_h" "$ac_includes_default" -if test "x$ac_cv_header_curses_h" = xyes -then : - printf "%s\n" "#define HAVE_CURSES_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "ncursesw/curses.h" "ac_cv_header_ncursesw_curses_h" "$ac_includes_default" -if test "x$ac_cv_header_ncursesw_curses_h" = xyes -then : - printf "%s\n" "#define HAVE_NCURSESW_CURSES_H 1" >>confdefs.h - -fi - - ac_fn_c_check_header_compile "$LINENO" "termcap.h" "ac_cv_header_termcap_h" "$ac_includes_default" -if test "x$ac_cv_header_termcap_h" = xyes -then : - printf "%s\n" "#define HAVE_TERMCAP_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "ncursesw/termcap.h" "ac_cv_header_ncursesw_termcap_h" "$ac_includes_default" -if test "x$ac_cv_header_ncursesw_termcap_h" = xyes -then : - printf "%s\n" "#define HAVE_NCURSESW_TERMCAP_H 1" >>confdefs.h - -fi - - ac_fn_c_check_header_compile "$LINENO" "term.h" "ac_cv_header_term_h" "$ac_includes_default" -if test "x$ac_cv_header_term_h" = xyes -then : - printf "%s\n" "#define HAVE_TERM_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "ncursesw/term.h" "ac_cv_header_ncursesw_term_h" "$ac_includes_default" -if test "x$ac_cv_header_ncursesw_term_h" = xyes -then : - printf "%s\n" "#define HAVE_NCURSESW_TERM_H 1" >>confdefs.h - -fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for main in -lncursesw" >&5 printf %s "checking for main in -lncursesw... " >&6; } if test ${ac_cv_lib_ncursesw_main+y} @@ -22114,89 +24417,12 @@ then : fi + cf_libterm_cv_headers=ncursesw - else if test "x$termlib_name" = "xncurses"; then + elif test "x$cf_libterm_name" = "xncurses"; then printf "%s\n" "#define HAVE_LIBNCURSES 1" >>confdefs.h - ac_fn_c_check_header_compile "$LINENO" "nc_alloc.h" "ac_cv_header_nc_alloc_h" "$ac_includes_default" -if test "x$ac_cv_header_nc_alloc_h" = xyes -then : - printf "%s\n" "#define HAVE_NC_ALLOC_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "ncurses/nc_alloc.h" "ac_cv_header_ncurses_nc_alloc_h" "$ac_includes_default" -if test "x$ac_cv_header_ncurses_nc_alloc_h" = xyes -then : - printf "%s\n" "#define HAVE_NCURSES_NC_ALLOC_H 1" >>confdefs.h - -fi - - ac_fn_c_check_header_compile "$LINENO" "nomacros.h" "ac_cv_header_nomacros_h" "$ac_includes_default" -if test "x$ac_cv_header_nomacros_h" = xyes -then : - printf "%s\n" "#define HAVE_NOMACROS_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "ncurses/nomacros.h" "ac_cv_header_ncurses_nomacros_h" "$ac_includes_default" -if test "x$ac_cv_header_ncurses_nomacros_h" = xyes -then : - printf "%s\n" "#define HAVE_NCURSES_NOMACROS_H 1" >>confdefs.h - -fi - - ac_fn_c_check_header_compile "$LINENO" "ncurses.h" "ac_cv_header_ncurses_h" "$ac_includes_default" -if test "x$ac_cv_header_ncurses_h" = xyes -then : - printf "%s\n" "#define HAVE_NCURSES_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "ncurses/ncurses.h" "ac_cv_header_ncurses_ncurses_h" "$ac_includes_default" -if test "x$ac_cv_header_ncurses_ncurses_h" = xyes -then : - printf "%s\n" "#define HAVE_NCURSES_NCURSES_H 1" >>confdefs.h - -fi - - ac_fn_c_check_header_compile "$LINENO" "curses.h" "ac_cv_header_curses_h" "$ac_includes_default" -if test "x$ac_cv_header_curses_h" = xyes -then : - printf "%s\n" "#define HAVE_CURSES_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "ncurses/curses.h" "ac_cv_header_ncurses_curses_h" "$ac_includes_default" -if test "x$ac_cv_header_ncurses_curses_h" = xyes -then : - printf "%s\n" "#define HAVE_NCURSES_CURSES_H 1" >>confdefs.h - -fi - - ac_fn_c_check_header_compile "$LINENO" "termcap.h" "ac_cv_header_termcap_h" "$ac_includes_default" -if test "x$ac_cv_header_termcap_h" = xyes -then : - printf "%s\n" "#define HAVE_TERMCAP_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "ncurses/termcap.h" "ac_cv_header_ncurses_termcap_h" "$ac_includes_default" -if test "x$ac_cv_header_ncurses_termcap_h" = xyes -then : - printf "%s\n" "#define HAVE_NCURSES_TERMCAP_H 1" >>confdefs.h - -fi - - ac_fn_c_check_header_compile "$LINENO" "term.h" "ac_cv_header_term_h" "$ac_includes_default" -if test "x$ac_cv_header_term_h" = xyes -then : - printf "%s\n" "#define HAVE_TERM_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "ncurses/term.h" "ac_cv_header_ncurses_term_h" "$ac_includes_default" -if test "x$ac_cv_header_ncurses_term_h" = xyes -then : - printf "%s\n" "#define HAVE_NCURSES_TERM_H 1" >>confdefs.h - -fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for main in -lncurses" >&5 printf %s "checking for main in -lncurses... " >&6; } if test ${ac_cv_lib_ncurses_main+y} @@ -22281,80 +24507,313 @@ then : fi + if test -z "$with_termlib"; then + cf_libterm_cv_headers=ncursesw + else + cf_libterm_cv_headers=ncurses + fi + fi + + cf_libterm_includes="/usr/local/include" + if test -z "$CURSES_CFLAGS" && test -n "$PKG_CONFIG"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether pkg-config information available" >&5 +printf %s "checking whether pkg-config information available... " >&6; } + cf_pkg_config=`$PKG_CONFIG $cf_libterm_name --cflags-only-I 2>/dev/null` + if test $? = 0 && test -n "$cf_pkg_config"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cf_pkg_config" >&5 +printf "%s\n" "$cf_pkg_config" >&6; } + cf_libterm_includes="" + for cf_config in $cf_pkg_config; do + + cf_include=${cf_config#-I} + if test "$cf_include" = "$cf_config"; then + continue + fi + + cf_result=yes + for cf_config in $cf_libterm_includes; do + if test $cf_config = $cf_include; then + cf_result=no + break + fi + done + if test $cf_result = yes; then - else if test "x$termlib_name" = "xpdcurses"; then + test -n "$cf_libterm_includes" && cf_libterm_includes="$cf_libterm_includes " + cf_libterm_includes="${cf_libterm_includes}$cf_include" -printf "%s\n" "#define HAVE_LIBPDCURSES 1" >>confdefs.h + fi + done + else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none" >&5 +printf "%s\n" "none" >&6; } + fi + fi - ac_fn_c_check_header_compile "$LINENO" "pdcurses.h" "ac_cv_header_pdcurses_h" "$ac_includes_default" -if test "x$ac_cv_header_pdcurses_h" = xyes + if test -n "$cf_libterm_cv_headers"; then + + + cf_have_ncurses_h=no + if test "x$cf_libterm_cv_headers" = "xncursesw"; then + for ac_header in ncursesw/curses.h +do : + ac_fn_c_check_header_compile "$LINENO" "ncursesw/curses.h" "ac_cv_header_ncursesw_curses_h" "$ac_includes_default" +if test "x$ac_cv_header_ncursesw_curses_h" = xyes then : - printf "%s\n" "#define HAVE_PDCURSES_H 1" >>confdefs.h + printf "%s\n" "#define HAVE_NCURSESW_CURSES_H 1" >>confdefs.h + cf_have_ncurses_h=yesa +fi +done + + if test "x$cf_have_ncurses_h" = "xno" && test -z "$CURSES_CFLAGS" ; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking secondary ncurses directories" >&5 +printf "%s\n" "$as_me: checking secondary ncurses directories" >&6;} + for cf_include in $cf_libterm_includes; do + if test "$cf_include" != "${cf_include%/ncurses*}"; then + continue + fi + CFLAGS="$cf_saved_CFLAGS -I$cf_include" + { ac_cv_header_ncursesw_curses_h=; unset ac_cv_header_ncursesw_curses_h;} + ac_fn_c_check_header_compile "$LINENO" "ncursesw/curses.h" "ac_cv_header_ncursesw_curses_h" "$ac_includes_default" +if test "x$ac_cv_header_ncursesw_curses_h" = xyes +then : + cf_have_ncurses_h=yesa fi -ac_fn_c_check_header_compile "$LINENO" "pdterm.h" "ac_cv_header_pdterm_h" "$ac_includes_default" -if test "x$ac_cv_header_pdterm_h" = xyes + + if test "x$cf_have_ncurses_h" = "xyesa"; then + CURSES_CFLAGS="-I$cf_include" + break + fi + CFLAGS="$cf_saved_CFLAGS" + done + fi + + if test "x$cf_have_ncurses_h" = "xyesa"; then + for ac_header in ncursesw/nc_alloc.h +do : + ac_fn_c_check_header_compile "$LINENO" "ncursesw/nc_alloc.h" "ac_cv_header_ncursesw_nc_alloc_h" "$ac_includes_default" +if test "x$ac_cv_header_ncursesw_nc_alloc_h" = xyes then : - printf "%s\n" "#define HAVE_PDTERM_H 1" >>confdefs.h + printf "%s\n" "#define HAVE_NCURSESW_NC_ALLOC_H 1" >>confdefs.h + have_nc_alloc_h +fi +done + for ac_header in ncursesw/nomacros.h +do : + ac_fn_c_check_header_compile "$LINENO" "ncursesw/nomacros.h" "ac_cv_header_ncursesw_nomacros_h" "$ac_includes_default" +if test "x$ac_cv_header_ncursesw_nomacros_h" = xyes +then : + printf "%s\n" "#define HAVE_NCURSESW_NOMACROS_H 1" >>confdefs.h + have_nomacros_h fi -ac_fn_c_check_header_compile "$LINENO" "curses.h" "ac_cv_header_curses_h" "$ac_includes_default" -if test "x$ac_cv_header_curses_h" = xyes + +done + ac_fn_c_check_header_compile "$LINENO" "ncursesw/termcap.h" "ac_cv_header_ncursesw_termcap_h" "$ac_includes_default" +if test "x$ac_cv_header_ncursesw_termcap_h" = xyes then : - printf "%s\n" "#define HAVE_CURSES_H 1" >>confdefs.h + printf "%s\n" "#define HAVE_NCURSESW_TERMCAP_H 1" >>confdefs.h fi -ac_fn_c_check_header_compile "$LINENO" "term.h" "ac_cv_header_term_h" "$ac_includes_default" -if test "x$ac_cv_header_term_h" = xyes + + ac_fn_c_check_header_compile "$LINENO" "ncursesw/term.h" "ac_cv_header_ncursesw_term_h" "$ac_includes_default" +if test "x$ac_cv_header_ncursesw_term_h" = xyes then : - printf "%s\n" "#define HAVE_TERM_H 1" >>confdefs.h + printf "%s\n" "#define HAVE_NCURSESW_TERM_H 1" >>confdefs.h fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for main in -lpdcurses" >&5 -printf %s "checking for main in -lpdcurses... " >&6; } -if test ${ac_cv_lib_pdcurses_main+y} + fi + + if test "x$cf_have_ncurses_h" = "xno"; then + for ac_header in ncursesw.h +do : + ac_fn_c_check_header_compile "$LINENO" "ncursesw.h" "ac_cv_header_ncursesw_h" "$ac_includes_default" +if test "x$ac_cv_header_ncursesw_h" = xyes then : - printf %s "(cached) " >&6 -else case e in #( - e) ac_check_lib_save_LIBS=$LIBS -LIBS="-lpdcurses $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ + printf "%s\n" "#define HAVE_NCURSESW_H 1" >>confdefs.h + cf_have_ncurses_h=yesb +fi +done + if test "x$cf_have_ncurses_h" = "xno" && test -z "$CURSES_CFLAGS" ; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking secondary ncurses directories" >&5 +printf "%s\n" "$as_me: checking secondary ncurses directories" >&6;} + for cf_include in $cf_libterm_includes; do + CFLAGS="$cf_saved_CFLAGS -I$cf_include" + { ac_cv_header_ncursesw_h=; unset ac_cv_header_ncursesw_h;} + for ac_header in ncursesw.h +do : + ac_fn_c_check_header_compile "$LINENO" "ncursesw.h" "ac_cv_header_ncursesw_h" "$ac_includes_default" +if test "x$ac_cv_header_ncursesw_h" = xyes +then : + printf "%s\n" "#define HAVE_NCURSESW_H 1" >>confdefs.h + cf_have_ncurses_h=yesb +fi -int -main (void) -{ -return main (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" +done + if test "x$cf_have_ncurses_h" = "xyesb"; then + CURSES_CFLAGS="-I$cf_include" + break + fi + CFLAGS="$cf_saved_CFLAGS" + done + fi + fi + + if test "x$cf_have_ncurses_h" = "xno"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: checking for common ncurses header" >&5 +printf "%s\n" "checking for common ncurses header" >&6; } + cf_libterm_cv_headers=ncurses + fi + fi + + if test "x$cf_libterm_cv_headers" = "xncurses"; then + + for ac_header in ncurses/curses.h +do : + ac_fn_c_check_header_compile "$LINENO" "ncurses/curses.h" "ac_cv_header_ncurses_curses_h" "$ac_includes_default" +if test "x$ac_cv_header_ncurses_curses_h" = xyes then : - ac_cv_lib_pdcurses_main=yes -else case e in #( - e) ac_cv_lib_pdcurses_main=no ;; -esac + printf "%s\n" "#define HAVE_NCURSES_CURSES_H 1" >>confdefs.h + cf_have_ncurses_h=yesc fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS ;; -esac + +done + + if test "x$cf_have_ncurses_h" = "xno" && test -z "$CURSES_CFLAGS" ; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: checking secondary ncurses directories" >&5 +printf "%s\n" "checking secondary ncurses directories" >&6; } + for cf_include in $cf_libterm_includes; do + if test "$cf_include" != "${cf_include%/ncurses*}"; then + continue + fi + CFLAGS="$cf_saved_CFLAGS -I$cf_include" + { ac_cv_header_ncurses_curses_h=; unset ac_cv_header_ncurses_curses_h;} + for ac_header in ncurses/curses.h +do : + ac_fn_c_check_header_compile "$LINENO" "ncurses/curses.h" "ac_cv_header_ncurses_curses_h" "$ac_includes_default" +if test "x$ac_cv_header_ncurses_curses_h" = xyes +then : + printf "%s\n" "#define HAVE_NCURSES_CURSES_H 1" >>confdefs.h + cf_have_ncurses_h=yesc fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pdcurses_main" >&5 -printf "%s\n" "$ac_cv_lib_pdcurses_main" >&6; } -if test "x$ac_cv_lib_pdcurses_main" = xyes + +done + if test "x$cf_have_ncurses_h" = "xyesc"; then + CURSES_CFLAGS="-I$cf_include" + break + fi + CFLAGS="$cf_saved_CFLAGS" + done + fi + + if test "x$cf_have_ncurses_h" = "xyesc" ; then + for ac_header in ncurses/nc_alloc.h +do : + ac_fn_c_check_header_compile "$LINENO" "ncurses/nc_alloc.h" "ac_cv_header_ncurses_nc_alloc_h" "$ac_includes_default" +if test "x$ac_cv_header_ncurses_nc_alloc_h" = xyes +then : + printf "%s\n" "#define HAVE_NCURSES_NC_ALLOC_H 1" >>confdefs.h + have_nc_alloc_h +fi + +done + for ac_header in ncurses/nomacros.h +do : + ac_fn_c_check_header_compile "$LINENO" "ncurses/nomacros.h" "ac_cv_header_ncurses_nomacros_h" "$ac_includes_default" +if test "x$ac_cv_header_ncurses_nomacros_h" = xyes +then : + printf "%s\n" "#define HAVE_NCURSES_NOMACROS_H 1" >>confdefs.h + have_nomacros_h +fi + +done + ac_fn_c_check_header_compile "$LINENO" "ncurses/termcap.h" "ac_cv_header_ncurses_termcap_h" "$ac_includes_default" +if test "x$ac_cv_header_ncurses_termcap_h" = xyes +then : + printf "%s\n" "#define HAVE_NCURSES_TERMCAP_H 1" >>confdefs.h + +fi + + ac_fn_c_check_header_compile "$LINENO" "ncurses/term.h" "ac_cv_header_ncurses_term_h" "$ac_includes_default" +if test "x$ac_cv_header_ncurses_term_h" = xyes +then : + printf "%s\n" "#define HAVE_NCURSES_TERM_H 1" >>confdefs.h + +fi + + fi + + if test "x$cf_have_ncurses_h" = "xno" ; then + for ac_header in ncurses.h +do : + ac_fn_c_check_header_compile "$LINENO" "ncurses.h" "ac_cv_header_ncurses_h" "$ac_includes_default" +if test "x$ac_cv_header_ncurses_h" = xyes +then : + printf "%s\n" "#define HAVE_NCURSES_H 1" >>confdefs.h + cf_have_ncurses_h=yesd +fi + +done + + if test "x$cf_have_ncurses_h" = "xno" && test -z "$CURSES_CFLAGS" ; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking secondary ncurse directories" >&5 +printf "%s\n" "$as_me: checking secondary ncurse directories" >&6;} + for cf_include in $cf_libterm_includes; do + CFLAGS="$cf_saved_CFLAGS -I$cf_include" + { ac_cv_header_ncurses_h=; unset ac_cv_header_ncurses_h;} + for ac_header in ncurses.h +do : + ac_fn_c_check_header_compile "$LINENO" "ncurses.h" "ac_cv_header_ncurses_h" "$ac_includes_default" +if test "x$ac_cv_header_ncurses_h" = xyes +then : + printf "%s\n" "#define HAVE_NCURSES_H 1" >>confdefs.h + cf_have_ncurses_h=yesd +fi + +done + if test "x$cf_have_ncurses_h" = "xyesd"; then + CURSES_CFLAGS="-I$cf_include" + break + fi + CFLAGS="$cf_saved_CFLAGS" + done + fi + fi + fi + + if test "x$cf_have_ncurses_h" = "xno" ; then + if test "x$cf_libterm_name" = "xncursesw" ; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: could not find ncursesw/curses.h, ncursesw.h nor ncurses/curses.h or ncurses.h" >&5 +printf "%s\n" "$as_me: WARNING: could not find ncursesw/curses.h, ncursesw.h nor ncurses/curses.h or ncurses.h" >&2;} + else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: could not find ncurses/curses.h or ncurses.h" >&5 +printf "%s\n" "$as_me: WARNING: could not find ncurses/curses.h or ncurses.h" >&2;} + fi + else + if test "x$have_nc_alloc_h" = "x" ; then + ac_fn_c_check_header_compile "$LINENO" "nc_alloc.h" "ac_cv_header_nc_alloc_h" "$ac_includes_default" +if test "x$ac_cv_header_nc_alloc_h" = xyes then : - printf "%s\n" "#define HAVE_LIBPDCURSES 1" >>confdefs.h + printf "%s\n" "#define HAVE_NC_ALLOC_H 1" >>confdefs.h - LIBS="-lpdcurses $LIBS" +fi + + fi + if test "x$have_nomacros_h" = "x" ; then + ac_fn_c_check_header_compile "$LINENO" "nomacros.h" "ac_cv_header_nomacros_h" "$ac_includes_default" +if test "x$ac_cv_header_nomacros_h" = xyes +then : + printf "%s\n" "#define HAVE_NOMACROS_H 1" >>confdefs.h fi + fi + fi - else if test "x$termlib_name" = "xtinfo"; then + else if test "x$cf_libterm_name" = "xtinfo"; then printf "%s\n" "#define HAVE_LIBTINFO 1" >>confdefs.h @@ -22414,7 +24873,7 @@ then : fi - else if test "x$termlib_name" = "xcurses"; then + else if test "x$cf_libterm_name" = "xcurses"; then printf "%s\n" "#define HAVE_LIBCURSES 1" >>confdefs.h @@ -22468,7 +24927,7 @@ then : fi - else if test "x$termlib_name" = "xtermcap"; then + else if test "x$cf_libterm_name" = "xtermcap"; then printf "%s\n" "#define HAVE_LIBTERMCAP 1" >>confdefs.h @@ -22486,7 +24945,7 @@ then : fi - else if test "x$termlib_name" = "xtermlib"; then + else if test "x$cf_libterm_name" = "xtermlib"; then printf "%s\n" "#define HAVE_LIBTERMLIB 1" >>confdefs.h @@ -22498,13 +24957,230 @@ then : fi - fi; fi; fi; fi; fi; fi; fi; + fi; fi; fi; fi; fi + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses features" >&5 +printf %s "checking for curses features... " >&6; } + if test "x$cf_libterm_cv_features" = "xno" ; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#if defined(HAVE_NCURSESW_CURSES_H) +# include +# include +# include +#elif defined(HAVE_NCURSES_CURSES_H) +# include +# include +# include +#else +# if defined(HAVE_NCURSESW_H) +# include +# elif defined(HAVE_NCURSES_H) +# include +# elif defined(HAVE_CURSES_H) +# include +# endif +# if defined(HAVE_TERMCAP_H) +# include +# endif +# if defined(HAVE_TERM_H) +# include +# endif +#endif + +int +main (void) +{ + + chtype a = A_BOLD; + int b = KEY_LEFT; + chtype c = COLOR_PAIR(1) & A_COLOR; + attr_t d = WA_NORMAL; + cchar_t e; + wint_t f; + int g = getattrs(stdscr); + int h = getcurx(stdscr) + getmaxx(stdscr); + initscr(); + init_pair(1, COLOR_WHITE, COLOR_RED); + wattr_set(stdscr, d, 0, NULL); + wget_wch(stdscr, &f); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + cf_libterm_cv_features=enhanced +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + fi + + if test "x$cf_libterm_cv_features" = "xno" ; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#if defined(HAVE_NCURSESW_CURSES_H) +# include +# include +# include +#elif defined(HAVE_NCURSES_CURSES_H) +# include +# include +# include +#else +# if defined(HAVE_NCURSESW_H) +# include +# elif defined(HAVE_NCURSES_H) +# include +# elif defined(HAVE_CURSES_H) +# include +# endif +# if defined(HAVE_TERMCAP_H) +# include +# endif +# if defined(HAVE_TERM_H) +# include +# endif +#endif + +int +main (void) +{ + + chtype a = A_BOLD; + int b = KEY_LEFT; + chtype c = COLOR_PAIR(1) & A_COLOR; + int g = getattrs(stdscr); + int h = getcurx(stdscr) + getmaxx(stdscr); + initscr(); + init_pair(1, COLOR_WHITE, COLOR_RED); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + cf_libterm_cv_features=color +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + fi + + if test "x$cf_libterm_cv_features" = "xno" ; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#if defined(HAVE_NCURSESW_CURSES_H) +# include +# include +# include +#elif defined(HAVE_NCURSES_CURSES_H) +# include +# include +# include +#else +# if defined(HAVE_NCURSESW_H) +# include +# elif defined(HAVE_NCURSES_H) +# include +# elif defined(HAVE_CURSES_H) +# include +# endif +# if defined(HAVE_TERMCAP_H) +# include +# endif +# if defined(HAVE_TERM_H) +# include +# endif +#endif + +int +main (void) +{ + + chtype a = A_BOLD; + int b = KEY_LEFT; + initscr(); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + cf_libterm_cv_features=basic +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + fi + + if test "x$cf_libterm_cv_features" = "xenhanced" ; then + +printf "%s\n" "#define HAVE_CURSES_ENHANCED 1" >>confdefs.h + + +printf "%s\n" "#define HAVE_CURSES_COLOR 1" >>confdefs.h + + elif test "x$cf_libterm_cv_features" = "xcolor" ; then + +printf "%s\n" "#define HAVE_CURSES_COLOR 1" >>confdefs.h - if test "$termlib_cv_termcap" = "yes"; then - if test -n "$termlib_name"; then + fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cf_libterm_cv_features" >&5 +printf "%s\n" "$cf_libterm_cv_features" >&6; } + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether curses interface utilities const strings" >&5 +printf %s "checking whether curses interface utilities const strings... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +[ +#if defined(HAVE_NCURSESW_CURSES_H) +# include +# include +# include +#elif defined(HAVE_NCURSES_CURSES_H) +# include +# include +# include +#else +# if defined(HAVE_NCURSESW_H) +# include +# elif defined(HAVE_NCURSES_H) +# include +# elif defined(HAVE_CURSES_H) +# include +# endif +# if defined(HAVE_TERMCAP_H) +# include +# endif +# if defined(HAVE_TERM_H) +# include +# endif +#endif +] +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP_TRADITIONAL "[define\\\s+NCURSES_CONST\\\s+const]" >/dev/null 2>&1 +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; }; +printf "%s\n" "#define HAVE_CURSES_CONST 1" >>confdefs.h + +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } ;; +esac +fi +rm -rf conftest* + + + if test "$cf_libterm_cv_termcap" = "yes"; then + if test -n "$cf_libterm_name"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking what tgetent() returns for an unknown terminal" >&5 printf %s "checking what tgetent() returns for an unknown terminal... " >&6; } -if test ${termlib_cv_tgent+y} +if test ${cf_libterm_cv_tgent+y} then : printf %s "(cached) " >&6 else case e in #( @@ -22523,14 +25199,14 @@ else case e in #( #include #include #endif + int main (void) { - char s[10000]; - int res = tgetent(s, "terminalwontexist"); - exit(res != 0); - return 0; + char buffer[1024 * 2]; + int res = tgetent(buffer, "nonexistentterminal"); + exit(res != 0); ; return 0; @@ -22538,9 +25214,9 @@ main (void) _ACEOF if ac_fn_c_try_run "$LINENO" then : - termlib_cv_tgent=zero + cf_libterm_cv_tgent=zero else case e in #( - e) termlib_cv_tgent=non-zero ;; + e) cf_libterm_cv_tgent=non-zero ;; esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ @@ -22548,13 +25224,13 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ esac fi - ;; + ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $termlib_cv_tgent" >&5 -printf "%s\n" "$termlib_cv_tgent" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cf_libterm_cv_tgent" >&5 +printf "%s\n" "$cf_libterm_cv_tgent" >&6; } - if test "x$termlib_cv_tgent" = "xzero"; then + if test "x$cf_libterm_cv_tgent" = "xzero"; then printf "%s\n" "#define TGETENT_ZERO_ERR 0" >>confdefs.h @@ -22562,7 +25238,7 @@ printf "%s\n" "#define TGETENT_ZERO_ERR 0" >>confdefs.h fi fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether termcap.h contains ospeed" >&5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether termcap.h contains ospeed" >&5 printf %s "checking whether termcap.h contains ospeed... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -22570,6 +25246,7 @@ printf %s "checking whether termcap.h contains ospeed... " >&6; } #ifdef HAVE_TERMCAP_H #include #endif + int main (void) { @@ -22596,6 +25273,7 @@ printf %s "checking whether ospeed can be extern... " >&6; } #include #endif extern short ospeed; + int main (void) { @@ -22623,7 +25301,7 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether termcap.h contains UP, BC and PC" >&5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether termcap.h contains UP, BC and PC" >&5 printf %s "checking whether termcap.h contains UP, BC and PC... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -22631,6 +25309,7 @@ printf %s "checking whether termcap.h contains UP, BC and PC... " >&6; } #ifdef HAVE_TERMCAP_H #include #endif + int main (void) { @@ -22657,6 +25336,7 @@ printf %s "checking whether UP, BC and PC can be extern... " >&6; } #include #endif extern char *UP, *BC, PC; + int main (void) { @@ -22684,14 +25364,35 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether tputs() uses outfuntype" >&5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether tputs() uses outfuntype" >&5 printf %s "checking whether tputs() uses outfuntype... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#ifdef HAVE_TERMCAP_H -#include +#if defined(HAVE_NCURSESW_CURSES_H) +# include +# include +# include +#elif defined(HAVE_NCURSES_CURSES_H) +# include +# include +# include +#else +# if defined(HAVE_NCURSESW_H) +# include +# elif defined(HAVE_NCURSES_H) +# include +# elif defined(HAVE_CURSES_H) +# include +# endif +# if defined(HAVE_TERMCAP_H) +# include +# endif +# if defined(HAVE_TERM_H) +# include +# endif #endif + int main (void) { @@ -22713,11 +25414,28 @@ printf %s "checking determining tputs() function final argument type... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#ifdef HAVE_TERM_H -#include -#endif -#ifdef HAVE_CURSES_H -#include +#if defined(HAVE_NCURSESW_CURSES_H) +# include +# include +# include +#elif defined(HAVE_NCURSES_CURSES_H) +# include +# include +# include +#else +# if defined(HAVE_NCURSESW_H) +# include +# elif defined(HAVE_NCURSES_H) +# include +# elif defined(HAVE_CURSES_H) +# include +# endif +# if defined(HAVE_TERMCAP_H) +# include +# endif +# if defined(HAVE_TERM_H) +# include +# endif #endif _ACEOF @@ -22731,7 +25449,7 @@ printf "%s\n" "#define TPUTS_TAKES_CHAR 1" >>confdefs.h else case e in #( e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: not char" >&5 printf "%s\n" "not char" >&6; }; - ;; + ;; esac fi rm -rf conftest* @@ -22741,9 +25459,174 @@ esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + CFLAGS=$cf_save_CFLAGS LIBS=$cf_save_LIBS +ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" +if test "x$ac_cv_type_size_t" = xyes +then : + +else case e in #( + e) +printf "%s\n" "#define size_t unsigned int" >>confdefs.h + ;; +esac +fi + +# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works +# for constant arguments. Useless! +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5 +printf %s "checking for working alloca.h... " >&6; } +if test ${ac_cv_working_alloca_h+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +char *p = (char *) alloca (2 * sizeof (int)); + if (p) return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_working_alloca_h=yes +else case e in #( + e) ac_cv_working_alloca_h=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5 +printf "%s\n" "$ac_cv_working_alloca_h" >&6; } +if test $ac_cv_working_alloca_h = yes; then + +printf "%s\n" "#define HAVE_ALLOCA_H 1" >>confdefs.h + +fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5 +printf %s "checking for alloca... " >&6; } +if test ${ac_cv_func_alloca_works+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_cv_func_alloca_works=$ac_cv_working_alloca_h +if test "$ac_cv_func_alloca_works" != yes +then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#ifndef alloca +# ifdef __GNUC__ +# define alloca __builtin_alloca +# elif defined _MSC_VER +# include +# define alloca _alloca +# else +# ifdef __cplusplus +extern "C" +# endif +void *alloca (size_t); +# endif +#endif + +int +main (void) +{ +char *p = (char *) alloca (1); + if (p) return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_func_alloca_works=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +fi ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5 +printf "%s\n" "$ac_cv_func_alloca_works" >&6; } + +if test $ac_cv_func_alloca_works = yes; then + +printf "%s\n" "#define HAVE_ALLOCA 1" >>confdefs.h + +else + # The SVR3 libPW and SVR4 libucb both contain incompatible functions +# that cause trouble. Some versions do not even contain alloca or +# contain a buggy version. If you still want to use their alloca, +# use ar to extract alloca.o from them instead of compiling alloca.c. + +ALLOCA=\${LIBOBJDIR}alloca.$ac_objext + +printf "%s\n" "#define C_ALLOCA 1" >>confdefs.h + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5 +printf %s "checking stack direction for C alloca... " >&6; } +if test ${ac_cv_c_stack_direction+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if test "$cross_compiling" = yes +then : + ac_cv_c_stack_direction=0 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +find_stack_direction (int *addr, int depth) +{ + int dir, dummy = 0; + if (! addr) + addr = &dummy; + *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1; + dir = depth ? find_stack_direction (addr, depth - 1) : 0; + return dir + dummy; +} + +int +main (int argc, char **argv) +{ + return find_stack_direction (0, argc + !argv + 20) < 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO" +then : + ac_cv_c_stack_direction=1 +else case e in #( + e) ac_cv_c_stack_direction=-1 ;; +esac +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac +fi + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5 +printf "%s\n" "$ac_cv_c_stack_direction" >&6; } +printf "%s\n" "#define STACK_DIRECTION $ac_cv_c_stack_direction" >>confdefs.h + + +fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: determining memory allocation support" >&5 printf "%s\n" "$as_me: determining memory allocation support" >&6;} @@ -24368,14 +27251,16 @@ fi fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for bfd_openr in -lbfd" >&5 -printf %s "checking for bfd_openr in -lbfd... " >&6; } -if test ${ac_cv_lib_bfd_bfd_openr+y} + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for bfd_init in -lbfd" >&5 +printf %s "checking for bfd_init in -lbfd... " >&6; } +if test ${ac_cv_lib_bfd_bfd_init+y} then : printf %s "(cached) " >&6 else case e in #( e) ac_check_lib_save_LIBS=$LIBS -LIBS="-lbfd $LIBS" +LIBS="-lbfd $EXTRALIBS $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -24388,20 +27273,20 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #ifdef __cplusplus extern "C" #endif -char bfd_openr (void); +char bfd_init (void); int main (void) { -return bfd_openr (); +return bfd_init (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_bfd_bfd_openr=yes + ac_cv_lib_bfd_bfd_init=yes else case e in #( - e) ac_cv_lib_bfd_bfd_openr=no ;; + e) ac_cv_lib_bfd_bfd_init=no ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ @@ -24409,15 +27294,15 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam \ LIBS=$ac_check_lib_save_LIBS ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bfd_bfd_openr" >&5 -printf "%s\n" "$ac_cv_lib_bfd_bfd_openr" >&6; } -if test "x$ac_cv_lib_bfd_bfd_openr" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bfd_bfd_init" >&5 +printf "%s\n" "$ac_cv_lib_bfd_bfd_init" >&6; } +if test "x$ac_cv_lib_bfd_bfd_init" = xyes then : printf "%s\n" "#define HAVE_LIBBFD 1" >>confdefs.h - ac_fn_c_check_header_compile "$LINENO" "bfd.h" "ac_cv_header_bfd_h" "$ac_includes_default" + ac_fn_c_check_header_compile "$LINENO" "bfd.h" "ac_cv_header_bfd_h" "$ac_includes_default" if test "x$ac_cv_header_bfd_h" = xyes then : printf "%s\n" "#define HAVE_BFD_H 1" >>confdefs.h @@ -24436,7 +27321,113 @@ fi fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for bfd_section_flags" >&5 +printf %s "checking for bfd_section_flags... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +asection *s; + +int +main (void) +{ +return bfd_section_flags(s) == 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + with_bfd_section_flags=yes +else case e in #( + e) with_bfd_section_flags=no ;; +esac fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_bfd_section_flags" >&5 +printf "%s\n" "$with_bfd_section_flags" >&6; } + if test "$with_bfd_section_flags" = yes; then + +printf "%s\n" "#define HAVE_BFD_SECTION_FLAGS 1" >>confdefs.h + + fi + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for bfd_section_size" >&5 +printf %s "checking for bfd_section_size... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +asection *s; + +int +main (void) +{ +return bfd_section_size(s) == 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + with_bfd_section_size=yes +else case e in #( + e) with_bfd_section_size=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_bfd_section_size" >&5 +printf "%s\n" "$with_bfd_section_size" >&6; } + if test "$with_bfd_section_size" = yes; then + +printf "%s\n" "#define HAVE_BFD_SECTION_SIZE 1" >>confdefs.h + + fi + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for bfd_section_vma" >&5 +printf %s "checking for bfd_section_vma... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +asection *s; + +int +main (void) +{ +return bfd_section_vma(s) == 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + with_bfd_section_vma=yes +else case e in #( + e) with_bfd_section_vma=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_bfd_section_vma" >&5 +printf "%s\n" "$with_bfd_section_vma" >&6; } + if test "$with_bfd_section_vma" = yes; then + +printf "%s\n" "#define HAVE_BFD_SECTION_VMA 1" >>confdefs.h + + fi + + +fi + + + + + + @@ -25403,9 +28394,9 @@ printf %s "checking whether to enable mouse handling... " >&6; } # Check whether --with-mouse was given. if test ${with_mouse+y} then : - withval=$with_mouse; with_mouse=$withval + withval=$with_mouse; with_mouse=nol else case e in #( - e) with_mouse=no ;; + e) with_mouse=yes ;; esac fi @@ -25608,8 +28599,6 @@ printf "%s\n" "#define NDEBUG 1" >>confdefs.h fi - - # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: @@ -25756,53 +28745,6 @@ printf "%s\n" "no" >&6; } fi - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a race-free mkdir -p" >&5 -printf %s "checking for a race-free mkdir -p... " >&6; } -if test -z "$MKDIR_P"; then - if test ${ac_cv_path_mkdir+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_prog in mkdir gmkdir; do - for ac_exec_ext in '' $ac_executable_extensions; do - as_fn_executable_p "$as_dir$ac_prog$ac_exec_ext" || continue - case `"$as_dir$ac_prog$ac_exec_ext" --version 2>&1` in #( - 'mkdir ('*'coreutils) '* | \ - *'BusyBox '* | \ - 'mkdir (fileutils) '4.1*) - ac_cv_path_mkdir=$as_dir$ac_prog$ac_exec_ext - break 3;; - esac - done - done - done -IFS=$as_save_IFS - ;; -esac -fi - - test -d ./--version && rmdir ./--version - if test ${ac_cv_path_mkdir+y}; then - MKDIR_P="$ac_cv_path_mkdir -p" - else - # As a last resort, use plain mkdir -p, - # in the hope it doesn't have the bugs of ancient mkdir. - MKDIR_P='mkdir -p' - fi -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 -printf "%s\n" "$MKDIR_P" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 printf %s "checking whether ln -s works... " >&6; } LN_S=$as_ln_s @@ -25862,6 +28804,53 @@ fi test -n "$AWK" && break done + +# Extract the first word of "perl", so it can be a program name with args. +set dummy perl; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_PERL_CHECK+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if test -n "$PERL_CHECK"; then + ac_cv_prog_PERL_CHECK="$PERL_CHECK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_PERL_CHECK="yes" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi ;; +esac +fi +PERL_CHECK=$ac_cv_prog_PERL_CHECK +if test -n "$PERL_CHECK"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PERL_CHECK" >&5 +printf "%s\n" "$PERL_CHECK" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +if test x"$PERL_CHECK" != x"yes" ; then + as_fn_error $? "couldn't locate perl; make sure it's installed and in your path" "$LINENO" 5 +fi for ac_prog in flex lex do # Extract the first word of "$ac_prog", so it can be a program name with args. @@ -26087,7 +29076,15 @@ rm -f conftest.l $LEX_OUTPUT_ROOT.c fi if test "$LEX" != "flex"; then - as_fn_error $? "couldn't locate flex; make sure it's installed and in your path" "$LINENO" 5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: couldn't locate flex; make sure it's installed and in your path" >&5 +printf "%s\n" "$as_me: WARNING: couldn't locate flex; make sure it's installed and in your path" >&2;} + printf "%s\n" "" + printf "%s\n" "You should only need it if you modified a '.l' file." + printf "%s\n" "You may want to install the Fast Lexical Analyzer package:" + printf "%s\n" "" + printf "%s\n" " " + printf "%s\n" "" + as_fn_error $? "flex missing" "$LINENO" 5 fi for ac_prog in 'bison -y' byacc do @@ -26139,7 +29136,20 @@ done test -n "$YACC" || YACC="yacc" if test "$YACC" != "bison -y"; then - as_fn_error $? "couldn't locate bison; make sure it's installed and in your path" "$LINENO" 5 + if test "$YACC" != "byacc"; then + if test "$YACC" != "yacc"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: couldn't locate bison/byacc; make sure it's installed and in your path" >&5 +printf "%s\n" "$as_me: WARNING: couldn't locate bison/byacc; make sure it's installed and in your path" >&2;} + printf "%s\n" "" + printf "%s\n" "You should only need it if you modified a '.y' file."] + printf "%s\n" "You may want to install the either byacc or the bison package:"] + printf "%s\n" "" + printf "%s\n" " " + printf "%s\n" " or " + printf "%s\n" "" + as_fn_error $? "bison/byacc missing" "$LINENO" 5 + fi + fi fi # Extract the first word of "bison", so it can be a program name with args. set dummy bison; ac_word=$2 @@ -26256,7 +29266,7 @@ else case e in #( int main (void) { -double x = log10(1.0); printf("result = %g/%g\n", sin(x), tan(x)); +double x = log10(1.0); char buf[256]; sprintf(buf, "result = %g/%g\n", sin(x), tan(x)); ; return 0; } @@ -26292,7 +29302,7 @@ else case e in #( int main (void) { -double x = log10(1.0); printf("result = %g/%g\n", sin(x), tan(x)); +double x = log10(1.0); char buf[256]; sprintf(buf, "result = %g/%g\n", sin(x), tan(x)); ; return 0; } @@ -26688,6 +29698,70 @@ fi + ac_fn_c_check_header_compile "$LINENO" "threads.h" "ac_cv_header_threads_h" "$ac_includes_default" +if test "x$ac_cv_header_threads_h" = xyes +then : + printf "%s\n" "#define HAVE_THREADS_H 1" >>confdefs.h + +fi + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for thrd_create in -lstdthreads" >&5 +printf %s "checking for thrd_create in -lstdthreads... " >&6; } +if test ${ac_cv_lib_stdthreads_thrd_create+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-lstdthreads $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char thrd_create (void); +int +main (void) +{ +return thrd_create (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_stdthreads_thrd_create=yes +else case e in #( + e) ac_cv_lib_stdthreads_thrd_create=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_stdthreads_thrd_create" >&5 +printf "%s\n" "$ac_cv_lib_stdthreads_thrd_create" >&6; } +if test "x$ac_cv_lib_stdthreads_thrd_create" = xyes +then : + + +printf "%s\n" "#define HAVE_STDTHREADS 1" >>confdefs.h + + THREADS_LIBS="-lstdthreads" + +else case e in #( + e) THREADS_LIBS="" ;; +esac +fi + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if nanosleep requires any libraries" >&5 printf %s "checking if nanosleep requires any libraries... " >&6; } @@ -27564,22 +30638,10 @@ then : fi - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: - Threading:" >&5 -printf "%s\n" "- Threading:" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: - Compiler: $PTHREAD_CC" >&5 -printf "%s\n" "- Compiler: $PTHREAD_CC" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: - CFLAGS: $PTHREAD_CFLAGS" >&5 -printf "%s\n" "- CFLAGS: $PTHREAD_CFLAGS" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: - Libraries: $PTHREAD_LIBS $NANOSLEEP_LIBS" >&5 -printf "%s\n" "- Libraries: $PTHREAD_LIBS $NANOSLEEP_LIBS" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: -" >&5 -printf "%s\n" "-" >&6; } - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS" LDFLAGS="$LDFLAGS $PTHREAD_CFLAGS" - LIBTHREAD="$PTHREAD_LIBS $NANOSLEEP_LIBS" + LIBTHREAD="$THREADS_LIBS $PTHREAD_LIBS $NANOSLEEP_LIBS" : else @@ -27594,7 +30656,7 @@ then : fi - LIBTHREAD="$NANOSLEEP_LIB" + LIBTHREAD="$THREADS_LIBS $NANOSLEEP_LIB" fi ac_ext=c @@ -27605,6 +30667,18 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: - Threading:" >&5 +printf "%s\n" "- Threading:" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: - Compiler: $PTHREAD_CC" >&5 +printf "%s\n" "- Compiler: $PTHREAD_CC" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: - CFLAGS: $PTHREAD_CFLAGS" >&5 +printf "%s\n" "- CFLAGS: $PTHREAD_CFLAGS" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: - Libraries: $LIBTHREAD" >&5 +printf "%s\n" "- Libraries: $LIBTHREAD" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: -" >&5 +printf "%s\n" "-" >&6; } + + # @@ -28943,7 +32017,7 @@ printf "%s\n" "$cf_cv_pointer_va_list" >&6; } if test "$cf_cv_pointer_va_list" = no then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we can copy va_list indirectly" >&5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we can copy va_list indirectly" >&5 printf %s "checking if we can copy va_list indirectly... " >&6; } if test ${cf_cv_array_va_list+y} then : @@ -28979,7 +32053,7 @@ esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cf_cv_array_va_list" >&5 printf "%s\n" "$cf_cv_array_va_list" >&6; } - test "$cf_cv_array_va_list" = yes && + test "$cf_cv_array_va_list" = yes && printf "%s\n" "#define ARRAY_VA_LIST 1" >>confdefs.h fi @@ -29254,12 +32328,6 @@ then : printf "%s\n" "#define HAVE_STDATOMIC_H 1" >>confdefs.h fi -ac_fn_c_check_header_compile "$LINENO" "threads.h" "ac_cv_header_threads_h" "$ac_includes_default" -if test "x$ac_cv_header_threads_h" = xyes -then : - printf "%s\n" "#define HAVE_THREADS_H 1" >>confdefs.h - -fi ac_fn_c_check_header_compile "$LINENO" "sys/at_ansi.h" "ac_cv_header_sys_at_ansi_h" "$ac_includes_default" @@ -29295,9 +32363,9 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for type sigaction_t" >&5 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for type sigaction_t" >&5 printf %s "checking for type sigaction_t... " >&6; } - if test ${cf_cv_type_sigaction+y} +if test ${cf_cv_type_sigaction+y} then : printf %s "(cached) " >&6 else case e in #( @@ -29325,9 +32393,9 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; esac fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cf_cv_type_sigaction" >&5 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cf_cv_type_sigaction" >&5 printf "%s\n" "$cf_cv_type_sigaction" >&6; } - test "$cf_cv_type_sigaction" = yes && +test "$cf_cv_type_sigaction" = yes && printf "%s\n" "#define HAVE_TYPE_SIGACTION 1" >>confdefs.h @@ -29336,6 +32404,18 @@ if test "x$ac_cv_header_signal_h" = xyes then : printf "%s\n" "#define HAVE_SIGNAL_H 1" >>confdefs.h +fi +ac_fn_c_check_header_compile "$LINENO" "siginfo.h" "ac_cv_header_siginfo_h" "$ac_includes_default" +if test "x$ac_cv_header_siginfo_h" = xyes +then : + printf "%s\n" "#define HAVE_SIGINFO_H 1" >>confdefs.h + +fi +ac_fn_c_check_header_compile "$LINENO" "sys/siginfo.h" "ac_cv_header_sys_siginfo_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_siginfo_h" = xyes +then : + printf "%s\n" "#define HAVE_SYS_SIGINFO_H 1" >>confdefs.h + fi ac_fn_c_check_func "$LINENO" "sigsetmask" "ac_cv_func_sigsetmask" @@ -29826,6 +32906,55 @@ printf "%s\n" "#define HAVE_ISCSYM 1" >>confdefs.h + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for nl_langinfo and CODESET" >&5 +printf %s "checking for nl_langinfo and CODESET... " >&6; } +if test ${cf_cv_langinfo_codeset+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) + if test "$cross_compiling" = yes +then : + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "cannot run test program while cross compiling +See 'config.log' for more details" "$LINENO" 5; } +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +char* cs = nl_langinfo(CODESET); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO" +then : + cf_cv_langinfo_codeset=yes +else case e in #( + e) cf_cv_langinfo_codeset=no ;; +esac +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac +fi + + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cf_cv_langinfo_codeset" >&5 +printf "%s\n" "$cf_cv_langinfo_codeset" >&6; } + if test $cf_cv_langinfo_codeset = yes; then + +printf "%s\n" "#define HAVE_LANGINFO_CODESET 1" >>confdefs.h + + fi + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working mkstemp" >&5 printf %s "checking for working mkstemp... " >&6; } if test ${cf_cv_func_mkstemp+y} @@ -29907,36 +33036,47 @@ printf "%s\n" "#define HAVE_MKSTEMP 1" >>confdefs.h fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for nl_langinfo and CODESET" >&5 -printf %s "checking for nl_langinfo and CODESET... " >&6; } -if test ${cf_cv_langinfo_codeset+y} +ac_fn_c_check_func "$LINENO" "memmove" "ac_cv_func_memmove" +if test "x$ac_cv_func_memmove" = xyes +then : + +else case e in #( + e) +ac_fn_c_check_func "$LINENO" "bcopy" "ac_cv_func_bcopy" +if test "x$ac_cv_func_bcopy" = xyes +then : + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if bcopy does overlapping moves" >&5 +printf %s "checking if bcopy does overlapping moves... " >&6; } +if test ${cf_cv_good_bcopy+y} then : printf %s "(cached) " >&6 else case e in #( e) if test "$cross_compiling" = yes then : - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} -as_fn_error $? "cannot run test program while cross compiling -See 'config.log' for more details" "$LINENO" 5; } + cf_cv_good_bcopy=unknown else case e in #( e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include -int -main (void) -{ -char* cs = nl_langinfo(CODESET); - ; - return 0; + +$ac_includes_default + +int main(void) { + static char data[] = "abcdefghijklmnopqrstuwwxyz"; + char temp[40]; + bcopy(data, temp, sizeof(data)); + bcopy(temp+10, temp, 15); + bcopy(temp+5, temp+15, 10); + ${cf_cv_main_return:-return} (strcmp(temp, "klmnopqrstuwwxypqrstuwwxyz")); } + _ACEOF if ac_fn_c_try_run "$LINENO" then : - cf_cv_langinfo_codeset=yes + cf_cv_good_bcopy=yes else case e in #( - e) cf_cv_langinfo_codeset=no ;; + e) cf_cv_good_bcopy=no ;; esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ @@ -29947,84 +33087,566 @@ fi ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cf_cv_langinfo_codeset" >&5 -printf "%s\n" "$cf_cv_langinfo_codeset" >&6; } - if test $cf_cv_langinfo_codeset = yes; then +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cf_cv_good_bcopy" >&5 +printf "%s\n" "$cf_cv_good_bcopy" >&6; } -printf "%s\n" "#define HAVE_LANGINFO_CODESET 1" >>confdefs.h +else case e in #( + e) cf_cv_good_bcopy=no ;; +esac +fi + + if test "$cf_cv_good_bcopy" = yes ; then + +printf "%s\n" "#define USE_OK_BCOPY 1" >>confdefs.h + + else + +printf "%s\n" "#define USE_MY_MEMMOVE 1" >>confdefs.h fi + ;; +esac +fi - ac_fn_c_check_func "$LINENO" "memmove" "ac_cv_func_memmove" -if test "x$ac_cv_func_memmove" = xyes -then : +cf_gnu_xopen_source=500 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if this is the GNU C library" >&5 +printf %s "checking if this is the GNU C library... " >&6; } +if test ${cf_cv_gnu_library+y} +then : + printf %s "(cached) " >&6 else case e in #( e) - ac_fn_c_check_func "$LINENO" "bcopy" "ac_cv_func_bcopy" -if test "x$ac_cv_func_bcopy" = xyes +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ + + #if __GLIBC__ > 0 && __GLIBC_MINOR__ >= 0 + return 0; + #elif __NEWLIB__ > 0 && __NEWLIB_MINOR__ >= 0 + return 0; + #else + #error not GNU C library + #endif + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" then : + cf_cv_gnu_library=yes +else case e in #( + e) cf_cv_gnu_library=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cf_cv_gnu_library" >&5 +printf "%s\n" "$cf_cv_gnu_library" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if bcopy does overlapping moves" >&5 -printf %s "checking if bcopy does overlapping moves... " >&6; } -if test ${cf_cv_good_bcopy+y} +if test x$cf_cv_gnu_library = xyes; then + + # With glibc 2.19 (13 years after this check was begun), _DEFAULT_SOURCE + # was changed to help a little. newlib incorporated the change about 4 + # years later. + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if _DEFAULT_SOURCE can be used as a basis" >&5 +printf %s "checking if _DEFAULT_SOURCE can be used as a basis... " >&6; } +if test ${cf_cv_gnu_library_219+y} then : printf %s "(cached) " >&6 else case e in #( e) - if test "$cross_compiling" = yes + cf_save="$CPPFLAGS" + + test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " + CPPFLAGS="${CPPFLAGS}-D_DEFAULT_SOURCE" + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ + +#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 19) || (__GLIBC__ > 2) + return 0; +#elif (__NEWLIB__ == 2 && __NEWLIB_MINOR__ >= 4) || (__GLIBC__ > 3) + return 0; +#else +#error GNU C library __GLIBC__.__GLIBC_MINOR__ is too old +#endif + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" then : - cf_cv_good_bcopy=unknown + cf_cv_gnu_library_219=yes else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext + e) cf_cv_gnu_library_219=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + CPPFLAGS="$cf_save" + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cf_cv_gnu_library_219" >&5 +printf "%s\n" "$cf_cv_gnu_library_219" >&6; } + + if test "x$cf_cv_gnu_library_219" = xyes; then + cf_save="$CPPFLAGS" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE" >&5 +printf %s "checking if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE... " >&6; } +if test ${cf_cv_gnu_dftsrc_219+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) + +cf_fix_cppflags=no +cf_new_cflags= +cf_new_cppflags= +cf_new_extra_cppflags= + +for cf_add_cflags in -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=$cf_gnu_xopen_source +do +case "$cf_fix_cppflags" in +(no) + case "$cf_add_cflags" in + (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) + case "$cf_add_cflags" in + (-D*) + cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'` + + test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ + && test -z "${cf_tst_cflags}" \ + && cf_fix_cppflags=yes + + if test "$cf_fix_cppflags" = yes ; then + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + + continue + elif test "${cf_tst_cflags}" = "\"'" ; then + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + + continue + fi + ;; + esac + case "$CPPFLAGS" in + (*$cf_add_cflags) + ;; + (*) + case "$cf_add_cflags" in + (-D*) + cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'` + +CPPFLAGS=`echo "$CPPFLAGS" | \ + sed -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?[ ]/ /g' \ + -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?$//g'` + + ;; + esac + + test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags " + cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags" + + ;; + esac + ;; + (*) + + test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags " + cf_new_cflags="${cf_new_cflags}$cf_add_cflags" + + ;; + esac + ;; +(yes) + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + + + cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'` + + test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ + && test -z "${cf_tst_cflags}" \ + && cf_fix_cppflags=no + ;; +esac +done + +if test -n "$cf_new_cflags" ; then + + + test -n "$CFLAGS" && CFLAGS="$CFLAGS " + CFLAGS="${CFLAGS}$cf_new_cflags" + +fi + +if test -n "$cf_new_cppflags" ; then + + + test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " + CPPFLAGS="${CPPFLAGS}$cf_new_cppflags" + +fi + +if test -n "$cf_new_extra_cppflags" ; then + + + test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS " + EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags" + +fi + + + + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ + #include + #include + int main (void) { - static char data[] = "abcdefghijklmnopqrstuwwxyz"; - char temp[40]; - bcopy(data, temp, sizeof(data)); - bcopy(temp+10, temp, 15); - bcopy(temp+5, temp+15, 10); - ${cf_cv_main_return:-return} (strcmp(temp, "klmnopqrstuwwxypqrstuwwxyz")); - +#if (_XOPEN_SOURCE >= $cf_gnu_xopen_source) && (MB_LEN_MAX > 1) + return 0; +#else +#error GNU C library is too old +#endif ; return 0; } _ACEOF -if ac_fn_c_try_run "$LINENO" +if ac_fn_c_try_compile "$LINENO" then : - cf_cv_good_bcopy=yes + cf_cv_gnu_dftsrc_219=yes else case e in #( - e) cf_cv_good_bcopy=no ;; + e) cf_cv_gnu_dftsrc_219=no ;; esac fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; esac fi - ;; +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cf_cv_gnu_dftsrc_219" >&5 +printf "%s\n" "$cf_cv_gnu_dftsrc_219" >&6; } + test "x$cf_cv_gnu_dftsrc_219" = "xyes" || CPPFLAGS="$cf_save" + else + cf_cv_gnu_dftsrc_219=maybe + fi + + if test "x$cf_cv_gnu_dftsrc_219" != xyes; then + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we must define _GNU_SOURCE" >&5 +printf %s "checking if we must define _GNU_SOURCE... " >&6; } +if test ${cf_cv_gnu_source+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ + +#ifndef _XOPEN_SOURCE +#error expected _XOPEN_SOURCE to be defined +#endif + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + cf_cv_gnu_source=no +else case e in #( + e) cf_save="$CPPFLAGS" + +cf_fix_cppflags=no +cf_new_cflags= +cf_new_cppflags= +cf_new_extra_cppflags= + +for cf_add_cflags in -D_GNU_SOURCE +do +case "$cf_fix_cppflags" in +(no) + case "$cf_add_cflags" in + (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) + case "$cf_add_cflags" in + (-D*) + cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'` + + test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ + && test -z "${cf_tst_cflags}" \ + && cf_fix_cppflags=yes + + if test "$cf_fix_cppflags" = yes ; then + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + + continue + elif test "${cf_tst_cflags}" = "\"'" ; then + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + + continue + fi + ;; + esac + case "$CPPFLAGS" in + (*$cf_add_cflags) + ;; + (*) + case "$cf_add_cflags" in + (-D*) + cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'` + +CPPFLAGS=`echo "$CPPFLAGS" | \ + sed -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?[ ]/ /g' \ + -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?$//g'` + + ;; + esac + + test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags " + cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags" + + ;; + esac + ;; + (*) + + test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags " + cf_new_cflags="${cf_new_cflags}$cf_add_cflags" + + ;; + esac + ;; +(yes) + + test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " + cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" + + + cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'` + + test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ + && test -z "${cf_tst_cflags}" \ + && cf_fix_cppflags=no + ;; esac +done + +if test -n "$cf_new_cflags" ; then + + + test -n "$CFLAGS" && CFLAGS="$CFLAGS " + CFLAGS="${CFLAGS}$cf_new_cflags" + fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cf_cv_good_bcopy" >&5 -printf "%s\n" "$cf_cv_good_bcopy" >&6; } +if test -n "$cf_new_cppflags" ; then + + + test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " + CPPFLAGS="${CPPFLAGS}$cf_new_cppflags" + +fi + +if test -n "$cf_new_extra_cppflags" ; then + + + test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS " + EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags" + +fi + + + + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ + +#ifdef _XOPEN_SOURCE +#error expected _XOPEN_SOURCE to be undefined +#endif + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + cf_cv_gnu_source=no else case e in #( - e) cf_cv_good_bcopy=no ;; + e) cf_cv_gnu_source=yes ;; esac fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + CPPFLAGS="$cf_save" + ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cf_cv_gnu_source" >&5 +printf "%s\n" "$cf_cv_gnu_source" >&6; } - if test "$cf_cv_good_bcopy" != yes ; then + if test "$cf_cv_gnu_source" = yes + then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we should also define _DEFAULT_SOURCE" >&5 +printf %s "checking if we should also define _DEFAULT_SOURCE... " >&6; } +if test ${cf_cv_default_source+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) -printf "%s\n" "#define NEED_MEMMOVE 1" >>confdefs.h + test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " + CPPFLAGS="${CPPFLAGS}-D_GNU_SOURCE" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ + +#ifdef _DEFAULT_SOURCE +#error expected _DEFAULT_SOURCE to be undefined +#endif + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + cf_cv_default_source=no +else case e in #( + e) cf_cv_default_source=yes ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cf_cv_default_source" >&5 +printf "%s\n" "$cf_cv_default_source" >&6; } + if test "$cf_cv_default_source" = yes + then + + test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " + CPPFLAGS="${CPPFLAGS}-D_DEFAULT_SOURCE" + + fi fi + fi + +fi + + + +ac_fn_c_check_func "$LINENO" "vasprintf" "ac_cv_func_vasprintf" +if test "x$ac_cv_func_vasprintf" = xyes +then : + + +printf "%s\n" "#define HAVE_VASPRINTF 1" >>confdefs.h + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if vasprintf requires workaround" >&5 +printf %s "checking if vasprintf requires workaround... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include + +int +main (void) +{ + + void *p = (void *)vasprintf; return (p != 0) + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +else case e in #( + e) + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#include +#endif + +int +main (void) +{ + + void *p = (void *)vasprintf; return (p != 0) + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + + test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " + CPPFLAGS="${CPPFLAGS}-D_GNU_SOURCE" + + +else case e in #( + e) + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unknown" >&5 +printf "%s\n" "unknown" >&6; } + ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; esac fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + +fi @@ -30040,6 +33662,18 @@ then : printf "%s\n" "#define HAVE_SYS_WAIT_H 1" >>confdefs.h fi +ac_fn_c_check_header_compile "$LINENO" "sysinfo.h" "ac_cv_header_sysinfo_h" "$ac_includes_default" +if test "x$ac_cv_header_sysinfo_h" = xyes +then : + printf "%s\n" "#define HAVE_SYSINFO_H 1" >>confdefs.h + +fi +ac_fn_c_check_header_compile "$LINENO" "sys/sysinfo.h" "ac_cv_header_sys_sysinfo_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_sysinfo_h" = xyes +then : + printf "%s\n" "#define HAVE_SYS_SYSINFO_H 1" >>confdefs.h + +fi ac_func= @@ -30496,7 +34130,7 @@ fi ac_fn_c_check_header_compile "$LINENO" "sys/ptem.h" "ac_cv_header_sys_ptem_h" " #ifdef HAVE_SYS_STREAM_H -#include /* Solaris 8, sys/stream.h is a prerequisite. */ +#include /* Solaris 8, sys/stream.h is a prerequisite. */ #endif " @@ -31213,15 +34847,6 @@ then : fi -# AC_SEARCH_LIBS(mallinfo,malloc,[ -# AC_DEFINE([HAVE_MALLINFO],[1],[Define if mallinfo() is available on this platform.])]) -# AC_CHECK_TYPES([struct mallinfo],,, [#include ]) -# AC_CHECK_MEMBER([struct mallinfo.hblks]) -# AC_CHECK_MEMBER([struct mallinfo.keepcost]) -# AC_CHECK_MEMBER([struct mallinfo.treeoverhead]) -# AC_CHECK_MEMBER([struct mallinfo.grain]) -# AC_CHECK_MEMBER([struct mallinfo.allocated]) - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working strtod" >&5 printf %s "checking for working strtod... " >&6; } @@ -32205,6 +35830,11 @@ fi ac_config_files="$ac_config_files Makefile include/edpackage.h libllist/Makefile libmisc/Makefile libsplay/Makefile libmalloc/Makefile libvfs/Makefile libbsdio/Makefile libbsddb/Makefile libbsdfetch/Makefile libtrie/Makefile libterm/Makefile libteken/Makefile libonigrx/Makefile libtre/Makefile libchartable/Makefile libwidechar/Makefile libcharudet/Makefile libduktape/Makefile gr/Makefile gm/Makefile grcpp/Makefile grmandoc/Makefile grunch/Makefile hlpdoc/Makefile macsrc/Makefile util/Makefile" +if test "x$with_libfltk" = "xyes"; then + ac_config_files="$ac_config_files libfltk/Makefile" + +fi + case $host_os in mingw*) ac_config_files="$ac_config_files libw32/Makefile" @@ -32248,6 +35878,7 @@ var_bindir=`(test "x$prefix" = xNONE && prefix="$ac_default_prefix" done echo "$_lcl_receval")` + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: -" >&5 printf "%s\n" "-" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: - Configuration:" >&5 @@ -32262,18 +35893,18 @@ printf "%s\n" "- Depend: $CPPDEP" >&6; } printf "%s\n" "- CFLAGS: $CFLAGS $OPENSSL_INCLUDES $EXTRA_CFLAGS $CWARN" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: - Debug:$CDEBUG, Release:$CRELEASE" >&5 printf "%s\n" "- Debug:$CDEBUG, Release:$CRELEASE" >&6; } -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: - CXXFLAGS: $CXXFLAGS $EXTRA_CPPFLAGS $CXXWARN" >&5 -printf "%s\n" "- CXXFLAGS: $CXXFLAGS $EXTRA_CPPFLAGS $CXXWARN" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: - CXXFLAGS: $CXXFLAGS $EXTRA_CXXFLAGS $CXXWARN" >&5 +printf "%s\n" "- CXXFLAGS: $CXXFLAGS $EXTRA_CXXFLAGS $CXXWARN" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: - Debug:$CXXDEBUG, Release:$CXXRELEASE" >&5 printf "%s\n" "- Debug:$CXXDEBUG, Release:$CXXRELEASE" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: - LDFLAGS: $OPENSSL_LDFLAGS $LDFLAGS" >&5 printf "%s\n" "- LDFLAGS: $OPENSSL_LDFLAGS $LDFLAGS" >&6; } -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: - Preprocessor: $EXTRA_CPPFLAGS $LIBCURL_CPPFLAGS" >&5 -printf "%s\n" "- Preprocessor: $EXTRA_CPPFLAGS $LIBCURL_CPPFLAGS" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: - Preprocessor: -DHAVE_CONFIG_H $EXTRA_CPPFLAGS $LIBCURL_CPPFLAGS" >&5 +printf "%s\n" "- Preprocessor: -DHAVE_CONFIG_H $EXTRA_CPPFLAGS $LIBCURL_CPPFLAGS" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: - Mouse support: ${mouse_lib}" >&5 printf "%s\n" "- Mouse support: ${mouse_lib}" >&6; } -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: - Termap support: ${termlib_name}" >&5 -printf "%s\n" "- Termap support: ${termlib_name}" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: - Tercmap support: $CURSES_CFLAGS $TERMLIB" >&5 +printf "%s\n" "- Tercmap support: $CURSES_CFLAGS $TERMLIB" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: - Spell Support: $LIBSPELL" >&5 printf "%s\n" "- Spell Support: $LIBSPELL" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: - Conversion: $LIBICU $LIBAPRICONV $LIBICONV" >&5 @@ -32905,7 +36536,7 @@ $config_headers Configuration commands: $config_commands -Report bugs to ." +Report bugs to ." _ACEOF ac_cs_config=`printf "%s\n" "$ac_configure_args" | sed "$ac_safe_unquote"` @@ -33455,6 +37086,7 @@ do "hlpdoc/Makefile") CONFIG_FILES="$CONFIG_FILES hlpdoc/Makefile" ;; "macsrc/Makefile") CONFIG_FILES="$CONFIG_FILES macsrc/Makefile" ;; "util/Makefile") CONFIG_FILES="$CONFIG_FILES util/Makefile" ;; + "libfltk/Makefile") CONFIG_FILES="$CONFIG_FILES libfltk/Makefile" ;; "libw32/Makefile") CONFIG_FILES="$CONFIG_FILES libw32/Makefile" ;; "contrib/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/Makefile" ;; "contrib/makedepend/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/makedepend/Makefile" ;; diff --git a/auto/configure.in b/auto/configure.in index c5525b95..7095f639 100644 --- a/auto/configure.in +++ b/auto/configure.in @@ -1,13 +1,12 @@ -dnl $Id: configure.in,v 1.84 2024/06/10 08:53:28 cvsuser Exp $ +dnl $Id: configure.in,v 1.98 2024/08/25 06:00:04 cvsuser Exp $ dnl Process this file with autoconf to produce a configure script. dnl -*- mode: Autoconf; tabs: 8; -*- dnl -dnl +dnl Adam Young (c) 1995-2024 -AC_REVISION($Revision: 1.84 $) -## AC_COPYRIGHT(Adam Young 1995-2024, Paul Fox 1989-1991) +AC_REVISION($Revision: 1.98 $) AC_SUBST([PACKAGE]) -AC_INIT([GriefEdit],[3.2.3],[griefedit@gmail.com]) +AC_INIT([GriefEdit],[3.2.3],[https://github.com/adamyg/grief]) AC_PREREQ([2.69]) PACKAGE="gr" @@ -20,34 +19,35 @@ AC_MSG_RESULT([- You may set the CC/CXX and CFLAGS/CXXFLAGS environment variable AC_MSG_RESULT([- to predetermine the C and C++ compilers and associated options used.]) AC_MSG_RESULT([-]) +AC_USE_SYSTEM_EXTENSIONS + AC_CANONICAL_TARGET AC_CANONICAL_BUILD CF_CANONICAL_HOST +CF_ISWIN32 + AC_PROG_MAKE_SET AC_EXEEXT LT_INIT([dlopen win32-dll]) - AC_SUBST([LIBTOOL_DEPS]) AC_SUBST([LT_OBJDIR]) LT_INIT LT_OBJDIR="$lt_cv_objdir" -LIBTOOL='/bin/bash $(top_builddir)/libtool' +LIBTOOL='/bin/sh $(top_builddir)/libtool' AC_SUBST(PROGS) -## Stop AC_PROG_CC() assigning defaults. -CFLAGS="" -AC_PROG_CC(gcc cc clang c1 egcs) -AC_PROG_CXX(g++ CC clang++) -## AC_PROG_GCC_TRADITIONAL - -#TODO -#AX_COMPILER_VENDOR -#AX_COMPILER_VERSION -#AX_CHECK_COMPILE_FLAG([-std=c11], -# [AX_APPEND_FLAG([-std=c11])], -# [AC_MSG_WARN([-std=c11 not supported, you may have to set CFLAGS to enable C11 support.]) -# ]) + +dnl Restore CFLAGS/CXXFLAGS. +dnl We MUST set the flags before we call autoconf compiler configuration macros, +dnl because if we don't, they set CFLAGS to no optimization and -g, which isn't what we want. + +AC_PROG_CC([gcc cc clang]) +AC_PROG_CXX([g++ CC c++ clang++]) +AX_COMPILER_VENDOR +AX_COMPILER_VERSION +CFLAGS=${ac_env_CFLAGS_value} +CXXFLAGS=${ac_env_CXXFLAGS_value} AC_PROG_CPP AC_SUBST(CPPDEP) @@ -56,7 +56,12 @@ CPPDEP=${CPPDEP-"gcc -MM"} AC_SUBST([ABS_ROOT]) ABS_ROOT="`pwd`/" -AC_PATH_PROG(RM,rm,rm) +AC_CHECK_PROG(CP,cp,cp) +AC_CHECK_PROG(MV,mv,mv) +AC_CHECK_PROG(RM,rm,rm) +AC_CHECK_PROG(RMDIR,rmdir,rmdir) +AC_PROG_MKDIR_P + AC_PATH_PROG(SED,sed,sed) AC_PATH_PROG(TAR,tar,tar) AC_PATH_PROG(PERL,perl,perl) @@ -138,6 +143,7 @@ if test "x$with_floating" = "xno"; then [Define to disable float maths functions]) fi +dnl contrib BUILD_CONTRIB=0 AC_SUBST(BUILD_CONTRIB) AC_MSG_CHECKING(whether to enable contrib components) @@ -155,7 +161,18 @@ AC_ARG_WITH(contrib, esac],[ AC_DEFINE(BUILD_CONTRIB,1) with_contrib=$with_contribdefault]) -AC_MSG_RESULT($with_floating) +AC_MSG_RESULT($with_contrib) + +dnl libfltk +BUILD_LIBFLTK=0 +AC_SUBST(BUILD_LIBFLTK) +AC_MSG_CHECKING(whether to enable libfltk support) +AC_ARG_WITH(libfltk, + [ --with-libfltk enable libfltk support (default=no)], + [with_libfltk=$withval], + [with_libfltk=no]) +AC_MSG_RESULT($with_libfltk) + dnl dnl Types @@ -163,7 +180,13 @@ dnl AC_TYPE_LONG_LONG_INT AC_TYPE_UNSIGNED_LONG_LONG_INT -AC_CHECK_HEADERS(endian.h machine/endian.h arpa/nameser_compat.h) +AC_CHECK_HEADERS([unistd.h], [], + [AC_MSG_ERROR(system headers not found; unable to continue)]) + +AC_CHECK_HEADERS( \ + endian.h sys/endian.h machine/endian.h sys/byteorder.h \ + arpa/nameser_compat.h ) + AC_C_BIGENDIAN( [AC_DEFINE(IS_BIG_ENDIAN, 1, [big endian])], [AC_DEFINE(IS_LITTLE_ENDIAN, 1, [little endian])], @@ -263,16 +286,13 @@ dnl libcharudet (Mozilla universal character detector) dnl libenca dnl libmagic and optional libz dnl libguess (www.atheme.org) -dnl libintl +dnl lib[15~ICONVintl dnl libcurl dnl libltdl dnl liberty dnl libbfd dnl -dnl TODO: -dnl libpcre -dnl libtre -dnl +AC_FUNC_ALLOCA LIBMALLOC_CHECK_CONFIG() LIBSPELL_CHECK_CONFIG() @@ -282,7 +302,6 @@ AC_CHECK_LIB(aprutil,main) CF_WITH_LIBICONV dnl CF_WITH_LIBUTF8 -dnl CF_LIB_CHARUDET CF_WITH_LIBENCA CF_WITH_LIBMAGIC AC_CHECK_LIB(guess,libguess_determine_encoding, [LIBGUESS=['-lguess']]) @@ -306,19 +325,14 @@ AC_CHECK_LIB(ltdl, lt_dlinit, [ AC_CHECK_LIB(iberty, cplus_demangle, [ AC_DEFINE(HAVE_LIBIBERTY, 1, - [Define to enable libiberty support]) + [Define to enable liberty support]) AC_DEFINE(HAVE_CPLUS_DEMANGLE, 1, [Whether or not we have to demangle names]) AC_CHECK_HEADERS(libiberty.h demangle.h) CF_ADD_EXTRALIBS("-liberty") ]) -AC_CHECK_LIB(bfd, bfd_openr, [ - AC_DEFINE(HAVE_LIBBFD, 1, - [Define to enable libbfd support]) - AC_CHECK_HEADERS(bfd.h) - CF_ADD_EXTRALIBS("-lbfd") - ]) +CF_CHECK_LIBBFD AX_CHECK_OPENSSL([ AC_DEFINE(HAVE_OPENSSL, 1, @@ -349,13 +363,13 @@ dnl mouse_lib="none" AC_MSG_CHECKING(whether to enable mouse handling) AC_ARG_WITH(mouse, - [ --with-mouse enable mouse support], - [with_mouse=$withval], - [with_mouse=no]) + [ --without-mouse disable mouse support], + [with_mouse=nol], + [with_mouse=yes]) AC_MSG_RESULT($with_mouse) if test "$with_mouse" = yes ; then - AC_DEFINE(HAVE_MOUSE, 1, - [Define to enable mouse support]) + AC_DEFINE(HAVE_MOUSE, 1, + [Define to enable mouse support]) mouse_lib="xterm only" fi @@ -437,48 +451,48 @@ if test "$with_assert" = no ; then fi fi - -dnl TODO -dnl AC_MSG_CHECKING([For a working C99 __func__]) -dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], -dnl [[const char *foo = __func__;]])], -dnl [ac_cv_cpp_func=yes], -dnl [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], -dnl [[const char *foo = __FUNCTION__;]])], -dnl [ac_cv_cpp_func=__FUNCTION__], -dnl [ac_cv_cpp_func="\"no\""])] -dnl ) -dnl -dnl if test "X$ac_cv_cpp_func" = "X__FUNCTION__"; then -dnl AC_MSG_RESULT([__FUNCTION__]) -dnl elif test "x$ac_cv_cpp_func" = "xyes" ; then -dnl AC_MSG_RESULT([__func__]) -dnl else -dnl AC_MSG_RESULT([no]) -dnl fi -dnl if test "X$ac_cv_cpp_func" != "Xyes" ; then -dnl AC_DEFINE_UNQUOTED([__func__], [$ac_cv_cpp_func], [Define to be a __func__ replacement]) -dnl fi - dnl dnl Checks for programs. -dnl @AR@, @AWK@, @MKDIR_P@ -dnl @LEX@, @YACC@ and @BISON@ +dnl @AR@, @LN@, @AWK@ +dnl @LEX@, @YACC@ and @BISON@ dnl AC_PROG_INSTALL -AC_PATH_PROG(AR,ar,ar) -AC_PROG_MKDIR_P +AC_PATH_PROG([AR],[ar],[ar]) AC_PROG_LN_S AC_PROG_AWK + +AC_CHECK_PROG(PERL_CHECK,perl,yes) +if test x"$PERL_CHECK" != x"yes" ; then + AC_MSG_ERROR([couldn't locate perl; make sure it's installed and in your path]) +fi m4_version_prereq([2.70], [AC_PROG_LEX(noyywrap)], [AC_PROG_LEX]) if test "$LEX" != "flex"; then - AC_MSG_ERROR(couldn't locate flex; make sure it's installed and in your path) + AC_MSG_WARN([couldn't locate flex; make sure it's installed and in your path]) + AS_ECHO("") + AS_ECHO("You should only need it if you modified a '.l' file.") + AS_ECHO("You may want to install the Fast Lexical Analyzer package:") + AS_ECHO("") + AS_ECHO(" ") + AS_ECHO("") + AC_MSG_ERROR([flex missing]) fi AC_PROG_YACC if test "$YACC" != "bison -y"; then - AC_MSG_ERROR(couldn't locate bison; make sure it's installed and in your path) + if test "$YACC" != "byacc"; then + if test "$YACC" != "yacc"; then + AC_MSG_WARN([couldn't locate bison/byacc; make sure it's installed and in your path]) + AS_ECHO("") + AS_ECHO("You should only need it if you modified a '.y' file."]) + AS_ECHO("You may want to install the either byacc or the bison package:"]) + AS_ECHO("") + AS_ECHO(" ") + AS_ECHO(" or ") + AS_ECHO("") + AC_MSG_ERROR([bison/byacc missing]) + fi + fi fi AC_PATH_PROG(BISON,bison,bison) @@ -578,8 +592,7 @@ AC_CHECK_HEADERS( \ dnl C1X headers AC_CHECK_HEADERS( \ stdalign.h \ - stdatomic.h \ - threads.h ) + stdatomic.h ) dnl Terminal specific headers AC_CHECK_HEADERS( \ @@ -592,7 +605,8 @@ AC_CHECK_HEADERS( \ dnl Signal support CF_TYPE_SIGACTION AC_CHECK_HEADERS( \ - signal.h ) + signal.h \ + siginfo.h sys/siginfo.h ) AC_CHECK_FUNCS(\ sigsetmask \ siginterrupt \ @@ -628,11 +642,12 @@ CF_FUNC_ISASCII CF_FUNC_ISBLANK CF_FUNC_ISCSYM -CF_FUNC_MKSTEMP CF_LANGINFO_CODESET +CF_FUNC_MKSTEMP CF_FUNC_MEMMOVE +CF_FUNC_VASPRINTF -AC_CHECK_HEADERS(wait.h sys/wait.h) +AC_CHECK_HEADERS(wait.h sys/wait.h sysinfo.h sys/sysinfo.h) AC_FUNC_FORK AC_CHECK_HEADERS(spawn.h) AC_CHECK_FUNCS(\ @@ -648,7 +663,7 @@ AC_CHECK_HEADERS(pty.h grp.h stropts.h) AC_CHECK_HEADERS(sys/stream.h sys/termios) AC_CHECK_HEADERS(sys/ptem.h, [], [], [ #ifdef HAVE_SYS_STREAM_H -#include /* Solaris 8, sys/stream.h is a prerequisite. */ +#include /* Solaris 8, sys/stream.h is a prerequisite. */ #endif ]) AC_CHECK_FUNCS(posix_openpt, , [AC_CHECK_FUNCS(getpt)]) @@ -764,6 +779,10 @@ AC_CONFIG_FILES([\ macsrc/Makefile \ util/Makefile]) +if test "x$with_libfltk" = "xyes"; then + AC_CONFIG_FILES([libfltk/Makefile]) +fi + case $host_os in mingw*) AC_CONFIG_FILES([libw32/Makefile]) @@ -791,6 +810,8 @@ AX_RECURSIVE_EVAL([\$prefix], [var_prefix]) AX_RECURSIVE_EVAL([\$datadir], [var_datadir]) AX_RECURSIVE_EVAL([\$bindir], [var_bindir]) +dnl AC_CONFIG_HEADERS, replaces DEFS with -DHAVE_CONFIG_H + AC_MSG_RESULT([-]) AC_MSG_RESULT([- Configuration:]) AC_MSG_RESULT([-]) @@ -798,12 +819,12 @@ AC_MSG_RESULT([- Compiler: $CC / $CXX]) AC_MSG_RESULT([- Depend: $CPPDEP]) AC_MSG_RESULT([- CFLAGS: $CFLAGS $OPENSSL_INCLUDES $EXTRA_CFLAGS $CWARN]) AC_MSG_RESULT([- Debug:$CDEBUG, Release:$CRELEASE]) -AC_MSG_RESULT([- CXXFLAGS: $CXXFLAGS $EXTRA_CPPFLAGS $CXXWARN]) +AC_MSG_RESULT([- CXXFLAGS: $CXXFLAGS $EXTRA_CXXFLAGS $CXXWARN]) AC_MSG_RESULT([- Debug:$CXXDEBUG, Release:$CXXRELEASE]) AC_MSG_RESULT([- LDFLAGS: $OPENSSL_LDFLAGS $LDFLAGS]) -AC_MSG_RESULT([- Preprocessor: $EXTRA_CPPFLAGS $LIBCURL_CPPFLAGS]) +AC_MSG_RESULT([- Preprocessor: -DHAVE_CONFIG_H $EXTRA_CPPFLAGS $LIBCURL_CPPFLAGS]) AC_MSG_RESULT([- Mouse support: ${mouse_lib}]) -AC_MSG_RESULT([- Termap support: ${termlib_name}]) +AC_MSG_RESULT([- Tercmap support: $CURSES_CFLAGS $TERMLIB]) AC_MSG_RESULT([- Spell Support: $LIBSPELL]) AC_MSG_RESULT([- Conversion: $LIBICU $LIBAPRICONV $LIBICONV]) AC_MSG_RESULT([- Detection: $LIBENCA $LIBCHARUDET $LIBGUESS $LIBMAGIC]) diff --git a/auto/m4/ax_compiler_vendor.m4 b/auto/m4/ax_compiler_vendor.m4 new file mode 100644 index 00000000..039f99d2 --- /dev/null +++ b/auto/m4/ax_compiler_vendor.m4 @@ -0,0 +1,119 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_compiler_vendor.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_COMPILER_VENDOR +# +# DESCRIPTION +# +# Determine the vendor of the C, C++ or Fortran compiler. The vendor is +# returned in the cache variable $ax_cv_c_compiler_vendor for C, +# $ax_cv_cxx_compiler_vendor for C++ or $ax_cv_fc_compiler_vendor for +# (modern) Fortran. The value is one of "intel", "ibm", "pathscale", +# "clang" (LLVM), "cray", "fujitsu", "sdcc", "sx", "nvhpc" (NVIDIA HPC +# Compiler), "portland" (PGI), "gnu" (GCC), "sun" (Oracle Developer +# Studio), "hp", "dec", "borland", "comeau", "kai", "lcc", "sgi", +# "microsoft", "metrowerks", "watcom", "tcc" (Tiny CC) or "unknown" (if +# the compiler cannot be determined). +# +# To check for a Fortran compiler, you must first call AC_FC_PP_SRCEXT +# with an appropriate preprocessor-enabled extension. For example: +# +# AC_LANG_PUSH([Fortran]) +# AC_PROG_FC +# AC_FC_PP_SRCEXT([F]) +# AX_COMPILER_VENDOR +# AC_LANG_POP([Fortran]) +# +# LICENSE +# +# Copyright (c) 2008 Steven G. Johnson +# Copyright (c) 2008 Matteo Frigo +# Copyright (c) 2018-19 John Zaitseff +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 32 + +AC_DEFUN([AX_COMPILER_VENDOR], [dnl + AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor, [dnl + dnl If you modify this list of vendors, please add similar support + dnl to ax_compiler_version.m4 if at all possible. + dnl + dnl Note: Do NOT check for GCC first since some other compilers + dnl define __GNUC__ to remain compatible with it. Compilers that + dnl are very slow to start (such as Intel) are listed first. + + vendors=" + intel: __ICC,__ECC,__INTEL_COMPILER + ibm: __xlc__,__xlC__,__IBMC__,__IBMCPP__,__ibmxl__ + pathscale: __PATHCC__,__PATHSCALE__ + clang: __clang__ + cray: _CRAYC + fujitsu: __FUJITSU + sdcc: SDCC,__SDCC + sx: _SX + nvhpc: __NVCOMPILER + portland: __PGI + gnu: __GNUC__ + sun: __SUNPRO_C,__SUNPRO_CC,__SUNPRO_F90,__SUNPRO_F95 + hp: __HP_cc,__HP_aCC + dec: __DECC,__DECCXX,__DECC_VER,__DECCXX_VER + borland: __BORLANDC__,__CODEGEARC__,__TURBOC__ + comeau: __COMO__ + kai: __KCC + lcc: __LCC__ + sgi: __sgi,sgi + microsoft: _MSC_VER + metrowerks: __MWERKS__ + watcom: __WATCOMC__ + tcc: __TINYC__ + unknown: UNKNOWN + " + for ventest in $vendors; do + case $ventest in + *:) + vendor=$ventest + continue + ;; + *) + vencpp="defined("`echo $ventest | sed 's/,/) || defined(/g'`")" + ;; + esac + + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[ +#if !($vencpp) + thisisanerror; +#endif + ]])], [break]) + done + + ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=`echo $vendor | cut -d: -f1` + ]) +])dnl diff --git a/auto/m4/ax_compiler_version.m4 b/auto/m4/ax_compiler_version.m4 new file mode 100644 index 00000000..01d1ed5c --- /dev/null +++ b/auto/m4/ax_compiler_version.m4 @@ -0,0 +1,544 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_compiler_version.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_COMPILER_VERSION +# +# DESCRIPTION +# +# This macro retrieves the compiler version and returns it in the cache +# variable $ax_cv_c_compiler_version for C and $ax_cv_cxx_compiler_version +# for C++. +# +# Version is returned as epoch:major.minor.patchversion +# +# Epoch is used in order to have an increasing version number in case of +# marketing change. +# +# Epoch use: * borland compiler use chronologically 0turboc for turboc +# era, +# +# 1borlanc BORLANDC++ before 5, 2cppbuilder for cppbuilder era, +# 3borlancpp for return of BORLANDC++ (after version 5.5), +# 4cppbuilder for cppbuilder with year version, +# and 5xe for XE era. +# +# An empty string is returned otherwise. +# +# LICENSE +# +# Copyright (c) 2014 Bastien ROUCARIES +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 14 + +# for intel +AC_DEFUN([_AX_COMPILER_VERSION_INTEL], + [ dnl + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, + [__INTEL_COMPILER/100],, + AC_MSG_FAILURE([[[$0]] unknown intel compiler version])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, + [(__INTEL_COMPILER%100)/10],, + AC_MSG_FAILURE([[[$0]] unknown intel compiler version])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, + [(__INTEL_COMPILER%10)],, + AC_MSG_FAILURE([[[$0]] unknown intel compiler version])) + ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" + ]) + +# for IBM +AC_DEFUN([_AX_COMPILER_VERSION_IBM], + [ dnl + dnl check between z/OS C/C++ and XL C/C++ + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([], + [ + #if defined(__COMPILER_VER__) + choke me; + #endif + ])], + [ + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, + [__xlC__/100],, + AC_MSG_FAILURE([[[$0]] unknown IBM compiler major version])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, + [__xlC__%100],, + AC_MSG_FAILURE([[[$0]] unknown IBM compiler minor version])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, + [__xlC_ver__/0x100],, + AC_MSG_FAILURE([[[$0]] unknown IBM compiler patch version])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_build, + [__xlC_ver__%0x100],, + AC_MSG_FAILURE([[[$0]] unknown IBM compiler build version])) + ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_build" + ], + [ + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, + [__xlC__%1000],, + AC_MSG_FAILURE([[[$0]] unknown IBM compiler patch version])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, + [(__xlC__/10000)%10],, + AC_MSG_FAILURE([[[$0]] unknown IBM compiler minor version])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, + [(__xlC__/100000)%10],, + AC_MSG_FAILURE([[[$0]] unknown IBM compiler major version])) + ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" + ]) +]) + +# for pathscale +AC_DEFUN([_AX_COMPILER_VERSION_PATHSCALE],[ + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, + __PATHCC__,, + AC_MSG_FAILURE([[[$0]] unknown pathscale major])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, + __PATHCC_MINOR__,, + AC_MSG_FAILURE([[[$0]] unknown pathscale minor])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, + [__PATHCC_PATCHLEVEL__],, + AC_MSG_FAILURE([[[$0]] unknown pathscale patch level])) + ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" + ]) + +# for clang +AC_DEFUN([_AX_COMPILER_VERSION_CLANG],[ + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, + __clang_major__,, + AC_MSG_FAILURE([[[$0]] unknown clang major])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, + __clang_minor__,, + AC_MSG_FAILURE([[[$0]] unknown clang minor])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, + [__clang_patchlevel__],,0) + ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" + ]) + +# for crayc +AC_DEFUN([_AX_COMPILER_VERSION_CRAY],[ + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, + _RELEASE,, + AC_MSG_FAILURE([[[$0]] unknown crayc release])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, + _RELEASE_MINOR,, + AC_MSG_FAILURE([[[$0]] unknown crayc minor])) + ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor" + ]) + +# for fujitsu +AC_DEFUN([_AX_COMPILER_VERSION_FUJITSU],[ + AC_COMPUTE_INT(ax_cv_[]_AC_LANG_ABBREV[]_compiler_version, + __FCC_VERSION,, + AC_MSG_FAILURE([[[$0]]unknown fujitsu release])) + ]) + +# for GNU +AC_DEFUN([_AX_COMPILER_VERSION_GNU],[ + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, + __GNUC__,, + AC_MSG_FAILURE([[[$0]] unknown gcc major])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, + __GNUC_MINOR__,, + AC_MSG_FAILURE([[[$0]] unknown gcc minor])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, + [__GNUC_PATCHLEVEL__],, + AC_MSG_FAILURE([[[$0]] unknown gcc patch level])) + ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" + ]) + +# For sun +AC_DEFUN([_AX_COMPILER_VERSION_SUN],[ + m4_define([_AX_COMPILER_VERSION_SUN_NUMBER], + [ + #if defined(__SUNPRO_CC) + __SUNPRO_CC + #else + __SUNPRO_C + #endif + ]) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_until59, + !!(_AX_COMPILER_VERSION_SUN_NUMBER < 0x1000),, + AC_MSG_FAILURE([[[$0]] unknown sun release version])) + AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_until59" = X1], + [dnl + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, + _AX_COMPILER_VERSION_SUN_NUMBER % 0x10,, + AC_MSG_FAILURE([[[$0]] unknown sun patch version])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, + (_AX_COMPILER_VERSION_SUN_NUMBER / 0x10) % 0x10,, + AC_MSG_FAILURE([[[$0]] unknown sun minor version])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, + (_AX_COMPILER_VERSION_SUN_NUMBER / 0x100),, + AC_MSG_FAILURE([[[$0]] unknown sun major version])) + ], + [dnl + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, + _AX_COMPILER_VERSION_SUN_NUMBER % 0x10,, + AC_MSG_FAILURE([[[$0]] unknown sun patch version])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, + (_AX_COMPILER_VERSION_SUN_NUMBER / 0x100) % 0x100,, + AC_MSG_FAILURE([[[$0]] unknown sun minor version])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, + (_AX_COMPILER_VERSION_SUN_NUMBER / 0x1000),, + AC_MSG_FAILURE([[[$0]] unknown sun major version])) + ]) + ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" +]) + +AC_DEFUN([_AX_COMPILER_VERSION_HP],[ + m4_define([_AX_COMPILER_VERSION_HP_NUMBER], + [ + #if defined(__HP_cc) + __HP_cc + #else + __HP_aCC + #endif + ]) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_untilA0121, + !!(_AX_COMPILER_VERSION_HP_NUMBER <= 1),, + AC_MSG_FAILURE([[[$0]] unknown hp release version])) + AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_untilA0121" = X1], + [dnl By default output last version with this behavior. + dnl it is so old + ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="01.21.00" + ], + [dnl + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, + (_AX_COMPILER_VERSION_HP_NUMBER % 100),, + AC_MSG_FAILURE([[[$0]] unknown hp release version])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, + ((_AX_COMPILER_VERSION_HP_NUMBER / 100)%100),, + AC_MSG_FAILURE([[[$0]] unknown hp minor version])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, + ((_AX_COMPILER_VERSION_HP_NUMBER / 10000)%100),, + AC_MSG_FAILURE([[[$0]] unknown hp major version])) + ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" + ]) +]) + +AC_DEFUN([_AX_COMPILER_VERSION_DEC],[dnl + m4_define([_AX_COMPILER_VERSION_DEC_NUMBER], + [ + #if defined(__DECC_VER) + __DECC_VER + #else + __DECCXX_VER + #endif + ]) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, + (_AX_COMPILER_VERSION_DEC_NUMBER % 10000),, + AC_MSG_FAILURE([[[$0]] unknown dec release version])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, + ((_AX_COMPILER_VERSION_DEC_NUMBER / 100000UL)%100),, + AC_MSG_FAILURE([[[$0]] unknown dec minor version])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, + ((_AX_COMPILER_VERSION_DEC_NUMBER / 10000000UL)%100),, + AC_MSG_FAILURE([[[$0]] unknown dec major version])) + ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" + ]) + +# borland +AC_DEFUN([_AX_COMPILER_VERSION_BORLAND],[dnl + m4_define([_AX_COMPILER_VERSION_TURBOC_NUMBER], + [ + #if defined(__TURBOC__) + __TURBOC__ + #else + choke me + #endif + ]) + m4_define([_AX_COMPILER_VERSION_BORLANDC_NUMBER], + [ + #if defined(__BORLANDC__) + __BORLANDC__ + #else + __CODEGEARC__ + #endif + ]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM(, + _AX_COMPILER_VERSION_TURBOC_NUMBER)], + [dnl TURBOC + AC_COMPUTE_INT( + _ax_[]_AC_LANG_ABBREV[]_compiler_version_turboc_raw, + _AX_COMPILER_VERSION_TURBOC_NUMBER,, + AC_MSG_FAILURE([[[$0]] unknown turboc version])) + AS_IF( + [test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_turboc_raw -lt 661 || test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_turboc_raw -gt 1023], + [dnl compute normal version + AC_COMPUTE_INT( + _ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, + _AX_COMPILER_VERSION_TURBOC_NUMBER % 0x100,, + AC_MSG_FAILURE([[[$0]] unknown turboc minor version])) + AC_COMPUTE_INT( + _ax_[]_AC_LANG_ABBREV[]_compiler_version_major, + (_AX_COMPILER_VERSION_TURBOC_NUMBER/0x100)%0x100,, + AC_MSG_FAILURE([[[$0]] unknown turboc major version])) + ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="0turboc:$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor"], + [dnl special version + AS_CASE([$_ax_[]_AC_LANG_ABBREV[]_compiler_version_turboc_raw], + [661],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="0turboc:1.00"], + [662],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="0turboc:1.01"], + [663],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="0turboc:2.00"], + [ + AC_MSG_WARN([[[$0]] unknown turboc version between 0x295 and 0x400 please report bug]) + ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="" + ]) + ]) + ], + # borlandc + [ + AC_COMPUTE_INT( + _ax_[]_AC_LANG_ABBREV[]_compiler_version_borlandc_raw, + _AX_COMPILER_VERSION_BORLANDC_NUMBER,, + AC_MSG_FAILURE([[[$0]] unknown borlandc version])) + AS_CASE([$_ax_[]_AC_LANG_ABBREV[]_compiler_version_borlandc_raw], + dnl BORLANDC++ before 5.5 + [512] ,[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:2.00"], + [1024],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:3.00"], + [1024],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:3.00"], + [1040],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:3.1"], + [1106],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:4.0"], + [1280],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:5.0"], + [1312],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:5.02"], + dnl C++ Builder era + [1328],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="2cppbuilder:3.0"], + [1344],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="2cppbuilder:4.0"], + dnl BORLANDC++ after 5.5 + [1360],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="3borlancpp:5.5"], + [1361],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="3borlancpp:5.51"], + [1378],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="3borlancpp:5.6.4"], + dnl C++ Builder with year number + [1392],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="4cppbuilder:2006"], + [1424],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="4cppbuilder:2007"], + [1555],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="4cppbuilder:2009"], + [1569],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="4cppbuilder:2010"], + dnl XE version + [1584],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="5xe"], + [1600],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="5xe:2"], + [1616],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="5xe:3"], + [1632],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="5xe:4"], + [ + AC_MSG_WARN([[[$0]] Unknown borlandc compiler version $_ax_[]_AC_LANG_ABBREV[]_compiler_version_borlandc_raw please report bug]) + ]) + ]) + ]) + +# COMO +AC_DEFUN([_AX_COMPILER_VERSION_COMEAU], + [ dnl + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, + [__COMO_VERSION__%100],, + AC_MSG_FAILURE([[[$0]] unknown comeau compiler minor version])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, + [(__COMO_VERSION__/100)%10],, + AC_MSG_FAILURE([[[$0]] unknown comeau compiler major version])) + ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor" + ]) + +# KAI +AC_DEFUN([_AX_COMPILER_VERSION_KAI],[ + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, + [__KCC_VERSION%100],, + AC_MSG_FAILURE([[[$0]] unknown kay compiler patch version])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, + [(__KCC_VERSION/100)%10],, + AC_MSG_FAILURE([[[$0]] unknown kay compiler minor version])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, + [(__KCC_VERSION/1000)%10],, + AC_MSG_FAILURE([[[$0]] unknown kay compiler major version])) + ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" + ]) + +dnl LCC +dnl LCC does not output version... + +# SGI +AC_DEFUN([_AX_COMPILER_VERSION_SGI],[ + m4_define([_AX_COMPILER_VERSION_SGI_NUMBER], + [ + #if defined(_COMPILER_VERSION) + _COMPILER_VERSION + #else + _SGI_COMPILER_VERSION + #endif + ]) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, + [_AX_COMPILER_VERSION_SGI_NUMBER%10],, + AC_MSG_FAILURE([[[$0]] unknown SGI compiler patch version])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, + [(_AX_COMPILER_VERSION_SGI_NUMBER/10)%10],, + AC_MSG_FAILURE([[[$0]] unknown SGI compiler minor version])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, + [(_AX_COMPILER_VERSION_SGI_NUMBER/100)%10],, + AC_MSG_FAILURE([[[$0]] unknown SGI compiler major version])) + ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" + ]) + +# microsoft +AC_DEFUN([_AX_COMPILER_VERSION_MICROSOFT],[ + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, + _MSC_VER%100,, + AC_MSG_FAILURE([[[$0]] unknown microsoft compiler minor version])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, + (_MSC_VER/100)%100,, + AC_MSG_FAILURE([[[$0]] unknown microsoft compiler major version])) + dnl could be overridden + _ax_[]_AC_LANG_ABBREV[]_compiler_version_patch=0 + _ax_[]_AC_LANG_ABBREV[]_compiler_version_build=0 + # special case for version 6 + AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major" = "X12"], + [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, + _MSC_FULL_VER%1000,, + _ax_[]_AC_LANG_ABBREV[]_compiler_version_patch=0)]) + # for version 7 + AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major" = "X13"], + [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, + _MSC_FULL_VER%1000,, + AC_MSG_FAILURE([[[$0]] unknown microsoft compiler patch version])) + ]) + # for version > 8 + AS_IF([test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_major -ge 14], + [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, + _MSC_FULL_VER%10000,, + AC_MSG_FAILURE([[[$0]] unknown microsoft compiler patch version])) + ]) + AS_IF([test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_major -ge 15], + [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_build, + _MSC_BUILD,, + AC_MSG_FAILURE([[[$0]] unknown microsoft compiler build version])) + ]) + ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_build" + ]) + +# for metrowerks +AC_DEFUN([_AX_COMPILER_VERSION_METROWERKS],[dnl + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, + __MWERKS__%0x100,, + AC_MSG_FAILURE([[[$0]] unknown metrowerks compiler patch version])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, + (__MWERKS__/0x100)%0x10,, + AC_MSG_FAILURE([[[$0]] unknown metrowerks compiler minor version])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, + (__MWERKS__/0x1000)%0x10,, + AC_MSG_FAILURE([[[$0]] unknown metrowerks compiler major version])) + ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" + ]) + +# for watcom +AC_DEFUN([_AX_COMPILER_VERSION_WATCOM],[dnl + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, + __WATCOMC__%100,, + AC_MSG_FAILURE([[[$0]] unknown watcom compiler minor version])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, + (__WATCOMC__/100)%100,, + AC_MSG_FAILURE([[[$0]] unknown watcom compiler major version])) + ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor" + ]) + +# for NVHPC +AC_DEFUN([_AX_COMPILER_VERSION_NVHPC],[ + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, + __NVCOMPILER_MAJOR__,, + AC_MSG_FAILURE([[[$0]] unknown nvhpc major])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, + __NVCOMPILER_MINOR__,, + AC_MSG_FAILURE([[[$0]] unknown nvhpc minor])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, + [__NVCOMPILER_PATCHLEVEL__],, + AC_MSG_FAILURE([[[$0]] unknown nvhpc patch level])) + ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" + ]) + +# for PGI +AC_DEFUN([_AX_COMPILER_VERSION_PORTLAND],[ + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, + __PGIC__,, + AC_MSG_FAILURE([[[$0]] unknown pgi major])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, + __PGIC_MINOR__,, + AC_MSG_FAILURE([[[$0]] unknown pgi minor])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, + [__PGIC_PATCHLEVEL__],, + AC_MSG_FAILURE([[[$0]] unknown pgi patch level])) + ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" + ]) + +# tcc +AC_DEFUN([_AX_COMPILER_VERSION_TCC],[ + ax_cv_[]_AC_LANG_ABBREV[]_compiler_version=[`tcc -v | $SED 's/^[ ]*tcc[ ]\+version[ ]\+\([0-9.]\+\).*/\1/g'`] + ]) + +# for GNU +AC_DEFUN([_AX_COMPILER_VERSION_SDCC],[ + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, + /* avoid parse error with comments */ + #if(defined(__SDCC_VERSION_MAJOR)) + __SDCC_VERSION_MAJOR + #else + SDCC/100 + #endif + ,, + AC_MSG_FAILURE([[[$0]] unknown sdcc major])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, + /* avoid parse error with comments */ + #if(defined(__SDCC_VERSION_MINOR)) + __SDCC_VERSION_MINOR + #else + (SDCC%100)/10 + #endif + ,, + AC_MSG_FAILURE([[[$0]] unknown sdcc minor])) + AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, + [ + /* avoid parse error with comments */ + #if(defined(__SDCC_VERSION_PATCH)) + __SDCC_VERSION_PATCH + #elsif(defined(_SDCC_VERSION_PATCHLEVEL)) + __SDCC_VERSION_PATCHLEVEL + #else + SDCC%10 + #endif + ],, + AC_MSG_FAILURE([[[$0]] unknown sdcc patch level])) + ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" + ]) + +# main entry point +AC_DEFUN([AX_COMPILER_VERSION],[dnl + AC_REQUIRE([AX_COMPILER_VENDOR]) + AC_REQUIRE([AC_PROG_SED]) + AC_CACHE_CHECK([for _AC_LANG compiler version], + ax_cv_[]_AC_LANG_ABBREV[]_compiler_version, + [ dnl + AS_CASE([$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor], + [intel],[_AX_COMPILER_VERSION_INTEL], + [ibm],[_AX_COMPILER_VERSION_IBM], + [pathscale],[_AX_COMPILER_VERSION_PATHSCALE], + [clang],[_AX_COMPILER_VERSION_CLANG], + [cray],[_AX_COMPILER_VERSION_CRAY], + [fujitsu],[_AX_COMPILER_VERSION_FUJITSU], + [gnu],[_AX_COMPILER_VERSION_GNU], + [sun],[_AX_COMPILER_VERSION_SUN], + [hp],[_AX_COMPILER_VERSION_HP], + [dec],[_AX_COMPILER_VERSION_DEC], + [borland],[_AX_COMPILER_VERSION_BORLAND], + [comeau],[_AX_COMPILER_VERSION_COMEAU], + [kai],[_AX_COMPILER_VERSION_KAI], + [sgi],[_AX_COMPILER_VERSION_SGI], + [microsoft],[_AX_COMPILER_VERSION_MICROSOFT], + [metrowerks],[_AX_COMPILER_VERSION_METROWERKS], + [watcom],[_AX_COMPILER_VERSION_WATCOM], + [nvhpc],[_AX_COMPILER_VERSION_NVHPC], + [portland],[_AX_COMPILER_VERSION_PORTLAND], + [tcc],[_AX_COMPILER_VERSION_TCC], + [sdcc],[_AX_COMPILER_VERSION_SDCC], + [ax_cv_[]_AC_LANG_ABBREV[]_compiler_version=""]) + ]) +]) diff --git a/auto/m4/iswin32.m4 b/auto/m4/iswin32.m4 new file mode 100644 index 00000000..010c01f6 --- /dev/null +++ b/auto/m4/iswin32.m4 @@ -0,0 +1,28 @@ +dnl $Id: iswin32.m4,v 1.1 2024/07/12 18:22:15 cvsuser Exp $ +dnl ISWIN32=yes/no. +dnl -*- mode: autoconf; tab-width: 8; -*- +dnl + + +dnl --------------------------------------------------------------------------- +dnl CF_ISWIN32 - configure ISWIN32 +dnl + +AC_DEFUN([CF_ISWIN32],[ + AC_REQUIRE([CF_CANONICAL_HOST]) + AC_MSG_CHECKING(for win32-target) + case "$host_os" in + *cygwin*) + ISWIN32=yes + ;; + *mingw*) + ISWIN32=yes + ;; + *) + ISWIN32=no + ;; + esac + AC_MSG_RESULT([$ISWIN32]) + AC_SUBST([ISWIN32]) +])dnl + diff --git a/auto/m4/libm.m4 b/auto/m4/libm.m4 index c1e01bbe..8fc9b492 100644 --- a/auto/m4/libm.m4 +++ b/auto/m4/libm.m4 @@ -1,4 +1,4 @@ -dnl $Id: libm.m4,v 1.2 2024/05/02 14:34:31 cvsuser Exp $ +dnl $Id: libm.m4,v 1.3 2024/07/13 08:12:36 cvsuser Exp $ dnl libm autoconf dnl -*- mode: autoconf; tab-width: 8; -*- dnl @@ -8,7 +8,7 @@ AC_DEFUN([CF_NEED_LIBM],[ AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #include #include ]], - [[double x = log10(1.0); printf("result = %g/%g\n", sin(x), tan(x));]])], + [[double x = log10(1.0); char buf[256]; sprintf(buf, "result = %g/%g\n", sin(x), tan(x));]])], [cf_cv_need_libm=no], [cf_cv_need_libm=yes]) @@ -18,7 +18,7 @@ AC_DEFUN([CF_NEED_LIBM],[ AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #include #include ]], - [[double x = log10(1.0); printf("result = %g/%g\n", sin(x), tan(x));]])], + [[double x = log10(1.0); char buf[256]; sprintf(buf, "result = %g/%g\n", sin(x), tan(x));]])], [cf_cv_need_libm=yes], [cf_cv_need_libm=missing]) LIBS="$cf_save_LIBS" diff --git a/auto/m4/libmalloc.m4 b/auto/m4/libmalloc.m4 index 1e98ccc3..c99897fb 100644 --- a/auto/m4/libmalloc.m4 +++ b/auto/m4/libmalloc.m4 @@ -1,4 +1,4 @@ -dnl $Id: libmalloc.m4,v 1.5 2024/05/02 14:34:32 cvsuser Exp $ +dnl $Id: libmalloc.m4,v 1.6 2024/06/14 16:41:42 cvsuser Exp $ dnl Process this file with autoconf to produce a configure script. dnl -*- mode: autoconf; tab-width: 8; -*- dnl @@ -85,15 +85,15 @@ AC_DEFUN([CF_MALLOC_OPT],[ malloc_stats \ mallinfo \ mallopt) +])dnl + +dnl AC_SEARCH_LIBS(mallinfo,malloc,[ +dnl AC_DEFINE([HAVE_MALLINFO],[1],[Define if mallinfo() is available on this platform.])]) +dnl AC_CHECK_TYPES([struct mallinfo],,, [#include ]) +dnl AC_CHECK_MEMBER([struct mallinfo.hblks]) +dnl AC_CHECK_MEMBER([struct mallinfo.keepcost]) +dnl AC_CHECK_MEMBER([struct mallinfo.treeoverhead]) +dnl AC_CHECK_MEMBER([struct mallinfo.grain]) +dnl AC_CHECK_MEMBER([struct mallinfo.allocated]) -# AC_SEARCH_LIBS(mallinfo,malloc,[ -# AC_DEFINE([HAVE_MALLINFO],[1],[Define if mallinfo() is available on this platform.])]) -# AC_CHECK_TYPES([struct mallinfo],,, [#include ]) -# AC_CHECK_MEMBER([struct mallinfo.hblks]) -# AC_CHECK_MEMBER([struct mallinfo.keepcost]) -# AC_CHECK_MEMBER([struct mallinfo.treeoverhead]) -# AC_CHECK_MEMBER([struct mallinfo.grain]) -# AC_CHECK_MEMBER([struct mallinfo.allocated]) -]) - -dnl end \ No newline at end of file +dnl end diff --git a/auto/m4/libterm.m4 b/auto/m4/libterm.m4 index 83e4c2da..3aac22d0 100644 --- a/auto/m4/libterm.m4 +++ b/auto/m4/libterm.m4 @@ -1,22 +1,140 @@ -dnl $Id: libterm.m4,v 1.8 2024/05/28 10:33:29 cvsuser Exp $ +dnl $Id: libterm.m4,v 1.32 2024/09/09 12:20:39 cvsuser Exp $ dnl Process this file with autoconf to produce a configure script. dnl -*- mode: autoconf; tab-width: 8; -*- dnl dnl Terminal support library checks dnl +dnl Usage: +dnl +dnl #if defined(HAVE_LIBNCURSESW) +dnl #elif defined(HAVE_LIBNCURSES) +dnl #elif defined(HAVE_LIBCURSES) +dnl #endif +dnl +dnl #if defined HAVE_NCURSESW_CURSES_H +dnl # include +dnl # include +dnl # include +dnl #elif defined HAVE_NCURSESW_H +dnl # include +dnl # if defined(HAVE_TERMCAP_H) +dnl # include +dnl # endif +dnl # if defined(HAVE_TERM_H) +dnl # include +dnl # endif +dnl #elif defined HAVE_NCURSES_CURSES_H +dnl # include +dnl # include +dnl # include +dnl #elif defined HAVE_NCURSES_H +dnl # include +dnl # if defined(HAVE_TERMCAP_H) +dnl # include +dnl # endif +dnl # if defined(HAVE_TERM_H) +dnl # include +dnl # endif +dnl #else +dnl # error "missing ncurses" .. +dnl #endif +dnl +dnl Import: +dnl CURSES_CFLAGS +dnl CURSES_LDFLAGS +dnl +dnl Export: +dnl CURSES_CFLAGS +dnl CURSES_LDFLAGS (within TERMLIB) +dnl +dnl HAVE_LIBNCURSESW +dnl HAVE_LIBNCURSESW_G +dnl HAVE_LIBNCURSES +dnl HAVE_LIBNCURSES_G +dnl HAVE_LIBTINFO +dnl HAVE_LIBCURSES +dnl TERMLIB +dnl +dnl HAVE_NCURSESW_CURSES_H +dnl HAVE_NCURSESW_TERMCAP_H +dnl HAVE_NCURSESW_TERM_H +dnl HAVE_NCURSES_CURSES_H +dnl HAVE_NCURSES_TERMCAP_H +dnl HAVE_NCURSES_TERM_H +dnl HAVE_NCURSESW_H +dnl HAVE_NCURSES_H +dnl HAVE_TERMCAP_H +dnl HAVE_TERM_H +dnl +dnl HAVE_CURSES_ENHANCED +dnl HAVE_CURSES_COLOR +dnl +dnl HAVE_OSPEED +dnl or OSPEED_EXTERN +dnl +dnl HAVE_UP_BC_PC +dnl or UP_BC_PC_EXTERN +dnl +dnl HAVE_OUTFUNTYPE +dnl TPUTS_TAKES_CHAR +dnl + +AC_DEFUN([CF_LIBTERM_CHECK_TERMINFO],[ + AC_MSG_CHECKING([for terminfo setupterm(), tigetxxx() and tparm()]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +extern int setupterm(char *, int, int *); +extern int tigetflag(char *); +extern int tigetnum(char *); +extern char *tigetstr(char *); +extern char *tparm(const char *str, ...); +]],[[ + int err = 0; + setupterm((char *)"nonexistentterminal",1,(int *)&err); + tigetflag((char *)"flg"); + tigetnum((char *)"num"); + tigetstr((char *)"str"); + tparm("%p1%d", 1, (void *)0); +]])], + [cf_result=yes],[cf_result=no]) +])dnl + + +AC_DEFUN([CF_LIBTERM_CHECK_TERMCAP],[ + AC_MSG_CHECKING([for termcap tgetxxx() and tgoto()]) + AC_RUN_IFELSE([AC_LANG_PROGRAM([[ +#ifdef HAVE_CURSES_H +#include +#endif +#ifdef HAVE_TERMCAP_H +#include +#endif +#ifdef HAVE_TERM_H +#include +#endif +]],[[ + char buffer[1024 * 2]; + char *str = (char *)0; + tgetent(buffer, "nonexistentterminal"); + tgetflag((char *)"FF"); + tgetnum((char *)"NN"); + tgetstr((char *)"SS", &str); + tgoto("%p1%d", 0, 1); +]])], + [cf_result=yes],[cf_result=no]) +])dnl + AC_DEFUN([LIBTERM_CHECK_CONFIG],[ - AC_MSG_RESULT([determining term lib, --with-termlib options [ncursesw, ncurses, pdcurses, tinfo, curses, termcap, termlib]]) + AC_MSG_RESULT([determining term lib, --with-termlib options [ncursesw, ncurses, tinfo, curses, termcap, termlib]]) + AC_ARG_VAR([CURSES_CFLAGS], [preprocessor flags for Curses, e.g. -I/usr/include/ncursesw]) + AC_ARG_VAR([CURSES_LDFLAGS], [linker flags for Curses, e.g. -L/usr/pkg/lib]) AC_ARG_WITH(ncurses, [ --with-ncurses use ncurses library], with_termlib=ncurses) AC_ARG_WITH(ncursesw, [ --with-ncursesw use ncursesw library], with_termlib=ncursesw) - AC_ARG_WITH(pdcurses, - [ --with-pdcurses use pdcurses library], with_termlib=pdcurses) - AC_ARG_WITH(tinfo, [ --with-tinfo use tinfo library], with_termlib=tinfo) @@ -29,14 +147,22 @@ AC_DEFUN([LIBTERM_CHECK_CONFIG],[ AC_ARG_WITH(termlib, [ --with-termlib=library use names library for terminal support],) + AC_SUBST(CURSES_CFLAGS) + cf_save_CFLAGS="$CFLAGS" + AC_SUBST(TERMLIB) cf_save_LIBS="$LIBS" - termlib_name="" - termlib_cv_terminfo=no - termlib_cv_termcap=no + cf_libterm_name="" + cf_libterm_cv_headers="" + cf_libterm_cv_terminfo=no + cf_libterm_cv_termcap=no + cf_libterm_cv_features=no + cf_result="" + dnl dnl basic headers dnl + AC_CHECK_TOOL([PKG_CONFIG], [pkg-config]) AC_CHECK_HEADERS(curses.h) AC_CHECK_HEADERS(termcap.h) AC_CHECK_HEADERS(term.h, [], [], [ @@ -49,115 +175,181 @@ AC_DEFUN([LIBTERM_CHECK_CONFIG],[ #include ]) + dnl dnl library selection dnl + CFLAGS="$cf_saved_CFLAGS $CURSES_CFLAGS" if test -n "$with_termlib"; then - AC_MSG_RESULT([termcap library ... $with_termlib]) - termlib_name=$with_termlib - AC_MSG_CHECKING(for linking with $with_termlib library) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], AC_MSG_RESULT(OK), AC_MSG_ERROR(FAILED)) - + AC_MSG_RESULT([explicit termlib option, checking if a suitable terminal library]) + termlibs="${with_termlib}" else AC_MSG_RESULT([no termlib options, checking for suitable terminal library]) dnl Selection rules/ dnl - dnl o Newer versions of ncursesw/ncurses are preferred over anything, - dnl note: older versions of ncurses have bugs hence we assume the latest (5.5 +). - dnl o also allow the smaller ncurses tinfo library - dnl o Digital Unix (OSF1) should use curses. - dnl o SCO Openserver prefer termlib. + dnl o newer versions of ncursesw/ncurses are preferred over anything else, + dnl Note: older versions of ncurses have bugs hence we assume the latest (5.5 +). + dnl o smaller ncurses tinfo library. + dnl o otherwise termlib/curses. dnl case "`uname -s 2>/dev/null`" in OSF1|SCO_SV) termlibs="ncursesw ncurses tinfo curses termlib termcap";; - *) termlibs="ncursesw ncurses tinfo termlib termcap curses";; + *) termlibs="ncursesw ncurses tinfo termlib curses termcap";; esac + fi - for libname in $termlibs; do - AC_CHECK_LIB(${libname}, tgetent,,) - if test "x$cf_save_LIBS" != "x$LIBS"; then - dnl It's possible that a library is found but it doesn't work, for example - dnl shared library that cannot be found; compile and run a test program to be sure - dnl - AC_RUN_IFELSE([AC_LANG_PROGRAM([[ -#ifdef HAVE_TERMCAP_H -# include -#endif -#ifdef HAVE_TERM_H -# include -#endif -#if STDC_HEADERS -# include -# include -#endif]],[[ - char *s; s=(char *)tgoto("%p1%d", 0, 1); - return 0;]])], - [res="OK"], [res="FAIL"], [res="FAIL"]) - LIBS="$cf_save_LIBS" - if test "$res" = "OK"; then - termlib_name=$libname - break + dnl + dnl test library selection + dnl + CFLAGS="$cf_saved_CFLAGS $CURSES_CFLAGS" + TERMLIB="" + cf_check_LIBS="$cf_save_LIBS" + if test -n "$CURSES_LDFLAGS"; then + CF_APPEND_TEXT(cf_check_LIBS,$CURSES_LDFLAGS) + fi + + for libname in $termlibs; do + + LIBS="$cf_check_LIBS" + + if test "$libname" = "ncursesw" || test "$libname" = "ncurses"; then + dnl + dnl libncurses[w] + dnl + AC_CHECK_LIB($libname, setupterm) + if test "x$cf_check_LIBS" = "x$LIBS"; then + if test -z "$CURSES_LDFLAGS" && test -n "$PKG_CONFIG"; then + AC_MSG_CHECKING([whether pkg-config information available]) + cf_pkg_config=`$PKG_CONFIG $libname --libs-only-L --libs-only-other 2>/dev/null` + if test $? = 0 && test -n "$cf_pkg_config"; then + AC_MSG_RESULT([$cf_pkg_config]) + LIBS="${cf_check_LIBS} ${cf_pkg_config}" + AS_UNSET(ac_cv_lib_${libname}_setupterm) + AC_CHECK_LIB($libname, setupterm, [], [LIBS="$cf_check_LIBS"]) + if test "x$cf_check_LIBS" != "x$LIBS"; then + TERMLIB="${cf_pkg_config} -l${libname}" + fi + else + AC_MSG_RESULT([none]) + fi fi - AC_MSG_RESULT($libname library is not usable) fi - done - if test -z "$termlib_name"; then - AC_MSG_RESULT(no terminal library found) + if test "x$cf_check_LIBS" != "x$LIBS"; then + CF_LIBTERM_CHECK_TERMINFO + if test "$cf_result" = "yes"; then + AC_RUN_IFELSE([AC_LANG_PROGRAM([[ +#include +extern const char *curses_version(void); +]],[[ + /*routine specific to ncurses*/ + const char *v = curses_version(); + if (v) printf("%s... ", v); + return (v == 0); +]])], + [cf_result=yes],[cf_result=no]) + fi + AC_MSG_RESULT($cf_result) + fi + LIBS="$cf_save_LIBS" + if test "$cf_result" = "yes"; then + cf_libterm_cv_terminfo=yes + cf_libterm_name=$libname + break + fi + + else if test "$libname" = "tinfo"; then + dnl + dnl libtinfo + dnl + AC_CHECK_LIB($libname, setupterm) + if test "x$cf_check_LIBS" != "x$LIBS"; then + CF_LIBTERM_CHECK_TERMINFO + AC_MSG_RESULT($cf_result) + fi + LIBS="$cf_save_LIBS" + if test "$cf_result" = "yes"; then + cf_libterm_cv_terminfo=yes + cf_libterm_name=$libname + break + fi + + else + dnl + dnl curses/termcap/termlib + dnl + AC_CHECK_LIB($libname, tgetent) + if test "x$cf_check_LIBS" = "x$LIBS" && test "$libname" = "curses"; then + AC_MSG_CHECKING(if we need both curses and termcap libraries) + LIBS="$cf_check_LIBS -lcurses -ltermcap" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +extern int tgetent(char *, const char *); +]],[[ + char buffer[1024 * 2]; + tgetent(buffer, "nonexistentterminal"); +]])], + [cf_result=yes; TERMLIB="$CURSES_LDFLAGS -lcurses -ltermcap"; AC_MSG_RESULT(yes)], + [cf_result=no; LIBS="$cf_check_LIBS"; AC_MSG_RESULT(no)]) + AC_MSG_RESULT([yes]) + fi + if test "x$cf_check_LIBS" != "x$LIBS"; then + CF_LIBTERM_CHECK_TERMCAP + AC_MSG_RESULT($cf_result) + fi + LIBS="$cf_save_LIBS" + if test "$cf_result" = "yes"; then + cf_libterm_cv_termcap=yes + cf_libterm_name=$libname + break + fi + fi; fi + + AC_MSG_RESULT($libname library is not usable) + done + + if test -n "$cf_libterm_name"; then + if test -z "$TERMLIB"; then + TERMLIB="$CURSES_LDFLAGS" + CF_APPEND_TEXT(TERMLIB,"-l${cf_libterm_name}") fi + LIBS="$LIBS $TERMLIB" + else + AC_MSG_RESULT(no terminal library found) fi - if test -n "$termlib_name"; then - if test "x$termlib_name" = "xtermlib"; then - AC_MSG_NOTICE([using internal terminal interface library]) - - elif test "x$termlib_name" = "xyes"; then + if test -n "$cf_libterm_name"; then + if test "x$cf_libterm_name" = "xtermlib" || test "x$cf_libterm_name" = "xyes"; then AC_MSG_NOTICE([using internal terminal interface library]) else - TERMLIB="-l$termlib_name" - LIBS="$LIBS $TERMLIB" + if test "$cf_libterm_cv_terminfo" != "yes"; then + CF_LIBTERM_CHECK_TERMINFO + AC_MSG_RESULT($cf_result) + cf_libterm_cv_terminfo=$cf_result + fi - AC_MSG_CHECKING([for setupterm and tigetxxx()]) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[ -#ifdef HAVE_CURSES_H -#include -#endif -#ifdef HAVE_TERM_H -#include -#endif]], - [[setupterm("terminalwontexist",0,0); tigetstr("str"); tigetnum("num"); tigetflag("flag");]])], - [termlib_cv_terminfo=yes; AC_MSG_RESULT(yes)], - AC_MSG_RESULT(no)) + if test "$cf_libterm_cv_termcap" != "yes"; then + CF_LIBTERM_CHECK_TERMCAP + AC_MSG_RESULT($cf_result) + cf_libterm_cv_termcap=$cf_result + fi - AC_MSG_CHECKING([for tgetent() and tgetxxx()]) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[ -#ifdef HAVE_CURSES_H -#include -#endif -#ifdef HAVE_TERM_H -#include -#endif]], - [[char buffer[10000]; char *area = (char *)0; -int res = tgetent(buffer, "terminalwontexist"); tgetstr("str", &area); tgetnum("num"); tgetflag("flag");]])], - [termlib_cv_termcap=yes; AC_MSG_RESULT(yes)], - AC_MSG_RESULT(no)) - - if test "$termlib_cv_terminfo" != "yes"; then - if test "$termlib_cv_termcap" != "yes"; then + if test "$cf_libterm_cv_terminfo" != "yes"; then + if test "$cf_libterm_cv_termcap" != "yes"; then AC_MSG_ERROR([ You need to install a suitable terminal library; for example ncurses. alternatively specify the name of the library with --with-termlib=.]) fi fi fi + AC_MSG_RESULT([using terminal library... $TERMLIB]) fi - TERMLIB="-l$termlib_name" + dnl dnl library features dnl - if test "$termlib_cv_terminfo" = "no"; then - AC_CACHE_CHECK([whether we talk terminfo], termlib_cv_terminfo, [ + if test "$cf_libterm_cv_terminfo" = "no"; then + AC_CACHE_CHECK([whether we talk terminfo], cf_libterm_cv_terminfo, [ AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #ifdef HAVE_TERMCAP_H # include @@ -169,84 +361,405 @@ int res = tgetent(buffer, "terminalwontexist"); tgetstr("str", &area); tgetnum(" # include # include #endif]],[[ - char *s; s=(char *)tgoto("%p1%d", 0, 1); - exit(!strcmp(s==0 ? "" : s, "1")); - return 0; + char *s = (char *)tgoto("%p1%d", 0, 1); + return (0 == strcmp(s == 0 ? "" : s, "1")); ]])], - [termlib_cv_terminfo=no], - [termlib_cv_terminfo=yes], - [AC_MSG_ERROR(cross-compiling: please set 'termlib_cv_terminfo')])]) + [cf_libterm_cv_terminfo=no], + [cf_libterm_cv_terminfo=yes], + [AC_MSG_ERROR(cross-compiling: please set 'cf_libterm_cv_terminfo')])]) fi + dnl dnl library specific resources dnl - dnl ncursesw - dnl ncurses / ncurses_g - dnl pdcurses(*) - dnl tinfo(*) - dnl curses - dnl termcap - dnl termlib + dnl ncursesw + dnl ncurses / ncurses_g (debug ncurses, diagnostic to trace) + dnl tinfo(*) + dnl curses + dnl termcap(*) + dnl termlib(*) dnl - dnl (*) should in theory work, yet fully tested. + dnl (*) should in theory work, yet not generally tested. dnl - if test "x$termlib_cv_terminfo" = "xyes"; then + if test "x$cf_libterm_cv_terminfo" = "xyes"; then AC_DEFINE([HAVE_TERMINFO], 1, [terminfo interface.]) fi - if test "x$termlib_cv_termcap" = "xyes"; then + if test "x$cf_libterm_cv_termcap" = "xyes"; then AC_DEFINE([HAVE_TERMCAP], 1, [termcap interface.]) fi - if test "x$termlib_name" = "xncursesw"; then + if test "x$cf_libterm_name" = "xncursesw"; then AC_DEFINE([HAVE_LIBNCURSESW], 1, [enable libncursesw support.]) - AC_CHECK_HEADERS(nc_alloc.h ncursesw/nc_alloc.h) - AC_CHECK_HEADERS(nomacros.h ncursesw/nomacros.h) - AC_CHECK_HEADERS(ncursesw.h ncursesw/ncursesw.h) - AC_CHECK_HEADERS(curses.h ncursesw/curses.h) - AC_CHECK_HEADERS(termcap.h ncursesw/termcap.h) - AC_CHECK_HEADERS(term.h ncursesw/term.h) AC_CHECK_LIB(ncursesw, main) AC_CHECK_LIB(ncursesw_g, main) + cf_libterm_cv_headers=ncursesw - else if test "x$termlib_name" = "xncurses"; then + elif test "x$cf_libterm_name" = "xncurses"; then AC_DEFINE([HAVE_LIBNCURSES], 1, [enable libncurses support.]) - AC_CHECK_HEADERS(nc_alloc.h ncurses/nc_alloc.h) - AC_CHECK_HEADERS(nomacros.h ncurses/nomacros.h) - AC_CHECK_HEADERS(ncurses.h ncurses/ncurses.h) - AC_CHECK_HEADERS(curses.h ncurses/curses.h) - AC_CHECK_HEADERS(termcap.h ncurses/termcap.h) - AC_CHECK_HEADERS(term.h ncurses/term.h) AC_CHECK_LIB(ncurses, main) AC_CHECK_LIB(ncurses_g, main) + if test -z "$with_termlib"; then + cf_libterm_cv_headers=ncursesw + else + cf_libterm_cv_headers=ncurses + fi + fi + + dnl additional search directories + dnl main plus base, without trailing ncurses/w package name + dnl + dnl Note: + dnl Allow alternative installation under "/usr/local/include", unless pkg-config advices otherwise. + dnl + cf_libterm_includes="/usr/local/include" + if test -z "$CURSES_CFLAGS" && test -n "$PKG_CONFIG"; then + AC_MSG_CHECKING([whether pkg-config information available]) + cf_pkg_config=`$PKG_CONFIG $cf_libterm_name --cflags-only-I 2>/dev/null` + if test $? = 0 && test -n "$cf_pkg_config"; then + AC_MSG_RESULT([$cf_pkg_config]) + cf_libterm_includes="" + for cf_config in $cf_pkg_config; do + + cf_include=${cf_config#-I} + if test "$cf_include" = "$cf_config"; then + continue + fi + + cf_result=yes + for cf_config in $cf_libterm_includes; do + if test $cf_config = $cf_include; then + cf_result=no + break + fi + done + if test $cf_result = yes; then + CF_APPEND_TEXT(cf_libterm_includes, $cf_include) + fi + done + else + AC_MSG_RESULT([none]) + fi + fi - else if test "x$termlib_name" = "xpdcurses"; then - AC_DEFINE([HAVE_LIBPDCURSES], 1, [enable libpdcurses support.]) - AC_CHECK_HEADERS(pdcurses.h pdterm.h curses.h term.h) - AC_CHECK_LIB(pdcurses, main) + dnl package headers + if test -n "$cf_libterm_cv_headers"; then - else if test "x$termlib_name" = "xtinfo"; then + dnl Newer versions of ncurses only publish ncurses.h supporting both char and wchar_t interfaces, + dnl yet dependent on packaging/host the following may exist. + dnl + dnl ncursesw/curses.h + dnl ncursesw.h + dnl ncurses/curses.h + dnl ncurses.h + dnl + + cf_have_ncurses_h=no + if test "x$cf_libterm_cv_headers" = "xncursesw"; then + dnl + dnl ncursesw/curses.h + dnl + AC_CHECK_HEADERS(ncursesw/curses.h, [cf_have_ncurses_h=yesa], []) + + if test "x$cf_have_ncurses_h" = "xno" && test -z "$CURSES_CFLAGS" ; then + AC_MSG_NOTICE([checking secondary ncurses directories]) + for cf_include in $cf_libterm_includes; do + if test "$cf_include" != "${cf_include%/ncurses*}"; then + continue + fi + CFLAGS="$cf_saved_CFLAGS -I$cf_include" + AS_UNSET(ac_cv_header_ncursesw_curses_h) + AC_CHECK_HEADER(ncursesw/curses.h, [cf_have_ncurses_h=yesa], []) + if test "x$cf_have_ncurses_h" = "xyesa"; then + CURSES_CFLAGS="-I$cf_include" + break + fi + CFLAGS="$cf_saved_CFLAGS" + done + fi + + if test "x$cf_have_ncurses_h" = "xyesa"; then + AC_CHECK_HEADERS(ncursesw/nc_alloc.h, [have_nc_alloc_h]) + AC_CHECK_HEADERS(ncursesw/nomacros.h, [have_nomacros_h]) + AC_CHECK_HEADERS(ncursesw/termcap.h) + AC_CHECK_HEADERS(ncursesw/term.h) + fi + + dnl + dnl ncursesw.h + dnl + if test "x$cf_have_ncurses_h" = "xno"; then + AC_CHECK_HEADERS(ncursesw.h, [cf_have_ncurses_h=yesb], []) + if test "x$cf_have_ncurses_h" = "xno" && test -z "$CURSES_CFLAGS" ; then + AC_MSG_NOTICE([checking secondary ncurses directories]) + for cf_include in $cf_libterm_includes; do + CFLAGS="$cf_saved_CFLAGS -I$cf_include" + AS_UNSET(ac_cv_header_ncursesw_h) + AC_CHECK_HEADERS(ncursesw.h, [cf_have_ncurses_h=yesb], []) + if test "x$cf_have_ncurses_h" = "xyesb"; then + CURSES_CFLAGS="-I$cf_include" + break + fi + CFLAGS="$cf_saved_CFLAGS" + done + fi + fi + + if test "x$cf_have_ncurses_h" = "xno"; then + AC_MSG_RESULT([checking for common ncurses header]) + cf_libterm_cv_headers=ncurses + fi + fi + + if test "x$cf_libterm_cv_headers" = "xncurses"; then + + dnl + dnl ncurses/curses.h + dnl + AC_CHECK_HEADERS(ncurses/curses.h, [cf_have_ncurses_h=yesc], []) + + if test "x$cf_have_ncurses_h" = "xno" && test -z "$CURSES_CFLAGS" ; then + AC_MSG_RESULT([checking secondary ncurses directories]) + for cf_include in $cf_libterm_includes; do + if test "$cf_include" != "${cf_include%/ncurses*}"; then + continue + fi + CFLAGS="$cf_saved_CFLAGS -I$cf_include" + AS_UNSET(ac_cv_header_ncurses_curses_h) + AC_CHECK_HEADERS(ncurses/curses.h, [cf_have_ncurses_h=yesc], []) + if test "x$cf_have_ncurses_h" = "xyesc"; then + CURSES_CFLAGS="-I$cf_include" + break + fi + CFLAGS="$cf_saved_CFLAGS" + done + fi + + if test "x$cf_have_ncurses_h" = "xyesc" ; then + AC_CHECK_HEADERS(ncurses/nc_alloc.h, [have_nc_alloc_h]) + AC_CHECK_HEADERS(ncurses/nomacros.h, [have_nomacros_h]) + AC_CHECK_HEADERS(ncurses/termcap.h) + AC_CHECK_HEADERS(ncurses/term.h) + fi + + dnl + dnl ncurses.h + dnl + if test "x$cf_have_ncurses_h" = "xno" ; then + AC_CHECK_HEADERS(ncurses.h, [cf_have_ncurses_h=yesd], []) + + if test "x$cf_have_ncurses_h" = "xno" && test -z "$CURSES_CFLAGS" ; then + AC_MSG_NOTICE([checking secondary ncurse directories]) + for cf_include in $cf_libterm_includes; do + CFLAGS="$cf_saved_CFLAGS -I$cf_include" + AS_UNSET(ac_cv_header_ncurses_h) + AC_CHECK_HEADERS(ncurses.h, [cf_have_ncurses_h=yesd], []) + if test "x$cf_have_ncurses_h" = "xyesd"; then + CURSES_CFLAGS="-I$cf_include" + break + fi + CFLAGS="$cf_saved_CFLAGS" + done + fi + fi + fi + + if test "x$cf_have_ncurses_h" = "xno" ; then + if test "x$cf_libterm_name" = "xncursesw" ; then + AC_MSG_WARN([could not find ncursesw/curses.h, ncursesw.h nor ncurses/curses.h or ncurses.h]) + else + AC_MSG_WARN([could not find ncurses/curses.h or ncurses.h]) + fi + else + if test "x$have_nc_alloc_h" = "x" ; then + AC_CHECK_HEADERS(nc_alloc.h) + fi + if test "x$have_nomacros_h" = "x" ; then + AC_CHECK_HEADERS(nomacros.h) + fi + fi + + else if test "x$cf_libterm_name" = "xtinfo"; then AC_DEFINE([HAVE_LIBTINFO], 1, [enable libtinfo support.]) AC_CHECK_HEADERS(ncurses/termcap.h ncurses/term.h) AC_CHECK_LIB(tinfo, main) - else if test "x$termlib_name" = "xcurses"; then + else if test "x$cf_libterm_name" = "xcurses"; then AC_DEFINE([HAVE_LIBCURSES], 1, [enable libcurses support.]) AC_CHECK_HEADERS(curses.h) AC_CHECK_LIB(curses, main) - else if test "x$termlib_name" = "xtermcap"; then + else if test "x$cf_libterm_name" = "xtermcap"; then AC_DEFINE([HAVE_LIBTERMCAP], 1, [enable libtermcap support.]) AC_CHECK_HEADERS(term.h termcap.h) - else if test "x$termlib_name" = "xtermlib"; then + else if test "x$cf_libterm_name" = "xtermlib"; then AC_DEFINE([HAVE_LIBTERMLIB], 1, [enable libtermlib support.]) AC_CHECK_HEADERS(edtermcap.h) - fi; fi; fi; fi; fi; fi; fi; + fi; fi; fi; fi; fi + + dnl + dnl features + dnl + AC_MSG_CHECKING([for curses features]) + if test "x$cf_libterm_cv_features" = "xno" ; then + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#if defined(HAVE_NCURSESW_CURSES_H) +# include +# include +# include +#elif defined(HAVE_NCURSES_CURSES_H) +# include +# include +# include +#else +# if defined(HAVE_NCURSESW_H) +# include +# elif defined(HAVE_NCURSES_H) +# include +# elif defined(HAVE_CURSES_H) +# include +# endif +# if defined(HAVE_TERMCAP_H) +# include +# endif +# if defined(HAVE_TERM_H) +# include +# endif +#endif +]], [[ + chtype a = A_BOLD; + int b = KEY_LEFT; + chtype c = COLOR_PAIR(1) & A_COLOR; + attr_t d = WA_NORMAL; + cchar_t e; + wint_t f; + int g = getattrs(stdscr); + int h = getcurx(stdscr) + getmaxx(stdscr); + initscr(); + init_pair(1, COLOR_WHITE, COLOR_RED); + wattr_set(stdscr, d, 0, NULL); + wget_wch(stdscr, &f);]])], + [cf_libterm_cv_features=enhanced],[]) + fi + + if test "x$cf_libterm_cv_features" = "xno" ; then + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#if defined(HAVE_NCURSESW_CURSES_H) +# include +# include +# include +#elif defined(HAVE_NCURSES_CURSES_H) +# include +# include +# include +#else +# if defined(HAVE_NCURSESW_H) +# include +# elif defined(HAVE_NCURSES_H) +# include +# elif defined(HAVE_CURSES_H) +# include +# endif +# if defined(HAVE_TERMCAP_H) +# include +# endif +# if defined(HAVE_TERM_H) +# include +# endif +#endif +]], [[ + chtype a = A_BOLD; + int b = KEY_LEFT; + chtype c = COLOR_PAIR(1) & A_COLOR; + int g = getattrs(stdscr); + int h = getcurx(stdscr) + getmaxx(stdscr); + initscr(); + init_pair(1, COLOR_WHITE, COLOR_RED);]])], + [cf_libterm_cv_features=color],[]) + fi + + if test "x$cf_libterm_cv_features" = "xno" ; then + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#if defined(HAVE_NCURSESW_CURSES_H) +# include +# include +# include +#elif defined(HAVE_NCURSES_CURSES_H) +# include +# include +# include +#else +# if defined(HAVE_NCURSESW_H) +# include +# elif defined(HAVE_NCURSES_H) +# include +# elif defined(HAVE_CURSES_H) +# include +# endif +# if defined(HAVE_TERMCAP_H) +# include +# endif +# if defined(HAVE_TERM_H) +# include +# endif +#endif +]], [[ + chtype a = A_BOLD; + int b = KEY_LEFT; + initscr(); +]])], + [cf_libterm_cv_features=basic],[]) + fi + + if test "x$cf_libterm_cv_features" = "xenhanced" ; then + AC_DEFINE([HAVE_CURSES_ENHANCED], [1], + [Define to 1 if library supports enhanced functions]) + AC_DEFINE([HAVE_CURSES_COLOR], [1], + [Define to 1 if library supports color functions]) + elif test "x$cf_libterm_cv_features" = "xcolor" ; then + AC_DEFINE([HAVE_CURSES_COLOR], [1], + [Define to 1 if library supports color functions]) + fi + AC_MSG_RESULT($cf_libterm_cv_features) - if test "$termlib_cv_termcap" = "yes"; then - if test -n "$termlib_name"; then - AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], termlib_cv_tgent, [ + dnl + dnl compatibility + dnl + dnl -- const + AC_MSG_CHECKING(whether curses interface utilities const strings) + AC_EGREP_CPP([[define\\\s+NCURSES_CONST\\\s+const]],[[ +#if defined(HAVE_NCURSESW_CURSES_H) +# include +# include +# include +#elif defined(HAVE_NCURSES_CURSES_H) +# include +# include +# include +#else +# if defined(HAVE_NCURSESW_H) +# include +# elif defined(HAVE_NCURSES_H) +# include +# elif defined(HAVE_CURSES_H) +# include +# endif +# if defined(HAVE_TERMCAP_H) +# include +# endif +# if defined(HAVE_TERM_H) +# include +# endif +#endif +]], + [AC_MSG_RESULT(yes); AC_DEFINE([HAVE_CURSES_CONST], [1], [const strings])], + [AC_MSG_RESULT(no)]) + + dnl -- zero + if test "$cf_libterm_cv_termcap" = "yes"; then + if test -n "$cf_libterm_name"; then + AC_CACHE_CHECK([what tgetent() returns for an unknown terminal], cf_libterm_cv_tgent, [ AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #ifdef HAVE_TERMCAP_H #include @@ -254,28 +767,30 @@ int res = tgetent(buffer, "terminalwontexist"); tgetstr("str", &area); tgetnum(" #if STDC_HEADERS #include #include -#endif]],[[ - char s[10000]; - int res = tgetent(s, "terminalwontexist"); - exit(res != 0); - return 0; +#endif +]],[[ + char buffer[1024 * 2]; + int res = tgetent(buffer, "nonexistentterminal"); + exit(res != 0); ]])], - [termlib_cv_tgent=zero], - [termlib_cv_tgent=non-zero], + [cf_libterm_cv_tgent=zero], + [cf_libterm_cv_tgent=non-zero], [AC_MSG_ERROR(failed to compile test program.)]) - ]) + ]) - if test "x$termlib_cv_tgent" = "xzero"; then + if test "x$cf_libterm_cv_tgent" = "xzero"; then AC_DEFINE([TGETENT_ZERO_ERR], 0, [tgetent() return code.]) fi fi fi + dnl -- ospeed AC_MSG_CHECKING(whether termcap.h contains ospeed) AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #ifdef HAVE_TERMCAP_H #include -#endif]], [[ospeed = 20000;]])], +#endif +]], [[ospeed = 20000;]])], AC_MSG_RESULT(yes); AC_DEFINE([HAVE_OSPEED], 1, [extern ospeed available.]), [AC_MSG_RESULT(no) AC_MSG_CHECKING(whether ospeed can be extern) @@ -283,16 +798,19 @@ int res = tgetent(buffer, "terminalwontexist"); tgetstr("str", &area); tgetnum(" #ifdef HAVE_TERMCAP_H #include #endif -extern short ospeed;]], [[ospeed = 20000;]])], +extern short ospeed; +]], [[ospeed = 20000;]])], AC_MSG_RESULT(yes); AC_DEFINE([OSPEED_EXTERN], 1, [extern ospeed needed.]), AC_MSG_RESULT(no))] ) + dnl -- UP, BC and RC AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #ifdef HAVE_TERMCAP_H #include -#endif]], [[if (UP == 0 && BC == 0) PC = 1]])], +#endif +]], [[if (UP == 0 && BC == 0) PC = 1]])], AC_MSG_RESULT(yes); AC_DEFINE([HAVE_UP_BC_PC], 1, [extern UP BC and PC available.]), [AC_MSG_RESULT(no) AC_MSG_CHECKING([whether UP, BC and PC can be extern]) @@ -300,29 +818,70 @@ extern short ospeed;]], [[ospeed = 20000;]])], #ifdef HAVE_TERMCAP_H #include #endif -extern char *UP, *BC, PC;]], [[if (UP == 0 && BC == 0) PC = 1;]])], +extern char *UP, *BC, PC; +]], [[if (UP == 0 && BC == 0) PC = 1;]])], AC_MSG_RESULT(yes); AC_DEFINE([UP_BC_PC_EXTERN], 1, [extern UP BC and PC needed.]), AC_MSG_RESULT(no))] ) + dnl -- tputs AC_MSG_CHECKING(whether tputs() uses outfuntype) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#ifdef HAVE_TERMCAP_H -#include -#endif]], [[extern int xx(); tputs("test", 1, (outfuntype)xx)]])], + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ +#if defined(HAVE_NCURSESW_CURSES_H) +# include +# include +# include +#elif defined(HAVE_NCURSES_CURSES_H) +# include +# include +# include +#else +# if defined(HAVE_NCURSESW_H) +# include +# elif defined(HAVE_NCURSES_H) +# include +# elif defined(HAVE_CURSES_H) +# include +# endif +# if defined(HAVE_TERMCAP_H) +# include +# endif +# if defined(HAVE_TERM_H) +# include +# endif +#endif +], [[extern int xx(); tputs("test", 1, (outfuntype)xx)]])], [AC_MSG_RESULT(yes); AC_DEFINE([HAVE_OUTFUNTYPE], 1, [typedef outfuntype available.])], [AC_MSG_RESULT(no); AC_MSG_CHECKING(determining tputs() function final argument type) AC_EGREP_CPP([tputs.*[(][ \\\t]*char[ \\\t]*[)]],[ -#ifdef HAVE_TERM_H -#include +#if defined(HAVE_NCURSESW_CURSES_H) +# include +# include +# include +#elif defined(HAVE_NCURSES_CURSES_H) +# include +# include +# include +#else +# if defined(HAVE_NCURSESW_H) +# include +# elif defined(HAVE_NCURSES_H) +# include +# elif defined(HAVE_CURSES_H) +# include +# endif +# if defined(HAVE_TERMCAP_H) +# include +# endif +# if defined(HAVE_TERM_H) +# include +# endif #endif -#ifdef HAVE_CURSES_H -#include -#endif - ], [AC_MSG_RESULT(char); AC_DEFINE([TPUTS_TAKES_CHAR], 1, [tputs character interface.])], - [AC_MSG_RESULT(not char, int assumed); - ]) +], [AC_MSG_RESULT(char); AC_DEFINE([TPUTS_TAKES_CHAR], 1, [tputs character interface.])], + [AC_MSG_RESULT(not char, int assumed); + ]) ]) + CFLAGS=$cf_save_CFLAGS LIBS=$cf_save_LIBS ])dnl diff --git a/auto/m4/libthread.m4 b/auto/m4/libthread.m4 index e96e34cd..ade9276a 100644 --- a/auto/m4/libthread.m4 +++ b/auto/m4/libthread.m4 @@ -1,4 +1,4 @@ -dnl $Id: libthread.m4,v 1.4 2024/05/02 14:34:32 cvsuser Exp $ +dnl $Id: libthread.m4,v 1.5 2024/07/13 18:28:49 cvsuser Exp $ dnl Process this file with autoconf to produce a configure script. dnl -*- mode: autoconf; tab-width: 8; -*- dnl @@ -8,24 +8,32 @@ dnl AC_DEFUN([CF_WITH_THREADS],[ AC_SUBST([LIBTHREAD]) + dnl threads + AC_CHECK_HEADERS(threads.h) + AC_CHECK_LIB(stdthreads, thrd_create, [ + AC_DEFINE(HAVE_STDTHREADS, 1, [Define if we have libstdthreads]) + THREADS_LIBS="-lstdthreads" + ],[THREADS_LIBS=""]) + + dnl pthread ACX_NANOSLEEP AX_PTHREAD([ AC_CHECK_HEADERS(pthread.h) - - AC_MSG_RESULT([- Threading:]) - AC_MSG_RESULT([- Compiler: $PTHREAD_CC]) - AC_MSG_RESULT([- CFLAGS: $PTHREAD_CFLAGS]) - AC_MSG_RESULT([- Libraries: $PTHREAD_LIBS $NANOSLEEP_LIBS]) - AC_MSG_RESULT([-]) - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS" LDFLAGS="$LDFLAGS $PTHREAD_CFLAGS" - LIBTHREAD="$PTHREAD_LIBS $NANOSLEEP_LIBS" + LIBTHREAD="$THREADS_LIBS $PTHREAD_LIBS $NANOSLEEP_LIBS" ],[ AC_MSG_WARN([Compiling without POSIX threads support]) AC_CHECK_HEADERS(thread.h) - LIBTHREAD="$NANOSLEEP_LIB" + LIBTHREAD="$THREADS_LIBS $NANOSLEEP_LIB" ]) + + AC_MSG_RESULT([- Threading:]) + AC_MSG_RESULT([- Compiler: $PTHREAD_CC]) + AC_MSG_RESULT([- CFLAGS: $PTHREAD_CFLAGS]) + AC_MSG_RESULT([- Libraries: $LIBTHREAD]) + AC_MSG_RESULT([-]) + ]) dnl diff --git a/auto/m4/misc.m4 b/auto/m4/misc.m4 index 49987cbf..fb94bc44 100644 --- a/auto/m4/misc.m4 +++ b/auto/m4/misc.m4 @@ -1,80 +1,131 @@ -dnl $Id: misc.m4,v 1.13 2024/06/10 06:07:15 cvsuser Exp $ +dnl $Id: misc.m4,v 1.15 2024/06/15 06:33:17 cvsuser Exp $ dnl Process this file with autoconf to produce a configure script. dnl -*- mode: autoconf; tab-width: 8; -*- dnl + + dnl --------------------------------------------------------------------------- -dnl Check if the file-system supports mixed-case filenames. If we are able to -dnl create a lowercase name and see it as uppercase, it doesnt support that. +dnl CF_CHECK_LIBBFD dnl -AC_DEFUN([CF_MIXEDCASE_FILENAMES],[ - AC_CACHE_CHECK(if filesystem supports mixed case filenames,cf_cv_mixedcase,[ - rm -f conftest CONFTEST - echo test >conftest - if test -f CONFTEST ; then - cf_cv_mixedcase=no - else - cf_cv_mixedcase=yes +AC_DEFUN([CF_CHECK_LIBBFD],[ + + AC_CHECK_LIB(bfd, bfd_init, [ + AC_DEFINE(HAVE_LIBBFD, 1, + [Define to enable libbfd support]) + AC_CHECK_HEADERS(bfd.h) + CF_ADD_EXTRALIBS("-lbfd") + + dnl --- bfd_section_flags + AC_MSG_CHECKING(for bfd_section_flags) + AC_LINK_IFELSE([AC_LANG_PROGRAM([ +#include +asection *s; +],[return bfd_section_flags(s) == 0;])], + [with_bfd_section_flags=yes], + [with_bfd_section_flags=no]) + AC_MSG_RESULT([$with_bfd_section_flags]) + if test "$with_bfd_section_flags" = yes; then + AC_DEFINE(HAVE_BFD_SECTION_FLAGS, 1, + [Define for newer libbdf API support]) fi - rm -f conftest CONFTEST - ]) - test "$cf_cv_mixedcase" = yes && \ - AC_DEFINE([MIXEDCASE_FILENAMES], 1, [supports mixed case filenames.]) + + dnl --- bfd_section_size + AC_MSG_CHECKING(for bfd_section_size) + AC_LINK_IFELSE([AC_LANG_PROGRAM([ +#include +asection *s; +],[return bfd_section_size(s) == 0;])], + [with_bfd_section_size=yes], + [with_bfd_section_size=no]) + AC_MSG_RESULT([$with_bfd_section_size]) + if test "$with_bfd_section_size" = yes; then + AC_DEFINE(HAVE_BFD_SECTION_SIZE, 1, + [Define for newer libbdf API support]) + fi + + dnl --- bfd_section_vma + AC_MSG_CHECKING(for bfd_section_vma) + AC_LINK_IFELSE([AC_LANG_PROGRAM([ +#include +asection *s; +],[return bfd_section_vma(s) == 0;])], + [with_bfd_section_vma=yes], + [with_bfd_section_vma=no]) + AC_MSG_RESULT([$with_bfd_section_vma]) + if test "$with_bfd_section_vma" = yes; then + AC_DEFINE(HAVE_BFD_SECTION_VMA, 1, + [Define for newer libbdf API support]) + fi + + ], [], [$EXTRALIBS]) + + AC_SUBST([HAVE_BFD_SECTION_FLAGS]) + AC_SUBST([HAVE_BFD_SECTION_SIZE]) + AC_SUBST([HAVE_BFD_SECTION_VMA]) + ])dnl dnl --------------------------------------------------------------------------- -dnl Provide a value for the $PATH and similar separator +dnl CF_ADD_EXTRALIBS +dnl +dnl Add a lib to current LIBS if it is not already there. dnl -AC_DEFUN([CF_PATHSEP],[ - case $cf_cv_system_name in - os2*) PATHSEP=';' ;; - *) PATHSEP=':' ;; - esac -ifelse($1,,,[$1=$PATHSEP]) - AC_SUBST(PATHSEP) +AC_DEFUN([CF_ADD_EXTRALIBS],[ + EXTRALIBS_addsave=[$EXTRALIBS] + if test "x$EXTRALIBS_addsave" != "x" ; then + flag=`echo "$1" | sed 's/-/\\\-/g'` + if test -z "`echo \"${EXTRALIBS}\" | grep \"${flag}\"`" ; then + EXTRALIBS="$EXTRALIBS_addsave $1" + fi + else + EXTRALIBS="$1" + fi ])dnl - dnl --------------------------------------------------------------------------- -dnl Add checks for large file support. +dnl Check if we have either a function or macro for additional ctypes +dnl +dnl isascii (extension) +dnl isblank (c99) dnl -AC_DEFUN([CF_LARGEFILE],[ - ifdef([AC_FUNC_FSEEKO],[ - AC_SYS_LARGEFILE - if test "$enable_largefile" != no ; then - AC_FUNC_FSEEKO +AC_DEFUN([CF_FUNC_ISASCII],[ + AC_MSG_CHECKING(for isascii) + AC_CACHE_VAL(cf_cv_have_isascii,[ + AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include ]],[[int x = isascii(' ')]])], + [cf_cv_have_isascii=yes], + [cf_cv_have_isascii=no]) + ])dnl + AC_MSG_RESULT($cf_cv_have_isascii) + test "$cf_cv_have_isascii" = yes && \ + AC_DEFINE([HAVE_ISASCII], 1, [isascii() available.]) +])dnl - # Normally we would collect these definitions in the config.h, - # but (like _XOPEN_SOURCE), some environments rely on having these - # defined before any of the system headers are included. Another - # case comes up with C++, e.g., on AIX the compiler compiles the - # header files by themselves before looking at the body files it is - # told to compile. For ncurses, those header files do not include - # the config.h - test "$ac_cv_sys_large_files" != no && CPPFLAGS="$CPPFLAGS -D_LARGE_FILES " - test "$ac_cv_sys_largefile_source" != no && CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE " - test "$ac_cv_sys_file_offset_bits" != no && CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits " +AC_DEFUN([CF_FUNC_ISBLANK],[ + AC_MSG_CHECKING(for isblank) + AC_CACHE_VAL(cf_cv_have_isblank,[ + AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include ]],[[int x = isblank(' ')]])], + [cf_cv_have_isblank=yes], + [cf_cv_have_isblank=no]) + ])dnl + AC_MSG_RESULT($cf_cv_have_isblank) + test "$cf_cv_have_isblank" = yes && \ + AC_DEFINE([HAVE_ISBLANK], 1, [isblank() available.]) +])dnl - AC_CACHE_CHECK(whether to use struct dirent64, cf_cv_struct_dirent64,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#include -#include ]],[[ - /* if transitional largefile support is setup, this is true */ - extern struct dirent64 * readdir(DIR *); - struct dirent64 *x = readdir((DIR *)0); - struct dirent *y = readdir((DIR *)0); - int z = x - y; -]])], - [cf_cv_struct_dirent64=yes], - [cf_cv_struct_dirent64=no]) - ]) - test "$cf_cv_struct_dirent64" = yes && \ - AC_DEFINE([HAVE_STRUCT_DIRENT64], 1, [struct dirent64.]) - fi - ]) +AC_DEFUN([CF_FUNC_ISCSYM],[ + AC_MSG_CHECKING(for iscsym) + AC_CACHE_VAL(cf_cv_have_iscsym,[ + AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include ]],[[int x = iscsym(' ')]])], + [cf_cv_have_iscsym=yes], + [cf_cv_have_iscsym=no]) + ])dnl + AC_MSG_RESULT($cf_cv_have_iscsym) + test "$cf_cv_have_iscsym" = yes && \ + AC_DEFINE([HAVE_ISCSYM], 1, [iscsym() available.]) ])dnl @@ -141,515 +192,4 @@ AC_DEFUN([CF_LANGINFO_CODESET],[ fi ])dnl - -dnl --------------------------------------------------------------------------- -dnl Check if we have either a function or macro for additional ctypes -dnl -dnl isascii (extension) -dnl isblank (c99) -dnl - -AC_DEFUN([CF_FUNC_ISASCII],[ - AC_MSG_CHECKING(for isascii) - AC_CACHE_VAL(cf_cv_have_isascii,[ - AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include ]],[[int x = isascii(' ')]])], - [cf_cv_have_isascii=yes], - [cf_cv_have_isascii=no]) - ])dnl - AC_MSG_RESULT($cf_cv_have_isascii) - test "$cf_cv_have_isascii" = yes && \ - AC_DEFINE([HAVE_ISASCII], 1, [isascii() available.]) -])dnl - -AC_DEFUN([CF_FUNC_ISBLANK],[ - AC_MSG_CHECKING(for isblank) - AC_CACHE_VAL(cf_cv_have_isblank,[ - AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include ]],[[int x = isblank(' ')]])], - [cf_cv_have_isblank=yes], - [cf_cv_have_isblank=no]) - ])dnl - AC_MSG_RESULT($cf_cv_have_isblank) - test "$cf_cv_have_isblank" = yes && \ - AC_DEFINE([HAVE_ISBLANK], 1, [isblank() available.]) -])dnl - -AC_DEFUN([CF_FUNC_ISCSYM],[ - AC_MSG_CHECKING(for iscsym) - AC_CACHE_VAL(cf_cv_have_iscsym,[ - AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include ]],[[int x = iscsym(' ')]])], - [cf_cv_have_iscsym=yes], - [cf_cv_have_iscsym=no]) - ])dnl - AC_MSG_RESULT($cf_cv_have_iscsym) - test "$cf_cv_have_iscsym" = yes && \ - AC_DEFINE([HAVE_ISCSYM], 1, [iscsym() available.]) -])dnl - -dnl --------------------------------------------------------------------------- -dnl Check if the C compiler supports "inline". -dnl -dnl CF_C_INLINE(,) -dnl - -AC_DEFUN([CF_C_INLINE],[ - cf_c_inline_define=$1 - AC_C_INLINE - if test "$ac_cv_c_inline" != no ; then - $1=inline - if test "$INTEL_COMPILER" = yes - then - : - elif test "$GCC" = yes - then - AC_CACHE_CHECK(if gcc supports options to tune inlining,cf_cv_gcc_inline,[ - cf_save_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS --param max-inline-insns-single=$2" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -inline int foo(void) { return 1; }]],[[${cf_cv_main_return:-return} foo()]])], - [cf_cv_gcc_inline=yes], - [cf_cv_gcc_inline=no]) - CFLAGS=$cf_save_CFLAGS - ]) - if test "$cf_cv_gcc_inline" = yes ; then - CF_ADD_CFLAGS([--param max-inline-insns-single=$2]) - fi - fi - fi - - if test "$cf_c_inline_define" = yes ; then - if test "$ac_cv_c_inline" != no ; then - AC_DEFINE(HAVE_INLINE, 1, [Have inline keyword]) - AC_SUBST(HAVE_INLINE) - else - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -__inline int foo(void) { return 1; }]],[[${cf_cv_main_return:-return} foo()]])], - [cf_cv_c_inline=yes], - [cf_cv_c_inline=no]) - if test "$ac_cv_c_inline" != no ; then - AC_DEFINE(HAVE___INLINE, 1, [Have __inline keyword]) - AC_SUBST(HAVE___INLINE) - fi - fi - fi -])dnl - - -dnl --------------------------------------------------------------------------- -dnl Check for memmove, or a bcopy that can handle overlapping copy. -dnl -dnl If neither is found define NEED_MEMMOVE -dnl - -AC_DEFUN([CF_FUNC_MEMMOVE],[ - AC_CHECK_FUNC(memmove,,[ - AC_CHECK_FUNC(bcopy,[ - AC_CACHE_CHECK(if bcopy does overlapping moves,cf_cv_good_bcopy,[ - AC_RUN_IFELSE([AC_LANG_PROGRAM([],[[ - static char data[] = "abcdefghijklmnopqrstuwwxyz"; - char temp[40]; - bcopy(data, temp, sizeof(data)); - bcopy(temp+10, temp, 15); - bcopy(temp+5, temp+15, 10); - ${cf_cv_main_return:-return} (strcmp(temp, "klmnopqrstuwwxypqrstuwwxyz")); -]])], - [cf_cv_good_bcopy=yes], - [cf_cv_good_bcopy=no], - [cf_cv_good_bcopy=unknown])]) - ],[cf_cv_good_bcopy=no]) - if test "$cf_cv_good_bcopy" != yes ; then - AC_DEFINE([NEED_MEMMOVE], 1, [need external memmove().]) - fi - ]) -])dnl - -dnl --------------------------------------------------------------------------- -dnl Checl for existence of sigaction_t -dnl -AC_DEFUN([CF_TYPE_SIGACTION], -[ - AC_MSG_CHECKING([for type sigaction_t]) - AC_CACHE_VAL(cf_cv_type_sigaction,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#include ]], [[sigaction_t x]])],[cf_cv_type_sigaction=yes],[cf_cv_type_sigaction=no])]) - AC_MSG_RESULT($cf_cv_type_sigaction) - test "$cf_cv_type_sigaction" = yes && AC_DEFINE(HAVE_TYPE_SIGACTION,1,[Define to 1 if we have the sigaction_t type]) -])dnl - -dnl --------------------------------------------------------------------------- -dnl source: ncurses/aclocal.m4 -dnl CF_VA_COPY version: 6 updated: 2018/12/04 18:14:25 -dnl ---------- -dnl check for va_copy, part of stdarg.h starting with ISO C 1999. -dnl --------------------------------------------------------------------------- -dnl CF_VA_COPY version: 6 updated: 2018/12/04 18:14:25 -dnl ---------- -dnl check for va_copy, part of stdarg.h starting with ISO C 1999. -dnl Also, workaround for glibc's __va_copy, by checking for both. -dnl Finally, try to accommodate pre-ISO C 1999 headers. -AC_DEFUN([CF_VA_COPY],[ -AC_CACHE_CHECK(for va_copy, cf_cv_have_va_copy,[ -AC_LINK_IFELSE([AC_LANG_PROGRAM([[ -#include -]], [[ - static va_list dst; - static va_list src; - va_copy(dst, src)]])],[cf_cv_have_va_copy=yes],[cf_cv_have_va_copy=no])]) - -if test "$cf_cv_have_va_copy" = yes; -then - AC_DEFINE(HAVE_VA_COPY,1,[Define to 1 if we have va_copy]) -else # !cf_cv_have_va_copy - -AC_CACHE_CHECK(for __va_copy, cf_cv_have___va_copy,[ -AC_LINK_IFELSE([AC_LANG_PROGRAM([[ -#include -]], [[ - static va_list dst; - static va_list src; - __va_copy(dst, src)]])],[cf_cv_have___va_copy=yes],[cf_cv_have___va_copy=no])]) - -if test "$cf_cv_have___va_copy" = yes -then - AC_DEFINE(HAVE___VA_COPY,1,[Define to 1 if we have __va_copy]) -else # !cf_cv_have___va_copy - -AC_CACHE_CHECK(for __builtin_va_copy, cf_cv_have___builtin_va_copy,[ -AC_LINK_IFELSE([AC_LANG_PROGRAM([[ -#include -]], [[ - static va_list dst; - static va_list src; - __builtin_va_copy(dst, src)]])],[cf_cv_have___builtin_va_copy=yes],[cf_cv_have___builtin_va_copy=no])]) - -test "$cf_cv_have___builtin_va_copy" = yes && - AC_DEFINE(HAVE___BUILTIN_VA_COPY,1,[Define to 1 if we have __builtin_va_copy]) - -fi # cf_cv_have___va_copy - -fi # cf_cv_have_va_copy - -case "${cf_cv_have_va_copy}${cf_cv_have___va_copy}${cf_cv_have___builtin_va_copy}" in -(*yes*) - ;; - -(*) - AC_CACHE_CHECK(if we can simply copy va_list, cf_cv_pointer_va_list,[ -AC_LINK_IFELSE([AC_LANG_PROGRAM([[ -#include -]], [[ - va_list dst; - va_list src; - dst = src]])],[cf_cv_pointer_va_list=yes],[cf_cv_pointer_va_list=no])]) - - if test "$cf_cv_pointer_va_list" = no - then - AC_CACHE_CHECK(if we can copy va_list indirectly, cf_cv_array_va_list,[ -AC_LINK_IFELSE([AC_LANG_PROGRAM([[ -#include -]], [[ - va_list dst; - va_list src; - *dst = *src]])],[cf_cv_array_va_list=yes],[cf_cv_array_va_list=no])]) - test "$cf_cv_array_va_list" = yes && AC_DEFINE(ARRAY_VA_LIST,1,[Define to 1 if we can copy va_list indirectly]) - fi - ;; -esac -]) - - -dnl --------------------------------------------------------------------------- -dnl Check for existence of workable nanosleep() function. -dnl Some systems, e.g. AIX 4.x, provide a non-working version. -dnl - -AC_DEFUN([CF_FUNC_NANOSLEEP],[ - AC_CACHE_CHECK(if nanosleep really works,cf_cv_func_nanosleep,[ - AC_RUN_IFELSE([AC_LANG_PROGRAM([[ -#include -#include -#include - -#ifdef HAVE_SYS_TIME_H -#include -#endif]],[[ - struct timespec ts1, ts2; - int code; - ts1.tv_sec = 0; - ts1.tv_nsec = 750000000; - ts2.tv_sec = 0; - ts2.tv_nsec = 0; - errno = 0; - code = nanosleep(&ts1, &ts2); /* on failure errno is ENOSYS. */ - ${cf_cv_main_return:-return}(code != 0); -]])], - [cf_cv_func_nanosleep=yes], - [cf_cv_func_nanosleep=no], - [cf_cv_func_nanosleep=unknown])]) - - test "$cf_cv_func_nanosleep" = "yes" && \ - AC_DEFINE([HAVE_NANOSLEEP], 1, [nonosleep() available.]) -]) - - -dnl --------------------------------------------------------------------------- -dnl CF_ADD_CFLAGS -dnl -dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS -dnl The second parameter if given makes this macro verbose. -dnl -dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS, -dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily -dnl confused by the quotes (which require backslashes to keep them usable). -dnl - -AC_DEFUN([CF_ADD_CFLAGS],[ - cf_fix_cppflags=no - cf_new_cflags= - cf_new_cppflags= - cf_new_extra_cppflags= - - for cf_add_cflags in $1 - do - case $cf_fix_cppflags in - no) - case $cf_add_cflags in #(vi - -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi - case $cf_add_cflags in - -D*) - cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'` - - test "${cf_add_cflags}" != "${cf_tst_cflags}" \ - && test -z "${cf_tst_cflags}" \ - && cf_fix_cppflags=yes - - if test $cf_fix_cppflags = yes ; then - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" - continue - elif test "${cf_tst_cflags}" = "\"'" ; then - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" - continue - fi - ;; - esac - case "$CPPFLAGS" in - *$cf_add_cflags) #(vi - ;; - *) #(vi - cf_new_cppflags="$cf_new_cppflags $cf_add_cflags" - ;; - esac - ;; - *) - cf_new_cflags="$cf_new_cflags $cf_add_cflags" - ;; - esac - ;; - yes) - cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" - - cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'` - - test "${cf_add_cflags}" != "${cf_tst_cflags}" \ - && test -z "${cf_tst_cflags}" \ - && cf_fix_cppflags=no - ;; - esac - done - - if test -n "$cf_new_cflags" ; then - ifelse($2,,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)]) - CFLAGS="$CFLAGS $cf_new_cflags" - fi - - if test -n "$cf_new_cppflags" ; then - ifelse($2,,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)]) - CPPFLAGS="$cf_new_cppflags $CPPFLAGS" - fi - - if test -n "$cf_new_extra_cppflags" ; then - ifelse($2,,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)]) - EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS" - fi - AC_SUBST(EXTRA_CPPFLAGS) -])dnl - - -dnl --------------------------------------------------------------------------- -dnl CF_ADD_EXTRALIBS -dnl -dnl Add a lib to current LIBS if it is not already there. -dnl - -AC_DEFUN([CF_ADD_EXTRALIBS],[ - EXTRALIBS_addsave=[$EXTRALIBS] - if test "x$EXTRALIBS_addsave" != "x" ; then - flag=`echo "$1" | sed 's/-/\\\-/g'` - if test -z "`echo \"${EXTRALIBS}\" | grep \"${flag}\"`" ; then - EXTRALIBS="$EXTRALIBS_addsave $1" - fi - else - EXTRALIBS="$1" - fi -])dnl - - -dnl --------------------------------------------------------------------------- -dnl CF_ADD_LIBS -dnl -dnl Add a lib to current LIBS if it is not already there. -dnl - -AC_DEFUN([CF_ADD_LIBS],[ - LIBS_addsave=[$LIBS] - if test "x$LIBS_addsave" != "x" ; then - flag=`echo "$1" | sed 's/-/\\\-/g'` - if test -z "`echo \"${LIBS}\" | grep \"${flag}\"`" ; then - LIBS="$LIBS_addsave $1" - fi - else - LIBS="$1" - fi -])dnl - - -dnl --------------------------------------------------------------------------- -dnl Find version of gcc -dnl - -AC_DEFUN([CF_GCC_VERSION],[ - AC_REQUIRE([AC_PROG_CC]) - GCC_VERSION=none - if test "$GCC" = yes ; then - AC_MSG_CHECKING(version of $CC) - GCC_VERSION="`${CC} --version| sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`" - test -z "$GCC_VERSION" && GCC_VERSION=unknown - AC_MSG_RESULT($GCC_VERSION) - fi -])dnl - -dnl --------------------------------------------------------------------------- -dnl Make an uppercase version of a variable -dnl $1=uppercase($2) -dnl - -AC_DEFUN([CF_UPPER],[ - $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%` -]) - -dnl --------------------------------------------------------------------------- -dnl Test for availability of useful gcc __attribute__ directives to quiet -dnl compiler warnings. -dnl -dnl Defines the following: -dnl GCC_SCANF -dnl GCC_PRINTF -dnl GCC_UNUSED -dnl GCC_NORETURN -dnl GCC_SCANFLIKE -dnl GCC_PRINTFLIKE -dnl - -AC_DEFUN([CF_GCC_ATTRIBUTES],[ - - if test "$GCC" = yes; then - cat > conftest.i < conftest.$ac_ext <&AS_MESSAGE_LOG_FD - - case $cf_attribute in #(vi - printf) #(vi - cf_printf_attribute=yes - cat >conftest.h <conftest.h <conftest.h <>confdefs.h - case $cf_attribute in #(vi - printf) #(vi - if test "$cf_printf_attribute" = no ; then - cat >>confdefs.h <>confdefs.h <>confdefs.h <>confdefs.h <>confdefs.h - fi - rm -rf conftest* - fi -])dnl +dnl -- end diff --git a/buildinfo.pl b/buildinfo.pl index 3a2d1a5c..f85bb59d 100644 --- a/buildinfo.pl +++ b/buildinfo.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -*- mode: perl; -*- -# $Id: buildinfo.pl,v 1.8 2024/04/22 14:34:13 cvsuser Exp $ +# $Id: buildinfo.pl,v 1.9 2024/07/30 05:06:10 cvsuser Exp $ # buildinfo generation # # Copyright Adam Young 2018 - 2024 @@ -42,6 +42,9 @@ my $version = "0.0.1"; my $builddate = undef; +my $buildyear = undef; +my $buildmonth = undef; +my $buildmday = undef; my $buildnumber = "1"; my $buildtype = undef; my $buildtoolchain = undef; @@ -102,6 +105,12 @@ $builddate = strftime('%Y%m%d', localtime) if (! $builddate); +($buildyear, $buildmonth, $buildmday) = ($1,$2,$3) + if ($builddate =~ /^(\d\d\d\d)(\d\d)(\d\d)$/); + +die "buildinfo: BUILD_DATE invalid" + if (! $buildyear); + Generate(); sub @@ -128,6 +137,9 @@ #define ${prefix}VERSION_3 ${version3} #define ${prefix}VERSION_4 ${buildnumber} #define ${prefix}BUILD_DATE "${builddate}" +#define ${prefix}BUILD_YEAR "${buildyear}" +#define ${prefix}BUILD_MONTH "${buildmonth}" +#define ${prefix}BUILD_MDAY "${buildmday}" #define ${prefix}BUILD_NUMBER "${buildnumber}" EOT diff --git a/contrib/contrib_config.h b/contrib/contrib_config.h index 73450167..bcd04949 100644 --- a/contrib/contrib_config.h +++ b/contrib/contrib_config.h @@ -1,6 +1,6 @@ #ifndef CONTRIB_CONFIG_H_INCLUDED #define CONTRIB_CONFIG_H_INCLUDED -/* $Id: contrib_config.h,v 1.17 2024/05/25 03:51:42 cvsuser Exp $ +/* $Id: contrib_config.h,v 1.18 2024/07/19 05:05:21 cvsuser Exp $ * contrib ... * * @@ -28,7 +28,7 @@ */ /*config.h*/ -#if defined(unix) +#if defined(unix) || defined(__unix__) #undef _WIN32 #undef _WIN32_NT #elif !defined(_WIN32) @@ -38,7 +38,7 @@ #define APPLICATIONDIR "Grief" /* FIXME, edconfig.h */ -#if defined(unix) +#if defined(unix) || defined(__unix__) #include "../../include/config.h" #else #include "../../libw32/config.h" diff --git a/contrib/libiconv/makelib.def b/contrib/libiconv/makelib.def index 16904324..a72a9410 100644 --- a/contrib/libiconv/makelib.def +++ b/contrib/libiconv/makelib.def @@ -1,4 +1,4 @@ -# $Id: makelib.def,v 1.4 2021/06/12 15:34:33 cvsuser Exp $ +# $Id: makelib.def,v 1.5 2024/07/19 18:11:01 cvsuser Exp $ # win32 makelib configuration # inc=../include @@ -6,5 +6,5 @@ lbl=LIBICONV lib=libiconv.lib def=HAVE_LIBICONV def=HAVE_ICONV_CITRUS_H -def=HAVE_LIBICONV_CITRUS_DLL="libiconv.1.0.dll" +def=HAVE_LIBICONV_CITRUS_DLL="libiconv.1.0.3.dll" diff --git a/doc/INSTALL-UNIX.md b/doc/INSTALL-UNIX.md index d2e49c49..37188585 100644 --- a/doc/INSTALL-UNIX.md +++ b/doc/INSTALL-UNIX.md @@ -25,8 +25,16 @@ Notes for UNIX-like platforms * A development environment in the form of development libraries and C header files. -Optionally the following external packages can be installed adding additional run-time functionality; these shall be auto-detected during 'configure'. +Additionally the following system development packages can be installed adding further run-time functionality; these shall be auto-detected during 'configure'. + * binutils-dev - _GNU binary utilities (BFD development files)_. + + * libx11-dev - _X11 development libraries_. + + * xorg-dev - _X.Org X Window System development libraries_. + +Finally, the following external packages can be installed adding additional run-time functionality; these shall be auto-detected during 'configure'. + * enchant-devel - _Wrapper library for various spell checker engines_. * hunspell-devel - _Spell checker and morphologic_. @@ -59,6 +67,10 @@ plus the following, which are generally available. * openssl-devel - _OpenSSL_. +To enable backtrace support, you need to install one of the following packages: + + * binutils-dev - _Binary File Descriptor_. + Native builds using gcc/clang/cc ================================ diff --git a/gm/Makefile.in b/gm/Makefile.in index bbea21c8..e810a2ab 100644 --- a/gm/Makefile.in +++ b/gm/Makefile.in @@ -1,5 +1,5 @@ # -*- mode: mak; indent-tabs-mode: t; tab-width: 8 -*- -# $Id: Makefile.in,v 1.27 2024/05/03 14:35:16 cvsuser Exp $ +# $Id: Makefile.in,v 1.28 2024/07/30 05:25:48 cvsuser Exp $ # GRIEF Macro Compiler makefile. # # @@ -44,6 +44,7 @@ XCLEAN= CC= @CC@ RM= @RM@ +RC= @RC@ PERL= @PERL@ LIBTOOL= @LIBTOOL@ @@ -114,6 +115,16 @@ OBJS= $(D_OBJ)/gm$(O) \ $(D_OBJ)/language$(O) \ $(D_OBJ)/word$(O) +RESOURCES= gm.rc + +ifeq ("win32","@build_os@") +ifeq (mingw,$(findstring mingw,"@TOOLCHAIN@")) +OBJS+= $(addprefix $(D_OBJ)/,$(subst .rc,_res.o,$(RESOURCES))) +else +OBJS+= $(addprefix $(D_OBJ)/,$(subst .rc,.res,$(RESOURCES))) +endif +endif #build_os + ######################################################################################### # Rules @@ -147,4 +158,10 @@ $(D_OBJ)/%$(O): %$(C) $(D_OBJ)/%$(O): $(D_GR)/%$(C) $(CC) $(CFLAGS) -o $@ -c $< +$(D_OBJ)/%.res: %.rc + $(RC) -fo $@ $< + +$(D_OBJ)/%_res.o: %.rc + $(RC) -o $@ $< + #end diff --git a/gm/gm.rc b/gm/gm.rc new file mode 100644 index 00000000..1fe696de --- /dev/null +++ b/gm/gm.rc @@ -0,0 +1,121 @@ +/* -*- mode: c; indent-width: 4; -*- + * + * windows resource file + * + * This file is part of the GRIEF Editor. + * + * The GRIEF Editor is free software: you can redistribute it + * and/or modify it under the terms of the GRIEF Editor License. + * + * Redistributions of source code must retain the above copyright + * notice, and must be distributed with the license document above. + * + * Redistributions in binary form must reproduce the above copyright + * notice, and must include the license document above in + * the documentation and/or other materials provided with the + * distribution. + * + * The GRIEF Editor is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * License for more details. + * ==end== + */ + +#include "../include/edbuildinfo.h" + +#define RC_PRODUCTVERSION GR_VERSION_1 , GR_VERSION_2 , GR_VERSION_3 , GR_VERSION_4 +#define RC_FILEVERSION GR_VERSION_1 , GR_VERSION_2 , GR_VERSION_3 , GR_VERSION_4 + +#ifndef WINDRES +#include "windows.h" +#include "winver.h" +#endif + +/* + * English (U.S.) resources + */ + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) + +#ifdef _WIN32 +#ifndef WINDRES +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#endif +#pragma code_page(1252) +#endif /* _WIN32 */ + +/* + * Manifest + */ + +#ifndef RT_MANIFEST +#define RT_MANIFEST 24 +#endif +#ifndef CREATEPROCESS_MANIFEST_RESOURCE_ID +#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1 +#endif +CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "../gr/gr.manifest.xml" + +/* + * Updater Meta Data + * nameID typeID { raw data } + */ + +UPDATER HostURL { "\0" } +UPDATER Channel { "release\0" } + + +/* + * Version Information + */ + +VS_VERSION_INFO VERSIONINFO + FILEVERSION RC_FILEVERSION + PRODUCTVERSION RC_PRODUCTVERSION + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS (VS_FF_SPECIALBUILD|VS_FF_DEBUG) +#else + FILEFLAGS (VS_FF_SPECIALBUILD) +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE VFT2_UNKNOWN + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + BEGIN + VALUE "CompanyName", "" + VALUE "FileDescription", "GRIEF Editor, gm" + VALUE "FileVersion", GR_VERSION ", Build:" GR_BUILD_DATE "-" GR_BUILD_NUMBER + VALUE "InternalName", "gm" + VALUE "Copyright", + "Copyright (C) 1998 - " GR_BUILD_YEAR ", Adam Young. All rights reserved. \n" + "Copyright (C) 1990, 1993, The Regents of the University of California. \n" + "Derived from crisp2.2, Paul Fox, 1991. \n" + "This is free software; see the source for copying conditions. \n" + "There is NO warranty; not even for MERCHANTABILITY \n" + "or FITNESS FOR A PARTICULAR PURPOSE. \0" + VALUE "Maintainers", "https://github.com/adamyg/grief\n" + VALUE "LegalTrademarks", "see GRIEF License" + VALUE "OriginalFilename", "gm.exe" + VALUE "ProductName", "GRIEF" + END + END + + /* The following line should only be modified for localized versions. */ + /* It consists of any number of WORD,WORD pairs, with each pair */ + /* describing a language,codepage combination supported by the file. */ + /* */ + /* For example, a file might have values "0x409,1252" indicating that it */ + /* supports English language (0x409) in the Windows ANSI codepage (1252). */ + + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END + END + +#endif /* English (U.S.) resources */ diff --git a/gr/.gdbinit b/gr/.gdbinit index b666adfb..e7cc1a1d 100644 --- a/gr/.gdbinit +++ b/gr/.gdbinit @@ -1,6 +1,5 @@ # -# -set new-console yes + br abort br __assert br __assert_func diff --git a/gr/Makefile.in b/gr/Makefile.in index 3b26ebe6..3d424932 100644 --- a/gr/Makefile.in +++ b/gr/Makefile.in @@ -1,5 +1,5 @@ # -*- mode: mak; indent-tabs-mode: t; tab-width: 8 -*- -# $Id: Makefile.in,v 1.97 2024/05/25 04:48:57 cvsuser Exp $ +# $Id: Makefile.in,v 1.101 2024/09/19 15:43:53 cvsuser Exp $ # GRIEF editor makefile. # # @@ -183,7 +183,7 @@ LDRELEASE= @LDRELEASE@ CINCLUDE= -I$(D_INC) @OPENSSL_INCLUDES@ @CINCLUDE@ -CEXTRA= @DEFS@ @LIBCURL_CPPFLAGS@ -DLIBTRE_DLL +CEXTRA= @DEFS@ @CURSES_CFLAGS@ @LIBCURL_CPPFLAGS@ -DLIBTRE_DLL ifdef PURIFY CEXTRA+= -DUSING_PURIFY endif @@ -357,6 +357,8 @@ CSRC=\ tty.c \ ttyrgb.c \ ttyterm.c \ + ttycmd.c \ + ttyutil.c \ ttyvio.c \ ttyncurses.c \ ttydos.c \ @@ -433,6 +435,8 @@ clean: -@$(RM) $(RMFLAGS) $(OBJS) $(D_OBJDEP)/*.Po $(CLEANFILES) $(QUIETOUT) -@$(RM) $(RMFLAGS) $(BAK) $(CLEAN) $(XCLEAN) $(QUIETOUT) +version.c: ../include/edbuildinfo.h + -include $(CSRC:%.c=$(D_OBJDEP)/%.Po) -include $(CPPSRC:%.cpp=$(D_OBJDEP)/%.Po) diff --git a/gr/accum.c b/gr/accum.c index 31412a14..c4cebf59 100644 --- a/gr/accum.c +++ b/gr/accum.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_accum_c,"$Id: accum.c,v 1.37 2022/05/26 16:33:10 cvsuser Exp $") +__CIDENT_RCSID(gr_accum_c,"$Id: accum.c,v 1.38 2024/07/21 07:34:57 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: accum.c,v 1.37 2022/05/26 16:33:10 cvsuser Exp $ +/* $Id: accum.c,v 1.38 2024/07/21 07:34:57 cvsuser Exp $ * Accumulator manipulating. * * @@ -150,7 +150,10 @@ acc_zap(void) r_dec(accum.ac_rval); accum.ac_rval = NULL; break; -#if !defined(NDEBUG) +#if defined(NDEBUG) + default: + break; +#else case F_INT: case F_FLOAT: case F_LIT: diff --git a/gr/anchor.c b/gr/anchor.c index 772f826d..4e17231d 100644 --- a/gr/anchor.c +++ b/gr/anchor.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_anchor_c,"$Id: anchor.c,v 1.50 2024/05/16 15:45:56 cvsuser Exp $") +__CIDENT_RCSID(gr_anchor_c,"$Id: anchor.c,v 1.52 2024/08/24 10:34:37 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: anchor.c,v 1.50 2024/05/16 15:45:56 cvsuser Exp $ +/* $Id: anchor.c,v 1.52 2024/08/24 10:34:37 cvsuser Exp $ * Anchor primitives. * * @@ -324,12 +324,15 @@ anchor_get(WINDOW_t *wp, BUFFER_t *bp, ANCHOR_t *a) a->end_col = CURSOR_HUGE_COL; } else if (MK_NONINC == a->type) { - if (--a->end_col <= 0) { // start-of-line - if (--a->end_line > 0) { - a->end_col = CURSOR_HUGE_COL; - } else { - a->end_line = 1; - a->end_col = 1; + if (a->start_line < a->end_line || // able to move back + (a->start_line == a->end_line && a->start_col < a->end_col)) { + if (--a->end_col <= 0) { // start-of-line + if (--a->end_line > 0) { + a->end_col = CURSOR_HUGE_COL; + } else { + a->end_line = 1; + a->end_col = 1; + } } } @@ -560,6 +563,7 @@ do_end_anchor(void) /* int ([int line], [int column]) */ Anchor_t *ap = (Anchor_t *)curbp->b_anchor; u_anchor(); + win_modify(WFHARD); ap->a_eline = line; ap->a_eoffset = col; ret = 1; diff --git a/gr/basic.c b/gr/basic.c index b12c13ec..0bda819e 100644 --- a/gr/basic.c +++ b/gr/basic.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_basic_c,"$Id: basic.c,v 1.31 2021/10/18 13:14:57 cvsuser Exp $") +__CIDENT_RCSID(gr_basic_c,"$Id: basic.c,v 1.32 2024/09/03 14:08:33 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: basic.c,v 1.31 2021/10/18 13:14:57 cvsuser Exp $ +/* $Id: basic.c,v 1.32 2024/09/03 14:08:33 cvsuser Exp $ * Basic cursor movement. * * @@ -422,12 +422,14 @@ do_page_down(void) /* int ([int pages = 1]) */ accint_t pages = get_xinteger(1, 1); /* extension */ const int lines = win_height(curwp); - if (pages < 0) { /* half pages */ - mov_forwline(lines > 2 ? (lines / 2) : 1); - } else if (pages) { - mov_forwline(pages * lines); - } else { - mov_forwline(lines); + if (lines > 0) { + if (pages < 0) { /* half pages */ + mov_forwline(lines > 2 ? (lines / 2) : 1); + } else if (pages) { + mov_forwline(pages * lines); + } else { + mov_forwline(lines); + } } } @@ -473,12 +475,14 @@ do_page_up(void) /* int ([int pages = 1]) */ accint_t pages = get_xinteger(1, 1); /* extension */ const int lines = win_height(curwp); - if (pages < 0) { /* half pages */ - mov_backline(lines > 2 ? (lines / 2) : 1); - } else if (pages) { - mov_backline(pages * lines); - } else { - mov_backline(lines); + if (lines > 0) { + if (pages < 0) { /* half pages */ + mov_backline(lines > 2 ? (lines / 2) : 1); + } else if (pages) { + mov_backline(pages * lines); + } else { + mov_backline(lines); + } } } diff --git a/gr/bookmark.c b/gr/bookmark.c index a09dc5ae..fd82152c 100644 --- a/gr/bookmark.c +++ b/gr/bookmark.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_bookmark_c,"$Id: bookmark.c,v 1.33 2020/04/21 00:01:54 cvsuser Exp $") +__CIDENT_RCSID(gr_bookmark_c,"$Id: bookmark.c,v 1.35 2024/08/18 10:49:05 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: bookmark.c,v 1.33 2020/04/21 00:01:54 cvsuser Exp $ +/* $Id: bookmark.c,v 1.35 2024/08/18 10:49:05 cvsuser Exp $ * Bookmark implementation. * * @@ -161,7 +161,7 @@ bookmark_shutdown(void) column - Optional integer column number within the buffer, if omitted shall default to the left of the buffer (1). - local - Reserved for future use. + local - Reserved for future use. Macro Returns: The 'drop_bookmark()' primitive returns the associated book @@ -547,4 +547,4 @@ bookmark_find(accint_t bookid, int create) return bk; } -/*end*/ \ No newline at end of file +/*end*/ diff --git a/gr/border.c b/gr/border.c index 8e7d7089..3a721cfd 100644 --- a/gr/border.c +++ b/gr/border.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_border_c,"$Id: border.c,v 1.15 2014/10/22 02:32:54 ayoung Exp $") +__CIDENT_RCSID(gr_border_c,"$Id: border.c,v 1.16 2024/08/18 10:49:23 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: border.c,v 1.15 2014/10/22 02:32:54 ayoung Exp $ +/* $Id: border.c,v 1.16 2024/08/18 10:49:23 cvsuser Exp $ * Window helper function, dealing with size and border requirements. * * @@ -262,4 +262,5 @@ win_rcolumn(const WINDOW_t *wp) { return (win_fcolumn(wp) + win_width(wp) - 1); } + /*end*/ diff --git a/gr/buffer.c b/gr/buffer.c index e042f698..53456765 100644 --- a/gr/buffer.c +++ b/gr/buffer.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_buffer_c,"$Id: buffer.c,v 1.52 2022/09/12 15:57:28 cvsuser Exp $") +__CIDENT_RCSID(gr_buffer_c,"$Id: buffer.c,v 1.53 2024/09/06 14:02:02 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: buffer.c,v 1.52 2022/09/12 15:57:28 cvsuser Exp $ +/* $Id: buffer.c,v 1.53 2024/09/06 14:02:02 cvsuser Exp $ * Buffer managment. * * @@ -478,8 +478,12 @@ buf_create(const char *name, const char *encoding, int aflag) bp->b_attrnormal = ATTR_NORMAL; bp->b_imode = -1; /* non-localised insert-mode */ - - bp->b_fname = file_canonicalize(name, NULL, 0); + if (name && *name) { + name = file_canonicalize(name, NULL, 0); + } else { + name = chk_salloc(""); + } + bp->b_fname = name; #if defined(S_IRUSR) && !defined(__MINGW32__) bp->b_mode = (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) & ~x_umask; #else @@ -728,7 +732,7 @@ buf_dirty(BUFFER_t *bp, LINENO start, LINENO end) if (0 == bp->b_dirty_min) { bp->b_dirty_min = start; - bp->b_dirty_max = end; + bp->b_dirty_max = end; } else { if (bp->b_dirty_min > start) { bp->b_dirty_min = start; @@ -1121,3 +1125,4 @@ set_buffer_parms(BUFFER_t *bp, const WINDOW_t *wp) } /*end*/ + diff --git a/gr/builtin.c b/gr/builtin.c index a3211600..0888c92e 100644 --- a/gr/builtin.c +++ b/gr/builtin.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_builtin_c,"$Id: builtin.c,v 1.66 2022/06/16 10:19:31 cvsuser Exp $") +__CIDENT_RCSID(gr_builtin_c,"$Id: builtin.c,v 1.71 2024/08/27 12:44:33 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: builtin.c,v 1.66 2022/06/16 10:19:31 cvsuser Exp $ +/* $Id: builtin.c,v 1.71 2024/08/27 12:44:33 cvsuser Exp $ * Builtin expresssion evaluation. * * @@ -20,6 +20,9 @@ __CIDENT_RCSID(gr_builtin_c,"$Id: builtin.c,v 1.66 2022/06/16 10:19:31 cvsuser E #include #include /* str_...()/sxprintf() */ +#if defined(HAVE_ALLOCA_H) +#include +#endif #include "accum.h" /* acc_... */ #include "builtin.h" @@ -238,6 +241,7 @@ string:; term = ' '; ewprintf("Out of space in execute_str(3)"); return -1; } + //XXX: remove quotes? *dp++ = *cp++; } *dp++ = '\0'; @@ -254,6 +258,130 @@ string:; term = ' '; } + +int +execute_opendir(const char *path) +{ + LIST list[LIST_SIZEOF(4)], /* 4 atoms */ + *lp = list, *lpend = lp + (sizeof(list) - 1 /*HALT*/); + + lp = atom_push_sym(lp, "opendir"); + lp = atom_push_str(lp, path && *path ? path : "."); + assert(lp < lpend); + atom_push_halt(lp); + execute_nmacro(list); + return (int)acc_get_ival(); +} + + + +void +execute_unassigned(const char *spec, int key, const char *seq) +{ + // + // TODO: general execute_key(), precompile during assign_to_key() + // +#define UNASSIGNED_ARGV 16 + + LIST list[LIST_SIZEOF(UNASSIGNED_ARGV)], // 16 atoms + *lp = list, *lpend = lp + (sizeof(list) - 1 /*HALT*/); + + const int speclen = strlen(spec) + 1 /*nul*/; + char *cp = memcpy(alloca(speclen), spec, speclen); + + if (NULL == cp) + return; + + lp = atom_push_sym(lp, cp); // macro + + if ((cp = strchr(cp, ' ')) != NULL) { + // + // trailing arguments + // + int argv = 0; + + *cp++ = 0; // terminate macro + + for (argv = 1; argv < (UNASSIGNED_ARGV - 2); ++argv) { + + // leading white-space + while (*cp && isspace(*cp)) + ++cp; + if (! *cp) + break; // EOS + + // sequence placeholder + if (cp[0] == '{' && cp[1] == '}') { + // TODO: {k} == key, {s} = seq, {d} = description + lp = atom_push_const(lp, seq ? seq : ""); + cp += 2; + continue; + } + + // numeric value (possible) + if ((*cp >= '0' && *cp <= '9') || + (*cp == '-' && (cp[1] >= '0' && cp[1] <= '9')) || + (*cp == '+' && (cp[1] >= '0' && cp[1] <= '9')) || + (*cp == '.' && (cp[1] >= '0' && cp[1] <= '9'))) + { + accfloat_t fval; + accint_t ival; + int ret, len = 0; + +#if (CM_ATOMSIZE == SIZEOF_LONG_LONG && CM_ATOMSIZE != SIZEOF_LONG) + ret = str_numparsel((const char *)cp, &fval, &ival, &len); +#else + ret = str_numparse((const char *)cp, &fval, &ival, &len); +#endif + switch (ret) { + case NUMPARSE_INTEGER: // integer-constant + case NUMPARSE_FLOAT: // float-constant + cp += len; + if (!*cp || isspace(*cp)) { + if (ret == NUMPARSE_INTEGER) { + lp = atom_push_int(lp, ival); + } else { + lp = atom_push_float(lp, fval); + } + continue; + } + cp -= len; + /*FALLTHRU*/ + default: // bad number + break; + } + } + + // string constants + { + char term = ' ', *out = cp; + + lp = atom_push_const(lp, (const char*)out); + if (*cp == '"') { // quoted string + term = '"', ++cp; + } + while (*cp) { + if (*cp == '\\') { // escaped, consume; if suitable + if (cp[1]) + ++cp; + } else if (*cp == term) { // terminator + break; + } + *out++ = *cp++; + } + *out = 0; // terminate string + } + } + } + + lp = atom_push_int(lp, key); + assert(lp < lpend); + atom_push_halt(lp); + + execute_nmacro(list); +} + + void execute_expr(const LISTV *lp) { @@ -536,7 +664,6 @@ execute_xmacro(register const LIST *lp, const LIST *lp_argv) assert(mac_sp == (mac_stack + (mac_sd - 1))); --mac_sd; --mac_sp; /* --- pop */ - return; } @@ -1012,24 +1139,30 @@ execute_expr2(const argtype_t arg, register const LIST *argp, LISTV *lap) assert(sp == sp2); } #endif //_DEBUG + type = sp->s_type; } else if (F_SYM == argtype) { /* SYM */ if (NULL == (sp = sym_elookup(LGET_PTR2(const char, argp)))) { return EERROR; /* lookup error */ } + type = sp->s_type; } else { if (F_NULL != argtype) { /* 05/01/11 */ - ewprintf("Symbol reference expected"); + if (ARG_OPT & arg) { + type = F_NULL; + sp = NULL; /* optional LVAL, 07/24 */ + } else { + ewprintf("Symbol reference expected"); + return EERROR; /* symbol/register expected */ + } #if !defined(NDEBUG) } else { panic("execute_xmacro: F_WHAT? (0x%x/%u)", argtype, argtype); + return EERROR; /* symbol/register expected */ #endif } - return EERROR; /* symbol/register expected */ } - - type = sp->s_type; lap->l_sym = sp; lap->l_flags = F_SYM; assert(type >= 0 && type <= F_OPDATA); diff --git a/gr/builtin.h b/gr/builtin.h index 2f172f14..9597cbcf 100644 --- a/gr/builtin.h +++ b/gr/builtin.h @@ -1,11 +1,11 @@ #ifndef GR_BUILTIN_H_INCLUDED #define GR_BUILTIN_H_INCLUDED #include -__CIDENT_RCSID(gr_builtin_h,"$Id: builtin.h,v 1.27 2024/04/07 15:49:17 cvsuser Exp $") +__CIDENT_RCSID(gr_builtin_h,"$Id: builtin.h,v 1.30 2024/08/25 06:01:52 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: builtin.h,v 1.27 2024/04/07 15:49:17 cvsuser Exp $ +/* $Id: builtin.h,v 1.30 2024/08/25 06:01:52 cvsuser Exp $ * Builtin primitive table. * * @@ -26,6 +26,8 @@ __CPRAGMA_ONCE __CBEGIN_DECLS extern int execute_str(const char *str); +extern int execute_opendir(const char *name); +extern void execute_unassigned(const char *spec, int key, const char *seq); extern void execute_expr(const LISTV *lp); extern void execute_macro(const LIST *lp); extern void execute_nmacro(const LIST *lp); @@ -47,7 +49,6 @@ extern struct mac_stack mac_stack[]; /* Macro name stack */ extern unsigned __CCACHEALIGN mexecflags; extern const LISTV *margv; extern int margc; - //extern const char *mname; extern void *x_returns; diff --git a/gr/cmain.c b/gr/cmain.c index 6a7299b6..25ff4a9c 100644 --- a/gr/cmain.c +++ b/gr/cmain.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_cmain_c,"$Id: cmain.c,v 1.55 2024/06/10 06:00:44 cvsuser Exp $") +__CIDENT_RCSID(gr_cmain_c,"$Id: cmain.c,v 1.65 2024/09/25 15:51:54 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: cmain.c,v 1.55 2024/06/10 06:00:44 cvsuser Exp $ +/* $Id: cmain.c,v 1.65 2024/09/25 15:51:54 cvsuser Exp $ * Main body, startup and command-line processing. * * @@ -78,7 +78,22 @@ __CIDENT_RCSID(gr_cmain_c,"$Id: cmain.c,v 1.55 2024/06/10 06:00:44 cvsuser Exp $ #include "m_feature.h" /* x_features */ #include "m_userprofile.h" -#define MAX_M 32 /* Number of -m switches, including -u switch. */ +#if defined(HAVE_MOUSE) +#define MOUSE_MODE_DEFAULT "auto" +#if defined(HAVE_LIBGPM) && defined(HAVE_GPM_H) +#define MOUSE_MODE_OPTIONS "=[/ttydev|gpm|xterm|xterm-x11,xterm2|xterm-sgr,sgr]" +#else +#define MOUSE_MODE_OPTIONS "=[/ttydev|xterm|xterm-x11,xterm2|xterm-sgr,sgr]" +#endif +#else +#define MOUSE_MODE_DEFAULT "disabled" +#define MOUSE_MODE_OPTIONS "=none" +#endif + +#define KBPROTOCOL_DEFAULT "auto" +#define KBPROTOCOL_OPTIONS "=none|auto|meta|cygwin|msterminal|xterm-mok2|mintty-mok2" + +#define MAX_M 32 /* -m switches, including -u switch. */ static struct argoption options[] = { { "add", arg_none, NULL, 'a', "Add file to current profile" }, @@ -106,7 +121,8 @@ static struct argoption options[] = { { "vm", arg_required, NULL, 'M', "Set virtual memory size to # lines", "#" }, - { "mouse", arg_none, NULL, 1, "Enable mouse" }, + { "mouse", arg_required, NULL, 1, "Configure the mouse mode; default=" MOUSE_MODE_DEFAULT, + MOUSE_MODE_OPTIONS }, { "nomouse", arg_none, NULL, 1, "Disable mouse support" }, @@ -125,7 +141,7 @@ static struct argoption options[] = { { "dark", arg_none, NULL, 4, "or dark color scheme" }, - { "utf8", arg_optional, NULL, 303, "UTF8 features", + { "utf8", arg_optional, NULL, 303, "UTF8 display features", "=[no|yes],[[no]combined,seperate],[subst|ncr|ucn|hex]" }, { "8bit", arg_optional, NULL, 304, "Eight bit terminal encoding, with optional encoding", @@ -153,7 +169,12 @@ static struct argoption options[] = { { "nohilite", arg_none, NULL, 7, "Disable syntax hiliting" }, - { "nocygwinkb", arg_none, NULL, 8, "Disable use of cygwin raw scancodes" }, + { "norawkb", arg_none, NULL, 420, "Disable use of raw kbprotocol; kbprotocol=meta" }, + + { "kbprotocol", arg_required, NULL, 421, "Enable given keyboard protocol: default=" KBPROTOCOL_DEFAULT, + KBPROTOCOL_OPTIONS }, + + { "kbconfig", arg_required, NULL, 422, "Keyboard protocol selection config; format \"term:mode[;..]\"" }, { "nosigtrap", arg_none, NULL, 17, "Disable signal trapping (for debugging)" }, @@ -260,7 +281,11 @@ static int xf_dumpstats = FALSE; /* TRUE if stats reporting on ex static int xf_dumprefs = FALSE; /* TRUE if ref status are dumped on exit. */ -int xf_mouse = TRUE; /* TRUE enable mouse. */ +#if defined(HAVE_MOUSE) || defined(WIN32) +const char * xf_mouse = ""; /* mouse mode; default auto-detect */ +#else +const char * xf_mouse = NULL; +#endif static int xf_ttydrv = 't'; /* TTY driver type */ @@ -276,7 +301,7 @@ int xf_wait = TRUE; /* Set to FALSE if read_char sho * No macros currently use the fact that read_char can return -1 */ -int xf_restore = FALSE; /* TRUE if -a or no files are specified */ +int xf_restore = -1; /* TRUE if -a or no files are specified */ int xf_readonly = FALSE; /* TRUE if -R/--readonly specified. */ int xf_profile = FALSE; /* TRUE if profiling on. */ @@ -296,7 +321,9 @@ int xf_graph = -1; /* TRUE/FALSE, user specified gr int xf_visbell = FALSE; /* TRUE/FALSE, visual bell. */ -int xf_cygwinkb = TRUE; /* TRUE/FALSE, cygwin raw keyboard. */ +int xf_kbprotocol = KBPROTOCOL_AUTO; /* TRUE/FALSE, raw keyboard. */ + +const char * xf_kbconfig = NULL; /* Optional keyboard configuration. */ int xf_sigtrap = TRUE; /* TRUE/FALSE, control signal traps. */ @@ -362,6 +389,9 @@ static const char * m_strings[MAX_M+1]; /* Array of pointer to -m string BUFFER_t * curbp = NULL; /* Current buffer. */ WINDOW_t * curwp = NULL; /* Current window. */ + +static int isdir(const char *path); + static int path_cat(const char *path, const char *sub, char *buf, int length); static char * path_cook2(const char *name, char *result, int length); static char * path_cook(const char *name); @@ -443,6 +473,7 @@ cpp_linkage(const char *str); int cmain(int argc, char **argv) { + unsigned loaded = 0; int arg_index, i; #if defined(HAVE_SIGACTION) @@ -517,10 +548,11 @@ cmain(int argc, char **argv) else if ('x' == xf_ttydrv) ttx11(); #endif vtinit(&argc, argv); - color_setscheme(NULL); ttopen(); + //TODO: resource macro? /* high-level */ + color_setscheme(NULL); cmap_init(); /* character map */ syntax_init(); /* syntax hilite engine */ key_init(); @@ -533,7 +565,7 @@ cmain(int argc, char **argv) unicode_init(); vtready(); if (xf_mouse) { - if (mouse_init("")) { /* mouse interface */ + if (mouse_init(xf_mouse)) { /* mouse interface */ x_display_ctrl |= DC_MOUSE; } xf_usevmin = TRUE; @@ -595,23 +627,42 @@ cmain(int argc, char **argv) x_mflag = FALSE; if (arg_index < argc) { /* load listed files */ - BUFFER_t *firstbp = NULL; + BUFFER_t* firstbp = NULL; while (arg_index < argc) { - x_msglevel = 1; /* no warnings */ - file_edit(argv[arg_index++], EDIT_NORMAL, NULL); - if (NULL == firstbp) { - firstbp = curbp; + const char* name = argv[arg_index++]; + + if (!*name || isdir(name)) { + if (execute_opendir(name) >= 1) { + if (NULL == firstbp) { + firstbp = curbp; + } + ++loaded; + } + } else { + x_msglevel = 1; /* no warnings */ + file_edit(name, EDIT_NORMAL, NULL); + if (NULL == firstbp) { + firstbp = curbp; + } + ++loaded; } } - buf_show(firstbp, curwp); - set_curbp(firstbp); - } else { /* load default quietly */ + if (firstbp) { + if (-1 == xf_restore) + xf_restore = FALSE; + buf_show(firstbp, curwp); + set_curbp(firstbp); + } + } + + if (0 == loaded) { /* load default quietly */ const char *grfile = ggetenv("GRFILE"); + x_msglevel = 1; file_load((grfile && *grfile ? grfile : "newfile"), EDIT_NORMAL|EDIT_STARTUP, NULL); - xf_restore = 1; + xf_restore = TRUE; } /* Hook to allow restore state macro to get called. */ @@ -635,6 +686,14 @@ cmain(int argc, char **argv) } +static int +isdir(const char *path) +{ + struct stat st = {0}; + return (0 == stat(path, &st) && (S_ISDIR(st.st_mode) ? 1 : 0)); +} + + /* Function: panic * System panic, restore console, dump current process and exit. * @@ -939,8 +998,12 @@ argv_process(const int doerr, int argc, const char **argv) } switch(c) { - case 1: /* [no]mouse */ - xf_mouse = (args.opt == 'm' ? TRUE : FALSE); + case 1: /* [no]mouse=[type] */ + if (args.opt == 'm') { + xf_mouse = (args.val ? args.val : ""); + } else { + xf_mouse = NULL; /* nomouse; disable */ + } break; case 2: /* tty - [no]scroll regions */ @@ -970,8 +1033,25 @@ argv_process(const int doerr, int argc, const char **argv) xf_visbell = TRUE; break; - case 8: /* tty - cygwin raw keyboard disabled. */ - xf_cygwinkb = FALSE; + case 420: /* tty - raw keyboard disabled. */ + xf_kbprotocol = KBPROTOCOL_META; + break; + + case 421: { /* tty - keyboard protocol. */ + const int protocol = key_protocolid(args.val, -1); + + if (protocol >= 0) { + xf_kbprotocol = (unsigned)protocol; + } else { + fprintf(stderr, "%s: unknown keyboard protocol mode '%s'\n", x_progname, args.val); + ++errflag; + } + } + break; + + case 422: /* tty - keyboard config. */ + xf_kbprotocol = KBPROTOCOL_AUTO; + xf_kbconfig = args.val; break; case 6: /* tty - underline mode. */ @@ -990,6 +1070,7 @@ argv_process(const int doerr, int argc, const char **argv) xf_nokeypad = TRUE; break; + case 12: /* window (main) borders. */ xf_borders = FALSE; break; @@ -1075,7 +1156,6 @@ argv_process(const int doerr, int argc, const char **argv) const char *val = args.val; unsigned v; - trace_log("-D%s\n", val); for (v = 0; v < (sizeof(vm)/sizeof(vm[0])); ++v) { if (0 == strncmp(vm[v].from, val, vm[v].fromlen)) { const char *path = val + vm[v].fromlen; @@ -1083,13 +1163,16 @@ argv_process(const int doerr, int argc, const char **argv) if (vm[v].ispath) { path = path_cook2(path, t_path, sizeof(t_path)); } - trace_log("==> %s=%s (%s)\n", vm[v].to, path, val + vm[v].fromlen); + trace_log("\t==> %s=%s (%s)\n", vm[v].to, path, val + vm[v].fromlen); gputenv2(vm[v].to, path); val = NULL; break; } } - gputenv(val); + if (val) { + trace_log("\t==>%s", val); + gputenv(val); + } } break; @@ -1855,7 +1938,7 @@ description(const struct argoption *arg, void *buffer) { #define DESCRIPTIONLEN 1024 const char *desc = arg->d1, *token; - + if (NULL != (token = strchr(desc, '%'))) { const char *value = NULL; @@ -2005,7 +2088,8 @@ usage(int what) fflush(stderr); exit(EXIT_FAILURE); -#undef HINDENT +#undef HINDENT } /*end*/ + diff --git a/gr/config.c b/gr/config.c index c22f030a..87f29b0e 100644 --- a/gr/config.c +++ b/gr/config.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_config_c,"$Id: config.c,v 1.35 2022/08/10 15:44:56 cvsuser Exp $") +__CIDENT_RCSID(gr_config_c,"$Id: config.c,v 1.36 2024/07/11 10:24:54 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: config.c,v 1.35 2022/08/10 15:44:56 cvsuser Exp $ +/* $Id: config.c,v 1.36 2024/07/11 10:24:54 cvsuser Exp $ * Machine dependent configuration variables. * * @@ -117,7 +117,7 @@ const char * x_col_table_dark[] = { "operator=" "BLUE", "number=" "GREEN", "comment=" "CYAN", - "delimiter=" "DARK-GREY", + "delimiter=" "GREY", "preprocessor=" "MAGENTA", "preprocessor_keyword=" "DARK-MAGENTA", "keyword=" "YELLOW", diff --git a/gr/debug.h b/gr/debug.h index a06584b6..818cf65d 100644 --- a/gr/debug.h +++ b/gr/debug.h @@ -1,11 +1,11 @@ #ifndef GR_DEBUG_H_INCLUDED #define GR_DEBUG_H_INCLUDED #include -__CIDENT_RCSID(gr_debug_h,"$Id: debug.h,v 1.12 2020/04/21 00:01:55 cvsuser Exp $") +__CIDENT_RCSID(gr_debug_h,"$Id: debug.h,v 1.13 2024/07/29 16:14:45 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: debug.h,v 1.12 2020/04/21 00:01:55 cvsuser Exp $ +/* $Id: debug.h,v 1.13 2024/07/29 16:14:45 cvsuser Exp $ * Debugging support. * * @@ -98,4 +98,3 @@ extern void trace_refs(void); __CEND_DECLS #endif /*GR_DEBUG_H_INCLUDED*/ - diff --git a/gr/dialog.c b/gr/dialog.c index fc9ef121..3fdd3f45 100644 --- a/gr/dialog.c +++ b/gr/dialog.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_dialog_c,"$Id: dialog.c,v 1.31 2022/08/10 15:44:56 cvsuser Exp $") +__CIDENT_RCSID(gr_dialog_c,"$Id: dialog.c,v 1.35 2024/09/25 13:59:56 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: dialog.c,v 1.31 2022/08/10 15:44:56 cvsuser Exp $ +/* $Id: dialog.c,v 1.35 2024/09/25 13:59:56 cvsuser Exp $ * Dialog manager. * * @@ -48,11 +48,26 @@ static void dlg_inherit(WIDGET_t *parent, WIDGET_t *w); static int callback(const char *label, const char *callback, WIDGET_t *w, int event, accint_t val1, accint_t val2, int *iret); -static const struct { /* Widget classes */ +typedef struct { /* Widget definition */ uint16_t w_class; const char * w_desc; WIDGETNEW_t w_new; -} widgets[] = { +} WidgetDef; + +typedef struct { /* Attribute definition */ + uint16_t a_ident; + const char * a_desc; + int32_t a_type; +#define A_NONE 0x00 +#define A_STR 0x01 +#define A_INT 0x02 +#define A_BOOL A_INT +#define A_FLOAT 0x04 +#define A_LIST 0x08 +#define A_NULL 0x10 +} AttributeDef; + +static WidgetDef frame_widgets[] = { /* Frame widget classes */ /* * containers */ @@ -62,7 +77,7 @@ static const struct { /* Widget classes */ { DLGC_CONTAINER, "CONTAINER", container_new }, /* - * primitives + * elements */ { DLGC_SPACER, "SPACER", spacer_new }, { DLGC_SEPARATOR_HORIZONTAL, "SEPARATOR_HORIZONTAL", separatorh_new }, @@ -76,27 +91,30 @@ static const struct { /* Widget classes */ { DLGC_NUMERIC_FIELD, "NUMERIC_FIELD", numericfield_new }, { DLGC_COMBO_FIELD, "COMBO_FIELD", combofield_new }, /*- { DLGC_TREE, "TREE", tree_new }, -*/ + /*- { DLGC_TABLE, "TABLE", table_new }, -*/ { DLGC_GAUGE, "GAUGE", gauge_new }, /*- { DLGC_SLIDER, "SLIDER", slider_new }, -*/ - /*- { DLGC_VSCROLLBAR, "VSCROLLBAR", vscrollbar_new }, -*/ - /*- { DLGC_HSCROLLBAR, "HSCROLLBAR", hscrollbar_new }, -*/ - /*- { DLGC_TOGGLE, "TOGGLE", toggle_new }, -*/ { 0, NULL, NULL } }; -static const struct { /* Attribute definition */ - uint16_t a_ident; - const char * a_desc; - int32_t a_type; -} attrs[] = { -#define A_NONE 0x00 -#define A_STR 0x01 -#define A_INT 0x02 -#define A_BOOL A_INT -#define A_FLOAT 0x04 -#define A_LIST 0x08 -#define A_NULL 0x10 +static WidgetDef menu_widgets[] = { /* Menu context, widget classes */ + /* + * containers + */ + { DLGC_MENU, "MENU", menu_new }, + /* + * elements + */ + { DLGC_MENU_ITEM, "MENU_ITEM", menu_item_new }, + { DLGC_MENU_SEPARATOR, "MENU_SEPARATOR", menu_separator_new }, + { 0, NULL, 0 } + }; + +static AttributeDef attrs[] = { + /* + * Attribute definitions + */ { DLGA_TITLE, "TITLE", A_STR }, { DLGA_NAME, "NAME", A_STR }, { DLGA_IDENT, "IDENT", A_INT }, @@ -107,6 +125,8 @@ static const struct { /* Attribute definition */ { DLGA_Y, "Y", A_INT|A_STR }, { DLGA_COLS, "COLS", A_INT|A_STR }, { DLGA_ROWS, "ROWS", A_INT|A_STR }, + { DLGA_VERSION, "VERSION", A_INT }, + { DLGA_STYLES, "STYLES", A_INT }, { DLGA_ATTACH_TOP, "ATTACH_TOP", A_NONE }, { DLGA_ATTACH_BOTTOM, "ATTACH_BOTTOM", A_NONE }, @@ -132,7 +152,7 @@ static const struct { /* Attribute definition */ { DLGA_DEFAULT_BUTTON, "DEFAULT_BUTTON", A_NONE }, { DLGA_DEFAULT_FOCUS, "DEFAULT_FOCUS", A_NONE }, { DLGA_VALUE, "VALUE", A_INT|A_STR|A_LIST|A_NULL }, - { DLGA_LABEL, "LABEL", A_STR }, + { DLGA_LABEL, "LABEL", A_STR }, { DLGA_TEXT_ONLY, "TEXT_ONLY", A_NONE }, { DLGA_GUI_ONLY, "GUI_ONLY", A_NONE }, { DLGA_ACCELERATOR, "ACCELERATOR", A_STR }, @@ -172,7 +192,7 @@ static const struct { /* Attribute definition */ { DLGA_LBICASESTRINGS, "LBICASESTRINGS", A_INT }, { DLGA_LBDUPLICATES, "LBDUPLICATES", A_INT }, /* { DLGA_LBINSERT, "LBINSERT", A_INT|A_STR|A_LIST }, */ - /* { DLGA_LBREMOVE, "LBREMOVE", A_INT|A_STR|A_LIST }, */ + /* { DLGA_LBREMOVE, "LBREMOVE", A_INT }, */ { DLGA_LBCLEAR, "LBCLEAR", A_NONE }, { DLGA_LBCURSOR, "LBCURSOR", A_INT }, @@ -255,7 +275,7 @@ dialog_shutdown(void) *Containers* (start table,table=nd) - [Atom [Description ] + [Atom [Description ] ! DLGC_GROUP Variable sized visual and logical group container, with an optional frame and title. @@ -265,12 +285,17 @@ dialog_shutdown(void) ! DLGC_TAB Fixed size visual and logical container, with an optional title. + + ! DLGC_MENU Specialised menu container. + Note: work-in-progress (end table) *Widgets* + Non-menu containers support the following widgets. + (start table,table=nd) - [Atom [Description ] + [Atom [Description ] ! DLGC_CHECK_BOX Check box ! DLGC_COMBO_FIELD Combo field ! DLGC_EDIT_FIELD Edit field @@ -284,28 +309,38 @@ dialog_shutdown(void) ! DLGC_SPACER Spacer (end table) + Menu containers support the following widgets only. + +(start table,table=nd) + [Atom [Description ] + ! DLGC_MENU_ITEM Item + ! DLGC_MENU_SEPARATOR Separator +(end table) + *Attributes* + Frame/non-menu dialog widgets support the following attributes. + (start table,table=nd) - [Atom [Type [Description ] - ! DLGA_TITLE String Attribute title. - ! DLGA_NAME String Attribute name. - ! DLGA_IDENT Int Identifier. - ! DLGA_CALLBACK String Macro callback. - ! DLGA_HELP String Help topic. - ! DLGA_TOOLTIP String Tooltip topic. - - ! DLGA_X Int Horizontal position. - ! DLGA_Y Int Vertical position. - ! DLGA_COLS Int Width in columns. - ! DLGA_ROWS Int Height in rows. - - ! DLGA_ATTACH_TOP n/a + [Atom [Type [Description ] + ! DLGA_TITLE String Attribute title. + ! DLGA_NAME String Attribute name. + ! DLGA_IDENT Int Identifier. + ! DLGA_CALLBACK String Macro callback. + ! DLGA_HELP String Help topic. + ! DLGA_TOOLTIP String Tooltip topic. + + ! DLGA_X Int Horizontal position. + ! DLGA_Y Int Vertical position. + ! DLGA_COLS Int Width in columns. + ! DLGA_ROWS Int Height in rows. + + ! DLGA_ATTACH_TOP n/a Attachment within frame. ! DLGA_ATTACH_BOTTOM n/a ! DLGA_ATTACH_LEFT n/a ! DLGA_ATTACH_RIGHT n/a - ! DLGA_ALIGN_N n/a + ! DLGA_ALIGN_N n/a Alignment within frame. ! DLGA_ALIGN_NE n/a ! DLGA_ALIGN_E n/a ! DLGA_ALIGN_SE n/a @@ -315,7 +350,7 @@ dialog_shutdown(void) ! DLGA_ALIGN_NW n/a ! DLGA_ALIGN_CENTER n/a - ! DLGA_ALLOW_EXPAND n/a + ! DLGA_ALLOW_EXPAND n/a Auto sizing ! DLGA_ALLOW_FILLX n/a ! DLGA_ALLOW_FILLY n/a ! DLGA_PROPAGATE Boolean @@ -377,11 +412,29 @@ dialog_shutdown(void) ! DLGA_GAUGEMAX Int|Str (end table) + Menu widgets support the following attributes (work-in-progress). + +(start table,table=nd) + [Atom [Type [Description ] + ! DLGA_NAME String Attribute name. + ! DLGA_IDENT Int Identifier. + ! DLGA_CALLBACK String Macro callback. + ! DLGA_HELP String Help topic. + ! DLGA_TOOLTIP String Tooltip topic. + + ! DLGA_VALUE Any + ! DLGA_LABEL String + ! DLGA_ACCELERATOR String + ! DLGA_HOTKEY Integer + ! DLGA_GREYED n/a + ! DLGA_ACTIVE n/a +(end table) + Macro Parameters: decl - Dialog definition. Macro TODO: - Allow the dialog definition to be XML. + Allow the dialog definition to be json. Macro Returns: On success returns a unique dialog resource identifier otherwise @@ -399,8 +452,14 @@ do_dialog_create(void) /* int (list decl) */ DIALOG_t *dialog; WIDGET_t *stack[WIDGET_MAXDEPTH] = {0}, /* container stack */ *parent = NULL, *widget = NULL; - uint32_t groupid = 1, containerid = 10000; const LIST *nextlp, *lp; + + unsigned dlgcontext = 0; +#define DLGCONTEXT_UNDEFINED 0 +#define DLGCONTEXT_FRAME 1 +#define DLGCONTEXT_MENU 2 + + uint32_t groupid = 1, containerid = 10000; int length, padding; int32_t attribute; int depth = 0, object = 0; /* current depths */ @@ -451,57 +510,77 @@ do_dialog_create(void) /* int (list decl) */ break; case DLGC_CONTAINER: case DLGC_TAB: + case DLGC_MENU: ++containerid; break; } widget = NULL; - } else { ewprintf("dialog_create: container nesting incorrect."); idx = -idx; /* error */ } } else { - for (i = 0; widgets[i].w_class; ++i) - if (attribute == widgets[i].w_class) { - WIDGET_t *t_widget; - - if ((WIDGET_t *)NULL != (t_widget = (widgets[i].w_new)())) { - widget = t_widget; - - widget->w_desc = widgets[i].w_desc; - widget->w_class = (uint16_t)attribute; - - dlg_queue(dialog, widget); - dlg_inherit(parent, widget); - - object = 1; /* containers, push and inc identifiers */ - if (attribute < DLGC_END) { - if (depth >= WIDGET_MAXDEPTH) { - ewprintf("dialog_create: nesting depth >%d.", WIDGET_MAXDEPTH); - break; - } - if (0 == depth) { - ++containerid, ++groupid; - } - stack[ depth++ ] = parent; - parent = widget; - object = 0; - } + const WidgetDef *def = NULL; + + if (dlgcontext != DLGCONTEXT_MENU) + for (i = 0; frame_widgets[i].w_class; ++i) + if (attribute == frame_widgets[i].w_class) { + dlgcontext = DLGCONTEXT_FRAME; + def = frame_widgets + i; + break; + } + if (dlgcontext != DLGCONTEXT_FRAME && NULL == def) + for (i = 0; menu_widgets[i].w_class; ++i) + if (attribute == menu_widgets[i].w_class) { + dlgcontext = DLGCONTEXT_MENU; + def = menu_widgets + i; + break; + } + + if (def) { + WIDGET_t *t_widget; + + if ((WIDGET_t *)NULL != (t_widget = def->w_new())) { + widget = t_widget; - widget->w_groupid = groupid; - widget->w_containerid = containerid; + widget->w_desc = def->w_desc; + widget->w_class = (uint16_t)attribute; - length = trace_log("\t[%3d/%3d] %*sDLGC_%s,", - idx, depth, (depth + object) * 4, "", widgets[i].w_desc); - trace_log(" %*s// group:%u, container:%u\n", - (length > 59 ? 0 : 59 - length), "", (unsigned)groupid, (unsigned)containerid); + dlg_queue(dialog, widget); + dlg_inherit(parent, widget); - attribute = 0; /* done */ + object = 1; /* containers, push and inc identifiers */ + if (attribute < DLGC_END) { + if (depth >= WIDGET_MAXDEPTH) { + ewprintf("dialog_create: nesting depth >%d.", WIDGET_MAXDEPTH); + break; + } + if (0 == depth) { + ++containerid, ++groupid; + } + stack[ depth++ ] = parent; + parent = widget; + object = 0; } - break; + + widget->w_groupid = groupid; + widget->w_containerid = containerid; + length = trace_log("\t[%3d/%3d] %*sDLGC_%s,", + idx, depth, (depth + object) * 4, "", def->w_desc); + trace_log(" %*s// group:%u, container:%u\n", + (length > 59 ? 0 : 59 - length), "", (unsigned)groupid, (unsigned)containerid); + + attribute = 0; /* done */ + + } else { + ewprintf("dialog_create: unable to create %swidget '%d/0x%x'.", + (dlgcontext == DLGCONTEXT_FRAME ? "dialog " : (dlgcontext == DLGCONTEXT_MENU ? "menu " : "")), attribute, attribute); + idx = -idx; /* error */ } - if (attribute) { - ewprintf("dialog_create: invalid widget '%d/0x%x'.", attribute, attribute); + + } else { + ewprintf("dialog_create: invalid %swidget '%d/0x%x'.", + (dlgcontext == DLGCONTEXT_FRAME ? "dialog " : (dlgcontext == DLGCONTEXT_MENU ? "menu " : "")), attribute, attribute); idx = -idx; /* error */ } } @@ -610,7 +689,7 @@ do_dialog_create(void) /* int (list decl) */ Macro: dialog_run - Execute a dialog resource int - dialog_run(int dialog, [string args]) + dialog_run(int dialog, [int x], [int y], [string args]) Macro Description: The 'dialog_run()' primitive executes the dialog associated @@ -618,7 +697,8 @@ do_dialog_create(void) /* int (list decl) */ Macro Parameters: dialog - Dialog instance handle. - args - Optional string containing + x, y - Optional coordinates of the top left corner. + args - Optional arguments; future extensions. Macro Returns: The 'dialog_run()' primitive returns the exit value of the @@ -642,6 +722,9 @@ do_dialog_run(void) /* int (int dialog, [string args]) */ ocurdlg = curdlg; curdlg = ident; + + d->d_xhint = get_xinteger(2, -1); /* coordinates */ + d->d_yhint = get_xinteger(3, -1); d->d_retval = -1; d->d_running = 1; @@ -1133,7 +1216,7 @@ dlg_new(void) widget_init(&d->d_widget, sizeof(WIDGET_t), (WIDGETCB_t)dialog_default); d->d_widget.w_root = d; d->d_widget.w_ident = d->d_ident; /* need by callback() */ - + d->d_styles = DLGS_BORDER | DLGS_CAPTION; return d; } @@ -1173,6 +1256,21 @@ dialog_find(int ident) } +void +widget_clear(DIALOG_t* d) +{ + WIDGET_t *first, *w; + + if (NULL != (first = CIRCLEQ_FIRST(&d->d_widgetq))) { + w = first; + do { + assert(WIDGET_MAGIC == w->w_magic); + w->w_uflags = 0; + } while (first != (w = dialog_next(d, w))); + } +} + + WIDGET_t * widget_byname(DIALOG_t *d, const char *name) { @@ -1353,8 +1451,8 @@ dialog_callback(DIALOG_t *d, int event, accint_t val1, accint_t val2) /* Function: widget_callback2 - * Send a message to the widget "callback". The message shall be - * directed firstly at the widget specific callback, if assigned, + * Send a message to the widget "callback". + * The message shall be directed firstly at the widget specific callback, if assigned, * otherwise the dialog callback, if assigned. * * Parameters: @@ -1448,7 +1546,7 @@ callback(const char *label, assert(lp < (tmpl + sizeof(tmpl))); execute_nmacro(tmpl); ret = (int) acc_get_ival(); - trace_ilog("%s_callback ; %d\n", label, ret); + trace_ilog("%s_callback : %d\n", label, ret); if (rval) { *rval = ret; } @@ -1546,6 +1644,7 @@ uint32_t dialog_default(WIDGET_t *w, WIDGETMSG_t msg, WIDGETARG_t p1, WIDGETARG_t p2) { DIALOG_t *d = (DIALOG_t *)w; + int iret = 0; switch (msg) { case WIDGET_SET: { /* set attribute */ @@ -1562,7 +1661,13 @@ dialog_default(WIDGET_t *w, WIDGETMSG_t msg, WIDGETARG_t p1, WIDGETARG_t p2) case DLGA_TEXT_ONLY: case DLGA_GUI_ONLY: - d->d_type = DIALOGARGLO(p1); + d->d_type = widgetdata_uint32(data); + break; + + case DLGA_STYLES: + if (d->d_running) + return FALSE; /* read-only */ + d->d_styles = widgetdata_uint32(data); break; default: @@ -1571,6 +1676,25 @@ dialog_default(WIDGET_t *w, WIDGETMSG_t msg, WIDGETARG_t p1, WIDGETARG_t p2) } return TRUE; + case WIDGET_GET: { /* get attribute */ + WIDGETDATA_t* data = (WIDGETDATA_t*)p2; + + switch (DIALOGARGLO(p1)) { + case DLGA_STYLES: + data->d_u.ivalue = d->d_styles; + data->d_type = D_INT; + d->d_styles; + return TRUE; + } + } + break; + + case WIDGET_SYSCOMMAND: + if (dialog_callback2(d, DLGE_SYSCOMMAND, p1, p2, &iret)) { + return iret; + } + break; + case WIDGET_DESTROY: chk_free((void *)d->d_title), d->d_title = NULL; break; @@ -1738,6 +1862,12 @@ widget_default(WIDGET_t *w, WIDGETMSG_t msg, WIDGETARG_t p1, WIDGETARG_t p2) } break; + case DLGA_STYLES: /* styles, DLGS_XXXX */ + if (w->w_root && w->w_root->d_running) + return FALSE; /* read-only */ + w->w_styles = widgetdata_int32(data); + break; + case DLGA_PADX: if ((w->w_padx = (int)widgetdata_int32(data)) < 0) { w->w_padx = 0; diff --git a/gr/dialog.h b/gr/dialog.h index 608a547b..bed7ccd7 100644 --- a/gr/dialog.h +++ b/gr/dialog.h @@ -1,11 +1,11 @@ #ifndef GR_DIALOG_H_INCLUDED #define GR_DIALOG_H_INCLUDED #include -__CIDENT_RCSID(gr_dialog_h,"$Id: dialog.h,v 1.18 2014/10/26 22:13:10 ayoung Exp $") +__CIDENT_RCSID(gr_dialog_h,"$Id: dialog.h,v 1.21 2024/09/25 13:58:06 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: dialog.h,v 1.18 2014/10/26 22:13:10 ayoung Exp $ +/* $Id: dialog.h,v 1.21 2024/09/25 13:58:06 cvsuser Exp $ * Dialog manager public interface. * * @@ -36,6 +36,7 @@ __CPRAGMA_ONCE #define DLGC_CONTAINER 0x2001 /* Widget container */ #define DLGC_GROUP 0x2002 /* Group start */ #define DLGC_TAB 0x2003 /* Tab panel */ +#define DLGC_MENU 0x2004 /* Menu */ #define DLGC_END 0x200f /* End of current container */ #define DLGC_PUSH_BUTTON 0x2011 /* Push button */ @@ -47,17 +48,21 @@ __CPRAGMA_ONCE #define DLGC_EDIT_FIELD 0x2017 /* Edit field */ #define DLGC_NUMERIC_FIELD 0x2018 /* Numeric edit field */ #define DLGC_COMBO_FIELD 0x2019 /* Edit field and drop list */ +#define DLGC_GAUGE 0x201a /* Gauge */ #define DLGC_SPACER 0x2030 /* Display spacer */ #define DLGC_SEPARATOR_HORIZONTAL 0x2031 #define DLGC_SEPARATOR_VERTICAL 0x2032 -#define DLGC_TREE 0x2040 /* *not* implemented */ -#define DLGC_GAUGE 0x2041 /* *not* implemented */ -#define DLGC_SLIDER 0x2042 /* *not* implemented */ -#define DLGC_VSCROLLBAR 0x2043 /* *not* implemented */ -#define DLGC_HSCROLLBAR 0x2044 /* *not* implemented */ -#define DLGC_GRID 0x2070 /* *not* implemented */ +#define DLGC_MENU_ITEM 0x2041 +#define DLGC_MENU_SEPARATOR 0x2042 + +#define DLGC_TREE 0x20f0 /* *not* implemented */ +#define DLGC_TABLE 0x20f1 /* *not* implemented */ +#define DLGC_SLIDER 0x20f2 /* *not* implemented */ +#define DLGC_VSCROLLBAR 0x20f3 /* *not* implemented */ +#define DLGC_HSCROLLBAR 0x20f4 /* *not* implemented */ +#define DLGC_GRID 0x20f5 /* *not* implemented */ #define DLGC_MAX 0x2100 /* @@ -77,6 +82,7 @@ __CPRAGMA_ONCE #define DLGA_COLS 0x3009 #define DLGA_ROWS 0x300a #define DLGA_VERSION 0x300b /* Wiget specific version/feature set identifier */ +#define DLGA_STYLES 0x300c #define DLGA_ATTACH_BOTTOM 0x3010 /* Attachment of widget within dialog box. */ #define DLGA_ATTACH_TOP 0x3011 @@ -206,6 +212,22 @@ __CPRAGMA_ONCE /*--end--*/ #define DLGA_MAX 0x3100 +/*--export--defines--*/ +/* + * Dialog styles. + */ +#define DLGS_BORDER 0x0001 +#define DLGS_CAPTION 0x0002 + +#define DLGS_MAXIMIZE 0x0100 +#define DLGS_MINIMIZE 0x0200 +#define DLGS_RESTORE 0x0400 +#define DLGS_SYSCLOSE 0x1000 +#define DLGS_SYSMOVE 0x2000 +#define DLGS_SYSSIZE 0x4000 +#define DLGS_SYSMENU 0x8000 +/*--end--*/ + /*--export--defines--*/ /* * Dialog callback events @@ -226,10 +248,10 @@ __CPRAGMA_ONCE DLGE_HELP Indicates that the user pressed the F1 key. - If a menu is active when F1 is pressed, WM_HELP is sent to the - window associated with the menu; otherwise, WM_HELP is sent to + If a menu is active when F1 is pressed, DLGE_HELP is sent to the + window associated with the menu; otherwise, DLGE_HELP is sent to the widget that has the keyboard focus. If no widget has the - focus, WM_HELP is sent to the currently active window. + focus, DLGE_HELP is sent to the currently active window. */ #define DLGE_INIT 0 /* Initlisation */ @@ -241,6 +263,19 @@ __CPRAGMA_ONCE #define DLGE_KEYDOWN 6 /* Keydown event */ #define DLGE_COMMAND 7 /* Accelerator/Menu command */ #define DLGE_HELP 8 /* Help event */ +#define DLGE_SYSCOMMAND 9 /* System command */ +/*--end--*/ + +/*--export--defines--*/ +/* + * System commands. + */ +#define DLSC_CLOSE 0xf010 +#define DLSC_TITLE 0xf020 +#define DLSC_MOVE 0xf100 +#define DLSC_SIZE 0xf120 +#define DLSC_MAXIMIZE 0xf200 +#define DLSC_MINIMIZE 0xf210 /*--end--*/ /*--export--defines--*/ @@ -272,6 +307,7 @@ __CPRAGMA_ONCE #define DLIDYES 104 /*--end--*/ + /* * BS_3STATE * Creates a button that is the same as a check box, except that the box @@ -307,8 +343,8 @@ __CPRAGMA_ONCE #define WIDGET_READY 2 - /* The DESTROY message is sent when a widget is being destroyed. It is - * sent to the widget handler being destroyed after the dialog + /* The DESTROY message is sent when a widget is being destroyed. + * It is sent to the widget handler being destroyed after the dialog * has been removed from the screen. */ #define WIDGET_DESTROY 3 @@ -323,6 +359,11 @@ __CPRAGMA_ONCE */ #define WIDGET_GET 5 + /* Message when the user chooses a command from the window control menu or + * when one the window buttons is selected. + */ +#define WIDGET_SYSCOMMAND 6 + /* BASE for implementation specific messages */ #define WIDGET_BASE 10 @@ -416,6 +457,7 @@ typedef struct _widget { void *w_ucontrol; /* Fields for use by controller */ uint32_t w_uflags; /* User flags, widget specific */ + uint32_t w_styles; /* Style, most only apply to top */ } WIDGET_t; typedef struct { @@ -442,6 +484,8 @@ typedef struct _dialog { #define d_name d_widget.w_name #define d_help d_widget.w_help + int d_xhint; /* Hint from the top left corner coordinates */ + int d_yhint; int d_retval; /* Last return from dialog_run() */ const char * d_title; /* Title */ int d_running; /* Are we running? */ @@ -450,6 +494,7 @@ typedef struct _dialog { int32_t d_ident; /* Object identifier (handle) */ uint32_t d_widgetseq; /* Widget sequence */ + uint32_t d_styles; /* Styles DLGS_XXXX */ TAILQ_ENTRY(_dialog) /* Dialog queue */ d_node; @@ -480,6 +525,7 @@ extern int dialog_count(DIALOG_t *d); extern WIDGET_t * dialog_next(DIALOG_t *d, WIDGET_t *w); extern WIDGET_t * dialog_prev(DIALOG_t *d, WIDGET_t *w); +extern void widget_clear(DIALOG_t* d); extern WIDGET_t * widget_byname(DIALOG_t *d, const char *name); extern WIDGET_t * widget_byident(DIALOG_t *d, int ident); diff --git a/gr/dialog_tty.c b/gr/dialog_tty.c index 44222195..8263b83e 100644 --- a/gr/dialog_tty.c +++ b/gr/dialog_tty.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_dialog_tty_c,"$Id: dialog_tty.c,v 1.28 2022/08/10 15:44:56 cvsuser Exp $") +__CIDENT_RCSID(gr_dialog_tty_c,"$Id: dialog_tty.c,v 1.32 2024/09/25 13:58:06 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: dialog_tty.c,v 1.28 2022/08/10 15:44:56 cvsuser Exp $ +/* $Id: dialog_tty.c,v 1.32 2024/09/25 13:58:06 cvsuser Exp $ * Dialog manager, TTY interface. * * @@ -225,7 +225,7 @@ dialog_tty_popup_create(DIALOG_t *d, const WIDGET_t *w, int rows, int cols, cons y = (maxrows - (d->d_rows + 2)) / 3; } - if (-1 == ttyframe_create(&c->cx_popup, TRUE, NULL, x, y, cols, rows)) { + if (! ttyframe_create(&c->cx_popup, TRUE, NULL, x, y, cols, rows)) { return -1; } @@ -323,6 +323,7 @@ dialog_tty_popup_close(DIALOG_t *d) static int dlg_open(DIALOG_t *d, DialogContext_t *c) { + const int cols = ttcols() - 1, rows = ttrows() - 3; int x, y; /* @@ -338,12 +339,11 @@ dlg_open(DIALOG_t *d, DialogContext_t *c) * widget sizing/ * either run the widget packer or grid processing logic. */ + widget_clear(d); if (0 == d->d_uflags) { dialog_send(d, WIDGET_INIT, 0, 0); dialog_bcast(d, NULL, NULL, FALSE, WIDGET_INIT, 0, 0); - dialog_callback(d, DLGE_INIT, 0, 0); /* dialog initialisation */ - d->d_uflags |= DIALOG_UFPACKED; dlg_pack(d); @@ -355,18 +355,39 @@ dlg_open(DIALOG_t *d, DialogContext_t *c) * Create the window, * positioned (if possible) centered 1/2 vert and 1/3 horz. */ - if ((x = (ttcols() - (d->d_cols + 2)) / 2) < 0) { - x = 0; + if ((x = d->d_xhint) < 0) { /* dynamic position */ + if ((x = (cols - (d->d_cols + 2)) / 2) < 0) { + x = 0; + } + } + + if ((x + d->d_cols) >= cols) { /* limit to cols */ + if ((x = cols - (d->d_cols + 2)) < 0) { + x = 0; + } } - if ((y = (ttrows() - (d->d_rows + 2)) / 3) < 0) { - y = 0; + + if ((y = d->d_yhint) < 0) { /* dynamic position */ + if ((y = (rows - (d->d_rows + 2)) / 3) < 0) { + y = 0; + } + } + + if ((y + d->d_rows) >= rows) { /* limit to rows */ + if ((y = rows - (d->d_rows + 2)) < 0) { + y = 0; + } } if (! ttyframe_create(&c->cx_base, TRUE, - (d->d_title ? d->d_title : "dialog"), x + 1, y + 1, d->d_cols, d->d_rows)) { + (d->d_title ? d->d_title : ""), x + 1, y + 1, d->d_cols, d->d_rows)) { return -1; } + if (d->d_styles & DLGS_SYSCLOSE) { + window_ctrl_set(c->cx_base.f_wp, WCTRLO_CLOSE_BTN); + } + ttyframe_focus(&c->cx_base); curwp->w_dialogp = d; c->cx_dirty = TRUE; @@ -782,7 +803,7 @@ dlg_keydown(DIALOG_t *d, const int key) done = TRUE; break; - case F(10): /* XXX - backdoor exit */ + case F(10): /* XXX - backdoor exit */ d->d_retval = -1; dlg_stop(d); done = TRUE; @@ -809,7 +830,8 @@ dlg_mouse(DIALOG_t *d, struct IOEvent *evt) { DialogContext_t *c = d->d_ucontrol; WIDGET_t *parent, *first, *w; - int wid, where; + WINDOW_t* wp = NULL; + int wid, where = MOBJ_NOWHERE; int x, y; x = evt->mouse.x; @@ -819,47 +841,85 @@ dlg_mouse(DIALOG_t *d, struct IOEvent *evt) first = dialog_next(d, NULL); /* retrieve first */ } - if (NULL == (w = first) || EVT_MOUSE != evt->type || - curwp != mouse_pos(x, y, &wid, &where) || MOBJ_INSIDE != where) { - return; - } + if (NULL != (w = first)) { + /* + * popup/child + */ + if (curwp != (wp = mouse_pos(x, y, &wid, &where))) { + if (wp && c->cx_popup.f_wp == wp) { + switch (where) { + case MOBJ_INSIDE: + x -= wp->w_x + win_lborder(wp) + 1; + y -= wp->w_y + win_tborder(wp) + 1; + widget_send(w, WIDGET_MOUSE_POPUP, DIALOGARG32(x, y), evt->code); + break; + } + } + return; + } - x -= curwp->w_x + win_lborder(curwp) + 1; /* normalise to window */ - y -= curwp->w_y + win_tborder(curwp) + 1; + /* + * primary + */ + assert(wp == curwp); + switch (where) { + case MOBJ_INSIDE: + x -= wp->w_x + win_lborder(wp) + 1; + y -= wp->w_y + win_tborder(wp) + 1; - parent = NULL; - if (first) { - do { - if ((WIDGET_FGREYED|WIDGET_FHIDDEN) & w->w_flags) { - if ((x >= w->w_absx) && (x < w->w_absx + w->w_cols + (w->w_border * 2)) && + parent = NULL; + do { + if (0 == ((WIDGET_FGREYED | WIDGET_FHIDDEN) & w->w_flags)) { + if ((x >= w->w_absx) && (x < w->w_absx + w->w_cols + (w->w_border * 2)) && (y >= w->w_absy) && (y < w->w_absy + w->w_rows + (w->w_border * 2))) { - /* inner most widget */ - if (NULL == TAILQ_FIRST(&w->w_children)) { - x -= w->w_absx; /* normalise to widget */ - y -= w->w_absy; - widget_send(w, WIDGET_MOUSE, DIALOGARG32(x, y), evt->code); - parent = NULL; - break; - } else { /* parent */ - parent = w; + /* inner most widget */ + if (NULL == TAILQ_FIRST(&w->w_children)) { + x -= w->w_absx; /* normalise to widget */ + y -= w->w_absy; + widget_send(w, WIDGET_MOUSE, DIALOGARG32(x, y), evt->code); + parent = NULL; + break; + } else { /* parent */ + parent = w; + } } } + } while ((w = dialog_next(d, w)) != first); + + __CUNUSED(parent) +#if (TODO) // style WIDGET_NORMALISE + if (parent) { + x -= w->w_absx; /* normalise to widget */ + y -= w->w_absy; + widget_send(parent, WIDGET_MOUSE, DIALOGARG32(x, y), evt->code); } - } while ((w = dialog_next(d, w)) != first); - } - - __CUNUSED(parent) -#if (XXX_WIDGET_NORMALISE) - if (parent) { - x -= w->w_absx; /* normalise to widget */ - y -= w->w_absy; - widget_send(parent, WIDGET_MOUSE, DIALOGARG32(x, y), e->u.mouse.event); - } #endif + break; + case MOBJ_CLOSE: + if (FALSE == widget_send(&d->d_widget, WIDGET_SYSCOMMAND, DLSC_CLOSE, DIALOGARG32(x, y))) { + dlg_stop(d); + } + break; + case MOBJ_TITLE: + widget_send(&d->d_widget, WIDGET_SYSCOMMAND, DLSC_TITLE, DIALOGARG32(x, y)); + break; + default: + break; + } + } } +#if (XXX) + case WIDGET_SYSCOMMAND: + if (dialog_callback2(d, DLGE_COMMAND, p1, p2, &iret)) { + return iret; + } + break; +#endif + + /* Function: dlg_focusfirst * Select the first widget that takes focus. * @@ -943,10 +1003,16 @@ dialog_tty_setfocus(DIALOG_t *d, WIDGET_t *w) WIDGET_t *current = c->cx_current; if (current) { + if (current == w) { + assert(HasFocus(w)); + return TRUE; + } dlg_clrfocus(d, TRUE); /* unfocus current */ } c->cx_current = w; /* focus new/current */ + assert(! HasFocus(w)); + if (FALSE == widget_send(w, WIDGET_SETFOCUS, 1, 0)) { if (NULL == current || FALSE == widget_send(current, WIDGET_SETFOCUS, 1, 0)) { c->cx_current = w = NULL; @@ -973,7 +1039,7 @@ dialog_tty_setfocus(DIALOG_t *d, WIDGET_t *w) * * Parameters: * d - Dialog instances. - * force - *TRUE* if the focus should be forecfully unfocused. + * force - *TRUE* if the focus should be forcefully unfocused. * * Returns: * TRUE if the current widget was unfocused, otherwise *FALSE*. diff --git a/gr/dialog_tty.h b/gr/dialog_tty.h index 7c3c8fca..7aeb3380 100644 --- a/gr/dialog_tty.h +++ b/gr/dialog_tty.h @@ -1,11 +1,11 @@ #ifndef GR_DIALOG_TTY_H_INCLUDED #define GR_DIALOG_TTY_H_INCLUDED #include -__CIDENT_RCSID(gr_dialog_tty_h,"$Id: dialog_tty.h,v 1.10 2020/04/21 00:01:55 cvsuser Exp $") +__CIDENT_RCSID(gr_dialog_tty_h,"$Id: dialog_tty.h,v 1.11 2024/07/29 16:14:45 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: dialog_tty.h,v 1.10 2020/04/21 00:01:55 cvsuser Exp $ +/* $Id: dialog_tty.h,v 1.11 2024/07/29 16:14:45 cvsuser Exp $ * Dialog manager, TTY specific functionality * * @@ -36,4 +36,4 @@ extern int dialog_tty_popup_close(DIALOG_t *d); __CEND_DECLS -#endif /*GR_DIALOG_TTY_H_INCLUDED*/ \ No newline at end of file +#endif /*GR_DIALOG_TTY_H_INCLUDED*/ diff --git a/gr/dict.c b/gr/dict.c index d88f6009..217b2e61 100644 --- a/gr/dict.c +++ b/gr/dict.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_dict_c,"$Id: dict.c,v 1.22 2020/04/21 00:01:55 cvsuser Exp $") +__CIDENT_RCSID(gr_dict_c,"$Id: dict.c,v 1.23 2024/07/05 18:33:38 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: dict.c,v 1.22 2020/04/21 00:01:55 cvsuser Exp $ +/* $Id: dict.c,v 1.23 2024/07/05 18:33:38 cvsuser Exp $ * Dictionary functionality. * * @@ -490,7 +490,7 @@ do_dict_name(void) /* string (int obj_id) */ A Grief extension. Macro See Also: - create_dictionary, dict_delete, dict_each, dict_keys, dict_values + delete_dictionary, dict_delete, dict_each, dict_keys, dict_values */ void do_dict_clear(void) /* int (int obj_id) */ @@ -523,14 +523,14 @@ do_dict_clear(void) /* int (int obj_id) */ key - Item key. Macro Returns: - The 'dict_clear()' primitive returns 0 on success, otherwise + The 'dict_delete()' primitive returns 0 on success, otherwise -1 on error. Macro Portability: A Grief extension. Macro See Also: - create_dictionary, dict_each, dict_keys, dict_values + delete_dictionary, dict_clear, dict_each, dict_keys, dict_values */ void do_dict_delete(void) /* int (int obj_id) */ @@ -561,7 +561,7 @@ do_dict_delete(void) /* int (int obj_id) */ Macro: dict_list - Retrieve dictionary items. list - dict_list(int obj_id) + dict_list(int obj_id, [int keys = TRUE]) Macro Description: The 'dict_list()' primitive retrieves the keys or values @@ -584,10 +584,10 @@ do_dict_delete(void) /* int (int obj_id) */ create_dictionary */ void -do_dict_list(void) /* list (int obj_id, [int value = FALSE]) */ +do_dict_list(void) /* list (int obj_id, [int keys = TRUE]) */ { const int objid = get_xinteger(1, -1); /* objid */ - const int keys = get_xinteger(2, 1); /* 1=keys, 0=values */ + const int keys = get_xinteger(2, TRUE); /* 1=keys, 0=values */ DICT *dict = dict_lookup(objid); LIST *dictlist = NULL; @@ -1008,4 +1008,4 @@ do_dict_each(int what) /* (int obj_id, [string key], [declare value]) * acc_assign_int(ret); } -/*end*/ \ No newline at end of file +/*end*/ diff --git a/gr/dict.h b/gr/dict.h index d17cde6c..a1114ebd 100644 --- a/gr/dict.h +++ b/gr/dict.h @@ -1,11 +1,11 @@ #ifndef GR_DICT_H_INCLUDED #define GR_DICT_H_INCLUDED #include -__CIDENT_RCSID(gr_dict_h,"$Id: dict.h,v 1.10 2020/04/21 00:01:55 cvsuser Exp $") +__CIDENT_RCSID(gr_dict_h,"$Id: dict.h,v 1.11 2024/07/29 16:14:45 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: dict.h,v 1.10 2020/04/21 00:01:55 cvsuser Exp $ +/* $Id: dict.h,v 1.11 2024/07/29 16:14:45 cvsuser Exp $ * Dictionaries. * * @@ -45,4 +45,4 @@ extern void do_set_property(void); __CEND_DECLS -#endif /*GR_DICT_H_INCLUDED*/ \ No newline at end of file +#endif /*GR_DICT_H_INCLUDED*/ diff --git a/gr/diff.c b/gr/diff.c index 06da57ac..c1074ac7 100644 --- a/gr/diff.c +++ b/gr/diff.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_diff_c,"$Id: diff.c,v 1.16 2022/08/10 15:44:56 cvsuser Exp $") +__CIDENT_RCSID(gr_diff_c,"$Id: diff.c,v 1.17 2024/08/25 06:01:53 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: diff.c,v 1.16 2022/08/10 15:44:56 cvsuser Exp $ +/* $Id: diff.c,v 1.17 2024/08/25 06:01:53 cvsuser Exp $ * Buffer differ. * * @@ -312,17 +312,17 @@ do_diff_strings(void) /* int([int flags], string s1, string s2, // BUFFER_t *saved_bp = curbp; // uint32_t line, nlines = bp->b_numlines; // LINE_t *lp; -// +// // curbp = bp; -// +// // for (lp = linep(1), line = 1; line < nlines; ++line) { // uint32_t hash; -// +// // hash = diff_hash(ltext(lp), llength(lp), flags); // lp->l_oldlineno = hash; // test only // lp = lforw(lp); // } -// +// // curbp = saved_bp; // //TODO - return v; // } diff --git a/gr/diff.h b/gr/diff.h index 8bb372c2..23c6e539 100644 --- a/gr/diff.h +++ b/gr/diff.h @@ -1,11 +1,11 @@ #ifndef GR_DIFF_H_INCLUDED #define GR_DIFF_H_INCLUDED #include -__CIDENT_RCSID(gr_diff_h,"$Id: diff.h,v 1.10 2020/04/21 00:01:55 cvsuser Exp $") +__CIDENT_RCSID(gr_diff_h,"$Id: diff.h,v 1.11 2024/07/29 16:14:45 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: diff.h,v 1.10 2020/04/21 00:01:55 cvsuser Exp $ +/* $Id: diff.h,v 1.11 2024/07/29 16:14:45 cvsuser Exp $ * Differ interface. * * @@ -46,4 +46,4 @@ extern uint32_t diff_hash(const void *buf, uint32_t length, uint32_t __CEND_DECLS -#endif /*GR_DIFF_H_INCLUDED*/ \ No newline at end of file +#endif /*GR_DIFF_H_INCLUDED*/ diff --git a/gr/display.c b/gr/display.c index e46da190..b59fcd45 100644 --- a/gr/display.c +++ b/gr/display.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_display_c,"$Id: display.c,v 1.87 2024/05/17 16:43:00 cvsuser Exp $") +__CIDENT_RCSID(gr_display_c,"$Id: display.c,v 1.88 2024/09/12 17:28:50 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: display.c,v 1.87 2024/05/17 16:43:00 cvsuser Exp $ +/* $Id: display.c,v 1.88 2024/09/12 17:28:50 cvsuser Exp $ * High level display interface. * * @@ -111,7 +111,7 @@ static __CINLINE int hasborders(const WINDOW_t *wp); static void draw_window(WINDOW_t *wp, int top, LINENO line, int end, const int bottom, int actions); -static void draw_title(const WINDOW_t *wp, const int top, const int line); +static void draw_title(WINDOW_t *wp, const int top, const int line); static int draw_hscroll(WINDOW_t *wp, int line); static void draw_ruler(const WINDOW_t *wp, int line, int ledge); static void draw_left(const WINDOW_t *wp); @@ -2938,14 +2938,15 @@ draw_window(WINDOW_t *wp, int top, LINENO line, int end, const int bottom, int a * nothing. */ static void -draw_title(const WINDOW_t *wp, const int top, const int line) +draw_title(WINDOW_t *wp, const int top, const int line) { const BUFFER_t *bp = wp->w_bufp; const int width = wp->w_w; const int ledge = win_ledge(wp); - const int digits = (((x_dflags && width > 20) || x_applevel > 1) && 0 == line) ? 1 : 0; + const int digits = (0 == line && ((x_dflags && width > 20) || x_applevel > 1) && W_TILED == wp->w_type) ? 1 : 0; const int closebtn = (top && W_POPUP == wp->w_type ? window_ctrl_test(wp, WCTRLO_CLOSE_BTN) : FALSE); // const int zoombtn = (top && W_POPUP == wp->w_type ? window_ctrl_test(wp, WCTRLO_ZOOM_BTN) : FALSE); +// const int sysmenu = (top && W_POPUP == wp->w_type ? window_ctrl_test(wp, WCTRLO_SYSMENU) : FALSE); const unsigned char *title = (unsigned char *)(!top ? wp->w_message : (bp && BF2TST(bp, BF2_TITLE_FULL) && bp->b_fname[0] ? bp->b_fname : wp->w_title)); @@ -2953,8 +2954,8 @@ draw_title(const WINDOW_t *wp, const int top, const int line) const char *suffix = NULL; const vbyte_t col = framecolor(wp); int titlelen = (title && *title ? (int)utf8_width(title, titleend) : 0); /*MCHAR*/ - int left = 0; - int right = 0; + int left = 0; + int right = 0; char numbuf[20]; vbyte_t ch; @@ -2977,7 +2978,8 @@ draw_title(const WINDOW_t *wp, const int top, const int line) /* calc display offset */ if (titlelen <= 0) { - left = width; + left = width/2; + right = width - left; } else { const int scroll = (bp ? BF2TST(bp, BF2_TITLE_SCROLL) : 0); int norm; /* title length, include left/right separators (+2) */ @@ -3017,20 +3019,26 @@ draw_title(const WINDOW_t *wp, const int top, const int line) if (right < 0) right = 0; } } - assert(left >= 0); + assert(left >= 0); assert(right >= 0); + if (top) { + if (titlelen) { + wp->w_coords.title_start = left + 1; + wp->w_coords.title_end = left + titlelen + 1; + } else { + wp->w_coords.title_start = 0; + wp->w_coords.title_end = 0; + } + wp->w_coords.close_start = 0; + wp->w_coords.close_end = 0; + } + /* corner */ vtmove(line, ledge); ch = col | v_corner_map[wp->w_corner_hints[top ? TL_CORNER : BL_CORNER]]; vtputb(ch); - /* close button */ - if (closebtn && right > 3) { /* MCHAR??? */ - vtputs((const unsigned char *)"[*]", col); - right -= 3; - } - /* left side of frame */ ch = col | CH_HORIZONTAL; while (left-- > 0) { @@ -3075,9 +3083,20 @@ draw_title(const WINDOW_t *wp, const int top, const int line) } /* right */ - ch = col | CH_HORIZONTAL; - while (right-- > 0) { - vtputb(ch); + if (closebtn && right > 3) { + right -= 3; + ch = col | CH_HORIZONTAL; + while (right-- > 0) { + vtputb(ch); + } + vtputs((const unsigned char*)"[x]", col); //TODO: Ux2327 or U+1F5D9 + wp->w_coords.close_start = width - 4; + wp->w_coords.close_end = width - 1; + } else { + ch = col | CH_HORIZONTAL; + while (right-- > 0) { + vtputb(ch); + } } /* window level or corner */ diff --git a/gr/display.h b/gr/display.h index 60b594b2..8c0f2190 100644 --- a/gr/display.h +++ b/gr/display.h @@ -1,11 +1,11 @@ #ifndef GR_DISPLAY_H_INCLUDED #define GR_DISPLAY_H_INCLUDED #include -__CIDENT_RCSID(gr_display_h,"$Id: display.h,v 1.27 2020/04/21 00:01:55 cvsuser Exp $") +__CIDENT_RCSID(gr_display_h,"$Id: display.h,v 1.28 2024/07/29 16:14:45 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: display.h,v 1.27 2020/04/21 00:01:55 cvsuser Exp $ +/* $Id: display.h,v 1.28 2024/07/29 16:14:45 cvsuser Exp $ * Display management. * * @@ -101,4 +101,4 @@ extern int xf_termcap; __CEND_DECLS -#endif /*GR_DISPLAY_H_INCLUDED*/ \ No newline at end of file +#endif /*GR_DISPLAY_H_INCLUDED*/ diff --git a/gr/file.c b/gr/file.c index 70c69cbe..577f459b 100644 --- a/gr/file.c +++ b/gr/file.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_file_c,"$Id: file.c,v 1.95 2024/05/11 16:38:28 cvsuser Exp $") +__CIDENT_RCSID(gr_file_c,"$Id: file.c,v 1.96 2024/07/20 09:21:58 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: file.c,v 1.95 2024/05/11 16:38:28 cvsuser Exp $ +/* $Id: file.c,v 1.96 2024/07/20 09:21:58 cvsuser Exp $ * File-buffer primitives and support. * * @@ -27,6 +27,9 @@ __CIDENT_RCSID(gr_file_c,"$Id: file.c,v 1.95 2024/05/11 16:38:28 cvsuser Exp $") #if defined(HAVE_PWD_H) #include #endif +#if defined(HAVE_ALLOCA_H) +#include +#endif #include #include /* gputenvv(), ggetenv() */ #include /* str_...()/sxprintf() */ diff --git a/gr/getkey.c b/gr/getkey.c index 021967cd..a20f162b 100644 --- a/gr/getkey.c +++ b/gr/getkey.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_getkey_c,"$Id: getkey.c,v 1.46 2021/10/15 08:58:07 cvsuser Exp $") +__CIDENT_RCSID(gr_getkey_c,"$Id: getkey.c,v 1.50 2024/09/15 14:17:23 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: getkey.c,v 1.46 2021/10/15 08:58:07 cvsuser Exp $ +/* $Id: getkey.c,v 1.50 2024/09/15 14:17:23 cvsuser Exp $ * Low level input, both keyboard and mouse. * * @@ -54,6 +54,7 @@ __CIDENT_RCSID(gr_getkey_c,"$Id: getkey.c,v 1.46 2021/10/15 08:58:07 cvsuser Exp #include "symbol.h" #include "system.h" #include "tty.h" +#include "ttyutil.h" #if defined(__OS2__) #define INCL_BASE @@ -98,8 +99,8 @@ static int x_escsource; static int x_kbdq; /* pending key event */ -static KEY * x_pushback = NULL; /* local push back */ -static KEY x_pushbuffer[32]; +static KEYCHAR * x_pushback = NULL; /* local push back */ +static KEYCHAR x_pushbuffer[IOSEQUENCE_LENGTH * 2]; #if defined(HAVE_SELECT) && \ !defined(__OS2__) && !defined(__MSDOS__) @@ -205,7 +206,7 @@ static int io_wait(int state, struct IOEvent *evt, accint_t utmo) { int tmo = EVT_SECOND(DEF_TIMEOUT); /* default */ - int ret, event = 0; + int ret, event; #if defined(HAVE_SELECT) && \ !defined(__OS2__) && !defined(__MSDOS__) @@ -228,8 +229,9 @@ io_wait(int state, struct IOEvent *evt, accint_t utmo) * STATE_2ND ESC delay (~750 ms). * utmo If callers/user specified timeout is shorter. */ + event = WAIT_TIMEDOUT; + if (STATE_RAW & state) { /* 'utmo' is absolute */ - event = WAIT_TIMEDOUT; tmo = utmo; } else if (STATE_2ND & state) { /* 2nd character, apply esc-delay */ @@ -296,11 +298,12 @@ io_wait(int state, struct IOEvent *evt, accint_t utmo) if (tmo > 0 && ((STATE_RAW|STATE_2ND) & state)) { do { if (sys_iocheck(evt)) { /* poll issues, 1.7/windows 7 */ - assert(EVT_NONE != evt->type); + assert(EVT_KEYRAW == evt->type); return 0; } Sleep(50); } while ((tmo -= 50) > 0); + assert(event); return event; } #endif /*CYGWIN*/ @@ -771,6 +774,7 @@ do_read_char(void) /* int ([int ms = 0], [int mode = 0]) */ { const accint_t tmo = get_xaccint(1, 0); /* timeout, default=0 (block) */ const accint_t mode = get_xaccint(2, 0); /* >0=raw, <0=full, 0=normal */ + struct IOEvent evt = {0}; int ret; vtupdate(); /* echo-line update */ @@ -787,7 +791,7 @@ do_read_char(void) /* int ([int ms = 0], [int mode = 0]) */ /* * full, including mouse (extension) */ - ret = io_next(tmo); + ret = io_next(&evt, tmo); acc_assign_int(ret > 0 ? (accint_t) ret : (accint_t) -1); } else { @@ -813,115 +817,75 @@ do_read_char(void) /* int ([int ms = 0], [int mode = 0]) */ * buffer. * * Parameters: - * buf - Current i/o status. - * multikey - Reply buffer. - * noambig - Timeout in milliseconds. - * - * Notes: - * - * Normal tracking mode sends an escape sequence on both button press and - * release. Modifier key (shift, ctrl, meta) information is also sent. It - * is enabled by specifying parameter 1000 to DECSET. - * - * On button press or release, xterm sends CSI M Cb Cx Cy . - * - * o The low two bits of C b encode button information: - * - * 0=MB1 pressed, - * 1=MB2 pressed, - * 2=MB3 pressed, - * 3=release. - * - * o The next three bits encode the modifiers which were down when the - * button was pressed and are added together: - * - * 4=Shift, 8=Meta, 16=Control. - * - * Note however that the shift and control bits are normally unavailable - * because xterm uses the control modifier with mouse for popup menus, and - * the shift modifier is used in the default translations for button events. - * The Meta modifier recognized by xterm is the mod1 mask, and is not - * necessarily the "Meta" key (see xmodmap). - * - * o C x and C y are the x and y coordinates of the mouse event, encoded as - * in X10 mode. x = (Cx - 33), y = (Cy - 33) - * - * Wheel mice may return buttons 4 and 5. Those buttons are represented by - * the same event codes as buttons 1 and 2 respectively, except that 64 is - * added to the event code. Release events for the wheel buttons are not - * reported. By default, the wheel mouse events are translated to scroll-back - * and scroll-forw actions. Those actions normally scroll the whole window, - * as if the scrollbar was used. However if Alternate Scroll mode is set, - * then cursor up/down controls are sent when the terminal is displaying the - * alternate screen. + * buf - Current i/o status. + * multikey - Reply buffer. + * noambig - Timeout in milliseconds. * */ static int -io_cook(const KEY *buf, int noambig, struct IOEvent *evt, int *multikey) +io_cook(struct IOEvent *evt, int noambig, int *multikey) { int key; - if ((key = key_check(buf, multikey, noambig)) > 0) { - if (MOUSE_KEY == key) { + if ((key = key_check((const char *)(evt->sequence.data), evt->sequence.len, multikey, noambig)) > 0) { + if (IS_SPECIAL(key)) { /* * mouse events ... */ - struct IOEvent t_evt = {0}; - int button, ch[3] = {0}; - unsigned i; + if (key == MOUSE_XTERM_KEY || key == MOUSE_SGR_KEY) { + KEYCHAR *buf = evt->sequence.data; + struct MouseEvent me = {0}; + int ret = 0; + + while (0 == ret && evt->sequence.len < (IOSEQUENCE_LENGTH - 1)) + { + if (key == MOUSE_XTERM_KEY) + ret = tty_mouse_xterm(&me, buf); + else if (key == MOUSE_SGR_KEY) + ret = tty_mouse_sgr(&me, buf); + else + ret = -1; + + if (ret >= 1) { /* success */ + if (me.type & MOUSEEVENT_TWHEELED) { + if (0 == (me.type & MOUSEEVENT_TRELEASE)) { + if (me.b1) { + key = (me.ctrl ? KEY_PAGEUP : KEY_UP); + } else { + key = (me.ctrl ? KEY_PAGEDOWN : KEY_DOWN); + } + evt->type = EVT_KEYDOWN; + return (evt->code = key); + } + } else { + mouse_process(&me, (const char *)buf); + } + evt->type = EVT_NONE; + return (evt->code = KEY_VOID); + } - for (i = 0; i < 3; ++i) { - if (io_wait(STATE_2ND, &t_evt, 0) || - t_evt.type != EVT_KEYRAW) { - evt->type = EVT_TIMEOUT; - return (evt->code = -1); - } - ch[i] = t_evt.code; - } + if (0 == ret) { /* additional */ + if (io_wait(STATE_2ND, evt, 0) + || evt->type != EVT_KEYRAW) { + evt->type = EVT_TIMEOUT; + return (evt->code = -1); + } - /* wheel, convert to cursor and page up/down events. */ - button = ch[0]; - if (0x60 == (0x60 & button)) { - switch (button & 0x1f) { - case 0: /* 00000 - '`' */ - key = KEY_UP; - break; - - case 1: /* 00001 - 'a' */ - key = KEY_DOWN; - break; - - case 4|0: /* 00100 - 'd', shift */ - case 8|0: /* 01000 - 'h', meta */ - case 16|0: /* 10000 - 'p', ctrl */ - key = KEY_PAGEUP; - break; - - case 4|1: /* 00101 - 'e', shift */ - case 8|1: /* 01000 - 'i', meta */ - case 16|1: /* 10001 - 'q', ctrl */ - key = KEY_PAGEDOWN; - break; - - default: - evt->type = EVT_NONE; - return (evt->code = KEY_VOID); - } + if (evt->code == 0 || evt->code > 0xff) + evt->code = 0xff; /* mintty/xterm-mode, coord 224 returns NUL, remap */ - evt->type = EVT_KEYDOWN; - return (evt->code = key); - } + buf[evt->sequence.len++] = (KEYCHAR)evt->code; + buf[evt->sequence.len] = 0; - /* others, click and movement */ - mouse_process((ch[1] - ' ' - 1), (ch[2] - ' ' - 1), - (' ' == button), ('!' == button), ('"' == button), -1); + trace_log("KEYSEQ="); + trace_hex(buf, evt->sequence.len); + } + } - evt->type = EVT_NONE; - return (evt->code = KEY_VOID); + evt->type = EVT_NONE; + return (evt->code = KEY_VOID); + } } - - evt->type = EVT_KEYDOWN; - return (evt->code = key); } evt->type = EVT_NONE; @@ -942,9 +906,9 @@ io_cook(const KEY *buf, int noambig, struct IOEvent *evt, int *multikey) * buffered up. * * Parameteres: - * evt - Input event. - * mousemode - Whether mouse events should be returned. - * tmo - Timeout, in milliseconds. + * evt - Input event. + * mousemode - Whether mouse events should be returned. + * tmo - Timeout, in milliseconds. * * Returns: * -1 - Timeout. @@ -955,21 +919,24 @@ static int io_check(struct IOEvent *evt, int mousemode, accint_t tmo) { IOTimer_t timer; - KEY seq[32], seqidx; + struct IOSequence *seq = &evt->sequence; int state, event, multikey; int ch16 = 0, key, ret; iot_current(); if (tmo <= -1) { /* poll, only process typeahead */ - if (!x_pushback && !io_typeahead()) { + if (NULL == x_pushback && !io_typeahead()) { evt->type = EVT_TIMEOUT; + seq->len = 0; return (evt->code = -1); } } + #define IO_RESET() { /* initial state WAIT1 and IDLE */ \ state = (x_waitstate & ~STATE_KEYS) | (STATE_1ST | STATE_IDLE); \ - seq[seqidx = 0] = 0; \ + seq->data[0] = 0; \ + seq->len = 0; \ ch16 = 0; \ } @@ -1049,23 +1016,28 @@ io_check(struct IOEvent *evt, int mousemode, accint_t tmo) if (0 == ret && (ch16 = io_pending(evt)) > 0) { if (EVT_KEYRAW != evt->type) { - if (EVT_MOUSE == evt->type && !mousemode) { - continue; /* consume */ + if (EVT_MOUSE == evt->type) { + if (!mousemode || ch16 == KEY_VOID) { + continue; /* consume */ + } } return ch16; } - break; //KEYRAW + break; //KEYRAW } if (0 == (event = io_wait(state, evt, tmo))) { ch16 = evt->code; + assert(ch16); if (EVT_KEYRAW != evt->type) { - if (EVT_MOUSE == evt->type && !mousemode) { - continue; /* consume */ + if (EVT_MOUSE == evt->type) { + if (!mousemode || ch16 == KEY_VOID) { + continue; /* consume */ + } } return ch16; } - break; //KEYRAW + break; //KEYRAW } /* timers */ @@ -1100,7 +1072,7 @@ io_check(struct IOEvent *evt, int mousemode, accint_t tmo) * Awaiting additional character(s) and previous sequence was an * ambiguous sequence, eg ABC & ABCD; now check not ambiguous. */ - if ((key = io_cook(seq, TRUE, evt, &multikey)) > 0) { + if ((key = io_cook(evt, TRUE, &multikey)) > 0) { if (EVT_MOUSE == evt->type && !mousemode) { if (tmo <= -1 || iot_expired(&timer)) { evt->type = EVT_TIMEOUT; @@ -1114,25 +1086,23 @@ io_check(struct IOEvent *evt, int mousemode, accint_t tmo) } return key; } - goto timeout; + goto unmatched; } - - } //while (ch16 <= 0); + } /* * Append to sequence and cook ... * determine whether the current sequence (seq) is a complete key. */ assert(ch16 > 0); - assert(ch16 <= KEY_VOID); - assert(0 == (ch16 & ~0xff)); /* 8-bit only */ + assert(0 == (ch16 & ~0xff)); /* positive 8-bit only */ iot_current(); /* update timer */ - seq[seqidx] = (KEY) ch16; - seq[++seqidx] = 0; + seq->data[seq->len++] = (KEYCHAR) ch16; + seq->data[seq->len] = 0; - if ((key = io_cook(seq, STATE_2ND & state, evt, &multikey)) <= 0) { + if ((key = io_cook(evt, STATE_2ND & state, &multikey)) <= 0) { if (0 == key) { break; /* no matches */ } @@ -1151,30 +1121,40 @@ io_check(struct IOEvent *evt, int mousemode, accint_t tmo) return key; } + if (seq->len >= (IOSEQUENCE_LENGTH - 1)) { + goto unmatched; /* overflow guard */ + } + if (! multikey) { /* !multikey, secondary characters */ state &= ~STATE_KEYS; state |= STATE_2ND; } } -timeout:; - ch16 = seq[0]; - assert(seqidx > 0); +unmatched:; + assert(seq->len); + ch16 = seq->data[0]; assert(ch16); - playback_store(ch16); - if (seq[seqidx]) { - KEY tkey; + if (seq->len > 1) { + unsigned idx; + assert(x_pushback == NULL); x_pushback = x_pushbuffer; - for (ret = 1; 0 != (tkey = seq[ret]); ++ret) { - *x_pushback++ = tkey; + + for (idx = 1; idx < seq->len; ++idx) { + x_pushbuffer[idx - 1] = seq->data[idx]; } - *x_pushback = 0; + x_pushbuffer[idx] = 0; + seq->data[1] = 0; + seq->len = 1; + } else { x_pushback = NULL; } + playback_store(ch16); + evt->type = EVT_KEYDOWN; return (evt->code = ch16); } @@ -1189,24 +1169,25 @@ timeout:; * and the echo-line are serviced. * * Parameters: - * none + * evt - Event management object. + * tmo - Timeout. * * Returns: * Key code, otherwise -1 on a timeout. */ int -io_next(accint_t tmo) +io_next(struct IOEvent *evt, accint_t tmo) { - struct IOEvent evt = {0}; int key; - if ((key = io_check(&evt, TRUE, tmo)) > 0) { + if ((key = io_check(evt, TRUE, tmo)) > 0) { x_time_last_key = x_ionow; - if (EVT_MOUSE == evt.type) { - mouse_execute(&evt); + if (EVT_MOUSE == evt->type) { + mouse_execute(evt); } } - ED_TRACE(("io_next() = [%d/0x%x]\n", key, key)) + ED_TRACE(("io_next() = [%d/0x%x] <%.*s>\n", key, key, evt->sequence.len, evt->sequence.data)) + assert(evt->code == key); return key; } @@ -1219,8 +1200,8 @@ io_next(accint_t tmo) * display-timers and the echo-line are serviced. * * Parameters: - * evt - Input event. - * tmo - Timeout, in milliseconds. + * evt - Input event. + * tmo - Timeout, in milliseconds. * * Returns: * EVT_TIMEOUT, EVT_MOUSE or EVT_KEYDOWN. @@ -1251,7 +1232,7 @@ io_get_event(struct IOEvent *evt, accint_t tmo) * update-timers and the echo-line are serviced. * * Parameters: - * tmo - Timeout, in milliseconds. + * tmo - Timeout, in milliseconds. * * Returns: * Key code, otherwise -1 on a timeout. @@ -1264,7 +1245,7 @@ io_get_key(accint_t tmo) ED_TRACE(("io_getkey(tmo:%d) = [%d/0x%x]\n", (int)tmo, key, key)) if (key > 0) { - x_time_last_key = x_ionow; + x_time_last_key = x_ionow; } return key; } @@ -1274,7 +1255,7 @@ io_get_key(accint_t tmo) * Retrieve the next raw keystroke from the keyboard. * * Parameters: - * tmo - Timeout, in milliseconds. + * tmo - Timeout, in milliseconds. * * Returns: * Key-code, otherwise 0. @@ -1348,7 +1329,7 @@ io_typeahead(void) * streams and secondary from the underlying keyboard stream. * * Parameters: - * evt - Input event. + * evt - Input event. * * Returns: * Character code otherwise -1. @@ -1385,7 +1366,7 @@ io_pending(struct IOEvent *evt) * Controls whether pty are polled (at least) every 1 second. * * Parameters: - * state - *true* or *false*. + * state - *true* or *false*. * * Returns: * nothing. @@ -1455,7 +1436,7 @@ io_reset_timers(void) * we may need to tell the operating system in a funny way (e.g. X-Windows). * * Parameters: - * fd - File descriptor. + * fd - File descriptor. * * Returns: * nothing. diff --git a/gr/getkey.h b/gr/getkey.h index 76d76525..ccd3efe6 100644 --- a/gr/getkey.h +++ b/gr/getkey.h @@ -1,11 +1,11 @@ #ifndef GR_GETKEY_H_INCLUDED #define GR_GETKEY_H_INCLUDED #include -__CIDENT_RCSID(gr_getkey_h,"$Id: getkey.h,v 1.18 2014/10/22 02:32:57 ayoung Exp $") +__CIDENT_RCSID(gr_getkey_h,"$Id: getkey.h,v 1.19 2024/08/25 06:01:53 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: getkey.h,v 1.18 2014/10/22 02:32:57 ayoung Exp $ +/* $Id: getkey.h,v 1.19 2024/08/25 06:01:53 cvsuser Exp $ * Keyboard event interface. * * @@ -30,28 +30,37 @@ __CPRAGMA_ONCE __CBEGIN_DECLS struct IOMouse { - int x, y; /* coordinates */ - int win; /* associated window */ - int where; /* window location */ - accint_t when; /* timestamp, in milliseconds */ + int x, y; /* coordinates */ + int win; /* associated window */ + int where; /* window location */ + accint_t when; /* timestamp, in milliseconds */ +}; + +typedef unsigned char KEYCHAR; + +struct IOSequence { + unsigned len; /* sequence length, in bytes */ +#define IOSEQUENCE_LENGTH 64 + KEYCHAR data[IOSEQUENCE_LENGTH]; /* raw key sequence data (63 + NUL) */ }; struct IOEvent { - int type; /* event type */ -#define EVT_TIMEOUT -1 -#define EVT_NONE 0 + int type; /* event type */ +#define EVT_TIMEOUT -1 /* read timeout */ +#define EVT_NONE 0 /* no reportable event */ #define EVT_KEYDOWN 1 /* key-down event */ #define EVT_MOUSE 2 /* mouse event */ #define EVT_KEYRAW 99 /* raw key-code */ - int code; /* key-code */ - unsigned modifiers; /* raw modifiers */ - struct IOMouse mouse; + int code; /* key-code, see edalt.h */ + unsigned modifiers; /* raw modifiers */ + struct IOMouse mouse; /* associated mouse details; type=EVT_MOUSE */ + struct IOSequence sequence; /* underlying key data */ }; #define EVT_SECOND(_s) ((_s) * 1000L) #define EVT_MILLISECOND(_m) (_m) -extern int io_next(accint_t tmo); +extern int io_next(struct IOEvent *evt, accint_t tmo); extern int io_get_event(struct IOEvent *evt, accint_t tmo); extern int io_get_key(accint_t tmo); extern int io_get_raw(accint_t tmo); diff --git a/gr/getpwd.c b/gr/getpwd.c index e6229bcf..b443389b 100644 --- a/gr/getpwd.c +++ b/gr/getpwd.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_getpwd_c,"$Id: getpwd.c,v 1.4 2021/04/19 16:35:28 cvsuser Exp $") +__CIDENT_RCSID(gr_getpwd_c,"$Id: getpwd.c,v 1.5 2024/09/21 09:05:16 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: getpwd.c,v 1.4 2021/04/19 16:35:28 cvsuser Exp $ +/* $Id: getpwd.c,v 1.5 2024/09/21 09:05:16 cvsuser Exp $ * Pasword support. * * @@ -109,8 +109,8 @@ getpwlimit(void) #if defined(_SC_GETPW_R_SIZE_MAX) const long limit = sysconf(_SC_GETPW_R_SIZE_MAX); if (limit > 0) - return (size_t)limit; -#endif //_SC_GETPW_R_SIZE_MAX + return (size_t)limit; +#endif //_SC_GETPW_R_SIZE_MAX return 4096; } @@ -125,7 +125,7 @@ sys_getpwnam(passwd_t *pwd, const char *user) assert(pwd && user); if (NULL == pwd || NULL == user) { - return NULL; + return NULL; } pwd->buffer = pwd->result = NULL; @@ -344,8 +344,8 @@ native_getpwlogin() int main() { - { const size_t length_limit = getpwlimit(); - assert(length_limit); + { const size_t length_limit = getpwlimit(); + assert(length_limit); printf("length_limit: %u\n", (unsigned)length_limit); } @@ -375,3 +375,4 @@ main() /*end*/ + diff --git a/gr/getpwd.h b/gr/getpwd.h index da36be39..40b7310b 100644 --- a/gr/getpwd.h +++ b/gr/getpwd.h @@ -1,11 +1,11 @@ #ifndef GR_GETPWD_H_INCLUDED #define GR_GETPWD_H_INCLUDED #include -__CIDENT_RCSID(gr_getpwd_h,"$Id: getpwd.h,v 1.1 2021/04/18 15:54:44 cvsuser Exp $") +__CIDENT_RCSID(gr_getpwd_h,"$Id: getpwd.h,v 1.2 2024/09/21 09:05:16 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: getpwd.h,v 1.1 2021/04/18 15:54:44 cvsuser Exp $ +/* $Id: getpwd.h,v 1.2 2024/09/21 09:05:16 cvsuser Exp $ * Pasword support. * * @@ -36,5 +36,3 @@ void sys_getpwend(passwd_t *pwd, struct passwd *result); __CEND_DECLS #endif /*GR_GETPWD_H_INCLUDED*/ - - diff --git a/gr/getpwd.sh b/gr/getpwd.sh index 15881bfd..402cd5c8 100644 --- a/gr/getpwd.sh +++ b/gr/getpwd.sh @@ -2,5 +2,3 @@ # gcc -I../include -DHAVE_CONFIG_H -DLOCAL_MAIN -Wall -o getpwd getpwd.c - - diff --git a/gr/gr.rc b/gr/gr.rc index 47e7bc38..c2a5f9cf 100644 --- a/gr/gr.rc +++ b/gr/gr.rc @@ -70,26 +70,20 @@ VS_VERSION_INFO VERSIONINFO // VALUE "CompanyName", "" VALUE "FileDescription", "The GRIEF Editor" - VALUE "FileVersion", GR_VERSION ", Build:" GR_BUILD_DATE "-" GR_BUILD_NUMBER - VALUE "InternalName", "GRIEFEdit" - VALUE "LegalCopyright", - "Copyright (C) 1998 - 2024, Adam Young. All rights reserved. \n" - "Derived from crisp2.2, Paul Fox, 1991. \n" + "Copyright (C) 1998 - " GR_BUILD_YEAR ", Adam Young. All rights reserved. \n" "Copyright (C) 1990, 1993, The Regents of the University of California. \n" - + "Derived from crisp2.2, Paul Fox, 1991. \n" + "This is free software; see the source for copying conditions. \n" + "There is NO warranty; not even for MERCHANTABILITY \n" + "or FITNESS FOR A PARTICULAR PURPOSE. \0" VALUE "LegalTrademarks", "see the GRIEF License" - VALUE "Maintainers", "https://github.com/adamyg/grief\n" - VALUE "OriginalFilename", "gr.exe" - - VALUE "ProductName", "GRIEF Edit" - + VALUE "ProductName", "GRIEFEdit" VALUE "ProductVersion", GR_VERSION "-win32" - VALUE "SpecialBuild", "gr-win32-native" END END @@ -117,5 +111,3 @@ VS_VERSION_INFO VERSIONINFO */ #endif /* English (U.S.) resources */ - - diff --git a/gr/keyboard.c b/gr/keyboard.c index 10e2ef05..de43dd2d 100644 --- a/gr/keyboard.c +++ b/gr/keyboard.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_keyboard_c,"$Id: keyboard.c,v 1.67 2022/05/26 16:35:06 cvsuser Exp $") +__CIDENT_RCSID(gr_keyboard_c,"$Id: keyboard.c,v 1.80 2024/09/25 15:51:54 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: keyboard.c,v 1.67 2022/05/26 16:35:06 cvsuser Exp $ +/* $Id: keyboard.c,v 1.80 2024/09/25 15:51:54 cvsuser Exp $ * Manipulate key maps and bindings. * * @@ -49,10 +49,15 @@ __CIDENT_RCSID(gr_keyboard_c,"$Id: keyboard.c,v 1.67 2022/05/26 16:35:06 cvsuser #include "symbol.h" #include "system.h" #include "tty.h" +#include "ttyutil.h" #include "undo.h" #include "window.h" #include "word.h" +#if !defined(USE_VIO_BUFFER) && !defined(DJGPP) +#define USE_KBPROTOCOL +#endif + /* * NBLOCK defines the blocking sizes used during buffer allocation. @@ -118,7 +123,13 @@ static const char * key_macro_value(const object_t *def); static const char * key_macro_find(int key); static char * key_to_char(char *buf, int key); +#if defined(USE_KBPROTOCOL) +static int mok2_to_key(const char *buf, unsigned buflen); +static int xterm_to_key(const char *buf, unsigned buflen); +static unsigned xterm_modifiers(unsigned mods); static int cygwin_to_int(const char *buf); +static int msterminal_to_int(const char *buf); +#endif static char * historyget(int idx); @@ -194,7 +205,10 @@ static const struct map keystring_tbl[] = { { 3, "INS", RANGE_KEYPAD, KEY_INS }, { 5, "PRTSC", RANGE_KEYPAD, KEYPAD_PRTSC }, { 6, "SCROLL", RANGE_KEYPAD, KEYPAD_SCROLL }, - { 5, "MOUSE", RANGE_MISC, MOUSE_KEY }, + { 5, "MOUSE", RANGE_SPECIAL, MOUSE_XTERM_KEY }, + { 5, "MOUSE", RANGE_SPECIAL, MOUSE_SGR_KEY }, + { 7, "FOCUSIN", RANGE_SPECIAL, MOUSE_FOCUSIN_KEY }, + { 8, "FOCUSOUT", RANGE_SPECIAL, MOUSE_FOCUSOUT_KEY }, { 4, "UNDO", RANGE_MISC, KEY_UNDO_CMD }, { 4, "REDO", RANGE_MISC, KEY_REDO }, { 4, "COPY", RANGE_MISC, KEY_COPY_CMD }, @@ -212,7 +226,8 @@ static const struct map keystring_tbl[] = { { 4, "SAVE", RANGE_MISC, KEY_SAVE }, { 4, "MENU", RANGE_MISC, KEY_MENU }, { 5, "BREAK", RANGE_MISC, KEY_BREAK }, - { 0, NULL, 0, 0} + { 10, "UNASSIGNED", 0, KEY_UNASSIGNED }, + { 0, NULL, 0, 0 } }; @@ -255,11 +270,11 @@ static const struct w32key { { VK_BACK, 0, "Back", KEY_BACKSPACE }, { VK_TAB, 0, "Tab", KEY_TAB }, - { VK_BACK, MOD_SHIFT, "Shift-Back", SHIFT_BACKSPACE }, + { VK_BACK, MOD_SHIFT, "Shift-Backspace", SHIFT_BACKSPACE }, { VK_TAB, MOD_SHIFT, "Shift-Tab", BACK_TAB }, - { VK_BACK, MOD_CTRL, "Ctrl-Back", CTRL_BACKSPACE }, + { VK_BACK, MOD_CTRL, "Ctrl-Backspace", CTRL_BACKSPACE }, { VK_TAB, MOD_CTRL, "Ctrl-Tab", CTRL_TAB }, - { VK_BACK, MOD_META, "Alt-Back", ALT_BACKSPACE }, + { VK_BACK, MOD_META, "Alt-Backspace", ALT_BACKSPACE }, { VK_TAB, MOD_META, "Alt-Tab", ALT_TAB }, { VK_ESCAPE, VKMOD_ANY, "Esc", KEY_ESC }, { VK_RETURN, VKMOD_ANY, "Return", KEY_ENTER }, @@ -368,6 +383,28 @@ static const struct w32key { #endif /*WIN32 || __CYGWIN__*/ +static const struct { + const char* name; + size_t namelen; + int mode; +} protocols[] = { +#define PROTONAME(__name) __name, sizeof(__name)-1 + { PROTONAME("none"), KBPROTOCOL_NONE }, + { PROTONAME("auto"), KBPROTOCOL_AUTO }, + { PROTONAME("meta"), KBPROTOCOL_META }, + { PROTONAME("cygwin"), KBPROTOCOL_CYGWIN }, + { PROTONAME("xterm-mok2"), KBPROTOCOL_XTERM_MOK2 }, + { PROTONAME("mintty-mok2"), KBPROTOCOL_MINTTY_MOK2 }, +#if defined(KBPROTOCOL_MSTERMINAL) + { PROTONAME("msterminal"), KBPROTOCOL_MSTERMINAL }, +#endif +#if defined(KBPROTOCOL_MSTERMINAL) + { PROTONAME("kitty"), KBPROTOCOL_MSTERMINAL } +#endif +#undef PROTONAME +}; + + /* Function: key_init * Function called at start-up to initialise the first key map. * @@ -779,6 +816,7 @@ key_macro_add(int key, const char *value) object_t *def; if (NULL != (def = obj_alloc())) { + // TODO: compile into a ARGV; reduce execute overheads. if (value) { /* assign value, otherwise NULL */ obj_assign_str(def, value, -1); } @@ -841,15 +879,25 @@ key_macro_find(int key) if (curbp->b_keyboard) { /* buffer specific */ sep = stype_lookup(curbp->b_keyboard->kt_macros, (stypekey_t) key); - if (NULL == sep && IS_UNICODE(key)) { - sep = stype_lookup(curbp->b_keyboard->kt_macros, (stypekey_t) KEY_UNICODE); + if (NULL == sep) { + if (IS_UNICODE(key)) { + sep = stype_lookup(curbp->b_keyboard->kt_macros, (stypekey_t) KEY_UNICODE); + } + if (NULL == sep) { + sep = stype_lookup(curbp->b_keyboard->kt_macros, (stypekey_t) KEY_UNASSIGNED); + } } } if (NULL == sep) { /* keyboard */ sep = stype_lookup(x_kbdcur->kt_macros, (stypekey_t) key); - if (NULL == sep && IS_UNICODE(key)) { - sep = stype_lookup(x_kbdcur->kt_macros, (stypekey_t) KEY_UNICODE); + if (NULL == sep) { + if (IS_UNICODE(key)) { + sep = stype_lookup(x_kbdcur->kt_macros, (stypekey_t) KEY_UNICODE); + } + if (NULL == sep) { + sep = stype_lookup(x_kbdcur->kt_macros, (stypekey_t) KEY_UNASSIGNED); + } } } @@ -1067,6 +1115,12 @@ key_name2code(const char *string, int *lenp) } else if (0 == strncmp(cp, "DOWN", 4)) { key = WHEEL_DOWN; cp += 4; + } else if (0 == strncmp(cp, "LEFT", 4)) { + key = WHEEL_LEFT; + cp += 4; + } else if (0 == strncmp(cp, "RIGHT", 5)) { + key = WHEEL_RIGHT; + cp += 5; } } flags |= RANGE_MISC; @@ -1175,9 +1229,10 @@ key_name2code(const char *string, int *lenp) key - String identifying the particular keystroke that is being assigned. - macro - String containing the command which shall be invoked, - which may contain literal integer and/or string arguments - to be passed upon the macro upon execution. + macro - String containing the command to be invoked, which + may optionally contain one or more space seperated + integer or string arguments, to be passed upon the + macro upon execution. Key Sequences: @@ -1299,8 +1354,19 @@ key_name2code(const char *string, int *lenp) |wheel-Down |Mousewheel down | | | | | | movement + + |Unassigned |Default key Event | x | x | x | x | x | + + |FocusIn |Mouse focus Events | x | x | x | x | x | + |FocusOut | | x | x | x | x | x | + (end table) + Note!: + The special 'Unassigned' key matches any unregistered key events, + similar to REG_UNASSIGNED yet is assignable within + the context of a specific keyboard. + Macro Returns: The 'assign_to_key' returns the key value assigned to sequence, otherwise -1 if the key sequence is invalid or the @@ -1472,13 +1538,14 @@ do_push_back(void) /* (int key, [int front], [int x], [int y]) */ key_cache_key(x_push_ref, key, front); } else { /* mouse-event, extension */ - const int x = get_xinteger(3, -1); - const int y = get_xinteger(4, -1); - int win = 0, where = 0; + mouseevt_t evt = { 0 }; + + evt.x = get_xinteger(3, -1); + evt.y = get_xinteger(4, -1); - if (x >= 0 && y >= 0) { - if (mouse_pos(x, y, &win, &where)) { - key_cache_mouse(x_push_ref, key, front, x, y, win, where); + if (evt.x >= 0 && evt.y >= 0) { + if (mouse_pos(evt.x, evt.y, &evt.win, &evt.where)) { + key_cache_mouse(x_push_ref, key, front, &evt); } } } @@ -1502,7 +1569,7 @@ void key_cache_key(ref_t *pp, int ch, int front) { assert(RANGE_BUTTON != (ch & RANGE_MASK)); - key_cache_mouse(pp, ch, front, 0, 0, 0, 0); + key_cache_mouse(pp, ch, front, NULL); } @@ -1515,43 +1582,63 @@ key_cache_key(ref_t *pp, int ch, int front) * code - Key code. * front - If TRUE, insert to the front of the keyboard queue * otherwise append to the end. - * x,y - Mouse coordinates. - * win - Where within the window. - * where - Timestamp, in milliseconds. + * evt - Mouse event, containing + * + * seq - Optional escape sequence. + * x,y - Mouse coordinates. + * win - Where within the window. + * where - Timestamp, in milliseconds. * * Returns: * nothing */ + void -key_cache_mouse(ref_t *pp, int code, int front, int x, int y, int win, int where) +key_cache_mouse(ref_t *pp, int code, int front, const mouseevt_t* evt) { - size_t length = sizeof(KEY); - - KEY buffer[(sizeof(KEY) + sizeof(struct IOMouse))/2] = {0}, - *msg = buffer; + unsigned char buffer[sizeof(KEY) + sizeof(struct IOMouse) + IOSEQUENCE_LENGTH] = {0}, + *cursor = buffer; + assert(sizeof(buffer) <= 128); assert(code > 0 && code <= (MOD_MASK|RANGE_MASK|KEY_MASK) && code != KEY_VOID); - *msg++ = (KEY)code; + assert(evt || 0 == (RANGE_BUTTON == (RANGE_MASK & code))); - if (RANGE_BUTTON == (RANGE_MASK & code)) { - struct IOMouse *mouse = (struct IOMouse *)(msg); - int ms = 0; - time_t now = sys_time(&ms); + *((KEY *)cursor) = (KEY)code; + cursor += sizeof(KEY); - mouse->x = x; - mouse->y = y; - mouse->win = win; - mouse->where = where; - mouse->when = - (accint_t) (((now - x_startup_time) * 1000) + ms); - length += sizeof(struct IOMouse); + if (RANGE_BUTTON == (RANGE_MASK & code)) { + if (NULL == evt) { + return; + } else { + unsigned char seqlen = (evt->seq ? (unsigned char)strlen(evt->seq) : 0); + struct IOMouse* mouse = (struct IOMouse*)(cursor); + int ms = 0; + time_t now = sys_time(&ms); + + assert(seqlen <= IOSEQUENCE_LENGTH); + if (seqlen > IOSEQUENCE_LENGTH) seqlen = IOSEQUENCE_LENGTH; + + mouse->x = evt->x; + mouse->y = evt->y; + mouse->win = evt->win; + mouse->where = evt->where; + mouse->when = + (accint_t)(((now - x_startup_time) * 1000) + ms); + cursor += sizeof(struct IOMouse); + *cursor++ = seqlen; + + if (seqlen) { + (void)memcpy(cursor, evt->seq, seqlen); + cursor += seqlen; + } + } } assert(1 == r_refs(pp)); if (TRUE == front) { - r_push(pp, (void *)buffer, length, 128); + r_push(pp, (void *)buffer, cursor - buffer, 128); } else { - r_append(pp, (void *)buffer, length, 128); + r_append(pp, (void *)buffer, cursor - buffer, 128); } } @@ -1569,8 +1656,9 @@ key_cache_mouse(ref_t *pp, int code, int front, int x, int y, int win, int where int key_cache_pop(ref_t *pp, struct IOEvent *evt) { - const KEY *msg = (const KEY *)r_ptr(pp); - size_t used, length = sizeof(KEY); + const unsigned char *msg = (const unsigned char *)r_ptr(pp), + *cursor = msg; + size_t used; int code; if (0 == (used = r_used(pp))) { @@ -1578,7 +1666,8 @@ key_cache_pop(ref_t *pp, struct IOEvent *evt) } assert(used >= (int)sizeof(KEY)); - code = (int) *msg; + code = (int) *((const KEY *)cursor); + cursor += sizeof(KEY); assert(code > 0 && code <= (MOD_MASK|RANGE_MASK|KEY_MASK) && code != KEY_VOID); evt->type = EVT_KEYDOWN; @@ -1587,14 +1676,26 @@ key_cache_pop(ref_t *pp, struct IOEvent *evt) /* * mouse actions ... */ - if (used >= (sizeof(KEY) + sizeof(struct IOMouse))) { - memcpy(&evt->mouse, (const void *)(msg + 1), sizeof(struct IOMouse)); + if (used >= (sizeof(KEY) + sizeof(struct IOMouse) + 1)) { + unsigned char seqlen; + + memcpy(&evt->mouse, (const void *)(cursor), sizeof(struct IOMouse)); evt->type = EVT_MOUSE; - length += sizeof(struct IOMouse); + cursor += sizeof(struct IOMouse); + seqlen = *cursor++; + + if (seqlen) { + if (used >= (sizeof(KEY) + sizeof(struct IOMouse) + 1 + seqlen)) { + assert(seqlen && seqlen < IOSEQUENCE_LENGTH); + evt->sequence.len = seqlen; + (void) memcpy(evt->sequence.data, (const void *)(cursor), seqlen); + cursor += seqlen; + } + } } } - r_pop(pp, length); + r_pop(pp, cursor - msg); return (evt->code = code); } @@ -1676,7 +1777,7 @@ key_cache_test(ref_t *pp) ! KEY_CLOSE Close key. ! KEY_COMMAND ! KEY_COPY Copy to clipboard. - ! KEY_COPY_CMD + ! KEY_COPY_CMD ! KEY_CUT Cut to clipboard. ! KEY_CUT_CMD ! KEY_DEL Delete, rubout. @@ -1737,8 +1838,8 @@ key_cache_test(ref_t *pp) > : Macro Parameters: - key - String contains a single mnemonic key description - (like "i" or ""). + key - String contains a single mnemonic key description, + for example ("i" or ""). raw - Optional boolean flag. If non-zero, then 'key' is taken to be a raw key stroke/escape sequence, as @@ -1769,13 +1870,45 @@ do_key_to_int(void) /* (string key, int raw) */ } else { if (NULL == (sp = splookup(cp, x_kseqtree))) { - const int kcode = cygwin_to_int(cp); + int kcode = -1; - if (kcode > 0) { - acc_assign_int((accint_t) kcode); - } else { - acc_assign_int((accint_t) -1); +#if defined(USE_KBPROTOCOL) + const int len = strlen(cp); + + kcode = cygwin_to_int(cp); +#if defined(KBPROTOCOL_MSTERMINAL) + if (kcode <= 0) { + if (xf_kbprotocol & (KBPROTOCOL_MSTERMINAL)) { + kcode = msterminal_to_int(cp); + } + } +#endif +#if defined(KBPROTOCOL_KITTY) + if (xf_kbprotocol & (KBPROTOCOL_KITTY)) { + if (kcode <= 0) { + kcode = kitty_to_key(cp, len); + } + } +#endif + if (xf_kbprotocol & (KBPROTOCOL_MOK2)) { + if (kcode <= 0) { + kcode = mok2_to_key(cp, len); + } + } + + if (kcode <= 0) { + kcode = xterm_to_key(cp, len); + } + + if (kcode < 0) { + kcode = tty_mouse_xterm(NULL, cp); + } + if (kcode < 0) { + kcode = tty_mouse_sgr(NULL, cp); } +#endif //USE_KBPROTOCOL + + acc_assign_int((accint_t) kcode); } else { const keyseq_t *ks = (const keyseq_t *) sp->data; @@ -1903,20 +2036,42 @@ key_code2name(int key) buf[0] = '<'; buf[1] = '\0'; - if (key & MOD_META) strcat(buf, "Alt-"); - if (key & MOD_CTRL) strcat(buf, "Ctrl-"); + if (key & MOD_META) strcat(buf, "Alt-"); + if (key & MOD_CTRL) strcat(buf, "Ctrl-"); if (key & MOD_SHIFT) strcat(buf, "Shift-"); /* function keys */ bp = buf + strlen(buf); switch (key & RANGE_MASK) { - case RANGE_MISC: { + case RANGE_SPECIAL: { const char *desc = NULL; switch (key) { - case MOUSE_KEY: - desc ="Mouse"; + case MOUSE_XTERM_KEY: + case MOUSE_SGR_KEY: + desc = "Mouse"; + break; + case PASTE_BRACKETED_EVT: + desc = "PasteBracketed"; + break; + case MOUSE_FOCUSOUT_KEY: + desc = "FosusOut"; + break; + case MOUSE_FOCUSIN_KEY: + desc = "FosusIn"; + break; + default: + sprintf(bp, "#%u", key); break; + } + if (desc) strcpy(bp, desc); + } + break; + + case RANGE_MISC: { + const char *desc = NULL; + + switch (key) { case BACK_TAB: desc = "Back-Tab"; break; @@ -1995,6 +2150,12 @@ key_code2name(int key) case WHEEL_DOWN: desc = "Wheel-Down"; break; + case WHEEL_LEFT: + desc = "Wheel-Left"; + break; + case WHEEL_RIGHT: + desc = "Wheel-Right"; + break; default: sprintf(bp, "#%u", key); break; @@ -2054,16 +2215,16 @@ key_code2name(int key) case RANGE_BUTTON: key &= ~(MOD_META | MOD_CTRL | MOD_SHIFT); if (key >= BUTTON1_MOTION) { - sprintf(bp, "Button%d-Motion", key - (BUTTON1_MOTION + 1)); + sprintf(bp, "Button%u-Motion", (key - BUTTON1_MOTION) + 1); } else if (key >= BUTTON1_UP) { - sprintf(bp, "Button%d-Up", key - (BUTTON1_UP + 1)); + sprintf(bp, "Button%u-Up", (key - BUTTON1_UP) + 1); } else if (key >= BUTTON1_DOUBLE) { - sprintf(bp, "Button%d-Double", key - (BUTTON1_DOUBLE + 1)); + sprintf(bp, "Button%u-Double", (key - BUTTON1_DOUBLE) + 1); } else { - sprintf(bp, "Button%d-Down", key - (BUTTON1_DOWN + 1)); + sprintf(bp, "Button%u-Down", (key - BUTTON1_DOWN) + 1); } break; @@ -2173,12 +2334,19 @@ key_to_char(char *buf, int key) /* Function: key_execute * Execute the macro associated with an internal key code. + * + * Parameter: + * key - Keycode. + * + * Returns: + * void */ void -key_execute(int key) +key_execute(int key, const char *seq) { sentry_t *sep = NULL; - const char *cp; + const char *cp = ""; + int badkey = 0; assert(key >= 0); if (KEY_WINCH == key) { @@ -2188,21 +2356,31 @@ key_execute(int key) if (curbp && curbp->b_keyboard) { /* buffer specific */ sep = stype_lookup(curbp->b_keyboard->kt_macros, key); - if (NULL == sep && IS_UNICODE(key)) { - sep = stype_lookup(curbp->b_keyboard->kt_macros, (stypekey_t) KEY_UNICODE); + if (NULL == sep) { + if (IS_UNICODE(key)) { + sep = stype_lookup(curbp->b_keyboard->kt_macros, (stypekey_t) KEY_UNICODE); + } + if (NULL == sep) { + sep = stype_lookup(curbp->b_keyboard->kt_macros, (stypekey_t) KEY_UNASSIGNED); + if (sep) badkey = 1; + } } } if (NULL == sep) { /* current keyboard */ sep = stype_lookup(x_kbdcur->kt_macros, key); - if (NULL == sep && IS_UNICODE(key)) { - sep = stype_lookup(x_kbdcur->kt_macros, (stypekey_t) KEY_UNICODE); + if (NULL == sep) { + if (IS_UNICODE(key)) { + sep = stype_lookup(x_kbdcur->kt_macros, (stypekey_t) KEY_UNICODE); + } + if (NULL == sep) { + sep = stype_lookup(x_kbdcur->kt_macros, (stypekey_t) KEY_UNASSIGNED); + if (sep) badkey = 1; + } } } - if (NULL == sep) { - cp = ""; - } else { + if (sep) { cp = key_macro_value((const object_t *)sep->se_ptr); } @@ -2248,7 +2426,11 @@ key_execute(int key) if (0 == *cp) { trigger(REG_UNASSIGNED /*REG_INVALID*/); } else { - execute_str(cp); + if (badkey) { + execute_unassigned(cp, key, seq); + } else { + execute_str(cp); + } } } @@ -2504,73 +2686,160 @@ inq_local_keyboard(void) /* int inq_local_keyboard() */ } + +/* Function: key_protocolid + * Map a keyboard protocol to its idenifier. + * + * Parameters: + * name - Keyboard protocol name. + * + * Results: + * Protocol identifier, otherwise -1. + */ +int +key_protocolid(const char* name, int namelen) +{ + if (name && *name) { + unsigned p = 0; + + if (namelen < 0) + namelen = strlen(name); + + for (p = 0; p < (sizeof(protocols) / sizeof(protocols[0])); ++p) { + if (namelen == (int)protocols[p].namelen && + 0 == memcmp(protocols[p].name, name, namelen)) { + return protocols[p].mode; + } + } + } + return -1; +} + + +const char * +key_protocolname(int mode, const char *def) +{ + unsigned p = 0; + + for (p = 0; p < (sizeof(protocols) / sizeof(protocols[0])); ++p) { + if (mode == protocols[p].mode) { + return protocols[p].name; + } + } + return def; +} + + /* Function: key_check - * Utility used whilst assembling a keystroke to test whether a - * full key sequence has been encountered. Return key code if we - * have an unambiguous keystroke. + * Utility used whilst assembling a keystroke to test whether a full key sequence has been encountered. + * Return key code if we have an unambiguous keystroke. * - * If we have an ambiguity, check for a multikey press, and set - * multi_key if so. This way we can force the caller to wait - * until the ambiguity is resolved. + * If we have an ambiguity, check for a multikey press, and set 'multi' if so. + * When multi implies the caller should wait until the ambiguity is resolved. * * Parameters: - * sbuf - Key buffer. - * multi_key - Multiple key flag storage. + * buf - Key buffer; nul terminated. + * buflen - Buffer length, in bytes; excluding nul. + * multi - Multiple key flag storage. * noambig - Ambiguity flag. * * Results: * Key code, otherwise -1. */ int -key_check(const KEY *sbuf, int *multi_key, int noambig) +key_check(const char *buf, unsigned buflen, int *multi, int noambig) { - char buf[128], *cp; /* MAGIC */ +#if defined(USE_KBPROTOCOL) + const char* end = buf + (buflen - 1); +#endif SPBLK *sp_first, *sp; - int klen, kcode, ambig = 0; + int kcode, ambig = 0; - *multi_key = FALSE; + *multi = FALSE; +#if defined(USE_KBPROTOCOL) /* - * Import key, 16bit to 8bit conversion + * cygwin: + * {0;1;13;28;13;0K */ - for (cp = buf, klen = 0; *sbuf; ++klen) { - *cp++ = (char) *sbuf++; + if (xf_kbprotocol & KBPROTOCOL_CYGWIN) { + if ('\033' == buf[0] && '{' == buf[1]) { + const int isfinal = (buflen >= 4 && (*end == 'K')); + + if (! isfinal) { + *multi = TRUE; + return -1; + } + kcode = cygwin_to_int(buf); /* cygwin-raw-mode */ + return (-1 == kcode ? 0 : kcode); + } } - *cp = 0; +#endif //USE_KBPROTOCOL - assert(cp < buf + sizeof(buf)); + trace_log("KEYSEQ="); + trace_hex(buf, buflen); - /* - * Cook cygwin raw keyboard mode which reports the native WIN32 scancode, for example - * - * {0;1;13;28;13;0K - */ -#if defined(__CYGWIN__) - if ('\033' == buf[0] && '{' == buf[1]) { /* RAW MODE */ - extern int xf_cygwinkdb; + if (NULL == (sp = sp_partial_lookup(buf, x_kseqtree, &ambig, &sp_first))) { + /* + * Keyboard protocols + */ +#if defined(USE_KBPROTOCOL) +#if defined(KBPROTOCOL_MSTERMINAL) +#define KBPROTOCOL_1 KBPROTOCOL_MSTERMINAL +#else +#define KBPROTOCOL_1 0 +#endif +#if defined(KBPROTOCOL_KITTY) +#define KBPROTOCOL_2 KBPROTOCOL_KITTY +#else +#define KBPROTOCOL_2 0 +#endif + if (xf_kbprotocol & (KBPROTOCOL_MOK2|KBPROTOCOL_1|KBPROTOCOL_2)) { + if ('\033' == buf[0] && '[' == buf[1]) { // CSI + const int isfinal = + (buflen >= 4 && (*end >= 0x40 && *end < 0x80)); // SGR final + + if (! isfinal) { + *multi = TRUE; + return -1; + } - if (xf_cygwinkb) { - *multi_key = TRUE; - if (klen < 10 || 'K' != buf[klen-1]) { /* incomplete */ - return -1; + if ('_' == *end) { /* win32-input-mode */ +#if defined(KBPROTOCOL_MSTERMINAL) + kcode = msterminal_to_int(buf); + return (-1 == kcode ? 0 : kcode); +#endif + } else if ('~' == *end || 'u' == *end) { /* xterm-mok2/mintty-mok2 or kitty-protocol */ +#if defined(KBPROTOCOL_KITTY) + if (xf_kbprotocol & (KBPROTOCOL_KITTY)) { + if ((kcode = kitty_to_key(buf, buflen)) > 0) { + return kcode; + } + } +#endif + if (xf_kbprotocol & (KBPROTOCOL_MOK2)) { + if ((kcode = mok2_to_key(buf, buflen)) > 0) { + return kcode; + } + } + + } else { /* others */ + if ((kcode = xterm_to_key(buf, buflen)) > 0) { + return kcode; + } + } } - kcode = cygwin_to_int(buf); - return (-1 == kcode ? 0 : kcode); } - } -#endif /*__CYGWIN__*/ - - trace_log("KEYSEQ="); - trace_hex(buf, klen); +#endif //USE_KBPROTOCOL - if (NULL == (sp = sp_partial_lookup(buf, x_kseqtree, &ambig, &sp_first))) { if (sp_first) { const keyseq_t *kst = (const keyseq_t *) sp_first->data; if (IS_MULTIKEY(kst->ks_code)) { - *multi_key = TRUE; + *multi = TRUE; } } + trace_log("keycode: %d\n", ambig ? -1 : 0); return (ambig ? -1 : 0); } @@ -2586,12 +2855,203 @@ key_check(const KEY *sbuf, int *multi_key, int noambig) } +#if defined(USE_KBPROTOCOL) +/* Function: mok2_to_key + * Decode a xterm modifyOtherKeys into our internal key-code. + * + * Parameters: + * buf - Escape sequence buffer. + * buflen - Buffer length in bytes. + * + * Results: + * nothing + */ +static int +mok2_to_key(const char *buf, unsigned buflen) +{ + unsigned args[4] = {0, 0, 0, 0}, nargs = 0; + char params[3] = {0}; + + /* + * xterm-mok2/mintty-mok2: + * \e[27;;~ or xterm + * \e[;u formatOtherKeys=1 in xterm; which is the mintty default. + * + * https://invisible-island.net/xterm/modified-keys-gb-altgr-intl.html#other_modifiable_keycodes + * + * plus: + * + * \e[; ~ Edit, cursor and function keys. + */ + if (tty_csi_parse(buf, buflen, 4, args, params, &nargs)) { + unsigned key = + ((params[0] == '~' && 3 == nargs && args[0] == 27) ? args[2] + : ((params[0] == 'u' && 2 == nargs) ? args[0] : 0)); + + if (key) { + unsigned modifiers = xterm_modifiers(args[1]); + int kcode; + + if (key == KEY_TAB) { /* XXX - consider remapping */ + if (modifiers & MOD_SHIFT) { + key = BACK_TAB; + } else if (modifiers & MOD_CTRL) { + key = CTRL_TAB; + } else if (modifiers & MOD_META) { + key = ALT_TAB; + } + modifiers = 0; + + } else if (key == KEY_DELETE) { /* XXX - consider remapping */ + if (modifiers & MOD_SHIFT) { + key = SHIFT_BACKSPACE; + } else if (modifiers & MOD_CTRL) { + key = CTRL_BACKSPACE; + } else if (modifiers & MOD_META) { + key = ALT_BACKSPACE; + } + modifiers = 0; + + } else if (key >= 'a' && key <= 'z') { + if (modifiers) { /* upper-case, apply shift */ + modifiers &= ~MOD_SHIFT; + key += (unsigned)('A' - 'a'); + } + + } else if (key >= ' ') { + modifiers &= ~MOD_SHIFT; + + } else { + switch (key) { // ^[[#;m~ + // case 0: n/a + case 1: key = KEY_SEARCH; break; + case 2: key = KEY_INS; break; + case 3: key = KEY_DELETE; break; + // case 4: n/a + case 5: key = KEY_PAGEUP; break; + case 6: key = KEY_PAGEDOWN; break; + case 7: key = KEY_HOME; break; + case 8: key = KEY_END; break; + // case 9: KEY_TAB + // case 10: n/a + // case 11: n/a + // case 12: n/a + // case 13: KEY_ENTER + // case 14: n/a + case 15: key = F(5); break; + // case 16; n/a + case 17: key = F(6); break; + case 18: key = F(7); break; + case 19: key = F(8); break; + case 20: key = F(9); break; + case 21: key = F(10); break; + // case 22: n/a + case 23: key = F(11); break; + case 24: key = F(12); break; + // case 25: n/a + // case 26: n/a + // case 27: KEY_ESCAPE + } + } + + kcode = (int)(modifiers | key); + trace_log("keycode-mok2: %d\n", kcode); + return kcode; + } + } + return -1; +} +#endif //USE_KBPROTOCOL + + +#if defined(USE_KBPROTOCOL) +static int +xterm_to_key(const char *buf, unsigned buflen) +{ + unsigned args[4] = {1,0,0,0}, nargs = 0; + char params[3] = {0}; + + /* + * CSI 1;m{ABCDFHPQRS} {MXjklmnopqrstuvwxy} + */ + if (tty_csi_parse(buf, buflen, 4, args, params, &nargs)) { + if (2 == nargs && args[0] == 1) { + const unsigned modifiers = xterm_modifiers(args[1]); + int key = 0; + + switch (params[0]) { + case 'A': key = KEY_UP; break; // ^[[1;mA + case 'B': key = KEY_DOWN; break; // ^[[1;mB + case 'D': key = KEY_LEFT; break; // ^[[1;mD + case 'C': key = KEY_RIGHT; break; // ^[[1;mC + case 'F': key = KEY_END; break; // ^[[1;mF + case 'H': key = KEY_HOME; break; // ^[[1;mH + case 'P': key = F(1); break; // ^[[1;mP + case 'Q': key = F(2); break; // ^[[1;mQ + case 'R': key = F(3); break; // ^[[1;mR + case 'S': key = F(4); break; // ^[[1;mS + + case 'M': key = KEYPAD_ENTER; break; // ^[[1;mM, Enter + case 'X': key = KEYPAD_EQUAL; break; // ^[[1;mX, '=' + case 'j': key = KEYPAD_STAR; break; // ^[[1;mj, '*' + case 'k': key = KEYPAD_PLUS; break; // ^[[1;mk, '+' + case 'l': key = ','; break; // ^[[1;ml, ',' + case 'm': key = KEYPAD_MINUS; break; // ^[[1;mm, '-' + case 'n': key = KEYPAD_DEL; break; // ^[[1;mn, '.' + case 'o': key = KEYPAD_DIV; break; // ^[[1;mo, '/' + case 'p': key = KEYPAD_0; break; // ^[[1;mp, '0' + case 'q': key = KEYPAD_1; break; // ^[[1;mq, '1' + case 'r': key = KEYPAD_2; break; // ^[[1;mr, '2' + case 's': key = KEYPAD_3; break; // ^[[1;ms, '3' + case 't': key = KEYPAD_4; break; // ^[[1;mt, '4' + case 'u': key = KEYPAD_5; break; // ^[[1;mu, '5' + case 'v': key = KEYPAD_6; break; // ^[[1;mv, '6' + case 'w': key = KEYPAD_7; break; // ^[[1;mw, '7' + case 'x': key = KEYPAD_8; break; // ^[[1;mx, '8' + case 'y': key = KEYPAD_9; break; // ^[[1;my, '9' + + default: + break; + } + + if (key) { + int kcode = (int)(modifiers | key); + trace_log("keycode-xt: %d\n", kcode); + return kcode; + } + } + } + return -1; +} +#endif //USE_KBPROTOCOL + + +#if defined(USE_KBPROTOCOL) +static unsigned +xterm_modifiers(unsigned mods) +{ + unsigned code = mods - 1, modifiers = 0; + + if (code & 1) + modifiers |= MOD_SHIFT; + if (code & 2) + modifiers |= MOD_META; //ALT + if (code & 4) + modifiers |= MOD_CTRL; + if (code & 8) + modifiers |= MOD_META; + //generally consumed by system, for example WINKEY/mintty. + return modifiers; +} +#endif //USE_KBPROTOCOL + + +#if defined(USE_KBPROTOCOL) /* Function: cygwin_to_int - * Decode a cygwin specific key escape sequence into - * our internal key-code. + * Decode a cygwin specific key escape sequence into our internal key-code. * * Parameters: - * buf - Escape sequnence buffer. + * buf - Escape sequence buffer. * * Results: * nothing @@ -2599,32 +3059,156 @@ key_check(const KEY *sbuf, int *multi_key, int noambig) static int cygwin_to_int(const char *buf) { -#if defined(WIN32) || defined(__CYGWIN__) - if (buf[0] == '\033' && buf[1] == '{') { /* RAW MODE */ - unsigned bKeyDown, wRepeatCount; - unsigned wVirtKeyCode, wVirtScanCode, Unicode; - unsigned dwCtrlState; - - /* Example: +#if defined(WIN32) || defined(__CYGWIN__) /* cygwin-raw-mode */ + if (buf[0] == '\033' && buf[1] == '{') { + /* + * \033[2000h - turn on raw keyboard mode, + * \033[2000l - turn off raw keyboard mode. + * + * Format: + * {Kd;Rc;Vk;Sc;Uc;CsK + * + * Kd: the value of bKeyDown. + * Rc: the value of wRepeatCount. + * Vk: the value of wVirtualKeyCode. + * Sc: the value of wVirtualScanCode. + * Uc: the decimal value of UnicodeChar. + * Cs: the value of dwControlKeyState. + * + * Example: * {0;1;13;28;13;0K + * */ - if (6 == sscanf(buf + 2, "%u;%u;%u;%u;%u;%uK", &bKeyDown, &wRepeatCount, - &wVirtKeyCode, &wVirtScanCode, &Unicode, &dwCtrlState)) { + unsigned bKeyDown, wRepeatCount; + unsigned wVirtKeyCode, wVirtScanCode, UnicodeChar; + unsigned dwControlKeyState; + + if (6 == sscanf(buf + 2, "%u;%u;%u;%u;%u;%uK", + &bKeyDown, &wRepeatCount, &wVirtKeyCode, &wVirtScanCode, &UnicodeChar, &dwControlKeyState)) { if (bKeyDown) { - const int w32key = key_mapwin32(dwCtrlState, wVirtKeyCode, Unicode); + const int w32key = + key_mapwin32(dwControlKeyState, wVirtKeyCode, UnicodeChar); + + trace_log("cygkey[%s]=%d/0x%x\n", buf + 2, w32key, w32key); + return w32key; + } + trace_log("cygkey[%s]=up\n", buf + 2); + return KEY_VOID; + } + } +#else + __CUNUSED(buf) +#endif + return -1; +} +#endif //USE_KBPROTOCOL + + +#if defined(USE_KBPROTOCOL) +/* Function: msterminal_to_int + * Decode a MSTerminal specific key escape sequence into our internal key-code. + * + * Parameters: + * buf - Escape sequnence buffer. + * + * Results: + * nothing + */ + +enum { + msVirtualKeyCode, + msVirtualScanCode, + msUnicodeChar, + msKeyDown, + msControlKeyState, + msRepeatCount, + msgArgumentMax +}; + + +static int +msterminal_args(const char *buffer, unsigned arguments[]) +{ + const char *cursor = buffer + 2, *value = NULL; + unsigned args = 0; + + while (*cursor) { + const unsigned char c = *cursor++; + + if (c >= '0' && c <= '9') { + if (NULL == value) { + value = cursor - 1; // value + } + + } else if (c == ';' || c == '_') { + if (args >= msgArgumentMax) { + args = 0; // overflow + break; + } + + if (value) { + arguments[args] = (unsigned)strtoul((const char *)value, NULL, 10); + value = NULL; + } + ++args; + if (c == '_') { + break; // terminator + } - trace_log("cygwin32[%s]=%d/0x%x\n", buf + 2, w32key, w32key); + } else { + args = 0; // non-digit + break; + } + } + return (args >= 1); +} + +static int +msterminal_to_int(const char *buf) +{ +#if defined(WIN32) || defined(__CYGWIN__) /* win32-input-mode */ + if (buf[0] == '\033' && buf[1] == '[') { + /* + * Terminal win32-input-mode + * + * [17;29;0;1;8;1_ + * + * Format: + * + * [Vk;Sc;Uc;Kd;Cs;Rc_ + * + * Vk: the value of wVirtualKeyCode - any number. If omitted, defaults to '0'. + * Sc: the value of wVirtualScanCode - any number. If omitted, defaults to '0'. + * Uc: the decimal value of UnicodeChar - for example, NUL is "0", LF is + * "10", the character 'A' is "65". If omitted, defaults to '0'. + * Kd: the value of bKeyDown - either a '0' or '1'. If omitted, defaults to '0'. + * Cs: the value of dwControlKeyState - any number. If omitted, defaults to '0'. + * Rc: the value of wRepeatCount - any number. If omitted, defaults to '1'. + * + * Reference + * https://github.com/microsoft/terminal/blob/main/doc/specs/%234999%20-%20Improved%20keyboard%20handling%20in%20Conpty.md + */ + unsigned args[msgArgumentMax] = { 0, 0, 0, 0, 0, 1 }; + + if (msterminal_args(buf, args)) { + if (args[msKeyDown]) { + const int w32key = + key_mapwin32(args[msControlKeyState], args[msVirtualKeyCode], args[msUnicodeChar]); + + trace_log("winkey[%s]=0x%x/%u\n", buf + 2, w32key, w32key); return w32key; } - trace_log("cygwin32[%s]=up\n", buf + 2); + trace_log("winkey[%s]=up\n", buf + 2); return KEY_VOID; } + trace_log("winkey[%s]=na\n", buf + 2); } #else __CUNUSED(buf) #endif return -1; } +#endif //USE_KBPROTOCOL #if defined(WIN32) || defined(__CYGWIN__) @@ -2694,10 +3278,12 @@ key_mapwin32(unsigned dwCtrlKeyState, unsigned wVirtKeyCode, unsigned CharCode) } } - trace_log("W32KEY %c%c%c = %d/0x%x (%s=%s)\n", - (mod & MOD_META ? 'M' : '.'), (mod & MOD_CTRL ? 'C' : '.'), (mod & MOD_SHIFT ? 'S' : '.'), - ch, ch, (ch == -1 ? "n/a" : (key >= w32Keys ? key->desc : "ASCII")), key_code2name(ch)); - return (ch); + if (ch != -1) { + trace_log("W32KEY %c%c%c = %d/0x%x (%s=%s)\n", + (mod & MOD_META ? 'M' : '.'), (mod & MOD_CTRL ? 'C' : '.'), (mod & MOD_SHIFT ? 'S' : '.'), + ch, ch, (key >= w32Keys ? key->desc : "ASCII"), key_code2name(ch)); + } + return ch; } #endif /*WIN32 || __CYGWIN__*/ @@ -3480,3 +4066,5 @@ inq_kbd_name(void) /* string ([int kbdid]) */ } /*end*/ + + diff --git a/gr/keyboard.h b/gr/keyboard.h index 42df01c3..cb928c52 100644 --- a/gr/keyboard.h +++ b/gr/keyboard.h @@ -1,11 +1,11 @@ #ifndef GR_KEYBOARD_H_INCLUDED #define GR_KEYBOARD_H_INCLUDED #include -__CIDENT_RCSID(gr_keyboard_h,"$Id: keyboard.h,v 1.24 2024/04/14 16:03:45 cvsuser Exp $") +__CIDENT_RCSID(gr_keyboard_h,"$Id: keyboard.h,v 1.28 2024/09/25 15:51:54 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: keyboard.h,v 1.24 2024/04/14 16:03:45 cvsuser Exp $ +/* $Id: keyboard.h,v 1.28 2024/09/25 15:51:54 cvsuser Exp $ * Key maps and binding management. * * @@ -29,11 +29,30 @@ struct IOEvent; #define MAX_KEYBUF 64 /* key description buffer length. */ -typedef struct keyseq_t { - KEY ks_code; /* internal keycode */ - char ks_buf[1]; /* array of characters null terminated */ +#define KBPROTOCOL_NONE 0 +#define KBPROTOCOL_AUTO 0x0001 /* Auto select, based on terminal type */ +#define KBPROTOCOL_META 0x0002 /* Meta- only */ +#define KBPROTOCOL_FEATURE 0x0004 /* Terminal feature overrides -- internal only */ +#define KBPROTOCOL_VT100_CURSOR 0x0008 +#define KBPROTOCOL_XTERM_MOK2 0x0010 +#define KBPROTOCOL_MINTTY_MOK2 0x0020 +#define KBPROTOCOL_MOK2 (KBPROTOCOL_XTERM_MOK2|KBPROTOCOL_MINTTY_MOK2) +#define KBPROTOCOL_CYGWIN 0x0100 +// #define KBPROTOCOL_MSTERMINAL 0x0200 +/// #define KBPROTOCOL_KITTY 0x0400 + +typedef struct keyseq { + KEY ks_code; /* internal keycode */ + char ks_buf[1]; /* array of characters null terminated */ } keyseq_t; +typedef struct mouseevt { + const char* seq; + int x, y; + int win; + int where; +} mouseevt_t; + extern void key_init(void); extern void key_shutdown(void); extern void key_typeables(void); @@ -46,13 +65,16 @@ extern const char * key_code2name(int key); extern int key_name2code(const char *name, int *lenp); extern void key_cache_key(ref_t *pp, int ch, int front); -extern void key_cache_mouse(ref_t *pp, int ch, int front, int x, int y, int win, int where); +extern void key_cache_mouse(ref_t *pp, int ch, int front, const mouseevt_t *evt); extern int key_cache_test(ref_t *pp); extern int key_cache_pop(ref_t *pp, struct IOEvent *evt); -extern void key_execute(int c); +extern void key_execute(int c, const char *seq); + +extern int key_protocolid(const char *name, int namelen); +extern const char * key_protocolname(int mode, const char *def); -extern int key_check(const KEY *sbuf, int *multi_key, int no_ambig); +extern int key_check(const char *buf, unsigned buflen, int *multi, int no_ambig); extern int key_mapwin32(unsigned, unsigned, unsigned); extern void key_local_detach(BUFFER_t *bp); @@ -84,3 +106,4 @@ extern int32_t x_character; /* Current character typed. */ __CEND_DECLS #endif /*GR_KEYBOARD_H_INCLUDED*/ + diff --git a/gr/keywd.c b/gr/keywd.c index c6ffbd13..084f5eee 100644 --- a/gr/keywd.c +++ b/gr/keywd.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_keywd_c,"$Id: keywd.c,v 1.103 2024/05/11 16:38:28 cvsuser Exp $") +__CIDENT_RCSID(gr_keywd_c,"$Id: keywd.c,v 1.111 2024/09/08 16:29:24 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: keywd.c,v 1.103 2024/05/11 16:38:28 cvsuser Exp $ +/* $Id: keywd.c,v 1.111 2024/09/08 16:29:24 cvsuser Exp $ * Keyword table. * * @@ -121,9 +121,10 @@ const int cm_version = CM_VERSION; #define VERSION_205 /* 01/04/2020, register(), __lexicalblock(), isclose() and cast_xxx() */ #define VERSION_206 /* 06/21, UTF8 */ #define VERSION_207 /* 07/22, syntax_find() */ +#define VERSION_208 /* 07/24, inq_syntax_name(), splitpath() */ -// #define VERSION_XX1 /* array's, staged/experimental */ -// #define VERSION_XX2 /* not implemented/alpha */ +// #define VERSION_XX1 /* array's, staged/experimental */ +// #define VERSION_XX2 /* not implemented/alpha */ /* * Keyword table, assumed to be in alphabetic order. @@ -548,7 +549,7 @@ BUILTIN builtin[] = { 2, {ARG_OPT | ARG_INT, ARG_OPT | ARG_INT}}, {"dialog_run", MACRO(do_dialog_run), ARG_INT, 0, 0, /* dialog */ - 1, {ARG_INT}}, + 3, {ARG_INT, ARG_OPT | ARG_INT, ARG_OPT | ARG_INT}}, #if defined(VERSION_204) {"dict_clear", MACRO(do_dict_clear), ARG_INT, 0, 0, /* macro */ @@ -1318,6 +1319,11 @@ BUILTIN builtin[] = { {"inq_syntax", MACRO(inq_syntax), ARG_INT, 0, 0, /* syntax */ 2, {ARG_OPT | ARG_LVAL | ARG_INT, ARG_OPT | ARG_INT | ARG_STRING}}, +#if defined(VERSION_208) + {"inq_syntax_name", MACRO(inq_syntax_name), ARG_STRING, 0, 0, /* syntax */ + 1, {ARG_OPT | ARG_INT}}, +#endif + {"inq_system", MACRO(inq_system), ARG_INT, 0, 0, /* buffer */ 1, {ARG_OPT | ARG_INT}}, @@ -1351,7 +1357,7 @@ BUILTIN builtin[] = { {"inq_username", MACRO(inq_username), ARG_STRING, 0, 0, /* env */ 0, {0}}, - + {"inq_vfs_mounts", MACRO(inq_vfs_mounts), ARG_LIST, 0, 0, /* file */ 0, {0}}, @@ -2143,11 +2149,20 @@ BUILTIN builtin[] = { -4, {ARG_LVAL | ARG_LIST, ARG_INT, ARG_OPT | ARG_INT, ARG_OPT | ARG_ANY}}, {"split", MACRO(do_split), ARG_LIST, 0, 0, /* string */ - 5, {ARG_STRING, ARG_INT | ARG_STRING, ARG_OPT | ARG_INT, ARG_OPT | ARG_INT, ARG_OPT | ARG_INT}}, + 6, {ARG_STRING, ARG_INT | ARG_STRING, ARG_OPT | ARG_INT, ARG_OPT | ARG_INT, ARG_OPT | ARG_INT, ARG_OPT | ARG_INT}}, {"split_arguments", MACRO(do_split_arguments), ARG_LIST, 0, 0, /* string */ 1, {ARG_OPT | ARG_STRING}}, +#if defined(VERSION_208) + { "splitpath", MACRO(do_splitpath), ARG_VOID, 0, 0, /* file */ + 5, {ARG_STRING, + ARG_OPT | ARG_LVAL | ARG_STRING, + ARG_OPT | ARG_LVAL | ARG_STRING, + ARG_OPT | ARG_LVAL | ARG_STRING, + ARG_OPT | ARG_LVAL | ARG_STRING}}, +#endif + {"sprintf", MACRO(do_sprintf), ARG_INT, 0, 0, /* string */ -3, {ARG_LVAL | ARG_STRING, ARG_STRING, @@ -2542,10 +2557,10 @@ builtin_init(void) bp->b_flags |= B_VARARGS; } -#if !defined(NDEBUG) +#if !defined(NDEBUG) { const int argc = bp->b_arg_count; int iarg; - + assert(argc <= MAX_BUILTIN_ARGS); for (iarg = 0; iarg < argc; ++iarg) { assert(bp->b_arg_types[iarg]); @@ -2593,3 +2608,4 @@ builtin_index(const char *str) } /*end*/ + diff --git a/gr/lisp.c b/gr/lisp.c index e434e730..66d61c6c 100644 --- a/gr/lisp.c +++ b/gr/lisp.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_lisp_c,"$Id: lisp.c,v 1.46 2022/05/26 16:36:12 cvsuser Exp $") +__CIDENT_RCSID(gr_lisp_c,"$Id: lisp.c,v 1.48 2024/07/25 15:38:40 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: lisp.c,v 1.46 2022/05/26 16:36:12 cvsuser Exp $ +/* $Id: lisp.c,v 1.48 2024/07/25 15:38:40 cvsuser Exp $ * List primitives. * * @@ -2394,6 +2394,9 @@ do_length_of_list(void) /* int (list expr) */ polymorphic expression and tests whether the specified 'symbol' has of a NULL type. + Beware that the is_type collection of functions wont behave when + given list elements, as these are not referenceable l-values. + Macro Parameters: symbol - Symbol reference. @@ -2417,6 +2420,9 @@ do_length_of_list(void) /* int (list expr) */ expression and tests whether the specified 'symbol' has of a string type. + Beware that the is_type collection of functions wont behave when + given list elements, as these are not referenceable l-values. + Macro Parameters: symbol - Symbol reference. @@ -2440,6 +2446,9 @@ do_length_of_list(void) /* int (list expr) */ polymorphic expression and tests whether the specified 'symbol' has of a array type. + Beware that the is_type collection of functions wont behave when + given list elements, as these are not referenceable l-values. + Macro Parameters: symbol - Symbol reference. @@ -2463,6 +2472,9 @@ do_length_of_list(void) /* int (list expr) */ expression and tests whether the specified 'symbol' is of the type 'type'. + Beware that the is_type collection of functions wont behave when + given list elements, as these are not referenceable l-values. + Macro Parameters: symbol - Symbol reference. @@ -2574,6 +2586,10 @@ do_is_type(int type) /* int (declare symbol, [int | string type]) */ } else { ret = (sp->s_type == type); /* symbol type */ } + } else { + if (F_NULL == type) { + ret = 1; + } } acc_assign_int(ret ? 1 : 0); } @@ -2643,7 +2659,7 @@ do_typeof(void) /* (declare symbol) */ } else if (isa_list(1)) { acc_assign_str("list", 4); - } else if (TRUE == isa_null(1)) { + } else if (TRUE == isa_null(1) || NULL == get_symbol(1)) { acc_assign_str("NULL", 4); } else if (isa_undef(1)) { diff --git a/gr/m_brief.c b/gr/m_brief.c index f303e659..32b301b4 100644 --- a/gr/m_brief.c +++ b/gr/m_brief.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_m_brief_c,"$Id: m_brief.c,v 1.9 2022/07/10 13:13:07 cvsuser Exp $") +__CIDENT_RCSID(gr_m_brief_c,"$Id: m_brief.c,v 1.10 2024/08/18 10:50:14 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: m_brief.c,v 1.9 2022/07/10 13:13:07 cvsuser Exp $ +/* $Id: m_brief.c,v 1.10 2024/08/18 10:50:14 cvsuser Exp $ * BRIEF compatibility. * * @@ -31,7 +31,7 @@ __CIDENT_RCSID(gr_m_brief_c,"$Id: m_brief.c,v 1.9 2022/07/10 13:13:07 cvsuser Ex /*<> Macro: inq_brief_level - Retrieve the editor nesting level. - int + int inq_brief_level() Macro Description: @@ -70,18 +70,64 @@ inq_brief_level(void) /*<> Macro: set_mouse_action - Set keyboard mouse handler. - int - set_mouse_action(string name) + int + set_mouse_action(string mouse_handler) Macro Description: The 'set_mouse_button()' primitive is reserved for future BRIEF compatibility. - The 'set_mouse_action()' primitive sets the name of the mouse - action handler within the current keyboard. + The 'set_mouse_action()' primitive sets the function mouse_handler + as the mouse action handler within the current keyboard. + +> void +> mouse_handler( +> int event, // event code; see below +> int modifier, // modifier keys +> int parm2, // either line or scrollbar position +> int parm3 // either colume or thrumb position +> ) +> { +> switch(event) { +> case BTN1_MOVE: +> break; +> case BTN2_MOVE: +> break; +> case BTN3_MOVE: +> break; +> +> case BTN1_DOWN: +> break; +> case BTN2_DOWN: +> break; +> case BTN3_DOWN: +> break; +> +> case BTN1_UP: +> break; +> case BTN2_UP: +> break; +> case BTN3_UP: +> break; +> +> case BTN1_CLICK: +> break; +> case BTN2_CLICK: +> break; +> case BTN3_CLICK: +> break; +> +> case BTN1_DBLCLK: +> break; +> case BTN2_DBLCLK: +> break; +> case BTN3_DBLCLK: +> break; +> } +> } Macro Parameters: - name - A string containing the name of the function to be + mouse_handler - A string containing the name of the function to be associated with the current keyboard. Macro Returns: @@ -138,7 +184,7 @@ inq_mouse_action(void) /* string () */ /*<> Macro: set_mouse_type - Sets the mouse type. - int + int set_mouse_type() Macro Description: @@ -148,7 +194,7 @@ inq_mouse_action(void) /* string () */ type - Integer stating the current mouse type. (start table,format=nd) - [Value [Description ] + [Value [Description ] ! 0 No mouse. ! 1 One-button mouse. ! 2 Two-button mouse. @@ -180,7 +226,7 @@ do_set_mouse_type(void) /* void ([int type], [int button1]) */ /*<> Macro: inq_mouse_type - Retrieve the button type. - int + int inq_mouse_type() Macro Description: @@ -193,7 +239,7 @@ do_set_mouse_type(void) /* void ([int type], [int button1]) */ Returns the current mouse type. (start table,format=nd) - [Value [Description ] + [Value [Description ] ! 0 No mouse. ! 1 One-button mouse. ! 2 Two-button mouse. @@ -217,7 +263,7 @@ inq_mouse_type(void) /* int () */ /*<> Macro: inq_btn2_action - Retrieve the second button action. - int + int inq_btn2_action() Macro Description: @@ -250,7 +296,7 @@ inq_btn2_action(void) /* string () */ /*<> Macro: set_btn2_action - Set the second button action. - int + int set_btn2_action([int action]) Macro Description: @@ -282,7 +328,7 @@ do_set_btn2_action(void) /* int ([int action]) */ /*<> [env] Macro: inq_environment - Retrieve an environment variable. - string + string inq_environment(string name) Macro Description: @@ -347,11 +393,11 @@ do_set_btn2_action(void) /* int ([int action]) */ /*<> [proc] Macro: dos - Create a sub-shell. - int + int dos([string cmd], [int use_shell], [string callback]) Macro Description: - The 'dos()' primitive executes the specified command 'cmd', + The 'dos()' primitive executes the specified command 'cmd', if omitted starts an interactive command shell. This function is provided for compatibility using the @@ -367,7 +413,7 @@ do_set_btn2_action(void) /* int ([int action]) */ callback - Optional string containing the name of a macro to be executed on the completion of the task. If stated the - command is intended to run as a background task, + command is intended to run as a background task, otherwise in the foreground. Macro Returns: @@ -419,3 +465,6 @@ do_set_btn2_action(void) /* int ([int action]) */ // } /*end*/ + + + diff --git a/gr/m_color.c b/gr/m_color.c index 28209999..66f12464 100644 --- a/gr/m_color.c +++ b/gr/m_color.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_m_color_c,"$Id: m_color.c,v 1.47 2024/05/20 16:32:42 cvsuser Exp $") +__CIDENT_RCSID(gr_m_color_c,"$Id: m_color.c,v 1.50 2024/07/11 10:20:05 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: m_color.c,v 1.47 2024/05/20 16:32:42 cvsuser Exp $ +/* $Id: m_color.c,v 1.50 2024/07/11 10:20:05 cvsuser Exp $ * Color configuration. * * @@ -80,7 +80,7 @@ typedef struct { } colors_t; -static int set_color(colors_t *colors, const char *spec, int create, int ident); +static int set_color(colors_t *colors, const char *spec, int create, accint_t *ident); static colors_t * col_working(void); static colors_t * col_reworked(void); @@ -240,6 +240,7 @@ static const struct attribute attributes_default[] = { { _A1("hilite"), COL_HILITE_BACKGROUND, CA_BG|CA_FULL, ATTR_HILITE, 0 }, { _A1("hilite_fg"), COL_HILITE_FOREGROUND, CA_FG, -1, 0 }, { _A1("frame"), COL_BORDERS, CA_FG, ATTR_FRAME, 0 }, +// { _A1("vframe"), COL_VFRAME, CA_FG, ATTR_FRAME, 0 }, { _A1("cursor_insert"), COL_INSERT_CURSOR, CA_FG, ATTR_CURSOR_INSERT, 0 }, { _A1("cursor_overtype"), COL_OVERTYPE_CURSOR, CA_FG, ATTR_CURSOR_OVERTYPE, 0 }, @@ -342,6 +343,7 @@ static const struct attribute attributes_default[] = { // TODO - ansi mode, 'underlined' text { _A1("spell"), -1, CA_ATTR, ATTR_SPELL, ATTR_STANDOUT }, +// { _A1("spell_caps"), -1, CA_ATTR, ATTR_SPELL_CAPS, ATTR_SPELL }, // { _A1("spell_local"), -1, CA_ATTR, ATTR_SPELL_LOCAL, ATTR_SPELL }, // { _A1("spell_special"), -1, CA_ATTR, ATTR_SPELL_SPECIAL, ATTR_SPELL }, // TODO - additional special attritbutes @@ -1298,11 +1300,8 @@ do_set_color(void) /* ([list|string], [int create = TRUE]) */ } if (listv_str(&result, &spec)) { /* color specification */ - if (ident < COL_MAX) { - if (set_color(colors, spec, create, ident)) { - ++count; - } - ++ident; + if (set_color(colors, spec, create, &ident)) { + ++count; } } else { /* index specification */ @@ -1326,7 +1325,7 @@ do_set_color(void) /* ([list|string], [int create = TRUE]) */ if (len > 0 && len < (int)sizeof(buf)) { memcpy(buf, spec, len); buf[len] = 0; - if (set_color(colors, buf, create, -1)) { + if (set_color(colors, buf, create, NULL)) { ++count; } } @@ -1335,13 +1334,13 @@ do_set_color(void) /* ([list|string], [int create = TRUE]) */ } while (NULL != (nl = strchr(spec, '\n'))); if (*spec) { /* .. last */ - if (set_color(colors, spec, create, -1)) { + if (set_color(colors, spec, create, NULL)) { ++count; } } } else { /* single */ - if (set_color(colors, spec, create, -1)) { + if (set_color(colors, spec, create, NULL)) { ++count; } } @@ -1534,7 +1533,7 @@ color_setscheme(const char *scheme) int isdark = FALSE; trace_ilog("color_setscheme=%s\n", scheme); - if (0 == str_icmp(scheme, "l") || 0 == str_icmp(scheme, "light") || 0 == str_icmp(scheme, "lite")) { + if (0 == str_icmp(scheme, "l") || 0 == str_icmp(scheme, "light")) { colorspec = x_col_table_light; } else if (0 == str_icmp(scheme, "d") || 0 == str_icmp(scheme, "dark")) { @@ -1547,11 +1546,11 @@ color_setscheme(const char *scheme) unsigned i; for (i = 0; colorspec[i]; ++i) { - set_color(colors, colorspec[i], FALSE, -1); + set_color(colors, colorspec[i], FALSE, NULL); } for (i = 0; x_col_windows[i]; ++i) { - set_color(colors, x_col_windows[i], FALSE, -1); + set_color(colors, x_col_windows[i], FALSE, NULL); } col_apply(colors); @@ -1604,7 +1603,7 @@ color_setscheme(const char *scheme) * *true* otherwise *false*. */ static int -set_color(colors_t *colors, const char *spec, int create, int ident) +set_color(colors_t *colors, const char *spec, int create, accint_t *ident) { static const char who[] = "set_color"; struct attribute *ap = NULL; @@ -1612,7 +1611,8 @@ set_color(colors_t *colors, const char *spec, int create, int ident) colattr_t ca = COLATTR_INIT; int ret = -1; - trace_ilog("set_color\n", spec, create, ident); + trace_ilog("set_color\n", + spec, create, (int)(ident ? *ident : -1)); if (NULL == (eq = strchr(spec, '='))) { /* @@ -1620,11 +1620,15 @@ set_color(colors_t *colors, const char *spec, int create, int ident) * * foreground [,background] [:style] */ - if (ident < 0) { + if (NULL == ident) { errorf("%s: attribute missing", who); } else { - if (NULL == (ap = attr_byenum(colors, ident))) { - errorf("%s: unknown attribute ident '%d'", who, ident); + const int nident = *ident++; // next identifier + + if (nident >= COL_MAX) { + errorf("%s: attribute ident unexpected '%d'", who, nident); + } else if (NULL == (ap = attr_byenum(colors, nident))) { + errorf("%s: unknown attribute ident '%d'", who, nident); } else { ret = col_import(colors, who, ap, spec, &ca, NULL); } @@ -1792,8 +1796,8 @@ col_encode(const colors_t *colors, const struct attribute *ap, const colattr_t * } col_export(colors, ap, &ret, buf, sizeof(buf)); - trace_ilog("\tcol_encode(%s, fg:%d/%d, bg:%d/%d, sf:%d) = %s\n", - ap->ca_name, ca->fg.color, ca->fg.source, ca->bg.color, ca->bg.source, ca->sf, buf); + trace_ilog("\tcol_encode(%s, fg:0x%x-%d/%d, bg:0x%x-%d/%d, sf:%d) = %s\n", + ap->ca_name, ca->fg.color, ca->fg.color, ca->fg.source, ca->bg.color, ca->bg.color, ca->bg.source, ca->sf, buf); return ret; } @@ -2031,9 +2035,9 @@ col_apply(colors_t *colors) ca.fg.color, ca.fg.source, ca.bg.color, ca.bg.source, ca.sf, buf); assert(ca.fg.source >= COLORSOURCE_NONE); //>= SYMBOLIC - assert(ca.fg.color >= -1); //>= 0 + assert(ca.fg.color >= -1); //>= 0 assert(ca.bg.source >= COLORSOURCE_NONE); //>= SYMBOLIC - assert(ca.bg.color >= -1); //>= 0 + assert(ca.bg.color >= -1); //>= 0 assert(ca.sf >= 0); x_attrs[ attr ].fg = ca.fg; diff --git a/gr/m_file.c b/gr/m_file.c index 3f7ffcb5..088e79ba 100644 --- a/gr/m_file.c +++ b/gr/m_file.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_m_file_c,"$Id: m_file.c,v 1.44 2022/07/10 10:22:35 cvsuser Exp $") +__CIDENT_RCSID(gr_m_file_c,"$Id: m_file.c,v 1.46 2024/08/01 17:11:07 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: m_file.c,v 1.44 2022/07/10 10:22:35 cvsuser Exp $ +/* $Id: m_file.c,v 1.46 2024/08/01 17:11:07 cvsuser Exp $ * File primitives. * * @@ -345,6 +345,89 @@ do_searchpath(void) /* int (string searchpath, string file, [string } +/* Function: do_splitpath + * searchpath primitive. + * + * Parameters: + * none. + * + * Returns: + * nothing. + * + *<> + Macro: splitpath - Searches for a given file in a specified path. + + int + splithpath(string path, + [string &dir], [string &name], [string &ext], [string &drive]) + + Macro Description: + The 'splitpath()' primitive break a path into components. + + Macro Parameters: + path - Full path. + + dir - Optional string variable reference to be populated with the + directory path, including trailing slash. Forward slashes(/ ), + backslashes(\), or both may be used. + + name - Optional string variable reference to be populated with the + base filename (no extension). + + ext - Optional string variable reference to be populated with the + filename extension, including leading period (.) + + drive - Optional string variable reference to be populated with the + drive letter, followed by a colon(:). + + Macro Returns: + The 'splitpath()' primitive returns pothing. + + Macro Portability: + A Grief extension. + + Macro See Also: + expandpath + + */ +void +do_splitpath(void) /* int (string path, string &dir, string &name, string &ext, [string &drive]) */ +{ + const char* path = get_xstr(1); + const char* end, *p, *ext = ""; + char drv[3] = { 0,0,0 }; + + /* drive */ + if (path[0] && path[1] == ':') { + if (isalpha(path[0])) { + drv[0] = *path++; + drv[1] = *path++; + } + } + end = path + strlen(path); + + /* extension */ + for (p = end; p > path && *--p != '\\' && *p != '/'; ) + if (*p == '.') { + end = ext = p; + break; + } + + /* directory / name */ + for (p = end; p > path; ) + if (*--p == '\\' || *p == '/') { + p++; + break; + } + + argv_assign_str(5, (const char*)drv); + argv_assign_str(4, (const char*)ext); + argv_assign_nstr(3, p, (int)(end - p)); + argv_assign_nstr(2, path, (int)(p - path)); +} + + + /* Function: do_file_glob * file_glob primitive, returning a list of matching filenames. * @@ -1799,14 +1882,14 @@ do_ftest(void) /* int (string condition, string path) */ /* ownership */ case 'O': -#if defined(unix) || defined(__APPLE__) +#if defined(unix) || defined(__unix__) || defined(__APPLE__) ret = (x_stat(path, &sb) == 0 && geteuid() == (uid_t) sb.st_uid); #endif break; case 'G': -#if defined(unix) || defined(__APPLE__) +#if defined(unix) || defined(__unix__) || defined(__APPLE__) ret = (x_stat(path, &sb) == 0 && getegid() == (gid_t) sb.st_gid); #endif diff --git a/gr/m_file.h b/gr/m_file.h index 9aa398c6..60a234fd 100644 --- a/gr/m_file.h +++ b/gr/m_file.h @@ -1,11 +1,11 @@ #ifndef GR_M_FILE_H_INCLUDED #define GR_M_FILE_H_INCLUDED #include -__CIDENT_RCSID(gr_m_file_h,"$Id: m_file.h,v 1.17 2014/10/26 22:13:11 ayoung Exp $") +__CIDENT_RCSID(gr_m_file_h,"$Id: m_file.h,v 1.18 2024/08/01 17:11:07 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: m_file.h,v 1.17 2014/10/26 22:13:11 ayoung Exp $ +/* $Id: m_file.h,v 1.18 2024/08/01 17:11:07 cvsuser Exp $ * File primitives. * * @@ -39,6 +39,7 @@ extern void do_copy_ea_info(void); extern void do_exist(void); extern void do_expandpath(void); extern void do_searchpath(void); +extern void do_splitpath(void); extern void do_file_canon(void); extern void do_file_glob(void); extern void do_file_match(void); diff --git a/gr/m_getopt.c b/gr/m_getopt.c index 00642d66..f57e1707 100644 --- a/gr/m_getopt.c +++ b/gr/m_getopt.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_m_getopt_c,"$Id: m_getopt.c,v 1.25 2022/07/10 13:13:07 cvsuser Exp $") +__CIDENT_RCSID(gr_m_getopt_c,"$Id: m_getopt.c,v 1.26 2024/07/04 11:09:30 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: m_getopt.c,v 1.25 2022/07/10 13:13:07 cvsuser Exp $ +/* $Id: m_getopt.c,v 1.26 2024/07/04 11:09:30 cvsuser Exp $ * Command line/argument option processing. * * @@ -84,7 +84,7 @@ static const char * x_getsubopt_quotes; Macro: getopt - Get options int - getopt(string value, [[string shortopts], list longopts, + getopt(string &value, [[string shortopts], list longopts, string|list args, [string caller]]) Macro Description: @@ -167,6 +167,9 @@ static const char * x_getsubopt_quotes; -3 - Ambiguous option. -4 - Argument required. -5 - Unexpected argument. + + Plus the following argument syntax error conditions. + -10 - Invalid value, for example "expected a numeric value". -99 - Invalid option specification. @@ -218,7 +221,7 @@ static const char * x_getsubopt_quotes; arg_list, split_arguments */ void -do_getopt(void) /* (string value, [[string shortoptions], list longoptions, string|list args, +do_getopt(void) /* (string &value, [[string shortoptions], list longoptions, string|list args, [string caller], [int maxargc], [int flags]]) */ { const char *shortoptions = get_xstr(2); @@ -322,14 +325,14 @@ do_getopt(void) /* (string value, [[string shortoptions], list l if (x_getopt_parms.lidx >= 0) { const struct argoption *lopt = &x_getopt_longoptions[x_getopt_parms.lidx]; const int type = lopt->udata; - + if (OTYPE_BOOLEAN == type) { switch (booleanvalue(value)) { case TRUE: value = "1"; break; case FALSE: value = "0"; break; - default: + default: ret = -10; - } + } } else { if (! optioncheck(type, value)) { ret = -10; @@ -394,7 +397,7 @@ do_getopt(void) /* (string value, [[string shortoptions], list l } } - ED_TRACE(("getopt() : %d (%s)\n", ret, value?value:"(null)")) + ED_TRACE(("getopt() : %d (%s)\n", ret, value?value:"(null)")) argv_assign_str(1, value); acc_assign_int(ret); @@ -1147,3 +1150,4 @@ is_white(int ch) } /*end*/ + diff --git a/gr/m_main.c b/gr/m_main.c index 7f698392..c1fe2eff 100644 --- a/gr/m_main.c +++ b/gr/m_main.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_m_main_c,"$Id: m_main.c,v 1.13 2022/07/10 13:13:08 cvsuser Exp $") +__CIDENT_RCSID(gr_m_main_c,"$Id: m_main.c,v 1.15 2024/08/27 12:44:33 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: m_main.c,v 1.13 2022/07/10 13:13:08 cvsuser Exp $ +/* $Id: m_main.c,v 1.15 2024/08/27 12:44:33 cvsuser Exp $ * Initialisation and primary processing loop. * * @@ -115,8 +115,9 @@ do_process(void) /* () */ vtupdate_cursor(); vtupdate2(TRUE); /* ignore typehead() */ while (1) { + struct IOEvent evt = {0}; last_plevel = x_plevel; - (void) key_execute(io_next(0)); + (void) key_execute(io_next(&evt, 0), (const char *)evt.sequence.data); if (x_plevel < last_plevel) { return; } diff --git a/gr/m_pty.c b/gr/m_pty.c index c394f822..a60a64a7 100644 --- a/gr/m_pty.c +++ b/gr/m_pty.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_m_pty_c,"$Id: m_pty.c,v 1.26 2022/08/10 15:44:57 cvsuser Exp $") +__CIDENT_RCSID(gr_m_pty_c,"$Id: m_pty.c,v 1.27 2024/08/25 06:01:53 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: m_pty.c,v 1.26 2022/08/10 15:44:57 cvsuser Exp $ +/* $Id: m_pty.c,v 1.27 2024/08/25 06:01:53 cvsuser Exp $ * * * This file is part of the GRIEF Editor. @@ -116,13 +116,13 @@ static int x_ptyident = 12000; | | | | .......... | | ................... | | .............. | | | | - Kernel Space | | | | + Kernel Space | | | | | | | | | V | V /-----------------\ /-----------------\ | Psuedo Terminal |<--->| Slave /dev/tty/ | \-----------------/ \-----------------/ - + (end ditaa) All text inserted into the buffer is automatically forwarded diff --git a/gr/m_scan.c b/gr/m_scan.c index 25c76ff3..d880bfc4 100644 --- a/gr/m_scan.c +++ b/gr/m_scan.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_m_scan_c,"$Id: m_scan.c,v 1.25 2022/05/26 16:42:10 cvsuser Exp $") +__CIDENT_RCSID(gr_m_scan_c,"$Id: m_scan.c,v 1.27 2024/07/29 16:14:45 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: m_scan.c,v 1.25 2022/05/26 16:42:10 cvsuser Exp $ +/* $Id: m_scan.c,v 1.27 2024/07/29 16:14:45 cvsuser Exp $ * scanf implementation. * * @@ -38,7 +38,7 @@ typedef struct iostream { unsigned s_total; unsigned s_count; unsigned char * s_cursor; - unsigned s_ungetb[4]; /* min of 3 required */ + unsigned s_ungetb[4]; /* min of 3 required */ unsigned s_ungetc; } IOSTREAM_t; @@ -320,7 +320,7 @@ literal:; if ((c = ioget(io)) < 0) { goto ioerror; } - if (0 == (F_WANTWHITE & flags)) { /* consume leading white space */ + if (0 == (F_WANTWHITE & flags)) { /* consume leading white space */ while (isspace(c)) { if ((c = ioget(io)) < 0) { goto ioerror; @@ -362,7 +362,8 @@ literal:; if ((c = ioget(io)) < 0) { 0 == (flags & (F_HAVEZERO|F_HAVEDIGITS))) { flags &= ~F_PREFIX; flags |= F_MAYBEPREFIX; - base = 8; /* oct until unless 0b or 0x */ + if (0 == (flags & (F_BIN|F_HEX))) + base = 8; /* oct until unless 0b or 0x */ } flags |= F_HAVEZERO; break; @@ -737,7 +738,7 @@ is_ascii(int c) static int is_alnum(int ch) { return isalnum((unsigned char)ch); } static int is_alpha(int ch) { return isalpha((unsigned char)ch); } -static int is_blank(int c) +static int is_blank(int c) { #if defined(HAVE___ISBLANK) return __isblank((unsigned char)c)); @@ -748,15 +749,15 @@ static int is_blank(int c) #endif } -static int is_cntrl(int ch) { return iscntrl((unsigned char)ch); } +static int is_cntrl(int ch) { return iscntrl((unsigned char)ch); } static int is_csym(int ch) { return ('_' == ch || isalnum((unsigned char)ch)); } -static int is_digit(int ch) { return isdigit((unsigned char)ch); } -static int is_graph(int ch) { return isgraph((unsigned char)ch); } -static int is_lower(int ch) { return islower((unsigned char)ch); } -static int is_print(int ch) { return isprint((unsigned char)ch); } -static int is_punct(int ch) { return ispunct((unsigned char)ch); } -static int is_space(int ch) { return isspace((unsigned char)ch); } -static int is_upper(int ch) { return isupper((unsigned char)ch); } +static int is_digit(int ch) { return isdigit((unsigned char)ch); } +static int is_graph(int ch) { return isgraph((unsigned char)ch); } +static int is_lower(int ch) { return islower((unsigned char)ch); } +static int is_print(int ch) { return isprint((unsigned char)ch); } +static int is_punct(int ch) { return ispunct((unsigned char)ch); } +static int is_space(int ch) { return isspace((unsigned char)ch); } +static int is_upper(int ch) { return isupper((unsigned char)ch); } static int is_word(int ch) { return ('_' == ch || '-' == ch || isalnum((unsigned char)ch)); } static int is_xdigit(int ch) { return isxdigit((unsigned char)ch); } @@ -937,11 +938,11 @@ setcook(const unsigned char *fmt, unsigned char *tab) * * Returns: * none - * + * *<> Macro: sscanf - Read formatted data from string. - int + int sscanf(string str, string format, ...) Description: @@ -971,7 +972,7 @@ setcook(const unsigned char *fmt, unsigned char *tab) that were successfully converted. An EOF (-1) is returned if an error is encountered. - Macro Portability: + Macro Portability: A Grief extension. Format Specification: @@ -985,20 +986,20 @@ setcook(const unsigned char *fmt, unsigned char *tab) input stream conflicts with the format string, scanf terminates. Any conflicting characters remain in the input stream. - o whitespace characters - + o whitespace characters - blank (' '), tab ('\t'), or newline ('\n'), cause scanf to skip whitespace characters in the input stream. A single whitespace character in the format string matches 0 or more whitespace characters in the input stream. - o non whitespace characters - + o non whitespace characters - with the exception of the percent sign ('%'), cause scanf to read but not store a matching character from the input stream. The scanf function terminates if the next character in the input stream does not match the specified non-whitespace character. - o format specifications - + o format specifications - begin with a percent sign ('%') and cause scanf to read and convert characters from the input stream to the specified type values. The converted value is stored to an argument @@ -1019,7 +1020,7 @@ setcook(const unsigned char *fmt, unsigned char *tab) arguments for the format specifications. Values in the input stream are called input fields and are - delimited by whitespace characters. When converting input fields, + delimited by whitespace characters. When converting input fields, scanf ends a conversion for an argument when a whitespace character or another unrecognized character is encountered. @@ -1077,12 +1078,12 @@ setcook(const unsigned char *fmt, unsigned char *tab) Character Set: '[' indicates a string not to be delimited by space characters. - + The conversion specification includes all subsequent characters in the format string up to and including the matching right square bracket (]). - The characters between the square brackets comprise the scanset, + The characters between the square brackets comprise the scanset, unless the character after the left square bracket is a circumflex (^), in which case the scanset contains all characters that do not appear in the scanlist between the @@ -1098,7 +1099,7 @@ setcook(const unsigned char *fmt, unsigned char *tab) first character, nor the second where the first character is a circumflex (^), nor the last character, it indicates a range of characters to be matched. To include a hyphen, make it the last - character before the final close bracket. For instance, + character before the final close bracket. For instance, `[^]0-9-]' means the set `everything except close bracket, zero through nine, and hyphen'. @@ -1141,4 +1142,5 @@ do_sscanf(void) /* (string buf, string format, ...) */ ret = scan_formatted(&io, 2); acc_assign_int((accint_t) ret); } + /*end*/ diff --git a/gr/m_spell.c b/gr/m_spell.c index 742c28d3..181a94a7 100644 --- a/gr/m_spell.c +++ b/gr/m_spell.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_m_spell_c,"$Id: m_spell.c,v 1.45 2024/04/16 10:30:36 cvsuser Exp $") +__CIDENT_RCSID(gr_m_spell_c,"$Id: m_spell.c,v 1.46 2024/07/20 09:22:39 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: m_spell.c,v 1.45 2024/04/16 10:30:36 cvsuser Exp $ +/* $Id: m_spell.c,v 1.46 2024/07/20 09:22:39 cvsuser Exp $ * Spell primitives. * * Enchant - AbiWord spell-checker generic interface @@ -380,7 +380,10 @@ spell_nextword(BUFFER_t *bp, const char *buffer, const int length, int *wordlen, int *offset, int *chars, int *column) { static const unsigned char punctuationchars[] = "_-'"; - static const unsigned char wordchars[] = /* FIXME - ascii/latin-1 plus backspace */ +#if defined(__clang__) +#pragma clang diagnostic ignored "-Winvalid-source-encoding" +#endif + static const unsigned char wordchars[] = /* XXX/FIXME - ascii/latin-1 plus backspace */ "\b" "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZéáúõûóüöíÉÁÕÚÖÜÓÛÍ"; static unsigned char wordtable[256] = {0}; diff --git a/gr/m_sysinfo.c b/gr/m_sysinfo.c index 8ad1f839..ba5976c5 100644 --- a/gr/m_sysinfo.c +++ b/gr/m_sysinfo.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_m_sysinfo_c,"$Id: m_sysinfo.c,v 1.11 2022/12/03 16:40:17 cvsuser Exp $") +__CIDENT_RCSID(gr_m_sysinfo_c,"$Id: m_sysinfo.c,v 1.12 2024/07/19 05:04:22 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: m_sysinfo.c,v 1.11 2022/12/03 16:40:17 cvsuser Exp $ +/* $Id: m_sysinfo.c,v 1.12 2024/07/19 05:04:22 cvsuser Exp $ * System information primitives. * * @@ -20,7 +20,7 @@ __CIDENT_RCSID(gr_m_sysinfo_c,"$Id: m_sysinfo.c,v 1.11 2022/12/03 16:40:17 cvsus #include -#if defined(unix) || defined(_AIX) || defined(linux) || \ +#if defined(unix) || defined(__unix__) || defined(_AIX) || defined(linux) || \ defined(WIN32) || defined(__APPLE__) #define HAVE_UTSNAME #include @@ -260,7 +260,7 @@ do_uname(void) /* int ([string &sysname], [string &nodename], [ [string &release], [string &machine]) */ { #if defined(HAVE_UTSNAME) -#if defined(unix) || defined(_AIX) || defined(linux) || \ +#if defined(unix) || defined(__unix__) || defined(_AIX) || defined(linux) || \ defined(WIN32) || defined(__APPLE__) struct utsname u = {0}; diff --git a/gr/m_terminal.c b/gr/m_terminal.c index c166a0d5..9db069c0 100644 --- a/gr/m_terminal.c +++ b/gr/m_terminal.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_m_terminal_c,"$Id: m_terminal.c,v 1.18 2021/06/22 15:52:44 cvsuser Exp $") +__CIDENT_RCSID(gr_m_terminal_c,"$Id: m_terminal.c,v 1.23 2024/09/25 15:51:54 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: m_terminal.c,v 1.18 2021/06/22 15:52:44 cvsuser Exp $ +/* $Id: m_terminal.c,v 1.23 2024/09/25 15:51:54 cvsuser Exp $ * Terminal screen and keyboard primitives. * * @@ -129,14 +129,16 @@ static struct pt_map pt_features[] = { * o scheme_dark - Boolean, *true* if a dark color scheme is desired, otherwise light. * */ - { TF_COLORSETFGBG, PT_MKSTR(x_pt.pt_colorsetfgbg), "colorset_fgbg" }, - { TF_COLORSET_FG, PT_MKSTR(x_pt.pt_colorsetfg), "colorset_fg" }, - { TF_COLORSET_BG, PT_MKSTR(x_pt.pt_colorsetbg), "colorset_bg" }, +// { TF_COLORSET_FG, PT_MKSTR(x_pt.pt_colorsetfg), "color_set_fg" }, +// { TF_COLORSET_BG, PT_MKSTR(x_pt.pt_colorsetbg), "color_set_bg" }, +// { TF_COLORSETRGB_FG, PT_MKSTR(x_pt.pt_colorsetrgbfg), "color_setrgb_fg" }, +// { TF_COLORSETRGB_BG, PT_MKSTR(x_pt.pt_colorsetrgbbg), "color_setrgb_bg" }, { TF_COLORDEPTH, PT_MKINT(x_pt.pt_colordepth), "color_depth" }, { TF_DEFAULT_FG, PT_MKINT(x_pt.pt_defaultfg), "default_fg_color" }, { TF_DEFAULT_BG, PT_MKINT(x_pt.pt_defaultbg), "default_bg_color" }, { TF_SCHEMEDARK, PT_MKFLG(x_pt.pt_schemedark), "scheme_dark" }, + { TF_COLORRGB, PT_MKFLG(x_pt.pt_colorrgb), "color_rgb" }, { TF_COLORMAP, PT_MKSTR(x_pt.pt_colormap), "color_map" }, { TF_COLORPALETTE, PT_MKSTR(x_pt.pt_colorpalette), "color_palette" }, { TF_COLORSCHEME, PT_MKSTR(x_pt.pt_colorscheme), "color_scheme" }, @@ -157,6 +159,7 @@ static struct pt_map pt_features[] = { { TF_TTY_FAST, PT_MKINT(x_pt.pt_tty_fast), "tty_fast" }, { TF_TTY_GRAPHICSBOX, PT_MKINT(x_pt.pt_tty_graphicsbox), "tty_graphicsbox" }, + { TF_KBPROTOCOL, PT_MKSTR(x_pt.pt_kbprotocol), "kbprotocol" }, { TF_SCREEN_ROWS, PT_MKINT(x_pt.pt_screen_rows), "screen_rows" }, { TF_SCREEN_COLS, PT_MKINT(x_pt.pt_screen_cols), "screen_cols" }, @@ -171,6 +174,7 @@ static struct pt_map pt_features[] = { { TF_VT_DATYPE, PT_MKINT(x_pt.pt_vtdatype), "vt_datype" }, { TF_VT_DAVERSION, PT_MKINT(x_pt.pt_vtdaversion), "vt_daversion" }, + { TF_VT_DAOPTIONS, PT_MKINT(x_pt.pt_vtdaoptions), "vt_daoptions" }, { TF_ENCODING, PT_MKSTR(x_pt.pt_encoding), "encoding" }, { TF_UNICODE_VERSION, PT_MKSTR(x_pt.pt_unicode_version), "unicode_version" }, @@ -501,6 +505,8 @@ do_set_term_characters(void) /* int ([int ident string desc], [string|int] va ! TF_TTY_GRAPHICSBOX tty_graphicsbox Integer When *true* enables use of graphic box characters. + ! TF_KBPROTOCOL kbprotocol String Active kb-protocol. + ! TF_SCREEN_ROWS screen_rows Integer Number of screen rows. ! TF_SCREEN_COLS screen_cols Integer Number of screen columns. @@ -535,17 +541,18 @@ do_set_term_characters(void) /* int ([int ident string desc], [string|int] va ! TF_VT_DAVERSION vt_daversion Integer Terminal version. + ! TF_VT_DAOPTIONS vt_daoptions Integer Terminal options. + ! TF_ENCODING encoding String Terminal character encoding. ! TF_UNICODE_VERSION unicode_version String UNICODE interface version, for - example "6.0.1". + example "6.0.1". (end table) TF_ATTRIBUTE: - The reported *TF_ATTRIBUTE* attribute represents special - terminal features mined during terminal initialisation. The - flag argument can contain none or more of the following + The reported *TF_ATTRIBUTE* attribute represents special terminal features mined during + terminal initialisation. The flag argument can contain none or more of the following symbols bitwise OR'ed together. (start table) @@ -561,6 +568,10 @@ do_set_term_characters(void) /* int ([int ident string desc], [string|int] va ! TF_AUNICODEENCODING Unicode character encoding. ! TF_AMETAKEY Meta keys. + + ! TF_AXTERMKEYS XTerm modifyOtherKeys available. + + ! TF_AKITTYKEYS Kitty extended keycodes available. (end table) Note!: @@ -1377,5 +1388,10 @@ do_get_term_keyboard(void) /* list () */ acc_donate_list(newlp, llen); /* return value */ chk_free(array); } + /*end*/ + + + + diff --git a/gr/m_time.c b/gr/m_time.c index 274293a6..fb85222b 100644 --- a/gr/m_time.c +++ b/gr/m_time.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_m_time_c,"$Id: m_time.c,v 1.18 2015/02/11 23:25:13 cvsuser Exp $") +__CIDENT_RCSID(gr_m_time_c,"$Id: m_time.c,v 1.19 2024/08/25 06:01:53 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: m_time.c,v 1.18 2015/02/11 23:25:13 cvsuser Exp $ +/* $Id: m_time.c,v 1.19 2024/08/25 06:01:53 cvsuser Exp $ * Time primitives. * * @@ -196,7 +196,7 @@ do_time(void) /* int ([int &hour], [int &min], [int &sec], [in argv_assign_int(1, (accint_t) tp->tm_hour); argv_assign_int(2, (accint_t) tp->tm_min); argv_assign_int(3, (accint_t) tp->tm_sec); - argv_assign_int(4, (accint_t) msec); /*5/03/06*/ + argv_assign_int(4, (accint_t) msec); acc_assign_int((accint_t) tmsec); } diff --git a/gr/m_tokenize.c b/gr/m_tokenize.c index 9f0553d4..0c220571 100644 --- a/gr/m_tokenize.c +++ b/gr/m_tokenize.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_m_tokenize_c,"$Id: m_tokenize.c,v 1.28 2022/07/10 13:13:08 cvsuser Exp $") +__CIDENT_RCSID(gr_m_tokenize_c,"$Id: m_tokenize.c,v 1.29 2024/07/05 18:33:16 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: m_tokenize.c,v 1.28 2022/07/10 13:13:08 cvsuser Exp $ +/* $Id: m_tokenize.c,v 1.29 2024/07/05 18:33:16 cvsuser Exp $ * String primitives. * * @@ -47,6 +47,7 @@ struct split { unsigned sp_quoting; unsigned sp_numerics; unsigned sp_empties; + unsigned sp_limit; unsigned sp_strings; /* string atom count */ unsigned sp_integers; /* integer atom count */ LIST * sp_list; /* reply */ @@ -113,7 +114,7 @@ static unsigned tok_trimr(const struct tokenizer *tok, const char *buffe list split(string expr, string|integer delims, [int numeric = FALSE], [int noquoting = FALSE], - [int empties = FALSE], [int limit = NULL]) + [int empties = FALSE], [int limit = 0]) Macro Description: The 'split()' primitive splits the string 'expr' into a list of @@ -147,8 +148,9 @@ static unsigned tok_trimr(const struct tokenizer *tok, const char *buffe control enabling (non-zero) and disabling (zero) to whether empties are returned. - limit - Limit the split to 'limit' elements, returning remaining - content in the last element; not implemented at this time. + limit - Limit the split to 'limit' elements, returning the trailing + content in the last element; note any special processing + including quotes and numeric wont apply on the trailing. Macro Results: List of strings where each string is a 'token' from the string @@ -186,15 +188,15 @@ static unsigned tok_trimr(const struct tokenizer *tok, const char *buffe */ void do_split(void) /* (string buffer, string|integer delims, [, int numeric = FALSE] - [, int noquoting = FALSE] [, int empties = FALSE] [, int limit = NULL]) */ + [, int noquoting = FALSE] [, int empties = FALSE] [, int limit = 0]) */ { const char *buffer = get_str(1); /* buffer */ int length = (buffer ? get_strlen(1) : 0); /* and its associated length */ const char *delims = get_xstr(2); /* string|integer */ - int numerics = get_xinteger(3, FALSE); + int numerics = get_xinteger(3, FALSE); int noquoting = get_xinteger(4, FALSE); - int empties = get_xinteger(5, FALSE); - /* int limit = get_xinteger(6, 0xffff);*/ /* TODO - limit elements */ + int empties = get_xinteger(5, FALSE); + int limit = get_xinteger(6, 0); unsigned quoting = 0; char t_delims[2]; @@ -242,8 +244,9 @@ do_split(void) /* (string buffer, string|integer delims, [, int sp.sp_numerics = numerics; sp.sp_quoting = quoting; sp.sp_empties = empties; + sp.sp_limit = (limit <= 0 ? 0 : (unsigned)limit); - ED_TRACE(("\tsplit(%d, %d/%d/%d, '%s', '%s')\n", length, numerics, quoting, empties, delims, buffer)) + ED_TRACE(("\tsplit(%d, %d/%d/%d/%d, '%s', '%s')\n", length, numerics, quoting, empties, limit, delims, buffer)) if (0 == split_buffer(&sp, buffer, length)) { acc_assign_null(); @@ -270,6 +273,7 @@ split_buffer(struct split *sp, const char *str, unsigned length) const char *delims = sp->sp_delims; const unsigned numerics = sp->sp_numerics; const unsigned empties = sp->sp_empties; + unsigned limit = sp->sp_limit; LIST *lp = sp->sp_list; unsigned atoms = 0; const char *start, *end; @@ -294,6 +298,12 @@ split_buffer(struct split *sp, const char *str, unsigned length) /* Skip over this token. */ start = end; + if (limit && 0 == --limit) { + while (*end) + ++end; /* last token; implied string */ + goto asstring; + } + if (split_isquote(sp, *end)) { char endquote = *end; /* closing character */ @@ -449,8 +459,8 @@ split_isnumeric(char ch) o *TOK_COLLAPSE_MULTIPLE* - Splits the string 'expr' into a list of strings and returns - the list in list context. Collapses occurrences of the repeated - delimiter characters treating them as single delimiter, in other + the list in list context. Collapses occurrences of the repeated + delimiter characters treating them as single delimiter, in other words empty elements with the delimited text shall not be returned. @@ -463,7 +473,7 @@ split_isnumeric(char ch) o *TOK_NUMERIC_STRTOL* - Numeric fields are converted using allowing - support leading base specifications hexadecimal (0x), + support leading base specifications hexadecimal (0x), octal (0) and binary (0b). o *TOK_NUMERIC_STRICT* - @@ -789,7 +799,7 @@ tokenize_buffer(struct tokenizer *tok, const char *buffer, int buflen) // Numeric // allow hex (0x###), dec, oct (0###) and binary (0b###) (numerics >= 2) */ - accint_t ret = 0; /* result */ + accint_t ret = 0; /* result */ if (lp || (TOK_NUMERIC_STRICT & flags)) { char *endp = NULL; @@ -1084,8 +1094,8 @@ tok_iswhitespace(const struct tokenizer *tok, const char ch) * local test framework */ struct ATOM { - int type; - unsigned length; + int type; + unsigned length; union { const char *s; double d; @@ -1331,31 +1341,33 @@ acc_donate_list(LIST *lp, int length) { } static void -split_test1(unsigned test, const char *text, const char *delim, int numeric, int noquoting, int empties) { +split_test1(unsigned test, const char *text, const char *delim, int numeric, int noquoting, int empties, int limit) { trace_log("\n\n"); - trace_log("test 1.%u: split('%s','%s', numeric:%u, noquoting:%u, empties:%u)\n", - test, text, delim, numeric, noquoting, empties); + trace_log("test 1.%u: split('%s','%s', numeric:%u, noquoting:%u, empties:%u, limit:%u)\n", + test, text, delim, numeric, noquoting, empties, limit); arg_clear(); arg_strings[0] = text; arg_strings[1] = delim; arg_integers[2] = numeric; arg_integers[3] = noquoting; arg_integers[4] = empties; + arg_integers[5] = limit; ret_clear(); do_split(); } static void -split_test2(unsigned test, const char *text, char delim, int numeric, int noquoting, int empties) { +split_test2(unsigned test, const char *text, char delim, int numeric, int noquoting, int empties, int limit) { trace_log("\n\n"); - trace_log("test 1.%u: split('%s','%c', numeric:%u, noquoting:%u, empties:%u)\n", - test, text, delim, numeric, noquoting, empties); + trace_log("test 1.%u: split('%s','%c', numeric:%u, noquoting:%u, empties:%u, limit:%u)\n", + test, text, delim, numeric, noquoting, empties, limit); arg_clear(); arg_strings[0] = text; arg_integers[1] = delim; arg_integers[2] = numeric; arg_integers[3] = noquoting; arg_integers[4] = empties; + arg_integers[5] = limit; ret_clear(); do_split(); } @@ -1368,6 +1380,7 @@ tokenize_test1(unsigned test, const char *text, const char *delim, int flags) { arg_strings[0] = text; arg_strings[1] = delim; arg_integers[2] = flags; + arg_integers[5] = 0; ret_clear(); do_tokenize(); } @@ -1398,18 +1411,37 @@ test_split(void) { int rc; /* basic */ - split_test1(1, "hello world", " ", 0, 0, 0); + split_test1(1, "hello world", " ", 0, 0, 0, 0); rc = ret_test_str(0, "hello"); rc |= ret_test_str(1, "world"); ret_success(rc); - split_test2(2, "hello world", ' ', 0, 0, 0); + split_test2(2, "hello world", ' ', 0, 0, 0, 0); + rc = ret_test_str(0, "hello"); + rc |= ret_test_str(1, "world"); + ret_success(rc); + + /* limits */ + split_test2(10, "hello", ' ', 0, 0, 0, 1); + rc = ret_test_str(0, "hello"); + ret_success(rc); + + split_test2(11, "hello", ' ', 0, 0, 0, 2); + rc = ret_test_str(0, "hello"); + ret_success(rc); + + split_test2(12, "hello world", ' ', 0, 0, 0, 2); rc = ret_test_str(0, "hello"); rc |= ret_test_str(1, "world"); ret_success(rc); + split_test2(13, "hello world hello world ", ' ', 0, 0, 0, 2); + rc = ret_test_str(0, "hello"); + rc |= ret_test_str(1, "world hello world "); + ret_success(rc); + /* quotes */ - split_test1(20, "\" hello \",\" world \"", "\",", 0, 0, 0); + split_test1(20, "\" hello \",\" world \"", "\",", 0, 0, 0, 0); rc = ret_test_str(0, " hello "); rc |= ret_test_str(1, " world "); ret_success(rc); @@ -1690,3 +1722,6 @@ main(int argc, char *argv[]) { #endif /*LOCAL_MAIN*/ /*eof*/ + + + diff --git a/gr/mac1.c b/gr/mac1.c index ca235a9f..c2529e8e 100644 --- a/gr/mac1.c +++ b/gr/mac1.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_mac1_c,"$Id: mac1.c,v 1.77 2024/05/04 18:00:16 cvsuser Exp $") +__CIDENT_RCSID(gr_mac1_c,"$Id: mac1.c,v 1.78 2024/08/04 10:07:46 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: mac1.c,v 1.77 2024/05/04 18:00:16 cvsuser Exp $ +/* $Id: mac1.c,v 1.78 2024/08/04 10:07:46 cvsuser Exp $ * Basic primitives. * * @@ -2201,10 +2201,10 @@ do_self_insert(void) /* void ([int character]) */ edit - Integer sub version number. - machtype - Machine type labels, value include - "DOS", "OS/2", "UNIX" and "VMS". + release - Integer build-number. - release - Reserved for future use. + machtype - Machine type labels, value include + "DOS", "OS/2", "UNIX" and "VMS"; for additional host information see . compiled - GRIEF engine compilation timestamp. @@ -2217,13 +2217,13 @@ do_self_insert(void) /* void ([int character]) */ Macro Returns: The 'version()' primitive returns the current version multiplied - by 100, plus the minor; for example '301' represents version '3.1'. + by 100, plus the minor; for example '301' represents version '3.1'. Macro Portability: All the arguments are extensions. Macro See Also: - grief_version + grief_version, uname */ void do_version(void) /* int ([maj|mach], [min], [edit], [release], [machtype], @@ -2248,7 +2248,7 @@ do_version(void) /* int ([maj|mach], [min], [edit], [release], [m argv_assign_int(2, (accint_t) x_minor_version); argv_assign_int(3, (accint_t) x_edit_version); - argv_assign_int(4, (accint_t) 0); /* todo - o/s release */ + argv_assign_int(4, (accint_t) x_build_version); argv_assign_str(5, x_machtype); /* DOS, OS/2, UNIX and VMS. */ argv_assign_str(6, x_compiled); argv_assign_int(7, (accint_t) cm_version); diff --git a/gr/macros.c b/gr/macros.c index 7d1f6570..43e1cd94 100644 --- a/gr/macros.c +++ b/gr/macros.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_macros_c,"$Id: macros.c,v 1.56 2023/09/10 17:06:53 cvsuser Exp $") +__CIDENT_RCSID(gr_macros_c,"$Id: macros.c,v 1.57 2024/07/05 18:34:12 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: macros.c,v 1.56 2023/09/10 17:06:53 cvsuser Exp $ +/* $Id: macros.c,v 1.57 2024/07/05 18:34:12 cvsuser Exp $ * Manipulating macro definitions. * * @@ -560,7 +560,7 @@ macro_resolve(const char *cmd) modules from accessing on each other's variables. The purpose of this functionality is to provide data hiding - within a set of common macro files (objects), by allowed separate + within a set of common macro files (objects), by allowing separate function and variables namespaces. Each namespace creates a container for a set of symbols, providing a level of indirection to specific identifiers, thus making it possible to distinguish @@ -800,15 +800,15 @@ mac_validname(const char *name) The following example setups a static scoped callback function: > void -> main(void) -> { -> register_callback( inq_module() + "::callback" ); -> } +> main(void) +> { +> register_callback( inq_module() + "::callback" ); +> } > -> static void -> callback(void) -> { -> } +> static void +> callback(void) +> { +> } Macro Returns: The 'inq_module()' primitive returns the name of the current @@ -913,7 +913,7 @@ mac_walk(SPBLK *sp, void *arg) scoping flags, macro name and the function body. Macro Note!: - This interface should be considered as a *internal* primitive, + This interface should be considered as a *internal* primitive, reserved for exclusive use by the GRIEF Macro Compiler and may change without notice. Management of macro definitions plus any associated argument binding shall be handled @@ -2314,3 +2314,4 @@ do_require(void) /* int (string filename) */ acc_assign_int((accint_t) ret); } /*end*/ + diff --git a/gr/main.h b/gr/main.h index 89a4c86d..bd52ab7e 100644 --- a/gr/main.h +++ b/gr/main.h @@ -1,11 +1,11 @@ #ifndef GR_MAIN_H_INCLUDED #define GR_MAIN_H_INCLUDED #include -__CIDENT_RCSID(gr_main_h,"$Id: main.h,v 1.30 2022/08/10 15:44:57 cvsuser Exp $") +__CIDENT_RCSID(gr_main_h,"$Id: main.h,v 1.33 2024/09/21 09:05:16 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: main.h,v 1.30 2022/08/10 15:44:57 cvsuser Exp $ +/* $Id: main.h,v 1.33 2024/09/21 09:05:16 cvsuser Exp $ * Globals and main process primitives. * * @@ -31,7 +31,7 @@ __CBEGIN_DECLS */ extern const char * x_progname; /* arg0 or better */ -extern int xf_mouse; /* TRUE enable mouse. */ +extern const char * xf_mouse; /* mouse mode; NULL disabled. */ extern int xf_compat; /* TRUE normal stdout I/O otherwise optimised */ @@ -57,7 +57,9 @@ extern int xf_graph; /* TRUE/FALSE, user specified gr extern int xf_visbell; /* TRUE/FALSE, visual bell. */ -extern int xf_cygwinkb; /* TRUE/FALSE, cygwin raw keyboard */ +extern int xf_kbprotocol; /* Keyboard protocol mode. */ + +extern const char * xf_kbconfig; /* Optional keyboard configuration. */ extern int xf_underline; /* TRUE/FALSE, user specified underline mode. */ @@ -113,8 +115,8 @@ extern int x_ctrlc; /* TRUE when SIGINT occured */ extern uint32_t xf_test; /* TRUE enables test code --- internal use only --- */ -#define XF_FLAG(__test) (1 << (__test - 1)) -#define XF_TEST(__test) (xf_test & XF_FLAG(__test)) +#define XF_FLAG(__flag) (1 << (__flag - 1)) +#define XF_TEST(__test) (xf_test & XF_FLAG(__test)) extern BUFFER_t * curbp; /* Current buffer */ extern WINDOW_t * curwp; /* Current window */ @@ -137,3 +139,5 @@ extern void do_suspend(void); __CEND_DECLS #endif /*GR_MAIN_H_INCLUDED*/ + + diff --git a/gr/mchar_iconv.c b/gr/mchar_iconv.c index fde2de91..e00b05eb 100644 --- a/gr/mchar_iconv.c +++ b/gr/mchar_iconv.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_mchar_iconv_c,"$Id: mchar_iconv.c,v 1.29 2024/04/16 10:30:36 cvsuser Exp $") +__CIDENT_RCSID(gr_mchar_iconv_c,"$Id: mchar_iconv.c,v 1.32 2024/07/20 18:18:52 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: mchar_iconv.c,v 1.29 2024/04/16 10:30:36 cvsuser Exp $ +/* $Id: mchar_iconv.c,v 1.32 2024/07/20 18:18:52 cvsuser Exp $ * Character-set conversion/mapping interface and adapters. * * @@ -1047,29 +1047,28 @@ my_iconv_open(const char *to, const char *from) static int iconv_ok = -1; /* one-shot test */ iconv_t fd = ICONV_NULL; - if (0 == iconv_ok) { - return (void *) -1; /* detected a broken iconv() previously */ + if (FALSE == iconv_ok) { + return ICONV_NULL; /* detected a broken iconv() previously */ } if (ICONV_NULL != (fd = iconv_open(to, from))) { if (-1 == iconv_ok) { /* * Test for broken iconv() versions, thru a dummy iconv() call. - * The symptoms are that after outputting the initial shift state the - * "to" pointer is NULL and conversion stops for no apparent reason - * after about 8160 characters. + * The symptoms are that after outputting the initial shift state the "to" pointer is NULL + * and conversion stops for no apparent reason after about 8160 characters. */ #if !defined(ICONV_TESTLEN) -#define ICONV_TESTLEN (1024) +#define ICONV_TESTLEN (1024) #endif - char tobuf[ICONV_TESTLEN]; + char tobuf[ICONV_TESTLEN] = {0}; size_t tolen; char *p; p = (char *)tobuf; tolen = sizeof(tobuf); (void) iconv(fd, NULL, NULL, &p, &tolen); - if (NULL == p) { + if (NULL == p) { /*unexpected*/ iconv_ok = FALSE; iconv_close(fd); fd = ICONV_NULL; diff --git a/gr/mouse.c b/gr/mouse.c index 551f9af1..816f4fbf 100644 --- a/gr/mouse.c +++ b/gr/mouse.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_mouse_c,"$Id: mouse.c,v 1.41 2023/09/10 16:35:52 cvsuser Exp $") +__CIDENT_RCSID(gr_mouse_c,"$Id: mouse.c,v 1.49 2024/09/15 14:29:51 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: mouse.c,v 1.41 2023/09/10 16:35:52 cvsuser Exp $ +/* $Id: mouse.c,v 1.49 2024/09/15 14:29:51 cvsuser Exp $ * Mouse support code. * * @@ -21,6 +21,7 @@ __CIDENT_RCSID(gr_mouse_c,"$Id: mouse.c,v 1.41 2023/09/10 16:35:52 cvsuser Exp $ #include #include #include +#include #include "accum.h" #include "anchor.h" @@ -34,6 +35,7 @@ __CIDENT_RCSID(gr_mouse_c,"$Id: mouse.c,v 1.41 2023/09/10 16:35:52 cvsuser Exp $ #include "main.h" #include "register.h" /* trigger() */ #include "symbol.h" +#include "system.h" #include "tty.h" #include "window.h" @@ -63,9 +65,8 @@ static time_t x_mouse_prev; /* * mouse_init --- - * Function to try and initialise mouse device. Called only - * if -mouse flag set. Called with name of device for - * accessing. + * Initialise the mouse interface using the given device. + * Called only if mouse functionality has been enabled. */ int mouse_init(const char *dev) @@ -113,8 +114,9 @@ mouse_poll(fd_set *fds) { struct MouseEvent m = {0}; + m.multi = -1; if (sys_mousepoll(fds, &m)) { - mouse_process(m.x, m.y, m.b1, m.b2, m.b3, m.multi); + mouse_process(&m, NULL); } return (0); } @@ -199,7 +201,7 @@ do_translate_pos(void) /* int (int x, int y, int &wid, int &line, i y -= (wp->w_y - !win_tborder(wp)) - 1; argv_assign_int(4, (accint_t)(wp->w_top_line + y)); - argv_assign_int(5, (accint_t)(wp->w_left_offset + x)); + argv_assign_int(5, (accint_t)(wp->w_left_offset + 1 + x)); } else { argv_assign_int(4, (accint_t) -1); @@ -226,9 +228,8 @@ do_translate_pos(void) /* int (int x, int y, int &wid, int &line, i [int b1], [int b2], [int b3], int x, int y) Macro Description: - The 'process_mouse()' primitive allows an external mouse - event to be processed; some mice types are handled internally - whereas others require macro support. + The 'process_mouse()' primitive allows an external mouse event to be processed; + some mice types are handled internally whereas others require macro support. Macro Parameters: b1, b2, b3 - Button states, zero for up otherwise non-zero @@ -247,13 +248,14 @@ do_translate_pos(void) /* int (int x, int y, int &wid, int &line, i void do_process_mouse(void) /* void (int b1, int b2, int b3, int x, int y) */ { - const int b1 = get_xinteger(1, 0); - const int b2 = get_xinteger(2, 0); - const int b3 = get_xinteger(3, 0); - const int x = get_xinteger(4, 0); - const int y = get_xinteger(5, 0); + struct MouseEvent m = {0}; - mouse_process(x, y, b1, b2, b3, 0); + m.b1 = get_xinteger(1, 0); + m.b2 = get_xinteger(2, 0); + m.b3 = get_xinteger(3, 0); + m.x = get_xinteger(4, 0); + m.y = get_xinteger(5, 0); + mouse_process(&m, NULL); } @@ -301,24 +303,24 @@ do_process_mouse(void) /* void (int b1, int b2, int b3, int x, int Where:: (start table) - [Value [Definition ] - ! MOBJ_NOWHERE Not in any window. - - ! MOBJ_LEFT_EDGE Left bar of window. - ! MOBJ_RIGHT_EDGE Right bar of window. - ! MOBJ_TOP_EDGE Top line of window. - ! MOBJ_BOTTOM_EDGE Bottom line of window. - ! MOBJ_INSIDE Mouse inside window. - ! MOBJ_TITLE On title. - - ! MOBJ_VSCROLL Vertical scroll area. - ! MOBJ_VTHUMB Vertical scroll area. - ! MOBJ_HSCROLL Horizontal scroll area. - ! MOBJ_HTHUMB Horizontal scroll area. - - ! MOBJ_ZOOM Zoom button, - ! MOBJ_CLOSE Close. - ! MOBJ_SYSMENU System Menu. + [Value [Definition [Definition ] + ! 0 MOBJ_NOWHERE Not in any window. + + ! 1 MOBJ_LEFT_EDGE Left bar of window. + ! 2 MOBJ_RIGHT_EDGE Right bar of window. + ! 3 MOBJ_TOP_EDGE Top line of window. + ! 4 MOBJ_BOTTOM_EDGE Bottom line of window. + ! 5 MOBJ_INSIDE Mouse inside window. + ! 6 MOBJ_TITLE On title. + + ! 20 MOBJ_VSCROLL Vertical scroll area. + ! 21 MOBJ_VTHUMB Vertical scroll area. + ! 22 MOBJ_HSCROLL Horizontal scroll area. + ! 23 MOBJ_HTHUMB Horizontal scroll area. + + ! 30 MOBJ_ZOOM Zoom button. + ! 31 MOBJ_CLOSE Close. + ! 32 MOBJ_SYSMENU System Menu. (end table) Region:: @@ -334,7 +336,7 @@ do_process_mouse(void) /* void (int b1, int b2, int b3, int x, int (end table) Macro Returns: - nothing + Returns the time since the previous mouse event. Macro Portability: n/a @@ -364,7 +366,7 @@ do_get_mouse_pos(void) /* int ([int x], [int y], [int win]. [int line], x -= wp->w_x + win_lborder(wp) + 1; /* normalise to window */ y -= wp->w_y + win_tborder(wp) + 1; y += wp->w_top_line; - x += wp->w_left_offset; + x += wp->w_left_offset + 1; argv_assign_int(4, (accint_t) y); /* line */ argv_assign_int(5, (accint_t) x); /* column */ @@ -435,93 +437,370 @@ do_get_mouse_pos(void) /* int ([int x], [int y], [int win]. [int line], /* * mouse_process --- - * Determine if a mouse status change has occured - * and generate a key action to match. + * Determine if a mouse status change has occured and generate a key action to match. */ + +struct MouseState { + mouseevt_t evt; + unsigned mods; + WINDOW_t* wp; +}; + +static uint64_t mouse_time(void); +static unsigned mouse_mods(const struct MouseEvent* me); +static int mouse_press(const struct MouseEvent* me, const struct MouseState* ms); +static int mouse_press_release(const struct MouseEvent* me, const struct MouseState* ms); +static int mouse_ismulti(int click, int x, int y); +static int mouse_motion(const struct MouseEvent *me, const struct MouseState *ms); +static int mouse_release(const struct MouseEvent *me, const struct MouseState *ms, int b1, int b2, int b3); + +static struct MouseEvent prev; + int -mouse_process(int x, int y, int b1, int b2, int b3, int multi) +mouse_process(const struct MouseEvent *me, const char *seq) { - static int click_last, click_ypos, click_xpos; - static struct MouseEvent oldm; - static clock_t click_time; + struct MouseState ms = {0}; + int msgs = 0; - WINDOW_t *wp; - int click, win, where; +#if (0) + char buffer[64]; + sxprintf(buffer, sizeof(buffer), "%s:%u%u%u,%x,%x", seq, me->b1, me->b2, me->b3, me->type, me->ctrl); + seq = buffer; +#endif + + ms.evt.seq = seq; + ms.evt.x = me->x; + ms.evt.y = me->y; + ms.mods = mouse_mods(me); + ms.wp = mouse_pos(me->x, me->y, &ms.evt.win, &ms.evt.where); + + if (me->type == MOUSEEVENT_TPRESSRELEASE) { + /* + * Absolute mouse reporting semantics for example win32, + * explicit button status events. + */ + if ((msgs = mouse_press_release(me, &ms)) != 0) { + return msgs; + } + + } else if (me->type & (MOUSEEVENT_TPRESS | MOUSEEVENT_TRELEASE)) { + /* + * Advanced mouse reporting semantics, + * individual explicit press and release events + */ + if (me->type & MOUSEEVENT_TRELEASE) { + return mouse_release(me, &ms, me->b1, me->b2, me->b3); + } + msgs = mouse_press(me, &ms); + + } else { + /* + * Simple mouse reporting semantics for example xterm legacy, + * individual press event and with a group release event. + */ + if (me->type & MOUSEEVENT_TRELEASE_ALL) { + msgs = mouse_motion(me, &ms); + msgs += mouse_release(me, &ms, prev.b1, prev.b2, prev.b3); + return msgs; + } + msgs = mouse_press(me, &ms); + } + + if (0 == msgs) { + msgs = mouse_motion(me, &ms); + } + + return msgs; +} + + +static uint64_t +mouse_time(void) +{ + int ms = 0; + time_t now = sys_time(&ms); + return ((uint64_t)now * 1000) + ms; +} + + +static unsigned +mouse_mods(const struct MouseEvent* me) +{ + unsigned mods = 0; + + if (me->ctrl & MOUSEEVENT_CSHIFT) + mods |= MOD_SHIFT; + if (me->ctrl & MOUSEEVENT_CCTRL) + mods |= MOD_CTRL; + if (me->ctrl & MOUSEEVENT_CMETA) + mods |= MOD_META; + return mods; +} + + +/* + * mouse_press --- + * Mouse press logic, common to mouse handlers; unless multi, emumulate double-click + */ +static int +mouse_press(const struct MouseEvent* me, const struct MouseState* ms) +{ + const int x = me->x, y = me->y; + int b1 = me->b1, b2 = me->b2, b3 = me->b3, click = 0; int msgs = 0; /* - * Find out if this is a multi-click + * determine click type. */ - click = 0; - if (b1 && !oldm.b1) { + if (b1 && 0 == prev.b1) { click = 1; - } else if (b2 && !oldm.b2) { + } else if (b2 && 0 == prev.b2) { click = 2; - } else if (b3 && !oldm.b3) { + } else if (b3 && 0 == prev.b3) { click = 3; } if (click) { - if (-1 == multi) { - const clock_t now = clock(); + int multi = me->multi; - if (click == click_last && x == click_xpos && y == click_ypos && - now < click_time + (CLOCKS_PER_SEC/3)) { - multi = 1; /* ~330ms */ - } else { - click_last = click; - click_xpos = x; - click_ypos = y; - click_time = now; - multi = 0; + if (-1 == multi) { /* derive */ + multi = mouse_ismulti(click, x, y); + } + if (multi) { + if (click == 1) { + ++b1; + } else if (click == 2) { + ++b2; + } else if (click == 3) { + ++b3; } } + } - if (multi) { - if (click == 1) b1++; - else if (click == 2) b2++; - else if (click == 3) b3++; - click_last = 0; + /* + * publish + */ + if (!click) { + return 0; + } + + trace_log("mouse_press(%d, %d, %d-%d-%d, 0x%x)\n", x, y, b1, b2, b3, ms->mods); + if (ms->wp) { + triggerx(REG_MOUSE, "%d %d %d %d %d %d %d %d %d", ms->evt.win, ms->evt.where, x, y, click, b1, b2, b3, ms->mods); + } + +#define BUTTON_PRESS(__s, __b) \ + ((1 == __s ? (BUTTON1_DOWN + __b) : (BUTTON1_DOUBLE + __b)) | ms->mods) + +#define BUTTON_MOTION(__b) \ + ((BUTTON1_MOTION + __b) | ms->mods) + + // XXX: should mods be sticky, for example Button1-Ctl- is retained across motion and release? + if (click) { + if (b1 && b1 != prev.b1) { + if (ms->wp) { + key_cache_mouse(x_push_ref, BUTTON_PRESS(b1, 0), FALSE, &ms->evt); + ++msgs; + } + prev.b1 = b1; + } + + if (b2 && b2 != prev.b2) { + if (ms->wp) { + key_cache_mouse(x_push_ref, BUTTON_PRESS(b2, 1), FALSE, &ms->evt); + ++msgs; + } + prev.b2 = b2; + } + + if (b3 && b3 != prev.b3) { + if (ms->wp) { + key_cache_mouse(x_push_ref, BUTTON_PRESS(b3, 2), FALSE, &ms->evt); + ++msgs; + } + prev.b3 = b3; + } + + prev.x = x; + prev.y = y; + } + return msgs; +} + + +/* + * mouse_press_release --- + * Mouse specific release logic, for example win32-console, system double-click reporting assumed. + */ +static int +mouse_press_release(const struct MouseEvent* me, const struct MouseState* ms) +{ + const int x = me->x, y = me->y, + b1 = me->b1, b2 = me->b2, b3 = me->b3; + const int multi = (me->multi > 0 ? 1 : 0); + int msgs = 0; + +#define BUTTON_PRESSRELEASE(__s, __b) \ + ((__s ? (multi ? (BUTTON1_DOUBLE + __b) : (BUTTON1_DOWN + __b)) : (BUTTON1_UP + __b)) | ms->mods) + + if (b1 == prev.b1 && b2 == prev.b2 && b3 == prev.b3) { + return 0; + } + + trace_log("mouse_press_release(%d, %d, %d-%d-%d, 0x%x)\n", x, y, b1, b2, b3, ms->mods); + if (ms->wp) { + triggerx(REG_MOUSE, "%d %d %d %d %d %d %d %d %d", ms->evt.win, ms->evt.where, x, y, 0, b1, b2, b3, ms->mods); + } + + if (b1 != prev.b1) { + if (ms->wp) { + key_cache_mouse(x_push_ref, BUTTON_PRESSRELEASE(b1, 0), FALSE, &ms->evt); + ++msgs; + } + prev.b1 = b1; + } + + if (b2 != prev.b2) { + if (ms->wp) { + key_cache_mouse(x_push_ref, BUTTON_PRESSRELEASE(b2, 1), FALSE, &ms->evt); + ++msgs; } + prev.b2 = b2; + } + + if (b3 != prev.b3) { + if (ms->wp) { + key_cache_mouse(x_push_ref, BUTTON_PRESSRELEASE(b3, 2), FALSE, &ms->evt); + ++msgs; + } + prev.b3 = b3; + } + + return msgs; +} + + +static int +mouse_ismulti(int click, int x, int y) +{ + static int click_last, click_ypos, click_xpos; + static uint64_t click_time; + uint64_t now = mouse_time(); + + if (click == click_last && x == click_xpos && y == click_ypos && + now < (click_time + sys_doubleclickms())) { + click_last = 0; + return 1; /* double-click */ } + click_last = click; + click_xpos = x; + click_ypos = y; + click_time = now; + return 0; +} - trace_log("mouse_process(%d, %d, %d-%d-%d-%d)\n", x, y, b1, b2, b3, multi); + +/* + * mouse_motion --- + * Mouse motion logic, common to mouse handlers. + */ +static int +mouse_motion(const struct MouseEvent* me, const struct MouseState* ms) +{ + const int x = me->x, y = me->y, + motion = (x != prev.x) || (y != prev.y) || (me->type & MOUSEEVENT_TMOTION); + const int b1 = me->b1, b2 = me->b2, b3 = me->b3; + int msgs = 0; + + if (!motion) { + return 0; + } + + trace_log("mouse_motion(%d, %d, %d-%d-%d, 0x%x)\n", x, y, b1, b2, b3, ms->mods); + if (ms->wp) { + triggerx(REG_MOUSE, "%d %d %d %d %d %d %d %d %d", ms->evt.win, ms->evt.where, x, y, -1, b1, b2, b3, ms->mods); + } + + if (ms->wp) { + if (prev.b1) { + key_cache_mouse(x_push_ref, BUTTON_MOTION(0), FALSE, &ms->evt); + ++msgs; + } + + if (prev.b2) { + key_cache_mouse(x_push_ref, BUTTON_MOTION(1), FALSE, &ms->evt); + ++msgs; + } + + if (prev.b3) { + key_cache_mouse(x_push_ref, BUTTON_MOTION(2), FALSE, &ms->evt); + ++msgs; + } + } + + prev.x = x; + prev.y = y; + return msgs; +} + + +/* + * mouse_release --- + * Mouse specific release logic, for example xterm-sgr. + */ +static int +mouse_release(const struct MouseEvent *me, const struct MouseState* ms, int b1, int b2, int b3) +{ + const int x = me->x, y = me->y; + int msgs = 0; + + if (!((b1 && prev.b1) || (b2 && prev.b2) || (b3 || prev.b3))) { + return 0; + } /* - * State change, send message + * publish */ - if ((b1 != oldm.b1) || (b2 != oldm.b2) || (b3 != oldm.b3) || (x != oldm.x) || (y != oldm.y)) { - if ((wp = mouse_pos(x, y, &win, &where)) != NULL) { - int motion = ((x != oldm.x) || (y != oldm.y)); - -#define BUTTON_ACTION(s, b) \ - (s ? (s > 1 ? (BUTTON1_DOUBLE + b) : (BUTTON1_DOWN + b)) : BUTTON1_UP + b) - - /* - * Old-style mouse trigger - */ - triggerx(REG_MOUSE, "%d %d %d %d %d %d %d", win, where, x, y, b1, b2, b3); - - /* - * report button changes - */ - if (b1 != oldm.b1) key_cache_mouse(x_push_ref, BUTTON_ACTION(b1, 0), FALSE, x, y, win, where), ++msgs; - if (b2 != oldm.b2) key_cache_mouse(x_push_ref, BUTTON_ACTION(b2, 1), FALSE, x, y, win, where), ++msgs; - if (b3 != oldm.b3) key_cache_mouse(x_push_ref, BUTTON_ACTION(b3, 2), FALSE, x, y, win, where), ++msgs; - - /* - * and secondary motion - */ - if (motion) { - if (b1) key_cache_mouse(x_push_ref, BUTTON1_MOTION, FALSE, x, y, win, where), ++msgs; - if (b2) key_cache_mouse(x_push_ref, BUTTON2_MOTION, FALSE, x, y, win, where), ++msgs; - if (b3) key_cache_mouse(x_push_ref, BUTTON3_MOTION, FALSE, x, y, win, where), ++msgs; - } + trace_log("mouse_release(%d, %d, %d-%d-%d)\n", x, y, b1, b2, b3); + if (ms->wp) { + triggerx(REG_MOUSE, "%d %d %d %d %d %d %d %d %d", ms->evt.win, ms->evt.where, x, y, 0, b1, b2, b3, 0); + } + +#define BUTTON_RELEASE(__b) \ + (BUTTON1_UP + __b) + + if (b1 && prev.b1) { + if (ms->wp) { + key_cache_mouse(x_push_ref, BUTTON_RELEASE(0), FALSE, &ms->evt); + ++msgs; } + prev.b1 = 0; + } - oldm.x = x; oldm.y = y; - oldm.b1 = b1; oldm.b2 = b2; oldm.b3 = b3; + if (b2 && prev.b2) { + if (ms->wp) { + key_cache_mouse(x_push_ref, BUTTON_RELEASE(1), FALSE, &ms->evt); + ++msgs; + } + prev.b2 = 0; + + } + + if (b3 && prev.b3) { + if (ms->wp) { + key_cache_mouse(x_push_ref, BUTTON_RELEASE(2), FALSE, &ms->evt); + ++msgs; + } + prev.b3 = 0; + } + + if (prev.b1 | prev.b2 | prev.b3) { + prev.x = x; + prev.y = y; + } else { + prev.x = prev.y = 0; } + return msgs; } @@ -538,6 +817,7 @@ mouse_execute(const struct IOEvent *evt) assert(EVT_MOUSE == evt->type); assert(RANGE_BUTTON == (RANGE_MASK & code)); + x_mouse_event = code; x_mouse_xpos = mouse->x; x_mouse_ypos = mouse->y; @@ -551,23 +831,25 @@ mouse_execute(const struct IOEvent *evt) /* * mouse_pos --- * Determine on what type of object the mouse is sitting on. - * Returns window pointer to window where mouse is. Set win_id to the - * window id, and where identifies the type of area the mouse is on. + * + * Returns: + * Returns window pointer to window where mouse is located, otherwise NULL. + * If successful, set win to the window id, and where identifies the type of area the mouse is on. */ WINDOW_t * -mouse_pos(int x, int y, int * win, int * where) +mouse_pos(int x, int y, int *win, int *where) { - register WINDOW_t *wp, *topwp; - int b; - - --x, --y; /* mouse 1,1 via window 0,0 origins */ + register WINDOW_t *wp, *topwp = NULL; + int t_where = 0; /* * Walk window chain, * all windows within the current stack must be checked as the * current (top) popup shall match last. */ - topwp = NULL; + if (x) --x; + if (y) --y; /* mouse 1,1 via window 0,0 origins */ + for (wp = window_first(); wp; wp = window_next(wp)) if (x >= (win_lcolumn(wp) - win_lborder(wp)) && x <= (win_rcolumn(wp) + win_rborder(wp)) && y >= (win_tline(wp) - win_tborder(wp)) && y <= (win_bline(wp) + win_bborder(wp)) ) { @@ -577,47 +859,47 @@ mouse_pos(int x, int y, int * win, int * where) /* * Process matched window */ - *where = 0; - if (NULL == topwp) { - *win = -1; /* no active window */ - - } else { - *win = topwp->w_num; + if (topwp) { + const int wx = x - topwp->w_x; //, wy = y - topwp->w_y; + int b; if ((b = win_lborder(topwp)) && x == win_lcolumn(topwp) - b) { - *where = MOBJ_LEFT_EDGE; - -// *where = MOBJ_ZOOM; -// *where = MOBJ_CLOSE; + t_where = MOBJ_LEFT_EDGE; -// } else if (win_lmargin(topwp)) { /* XXX/TOD0 */ -// *where = MOBJ_LEFT_MARGIN; + // } else if (win_lmargin(topwp)) { + // t_where = MOBJ_LEFT_MARGIN; } else if ((b = win_rborder(topwp)) && x == win_rcolumn(topwp) + b) { -// if (y >= win_tline(topwp) + 1 && y <= win_bline(topwp) - 1) { -// *where = MOBJ_VSCROLL_AREA; -// } else { - *where = MOBJ_RIGHT_EDGE; -// } + // MOBJ_VSCROLL_AREA; + t_where = MOBJ_RIGHT_EDGE; } else if ((b = win_tborder(topwp)) && y == win_tline(topwp) - b) { -// if (vscreen[y][x] & 0x80) { - *where = MOBJ_TOP_EDGE; -// } else { -// *where = MOBJ_TITLE; -// } + if (wx <= topwp->w_coords.title_end && wx > topwp->w_coords.title_start) { + t_where = MOBJ_TITLE; + // } else if (wx <= topwp->w_coords.zoom_end && wx > topwp->w_coords.zoom_start) { + // t_where = MOBJ_ZOOM; + } else if (wx <= topwp->w_coords.close_end && wx > topwp->w_coords.close_start) { + t_where = MOBJ_CLOSE; + } else { + t_where = MOBJ_TOP_EDGE; + } } else if ((b = win_bborder(topwp)) && y == win_bline(topwp) + b) { -// if (x >= win_lcolumn(topwp)+1 && x <= win_rcolumn(topwp)-1) { -// *where = MOBJ_HSCROLL_AREA; -// } else { - *where = MOBJ_BOTTOM_EDGE; -// } + // MOBJ_HSCROLL_AREA; + t_where = MOBJ_BOTTOM_EDGE; } else { - *where = MOBJ_INSIDE; /* must be inside */ + t_where = MOBJ_INSIDE; } } + + if (win) + *win = (topwp ? topwp->w_num : -1 ); + + if (where) + *where = t_where; + return topwp; } +/*end*/ diff --git a/gr/mouse.h b/gr/mouse.h index 97d0012b..56562a7c 100644 --- a/gr/mouse.h +++ b/gr/mouse.h @@ -1,11 +1,11 @@ #ifndef GR_MOUSE_H_INCLUDED #define GR_MOUSE_H_INCLUDED #include -__CIDENT_RCSID(gr_mouse_h,"$Id: mouse.h,v 1.23 2020/06/03 16:04:16 cvsuser Exp $") +__CIDENT_RCSID(gr_mouse_h,"$Id: mouse.h,v 1.25 2024/08/27 12:44:33 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: mouse.h,v 1.23 2020/06/03 16:04:16 cvsuser Exp $ +/* $Id: mouse.h,v 1.25 2024/08/27 12:44:33 cvsuser Exp $ * Mouse support. * * @@ -80,8 +80,19 @@ struct IOEvent; struct MouseEvent { int b1, b2, b3; /* Button state */ - int multi; + int multi; /* Multiple button click's */ int x, y; /* Coordinates */ +#define MOUSEEVENT_CSHIFT 1 +#define MOUSEEVENT_CCTRL 2 +#define MOUSEEVENT_CMETA 4 + int ctrl; /* Optional Ctrl keys */ +#define MOUSEEVENT_TPRESS 1 // single press +#define MOUSEEVENT_TRELEASE 2 // signle release +#define MOUSEEVENT_TRELEASE_ALL 4 // release all buttons +#define MOUSEEVENT_TPRESSRELEASE 8 // button delta +#define MOUSEEVENT_TMOTION 16 +#define MOUSEEVENT_TWHEELED 32 + int type; /* Event, otherwise 0 if undefined */ }; extern int mouse_init(const char *dev); @@ -89,7 +100,7 @@ extern void mouse_close(void); extern int mouse_active(void); extern void mouse_pointer(int state); extern WINDOW_t * mouse_pos(int x, int y, int *win, int *where); -extern int mouse_process(int x, int y, int b1, int b2, int b3, int multi); +extern int mouse_process(const struct MouseEvent *m, const char *seq); extern void mouse_execute(const struct IOEvent *evt); #if defined(HAVE_MOUSE) @@ -100,10 +111,13 @@ extern void sys_mousepointer(int on); extern void mouse_pointer(int state); extern void mouse_draw_icon(int y, int x, int oldy, int oldx); extern int mouse_poll(fd_set *fds); -extern int sys_mousepoll(fd_set *fds, struct MouseEvent *mevt); +extern int sys_mousepoll(fd_set *fds, struct MouseEvent *me); #endif +extern unsigned sys_doubleclickms(void); + extern void do_process_mouse(void); extern void do_translate_pos(void); #endif /*GR_MOUSE_H_INCLUDED*/ + diff --git a/gr/procspawn.c b/gr/procspawn.c index 6ebc563d..7bf5fdbe 100644 --- a/gr/procspawn.c +++ b/gr/procspawn.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_procspawn_c,"$Id: procspawn.c,v 1.25 2024/06/10 06:00:44 cvsuser Exp $") +__CIDENT_RCSID(gr_procspawn_c,"$Id: procspawn.c,v 1.26 2024/08/18 10:50:36 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: procspawn.c,v 1.25 2024/06/10 06:00:44 cvsuser Exp $ +/* $Id: procspawn.c,v 1.26 2024/08/18 10:50:36 cvsuser Exp $ * Process spawn primitive and management. * * @@ -122,15 +122,15 @@ int x_background = FALSE; /* background process ? */ output plus registers the macro 'gmake_complete' to be executed on completion. -> shell("gmake 2>&1 >/tmp/gmake.tmp", TRUE, "gmake_completion"); +> shell("gmake 2>&1 >/tmp/gmake.tmp", TRUE, "gmake_completion"); associated completion macro. > void > gmake_completion(int status) -> { +> { > message("gmake done, status = %d", status); -> } +> } Meta Characters:: @@ -618,3 +618,4 @@ proc_prep_start(void) } /*end*/ + diff --git a/gr/pty_unix.c b/gr/pty_unix.c index 9caed145..a9f5d934 100644 --- a/gr/pty_unix.c +++ b/gr/pty_unix.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_pty_unix_c,"$Id: pty_unix.c,v 1.24 2020/06/20 12:39:45 cvsuser Exp $") +__CIDENT_RCSID(gr_pty_unix_c,"$Id: pty_unix.c,v 1.27 2024/07/19 05:04:22 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: pty_unix.c,v 1.24 2020/06/20 12:39:45 cvsuser Exp $ +/* $Id: pty_unix.c,v 1.27 2024/07/19 05:04:22 cvsuser Exp $ * PTY interface for Unix and Unix-like environments. * * Linux @@ -38,7 +38,7 @@ __CIDENT_RCSID(gr_pty_unix_c,"$Id: pty_unix.c,v 1.24 2020/06/20 12:39:45 cvsuser #include #include /* gputenvv(), ggetenv() */ -#if defined(unix) || defined(__APPLE__) +#if defined(unix) || defined(__unix__) || defined(__APPLE__) #if !defined(ED_LEVEL) #define ED_LEVEL 1 /* debug/trace level */ @@ -759,9 +759,9 @@ sys_pty_ptsname(int fd, char *buf, int len) int pty = 0; if (0 == ioctl(fd, TIOCGPTN, &pty)) { - sxprintf(buf, len), "/dev/pts/%d", pty); + sxprintf(buf, len, "/dev/pts/%d", pty); if (0 != stat(buf, &sb)) { - pty_perror("warning: stat(\"%s\")", namebuf); + pty_perror("warning: stat(\"%s\")", buf); } return buf; } @@ -918,4 +918,4 @@ pty_tty_name(char *name, int major, int minor) return name; } -#endif /*unix*/ \ No newline at end of file +#endif /*unix*/ diff --git a/gr/regexp.c b/gr/regexp.c index 6b560afe..0ca4c005 100644 --- a/gr/regexp.c +++ b/gr/regexp.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_regexp_c,"$Id: regexp.c,v 1.49 2022/12/03 16:40:17 cvsuser Exp $") +__CIDENT_RCSID(gr_regexp_c,"$Id: regexp.c,v 1.50 2024/07/13 09:56:42 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: regexp.c,v 1.49 2022/12/03 16:40:17 cvsuser Exp $ +/* $Id: regexp.c,v 1.50 2024/07/13 09:56:42 cvsuser Exp $ * Regular expression engine. * * The orgin of this regular expression implementation has been lost with time, @@ -165,7 +165,7 @@ typedef struct { typedef int loopstate_t; -static int re_comp(recomp_t *rx); +static int re_compile(recomp_t *rx); static const char * re_atom(recomp_t *rx, const char *pattern); static const REGEXPATOM * re_nextblock(const REGEXPATOM *re); static int re_escape(const char **patternp, int *result); @@ -300,7 +300,7 @@ regexp_comp2(REGEXP *regexp, const struct regopts *options, const char *pattern) goto error; } - if (re_comp(&rx) < 0) { + if (re_compile(&rx) < 0) { goto error; } @@ -394,7 +394,7 @@ error:; static int -re_comp(recomp_t *rx) +re_compile(recomp_t *rx) { const size_t lastend_on_entry = rx->opend; const char *pattern = rx->pattern; @@ -468,7 +468,7 @@ re_comp(recomp_t *rx) LPUT16((LIST *)(rx->atoms + rx->opidx), 3); rx->opidx += 3; rx->pattern = ++pattern; - if (re_comp(rx) < 0) { + if (re_compile(rx) < 0) { --rx->level; return -1; } diff --git a/gr/regprog.h b/gr/regprog.h index b26b04e3..2c50d6e8 100644 --- a/gr/regprog.h +++ b/gr/regprog.h @@ -1,11 +1,11 @@ #ifndef GR_REGPROG_H_INCLUDED #define GR_REGPROG_H_INCLUDED #include -__CIDENT_RCSID(gr_regprog_h,"$Id: regprog.h,v 1.6 2021/04/12 15:16:10 cvsuser Exp $") +__CIDENT_RCSID(gr_regprog_h,"$Id: regprog.h,v 1.7 2024/07/14 16:07:33 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: regprog.h,v 1.6 2021/04/12 15:16:10 cvsuser Exp $ +/* $Id: regprog.h,v 1.7 2024/07/14 16:07:33 cvsuser Exp $ * Regular expression program interface. * * @@ -28,6 +28,9 @@ __CPRAGMA_ONCE #define ONIG_ESCAPE_REGEX_T_COLLISION #endif +#if defined(__sun) && defined(reg) +#undef reg /*FIXME*/ +#endif #include #include "regexp.h" /* local implementation */ diff --git a/gr/search.c b/gr/search.c index 86f9979e..fbb9c2b2 100644 --- a/gr/search.c +++ b/gr/search.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_search_c,"$Id: search.c,v 1.59 2022/08/14 12:38:51 cvsuser Exp $") +__CIDENT_RCSID(gr_search_c,"$Id: search.c,v 1.61 2024/07/13 10:24:01 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: search.c,v 1.59 2022/08/14 12:38:51 cvsuser Exp $ +/* $Id: search.c,v 1.61 2024/07/13 10:24:01 cvsuser Exp $ * Search interface. * * TODO: @@ -122,7 +122,7 @@ static const char * search_capture(const struct regprog *prog, int group, co static __CINLINE void search_end(struct re_state *rs); static __CINLINE void search_free(struct re_state *rs); -static int re_exec(struct regprog *prog, const char *buf, int buflen, int offset); +static int re_execute(struct regprog *prog, const char *buf, int buflen, int offset); static const char * re_capture(const struct regprog *prog, int group, const char **end); static void re_destroy(struct regprog *prog); @@ -131,7 +131,7 @@ static const char * on_capture(const struct regprog *prog, int group, const static void on_destroy(struct regprog *prog); #if defined(HAVE_LIBTRE) -static int tre_exec(struct regprog *prog, const char *buf, int buflen, int offset); +static int tre_execute(struct regprog *prog, const char *buf, int buflen, int offset); static const char * tre_capture(const struct regprog *prog, int group, const char **end); static void tre_destroy(struct regprog *prog); #endif @@ -563,7 +563,7 @@ do_search_string(void) /* (string pattern, string text, [int &length], on 'case'. Note!: - The 'search_string' primitive is provided primary for Crisp + The 'search_list' primitive is provided primary for Crisp compatibility. Since 're' and 'case' can reference the current global search states, inconsistent and/or unexpected results may result between usage; as such it is advised that the @@ -2007,7 +2007,7 @@ search_comp(struct re_state *rs, const char *pattern, int patlen) prog->engine = REGPROG_TRE; prog->hasgrps = TRUE; /* TODO */ - prog->exec = tre_exec; + prog->exec = tre_execute; prog->capture = tre_capture; prog->destroy = tre_destroy; @@ -2069,7 +2069,7 @@ search_comp(struct re_state *rs, const char *pattern, int patlen) prog->engine = REGPROG_REGEXP; prog->hasgrps = TRUE; /* TODO */ - prog->exec = re_exec; + prog->exec = re_execute; prog->capture = re_capture; prog->destroy = re_destroy; } @@ -2141,7 +2141,7 @@ search_free(struct re_state *rs) */ static int -re_exec(struct regprog *prog, const char *buf, int buflen, int offset) +re_execute(struct regprog *prog, const char *buf, int buflen, int offset) { REGEXP *regexp = &prog->rx.regexp; @@ -2290,7 +2290,7 @@ on_destroy(struct regprog *prog) */ static int -tre_exec(struct regprog *prog, const char *buf, int buflen, int offset) +tre_execute(struct regprog *prog, const char *buf, int buflen, int offset) { regex_t *regexp = &prog->rx.tre.regex; regmatch_t *regions = prog->rx.tre.regions; diff --git a/gr/sh_os2.c b/gr/sh_os2.c index 06816ca9..f2cb2db3 100644 --- a/gr/sh_os2.c +++ b/gr/sh_os2.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_sh_os2_c,"$Id: sh_os2.c,v 1.13 2014/10/22 02:33:19 ayoung Exp $") +__CIDENT_RCSID(gr_sh_os2_c,"$Id: sh_os2.c,v 1.14 2024/08/18 10:52:14 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: sh_os2.c,v 1.13 2014/10/22 02:33:19 ayoung Exp $ +/* $Id: sh_os2.c,v 1.14 2024/08/18 10:52:14 cvsuser Exp $ * * * This file is part of the GRIEF Editor. @@ -124,7 +124,7 @@ static const char * outdirect(const char *path, int *mode) { *mode = O_WRONLY|O_CREAT|O_TRUNC; - if (path) { + if (path) { if (*path == '>') { /* ">name" */ ++path; if (*path == '>') { /* ">>name" */ diff --git a/gr/sh_unix.c b/gr/sh_unix.c index 7588f925..6c130da6 100644 --- a/gr/sh_unix.c +++ b/gr/sh_unix.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_sh_unix_c,"$Id: sh_unix.c,v 1.19 2022/05/31 16:18:21 cvsuser Exp $") +__CIDENT_RCSID(gr_sh_unix_c,"$Id: sh_unix.c,v 1.20 2024/07/19 05:04:22 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: sh_unix.c,v 1.19 2022/05/31 16:18:21 cvsuser Exp $ +/* $Id: sh_unix.c,v 1.20 2024/07/19 05:04:22 cvsuser Exp $ * * Linux * Sun Solaris @@ -30,7 +30,7 @@ __CIDENT_RCSID(gr_sh_unix_c,"$Id: sh_unix.c,v 1.19 2022/05/31 16:18:21 cvsuser E #include -#if defined(unix) || defined(__APPLE__) +#if defined(unix) || defined(__unix__) || defined(__APPLE__) #if defined(HAVE_SPAWN_H) #include /* posix spawn interface */ diff --git a/gr/signals.c b/gr/signals.c index 5864a898..e47136ce 100644 --- a/gr/signals.c +++ b/gr/signals.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_signals_c,"$Id: signals.c,v 1.21 2024/04/16 10:30:36 cvsuser Exp $") +__CIDENT_RCSID(gr_signals_c,"$Id: signals.c,v 1.23 2024/08/25 06:01:53 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: signals.c,v 1.21 2024/04/16 10:30:36 cvsuser Exp $ +/* $Id: signals.c,v 1.23 2024/08/25 06:01:53 cvsuser Exp $ * Signal handling. * * @@ -24,7 +24,7 @@ __CIDENT_RCSID(gr_signals_c,"$Id: signals.c,v 1.21 2024/04/16 10:30:36 cvsuser E #include #include /* str_...()/sxprintf() */ -#include "signals.h" /* public interface */ +#include "signals.h" /* public interface */ #include "builtin.h" #include "debug.h" @@ -40,7 +40,7 @@ static int x_fatallevel = 0; /* Fatal exception level */ static void signal_mode0(void); static void signal_mode1(void); static const char * signame(int sig, int unknown); -static int sigfatal(int sig, const char **name); +static int sigfatal(int sig, const char *name); extern void sighandler_int(int sig); extern void sighandler_tstp(int sig); @@ -81,7 +81,7 @@ signal_mode0(void) { signal(SIGINT, sighandler_int); -#if defined(linux) || defined(unix) || defined(_AIX) || defined(__APPLE__) +#if defined(linux) || defined(unix) || defined(__unix__) || defined(_AIX) || defined(__APPLE__) if (xf_sigtrap) { #if defined(SIGBUS) signal(SIGBUS, sighandler_sys1); /* bus error */ @@ -117,7 +117,7 @@ signal_mode1(void) * Signal handlers. */ if (xf_sigtrap) { -#if defined(linux) || defined(unix) || defined(_AIX) || defined(__APPLE__) +#if defined(linux) || defined(unix) || defined(__unix__) || defined(_AIX) || defined(__APPLE__) #if defined(SIGBUS) signal(SIGBUS, sighandler_sys2); /* bus error */ #endif @@ -293,19 +293,20 @@ signame(int sig, int unknown) * Common fatal handler. */ static __CINLINE int -sigfatal(int sig, const char **name) +sigfatal(int sig, const char *name) { - const char *t_name = signame(sig, TRUE); const int level = ++x_fatallevel; + if (NULL == name) + name = signame(sig, TRUE); + if (1 == level) { char buf[100]; signal(sig, SIG_DFL); /* reset handler */ - sxprintf(buf, sizeof(buf), "_fatal_error %d \"%s\"", sig, t_name); + sxprintf(buf, sizeof(buf), "_fatal_error %d \"%s\"", sig, name); execute_str(buf); } - *name = t_name; return level; } @@ -329,7 +330,7 @@ sighandler_sys1(int sig) } -#if defined(linux) || defined(unix) || defined(_AIX) || defined(__APPLE__) +#if defined(linux) || defined(unix) || defined(__unix__) || defined(_AIX) || defined(__APPLE__) /* * sighandler_sys2 --- * SIGBUS/SIGSEGV/SIGIOT fatal handler, single level handler. @@ -382,7 +383,7 @@ void sighandler_sys2(int sig) { const char *name = signame(sig, TRUE); - const int level = sigfatal(sig, &name); + const int level = sigfatal(sig, name); xf_dumpcore = 2; /* dump core on exit */ @@ -534,3 +535,4 @@ sighandler_danger(int sig) #endif /*SIGDANGER*/ /*end*/ + diff --git a/gr/syntax.c b/gr/syntax.c index 0ceec768..2e627a28 100644 --- a/gr/syntax.c +++ b/gr/syntax.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_syntax_c, "$Id: syntax.c,v 1.68 2022/09/13 14:31:24 cvsuser Exp $") +__CIDENT_RCSID(gr_syntax_c, "$Id: syntax.c,v 1.71 2024/08/01 17:11:43 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: syntax.c,v 1.68 2022/09/13 14:31:24 cvsuser Exp $ +/* $Id: syntax.c,v 1.71 2024/08/01 17:11:43 cvsuser Exp $ * Syntax pre-processor. * * @@ -22,6 +22,7 @@ __CIDENT_RCSID(gr_syntax_c, "$Id: syntax.c,v 1.68 2022/09/13 14:31:24 cvsuser Ex #include /* str_...()/sxprintf() */ #include "accum.h" +#include "buffer.h" #include "color.h" /* attribute_value() */ #include "builtin.h" #include "debug.h" @@ -434,7 +435,7 @@ do_set_syntax_flags(void) /* int ([int flags], [int|string syntable]) */ A Grief extension. Macro See Also: - create_syntax, set_syntax_flags, inq_syntax + create_syntax, set_syntax_flags, inq_syntax, inq_syntax_name */ void inq_syntax(void) /* ([int &flags], [int|string syntable]) */ @@ -450,6 +451,43 @@ inq_syntax(void) /* ([int &flags], [int|string syntable]) */ } +/*<> + Macro: inq_syntax_name - Retrieve the syntax name. + + int + inq_syntax_name([int bufnum]) + + Macro Description: + The 'inq_syntax_name()' primitive retrieves the name of the syntax + associated with the specified buffer. + + Macro Parameters: + bufnum - Optional buffer number, if omitted the current buffer + shall be referenced. + + Macro Returns: + The 'inq_syntax_name()' primitive returns the syntax-table + name, otherwise an empty string. + + Macro Portability: + A Grief extension. + + Macro See Also: + create_syntax, set_syntax_flags, inq_syntax + */ +void +inq_syntax_name(void) /* [int bufnum = -1]) */ +{ + BUFFER_t* bp = buf_argument(1); + SyntaxTable_t* st = NULL; + + if (bp) { + st = bp->b_syntax; + } + acc_assign_str(st ? st->st_name : "", -1); +} + + /*<> Macro: define_keywords - Add keywords to a syntax dictionary. @@ -802,11 +840,16 @@ keyword_push_pat(SyntaxTable_t *st, int attr, int length, int total, const char st->keyword_patterns = patterns = trie_create(); } +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" /*XXX*/ +#endif if (sep) { const char *end = keywords + total + /*seps*/count; while (keywords < end) { assert(sep == keywords[length] || 0 == keywords[length]); trace_ilog("\t%.*s\n", length, keywords); + trie_insert_nwild(patterns, (const char *)keywords, length, (void *)attr); keywords += length + /*sep*/1; ++elements; @@ -821,6 +864,9 @@ keyword_push_pat(SyntaxTable_t *st, int attr, int length, int total, const char ++elements; } } +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif return elements; } @@ -2097,7 +2143,14 @@ syntax_keywordx(const SyntaxTable_t *st, const LINECHAR *token, int length, int const void *attr = trie_search_nwild(st->keyword_patterns, (const char *)token, length); if (attr) { +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpointer-to-int-cast" /*XXX*/ +#endif return (int)attr; /* associated attribute */ +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif } } diff --git a/gr/syntax.h b/gr/syntax.h index 252b07cd..7471d006 100644 --- a/gr/syntax.h +++ b/gr/syntax.h @@ -1,11 +1,11 @@ #ifndef GR_SYNTAX_H_INCLUDED #define GR_SYNTAX_H_INCLUDED #include -__CIDENT_RCSID(gr_syntax_h,"$Id: syntax.h,v 1.39 2022/08/28 12:38:01 cvsuser Exp $") +__CIDENT_RCSID(gr_syntax_h,"$Id: syntax.h,v 1.40 2024/08/01 14:10:44 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: syntax.h,v 1.39 2022/08/28 12:38:01 cvsuser Exp $ +/* $Id: syntax.h,v 1.40 2024/08/01 14:10:44 cvsuser Exp $ * Syntax hiliting constructs. * * @@ -416,6 +416,7 @@ extern void do_syntax_rule(void); extern void do_syntax_token(void); extern void do_syntax_find(void); extern void inq_syntax(void); +extern void inq_syntax_name(void); __CEND_DECLS diff --git a/gr/sys_dos.c b/gr/sys_dos.c index 78f585de..706ad23e 100644 --- a/gr/sys_dos.c +++ b/gr/sys_dos.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_sys_dos_c,"$Id: sys_dos.c,v 1.38 2023/09/10 16:35:52 cvsuser Exp $") +__CIDENT_RCSID(gr_sys_dos_c,"$Id: sys_dos.c,v 1.39 2024/08/25 06:01:53 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: sys_dos.c,v 1.38 2023/09/10 16:35:52 cvsuser Exp $ +/* $Id: sys_dos.c,v 1.39 2024/08/25 06:01:53 cvsuser Exp $ * * * This file is part of the GRIEF Editor. @@ -419,12 +419,12 @@ mouse_area(void) int rows, columns; ttgetsize(&rows, &columns); - regs.x.cx = 0; /* mouse visible between cx and dx */ + regs.x.cx = 0; /* mouse visible between cx and dx */ regs.x.dx = columns * mouse_x_div - 1; regs.x.ax = 7; (void)int86(0x33, ®s, ®s); - regs.x.cx = 0; /* mouse visible between cx and dx */ + regs.x.cx = 0; /* mouse visible between cx and dx */ regs.x.dx = rows * mouse_y_div - 1; regs.x.ax = 8; (void)int86(0x33, ®s, ®s); @@ -437,14 +437,14 @@ sys_mousepoll(fd_set *fds, struct MouseEvent *m) { (void) fds; - if (!mouse_avail || !mouse_click) { + if (!mouse_avail || 0 == mouse_click) { return FALSE; } - m->b1 = (mouse_click & MOUSE_LEFT); - m->b2 = (mouse_click & MOUSE_RIGHT); - m->b3 = (mouse_click & MOUSE_MIDDLE); - m->multi = (mouse_click & MOUSE_DOUBLE); + m->b1 = (mouse_click & MOUSE_LEFT); + m->b2 = (mouse_click & MOUSE_RIGHT); + m->b3 = (mouse_click & MOUSE_MIDDLE); + m->multi = (mouse_click & MOUSE_DOUBLE) ? 1 : 0; if (mouse_click & MOUSE_DRAG) { m->x = mouse_x; m->y = mouse_y; @@ -452,6 +452,8 @@ sys_mousepoll(fd_set *fds, struct MouseEvent *m) m->x = mouse_click_x; m->y = mouse_click_y; } + m->type = (mouse_click == MOUSE_RELEASE ? MOUSEEVT_TRELEASE : + (mouse_click == MOUSE_DRAG ? MOUSEEVT_TMOTION : 0)); mouse_click = 0; return TRUE; } @@ -479,6 +481,22 @@ sys_mousepointer(int on) #endif /*HAVE_MOUSE*/ +/* Function: sys_doubleclickms + * System double-click time. + * + * Parameters: + * none + * + * Returns: + * Returns double-click time is milliseconds. + */ +unsigned +sys_doubleclickms(void) +{ + return 500; +} + + #define BIOSTICK 55 /* biostime() about every 55 msec */ static KEY @@ -498,9 +516,9 @@ vio_keyxlat(int key) * the specified timeout 'tmo'. * * Parameters: - * fd - File descriptor. - * buf - Output buffer. - * tmo - Timeout, in milliseconds. + * fd - File descriptor. + * buf - Output buffer. + * tmo - Timeout, in milliseconds. * * Returns: * On success (1), otherwise (0) unless a timeout (-1). @@ -842,4 +860,4 @@ sys_realpath(const char *name, char *buf) return buf; } -#endif /*__MSDOS__*/ +#endif /*__MSDOS__*/ diff --git a/gr/sys_os2.c b/gr/sys_os2.c index f3e621a9..5c1a2076 100644 --- a/gr/sys_os2.c +++ b/gr/sys_os2.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_sys_os2_c,"$Id: sys_os2.c,v 1.28 2023/09/10 16:35:52 cvsuser Exp $") +__CIDENT_RCSID(gr_sys_os2_c,"$Id: sys_os2.c,v 1.30 2024/09/21 09:05:16 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: sys_os2.c,v 1.28 2023/09/10 16:35:52 cvsuser Exp $ +/* $Id: sys_os2.c,v 1.30 2024/09/21 09:05:16 cvsuser Exp $ * * * This file is part of the GRIEF Editor. @@ -299,7 +299,7 @@ sys_noinherit(int fd) } -/* System specific copy, under OS/2's DosCopy is faster and may +/* System specific copy, under OS/2's DosCopy is faster and may * be able to preserve EA's */ int @@ -351,7 +351,7 @@ kbhit(void) /* Function: sys_getchar - * Retrieve the character from the status keyboard stream, within + * Retrieve the character from the status keyboard stream, within * the specified timeout 'tmo'. * * Parameters: @@ -364,7 +364,7 @@ kbhit(void) */ int sys_getchar(int fd, int *buf, accint_t tmo) -{ +{ KBDKEYINFO ky; (void)fd; (void)(tmo); (void)(mt); @@ -384,7 +384,7 @@ sys_getchar(int fd, int *buf, accint_t tmo) * * Returns: * *true* or *false*. - */ + */ int sys_iocheck(struct IOEvent *evt) { @@ -507,7 +507,7 @@ getcwd(char *buffer, size_t size) #endif -/* +/* * sys_getcwd --- */ void @@ -518,7 +518,7 @@ sys_cwdd(int drv, char *path, int size) } -/* +/* * Get current drive --- */ int @@ -569,7 +569,7 @@ sys_fstype(const char *path) } -/* +/* * Set the current drive --- */ int @@ -597,7 +597,7 @@ sys_enable_char(int ch, int enable) } -/* +/* * Routines which are machine independent but are useful for * making the rest of the code portable, especially to VMS. */ @@ -678,7 +678,7 @@ sys_mousepoll(fd_set *fds, struct MouseEvent *m) return FALSE; } - if (MouGetNumQueEl(&qi, mouse_fd) != 0 || + if (MouGetNumQueEl(&qi, mouse_fd) != 0 || !qi.cEvents || MouReadEventQue(&me, &p, mouse_fd) != 0) { return FALSE; } @@ -688,7 +688,6 @@ sys_mousepoll(fd_set *fds, struct MouseEvent *m) m->b1 = (me.fs & MOUSE_BN1_DOWN) != 0; m->b2 = (me.fs & MOUSE_BN2_DOWN) != 0; m->b3 = (me.fs & MOUSE_BN3_DOWN) != 0; - m->mutli = 0; return TRUE; } @@ -702,7 +701,7 @@ sys_mousepointer(int state) MouDrawPtr(mouse_fd); } mouse_is_visible = 1; - + } else if (mouse_is_visible) { NOPTRRECT pr; @@ -718,3 +717,4 @@ sys_mousepointer(int state) #endif /*HAVE_MOUSE*/ #endif /*__OS2__*/ + diff --git a/gr/sys_unix.c b/gr/sys_unix.c index aa491e26..57fd81dc 100644 --- a/gr/sys_unix.c +++ b/gr/sys_unix.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_sys_unix_c,"$Id: sys_unix.c,v 1.65 2024/04/27 15:22:03 cvsuser Exp $") +__CIDENT_RCSID(gr_sys_unix_c,"$Id: sys_unix.c,v 1.70 2024/09/21 09:05:16 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: sys_unix.c,v 1.65 2024/04/27 15:22:03 cvsuser Exp $ +/* $Id: sys_unix.c,v 1.70 2024/09/21 09:05:16 cvsuser Exp $ * System dependent functionality - UNIX. * * @@ -50,6 +50,7 @@ __CIDENT_RCSID(gr_sys_unix_c,"$Id: sys_unix.c,v 1.65 2024/04/27 15:22:03 cvsuser #include "keyboard.h" #include "system.h" /* sys_...() */ #include "tty.h" +#include "ttyutil.h" #include "edstacktrace.h" #include "m_pty.h" @@ -86,7 +87,12 @@ static int nonblocking(int fd); #define MOUSE_NONE 0x00 /* mouse types */ #define MOUSE_GPM 0x01 #define MOUSE_X11 0x02 -#define MOUSE_XTERM 0x03 +#define MOUSE_XTERM 0x10 +#define MOUSE_XTERM_X11 0x11 +#define MOUSE_XTERM_SGR 0x12 + +static int xterm_mouse_detect(void); +static void xterm_mouse_keys(void); static const char * mouse_dev = NULL; /* mouse device name/type */ static int mouse_fd = -1; /* fd resource, if any */ @@ -197,7 +203,21 @@ sys_initialise(void) /* nt.c_iflag &= ~IXON; -* disable stop/start output flow control */ nt.c_oflag &= ~OPOST; /* disable output processing. */ +/* --- review +#if defined(ONLCR) // disable NL -> CR/NL mapping. +# if defined(XTABS) // disable expanding tabs if possible. + nt.c_oflag &= ~(ONLCR | XTABS); +# else +# if defined(TAB3) + nt.c_oflag &= ~(ONLCR | TAB3); +# else + nt.c_oflag &= ~ONLCR; +# endif +# endif +#endif + */ + nt.c_cflag &= ~CSIZE; /* clear existing CS5, CS6, CS7, or CS8 */ nt.c_cflag |= CS8; /* allow 8th bit on input. */ nt.c_cflag &= ~PARENB; /* don't check parity. */ @@ -354,7 +374,7 @@ sys_iocheck(struct IOEvent *evt) unsigned char ch = 0; sys_tty_delay(TTY_INFD, 0); - if (1 == read(TTY_INFD, (char *)&ch, 1)) { + if (1 == read(TTY_INFD, (void *)&ch, 1)) { evt->type = EVT_KEYRAW; /* uncooked key */ evt->code = ch; return TRUE; @@ -434,7 +454,7 @@ sys_getchar(int fd, int *ibuf, accint_t tmo) #endif n = read(TTY_INFD, (char *) buf, 1); } - *ibuf = buf[0]; + *ibuf = (int)buf[0]; if (n == 1) { return 1; } @@ -502,7 +522,7 @@ sys_getshell(void) if (NULL == shname) { shname = ggetenv("SHELL"); } -#if defined(__CYGWIN__) +#if defined(__CYGWIN__) || defined(linux) || defined(__APPLE__) || defined(BSD) if (NULL == shname && 0 == access("/bin/bash", F_OK)) { shname = "/bin/bash"; } @@ -687,6 +707,72 @@ sys_read(int fd, void *buf, int size) } +/* + * sys_read_timed --- + * Read from a file descriptor, against a trigger timeout in millseconds. + */ +int +sys_read_timed(int fd, void *buf, int size, unsigned timeoutms, unsigned *remainingms) +{ + const int osize = size, + interval = (timeoutms ? (timeoutms > 500 ? 100 : 50) : 0); + unsigned duration = timeoutms; + char *data = (char *)buf; + + while (size > 0) { + struct pollfd fds = {0}; + int ready, n; + + fds.fd = fd; + fds.events = POLLIN; + ready = poll(&fds, 1, interval); + + if (0 == ready) { /* timeout */ + if (0 == interval) break; + if (duration <= interval) { + duration = 0; + break; + } + duration -= interval; + if (osize != size) + break; + continue; + + } else if (-1 == ready) { /* error */ + if (errno == EINTR || errno == EAGAIN) + continue; + break; + } + + if (fds.revents & (POLLERR|POLLHUP)) { + if (osize == size) { + return -1; + } + break; + } + + if (0 == (fds.revents & POLLIN)) + break; + + if ((n = read(fd, data, size)) <= 0) { + if (n < 0 && osize == size) { + return -1; + } + break; + } + + size -= n; + data += n; + } + + if (remainingms) { + *remainingms = (timeoutms > duration ? timeoutms - duration : 0); + } + + return (osize - size); +} + + /* * sys_write --- * Write to a file descriptor. @@ -701,13 +787,13 @@ sys_write(int fd, const void *buf, int size) do { /* EINTR safe */ if ((n = write(fd, data, size)) >= 0) { data += n, cnt += n; - if ((size -= n) <= 0) { + if ((size -= n) <= 0) { if (nblock) { nonblocking(fd); } return cnt; /* success */ - } - } + } + } } while (n >= 0 || (n < 0 && errno == EINTR)); if (nblock) { nonblocking(fd); @@ -1141,7 +1227,8 @@ sys_abort(void) * Signal handler installation. * * Parameters: - * XXX - + * sig - signal number. + * func - handler function. * * Returns: * Returns 0 on success, otherwise -1; @@ -1157,7 +1244,7 @@ sys_signal(int sig, signal_handler_t func) * Determine if given process is still running. * * Parameters: - * pid - Process identifier. + * pid - Process identifier. * * Returns: * Returns 1 if the processing is still running, 0 if not otherwise -1 on an error condition. @@ -1174,7 +1261,6 @@ sys_running(int pid) } - #if defined(HAVE_MOUSE) /* * sys_mouseinit --- @@ -1198,32 +1284,26 @@ sys_mouseinit(const char *dev) } if (NULL == dev || '\0' == *dev) { - if (NULL == (dev = bmouse)) { /* BMOUSE or auto-configure */ - static const struct { - unsigned len; - const char *desc; - } xtermlike[] = { -#define XTERMLIKE(x) { sizeof(x)-1, x } - XTERMLIKE("xterm"), - XTERMLIKE("rxvt"), - XTERMLIKE("Eterm"), - XTERMLIKE("dtterm"), - XTERMLIKE("cygwin") - }; -#undef XTERMLIKE - - const char *term = ggetenv("TERM"); - - if (term) { - unsigned i; - /* e.g. xterm-color */ - for (i = 0; i < (sizeof(xtermlike)/sizeof(xtermlike[0])); ++i) - if (strncmp(term, xtermlike[i].desc, xtermlike[i].len) == 0 && - ('\0' == term[xtermlike[i].len] || '-' == term[xtermlike[i].len])) { - xterm = 1; /* known xterm, force xterm */ - break; - } - } + dev = bmouse; /* BMOUSE or auto-configure */ + } + + if (NULL == dev || '\0' == *dev) { + if (ttxtermlike() | xterm_mouse_detect()) { + xterm = MOUSE_XTERM_SGR; + dev = "xterm-sgr"; + } + + } else { + if (0 == strcmp(dev, "sgr") || 0 == strcmp(dev, "xterm-sgr")) { + xterm = MOUSE_XTERM_SGR; + dev = "xterm-sgr"; + + } else if (0 == strcmp(dev, "xterm2") || 0 == strcmp(dev, "xterm-x11")) { + xterm = MOUSE_XTERM_X11; + dev = "xterm-x11"; + + } else if (0 == strcmp(dev, "xterm")) { + xterm = MOUSE_XTERM; } } @@ -1247,39 +1327,45 @@ sys_mouseinit(const char *dev) io_device_add(gpm_fd); mouse_type = MOUSE_GPM; - } else if (-2 == mouse_fd) { /* running under xterm */ - /* ttpush("\033[?1000h"); */ - key_define_key_seq(MOUSE_KEY, "\x1b[M"); + } else if (-2 == mouse_fd) { + key_define_key_seq(MOUSE_XTERM_KEY, "\x1b[M"); mouse_type = MOUSE_XTERM; mouse_fd = -1; } -#endif /*HAVE_LIBGPM*/ +#endif /*HAVE_LIBGPM*/ - } else if (xterm || (dev && 0 == strcmp(dev, "xterm"))) { + } else if (xterm) { /* - * xterm - * o 1001 not supported under Cygwin, causes terminal state corruption. + * xterm/xterm-x11/xterm-sgr */ #if !defined(__CYGWIN__) - ttpush("\033[?1001s"); /* save old highlight mouse tracking */ + ttpush("\033[?1001s"); /* disable/save highlight mouse tracking. */ #endif - ttpush("\033[?1000h"); /* enable mouse tracking */ + if (xterm == MOUSE_XTERM) { + ttpush("\033[?1000h"); /* enable mouse presses. */ + } else { + ttpush("\033[?1002h"); /* enable cell-motion tracking tracking. */ + if (xterm == MOUSE_XTERM_SGR) { + //ttpush("\033[?1003h"); /* enable any-event tracking mode. */ + ttpush("\033[?1006h"); /* enable SGR extended mouse mode. */ + } + ttpush("\033[?1004h"); /* enable mouse focus events. */ + } ttflush(); - - key_define_key_seq(MOUSE_KEY, "\x1b[M"); - mouse_type = MOUSE_XTERM; - dev = "xterm"; + xterm_mouse_keys(); + mouse_type = xterm; } else { /* X11 */ /* * X11 mouse -- - * if open fails, then no mouse support is available. - * + * If open fails, then no mouse support is available. * Fail quietly so we can use same aliases with or without mouse support. */ TERMIO mouse_term; - dev = (bmouse ? bmouse : "/dev/tty00"); /* /dev/tty00 as default */ + if (NULL == dev || dev[0] != '/') + dev = (bmouse ? bmouse : "/dev/tty00"); /* /dev/tty00 as default */ + mouse_fd = open(dev, O_RDONLY | O_EXCL); if (mouse_fd != -1) { /* Make mouse device into raw mode, etc */ @@ -1315,10 +1401,39 @@ sys_mouseinit(const char *dev) trace_ilog("mouse_init(%s) : %d (%d)\n", (dev ? dev : "n/a"), (mouse_type == MOUSE_NONE ? -1 : 0), mouse_fd); - if (mouse_type != MOUSE_NONE) { - return (TRUE); - } - return (FALSE); + return (mouse_type != MOUSE_NONE); +} + + +static int +xterm_mouse_detect(void) +{ + const char *name = ggetenv("TERM"); + return (name != NULL && ( /* Also See: term_xtermlike() */ + tty_isterm(name, "screen") || + tty_isterm(name, "tmux") || + tty_isterm(name, "st") || + tty_isterm(name, "stterm"))); +} + + +static void +xterm_mouse_keys(void) +{ + /* X10 compatibility mode (1000) */ + key_define_key_seq(MOUSE_XTERM_KEY, "\x1b[M"); + + /* SGR mode (1006) */ + key_define_key_seq(MOUSE_SGR_KEY, "\x1b[<"); + + /* FocusIn/FocusOut (1004): + * + * FocusIn/FocusOut can be combined with any of the mouse events since it uses a different protocol. + * When set, it causes xterm to send "CSI I" when the terminal gains focus, and "CSI O" when it loses focus. + * + */ + key_define_key_seq(MOUSE_FOCUSIN_KEY, "\x1b[I"); + key_define_key_seq(MOUSE_FOCUSOUT_KEY, "\x1b[O"); } @@ -1331,6 +1446,9 @@ sys_mouseclose(void) { switch (mouse_type) { case MOUSE_GPM: + /* + * GPM driver + */ #if defined(HAVE_LIBGPM) && defined(HAVE_GPM_H) if (mouse_fd != -1) { io_device_remove(gpm_fd); @@ -1341,6 +1459,9 @@ sys_mouseclose(void) break; case MOUSE_X11: + /* + * X11 mouse + */ if (mouse_fd != -1) { io_device_remove(mouse_fd); close(mouse_fd); @@ -1349,13 +1470,23 @@ sys_mouseclose(void) break; case MOUSE_XTERM: + case MOUSE_XTERM_X11: + case MOUSE_XTERM_SGR: /* - * xterm - * o 1001 not supported under Cygwin, causing terminal state corruption. + * xterm/xterm-x11/xterm-sgr */ - ttpush("\033[?1000l"); /* disable mouse tracking */ + if (mouse_type == MOUSE_XTERM) { + ttpush("\033[?1000l"); /* disable mouse presses. */ + } else { + ttpush("\033[?1004h"); /* disable mouse focus events. */ + if (mouse_type == MOUSE_XTERM_SGR) { + //ttpush("\033[?1003l"); /* disable any-event tracking mode. */ + ttpush("\033[?1006l"); /* disable SGR extended mouse mode. */ + } + ttpush("\033[?1002l"); /* disable cell-motion tracking tracking. */ + } #if !defined(__CYGWIN__) - ttpush("\033[?1001r"); /* restore old highlight mouse tracking */ + ttpush("\033[?1001r"); /* restore highlight mouse tracking. */ #endif ttflush(); break; @@ -1395,7 +1526,8 @@ sys_mousepoll(fd_set *fds, struct MouseEvent *m) } else { m->multi = 0; } - + m->type == (ev.type == GPM_DRAG ? MOUSEEVT_TMOTION : + (ev.type == GPM_DOWN ? MOUSEEVT_TPRESS : 0); trace_ilog("mouse_event(%0x[%d,%d])\n", ev.type, ev.x, ev.y); return TRUE; } @@ -1408,7 +1540,7 @@ sys_mousepoll(fd_set *fds, struct MouseEvent *m) break; case MOUSE_X11: { - static int x_pitch, y_pitch; + static int pitch_x, pitch_y; static int max_x, max_y; unsigned char mbuf[3]; int n; @@ -1417,11 +1549,11 @@ sys_mousepoll(fd_set *fds, struct MouseEvent *m) break; } - if (x_pitch == 0) { - x_pitch = MAX_X / ttcols(); - y_pitch = MAX_Y / ttrows(); - max_x = x_pitch * (ttcols() - 1); - max_y = y_pitch * (ttrows() - 1); + if (pitch_x == 0) { + pitch_x = MAX_X / ttcols(); + pitch_y = MAX_Y / ttrows(); + max_x = pitch_x * (ttcols() - 1); + max_y = pitch_y * (ttrows() - 1); } /* @@ -1439,7 +1571,7 @@ sys_mousepoll(fd_set *fds, struct MouseEvent *m) return FALSE; if (mbuf[1] != 0x80) { - int d = mbuf[1] & 0x3f; + const int d = mbuf[1] & 0x3f; if (mbuf[0] & 0x03) { m->x -= 0x40 - d; } else { @@ -1448,7 +1580,7 @@ sys_mousepoll(fd_set *fds, struct MouseEvent *m) } if (mbuf[2] != 0x80) { - int d = mbuf[2] & 0x3f; + const int d = mbuf[2] & 0x3f; if (mbuf[0] & 0x0c) { m->y -= 0x40 - d; } else { @@ -1458,29 +1590,52 @@ sys_mousepoll(fd_set *fds, struct MouseEvent *m) m->b1 = (mbuf[0] & 0x20) != 0; m->b2 = (mbuf[0] & 0x10) != 0; m->b3 = 0; - m->multi = 0; + m->multi = -1; /* * Check againt dim, limit bottom-right usage to * remove possible scrolling issues. */ - if (m->y < 0) m->y = 0; - if (m->x < 0) m->x = 0; - if (m->y >= max_y) m->y = max_y - 1; - if (m->x > max_x) m->x = max_x; + if (m->y < 0) m->y = 0; + if (m->x < 0) m->x = 0; + if (m->y >= max_y) m->y = max_y - 1; + if (m->x > max_x) m->x = max_x; if (m->x == max_x - 1 && m->y == max_y - 1) { --m->x; } if (m->y != mouse_oldy || m->x != mouse_oldx) { - vtmouseicon(m->y / y_pitch, m->x / x_pitch, mouse_oldy / y_pitch, mouse_oldx / x_pitch); + vtmouseicon(m->y / pitch_y, m->x / pitch_x, mouse_oldy / pitch_y, mouse_oldx / pitch_x); mouse_oldy = m->y; mouse_oldx = m->x; } return TRUE; } break; + +// case MOUSE_CONSOLE: +// // see: +// // https://man7.org/linux/man-pages/man4/console_ioctl.4.html +// // and https://github.com/Lyude/libinput +// // +// +// libinput_dispatch(li); +// while (((event = libinput_get_event(li)) != NULL) { +// if (libinput_event_get_type(event) == LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE) { +// :: +// } +// if (libinput_event_get_type(event) == LIBINPUT_EVENT_POINTER_MOTION) { +// :: +// } +// if (libinput_event_get_type(event) == LIBINPUT_EVENT_POINTER_BUTTON) { +// :: +// } +// if (libinput_event_get_type(event) == LIBINPUT_EVENT_POINTER_AXIS) { +// :: +// } +// } +// break; } return FALSE; } @@ -1491,6 +1646,25 @@ sys_mousepointer(int on) { (void) on; } + #endif /*HAVE_MOUSE*/ +/* Function: sys_doubleclickms + * System double-click time. + * + * Parameters: + * none + * + * Returns: + * Returns double-click time is milliseconds. + */ +unsigned +sys_doubleclickms(void) +{ + //return GetDoubleClickTime(); /* os configuration? */ + return 500; //ms +} + #endif /*!_VMS && !__OS2__ && !__MSDOS__*/ + +//end diff --git a/gr/sys_win32.c b/gr/sys_win32.c index 97ced822..232410e8 100644 --- a/gr/sys_win32.c +++ b/gr/sys_win32.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_sys_win32_c,"$Id: sys_win32.c,v 1.75 2024/05/19 09:08:31 cvsuser Exp $") +__CIDENT_RCSID(gr_sys_win32_c,"$Id: sys_win32.c,v 1.81 2024/09/08 16:29:24 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: sys_win32.c,v 1.75 2024/05/19 09:08:31 cvsuser Exp $ +/* $Id: sys_win32.c,v 1.81 2024/09/08 16:29:24 cvsuser Exp $ * WIN32 system support. * * @@ -61,6 +61,8 @@ static void CALLBACK HandleWinEvent(HWINEVENTHOOK hook, DWORD event, HWND static int Resize(int winch); static int ResizeCheck(unsigned *checks); +static void OutputDebugPrintA(const char* fmt, ...); + #if defined(__WATCOMC__) #if (__WATCOMC__ >= 1300) /*XXX, still supported?*/ volatile char __WD_Present = 0; @@ -257,6 +259,22 @@ sys_mousepointer(int on) } +/* Function: sys_doubleclickms + * System double-click time. + * + * Parameters: + * none + * + * Returns: + * Returns double-click time is milliseconds. + */ +unsigned +sys_doubleclickms(void) +{ + return GetDoubleClickTime(); /* default=500ms */ +} + + /* Function: sys_noinherit * Make sure we don't inherit the specified file descriptor when we create a new process. * @@ -386,32 +404,63 @@ Modifiers(const DWORD dwControlKeyState) } +// MouseProcess --- +// Process a console mouse event. +// +// Notes: +// o Mouse events are placed in the input buffer when the console is in mouse mode (ENABLE_MOUSE_INPUT). +// o Mouse events are generated whenever the user moves the mouse, or presses or releases one of the mouse buttons. +// o Mouse events are placed in a console's input buffer only when the console group has the keyboard focus +// and the cursor is within the borders of the console's window. +// o Focus is retained if button are active and the mouse cursor is moved outside the window borders, +// with reported positions clipped to the borders. +// o Coordinate system (0, 0) is at the top, left cell of the buffer. +// static int -MouseEvent(const DWORD dwEventFlags, const DWORD dwButtonState) +MouseProcess(const MOUSE_EVENT_RECORD *mer) { - const int move = (dwEventFlags & MOUSE_MOVED ? 1 : 0); - const int multi = (dwEventFlags & DOUBLE_CLICK ? 1 : 0); - - if (dwButtonState & FROM_LEFT_1ST_BUTTON_PRESSED) { - //button1 - if (move) return BUTTON1_MOTION; - return (multi ? BUTTON1_DOUBLE : BUTTON1_DOWN); - - } else if (dwButtonState & RIGHTMOST_BUTTON_PRESSED) { - //button2 - if (move) return BUTTON2_MOTION; - return (multi ? BUTTON2_DOUBLE : BUTTON2_DOWN); - - } else if (dwButtonState & FROM_LEFT_2ND_BUTTON_PRESSED) { - //button3 - if (move) return BUTTON3_MOTION; - return (multi ? BUTTON3_DOUBLE : BUTTON3_DOWN); + struct MouseEvent me = { 0 }; + const DWORD dwButtonState = mer->dwButtonState; + const DWORD dwControlKeyState = mer->dwControlKeyState; + const DWORD dwEventFlags = mer->dwEventFlags; + + // meta data + me.x = mer->dwMousePosition.X + 1; + me.y = mer->dwMousePosition.Y + 1; + me.b1 = (dwButtonState & FROM_LEFT_1ST_BUTTON_PRESSED) ? 1 : 0; + me.b2 = (dwButtonState & FROM_LEFT_2ND_BUTTON_PRESSED) ? 1 : 0; + me.b3 = (dwButtonState & RIGHTMOST_BUTTON_PRESSED) ? 1 : 0; + if (dwControlKeyState & ALT_PRESSED) + me.ctrl |= MOUSEEVENT_CMETA; + if (dwControlKeyState & CTRL_PRESSED) + me.ctrl |= MOUSEEVENT_CCTRL; + if (dwControlKeyState & SHIFT_PRESSED) + me.ctrl |= MOUSEEVENT_CSHIFT; + me.multi = 0; + + if (dwEventFlags == MOUSE_MOVED) { + // motion events + if (me.b1 | me.b2 | me.b3) { + me.type = MOUSEEVENT_TMOTION; + mouse_process(&me, ""); + return 1; + } + } else { + // button events + assert(dwEventFlags == 0 || dwEventFlags == DOUBLE_CLICK); + if (dwEventFlags == DOUBLE_CLICK) + me.multi = 1; + me.type = MOUSEEVENT_TPRESSRELEASE; + mouse_process(&me, ""); + return 1; } return 0; } -// Alt+ event handler +// AltPlusEnabled, AltPlusEvent --- +// +// Alt+ event handler // // Alt+KeyCode works and behaves well when character only input is required, by simply // reporting any down or up key events which populate the 'UnicodeChar' value. Whereas @@ -425,11 +474,11 @@ MouseEvent(const DWORD dwEventFlags, const DWORD dwButtonState) // to filter. Furthermore, if during the key-code entry an invalid non-hex key combination is // given, the key-code is invalidated and UnicodeChar=0 is returned on the ALT release. // -// Notes: -// o To enable requires the registry REG_SZ value "EnableHexNumpad" under -// "HKEY_Current_User/Control Panel/Input Method" to be "1". +// Notes: +// o To enable requires the registry REG_SZ value "EnableHexNumpad" under +// "HKEY_Current_User/Control Panel/Input Method" to be "1". // -// o Hex-value overflow goes unreported, limiting input to a 16-bit unicode result. +// o Hex-value overflow goes unreported, limiting input to a 16-bit unicode result. // #pragma comment(lib, "Imm32.lib") @@ -437,55 +486,85 @@ MouseEvent(const DWORD dwEventFlags, const DWORD dwButtonState) static int AltPlusEnabled(void) { - HKEY hKey = 0; - int enabled = 0; - - if (RegOpenKeyExA(HKEY_CURRENT_USER, - "Control Panel\\Input Method", 0, KEY_READ, &hKey) == ERROR_SUCCESS) { - char szEnableHexNumpad[100] = {0}; - DWORD dwSize = _countof(szEnableHexNumpad); - if (RegQueryValueExA(hKey, "EnableHexNumpad", NULL, NULL, (LPBYTE) szEnableHexNumpad, &dwSize) == ERROR_SUCCESS) { - if (szEnableHexNumpad[0] == '1' && szEnableHexNumpad[1] == 0) { - enabled = 1; + static int state = -1; + + if (-1 == state) { + HKEY hKey = 0; + + state = 0; + if (RegOpenKeyExA(HKEY_CURRENT_USER, + "Control Panel\\Input Method", 0, KEY_READ, &hKey) == ERROR_SUCCESS) { + char szEnableHexNumpad[100] = { 0 }; + DWORD dwSize = _countof(szEnableHexNumpad); + if (RegQueryValueExA(hKey, "EnableHexNumpad", NULL, NULL, (LPBYTE)szEnableHexNumpad, &dwSize) == ERROR_SUCCESS) { + if (szEnableHexNumpad[0] == '1' && szEnableHexNumpad[1] == 0) { + state = 1; + } } + RegCloseKey(hKey); } - RegCloseKey(hKey); } - return enabled; + return state; } + static int AltPlusEvent(const KEY_EVENT_RECORD *ke, struct IOEvent *evt) { #define ISXDIGIT(_uc) \ ((_uc >= '0' && _uc <= '9') || (_uc >= 'a' && _uc <= 'f') || (_uc >= 'A' && _uc <= 'F') ? 1 : 0) - static int alt_code = -2; // >0=active, 0=enabled, -1=disabled, -2=auto. + static unsigned alt_code = 0; // >0=active static DWORD alt_control = 0; - if (alt_code < 0) { - if (-1 == alt_code) return -1; - if (! AltPlusEnabled()) { - alt_code = -1; - return -1; - } - alt_code = 0; - } + const unsigned wVirtualKeyCode = ke->wVirtualKeyCode, + dwControlKeyState = (CTRLSTATUSMASK & ke->dwControlKeyState), + dwEnhanced = (ENHANCED_KEY & ke->dwControlKeyState); + +#if (DO_KEYTRACE) + OutputDebugPrintA("Key: %s-%s%s%s%s%s%sVK=0x%02x/%u, UC=0x%04x/%u/%c, SC=0x%x/%u\n", + (ke->bKeyDown ? "DN" : "UP"), + (dwEnhanced ? "Enh-" : ""), + (dwControlKeyState & LEFT_ALT_PRESSED) ? "LAlt-" : "", + (dwControlKeyState & RIGHT_ALT_PRESSED) ? "RAlt-" : "", + (dwControlKeyState & LEFT_CTRL_PRESSED) ? "LCtrl-" : "", + (dwControlKeyState & RIGHT_CTRL_PRESSED) ? "RCtrl-" : "", + (dwControlKeyState & SHIFT_PRESSED) ? "Shift-" : "", + wVirtualKeyCode, wVirtualKeyCode, + ke->uChar.UnicodeChar, ke->uChar.UnicodeChar, + (ke->uChar.UnicodeChar && ke->uChar.UnicodeChar < 255 ? ke->uChar.UnicodeChar : ' '), + ke->wVirtualScanCode, ke->wVirtualScanCode); +#endif if (ke->bKeyDown) { // down event - const unsigned controlKeyState = (CTRLSTATUSMASK & ke->dwControlKeyState); - if (VK_ADD == ke->wVirtualKeyCode && - (LEFT_ALT_PRESSED == controlKeyState || RIGHT_ALT_PRESSED == controlKeyState)) { - // "Alt + ..." event - alt_control = controlKeyState; - if (alt_code == 0) { + if ((wVirtualKeyCode >= VK_NUMPAD0 && wVirtualKeyCode <= VK_NUMPAD9) && + 0 == dwEnhanced && (LEFT_ALT_PRESSED == dwControlKeyState || RIGHT_ALT_PRESSED == dwControlKeyState)) { + // "Alt NumPad ..." event + // Note: + // o NumLock is required to be enabled for NUMPAD key reporting. + // o Non-enhanced, NumPad verses 101 cursor-keys; same VK codes. + if (0 == alt_code) { + alt_control = dwControlKeyState; alt_code = 1; } return 1; // consume + } - } else if (alt_code) { - if (alt_control != controlKeyState || + if (VK_ADD == wVirtualKeyCode && + (LEFT_ALT_PRESSED == dwControlKeyState || RIGHT_ALT_PRESSED == dwControlKeyState)) { + // "Alt + Hex" event + if (0 == AltPlusEnabled()) + return -1; // enabled? + if (0 == alt_code) { + alt_control = dwControlKeyState; + alt_code = 1; + } + return 1; // consume + } + + if (alt_code) { + if (alt_control != dwControlKeyState || (ke->uChar.UnicodeChar && 0 == ISXDIGIT(ke->uChar.UnicodeChar))) { // new control status or non-hex, emit "Alt-Plus" and reset state evt->type = EVT_KEYDOWN; @@ -494,29 +573,29 @@ AltPlusEvent(const KEY_EVENT_RECORD *ke, struct IOEvent *evt) alt_code = 0; return 0; } - ++alt_code; // associated key count return 1; // consume } } else if (alt_code) { // up event - if (VK_MENU == ke->wVirtualKeyCode && + if (VK_MENU == wVirtualKeyCode && (0 == (ke->dwControlKeyState & ALT_PRESSED))) { // Alt completion - const int oalt_code = alt_code; + const WCHAR UnicodeChar = ke->uChar.UnicodeChar; + const int alt_old = alt_code; alt_code = 0; - if (1 == oalt_code && 0 == ke->uChar.UnicodeChar) { - // "Alt-Plus" only, emit + if (1 == alt_old && 0 == UnicodeChar) { + // Alt only, emit. evt->type = EVT_KEYDOWN; evt->code = KEYPAD_PLUS; evt->modifiers = MOD_ALT; return 0; - } else if (ke->uChar.UnicodeChar) { - // "Alt-Plus keycode", return keycode. + } else if (UnicodeChar) { + // Alt keycode, return keycode. evt->type = EVT_KEYDOWN; - evt->code = ke->uChar.UnicodeChar; + evt->code = UnicodeChar; evt->modifiers = 0; return 0; } @@ -527,7 +606,7 @@ AltPlusEvent(const KEY_EVENT_RECORD *ke, struct IOEvent *evt) } -/* Function: key_normalizeAltGr +/* Function: AltGrEvent * Filter AtrGr events from modifiers; attempt to allow: * * Left-Alt + AltGr, @@ -535,7 +614,7 @@ AltPlusEvent(const KEY_EVENT_RECORD *ke, struct IOEvent *evt) * Left-Alt + Right-Ctrl + AltGr. */ static DWORD -key_normalizeAltGr(const KEY_EVENT_RECORD* key) +AltGrEvent(const KEY_EVENT_RECORD* key) { DWORD state = key->dwControlKeyState; @@ -626,8 +705,8 @@ sys_getevent(struct IOEvent *evt, int tmo) if (altstate == 1) break; } - if (k.Event.KeyEvent.bKeyDown) { - const DWORD dwControlKeyState = key_normalizeAltGr(ke); + if (ke->bKeyDown) { + const DWORD dwControlKeyState = AltGrEvent(ke); int code; /* see kbd.c */ if ((code = key_mapwin32((unsigned) dwControlKeyState, @@ -639,7 +718,6 @@ sys_getevent(struct IOEvent *evt, int tmo) assert(code > 0 && code <= (MOD_MASK|RANGE_MASK|KEY_MASK) && code != KEY_VOID); return 0; } - } else { resize = ResizeCheck(&checks); } @@ -650,8 +728,12 @@ sys_getevent(struct IOEvent *evt, int tmo) const MOUSE_EVENT_RECORD *me = &k.Event.MouseEvent; #ifndef MOUSE_WHEELED -#define MOUSE_WHEELED 4 /* Not available within NT or 95/98 SDK */ +#define MOUSE_WHEELED 0x0004 /* Not available within NT or 95/98 SDK */ #endif +#ifndef MOUSE_HWHEELED +#define MOUSE_HWHEELED 0x0008 +#endif + if (MOUSE_WHEELED & me->dwEventFlags) { const int down = (0xFF000000 & me->dwButtonState ? TRUE : FALSE); @@ -664,13 +746,17 @@ sys_getevent(struct IOEvent *evt, int tmo) return 0; } - if (0 == me->dwEventFlags || - ((me->dwEventFlags & (MOUSE_MOVED|DOUBLE_CLICK)) && me->dwButtonState)) { + if (MOUSE_HWHEELED & me->dwEventFlags) { + const int down = (0xFF000000 & me->dwButtonState ? TRUE : FALSE); + + evt->type = EVT_KEYDOWN; + evt->code = (down ? WHEEL_RIGHT : WHEEL_LEFT); + return 0; + } + + if (MouseProcess(me)) { evt->type = EVT_MOUSE; - evt->code = MouseEvent(me->dwEventFlags, me->dwButtonState); - evt->modifiers = Modifiers(me->dwControlKeyState); - evt->mouse.x = me->dwMousePosition.X + 1; - evt->mouse.y = me->dwMousePosition.Y + 1; + evt->code = KEY_VOID; return 0; } } @@ -767,7 +853,7 @@ sys_cut(int total, int append, void (*copy)(char *buf, int total)) { int ret = 0; - if (OpenClipboard(NULL)) { + if (NULL == copy || OpenClipboard(NULL)) { ret = -1; } else { HGLOBAL hglb; @@ -797,7 +883,7 @@ sys_cut(int total, int append, void (*copy)(char *buf, int total)) * Paste the 'system' clipboard/scrap into the current buffer. * * Parameters: - * paste - Paste callback. + * paste - Paste callback. * */ int @@ -937,9 +1023,9 @@ sys_drive_set(int drive) int sys_fstype(const char *directory) { -#define DISABLE_HARD_ERRORS SetErrorMode (0) -#define ENABLE_HARD_ERRORS SetErrorMode (SEM_FAILCRITICALERRORS | \ - SEM_NOOPENFILEERRORBOX) +#define DISABLE_HARD_ERRORS SetErrorMode (0) +#define ENABLE_HARD_ERRORS SetErrorMode (SEM_FAILCRITICALERRORS | \ + SEM_NOOPENFILEERRORBOX) char bName[4]; DWORD flags; @@ -1133,7 +1219,7 @@ GetSystemTimeNS100(void) FILETIME ft = {0}; unsigned long long ns100; - /* + /* * GetSystemTime(Precise)AsFileTime returns the number of 100-nanosecond intervals since January 1, 1601 (UTC). * * GetSystemTimeAsFileTime has a resolution of approximately the TimerResolution (~15.6ms) on Windows XP. @@ -1147,9 +1233,9 @@ GetSystemTimeNS100(void) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wcast-function-type" #endif - if (0 == (hinst = LoadLibraryA("Kernel32")) || - NULL == (fGetSystemTimePreciseAsFileTime = - (GetSystemTimePreciseAsFileTime_t)GetProcAddress(hinst, "GetSystemTimePreciseAsFileTime"))) { + hinst = LoadLibraryA("Kernel32"); + if (NULL == (fGetSystemTimePreciseAsFileTime = + (GetSystemTimePreciseAsFileTime_t)GetProcAddress(hinst, "GetSystemTimePreciseAsFileTime"))) { fGetSystemTimePreciseAsFileTime = (GetSystemTimePreciseAsFileTime_t)GetProcAddress(hinst, "GetSystemTimeAsFileTime"); /*fall-back*/ } @@ -1157,7 +1243,7 @@ GetSystemTimeNS100(void) #pragma GCC diagnostic pop #endif } - + fGetSystemTimePreciseAsFileTime(&ft); ns100 = ft.dwHighDateTime; @@ -1312,4 +1398,31 @@ sys_running(int pid) } return 0; } -#endif /*WIN32*/ + + +void +OutputDebugPrintA(const char* fmt, ...) +{ + struct timeval tv; + char out[512]; + va_list ap; + int prefix; + + va_start(ap, fmt); + w32_gettimeofday(&tv, NULL); +#if !defined(SIZEOF_TIME_T) +#error SIZEOF_TIME_T missing +#endif +#if (SIZEOF_TIME_T == SIZEOF_LONG_LONG) + prefix = sprintf(out, "%lld.%03u: ", (long long)tv.tv_sec, (unsigned)(tv.tv_usec / 1000)); +#elif (SIZEOF_TIME_T == SIZEOF_LONG) + prefix = sprintf(out, "%ld.%03u: ", (long)tv.tv_sec, (unsigned)(tv.tv_usec / 1000)); +#else + prefix = sprintf(out, "%d.%03u: ", tv.tv_sec, (unsigned)(tv.tv_usec / 1000)); +#endif + vsprintf_s(out + prefix, _countof(out) - prefix, fmt, ap); + va_end(ap); + OutputDebugStringA(out); +} + +#endif /*WIN32*/ diff --git a/gr/sysinfo.c b/gr/sysinfo.c index 2325f594..9016a8bc 100644 --- a/gr/sysinfo.c +++ b/gr/sysinfo.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_sysinfo_c,"$Id: sysinfo.c,v 1.53 2022/08/10 15:44:58 cvsuser Exp $") +__CIDENT_RCSID(gr_sysinfo_c,"$Id: sysinfo.c,v 1.57 2024/07/19 05:04:22 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: sysinfo.c,v 1.53 2022/08/10 15:44:58 cvsuser Exp $ +/* $Id: sysinfo.c,v 1.57 2024/07/19 05:04:22 cvsuser Exp $ * System information services. * * @@ -28,9 +28,10 @@ __CIDENT_RCSID(gr_sysinfo_c,"$Id: sysinfo.c,v 1.53 2022/08/10 15:44:58 cvsuser E #if defined(HAVE_PWD_H) #include #endif -#if defined(unix) || defined(__APPLE__) || defined(HAVE_NETDB_H) +#if defined(unix) || defined(__unix__) || defined(__APPLE__) || defined(HAVE_NETDB_H) #include #endif + #if defined(linux) #ifndef _GNU_SOURCE #define _GNU_SOURCE @@ -38,7 +39,7 @@ __CIDENT_RCSID(gr_sysinfo_c,"$Id: sysinfo.c,v 1.53 2022/08/10 15:44:58 cvsuser E #include #endif -#if defined(unix) || defined(_AIX) || defined(linux) || defined(__APPLE__) +#if defined(unix) || defined(__unix__) || defined(__APPLE__) || defined(_AIX) || defined(linux) #include #endif @@ -50,6 +51,11 @@ __CIDENT_RCSID(gr_sysinfo_c,"$Id: sysinfo.c,v 1.53 2022/08/10 15:44:58 cvsuser E #include /* proc_pidpath */ #endif +#if defined(BSD) +#include +#include +#endif + #if defined(WIN32) || defined(__CYGWIN__) #if !defined(WINDOWS_MEAN_AND_LEAN) #define WINDOWS_MEAN_AND_LEAN @@ -286,7 +292,7 @@ sysinfo_tmpdir(void) #else static const char *tmpdirs[] = { "/tmp", -#if defined(unix) || defined(__APPLE__) +#if defined(unix) || defined(__unix__) || defined(__APPLE__) "/var/tmp", #endif #if defined(__MSDOS__) @@ -389,7 +395,7 @@ resolve_execname(const char *name) } #endif /*CYGWIN*/ -#else /*unix and friends */ +#else /*unix and friends */ char t_path[MAX_PATH+1] = {0}, t_self[64]; struct stat sb = {0}; int source = -1; @@ -406,15 +412,17 @@ resolve_execname(const char *name) if (name != t_name) { #if defined(linux) || defined(__linux__) sxprintf(t_self, sizeof(t_self), "/proc/%d/exe", getpid()); - if ((namelen = readlink("/proc/self/exe", t_name, sizeof(t_name))) > 0 || - (namelen = readlink(t_self, t_name, sizeof(t_name))) > 0) { + if ((namelen = readlink("/proc/self/exe", t_name, sizeof(t_name)-1)) > 0 || + (namelen = readlink(t_self, t_name, sizeof(t_name)-1)) > 0) { + // Note: + // if /proc/self/exe points to a deleted/updated image then linux adds a " (deleted)" suffix. t_name[namelen] = 0; name = t_name; source = 1; } #elif defined(__sun__) || defined(sun) - if ((namelen = readlink("/proc/self/paths/a.out", t_name, sizeof(t_name))) > 0) { + if ((namelen = readlink("/proc/self/paths/a.out", t_name, sizeof(t_name)-1)) > 0) { t_name[namelen] = 0; name = t_name; source = 2; @@ -431,20 +439,54 @@ resolve_execname(const char *name) } #elif defined(BSD) - if ((namelen = readlink("/proc/curproc/file", t_name, sizeof(t_name))) > 0) { + if ((namelen = readlink("/proc/curproc/file", t_name, sizeof(t_name)-1)) > 0 || // Free and DragonFly + (namelen = readlink("/proc/curproc/exe", t_name, sizeof(t_name)-1)) > 0) { // Net t_name[namelen] = 0; name = t_name; /* procfs */ source = 5; } else { +#if defined(__FreeBSD__) || defined(__DragonFly__) int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1}; - size cb = sizeof(t_name); + size_t cb = sizeof(t_name); + + if (-1 != sysctl(mib, 4, t_name, &cb, NULL, 0)) { + name = t_name; /* alt method */ + source = 6; + } + +#elif defined(__NetBSD__) + int mib[4] = { CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PATHNAME }; + size_t cb = sizeof(t_name); if (-1 != sysctl(mib, 4, t_name, &cb, NULL, 0)) { name = t_name; /* alt method */ source = 6; } + +#elif defined(__OpenBSD__) + int mib[4] = {CTL_KERN, KERN_PROC, getpid(), KERN_PROC_ARGV}; + size_t size; + + if (sysctl(mib, 4, NULL, &size, NULL, 0) == 0) { + char **argv; + + if (size && (argv = (char **)calloc(1, size)) != NULL) { + if (sysctl(mib, 4, argv, &size, NULL, 0) == 0) { + if (strchr(argv[0], '/') == NULL || realpath(argv[0], t_name) == NULL) { + strxcpy(t_name, argv[0], sizeof(t_name)); + } + name = t_name; /* alt method */ + source = 7; + } + free((void *)argv); + } + } +#else +#error Unsupported BSD target +#endif } + #endif /*unix||linux*/ } @@ -545,17 +587,17 @@ sysinfo_hostname(char *buf, int len) #if !defined(MAXHOSTNAMELEN) #define MAXHOSTNAMELEN 256 #endif -#if defined(unix) || defined(__APPLE__) +#if defined(unix) || defined(__unix__) || defined(__APPLE__) char host_buf[MAXHOSTNAMELEN]; #endif char domain_buf[MAXHOSTNAMELEN]; -#if defined(unix) || defined(__APPLE__) || defined(HAVE_NETDB_H) +#if defined(unix) || defined(__unix__) || defined(__APPLE__) || defined(HAVE_NETDB_H) struct hostent *hent = NULL; #endif const char * p = NULL; /* default gethostname(), then env */ -#if defined(unix) || defined(__APPLE__) +#if defined(unix) || defined(__unix__) || defined(__APPLE__) if (0 == gethostname(host_buf, sizeof(host_buf)) && host_buf[0]) { p = host_buf; } @@ -570,7 +612,7 @@ sysinfo_hostname(char *buf, int len) host = (char *)p; /* gethostbyname seems a better option */ -#if defined(unix) || defined(__APPLE__) || defined(HAVE_NETDB_H) +#if defined(unix) || defined(__unix__) || defined(__APPLE__) || defined(HAVE_NETDB_H) if (NULL != (hent = gethostbyname (host)) && NULL != hent->h_name && hent->h_name[0] != 0) { diff --git a/gr/system.h b/gr/system.h index 24cbe969..81ee9900 100644 --- a/gr/system.h +++ b/gr/system.h @@ -1,11 +1,11 @@ #ifndef GR_SYSTEM_H_INCLUDED #define GR_SYSTEM_H_INCLUDED #include -__CIDENT_RCSID(gr_system_h,"$Id: system.h,v 1.39 2022/05/31 16:18:22 cvsuser Exp $") +__CIDENT_RCSID(gr_system_h,"$Id: system.h,v 1.40 2024/06/23 15:41:55 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: system.h,v 1.39 2022/05/31 16:18:22 cvsuser Exp $ +/* $Id: system.h,v 1.40 2024/06/23 15:41:55 cvsuser Exp $ * System interface. * * @@ -61,6 +61,7 @@ extern int sys_chmod(const char *path, int mode); extern int sys_realpath(const char *path, char *real, int size); extern const char * sys_cwd(char *cwd, int size); extern int sys_read(int fd, void *buf, int size); +extern int sys_read_timed(int fd, void *buf, int size, unsigned timeoutms, unsigned *remainingms); extern int sys_write(int fd, const void *buf, int size); extern int sys_copy(const char *src, const char *dst, int perms, int owner, int group); extern void sys_noinherit(int fd); diff --git a/gr/termemu_vio.c b/gr/termemu_vio.c index 86bed5bb..dfe06bc1 100644 --- a/gr/termemu_vio.c +++ b/gr/termemu_vio.c @@ -315,7 +315,7 @@ static struct { /* Video state */ uint32_t available; } fcnames[FACENAME_MAX]; - int fontindex; + unsigned fontindex; int fontnumber; CONSOLE_FONT_INFOEX fonts[FONTS_MAX]; @@ -707,7 +707,7 @@ vio_size(int *rows, int *cols) static void -vio_profile(int rebuild) +vio_profile(int rebuild /*TRUE/FALSE/-1 (check)*/) { HANDLE chandle = vio.chandle; DWORD consolemode = 0; @@ -854,22 +854,24 @@ vio_profile(int rebuild) consolefontsenum(); } - if (0 == vio.fontnumber || rebuild) { - + if (0 == vio.fontnumber || rebuild == TRUE) { // dynamic colors if (vio.GetConsoleScreenBufferInfoEx) { // vista+ - CONSOLE_SCREEN_BUFFER_INFOEX csbix = {0}; + CONSOLE_SCREEN_BUFFER_INFOEX csbix = { 0 }; WORD c; csbix.cbSize = sizeof(csbix); vio.GetConsoleScreenBufferInfoEx(chandle, &csbix); TRACE_LOG(("Console Colors (BBGGRR)\n")) - for (c = 0; c < 16; ++c) { - TRACE_LOG((" [%2u] 0x%06x\n", c, (unsigned)csbix.ColorTable[c])) - vio.rgb16[c] = csbix.ColorTable[c]; - } + for (c = 0; c < 16; ++c) { + TRACE_LOG((" [%2u] 0x%06x\n", c, (unsigned)csbix.ColorTable[c])) + vio.rgb16[c] = csbix.ColorTable[c]; + } vio.console_rgb16 = 1; // RGB16 is available } + } + + if (0 == vio.fontnumber || rebuild) { // current fonts if (vio.GetCurrentConsoleFontEx) { @@ -879,8 +881,14 @@ vio_profile(int rebuild) if (vio.GetCurrentConsoleFontEx(chandle, FALSE, &cfix)) { COORD coord; - vio.fontindex = cfix.nFont; coord = GetConsoleFontSize(chandle, cfix.nFont); + if (-1 == rebuild) { + if (vio.fontindex == cfix.nFont && + vio.fcheight == coord.Y && vio.fcwidth == coord.X) { + return; // no-change + } + } + vio.fontindex = cfix.nFont; vio.fcheight = coord.Y; // cfix.dwFontSize.Y; vio.fcwidth = coord.X; // cfix.dwFontSize.X; vio.fcfamily = cfix.FontFamily; @@ -895,8 +903,14 @@ vio_profile(int rebuild) if (GetCurrentConsoleFont(chandle, FALSE, &cfi)) { COORD coord; - vio.fontindex = cfi.nFont; coord = GetConsoleFontSize(chandle, cfi.nFont); + if (-1 == rebuild) { + if (vio.fontindex == cfi.nFont && + vio.fcheight == coord.Y && vio.fcwidth == coord.X) { + return; // no-change + } + } + vio.fontindex = cfi.nFont; vio.fcheight = coord.Y; // cfi.dwFontSize.Y; vio.fcwidth = coord.X; // cfi.dwFontSize.X; vio.fcfamily = -1; @@ -904,7 +918,7 @@ vio_profile(int rebuild) vio.fcfacename[0] = 0; // Note: GetTextFace() is 'System' } else { - vio.fontindex = -1; // full screen + vio.fontindex = (unsigned)-1; // full screen vio.fcheight = 16; vio.fcwidth = 8; vio.fcweight = -1; @@ -2639,38 +2653,33 @@ WCHAR_UPDATE(WCHAR_INFO *cursor, const uint32_t ch, const struct WCHAR_COLORINFO static int parse_color(const char *color, const char *defname, const struct attrmap *map, int *attr) { - char t_name[128] = {0}; - const char *a; + int len = strlen(color); + const char *name, *a; int c, col = -1; - // color[;attribute[;...]] - // + // color[;attribute[;...]] if (!defname || !*defname) // undefined; assume white/black. defname = (map == win16_foreground ? "white" : "black"); if (!color || !*color) color = defname; // undefined, apply default. - // optional trailing attributes + // optional trailing attributes if (NULL != (a = strchr(color, ';'))) { - const int len = (int)(a - color); - - strncpy(t_name, color, sizeof(t_name)-1);// remove attribute component. - if (len < (int)sizeof(t_name)) - t_name[len] = 0; - color = t_name; - *attr = parse_attributes(a); + len = (int)(a - color); // remove attribute component. } - // non-optional color - while (' ' == *color || '\t' == *color) ++color; + // non-optional color + while (' ' == *color || '\t' == *color) + ++color; + if (0 == sscanf(color, "color%u", &col)) { // extension - for (c = 0; map[c].name; ++c) { // search color map - if (0 == stricmp(color, map[c].name)) { - return map[c].win; //done + for (c = 0; (name = map[c].name) != NULL; ++c) { // search color map + if (len == (int)strlen(name) && 0 == strnicmp(color, name, len)) { + return map[c].win; // done - } else if (0 == stricmp(defname, map[c].name)) { - col = map[c].win; //apply default + } else if (0 == stricmp(defname, name)) { + col = map[c].win; // apply default } } } diff --git a/gr/tty.h b/gr/tty.h index 4f9fd0e6..137a4f54 100644 --- a/gr/tty.h +++ b/gr/tty.h @@ -1,11 +1,11 @@ #ifndef GR_TTY_H_INCLUDED #define GR_TTY_H_INCLUDED #include -__CIDENT_RCSID(gr_tty_h,"$Id: tty.h,v 1.36 2014/10/22 02:33:22 ayoung Exp $") +__CIDENT_RCSID(gr_tty_h,"$Id: tty.h,v 1.37 2024/08/25 06:01:53 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: tty.h,v 1.36 2014/10/22 02:33:22 ayoung Exp $ +/* $Id: tty.h,v 1.37 2024/08/25 06:01:53 cvsuser Exp $ * TTY interface. * * @@ -136,6 +136,7 @@ extern void ttcurses(void); extern void ttx11(void); extern void ttinit(void); +extern int ttxtermlike(void); extern void ttopen(void); extern void ttsizeinit(void); extern void ttready(int repaint); diff --git a/gr/ttycmd.c b/gr/ttycmd.c new file mode 100644 index 00000000..998d7d69 --- /dev/null +++ b/gr/ttycmd.c @@ -0,0 +1,403 @@ +#include +__CIDENT_RCSID(gr_ttycmd_c,"$Id: ttycmd.c,v 1.2 2024/09/25 15:51:54 cvsuser Exp $") + +/* -*- mode: c; indent-width: 4; -*- */ +/* $Id: ttycmd.c,v 1.2 2024/09/25 15:51:54 cvsuser Exp $ + * TTY common command functions + * + * + * This file is part of the GRIEF Editor. + * + * The GRIEF Editor is free software: you can redistribute it + * and/or modify it under the terms of the GRIEF Editor License. + * + * The GRIEF Editor is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * License for more details. + * ==end== + */ + +#include + +#include "ttyutil.h" + +#if !defined(USE_VIO_BUFFER) && !defined(DJGPP) + +#include +#include /* gputenvv(), ggetenv() */ +#include + +#include "debug.h" /* trace ... */ +#include "mouse.h" +#include "system.h" +#include "tty.h" + +static int isterm(const char *term, const char *name); + + +/* Function: tty_defaultscheme + * Determine the terminals default luminance, based on legacy TERM/environment logic. + * + * Parameters: + * none + * + * Returns: + * 0 if light, otherwise 1 if dark. + */ +int +tty_defaultscheme(void) +{ + const char *fgbg, *term = ggetenv("TERM"); // TODO/TERM_PROGRAM + int isdark = 0; + + if (term) { + if (isterm(term, "linux") == 0 + || isterm(term, "screen.linux") == 0 + || isterm(term, "cygwin") == 0 + || isterm(term, "putty") == 0 + || isterm(term, "ms-terminal") == 0 + || ggetenv("WT_SESSION") + || ((fgbg = ggetenv("COLORFGBG")) != NULL && // rxvt, COLORFGBG='0;default;15' + (fgbg = strrchr(fgbg, ';')) != NULL && ((fgbg[1] >= '0' && fgbg[1] <= '6') || fgbg[1] == '8') && fgbg[2] == '\0')) { + isdark = 1; + } + } else { +#if defined(WIN32) || defined(__CYGWIN__) + isdark = 1; /* generally dark */ +#endif + } + return isdark; +} + + +static int +isterm(const char *term, const char *name) +{ + const size_t tlen = (size_t)strlen(term); + const size_t nlen = (size_t)strlen(name); + + if (tlen >= nlen) { /* xxxx[\0.-] */ + if (0 == memcmp(term, name, nlen)) { /* dot, allow */ + return (term[nlen] == '\0' || term[nlen] == '-' || term[nlen] == '.'); + } + } + return 0; +} + + +/* + * tty_identification --- + * Request the terminal version/DA2 details. + * + * DA2 - Secondary Device Attributes + * In this DA exchange, the host requests the terminal's identification code, firmware version level, and hardware options. + * + * Host Request: + * The host uses the following sequence to send this request. + * + * CSI > c or CSI > 0 c + * 9/11 3/14 6/3 9/11 3/14 3/0 6/3 + * + * Terminal Response: + * The terminal with a VT keyboard uses the following sequence to respond. + * + * CSI > 6 1 ; Pv ; 0 c + * 9/11 3/14 3/6 3/1 3/11 3/n 3/11 3/0 6/3 DA2R for terminal with STD keyboard. + * + * CSI > 6 1 ; Pv ; 1 c + * 9/11 3/14 3/6 3/1 3/11 3/n 3/11 3/1 6/3 DA2R for terminal with PC keyboard. + * + * Example: + * \033[>82;20710;0c + * ^type + * ^version + * + * Terminal Type Version Example + * ------------------------------------------------------------------ + * Gnome-terminal (legacy) 1 >= 1115 1;3801;0 + * PuTTY 0 136 0;136;0 + * MinTTY 77(=M) 77;20005;0c + * rxvt 82(=R) + * screen 83(=S) 83;40500;0 + * urxvt 85(=U) + * xterm -2(a) 123 XTERM_VERSION=123 + * + * Parameters: + * RV - Optional request-command string; default applied otherwise. + * timeoutoutms - Timeout in millseconds. + * + * Returns: + * 0 if successful, otherwise -1. + * + * x_pt.pt_vtdatype/vtdaversion and vtdaoptions upon details being available. + */ +int +tty_identification(const char *RV, int timeoutms) +{ // TODO/TERM_PROGRAM + static char xterm_da2_cmd[] = "\033[>c"; + const char *xterm_version; + int ret = -1; + + /* + * XTERM_VERSION/ + * Xterm(256) ==> 256 + */ + if (NULL != (xterm_version = ggetenv("XTERM_VERSION"))) { + char vname[32+1] = {0}; + int vnumber = 0; + /* decode and return patch/version number */ + if (2 == sscanf(xterm_version, "%32[^(](%u)", vname, &vnumber)) + if (vnumber > 0) { + x_pt.pt_vtdatype = -2; /* source: xterm_version */ + x_pt.pt_vtdaversion = vnumber; + x_pt.pt_vtdaoptions = 0; + } + trace_ilog("XTERM_VERSION(%s) = %d (%s)\n", xterm_version, vnumber, vname); + ret = -2; + } + + /* + * DA2/Request version. + */ + if (NULL == RV || 0 == *RV) + RV = xterm_da2_cmd; /* default */ + + { + const int rvlen = strlen(RV); + char buffer[32] = {0}; + int len = 0; + + if (rvlen == tty_write(RV, rvlen) && + (len = tty_read(buffer, sizeof(buffer), timeoutms)) > 1) { + trace_ilog("term_da2(%d, %s)\n", len, buffer); + + if ('\033' == buffer[0] && '[' == buffer[1] && + ('>' == buffer[2] || '?' == buffer[2])) { + unsigned datype, daversion, daoptions = 0; + + if (sscanf(buffer + 3, "%u;%u;%uc", &datype, &daversion, &daoptions) >= 2) { + trace_ilog("\t==> type:%d, version:%d, options:%x\n", datype, daversion, daoptions); + x_pt.pt_vtdatype = datype; + x_pt.pt_vtdaversion = daversion; + x_pt.pt_vtdaoptions = daoptions; + return 0; + } + } + } + } + return ret; +} + + +/* Function: tty_luminance + * Request the terminals background RGB color and determine the luminance. + * + * Parameters: + * RV - Optional request-command string; default applied otherwise. + * timeoutoutms - Timeout in millseconds. + * + * Returns: + * 0 if light, 1 if dark, otherwise -1. + */ +int +tty_luminance(int timeoutms) +{ +#define XTERM_OCS11_LEN (sizeof(xterm_ocs11) - 1) + + static char xterm_ocs11[] = "\x1b]11;?\007"; + + unsigned rgb[3] = {0,0,0}, rgbmax = 0; + unsigned char *cp, buffer[32] = {0}; + int len = 0; + + /* + * Format: + * + * ]rgb:xx/xx/xx + * or ]rgb:xxxx/xxxx/xxxx + * + * Example: + * + * echo -ne '\e]11;?\a'; cat + * + * ESC]11;rgb:0000/0000/0000 + */ + if ((XTERM_OCS11_LEN != tty_write(xterm_ocs11, XTERM_OCS11_LEN)) || + (len = tty_read(buffer, sizeof(buffer), timeoutms)) < 1) { + trace_ilog("ttluminance : io (tm=%d, len=%d)\n", timeoutms, len); + return -1; + } + + cp = buffer; + if (cp[0] == '\033' && cp[1] == ']') { /* ESC] */ + cp += 2; + } else if (cp[0] == 0x9d) { /* OSC */ + cp += 1; + } else { + cp = NULL; + } + + if (cp && cp[0] == '1' && (cp[1] == '0' || cp[1] == '1') && cp[2] == ';') { + /* + * parse RGB values + */ + const char *spec = (const char *)(cp + 3); + if (cp[11] == '/') { + if (sscanf(spec, "rgb:%4x/%4x/%4x\033", rgb+0, rgb+1, rgb+2) == 3 || + sscanf(spec, "rgb:%4x/%4x/%4x\007", rgb+0, rgb+1, rgb+2) == 3) { + rgbmax = 0xffff; + } + + } else if (cp[9] == '/') { + if (sscanf(spec, "rgb:%2x/%2x/%2x\033", rgb+0, rgb+1, rgb+2) == 3 || + sscanf(spec, "rgb:%2x/%2x/%2x\007", rgb+0, rgb+1, rgb+2) == 3) { + rgbmax = 0xff; + } + } + } + + if (rgbmax) { + /* + * Luminance (perceived) + * Reference: https://www.w3.org/TR/AERT/#color-contrast + */ + const double r = (double)rgb[0] / (double)rgbmax; + const double g = (double)rgb[1] / (double)rgbmax; + const double b = (double)rgb[2] / (double)rgbmax; + const double l = (0.299 * r) + (0.587 * g) + (0.114 * b); + + trace_ilog("ttluminance(%d, %s) : %04x/%04x/%04x\n", len, buffer, rgb[0], rgb[1], rgb[2]); + trace_ilog("\t==> %g [%s]\n", l, l < 0.5 ? "dark" : "light"); + + if (l < 0.5) { + return 1; /* dark */ + } + return 0; /* otherwise light */ + } + + trace_ilog("ttluminance(%d, %s) : n/a", len, buffer); + return -1; +} + + +#if (TODO_MCHAR_DETECT) /* TODO: terminal ambiguous width */ +/* Function: tty_utf8_features + * Request the terminals background RGB color and determine the luminance. + * + * Parameters: + * RV - Optional request-command string; default applied otherwise. + * timeoutoutms - Timeout in millseconds. + * + * Returns: + * 0 if light, 1 if dark, otherwise -1. + */ +static void +tty_utf8_features(void) +{ +#define XTERM_UTF8_TEST2 (sizeof(xterm_utf8_test2)-1) + + static unsigned char xterm_utf8_test2[] = { + '\r', /* UTF features */ + 0xa5, + 0xc3, 0x84, 0xd9, + 0xa7, + 0xd8, 0xb8, 0xe0, 0xe0, + 0xa9, + 0xa9, + 0xb8, 0x88, 0xe5, 0xe5, 0x88, + 0xa2, 0xa2, + 0x1b, '[', '6', 'n', /* cursor position */ + 0x00 /* NUL */ + }; + + if (XTERM_UTF8_TEST2 == tty_write(xterm_utf8_test2, XTERM_UTF8_TEST2)) { + int row = -1, col = -1; + char buffer[32] = {0}; + int len; + + /* + * check cursor column after test string, determine screen mode + * + * 6 -> UTF-8, no double-width, with LAM/ALEF ligature joining + * 7 -> UTF-8, no double-width, no LAM/ALEF ligature joining + * 8 -> UTF-8, double-width, with LAM/ALEF ligature joining + * 9 -> UTF-8, double-width, no LAM/ALEF ligature joining + * 11,16 -> CJK terminal (with luit) + * 10,15 -> 8 bit terminal or CJK terminal + * 13 -> Poderosa terminal emulator, UTF-8, or TIS620 terminal + * 14,17 -> CJK terminal + * 16 -> Poderosa, ISO Latin-1 + * (17) -> Poderosa, (JIS) + * 18 -> CJK terminal (or 8 bit terminal, e.g. Linux console) + */ + if ((len = tty_read(buffer, sizeof(buffer), -2)) >= 4) { + sscanf(buffer, "\033[%d;%dR", &row, &col); + } + + trace_ilog("\tisutf8B(%d) = col:%d\n", len, col); + } +} +#endif /*XXX_MCHAR_DETECT*/ + + +/* + * tty_write--- + * Terminal low-level write. + */ +int +tty_write(const void *buffer, int length) +{ + return sys_write(TTY_OUTFD, buffer, length); +} + + +/* + * tty_read --- + * Terminal low-level read. + */ +int +tty_read(void *ibuffer, int length, int timeoutms) +{ + char *buffer = ((char *)ibuffer); + int cnt = 0; + + if (timeoutms <= -2) + timeoutms = 700; /* ms escape character wait; delay */ + + assert(buffer && length); + assert(timeoutms >= -1); + if (NULL == buffer || 0 == length) + return 0; + + if (length > 1) { + int ret; + + --length; /* null terminator */ + + if (timeoutms < 0) { /* blocking */ + if ((ret = sys_read(TTY_INFD, buffer + cnt, length - cnt)) > 0) { + cnt = ret; + while (cnt < length && + (ret = sys_read_timed(TTY_INFD, buffer + cnt, length - cnt, 100, NULL)) > 0) { + cnt += ret; /* secondary characters */ + } + } + + } else { /* timed */ + if ((ret = sys_read_timed(TTY_INFD, buffer, length, timeoutms, NULL)) > 0) { + cnt = ret; + } + } + } + + buffer[cnt] = '\0'; + return cnt; +} + +#endif /*!USE_VIO_BUFFER && !DJGPP*/ + +/*end*/ + + + diff --git a/gr/ttyncurses.c b/gr/ttyncurses.c index 3c85db25..1b6d1bd6 100644 --- a/gr/ttyncurses.c +++ b/gr/ttyncurses.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_ttyncurses_c,"$Id: ttyncurses.c,v 1.19 2024/06/09 19:50:16 cvsuser Exp $") +__CIDENT_RCSID(gr_ttyncurses_c,"$Id: ttyncurses.c,v 1.25 2024/07/23 12:00:35 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: ttyncurses.c,v 1.19 2024/06/09 19:50:16 cvsuser Exp $ +/* $Id: ttyncurses.c,v 1.25 2024/07/23 12:00:35 cvsuser Exp $ * [n]curses tty driver interface -- alt driver when running under ncurses. * * @@ -50,57 +50,54 @@ ttcurses(void) #ifndef _XOPEN_SOURCE_EXTENDED #define _XOPEN_SOURCE_EXTENDED /* cchar_t */ #endif -#if defined(HAVE_NCURSESW_CURSESW_H) -#include -#include -#include - -#elif defined(HAVE_NCURSESW_CURSES_H) -#include -#include -#include - +#if defined(HAVE_NCURSESW_CURSES_H) +# include +# include +# include #elif defined(HAVE_NCURSESW_H) -#include -#if defined(HAVE_TERMCAP_H) -#include -#endif -#if defined(HAVE_TERM_H) -#include -#endif - +# include +# if defined(HAVE_TERMCAP_H) +# include +# endif +# if defined(HAVE_TERM_H) +# include +# endif +#elif defined(HAVE_NCURSES_CURSES_H) +# include +# include +# include +#elif defined(HAVE_NCURSES_H) +# include +# if defined(HAVE_TERMCAP_H) +# include +# endif +# if defined(HAVE_TERM_H) +# include +# endif #else /*!HAVE_NCURSESW_CURSES_H || HAVE_NCURSESW_H*/ #error "HAVE_LIBNCURSEW defined yet missing headers, check config" #endif #elif defined(HAVE_LIBNCURSES) -#if defined(HAVE_NCURSES_NCURSES_H) -#include -#include -#include - -#elif defined(HAVE_NCURSES_CURSES_H) -#include -#include -#include - +#if defined(HAVE_NCURSES_CURSES_H) +# include +# include +# include #elif defined(HAVE_NCURSES_H) -#include - -#if defined(HAVE_TERMCAP_H) -#include -#endif -#if defined(HAVE_TERM_H) -#include -#endif - +# include +# if defined(HAVE_TERMCAP_H) +# include +# endif +# if defined(HAVE_TERM_H) +# include +# endif #else /*!HAVE_NCURSES_CURSES_H || HAVE_NCURSES_H*/ #error "HAVE_LIBNCURSE defined yet missing headers, check config" #endif #endif #if defined(NCURSES_VERSION) && defined(HAVE_LIBNCURSESW) -extern int _nc_unicode_locale(void); /* XXX - private/exported */ +extern int _nc_unicode_locale(void); /* XXX - private/exported */ #endif #include "cmap.h" @@ -111,8 +108,15 @@ extern int _nc_unicode_locale(void); /* XXX - private/exported */ #include "main.h" #include "system.h" /* sys_...() */ #include "tty.h" +#include "ttyutil.h" #include "window.h" +#if defined(NCURSES_CONST) +#define CURSES_CAST(__x) (NCURSES_CONST char *)(__x) +#else +#define CURSES_CAST(__x) (char *)(__x) +#endif + typedef int16_t nccolor_t; static void nc_init(int *argcp, char **argv); @@ -135,9 +139,14 @@ static void nc_flush(void); static int nc_names(const char *title, const char *icon); static void nc_beep(int freq, int duration); +static void term_identification(void); +static void term_defaultscheme(void); +static void term_dump(void); +static void acs_dump(const char *bp); + static void term_colors(void); static nccolor_t term_color(const colvalue_t ca, int def, int fg, int *attr); -static int term_attr(int sf); +static int term_attribute(int sf); static void term_start(void); static void term_tidy(void); @@ -237,7 +246,7 @@ ttcurses(void) * General terminal identification. * o LINES/COLUMNS * Default terminal size. - * + * * Terminal capabilities (ncurses). * * o NCURSES_NO_UTF8_ACS - @@ -305,6 +314,8 @@ nc_open(scrprofile_t *profile) term_start(); term_colors(); + term_defaultscheme(); + term_identification(); profile->sp_rows = LINES; profile->sp_cols = COLS; @@ -376,6 +387,8 @@ nc_ready(int repaint, scrprofile_t *profile) static void nc_display(void) { + const int colors = tigetnum("colors"); + strxcpy(x_pt.pt_name, longname(), sizeof(x_pt.pt_name)); #if defined(NCURSES_VERSION) @@ -388,7 +401,7 @@ nc_display(void) trace_log("ttync:\n"); trace_log(" disptype: %d\n", xf_disptype); - trace_log(" colors : %d (%d)\n", tt_colors, COLORS); + trace_log(" colors : %d (%d,%d)\n", tt_colors, COLORS, colors); trace_log(" pairs : %d\n", COLOR_PAIRS); x_pt.pt_colordepth = tt_colors; @@ -588,9 +601,9 @@ nc_putc(const struct _VCELL *cell) if (tt_colors <= 2) { #if defined(A_ITALIC) /* TODO - runtime attribute checks */ - attrset(term_attr(ttbandw(attr, 1, 1, 0))); + attrset(term_attribute(ttbandw(attr, 1, 1, 0))); #else - attrset(term_attr(ttbandw(attr, 1, 0, 0))); + attrset(term_attribute(ttbandw(attr, 1, 0, 0))); #endif } else { @@ -626,7 +639,7 @@ nc_putc(const struct _VCELL *cell) a = COLOR_PAIR(id) | t_attr; color_valueset(attr, a); } - attrset(a | term_attr(ca.sf)); + attrset(a | term_attribute(ca.sf)); } } @@ -766,6 +779,218 @@ nc_names(const char *title, const char *icon) } +/* + * term_identification --- + * Request the terminal version/DA2 details. + */ +static void +term_identification(void) +{ + const char *RV = tigetstr("RV"); + + if (NULL == (RV = tigetstr("RV")) || *RV == '\0') { + const char *term = ggetenv("TERM"); + if (NULL == term) /* missing, source: vim */ + return; + if (NULL == strstr(term, "xterm") && NULL == strstr(term, "kitty")) + return; + } + tty_identification(RV, ESCDELAY); +} + + +/* + * term_defaultscheme --- + * Determine the terminal deault color-scheme. + */ +static void +term_defaultscheme(void) +{ + if (x_pt.pt_schemedark < 0) { + int isdark = -1; + + if (tigetflag("XT") > 0) { /* OSC-11 supported? */ + isdark = tty_luminance(ESCDELAY); + } + + if (isdark < 0) { + isdark = tty_defaultscheme(); /* Legacy */ + } + + x_pt.pt_schemedark = isdark; + } +} + + +/* + * term_dump --- + * Dump the terminal definition. + */ +static void +term_dump(void) +{ + // https://invisible-island.net/ncurses/man/user_caps.5.html + // https://www.gnu.org/software/screen/manual/screen.html#Termcap-Syntax + // screen - special terminal capabilities + // XT = terminal understands special xterm sequences (OSC, mouse tracking). + // + static const struct { + const char *name, *fname; + } extrastr[] = { + { "E3", "userdef_clear_scrollback" }, + { "RGB", "userdef_rgb_number" }, + { "XM", "userdef_mouse_enable_disable" }, + { NULL, NULL } + }; + + static const struct { + const char *name, *fname; + } extranum[] = { + { "RGB", "userdef_rgb_num" }, + { "U8", "userdef_unicode_line" }, + { NULL, NULL } + }; + + static const struct { + const char *name, *fname; + } extrabool[] = { + { "AX", "userdef_sgr_default" }, + { "RGB", "userdef_rgb_bool" }, + { "XT", "userdef_xterm_osc" }, + { NULL, NULL } + }; + const char *fname; + int i; + + if (0 == trace_flags()) return; + + trace_log("termcap:\n"); + trace_log(" Strings:\n"); + for (i = 0; (fname = strfnames[i]) != NULL; ++i) { + if (0 != memcmp(fname, "key_", 4)) { // key_xxx + const char *name = strnames[i]; + const char *val = tigetstr(CURSES_CAST(name)); + trace_log("\t%-24.24s %-4s %-8s : %s\n", + fname, strcodes[i], name, (val == NULL ? "" : (val == (void *)-1 ? "NA" : c_string(val)))); + if (0 == strcmp(fname, "acs_chars")) { + acs_dump(val); + } + } + } + for (i = 0; (fname = extrastr[i].fname) != NULL; ++i) { + const char *name = extrastr[i].name; + const char *val = tigetstr(CURSES_CAST(name)); + trace_log("\t%-24.24s %-4s %-8s : %s\n", + fname, "", name, (val == NULL ? "" : (val == (void *)-1 ? "NA" : c_string(val)))); + } + + trace_log(" Keys:\n"); + for (i = 0; (fname = strfnames[i]) != NULL; ++i) { + if (0 == memcmp(fname, "key_", 4)) { // key_xxx + const char *name = strnames[i]; + const char *val = tigetstr(CURSES_CAST(name)); + trace_log("\t%-24.24s %-4s %-8s : %s\n", + fname, strcodes[i], name, (val == NULL ? "" : (val == (void *)-1 ? "NA" : c_string(val)))); + } + } + + trace_log(" Numeric:\n"); + for (i = 0; (fname = numfnames[i]) != NULL; ++i) { + const char *name = numnames[i]; + const int val = tigetnum(CURSES_CAST(name)); + trace_log("\t%-24.24s %-4s %-8s : %d\n", + fname, numcodes[i], name, val); + } + for (i = 0; (fname = extranum[i].fname) != NULL; ++i) { + const char *name = extranum[i].name; + const int val = tigetnum(CURSES_CAST(name)); + trace_log("\t%-24.24s %-4s %-8s : %d\n", + fname, "", name, val); + } + + trace_log(" Boolean/Flags:\n"); + for (i = 0; (fname = boolfnames[i]) != NULL; ++i) { + const char *name = boolnames[i]; + const int val = tigetflag(CURSES_CAST(name)); + trace_log("\t%-24.24s %-4s %-8s : %d\n", + fname, boolcodes[i], name, val); + } + for (i = 0; (fname = extrabool[i].fname) != NULL; ++i) { + const char *name = extrabool[i].name; + const int val = tigetflag(CURSES_CAST(name)); + trace_log("\t%-24.24s %-4s %-8s : %d\n", + fname, "", name, val); + } +} + + +static void +acs_dump(const char *bp) +{ + const static struct { + unsigned char ident; + const char *desc; + } term_characters[] = { /* graphic characters */ + { '}', "UK pound sign" }, + { '.', "arrow pointing down" }, + { ',', "arrow pointing left" }, + { '+', "arrow pointing right" }, + { '-', "arrow pointing up" }, + { 'h', "board of squares" }, + { '~', "bullet" }, + { 'a', "checker board (stipple)" }, + { 'f', "degree symbol" }, + { '`', "diamond" }, + { 'z', "greater-than-or-equal-to" }, + { '{', "greek pi" }, + { 'q', "horizontal line" }, + { 'i', "lantern symbol" }, + { 'n', "large plus or crossover" }, + { 'y', "less-than-or-equal-to" }, + { 'm', "lower left corner" }, + { 'j', "lower right corner" }, + { '|', "not-equal" }, + { 'g', "plus/minus" }, + { 'o', "scan line 1" }, + { 'p', "scan line 3" }, + { 'r', "scan line 7" }, + { 's', "scan line 9" }, + { '0', "solid square block" }, + { 'w', "tee pointing down" }, + { 'u', "tee pointing left" }, + { 't', "tee pointing right" }, + { 'v', "tee pointing up" }, + { 'l', "upper left corner" }, + { 'k', "upper right corner" }, + { 'x', "vertical line" } + }; + + const unsigned char *p = (unsigned char *)bp; + unsigned char ident, ch; + unsigned i; + + while (*p) { + const char *desc = "unknown"; + + ident = *p++; + if (! isprint(ident)) continue; + ch = *p++; + + for (i = 0; i < (sizeof(term_characters)/sizeof(term_characters[0])); ++i) + if (term_characters[i].ident == ident) { + desc = term_characters[i].desc; + break; + } + + trace_log("\t\t%-30s %c/0x%x : %u/0x%x\n", desc, ident, ident, ch, ch); + } +} + + +/* + * term_colors --- + * Determine the terminal color depth. + */ static void term_colors(void) { @@ -806,6 +1031,10 @@ term_colors(void) } +/* + * term_color --- + * Map color-attribute to a terminal color. + */ static nccolor_t term_color(const colvalue_t ca, int def, int fg, int *attrs) { @@ -853,8 +1082,12 @@ term_color(const colvalue_t ca, int def, int fg, int *attrs) } +/* + * term_attribute --- + * Map color-style to a terminal attribute. + */ static int -term_attr(int sf) +term_attribute(int sf) { int attr = 0; @@ -872,11 +1105,16 @@ term_attr(int sf) } +/* + * term_start --- + * Terminal start session operation. + */ static void term_start(void) { if (NULL == tt_win) { tt_win = initscr(); + term_dump(); } nonl(); noecho(); @@ -887,6 +1125,10 @@ term_start(void) } +/* + * term_tidy --- + * Terminal end session operation. + */ static void term_tidy(void) { @@ -902,5 +1144,5 @@ term_tidy(void) } #endif /*HAVE_LIBNCURSES*/ -/*end*/ +/*end*/ diff --git a/gr/ttyrgb.c b/gr/ttyrgb.c index 88665ed9..e94c93df 100644 --- a/gr/ttyrgb.c +++ b/gr/ttyrgb.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_ttyrgb_c,"$Id: ttyrgb.c,v 1.16 2018/10/18 01:49:26 cvsuser Exp $") +__CIDENT_RCSID(gr_ttyrgb_c,"$Id: ttyrgb.c,v 1.19 2024/07/23 12:00:35 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: ttyrgb.c,v 1.16 2018/10/18 01:49:26 cvsuser Exp $ +/* $Id: ttyrgb.c,v 1.19 2024/07/23 12:00:35 cvsuser Exp $ * Color RGB support. * * @@ -43,8 +43,8 @@ struct rgbdef { uint8_t blue; }; -static int rgbvalue_new(const char **cursor, int rgbmax); -static int rgbvalue_old(const char **cursor, int len, int rgbmax); +static int rgblist(const char **cursor, int rgbmax); +static int rgbhex(const char **cursor, int len, int rgbmax); static const struct rgbdef *rgb_win256table(void); static const struct rgbdef *rgb_xterm256table(void); @@ -56,7 +56,10 @@ void hsl2rgb(float h, float s, float l, struct rgbvalue *rgb) static float huetorgb(float m1, float m2, float h); void rgb2hsl(const struct rgbvalue *rgb, float *h, float *s, float *l); -static const struct rgbdef xterm_basic16[16] = { +#define BASIC16 16 +#define GREY24 24 + +static const struct rgbdef xterm_basic16[BASIC16] = { { 0, 0x00, 0x00, 0x00 }, { 1, 0xCD, 0x00, 0x00 }, { 2, 0x00, 0xCD, 0x00 }, @@ -76,7 +79,7 @@ static const struct rgbdef xterm_basic16[16] = { }; -static const struct rgbdef win_basic16[16] = { +static const struct rgbdef win_basic16[BASIC16] = { { 0, 0x00, 0x00, 0x00 }, { 1, 0x00, 0x00, 0x80 }, { 2, 0x00, 0x80, 0x00 }, @@ -101,10 +104,10 @@ static const struct rgbdef win_basic16[16] = { static double round(const double x) //middle value point test { - if (ceil(x + 0.5) == floor(x + 0.5)) { - int a = (int)ceil(x); - if (a % 2 == 0) {return ceil(x);} - return floor(x); + if (ceil(x + 0.5) == floor(x + 0.5)) { + int a = (int)ceil(x); + if (a % 2 == 0) {return ceil(x);} + return floor(x); } return floor(x + 0.5); } @@ -151,9 +154,9 @@ rgb_import(const char *name, int length, struct rgbvalue *rgb, int rgbmax) */ const char *cursor = name + 4; - r = rgbvalue_new(&cursor, rgbmax); - g = rgbvalue_new(&cursor, rgbmax); - b = rgbvalue_new(&cursor, rgbmax); + r = rgblist(&cursor, rgbmax); + g = rgblist(&cursor, rgbmax); + b = rgblist(&cursor, rgbmax); if (b >= 0 && 0 == *cursor) { ret = COLORRGB_RGB; } @@ -224,7 +227,7 @@ rgb_import(const char *name, int length, struct rgbvalue *rgb, int rgbmax) } } - } else if ('#' == name[0]) { + } else if ('#' == name[0] || isxdigit((unsigned)name[0])) { /* * RGB Device String Specification (older style) * @@ -237,28 +240,34 @@ rgb_import(const char *name, int length, struct rgbvalue *rgb, int rgbmax) * For example: * #3a7 ==> #3000a0007000 */ - const char *cursor = name + 1; + const char *cursor = name; + + if ('#' == name[0]) { + ++cursor, --length; + } - switch (--length) { - case 3: /* 4 bits */ - r = rgbvalue_old(&cursor, 1, rgbmax); - g = rgbvalue_old(&cursor, 1, rgbmax); - b = rgbvalue_old(&cursor, 1, rgbmax); + switch (length) { + case 3: /* 4 bits */ + if ('#' == name[0]) { /* #RGB only */ + r = rgbhex(&cursor, 1, rgbmax); + g = rgbhex(&cursor, 1, rgbmax); + b = rgbhex(&cursor, 1, rgbmax); + } break; - case 6: /* 8 bits */ - r = rgbvalue_old(&cursor, 2, rgbmax); - g = rgbvalue_old(&cursor, 2, rgbmax); - b = rgbvalue_old(&cursor, 2, rgbmax); + case 6: /* 8 bits */ + r = rgbhex(&cursor, 2, rgbmax); + g = rgbhex(&cursor, 2, rgbmax); + b = rgbhex(&cursor, 2, rgbmax); break; - case 9: /* 12 bits */ - r = rgbvalue_old(&cursor, 3, rgbmax); - g = rgbvalue_old(&cursor, 3, rgbmax); - b = rgbvalue_old(&cursor, 3, rgbmax); + case 9: /* 12 bits */ + r = rgbhex(&cursor, 3, rgbmax); + g = rgbhex(&cursor, 3, rgbmax); + b = rgbhex(&cursor, 3, rgbmax); break; - case 12: /* 16 bits */ - r = rgbvalue_old(&cursor, 4, rgbmax); - g = rgbvalue_old(&cursor, 4, rgbmax); - b = rgbvalue_old(&cursor, 4, rgbmax); + case 12: /* 16 bits */ + r = rgbhex(&cursor, 4, rgbmax); + g = rgbhex(&cursor, 4, rgbmax); + b = rgbhex(&cursor, 4, rgbmax); break; default: break; @@ -297,7 +306,7 @@ is_white(int ch) * // */ static int -rgbvalue_new(const char **cursor, int rgbmax) +rgblist(const char **cursor, int rgbmax) { const char *t_cursor = *cursor; int digits = 0, value = 0, c; @@ -364,7 +373,7 @@ rgbvalue_new(const char **cursor, int rgbmax) * #RRGGBB */ static int -rgbvalue_old(const char **cursor, int len, int rgbmax) +rgbhex(const char **cursor, int len, int rgbmax) { const char *t_cursor = *cursor; int digits = 0, value = 0, c; @@ -535,13 +544,14 @@ rgb_256xterm(const int color, struct rgbvalue *rgb) rgb->blue = xterm_basic16[color].blue; } else if (color < 232) { /* color cube color 6x6x6 */ - unsigned idx = (unsigned)color - 16; + const unsigned idx = (unsigned)color - 16; + rgb->red = colorcube[(idx/36)%6]; rgb->green = colorcube[(idx/6)%6]; rgb->blue = colorcube[idx%6]; } else if (color < 256) { /* grey scale */ - const int grey = 8 + (color - 232) * 10; + const unsigned grey = (((unsigned)color - 232U) * 10) + 8; rgb->red = grey; rgb->green = grey; @@ -627,17 +637,36 @@ rgb_88xterm(const int color, struct rgbvalue *rgb) } +/* + * rgb_color256 --- + * RGB to 256-color palette, ignoring system-colors. + */ +int +rgb_color256(const struct rgbvalue *rgb) +{ + return rgb_searchtable(rgb_xterm256table() + BASIC16, 256 - BASIC16, GREY24, rgb); +} + + +/* + * rgb_win256 --- + * RGB to 256-color palette, including default windows system-colors. + */ int rgb_win256(const struct rgbvalue *rgb) { - return rgb_searchtable(rgb_win256table(), 256, 24, rgb); + return rgb_searchtable(rgb_win256table(), 256, GREY24, rgb); } +/* + * rgb_xterm256 --- + * RGB to 256-color palette, including default Xterm system-colors. + */ int rgb_xterm256(const struct rgbvalue *rgb) { - return rgb_searchtable(rgb_xterm256table(), 256, 24, rgb); + return rgb_searchtable(rgb_xterm256table(), 256, GREY24, rgb); } @@ -735,21 +764,24 @@ rgb_searchtable(const struct rgbdef *table, int maxval, int greyscale, const str int color = 0, minval, i; /* - * Euclidean distance-metric + * Table selection */ - if (greyscale > 0 && red == green && red == blue) { - minval = maxval - greyscale; /* grey-scale table */ + if (greyscale > 0 && red == green && red == blue && red != 0x00 && red != 0xff) { + minval = maxval - greyscale; /* grey-scale table; exclude black&white */ table += minval; } else { /* non grey-scale colours */ - minval = 0; - /* maxval -= greyscale; ??? */ + minval = 0; + maxval -= greyscale; } + /* + * Euclidean distance-metric + */ for (i = minval; i < maxval; ++i) { double distance, tmp; - tmp = red - (int)table->red; - distance = tmp * tmp; + tmp = red - (int)table->red; + distance = tmp * tmp; tmp = green - (int)table->green; distance += tmp * tmp; tmp = blue - (int)table->blue; @@ -765,21 +797,20 @@ rgb_searchtable(const struct rgbdef *table, int maxval, int greyscale, const str /* + * Translate HSL to RGB is simple, which was used to generate the tables.) In these + * algorithms, all three values (H, S and L) have been normalized to fractions 0..1: + * + * Notes: + * The advantage of HSL over RGB is that it is far more intuitive: you can guess at the + * colors you want, and then tweak. It is also easier to create sets of matching colors (by + * keeping the hue the same and varying the lightness/darkness, and saturation) + * + * If saturation is less than 0%, implementations must clip it to 0%. If the resulting value + * is outside the device gamut, implementations must clip it to the device gamut. This + * clipping should preserve the hue when possible, but is otherwise undefined. (In other + * words, the clipping is different from applying the rules for clipping of RGB colors after + * applying the algorithm below for converting HSL to RGB.) * - Translate HSL to RGB is simple, which was used to generate the tables.) In these - algorithms, all three values (H, S and L) have been normalized to fractions 0..1: - - Notes: - The advantage of HSL over RGB is that it is far more intuitive: you can guess at the - colors you want, and then tweak. It is also easier to create sets of matching colors (by - keeping the hue the same and varying the lightness/darkness, and saturation) - - If saturation is less than 0%, implementations must clip it to 0%. If the resulting value - is outside the device gamut, implementations must clip it to the device gamut. This - clipping should preserve the hue when possible, but is otherwise undefined. (In other - words, the clipping is different from applying the rules for clipping of RGB colors after - applying the algorithm below for converting HSL to RGB.) - * References: * http://www.w3.org/TR/css3-color */ @@ -858,11 +889,11 @@ rgb_exporttable(const char *label, const struct rgbdef *table, int maxval, int b { unsigned color; -printf("const struct rgbvalue %srgb_%dtable[%d] = {\n", label, maxval, maxval); + printf("const struct rgbvalue %srgb_%dtable[%d] = {\n", label, maxval, maxval); if (10 == base) { for (color = 0; color < maxval; ++color) { -printf(" { %d,%s %3d, %3d, %3d },\n", + printf(" { %d,%s %3d, %3d, %3d },\n", color, (color < 10 ? " " : (color < 100 ? " " : "")), table->red, table->green, table->blue); ++table; @@ -870,19 +901,85 @@ printf(" { %d,%s %3d, %3d, %3d },\n", } else { for (color = 0; color < maxval; ++color) { -printf(" { %d,%s 0x%02x, 0x%02x, 0x%02x },\n", + printf(" { %d,%s 0x%02x, 0x%02x, 0x%02x },\n", color, (color < 10 ? " " : (color < 100 ? " " : "")), table->red, table->green, table->blue); ++table; } } -printf(" };\n"); -printf("\n"); + printf(" };\n"); + printf("\n"); } -void +static const struct { + char rgb[9]; + unsigned cterm; +} gui2cterm[] = { + {"#000000", 16}, {"#00005f", 17}, {"#000087", 18}, {"#0000af", 19}, + {"#0000d7", 20}, {"#0000ff", 21}, {"#005f00", 22}, {"#005f5f", 23}, + {"#005f87", 24}, {"#005faf", 25}, {"#005fd7", 26}, {"#005fff", 27}, + {"#008700", 28}, {"#00875f", 29}, {"#008787", 30}, {"#0087af", 31}, + {"#0087d7", 32}, {"#0087ff", 33}, {"#00af00", 34}, {"#00af5f", 35}, + {"#00af87", 36}, {"#00afaf", 37}, {"#00afd7", 38}, {"#00afff", 39}, + {"#00d700", 40}, {"#00d75f", 41}, {"#00d787", 42}, {"#00d7af", 43}, + {"#00d7d7", 44}, {"#00d7ff", 45}, {"#00ff00", 46}, {"#00ff5f", 47}, + {"#00ff87", 48}, {"#00ffaf", 49}, {"#00ffd7", 50}, {"#00ffff", 51}, + {"#5f0000", 52}, {"#5f005f", 53}, {"#5f0087", 54}, {"#5f00af", 55}, + {"#5f00d7", 56}, {"#5f00ff", 57}, {"#5f5f00", 58}, {"#5f5f5f", 59}, + {"#5f5f87", 60}, {"#5f5faf", 61}, {"#5f5fd7", 62}, {"#5f5fff", 63}, + {"#5f8700", 64}, {"#5f875f", 65}, {"#5f8787", 66}, {"#5f87af", 67}, + {"#5f87d7", 68}, {"#5f87ff", 69}, {"#5faf00", 70}, {"#5faf5f", 71}, + {"#5faf87", 72}, {"#5fafaf", 73}, {"#5fafd7", 74}, {"#5fafff", 75}, + {"#5fd700", 76}, {"#5fd75f", 77}, {"#5fd787", 78}, {"#5fd7af", 79}, + {"#5fd7d7", 80}, {"#5fd7ff", 81}, {"#5fff00", 82}, {"#5fff5f", 83}, + {"#5fff87", 84}, {"#5fffaf", 85}, {"#5fffd7", 86}, {"#5fffff", 87}, + {"#870000", 88}, {"#87005f", 89}, {"#870087", 90}, {"#8700af", 91}, + {"#8700d7", 92}, {"#8700ff", 93}, {"#875f00", 94}, {"#875f5f", 95}, + {"#875f87", 96}, {"#875faf", 97}, {"#875fd7", 98}, {"#875fff", 99}, + {"#878700", 100}, {"#87875f", 101}, {"#878787", 102}, {"#8787af", 103}, + {"#8787d7", 104}, {"#8787ff", 105}, {"#87af00", 106}, {"#87af5f", 107}, + {"#87af87", 108}, {"#87afaf", 109}, {"#87afd7", 110}, {"#87afff", 111}, + {"#87d700", 112}, {"#87d75f", 113}, {"#87d787", 114}, {"#87d7af", 115}, + {"#87d7d7", 116}, {"#87d7ff", 117}, {"#87ff00", 118}, {"#87ff5f", 119}, + {"#87ff87", 120}, {"#87ffaf", 121}, {"#87ffd7", 122}, {"#87ffff", 123}, + {"#af0000", 124}, {"#af005f", 125}, {"#af0087", 126}, {"#af00af", 127}, + {"#af00d7", 128}, {"#af00ff", 129}, {"#af5f00", 130}, {"#af5f5f", 131}, + {"#af5f87", 132}, {"#af5faf", 133}, {"#af5fd7", 134}, {"#af5fff", 135}, + {"#af8700", 136}, {"#af875f", 137}, {"#af8787", 138}, {"#af87af", 139}, + {"#af87d7", 140}, {"#af87ff", 141}, {"#afaf00", 142}, {"#afaf5f", 143}, + {"#afaf87", 144}, {"#afafaf", 145}, {"#afafd7", 146}, {"#afafff", 147}, + {"#afd700", 148}, {"#afd75f", 149}, {"#afd787", 150}, {"#afd7af", 151}, + {"#afd7d7", 152}, {"#afd7ff", 153}, {"#afff00", 154}, {"#afff5f", 155}, + {"#afff87", 156}, {"#afffaf", 157}, {"#afffd7", 158}, {"#afffff", 159}, + {"#d70000", 160}, {"#d7005f", 161}, {"#d70087", 162}, {"#d700af", 163}, + {"#d700d7", 164}, {"#d700ff", 165}, {"#d75f00", 166}, {"#d75f5f", 167}, + {"#d75f87", 168}, {"#d75faf", 169}, {"#d75fd7", 170}, {"#d75fff", 171}, + {"#d78700", 172}, {"#d7875f", 173}, {"#d78787", 174}, {"#d787af", 175}, + {"#d787d7", 176}, {"#d787ff", 177}, {"#d7af00", 178}, {"#d7af5f", 179}, + {"#d7af87", 180}, {"#d7afaf", 181}, {"#d7afd7", 182}, {"#d7afff", 183}, + {"#d7d700", 184}, {"#d7d75f", 185}, {"#d7d787", 186}, {"#d7d7af", 187}, + {"#d7d7d7", 188}, {"#d7d7ff", 189}, {"#d7ff00", 190}, {"#d7ff5f", 191}, + {"#d7ff87", 192}, {"#d7ffaf", 193}, {"#d7ffd7", 194}, {"#d7ffff", 195}, + {"#ff0000", 196}, {"#ff005f", 197}, {"#ff0087", 198}, {"#ff00af", 199}, + {"#ff00d7", 200}, {"#ff00ff", 201}, {"#ff5f00", 202}, {"#ff5f5f", 203}, + {"#ff5f87", 204}, {"#ff5faf", 205}, {"#ff5fd7", 206}, {"#ff5fff", 207}, + {"#ff8700", 208}, {"#ff875f", 209}, {"#ff8787", 210}, {"#ff87af", 211}, + {"#ff87d7", 212}, {"#ff87ff", 213}, {"#ffaf00", 214}, {"#ffaf5f", 215}, + {"#ffaf87", 216}, {"#ffafaf", 217}, {"#ffafd7", 218}, {"#ffafff", 219}, + {"#ffd700", 220}, {"#ffd75f", 221}, {"#ffd787", 222}, {"#ffd7af", 223}, + {"#ffd7d7", 224}, {"#ffd7ff", 225}, {"#ffff00", 226}, {"#ffff5f", 227}, + {"#ffff87", 228}, {"#ffffaf", 229}, {"#ffffd7", 230}, {"#ffffff", 231}, + {"#080808", 232}, {"#121212", 233}, {"#1c1c1c", 234}, {"#262626", 235}, + {"#303030", 236}, {"#3a3a3a", 237}, {"#444444", 238}, {"#4e4e4e", 239}, + {"#585858", 240}, {"#626262", 241}, {"#6c6c6c", 242}, {"#767676", 243}, + {"#808080", 244}, {"#8a8a8a", 245}, {"#949494", 246}, {"#9e9e9e", 247}, + {"#a8a8a8", 248}, {"#b2b2b2", 249}, {"#bcbcbc", 250}, {"#c6c6c6", 251}, + {"#d0d0d0", 252}, {"#dadada", 253}, {"#e4e4e4", 254}, {"#eeeeee", 255}, + }; + +int main(int argc, char *argv[]) { static const char *specs[] = { @@ -891,6 +988,11 @@ main(int argc, char *argv[]) "#001002003", "#000100020003", "", + "123", + "010203", + "001002003", + "000100020003", + "", "rgb:12/34/45", "rgb: 12/34 / 45 ", @@ -902,13 +1004,13 @@ main(int argc, char *argv[]) "rgb( 50%,100% , 0 %)", "", - "hsl(0, 100%, 50%)", /* red #FF0000 */ - "hsl(360, 100%, 50%)", /* " " */ - "hsl(120, 100%, 50%)", /* lime #00FF00 */ - "hsl(480, 100%, 50%)", /* " " */ - "hsl(120, 100%, 25%)", /* dark green #006400 */ - "hsl(120, 100%, 75%)", /* light green #90EE90 */ - "hsl(120, 75%, 75%)", /* pastel green #8F3F8F */ + "hsl(0, 100%, 50%)", /* red #FF0000 */ + "hsl(360, 100%, 50%)", /* " " */ + "hsl(120, 100%, 50%)", /* lime #00FF00 */ + "hsl(480, 100%, 50%)", /* " " */ + "hsl(120, 100%, 25%)", /* dark green #006400 */ + "hsl(120, 100%, 75%)", /* light green #90EE90 */ + "hsl(120, 75%, 75%)", /* pastel green #8F3F8F */ "hsl(360, 75%, 75%)", "", @@ -917,6 +1019,10 @@ main(int argc, char *argv[]) "#01023", "#00100203", "#00010002003", + "12", + "01023", + "00100203", + "00010002003", "rgb(110%, 50%, 0%)", "rgb(-110%, 50%, 0%)", "rgb(100%, 50, 0%)", @@ -938,7 +1044,7 @@ main(int argc, char *argv[]) } if (base) { - rgb_exporttable("win_", rgb_win256table(), 256, base); + rgb_exporttable("win_", rgb_win256table(), 256, base); rgb_exporttable("xterm_", rgb_xterm256table(), 256, base); rgb_exporttable("xterm_", rgb_xterm88table(), 88, base); } @@ -949,12 +1055,32 @@ main(int argc, char *argv[]) int ret = rgb_import(p, strlen(p), &rgb, 0xff); rgb_export(buf, sizeof(buf), &rgb, 0xff); - printf("%02d: %-32s (%2d) == %2d/%02x/%02x/%02x [%s]\n", + printf("%02d: %-16s (%2d) == %2d/%02x/%02x/%02x [%s]\n", cnt++, p, ret, rgb.type, rgb.red, rgb.green, rgb.blue, buf); } else { printf("\n"); } } + + printf("\n\nrgb2xterm\n"); + for (i = 0; i < 256; ++i) { + rgb_256xterm(i, &rgb); + + printf("%03d: rgb:%02x/%02x/%02x, xterm=%3d, color=%3d\n", + i, rgb.red, rgb.green, rgb.blue, rgb_xterm256(&rgb), rgb_color256(&rgb)); + } + + printf("\n\nrgb2cterm\n"); + for (i = 0; i < sizeof(gui2cterm)/sizeof(gui2cterm[0]); ++i) { + const char *spec = gui2cterm[i].rgb; + int ret = rgb_import(spec, strlen(spec), &rgb, 0xff); + + printf("%03d: %-15s (%2d) == rgb:%02x/%02x/%02x [xterm=%3d verses %3d]\n", + BASIC16+i, spec, ret, rgb.red, rgb.green, rgb.blue, rgb_color256(&rgb), gui2cterm[i].cterm); + } + + return 0; } #endif /*LOCAL_MAIN*/ + diff --git a/gr/ttyrgb.h b/gr/ttyrgb.h index 4dc1b204..9e0ca258 100644 --- a/gr/ttyrgb.h +++ b/gr/ttyrgb.h @@ -1,11 +1,11 @@ #ifndef GR_TTYRGB_H_INCLUDED #define GR_TTYRGB_H_INCLUDED #include -__CIDENT_RCSID(gr_ttyrgb_h,"$Id: ttyrgb.h,v 1.8 2014/10/22 02:33:22 ayoung Exp $") +__CIDENT_RCSID(gr_ttyrgb_h,"$Id: ttyrgb.h,v 1.9 2024/07/05 18:55:53 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: ttyrgb.h,v 1.8 2014/10/22 02:33:22 ayoung Exp $ +/* $Id: ttyrgb.h,v 1.9 2024/07/05 18:55:53 cvsuser Exp $ * Color RGB support. * * @@ -39,6 +39,7 @@ extern void rgb_256win(const int color, struct rgbvalue *rgb); extern void rgb_256xterm(const int color, struct rgbvalue *rgb); extern void rgb_88xterm(const int color, struct rgbvalue *rgb); +extern int rgb_color256(const struct rgbvalue *rgb); extern int rgb_win256(const struct rgbvalue *rgb); extern int rgb_xterm256(const struct rgbvalue *rgb); extern int rgb_xterm88(const struct rgbvalue *rgb); diff --git a/gr/ttyterm.c b/gr/ttyterm.c index 68263b76..9ae7056f 100644 --- a/gr/ttyterm.c +++ b/gr/ttyterm.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_ttyterm_c,"$Id: ttyterm.c,v 1.117 2024/05/22 12:51:34 cvsuser Exp $") +__CIDENT_RCSID(gr_ttyterm_c,"$Id: ttyterm.c,v 1.138 2024/09/26 12:19:35 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: ttyterm.c,v 1.117 2024/05/22 12:51:34 cvsuser Exp $ +/* $Id: ttyterm.c,v 1.138 2024/09/26 12:19:35 cvsuser Exp $ * TTY driver termcap/terminfo based. * * @@ -18,7 +18,7 @@ __CIDENT_RCSID(gr_ttyterm_c,"$Id: ttyterm.c,v 1.117 2024/05/22 12:51:34 cvsuser * ==end== */ -// #define ED_LEVEL 2 +// #define ED_LEVEL 2 #include @@ -32,7 +32,6 @@ __CIDENT_RCSID(gr_ttyterm_c,"$Id: ttyterm.c,v 1.117 2024/05/22 12:51:34 cvsuser #include #include /* gputenvv(), ggetenv() */ - #if defined(_VMS) #include #include @@ -43,43 +42,49 @@ __CIDENT_RCSID(gr_ttyterm_c,"$Id: ttyterm.c,v 1.117 2024/05/22 12:51:34 cvsuser #endif #if defined(HAVE_LIBNCURSESW) -#if defined(HAVE_NCURSESW_CURSESW_H) -#include -#include -#include -#elif defined(HAVE_NCURSESW_CURSES_H) -#include -#include -#include -#elif defined(HAVE_NCURSESW_H) -#include -#if defined(HAVE_TERMCAP_H) -#include -#endif -#if defined(HAVE_TERM_H) -#include -#endif +#if defined(HAVE_NCURSESW_CURSES_H) +# include +# include +# include +#elif defined(HAVE_NCURSES_CURSES_H) +# include +# include +# include +#elif defined(HAVE_NCURSESW_H) || defined(HAVE_NCURSES_H) || defined(HAVE_CURSES_H) +# if defined(HAVE_NCURSESW_H) +# include +# elif defined(HAVE_NCURSES_H) +# include +# else +# include +# endif +# if defined(HAVE_TERMCAP_H) +# include +# endif +# if defined(HAVE_TERM_H) +# include +# endif #else /*!HAVE_NCURSESW_CURSES_H || HAVE_NCURSESW_H*/ #error "HAVE_LIBNCURSEW defined yet missing headers, check config" #endif #elif defined(HAVE_LIBNCURSES) -#if defined(HAVE_NCURSES_NCURSES_H) -#include -#include -#include -#elif defined(HAVE_NCURSES_CURSES_H) -#include -#include -#include -#elif defined(HAVE_NCURSES_H) -#include -#if defined(HAVE_TERMCAP_H) -#include -#endif -#if defined(HAVE_TERM_H) -#include -#endif +#if defined(HAVE_NCURSES_CURSES_H) +# include +# include +# include +#elif defined(HAVE_NCURSES_H) || defined(HAVE_CURSES_H) +# if defined(HAVE_NCURSES_H) +# include +# else +# include +# endif +# if defined(HAVE_TERMCAP_H) +# include +# endif +# if defined(HAVE_TERM_H) +# include +# endif #else /*!HAVE_NCURSES_CURSES_H || HAVE_NCURSES_H*/ #error "HAVE_LIBNCURSE defined yet missing headers, check config" #endif @@ -113,7 +118,9 @@ extern char * tparm(const char *, ...); #elif defined(HAVE_LIBTERMLIB) #include -#define HAVE_TERMCAP +#if !defined(HAVE_TERMCAP) +#define HAVE_TERMCAP 1 +#endif #else #include "edtermcap.h" /* use local implementation -- BAD */ @@ -169,6 +176,7 @@ extern int ospeed; #include "procspawn.h" #include "system.h" #include "tty.h" +#include "ttyutil.h" #include "undo.h" #include "window.h" @@ -176,10 +184,21 @@ extern int ospeed; #define XTERM_COLORS 16 #define NOCOLOR 0x7fff +#if defined(NCURSES_CONST) +#define CURSES_CAST(__x) (NCURSES_CONST char *)(__x) +#else +#define CURSES_CAST(__x) (char *)(__x) +#endif + typedef struct { + const char * termfname; /* function name */ + unsigned userdef; /* is userdef attribute */ const char * termcapname; /* termcap name */ const char * terminfoname; /* terminfo name */ const char * comment; /* comment string */ +#define TC_FNAME(__fname) #__fname, 0 +#define TC_UNAME(__uname) "userdef_" #__uname, 1 +#define TC_KNAME(__kname) "keydef_" #__kname, 1 #define TC_DESC(__desc) __desc } Term_t; @@ -204,13 +223,14 @@ typedef struct { int ivalue; /* runtime value*/ } TermNumeric_t; +typedef uint32_t TAttributes_t; + static void term_open(scrprofile_t *profile); static void term_ready(int repaint, scrprofile_t *profile); static void term_feature(int ident, scrprofile_t *profile); static void term_display(void); static int term_control(int action, int param, ...); static void term_close(void); -static int hasfeature(const char *term, const char *what); static const char * ttisetup(void); static const char * ttiname(const Term_t *ti); @@ -218,7 +238,12 @@ static const char * ttigetstr(const Term_t *ti); static int ttigetnum(const Term_t *ti); static int ttigetflag(const Term_t *ti); -static int term_xtermlike(const char *term); +static TAttributes_t term_xtermlike(const char *term); + +static void key_enable(void); +static void key_config(void); +static int key_protocol(const char *term, int termlen); +static void key_disable(void); static void acs_dump(const char *bp); static const char * acs_box_characters(const char *bp); @@ -230,6 +255,7 @@ static int term_cursor(int visible, int imode, int virtual_space); static int term_names(const char *title, const char *icon); static void term_beep(int freq, int duration); +static void term_config(void); static void term_colors(void); static void term_fgbg(void); static const char * fgbg_value(const char *src, int *result); @@ -240,8 +266,9 @@ static int xterm_colors_get(char *buffer, int length); static int xterm_colors_set(const char *value); static int term_isutf8(void); -static int term_identification(void); -static int term_read(char *buf, int blen, accint_t tmo); +static void term_attributes(void); +static void term_identification(void); +static int term_luminance(void); static __CINLINE void term_graphic_enter(void); static __CINLINE void term_graphic_exit(void); @@ -300,21 +327,29 @@ static char tcapstrings[TC_SLEN]; /* termcap local storage */ /* * Terminate attributes */ -#define TA_XTERM 0x0001 -#define TA_VT100LIKE 0x0002 -#define TA_XTERMLIKE 0x0004 - -#define TA_LINUX 0x0010 -#define TA_CYGWIN 0x0020 -#define TA_KONSOLE 0x0040 -#define TA_SCREEN 0x0080 -#define TA_MINTTY 0x0100 - -#define TA_DARK 0x1000 /* generally dark background */ -#define TA_LIGHT 0x2000 /* light */ -#define TA_MONO 0x4000 /* mono terminal */ - -static unsigned t_attributes; /* attributes */ +#define TA_XTERM 0x00000001 +#define TA_VT100LIKE 0x00000002 +#define TA_XTERMLIKE 0x00000004 +#define TA_LINUX 0x00010000 +#define TA_CYGWIN 0x00020000 +#define TA_KONSOLE 0x00040000 +#define TA_SCREEN 0x00080000 +#define TA_MINTTY 0x00100000 /* see: https://github.com/mintty/mintty/wiki/CtrlSeqs */ +#define TA_PUTTY 0x00200000 +#define TA_MSTERMINAL 0x00400000 +#define TA_GNOME 0x01000000 +#define TA_KITTY 0x02000000 +#define TA_ALACRITTY 0x04000000 +#define TA_ITERM 0x08000000 +#define TA_HTERM 0x10000000 +#define TA_WEZTERM 0x20000000 +#define TA_DARK 0x00000010 /* generally dark background */ +#define TA_LIGHT 0x00000020 /* generally light */ +#define TA_MONO 0x00000040 /* mono terminal */ +#define TA_LUMINANCE_DARK 0x00000100 +#define TA_LUMINANCE_LIGHT 0x00000200 + +static TAttributes_t t_attributes; /* attributes */ static int t_charout; /* number of characters output. */ static unsigned t_insdel; /* do we have both insert & delete line? */ static int t_padchar = -1; /* pad character (if any) */ @@ -333,7 +368,6 @@ static unsigned t_specials; /* special bits */ static char t_colorsorg[XTERM_COLORS * 32]; static char t_colorsuser[XTERM_COLORS * 32]; - /* * Cached termap controls * @@ -342,11 +376,7 @@ static char t_colorsuser[XTERM_COLORS * 32]; * X/Open System Interface Definitions, Issue 4, Version 2. * * http://www.xfree86.org/current/ctlseqs.html - * - * http://dickey.his.com/xterm/xterm.faq.html - * - * http://frexx.de/xterm-256-notes - * + * http://invisible-island.net/ncurses/#download_database * http://en.wikipedia.org/wiki/ANSI_escape_code */ static int @@ -366,12 +396,14 @@ static int tf_ut, /* screen erased with background color. */ tf_be, /* back color erase (xterm). */ tf_xs, tf_xt, /* attribute clear mode */ - tf_ms; /* save to move cursor whilst standout/underlined */ + tf_ms, /* save to move cursor whilst standout/underlined */ + tf_XT; /* supports xterm OCS and mouse */ static int tn_sg, /* number of glitches, 0 for invisable, -1 for none */ tn_li, tn_co, /* lines/columns */ - tn_NC; /* attributes which dont mix with colors */ + tn_NC, /* attributes which dont mix with colors */ + tn_RGB; /* RGB bits */ static const char *tc_ti, /* Term init -- start using cursor motion. */ @@ -392,7 +424,7 @@ static const char *tc_pDO, /* Cursor down - parameterised. */ *tc_le, /* Cursor left (new style). */ *tc_bc, /* Cursor left (old style). */ - *tc_pBC, /* Cursor left - parameterised. */ + *tc_pLE, /* Cursor left - parameterised. */ *tc_nd, /* Cursor right. */ *tc_pRI, /* Cursor right - parameterised. */ *tc_cv, /* Cursor vertical movement. */ @@ -437,7 +469,9 @@ static const char *tc_md, /* Make bold. */ *tc_ZH, *tc_ZR, /* Italic (on/off). */ *tc_mr, *tc_ZX, /* Reverse (on/off). */ - *tc_sa; /* Attribute set. */ + *tc_sa, /* Attribute set. */ + + *tc_RV; /* XTerm version */ static const char *tc_acs_start, /* as */ @@ -537,585 +571,720 @@ static GraphicChars_t term_characters[] = { /* graphic characters */ }; static TermString_t term_strings[] = { /* strings - termcap/terminfo elements */ - { "ac", "acsc", TC_DESC("acs characters"), TC_STRING(&tc_graphic_pairs) }, - { "bt", "cbt", TC_DESC("back tab")}, - { "bl", "bel", TC_DESC("audible signal (bell)"), TC_STRING(&tc_bl) }, - { "cr", "cr", TC_DESC("carriage return"), TC_STRING(&tc_cr) }, - { "ZA", "cpi", TC_DESC("change number of characters per inch") }, - { "ZB", "lpi", TC_DESC("change number of lines per inch") }, - { "ZC", "chr", TC_DESC("change horizontal resolution") }, - { "ZD", "cvr", TC_DESC("change vertical resolution") }, - { "cs", "csr", TC_DESC("change region to line #1 to line #2"), &tc_cs }, - { "rP", "rmp", TC_DESC("like ip but when in insert mode") }, - { "ct", "tbc", TC_DESC("clear all tab stops") }, - { "MC", "mgc", TC_DESC("clear right and left soft margins") }, - { "cl", "clear", TC_DESC("clear screen and home cursor"), &tc_cl }, - { "cb", "el1", TC_DESC("clear to beginning of line"), &tc_cb }, - { "ce", "el", TC_DESC("clr eol"), &tc_ce }, - { "cd", "ed", TC_DESC("clear to end of screen"), &tc_cd }, - { "ch", "hpa", TC_DESC("horizontal position #1, absolute"), &tc_ch }, - { "CC", "cmdch", TC_DESC("terminal settable cmd character in prototype !?") }, - { "CW", "cwin", TC_DESC("define a window #1 from #2, #3 to #4, #5") }, - { "cm", "cup", TC_DESC("move to row #1 columns #2"), &tc_cm }, - { "do", "cud1", TC_DESC("down one line"), &tc_do }, - { "ho", "home", TC_DESC("home cursor (if no cup)"), &tc_ho }, - { "vi", "civis", TC_DESC("make cursor invisible"), &tc_vi }, - { "le", "cub1", TC_DESC("move left one space"), &tc_le }, - { "CM", "mrcup", TC_DESC("memory relative cursor addressing") }, - { "ve", "cnorm", TC_DESC("make cursor appear normal (undo civis/cvvis)"), &tc_ve }, - { "nd", "cuf1", TC_DESC("move right one space"), &tc_nd }, - { "ll", "ll", TC_DESC("last line, first column (if no cup)"), &tc_ll }, - { "up", "cuu1", TC_DESC("up one line"), &tc_up }, - { "vs", "cvvis", TC_DESC("make cursor very visible"), &tc_vs }, - { "ZE", "defc", TC_DESC("define a character") }, - { "dc", "dch1", TC_DESC("delete character"), &tc_dc }, - { "dl", "dl1", TC_DESC("delete line"), &tc_dl }, - { "DI", "dial", TC_DESC("dial number #1") }, - { "ds", "dsl", TC_DESC("disable status line") }, - { "DK", "dclk", TC_DESC("display clock at (#1,#2)") }, - { "hd", "hd", TC_DESC("half a line down") }, - { "eA", "enacs", TC_DESC("enable alternate char set"), &tc_acs_enable }, - { "as", "smacs", TC_DESC("enter alt charset mode"), &tc_acs_start }, - { "SA", "smam", TC_DESC("turn on automatic margins"), &tc_am_on }, - { "mb", "blink", TC_DESC("turn on blinking"), &tc_mb }, - { "md", "bold", TC_DESC("turn on bold (extra bright) mode"), &tc_md }, - { "ti", "smcup", TC_DESC("string to start programs using cup"), &tc_ti }, - { "dm", "smdc", TC_DESC("enter delete mode") }, - { "mh", "dim", TC_DESC("turn on half-bright mode") }, - { "ZF", "swidm", TC_DESC("enter double-wide mode") }, - { "ZG", "sdrfq", TC_DESC("enter draft-quality mode") }, - { "im", "smir", TC_DESC("enter insert mode"), &tc_im }, - { "ZH", "sitm", TC_DESC("enter italic mode"), &tc_ZH }, - { "ZI", "slm", TC_DESC("start leftward carriage motion") }, - { "ZJ", "smicm", TC_DESC("start micro-motion mode") }, - { "ZK", "snlq", TC_DESC("enter NLQ mode") }, - { "ZL", "snrmq", TC_DESC("enter normal-quality mode") }, - { "mp", "prot", TC_DESC("turn on protected mode") }, - { "mr", "rev", TC_DESC("turn on reverse video mode"), &tc_mr }, - { "mk", "invis", TC_DESC("turn on blank mode (characters invisible)") }, - { "ZM", "sshm", TC_DESC("enter shadow-print mode") }, - { "so", "smso", TC_DESC("begin standout mode"), &tc_so }, - { "ZN", "ssubm", TC_DESC("enter subscript mode") }, - { "ZO", "ssupm", TC_DESC("enter superscript mode") }, - { "us", "smul", TC_DESC("begin underline mode"), &tc_us }, - { "ZP", "sum", TC_DESC("start upward carriage motion") }, - { "SX", "smxon", TC_DESC("turn on xon/xoff handshaking") }, - { "ec", "ech", TC_DESC("erase #1 characters"), &tc_ech }, - { "ae", "rmacs", TC_DESC("exit alt charset mode"), &tc_acs_end }, - { "RA", "rmam", TC_DESC("turn off automatic margins") }, - { "me", "sgr0", TC_DESC("turn off all attributes"), &tc_me }, - { "te", "rmcup", TC_DESC("strings to end programs using cup"), &tc_te }, - { "ed", "rmdc", TC_DESC("end delete mode") }, - { "ZQ", "rwidm", TC_DESC("end double-wide mode") }, - { "ei", "rmir", TC_DESC("exit insert mode"), &tc_ei }, - { "ZR", "ritm", TC_DESC("end italic mode"), &tc_ZR }, - { "ZS", "rlm", TC_DESC("end left-motion mode") }, - { "ZU", "rmicm", TC_DESC("end shadow-print mode") }, - { "ZT", "rshm", TC_DESC("end micro-motion mode") }, - { "se", "rmso", TC_DESC("exit standout mode"), &tc_se }, - { "ZV", "rsubm", TC_DESC("exit_subscript_mode") }, - { "ZW", "rsupm", TC_DESC("end superscript mode") }, - { "ue", "rmul", TC_DESC("exit underline mode"), &tc_ue }, - { "ZX", "rum", TC_DESC("end reverse character motion"), &tc_ZX }, - { "RX", "rmxon", TC_DESC("turn off xon/xoff handshaking") }, - { "PA", "pause", TC_DESC("pause for 2-3 seconds") }, - { "fh", "hook", TC_DESC("flash switch hook") }, - { "vb", "flash", TC_DESC("visible bell (may not move cursor)"), &tc_vb }, - { "ff", "ff", TC_DESC("hardcopy terminal page eject") }, - { "fs", "fsl", TC_DESC("return from status line") }, - { "WG", "wingo", TC_DESC("go to window #1") }, - { "HU", "hup", TC_DESC("hang-up phone") }, - { "i1", "is1", TC_DESC("initialization string") }, - { "is", "is2", TC_DESC("initialization string") }, - { "i2", NULL, TC_DESC("secondary initialization string") }, - { "i3", "is3", TC_DESC("initialization string") }, - { "if", "if", TC_DESC("name of initialization file") }, - { "iP", "iprog", TC_DESC("path name of program for initialization") }, - { "Ic", "initc", TC_DESC("initialize color #1 to (#2,#3,#4)") }, - { "Ip", "initp", TC_DESC("initialize color pair #1 to fg=(#2,#3,#4), bg=(#5,#6,#7)") }, - { "ic", "ich1", TC_DESC("insert character"), &tc_ic }, - { "al", "il1", TC_DESC("insert line"), &tc_al }, - { "ip", "ip", TC_DESC("insert padding after inserted character") }, - { "ke", "rmkx", TC_DESC("leave 'keyboard_transmit' mode"), &tc_ke }, - { "ks", "smkx", TC_DESC("enter 'keyboard_transmit' mode"), &tc_ks }, - { "l0", "lf0", TC_DESC("label on function key f0 if not f0") }, - { "l1", "lf1", TC_DESC("label on function key f1 if not f1") }, - { "l2", "lf10", TC_DESC("label on function key f2 if not f2") }, - { "l3", "lf2", TC_DESC("label on function key f3 if not f3") }, - { "l4", "lf3", TC_DESC("label on function key f4 if not f4") }, - { "l5", "lf4", TC_DESC("label on function key f5 if not f5") }, - { "l6", "lf5", TC_DESC("label on function key f6 if not f6") }, - { "l7", "lf6", TC_DESC("label on function key f7 if not f7") }, - { "l8", "lf7", TC_DESC("label on function key f8 if not f8") }, - { "l9", "lf8", TC_DESC("label on function key f9 if not f9") }, - { "la", "lf9", TC_DESC("label on function key f10 if not f10") }, - { "Lf", "fln", TC_DESC("label format") }, - { "LF", "rmln", TC_DESC("turn off soft labels") }, - { "LO", "smln", TC_DESC("turn on soft labels") }, - { "mo", "rmm", TC_DESC("turn off meta mode"), &tc_mo }, - { "mm", "smm", TC_DESC("turn on meta mode (8th-bit on)"), &tc_mm }, - { "ZY", "mhpa", TC_DESC("like column_address in micro mode") }, - { "ZZ", "mcud1", TC_DESC("like cursor_down in micro mode") }, - { "Za", "mcub1", TC_DESC("like cursor_left in micro mode") }, - { "Zb", "mcuf1", TC_DESC("like cursor_right in micro mode") }, - { "Zc", "mvpa", TC_DESC("like row_address in micro mode") }, - { "Zd", "mcuu1", TC_DESC("like cursor_up in micro mode") }, - { "nw", "nel", TC_DESC("newline (behave like cr followed by lf)") }, - { "Ze", "porder", TC_DESC("match software bits to print-head pins") }, - { "oc", "oc", TC_DESC("set all color pairs to the original ones"), &tc_oc }, - { "op", "op", TC_DESC("set default pair to its original value"), &tc_op }, - { "pc", "pad", TC_DESC("padding char (instead of null)"), &tc_pc }, - { "DC", "dch", TC_DESC("delete #1 chars"), &tc_pDC }, - { "DL", "dl", TC_DESC("parm_delete_line"), &tc_pDL }, - { "DO", "cud", TC_DESC("down #1 lines"), &tc_pDO }, - { "Zf", "mcud", TC_DESC("like parm down cursor in micro mode") }, - { "IC", "ich", TC_DESC("insert #1 chars") }, - { "SF", "indn", TC_DESC("scroll forward #1 lines"), &tc_pSF }, - { "AL", "il", TC_DESC("parm insert line"), &tc_pAL }, - { "LE", "cub", TC_DESC("move #1 chars to the left"), &tc_pBC }, - { "Zg", "mcub", TC_DESC("Like parm left cursor in micro mode") }, - { "RI", "cuf", TC_DESC("parm right cursor"), &tc_pRI }, - { "Zh", "mcuf", TC_DESC("Like parm right cursor in micro mode") }, - { "SR", "rin", TC_DESC("scroll back #1 lines"), &tc_pSR }, - { "UP", "cuu", TC_DESC("up #1 lines"), &tc_pUP }, - { "Zi", "mcuu", TC_DESC("Like parm_up_cursor in micro mode") }, - { "pk", "pfkey", TC_DESC("program function key #1 to type string #2") }, - { "pl", "pfloc", TC_DESC("program function key #1 to execute string #2") }, - { "px", "pfx", TC_DESC("program function key #1 to transmit string #2") }, - { "pn", "pln", TC_DESC("program label #1 to show string #2") }, - { "ps", "mc0", TC_DESC("print contents of screen") }, - { "pO", "mc5p", TC_DESC("turn on printer for #1 bytes") }, - { "pf", "mc4", TC_DESC("turn off printer") }, - { "po", "mc5", TC_DESC("turn on printer") }, - { "PU", "pulse", TC_DESC("select pulse dialling") }, - { "QD", "qdial", TC_DESC("dial number #1 without checking") }, - { "RC", "rmclk", TC_DESC("remove clock") }, - { "rp", "rep", TC_DESC("repeat char #1 #2 times"), &tc_rp }, - { "RF", "rfi", TC_DESC("send next input char (for ptys)") }, - { "rs", NULL, TC_DESC("terminal reset string"), &tc_rs }, - { "r1", "rs1", TC_DESC("reset string") }, - { "r2", "rs2", TC_DESC("reset string") }, - { "r3", "rs3", TC_DESC("reset string") }, - { "rf", "rf", TC_DESC("name of reset file") }, - { "rc", "rc", TC_DESC("restore cursor to last position of sc") }, - { "cv", "vpa", TC_DESC("vertical position #1 absolute"), &tc_cv }, - { "sc", "sc", TC_DESC("save current cursor position") }, - { "sf", "ind", TC_DESC("scroll text up"), &tc_sf }, - { "sr", "ri", TC_DESC("scroll text down"), &tc_sr }, - { "Zj", "scs", TC_DESC("select character set") }, - { "sa", "sgr", TC_DESC("define video attributes #1-#9 (PG9)"), &tc_sa }, - { "Sb", "setb", TC_DESC("set background (color)"), &tc_Color_Bg }, - { "Zk", "smgb", TC_DESC("set bottom margin at current line") }, - { "Zl", "smgbp", TC_DESC("set bottom margin at line #1 or #2 lines from bottom") }, - { "SC", "sclk", TC_DESC("set clock, #1 hrs #2 mins #3 secs") }, - { "sp", "scp", TC_DESC("set current color pair to #1") }, - { "Sf", "setf", TC_DESC("set foreground (color)"), &tc_Color_Fg }, - { "ML", "smgl", TC_DESC("set left soft margin") }, - { "Zm", "smglp", TC_DESC("set left (right) margin at column #1 (#2)") }, - { "MR", "smgr", TC_DESC("set right soft margin") }, - { "Zn", "smgrp", TC_DESC("set right margin at column #1") }, - { "st", "hts", TC_DESC("set a tab in every row, current columns") }, - { "Zo", "smgt", TC_DESC("set top margin at current line") }, - { "Zq", "smgtp", TC_DESC("start printing bit image braphics") }, - { "wi", "wind", TC_DESC("current window is lines #1-#2 cols #3-#4") }, - { "Zq", "sbim", TC_DESC("start bit image") }, - { "Zr", "scsd", TC_DESC("start character set definition") }, - { "Zs", "rbim", TC_DESC("stop printing bit image graphics") }, - { "Zt", "rcsd", TC_DESC("end definition of character aet") }, - { "Zu", "subcs", TC_DESC("list of subscriptable characters") }, - { "Zv", "supcs", TC_DESC("list of superscriptable characters") }, - { "ta", "ht", TC_DESC("tab to next 8-space hardware tab stop") }, - { "Zw", "docr", TC_DESC("printing any of these chars causes CR") }, - { "ts", "tsl", TC_DESC("move to status line") }, - { "TO", "tone", TC_DESC("select touch tone dialing") }, - { "uc", "uc", TC_DESC("underline char and move past it") }, - { "hu", "hu", TC_DESC("half a line up") }, - { "u0", "u0", TC_DESC("user string #0") }, - { "u1", "u1", TC_DESC("user string #1") }, - { "u2", "u2", TC_DESC("user string #2") }, - { "u3", "u3", TC_DESC("user string #3") }, - { "u4", "u4", TC_DESC("user string #4") }, - { "u5", "u5", TC_DESC("user string #5") }, - { "u6", "u6", TC_DESC("user string #6") }, - { "u7", "u7", TC_DESC("user string #7") }, - { "u8", "u8", TC_DESC("user string #8") }, - { "u9", "u9", TC_DESC("user string #9") }, - { "WA", "wait", TC_DESC("wait for dial-tone") }, - { "XF", "xoffc", TC_DESC("XOFF character") }, - { "XN", "xonc", TC_DESC("XON character") }, - { "Zx", "zerom", TC_DESC("no motion for subsequent character") }, - - /* - * The following string capabilities are present in the SVr4.0 term - * structure, but were originally not documented in the man page. - */ - { "S8", "scesa", TC_DESC("alternate escape for scancode emulation") }, - { "Yv", "bicr", TC_DESC("move to beginning of same row") }, - { "Zz", "binel", TC_DESC("move to next row of the bit image") }, - { "Xy", "birep", TC_DESC("repeat bit image cell #1 #2 times") }, - { "Zy", "csnm", TC_DESC("list of character set names") }, - { "ci", "csin", TC_DESC("init sequence for multiple codesets") }, - { "Yw", "colornm", TC_DESC("give name for color #1") }, - { "Yx", "defbi", TC_DESC("define rectangualar bit image region") }, - { "dv", "devt", TC_DESC("indicate language/codeset support") }, - { "S1", "dispc", TC_DESC("display PC character") }, - { "Yy", "endbi", TC_DESC("end a bit-image region") }, - { "S2", "smpch", TC_DESC("enter PC character display mode") }, - { "S4", "smsc", TC_DESC("enter PC scancode mode") }, - { "S3", "rmpch", TC_DESC("exit PC character display mode") }, - { "S5", "rmsc", TC_DESC("exit PC scancode mode") }, - { "Gm", "getm", TC_DESC("curses should get button events") }, - { "Km", "kmous", TC_DESC("mouse event has occurred") }, - { "Mi", "minfo", TC_DESC("mouse status information") }, - { "S6", "pctrm", TC_DESC("PC terminal options") }, - { "xl", "pfxl", TC_DESC("program function key #1 to type string #2 and show string #3") }, - { "RQ", "reqmp", TC_DESC("request mouse position") }, - { "S7", "scesc", TC_DESC("escape for scancode emulation") }, - { "s0", "s0ds", TC_DESC("shift to code set 0 (EUC set 0, ASCII)") }, - { "s1", "s1ds", TC_DESC("shift to code set 1") }, - { "s2", "s2ds", TC_DESC("shift to code set 2") }, - { "s3", "s3ds", TC_DESC("shift to code set 3") }, - { "AB", "setab", TC_DESC("set ANSI color background"), &tc_ANSI_Color_Bg }, - { "AF", "setaf", TC_DESC("set ANSI color foreground"), &tc_ANSI_Color_Fg }, - { "Yz", "setcolor", TC_DESC("change to ribbon color #1") }, - { "ML", "smglr", TC_DESC("set both left and right margins to #1, #2") }, - { "YZ", "slines", TC_DESC("set page length to #1 lines") }, - { "MT", "smgtb", TC_DESC("sets both top and bottom margins to #1, #2") }, - /* - * The XSI Curses standard added these. They are some post-4.1 versions - * of System V curses, e.g., Solaris 2.5 and IRIX 6.x. The ncurses term- - * cap names for them are invented; according to the XSI Curses standard, - * they have no termcap names. If your compiled terminfo entries use - * these, they may not be binary-compatible with System V terminfo - * entries after SVr4.1; beware! + * Source: https://invisible-island.net/ncurses/man/terminfo.5.html */ - { "Xh", "ehhlm", TC_DESC("enter horizontal highlight mode") }, - { "Xl", "elhlm", TC_DESC("enter left highlight mode") }, - { "Xo", "elohlm", TC_DESC("enter low highlight mode") }, - { "Xr", "erhlm", TC_DESC("enter right highlight mode") }, - { "Xt", "ethlm", TC_DESC("enter top highlight mode") }, - { "Xv", "evhlm", TC_DESC("enter vertical highlight mode") }, + { TC_FNAME(back_tab), "bt", "cbt", TC_DESC("back tab") }, + { TC_FNAME(bell), "bl", "bel", TC_DESC("audible signal (bell)"), TC_STRING(&tc_bl) }, + { TC_FNAME(carriage_return), "cr", "cr", TC_DESC("carriage return"), TC_STRING(&tc_cr) }, + { TC_FNAME(change_scroll_region), "cs", "csr", TC_DESC("change region to line #1 to line #2"), &tc_cs }, + { TC_FNAME(na), "cS", NULL, TC_DESC("change region to line #1 to line #2, alt form"), &tc_cS }, + { TC_FNAME(clear_all_tabs), "ct", "tbc", TC_DESC("clear all tab stops") }, + { TC_FNAME(clear_screen), "cl", "clear", TC_DESC("clear screen and home cursor"), &tc_cl }, + { TC_FNAME(clr_eol), "ce", "el", TC_DESC("clr eol"), &tc_ce }, + { TC_FNAME(clr_eos), "cd", "ed", TC_DESC("clear to end of screen"), &tc_cd }, + { TC_FNAME(column_address), "ch", "hpa", TC_DESC("horizontal position #1, absolute"), &tc_ch }, + { TC_FNAME(command_character), "CC", "cmdch", TC_DESC("terminal settable cmd character in prototype !?") }, + { TC_FNAME(cursor_address), "cm", "cup", TC_DESC("move to row #1 columns #2"), &tc_cm }, + { TC_FNAME(cursor_down), "do", "cud1", TC_DESC("down one line"), &tc_do }, + { TC_FNAME(cursor_home), "ho", "home", TC_DESC("home cursor (if no cup)"), &tc_ho }, + { TC_FNAME(cursor_invisible), "vi", "civis", TC_DESC("make cursor invisible"), &tc_vi }, + { TC_FNAME(cursor_left), "le", "cub1", TC_DESC("move left one space"), &tc_le }, + { TC_FNAME(cursor_mem_address), "CM", "mrcup", TC_DESC("memory relative cursor addressing") }, + { TC_FNAME(cursor_normal), "ve", "cnorm", TC_DESC("make cursor appear normal (undo civis/cvvis)"), &tc_ve }, + { TC_FNAME(cursor_right), "nd", "cuf1", TC_DESC("move right one space"), &tc_nd }, + { TC_FNAME(cursor_to_ll), "ll", "ll", TC_DESC("last line, first column (if no cup)"), &tc_ll }, + { TC_FNAME(cursor_up), "up", "cuu1", TC_DESC("up one line"), &tc_up }, + { TC_FNAME(cursor_visible), "vs", "cvvis", TC_DESC("make cursor very visible"), &tc_vs }, + { TC_FNAME(delete_character), "dc", "dch1", TC_DESC("delete character"), &tc_dc }, + { TC_FNAME(delete_line), "dl", "dl1", TC_DESC("delete line"), &tc_dl }, + { TC_FNAME(dis_status_line), "ds", "dsl", TC_DESC("disable status line") }, + { TC_FNAME(down_half_line), "hd", "hd", TC_DESC("half a line down") }, + { TC_FNAME(enter_alt_charset_mode), "as", "smacs", TC_DESC("enter alt charset mode"), &tc_acs_start }, + { TC_FNAME(enter_blink_mode), "mb", "blink", TC_DESC("turn on blinking"), &tc_mb }, + { TC_FNAME(enter_bold_mode), "md", "bold", TC_DESC("turn on bold (extra bright) mode"), &tc_md }, + { TC_FNAME(enter_ca_mode), "ti", "smcup", TC_DESC("string to start programs using cup"), &tc_ti }, + { TC_FNAME(enter_delete_mode), "dm", "smdc", TC_DESC("enter delete mode") }, + { TC_FNAME(enter_dim_mode), "mh", "dim", TC_DESC("turn on half-bright mode") }, + { TC_FNAME(enter_insert_mode), "im", "smir", TC_DESC("enter insert mode"), &tc_im }, + { TC_FNAME(enter_secure_mode), "mk", "invis", TC_DESC("turn on blank mode (characters invisible)") }, + { TC_FNAME(enter_protected_mode), "mp", "prot", TC_DESC("turn on protected mode") }, + { TC_FNAME(enter_reverse_mode), "mr", "rev", TC_DESC("turn on reverse video mode"), &tc_mr }, + { TC_FNAME(enter_standout_mode), "so", "smso", TC_DESC("begin standout mode"), &tc_so }, + { TC_FNAME(enter_underline_mode), "us", "smul", TC_DESC("begin underline mode"), &tc_us }, + { TC_FNAME(erase_chars), "ec", "ech", TC_DESC("erase #1 characters"), &tc_ech }, + { TC_FNAME(exit_alt_charset_mode), "ae", "rmacs", TC_DESC("exit alt charset mode"), &tc_acs_end }, + { TC_FNAME(exit_attribute_mode), "me", "sgr0", TC_DESC("turn off all attributes"), &tc_me }, + { TC_FNAME(exit_ca_mode), "te", "rmcup", TC_DESC("strings to end programs using cup"), &tc_te }, + { TC_FNAME(exit_delete_mode), "ed", "rmdc", TC_DESC("end delete mode") }, + { TC_FNAME(exit_insert_mode), "ei", "rmir", TC_DESC("exit insert mode"), &tc_ei }, + { TC_FNAME(exit_standout_mode), "se", "rmso", TC_DESC("exit standout mode"), &tc_se }, + { TC_FNAME(exit_underline_mode), "ue", "rmul", TC_DESC("exit underline mode"), &tc_ue }, + { TC_FNAME(flash_screen), "vb", "flash", TC_DESC("visible bell (may not move cursor)"), &tc_vb }, + { TC_FNAME(form_feed), "ff", "ff", TC_DESC("hardcopy terminal page eject") }, + { TC_FNAME(from_status_line), "fs", "fsl", TC_DESC("return from status line") }, + { TC_FNAME(init_1string), "i1", "is1", TC_DESC("initialization string #1") }, + { TC_FNAME(init_2string), "is", "is2", TC_DESC("initialization string #2") }, + { TC_FNAME(init_3string), "i3", "is3", TC_DESC("initialization string #3") }, + { TC_FNAME(init_file), "if", "if", TC_DESC("name of initialization file") }, + { TC_FNAME(insert_character), "ic", "ich1", TC_DESC("insert character"), &tc_ic }, + { TC_FNAME(insert_line), "al", "il1", TC_DESC("insert line"), &tc_al }, + { TC_FNAME(insert_padding), "ip", "ip", TC_DESC("insert padding after inserted character") }, + { TC_FNAME(keypad_local), "ke", "rmkx", TC_DESC("leave 'keyboard_transmit' mode"), &tc_ke }, + { TC_FNAME(keypad_xmit), "ks", "smkx", TC_DESC("enter 'keyboard_transmit' mode"), &tc_ks }, + { TC_FNAME(lab_f0), "l0", "lf0", TC_DESC("label on function key f0 if not f0") }, + { TC_FNAME(lab_f1), "l1", "lf1", TC_DESC("label on function key f1 if not f1") }, + { TC_FNAME(lab_f2), "l2", "lf2", TC_DESC("label on function key f2 if not f2") }, + { TC_FNAME(lab_f3), "l3", "lf3", TC_DESC("label on function key f3 if not f3") }, + { TC_FNAME(lab_f4), "l4", "lf4", TC_DESC("label on function key f4 if not f4") }, + { TC_FNAME(lab_f5), "l5", "lf5", TC_DESC("label on function key f5 if not f5") }, + { TC_FNAME(lab_f6), "l6", "lf6", TC_DESC("label on function key f6 if not f6") }, + { TC_FNAME(lab_f7), "l7", "lf7", TC_DESC("label on function key f7 if not f7") }, + { TC_FNAME(lab_f8), "l8", "lf8", TC_DESC("label on function key f8 if not f8") }, + { TC_FNAME(lab_f9), "l9", "lf9", TC_DESC("label on function key f9 if not f9") }, + { TC_FNAME(lab_f10), "la", "lf10", TC_DESC("label on function key f10 if not f10") }, + { TC_FNAME(meta_off), "mo", "rmm", TC_DESC("turn off meta mode"), &tc_mo }, + { TC_FNAME(meta_on), "mm", "smm", TC_DESC("turn on meta mode (8th-bit on)"), &tc_mm }, + { TC_FNAME(newline), "nw", "nel", TC_DESC("newline (behave like cr followed by lf)") }, + { TC_FNAME(pad_char), "pc", "pad", TC_DESC("padding char (instead of null)"), &tc_pc }, + { TC_FNAME(parm_dch), "DC", "dch", TC_DESC("delete #1 chars"), &tc_pDC }, + { TC_FNAME(parm_delete_line), "DL", "dl", TC_DESC("parm_delete_line"), &tc_pDL }, + { TC_FNAME(parm_down_cursor), "DO", "cud", TC_DESC("down #1 lines"), &tc_pDO }, + { TC_FNAME(parm_ich), "IC", "ich", TC_DESC("insert #1 chars") }, + { TC_FNAME(parm_index), "SF", "indn", TC_DESC("scroll forward #1 lines"), &tc_pSF }, + { TC_FNAME(parm_insert_line), "AL", "il", TC_DESC("parm insert line"), &tc_pAL }, + { TC_FNAME(parm_left_cursor), "LE", "cub", TC_DESC("move #1 chars to the left"), &tc_pLE }, + { TC_FNAME(parm_right_cursor), "RI", "cuf", TC_DESC("parm right cursor"), &tc_pRI }, + { TC_FNAME(parm_rindex), "SR", "rin", TC_DESC("scroll back #1 lines"), &tc_pSR }, + { TC_FNAME(parm_up_cursor), "UP", "cuu", TC_DESC("up #1 lines"), &tc_pUP }, + { TC_FNAME(pkey_key), "pk", "pfkey", TC_DESC("program function key #1 to type string #2") }, + { TC_FNAME(pkey_local), "pl", "pfloc", TC_DESC("program function key #1 to execute string #2") }, + { TC_FNAME(pkey_xmit), "px", "pfx", TC_DESC("program function key #1 to transmit string #2") }, + { TC_FNAME(print_screen), "ps", "mc0", TC_DESC("print contents of screen") }, + { TC_FNAME(prtr_off), "pf", "mc4", TC_DESC("turn off printer") }, + { TC_FNAME(prtr_on), "po", "mc5", TC_DESC("turn on printer") }, + { TC_FNAME(repeat_char), "rp", "rep", TC_DESC("repeat char #1 #2 times"), &tc_rp }, + { TC_FNAME(reset_1string), "r1", "rs1", TC_DESC("reset string #1") }, + { TC_FNAME(reset_2string), "r2", "rs2", TC_DESC("reset string #2") }, + { TC_FNAME(reset_3string), "r3", "rs3", TC_DESC("reset string #2") }, + { TC_FNAME(reset_file), "rf", "rf", TC_DESC("name of reset file") }, + { TC_FNAME(restore_cursor), "rc", "rc", TC_DESC("restore cursor to last position of sc") }, + { TC_FNAME(row_address), "cv", "vpa", TC_DESC("vertical position #1 absolute"), &tc_cv }, + { TC_FNAME(save_cursor), "sc", "sc", TC_DESC("save current cursor position") }, + { TC_FNAME(scroll_forward), "sf", "ind", TC_DESC("scroll text up"), &tc_sf }, + { TC_FNAME(scroll_reverse), "sr", "ri", TC_DESC("scroll text down"), &tc_sr }, + { TC_FNAME(set_attributes), "sa", "sgr", TC_DESC("define video attributes #1-#9 (PG9)"), &tc_sa }, + { TC_FNAME(set_tab), "st", "hts", TC_DESC("set a tab in every row, current columns") }, + { TC_FNAME(set_window), "wi", "wind", TC_DESC("current window is lines #1-#2 cols #3-#4") }, + { TC_FNAME(tab), "ta", "ht", TC_DESC("tab to next 8-space hardware tab stop") }, + { TC_FNAME(to_status_line), "ts", "tsl", TC_DESC("move to status line") }, + { TC_FNAME(underline_char), "uc", "uc", TC_DESC("underline char and move past it") }, + { TC_FNAME(up_half_line), "hu", "hu", TC_DESC("half a line up") }, + { TC_FNAME(init_prog), "iP", "iprog", TC_DESC("path name of program for initialization") }, + { TC_FNAME(prtr_non), "pO", "mc5p", TC_DESC("turn on printer for #1 bytes") }, + { TC_FNAME(char_padding), "rP", "rmp", TC_DESC("like ip but when in insert mode") }, + { TC_FNAME(acs_chars), "ac", "acsc", TC_DESC("acs characters"), TC_STRING(&tc_graphic_pairs) }, + { TC_FNAME(plab_norm), "pn", "pln", TC_DESC("program label #1 to show string #2") }, + { TC_FNAME(enter_xon_mode), "SX", "smxon", TC_DESC("turn on xon/xoff handshaking") }, + { TC_FNAME(exit_xon_mode), "RX", "rmxon", TC_DESC("turn off xon/xoff handshaking") }, + { TC_FNAME(enter_am_mode), "SA", "smam", TC_DESC("turn on automatic margins"), &tc_am_on }, + { TC_FNAME(exit_am_mode), "RA", "rmam", TC_DESC("turn off automatic margins") }, + { TC_FNAME(xon_character), "XN", "xonc", TC_DESC("XON character") }, + { TC_FNAME(xoff_character), "XF", "xoffc", TC_DESC("XOFF character") }, + { TC_FNAME(ena_acs), "eA", "enacs", TC_DESC("enable alternate char set"), &tc_acs_enable }, + { TC_FNAME(label_on), "LO", "smln", TC_DESC("turn on soft labels") }, + { TC_FNAME(label_off), "LF", "rmln", TC_DESC("turn off soft labels") }, + { TC_FNAME(req_for_input), "RF", "rfi", TC_DESC("send next input char (for ptys)") }, + { TC_FNAME(clr_bol), "cb", "el1", TC_DESC("clear to beginning of line"), &tc_cb }, + { TC_FNAME(clear_margins), "MC", "mgc", TC_DESC("clear right and left soft margins") }, + { TC_FNAME(set_left_margin), "ML", "smgl", TC_DESC("set left soft margin") }, + { TC_FNAME(set_right_margin), "MR", "smgr", TC_DESC("set right soft margin") }, + { TC_FNAME(label_format), "Lf", "fln", TC_DESC("label format") }, + { TC_FNAME(set_clock), "SC", "sclk", TC_DESC("set clock, #1 hrs #2 mins #3 secs") }, + { TC_FNAME(display_clock), "DK", "dclk", TC_DESC("display clock at (#1,#2)") }, + { TC_FNAME(remove_clock), "RC", "rmclk", TC_DESC("remove clock") }, + { TC_FNAME(create_window), "CW", "cwin", TC_DESC("define a window #1 from #2, #3 to #4, #5") }, + { TC_FNAME(goto_window), "WG", "wingo", TC_DESC("go to window #1") }, + { TC_FNAME(hangup ), "HU", "hup", TC_DESC("hang-up phone") }, + { TC_FNAME(dial_phone), "DI", "dial", TC_DESC("dial number #1") }, + { TC_FNAME(quick_dial), "QD", "qdial", TC_DESC("dial number #1 without checking") }, + { TC_FNAME(tone), "TO", "tone", TC_DESC("select touch tone dialing") }, + { TC_FNAME(pulse), "PU", "pulse", TC_DESC("select pulse dialling") }, + { TC_FNAME(flash_hook), "fh", "hook", TC_DESC("flash switch hook") }, + { TC_FNAME(fixed_pause), "PA", "pause", TC_DESC("pause for 2-3 seconds") }, + { TC_FNAME(wait_tone), "WA", "wait", TC_DESC("wait for dial-tone") }, + { TC_FNAME(user0), "u0", "u0", TC_DESC("user string #0") }, + { TC_FNAME(user1), "u1", "u1", TC_DESC("user string #1") }, + { TC_FNAME(user2), "u2", "u2", TC_DESC("user string #2") }, + { TC_FNAME(user3), "u3", "u3", TC_DESC("user string #3") }, + { TC_FNAME(user4), "u4", "u4", TC_DESC("user string #4") }, + { TC_FNAME(user5), "u5", "u5", TC_DESC("user string #5") }, + { TC_FNAME(user6), "u6", "u6", TC_DESC("user string #6") }, + { TC_FNAME(user7), "u7", "u7", TC_DESC("user string #7") }, + { TC_FNAME(user8), "u8", "u8", TC_DESC("user string #8") }, + { TC_FNAME(user9), "u9", "u9", TC_DESC("user string #9") }, + { TC_FNAME(orig_pair), "op", "op", TC_DESC("set default pair to its original value"), &tc_op }, + { TC_FNAME(orig_colors), "oc", "oc", TC_DESC("set all color pairs to the original ones"), &tc_oc }, + { TC_FNAME(initialize_color), "Ic", "initc", TC_DESC("initialize color #1 to (#2,#3,#4)") }, + { TC_FNAME(initialize_pair), "Ip", "initp", TC_DESC("initialize color pair #1 to fg=(#2,#3,#4), bg=(#5,#6,#7)") }, + { TC_FNAME(set_color_pair), "sp", "scp", TC_DESC("set current color pair to #1") }, + { TC_FNAME(set_foreground), "Sf", "setf", TC_DESC("set foreground (color)"), &tc_Color_Fg }, + { TC_FNAME(set_background), "Sb", "setb", TC_DESC("set background (color)"), &tc_Color_Bg }, + { TC_FNAME(change_char_pitch), "ZA", "cpi", TC_DESC("change number of characters per inch") }, + { TC_FNAME(change_line_pitch), "ZB", "lpi", TC_DESC("change number of lines per inch") }, + { TC_FNAME(change_res_horz), "ZC", "chr", TC_DESC("change horizontal resolution") }, + { TC_FNAME(change_res_vert), "ZD", "cvr", TC_DESC("change vertical resolution") }, + { TC_FNAME(define_char), "ZE", "defc", TC_DESC("define a character") }, + { TC_FNAME(enter_doublewide_mode), "ZF", "swidm", TC_DESC("enter double-wide mode") }, + { TC_FNAME(enter_draft_quality), "ZG", "sdrfq", TC_DESC("enter draft-quality mode") }, + { TC_FNAME(enter_italics_mode), "ZH", "sitm", TC_DESC("enter italic mode"), &tc_ZH }, + { TC_FNAME(enter_leftward_mode), "ZI", "slm", TC_DESC("start leftward carriage motion") }, + { TC_FNAME(enter_micro_mode), "ZJ", "smicm", TC_DESC("start micro-motion mode") }, + { TC_FNAME(enter_near_letter_quality), "ZK", "snlq", TC_DESC("enter NLQ mode") }, + { TC_FNAME(enter_normal_quality), "ZL", "snrmq", TC_DESC("enter normal-quality mode") }, + { TC_FNAME(enter_shadow_mode), "ZM", "sshm", TC_DESC("enter shadow-print mode") }, + { TC_FNAME(enter_subscript_mode), "ZN", "ssubm", TC_DESC("enter subscript mode") }, + { TC_FNAME(enter_superscript_mode), "ZO", "ssupm", TC_DESC("enter superscript mode") }, + { TC_FNAME(enter_upward_mode), "ZP", "sum", TC_DESC("start upward carriage motion") }, + { TC_FNAME(exit_doublewide_mode), "ZQ", "rwidm", TC_DESC("end double-wide mode") }, + { TC_FNAME(exit_italics_mode), "ZR", "ritm", TC_DESC("end italic mode"), &tc_ZR }, + { TC_FNAME(exit_leftward_mode), "ZS", "rlm", TC_DESC("end left-motion mode") }, + { TC_FNAME(exit_micro_mode), "ZT", "rmicm", TC_DESC("end micro-motion mode") }, + { TC_FNAME(exit_shadow_mode), "ZU", "rshm", TC_DESC("end shadow-print mode") }, + { TC_FNAME(exit_subscript_mode), "ZV", "rsubm", TC_DESC("exit_subscript_mode") }, + { TC_FNAME(exit_superscript_mode), "ZW", "rsupm", TC_DESC("end superscript mode") }, + { TC_FNAME(exit_upward_mode), "ZX", "rum", TC_DESC("end reverse character motion"), &tc_ZX }, + { TC_FNAME(micro_column_address), "ZY", "mhpa", TC_DESC("like column_address in micro mode") }, + { TC_FNAME(micro_down), "ZZ", "mcud1", TC_DESC("like cursor_down in micro mode") }, + { TC_FNAME(micro_left), "Za", "mcub1", TC_DESC("like cursor_left in micro mode") }, + { TC_FNAME(micro_right), "Zb", "mcuf1", TC_DESC("like cursor_right in micro mode") }, + { TC_FNAME(micro_row_address), "Zc", "mvpa", TC_DESC("like row_address in micro mode") }, + { TC_FNAME(micro_up), "Zd", "mcuu1", TC_DESC("like cursor_up in micro mode") }, + { TC_FNAME(order_of_pins), "Ze", "porder", TC_DESC("match software bits to print-head pins") }, + { TC_FNAME(parm_down_micro), "Zf", "mcud", TC_DESC("like parm down cursor in micro mode") }, + { TC_FNAME(parm_left_micro), "Zg", "mcub", TC_DESC("Like parm left cursor in micro mode") }, + { TC_FNAME(parm_right_micro), "Zh", "mcuf", TC_DESC("Like parm right cursor in micro mode") }, + { TC_FNAME(parm_up_micro), "Zi", "mcuu", TC_DESC("Like parm_up_cursor in micro mode") }, + { TC_FNAME(select_char_set), "Zj", "scs", TC_DESC("select character set") }, + { TC_FNAME(set_bottom_margin), "Zk", "smgb", TC_DESC("set bottom margin at current line") }, + { TC_FNAME(set_bottom_margin_parm), "Zl", "smgbp", TC_DESC("set bottom margin at line #1 or #2 lines from bottom") }, + { TC_FNAME(set_left_margin_parm), "Zm", "smglp", TC_DESC("set left (right) margin at column #1 (#2)") }, + { TC_FNAME(set_right_margin_parm), "Zn", "smgrp", TC_DESC("set right margin at column #1") }, + { TC_FNAME(set_top_margin), "Zo", "smgt", TC_DESC("set top margin at current line") }, + { TC_FNAME(set_top_margin_parm), "Zp", "smgtp", TC_DESC("start printing bit image braphics") }, + { TC_FNAME(start_bit_image), "Zq", "sbim", TC_DESC("start bit image") }, + { TC_FNAME(start_char_set_def), "Zr", "scsd", TC_DESC("start character set definition") }, + { TC_FNAME(stop_bit_image), "Zs", "rbim", TC_DESC("stop printing bit image graphics") }, + { TC_FNAME(stop_char_set_def), "Zt", "rcsd", TC_DESC("end definition of character aet") }, + { TC_FNAME(subscript_characters), "Zu", "subcs", TC_DESC("list of subscriptable characters") }, + { TC_FNAME(superscript_characters), "Zv", "supcs", TC_DESC("list of superscriptable characters") }, + { TC_FNAME(these_cause_cr), "Zw", "docr", TC_DESC("printing any of these chars causes CR") }, + { TC_FNAME(zero_motion), "Zx", "zerom", TC_DESC("no motion for subsequent character") }, + + /* + * The following string capabilities are present in the SVr4.0 term + * structure, but were originally not documented in the man page. + */ + { TC_FNAME(char_set_names), "Zy", "csnm", TC_DESC("list of character set names") }, + { TC_FNAME(mouse_info), "Mi", "minfo", TC_DESC("mouse status information") }, + { TC_FNAME(req_mouse_pos), "RQ", "reqmp", TC_DESC("request mouse position") }, + { TC_FNAME(get_mouse), "Gm", "getm", TC_DESC("curses should get button events") }, + { TC_FNAME(set_a_foreground), "AF", "setaf", TC_DESC("set ANSI color foreground"), &tc_ANSI_Color_Fg }, + { TC_FNAME(set_a_background), "AB", "setab", TC_DESC("set ANSI color background"), &tc_ANSI_Color_Bg }, + { TC_FNAME(pkey_plab), "xl", "pfxl", TC_DESC("program function key #1 to type string #2 and show string #3") }, + { TC_FNAME(device_type), "dv", "devt", TC_DESC("indicate language/codeset support") }, + { TC_FNAME(code_set_init), "ci", "csin", TC_DESC("init sequence for multiple codesets") }, + { TC_FNAME(set0_des_seq), "s0", "s0ds", TC_DESC("shift to code set 0 (EUC set 0, ASCII)") }, + { TC_FNAME(set1_des_seq), "s1", "s1ds", TC_DESC("shift to code set 1") }, + { TC_FNAME(set2_des_seq), "s2", "s2ds", TC_DESC("shift to code set 2") }, + { TC_FNAME(set3_des_seq), "s3", "s3ds", TC_DESC("shift to code set 3") }, + { TC_FNAME(set_lr_margin), "ML", "smglr", TC_DESC("set both left and right margins to #1, #2") }, + { TC_FNAME(set_tb_margin), "MT", "smgtb", TC_DESC("sets both top and bottom margins to #1, #2") }, + { TC_FNAME(bit_image_repeat), "Xy", "birep", TC_DESC("repeat bit image cell #1 #2 times") }, + { TC_FNAME(bit_image_newline), "Zz", "binel", TC_DESC("move to next row of the bit image") }, + { TC_FNAME(bit_image_carriage_return), "Yv", "bicr", TC_DESC("move to beginning of same row") }, + { TC_FNAME(color_names), "Yw", "colornm", TC_DESC("give name for color #1") }, + { TC_FNAME(define_bit_image_region), "Yx", "defbi", TC_DESC("define rectangualar bit image region") }, + { TC_FNAME(end_bit_image_region), "Yy", "endbi", TC_DESC("end a bit-image region") }, + { TC_FNAME(set_color_band), "Yz", "setcolor", TC_DESC("change to ribbon color #1") }, + { TC_FNAME(set_page_length), "YZ", "slines", TC_DESC("set page length to #1 lines") }, + { TC_FNAME(display_pc_char), "S1", "dispc", TC_DESC("display PC character") }, + { TC_FNAME(enter_pc_charset_mode), "S2", "smpch", TC_DESC("enter PC character display mode") }, + { TC_FNAME(exit_pc_charset_mode), "S3", "rmpch", TC_DESC("exit PC character display mode") }, + { TC_FNAME(enter_scancode_mode), "S4", "smsc", TC_DESC("enter PC scancode mode") }, + { TC_FNAME(exit_scancode_mode), "S5", "rmsc", TC_DESC("exit PC scancode mode") }, + { TC_FNAME(pc_term_options), "S6", "pctrm", TC_DESC("PC terminal options") }, + { TC_FNAME(scancode_escape), "S7", "scesc", TC_DESC("escape for scancode emulation") }, + { TC_FNAME(alt_scancode_esc), "S8", "scesa", TC_DESC("alternate escape for scancode emulation") }, - /* - * Characters, Note: have only seen 'bx' under AIX, which must be ordered - * after "ac" for correct selection. - */ - { "G1", NULL, TC_DESC("single upper right") }, - { "G2", NULL, TC_DESC("single upper left") }, - { "G3", NULL, TC_DESC("single lower left") }, - { "G4", NULL, TC_DESC("single lower right") }, - { "GC", NULL, TC_DESC("single intersection") }, - { "GD", NULL, TC_DESC("tee pointing down") }, - { "GH", NULL, TC_DESC("single horizontal line") }, - { "GL", NULL, TC_DESC("tee pointing left") }, - { "GR", NULL, TC_DESC("tee pointing right") }, - { "GU", NULL, TC_DESC("tee pointing up") }, - { "GV", NULL, TC_DESC("single vertical line") }, - { "bx", NULL, TC_DESC("box chars primary set"), &tc_box_characters }, - - /* - * Others - */ - { "cS", NULL, TC_DESC("change region to line #1 to line #2, alt form"), &tc_cS }, - { "bc", NULL, TC_DESC("move left, if not ^H (old-style)"), &tc_bc }, - { "nl", NULL, TC_DESC("use to move down") }, - /* { "ko", NULL, TC_DESC("list of self-mapped keycaps") }, */ - /* { "ma", NULL, TC_DESC("map arrow keys rogue(1) motion keys") }, */ - { "ml", NULL, TC_DESC("memory lock above") }, - { "mu", NULL, TC_DESC("memory unlock") } - }; - -#if (XXX_KO) -/* - ko capability, consists of a comma-separated capability list. - For each capability, it should be assumed there is a keycap - that sends the string which is the value of that capability. - - String listing the other function keys the terminal has. - - This is a very obsolete way of describing the same - information found in the `kH' ... `kT' keys. + /* + * The XSI Curses standard added these. + * + * They are some post-4.1 versions of System V curses, e.g., Solaris 2.5 and IRIX 6.x. + * The ncurses termcap names for them are invented; according to the XSI Curses standard, they have no termcap names. + * If your compiled terminfo entries use these, they may not be binary-compatible with System V terminfo entries after SVr4.1; beware! + */ + { TC_FNAME(enter_horizontal_hl_mode), "Xh", "ehhlm", TC_DESC("enter horizontal highlight mode") }, + { TC_FNAME(enter_left_hl_mode), "Xl", "elhlm", TC_DESC("enter left highlight mode") }, + { TC_FNAME(enter_low_hl_mode), "Xo", "elohlm", TC_DESC("enter low highlight mode") }, + { TC_FNAME(enter_right_hl_mode), "Xr", "erhlm", TC_DESC("enter right highlight mode") }, + { TC_FNAME(enter_top_hl_mode), "Xt", "ethlm", TC_DESC("enter top highlight mode") }, + { TC_FNAME(enter_vertical_hl_mode), "Xv", "evhlm", TC_DESC("enter vertical highlight mode") }, + { TC_FNAME(set_a_attributes), "sA", "sgr1", TC_DESC("Define second set of video attributes #1-#6") }, + { TC_FNAME(set_pglen_inch), "YI", "slength", TC_DESC("Set page length to #1 hundredth of an inch") }, + { TC_FNAME(termcap_init2), "i2", "OTi2", TC_DESC("secondary initialization string") }, + { TC_FNAME(termcap_reset), "rs", "OTrs", TC_DESC("terminal reset string"), &tc_rs }, + { TC_FNAME(linefeed_if_not_lf), "nl", "OTnl", TC_DESC("use to move down") }, + { TC_FNAME(backspace_if_not_bs), "bc", "OTbc", TC_DESC("move left, if not ^H (old-style)"), &tc_bc }, + { TC_FNAME(other_non_function_keys), "ko", "OTko", TC_DESC("list of self-mapped keycaps") }, + { TC_FNAME(arrow_key_map), "ma", "OTma", TC_DESC("map arrow keys rogue(1) motion keys") }, - The string contains a list of two-character termcap - capability names, separated by commas. The meaning is that - for each capability name listed, the terminal has a key which - sends the string which is the value of that capability. + /* + * Speical characters + * + * Note: 'bx' only under AIX, which must be ordered after "ac" for correct selection. + */ + { TC_FNAME(acs_ulcorner), "G2", "OTG2", TC_DESC("single upper left") }, + { TC_FNAME(acs_llcorner), "G3", "OTG3", TC_DESC("single lower left") }, + { TC_FNAME(acs_urcorner), "G1", "OTG1", TC_DESC("single upper right") }, + { TC_FNAME(acs_lrcorner), "G4", "OTG4", TC_DESC("single lower right") }, + { TC_FNAME(acs_ltee), "GR", "OTGR", TC_DESC("tee pointing left") }, + { TC_FNAME(acs_rtee), "GL", "OTGL", TC_DESC("tee pointing left") }, + { TC_FNAME(acs_btee), "GU", "OTGU", TC_DESC("tee pointing up") }, + { TC_FNAME(acs_ttee), "GD", "OTGD", TC_DESC("tee pointing down") }, + { TC_FNAME(acs_hline), "GH", "OTGH", TC_DESC("single horizontal line") }, + { TC_FNAME(acs_vline), "GV", "OTGV", TC_DESC("single vertical line") }, + { TC_FNAME(acs_plus), "GC", "OTGC", TC_DESC("single intersection") }, + { TC_FNAME(memory_lock), "ml", "meml", TC_DESC("memory lock above") }, + { TC_FNAME(memory_unlock), "mu", "memu", TC_DESC("memory unlock") }, + { TC_FNAME(box_chars_1), "bx", "box1", TC_DESC("box chars primary set"), &tc_box_characters }, // aix-only - For example, the value `:ko=cl, ll, sf, sr:' says that the - terminal has four function keys which mean "clear screen", - "home down", "scroll forward" and "scroll reverse - */ -static const struct { - const char *from; - const char *to; -} ko_xlate[] = { - { "al", "kil1" }, /* insert line key */ - { "bt", "kcbt" }, /* back tab */ - { "cd", "ked" }, /* clear-to-eos key */ - { "ce", "kel" }, /* clear-to-eol key */ - { "cl", "kclr" }, /* clear key */ - { "ct", "tbc" }, /* clear all tabs */ - { "dc", "kdch1" }, /* delete char */ - { "dl", "kdl1" }, /* delete line */ - { "do", "kcud1" }, /* down key */ - { "ei", "krmir" }, /* exit insert key */ - { "ho", "khome" }, /* home key */ - { "ic", "kich1" }, /* insert char key */ - { "im", "kIC" }, /* insert-mode key */ - { "le", "kcub1" }, /* le key */ - { "nd", "kcuf1" }, /* nd key */ - { "nl", "kent" }, /* new line key */ - { "st", "khts" }, /* set-tab key */ - { "ta", "kcan" }, /* cancel */ - { "up", "kcuu1" }, /* up-arrow key */ - }; -#endif /*XXX_KO*/ + /* + * User-Defined Capabilities + * + * https://invisible-island.net/ncurses/man/user_caps.5.html + * See: ncurses/include/Caps-ncurses + */ + { TC_UNAME(nc), NULL, "C0", TC_DESC("number of indexed colors overlaying RGB space") }, + { TC_UNAME(nc), NULL, "E3", TC_DESC("clears the terminal's scrollback buffer") }, + { TC_UNAME(nc), NULL, "RGB", TC_DESC("use direct colors with given bit-layout") }, + { TC_UNAME(nc), NULL, "TS", TC_DESC("parameterless tsl") }, + { TC_UNAME(nc), NULL, "XM", TC_DESC("initialize alternate xterm mouse mode") }, + + /* mintty specials */ + { TC_UNAME(mintty), NULL, "Rmol", TC_DESC("remove overline-mode") }, + { TC_UNAME(mintty), NULL, "Smol", TC_DESC("set overline-mode") }, + { TC_UNAME(mintty), NULL, "blink2", TC_DESC("turn on rapid blinking") }, + { TC_UNAME(mintty), NULL, "norm", TC_DESC("turn off bold and half-bright mode") }, + { TC_UNAME(mintty), NULL, "opaq", TC_DESC("turn off blank mode") }, + { TC_UNAME(mintty), NULL, "setal", TC_DESC("set underline-color") }, + { TC_UNAME(mintty), NULL, "smul2", TC_DESC("begin double underline mode") }, + + /* screen specials */ + { TC_UNAME(screen), NULL, "C0", TC_DESC("use the string as a conversion table for font '0', like acsc") }, + { TC_UNAME(screen), NULL, "CE", TC_DESC("switch cursor-keys back to normal mode") }, + { TC_UNAME(screen), NULL, "CS", TC_DESC("switch cursor-keys to application mode") }, + { TC_UNAME(screen), NULL, "E0", TC_DESC("switch charset 'G0' back to standard charset") }, + { TC_UNAME(screen), NULL, "KJ", TC_DESC("set the encoding of the terminal") }, + { TC_UNAME(screen), NULL, "S0", TC_DESC("switch charset 'G0' to the specified charset") }, + { TC_UNAME(screen), NULL, "WS", TC_DESC("resize display") }, + { TC_UNAME(screen), NULL, "XC", TC_DESC("character translation") }, + { TC_UNAME(screen), NULL, "Z0", TC_DESC("change width to 132 columns") }, + { TC_UNAME(screen), NULL, "Z1", TC_DESC("change width to 80 columns") }, + + /* tmux specials */ + { TC_UNAME(tmux), NULL, "Cr", TC_DESC("restore the default cursor color") }, + { TC_UNAME(tmux), NULL, "Cs", TC_DESC("set the cursor color") }, + { TC_UNAME(tmux), NULL, "Csr", TC_DESC("change the cursor style, overriding Ss") }, + { TC_UNAME(tmux), NULL, "Ms", TC_DESC("store buffer in the host clipboard") }, + { TC_UNAME(tmux), NULL, "Se", TC_DESC("reset the cursor style") }, + { TC_UNAME(tmux), NULL, "Smulx", TC_DESC("modify the appearance of underlines in VTE") }, + // + // 0 for no underscore, + // 1 for normal underscore, + // 2 for double underscore, + // 3 for curly underscore, + // 4 for dotted underscore and; + // 5 for dashed underscore. + // + { TC_UNAME(tmux), NULL, "Ss", TC_DESC("change the cursor style") }, + // + // 0, 1 or none - blinking block cursor + // 2 - block cursor + // 3 - blinking underline cursor + // 4 - underline cursor + // 5 - blinking vertical bar cursor + // 6 - vertical bar cursor + // + { TC_UNAME(tmux), NULL, "rmxx", TC_DESC("reset ECMA-48 strikeout/crossed-out attributes") }, + { TC_UNAME(tmux), NULL, "smxx", TC_DESC("set ECMA-48 strikeout/crossed-out attributes") }, + + /* VIM specials */ + { TC_UNAME(vim), NULL, "BD", TC_DESC("disables bracketed paste") }, + { TC_UNAME(vim), NULL, "BE", TC_DESC("enables bracketed paste") }, + { TC_UNAME(vim), NULL, "PE", TC_DESC("is sent after pasted text") }, + { TC_UNAME(vim), NULL, "PS", TC_DESC("is sent before pasted text") }, + { TC_UNAME(vim), NULL, "RV", TC_DESC("report terminal secondary device attributes"), &tc_RV }, + { TC_UNAME(vim), NULL, "XR", TC_DESC("report terminal version as a free-format string.") }, + { TC_UNAME(vim), NULL, "fd", TC_DESC("disable xterm focus-events") }, + { TC_UNAME(vim), NULL, "fe", TC_DESC("enable xterm focus-events") }, + { TC_UNAME(vim), NULL, "rv", TC_DESC("response to RV, regular expression") }, + { TC_UNAME(vim), NULL, "xr", TC_DESC("response to XR, regular expression") }, + { TC_UNAME(vim), NULL, "SH", TC_DESC("cursor shape") } //XXX + // + // 0, 1 or none - blinking block cursor + // 2 - block cursor + // 3 - blinking underline cursor + // 4 - underline cursor + // 5 - blinking vertical bar cursor + // 6 - vertical bar cursor + // +}; static TermNumeric_t term_numbers[] = { /* numeric - termcap/terminfo elements */ /* - * standard + * Standard */ - { "MW", "wnum", TC_DESC("max number of defineable windows") }, - { "co", "cols", TC_DESC("number of columns"), &tn_co }, - { "it", "it", TC_DESC("tabs initially every # spaces") }, - { "Nl", "nlab", TC_DESC("number of labels") }, - { "lh", "lh", TC_DESC("rows in each label") }, - { "li", "lines", TC_DESC("number of lines on screen or page"), &tn_li }, - { "lm", "lm", TC_DESC("lines of memory if > line, 0 means varies") }, - { "lw", "lw", TC_DESC("columns in each label") }, - { "ma", "ma", TC_DESC("max combined attributes") }, - { "pb", "pb", TC_DESC("lowest baud rate needing padding") }, - { "sg", "xmc", TC_DESC("number of blank chars left by smso or rmso"), &tn_sg }, - { "vt", "vt", TC_DESC("virtual terminal number") }, - { "ws", "wsl", TC_DESC("number of columns within status line") }, + { TC_FNAME(columns), "co", "cols", TC_DESC("number of columns"), &tn_co }, + { TC_FNAME(init_tabs), "it", "it", TC_DESC("tabs initially every # spaces") }, + { TC_FNAME(lines), "li", "lines", TC_DESC("number of lines on screen or page"), &tn_li }, + { TC_FNAME(lines_of_memory), "lm", "lm", TC_DESC("lines of memory if > line, 0 means varies") }, + { TC_FNAME(magic_cookie_glitch), "sg", "xmc", TC_DESC("number of blank chars left by smso or rmso"), &tn_sg }, + { TC_FNAME(padding_baud_rate), "pb", "pb", TC_DESC("lowest baud rate needing padding") }, + { TC_FNAME(virtual_terminal), "vt", "vt", TC_DESC("virtual terminal number") }, + { TC_FNAME(width_status_line), "ws", "wsl", TC_DESC("number of columns within status line") }, + { TC_FNAME(num_labels), "Nl", "nlab", TC_DESC("number of labels") }, + { TC_FNAME(label_height), "lh", "lh", TC_DESC("rows in each label") }, + { TC_FNAME(label_width), "lw", "lw", TC_DESC("columns in each label") }, + { TC_FNAME(max_attributes), "ma", "ma", TC_DESC("max combined attributes") }, + { TC_FNAME(maximum_windows), "MW", "wnum", TC_DESC("max number of defineable windows") }, + + { TC_FNAME(max_colors), "Co", "colors", TC_DESC("max color"), &tf_Colors }, + { TC_FNAME(max_pairs), "pa", "pairs", TC_DESC("max of color-pairs"), &tf_Pairs }, + { TC_FNAME(no_color_video), "NC", "ncv", TC_DESC("video attributes that cannot be used with colors"), &tn_NC }, + + { TC_FNAME(buffer_capacity), "Ya", "bufsz", TC_DESC("numbers of bytes buffered before printing") }, + { TC_FNAME(dot_vert_spacing), "Yb", "spinv", TC_DESC("spacing of pins vertically in pins per inch") }, + { TC_FNAME(dot_horz_spacing), "Yc", "spinh", TC_DESC("spacing of dots horizontally in dots per inch") }, + { TC_FNAME(max_micro_address), "Yd", "maddr", TC_DESC("maximum value in micro_..._address") }, + { TC_FNAME(max_micro_jump), "Ye", "mjump", TC_DESC("maximum value in parm_..._micro") }, + { TC_FNAME(micro_col_size), "Yf", "mcs", TC_DESC("character step size when in micro mode") }, + { TC_FNAME(micro_line_size), "Yg", "mls", TC_DESC("line step size when in micro mode") }, + { TC_FNAME(number_of_pins), "Yh", "npins", TC_DESC("numbers of pins in print-head") }, + { TC_FNAME(output_res_char), "Yi", "orc", TC_DESC("horizontal resolution in units per line") }, + { TC_FNAME(output_res_line), "Yj", "orl", TC_DESC("vertical resolution in units per line") }, + { TC_FNAME(output_res_horz_inch), "Yk", "orhi", TC_DESC("horizontal resolution in units per inch") }, + { TC_FNAME(output_res_vert_inch), "Yl", "orvi", TC_DESC("vertical resolution in units per inch") }, + { TC_FNAME(print_rate), "Ym", "cps", TC_DESC("print rate in characters per second") }, + { TC_FNAME(wide_char_size), "Yn", "widcs", TC_DESC("character step size when in double wide mode") }, + { TC_FNAME(buttons), "BT", "btns", TC_DESC("number of buttons on mouse") }, + { TC_FNAME(bit_image_entwining), "Yo", "bitwin", TC_DESC("number of passes for each bit-image row") }, + { TC_FNAME(bit_image_type), "Yp", "bitype", TC_DESC("type of bit-image device") }, + { TC_FNAME(magic_cookie_glitch_ul), "ug", "OTug", TC_DESC("number of blanks left by ul") }, + + { TC_FNAME(carriage_return_delay), "dC", "OTdC", TC_DESC("msec of padding for carriage-return character") }, + { TC_FNAME(new_line_delay), "dN", "OTdN", TC_DESC("msec of padding for newline (linefeed) character") }, + { TC_FNAME(backspace_delay), "dB", "OTdB", TC_DESC("msec of padding for backspace character") }, + { TC_FNAME(horizontal_tab_delay), "dT", "OTdT", TC_DESC("msec of padding for tab character") }, + { TC_FNAME(number_of_function_keys), "kn", "OTkn", TC_DESC("msec of padding for formfeed character") }, - /* - * SRV 4.0 color - */ - { "Co", "colors", TC_DESC("max color"), &tf_Colors }, - { "pa", "pairs", TC_DESC("max of color-pairs"), &tf_Pairs }, - { "NC", "ncv", TC_DESC("video attributes that cannot be used with colors"), &tn_NC }, - - /* - * The following numeric capabilities are present in the SVr4.0 term structure, - * but are not yet documented in the man page. They came in with SVr4's printer support. - */ - { "BT", NULL, TC_DESC("number of buttons on the mouse") }, + /* + * User-Defined Capabilities + * + * https://invisible-island.net/ncurses/man/user_caps.5.html + * See: ncurses/include/Caps-ncurses + */ + { TC_UNAME(nc), NULL, "RGB", TC_DESC("use direct colors with given number of bits"), &tn_RGB }, + { TC_UNAME(nc), NULL, "U8", TC_DESC("terminal VT100 SI/SO processing UTF-8 encoding") }, - /* - * Padding times - */ - { "dC", NULL, TC_DESC("msec of padding for carriage-return character") }, - { "dN", NULL, TC_DESC("msec of padding for newline (linefeed) character") }, - { "dB", NULL, TC_DESC("msec of padding for backspace character") }, - { "dF", NULL, TC_DESC("msec of padding for formfeed character") }, - { "dT", NULL, TC_DESC("msec of padding for tab character") } + /* screen */ + { TC_UNAME(screen), NULL, "OL", TC_DESC("set the screen program's output buffer limit.") }, }; static TermKey_t term_keys[] = { /* keys - termcap/terminfo elements */ - { "!1", "kSAV", TC_DESC("shifted save key") }, - { "!2", "kSPD", TC_DESC("shifted suspend key") }, - { "!3", "kUND", TC_DESC("shifted undo key"), TC_TOKEN(KEY_REDO) }, - { "#1", "kHLP", TC_DESC("shifted help key") }, /* KEY_HELP */ - { "#2", "kHOM", TC_DESC("shifted home key"), TC_TOKEN(MOD_SHIFT|KEY_HOME) }, - { "#3", "kIC", TC_DESC("shifted insert-character key") }, - { "#4", "kLFT", TC_DESC("shifted left-arrow key") }, - { "%0", "krdo", TC_DESC("redo key"), TC_TOKEN(KEY_REDO) }, - { "%1", "khlp", TC_DESC("help key"), TC_TOKEN(KEY_HELP) }, - { "%2", "kmrk", TC_DESC("mark key") }, /* KEY_MARK */ - { "%3", "kmsg", TC_DESC("message key") }, - { "%4", "kmov", TC_DESC("move key") }, - { "%5", "knxt", TC_DESC("next key"), TC_TOKEN(KEY_NEXT) }, - { "%6", "kopn", TC_DESC("open key"), TC_TOKEN(KEY_OPEN) }, - { "%7", "kopt", TC_DESC("options key"), TC_TOKEN(KEY_MENU) }, - { "%8", "kprv", TC_DESC("previous key"), TC_TOKEN(KEY_PREV) }, - { "%9", "kprt", TC_DESC("print key") }, /* KEY_PRINT */ - { "%a", "kMSG", TC_DESC("shifted message key") }, - { "%b", "kMOV", TC_DESC("shifted move key") }, - { "%c", "kNXT", TC_DESC("shifted next key") }, - { "%d", "kOPT", TC_DESC("shifted options key") }, - { "%e", "kPRV", TC_DESC("shifted previous key") }, - { "%f", "kPRT", TC_DESC("shifted print key") }, - { "%g", "kRDO", TC_DESC("shifted redo key") }, - { "%h", "kRPL", TC_DESC("shifted replace key") }, - { "%i", "kRIT", TC_DESC("shifted right-arrow key") }, - { "%j", "kRES", TC_DESC("shifted resume key") }, - { "&0", "kCAN", TC_DESC("shifted cancel key") }, - { "&1", "kref", TC_DESC("reference key") }, - { "&2", "krfr", TC_DESC("refresh key") }, /* KEY_REFRESH */ - { "&3", "krpl", TC_DESC("replace key"), TC_TOKEN(KEY_REPLACE) }, - { "&4", "krst", TC_DESC("restart key") }, - { "&5", "kres", TC_DESC("resume key") }, - { "&6", "ksav", TC_DESC("save key"), TC_TOKEN(KEY_SAVE) }, - { "&7", "kspd", TC_DESC("suspend key") }, - { "&8", "kund", TC_DESC("undo key"), TC_TOKEN(KEY_UNDO_CMD) }, - { "&9", "kBEG", TC_DESC("shifted begin key") }, - { "*0", "kFND", TC_DESC("shifted find key") }, - { "*1", "kCMD", TC_DESC("shifted command key") }, - { "*2", "kCPY", TC_DESC("shifted copy key") }, - { "*3", "kCRT", TC_DESC("shifted create key") }, - { "*4", "kDC", TC_DESC("shifted delete-char") }, - { "*5", "kDL", TC_DESC("shifted delete-line key") }, - { "*6", "kslt", TC_DESC("select key") }, - { "*7", "kEND", TC_DESC("shifted end key"), TC_TOKEN(MOD_SHIFT|KEY_END) }, - { "*8", "kEOL", TC_DESC("shifted clear-to-end-of-line key") }, - { "*9", "kEXT", TC_DESC("shifted exit key") }, - { "@0", "kfnd", TC_DESC("find key"), TC_TOKEN(KEY_SEARCH) }, - { "@1", "kbeg", TC_DESC("begin key") }, - { "@2", "kcan", TC_DESC("cancel key"), TC_TOKEN(KEY_CANCEL) }, - { "@3", "kclo", TC_DESC("close key") }, - { "@4", "kcmd", TC_DESC("command key"), TC_TOKEN(KEY_COMMAND) }, - { "@5", "kcpy", TC_DESC("copy key"), TC_TOKEN(KEY_COPY_CMD) }, - { "@6", "kcrt", TC_DESC("create key") }, - { "@7", "kend", TC_DESC("end key"), TC_TOKEN(KEY_END) }, - { "@8", "kent", TC_DESC("enter/send key") }, - { "@9", "kext", TC_DESC("exit key"), TC_TOKEN(KEY_EXIT) }, - { "F1", "kf11", TC_DESC("F11 function key"), TC_TOKEN(F(11)) }, - { "F2", "kf12", TC_DESC("F12 function key"), TC_TOKEN(F(12)) }, - { "F3", "kf13", TC_DESC("F13 function key") /*, TC_TOKEN(F(13))*/ }, - { "F4", "kf14", TC_DESC("F14 function key") /*, TC_TOKEN(F(14))*/ }, - { "F5", "kf15", TC_DESC("F15 function key") /*, TC_TOKEN(F(15))*/ }, - { "F6", "kf16", TC_DESC("F16 function key") /*, TC_TOKEN(F(16))*/ }, - { "F7", "kf17", TC_DESC("F17 function key") /*, TC_TOKEN(F(17))*/ }, - { "F8", "kf18", TC_DESC("F18 function key") /*, TC_TOKEN(F(18))*/ }, - { "F9", "kf19", TC_DESC("F19 function key") /*, TC_TOKEN(F(19))*/ }, - { "FA", "kf20", TC_DESC("F20 function key") /*, TC_TOKEN(F(20))*/ }, - { "FB", "kf21", TC_DESC("F21 function key") }, - { "FC", "kf22", TC_DESC("F22 function key") }, - { "FD", "kf23", TC_DESC("F23 function key") }, - { "FE", "kf24", TC_DESC("F24 function key") }, - { "FF", "kf25", TC_DESC("F25 function key") }, - { "FG", "kf26", TC_DESC("F26 function key") }, - { "FH", "kf27", TC_DESC("F27 function key") }, - { "FI", "kf28", TC_DESC("F28 function key") }, - { "FJ", "kf29", TC_DESC("F29 function key") }, - { "FK", "kf30", TC_DESC("F30 function key") }, - { "FL", "kf31", TC_DESC("F31 function key") }, - { "FM", "kf32", TC_DESC("F32 function key") }, - { "FN", "kf33", TC_DESC("F33 function key") }, - { "FO", "kf34", TC_DESC("F34 function key") }, - { "FP", "kf35", TC_DESC("F35 function key") }, - { "FQ", "kf36", TC_DESC("F36 function key") }, - { "FR", "kf37", TC_DESC("F37 function key") }, - { "FS", "kf38", TC_DESC("F38 function key") }, - { "FT", "kf39", TC_DESC("F39 function key") }, - { "FU", "kf40", TC_DESC("F40 function key") }, - { "FV", "kf41", TC_DESC("F41 function key") }, - { "FW", "kf42", TC_DESC("F42 function key") }, - { "FX", "kf43", TC_DESC("F43 function key") }, - { "FY", "kf44", TC_DESC("F44 function key") }, - { "FZ", "kf45", TC_DESC("F45 function key") }, - { "Fa", "kf46", TC_DESC("F46 function key") }, - { "Fb", "kf47", TC_DESC("F47 function key") }, - { "Fc", "kf48", TC_DESC("F48 function key") }, - { "Fd", "kf49", TC_DESC("F49 function key") }, - { "Fe", "kf50", TC_DESC("F50 function key") }, - { "Ff", "kf51", TC_DESC("F51 function key") }, - { "Fg", "kf52", TC_DESC("F52 function key") }, - { "Fh", "kf53", TC_DESC("F53 function key") }, - { "Fi", "kf54", TC_DESC("F54 function key") }, - { "Fj", "kf55", TC_DESC("F55 function key") }, - { "Fk", "kf56", TC_DESC("F56 function key") }, - { "Fl", "kf57", TC_DESC("F57 function key") }, - { "Fm", "kf58", TC_DESC("F58 function key") }, - { "Fn", "kf59", TC_DESC("F59 function key") }, - { "Fo", "kf60", TC_DESC("F60 function key") }, - { "Fp", "kf61", TC_DESC("F61 function key") }, - { "Fq", "kf62", TC_DESC("F62 function key") }, - { "Fr", "kf63", TC_DESC("F63 function key") }, - { "K1", "ka1", TC_DESC("upper left of keypad"), TC_TOKEN(KEYPAD_7) }, - { "K2", "kb2", TC_DESC("center of keypad"), TC_TOKEN(KEYPAD_9) }, - { "K3", "ka3", TC_DESC("upper right of key-pad"), TC_TOKEN(KEYPAD_5) }, - { "K4", "kc1", TC_DESC("lower left of keypad"), TC_TOKEN(KEYPAD_1) }, - { "K5", "kc3", TC_DESC("lower right of key-pad"), TC_TOKEN(KEYPAD_3) }, - { "k0", "kf0", TC_DESC("F0 function key"), TC_TOKEN(F(10)) }, - { "k1", "kf1", TC_DESC("F1 function key"), TC_TOKEN(F(1)) }, - { "k2", "kf2", TC_DESC("F2 function key"), TC_TOKEN(F(2)) }, - { "k3", "kf3", TC_DESC("F3 function key"), TC_TOKEN(F(3)) }, - { "k4", "kf4", TC_DESC("F4 function key"), TC_TOKEN(F(4)) }, - { "k5", "kf5", TC_DESC("F5 function key"), TC_TOKEN(F(5)) }, - { "k6", "kf6", TC_DESC("F6 function key"), TC_TOKEN(F(6)) }, - { "k7", "kf7", TC_DESC("F7 function key"), TC_TOKEN(F(7)) }, - { "k8", "kf8", TC_DESC("F8 function key"), TC_TOKEN(F(8)) }, - { "k9", "kf9", TC_DESC("F9 function key"), TC_TOKEN(F(9)) }, - { "k;", "kf10", TC_DESC("F10 function key"), TC_TOKEN(F(10)) }, - { "kA", "kil1", TC_DESC("insert-line key") }, - { "kB", "kcbt", TC_DESC("back-tab key"), TC_TOKEN(BACK_TAB) }, - { "kC", "kclr", TC_DESC("clear-screen or erase key") }, - { "kD", "kdch1", TC_DESC("delete-character key"), TC_TOKEN(KEY_DEL) }, - { "kE", "kel", TC_DESC("clear-to-end-of-line key") }, - { "kF", "kind", TC_DESC("scroll-forward key") }, - { "kH", "kll", TC_DESC("lower-left key (home down)"), TC_TOKEN(KEY_END) }, - { "kI", "kich1", TC_DESC("insert-character key"), TC_TOKEN(KEY_INS) }, - { "kL", "kdl1", TC_DESC("delete-line key") }, - { "kM", "krmir", TC_DESC("sent by rmir or smi rin insert mode") }, - { "kN", "knp", TC_DESC("next-page key"), TC_TOKEN(KEY_PAGEDOWN) }, - { "kP", "kpp", TC_DESC("previous-page key"), TC_TOKEN(KEY_PAGEUP) }, - { "kR", "kri", TC_DESC("scroll-backward key") }, - { "kS", "ked", TC_DESC("clear-to-end-of-screen key") }, - { "kT", "khts", TC_DESC("set-tab key") }, - { "ka", "ktbc", TC_DESC("clear-all-tabs key") }, - { "kb", "kbs", TC_DESC("backspace key"), TC_TOKEN(CTRL_H) }, - { "kd", "kcud1", TC_DESC("down-arrow key"), TC_TOKEN(KEY_DOWN) }, - { "kh", "khome", TC_DESC("home key"), TC_TOKEN(KEY_HOME) }, - { "kl", "kcub1", TC_DESC("left-arrow key"), TC_TOKEN(KEY_LEFT) }, - { "kr", "kcuf1", TC_DESC("right-arrow key"), TC_TOKEN(KEY_RIGHT) }, - { "kt", "kctab", TC_DESC("clear-tab key") }, - { "ku", "kcuu1", TC_DESC("up-arrow key"), TC_TOKEN(KEY_UP) }, + /* + * Standard + */ + { TC_FNAME(key_backspace), "kb", "kbs", TC_DESC("backspace key"), TC_TOKEN(CTRL_H) }, + { TC_FNAME(key_catab), "ka", "ktbc", TC_DESC("clear-all-tabs key") }, + { TC_FNAME(key_clear), "kC", "kclr", TC_DESC("clear-screen or erase key") }, + { TC_FNAME(key_ctab), "kt", "kctab", TC_DESC("clear-tab key") }, + { TC_FNAME(key_dc), "kD", "kdch1", TC_DESC("delete-character key"), TC_TOKEN(KEY_DEL) }, + { TC_FNAME(key_dl), "kL", "kdl1", TC_DESC("delete-line key") }, + { TC_FNAME(key_down), "kd", "kcud1", TC_DESC("down-arrow key"), TC_TOKEN(KEY_DOWN) }, + { TC_FNAME(key_eic), "kM", "krmir", TC_DESC("sent by rmir or smi rin insert mode") }, + { TC_FNAME(key_eol), "kE", "kel", TC_DESC("clear-to-end-of-line key") }, + { TC_FNAME(key_eos), "kS", "ked", TC_DESC("clear-to-end-of-screen key") }, + { TC_FNAME(key_f0), "k0", "kf0", TC_DESC("F0 function key"), TC_TOKEN(F(10)) }, + { TC_FNAME(key_f1), "k1", "kf1", TC_DESC("F1 function key"), TC_TOKEN(F(1)) }, + { TC_FNAME(key_f10), "k;", "kf10", TC_DESC("F10 function key"), TC_TOKEN(F(10)) }, + { TC_FNAME(key_f2), "k2", "kf2", TC_DESC("F2 function key"), TC_TOKEN(F(2)) }, + { TC_FNAME(key_f3), "k3", "kf3", TC_DESC("F3 function key"), TC_TOKEN(F(3)) }, + { TC_FNAME(key_f4), "k4", "kf4", TC_DESC("F4 function key"), TC_TOKEN(F(4)) }, + { TC_FNAME(key_f5), "k5", "kf5", TC_DESC("F5 function key"), TC_TOKEN(F(5)) }, + { TC_FNAME(key_f6), "k6", "kf6", TC_DESC("F6 function key"), TC_TOKEN(F(6)) }, + { TC_FNAME(key_f7), "k7", "kf7", TC_DESC("F7 function key"), TC_TOKEN(F(7)) }, + { TC_FNAME(key_f8), "k8", "kf8", TC_DESC("F8 function key"), TC_TOKEN(F(8)) }, + { TC_FNAME(key_f9), "k9", "kf9", TC_DESC("F9 function key"), TC_TOKEN(F(9)) }, + { TC_FNAME(key_home), "kh", "khome", TC_DESC("home key"), TC_TOKEN(KEY_HOME) }, + { TC_FNAME(key_ic), "kI", "kich1", TC_DESC("insert-character key"), TC_TOKEN(KEY_INS) }, + { TC_FNAME(key_il), "kA", "kil1", TC_DESC("insert-line key") }, + { TC_FNAME(key_left), "kl", "kcub1", TC_DESC("left-arrow key"), TC_TOKEN(KEY_LEFT) }, + { TC_FNAME(key_ll), "kH", "kll", TC_DESC("lower-left key (home down)"), TC_TOKEN(KEY_END) }, + { TC_FNAME(key_npage), "kN", "knp", TC_DESC("next-page key"), TC_TOKEN(KEY_PAGEDOWN) }, + { TC_FNAME(key_ppage), "kP", "kpp", TC_DESC("previous-page key"), TC_TOKEN(KEY_PAGEUP) }, + { TC_FNAME(key_right), "kr", "kcuf1", TC_DESC("right-arrow key"), TC_TOKEN(KEY_RIGHT) }, + { TC_FNAME(key_sf), "kF", "kind", TC_DESC("scroll-forward key") }, + { TC_FNAME(key_sr), "kR", "kri", TC_DESC("scroll-backward key") }, + { TC_FNAME(key_stab), "kT", "khts", TC_DESC("set-tab key") }, + { TC_FNAME(key_up), "ku", "kcuu1", TC_DESC("up-arrow key"), TC_TOKEN(KEY_UP) }, + { TC_FNAME(key_a1), "K1", "ka1", TC_DESC("upper left of keypad"), TC_TOKEN(KEYPAD_7) }, + { TC_FNAME(key_a3), "K3", "ka3", TC_DESC("center of keypad"), TC_TOKEN(KEYPAD_9) }, + { TC_FNAME(key_b2), "K2", "kb2", TC_DESC("upper right of key-pad"), TC_TOKEN(KEYPAD_5) }, + { TC_FNAME(key_c1), "K4", "kc1", TC_DESC("lower left of keypad"), TC_TOKEN(KEYPAD_1) }, + { TC_FNAME(key_c3), "K5", "kc3", TC_DESC("lower right of key-pad"), TC_TOKEN(KEYPAD_3) }, + { TC_FNAME(key_btab), "kB", "kcbt", TC_DESC("back-tab key"), TC_TOKEN(BACK_TAB) }, + { TC_FNAME(key_beg), "@1", "kbeg", TC_DESC("reference key") }, + { TC_FNAME(key_cancel), "@2", "kcan", TC_DESC("refresh key") }, + { TC_FNAME(key_close), "@3", "kclo", TC_DESC("replace key"), TC_TOKEN(KEY_REPLACE) }, + { TC_FNAME(key_command), "@4", "kcmd", TC_DESC("restart key") }, + { TC_FNAME(key_copy), "@5", "kcpy", TC_DESC("resume key") }, + { TC_FNAME(key_create), "@6", "kcrt", TC_DESC("save key"), TC_TOKEN(KEY_SAVE) }, + { TC_FNAME(key_end), "@7", "kend", TC_DESC("suspend key") }, + { TC_FNAME(key_enter), "@8", "kent", TC_DESC("undo key"), TC_TOKEN(KEY_UNDO_CMD) }, + { TC_FNAME(key_exit), "@9", "kext", TC_DESC("shifted begin key") }, + { TC_FNAME(key_find), "@0", "kfnd", TC_DESC("shifted cancel key") }, + { TC_FNAME(key_help), "%1", "khlp", TC_DESC("help key"), TC_TOKEN(KEY_HELP) }, + { TC_FNAME(key_mark), "%2", "kmrk", TC_DESC("mark key") }, /* KEY_MARK */ + { TC_FNAME(key_message), "%3", "kmsg", TC_DESC("message key") }, + { TC_FNAME(key_move), "%4", "kmov", TC_DESC("move key") }, + { TC_FNAME(key_next), "%5", "knxt", TC_DESC("next key"), TC_TOKEN(KEY_NEXT) }, + { TC_FNAME(key_open), "%6", "kopn", TC_DESC("open key"), TC_TOKEN(KEY_OPEN) }, + { TC_FNAME(key_options), "%7", "kopt", TC_DESC("options key"), TC_TOKEN(KEY_MENU) }, + { TC_FNAME(key_previous), "%8", "kprv", TC_DESC("previous key"), TC_TOKEN(KEY_PREV) }, + { TC_FNAME(key_print), "%9", "kprt", TC_DESC("print key") }, /* KEY_PRINT */ + { TC_FNAME(key_redo), "%0", "krdo", TC_DESC("redo key"), TC_TOKEN(KEY_REDO) }, + { TC_FNAME(key_reference), "&1", "kref", TC_DESC("reference key") }, + { TC_FNAME(key_refresh), "&2", "krfr", TC_DESC("refresh key") }, /* KEY_REFRESH */ + { TC_FNAME(key_replace), "&3", "krpl", TC_DESC("replace key"), TC_TOKEN(KEY_REPLACE) }, + { TC_FNAME(key_restart), "&4", "krst", TC_DESC("restart key") }, + { TC_FNAME(key_resume), "&5", "kres", TC_DESC("resume key") }, + { TC_FNAME(key_save), "&6", "ksav", TC_DESC("save key"), TC_TOKEN(KEY_SAVE) }, + { TC_FNAME(key_suspend), "&7", "kspd", TC_DESC("suspend key") }, + { TC_FNAME(key_undo), "&8", "kund", TC_DESC("undo key"), TC_TOKEN(KEY_UNDO_CMD) }, + { TC_FNAME(key_sbeg), "&9", "kBEG", TC_DESC("shifted begin key") }, + { TC_FNAME(key_scancel), "&0", "kCAN", TC_DESC("shifted cancel key") }, + { TC_FNAME(key_scommand), "*1", "kCMD", TC_DESC("shifted command key") }, + { TC_FNAME(key_scopy), "*2", "kCPY", TC_DESC("shifted copy key") }, + { TC_FNAME(key_screate), "*3", "kCRT", TC_DESC("shifted create key") }, + { TC_FNAME(key_sdc), "*4", "kDC", TC_DESC("shifted delete-char") }, + { TC_FNAME(key_sdl), "*5", "kDL", TC_DESC("shifted delete-line key") }, + { TC_FNAME(key_select), "*6", "kslt", TC_DESC("select key") }, + { TC_FNAME(key_send), "*7", "kEND", TC_DESC("shifted end key"), TC_TOKEN(MOD_SHIFT|KEY_END) }, + { TC_FNAME(key_seol), "*8", "kEOL", TC_DESC("shifted clear-to-end-of-line key") }, + { TC_FNAME(key_sexit), "*9", "kEXT", TC_DESC("shifted exit key") }, + { TC_FNAME(key_sfind), "*0", "kFND", TC_DESC("shifted find key") }, + { TC_FNAME(key_shelp), "#1", "kHLP", TC_DESC("shifted help key") }, /* KEY_HELP */ + { TC_FNAME(key_shome), "#2", "kHOM", TC_DESC("shifted home key"), TC_TOKEN(MOD_SHIFT|KEY_HOME) }, + { TC_FNAME(key_sic), "#3", "kIC", TC_DESC("shifted insert-character key") }, + { TC_FNAME(key_sleft), "#4", "kLFT", TC_DESC("shifted left-arrow key") }, + { TC_FNAME(key_smessage), "%a", "kMSG", TC_DESC("shifted message key") }, + { TC_FNAME(key_smove), "%b", "kMOV", TC_DESC("shifted move key") }, + { TC_FNAME(key_snext), "%c", "kNXT", TC_DESC("shifted next key") }, + { TC_FNAME(key_soptions), "%d", "kOPT", TC_DESC("shifted options key") }, + { TC_FNAME(key_sprevious), "%e", "kPRV", TC_DESC("shifted previous key") }, + { TC_FNAME(key_sprint), "%f", "kPRT", TC_DESC("shifted print key") }, + { TC_FNAME(key_sredo), "%g", "kRDO", TC_DESC("shifted redo key") }, + { TC_FNAME(key_sreplace), "%h", "kRPL", TC_DESC("shifted replace key") }, + { TC_FNAME(key_sright), "%i", "kRIT", TC_DESC("shifted right-arrow key") }, + { TC_FNAME(key_srsume), "%j", "kRES", TC_DESC("shifted resume key") }, + { TC_FNAME(key_ssave), "!1", "kSAV", TC_DESC("shifted save key") }, + { TC_FNAME(key_ssuspend), "!2", "kSPD", TC_DESC("shifted suspend key") }, + { TC_FNAME(key_sundo), "!3", "kUND", TC_DESC("shifted undo key"), TC_TOKEN(KEY_REDO) }, + { TC_FNAME(key_f11), "F1", "kf11", TC_DESC("F11 function key"), TC_TOKEN(F(11)) }, + { TC_FNAME(key_f12), "F2", "kf12", TC_DESC("F12 function key"), TC_TOKEN(F(12)) }, + { TC_FNAME(key_f13), "F3", "kf13", TC_DESC("F13 function key") /*, TC_TOKEN(F(13))*/ }, + { TC_FNAME(key_f14), "F4", "kf14", TC_DESC("F14 function key") /*, TC_TOKEN(F(14))*/ }, + { TC_FNAME(key_f15), "F5", "kf15", TC_DESC("F15 function key") /*, TC_TOKEN(F(15))*/ }, + { TC_FNAME(key_f16), "F6", "kf16", TC_DESC("F16 function key") /*, TC_TOKEN(F(16))*/ }, + { TC_FNAME(key_f17), "F7", "kf17", TC_DESC("F17 function key") /*, TC_TOKEN(F(17))*/ }, + { TC_FNAME(key_f18), "F8", "kf18", TC_DESC("F18 function key") /*, TC_TOKEN(F(18))*/ }, + { TC_FNAME(key_f19), "F9", "kf19", TC_DESC("F19 function key") /*, TC_TOKEN(F(19))*/ }, + { TC_FNAME(key_f20), "FA", "kf20", TC_DESC("F20 function key") /*, TC_TOKEN(F(20))*/ }, + { TC_FNAME(key_f21), "FB", "kf21", TC_DESC("F21 function key") }, + { TC_FNAME(key_f22), "FC", "kf22", TC_DESC("F22 function key") }, + { TC_FNAME(key_f23), "FD", "kf23", TC_DESC("F23 function key") }, + { TC_FNAME(key_f24), "FE", "kf24", TC_DESC("F24 function key") }, + { TC_FNAME(key_f25), "FF", "kf25", TC_DESC("F25 function key") }, + { TC_FNAME(key_f26), "FG", "kf26", TC_DESC("F26 function key") }, + { TC_FNAME(key_f27), "FH", "kf27", TC_DESC("F27 function key") }, + { TC_FNAME(key_f28), "FI", "kf28", TC_DESC("F28 function key") }, + { TC_FNAME(key_f29), "FJ", "kf29", TC_DESC("F29 function key") }, + { TC_FNAME(key_f30), "FK", "kf30", TC_DESC("F30 function key") }, + { TC_FNAME(key_f31), "FL", "kf31", TC_DESC("F31 function key") }, + { TC_FNAME(key_f32), "FM", "kf32", TC_DESC("F32 function key") }, + { TC_FNAME(key_f33), "FN", "kf33", TC_DESC("F33 function key") }, + { TC_FNAME(key_f34), "FO", "kf34", TC_DESC("F34 function key") }, + { TC_FNAME(key_f35), "FP", "kf35", TC_DESC("F35 function key") }, + { TC_FNAME(key_f36), "FQ", "kf36", TC_DESC("F36 function key") }, + { TC_FNAME(key_f37), "FR", "kf37", TC_DESC("F37 function key") }, + { TC_FNAME(key_f38), "FS", "kf38", TC_DESC("F38 function key") }, + { TC_FNAME(key_f39), "FT", "kf39", TC_DESC("F39 function key") }, + { TC_FNAME(key_f40), "FU", "kf40", TC_DESC("F40 function key") }, + { TC_FNAME(key_f41), "FV", "kf41", TC_DESC("F41 function key") }, + { TC_FNAME(key_f42), "FW", "kf42", TC_DESC("F42 function key") }, + { TC_FNAME(key_f43), "FX", "kf43", TC_DESC("F43 function key") }, + { TC_FNAME(key_f44), "FY", "kf44", TC_DESC("F44 function key") }, + { TC_FNAME(key_f45), "FZ", "kf45", TC_DESC("F45 function key") }, + { TC_FNAME(key_f46), "Fa", "kf46", TC_DESC("F46 function key") }, + { TC_FNAME(key_f47), "Fb", "kf47", TC_DESC("F47 function key") }, + { TC_FNAME(key_f48), "Fc", "kf48", TC_DESC("F48 function key") }, + { TC_FNAME(key_f49), "Fd", "kf49", TC_DESC("F49 function key") }, + { TC_FNAME(key_f50), "Fe", "kf50", TC_DESC("F50 function key") }, + { TC_FNAME(key_f51), "Ff", "kf51", TC_DESC("F51 function key") }, + { TC_FNAME(key_f52), "Fg", "kf52", TC_DESC("F52 function key") }, + { TC_FNAME(key_f53), "Fh", "kf53", TC_DESC("F53 function key") }, + { TC_FNAME(key_f54), "Fi", "kf54", TC_DESC("F54 function key") }, + { TC_FNAME(key_f55), "Fj", "kf55", TC_DESC("F55 function key") }, + { TC_FNAME(key_f56), "Fk", "kf56", TC_DESC("F56 function key") }, + { TC_FNAME(key_f57), "Fl", "kf57", TC_DESC("F57 function key") }, + { TC_FNAME(key_f58), "Fm", "kf58", TC_DESC("F58 function key") }, + { TC_FNAME(key_f59), "Fn", "kf59", TC_DESC("F59 function key") }, + { TC_FNAME(key_f60), "Fo", "kf60", TC_DESC("F60 function key") }, + { TC_FNAME(key_f61), "Fp", "kf61", TC_DESC("F61 function key") }, + { TC_FNAME(key_f62), "Fq", "kf62", TC_DESC("F62 function key") }, + { TC_FNAME(key_f63), "Fr", "kf63", TC_DESC("F63 function key") }, + { TC_FNAME(key_mouse), "Km", "kmous", TC_DESC("mouse event has occurred") }, + + /*xterm keys */ + { TC_KNAME(xt), NULL, "kDC3", TC_DESC("alt delete-character") }, + { TC_KNAME(xt), NULL, "kDC4", TC_DESC("shift+alt delete-character") }, + { TC_KNAME(xt), NULL, "kDC5", TC_DESC("control delete-character") }, + { TC_KNAME(xt), NULL, "kDC6", TC_DESC("shift+control delete-character") }, + { TC_KNAME(xt), NULL, "kDC7", TC_DESC("alt+control delete-character") }, + { TC_KNAME(xt), NULL, "kDN", TC_DESC("shift down-cursor") }, + { TC_KNAME(xt), NULL, "kDN3", TC_DESC("alt down-cursor") }, + { TC_KNAME(xt), NULL, "kDN4", TC_DESC("shift+alt down-cursor") }, + { TC_KNAME(xt), NULL, "kDN5", TC_DESC("control down-cursor") }, + { TC_KNAME(xt), NULL, "kDN6", TC_DESC("shift+control down-cursor") }, + { TC_KNAME(xt), NULL, "kDN7", TC_DESC("alt+control down-cursor") }, + { TC_KNAME(xt), NULL, "kEND3", TC_DESC("alt end") }, + { TC_KNAME(xt), NULL, "kEND4", TC_DESC("shift+alt end") }, + { TC_KNAME(xt), NULL, "kEND5", TC_DESC("control end") }, + { TC_KNAME(xt), NULL, "kEND6", TC_DESC("shift+control end") }, + { TC_KNAME(xt), NULL, "kEND7", TC_DESC("alt+control end") }, + { TC_KNAME(xt), NULL, "kHOM3", TC_DESC("alt home") }, + { TC_KNAME(xt), NULL, "kHOM4", TC_DESC("shift+alt home") }, + { TC_KNAME(xt), NULL, "kHOM5", TC_DESC("control home") }, + { TC_KNAME(xt), NULL, "kHOM6", TC_DESC("shift+control home") }, + { TC_KNAME(xt), NULL, "kHOM7", TC_DESC("alt+control home") }, + { TC_KNAME(xt), NULL, "kIC3", TC_DESC("alt insert-character") }, + { TC_KNAME(xt), NULL, "kIC4", TC_DESC("shift+alt insert-character") }, + { TC_KNAME(xt), NULL, "kIC5", TC_DESC("control insert-character") }, + { TC_KNAME(xt), NULL, "kIC6", TC_DESC("shift+control insert-character") }, + { TC_KNAME(xt), NULL, "kIC7", TC_DESC("alt+control insert-character") }, + { TC_KNAME(xt), NULL, "kLFT3", TC_DESC("alt left-cursor") }, + { TC_KNAME(xt), NULL, "kLFT4", TC_DESC("shift+alt left-cursor") }, + { TC_KNAME(xt), NULL, "kLFT5", TC_DESC("control left-cursor") }, + { TC_KNAME(xt), NULL, "kLFT6", TC_DESC("shift+control left-cursor") }, + { TC_KNAME(xt), NULL, "kLFT7", TC_DESC("alt+control left-cursor") }, + { TC_KNAME(xt), NULL, "kNXT3", TC_DESC("alt next") }, + { TC_KNAME(xt), NULL, "kNXT4", TC_DESC("shift+alt next") }, + { TC_KNAME(xt), NULL, "kNXT5", TC_DESC("control next") }, + { TC_KNAME(xt), NULL, "kNXT6", TC_DESC("shift+control next") }, + { TC_KNAME(xt), NULL, "kNXT7", TC_DESC("alt+control next") }, + { TC_KNAME(xt), NULL, "kPRV3", TC_DESC("alt previous") }, + { TC_KNAME(xt), NULL, "kPRV4", TC_DESC("shift+alt previous") }, + { TC_KNAME(xt), NULL, "kPRV5", TC_DESC("control previous") }, + { TC_KNAME(xt), NULL, "kPRV6", TC_DESC("shift+control previous") }, + { TC_KNAME(xt), NULL, "kPRV7", TC_DESC("alt+control previous") }, + { TC_KNAME(xt), NULL, "kRIT3", TC_DESC("alt right-cursor") }, + { TC_KNAME(xt), NULL, "kRIT4", TC_DESC("shift+alt right-cursor") }, + { TC_KNAME(xt), NULL, "kRIT5", TC_DESC("control right-cursor") }, + { TC_KNAME(xt), NULL, "kRIT6", TC_DESC("shift+control right-cursor") }, + { TC_KNAME(xt), NULL, "kRIT7", TC_DESC("alt+control right-cursor") }, + { TC_KNAME(xt), NULL, "kUP", TC_DESC("shift up-cursor") }, + { TC_KNAME(xt), NULL, "kUP3", TC_DESC("alt up-cursor") }, + { TC_KNAME(xt), NULL, "kUP4", TC_DESC("shift+alt up-cursor") }, + { TC_KNAME(xt), NULL, "kUP5", TC_DESC("control up-cursor") }, + { TC_KNAME(xt), NULL, "kUP6", TC_DESC("shift+control up-cursor") }, + { TC_KNAME(xt), NULL, "kUP7", TC_DESC("alt+control up-cursor") }, + { TC_KNAME(xt), NULL, "ka2", TC_DESC("vt220-keypad extensions") }, + { TC_KNAME(xt), NULL, "kb1", TC_DESC("vt220-keypad extensions") }, + { TC_KNAME(xt), NULL, "kb3", TC_DESC("vt220-keypad extensions") }, + { TC_KNAME(xt), NULL, "kc2", TC_DESC("vt220-keypad extensions") }, + { TC_KNAME(xt), NULL, "kxIN", TC_DESC("mouse response on focus-in") }, + { TC_KNAME(xt), NULL, "kxOU", TC_DESC("mouse response on focus-out") }, }; static TermNumeric_t term_flags[] = { /* boolean - termcap/terminfo elements */ - { "5i", "mc5i", TC_DESC("printer won't echo on screen") }, - { "HC", "chts", TC_DESC("cursor is hard to see") }, - { "LP", NULL, TC_DESC("last column of last line will not scroll"), TC_FLAG(&tf_LP) }, - { "MT", NULL, TC_DESC("has meta key") }, /* TODO */ - { "ND", "ndscr", TC_DESC("scrolling region is non-destructive") }, - { "NL", NULL, TC_DESC("move down with \\n"), TC_FLAG(&tf_NL) }, - { "NP", "npc", TC_DESC("pad character does not exist"), TC_FLAG(&tf_npc) }, - { "NR", "nrrmc", TC_DESC("smcup does not reverse rmcup") }, - { "YA", "xhpa", TC_DESC("only positive motion for hpa/mhpa caps") }, - { "YB", "crxm", TC_DESC("using cr turns off micro mode") }, - { "YC", "daisy", TC_DESC("printer needs operator to change character set") }, - { "YD", "xvpa", TC_DESC("only positive motion for vpa/mvpa caps") }, - { "YE", "sam", TC_DESC("printing in last column causes cr") }, - { "YF", "cpix", TC_DESC("changing character pitch changes resolution") }, - { "YG", "lpix", TC_DESC("changing line pitch changes resolution") }, - { "am", "am", TC_DESC("terminal has automatic margins"), TC_FLAG(&tf_am) }, - { "be", NULL, TC_DESC("back color erase"), TC_FLAG(&tf_be) }, - { "bs", NULL, TC_DESC("uses ^H to move left"), TC_FLAG(&tf_bs) }, - { "bw", "bw", TC_DESC("cub1 wraps from column 0 to last column") }, - { "cc", "ccc", TC_DESC("terminal can re-define existing colors") }, - { "da", "da", TC_DESC("display may be retained above the screen") }, - { "db", "db", TC_DESC("display may be retained below the screen") }, - { "eo", "eo", TC_DESC("can erase overstrikes with a blank") }, - { "es", "eslok", TC_DESC("escape can be used on the status line") }, - { "gn", "gn", TC_DESC("generic line type"), TC_FLAG(&tf_gn) }, - { "hc", "hc", TC_DESC("hardcopy terminal"), TC_FLAG(&tf_hc) }, - { "hl", "hls", TC_DESC("terminal uses only HLS color notation (tektronix)") }, - { "hs", "hs", TC_DESC("has extra status line") }, - { "hz", "hz", TC_DESC("can't print ~'s (hazeltine)"), TC_FLAG(&tf_hz) }, - { "in", "in", TC_DESC("insert mode distinguishes nulls") }, - { "km", "km", TC_DESC("Has a meta key, sets msb high"), TC_FLAG(&tf_km) }, - { "mi", "mir", TC_DESC("safe to move while in insert mode") }, - { "ms", "msgr", TC_DESC("safe to move while in standout/underline mode"), TC_FLAG(&tf_ms) }, - { "nc", NULL, TC_DESC("no way to go to start of line") }, - { "ns", NULL, TC_DESC("crt cannot scroll") }, - { "nx", "nxon", TC_DESC("padding won't work, xon/xoff required"), TC_FLAG(&tf_xonoff) }, - { "os", "os", TC_DESC("terminal can overstrike") }, - { "pt", NULL, TC_DESC("has 8-char tabs invoked with ^I") }, - { "ul", "ul", TC_DESC("underline character overstrikes") }, - { "ut", "bce", TC_DESC("screen erased with background color"), TC_FLAG(&tf_ut) }, - { "xb", "xsb", TC_DESC("beehive (f1=escape, f2=ctrl C)") }, - { "xn", "xenl", TC_DESC("newline ignored after 80 cols (concept)"), TC_FLAG(&tf_xn) }, - { "xo", NULL, TC_DESC("terminal uses xon/xoff handshaking"), TC_FLAG(&tf_xonoff) }, - { "xr", "xon", TC_DESC("return clears the line") }, - { "xs", "xhp", TC_DESC("standout not erased by overwriting (hp)"), TC_FLAG(&tf_xs) }, - { "xt", "xt", TC_DESC("tabs destructive, magic so char (Telray 1061)"), TC_FLAG(&tf_xt) } - }; + { TC_FNAME(auto_left_margin), "bw", "bw", TC_DESC("cub1 wraps from column 0 to last column") }, + { TC_FNAME(auto_right_margin), "am", "am", TC_DESC("terminal has automatic margins"), TC_FLAG(&tf_am) }, + { TC_FNAME(no_esc_ctlc), "xb", "xsb", TC_DESC("beehive (f1=escape, f2=ctrl C)") }, + { TC_FNAME(ceol_standout_glitch), "xs", "xhp", TC_DESC("standout not erased by overwriting (hp)"), TC_FLAG(&tf_xs) }, + { TC_FNAME(eat_newline_glitch), "xn", "xenl", TC_DESC("newline ignored after 80 cols (concept)"), TC_FLAG(&tf_xn) }, + { TC_FNAME(erase_overstrike), "eo", "eo", TC_DESC("can erase overstrikes with a blank") }, + { TC_FNAME(generic_type), "gn", "gn", TC_DESC("generic line type"), TC_FLAG(&tf_gn) }, + { TC_FNAME(hard_copy), "hc", "hc", TC_DESC("hardcopy terminal"), TC_FLAG(&tf_hc) }, + { TC_FNAME(has_meta_key), "km", "km", TC_DESC("has a meta key, sets msb high"), TC_FLAG(&tf_km) }, + { TC_FNAME(has_status_line), "hs", "hs", TC_DESC("has extra status line") }, + { TC_FNAME(insert_null_glitch), "in", "in", TC_DESC("insert mode distinguishes nulls") }, + { TC_FNAME(memory_above), "da", "da", TC_DESC("display may be retained above the screen") }, + { TC_FNAME(memory_below), "db", "db", TC_DESC("display may be retained below the screen") }, + { TC_FNAME(move_insert_mode), "mi", "mir", TC_DESC("safe to move while in insert mode") }, + { TC_FNAME(move_standout_mode), "ms", "msgr", TC_DESC("safe to move while in standout/underline mode"), TC_FLAG(&tf_ms) }, + { TC_FNAME(over_strike), "os", "os", TC_DESC("terminal can overstrike") }, + { TC_FNAME(status_line_esc_ok), "es", "eslok", TC_DESC("escape can be used on the status line") }, + { TC_FNAME(dest_tabs_magic_smso), "xt", "xt", TC_DESC("tabs destructive, magic so char (Telray 1061)"), TC_FLAG(&tf_xt) }, + { TC_FNAME(tilde_glitch), "hz", "hz", TC_DESC("can't print ~'s (hazeltine)"), TC_FLAG(&tf_hz) }, + { TC_FNAME(transparent_underline), "ul", "ul", TC_DESC("underline character overstrikes") }, + { TC_FNAME(xon_xoff), "xo", "xon", TC_DESC("terminal uses xon/xoff handshaking"), TC_FLAG(&tf_xonoff) }, + { TC_FNAME(needs_xon_xoff), "nx", "nxon", TC_DESC("padding won't work, xon/xoff required"), TC_FLAG(&tf_xonoff) }, + { TC_FNAME(prtr_silent), "5i", "mc5i", TC_DESC("printer wont echo on screen") }, + { TC_FNAME(hard_cursor), "HC", "chts", TC_DESC("cursor is hard to see") }, + { TC_FNAME(non_rev_rmcup), "NR", "nrrmc", TC_DESC("smcup does not reverse rmcup") }, + { TC_FNAME(no_pad_char), "NP", "npc", TC_DESC("pad character does not exist"), TC_FLAG(&tf_npc) }, + { TC_FNAME(non_dest_scroll_region), "ND", "ndscr", TC_DESC("scrolling region is non-destructive") }, + { TC_FNAME(can_change), "cc", "ccc", TC_DESC("terminal can re-define existing colors") }, + { TC_FNAME(back_color_erase), "ut", "bce", TC_DESC("screen erased with background color"), TC_FLAG(&tf_ut) }, + { TC_FNAME(hue_lightness_saturation), "hl", "hls", TC_DESC("terminal uses only HLS color notation (tektronix)") }, + { TC_FNAME(col_addr_glitch), "YA", "xhpa", TC_DESC("only positive motion for hpa/mhpa caps") }, + { TC_FNAME(cr_cancels_micro_mode), "YB", "crxm", TC_DESC("using cr turns off micro mode") }, + { TC_FNAME(has_print_wheel), "YC", "daisy", TC_DESC("printer needs operator to change character set") }, + { TC_FNAME(row_addr_glitch), "YD", "xvpa", TC_DESC("only positive motion for vpa/mvpa caps") }, + { TC_FNAME(semi_auto_right_margin), "YE", "sam", TC_DESC("printing in last column causes cr") }, + { TC_FNAME(cpi_changes_res), "YF", "cpix", TC_DESC("changing character pitch changes resolution") }, + { TC_FNAME(lpi_changes_res), "YG", "lpix", TC_DESC("changing line pitch changes resolution") }, + { TC_FNAME(backspaces_with_bs), "bs", "OTbs", TC_DESC("uses ^H to move left"), TC_FLAG(&tf_bs) }, + { TC_FNAME(crt_no_scrolling), "ns", "OTns", TC_DESC("crt cannot scroll") }, + { TC_FNAME(no_correctly_working_cr), "nc", "OTnc", TC_DESC("no way to go to start of line") }, + { TC_FNAME(gnu_has_meta_key), "MT", "OTMT", TC_DESC("has meta key") }, /* TODO */ + { TC_FNAME(linefeed_is_newline), "NL", "OTNL", TC_DESC("move down with \\n"), TC_FLAG(&tf_NL) }, + { TC_FNAME(has_hardware_tabs), "pt", "OTpt", TC_DESC("has 8-char tabs invoked with ^I") }, + { TC_FNAME(return_does_clr_eol), "xr", "OTxr", TC_DESC("return clears the line") }, + /* + * User-Defined Capabilities + * + * https://invisible-island.net/ncurses/man/user_caps.5.html + * See: ncurses/include/Caps-ncurses + */ + { TC_UNAME(xt), NULL, "NQ", TC_DESC("terminal does not support query/response") }, + { TC_UNAME(xt), NULL, "RGB", TC_DESC("RGB color support") }, + + /* screen */ + { TC_UNAME(xt), NULL, "AN", TC_DESC("turn on autonuke") }, + { TC_UNAME(xt), NULL, "AX", TC_DESC("understands ANSI set default fg/bg color") }, + { TC_UNAME(xt), NULL, "C8", TC_DESC("terminal shows bold as high-intensity colors") }, + { TC_UNAME(xt), NULL, "G0", TC_DESC("can deal with ISO 2022 font selection") }, + { TC_UNAME(xt), NULL, "TF", TC_DESC("add missing capabilities to screen") }, + { TC_UNAME(xt), NULL, "XT", TC_DESC("Supports xterm OCS and mouse"), TC_FLAG(&tf_XT) }, + + /* vim */ + { TC_UNAME(xt), NULL, "XF", TC_DESC("terminal supports xterm focus in/out") }, + }; static const unsigned ansicolor_map[] = { /* BRIEF -> ANSI color map */ /* BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, WHITE */ @@ -1242,6 +1411,8 @@ static int tt_colormap[COLOR_NONE + 1]; * Assume BCE capabilities. * o COLORTERM - * slang style color terminal configuration, if set color assumed. + * o OSC 11 + * Default background; rgb luminance. * o NCURSES_NO_UTF8_ACS - * When running in a UTF-8 locale several terminals (including Linux console and GNU screen) * ignore alternative character selection. If set use unicode box drawing characters in all @@ -1293,17 +1464,16 @@ ttinit(void) term = ttisetup(); /* - * build attributes + * build attributes, non-xterm */ - if (0 == strncmp(term, "linux", 5)) { /* linux console */ + if (tty_isterm(term, "linux")) { /* linux console */ t_attributes = TA_LINUX | TA_DARK; - } else if (0 == strncmp(term, "cygwin", 5)) { + } else if (tty_isterm(term, "cygwin")) { const char *cygwin = ggetenv("CYGWIN"); if (cygwin) { trace_log("\tCYGWIN:%s\n", cygwin); - if (strstr(cygwin, "codepage:oem")) { if (xf_disptype < 0) { /* 8bit terminal */ xf_disptype = DISPTYPE_8BIT; @@ -1319,180 +1489,72 @@ ttinit(void) t_attributes = TA_CYGWIN|TA_XTERMLIKE|TA_DARK; #if defined(linux) - } else if (0 == strncmp(term, "con", 3)) { /* console, con80x25 etc */ + } else if (tty_isterm(term, "console") || /* console, con80x25 etc */ + (0 == strncmp(term, "con", 3) && term[3] && isdigit(term[3]))) { t_attributes = TA_LINUX|TA_DARK; #endif - } else if (0 == strncmp(term, "konsole", 7) || + } else if (tty_isterm(term, "konsole") || getenv("KONSOLE_DCOP") || getenv("KONSOLE_DBUS_SESSION")) { - t_attributes = TA_KONSOLE | TA_XTERMLIKE; + t_attributes = TA_KONSOLE|TA_XTERMLIKE; - } else if (0 == strncmp(term, "screen", 6)) { - t_attributes = TA_SCREEN; - if (0 == strcmp(term, "screen.linux")) { + } else if (tty_isterm(term, "screen")) { + t_attributes = TA_SCREEN; /* screen[.linux] */ + if (0 == tty_isterm(term, "screen.linux")) { t_attributes |= TA_DARK; } - } else if (0 == strcmp(term, "putty")) { - t_attributes |= TA_DARK; - } else if (strcmp(term, "vt52") != 0 && /* vt100+ */ term[0] == 'v' && term[1] == 't' && term[2] >= '1' && term[2] <= '9') { t_attributes = TA_VT100LIKE; - } else if (term_xtermlike(term)) { /* eg. xterm-color */ - t_attributes = TA_XTERM | TA_XTERMLIKE; + } else { + t_attributes = term_xtermlike(term); #if defined(__CYGWIN__) - if (ggetenv("COMSPEC")) { - t_attributes |= TA_DARK; /* assume cmd/mintty */ + if (ggetenv("WT_SESSION")) { + t_attributes |= TA_MSTERMINAL|TA_DARK; /* ms-terminal */ + } else if (ggetenv("COMSPEC")) { + t_attributes |= TA_DARK; /* cmd/mintty */ } -#endif /*__CYGWIN__*/ +#endif /*__CYGWIN__*/ } - if (hasfeature(term, "rv")) { + if (tty_hasfeature(term, "rv")) { t_attributes |= TA_LIGHT; /* rv = reverse video (black on white) */ - } else if (hasfeature(term, "m") || hasfeature(term, "mono")) { + } else if (tty_hasfeature(term, "m") || tty_hasfeature(term, "mono")) { t_attributes |= TA_MONO; /* m = monochrome, suppress color support */ } - trace_log("terminal: %s (%s%s%s%s%s%s%s%s)\n", term, - (t_attributes & TA_LINUX ? "linux," : ""), - (t_attributes & TA_CYGWIN ? "cygwin," : ""), + trace_log("terminal: %s (0x%08x=%s%s%s%s%s%s)\n", term, t_attributes, (t_attributes & TA_VT100LIKE ? "vt100like," : ""), - (t_attributes & TA_XTERM ? "xterm," : ""), + (t_attributes & TA_XTERM ? "xterm," : ""), (t_attributes & TA_XTERMLIKE ? "xtermlike," : ""), - (t_attributes & TA_LIGHT ? "light," : ""), - (t_attributes & TA_DARK ? "dark," : ""), - (t_attributes & TA_MONO ? "mono," : "")); + (t_attributes & TA_LIGHT ? "light," : ""), + (t_attributes & TA_DARK ? "dark," : ""), + (t_attributes & TA_MONO ? "mono," : "")); /* - * Load termcap values. + * Load terminal values. */ - { - unsigned i, fkeys = 0; - const char *cp; - - trace_log("termcap:\n"); - - trace_log(" General:\n"); - for (i = 0; i < (sizeof(term_strings)/sizeof(term_strings[0])); i++) { - /* - * string values - */ - TermString_t *ti = term_strings + i; - const Term_t *term = &ti->term; - const char *name = ttiname(term); - - if (name && NULL != (cp = ttigetstr(term))) { - const char **token = ti->stoken; - - ti->svalue = cp; - if (token) { - *token = ti->svalue; - } - trace_log("\t%-50s%c %-5s : %s\n", term->comment, - (token ? '*' : ' '), name, c_string(cp)); - - if (token == &tc_graphic_pairs) { - acs_dump(cp); - x_pt.pt_attributes |= TF_AGRAPHICCHARACTERS; - - } else if (token == &tc_box_characters) { - const char *t_acs; - - if (NULL == tc_graphic_pairs && - (NULL != (t_acs = acs_box_characters(cp)))) { - acs_dump(t_acs); - tc_graphic_pairs = t_acs; - x_pt.pt_attributes |= TF_AGRAPHICCHARACTERS; - } - } - } - } - - fkeys = 0; - trace_log(" Keys:\n"); - for (i = 0; i < (sizeof(term_keys)/sizeof(term_keys[0])); ++i) { - /* - * keys - */ - TermKey_t *ti = term_keys + i; - const Term_t *term = &ti->term; - const char *name = ttiname(term); - - if (name && NULL != (cp = ttigetstr(term))) { - const size_t kcode = (size_t)ti->key; - - ti->svalue = cp; /* loaded later by ttkeys() */ - - trace_log("\t%-50s%c %-5s : %s\n", term->comment, - (kcode ? '*' : ' '), name, c_string(cp)); - - if (kcode >= F(1) && kcode <= F(10)) { - ++fkeys; - } - } - } - - if (fkeys >= 10) { /* have all 10 function keys */ - x_pt.pt_attributes |= TF_AFUNCTIONKEYS; - } - - trace_log(" Numeric:\n"); - for (i = 0; i < (sizeof(term_numbers)/sizeof(term_numbers[0])); ++i) { - /* - * numbers - */ - TermNumeric_t *ti = term_numbers + i; - const Term_t *term = &ti->term; - const char *name = ttiname(term); - - if (name) { - ti->ivalue = ttigetnum(term); - if (ti->itoken) { - *ti->itoken = ti->ivalue; - } - trace_log("\t%-50s%c %-5s : %d\n", term->comment, - (ti->itoken ? '*' : ' '), name, ti->ivalue); - } - } - - trace_log(" Boolean/Flags:\n"); - for (i = 0; i < (sizeof(term_flags)/sizeof(term_flags[0])); ++i) { - /* - * flags - */ - TermNumeric_t *ti = term_flags + i; - const Term_t *term = &ti->term; - const char *name = ttiname(term); - - if (name) { - ti->ivalue = ttigetflag(term); - if (ti->itoken) { - *ti->itoken = ti->ivalue; - } - trace_log("\t%-50s%c %-5s : %d\n", term->comment, - (ti->itoken ? '*' : ' '), name, ti->ivalue); - } - } - } - - /* color */ + term_config(); term_fgbg(); + /* + * Fixup defective termcap/terminfo databases + */ if (NULL != ggetenv("COLORTERM_BCE")) { tf_be = 1; /* slang compat override */ } - if (NULL == tc_Color_Fg || NULL == tc_Color_Fg) { - if (tc_ANSI_Color_Fg && tc_ANSI_Color_Bg) { - tc_Color_Fg = tc_ANSI_Color_Fg; - tc_Color_Bg = tc_ANSI_Color_Bg; - } + if (NULL == tc_Color_Fg || NULL == tc_Color_Bg) { + tc_Color_Fg = tc_Color_Bg = NULL; + } + + if (NULL == tc_ANSI_Color_Fg || NULL == tc_ANSI_Color_Bg) { + tc_ANSI_Color_Fg = tc_ANSI_Color_Bg = NULL; } - /* fixup defective termcap/terminfo databases */ if (NULL == tc_graphic_pairs && (t_attributes & TA_VT100LIKE)) { /* VT1xx */ tc_acs_start = "\016"; @@ -1501,7 +1563,7 @@ ttinit(void) } if (NULL == tc_graphic_pairs && - strncmp(term, "aixterm", 7) == 0) { /* aixterm (VT102) */ + tty_isterm(term, "aixterm")) { /* aixterm (VT102) */ tc_acs_start = "\016"; tc_acs_end = "\017"; tc_acs_enable = "\033(B\033)0"; @@ -1595,7 +1657,7 @@ ttinit(void) x_pt.pt_attributes |= TF_ACYGWIN; /* Cygwin terminal */ tf_xn = 1; } -#endif /*__CYGWIN__*/ +#endif /*__CYGWIN__*/ if (tf_km) { x_pt.pt_attributes |= TF_AMETAKEY; @@ -1607,19 +1669,131 @@ ttinit(void) } -static int -hasfeature(const char *term, const char *what) +static void +term_config(void) { - const char *p = strstr(term, what); + unsigned i, fkeys = 0; + const char *cp; + + trace_log("termcap:\n"); + + trace_log(" String:\n"); + for (i = 0; i < (sizeof(term_strings)/sizeof(term_strings[0])); i++) { + /* + * string values + */ + TermString_t *ti = term_strings + i; + const Term_t *term = &ti->term; + const char *name = ttiname(term); + + if (name && NULL != (cp = ttigetstr(term))) { + const char **token = ti->stoken; + + ti->svalue = cp; + if (token) { + *token = ti->svalue; + } + trace_log("\t%-24s %-50s%c %-6s : %s\n", + term->termfname, term->comment, (token ? '*' : ' '), name, c_string(cp)); + + if (token == &tc_graphic_pairs) { + acs_dump(cp); + x_pt.pt_attributes |= TF_AGRAPHICCHARACTERS; - if (p > term) { /* -rv[-] */ - const unsigned len = strlen(what); + } else if (token == &tc_box_characters) { + const char *t_acs; - if ('-' == p[-1] && ('-' == p[len] || 0 == p[len])) { - return 1; + if (NULL == tc_graphic_pairs && + (NULL != (t_acs = acs_box_characters(cp)))) { + acs_dump(t_acs); + tc_graphic_pairs = t_acs; + x_pt.pt_attributes |= TF_AGRAPHICCHARACTERS; + } + } + } + } + + fkeys = 0; + trace_log(" Keys:\n"); + for (i = 0; i < (sizeof(term_keys)/sizeof(term_keys[0])); ++i) { + /* + * keys + */ + TermKey_t *ti = term_keys + i; + const Term_t *term = &ti->term; + const char *name = ttiname(term); + + if (name && NULL != (cp = ttigetstr(term))) { + const size_t kcode = (size_t)ti->key; + + ti->svalue = cp; /* loaded later by ttkeys() */ + + trace_log("\t%-24s %-50s%c %-6s : %s\n", + term->termfname, term->comment, (kcode ? '*' : ' '), name, c_string(cp)); + + if (kcode >= F(1) && kcode <= F(10)) { + ++fkeys; + } + } + } + + if (fkeys >= 10) { /* have all 10 function keys */ + x_pt.pt_attributes |= TF_AFUNCTIONKEYS; + } + + trace_log(" Numeric:\n"); + for (i = 0; i < (sizeof(term_numbers)/sizeof(term_numbers[0])); ++i) { + /* + * numbers + */ + TermNumeric_t *ti = term_numbers + i; + const Term_t *term = &ti->term; + const char *name = ttiname(term); + + if (name) { + ti->ivalue = ttigetnum(term); + if (ti->itoken) { + *ti->itoken = ti->ivalue; + } + trace_log("\t%-24s %-50s%c %-6s : %d\n", + term->termfname, term->comment, (ti->itoken ? '*' : ' '), name, ti->ivalue); + } + } + + trace_log(" Boolean/Flags:\n"); + for (i = 0; i < (sizeof(term_flags)/sizeof(term_flags[0])); ++i) { + /* + * flags + */ + TermNumeric_t *ti = term_flags + i; + const Term_t *term = &ti->term; + const char *name = ttiname(term); + + if (name) { + ti->ivalue = ttigetflag(term); + if (ti->itoken) { + *ti->itoken = ti->ivalue; + } + trace_log("\t%-24s %-50s%c %-6s : %d\n", + term->termfname, term->comment, (ti->itoken ? '*' : ' '), name, ti->ivalue); } } - return 0; +} + + +/* Function: ttxtermlike + * Retrieve the derived xterm attributes. + * + * Parameters: + * none. + * + * Returns: + * Returns whether the terminal has xterm characteristics. + */ +int +ttxtermlike(void) +{ + return ((t_attributes & (TA_XTERM|TA_XTERMLIKE)) ? 1 : 0); } @@ -1641,11 +1815,22 @@ ttdefaultscheme(void) if (x_pt.pt_schemedark >= 0) { /* explicit configuration */ isdark = x_pt.pt_schemedark; - } else if (0 == (TA_LIGHT & t_attributes)) { - if (tt_defaultbg != NOCOLOR) { /* 0-6 or 8 */ + } else if ((TA_LUMINANCE_DARK|TA_LUMINANCE_LIGHT) & t_attributes) { + if (TA_LUMINANCE_DARK & t_attributes) { /* luminance calc */ + isdark = 1; + } + + } else if ((TA_DARK|TA_LIGHT) & t_attributes) { + if (TA_DARK & t_attributes) { /* assumed */ + isdark = 1; + } + + } else { + if (tt_defaultbg != NOCOLOR) { /* dark=0-6 or 8 */ if (tt_defaultbg <= 6 || 8 == tt_defaultbg) { isdark = 1; } + } else { /* generally dark */ if (TA_DARK & t_attributes) { isdark = 1; @@ -1673,7 +1858,9 @@ term_open(scrprofile_t *profile) { io_device_add(TTY_INFD); /* stream registration */ sys_initialise(); + term_attributes(); term_identification(); /* terminal identification */ + term_luminance(); term_sizeget(&profile->sp_rows, &profile->sp_cols); profile->sp_colors = tt_colors; } @@ -1822,24 +2009,7 @@ term_ready(int repaint, scrprofile_t *profile) ttputpad(tc_vs ? tc_vs : tc_ve); /* enable enhanced cursor */ if (tf_am) ttputpad(tc_am_on); /* enable automatic margins */ - ttputpad(tc_mm); /* enable meta key-codes */ - } - - /* - * terminal specific specials - */ - if (t_attributes & TA_CYGWIN) { - if (xf_cygwinkb) { - ttpush("\033[?2000h"); /* enable RAW mode (gives us WIN32 scancodes) */ - } - - } else if (t_attributes & TA_MINTTY) { - if (xf_mouse) { /* mouse enabled? */ - ttpush("\033[?7786h"); /* mouse-wheel reports only */ - } - - } else if (t_attributes & TA_VT100LIKE) { - ttpush("\033=\033[?1]"); /* enable cursor keys */ + key_enable(); /* enable keyboard mode */ } if (profile) { @@ -1858,7 +2028,7 @@ term_ready(int repaint, scrprofile_t *profile) * Signal a terminal feature change. * * Parameters: - * ident - Feature identifier. + * ident - Feature identifier. * * Returns: * nothing. @@ -2103,9 +2273,10 @@ ttigetstr(const Term_t *ti) XF_TERMINFO { const char *name = ti->terminfoname; - s = tigetstr((char *) name); + s = tigetstr(CURSES_CAST(name)); if ((char *)-1 == s) { /* 'name' is not a string capability */ - trace_log("\ttgetstr(%s) = unknown\n", name); + if (0 == ti->userdef) + trace_log("\ttgetstr(%s) = unknown\n", name); s = NULL; } } @@ -2166,7 +2337,7 @@ ttigetnum(const Term_t *ti) #if defined(HAVE_TERMINFO) XF_TERMINFO { name = ti->terminfoname; - num = tigetnum((char *) name); + num = tigetnum(CURSES_CAST(name)); } #endif #if defined(HAVE_TERMCAP) @@ -2175,7 +2346,7 @@ ttigetnum(const Term_t *ti) num = tgetnum((char *) name); } #endif - if (num < -1) { + if (num < -1 && 0 == ti->userdef) { trace_log("\ttgetnum(%s) = error (%d)\n", name, num); } return (num >= -1 ? num : -1); /* -1 or greater */ @@ -2200,7 +2371,7 @@ ttigetflag(const Term_t *ti) #if defined(HAVE_TERMINFO) XF_TERMINFO { name = ti->terminfoname; - flag = tigetflag((char *) name); + flag = tigetflag(CURSES_CAST(name)); } #endif #if defined(HAVE_TERMCAP) @@ -2209,7 +2380,7 @@ ttigetflag(const Term_t *ti) flag = tgetflag((char *) name); } #endif - if (flag < 0) { + if (flag < 0 && 0 == ti->userdef) { trace_log("\ttgetflag(%s) = error (%d)\n", name, flag); } return (flag >= 0 ? flag : 0); /* 0 or 1 */ @@ -2240,6 +2411,240 @@ ttisetflag(const char *tag, int taglen, const char *value) } + +/* Function: key_enable/disable + * Control alternative key encoding modes, based on xf_kbprotocol. + * + * Parameters: + * none + * + * Returns: + * nothing. + */ +static void +key_enable(void) +{ + key_config(); /* terminal specific selection */ + + strxcpy(x_pt.pt_kbprotocol, key_protocolname(xf_kbprotocol, "unknown"), sizeof(x_pt.pt_kbprotocol)); + + if (xf_kbprotocol == KBPROTOCOL_NONE) + return; + + ttputpad(tc_mm); /* enable meta key-codes */ + xf_kbprotocol |= KBPROTOCOL_META; + + if (t_attributes & TA_MINTTY) { + if (! xf_mouse) { + ttpush("\033[?7786h"); /* nomouse, mouse-wheel reports only */ + // mousewheel events are reported as cursor key presses; https://github.com/mintty/mintty/wiki/CtrlSeqs + } + } + + if (xf_kbprotocol & KBPROTOCOL_CYGWIN) { + trace_log("\tcygwin-raw-mode.\n"); + ttpush("\033[?2000h"); /* enable cygwin-raw-mode */ + +#if defined(KBPROTOCOL_MSTERMINAL) //TODO + } else if (xf_kbprotocol & KBPROTOCOL_MSTERMINAL) { + trace_log("\twin32-input-mode.\n"); + ttpush("\033[?9001h"); /* enable win32-input-mode */ +#endif + +#if defined(KBPROTOCOL_KITTY) //TODO + } else if (xf_kbprotocol & KBPROTOCOL_KITTY) { + /* + * Kitty progressive enhancement + * 0b1 (1) Disambiguate escape codes. + * 0b10 (2) Report event types. + * 0b100 (4) Report alternate keys. + * 0b1000 (8) Report all keys as escape codes. + * 0b10000 (16) Report associated text. + */ + trace_log("\tkitty-key-mode.\n"); + ttpush("\x1b[>1u"); /* enable kitty-keyboard-protocol */ +#endif + + } else if (xf_kbprotocol & (KBPROTOCOL_XTERM_MOK2|KBPROTOCOL_MINTTY_MOK2)) { + /* + * XTMODKEYS: set/reset key modifier options (modifyOtherKeys) + * CSI > Pp; Pv m + * CSI > Pp m + * + * The first parameter Pp identifies the resource to set/reset. + * Pp = 0, modifyKeyboard. + * Pp = 1, modifyCursorKeys. + * Pp = 2, modifyFunctionKeys. + * Pp = 4, modifyOtherKeys. + * + * The second parameter Pv is the value to assign to the resource. + * Pv = 0, disables + * Pv = 1, enables + * Pv = 2, extended + */ + trace_log("\tmok2-mode.\n"); + ttpush("\x1b[>4;2m"); /* enable xterm-mok2-mode */ + + } else if (xf_kbprotocol & KBPROTOCOL_VT100_CURSOR) { + ttpush("\033[=\033[?1h"); /* enable cursor keys/DECCKM */ + } +} + + +/* Function: key_config + * Keyboard protocol selection. + * + * Parameters: + * none + * + * Returns: + * nothing. + */ +static void +key_config(void) +{ + if (xf_kbprotocol != KBPROTOCOL_AUTO) + return; + + xf_kbprotocol = KBPROTOCOL_META; /* implied */ + + if (xf_kbconfig) { + /* + * user-config + */ + const char *term = ggetenv("TERM"); // TODO/TERM_PROGRAM + + if (-1 == key_protocol(term, strlen(term))) { + const char *dash = strchr(term, '-'); + if (dash) { /* term[-options] */ + const int termlen = dash - term; + + if (-1 == key_protocol(term, termlen)) { + trace_log("\tkbprotocol: %*s=N/A (none)\n", termlen, term); + xf_kbprotocol = KBPROTOCOL_NONE; + } + } + } + + } else { + /* + * terminal probe + */ + if (t_attributes & TA_CYGWIN) { + xf_kbprotocol = KBPROTOCOL_CYGWIN; + +#if defined(KBPROTOCOL_MSTERMINAL) //TODO, See issues: https://sourceware.org/pipermail/cygwin-patches/2024q3/012748.html + } else if (t_attributes & TA_MSTERMINAL) { + xf_kbprotocol = KBPROTOCOL_MSTERMINAL; +#endif + +#if defined(KBPROTOCOL_KITTY) //TODO + } else if (t_attributes & TA_KITTY) { + xf_kbprotocol = KBPROTOCOL_KITTY; +#endif + + } else if (t_attributes & TA_MINTTY) { + xf_kbprotocol = KBPROTOCOL_MINTTY_MOK2; + + } else if (t_attributes & TA_XTERMLIKE) { + xf_kbprotocol = KBPROTOCOL_XTERM_MOK2; + + } else if (t_attributes & TA_VT100LIKE) { + xf_kbprotocol = KBPROTOCOL_VT100_CURSOR; + } + } +} + + +static int +key_protocol(const char *term, int termlen) +{ + const char *elm; + + for (elm = xf_kbconfig; elm && *elm; ) { + const char *end = strchr(elm, ';'); /* term:protocol[;...] */ + + if (0 == strncmp(elm, term, termlen)) { + if (elm[termlen] == ':') { + const char *name = elm + termlen + 1; + const int namelen = (end ? end - name : strlen(name)); + int protocol; + + protocol = key_protocolid(name, namelen); + if (protocol >= 0 && protocol != KBPROTOCOL_AUTO) { + trace_log("\tkbprotocol: %*s=%*s\n", termlen, term, name, namelen); + xf_kbprotocol = protocol; + return 0; //success + } + trace_log("\tkbprotocol: *s, unknown ignored\n", name, namelen); + break; + } + } + + if (NULL != (elm = end)) { + ++elm; + } + } + return -1; +} + + +static void +key_disable(void) +{ + if (xf_kbprotocol <= KBPROTOCOL_AUTO) + return; + + //ttputpad(tc_mm); /* disable meta key-codes */ + if (t_attributes & TA_MINTTY) { + if (! xf_mouse) { + ttpush("\033[?7786l"); /* nomouse, disable mouse-wheel reports */ + } + } + + if (xf_kbprotocol & KBPROTOCOL_CYGWIN) { + ttpush("\033[?2000l"); /* disable cygwin-raw-mode */ + +#if defined(KBPROTOCOL_MSTERMINAL) //TODO + } else if (xf_kbprotocol & KBPROTOCOL_MSTERMINAL) { + ttpush("\033[?9001l"); /* disable win32-input-mode */ +#endif + +#if defined(KBPROTOCOL_KITTY) //TODO + } else if (xf_kbprotocol & KBPROTOCOL_KITTY) { + /* + * kitty progressive enhancement + * 0b1 (1) Disambiguate escape codes. + * 0b10 (2) Report event types. + * 0b100 (4) Report alternate keys. + * 0b1000 (8) Report all keys as escape codes. + * 0b10000 (16) Report associated text. + */ + ttpush("\x1b[<1u"); /* disable kitty-keyboard-protocol */ +#endif + + } else if (xf_kbprotocol & (KBPROTOCOL_XTERM_MOK2|KBPROTOCOL_MINTTY_MOK2)) { + /* + * XTMODKEYS: set/reset key modifier options (modifyOtherKeys) + * CSI > Pp; Pv m + * CSI > Pp m + * + * The first parameter Pp identifies the resource to set/reset. + * Pp = 0, modifyKeyboard. + * Pp = 1, modifyCursorKeys. + * Pp = 2, modifyFunctionKeys. + * Pp = 4, modifyOtherKeys. + * + * The second parameter Pv is the value to assign to the resource. + * Pv = 0, disables + * Pv = 1, enables + * Pv = 2, extended + */ + ttpush("\x1b[>4;0m"); /* disable xterm-mok2-mode */ + } +} + + /* Function: acs_dump * Alternative character dump. * @@ -2282,6 +2687,7 @@ acs_dump(const char *bp) * Parameters: * bx - Box character spec. * + * Returns: * Converted box characters into an acs specification. */ @@ -2328,23 +2734,28 @@ acs_locale_breaks(void) if ((env = ggetenv("NCURSES_NO_UTF8_ACS")) != 0) { return atoi(env); /* ncurses compatibility */ - } else if ((env = ggetenv("TERM")) != 0) { - if (strstr(env, "linux")) { + } else if ((env = ggetenv("TERM")) != NULL) { + if (tty_isterm(env, "linux")) { return TRUE; } - if (strstr(env, "screen") && + if (tty_isterm(env, "screen") && ((env = ggetenv("TERMCAP")) != 0 && strstr(env, "screen") != 0) && - strstr(env, "hhII00") != 0) { + strstr(env, "hhII00") != 0) { #define IS_CTRLN(s) ((s) != 0 && strstr(s, "\016") != 0) #define IS_CTRLO(s) ((s) != 0 && strstr(s, "\017") != 0) - if (IS_CTRLN(tc_acs_start) || IS_CTRLO(tc_acs_start) || - IS_CTRLN(set_attributes) || IS_CTRLO(set_attributes)) { + if (IS_CTRLN(tc_acs_start) || IS_CTRLO(tc_acs_start)) { return TRUE; } +#if defined(HAVE_LIBNCURSESW) || defined(HAVE_LIBNCURSES) + if (IS_CTRLN(set_attributes) || IS_CTRLO(set_attributes)) { + return TRUE; + } +#endif + #undef IS_CTRLN #undef IS_CTRLO } @@ -2360,48 +2771,48 @@ acs_locale_breaks(void) * term - Terminate name. * * Returns: - * nothing. + * Associated flags, if any. */ -static int +static TAttributes_t term_xtermlike(const char *term) { static const struct { - const char *desc; - unsigned len; + const char *name; + TAttributes_t flags; } xtermlike[] = { -#define XTERMLIKE(x) { x, sizeof(x)-1 } - XTERMLIKE("xterm"), /* generic */ - XTERMLIKE("aixterm"), /* AIX */ - XTERMLIKE("mintty"), /* non-standard. normally "xterm-256color" */ - XTERMLIKE("rxvt"), - XTERMLIKE("urxvt"), /* Unicode rxvt */ - XTERMLIKE("Eterm"), - XTERMLIKE("gnome"), /* gnome-terminal */ - XTERMLIKE("dtterm"), /* CDE terminal */ - XTERMLIKE("cygwin") /* Cygwin console */ + { "xterm", TA_XTERM }, /* Generic */ + { "mintty", TA_MINTTY }, /* Non-standard. normally "xterm-256color" */ + { "putty", TA_PUTTY | TA_DARK }, + { "msterminal", TA_MSTERMINAL | TA_DARK }, + { "gnome", TA_GNOME }, + { "vte", TA_GNOME }, + { "xterm-kitty", TA_KITTY }, + { "alacritty", TA_ALACRITTY }, + { "iterm", TA_ITERM }, + { "iterm2", TA_ITERM }, + { "iTerm.app", TA_ITERM }, + { "iTerm2.app", TA_ITERM }, + { "hterm", TA_HTERM }, + { "wezterm", TA_WEZTERM }, + { "aixterm" }, /* AIX */ + { "rxvt" }, /* [ou]r xvt */ + { "urxvt" }, /* Unicode rxvt */ + { "Eterm" }, /* Color vt102 terminal emulator */ + { "dtterm" } /* CDE terminal */ }; -#undef XTERMLIKE - int ret = 0; + TAttributes_t ret = 0; if (term) { unsigned i; - if (x_pt.pt_xtcompat >= 0) { - ret = x_pt.pt_xtcompat; /* feature override */ - } else { - for (i = 0; i < (unsigned)(sizeof(xtermlike)/sizeof(xtermlike[0])); ++i) - if (0 == strncmp(term, xtermlike[i].desc, xtermlike[i].len) && - ('\0' == term[xtermlike[i].len] || '-' == term[xtermlike[i].len])) { - /* - * for example, - * xterm-color - */ - ret = 1; - break; - } - } + for (i = 0; i < (unsigned)(sizeof(xtermlike)/sizeof(xtermlike[0])); ++i) + if (tty_isterm(term, xtermlike[i].name)) { + ret = xtermlike[i].flags | TA_XTERMLIKE; + break; + } } - trace_log("\txtermlike(%s) : %d\n", (term ? term : ""), ret); + + trace_log("\txtermlike(%s) : 0x%lx\n", (term ? term : ""), (unsigned long)ret); x_pt.pt_xtcompat = ret; return ret; } @@ -2522,11 +2933,11 @@ term_colors(void) } else if (x_pt.pt_color /*-1 or 1*/) { if (t_attributes & TA_XTERMLIKE) { - tt_colors = ANSI_COLORS; + tt_colors = XTERM_COLORS; } else if (0 == (tt_colors = tf_Colors)) { if (tc_ANSI_Color_Fg && tc_ANSI_Color_Bg) { - tt_colors = 16; + tt_colors = ANSI_COLORS; } else if (tc_Color_Fg && tc_Color_Bg) { tt_colors = 8; } else { @@ -2534,6 +2945,7 @@ term_colors(void) } } } + x_pt.pt_colorrgb = (tt_colors >= 256 && tn_RGB > 0 ? 1 : 0); /* configure colors */ assert((COLOR_NONE + 1) == (sizeof(tt_colormap)/sizeof(tt_colormap[0]))); @@ -2667,16 +3079,18 @@ fgbg_value(const char *src, int *result) if (0 == strncmp(src, "default", 7)) { end = src + 7; /* special case */ + } else { - char *endp = 0; + char *endp = NULL; int value = (int) strtol(src, &endp, 0); - if (0 == endp) { + if (NULL == endp) { end = src; } else if (value >= 0 && value <= 255) { *result = (unsigned) value; end = endp; } + while (*end && *end != ';') { ++end; } @@ -2771,8 +3185,8 @@ xterm_colors_get(char *buffer, int length) */ int cnt = sprintf((char *)t_buffer, "\033]4;%d;?\007", color); - if (cnt != sys_write(1, t_buffer, cnt) || - (cnt = term_read((char *)t_buffer, sizeof(t_buffer), 5 * 1000)) <= 0 || + if (cnt != tty_write(t_buffer, cnt) || + (cnt = tty_read((char *)t_buffer, sizeof(t_buffer), 5 * 1000)) <= 0 || sscanf((char *)t_buffer, "%*[^;];%*[^;];%s", buffer + len + (len ? 1 : 0)) != 1) { /* * Note, 'rxvt' and the 'linux console' only support set. @@ -2836,116 +3250,168 @@ xterm_colors_set(const char *value) } cnt += sprintf((char *)(t_buffer + cnt), "\007"); - sys_write(1, t_buffer, cnt); /* terminator */ + sys_write(TTY_OUTFD, t_buffer, cnt); /* terminator */ return 0; } +/* Function: term_attributes + * Request the terminal (VT100 and xterm style) to echo the "DA1 - Primary Device Attributes" + * report containing terminal terminal's architectural class and basic attributes. + * + * Send an extended query, test to see if it supports Kitty's keyboard protocol. + * + * DA1 - Primary Device Attributes + * In this DA exchange, the host asks for the terminal's architectural class and basic attributes. + * + * Host Request: + * The host uses the following sequence to send this request: + * + * CSI c or CSI 0 c + * 9/11 6/3 9/11 0 6/3 + * + * Terminal Response: + * The terminal responds by sending its architectural class and basic attributes to the host. This response depends on the terminal's current operating VT level. + * + * CSI ? 6 4 ; Ps1 ... + * 9/11 3/15 3/6 3/4 3/11 3/n .. + * + * Parameters: + * none. + * + * Returns: + * x_pt.pt_attributes update if suitable. + */ +static void +term_attributes(void) +{ + if ((TA_KITTY|TA_ALACRITTY|TA_WEZTERM) & t_attributes) { + static char xterm_da1x_cmd[] = "\033[?u\033[c"; +#define XTERM_DA1X (sizeof(xterm_da1x_cmd)-1) + // + // Extended DA1 request. + // + // Progressive enhancement key events: + // + // An application can query the terminal for support of this protocol by sending the escape code + // querying for the current progressive enhancement status followed by request for the primary + // device attributes . + // + // CSI ? flags u + // + // Reply with: + // + // CSI ? flags u + // + // If an answer for the device attributes is received without getting back an answer for the + // progressive enhancement the terminal does not support this protocol. + // + // Terminals: kitty, foot, WezTerm, alacritty, rio, crossterm + // + char buffer[64] = {0}; + int len = 0; + + term_flush(); + if (XTERM_DA1X == tty_write(xterm_da1x_cmd, XTERM_DA1X) && + (len = tty_read(buffer, sizeof(buffer), -2)) > 1) { + char *cursor = buffer; + + trace_ilog("term_da1x(%d, %s)\n", len, buffer); + if ('\033' == cursor[0] && '[' == cursor[1] && cursor[2] == '?' && cursor[3]) { + if (cursor[4] == 'u') { + x_pt.pt_attributes |= TF_AKITTYKEYS; + trace_ilog("\t==> kitty-keys\n"); + + } else { + trace_ilog("\t==> da1 response\n"); + } + } + } + } + + if (0 == (t_attributes & TA_KITTY)) { + const char *vte_version_env = ggetenv("VTE_VERSION"); + int vte_version = vte_version_env ? (int)strtol(vte_version_env, NULL, 10) : 0; + + trace_ilog("term_vte_version=%d\n", vte_version); + if (vte_version == 0 || vte_version >= 5400) { + x_pt.pt_attributes |= TF_AXTERMKEYS;/* xterm modifyOtherKeys */ + } + } +} + + /* Function: term_identification - * Request the terminal (VT100 and xterm style) to echo the "Device Attributes" + * Request the terminal (VT100 and xterm style) to echo the "DA2 - Secondary Device Attributes" * report containing terminal type and version. * * Parameters: * none. * * Returns: - * Length of the buffer retrieved. + * x_pt.pt_vtdatype and vtdaversion upon details being available. */ -static int +static void term_identification(void) { -#define XTERM_DEVICE_ATTR (sizeof(xterm_device_attr)-1) - static char xterm_device_attr[] = "\033[>c"; - int ret = -1; - #if defined(__CYGWIN__) + /* + * CYGWIN version + */ if (TA_CYGWIN & t_attributes) { - /* - * CYGWIN - */ struct utsname u = {0}; int r1 = 0, r2 = 0; - ret = -3; if (uname(&u) >= 0) { if (2 == sscanf(u.release, "%d.%d", &r1, &r2)) { - x_pt.pt_vtdatype = -3; /* source: xterm_cygwin */ + x_pt.pt_vtdatype = -3; /* source: xterm_cygwin */ x_pt.pt_vtdaversion = (r1 * 100) + (r2 > 99 ? 99 : r2); } trace_ilog("\tcygwin_uname(%s) = %d.%d\n", u.release, r1, r2); } - return ret; } -#endif /*__CYGWIN__*/ +#endif - if ((TA_VT100LIKE|TA_XTERM|TA_XTERMLIKE) & t_attributes) { - /* - * xterm and compatible terminals - */ - const char *vstring; + /* + * xterm and compatible terminals + */ + if (tc_RV || ((TA_VT100LIKE|TA_XTERM|TA_XTERMLIKE) & t_attributes)) { + tty_identification(tc_RV, io_escdelay()); + } +} - /* - * XTERM_VERSION/ - * Xterm(256) ==> 256 - */ - if (NULL != (vstring = ggetenv("XTERM_VERSION"))) { - char vname[32+1] = {0}; - int vnumber = 0; - /* decode and return patch/version number */ - if (2 == sscanf(vstring, "%32[^(](%u)", vname, &vnumber)) - if (vnumber > 0) { - x_pt.pt_vtdatype = -2; /* source: xterm_version */ - x_pt.pt_vtdaversion = vnumber; - ret = 0; - } - trace_ilog("XTERM_VERSION(%s) = %d (%s)\n", vstring, vnumber, vname); - } - /* - * device attribute - */ - if (-1 == ret) { - char buffer[32] = {0}; - int len = 0; +/* Function: term_luminance + * Request the terminals foreground or background RGB color. + * + * Parameters: + * none + * + * Returns: + * 0 on success, otherwise -1 if not available. + */ +static int +term_luminance(void) +{ + int ret; - term_flush(); - if (XTERM_DEVICE_ATTR == sys_write(1, xterm_device_attr, XTERM_DEVICE_ATTR) && - (len = term_read(buffer, sizeof(buffer), -2)) > 1) { - /* - * Example/ - * \033[>82;20710;0c - * ^type - * ^version - * - * Known terminal types/ - * xterm (0) 0;256;0c - * mintty (77) 77;10003;0c - * screen (83) - * old rxvt (82) - * rxvt unicode (85) - */ - trace_ilog("device_attr(%d, %s)\n", len, buffer); - - if ('\033' == buffer[0] && '[' == buffer[1] && - ('>' == buffer[2] || '?' == buffer[2])) { - int datype, daversion; - - if (2 == sscanf(buffer + 3, "%d;%d", &datype, &daversion)) { - trace_ilog("==> type:%d, version:%d\n", datype, daversion); - x_pt.pt_vtdatype = datype; - x_pt.pt_vtdaversion = daversion; - if (77 == datype) { - t_attributes |= TA_MINTTY; - ++tf_xn; - } - ret = 0; - } - } - } - } + if (!tf_XT && 0 == ((TA_XTERM|TA_XTERMLIKE) & t_attributes)) { + trace_ilog("ttluminance : not supported\n"); + return -1; /* supported? */ } - return ret; + term_flush(); + if ((ret = tty_luminance(io_escdelay())) < 0) { + return -1; + } + + t_attributes &= ~(TA_LUMINANCE_DARK|TA_LUMINANCE_LIGHT); + if (ret) { + t_attributes |= TA_LUMINANCE_DARK; + } else { + t_attributes |= TA_LUMINANCE_LIGHT; + } + return 0; } @@ -3005,19 +3471,19 @@ term_isutf8(void) ret = -5; term_flush(); - if (XTERM_UTF8_TEST1 == sys_write(1, (void *)xterm_utf8_test1, XTERM_UTF8_TEST1)) { + if (XTERM_UTF8_TEST1 == tty_write((void *)xterm_utf8_test1, XTERM_UTF8_TEST1)) { int row = -1, col = -1; char buffer[32] = {0}; int len; - if ((len = term_read(buffer, sizeof(buffer), -2)) >= 4 && + if ((len = tty_read(buffer, sizeof(buffer), -2)) >= 4 && 2 == sscanf(buffer, "\033[%d;%dR", &row, &col)) { if (2 == col) { ret = 5; /* cursor in second column */ } } trace_ilog("\tisutf8A(%d) = col:%d\n", len, col); - sys_write(1, (void *)xterm_utf8_clean1, XTERM_UTF8_CLEAN1); + sys_write(TTY_OUTFD, (void *)xterm_utf8_clean1, XTERM_UTF8_CLEAN1); } } @@ -3027,93 +3493,6 @@ term_isutf8(void) } -#if (XXX_MCHAR_DETECT) -static void -term_utf8_features(void) -{ -#define XTERM_UTF8_TEST2 (sizeof(xterm_utf8_test2)-1) - - static unsigned char xterm_utf8_test2[] = { - '\r', /* UTF* features */ - 0xa5, - 0xc3, 0x84, 0xd9, - 0xa7, - 0xd8, 0xb8, 0xe0, 0xe0, - 0xa9, - 0xa9, - 0xb8, 0x88, 0xe5, 0xe5, 0x88, - 0xa2, 0xa2, - 0x1b, '[', '6', 'n', /* cursor position */ - 0x00 /* NUL */ - }; - - term_flush(); - - if (XTERM_UTF8_TEST2 == sys_write(1, xterm_utf8_test2, XTERM_UTF8_TEST2)) { - int row = -1, col = -1; - char buffer[32] = {0}; - int len; - - /* - * check cursor column after test string, determine screen mode - * - * 6 -> UTF-8, no double-width, with LAM/ALEF ligature joining - * 7 -> UTF-8, no double-width, no LAM/ALEF ligature joining - * 8 -> UTF-8, double-width, with LAM/ALEF ligature joining - * 9 -> UTF-8, double-width, no LAM/ALEF ligature joining - * 11,16 -> CJK terminal (with luit) - * 10,15 -> 8 bit terminal or CJK terminal - * 13 -> Poderosa terminal emulator, UTF-8, or TIS620 terminal - * 14,17 -> CJK terminal - * 16 -> Poderosa, ISO Latin-1 - * (17) -> Poderosa, (JIS) - * 18 -> CJK terminal (or 8 bit terminal, e.g. Linux console) - */ - if ((len = term_read(buffer, sizeof(buffer), -2)) >= 4) { - sscanf(buffer, "\033[%d;%dR", &row, &col); - } - - trace_ilog("\tisutf8B(%d) = col:%d\n", len, col); - } -} -#endif /*XXX_MCHAR_DETECT*/ - - -/* Function: term_read - * Determine if the terminal supports UTF8 character encoding. - * - * Parameters: - * buf - Buffer. - * len - Length of the buffer, in bytes. - * tmo - Timeout is milliseconds. - * - * Returns: - * Number of bytes read. - */ -static int -term_read(char *buf, int len, accint_t tmo) -{ - int ch, cnt = 0; - - if (-2 == tmo) { - tmo = io_escdelay(); - } - - assert(buf); - assert(len); - assert(tmo >= -1); - - --len; - if ((ch = io_get_raw(tmo)) > 0) { - do { /* secondary characters */ - buf[cnt++] = (char) ch; - } while ((ch = io_get_raw(50)) > 0 && cnt < len); - } - buf[cnt] = '\0'; - return cnt; -} - - /* Function: term_tidy * Cleanup/restore the state of the console. * @@ -3131,26 +3510,14 @@ term_tidy(void) term_flush(); - if (t_attributes & TA_CYGWIN) { - if (xf_cygwinkb) { - ttpush("\033[?2000l"); /* disable RAW mode */ - } - } else if (t_attributes & TA_MINTTY) { - if (xf_mouse) { /* mouse enabled? */ - ttpush("\033[?7786l"); /* disable mouse-wheel reports */ - } - } - term_graphic_exit(); /* graphic mode */ term_colorreset(); term_styleoff(); xterm_colors_set(t_colorsorg); - - /* ttputpad(tc_mo); -* restore meta key-codes */ - ttputpad(tc_ve); /* restore normal cursor */ + key_disable(); /* restore keyboard mode */ if (! xf_nokeypad) { ttputpad(tc_ke); /* out of ``keypad-transmit'' mode */ } @@ -3194,6 +3561,7 @@ term_tidy(void) */ static int term_cursor(int visible, int imode, int virtual_space) + { if (visible >= 0) { if (visible != tt_cursor) @@ -3279,7 +3647,7 @@ term_move(int row, int col) if (1 != tf_ms) if (tt_style) { term_styleoff(); - tt_hue = -1; + tt_hue = (vbyte_t)-1; } if (tc_ho && 0 == col && 0 == row) { /* */ @@ -3372,11 +3740,11 @@ term_move(int row, int col) while (p1-- > 0) ttputpad(tc_bc); /* cursor left - parameterised */ - } else if (tc_pBC && col < (ttcol - 2)) { + } else if (tc_pLE && col < (ttcol - 2)) { const int p1 = (int)(ttcol - col); - ED_TERM(("->putctl(pBC,%d)\n", p1)) - ttputctl(tc_pBC, p1); + ED_TERM(("->putctl(pLE,%d)\n", p1)) + ttputctl(tc_pLE, p1); /* cursor right - one column */ } else if (tc_nd && col == ttcol + 1) { @@ -3638,6 +4006,7 @@ term_eeol(void) ED_TERM(("->putpad(CE)\n")) ttputpad(tc_ce); + /* * Character based * Avoid writing to the lower right corner; as the terminal does not have CE, @@ -3888,6 +4257,7 @@ term_insl(int row, int bot, int nlines, vbyte_t fillcolor) if (tc_cs && tc_sr && !x_pt.pt_scroll_disable) { term_scrollset(row, bot); ttmove(row, 0); + term_attr(VBYTE_ATTR(ATTR_NORMAL)); if (nlines > 1 && tc_pSR) { ttputctl(tc_pSR, nlines); } else { @@ -3902,6 +4272,7 @@ term_insl(int row, int bot, int nlines, vbyte_t fillcolor) if (t_insdel && !x_pt.pt_noinsdel) { /* line ins/del */ ttmove(1 + bot - nlines, 0); + term_attr(VBYTE_ATTR(ATTR_NORMAL)); if (nlines > 1 && tc_pDL) { ttputctl(tc_pDL, nlines); } else { @@ -3977,6 +4348,7 @@ term_dell(int row, int bot, int nlines, vbyte_t fillcolor) if (tc_cs && !x_pt.pt_scroll_disable && /* scrolling region and within limits */ (x_pt.pt_scroll_max <= 2 || (bot - row) <= x_pt.pt_scroll_max)) { term_scrollset(row, bot); + term_attr(VBYTE_ATTR(ATTR_NORMAL)); ttmove(bot, 0); if (nlines > 1 && tc_pSF) { ttputctl(tc_pSF, nlines); /* 24/11/08 */ @@ -3992,6 +4364,7 @@ term_dell(int row, int bot, int nlines, vbyte_t fillcolor) /* ins/del, unless disabled or fast */ if (t_insdel && !x_pt.pt_noinsdel && x_pt.pt_tty_fast <= 0) { ttmove(row, 0); + term_attr(VBYTE_ATTR(ATTR_NORMAL)); if (nlines > 1 && tc_pDL) { ttputctl(tc_pDL, nlines); } else { @@ -4122,6 +4495,7 @@ term_attr(vbyte_t color) } } else { + const char *reset = (tc_me ? tc_me : "\033[0m"); colattr_t ca = {0}; int fg, bg, sf; @@ -4136,15 +4510,23 @@ term_attr(vbyte_t color) /* 256 color mode * * \033[0m Set normal (foreground, background and styles) - * \033[39m Normal foreground color. - * \033[49m Normal background color. + * \033[39m Default foreground color (Implementation defined) + * \033[49m Default background color (Implementation defined) + * + * SGR 38 and 48/ + * * \033[38;5;#m Set the foreground color to index # * \033[48;5;#m Set the background color to index # + * + * 0-7: Standard colors (as in "ESC [ 30-37 m") + * 8-15: High intensity colors (as in "ESC [ 90-97 m") + * 16-231: 6x6x6 cube (216 colors) + * 232-255: Grayscale from dark to light in 24 steps. */ if (COLORSOURCE_SYMBOLIC == ca.fg.source) fg = tt_colormap[fg]; if (COLORSOURCE_SYMBOLIC == ca.bg.source) bg = tt_colormap[bg]; - ED_TERM(("->map(fg:%d, bg:%d)", fg, bg)) + ED_TERM(("->map256(fg:%d, bg:%d)", fg, bg)) if (fg != tt_fg || bg != tt_bg || sf != tt_style) { char ebuf[64]; @@ -4191,17 +4573,19 @@ term_attr(vbyte_t color) ttputpad(ebuf); } else { /* normal */ - sxprintf(ebuf, sizeof(ebuf), "\033[0m"); - ttputpad(tc_me ? tc_me : "\033[0m"); + ttputpad(reset); } if (sf) term_styleon(sf); } - } else if (tt_colors > 8 || NULL == tc_Color_Bg || NULL == tc_Color_Fg) { + } else if ((tt_colors >= 16 && tc_ANSI_Color_Fg) || + (NULL == tc_Color_Fg && NULL == tc_ANSI_Color_Fg)) { /* 16 color mode (standard - ANSI) * * \033[0m Set normal (foreground and background) + * \033[39m Default foreground color (Implementation defined) + * \033[49m Default background color (Implementation defined) * * \033[30m Set foreground color to Black * \033[31m Set foreground color to Red @@ -4211,7 +4595,7 @@ term_attr(vbyte_t color) * \033[35m Set foreground color to Magenta * \033[36m Set foreground color to Cyan * \033[37m Set foreground color to White - * \033[1;%dm Set foreground color (bright, 30 .. 37) + * \033[38;5;%dm Set foreground color (0 .. 15) * * \033[40m Set background color to Black * \033[41m Set background color to Red @@ -4221,12 +4605,8 @@ term_attr(vbyte_t color) * \033[45m Set background color to Magenta * \033[46m Set background color to Cyan * \033[47m Set background color to White - * \033[5;%dm Set background color (bright, 40 -- 47) - * + * \033[48;5;%dm Set background color (0 .. 15) */ - char ebuf[48] = "\033["; /* leading */ - int l = 2; - if (COLORSOURCE_SYMBOLIC == ca.fg.source) fg = tt_colormap[fg]; if (COLORSOURCE_SYMBOLIC == ca.bg.source) bg = tt_colormap[bg]; if (fg == bg && bg >= 0) { @@ -4239,54 +4619,55 @@ term_attr(vbyte_t color) } } - /* do we need/can reset to normal */ - if (fg < 0 || bg < 0) { - strcpy(ebuf+l, "0;"); /* normal */ - tt_fg = (fg < 0 ? fg : NOCOLOR); - tt_bg = (bg < 0 ? bg : NOCOLOR); - tt_style = 0; - l += 2; + ED_TERM(("->map16(fg:%d, bg:%d)", fg, bg)) - } else { - if ((NOCOLOR == tt_fg) || - (!(bg & 0x8) && (tt_bg & 0x8)) || (!(fg & 0x8) && (tt_fg & 0x8)) || - (tt_defaultfg == fg && fg != tt_fg) || (tt_defaultbg == bg && bg != tt_bg)) { - strcpy(ebuf+l, "0;"); /* normal */ - tt_fg = (tt_defaultfg == fg ? fg : NOCOLOR); - tt_bg = (tt_defaultbg == bg ? bg : NOCOLOR); - tt_style = 0; - l += 2; + if (fg != tt_fg || bg != tt_bg || sf != tt_style) { + char ebuf[64]; + int l = 0; + + if (tt_style) { + if (tc_me) reset = ""; + term_styleoff(); } - } - if (tt_style != sf && tt_style) { - term_styleoff(); - } + if (fg > 0 && bg > 0) { /* foreground (30-37,38+), background (40-47,48+) */ + if (fg > 7) { + l = sprintf(ebuf, "\033[38;5;%u;", fg & 0xff); + } else { + l = sprintf(ebuf, "\033[%u;", 30 + (fg & 7)); + } + if (bg > 7) { + l += sprintf(ebuf+l, "48;5;%um", bg & 0xff); + } else { + l += sprintf(ebuf+l, "%um", 40 + (bg & 7)); + } + ttputpad(ebuf); - /* color selection */ - if (fg != tt_fg) { /* foreground 30 - 37 */ - l += sprintf(ebuf+l, (fg & 8) ? "1;%u" : "%u", 30 + (fg & 7)); - } + } else if (fg > 0) { /* normal + foreground (30-37,38+) */ + if (fg > 7) { + l = sprintf(ebuf, "%s\033[38;5;%um", reset, fg & 0xff); + } else { + l = sprintf(ebuf, "%s\033[%um", reset, 30 + (fg & 7)); + } + ttputpad(ebuf); - if (bg != tt_bg) { /* background 40 - 47 */ - if (l > 2) { - ebuf[l++] = ';'; - } - l += sprintf(ebuf+l, (bg & 8) ? "5;%u" : "%u", 40 + (bg & 7)); - } + } else if (bg > 0) { /* normal + background (40-47,48+) */ + if (bg > 7) { + l = sprintf(ebuf, "%s\033[48;5;%um", reset, bg & 0xff); + } else { + l = sprintf(ebuf, "%s\033[%um", reset, 40 + (bg & 7)); + } + ttputpad(ebuf); - if (l > 2) { /* flush result */ - ebuf[l++] = 'm'; - ebuf[l++] = 0; - assert(l < (int)sizeof(ebuf)); - ttputpad(ebuf); - } + } else if (*reset) { /* normal */ + ttputpad(reset); + } + assert(l < sizeof(ebuf)); - if (tt_style != sf) { - term_styleon(sf); /* style changes */ + if (sf) term_styleon(sf); } - } else if (tc_Color_Fg == tc_ANSI_Color_Fg) { + } else if (tc_ANSI_Color_Fg) { /* * ANSI - 16+8 color mode */ @@ -4302,33 +4683,34 @@ term_attr(vbyte_t color) } } - if (fg < 0 || bg < 0) { - ttputpad(tc_me ? tc_me : "\033[0m"); - tt_fg = (fg < 0 ? fg : NOCOLOR); - tt_bg = (bg < 0 ? bg : NOCOLOR); - tt_style = 0; - } + ED_TERM(("->mapansi(fg:%d, bg:%d)", fg, bg)) - if (tt_style != sf && tt_style) { - term_styleoff(); - } + if (fg != tt_fg || bg != tt_bg || sf != tt_style) { + if (tt_style) { + if (tc_me) reset = NULL; + term_styleoff(); + } - if (fg != tt_fg) { - ttputpad((fg & 0x8) ? tc_md : tc_se); - ttputctl(tc_Color_Fg, (fg & 7)); - } + if (reset && (fg <= 0 || bg <= 0)) { + ttputpad(reset); /* normal */ + } - if (bg != tt_bg) { - ttputctl(tc_Color_Bg, (bg & 7)); - } + if (fg > 0) { /* foreground */ + if (tt_colors == 8) ttputpad((fg & 0x8) ? tc_md : tc_se); + ttputctl(tc_ANSI_Color_Fg, fg); + } - if (tt_style != sf) { - term_styleon(sf); /* style changes */ + if (bg > 0) { /* background */ + ttputctl(tc_ANSI_Color_Bg, bg & 7); + } + + if (sf) term_styleon(sf); } } else { /* * PC - 16+8 color mode + * Note: assumes alternative color mapping. */ if (COLORSOURCE_SYMBOLIC == ca.fg.source) fg = color_map[fg].c16_pc; if (COLORSOURCE_SYMBOLIC == ca.bg.source) bg = color_map[bg].c16_pc; @@ -4342,28 +4724,28 @@ term_attr(vbyte_t color) } } - if (fg < 0 || bg < 0) { - ttputpad(tc_me ? tc_me : "\033[0m"); - tt_fg = (fg < 0 ? fg : NOCOLOR); - tt_bg = (bg < 0 ? bg : NOCOLOR); - tt_style = 0; - } + ED_TERM(("->mappc(fg:%d, bg:%d)", fg, bg)) - if (tt_style != sf && tt_style) { - term_styleoff(); - } + if (fg != tt_fg || bg != tt_bg || sf != tt_style) { + if (tt_style) { + if (tc_me) reset = NULL; + term_styleoff(); + } - if (fg != tt_fg) { - ttputpad((fg & 0x8) ? tc_md : tc_se); - ttputctl(tc_Color_Fg, fg & 7); - } + if (reset && (fg <= 0 || bg <= 0)) { + ttputpad(reset); /* normal */ + } - if (bg != tt_bg) { - ttputctl(tc_Color_Bg, bg & 7); - } + if (fg > 0) { /* foreground */ + if (tt_colors == 8) ttputpad((fg & 0x8) ? tc_md : tc_se); + ttputctl(tc_Color_Fg, fg); + } + + if (bg > 0) { /* background */ + ttputctl(tc_Color_Bg, bg & 7); + } - if (tt_style != sf) { - term_styleon(sf); /* style changes */ + if (sf) term_styleon(sf); } } @@ -4554,6 +4936,7 @@ putpadch(TPUTS_OUTTYPE ch) } if (t_count >= sizeof(t_buffer)) { panic("ttputpad buffer overflow."); + return -1; } t_buffer[ t_count++ ] = (unsigned char)ch; return 0; @@ -4960,6 +5343,7 @@ term_flush(void) * Retrieve the display screen. * * Parameters: + * nrow - Storage for row number. * ncol - Number of columns. * diff --git a/gr/ttyutil.c b/gr/ttyutil.c new file mode 100644 index 00000000..f29e09ed --- /dev/null +++ b/gr/ttyutil.c @@ -0,0 +1,512 @@ +#include +__CIDENT_RCSID(gr_ttyutil_c,"$Id: ttyutil.c,v 1.12 2024/09/24 12:54:15 cvsuser Exp $") + +/* -*- mode: c; indent-width: 4; -*- */ +/* $Id: ttyutil.c,v 1.12 2024/09/24 12:54:15 cvsuser Exp $ + * TTY common utility functions + * + * + * This file is part of the GRIEF Editor. + * + * The GRIEF Editor is free software: you can redistribute it + * and/or modify it under the terms of the GRIEF Editor License. + * + * The GRIEF Editor is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * License for more details. + * ==end== + */ + +#include + +#include "ttyutil.h" + +#if !defined(USE_VIO_BUFFER) && !defined(DJGPP) + +#include +#include + +#include "debug.h" /* trace ... */ +#include "mouse.h" +#include "system.h" +#include "tty.h" + + +/* + * tty_mouse_xterm --- + * Parse a xterm (X10 compatibility mode) mouse encoded event. + * + * Parameters: + * me - Optional event structure if be populated; assumed zero initialised. + * seq - Mouse message sequence. + * + * Returns: + * Returns the positive value MOUSE_XTERM_KEY on success and populates 'me', + * 0 when additional data is required, otherwise -1 if not a recognised message. + * + * Notes: + * + * Normal tracking mode sends an escape sequence on both button press and + * release. Modifier key (shift, ctrl, meta) information is also sent. It + * is enabled by specifying parameter 1000 to DECSET. + * + * On button press or release, xterm sends CSI M Cb Cx Cy . + * + * o The low two bits of C b encode button information: + * + * 0=MB1 pressed, + * 1=MB2 pressed, + * 2=MB3 pressed, + * 3=release. + * + * o The next three bits encode the modifiers which were down when the + * button was pressed and are added together: + * + * 4=Shift, 8=Meta, 16=Control. + * + * Note however that the shift and control bits are normally unavailable + * because xterm uses the control modifier with mouse for popup menus, and + * the shift modifier is used in the default translations for button events. + * The Meta modifier recognized by xterm is the mod1 mask, and is not + * necessarily the "Meta" key (see xmodmap). + * + * o C x and C y are the x and y coordinates of the mouse event, encoded as + * in X10 mode. x = (Cx - 33), y = (Cy - 33) + * + * Wheel mice may return buttons 4 and 5. Those buttons are represented by + * the same event codes as buttons 1 and 2 respectively, except that 64 is + * added to the event code. Release events for the wheel buttons are not + * reported. By default, the wheel mouse events are translated to scroll-back + * and scroll-forw actions. Those actions normally scroll the whole window, + * as if the scrollbar was used. However if Alternate Scroll mode is set, + * then cursor up/down controls are sent when the terminal is displaying the + * alternate screen. + * + * Notes: + * mintty for example may return x/y values of 224, which is (224 + 32) == 256/0x100 + * yet as this value as an 8-bit 0x00 causes issues as NUL's cannot be represented + * within the buffer. + */ +int +tty_mouse_xterm(struct MouseEvent *me, const void *seq) +{ + const unsigned char *cursor = (unsigned char *)seq; + unsigned arguments[3] = {0}, nargs = 0; + + // + // \x1B[Mabc", where: + // a: Button number plus 32. + // b: Column number (one-based) plus 32. + // c: Row number (one-based) plus 32. + // + if (cursor[0] != 0x1b || cursor[1] != '[' || cursor[2] != 'M') { + return -1; // CSI + } + trace_ilog("\tXTERM: \x1b[M%s\n", cursor + 3); + + // parameters + for (cursor += 3; *cursor && *cursor >= ' ' && nargs < 3;) { + arguments[nargs++] = *cursor++; + } + + // decode + if (3 == nargs) { + if (NULL != me) { // key_to_int usage + const unsigned button = arguments[0]; + + if (0x60 == (0x60 & button)) { // 0110 000x + me->type = MOUSEEVENT_TWHEELED; + me->b1 = (button & 0x1) ? 0 : 1; + + } else { + me->type = ((button & 64) ? MOUSEEVENT_TMOTION : 0); // 1002 mode + switch (button & 0x3) { // 0000 00xx + case 0: // button-1 + me->b1 = 1; + break; + case 1: // button-2 + me->b2 = 1; + break; + case 2: // button-3 + me->b3 = 1; + break; + case 3: // release-all + me->type = MOUSEEVENT_TRELEASE_ALL; + break; + } + me->multi = -1; + } + + me->ctrl = // 000x xx00 + (-!!(button & 16) & MOUSEEVENT_CCTRL) | + (-!!(button & 8) & MOUSEEVENT_CMETA) | + (-!!(button & 4) & MOUSEEVENT_CSHIFT); + me->x = (int)(arguments[1] - 32); // + 1; + me->y = (int)(arguments[2] - 32); // + 1; + } + return MOUSE_XTERM_KEY; + } + return 0; +} + + +/* + * tty_mouse_sgr --- + * Parse a SGR mouse encoded event. + * + * Parameters: + * me - Optional event structure if be populated; assumed zero initialised. + * seq - Mouse message sequence. + * + * Returns: + * Returns the positive value MOUSE_SGR_KEY on success and populates 'me', + * 0 when additional data is required, otherwise -1 if not a recognised message. + */ +int +tty_mouse_sgr(struct MouseEvent *me, const void *seq) +{ + const unsigned char *cursor = (unsigned char *)seq; + unsigned arguments[3] = {0}, args = 0, digits = 0; + int function = 0; + + // + // \x1B[= '0' && c <= '9') { + if (0 == digits++) { + if (args > 3) { + break; // overflow + } + arguments[args] = (c - '0'); + } else { + arguments[args] = (arguments[args] * 10) + (c - '0'); + } + } else if (c == ';' || c == 'M' || c == 'm') { + trace_ilog("\tsgr[%d]=%u\n", args, arguments[args]); + digits = 0; + ++args; + if (c != ';') { + function = c; + break; // terminator + } + } + } + + // decode + if (args >= 3) { + if (NULL != me) { // key_to_int usage + const unsigned button = arguments[0]; + + if (button & 64) { + me->type = MOUSEEVENT_TWHEELED; + me->b1 = (button & 0x1) ? 0 : 1; + + } else { + me->type = ((button & 64) ? MOUSEEVENT_TMOTION : 0); // 1002 mode + me->type |= (function == 'M' ? MOUSEEVENT_TPRESS : MOUSEEVENT_TRELEASE); + switch (button & 0x3) { + case 0: // button-1 + me->b1 = 1; + break; + case 1: // button-2 + me->b2 = 1; + break; + case 2: // button-3 + me->b3 = 1; + break; + case 3: + assert(0); + break; + } + me->multi = -1; + } + me->ctrl = + (-!!(button & 16) & MOUSEEVENT_CCTRL) | + (-!!(button & 8) & MOUSEEVENT_CMETA) | + (-!!(button & 4) & MOUSEEVENT_CSHIFT); + me->x = (int)(arguments[1]); + me->y = (int)(arguments[2]); + } + return MOUSE_SGR_KEY; + } + return 0; +} + + + +/* + * tty_isterm --- + * Determine whether the terminal-name has the specified prefix. + * + * Parameters: + * term - TERM or BTERM value. + * name - Terminal name/prefix. + */ +int +tty_isterm(const char *term, const char *name) +{ + const size_t tlen = (size_t)strlen(term); + const size_t nlen = (size_t)strlen(name); + + if (tlen >= nlen) { /* xxxx[\0.-] */ + if (0 == memcmp(term, name, nlen)) { /* dot, allow */ + return (term[nlen] == '\0' || term[nlen] == '-' || term[nlen] == '.'); + } + } + return 0; +} + + + +int +tty_hasfeature(const char *term, const char *what) +{ + const size_t wlen = (size_t)strlen(what); + const char *elm; + + for (elm = strchr(term, '-'); elm; elm = strchr(elm, '-')) { + ++elm; + if (0 == strncmp(elm, what, wlen)) { /* -xxxx[\0-] */ + if (elm[wlen] == '\0' || elm[wlen] == '-') { + return 1; + } + } + } + return 0; +} + + +/* + * tty_csi_parse --- + * Control Sequence Introducer (CSI) parser. + * + * Parameters: + * buffer - Control string buffer. + * buflen - Length of the control buffer. + * maxargs - Maximum arguments; system limit is 16. + * arguments - Numeric arguments. + * params - Parameters, [0]=final, [1]=opening and [2]=intermediate (only one supported). + * pnargs - Optional value, populated with numeric arguments. + * + * Returns: + * Number of bytes consumed, otherwise 0 if additional characters are required or -1 on error. + */ +int +tty_csi_parse(const char *buffer, size_t buflen, + unsigned maxargs, unsigned arguments[], char params[3], unsigned *pnargs) +{ + const char *start = buffer, *end = buffer + buflen, + *cursor = start; + + /* Control Sequence Introducer (CSI) uses two or more bytes to define a specific control function. + * + * CSI P...P I...I F + * + * CSI: Control Sequence Introducer (CSI) + * + * P: Zero or more parameters characters received after CSI; in the range 0x30 -- 0x3F (0-9:;<=>?). + * + * These characters are in the 3/0 to 3/15 range in the code table. Parameter characters modify the action + * or interpretation of the seqence. You can use up to 16 parameters per sequence. + * You must use the ; (3/11) character to separate parameters. + * + * All parameters are unsigned, positive decimal integers, with the most significant digit sent first. + * Any parameter greater than 9999 (decimal) is set to 9999 (decimal). If you do not specify a value, + * a 0 value is assumed. A 0 value or omitted parameter indicates a default value for the sequence. + * For most sequences, the default value is 1. + * + * I: Intermediate (zero or more characters); in the range 0x20 -- 0x2F (' ' and !"#$%&'()*+,-./.). + * + * F: Final (one character); in the range 0x40 -- 0x7F (@A-Z[\]^_`a-z{\}~). + * + * If the first character in a parameter string is the "?") character, it indicates that VT parameters follow. + * All common sequences just use the parameters as a series of semicolon-separated numbers such as 1;2;3. + * + * Note: Parser limits the intermediate characters to zero or two; one leading and one as a parameter. + */ + + // CSI + if (start < end && *start == 0x1b) { // "\x1b[" + if (++start < end && *start == '[') { + ++start; + } + } + + for (cursor = start; cursor < end; ++cursor) { + if (*cursor >= 0x40 && *cursor < 0x80) { + break; // final byte; in the range 0x40-0x7E (@A-Z[\]^_`a-z{\}~) + } + } + + if (cursor >= end) { + return 0; // no terminator; more needed + } + + params[0] = params[1] = params[2] = 0; + + // arguments + { + unsigned digits = 0, nargs = 0; + + end = cursor; + cursor = start; + + if (*cursor >= '<' && *cursor <= '?') { + params[1] = *cursor++; // "<,=,>,?", initial command byte + // eg: "0x1b[?1004h" + } + + while (cursor < end) { + const unsigned char c = *((unsigned char *)cursor); + + if (c >= '0' && c <= '9') { // "0..9", numeric arguments + if (0 == digits++) { + arguments[nargs] = (c - '0'); + } else { + arguments[nargs] = (arguments[nargs] * 10) + (c - '0'); + } + + } else if (c == ';') { // terminator + digits = 0; + if (++nargs > 16 /*limit*/ || nargs > maxargs) { + break; + } + + } else if (c >= 0x20 && c <= 0x2f) { + if (0 == params[2]) { + params[2] = c; // intermediate byte + } else { + return -1; + } + + } else { + return -1; // unexpected + } + + ++cursor; + } + + if (digits) + ++nargs; + + if (pnargs) + *pnargs = nargs; + } + + assert(cursor == end); // terminating, command byte + params[0] = *cursor++; + + return (cursor - buffer); // number of bytes consumed +} + + +/* + * UnitTest's + */ + +#if defined(LOCAL_MAIN) +#if defined(NDEBUG) +#undef NDEBUG +#endif + +#include + +void +trace_ilog(const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + vprintf(fmt, ap); + va_end(ap); +} + + +int +main() +{ + assert(tty_isterm("screen", "screen")); + assert(tty_isterm("screen-xxx", "screen")); + assert(tty_isterm("screen.linux", "screen")); + assert(tty_isterm("screen.linux", "screen.linux")); + assert(! tty_isterm("screen1", "screen")); + assert(! tty_isterm("screen2", "screen")); + assert(tty_hasfeature("screen-rv", "rv")); + assert(tty_hasfeature("screen-rv-xxx", "rv")); + assert(tty_hasfeature("screen-xxx-rv", "rv")); + + { // xterm-mok2 + const char ctrltab[] = "\x1b[27;5;9~"; // Control-TAB + unsigned args[4] = {0}, nargs = sizeof(args)/sizeof(args[0]); + char params[3] = {0}; + int ret; + + ret = tty_csi_parse(ctrltab, sizeof(ctrltab) - 1, nargs, args, params, &nargs); + printf("Control-TAB = %d %u;%u;%u;%u %u\n", ret, args[0], args[1], args[2], args[3], params[0]); + + assert(ret == (sizeof(ctrltab) - 1)); + assert('~' == params[0]); + assert(3 == nargs); + assert(27 == args[0]); + assert(5 == args[1]); + assert(9 == args[2]); + assert(0 == args[3]); + } + + { // mintty-mok2 + const char ctrlp[] = "\x1b[112;5u"; // Control-p + unsigned args[4] = {0}, nargs = sizeof(args)/sizeof(args[0]); + char params[3] = {0}; + int ret; + + ret = tty_csi_parse(ctrlp, sizeof(ctrlp) - 1, nargs, args, params, &nargs); + printf("Control-p = %d %u;%u;%u;%u %u\n", ret, args[0], args[1], args[2], args[3], params[0]); + + assert(ret == (sizeof(ctrlp) - 1)); + assert('u' == params[0]); + assert(2 == nargs); + assert(112 == args[0]); + assert(5 == args[1]); + assert(0 == args[2]); + assert(0 == args[3]); + } + + return 0; +} +#endif + +#else + +int +tty_mouse_xterm(struct MouseEvent* me, const void* seq) +{ + __CUNUSED(me); + __CUNUSED(seq); + return -1; +} + + +int +tty_mouse_sgr(struct MouseEvent* me, const void* seq) +{ + __CUNUSED(me); + __CUNUSED(seq); + return -1; +} + +#endif /*!USE_VIO_BUFFER && !DJGPP*/ + +/*end*/ diff --git a/gr/ttyutil.h b/gr/ttyutil.h new file mode 100644 index 00000000..1fe55e04 --- /dev/null +++ b/gr/ttyutil.h @@ -0,0 +1,49 @@ +#ifndef GR_TTYUTIL_H_INCLUDED +#define GR_TTYUTIL_H_INCLUDED +#include +__CIDENT_RCSID(gr_ttyutil_h,"$Id: ttyutil.h,v 1.4 2024/08/25 06:01:53 cvsuser Exp $") +__CPRAGMA_ONCE + +/* -*- mode: c; indent-width: 4; -*- */ +/* $Id: ttyutil.h,v 1.4 2024/08/25 06:01:53 cvsuser Exp $ + * TTY utility functions + * + * + * This file is part of the GRIEF Editor. + * + * The GRIEF Editor is free software: you can redistribute it + * and/or modify it under the terms of the GRIEF Editor License. + * + * The GRIEF Editor is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * License for more details. + * ==end== + */ + +#include + +__CBEGIN_DECLS + +struct MouseEvent; + +extern int tty_defaultscheme(void); + +extern int tty_identification(const char *rv, int timeoutms); +extern int tty_luminance(int timeoutms); + +extern int tty_write(const void *buffer, int length); +extern int tty_read(void *buffer, int length, int timeoutms); + +extern int tty_mouse_xterm(struct MouseEvent *evt, const void *spec); +extern int tty_mouse_sgr(struct MouseEvent *evt, const void *spec); + +extern int tty_isterm(const char *term, const char *name); +extern int tty_hasfeature(const char *term, const char *what); + +extern int tty_csi_parse(const char *buffer, size_t buflen, + unsigned maxargs, unsigned arguments[], char params[3], unsigned *pnargs); + +__CEND_DECLS + +#endif /*GR_TTYUTIL_H_INCLUDED*/ diff --git a/gr/ttyvio.c b/gr/ttyvio.c index 3a93ef94..582f2a7e 100644 --- a/gr/ttyvio.c +++ b/gr/ttyvio.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_ttyvio_c,"$Id: ttyvio.c,v 1.78 2024/05/20 17:06:25 cvsuser Exp $") +__CIDENT_RCSID(gr_ttyvio_c,"$Id: ttyvio.c,v 1.80 2024/09/20 14:50:06 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: ttyvio.c,v 1.78 2024/05/20 17:06:25 cvsuser Exp $ +/* $Id: ttyvio.c,v 1.80 2024/09/20 14:50:06 cvsuser Exp $ * TTY VIO implementation. * * @@ -272,6 +272,22 @@ ttinit(void) } +/* Function: ttxtermlike + * Retrieve the derived xterm attributes. + * + * Parameters: + * none. + * + * Returns: + * Returns whether the terminal has xterm characteristics. + */ +int +ttxtermlike(void) +{ + return 0; +} + + /* Function: ttdefaultscheme * Retrieve the derived/guessed default background color based on the either * the published terminal background or the terminal type. @@ -611,7 +627,7 @@ vio_image_save(void) origCols = currCols; if (NULL != (screen = chk_calloc(length, 1))) { - rc = VioReadCellStr(screen, &length, 0, 0, 0); + rc = VioReadCellStr(screen, &length, 0, 0, 0); assert(0 == rc); /* image */ origCursor.cb = sizeof(VIOCURSORINFO); @@ -637,7 +653,7 @@ static void vio_image_restore(void) { #if defined(WIN32) - if (origTitle[0]) + if (origTitle[0]) SetConsoleTitleW(origTitle); vio_restore(); @@ -858,7 +874,7 @@ static void term_print(int row, int col, int len, const VCELL_t *vvp) { static VIOCELL null = { 0 }; - + if (len > 0) { const int isuc = (DC_CMAPFRAME & x_display_ctrl) || vtisunicode() || vtisutf8(); VIOCELL *p = currScreen + (row * ttcols()) + col; @@ -876,7 +892,7 @@ term_print(int row, int col, int len, const VCELL_t *vvp) continue; } - if (cattr != attr) { /* attribute change */ + if (cattr != attr) { /* attribute change */ cattr = attr, term_attribute(cattr); } @@ -1340,7 +1356,7 @@ term_hue(int fg, int bg) * nothing */ void -do_ega(void) /* void (int flag) */ +do_ega(void) /* void (int flag) */ { static USHORT orows, ocols, mrows, mcols, state; @@ -1352,12 +1368,12 @@ do_ega(void) /* void (int flag) */ VIOMODEINFO mi = { sizeof(VIOMODEINFO) }; if (flag < 0) { /* min/max toggle (-1), restore (-2) used on exit */ - if (state && (-1 == flag || -2 == flag)) { + if (state && (-1 == flag || -2 == flag)) { if (crows == mrows && ccols == mcols) { mi.row = orows; /* restore, unless modified */ mi.col = ocols; } - state = 0; + state = 0; } else if (0 == state && (-1 == flag || -3 == flag)) { orows = crows; /* maximise */ ocols = ccols; diff --git a/gr/ttywin32.c b/gr/ttywin32.c index 3a130466..b3f82d81 100644 --- a/gr/ttywin32.c +++ b/gr/ttywin32.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_ttywin32_c,"$Id: ttywin32.c,v 1.56 2024/04/14 15:31:10 cvsuser Exp $") +__CIDENT_RCSID(gr_ttywin32_c,"$Id: ttywin32.c,v 1.58 2024/09/20 14:50:06 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: ttywin32.c,v 1.56 2024/04/14 15:31:10 cvsuser Exp $ +/* $Id: ttywin32.c,v 1.58 2024/09/20 14:50:06 cvsuser Exp $ * WIN32 VIO driver. * see: http://www.edm2.com/index.php/Category:Vio * @@ -229,14 +229,14 @@ VioGetMode(VIOMODEINFO *info, HVIO viohandle) } } else if (info) { - /* + /* * initialised - report underlying size; * utilised during resize operations, see also VioSetMode() and VioGetBuf(). */ int rows = 0, cols = 0; assert(info->cb == sizeof(VIOMODEINFO)); - vio_size(&rows, &cols); // current physical size. + vio_size(&rows, &cols); // current physical size. info->row = (USHORT)rows; info->col = (USHORT)cols; info->color = (USHORT)vio.activecolors; @@ -444,7 +444,7 @@ int VioGetFont(char *font, int buflen) { if (font && buflen > 0) { - vio_profile(TRUE); + vio_profile(-1); sxprintf(font, buflen, "%s %dx%d", vio.fcfacename, vio.fcwidth, vio.fcheight); return 0; } @@ -979,4 +979,35 @@ DosBeep(int freq, int duration) #endif // USE_VIO_BUFFER #endif // WIN32 +#if (XXX) +int +UnicodeCharSupported(HWND Handle, wchar_t ch) +{ + int supported = 0; + if (Handle) + { + const DWORD dwSize = GetFontUnicodeRanges(Handle, NULL); + if (dwSize) { + BYTE* buffer; + + if (NULL != (buffer = calloc(sizeof(BYTE), sizeof(GLYPHSET) + dwSize))) { + GLYPHSET* pGlyphSet = (GLYPHSET *)(buffer); + + if (GetFontUnicodeRanges(Handle, pGlyphSet)) { + for (DWORD x = 0; x < pGlyphSet->cRanges; ++x) { + if (ch >= pGlyphSet->ranges[x].wcLow && + ch < (pGlyphSet->ranges[x].wcLow + pGlyphSet->ranges[x].cGlyphs)) { + supported = 1; + break; + } + } + } + } + free(buffer); + } + } + return supported; +} +#endif //XXX + /*end*/ diff --git a/gr/ttyx11if.c b/gr/ttyx11if.c index de127ccd..6984d95e 100644 --- a/gr/ttyx11if.c +++ b/gr/ttyx11if.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_ttyx11if_c,"$Id: ttyx11if.c,v 1.5 2014/10/22 02:33:24 ayoung Exp $") +__CIDENT_RCSID(gr_ttyx11if_c,"$Id: ttyx11if.c,v 1.6 2024/07/19 05:04:22 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: ttyx11if.c,v 1.5 2014/10/22 02:33:24 ayoung Exp $ +/* $Id: ttyx11if.c,v 1.6 2024/07/19 05:04:22 cvsuser Exp $ * X11 dynamic interface. * * @@ -347,7 +347,7 @@ void XrmInitialize(void) void XLibInitialise(void) { -#if defined(linux) || defined(unix) || defined(_AIX) || defined(__APPLE__) ||\ +#if defined(linux) || defined(unix) || defined(__unix__) || defined(_AIX) || defined(__APPLE__) ||\ defined(HAVE_DLFCN_H) const char *libX11 = "/usr/lib/libX11.so"; diff --git a/gr/undo.c b/gr/undo.c index 985a14c4..81522782 100644 --- a/gr/undo.c +++ b/gr/undo.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_undo_c,"$Id: undo.c,v 1.52 2023/03/05 10:17:45 cvsuser Exp $") +__CIDENT_RCSID(gr_undo_c,"$Id: undo.c,v 1.53 2024/08/25 06:01:53 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: undo.c,v 1.52 2023/03/05 10:17:45 cvsuser Exp $ +/* $Id: undo.c,v 1.53 2024/08/25 06:01:53 cvsuser Exp $ * undo and redo facilities. * * @@ -676,11 +676,11 @@ uwrite_op(undo_t *undo) assert(*cur_col >= 1); undo->u_line = *cur_line; - undo->u_col = *cur_col; + undo->u_col = *cur_col; undo->u_last = up->u_last; undo->u_chain = up->u_chain++; - undo->u_cmap = cur_cmap; /*XXX - cmap identifier??*/ - up->u_last = u_end_of_file; + undo->u_cmap = cur_cmap; /*XXX - cmap identifier??*/ + up->u_last = u_end_of_file; undo_debug(undo, US_NORMAL == x_undo_state ? "normal" : (US_UNDO == x_undo_state ? "undo" : "redo")); @@ -734,7 +734,7 @@ uwrite_data(FSIZE_t offset, const char *buf, int len) /* Function: slice_read_last - * Read from the undo file, caching were possible; used for undo + * Read from the undo file, caching were possible; used for undo * compaction code. * * Parameters: @@ -893,7 +893,7 @@ slice_find(FSIZE_t offset, const int rdwr) /* Function: upwrite - * Write data to undo file at a specified offset, seeking offset + * Write data to undo file at a specified offset, seeking offset * if required. * * Parameters: @@ -965,7 +965,7 @@ upread(char *buf, int len, FSIZE_t offset) Macro Description: The 'undo()' primitive undoes buffer modifications on the current buffer. - + Executing without arguments undoes the last operation performed on the buffer, including cursor movement, any text modification and marked region modification. If the previous operation on the @@ -977,14 +977,14 @@ upread(char *buf, int len, FSIZE_t offset) buffer modification, restoring the cursor to the its location where the buffer was actually modified. - Each buffer maintains their own undo stack, unless disabled + Each buffer maintains their own undo stack, unless disabled (see set_buffer_flags). Under BRIEF the undo stack for a particular buffer was cleared when the buffer is written to disk, as such it was not possible to undo any operations performed on the buffer before the last 'write_buffer'. Under Grief the undo stack is retained for the duration of the - editor lifetime. If 'pastwrite' is specified as positive value, + editor lifetime. If 'pastwrite' is specified as positive value, the 'undo' shall perform undo's beyond the last write_buffer; by default the user is prompted as follows @@ -1024,7 +1024,7 @@ do_undo(int mode) /* (int move, [int pastwrite = -1]. [int redo = F const int past = (-1 == mode ? get_xinteger(2, -1) : -1); const int redo = (-1 == mode ? get_xinteger(3, FALSE) : FALSE); int ret = 0; - + enum undo_state s_undo_state = x_undo_state; UNDO_t *up = (redo ? &curbp->b_redo : &curbp->b_undo); @@ -1110,6 +1110,7 @@ void do_redo(void) /* () */ { /*see macro implementation*/ -} +} /*end*/ + diff --git a/gr/version.c b/gr/version.c index 136e4a2b..4dce3e7a 100644 --- a/gr/version.c +++ b/gr/version.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_version_c,"$Id: version.c,v 1.32 2024/04/16 10:30:37 cvsuser Exp $") +__CIDENT_RCSID(gr_version_c,"$Id: version.c,v 1.33 2024/08/04 10:07:46 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: version.c,v 1.32 2024/04/16 10:30:37 cvsuser Exp $ +/* $Id: version.c,v 1.33 2024/08/04 10:07:46 cvsuser Exp $ * Version strings. * * @@ -23,6 +23,7 @@ __CIDENT_RCSID(gr_version_c,"$Id: version.c,v 1.32 2024/04/16 10:30:37 cvsuser E const int x_major_version = GR_VERSION_1; const int x_minor_version = GR_VERSION_2; const int x_edit_version = GR_VERSION_3; +const int x_build_version = GR_VERSION_4; const char * x_version = GR_VERSION; const char * x_buildnumber = GR_BUILD_NUMBER; diff --git a/gr/widgets.h b/gr/widgets.h index 1c969412..9424d54c 100644 --- a/gr/widgets.h +++ b/gr/widgets.h @@ -1,11 +1,11 @@ #ifndef GR_WIDGETS_H_INCLUDED #define GR_WIDGETS_H_INCLUDED #include -__CIDENT_RCSID(gr_widgets_h,"$Id: widgets.h,v 1.8 2014/10/22 02:33:25 ayoung Exp $") +__CIDENT_RCSID(gr_widgets_h,"$Id: widgets.h,v 1.9 2024/09/08 16:29:24 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: widgets.h,v 1.8 2014/10/22 02:33:25 ayoung Exp $ +/* $Id: widgets.h,v 1.9 2024/09/08 16:29:24 cvsuser Exp $ * Standard widgets. * * @@ -42,6 +42,10 @@ extern WIDGET_t * listbox_new(void); extern WIDGET_t * pushbutton_new(void); extern WIDGET_t * radiobutton_new(void); +extern WIDGET_t * menu_new(void); +extern WIDGET_t * menu_item_new(void); +extern WIDGET_t * menu_separator_new(void); + __CEND_DECLS #endif /*GR_WIDGETS_H_INCLUDED*/ diff --git a/gr/widgets_tty.c b/gr/widgets_tty.c index 4bc057de..3c981ee9 100644 --- a/gr/widgets_tty.c +++ b/gr/widgets_tty.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_widgets_tty_c,"$Id: widgets_tty.c,v 1.40 2024/05/20 17:16:39 cvsuser Exp $") +__CIDENT_RCSID(gr_widgets_tty_c,"$Id: widgets_tty.c,v 1.45 2024/09/15 14:15:54 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: widgets_tty.c,v 1.40 2024/05/20 17:16:39 cvsuser Exp $ +/* $Id: widgets_tty.c,v 1.45 2024/09/15 14:15:54 cvsuser Exp $ * Dialog widgets, tty interface. * * @@ -305,7 +305,7 @@ tty_isunicode(int special) { __CUNUSED(special) #if defined(WIN32) || defined(__CYGWIN__) - if (special) /* FIXME; generally aren't available. */ + if (special) /* FIXME */ return FALSE; #endif return (DC_UNICODE == ((DC_UNICODE|DC_ASCIIONLY) & x_display_ctrl)); @@ -380,7 +380,8 @@ typedef struct { char hotkey; /* hotkey value */ int offset; /* hilite offset within text */ int lalign; - int position; + int pstart; /* start line/column */ + int pend; /* end column */ int multiline; } WButtonText_t; @@ -430,7 +431,7 @@ bt_text(WButtonText_t *b, const char *text) } } b->multiline = (NULL != strchr(b->text, '\n') ? 1 : 0); - b->position = 0; + b->pstart = b->pend = 0; b->lalign = 0; } } @@ -511,7 +512,7 @@ static int container_callback(WContainer_t *g, WIDGETMSG_t msg, WID WIDGET_t * - container_new(void) +container_new(void) { return tty_new(sizeof(WContainer_t), (WIDGETCB_t)container_callback); } @@ -612,6 +613,7 @@ group_find(const WIDGET_t *group, int direction) case DLGC_GROUP: case DLGC_CONTAINER: case DLGC_TAB: + case DLGC_MENU: case DLGC_SPACER: break; @@ -1218,7 +1220,17 @@ radiobutton_callback(WRadioButton_t *b, WIDGETMSG_t msg, WIDGETARG_t p1, WIDGETA const int horiz = w->w_orientation; if (horiz) { - /*TODO*/; + const int x = GetXParam(p1); + + for (i = 0; i < b->rb_count; ++i) { + WButtonText_t* bt = b->rb_buttons + i; + + if (x >= bt->pstart && x <= bt->pend) { + b->rb_cursor = i; + radiobutton_callback(b, WIDGET_KEYDOWN, ' ', 0); + break; + } + } } else { b->rb_cursor = GetYParam(p1); radiobutton_callback(b, WIDGET_KEYDOWN, ' ', 0); @@ -1280,7 +1292,7 @@ radiobutton_callback(WRadioButton_t *b, WIDGETMSG_t msg, WIDGETARG_t p1, WIDGETA if (horiz) { const size_t len = strlen(bt->text); - bt->position = offset; + bt->pstart = offset; tty_move(w, offset, 0); if (b->rb_unicode) { /* MCHAR */ tty_char(NORMAL, (i == b->rb_active ? CH_RADIO_ON : CH_RADIO_OFF)); @@ -1297,10 +1309,10 @@ radiobutton_callback(WRadioButton_t *b, WIDGETMSG_t msg, WIDGETARG_t p1, WIDGETA tty_char((HasFocus(w) ? HOTKEY_FOCUS : HOTKEY_NORMAL), bt->text[bt->offset]); } offset += len + 2; + bt->pend = offset - 1; } else { - bt->position = i; - + bt->pstart = i; tty_move(w, 0, i); if (b->rb_unicode) { /* MCHAR */ tty_char(NORMAL, (i == b->rb_active ? CH_RADIO_ON : CH_RADIO_OFF)); @@ -1327,9 +1339,9 @@ radiobutton_callback(WRadioButton_t *b, WIDGETMSG_t msg, WIDGETARG_t p1, WIDGETA const int offset = (b->rb_unicode ? 0 : 1); if (horiz) { - tty_move(w, b->rb_buttons[b->rb_cursor].position + offset, 0); + tty_move(w, b->rb_buttons[b->rb_cursor].pstart + offset, 0); } else { - tty_move(w, offset, b->rb_buttons[b->rb_cursor].position); + tty_move(w, offset, b->rb_buttons[b->rb_cursor].pstart); } return TRUE; } @@ -1681,11 +1693,15 @@ typedef struct ListboxItem { uint16_t li_flags; /* control flags */ #define LBI_FHIDDEN 0x0001 #define LBI_FFILTERED 0x0002 +#define LBI_FSEPARATOR 0x0004 int16_t li_shortcut; /* short cut key, eg. 'Y - Yes' */ const char * li_display; /* display text */ uint32_t li_length; /* length, in bytes */ const char * li_data; /* item text/data */ + struct { + int32_t x, y; + } li_coord; } ListboxItem_t; #define LB_POSNORM -1 @@ -1743,7 +1759,7 @@ static int lb_active(Listbox_t *lb, int32_t active); static ListboxItem_t * lb_item_add(Listbox_t *lb, int32_t pos, uint16_t flags, const char *data); static int lb_item_delete(Listbox_t *lb, ListboxItem_t *n, int32_t index); static int lb_item_zap(Listbox_t *lb); -static const ListboxItem_t *lb_item_get(const Listbox_t *lb, int32_t index); +static ListboxItem_t * lb_item_get(const Listbox_t *lb, int32_t index); static const ListboxItem_t *lb_item_find(const Listbox_t *lb, const char *text, int32_t len, int32_t *index); static const ListboxItem_t *lb_item_match(const Listbox_t *lb, const ListboxItem_t *n, const char *text, int32_t *index); static const ListboxItem_t *lb_item_shortcut(const Listbox_t *lb, uint16_t ch, int32_t *index, int text0); @@ -1764,7 +1780,6 @@ static void lb_paint(Listbox_t *lb, WIDGET_t *w, int repaint); static int lb_caret(Listbox_t *lb, WIDGET_t *w); - static void lb_init(Listbox_t *lb, uint32_t flags) { @@ -1812,7 +1827,7 @@ lb_open(Listbox_t *lb, WIDGET_t *w) static void lb_complete(Listbox_t *lb) { - lb->lb_open = FALSE; + lb->lb_open = FALSE; } @@ -2062,12 +2077,18 @@ lb_item_add(Listbox_t *lb, int32_t pos, uint16_t flags, const char *data) } datalen = (int)strlen(data); + + } else { + data = ""; + datalen = 0; } - if (0 == (LB_FALLOWDUPLICATES & lb->lb_flags) && - NULL != lb_item_find(lb, display, displaylen ? displaylen : datalen, NULL)) { - trace_log("\t== duplicate:<%d/%s>\n", displaylen ? displaylen : datalen, display); - return NULL; + if (0 == (flags & LBI_FSEPARATOR)) { + if (0 == (LB_FALLOWDUPLICATES & lb->lb_flags) && + NULL != lb_item_find(lb, display, displaylen ? displaylen : datalen, NULL)) { + trace_log("\t== duplicate:<%d/%s>\n", displaylen ? displaylen : datalen, display); + return NULL; + } } if (NULL == (n = chk_alloc(sizeof(ListboxItem_t) + datalen + 1 + displaylen + 1))) { @@ -2101,9 +2122,11 @@ lb_item_add(Listbox_t *lb, int32_t pos, uint16_t flags, const char *data) n->li_data = buffer; } else { /* non-strings, assign image */ - if (0 == (LB_FALLOWDUPLICATES & lb->lb_flags) && - NULL != lb_item_find(lb, data, 0, NULL)) { - return NULL; + if (0 == (flags & LBI_FSEPARATOR)) { + if (0 == (LB_FALLOWDUPLICATES & lb->lb_flags) && + NULL != lb_item_find(lb, data, 0, NULL)) { + return NULL; + } } if (NULL == (n = chk_alloc(sizeof(ListboxItem_t)))) { @@ -2249,11 +2272,11 @@ lb_item_remove(Listbox_t *lb, int32_t idx) } -static const ListboxItem_t * +static ListboxItem_t * lb_item_get(const Listbox_t *lb, int32_t idx) { const ListboxList_t *queue = &lb->lb_list; - const ListboxItem_t *n; + ListboxItem_t *n; if (idx >= 0 && idx < lb->lb_count) { for (n = TAILQ_FIRST(queue); n; n = TAILQ_NEXT(n, li_node)) { @@ -2311,7 +2334,7 @@ lb_item_match(const Listbox_t *lb, const ListboxItem_t *n, const char *text, int n = (n ? TAILQ_NEXT(n, li_node) : TAILQ_FIRST(queue)); while (n) { - if (0 == (LBI_FHIDDEN & n->li_flags)) { + if (0 == ((LBI_FHIDDEN|LBI_FSEPARATOR) & n->li_flags)) { if (0 == (match)(n->li_display, text, len)) { if (idx) *idx = t_idx; return n; @@ -2591,37 +2614,37 @@ lb_key(Listbox_t *lb, WIDGET_t *w, int key) widget_callback(w, DLGE_CHANGE, (WIDGETARG_t) lb->lb_active, 0); return TRUE; - case KEY_HOME: /* - top of list */ + case KEY_HOME: /* - top of list */ lb_cursor(lb, w, 0); break; - case KEY_PAGEUP: /* - scroll up one page */ + case KEY_PAGEUP: /* - scroll up one page */ repaint = lb_backward(lb, w, page); break; - case KEY_UP: /* - scroll up one item */ + case KEY_UP: /* - scroll up one item */ case WHEEL_UP: repaint = lb_backward(lb, w, 1); break; - case KEY_LEFT: /* - previous item/column */ + case KEY_LEFT: /* - previous item/column */ repaint = lb_backward(lb, w, (columns > 1 ? rows : 1)); break; - case KEY_RIGHT: /* - previous item/column */ - repaint = lb_forward(lb, w, (columns > 1 ? rows : 1)); + case KEY_RIGHT: /* - previous item/column */ + repaint = lb_forward(lb, w, (columns > 1 ? rows : 1)); break; - case KEY_DOWN: /* - scroll down one item */ + case KEY_DOWN: /* - scroll down one item */ case WHEEL_DOWN: repaint = lb_forward(lb, w, 1); break; - case KEY_PAGEDOWN: /* - scroll down one page */ + case KEY_PAGEDOWN: /* - scroll down one page */ repaint = lb_forward(lb, w, page); break; - case KEY_END: /* - bottom of list */ + case KEY_END: /* - bottom of list */ if (lb->lb_count) { lb_cursor(lb, w, lb->lb_count - 1); } @@ -2676,12 +2699,12 @@ lb_filter(Listbox_t *lb, int state, ListboxItem_t *n) { if (n) { if (state) { /* filter */ - if (0 == ((LBI_FHIDDEN|LBI_FFILTERED) & n->li_flags)) { + if (0 == ((LBI_FHIDDEN|LBI_FFILTERED|LBI_FSEPARATOR) & n->li_flags)) { n->li_flags |= LBI_FFILTERED; --lb->lb_visible; } } else { /* unfilter */ - if (LBI_FFILTERED == ((LBI_FHIDDEN|LBI_FFILTERED) & n->li_flags)) { + if (LBI_FFILTERED == ((LBI_FHIDDEN|LBI_FFILTERED|LBI_FSEPARATOR) & n->li_flags)) { n->li_flags &= (uint16_t)~LBI_FFILTERED; ++lb->lb_visible; } @@ -2694,12 +2717,14 @@ lb_filter(Listbox_t *lb, int state, ListboxItem_t *n) if (state) { /* filter */ for (n = TAILQ_FIRST(queue); n; n = TAILQ_NEXT(n, li_node)) { - n->li_flags |= LBI_FFILTERED; + if (0 == ((LBI_FHIDDEN|LBI_FSEPARATOR) & n->li_flags)) { + n->li_flags |= LBI_FFILTERED; + } } lb->lb_visible = 0; } else { /* unfilter, ignore HIDDEN elements */ for (n = TAILQ_FIRST(queue); n; n = TAILQ_NEXT(n, li_node)) { - if (LBI_FFILTERED == ((LBI_FHIDDEN|LBI_FFILTERED) & n->li_flags)) { + if (LBI_FFILTERED == ((LBI_FHIDDEN|LBI_FFILTERED|LBI_FSEPARATOR) & n->li_flags)) { n->li_flags &= (uint16_t)~LBI_FFILTERED; if (count <= ++lb->lb_visible) { break; @@ -2838,7 +2863,7 @@ lb_paint(Listbox_t *lb, WIDGET_t *w, int repaint) (popup ? tty_absmove : tty_move); int32_t item = lb->lb_top; - const ListboxItem_t *n; + ListboxItem_t *n; if (0 == repaint || NULL == lb->lb_topcache) { repaint = LB_PAINT1|LB_PAINT2; @@ -2877,42 +2902,62 @@ lb_paint(Listbox_t *lb, WIDGET_t *w, int repaint) if (n) { const char *text = n->li_display; + n->li_coord.x = 0; + n->li_coord.y = 0; + if ((LBI_FHIDDEN|LBI_FFILTERED) & n->li_flags) { n = TAILQ_NEXT(n, li_node); ++item; continue; } - if ((len = n->li_length) > maxlen) { - len = maxlen; - } + if (LBI_FSEPARATOR & n->li_flags) { + int separator = (maxlen / 3) * 2, left = (maxlen - separator) / 2; - if (len) { /* current line */ - if (prefixlength) { + len = left + separator; + move(w, frame + x, frame + y); + while (left--) + tty_char(NORMAL, ' '); + while (separator--) + tty_char(NORMAL, '-'); /* FIXME */ + + } else { + if ((len = n->li_length) > maxlen) { + len = maxlen; + } + + if (len) { /* current line */ int idxoffset = 0; - if (LB_FHASSHORTCUT & lb->lb_flags) { - sxprintf(idxbuffer, sizeof(idxbuffer), "%c%*s", - (n->li_shortcut ? n->li_shortcut : ' '), prefixlength - 1, ""); + if (prefixlength) { + if (LB_FHASSHORTCUT & lb->lb_flags) { + sxprintf(idxbuffer, sizeof(idxbuffer), "%c%*s", + (n->li_shortcut ? n->li_shortcut : ' '), prefixlength - 1, ""); - /* 1. .. 20. */ - } else if (lb->lb_unicode && lb->lb_count <= 20) { - move(w, frame + x, frame + y); - tty_char(FOCUS, 0x2488 + item); - strcpy(idxbuffer, " "); - idxoffset = 2; + /* 1. .. 20. */ + } else if (lb->lb_unicode && lb->lb_count <= 20) { + move(w, frame + x, frame + y); + tty_char(FOCUS, 0x2488 + item); + strcpy(idxbuffer, " "); + idxoffset = 2; + + } else { + sxprintf(idxbuffer, sizeof(idxbuffer), "%-*d ", prefixlength - 1, item + 1); + } + + move(w, frame + x + idxoffset, frame + y); + tty_str(FOCUS, idxbuffer); } else { - sxprintf(idxbuffer, sizeof(idxbuffer), "%-*d ", prefixlength - 1, item + 1); + move(w, frame + x, frame + y); } - move(w, frame + x + idxoffset, frame + y); - tty_str(FOCUS, idxbuffer); + n->li_coord.x = frame + x; + n->li_coord.y = frame + y; + tty_strn(attr, text, len); } - - move(w, frame + x + prefixlength, frame + y); - tty_strn(attr, text, len); } + n = TAILQ_NEXT(n, li_node); if (cursor == item++) { lb->lb_focus = idx; /* focus element */ @@ -2961,14 +3006,36 @@ lb_paint(Listbox_t *lb, WIDGET_t *w, int repaint) } +static int32_t +lb_item_index(const Listbox_t* lb, int x, int y) +{ + int32_t item = lb->lb_top; + ListboxItem_t *n = lb_item_get(lb, item); + + while (n) { + if (0 == ((LBI_FHIDDEN|LBI_FFILTERED|LBI_FSEPARATOR) & n->li_flags)) { + if (n->li_coord.y == y) { + if (x >= n->li_coord.x && x < (n->li_coord.x + lb->lb_width)) { + return item; + } + } + } + n = TAILQ_NEXT(n, li_node); + ++item; + } + return -1; +} + + static int lb_caret(Listbox_t *lb, WIDGET_t *w) { - const int32_t focus = lb->lb_focus; - const int32_t rows = (lb->lb_rows > 0 ? lb->lb_rows : (w && w->w_rows > 0 ? w->w_rows : 1)); - const int popup = (LB_FISPOPUP & lb->lb_flags) ? TRUE : FALSE; + const int32_t focus = lb->lb_focus; if (focus >= 0) { + const int32_t rows = (lb->lb_rows > 0 ? lb->lb_rows : (w->w_rows > 0 ? w->w_rows : 1)); + const int popup = (LB_FISPOPUP & lb->lb_flags) ? TRUE : FALSE; + if (popup) { if (! dialog_tty_popup_select(w->w_root, TRUE)) { return FALSE; @@ -3777,6 +3844,25 @@ increment:; dval = 0; } +static int +ef_setpos(Editfield_t* ef, int pos) +{ + if (ef->ef_cursor != (ef->ef_loffset + pos)) { +#if defined(EWIDECHAR) + const int len = (int)Wcslen(ef->ef_buffer); +#else + const int len = (int)strlen(ef->ef_buffer); +#endif + ef->ef_cursor = ef->ef_loffset + pos; + if (ef->ef_cursor > len) { + ef->ef_cursor = len; + } + return TRUE; + } + return FALSE; +} + + // // Unicode Resources: // o 0x25BC BLACK DOWN-POINTING TRIANGLE @@ -3946,7 +4032,6 @@ listbox_callback(WListbox_t *l, WIDGETMSG_t msg, WIDGETARG_t p1, WIDGETARG_t p2) w->w_reqcols = 1; } w->w_flags |= WIDGET_FTABSTOP; - w->w_border = 1; return TRUE; case WIDGET_READY: /* dialog session ready */ @@ -4172,6 +4257,18 @@ editfield_callback(WEditfield_t *e, WIDGETMSG_t msg, WIDGETARG_t p1, WIDGETARG_t } return TRUE; + case WIDGET_MOUSE: /* mouse event */ + if (BUTTON1_DOWN == p2) { + if (!HasFocus(w)) { + dialog_tty_setfocus(w->w_root, w); + } else { + if (ef_setpos(ef, GetXParam(p1))) { + ef_paint(ef, w); + } + } + } + return TRUE; + case WIDGET_KEYDOWN: /* keyboard event */ return ef_key(ef, w, p1, NULL, NULL); @@ -4288,6 +4385,14 @@ numericfield_callback(WNumericfield_t *n, WIDGETMSG_t msg, WIDGETARG_t p1, WIDGE } return TRUE; + case WIDGET_MOUSE: /* mouse event */ + if (BUTTON1_DOWN == p2) { + if (! HasFocus(w)) { + dialog_tty_setfocus(w->w_root, w); + } + } + return TRUE; + case WIDGET_KEYDOWN: /* keyboard event */ return ef_key(ef, w, p1, NULL, NULL); @@ -4443,6 +4548,7 @@ combofield_select(WCombofield_t *cf, int idx) } + static void combofield_build(WCombofield_t *cf) { @@ -4494,8 +4600,8 @@ combofield_build(WCombofield_t *cf) } else { /* - * fixed columns - */ + * fixed columns + */ columns = (columns > 0 ? columns : 1); cols = columns * reqcols; if (cols < mincols) cols = mincols; @@ -4556,7 +4662,6 @@ combofield_autocomplete(Editfield_t *ef, WIDGET_t *w, void *arg) } else { /* single character short-cut */ if ((LB_FHASSHORTCUT & lb->lb_flags) && 0 == buffer[1] && (NULL != (n = lb_item_shortcut(lb, (uint16_t) *buffer, &idx, FALSE)))) { - strxcpy(complete + 1, n->li_display + strlen(buffer), sizeof(ef->ef_complete)); complete[0] = '-'; @@ -4622,20 +4727,8 @@ combofield_listbox(WCombofield_t *cf, const int state) const int current_state = cf->cf_popupstate; switch (state) { -// case CB_POPUPSTATE_HIDDEN: -// switch (current_state) { -// case CB_POPUPSTATE_FOCUS: -// case CB_POPUPSTATE_VISIBLE: -// if (dialog_tty_popup_focus(w->w_root, -1)) { -// cf->cf_popupstate = CB_POPUPSTATE_HIDDEN; -// } -// break; -// } -// break; - case CB_POPUPSTATE_VISIBLE: switch (current_state) { -// case CB_POPUPSTATE_HIDDEN: case CB_POPUPSTATE_FOCUS: if (dialog_tty_popup_focus(w->w_root, FALSE)) { cf->cf_popupstate = CB_POPUPSTATE_VISIBLE; @@ -4652,7 +4745,6 @@ combofield_listbox(WCombofield_t *cf, const int state) case CB_POPUPSTATE_NONE: combofield_build(cf); /*FALLTHRU*/ -// case CB_POPUPSTATE_HIDDEN: case CB_POPUPSTATE_VISIBLE: if (dialog_tty_popup_focus(w->w_root, TRUE)) { cf->cf_popupstate = CB_POPUPSTATE_FOCUS; @@ -4947,7 +5039,7 @@ combofield_callback(WCombofield_t *cf, WIDGETMSG_t msg, WIDGETARG_t p1, WIDGETAR return TRUE; case KEY_ESC: /* - escape */ - combofield_listbox(cf, CB_POPUPSTATE_VISIBLE); + combofield_listbox(cf, CB_POPUPSTATE_NONE); break; case KEY_PAGEUP: /* - listbox page */ @@ -4989,21 +5081,26 @@ combofield_callback(WCombofield_t *cf, WIDGETMSG_t msg, WIDGETARG_t p1, WIDGETAR } return FALSE; -#if defined(TODO) case WIDGET_MOUSE: /* mouse event */ - if ((CB_POPUPSTATE_FOCUS == cf->cf_popupstate || CB_POPUPSTATE_VISIBLE == cf->cf_popupstate) && - cf->cf_lbwidget == w) { - if (BUTTON1_DOWN == p2) { - const int y = GetYParam(p1) - w->w_border; + if (BUTTON1_DOWN == p2) { + if (! HasFocus(w)) { + if (dialog_tty_setfocus(w->w_root, w)) { + combofield_listbox(cf, CB_POPUPSTATE_FOCUS); + } + } + } + return TRUE; - if (combofield_select(cf, lb->lb_top + y)) { - combofield_listbox(cf, CB_POPUPSTATE_VISIBLE); + case WIDGET_MOUSE_POPUP: /* mouse event, child popup */ + if (BUTTON1_DOWN == p2) { + if (CB_POPUPSTATE_VISIBLE == cf->cf_popupstate || CB_POPUPSTATE_FOCUS == cf->cf_popupstate) { + const int32_t item = lb_item_index(lb, GetXParam(p1), GetYParam(p1)); + if (item >= 0) { + combofield_select(cf, item); } } - return TRUE; } - break; -#endif + return TRUE; case WIDGET_PAINT: /* widget display */ if (0 == (w->w_flags & WIDGET_FHIDDEN)) { @@ -5034,4 +5131,64 @@ combofield_callback(WCombofield_t *cf, WIDGETMSG_t msg, WIDGETARG_t p1, WIDGETAR return FALSE; } + +/* + * Group: Menu +**/ +typedef struct { + WIDGET_t mn_widget; + Listbox_t mn_listimpl; +} WMenu_t; + +static int menu_callback(WMenu_t* mn, WIDGETMSG_t msg, WIDGETARG_t p1, WIDGETARG_t p2); + + +WIDGET_t* +menu_new(void) +{ + WMenu_t* mn; + + if (NULL == (mn = (WMenu_t*)tty_new(sizeof(WMenu_t), (WIDGETCB_t)menu_callback))) { + return NULL; + } + lb_init(&mn->mn_listimpl, LB_FISPOPUP | LB_FHASSTRINGS); + return (WIDGET_t*)mn; +} + + +WIDGET_t* +menu_item_new(void) +{ + return tty_new(sizeof(WIDGET_t), (WIDGETCB_t)menu_callback); +} + + +WIDGET_t* +menu_separator_new(void) +{ + return tty_new(sizeof(WIDGET_t), (WIDGETCB_t)menu_callback); +} + + +static int +menu_callback(WMenu_t* mn, WIDGETMSG_t msg, WIDGETARG_t p1, WIDGETARG_t p2) +{ + WIDGET_t* w = (WIDGET_t*)mn; + + switch (msg) { + case WIDGET_INIT: /* initialise */ + if (w->w_reqrows <= 0) w->w_reqrows = 1; + if (w->w_reqcols <= 0) w->w_reqcols = 1; + w->w_flags |= WIDGET_FTABSTOP; + return TRUE; + + case WIDGET_READY: /* dialog session ready */ + return TRUE; + + default: + return tty_default(w, msg, p1, p2); + } + return FALSE; +} + /*end*/ diff --git a/gr/widgets_tty.h b/gr/widgets_tty.h index 298b7bb6..6d95804b 100644 --- a/gr/widgets_tty.h +++ b/gr/widgets_tty.h @@ -1,11 +1,11 @@ #ifndef GR_WIDGETS_TTY_H_INCLUDED #define GR_WIDGETS_TTY_H_INCLUDED #include -__CIDENT_RCSID(gr_widgets_tty_h,"$Id: widgets_tty.h,v 1.8 2014/10/22 02:33:25 ayoung Exp $") +__CIDENT_RCSID(gr_widgets_tty_h,"$Id: widgets_tty.h,v 1.11 2024/09/25 13:58:06 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: widgets_tty.h,v 1.8 2014/10/22 02:33:25 ayoung Exp $ +/* $Id: widgets_tty.h,v 1.11 2024/09/25 13:58:06 cvsuser Exp $ * Widgets, TTY specific functionality. * * @@ -59,12 +59,6 @@ __CBEGIN_DECLS */ #define WIDGET_COMMAND (WIDGET_BASE+5) - /* A widget receives this message when the user chooses a command from - * the system menu or when the user chooses the maximize button, - * minimize button, restore button, or close button. - */ -#define WIDGET_SYSCOMMAND (WIDGET_BASE+6) - /* The CLOSE message is sent as a signal that a widget should terminate. */ #define WIDGET_CLOSE (WIDGET_BASE+7) @@ -99,6 +93,7 @@ __CBEGIN_DECLS * of the BUTTON_ keys manifest values. */ #define WIDGET_MOUSE (WIDGET_BASE+9) +#define WIDGET_MOUSE_POPUP (WIDGET_BASE+10) /* Geometry support -- * The SIZE message is sent to a widget that the user is resizing. By @@ -106,9 +101,10 @@ __CBEGIN_DECLS * position of the drag rectangle and, if needed, change its size or * position. */ -#define WIDGET_SIZE (WIDGET_BASE+10) -#define WIDGET_BORDER (WIDGET_BASE+11) -#define WIDGET_RESIZED (WIDGET_BASE+12) +#define WIDGET_SIZE (WIDGET_BASE+11) +#define WIDGET_BORDER (WIDGET_BASE+12) +#define WIDGET_RESIZED (WIDGET_BASE+13) + /* Widget flags * @@ -139,15 +135,16 @@ __CBEGIN_DECLS * CLEAR --- * Widget was hidden and the underlying area needs clearing. */ -#define WTTY_FFOCUS 0x0001 -#define WTTY_FHIDDEN 0x0002 +#define WTTY_FFOCUS 0x0001 +#define WTTY_FHIDDEN 0x0002 -#define WTTY_FREPACK 0x0010 -#define WTTY_FRESIZE 0x0020 +#define WTTY_FREPACK 0x0010 +#define WTTY_FRESIZE 0x0020 -#define WTTY_FDIRTY 0x0100 -#define WTTY_FCLEAR 0x0200 +#define WTTY_FDIRTY 0x0100 +#define WTTY_FCLEAR 0x0200 +#define ClrFocus(w) w->w_uflags &= ~WTTY_FFOCUS #define HasFocus(w) (((WIDGET_t *)(w))->w_uflags & WTTY_FFOCUS) #define GetXParam(p) DIALOGARGLO(p) @@ -158,3 +155,4 @@ extern WIDGET_t * tty_new(uint32_t size, WIDGETCB_t handler); __CEND_DECLS #endif /*GR_WIDGETS_TTY_H_INCLUDED*/ + diff --git a/grcpp/grcpp.rc b/grcpp/grcpp.rc index ba28c7c3..64ad6f8c 100644 --- a/grcpp/grcpp.rc +++ b/grcpp/grcpp.rc @@ -1,74 +1,70 @@ -/* - * Copyright (c) 2020 - 2022 Adam Young. - * All rights reserved. +/* -*- mode: c; indent-width: 4; -*- * - * This file is part of the GRIEF Editor. + * windows resource file * - * The GRIEF Editor is free software: you can redistribute it - * and/or modify it under the terms of the GRIEF Editor License. - * - * Redistributions of source code must retain the above copyright - * notice, and must be distributed with the license document above. - * - * Redistributions in binary form must reproduce the above copyright - * notice, and must include the license document above in - * the documentation and/or other materials provided with the - * distribution. - * - * The GRIEF Editor is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * License for more details. - * ==end== + * This file is part of the GRIEF Editor. + * + * The GRIEF Editor is free software: you can redistribute it + * and/or modify it under the terms of the GRIEF Editor License. + * + * Redistributions of source code must retain the above copyright + * notice, and must be distributed with the license document above. + * + * Redistributions in binary form must reproduce the above copyright + * notice, and must include the license document above in + * the documentation and/or other materials provided with the + * distribution. + * + * The GRIEF Editor is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * License for more details. + * ==end== */ -#include #include "../include/edbuildinfo.h" +#define RC_PRODUCTVERSION GR_VERSION_1 , GR_VERSION_2 , GR_VERSION_3 , GR_VERSION_4 +#define RC_FILEVERSION GR_VERSION_1 , GR_VERSION_2 , GR_VERSION_3 , GR_VERSION_4 + +#ifndef WINDRES +#include +#include "winver.h" +#endif + #ifdef GCC_WINDRES VS_VERSION_INFO VERSIONINFO #else VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE #endif - FILEVERSION GR_VERSION_1,GR_VERSION_2,GR_VERSION_3,GR_VERSION_4 - PRODUCTVERSION GR_VERSION_1,GR_VERSION_2,GR_VERSION_3,GR_VERSION_4 - FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + FILEVERSION RC_FILEVERSION + PRODUCTVERSION RC_PRODUCTVERSION + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK #ifdef _DEBUG - FILEFLAGS 1 + FILEFLAGS 1 #else - FILEFLAGS 0 + FILEFLAGS 0 #endif - FILEOS VOS__WINDOWS32 - FILETYPE VFT_DLL - FILESUBTYPE 0 // not used + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE VFT2_UNKNOWN BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904E4" //language ID = U.S. English, char set = Windows, Multilingual BEGIN - VALUE "FileDescription", "Grief grucpp utility, based on ucpp-1.3.2\0" - - VALUE "FileVersion", GR_VERSION "\0" - - VALUE "InternalName", "grcpp.exe\0" - + VALUE "FileDescription", "GRIEF Editor, grucpp; ucpp-1.3.2\0" + VALUE "FileVersion", GR_VERSION ", Build:" GR_BUILD_DATE "-" GR_BUILD_NUMBER + VALUE "InternalName", "grcpp.exe\0" VALUE "LegalCopyright", - "Copyright (c) 2022 Adam Young, \n" - "Copyright (c) Thomas Pornin 1999 - 2002, \n" + "Copyright (c) 2022 - " GR_BUILD_YEAR ", Adam Young. \n" + "Copyright (c) Thomas Pornin 1999 - 2002. \n" "See --license for details. \n\0" - - VALUE "OriginalFilename", - "grcpp.exe\0" - - VALUE "ProductName", - "grcpp (ucpp-1.3.2)\0" - - VALUE "ProductVersion", - GR_VERSION "\0" - - VALUE "Comments", - "https://github/adamyg/grief\0" + VALUE "Maintainers", "https://github.com/adamyg/grief\n" + VALUE "LegalTrademarks", "see GRIEF License" + VALUE "OriginalFilename", "grcpp.exe" + VALUE "ProductName", "grcpp (ucpp-1.3.2)\0" END END BLOCK "VarFileInfo" diff --git a/grmandoc/Makefile.in b/grmandoc/Makefile.in index 62bcef2c..bb930861 100644 --- a/grmandoc/Makefile.in +++ b/grmandoc/Makefile.in @@ -1,5 +1,5 @@ # -*- mode: mak; indent-tabs-mode: t; tab-width: 8 -*- -# $Id: Makefile.in,v 1.36 2024/05/03 05:41:17 cvsuser Exp $ +# $Id: Makefile.in,v 1.38 2024/07/30 08:16:09 cvsuser Exp $ # libbsdmdoc and grmanddoc # # @@ -46,11 +46,12 @@ XCLEAN= CC= @CC@ CXX= @CXX@ +RM= @RM@ +RC= @RC@ AR= @AR@ RANLIB= @RANLIB@ LIBTOOL= @LIBTOOL@ PERL= @PERL@ -RM= @RM@ # Configuration @@ -85,6 +86,7 @@ CFLAGS= @CFLAGS@ ifeq ("gcc","@CC@") CWARN= $(filter-out -Wshadow -Wmissing-prototypes -Wsign-compare, @CWARN@ $(CWALL)) CWARN+= -Wno-sign-compare -Wno-unused-variable -Wno-implicit-fallthrough -Wno-implicit-function-declaration +CWARN+= -Wno-deprecated-declarations else CWARN= @CWARN@ $(CWALL) endif @@ -246,6 +248,16 @@ MANDOC_OBJS=\ $(D_OBJ)/mansearch$(O) \ $(MANDOC_DB_OBJS) +MANDOC_RESOURCES= grmandoc.rc + +ifeq ("win32","@build_os@") +ifeq (mingw,$(findstring mingw,"@TOOLCHAIN@")) +MANDOC_OBJS+= $(addprefix $(D_OBJ)/,$(subst .rc,_res.o,$(MANDOC_RESOURCES))) +else +MANDOC_OBJS+= $(addprefix $(D_OBJ)/,$(subst .rc,.res,$(MANDOC_RESOURCES))) +endif +endif #build_os + MANDOC= $(D_BIN)/grmandoc$(E) #--------------------------------------------------- @@ -299,7 +311,9 @@ CLEANFILES= mdocversion.h # Rules ifeq ("cygwin","@build_os@") -LDLIBS:= $(filter-out -liberty, $(LDLIBS)) +# libiberty has a local implementation of getopt; an invalid optarg binding results, conflicting local/dllexport usage. +# filter and explicity link again libcygwin, as libtool *may* also include. +LDLIBS:= $(patsubst -lmisc,-lmisc -lcygwin, $(filter-out -liberty, $(LDLIBS))) endif .PHONY: build release debug @@ -379,5 +393,11 @@ $(D_OBJ)/sqlite3$(O): CFLAGS := $(filter-out -gw -hw,$(CFLAGS)) $(D_OBJ)/%$(O): %$(C) $(CC) $(CFLAGS) -o $@ -I ./sqlite3 -DHAVE_SQLITE3 -c $< +$(D_OBJ)/%.res: %.rc + $(RC) -fo $@ $< + +$(D_OBJ)/%_res.o: %.rc + $(RC) -o $@ $< + #end diff --git a/grmandoc/grmandoc.rc b/grmandoc/grmandoc.rc new file mode 100644 index 00000000..2c429047 --- /dev/null +++ b/grmandoc/grmandoc.rc @@ -0,0 +1,121 @@ +/* -*- mode: c; indent-width: 4; -*- + * + * windows resource file + * + * This file is part of the GRIEF Editor. + * + * The GRIEF Editor is free software: you can redistribute it + * and/or modify it under the terms of the GRIEF Editor License. + * + * Redistributions of source code must retain the above copyright + * notice, and must be distributed with the license document above. + * + * Redistributions in binary form must reproduce the above copyright + * notice, and must include the license document above in + * the documentation and/or other materials provided with the + * distribution. + * + * The GRIEF Editor is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * License for more details. + * ==end== + */ + +#include "../include/edbuildinfo.h" + +#define RC_PRODUCTVERSION GR_VERSION_1 , GR_VERSION_2 , GR_VERSION_3 , GR_VERSION_4 +#define RC_FILEVERSION GR_VERSION_1 , GR_VERSION_2 , GR_VERSION_3 , GR_VERSION_4 + +#ifndef WINDRES +#include "windows.h" +#include "winver.h" +#endif + +/* + * English (U.S.) resources + */ + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) + +#ifdef _WIN32 +#ifndef WINDRES +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#endif +#pragma code_page(1252) +#endif /* _WIN32 */ + +/* + * Manifest + */ + +#ifndef RT_MANIFEST +#define RT_MANIFEST 24 +#endif +#ifndef CREATEPROCESS_MANIFEST_RESOURCE_ID +#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1 +#endif +CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "../gr/gr.manifest.xml" + +/* + * Updater Meta Data + * nameID typeID { raw data } + */ + +UPDATER HostURL { "\0" } +UPDATER Channel { "release\0" } + + +/* + * Version Information + */ + +VS_VERSION_INFO VERSIONINFO + FILEVERSION RC_FILEVERSION + PRODUCTVERSION RC_PRODUCTVERSION + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS (VS_FF_SPECIALBUILD|VS_FF_DEBUG) +#else + FILEFLAGS (VS_FF_SPECIALBUILD) +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE VFT2_UNKNOWN + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + BEGIN + VALUE "CompanyName", "" + VALUE "FileDescription", "GRIEF Editor, grmandoc" + VALUE "FileVersion", GR_VERSION ", Build:" GR_BUILD_DATE "-" GR_BUILD_NUMBER + VALUE "InternalName", "grmandoc" + VALUE "Copyright", + "Copyright (C) 2014 - " GR_BUILD_YEAR ", Adam Young. \n" + "Copyright (C) Authors, The mandoc UNIX manpage compiler toolset. \n" + "Copyright (c) 1989,1990,1993,1994 The Regents of the University of California. \n" + "This is free software; see the source for copying conditions. \n" + "There is NO warranty; not even for MERCHANTABILITY \n" + "or FITNESS FOR A PARTICULAR PURPOSE. \0" + VALUE "Maintainers", "https://github.com/adamyg/grief\n" + VALUE "LegalTrademarks", "see mandoc license, http://mdocml.bsd.lv/" + VALUE "OriginalFilename", "grmandoc.exe" + VALUE "ProductName", "GRIEF" + END + END + + /* The following line should only be modified for localized versions. */ + /* It consists of any number of WORD,WORD pairs, with each pair */ + /* describing a language,codepage combination supported by the file. */ + /* */ + /* For example, a file might have values "0x409,1252" indicating that it */ + /* supports English language (0x409) in the Windows ANSI codepage (1252). */ + + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END + END + +#endif /* English (U.S.) resources */ diff --git a/grmandoc/portable_endian.h b/grmandoc/portable_endian.h index 85a6147c..d9308950 100644 --- a/grmandoc/portable_endian.h +++ b/grmandoc/portable_endian.h @@ -1,5 +1,7 @@ // "License": Public Domain // I, Mathias Panzenböck, place this file hereby into the public domain. Use it at your own risk for whatever you like. +// +// Updated for __sun #ifndef PORTABLE_ENDIAN_H__ #define PORTABLE_ENDIAN_H__ @@ -15,9 +17,11 @@ # include #elif defined(HAVE_ENDIAN_H) + # include #elif defined(HAVE_SYS_ENDIAN_H) + # include # if defined(__OpenBSD__) @@ -65,6 +69,23 @@ # define __LITTLE_ENDIAN LITTLE_ENDIAN # define __PDP_ENDIAN PDP_ENDIAN +#elif defined(__sun) && defined(HAVE_SYS_BYTEORDER_H) + +# include + +# define htobe16(x) BE_16(x) +# define htole16(x) LE_16(x) +# define be16toh(x) BE_IN16(x) +# define le16toh(x) LE_IN16(x) +# define htobe32(x) BE_32(x) +# define htole32(x) LE_32(x) +# define be32toh(x) BE_IN32(x) +# define le32toh(x) LE_IN32(x) +# define htobe64(x) BE_64(x) +# define htole64(x) LE_64(x) +# define be64toh(x) BE_IN64(x) +# define le64toh(x) LE_IN64(x) + #elif defined(__sun) && defined(__SVR4) # include @@ -73,11 +94,11 @@ # if !defined (ntohll) || !defined(htonll) # ifdef _BIG_ENDIAN -# define htonll(x) (x) -# define ntohll(x) (x) +# define htonll(x) (x) +# define ntohll(x) (x) # else -# define htonll(x) ((((uint64_t)htonl(x)) << 32) + htonl((uint64_t)(x) >> 32)) -# define ntohll(x) ((((uint64_t)ntohl(x)) << 32) + ntohl((uint64_t)(x) >> 32)) +# define htonll(x) ((((uint64_t)htonl(x)) << 32) + htonl((uint64_t)(x) >> 32)) +# define ntohll(x) ((((uint64_t)ntohl(x)) << 32) + ntohl((uint64_t)(x) >> 32)) # endif # endif diff --git a/grunch/Makefile.in b/grunch/Makefile.in index 6af50b73..74d30570 100644 --- a/grunch/Makefile.in +++ b/grunch/Makefile.in @@ -1,5 +1,5 @@ # -*- mode: mak; indent-tabs-mode: t; tab-width: 8 -*- -# $Id: Makefile.in,v 1.35 2024/05/26 12:58:44 cvsuser Exp $ +# $Id: Makefile.in,v 1.36 2024/07/29 17:09:50 cvsuser Exp $ # GRIEF macro compiler. # # @@ -51,6 +51,7 @@ endif YACC= @YACC@ GREP= @GREP@ RM= @RM@ +RC= @RC@ PERL= @PERL@ LIBTOOL= @LIBTOOL@ LANG=C @@ -170,6 +171,16 @@ OBJS= $(D_OBJ)/crmain$(O) \ $(D_OBJ)/version$(O) \ $(D_OBJ)/word$(O) +RESOURCES= grunch.rc + +ifeq ("win32","@build_os@") +ifeq (mingw,$(findstring mingw,"@TOOLCHAIN@")) +OBJS+= $(addprefix $(D_OBJ)/,$(subst .rc,_res.o,$(RESOURCES))) +else +OBJS+= $(addprefix $(D_OBJ)/,$(subst .rc,.res,$(RESOURCES))) +endif +endif #build_os + XCLEAN+= $(YTAB)$(C) $(YTAB)$(H) $(YTAB)$(C) yygen$(H) crntypes$(H) @@ -204,7 +215,13 @@ $(D_OBJ)/%$(O): %$(C) $(D_OBJ)/%$(O): $(D_GR)/%$(C) $(CC) $(CFLAGS) -o $@ -c -DGRUNCH $< - + +$(D_OBJ)/%.res: %.rc + $(RC) -fo $@ $< + +$(D_OBJ)/%_res.o: %.rc + $(RC) -o $@ $< + ifeq (bison,$(findstring bison,$(YACC))) # bison crntypes$(H): grunch$(H) $(YTAB)$(C) makentypes.pl @@ -241,4 +258,3 @@ $(YTAB)$(C): cry$(Y) endif #end - diff --git a/grunch/crmain.c b/grunch/crmain.c index c6aeedde..84df0fd6 100644 --- a/grunch/crmain.c +++ b/grunch/crmain.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_crmain_c,"$Id: crmain.c,v 1.59 2022/09/19 16:30:11 cvsuser Exp $") +__CIDENT_RCSID(gr_crmain_c,"$Id: crmain.c,v 1.62 2024/07/18 15:19:27 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: crmain.c,v 1.59 2022/09/19 16:30:11 cvsuser Exp $ +/* $Id: crmain.c,v 1.62 2024/07/18 15:19:27 cvsuser Exp $ * grunch command line. * * @@ -30,11 +30,17 @@ __CIDENT_RCSID(gr_crmain_c,"$Id: crmain.c,v 1.59 2022/09/19 16:30:11 cvsuser Exp #undef u_char #include #endif + #if defined(__APPLE__) #include /* proc_..() */ #include /* _NSGetExecutablePath() */ #endif +#if defined(BSD) +#include +#include +#endif + /* * Basic system dependent definitions. */ @@ -1147,15 +1153,47 @@ resolve_self(const char *name) } #elif defined(BSD) - if ((namelen = readlink("/proc/curproc/file", t_name, sizeof(t_name))) > 0) { + if ((namelen = readlink("/proc/curproc/file", t_name, sizeof(t_name)-1)) > 0 || // Free and DragonFly + (namelen = readlink("/proc/curproc/exe", t_name, sizeof(t_name)-1)) > 0) { // Net t_name[namelen] = 0; name = t_name; /* procfs */ } else { +#if defined(__FreeBSD__) || defined(__DragonFly__) int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1}; - size cb = sizeof(t_name); + size_t cb = sizeof(t_name); + if (-1 != sysctl(mib, 4, t_name, &cb, NULL, 0)) { - name = t_name; /* alt method */ + name = t_name; /* alt method */ + } + +#elif defined(__NetBSD__) + int mib[4] = { CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PATHNAME }; + size_t cb = sizeof(t_name); + + if (-1 != sysctl(mib, 4, t_name, &cb, NULL, 0)) { + name = t_name; /* alt method */ + } + +#elif defined(__OpenBSD__) + int mib[4] = {CTL_KERN, KERN_PROC, getpid(), KERN_PROC_ARGV}; + size_t size; + + if (sysctl(mib, 4, NULL, &size, NULL, 0) == 0) { + char **argv; + + if (size && (argv = (char **)calloc(1, size)) != NULL) { + if (sysctl(mib, 4, argv, &size, NULL, 0) == 0) { + if (strchr(argv[0], '/') == NULL || realpath(argv[0], t_name) == NULL) { + strxcpy(t_name, argv[0], sizeof(t_name)); + } + name = t_name; /* alt method */ + } + free((void *)argv); + } } +#else +#error Unsupported BSD target +#endif } #endif } @@ -1383,3 +1421,5 @@ expand_var(const char *xenv, char *buf, int buflen) } /*end*/ + + diff --git a/grunch/crsubs.c b/grunch/crsubs.c index 40441ee0..68a9bbcc 100644 --- a/grunch/crsubs.c +++ b/grunch/crsubs.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_crsubs_c,"$Id: crsubs.c,v 1.30 2022/05/31 16:18:22 cvsuser Exp $") +__CIDENT_RCSID(gr_crsubs_c,"$Id: crsubs.c,v 1.31 2024/09/08 16:30:50 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: crsubs.c,v 1.30 2022/05/31 16:18:22 cvsuser Exp $ +/* $Id: crsubs.c,v 1.31 2024/09/08 16:30:50 cvsuser Exp $ * Parser ultities. * * @@ -1492,10 +1492,11 @@ switch_end(node_t *np) void case_start(node_t *np) { - switch_t *sw = (switch_t *) ll_elem(ll_first(hd_switch)); + List_p headlp = ll_first(hd_switch); + switch_t* sw = (switch_t *)(headlp ? ll_elem(headlp) : NULL); int typecheck = 0; - assert(sw); + if (NULL == sw) return; /* error */ xprintf("case_start(%p)->", np); node_dprint(np, 0); xprintf("\n"); diff --git a/grunch/cry.y b/grunch/cry.y index 43d8f0d1..0e0a80e7 100644 --- a/grunch/cry.y +++ b/grunch/cry.y @@ -1,5 +1,5 @@ /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: cry.y,v 1.36 2021/08/14 17:09:30 cvsuser Exp $ +/* $Id: cry.y,v 1.37 2024/08/02 12:58:32 cvsuser Exp $ * grunch/crunch grammer, extended c99 * * @@ -107,8 +107,8 @@ %type constant_expression /*declarations*/ -%type declaration -%type declaration_specifiers +%type declaration +%type declaration_specifiers %type decl_specs %type init_declarator_list init_declarator %type storage_class_specifier @@ -807,8 +807,8 @@ declaration: $$ = $1; decl_pop(); } - | error O_SEMICOLON { $$ = NULL; } - | error O_CCURLY { $$ = NULL; } + | error O_SEMICOLON { $$ = 0; } + | error O_CCURLY { $$ = 0; } ; declaration_specifiers: @@ -1623,12 +1623,16 @@ compound_statement: block_item_list: /* c99, 27/08/08 */ block_item + { } | block_item_list block_item + { } ; block_item: /* c99, 27/08/08 */ declaration + { } | statement + { } ; expression_statement: diff --git a/grunch/grunch.rc b/grunch/grunch.rc new file mode 100644 index 00000000..0a7a2598 --- /dev/null +++ b/grunch/grunch.rc @@ -0,0 +1,120 @@ +/* -*- mode: c; indent-width: 4; -*- + * + * windows resource file + * + * This file is part of the GRIEF Editor. + * + * The GRIEF Editor is free software: you can redistribute it + * and/or modify it under the terms of the GRIEF Editor License. + * + * Redistributions of source code must retain the above copyright + * notice, and must be distributed with the license document above. + * + * Redistributions in binary form must reproduce the above copyright + * notice, and must include the license document above in + * the documentation and/or other materials provided with the + * distribution. + * + * The GRIEF Editor is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * License for more details. + * ==end== + */ + +#include "../include/edbuildinfo.h" + +#define RC_PRODUCTVERSION GR_VERSION_1 , GR_VERSION_2 , GR_VERSION_3 , GR_VERSION_4 +#define RC_FILEVERSION GR_VERSION_1 , GR_VERSION_2 , GR_VERSION_3 , GR_VERSION_4 + +#ifndef WINDRES +#include "windows.h" +#include "winver.h" +#endif + +/* + * English (U.S.) resources + */ + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) + +#ifdef _WIN32 +#ifndef WINDRES +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#endif +#pragma code_page(1252) +#endif /* _WIN32 */ + +/* + * Manifest + */ + +#ifndef RT_MANIFEST +#define RT_MANIFEST 24 +#endif +#ifndef CREATEPROCESS_MANIFEST_RESOURCE_ID +#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1 +#endif +CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "../gr/gr.manifest.xml" + +/* + * Updater Meta Data + * nameID typeID { raw data } + */ + +UPDATER HostURL { "\0" } +UPDATER Channel { "release\0" } + + +/* + * Version Information + */ + +VS_VERSION_INFO VERSIONINFO + FILEVERSION RC_FILEVERSION + PRODUCTVERSION RC_PRODUCTVERSION + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS (VS_FF_SPECIALBUILD|VS_FF_DEBUG) +#else + FILEFLAGS (VS_FF_SPECIALBUILD) +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE VFT2_UNKNOWN + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + BEGIN + VALUE "CompanyName", "" + VALUE "FileDescription", "GRIEF Editor, grunch" + VALUE "FileVersion", GR_VERSION ", Build:" GR_BUILD_DATE "-" GR_BUILD_NUMBER + VALUE "InternalName", "grunch" + VALUE "Copyright", + "Copyright (C) 1998 - " GR_BUILD_YEAR ", Adam Young. All rights reserved. \n" + "Licensed under the Grief License.\n " + "This is free software; see the source for copying conditions. \n" + "There is NO warranty; not even for MERCHANTABILITY \n" + "or FITNESS FOR A PARTICULAR PURPOSE. " + VALUE "Maintainers", "https://github.com/adamyg/grief\n" + VALUE "LegalTrademarks", "see GRIEF License" + VALUE "OriginalFilename", "grunch.exe" + VALUE "ProductName", "GRIEF" + END + END + + /* The following line should only be modified for localized versions. */ + /* It consists of any number of WORD,WORD pairs, with each pair */ + /* describing a language,codepage combination supported by the file. */ + /* */ + /* For example, a file might have values "0x409,1252" indicating that it */ + /* supports English language (0x409) in the Windows ANSI codepage (1252). */ + + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END + END + +#endif /* English (U.S.) resources */ diff --git a/hlpdoc/makehelp.pl b/hlpdoc/makehelp.pl index 7b4b0ac3..ca57b62b 100644 --- a/hlpdoc/makehelp.pl +++ b/hlpdoc/makehelp.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $Id: makehelp.pl,v 1.24 2024/04/19 13:57:28 cvsuser Exp $ +# $Id: makehelp.pl,v 1.25 2024/06/14 07:25:51 cvsuser Exp $ # -*- tabs: 8; indent-width: 4; -*- # Help collection tool. # @@ -139,7 +139,7 @@ '_prompt_end' => 1, 'main' => 1, - #crunch only + #grunch only 'foreach' => 2, 'case' => 2, 'else' => 2, diff --git a/hlpdoc/mansrc/features/hpcalc.mandoc b/hlpdoc/mansrc/features/hpcalc.mandoc index 5b78dc6a..ceaf1c54 100644 --- a/hlpdoc/mansrc/features/hpcalc.mandoc +++ b/hlpdoc/mansrc/features/hpcalc.mandoc @@ -2,7 +2,7 @@ .\" -*- mode: nroff; -*- .\" .\" | -- Mandoc template -.\" | $Id: hpcalc.mandoc,v 1.2 2018/10/01 21:19:57 cvsuser Exp $ +.\" | $Id: hpcalc.mandoc,v 1.3 2024/06/14 07:26:19 cvsuser Exp $ .\" | .\"The following commands are required for all man pages. .\" | .Dd Month day, year .\" | .Dt DOCUMENT_TITLE [section number] [architecture/volume] @@ -106,7 +106,7 @@ The calculator also supports the following trig and logarithmic functions: This macro can be accessed from the GRIEF features menu or by typing \f(HBhpcalc\fR at the command prompt. .Sh BUGS -This calculator demonstrates the use of certain esoteric crunch language +This calculator demonstrates the use of certain esoteric grunch language features. It is a very trivial calculator but useful. Needs a lot of work to compare to anybody elses. .Pp diff --git a/hlpdoc/mansrc/features/keylib.mandoc b/hlpdoc/mansrc/features/keylib.mandoc index 3f0878ae..244e6d91 100644 --- a/hlpdoc/mansrc/features/keylib.mandoc +++ b/hlpdoc/mansrc/features/keylib.mandoc @@ -2,7 +2,7 @@ .\" -*- mode: nroff; -*- .\" .\" | -- Mandoc template -.\" | $Id: keylib.mandoc,v 1.1 2014/11/27 18:19:40 ayoung Exp $ +.\" | $Id: keylib.mandoc,v 1.2 2024/06/14 07:26:19 cvsuser Exp $ .\" | .\"The following commands are required for all man pages. .\" | .Dd Month day, year .\" | .Dt DOCUMENT_TITLE [section number] [architecture/volume] @@ -59,7 +59,7 @@ save them to a file, or reload a keystroke macro from a file. Saving and reloading keystroke macros allows the user to build up a personal collection of macros for performing simple and non-conditional editing tasks. Tasks which require a degree of decision making need -to be written in the crunch language. +to be written in the grunch language. .Pp When this option is selected, a popup window is displayed showing the currently defined keystroke macros. diff --git a/hlpdoc/mansrc/features/nc.mandoc b/hlpdoc/mansrc/features/nc.mandoc index 676aa2b6..53af9f32 100644 --- a/hlpdoc/mansrc/features/nc.mandoc +++ b/hlpdoc/mansrc/features/nc.mandoc @@ -2,7 +2,7 @@ .\" -*- mode: nroff; -*- .\" .\" | -- Mandoc template -.\" | $Id: nc.mandoc,v 1.2 2018/10/01 21:19:58 cvsuser Exp $ +.\" | $Id: nc.mandoc,v 1.3 2024/07/27 15:17:39 cvsuser Exp $ .\" | .\"The following commands are required for all man pages. .\" | .Dd Month day, year .\" | .Dt DOCUMENT_TITLE [section number] [architecture/volume] @@ -98,7 +98,7 @@ decide NOT to change the drive, or HIT the letter of the drive you want [A-Z]. No colon or return is needed, ONLY the drive letter. .It Alt-F7 File find -.It Alt-F7 +.It Alt-F10 Directory tree .It ESC Performs the same function as F10 when NOT withing a prompt for diff --git a/hlpdoc/mansrc/features/opendir.mandoc b/hlpdoc/mansrc/features/opendir.mandoc new file mode 100644 index 00000000..a5f5c2b5 --- /dev/null +++ b/hlpdoc/mansrc/features/opendir.mandoc @@ -0,0 +1,104 @@ +.\" ................................................................. +.\" -*- mode: nroff; -*- +.\" +.\" | -- Mandoc template +.\" | $Id: opendir.mandoc,v 1.1 2024/07/28 12:22:58 cvsuser Exp $ +.\" | .\"The following commands are required for all man pages. +.\" | .Dd Month day, year +.\" | .Dt DOCUMENT_TITLE [section number] [architecture/volume] +.\" | .Os [OPERATING_SYSTEM] [version/release] +.\" | .Sh NAME +.\" | .Nm name +.\" | .Nd one line description of name +.\" | .Sh LIBRARY +.\" | Sections 2 and 3 only. +.\" | .Sh SYNOPSIS +.\" | Usage. All '.Nm' macros must be given an argument. +.\" | .Sh DESCRIPTION +.\" | .\" The following commands should be uncommented and used where appropriate. +.\" | .Sh IMPLEMENTATION NOTES +.\" | .Sh RETURN VALUES +.\" | Sections two, three, and nine function calls. +.\" | .Sh ENVIRONMENT +.\" | Sections 1, 6, 7 and 8 only; describe environment variables. +.\" | .Sh FILES +.\" | Files associated with the subject, with short descriptions. +.\" | .Sh EXAMPLES +.\" | Examples and suggestions. +.\" | .Sh DIAGNOSTICS +.\" | Sections 1, 6, 7, 8 and 9 only (command return values (to shell) +.\" | and fprintf/stderr type diagnostics). +.\" | .Sh COMPATIBILITY +.\" | .Sh ERRORS +.\" | Sections two, three, and nine error and signal handling. +.\" | .Sh SEE ALSO +.\" | Cross references and citations. +.\" | .Sh STANDARDS +.\" | Conformance to standards if applicable. +.\" | .Sh HISTORY +.\" | A brief history of the subject, including where support first appeared. +.\" | .Sh AUTHORS +.\" | Credit to the person or persons who wrote the code and/or documentation. +.\" | .Sh CAVEATS +.\" | Explanations of common misuses, i.e., security considerations for certain +.\" | library functions. +.\" | .Sh BUGS +.\" | Gotchas and caveats. +.\" | -- +.Dd $Mdocdate$ +.Dt NC 1 +.Os +.Sh NAME +.Nm opendir +.Nd Directory open dialog +.Sh DESCRIPTION +.Pp +The \fIopendir\fR macro gives you capabilities to select one-or-more files within a given directory to edit. +To edit a single file, select then hit to edit. +.Pp +Alternatively, multiple files can be selected with the key and/or the <+> or <-> keys to mask the selection. +On exit using , the selected files are opened for editing. +.Pp +The following commands are available: +.Bl -tag -offset 1 -width xxxxxxxx +.It F1 +Usage informaion. +.It F4/F10 +Exit and continue. +Which shall either edit the selected files, otherwise when no files are selected only the highlighted file will be edited. +.It ESC +Exit without editing. +.It <+> +Select the file(s) matching the specified pattern. +.It <-> +Unselect the file(s) matching the specified pattern. +.It +Toggle the selection state of the active file and reposition to the next file. +.It +When a directory, is used to move-up or down the directory tree. +Otherwise when used on a file and no other items are selected, the active file is opened for editing, otherwise behaves the same as ; its selecton status is toggled and next file is selected. +.It or <\\> +Move to the root directory. +.It Alt-F1 +Where suitable, change the current drive. +.It +Move up one directory level. +.It +Change the current active directory. +.It +Re-read the current active Directory. +.It , , , , and +Cursor control, repositioning the active element within the directory list. +.It F9 +Change the display sort order. +.It +Change the display order to unordered. +.It +Order by file name. +.It +Order by file extension. +.It +Fast select, add the given character to the current match pattern, positioning the active element to the closest match. +To go to a particular location hold down the key and input the name of the desired file. +Once the key is release, the search string will be cleared and ready to start a new search. +.El diff --git a/include/config.hin b/include/config.hin index 2b37493b..435014af 100644 --- a/include/config.hin +++ b/include/config.hin @@ -1,11 +1,11 @@ #ifndef CR_CONFIG_H_INCLUDED #define CR_CONFIG_H_INCLUDED #include -__CIDENT_RCSID(config_h, "$Id: config.hin,v 1.62 2024/06/10 08:53:03 cvsuser Exp $") +__CIDENT_RCSID(config_h, "$Id: config.hin,v 1.67 2024/07/17 15:24:12 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; set-indent: 4; -*- */ -/* $Id: config.hin,v 1.62 2024/06/10 08:53:03 cvsuser Exp $ +/* $Id: config.hin,v 1.67 2024/07/17 15:24:12 cvsuser Exp $ * Machine configuration. * * @@ -121,6 +121,8 @@ __CPRAGMA_ONCE #undef HAVE_SYS_SOCKET_H #undef HAVE_SYS_SENDFILE_H #undef HAVE_SYS_WAIT_H +#undef HAVE_SYS_SIGINFO_H +#undef HAVE_SYS_SYSINFO_H #undef HAVE_SYS_STAT_H #undef HAVE_SYS_STATFS_H #undef HAVE_SYS_STATVFS_H @@ -128,6 +130,8 @@ __CPRAGMA_ONCE #undef HAVE_SYS_MMAN_H #undef HAVE_WAIT_H #undef HAVE_POLL_H +#undef HAVE_SIGINFO_H +#undef HAVE_SYSINFO_H #undef HAVE_SYS_PRCTL_H #undef HAVE_SYS_MOUNT_H #undef HAVE_SYS_RESOURCE_H @@ -154,6 +158,9 @@ __CPRAGMA_ONCE #undef HAVE_LIBBFD #undef HAVE_BFD_H +#undef HAVE_BFD_SECTION_FLAGS +#undef HAVE_BFD_SECTION_SIZE +#undef HAVE_BFD_SECTION_VMA #undef HAVE_FLOAT_H #undef HAVE_ERRNO_H @@ -320,7 +327,9 @@ __CPRAGMA_ONCE #undef HAVE__BOOL #undef HAVE_ENDIAN_H +#undef HAVE_SYS_ENDIAN_H #undef HAVE_MACHINE_ENDIAN_H +#undef HAVE_SYS_BYTEORDER_H #undef HAVE_ARPA_NAMESER_COMPAT_H #undef IS_BIG_ENDIAN diff --git a/include/edalt.h b/include/edalt.h index 628f7c86..719b2bfb 100644 --- a/include/edalt.h +++ b/include/edalt.h @@ -1,11 +1,11 @@ #ifndef GR_EDALT_H_INCLUDED #define GR_EDALT_H_INCLUDED #include -__CIDENT_RCSID(gr_edalt_h,"$Id: edalt.h,v 1.35 2024/04/08 15:07:02 cvsuser Exp $") +__CIDENT_RCSID(gr_edalt_h,"$Id: edalt.h,v 1.38 2024/09/02 14:04:03 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: edalt.h,v 1.35 2024/04/08 15:07:02 cvsuser Exp $ +/* $Id: edalt.h,v 1.38 2024/09/02 14:04:03 cvsuser Exp $ * Key definitions. * ==noguard== * @@ -126,6 +126,7 @@ typedef int32_t KEY; #define RANGE_MULTIKEY (4 << 26) #define RANGE_PRIVATE (5 << 26) #define RANGE_BUTTON (6 << 26) +#define RANGE_SPECIAL (7 << 26) #define RANGE_MAX (15 << 26) #define RANGE_MASK 0x3c000000 @@ -134,6 +135,7 @@ typedef int32_t KEY; #define IS_FUNCTION(x) (((x) & RANGE_MASK) == RANGE_FUNCTION) // function key. #define IS_MULTIKEY(x) ((x) >= RANGE_MULTIKEY && (x) <= (RANGE_MULTIKEY + MULTIKEY_SIZE)) #define IS_BUTTON(x) (((x) & RANGE_MASK) == RANGE_BUTTON) // mouse button. +#define IS_SPECIAL(x) (((x) & RANGE_MASK) == RANGE_SPECIAL) // special events. #define MOD_SHIFT 0x00200000 // modifiers #define MOD_CTRL 0x00400000 @@ -146,6 +148,7 @@ typedef int32_t KEY; */ #define KEY_VOID 0x001fffff // null #define KEY_WINCH 0x001ffffe // winch/resize event +#define KEY_UNASSIGNED 0x001ffffd // unassigned hook #define KEY_UNICODE 0x001ffff0 // keyboard special /* @@ -390,10 +393,18 @@ typedef int32_t KEY; #define KEY_WRIGHT2 CTRL_KEYPAD_6 #define KEY_WUP2 CTRL_KEYPAD_8 +/* + * Special events, not keys. + */ +#define MOUSE_XTERM_KEY (RANGE_SPECIAL | 1) +#define MOUSE_SGR_KEY (RANGE_SPECIAL | 2) +#define PASTE_BRACKETED_EVT (RANGE_SPECIAL | 10) +#define MOUSE_FOCUSOUT_KEY (RANGE_SPECIAL | 11) +#define MOUSE_FOCUSIN_KEY (RANGE_SPECIAL | 12) + /* * Miscellaneous keys. */ -#define MOUSE_KEY (RANGE_MISC | 0) /* Xterm Mouse, not really a key. */ #define BACK_TAB (RANGE_MISC | 1) #define CTRL_TAB (RANGE_MISC | 2) #define ALT_TAB (RANGE_MISC | 3) @@ -419,8 +430,10 @@ typedef int32_t KEY; #define KEY_MENU (RANGE_MISC | 22) #define KEY_BREAK (RANGE_MISC | 23) -#define WHEEL_UP (RANGE_MISC | 31) /* Mouse scroll wheel */ +#define WHEEL_UP (RANGE_MISC | 31) #define WHEEL_DOWN (RANGE_MISC | 32) +#define WHEEL_LEFT (RANGE_MISC | 33) +#define WHEEL_RIGHT (RANGE_MISC | 34) /* * Mouse events. diff --git a/include/edcdefs.h b/include/edcdefs.h new file mode 100644 index 00000000..55b35882 --- /dev/null +++ b/include/edcdefs.h @@ -0,0 +1,64 @@ +#ifndef GR_EDCDEFS_H_INCLUDED +#define GR_EDCDEFS_H_INCLUDED +#include +__CPRAGMA_ONCE + +/* -*- mode: c; indent-width: 4; -*- */ +/* $Id: edcdefs.h,v 1.3 2024/07/14 15:30:51 cvsuser Exp $ + * interface + * + * __BEGIN_DECLS + * __END_DECLS + * __P + * __attribute__ + * + */ + +#if !defined(HAVE_CONFIG_H) +#error HAVE_CONFIG_H expected to be defined ... +#endif +#include + +#if defined(HAVE_SYS_CDEFS_H) +#include + +#else + +#if defined(__sun) +#include +#endif + +#ifndef __BEGIN_DECLS +# ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +# else +# define __BEGIN_DECLS +# define __END_DECLS +# endif +#endif +#ifndef __P +# if (__STDC__) || defined(__cplusplus) || \ + defined(_MSC_VER) || defined(__PARADIGM__) || defined(__GNUC__) || \ + defined(__BORLANDC__) || defined(__WATCOMC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif + +#if !defined(__GNUC__) && !defined(__clang__) +#ifndef __attribute__ /*FIXME: HAVE_ATTRIBUTE*/ +#define __attribute__(__x) +#endif +#endif + +#ifndef __unused +#define __unused +#endif + +#endif /*HAVE_SYS_CDEFS_H*/ + +#endif /*GR_EDCDEFS_H_INCLUDED*/ + + diff --git a/include/edendian.h b/include/edendian.h index 793c3fb5..3f9de60c 100644 --- a/include/edendian.h +++ b/include/edendian.h @@ -1,11 +1,11 @@ #ifndef GR_EDENDIAN_H_INCLUDED #define GR_EDENDIAN_H_INCLUDED #include -__CIDENT_RCSID(gr_edendian_h,"$Id: edendian.h,v 1.17 2024/04/08 15:07:02 cvsuser Exp $") +__CIDENT_RCSID(gr_edendian_h,"$Id: edendian.h,v 1.18 2024/07/17 17:34:11 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: edendian.h,v 1.17 2024/04/08 15:07:02 cvsuser Exp $ +/* $Id: edendian.h,v 1.18 2024/07/17 17:34:11 cvsuser Exp $ * Endian interface. * * @@ -38,11 +38,17 @@ __CPRAGMA_ONCE /* * BYTE_ORDER, source/ * + * + * * * */ #if defined(HAVE_ENDIAN_H) #include +#elif defined(HAVE_SYS_ENDIAN_H) +#include +#elif defined(HAVE_SYS_BYTEORDER_H) +#include /* Solaris */ #elif defined(HAVE_MACHINE_ENDIAN_H) #include #elif defined(HAVE_ARPA_NAMESER_COMPAT_H) @@ -57,37 +63,49 @@ __CPRAGMA_ONCE * IS_UNIVERSAL_BUILD */ #if defined(IS_BIG_ENDIAN) /* big endian */ -#define HOST_BIG_ENDIAN +# define HOST_BIG_ENDIAN #elif defined(IS_LITTLE_ENDIAN) /* little endian */ -#define HOST_LITTLE_ENDIAN +# define HOST_LITTLE_ENDIAN #elif defined(IS_UNIVERSAL_BUILD) || /* universal */ \ (defined(AC_APPLE_UNIVERSAL_BUILD) && (AC_APPLE_UNIVERSAL_BUILD)) -#define HOST_UNIVERSAL_ENDIAN +# define HOST_UNIVERSAL_ENDIAN #elif defined(IS_UNKNOWN_ENDIAN) /* unknown/error */ -#define HOST_UNKNOWN_ENDIAN +# define HOST_UNKNOWN_ENDIAN #elif defined(BYTE_ORDER) /* BYTE_ORDER */ -#if defined(BIG_ENDIAN) && (BYTE_ORDER == BIG_ENDIAN) -#define HOST_BIG_ENDIAN +# if defined(BIG_ENDIAN) && (BYTE_ORDER == BIG_ENDIAN) +# define HOST_BIG_ENDIAN -#elif defined(LITTLE_ENDIAN) && (BYTE_ORDER == LITTLE_ENDIAN) -#define HOST_LITTLE_ENDIAN +# elif defined(LITTLE_ENDIAN) && (BYTE_ORDER == LITTLE_ENDIAN) +# define HOST_LITTLE_ENDIAN -#elif defined(PDP_ENDIAN) && (BYTE_ORDER == PDP_ENDIAN) -#define HOST_UNKNOWN_ENDIAN -#error PDP_ENDIAN not supported ... +# elif defined(PDP_ENDIAN) && (BYTE_ORDER == PDP_ENDIAN) +# define HOST_UNKNOWN_ENDIAN +# error PDP_ENDIAN not supported ... -#else -#define HOST_UNKNOWN_ENDIAN -#error Unknown BYTE_ORDER configuration ... -#endif +# else +# define HOST_UNKNOWN_ENDIAN +# error Unknown BYTE_ORDER configuration ... +# endif + +#elif defined(_BYTE_ORDER) /* BYTE_ORDER (Solaris) */ +# if defined(_BIG_ENDIAN) && (_BYTE_ORDER == _BIG_ENDIAN) +# define HOST_BIG_ENDIAN + +# elif defined(_LITTLE_ENDIAN) && (_BYTE_ORDER == _LITTLE_ENDIAN) +# define HOST_LITTLE_ENDIAN + +# else +# define HOST_UNKNOWN_ENDIAN +# error Unknown _BYTE_ORDER configuration ... +# endif #else /* ??? */ -#define HOST_UNKNOWN_ENDIAN -#error Unknown target architecture ... +# define HOST_UNKNOWN_ENDIAN +# error Unknown target architecture ... #endif @@ -96,20 +114,26 @@ __CPRAGMA_ONCE * overkill?? */ #if defined(BYTE_ORDER) -#if defined(HOST_UNIVERSAL_ENDIAN) || defined(HOST_UNKNOWN_ENDIAN) -#error BYTE_ORDER and HIST_XXX_ENDIAN differ ... +#if defined(HOST_UNIVERSAL_ENDIAN) +#error BYTE_ORDER host universal endian ... + +#elif defined(HOST_UNKNOWN_ENDIAN) +#error BYTE_ORDER host unknown endian ... #elif defined(BIG_ENDIAN) && (BYTE_ORDER == BIG_ENDIAN) #if !defined(HOST_BIG__ENDIAN) -#error BYTE_ORDER and HIST_XXX_ENDIAN differ ... +#error BYTE_ORDER and HIST_XXX_ENDIAN differ (big/little) ... #endif #elif defined(LITTLE_ENDIAN) && (BYTE_ORDER == LITTLE_ENDIAN) #if !defined(HOST_LITTLE_ENDIAN) -#error BYTE_ORDER and HIST_XXX_ENDIAN differ ... +#error BYTE_ORDER and HIST_XXX_ENDIAN differ (little/big) ... #endif #endif #endif /*BYTE_ORDER*/ #endif /*GR_EDENDIAN_H_INCLUDED*/ /*end*/ + + + diff --git a/include/edfeatures.h b/include/edfeatures.h index aa62671a..f97cf3ae 100644 --- a/include/edfeatures.h +++ b/include/edfeatures.h @@ -1,11 +1,11 @@ #ifndef GR_EDFEATURES_H_INCLUDED #define GR_EDFEATURES_H_INCLUDED #include -__CIDENT_RCSID(gr_edfeatures_h,"$Id: edfeatures.h,v 1.18 2024/04/08 15:07:03 cvsuser Exp $") +__CIDENT_RCSID(gr_edfeatures_h,"$Id: edfeatures.h,v 1.23 2024/09/25 16:00:42 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: edfeatures.h,v 1.18 2024/04/08 15:07:03 cvsuser Exp $ +/* $Id: edfeatures.h,v 1.23 2024/09/25 16:00:42 cvsuser Exp $ * Editor features. * * @@ -64,12 +64,14 @@ __CBEGIN_DECLS #define TF_DEFAULT_FG 32 /* default foreground color */ #define TF_DEFAULT_BG 33 /* default background color */ #define TF_SCHEMEDARK 34 /* *true* if the default color is "dark" */ -#define TF_COLORSETFGBG 35 -#define TF_COLORSET_FG 36 /* color set foreground control sequence */ -#define TF_COLORSET_BG 37 /* color set background control sequence */ +#define TF_COLORRGB 35 /* *true* if RGB colors are supported */ +#define TF_COLORSET_FG 36 /* color set foreground control sequence (ANSI colors) */ +#define TF_COLORSET_BG 37 /* color set background control sequence (ANSI colors) */ #define TF_COLORMAP 38 /* color map (terminal) */ #define TF_COLORPALETTE 39 /* color palette (driver) */ -#define TF_COLORSCHEME 40 /* current scheme dark or light */ +#define TF_COLORSCHEME 40 /* current color-scheme */ +#define TF_COLORSETRGB_FG 41 /* color set foreground control sequence (RGB colors) */ +#define TF_COLORSETRGB_BG 42 /* color set background control sequence (RGB colors) */ #define TF_CLEAR_IS_BLACK 50 /* clear is black */ #define TF_DISABLE_INSDEL 51 /* disable ins/del scrolling method */ @@ -84,6 +86,7 @@ __CBEGIN_DECLS #define TF_ATTRIBUTES 60 /* terminal attribute flags */ #define TF_TTY_FAST 62 /* fast tty optimisations */ #define TF_TTY_GRAPHICSBOX 63 /* graphics mode required for box characters */ +#define TF_KBPROTOCOL 64 /* kbprotocol */ #define TF_SCREEN_ROWS 70 /* screen rows */ #define TF_SCREEN_COLS 71 /* screen cols */ @@ -96,8 +99,9 @@ __CBEGIN_DECLS #define TF_XTERM_COMPAT 82 /* XTERM compatible termuinal */ #define TF_XTERM_PALETTE 83 /* XTERM palette control */ -#define TF_VT_DATYPE 90 /* VT/XTERM Devive Attribute Type */ -#define TF_VT_DAVERSION 91 /* VT/XTERM Devive Attribute Version */ +#define TF_VT_DATYPE 90 /* VT/XTERM Device Attribute Type */ +#define TF_VT_DAVERSION 91 /* VT/XTERM Device Attribute Version */ +#define TF_VT_DAOPTIONS 92 /* VT/XTERM Device Attribute Options */ #define TF_ENCODING 100 /* terminal character encoding */ #define TF_ENCODING_GUESS 101 /* text encoding guess specification */ @@ -133,6 +137,9 @@ __CBEGIN_DECLS #define TF_AUTF8ENCODING 0x0000010 /* UTF8 character encoding, Unicode implied */ #define TF_AUNICODEENCODING 0x0000020 /* Unicode character encoding */ #define TF_AMETAKEY 0x0000100 /* Meta keys */ +#define TF_AXTERMKEYS 0x0000200 /* XTerm modifyOtherKeys */ +#define TF_AKITTYKEYS 0x0000400 /* Kitty extended keycodes */ +#define TF_AMSTERMINALKEYS 0x0000800 /* MS-Terminal extended keycodes */ /*--end--*/ @@ -182,9 +189,10 @@ struct _features { char pt_winsetsize[PT_ESCMAX]; /* STRING, Escape sequence, set window size (rows/cols). */ char pt_winsetpos[PT_ESCMAX]; /* STRING, Escape sequence, set window position (row/col). */ - char pt_colorsetfgbg[PT_ESCMAX]; /* STRING, Escape eequence, set foreground and background. */ - char pt_colorsetfg[PT_ESCMAX]; /* STRING, Escape sequence, set foreground color. */ - char pt_colorsetbg[PT_ESCMAX]; /* STRING, Escape sequence, set background color. */ + char pt_colorsetfg[PT_ESCMAX]; /* STRING, Escape sequence, set foreground color (ANSI). */ + char pt_colorsetbg[PT_ESCMAX]; /* STRING, Escape sequence, set background color (ANSI). */ + char pt_colorsetrgbfg[PT_ESCMAX]; /* STRING, Escape sequence, set background color (RGB). */ + char pt_colorsetrgbbg[PT_ESCMAX]; /* STRING, Escape sequence, set background color (RGB). */ char pt_graphics_mode[PT_ESCMAX]; /* STRING, Escape sequence, go into graphics mode. */ char pt_text_mode[PT_ESCMAX]; /* STRING, Escape sequence, go into text mode. */ @@ -201,6 +209,7 @@ struct _features { int pt_0m; /* BOOL, "\033[0m" resets color as well as character attributes. */ int pt_color; /* BOOL,INT TRUE if terminal supports color (> 1 states default depth). */ int pt_colordepth; /* INT, Color depth (active). */ + int pt_colorrgb; /* INT, RGB color support (truecolor/24bit). */ int pt_clrisblack; /* BOOL, Erasing line clears to a black space. */ int pt_scroll_disable; /* BOOL, Disable scroll regions. */ int pt_scroll_max; /* INT, Max scroll region size. */ @@ -222,6 +231,7 @@ struct _features { int pt_vtdatype; /* INT, Device attribute type. */ int pt_vtdaversion; /* INT, Device attribute version. */ + int pt_vtdaoptions; /* INT, Device attribute options */ int pt_tty_fast; /* INT, TTY fast screen optimisations. */ int pt_tty_graphicsbox; /* INT, TTY box characters require graphics mode. */ @@ -238,7 +248,8 @@ struct _features { char pt_colormap[512]; /* STRING, XTERM color map. */ char pt_colorpalette[512]; /* STRING, Driver color palette =. */ - char pt_colorscheme[32]; /* STRING, Current color scheme (dark or light). */ + char pt_colorscheme[128]; /* STRING, Current color scheme name. */ + char pt_kbprotocol[32]; /* STRING, Active kbprotocol. */ uint32_t pt_magic2; /* Structure magic. */ }; @@ -249,3 +260,5 @@ __CEND_DECLS #endif /*GR_EDFEATURES_H_INCLUDED*/ /*end*/ + + diff --git a/include/edhandles.h b/include/edhandles.h index 51f1fd29..f4d5f765 100644 --- a/include/edhandles.h +++ b/include/edhandles.h @@ -1,11 +1,11 @@ #ifndef GR_EDHANDLES_H_INCLUDED #define GR_EDHANDLES_H_INCLUDED #include -__CIDENT_RCSID(gr_edhandles_h,"$Id: edhandles.h,v 1.10 2024/04/08 15:07:03 cvsuser Exp $") +__CIDENT_RCSID(gr_edhandles_h,"$Id: edhandles.h,v 1.11 2024/08/17 08:36:27 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: edhandles.h,v 1.10 2024/04/08 15:07:03 cvsuser Exp $ +/* $Id: edhandles.h,v 1.11 2024/08/17 08:36:27 cvsuser Exp $ * Internal handle base identifiers. * * @@ -35,7 +35,7 @@ __CPRAGMA_ONCE #define GRBASE_FILE 2000 #define GRBASE_DIALOG 10000 /* 2^16 */ -#define GRBASE_CMAP 80000 +#define GRBASE_CMAP 80000 #define GRBASE_DICT 100000 #define GRBASE_INI 120000 #define GRBASE_FTP 140000 diff --git a/include/edheaders.h b/include/edheaders.h index cbdfbbf2..22215405 100644 --- a/include/edheaders.h +++ b/include/edheaders.h @@ -1,11 +1,11 @@ #ifndef GR_EDHEADERS_H_INCLUDED #define GR_EDHEADERS_H_INCLUDED #include -__CIDENT_RCSID(gr_edheaders_h,"$Id: edheaders.h,v 1.20 2024/06/09 20:09:36 cvsuser Exp $") +__CIDENT_RCSID(gr_edheaders_h,"$Id: edheaders.h,v 1.26 2024/07/14 09:58:17 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: edheaders.h,v 1.20 2024/06/09 20:09:36 cvsuser Exp $ +/* $Id: edheaders.h,v 1.26 2024/07/14 09:58:17 cvsuser Exp $ * System headers. * * @@ -138,14 +138,26 @@ __CPRAGMA_ONCE #include #endif -#ifdef HAVE_WAIT_H -#include -#endif - #ifdef HAVE_SYS_WAIT_H +#if defined(sun) || defined(__sun) +# if defined(HAVE_SYS_SIGINFO_H) +# include +# endif +#include +#endif /*sun*/ #include #endif +#ifdef HAVE_WAIT_H +#if defined(sun) || defined(__sun) +# if defined(HAVE_SYS_SIGINFO_H) +# include +# endif +#include +#endif /*sun*/ +#include +#endif + #if !defined(WNOHANG) && !defined(SOLARIS2) #define WNOHANG 1 #endif diff --git a/include/edmacros.h b/include/edmacros.h index f6a25b22..586fb4a1 100644 --- a/include/edmacros.h +++ b/include/edmacros.h @@ -1,11 +1,11 @@ #ifndef GR_EDMACROS_H_INCLUDED #define GR_EDMACROS_H_INCLUDED #include -__CIDENT_RCSID(gr_edmacros_h,"$Id: edmacros.h,v 1.23 2024/04/08 15:07:03 cvsuser Exp $") +__CIDENT_RCSID(gr_edmacros_h,"$Id: edmacros.h,v 1.24 2024/08/17 08:36:27 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: edmacros.h,v 1.23 2024/04/08 15:07:03 cvsuser Exp $ +/* $Id: edmacros.h,v 1.24 2024/08/17 08:36:27 cvsuser Exp $ * Macro and symbolic interpreter information. * * Copyright (c) 1998 - 2024, Adam Young. @@ -247,4 +247,3 @@ __CEND_DECLS #endif #endif /*GR_EDMACROS_H_INCLUDED*/ - diff --git a/include/edopcode.h b/include/edopcode.h index fb509315..cd305417 100644 --- a/include/edopcode.h +++ b/include/edopcode.h @@ -1,11 +1,11 @@ #ifndef GR_EDOPCODE_H_INCLUDED #define GR_EDOPCODE_H_INCLUDED #include -__CIDENT_RCSID(gr_edopcode_h,"$Id: edopcode.h,v 1.25 2024/04/08 15:07:03 cvsuser Exp $") +__CIDENT_RCSID(gr_edopcode_h,"$Id: edopcode.h,v 1.26 2024/08/17 08:36:27 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: edopcode.h,v 1.25 2024/04/08 15:07:03 cvsuser Exp $ +/* $Id: edopcode.h,v 1.26 2024/08/17 08:36:27 cvsuser Exp $ * List types. * * @@ -71,4 +71,3 @@ typedef enum opcodes { } OPCODE; #endif /*GR_EDOPCODE_H_INCLUDED*/ - diff --git a/include/edstdarg.h b/include/edstdarg.h index a413bd6c..afb75ebb 100644 --- a/include/edstdarg.h +++ b/include/edstdarg.h @@ -1,11 +1,11 @@ #ifndef GR_EDSTDARG_H_INCLUDED #define GR_EDSTDARG_H_INCLUDED #include -__CIDENT_RCSID(gr_edstdarg_h,"$Id: edstdarg.h,v 1.4 2024/04/08 15:07:03 cvsuser Exp $") +__CIDENT_RCSID(gr_edstdarg_h,"$Id: edstdarg.h,v 1.5 2024/08/17 08:36:27 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: edstdarg.h,v 1.4 2024/04/08 15:07:03 cvsuser Exp $ +/* $Id: edstdarg.h,v 1.5 2024/08/17 08:36:27 cvsuser Exp $ * stdarg() interface/implemenation. * * @@ -82,6 +82,3 @@ __CPRAGMA_ONCE #endif /*GR_EDSTDARG_H_INCLUDED*/ /*end*/ - - - diff --git a/include/edstruct.h b/include/edstruct.h index b8968da0..5f7f1f10 100644 --- a/include/edstruct.h +++ b/include/edstruct.h @@ -1,11 +1,11 @@ #ifndef GR_EDSTRUCT_H_INCLUDED #define GR_EDSTRUCT_H_INCLUDED #include -__CIDENT_RCSID(gr_edstruct_h,"$Id: edstruct.h,v 1.78 2024/05/17 16:46:09 cvsuser Exp $") +__CIDENT_RCSID(gr_edstruct_h,"$Id: edstruct.h,v 1.81 2024/09/12 17:29:13 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: edstruct.h,v 1.78 2024/05/17 16:46:09 cvsuser Exp $ +/* $Id: edstruct.h,v 1.81 2024/09/12 17:29:13 cvsuser Exp $ * Window, buffer, line and character-map definitions. * * @@ -350,6 +350,13 @@ struct _window { vbyte_t w_disp_ansicolor; /* ANSI color cursor */ unsigned w_disp_ansiflags; + struct WCoords { + int title_start; + int title_end; + int close_start; + int close_end; + } w_coords; /* Element coordinates */ + struct _wthumbs w_vthumb; /* Vertical elevator positions */ struct _wthumbs w_hthumb; /* Horizontal elevator positions */ @@ -611,7 +618,7 @@ struct _display { #endif char d_buf[PTY_BUFSIZ]; /* Buffer for reading into */ #endif -#if defined(unix) || defined(__APPLE__) +#if defined(unix) || defined(__unix__) || defined(__APPLE__) pid_t d_pgrp; /* Process group of child */ #endif }; @@ -1217,6 +1224,7 @@ extern const char * const nameof_atoms[]; extern const int x_major_version; extern const int x_minor_version; extern const int x_edit_version; +extern const int x_build_version; extern const char * x_appname; extern const char * x_version; diff --git a/include/edthreads.h b/include/edthreads.h index 96c64279..d0e2c08a 100644 --- a/include/edthreads.h +++ b/include/edthreads.h @@ -1,11 +1,11 @@ #ifndef GR_EDTHREADS_H_INCLUDED #define GR_EDTHREADS_H_INCLUDED #include -__CIDENT_RCSID(gr_edthreads_h,"$Id: edthreads.h,v 1.21 2024/04/08 15:07:03 cvsuser Exp $") +__CIDENT_RCSID(gr_edthreads_h,"$Id: edthreads.h,v 1.22 2024/08/17 08:36:27 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: edthreads.h,v 1.21 2024/04/08 15:07:03 cvsuser Exp $ +/* $Id: edthreads.h,v 1.22 2024/08/17 08:36:27 cvsuser Exp $ * Threads interface * ISO/IEC 9899:201x Committee Draft * April 12, 2011 N1570 @@ -126,4 +126,3 @@ extern struct timespec timespec_sub(struct timespec ts1, struct timespec ts __CEND_DECLS #endif /*GR_EDTHREADS_H_INCLUDED*/ - diff --git a/include/edtypes.h b/include/edtypes.h index 41ee3785..c780b27e 100644 --- a/include/edtypes.h +++ b/include/edtypes.h @@ -1,11 +1,11 @@ #ifndef GR_EDTYPES_H_INCLUDED #define GR_EDTYPES_H_INCLUDED #include -__CIDENT_RCSID(gr_edtypes_h,"$Id: edtypes.h,v 1.44 2024/05/02 17:20:29 cvsuser Exp $") +__CIDENT_RCSID(gr_edtypes_h,"$Id: edtypes.h,v 1.45 2024/07/14 14:27:13 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: edtypes.h,v 1.44 2024/05/02 17:20:29 cvsuser Exp $ +/* $Id: edtypes.h,v 1.45 2024/07/14 14:27:13 cvsuser Exp $ * Editor base types. * * @@ -351,7 +351,7 @@ typedef unsigned char LINEATTR; /* line attribute management */ #define __CBEGIN_DECLS #define __CEND_DECLS #endif -#endif /*__BEGIN_DECLS*/ +#endif /*__CBEGIN_DECLS*/ #ifndef __CSTRINGIZE #define ____CSTRINGIZE(s) #s diff --git a/include/libllist.h b/include/libllist.h index dcbb72ff..3c53b4dd 100644 --- a/include/libllist.h +++ b/include/libllist.h @@ -1,11 +1,11 @@ #ifndef GR_LIBLLIST_H_INCLUDED #define GR_LIBLLIST_H_INCLUDED #include -__CIDENT_RCSID(gr_llist_h,"$Id: libllist.h,v 1.20 2024/04/08 15:07:12 cvsuser Exp $") +__CIDENT_RCSID(gr_llist_h,"$Id: libllist.h,v 1.21 2024/08/17 08:36:27 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: libllist.h,v 1.20 2024/04/08 15:07:12 cvsuser Exp $ +/* $Id: libllist.h,v 1.21 2024/08/17 08:36:27 cvsuser Exp $ * Linked list management system * * @@ -138,4 +138,3 @@ extern struct llist * ll_unhook(List_p); __CEND_DECLS #endif /*GR_LIBLLIST_H_INCLUDED*/ - diff --git a/include/msvcversions.h b/include/msvcversions.h index 2b25456d..75bd4019 100644 --- a/include/msvcversions.h +++ b/include/msvcversions.h @@ -1,11 +1,11 @@ #ifndef GR_MSVCVERSIONS_H_INCLUDED #define GR_MSVCVERSIONS_H_INCLUDED #include -__CIDENT_RCSID(gr_msvcversions_h,"$Id: msvcversions.h,v 1.7 2024/06/09 14:05:15 cvsuser Exp $") +__CIDENT_RCSID(gr_msvcversions_h,"$Id: msvcversions.h,v 1.8 2024/08/17 08:36:27 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: msvcversions.h,v 1.7 2024/06/09 14:05:15 cvsuser Exp $ +/* $Id: msvcversions.h,v 1.8 2024/08/17 08:36:27 cvsuser Exp $ * _MSC_VER definitions * * Copyright (c) 2017 - 2024, Adam Young. @@ -52,6 +52,3 @@ __CPRAGMA_ONCE #define _MSC_VER_2003 1310 /* (Visual Studio 2003 / MSVC++ 7.1) */ #endif /*GR_MSVCVERSIONS_H_INCLUDED*/ - - - diff --git a/include/winntvers.h b/include/winntvers.h index 6fd0b2d3..ec7766dc 100644 --- a/include/winntvers.h +++ b/include/winntvers.h @@ -3,7 +3,7 @@ __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: winntvers.h,v 1.2 2024/04/10 15:50:54 cvsuser Exp $ +/* $Id: winntvers.h,v 1.3 2024/08/17 08:36:27 cvsuser Exp $ * _WIN32_WINNT version constants * */ @@ -27,4 +27,3 @@ __CPRAGMA_ONCE #endif //_WIN32_WINNT_NT4 #endif /*GR_WINNTVERS_H_INCLUDED*/ - diff --git a/libbsddb/mpool/mpool.c b/libbsddb/mpool/mpool.c index 21521cea..cd6a2632 100644 --- a/libbsddb/mpool/mpool.c +++ b/libbsddb/mpool/mpool.c @@ -412,8 +412,7 @@ mpool_look(MPOOL *mp, pgno_t pgno) * Print out cache statistics. */ void -mpool_stat(mp) - MPOOL *mp; +mpool_stat(MPOOL *mp) { BKT *bp; int cnt; diff --git a/libbsdfetch/common.c b/libbsdfetch/common.c index 55f6a96b..63e5f7eb 100644 --- a/libbsdfetch/common.c +++ b/libbsdfetch/common.c @@ -532,12 +532,16 @@ fetch_ssl(conn_t *conn, const struct url *URL, int verbose) #if defined(HAVE_OPENSSL) && (WITH_SSL) /* Init the SSL library and context */ +#if (OPENSSL_VERSION_NUMBER < 0x10100000L) /*1.1.1, defunct interface*/ if (!SSL_library_init()){ fprintf(stderr, "SSL library init failed\n"); return (-1); } SSL_load_error_strings(); +#else + OPENSSL_init_ssl(0, NULL); +#endif conn->ssl_meth = SSLv23_client_method(); conn->ssl_ctx = SSL_CTX_new(conn->ssl_meth); diff --git a/libbsdfetch/common.h b/libbsdfetch/common.h index d3fa12f8..ea3994fd 100644 --- a/libbsdfetch/common.h +++ b/libbsdfetch/common.h @@ -39,6 +39,9 @@ #define HTTP_DEFAULT_PROXY_PORT 3128 #if defined(HAVE_OPENSSL) && (WITH_SSL) +#if !defined(OPENSSL_API_COMPAT) /*MD5, 1.1.1*/ +#define OPENSSL_API_COMPAT 0x10101000L +#endif #include #include #include diff --git a/libbsdfetch/ftpeplf.c b/libbsdfetch/ftpeplf.c index 327e723e..a57b4f67 100644 --- a/libbsdfetch/ftpeplf.c +++ b/libbsdfetch/ftpeplf.c @@ -1,5 +1,5 @@ /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: ftpeplf.c,v 1.5 2020/06/05 23:45:01 cvsuser Exp $ +/* $Id: ftpeplf.c,v 1.6 2024/07/13 09:34:10 cvsuser Exp $ * FTP EPLF command reply parser. * * @@ -27,6 +27,7 @@ #endif #endif +#include #include #include #include diff --git a/libbsdfetch/ftpmlsx.c b/libbsdfetch/ftpmlsx.c index 7ed1c10a..81d76ea8 100644 --- a/libbsdfetch/ftpmlsx.c +++ b/libbsdfetch/ftpmlsx.c @@ -1,5 +1,5 @@ /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: ftpmlsx.c,v 1.5 2020/06/05 23:45:01 cvsuser Exp $ +/* $Id: ftpmlsx.c,v 1.6 2024/07/13 09:34:10 cvsuser Exp $ * FTP MLSx command reply parser. * * @@ -15,8 +15,8 @@ * ==end== */ -#define _BSD_SOURCE /* implied orgin */ - +#define _BSD_SOURCE /* implied origin */ + #if HAVE_CONFIG_H #include "config.h" #endif @@ -27,6 +27,7 @@ #endif #endif +#include #include #include #include diff --git a/libbsdfetch/http.c b/libbsdfetch/http.c index e41ebbb6..81fd014b 100644 --- a/libbsdfetch/http.c +++ b/libbsdfetch/http.c @@ -104,6 +104,12 @@ #include #if defined(HAVE_OPENSSL) && (WITH_SSL) +#if defined(__GNUC__) +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif #include #else #include "md5.h" diff --git a/libbsdio/bstdio.c b/libbsdio/bstdio.c index 054abd29..fffd4eb5 100644 --- a/libbsdio/bstdio.c +++ b/libbsdio/bstdio.c @@ -26,7 +26,10 @@ main(int argc, char **argv) static void t1(void) { - static const char s1[] = +#if defined(__clang__) +#pragma clang diagnostic ignored "-Winvalid-source-encoding" +#endif + static const unsigned char s1[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZéáúõûóüöíÉÁÕÚÖÜÓÛÍ"; char b1[512] = {0}; BFILE *f1; diff --git a/libbsdio/bstdio.h b/libbsdio/bstdio.h index 6ef45b0f..83e71059 100644 --- a/libbsdio/bstdio.h +++ b/libbsdio/bstdio.h @@ -37,8 +37,40 @@ * @(#)stdio.h 5.17 (Berkeley) 6/3/91 */ +#if defined(HAVE_CONFIG_H) +#include +#endif + +#if defined(HAVE_FEATURES_H) +#include +#endif + +#if defined(__BSTDIO_INTERNAL) || defined(_BSD_SOURCE) +#ifndef __BSD_VISIBLE +#define __BSD_VISIBLE 1 +#endif + +#if !defined(_DEFAULT_SOURCE) && \ + defined(__GLIBC__) && defined(__GLIBC_PREREQ) +#if __GLIBC_PREREQ(2, 20) +// see: https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html +#define _DEFAULT_SOURCE 1 +#endif +#endif + +#if !defined(_DEFAULT_SOURCE) +#ifndef _BSD_SOURCE +#define _BSD_SOURCE 1 +#endif +#endif -#include +#ifndef __POSIX_VISIBLE +#define __POSIX_VISIBLE 199506 +#endif + +#endif /*__BSTDIO_INTERNAL || _BSD_SOURCE*/ + +#include #include #include @@ -50,16 +82,6 @@ #define __va_list va_list #endif -#if defined(__BSTDIO_INTERNAL) || defined(_BSD_SOURCE) -#ifndef __BSD_VISIBLE -#define __BSD_VISIBLE 1 -#endif - -#ifndef __POSIX_VISIBLE -#define __POSIX_VISIBLE 1 -#endif -#endif - #if defined(__BSTDIO_INLINE) || defined(__BSTDIO_INTERNAL) #if !defined(__BSTDIO_INLINE) #define __BSTDIO_INLINE diff --git a/libbsdio/vfprintf.c b/libbsdio/vfprintf.c index 9d8aff63..e1c99337 100644 --- a/libbsdio/vfprintf.c +++ b/libbsdio/vfprintf.c @@ -46,6 +46,8 @@ // USE_MMAP // USE_DTOA +#include + #ifdef HAVE_STDARG_H #include #endif @@ -69,8 +71,6 @@ #if defined(USE_MMAP) #include #endif - -#include #include #include #include @@ -94,11 +94,11 @@ #include "local.h" #include "fvwrite.h" -#if defined(_WIN32) || defined(WIN32) -#if !defined(u_long) -#define u_long unsigned long -#endif -#endif +//#if defined(_WIN32) || defined(WIN32) +//#if !defined(u_long) +//#define u_long unsigned long +//#endif +//#endif static void __find_arguments(const char *fmt0, va_list ap, va_list **argtable, size_t *argtablesiz); static int __grow_type_table(unsigned char **typetable, int *tablesize); @@ -665,7 +665,7 @@ reswitch: switch (ch) { * -- ANSI X3J11 */ /* NOSTRICT */ - _umax = (u_long)GETARG(void *); + _umax = (unsigned long)GETARG(void *); base = HEX; xdigs = "0123456789abcdef"; flags |= HEXPREFIX; diff --git a/libbsdio/vfscanf.c b/libbsdio/vfscanf.c index 3904eea3..04767024 100644 --- a/libbsdio/vfscanf.c +++ b/libbsdio/vfscanf.c @@ -94,9 +94,9 @@ #if !defined(u_char) #define u_char unsigned char #endif -#if !defined(u_long) -#define u_long unsigned long -#endif +//#if !defined(u_long) +//#define u_long unsigned long +//#endif #endif static u_char *__sccl(char *, u_char *); diff --git a/libchartable/charseticonv.c b/libchartable/charseticonv.c index 4aa52b78..9bdacdd1 100644 --- a/libchartable/charseticonv.c +++ b/libchartable/charseticonv.c @@ -1,5 +1,5 @@ #include -__CIDENT_RCSID(gr_charseticonv_c,"$Id: charseticonv.c,v 1.25 2024/04/17 16:00:28 cvsuser Exp $") +__CIDENT_RCSID(gr_charseticonv_c,"$Id: charseticonv.c,v 1.26 2024/07/27 09:04:22 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ /* Conversion tables loader/interface. @@ -688,7 +688,7 @@ dlmod_error(int xerrno) int n; buffer[0] = 0; - if ((n = loadquery(L_GETMESSAGE, msgs, sizeof(msgs))) > 0) { + if ((n = loadquery(L_GETMESSAGES, msgs, sizeof(msgs))) > 0) { int m, len; len = strpush(0, buffer, "dlopen: "); diff --git a/libduktape/Makefile.in b/libduktape/Makefile.in index 08ecc43e..01b28ca7 100644 --- a/libduktape/Makefile.in +++ b/libduktape/Makefile.in @@ -1,5 +1,5 @@ # -*- mode: mak; -*- -# $Id: Makefile.in,v 1.19 2024/05/03 14:35:16 cvsuser Exp $ +# $Id: Makefile.in,v 1.21 2024/07/30 10:35:29 cvsuser Exp $ # libduktape makefile. # # @@ -44,12 +44,13 @@ XCLEAN= # Compilers, programs CC= @CC@ +CXX= @CXX@ AR= @AR@ RANLIB= @RANLIB@ RM= @RM@ +RC= @RC@ PERL= @PERL@ LIBTOOL= @LIBTOOL@ -RC= @RC@ # Configuration @@ -96,6 +97,10 @@ endif LDDEBUG= @LDDEBUG@ LDRELEASE= @LDRELEASE@ +ifeq (gcc,$(findstring gcc,$(CC))) +XFLAGS+= -Wno-deprecated-non-prototype -Wno-unused-parameter -Wno-unused-function +endif #gcc + CINCLUDE= -I. -I$(D_INC) @CINCLUDE@ CEXTRA= @DEFS@ diff --git a/libmisc/bsd_endian.h b/libmisc/bsd_endian.h index 67109398..32d8ba01 100644 --- a/libmisc/bsd_endian.h +++ b/libmisc/bsd_endian.h @@ -29,6 +29,19 @@ #include #include +#if (defined(__NetBSD__) && (defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE))) + +/* + * Suitable definitions available + */ + +#if !defined(HAVE_SYS_ENDIAN_H) +#error assumed ... +#elif !defined(ntohl) || !defined(ntohs) || !defined(htonl) || !defined(htons) +#error Unknown BSD endian configuration ... +#endif + +#else /* * General byte order swapping functions. @@ -188,5 +201,7 @@ le64enc(void *pp, uint64_t u) le32enc(p + 4, (uint32_t)(u >> 32)); } +#endif /*__NetBSD__*/ + #endif /*GR_BSD_ENDIAN_H_INCLUDED*/ /*end*/ diff --git a/libmisc/bsd_getoptl.c b/libmisc/bsd_getoptl.c index b7d72a0a..192c8833 100644 --- a/libmisc/bsd_getoptl.c +++ b/libmisc/bsd_getoptl.c @@ -1,5 +1,5 @@ #include -__CIDENT_RCSID(gr_bsd_getoptl_c,"$Id: bsd_getoptl.c,v 1.10 2024/04/10 16:27:40 cvsuser Exp $") +__CIDENT_RCSID(gr_bsd_getoptl_c,"$Id: bsd_getoptl.c,v 1.11 2024/06/13 07:55:54 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ /* $OpenBSD: getopt_long.c,v 1.25 2011/03/05 22:10:11 guenther Exp $ */ @@ -62,12 +62,12 @@ __CIDENT_RCSID(gr_bsd_getoptl_c,"$Id: bsd_getoptl.c,v 1.10 2024/04/10 16:27:40 c #include #include -#if defined(_WIN32) #if !defined(__CYGWIN__) -LIBW32_VAR int optreset; /* reset getopt */ -#endif +#if defined(_WIN32) +LIBW32_VAR int optreset; /* reset getopt */ #else -extern int optreset; /* reset getopt */ +extern int optreset; /* reset getopt */ +#endif #endif static const char *optprog = NULL; /* argv[0] */ diff --git a/libmisc/edbt_linux.c b/libmisc/edbt_linux.c index e273eb1f..e7f1f785 100644 --- a/libmisc/edbt_linux.c +++ b/libmisc/edbt_linux.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_edbt_linux_c,"$Id: edbt_linux.c,v 1.14 2024/04/17 15:57:13 cvsuser Exp $") +__CIDENT_RCSID(gr_edbt_linux_c,"$Id: edbt_linux.c,v 1.15 2024/06/14 19:06:23 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: edbt_linux.c,v 1.14 2024/04/17 15:57:13 cvsuser Exp $ +/* $Id: edbt_linux.c,v 1.15 2024/06/14 19:06:23 cvsuser Exp $ * linux backtrace implementation * * @@ -117,16 +117,30 @@ section_search(bfd *bfd, asection *section, void *data) return; } +#if defined(HAVE_BFD_SECTION_FLAGS) + if (0 == (bfd_section_flags(bfd, section) & SEC_ALLOC)) { + return; + } +#else if (0 == (bfd_get_section_flags(bfd, section) & SEC_ALLOC)) { return; } +#endif +#if defined(HAVE_BFD_SECTION_VMA) + vma = bfd_section_vma(bfd, section); +#else vma = bfd_get_section_vma(bfd, section); +#endif if (psi->si_pc < vma) { return; } +#if defined(HAVE_BFD_SECTION_SIZE) + size = bfd_section_size(section); +#else size = bfd_get_section_size(section); +#endif if (psi->si_pc >= vma + size) { return; } diff --git a/libmisc/edbt_unix.c b/libmisc/edbt_unix.c index 520b6e5d..bd6c18a7 100644 --- a/libmisc/edbt_unix.c +++ b/libmisc/edbt_unix.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_edbt_unix_c,"$Id: edbt_unix.c,v 1.10 2024/04/17 15:57:13 cvsuser Exp $") +__CIDENT_RCSID(gr_edbt_unix_c,"$Id: edbt_unix.c,v 1.17 2024/07/19 05:05:03 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: edbt_unix.c,v 1.10 2024/04/17 15:57:13 cvsuser Exp $ +/* $Id: edbt_unix.c,v 1.17 2024/07/19 05:05:03 cvsuser Exp $ * unix backtrace implementation * * @@ -33,6 +33,7 @@ __CIDENT_RCSID(gr_edbt_unix_c,"$Id: edbt_unix.c,v 1.10 2024/04/17 15:57:13 cvsus #if defined(HAVE_CONFIG_H) #include #endif + #include // #define HAVE_BACKTRACE @@ -40,7 +41,7 @@ __CIDENT_RCSID(gr_edbt_unix_c,"$Id: edbt_unix.c,v 1.10 2024/04/17 15:57:13 cvsus // #define HAVE_PSTACK // #define HAVE_PROCSTACK -#if defined(unix) +#if defined(unix) || defined(__unix__) #if !defined(__CYGWIN__) && !defined(linux) #if defined(HAVE_BACKTRACE) @@ -56,6 +57,9 @@ __CIDENT_RCSID(gr_edbt_unix_c,"$Id: edbt_unix.c,v 1.10 2024/04/17 15:57:13 cvsus #endif /*!PSTACK && !PROCSTACK*/ #if defined(HAVE_PSTACK) || defined(HAVE_PROCSTACK) +#include +#include +#include #include #include #endif diff --git a/libmisc/edthreads_pthread.c b/libmisc/edthreads_pthread.c index 5510b282..7abc7894 100644 --- a/libmisc/edthreads_pthread.c +++ b/libmisc/edthreads_pthread.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_edthreads_pthread_c,"$Id: edthreads_pthread.c,v 1.15 2024/04/27 15:22:32 cvsuser Exp $") +__CIDENT_RCSID(gr_edthreads_pthread_c,"$Id: edthreads_pthread.c,v 1.17 2024/07/27 12:58:52 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: edthreads_pthread.c,v 1.15 2024/04/27 15:22:32 cvsuser Exp $ +/* $Id: edthreads_pthread.c,v 1.17 2024/07/27 12:58:52 cvsuser Exp $ * C11 threads implementation, for/using pthreads * based on ISO/IEC 9899:201x Committee Draft, April 12, 2011 * @@ -43,6 +43,9 @@ edthreads_pthreads_native(void) #elif defined(HAVE_PTHREAD_H) || defined(__CYGWIN__) +#if defined(HAVE_STDINT_H) +#include +#endif #include #include #include @@ -56,7 +59,7 @@ struct threadproc { void *arg; }; -static void * ThreadProc(void *p); +static void *ThreadProc(void *p); // 7.25.2.1 @@ -518,8 +521,9 @@ ThreadProc(void *p) struct threadproc *proc = (struct threadproc *)p; thrd_start_t func = proc->func; void *arg = proc->arg; + free(p); - return (void *)(*func)(arg); + return (void *)(intptr_t)(*func)(arg); } @@ -594,7 +598,7 @@ thrd_equal(thrd_t thr0, thrd_t thr1) void thrd_exit(int res) { - pthread_exit((void *)res); + pthread_exit((void *)(intptr_t)res); } @@ -620,7 +624,7 @@ thrd_join(thrd_t thr, int *res) if (pthread_join(thr, &code) != 0) { return thrd_error; } - if (res) *res = (int)code; + if (res) *res = (int)(intptr_t)code; return thrd_success; } diff --git a/libmisc/edtrace.c b/libmisc/edtrace.c index 8c5e0d1b..97c08ecb 100644 --- a/libmisc/edtrace.c +++ b/libmisc/edtrace.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_edtrace_c,"$Id: edtrace.c,v 1.48 2024/04/27 15:22:32 cvsuser Exp $") +__CIDENT_RCSID(gr_edtrace_c,"$Id: edtrace.c,v 1.49 2024/06/13 16:56:21 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: edtrace.c,v 1.48 2024/04/27 15:22:32 cvsuser Exp $ +/* $Id: edtrace.c,v 1.49 2024/06/13 16:56:21 cvsuser Exp $ * Simple diagnostic trace. * * @@ -35,9 +35,7 @@ __CIDENT_RCSID(gr_edtrace_c,"$Id: edtrace.c,v 1.48 2024/04/27 15:22:32 cvsuser E #if defined(HAVE_SYS_TIME_H) #include #endif -#if !defined(HAVE_SYS_TIME_H) || defined(TIME_WITH_SYS_TIME) #include -#endif #include #include diff --git a/libmisc/stable.c b/libmisc/stable.c index 5fc200a4..725c18ef 100644 --- a/libmisc/stable.c +++ b/libmisc/stable.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_stable_c,"$Id: stable.c,v 1.17 2024/04/17 15:57:13 cvsuser Exp $") +__CIDENT_RCSID(gr_stable_c,"$Id: stable.c,v 1.18 2024/06/30 14:19:03 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: stable.c,v 1.17 2024/04/17 15:57:13 cvsuser Exp $ +/* $Id: stable.c,v 1.18 2024/06/30 14:19:03 cvsuser Exp $ * String tables ... * * Linear Hashing is a dynamic hash table algorithm invented by Witold Litwin in 1980. @@ -149,6 +149,7 @@ stbl_clear(stable_t *st) } st->table[ bucket ] = NULL; } + st->nodes = 0; } diff --git a/libmisc/stype.c b/libmisc/stype.c index 3d5626b9..fc6d188a 100644 --- a/libmisc/stype.c +++ b/libmisc/stype.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_stype_c,"$Id: stype.c,v 1.23 2024/04/17 15:57:14 cvsuser Exp $") +__CIDENT_RCSID(gr_stype_c,"$Id: stype.c,v 1.24 2024/06/30 14:19:20 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: stype.c,v 1.23 2024/04/17 15:57:14 cvsuser Exp $ +/* $Id: stype.c,v 1.24 2024/06/30 14:19:20 cvsuser Exp $ * Simple integer data table. * * @@ -404,7 +404,7 @@ stype_remove(stype_t * sp, sentry_t *sep) assert(sp && sep); assert(STMAGIC == sp->st_magic); assert(sep >= sp->st_block); - assert(sep < sp->st_block + sp->st_bused); + assert(sep < sp->st_block + sp->st_used); idx = sep - sp->st_block; assert(idx < sp->st_used); @@ -580,4 +580,5 @@ main(void) printf("stype complete\n"); return 0; } -#endif //DO_LOCALMAIN + +#endif //DO_LOCALMAIN \ No newline at end of file diff --git a/libmisc/timegetutc.c b/libmisc/timegetutc.c index 0f315680..9e40deaa 100644 --- a/libmisc/timegetutc.c +++ b/libmisc/timegetutc.c @@ -1,8 +1,8 @@ #include -__CIDENT_RCSID(gr_timegetutc_c,"$Id: timegetutc.c,v 1.10 2024/04/17 15:57:14 cvsuser Exp $") +__CIDENT_RCSID(gr_timegetutc_c,"$Id: timegetutc.c,v 1.11 2024/07/19 05:05:03 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: timegetutc.c,v 1.10 2024/04/17 15:57:14 cvsuser Exp $ +/* $Id: timegetutc.c,v 1.11 2024/07/19 05:05:03 cvsuser Exp $ * Portable (somewhat) method to determine GMT offset. * * @@ -40,7 +40,7 @@ time_t timeutcoffsetx(const int year, const int mon, const int mday, const int hour, const int min) { /* #if defined(HAVE_MKTIME) || \ - * defined(_MSC_VER) || defined(__WATCOMC__) || defined(unix) + * defined(_MSC_VER) || defined(__WATCOMC__) || defined(unix) || defined(__unix__) */ struct tm local_tm = {0}, utc_tm = {0}, *utc_tmptr; diff --git a/libonigrx/.cvsignore b/libonigrx/.cvsignore index 97c747fe..221e95d3 100644 --- a/libonigrx/.cvsignore +++ b/libonigrx/.cvsignore @@ -1,7 +1,9 @@ -Makefile -*.err -.unpacked.* onig-5.9.4 onig-5.9.5 onig-6.9.6 +onig-6.9.9 +Makefile +*.err +.unpacked.* + diff --git a/libonigrx/.gitignore b/libonigrx/.gitignore index e12e71bd..3c04804a 100644 --- a/libonigrx/.gitignore +++ b/libonigrx/.gitignore @@ -1,7 +1,5 @@ onig-5.9.4/ onig-5.9.5/ onig-6.9.6/ -Makefile.in.* +onig-6.9.9/ .unpacked.* -*.tgz - diff --git a/libonigrx/Makefile.in b/libonigrx/Makefile.in index 830db2e7..fceebf08 100644 --- a/libonigrx/Makefile.in +++ b/libonigrx/Makefile.in @@ -1,5 +1,5 @@ # -*- mode: mak; indent-tabs-mode: t; tab-width: 8 -*- -# $Id: Makefile.in,v 1.16 2024/05/19 17:04:25 cvsuser Exp $ +# $Id: Makefile.in,v 1.18 2024/07/20 18:12:39 cvsuser Exp $ # libonigrx - regular expression makefile. # # @@ -51,6 +51,15 @@ LIBTOOL= @LIBTOOL@ # Configuration +QUIETOUT:= >/dev/null 2>&1 +ifeq ($(VERBOSE),1) +QUIETOUT:= +else ifeq ($(VERBOSE),0) +else ifeq ($(VERBOSE),) +else +$(error VERBOSE: unexpected value 0 or 1 required, $(VERBOSE) given])) +endif + ifeq ("$(BUILD_TYPE)","") #default BUILD_TYPE= debug MAKEFLAGS+= BUILD_TYPE=debug @@ -81,7 +90,7 @@ CRELEASE= @CRELEASE@ LDDEBUG= @LDDEBUG@ LDRELEASE= @LDRELEASE@ -CINCLUDE= -I$(D_INC) @CINCLUDE@ +CINCLUDE= -I. -I$(D_INC) @CINCLUDE@ CEXTRA= @DEFS@ CEXTRA+= -DUSE_POSIX_API -DUSE_BINARY_COMPATIBLE_POSIX_API ifeq ("wcl386","@CC@") @@ -121,7 +130,7 @@ else RELIB= $(D_LIB)/$(LP)onigrx$(A) endif -VERSION= 6.9.6 +VERSION= 6.9.9 VERSIONSPEC= $(subst .,:,$(VERSION)) REPACKED= onig-$(VERSION).tgz @@ -187,14 +196,16 @@ debug: $(RELIB): CEXTRA+=-DONIG_EXTERN=extern $(RELIB): $(D_OBJ)/.created $(D_OBJ)/enc/.created $(LIBOBJS) - $(RM) $(RMFLAGS) $@ >/dev/null 2>&1 + $(RM) $(RMFLAGS) $@ $(QUIETOUT) $(AR) $(ARFLAGS) $@ $(LIBOBJS) $(RANLIB) $@ ifeq ("yes","@ISWIN32@") +XCLEAN += $(basename $(REDLL)).map +$(REDLL): MAPFILE=$(basename $@).map $(REDLL): $(D_OBJ)/.created $(D_OBJ)/enc/.created $(DLLOBJS) $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ $(DLLOBJS) -version-number $(VERSIONSPEC) \ - -rpath $(D_LIB) -bindir $(D_BIN) $(LDLIBS) + -rpath $(D_LIB) -bindir $(D_BIN) $(LDLIBS) @LDMAPFILE@ endif source: .unpacked.$(VERSION) @@ -215,8 +226,14 @@ installinc: -@mkdir $(@D) @echo "do not delete, managed directory" > $@ +ifeq ("yes","@ISWIN32@") clean: - -@$(RM) $(RMFLAGS) $(BAK) $(TSKS) $(LIBS) $(OBJS) $(CLEAN) $(XCLEAN) >/dev/null 2>&1 + -@$(LIBTOOL) --mode=clean $(RM) $(REDLL) $(DLLOBJS) $(QUIETOUT) + -@$(RM) $(RMFLAGS) $(BAK) $(TSKS) $(LIBS) $(OBJS) $(CLEAN) $(XCLEAN) $(QUIETOUT) +else +clean: + -@$(RM) $(RMFLAGS) $(BAK) $(TSKS) $(LIBS) $(OBJS) $(CLEAN) $(XCLEAN) $(QUIETOUT) +endif ## $(D_OBJ)/%$(O): $(RESRC)/%.c diff --git a/libonigrx/README.txt b/libonigrx/README.txt index 140dcac4..7e0052d7 100644 --- a/libonigrx/README.txt +++ b/libonigrx/README.txt @@ -11,21 +11,17 @@ Oniguruma is Japanese for "Devil's Chariot". - Source, http://www.geocities.jp/kosako3/oniguruma + Source: + https://github.com/kkos/oniguruma + http://www.geocities.jp/kosako3/oniguruma (old) Releases: - - o 6.9.6 (patched), 5 Nov, 2020 - - WatcomC tweaks. - - o 5.9.5 (patched), October 21, 2013 - - 'onig_reg_init' modified, replaced regex_t reference. + + 6.9.9, Oct 14, 2023 Copyright: - Copyright (c) 2002-2020 K.Kosako + Copyright (c) 2002-2021 K.Kosako All rights reserved. Redistribution and use in source and binary forms, with or without @@ -48,4 +44,3 @@ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/libonigrx/config.h b/libonigrx/config.h new file mode 100644 index 00000000..a35bda57 --- /dev/null +++ b/libonigrx/config.h @@ -0,0 +1,39 @@ +#ifndef LIBONIGRX_CONFIG_H_INCLUDED +#define LIBONIGRX_CONFIG_H_INCLUDED +/* -*- mode: c; indent-width: 4; -*- */ +/* $Id: config.h,v 1.4 2024/08/24 15:11:13 cvsuser Exp $ + * libonigrx config.h + * + * + */ + +#if defined(_WIN32) || defined(WIN32) + +#include "../libw32/config.h" + +#if defined(_MSC_VER) || defined(__WATCOMC__) +#if !defined(inline) +#define inline _inline +#endif +#endif + +#if defined(__WATCOMC__) +#define xvsnprintf _vsnprintf /*regint.h*/ +#define xsnprintf _snprintf /*regint.h/regposerr.c*/ +#define xstrncpy strncpy /*regposerr.c*/ +#endif + +#else +#include "../include/config.h" + +#if defined(__sun) +#if defined(HAVE_ALLOCA_H) +#include +#endif +#endif /*__sun*/ + +#endif /*!WIN32*/ + +#endif /*LIBONIGRX_CONFIG_H_INCLUDED*/ + +/*end*/ diff --git a/libonigrx/onig-6.9.6.tgz b/libonigrx/onig-6.9.6.tgz deleted file mode 100644 index 90e6a58e..00000000 Binary files a/libonigrx/onig-6.9.6.tgz and /dev/null differ diff --git a/libonigrx/onig-6.9.9.tgz b/libonigrx/onig-6.9.9.tgz new file mode 100644 index 00000000..c946b854 Binary files /dev/null and b/libonigrx/onig-6.9.9.tgz differ diff --git a/libteken/teken_stress.c b/libteken/teken_stress.c index ff2e03b1..2c737fc8 100644 --- a/libteken/teken_stress.c +++ b/libteken/teken_stress.c @@ -28,7 +28,7 @@ * $FreeBSD: head/sys/teken/stress/teken_stress.c 326272 2017-11-27 15:23:17Z pfg $ */ -#include +#include #include #include diff --git a/libterm/termcap.c b/libterm/termcap.c index 3f3d9d6b..0709d10c 100644 --- a/libterm/termcap.c +++ b/libterm/termcap.c @@ -28,19 +28,21 @@ */ /* - * #include - * #include - * #include - * #include - * #include - * #include - * #include - * #include - * #include + * #include + * #include + * #include + * #include + * #include + * #include + * #include + * #include + * #include */ -#if defined(__linux__) || defined(__CYGWIN32__) || defined(__MINGW32__) -#define _GNU_SOURCE /* XXX: asprintf */ +#if defined(__linux__) || defined(__CYGWIN__) || defined(__MINGW32__) +#if !defined(_GNU_SOURCE) +#define _GNU_SOURCE /* XXX: asprintf */ +#endif #endif #include @@ -271,6 +273,49 @@ t_getent(struct tinfo **bp, const char *name) return error; } + +#if !defined(_GNU_SOURCE) +#if defined(_MSC_VER) || defined(__WATCOMC__) +static int /*XXX - libcompat*/ +asprintf(char **strp, const char *format, ...) +{ + char *str = NULL; + va_list ap; + int ret; + + /* size */ + va_start(ap, format); +#if defined(_MSC_VER) + ret = _vscprintf(format, ap); +#else + ret = sprintf(NULL, format, ap); +#endif + if (ret == -1) + goto error; + ++ret; /*nul*/ + str = (char *)malloc((size_t) ret); + if (str == NULL) + goto error; + va_end(ap); + + /* populate */ + va_start(ap, format); + ret = _vsnprintf(str, ret, format, ap); + if (ret == -1) + goto error; + va_end(ap); + *strp = str; + return ret; + +error:; + if (str) free(str); + va_end(ap); + return -1; +} +#endif /*_MSC_VER || __WATCOMC__*/ +#endif /*_GNU_SOURCE*/ + + /* * Get an entry for terminal name in buffer bp from the termcap file. */ diff --git a/libtre/.gitignore b/libtre/.gitignore index 67b0eaf0..36154ba9 100644 --- a/libtre/.gitignore +++ b/libtre/.gitignore @@ -1,4 +1,6 @@ tre-master/ +tre-0.8.0.tgz +*1402* tre-config.h tre.h .unpacked.* diff --git a/libtre/Makefile.in b/libtre/Makefile.in index 436f16a1..c7d4da2e 100644 --- a/libtre/Makefile.in +++ b/libtre/Makefile.in @@ -1,5 +1,5 @@ # -*- mode: mak; indent-tabs-mode: t; tab-width: 8 -*- -# $Id: Makefile.in,v 1.13 2024/04/17 15:57:15 cvsuser Exp $ +# $Id: Makefile.in,v 1.16 2024/06/15 18:53:09 cvsuser Exp $ # libtre - regular expression library makefile. # # @@ -52,6 +52,15 @@ RC= @RC@ # Configuration +QUIETOUT:= >/dev/null 2>&1 +ifeq ($(VERBOSE),1) +QUIETOUT:= +else ifeq ($(VERBOSE),0) +else ifeq ($(VERBOSE),) +else +$(error VERBOSE: unexpected value 0 or 1 required, $(VERBOSE) given])) +endif + ifeq ("$(BUILD_TYPE)","") #default BUILD_TYPE= debug MAKEFLAGS+= BUILD_TYPE=debug @@ -72,7 +81,8 @@ D_LIB= $(ROOT)/lib@TOOLCHAINEXT@/$(BUILD_TYPE) XFLAGS= CFLAGS= @CFLAGS@ ifeq ("gcc","@CC@") -CWARN= $(filter-out -Wshadow -Wmissing-prototypes -Wsign-compare -Wno-unused-value, @CWARN@ $(CWALL)) -Wno-sign-compare -Wno-unused-value +CWARN= $(filter-out -Wshadow -Wmissing-prototypes -Wsign-compare -Wunused-value, @CWARN@ $(CWALL)) -Wno-sign-compare -Wno-unused-value +CWARN+= -Wno-free-nonheap-object else CWARN= @CWARN@ $(CWALL) endif @@ -109,13 +119,13 @@ else RELIB= $(D_LIB)/$(LP)tre$(A) endif -VERSION= 0.8.0 +VERSION= 0.8.1 VERSIONSPEC= $(subst .,:,$(VERSION)) -REPACKED= tre-master.zip +REPACKED= tre-master-202406.zip UNPACKEDLABEL= .unpacked.tre-master -#UNPACKEDLABEL= .unpacked.$(VERSION) RESRC= ./tre-master/lib +REINC= ./tre-master/local_includes XCLEAN+= ./tre.h LIBOBJS=\ @@ -170,24 +180,26 @@ debug: $(RELIB): CEXTRA += -D__LIBTRE_BUILD -DLIBTRE_STATIC $(RELIB): $(D_OBJ)/.created $(LIBOBJS) - $(RM) $(RMFLAGS) $@ >/dev/null 2>&1 + $(RM) $(RMFLAGS) $@ $(QUIETOUT) $(AR) $(ARFLAGS) $@ $(LIBOBJS) $(RANLIB) $@ ifeq ("yes","@ISWIN32@") $(REDLL): DLLDEF = -export-symbols tre.def endif +XCLEAN += $(basename $(REDLL)).map $(REDLL): CEXTRA += -D__LIBTRE_BUILD -DLIBTRE_DLL +$(REDLL): MAPFILE=$(basename $@).map $(REDLL): $(D_OBJ)/.created $(DLLOBJS) $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ $(DLLOBJS) -version-number $(VERSIONSPEC) \ - -rpath $(D_LIB) -bindir $(D_BIN) $(DLLDEF) $(LDLIBS) + -rpath $(D_LIB) -bindir $(D_BIN) $(DLLDEF) $(LDLIBS) @LDMAPFILE@ source: $(UNPACKEDLABEL) @$(MAKE) unpacked -./tre.h: $(RESRC)/tre.h tredecl.pl Makefile +./tre.h: $(REINC)/tre.h tredecl.pl Makefile @echo importing tre.h ... - @$(PERL) tredecl.pl + @$(PERL) tredecl.pl --in=$(REINC)/tre.h ifeq (zip,$(findstring zip,$(REPACKED))) $(UNPACKEDLABEL): $(REPACKED) @@ -210,8 +222,14 @@ installinc: -@mkdir $(@D) @echo "do not delete, managed directory" > $@ +ifeq ("yes","@ISWIN32@") clean: - -@$(RM) $(RMFLAGS) $(BAK) $(TSKS) $(LIBS) $(OBJS) $(CLEAN) $(XCLEAN) >/dev/null 2>&1 + -@$(LIBTOOL) --mode=clean $(RM) $(REDLL) $(DLLOBJS) $(QUIETOUT) + -@$(RM) $(RMFLAGS) $(BAK) $(TSKS) $(LIBS) $(OBJS) $(CLEAN) $(XCLEAN) $(QUIETOUT) +else +clean: + -@$(RM) $(RMFLAGS) $(BAK) $(TSKS) $(LIBS) $(OBJS) $(CLEAN) $(XCLEAN) $(QUIETOUT) +endif ## $(D_OBJ)/%$(O): $(RESRC)/%.c diff --git a/libtre/config.h b/libtre/config.h index eeaa2c5e..25d7843a 100644 --- a/libtre/config.h +++ b/libtre/config.h @@ -1,7 +1,7 @@ #ifndef LIBTRE_CONFIG_H_INCLUDED #define LIBTRE_CONFIG_H_INCLUDED /* -*- mode: c; indent-width: 4; -*- */ -/* $Id: config.h,v 1.5 2022/05/26 02:13:06 cvsuser Exp $ +/* $Id: config.h,v 1.7 2024/07/20 17:41:35 cvsuser Exp $ * libtre config.h * * @@ -21,12 +21,19 @@ #if (_MSC_VER < 1900) #define snprintf _snprintf #endif -#endif //_MSC_VER +#endif /*_MSC_VER*/ #else #include "../include/config.h" + +#if defined(__sun) +#if defined(HAVE_ALLOCA_H) +#include #endif +#endif /*__sun*/ -#endif /*LIBTRE_CONFIG_H_INCLUDED*/ -/*end*/ +#endif /*!WIN32*/ +#endif /*LIBTRE_CONFIG_H_INCLUDED*/ + +/*end*/ diff --git a/libtre/source.txt b/libtre/source.txt index 0e4824af..c7b8169f 100644 --- a/libtre/source.txt +++ b/libtre/source.txt @@ -1,23 +1,311 @@ - Source: https://github.com/laurikari/tre/ - +# Reference + + Source: https://github.com/laurikari/tre/ - Latest release was version 0.8.0 as at (20 Sep 2009). - - - Introduction - - TRE is a lightweight, robust, and efficient POSIX compliant regexp matching - library with some exciting features such as approximate (fuzzy) matching. - - The matching algorithm used in TRE uses linear worst-case time in the length - of the text being searched, and quadratic worst-case time in the length of - the used regular expression. - - In other words, the time complexity of the algorithm is O(M^2N), where M is - the length of the regular expression and N is the length of the text. The used - space is also quadratic on the length of the regex, but does not depend on the - searched string. This quadratic behaviour occurs only on pathological cases - which are probably very rare in practice. - - + Latest release was version 0.8.x as at (June 2024). + +# README + +## Looking for maintainers! + +This project is looking for maintainers. For starters, there are a few +pull requests waiting for review. + +Let me know at ville@laurikari.net if you wish to step up! + +Introduction +============ + +TRE is a lightweight, robust, and efficient POSIX compliant regexp +matching library with some exciting features such as approximate +(fuzzy) matching. + +The matching algorithm used in TRE uses linear worst-case time in +the length of the text being searched, and quadratic worst-case +time in the length of the used regular expression. + +In other words, the time complexity of the algorithm is O(M^2N), where +M is the length of the regular expression and N is the length of the +text. The used space is also quadratic on the length of the regex, but +does not depend on the searched string. This quadratic behaviour +occurs only on pathological cases which are probably very rare in +practice. + + +Hacking +======= + +Here's how to work with this code. + +Prerequisites +------------- + +You will need the following tools installed on your system: + + - autoconf + - automake + - gettext + - libtool + - zip (optional) + +If you choose to use the "waf" build system you will need python 3.5 +or above. See the file "README_waf.txt" for more information. + +Building +-------- + +First, prepare the tre. Change to the root of the source directory +and run +``` +./utils/autogen.sh +``` +This will regenerate various things using the prerequisite tools so +that you end up with a buildable tree. + +After this, you can run the configure script and build TRE as usual: +``` +./configure +make +make check +make install +``` + + +Building a source code package +------------------------------ + +In a prepared tree, this command creates a source code tarball: +``` +./configure && make dist +``` + +Alternatively, you can run +``` +./utils/build-sources.sh +``` +which builds the source code packages and puts them in the `dist` +subdirectory. This script needs a working `zip` command. + + +Features +======== + +TRE is not just yet another regexp matcher. TRE has some features +which are not there in most free POSIX compatible implementations. +Most of these features are not present in non-free implementations +either, for that matter. + +Approximate matching +-------------------- + +Approximate pattern matching allows matches to be approximate, that +is, allows the matches to be close to the searched pattern under +some measure of closeness. TRE uses the edit-distance measure (also +known as the Levenshtein distance) where characters can be +inserted, deleted, or substituted in the searched text in order to +get an exact match. + +Each insertion, deletion, or substitution adds the distance, or cost, +of the match. TRE can report the matches which have a cost lower than +some given threshold value. TRE can also be used to search for matches +with the lowest cost. + +TRE includes a version of the agrep (approximate grep) command line +tool for approximate regexp matching in the style of grep. Unlike +other agrep implementations (like the one by Sun Wu and Udi Manber +from University of Arizona) TRE agrep allows full regexps of any +length, any number of errors, and non-uniform costs for insertion, +deletion and substitution. + +Strict standard conformance +--------------------------- + +POSIX defines the behaviour of regexp functions precisely. TRE +attempts to conform to these specifications as strictly as possible. +TRE always returns the correct matches for subpatterns, for example. +Very few other implementations do this correctly. In fact, the only +other implementations besides TRE that I am aware of (free or not) +that get it right are Rx by Tom Lord, Regex++ by John Maddock, and the +AT&T ast regex by Glenn Fowler and Doug McIlroy. + +The standard TRE tries to conform to is the IEEE Std 1003.1-2001, +or Open Group Base Specifications Issue 6, commonly referred to as +"POSIX". It can be found online here. The relevant parts are the +base specifications on regular expressions (and the rationale) and +the description of the regcomp() API. + +For an excellent survey on POSIX regexp matchers, see the testregex +pages by Glenn Fowler of AT&T Labs Research. + +Predictable matching speed +-------------------------- + +Because of the matching algorithm used in TRE, the maximum time +consumed by any regexec() call is always directly proportional to +the length of the searched string. There is one exception: if back +references are used, the matching may take time that grows +exponentially with the length of the string. This is because +matching back references is an NP complete problem, and almost +certainly requires exponential time to match in the worst case. + +Predictable and modest memory consumption +----------------------------------------- + +A regexec() call never allocates memory from the heap. TRE +allocates all the memory it needs during a regcomp() call, and some +temporary working space from the stack frame for the duration of +the regexec() call. The amount of temporary space needed is +constant during matching and does not depend on the searched +string. For regexps of reasonable size TRE needs less than 50K of +dynamically allocated memory during the regcomp() call, less than +20K for the compiled pattern buffer, and less than two kilobytes of +temporary working space from the stack frame during a regexec() +call. There is no time/memory tradeoff. TRE is also small in code +size; statically linking with TRE increases the executable size +less than 30K (gcc-3.2, x86, GNU/Linux). + +Wide character and multibyte character set support +-------------------------------------------------- + +TRE supports multibyte character sets. This makes it possible to +use regexps seamlessly with, for example, Japanese locales. TRE +also provides a wide character API. + +Binary pattern and data support +------------------------------- + +TRE provides APIs which allow binary zero characters both in +regexps and searched strings. The standard API cannot be easily +used to, for example, search for printable words from binary data +(although it is possible with some hacking). Searching for patterns +which contain binary zeroes embedded is not possible at all with +the standard API. + +Completely thread safe +---------------------- + +TRE is completely thread safe. All the exported functions are +re-entrant, and a single compiled regexp object can be used +simultaneously in multiple contexts; e.g. in main() and a signal +handler, or in many threads of a multithreaded application. + +Portable +-------- + +TRE is portable across multiple platforms. Here's a table of +platforms and compilers that have been successfully used to compile +and run TRE: + + + + + + + + + + + + + + + + +
Platform(s) Compiler(s)
AIX 4.3.2 - 5.3.0 GCC, C for AIX compiler version 5
Compaq Tru64 UNIX V5.1A/B Compaq C V6.4-014 - V6.5-011
Cygwin 1.3 - 1.5 GCC
Digital UNIX V4.0 DEC C V5.9-005
FreeBSD 4 and above GCC
GNU/Linux systems on x86, x86_64, ppc64, s390GCC
HP-UX 10.20- 11.00 GCC, HP C Compiler
IRIX 6.5 GCC, MIPSpro Compilers 7.3.1.3m
Max OS X
NetBSD 1.5 and above GCC, egcs
OpenBSD 3.3 and above GCC
Solaris 2.7-10 sparc/x86 GCC, Sun Workshop 6 compilers
Windows 98 - XP Microsoft Visual C++ 6.0
+ + +TRE 0.7.5 should compile without changes on all of the above +platforms. Tell me if you are using TRE on a platform that is not +listed above, and I'll add it to the list. Also let me know if TRE +does not work on a listed platform. + +Depending on the platform, you may need to install libutf8 to get +wide character and multibyte character set support. + +Free +---- + +TRE is released under a license which is essentially the same as +the "2 clause" BSD-style license used in NetBSD. See the file +LICENSE for details. + +Roadmap +------- + +There are currently two features, both related to collating +elements, missing from 100% POSIX compliance. These are: + +* Support for collating elements (e.g. [[.\.]], where \ is a + collating element). It is not possible to support + multi-character collating elements portably, since POSIX does + not define a way to determine whether a character sequence is a + multi-character collating element or not. + +* Support for equivalence classes, for example [[=\=]], where + \ is a collating element. An equivalence class matches any + character which has the same primary collation weight as + \. Again, POSIX provides no portable mechanism for + determining the primary collation weight of a collating + element. + +Note that other portable regexp implementations don't support +collating elements either. The single exception is Regex++, which +comes with its own database for collating elements for different +locales. Support for collating elements and equivalence classes has +not been widely requested and is not very high on the TODO list at +the moment. + +These are other features I'm planning to implement real soon now: + +* All the missing GNU extensions enabled in GNU regex, such as + [[:<:]] and [[:>:]] + +* A REG_SHORTEST regexec() flag for returning the shortest match + instead of the longest match. + +* Perl-compatible syntax + * `[:^class:]` + Matches anything but the characters in class. Note that + `[^[:class:]]` works already, this would be just a + convenience shorthand. + + * `\A` + Match only at beginning of string + + * `\Z` + Match only at end of string, or before newline at the end + + * `\z` + Match only at end of string + + * `\l` + Lowercase next char (think vi) + + * `\u` + Uppercase next char (think vi) + + * `\L` + Lowercase till \E (think vi) + + * `\U` + Uppercase till \E (think vi) + + * `(?=pattern)` + Zero-width positive look-ahead assertions. + + * `(?!pattern)` + Zero-width negative look-ahead assertions. + + * `(?<=pattern)` + Zero-width positive look-behind assertions. + + * `(? \$o_dryrun, - 'in' => \$o_trein, - 'out' => \$o_treout, + 'in:s' => \$o_trein, + 'out:s' => \$o_treout, 'help' => \$o_help ); diff --git a/libtrie/Makefile.in b/libtrie/Makefile.in index 10346db6..b603bbd6 100644 --- a/libtrie/Makefile.in +++ b/libtrie/Makefile.in @@ -1,5 +1,5 @@ # -*- mode: mak; indent-tabs-mode: t; tab-width: 8 -*- -# $Id: Makefile.in,v 1.9 2024/05/19 15:53:42 cvsuser Exp $ +# $Id: Makefile.in,v 1.10 2024/06/16 17:01:42 cvsuser Exp $ # libtrie - prefix tree # # @@ -73,7 +73,7 @@ endif D_INC= $(ROOT)/include D_BIN= $(ROOT)/bin@TOOLCHAINEXT@/$(BUILD_TYPE) -D_OBJ= $(ROOT)/obj@TOOLCHAINEXT@/$(BUILD_TYPE)/libmisc +D_OBJ= $(ROOT)/obj@TOOLCHAINEXT@/$(BUILD_TYPE)/libtrie D_LIB= $(ROOT)/lib@TOOLCHAINEXT@/$(BUILD_TYPE) # Common flags @@ -96,7 +96,7 @@ LDDEBUG= @LDDEBUG@ LDRELEASE= @LDRELEASE@ ifeq (gcc,$(findstring gcc,$(CC))) -XFLAGS+= -Wno-deprecated-non-prototype +XFLAGS+= -Wno-deprecated-non-prototype -Wno-unused-parameter endif #gcc CINCLUDE= -I$(D_INC) @CINCLUDE@ diff --git a/libtrie/trie_test.c b/libtrie/trie_test.c index f28d0e0f..3005f5f6 100644 --- a/libtrie/trie_test.c +++ b/libtrie/trie_test.c @@ -321,12 +321,12 @@ test2(void) int ret = trie_replace(t, "CMAKE_+_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES", NULL, NULL); TEST2(0 == ret, "trie_replace"); TEST(size == trie_size(t)); /* node count */ - TEST((count - 1) == trie_count(t, "")); /* non-null element count */ + TEST((size_t)(count - 1) == trie_count(t, "")); /* non-null element count */ ret = trie_prune(t); TEST2(1 == ret, "trie_prune()"); TEST(size > trie_size(t)); /* node pruned */ - TEST((count - 1) == trie_count(t, "")); /* no change in elements */ + TEST((size_t)(count - 1) == trie_count(t, "")); /* no change in elements */ } /* iterator */ @@ -383,8 +383,10 @@ test3(void) TEST(ret == test2_words[i]); // mixed - for (word = test2_words[i], t_cursor = t_buffer; *word; ++word) - *t_cursor++ = ((size_t)t_cursor & 1) ? tolower(*word) : *word; + for (word = test2_words[i], t_cursor = t_buffer; *word; ++word) { + *t_cursor = ((size_t)t_cursor & 1) ? tolower(*word) : *word; + ++t_cursor; + } *t_cursor = 0; ret = trie_search(t, t_buffer); TEST(ret == test2_words[i]); @@ -392,8 +394,10 @@ test3(void) TEST(ret == test2_words[i]); // mixed - for (word = test2_words[i], t_cursor = t_buffer; *word; ++word) - *t_cursor++ = ((size_t)t_cursor & 1) ? *word : tolower(*word); + for (word = test2_words[i], t_cursor = t_buffer; *word; ++word) { + *t_cursor = ((size_t)t_cursor & 1) ? *word : tolower(*word); + ++t_cursor; + } *t_cursor = 0; ret = trie_search(t, t_buffer); TEST(ret == test2_words[i]); @@ -418,12 +422,12 @@ test3(void) int ret = trie_replace(t, "CMAKE_+_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES", NULL, NULL); TEST2(0 == ret, "trie_replace"); TEST(size == trie_size(t)); /* node count */ - TEST((count - 1) == trie_count(t, "")); /* non-null element count */ + TEST((size_t)(count - 1) == trie_count(t, "")); /* non-null element count */ ret = trie_prune(t); TEST2(1 == ret, "trie_prune()"); TEST(size > trie_size(t)); /* node pruned */ - TEST((count - 1) == trie_count(t, "")); /* no change in elements */ + TEST((size_t)(count - 1) == trie_count(t, "")); /* no change in elements */ } /* iterator */ diff --git a/libvfs/Makefile.in b/libvfs/Makefile.in index c2305df0..c749d99c 100644 --- a/libvfs/Makefile.in +++ b/libvfs/Makefile.in @@ -1,5 +1,5 @@ # -*- mode: mak; indent-tabs-mode: t; tab-width: 8 -*- -# $Id: Makefile.in,v 1.14 2024/04/17 15:43:26 cvsuser Exp $ +# $Id: Makefile.in,v 1.15 2024/07/13 08:33:23 cvsuser Exp $ # libvfs makefile. # # @@ -76,7 +76,7 @@ LDDEBUG= @LDDEBUG@ LDRELEASE= @LDRELEASE@ CINCLUDE= -I$(D_INC) @CINCLUDE@ -CEXTRA= @DEFS@ +CEXTRA= @DEFS@ @LIBCURL_CPPFLAGS@ ifeq ("$(BUILD_TYPE)","release") CFLAGS+= $(CRELEASE) $(CWARN) $(CINCLUDE) $(CEXTRA) $(XFLAGS) diff --git a/libw32/unistd.h b/libw32/unistd.h index 95df0e37..c86621fe 100644 --- a/libw32/unistd.h +++ b/libw32/unistd.h @@ -1,7 +1,7 @@ #ifndef LIBW32_UNISTD_H_INCLUDED #define LIBW32_UNISTD_H_INCLUDED #include -__CIDENT_RCSID(gr_libw32_unistd_h,"$Id: unistd.h,v 1.73 2024/06/09 14:05:43 cvsuser Exp $") +__CIDENT_RCSID(gr_libw32_unistd_h,"$Id: unistd.h,v 1.74 2024/09/09 11:39:14 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ @@ -40,8 +40,8 @@ __CPRAGMA_ONCE #if (_MSC_VER != 1900) /* MSVC 19/2015 */ #if (_MSC_VER < 1910 || _MSC_VER > 1916) /* MSVC 2017: 19.10 .. 16 */ #if (_MSC_VER > 1929) /* MSVC 2019: 19.20 .. 29 */ -#if (_MSC_VER > 1940) /* MSVC 2022: 19.30 .. 40 */ -#error unistd.h: untested MSVC Version (2005 -- 2022 19.40) +#if (_MSC_VER > 1941) /* MSVC 2022: 19.30 .. 41 */ +#error unistd.h: untested MSVC Version (2005 -- 2022 19.41) //see: https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B #endif //2022 #endif //2019 diff --git a/libw32/w32_direntunc.c b/libw32/w32_direntunc.c index c9d6bb7b..4c5de826 100644 --- a/libw32/w32_direntunc.c +++ b/libw32/w32_direntunc.c @@ -1,5 +1,5 @@ #include -__CIDENT_RCSID(gr_w32_direntunc_c,"$Id: w32_direntunc.c,v 1.6 2024/03/31 15:57:25 cvsuser Exp $") +__CIDENT_RCSID(gr_w32_direntunc_c,"$Id: w32_direntunc.c,v 1.7 2024/07/25 15:50:13 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ /* @@ -197,7 +197,7 @@ struct dirent * w32_unc_readdirA(DIR *dp) { DWORD bufsize = 4 * 1024; - DWORD result, count; + DWORD result, count = 0; void *buffer; char *cursor; @@ -242,7 +242,7 @@ struct dirent * w32_unc_readdirW(DIR *dp) { DWORD bufsize = 4 * 1024; - DWORD result, count; + DWORD result, count = 0; void *buffer; wchar_t *cursor; diff --git a/libw32/w32_hunspell.c b/libw32/w32_hunspell.c index d2ba9b2e..333428db 100644 --- a/libw32/w32_hunspell.c +++ b/libw32/w32_hunspell.c @@ -1,5 +1,5 @@ #include -__CIDENT_RCSID(gr_w32_hunspell_c,"$Id: w32_hunspell.c,v 1.21 2023/12/29 16:49:46 cvsuser Exp $") +__CIDENT_RCSID(gr_w32_hunspell_c,"$Id: w32_hunspell.c,v 1.22 2024/07/19 18:50:54 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ /* @@ -75,22 +75,33 @@ static free_listfn_t x_free_list; static addfn_t x_add; static add_with_affixfn_t x_add_with_affix; -static void strxcopy(char *dest, const char *src, int len); -static FARPROC hunspell_resolve(const char *name); - - -LIBW32_API int -w32_hunspell_connect(int verbose) -{ - static const char *hunspellnames[] = { +static const char * x_hunspellnames[] = { + NULL, // place-holder/runtime configuration #if defined(HAVE_LIBHUNSPELL_DLL) HAVE_LIBHUNSPELL_DLL, // see: config.h +#elif defined(HUNSPELLDLL_NAME) + HUNSPELLDLL_NAME, #else "libhunspell.dll", "hunspell.dll", #endif - NULL }; + +static void strxcopy(char *dest, const char *src, int len); +static FARPROC hunspell_resolve(const char *name); + +LIBW32_API void +w32_hunspell_dllname(const char *dllname) +{ + if (x_hunspellnames[0]) + free((void *)x_hunspellnames[0]); + x_hunspellnames[0] = (dllname && *dllname ? strdup(dllname) : NULL); +} + + +LIBW32_API int +w32_hunspell_connect(int verbose) +{ char fullname[1024], *end; const char *name; unsigned i; @@ -105,7 +116,12 @@ w32_hunspell_connect(int verbose) *++end = 0; } - for (i = 0; NULL != (name = hunspellnames[i]); ++i) { + for (i = 0; i < sizeof(x_hunspellnames)/sizeof(x_hunspellnames[0]); ++i) { + + if (NULL == (name = x_hunspellnames[i])) { + continue; // empty slot + } + #if defined(DO_TRACE_LOG) trace_log("hunspell_dll(%s)\n", name); #endif diff --git a/libw32/w32_iconv.c b/libw32/w32_iconv.c index e2fccef1..9bb09ea1 100644 --- a/libw32/w32_iconv.c +++ b/libw32/w32_iconv.c @@ -1,5 +1,5 @@ #include -__CIDENT_RCSID(gr_w32_iconv_c,"$Id: w32_iconv.c,v 1.23 2024/03/31 15:57:26 cvsuser Exp $") +__CIDENT_RCSID(gr_w32_iconv_c,"$Id: w32_iconv.c,v 1.24 2024/07/19 18:50:54 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ /* @@ -69,15 +69,17 @@ static iconvfn_t x_iconv; // static void * x_iconv_errno; static const char * x_iconvnames[] = { - NULL, // place-holder -#if defined(ICONVDLL_NAME) - ICONVDLL_NAME, // compile-time configuration + NULL, // place-holder/runtime configuration +#if defined(HAVE_LIBICONV_CITRUS_DLL) + HAVE_LIBICONV_CITRUS_DLL, +#elif defined(ICONVDLL_NAME) + ICONVDLL_NAME, #else -#define ICONVDLL_NAME "[lib]iconv[2].dll" // dynamic - "libiconv2.dll", "libiconv.dll", - "iconv2.dll", - "iconv.dll", + "iconv.dll" +#endif +#if !defined(ICONVDLL_NAME) +#define ICONVDLL_NAME "iconv.dll" // generic name #endif }; diff --git a/libw32/w32_popen.c b/libw32/w32_popen.c index 72b772c0..2eebc56b 100644 --- a/libw32/w32_popen.c +++ b/libw32/w32_popen.c @@ -1,5 +1,5 @@ #include -__CIDENT_RCSID(gr_w32_popen_c,"$Id: w32_popen.c,v 1.19 2024/04/07 06:14:29 cvsuser Exp $") +__CIDENT_RCSID(gr_w32_popen_c,"$Id: w32_popen.c,v 1.20 2024/07/25 15:42:32 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ /* @@ -742,7 +742,7 @@ Dup(HANDLE old, HANDLE *dup, BOOL inherit) if (dup == NULL || old == INVALID_HANDLE_VALUE || !DuplicateHandle(self, old, self, dup, 0, inherit, DUPLICATE_SAME_ACCESS)) { - *dup = INVALID_HANDLE_VALUE; + if (dup) *dup = INVALID_HANDLE_VALUE; return (FALSE); } return (TRUE); diff --git a/libw32/w32_select.c b/libw32/w32_select.c index b2782b07..7873fef8 100644 --- a/libw32/w32_select.c +++ b/libw32/w32_select.c @@ -1,5 +1,5 @@ #include -__CIDENT_RCSID(gr_w32_select_c,"$Id: w32_select.c,v 1.18 2024/03/31 15:57:27 cvsuser Exp $") +__CIDENT_RCSID(gr_w32_select_c,"$Id: w32_select.c,v 1.19 2024/07/30 08:17:12 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ /* @@ -210,7 +210,7 @@ static int sel_wait(u_int cnt, Select_t *selfds, DWORD timeout) { DWORD stick, ret; - HANDLE waitfor[MAXIMUM_WAIT_OBJECTS]; // system limit + HANDLE waitfor[MAXIMUM_WAIT_OBJECTS] = {0}; // system limit u_int i = 0; if (cnt > sizeof(waitfor)/sizeof(waitfor[0])) diff --git a/libw32/w32_shell.c b/libw32/w32_shell.c index 15bb8376..dcb0d518 100644 --- a/libw32/w32_shell.c +++ b/libw32/w32_shell.c @@ -1,5 +1,5 @@ #include -__CIDENT_RCSID(gr_w32_shell_c,"$Id: w32_shell.c,v 1.17 2024/03/31 15:57:27 cvsuser Exp $") +__CIDENT_RCSID(gr_w32_shell_c,"$Id: w32_shell.c,v 1.18 2024/07/25 15:42:58 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ /* @@ -1169,7 +1169,7 @@ Dup(HANDLE old, HANDLE *dup, BOOL inherit) if (dup == NULL || old == INVALID_HANDLE_VALUE || !DuplicateHandle(self, old, self, dup, 0, inherit, DUPLICATE_SAME_ACCESS)) { - *dup = INVALID_HANDLE_VALUE; + if (dup) *dup = INVALID_HANDLE_VALUE; return FALSE; } return TRUE; diff --git a/libw32/w32_statfs.c b/libw32/w32_statfs.c index 9d1eecac..48f33383 100644 --- a/libw32/w32_statfs.c +++ b/libw32/w32_statfs.c @@ -1,5 +1,5 @@ #include -__CIDENT_RCSID(gr_w32_statfs_c,"$Id: w32_statfs.c,v 1.22 2024/03/31 15:57:28 cvsuser Exp $") +__CIDENT_RCSID(gr_w32_statfs_c,"$Id: w32_statfs.c,v 1.23 2024/07/25 15:43:33 cvsuser Exp $") /* -*- mode: c; indent-width: 4; -*- */ /* @@ -183,7 +183,7 @@ statfsA(const char *path, struct statfs *sb) } sb->f_type = MOUNT_PC; - strncat(sb->f_fstypename, "unknown", MFSNAMELEN); + strncpy(sb->f_fstypename, "unknown", MFSNAMELEN); if (GetVolumeInformationA(path, volName, MNAMELEN, /* VolumeName and size */ NULL, &MaximumComponentLength, &FileSystemFlags, fsName, MNAMELEN)) /* filesystem type */ @@ -258,7 +258,7 @@ statfsW(const wchar_t *path, struct statfs *sb) } sb->f_type = MOUNT_PC; - strncat(sb->f_fstypename, "unknown", MFSNAMELEN); + strncpy(sb->f_fstypename, "unknown", MFSNAMELEN); if (GetVolumeInformationW(path, volName, MNAMELEN, /* VolumeName and size */ NULL, &MaximumComponentLength, &FileSystemFlags, fsName, MNAMELEN)) /* filesystem type */ diff --git a/libw32/win32_hunspell.h b/libw32/win32_hunspell.h index 0b3df2f7..6ee45a78 100644 --- a/libw32/win32_hunspell.h +++ b/libw32/win32_hunspell.h @@ -1,7 +1,7 @@ #ifndef GR_WIN32_HUNSPELL_H_INCLUDED #define GR_WIN32_HUNSPELL_H_INCLUDED #include -__CIDENT_RCSID(gr_libw32_win32_hunspell_h,"$Id: win32_hunspell.h,v 1.11 2022/06/11 04:36:25 cvsuser Exp $") +__CIDENT_RCSID(gr_libw32_win32_hunspell_h,"$Id: win32_hunspell.h,v 1.12 2024/07/30 04:48:03 cvsuser Exp $") __CPRAGMA_ONCE /* -*- mode: c; indent-width: 4; -*- */ @@ -39,6 +39,7 @@ __CBEGIN_DECLS LIBW32_API int w32_hunspell_connect(int verbose); LIBW32_API void w32_hunspell_shutdown(void); +LIBW32_API void w32_hunspell_dllname(const char *dllname); LIBW32_API void * w32_hunspell_initialise(const char *aff, const char *dic); LIBW32_API void * w32_hunspell_initialise_key(const char *aff, const char *dic, const char *key); LIBW32_API void w32_hunspell_uninitialise(void *handle); diff --git a/libwidechar/Makefile.in b/libwidechar/Makefile.in index 62f4e3e5..52c256ea 100644 --- a/libwidechar/Makefile.in +++ b/libwidechar/Makefile.in @@ -1,5 +1,5 @@ # -*- mode: mak; indent-tabs-mode: t; tab-width: 8 -*- -# $Id: Makefile.in,v 1.7 2024/05/21 13:40:39 cvsuser Exp $ +# $Id: Makefile.in,v 1.8 2024/07/21 07:41:35 cvsuser Exp $ # libwidechar makefile. # # @@ -177,5 +177,4 @@ $(D_LIB)/%.la: %.lo $(D_OBJ)/%$(O): %.c $(CC) $(CFLAGS) -o $@ -c $< -#end - +#end \ No newline at end of file diff --git a/libwidechar/ucswidth.c b/libwidechar/ucswidth.c index 2553a5d4..14fdc385 100644 --- a/libwidechar/ucswidth.c +++ b/libwidechar/ucswidth.c @@ -1,5 +1,5 @@ #include -__CIDENT_RCSID(gr_wcwidth_c,"$Id: ucswidth.c,v 1.4 2024/05/21 13:40:39 cvsuser Exp $") +__CIDENT_RCSID(gr_wcwidth_c,"$Id: ucswidth.c,v 1.6 2024/07/25 17:05:09 cvsuser Exp $") /* ------------------------------------------------------------------------------ @@ -42,10 +42,17 @@ __CIDENT_RCSID(gr_wcwidth_c,"$Id: ucswidth.c,v 1.4 2024/05/21 13:40:39 cvsuser E #if defined(HAVE_WCHAR_H) #if defined(HAVE_WCWIDTH) +#if !defined(_GNU_SOURCE) #define _GNU_SOURCE -#define _POSIX_C_SOURCE 1 #endif +#if !defined(_XOPEN_SOURCE) +#define _XOPEN_SOURCE 600 #endif +#if !defined(_POSIX_C_SOURCE) +#define _POSIX_C_SOURCE 200112L +#endif +#endif +#endif /*HAVE_WCHAR_H && HAVE_WCWIDTH*/ #include #include "widechar.h" diff --git a/libwidechar/widechar.h b/libwidechar/widechar.h index f546b54c..d7a18858 100644 --- a/libwidechar/widechar.h +++ b/libwidechar/widechar.h @@ -66,7 +66,7 @@ int Wcstoutf8(const WChar_t *str, char *buf, int buflen); int Wcwidth(WChar_t ucs); int Wcswidth(const WChar_t *s, size_t n); - + int Wvasprintf(WChar_t **ret, const char *format, va_list ap); int Wvsnprintf(WChar_t *str, size_t size, const char *format, va_list args); diff --git a/libwidechar/wsnprintf.c b/libwidechar/wsnprintf.c index dc09ecbc..fc1707c7 100644 --- a/libwidechar/wsnprintf.c +++ b/libwidechar/wsnprintf.c @@ -1583,6 +1583,12 @@ cast(LDOUBLE value) * comparison (cf. C99: 6.3.1.4, 2). It might then equal the LDOUBLE * value although converting the latter to UINTMAX_T would overflow. */ +//#if defined(__GNUC__) +//#pragma GCC diagnostic ignored "-Wimplicit-float-conversion" +//#endif +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wimplicit-const-int-float-conversion" +#endif if (value >= UINTMAX_MAX) return UINTMAX_MAX; diff --git a/macsrc/Makefile.in b/macsrc/Makefile.in index 2f32d6f6..0644d23d 100644 --- a/macsrc/Makefile.in +++ b/macsrc/Makefile.in @@ -1,5 +1,5 @@ # -*- mode: mak; indent-tabs-mode: t; tab-width: 8 -*- -# $Id: Makefile.in,v 1.26 2024/04/16 10:37:31 cvsuser Exp $ +# $Id: Makefile.in,v 1.28 2024/07/05 18:41:28 cvsuser Exp $ # GRIEF macro library makefile. # # @@ -52,18 +52,23 @@ MACROS= $(ROOT)/macros.x64 else MACROS= $(ROOT)/macros endif -MKBD= $(MACROS)/kbd -MTTY= $(MACROS)/tty -MDEMOS= $(MACROS)/demos -MBENCHMARKS= $(MACROS)/benchmarks -MMODES= $(MACROS)/modes -MPROFILES= $(MACROS)/profiles -MCOLORS= $(MACROS)/colors -MACRODIRS= $(MACROS) $(MKBD) $(MTTY) $(MDEMOS) $(MBENCHMARKS) $(MMODES) $(MPROFILES) $(MCOLORS) + +Unique= $(if $(1),$(strip $(word 1,$(1)) $(call Unique,$(filter-out $(word 1,$(1)),$(1))))) +Reverse= $(if $(1),$(call Reverse,$(wordlist 2,$(words $(1)),$(1)))) $(firstword $(1)) + +COLORDIRS= $(filter-out %\CVS\,$(filter-out %/CVS/,$(call Unique,$(dir $(wildcard colors/*.cr colors/*/*.cr))))) +SOURCEDIRS= kbd tty demos benchmarks modes profiles $(COLORDIRS) + +MACRODIRS= $(MACROS) $(addprefix $(MACROS)/,$(SOURCEDIRS)) +RMACRODIRS= $(call Reverse, $(MACRODIRS)) + +#$(info SOURCEDIRS=$(SOURCEDIRS)) +#$(info MACRODIRS=$(MACRODIRS)) # Compilers, programs RM= @RM@ +MKDIR_P= @MKDIR_P@ RMDIR= @RMDIR@ PERL= @PERL@ @@ -81,44 +86,28 @@ release: debug: $(MAKE) BUILD_TYPE=debug $(filter-out debug, $(MAKECMDGOALS)) -SOURCE= $(wildcard *.cr kbd/*.cr tty/*.cr demos/*.cr benchmarks/*.cr modes/*.cr profiles/*.cr colors/*.cr) -OBJECTS= $(wildcard $(MACROS)/*.cm $(MACROS)/*.m $(MKBD)/*.cm $(MTTY)/*.cm $(MDEMOS)/*.cm $(MBENCHMARKS)/*.cm $(MMODES)/*.cm $(MPROFILES)/*.cm $(MCOLORS)/*.cm) +SOURCE= $(wildcard *.cr) $(foreach dir,$(SOURCEDIRS),$(wildcard $(dir)/*.cr)) +OBJECTS= $(foreach dir,$(MACRODIRS),$(wildcard $(dir)/*.cm)) -macros: $(MACRODIRS) +DIRECTORIES= $(addsuffix /.created, $(MACRODIRS)) +RDIRECTORIES= $(addsuffix /.created, $(RMACRODIRS)) + +macros: $(DIRECTORIES) $(GRUNCH) -w -m -A autoload.inc -o $(MACROS) $(SOURCE) -force: $(MACRODIRS) +force: $(DIRECTORIES) ${GRUNCH} -w -A autoload.inc -o $(MACROS) $(SOURCE) -withdebug: $(MACRODIRS) +withdebug: $(DIRECTORIES) $(GRUNCH) -w -g -A autoload.inc -o $(MACROS) $(SOURCE) ${GRUNCH} -w $(MACROS) grief.cr debug.cr -$(MACROS): $(MACROS)/.created - -$(MKBD): $(MKBD)/.created - -$(MTTY): $(MTTY)/.created - -$(MDEMOS): $(MDEMOS)/.created - -$(MBENCHMARKS): $(MBENCHMARKS)/.created - -$(MMODES): $(MMODES)/.created - -$(MPROFILES): $(MPROFILES)/.created - -$(MCOLORS): $(MCOLORS)/.created - %/.created: - -@$(PERL) ../win32/mkdir_p.pl $(@D) + -@$(MKDIR_P) $(@D) @echo "++ do not delete, grief edit managed content ++" > $@ -reverse = $(if $(1),$(call reverse,$(wordlist 2,$(words $(1)),$(1)))) $(firstword $(1)) -RMACRODIRS = $(call reverse, $(MACRODIRS)) - vclean: clean - -$(RM) $(RMDFLAGS) $(addsuffix /.created, $(RMACRODIRS)) + -$(RM) $(RMDFLAGS) $(RDIRECTORIES) -$(RMDIR) $(RMACRODIRS) clean: diff --git a/macsrc/about.cr b/macsrc/about.cr index 293871b0..6c96ef26 100644 --- a/macsrc/about.cr +++ b/macsrc/about.cr @@ -1,5 +1,5 @@ /* -*- indent-width: 4; -*- */ -/* $Id: about.cr,v 1.14 2024/04/17 15:57:15 cvsuser Exp $ +/* $Id: about.cr,v 1.15 2024/08/04 10:07:57 cvsuser Exp $ * About box. * * @@ -54,7 +54,7 @@ main() version(maj, min, edit, rel, machtype, compiled); - sprintf(extra1, "%s %s v%d.%d.%d", APPNAME, machtype, maj, min, edit, compiled); + sprintf(extra1, "%s %s v%d.%d.%d.%d", APPNAME, machtype, maj, min, edit, rel); sprintf(extra2, "Built on %s", compiled); dialog = diff --git a/macsrc/alt.h b/macsrc/alt.h index d1c71627..66c8013e 100644 --- a/macsrc/alt.h +++ b/macsrc/alt.h @@ -1,4 +1,4 @@ -/* $Id: alt.h,v 1.12 2021/07/12 15:55:11 cvsuser Exp $ +/* $Id: alt.h,v 1.13 2024/09/21 17:02:02 cvsuser Exp $ * Key definitions * */ @@ -27,7 +27,7 @@ * x Shift - MOD_SHIFT * x Ctrl/control - MOD_CTRL * x Meta - MOD_META - * x App - MOD_APP + * x App - MOD_APP * s . r r r r . Character ranges/namespaces - RANGE_MASK * * RANGE_CHARACTER, RANGE_FUNCTION, RANGE_KEYPAD, @@ -84,7 +84,7 @@ #define KEY_ENTER __ENTER #define KEY_NEWLINE '\n' -/* +/* * Namespaces and modifiers. */ #define KEY_MASK 0x001fffff // 0..10ffff @@ -113,7 +113,7 @@ /* * Specials */ -#define KEY_VOID 0x001fffff // null +#define KEY_VOID 0x001fffff // null #define KEY_WINCH 0x001ffffe // winch/resize event #define KEY_UNICODE 0x001ffff0 // keyboard special @@ -292,6 +292,9 @@ #define CTRL_KEYPAD_SCROLL __CTRL_KEYPAD(19) #define CTRL_KEYPAD_NUMLOCK __CTRL_KEYPAD(20) +#define __CTRLSHIFT_KEYPAD(__x) (MOD_SHIFT | MOD_CTRL | RANGE_KEYPAD | (__x)) +#define CTRLSHIFT_KEYPAD_0 __CTRLSHIFT_KEYPAD(0) + #define __ALT_KEYPAD(__x) (MOD_META | RANGE_KEYPAD | (__x)) #define ALT_KEYPAD_0 __ALT_KEYPAD(0) #define ALT_KEYPAD_1 __ALT_KEYPAD(1) @@ -304,6 +307,9 @@ #define ALT_KEYPAD_8 __ALT_KEYPAD(8) #define ALT_KEYPAD_9 __ALT_KEYPAD(9) +#define __ALTSHIFT_KEYPAD(__x) (MOD_SHIFT | MOD_META | RANGE_KEYPAD | (__x)) +#define ALTSHIFT_KEYPAD_0 __ALTSHIFT_KEYPAD(0) + #define ALT_KEYPAD_END __ALT_KEYPAD(1) #define ALT_KEYPAD_LEFT __ALT_KEYPAD(4) #define ALT_KEYPAD_RIGHT __ALT_KEYPAD(6) @@ -320,6 +326,12 @@ #define ALT_KEYPAD_SCROLL __ALT_KEYPAD(19) #define ALT_KEYPAD_NUMLOCK __ALT_KEYPAD(20) +#define __ALTCTRL_KEYPAD(__x) (MOD_CTRL | MOD_META | RANGE_KEYPAD | (__x)) +#define ALTCTRL_KEYPAD_0 __ALTCTRL_KEYPAD(0) + +#define __ALTCTRLSHIFT_KEYPAD(__x) (MOD_META | MOD_CTRL | MOD_SHIFT | RANGE_KEYPAD | (__x)) +#define ALTCTRLSHIFT_KEYPAD_0 __ALTCTRLSHIFT_KEYPAD(0) + /* * Shift keypad keys. */ @@ -429,3 +441,6 @@ #endif /*__ALT_H*/ + + + diff --git a/macsrc/bufinfo.cr b/macsrc/bufinfo.cr index 398d648d..eebbffd0 100644 --- a/macsrc/bufinfo.cr +++ b/macsrc/bufinfo.cr @@ -1,5 +1,5 @@ /* -*- indent-width: 4; -*- */ -/* $Id: bufinfo.cr,v 1.17 2022/08/10 15:44:58 cvsuser Exp $ +/* $Id: bufinfo.cr,v 1.18 2024/08/01 14:06:46 cvsuser Exp $ * Buffer Information/Configuration. * * @@ -132,7 +132,7 @@ main() DLGA_NAME, "buffername", DLGA_ATTACH_LEFT, DLGA_ROWS, 1, - DLGA_COLS, 60, + DLGA_COLS, 68, DLGA_ALLOW_FILLX, DLGA_GREYED, DLGC_END, @@ -145,7 +145,7 @@ main() DLGA_NAME, "filename", DLGA_ATTACH_LEFT, DLGA_ROWS, 1, - DLGA_COLS, 60, + DLGA_COLS, 68, DLGA_ALLOW_FILLX, DLGA_GREYED, DLGC_END, @@ -250,6 +250,18 @@ main() DLGA_COLS, 18, DLGA_GREYED, DLGC_END, + DLGC_CONTAINER, + DLGC_LABEL, + DLGA_VALUE, "Syntax:", + DLGA_ATTACH_LEFT, + DLGA_COLS, 13, + DLGC_EDIT_FIELD, + DLGA_NAME, "syntax", + DLGA_ATTACH_LEFT, + DLGA_ROWS, 1, + DLGA_COLS, 18, + DLGA_GREYED, + DLGC_END, DLGC_END, DLGC_END, @@ -494,7 +506,7 @@ main() DLGA_IDENT, IDENT_TITLE_FULL, DLGA_ALIGN_W, DLGC_CHECK_BOX, - DLGA_LABEL, "Read-only suffix", + DLGA_LABEL, "Readonly suffix", DLGA_IDENT, IDENT_SUFFIX_READONLY, DLGA_ALIGN_W, DLGC_CHECK_BOX, @@ -599,6 +611,9 @@ bi_callback(int ident, string name, int p1, int p2) // character-map. inq_char_map(curwin, charactermap); widget_set(NULL, "charactermap", charactermap); + + // syntax + widget_set(NULL, "syntax", inq_syntax_name()); // backup. widget_set(NULL, "bk_dir", inq_backup_option(BK_DIR)); diff --git a/macsrc/colors.cr b/macsrc/colors.cr index a0fe3f39..6e451128 100644 --- a/macsrc/colors.cr +++ b/macsrc/colors.cr @@ -1,16 +1,19 @@ /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: colors.cr,v 1.18 2024/05/20 17:04:23 cvsuser Exp $ +/* $Id: colors.cr,v 1.23 2024/07/05 18:41:55 cvsuser Exp $ * Enhanced colour/colorscheme support. * * */ #include "grief.h" +#include "colorsvim.h" -#define SCHEME_CTERMONLY 0x0001 -#define SCHEME_GUIONLY 0x0002 +static list coloriser_list(void); +static list vimcoloriser_list(void); -static int colorscheme_view(int ids); +static int schemeview(int ids); +static int schemevim(~ string base, ~int flags); +static int schemeload(string scheme, ~list args, ~string base, ~int flags); static void ca_keys(void); static void ca_attribute(void); @@ -20,167 +23,6 @@ static void ca_setfg(string type, int set); static void ca_setbg(string type, int set); static int ca_callback(int ident, string name, int p1, int p2); -static int colorscheme_vim(~ string base, ~int flags); -static int schemeload(string scheme, ~list args, ~string base, ~int flags); -static void schemeload_vim(string scheme, string base, int flags, string file); - -void vim_groupmap(string name); -string vim_attrmap(string attr); - -static list scheme_colors = { - // VIM to GRIEF attribute (where possible) - // - // default highlighting groups. - // - "=ColorColumn=", "ruler_column", // used for the columns set with 'colorcolumn'. (ie. colorcolumn=80) - - "=Conceal=", "", // place-holder characters substituted for concealed text. - - "=Cursor=", "cursor", // the character under the cursor. - "=CursorIM=", "", // like Cursor, but used when in IME mode. - "=CursorColumn=", "cursor_col", // the screen column that the cursor is in when 'cursorcolumn' is set. - "=CursorLine=", "cursor_row", // the screen line that the cursor is in when 'cursorline' is set. - - "=Directory=", "lsdirectory", // directory names (and other special names in listings). - - "=DiffAdd=", "additional", // diff: added line. - "=DiffChange=", "modified", // diff: changed line. - "=DiffDelete=", "diffdelete", // diff: deleted line. - "=DiffText=", "difftext", // diff: changed text within a changed line. - - "=ModeMsg=", "", // 'showmode' message. - "=MoreMsg=", "message", // |more-prompt|. - "=WarningMsg=", "", // warning messages. - "=ErrorMsg=", "error", // error messages on the command line. - - "=VertSplit=", "frame", // the column separating vertically split windows. - - // TODO ==> folded/fold_column - "=Folded=", "", // line used for closed folds. - "=FoldColumn=", "", // Foldcolumn. - - "=SignColumn=", "column_status", // column where *signs* are displayed. - "=LineNr=", "column_lineno", // line number. - - "=IncSearch=", "search_inc", // 'incsearch' highlighting; also used for the text replaced with. - "=MatchParen=", "search_match", // a paired character. - - "=NonText=", "nonbuffer", // '~' and '@' at the end of the window. - - "=Normal=", "normal", // normal text. - - "=Pmenu=", "popup_normal", // popup: normal item. - "=PmenuSel=", "popup_hilite", // popup: selected item. - "=PmenuSbar=", "scrollbar", // popup: scrollbar. - "=PmenuThumb=", "scrollbar_thumb", // popup: thumb of the scrollbar. - - "=Question=", "prompt", // prompt and yes/no questions. - - "=Search=", "search", // last search pattern highlighting. - - "=SpecialKey=", "", // meta and special keys listed with ":map", also unprintable characters. - - "=Todo=", "todo", // anything that needs extra attention; mostly the keywords TODO FIXME and XXX. - - "=SpellBad=", "spell", // spell: recognized word. - "=SpellCap=", "", // spell: word that should start with a capital. - "=SpellLocal=", "", // spell: recognized word as one that is used in another region. - "=SpellRare=", "", // spell: recognized word as one that is hardly ever used. - "=Spell=", "spell", - - "=StatusLine=", "echo_line", // status line of current window. - "=StatusLineNC=", "", // status lines of not-current windows. - - "=TabLine=", "", // tab pages line, not active tab page label. - "=TabLineFill=", "", // tab pages line, where there are no labels. - "=TabLineSel=", "", // tab pages line, active tab page label. - - "=Title=", "select", // titles for output from ":set all", ":autocmd" etc. - - "=Visual=", "hilite", // visual mode selection. - "=VisualNOS=", "", // visual mode selection when vim is "Not Owning the Selection". - - "=WildMenu=", "prompt_complete", // current match in 'wildmenu' completion. - - // syntax groups/ - // naming conventions. - // - "=Comment=", "comment", // any comment. - - "=Constant=", "constant", // any constant. - "=String=", "string", // a string constant: "this is a string" - "=Character=", "character", // a character constant: 'c', '\n' - "=Number=", "number", // a number constant: 123, 012, 0x12 - "=Boolean=", "boolean", // a boolean constant: TRUE, false - "=Float=", "float", // a floating constant: 2.3e10 - - // TODO ==> identifier - "=Identifier=", "keyword_function", // any variable name. - "=Function=", "keyword_function", // function name (also: methods for classes). - - "=PreProc=", "preprocessor", // preprocessor. - "=Include=", "preprocessor_include", // preprocessor #include - "=Define=", "preprocessor_define", // preprocessor #define - "=Macro=", "preprocessor_keyword", // same as Define - "=PreCondit=", "preprocessor_conditional", // preprocessor #if, #else, #endif, etc. - - "=Statement=", "code", // any statement. - "=Conditional=", "keyword_conditional", // if, then, else, endif, switch, etc. - "=Repeat=", "keyword_repeat", // for, do, while, etc. - "=Label=", "keyword_label", // case, default, etc. - "=Operator=", "operator", // operators - "=Keyword=", "keyword", // any other keyword - "=Exception=", "keyword_exception", // try, catch, throw - - "=Type=", "keyword_type", // int, long, char, etc. - "=StorageClass=", "keyword_storageclass", // static, register, volatile, etc. - "=Structure=", "keyword_structure", // struct, union, enum, etc. - "=Typedef=", "keyword_typedef", // Atypedef. - - "=Special=", "standout", // any special symbol. - "=SpecialChar=", "constant_standout", // special character in a constant. - "=Tag=", "tag", // you can use CTRL-] on this. - "=Delimiter=", "delimiter", // character that needs attention. - "=SpecialComment=", "comment_standout", // special things inside a comment. - "=Debug=", "keyword_debug", // debugging statements. - - "=Underlined=", "link", // text that stands out. - - // Notes: - // Some HTML tags are used to change the rendering of text within HTML (see: html.vim). - // - // - htmlBold .. - // - htmlUnderline .. - // - htmlItalic .. - // - htmlBoldUnderline - // - htmlBoldUnderlineItalic - // - htmlUnderlineItalic - // - htmlLink for links - // - htmlTitle for titles - // - htmlH1 ...htmlH6 for headings - // - // To make theses definitions work you must redefine them all with the exception of the last - // two (htmlTitle and htmlH[1-6], which are optional). - // - - "=Ignore=", "", // left blank, hidden. - - "=Error=", "alert", // any erroneous construct. - - // misc/ - // - "=Tab=", "whitespace", - "=Space=", "", - }; - -static list vim_paths = { // FIXME - needs work - "~/.vim/colors/", - "/usr/share/vim/vimcurrent/colors/" - }; - -static string scheme_background = "default"; -static string scheme_name = ""; // current color scheme. - enum { #define IDENT_BASE 1000 @@ -196,6 +38,13 @@ enum { IDENT_NONE // must be last }; +static string scheme_background = "default"; + +static list vim_paths = { // TODO, interface + "~/.vim/colors/", + "/usr/share/vim/vimcurrent/colors/" + }; + static list attrsset = { "bold", "inverse", @@ -230,7 +79,6 @@ static list color_names = { static int ca_dialog; // dialog resource. static list coloriser_list(void); -static list vimcoloriser_list(void); /* Function: main @@ -259,6 +107,11 @@ void main(void) { require("colorlabels"); + autoload("colorsvim", + "vim_colorscript", + "vim_colorscheme", + "vim_condition_tests" + ); } @@ -266,7 +119,7 @@ main(void) * Coloriser loader. * * Parameters: - * scheme - Optional color scheme name. + * scheme - Optional color scheme name. * * Returns: * nothing @@ -286,7 +139,9 @@ coloriser(~ string) string inq_coloriser(void) { - return scheme_name; + string name; + get_term_feature(TF_COLORSCHEME, name); + return name; } @@ -340,7 +195,7 @@ _completion_Coloriser(string arg) * colorscheme loader/viewer/editor. * * Parameters: - * scheme - Color scheme name. + * scheme - Color scheme name. * * Returns: * *true* if successful, otherwise *false*. @@ -351,33 +206,33 @@ colorscheme(~ string scheme, ...) // view or loader // if ("" == scheme) { - colorscheme_view(FALSE); + schemeview(FALSE); return FALSE; } else if ("--ids" == scheme) { - colorscheme_view(TRUE); + schemeview(TRUE); return FALSE; } else if ("--vim" == scheme) { - return colorscheme_vim(); + return schemevim(); } else if ("--vim-gui" == scheme) { - return colorscheme_vim(NULL, SCHEME_GUIONLY); + return schemevim(NULL, SCHEME_GUIONLY); } else if ("--vim-cterm" == scheme) { - return colorscheme_vim(NULL, SCHEME_CTERMONLY); + return schemevim(NULL, SCHEME_CTERMONLY); } else if ("--vim=dark" == scheme) { - return colorscheme_vim("dark"); + return schemevim("dark"); } else if ("--vim=light" == scheme) { - return colorscheme_vim("light"); + return schemevim("light"); } // default schemes/ // dark, light or default // - if ("dark" == scheme || "light" == scheme || "lite" == scheme || "default" == scheme) { + if ("dark" == scheme || "light" == scheme || "default" == scheme) { set_color("scheme=" + scheme); message("colorscheme: '%s'", scheme); return TRUE; @@ -436,13 +291,13 @@ vimcoloriser_list(void) // Display current color scheme definition. // static int -colorscheme_view(int ids) +schemeview(int ids) { - string title; + string title, coloriser = inq_coloriser(); int buf, idx; save_position(); - sprintf(title, "Color Scheme [%s]", (scheme_name ? scheme_name : "none")); + sprintf(title, "Color Scheme [%s]", (coloriser ? coloriser : "none")); if ((buf = create_buffer(title, NULL, 1)) >= 0) { list colors = get_color(ids ? (COLORGET_FNAME|COLORGET_FVALUE|COLORGET_FFLAGS) : COLORGET_FNAME|COLORGET_FFLAGS); @@ -511,8 +366,7 @@ ca_attribute(void) string ca_name; int ca_flags; - // flags,attribute=foreground[,background][: [link@name|sticky@name|styles][, ...]] - // + // flags,attribute=foreground[,background][: [link@name|sticky@name|styles][, ...]] move_abs(NULL, 81); string spec = trim(read()); move_abs(NULL, 1); @@ -520,7 +374,7 @@ ca_attribute(void) return; } - // clear dialog + // clear dialog if (0 == ca_dialog) { ca_dialoginit(); } @@ -533,7 +387,7 @@ ca_attribute(void) widget_set(ca_dialog, "link", ""); widget_set(ca_dialog, "sticky", ""); - // initialise dialog + // initialise dialog if (index(parts[1], ':')) { list colors_attrs = split(parts[1], ':'); list attrs = split(colors_attrs[1], ",@"); @@ -1073,7 +927,7 @@ ca_callback(int ident, string name, int p1, int p2) // Search for loadable 'vim' color schemes. // static int -colorscheme_vim(~ string base, ~int flags) +schemevim(~ string base, ~int flags) { list schemes; @@ -1099,28 +953,96 @@ colorscheme_vim(~ string base, ~int flags) // -// Load the specific color scheme. +// Load the specific color scheme. // static int schemeload(string scheme, ~list args, ~string base, ~int flags) { + // Scheme, examples: + // + // o colorscheme-package: + // + // o sunset-light + // ==> colors/sunset/cscheme + // colorschemepkg_sunset("light" ..) + // + // o sunset + // ==> colors/sunset/cscheme + // colorschemepkg_sunset(NULL, ..) + // + // o colorscheme: + // + // o sunset-light + // ==> colors/sunset + // colorscheme_sunset_light + // + // o sunset-light-lowcontrast + // ==> colors/sunset + // colorscheme_sunset_light_lowcontrast + // + // o sunset + // ==> colors/sunset + // colorscheme_sunset + // scheme = re_translate(SF_GLOBAL, "[ \t]+", "_", scheme); + list components = split(scheme, "-", NULL, NULL, NULL, 2); + + // colorscheme-package + if (require("colors/" + components[0] + "/cscheme") >= 0) { + string name = "colorschemepkg_" + components[0]; + int ret = -1; - if (require("colors/" + scheme) >= 0) { - if (inq_macro("colorscheme_" + scheme)) { - if (is_null(args)) { - execute_macro("colorscheme_" + scheme); + if (inq_macro(name) > 0) { + if (length_of_list(components) == 2) { + if (! is_null(args)) { + ret = execute_macro(name, components[1], args); + } else { + ret = execute_macro(name, components[1]); + } } else { - execute_macro("colorscheme_" + scheme, args); + if (! is_null(args)) { + ret = execute_macro(name, NULL, args); + } else { + ret = execute_macro(name); + } } + + } else { + error("colorschemepkg: '%s', not available", scheme); } + + if (ret == -1) + return FALSE; + set_term_feature(TF_COLORSCHEME, scheme); message("colorscheme: '%s'", scheme); - scheme_name = scheme; return TRUE; } - // import a vim colorscheme/ - // use with caution. + // colorscheme + if (require("colors/" + components[0]) >= 0) { + string name = "colorscheme_" + re_translate(SF_GLOBAL, "-", "_", scheme); + int ret = -1; + + if (inq_macro(name) > 0) { + if (! is_null(args)) { + ret = execute_macro(name, args); + } else { + ret = execute_macro(name); + } + } else { + error("colorscheme: '%s', not available", scheme); + return FALSE; + } + + if (ret == -1) + return FALSE; + set_term_feature(TF_COLORSCHEME, scheme); + message("colorscheme: '%s'", scheme); + return TRUE; + } + + // Import a vim colorscheme/ + // use with caution -- limited vim script support. // // Example: // runtimepath= @@ -1161,603 +1083,17 @@ schemeload(string scheme, ~list args, ~string base, ~int flags) } if (exist(path + file + ".vim")) { - schemeload_vim(scheme, base, flags, path + file + ".vim"); + vim_colorscript(scheme, base, flags, path + file + ".vim"); list_reset(vim_paths); return TRUE; } } } + message("colorscheme: unavailable to locate '%s'", scheme); return FALSE; } - -static void -schemeload_vim(string scheme, string base, int flags, string file) -{ - int buf, curbuf = inq_buffer(); - list spec; - - if ((buf = create_buffer("-colorscheme-vim-", file, TRUE)) >= 0) { - string ln; - int gui; - - message("loading: %s", file); - set_buffer(buf); - top_of_buffer(); - do { - ln = compress(read(), TRUE); // hi or :hi, set or let, conditionals - if (re_search(0, "^[:]@hi", ln) > 0 || - re_search(0, "^[sl]et", ln) > 0 || - re_search(0, "^{if}|{else}|{endif}", ln) > 0) { - spec += ln; - } - } while (down()); - set_buffer(curbuf); - delete_buffer(buf); - - if (SCHEME_GUIONLY & flags) { - // - // GUI only - // - vim_colorschemex(scheme, 0, base, spec, TRUE, gui); - - } else if (0 == vim_colorschemex(scheme, 0, base, spec, FALSE, gui) && gui > 15) { - // - // Console load failure, yet there maybe suitable GUI color settings - // try loading the GUI settings (unless CTERMONLY). - // - if (0 == (SCHEME_CTERMONLY & flags)) { - vim_colorschemex(scheme, 0, base, spec, TRUE, gui); - } - } - } -} - - -/* Function: vim_colorscheme - * Load a VIM style colorscheme. - * - * This interface is simple and requires a strict structure yet follows many of the - * basic colour schemas reviewed. - * - * See blackdust for an example schema. - * - * The latest top 100 VIM color schemes are www.vim.org are available as a single - * package "Color Scheme Pack", which generally fit the required structure for a - * successful import. - * - * In additional are a number of sites which demo the colorschemes, to name a few. - * - * http://www.vi-improved.org/color_sampler_pack/ - * http://vimcolorschemetest.googlecode.com/svn/html/index-c.html - * - * Color-Scheme editor - * - * http://bytefluent.com/vivify/ - * - * Parameters: - * label - Colorscheme name. - * colors - Supported colors (8, 16, 88 or 256). - * base - Base color scheme "dark" or "light". - * spec - Highlight command list. - * asgui - If *1* utilise gui colors otherwise terminal, *-1* dynamic. - * gui - GUI element count. - * - * Returns: - * Imported color count. - */ - -int -vim_colorscheme(string label, int colors, ~string base, list spec, int asgui) -{ - int gui; return vim_colorschemex(label, colors, base, spec, asgui, gui); -} - -int -vim_colorschemex(string label, int colors, ~string base, list spec, int asgui, int &gui) -{ - list ifstack; - int iflevel = -1, ifactive = 1, ifdepth; - int idx, done, links, ignored, cond; - declare value; - - // verify colors against current display environment - get_term_feature(TF_COLORDEPTH, ifdepth); - if (colors > 0) { - if (ifdepth != colors) { - message("%s: color depth %d not available (%d)", label, colors, ifdepth); - return -1; - } - } - - if (-1 == asgui) { // dynamic - asgui = (ifdepth > 256 ? TRUE : FALSE); - } - - if (0 == strlen(base)) { // dark or light base - get_term_feature(TF_COLORSCHEME, base); - base = "dark"; - } - - scheme_name = label; - - // load schema - // best effort load logic, with weak condition expression evaluation. - // - gui = 0; - while ((idx = list_each(spec, value)) >= 0) { - const list parts = - tokenize(value, " ", TOK_DOUBLE_QUOTES|TOK_PRESERVE_QUOTES|TOK_WHITESPACE|TOK_COLLAPSE_MULTIPLE|TOK_TRIM); - - switch (parts[0]) { - case "let": - case "set": // set command - if (length_of_list(parts) >= 2) { - // set bg=[dark|light]/ - // set background=[dark|light]/ - // When set to "dark", use colors that look good on a dark background. When - // set to "light", try to use colors that look good on a light background. - // Any other value is illegal. - // - // set g:colors_name= - // set colors_name= - // - const list parts2 = - tokenize(parts[1], "=", TOK_DOUBLE_QUOTES|TOK_WHITESPACE|TOK_TRIM); - - if (length_of_list(parts2) >= 2) { - if ("bg" == parts2[0] || "background" == parts2[0]) { - const string arg = parts2[1]; - - if (0 == strcasecmp("dark", arg) || - 0 == strcasecmp("light", arg) || - 0 == strcasecmp("default", arg)) { - scheme_background = arg; - } - } - } - } - break; - - case "hi": - case "hi!": - case ":hi": - case "highlight": - case ":highlight": // hi[ghtlight] command - if (length_of_list(parts) >= 2 && 1 == ifactive) { - if ("clear" == parts[1]) { - // clear - // Reset all highlighting to the defaults. Removes all highlighting for groups - // added by the user. Uses the current value of 'background' to decide which - // default colors to use. - // - // clear {group-name} - // Disable the highlighting for the specified highlight group. It is *not* set - // wback to the default colors. - // - const string groupname = - (length_of_list(parts) == 3 ? parts[2] : ""); - - // scheme=dark|light|default - if (0 == strlen(groupname)) { - set_color("scheme=" + scheme_background); - } - vim_groupmap(groupname); - - } else if ("link" == parts[1] || - (length_of_list(parts) >= 3 && "link" == parts[2])) { - // [default] link {from-group} {to-group} - // Setup an attribute link. - // - // [default] link {from-group} NONE - // Remove an attribute link. - // - string link; - - if ("default" == parts[1]) { - if (5 == length_of_list(parts)) { - string id1 = vim_attrmap(parts[3]), - id2 = vim_attrmap(parts[4]); - - if (strlen(id1) && strlen(id2)) { - sprintf(link, "%s=none:sticky@%s", id1, id2); - } - } - } else if (4 == length_of_list(parts)) { - string id1 = vim_attrmap(parts[2]), - id2 = vim_attrmap(parts[3]); - - if (strlen(id1) && strlen(id2)) { - sprintf(link, "%s=none:link@%s", id1, id2); - } - } - - if (link) { - set_color(link); - ++links; - } else { - ++ignored; - } - - } else { - // [default] {group-name} key=arg - // State an attributes color specification. - // - int baseidx = ("default" == parts[1] ? 2 : 1); - string fg, bg, sf, - ident = vim_attrmap(parts[baseidx]); - int i; - - if (ident) { - for (i = baseidx + 1; i < length_of_list(parts); ++i) { - if ("\"" == parts[i]) { - break; // comment - } - - const list parts2 = - tokenize(parts[i], "=", TOK_DOUBLE_QUOTES|TOK_WHITESPACE|TOK_TRIM); - - if (length_of_list(parts2) >= 2) { - string val = parts2[1]; - - if (0 == asgui) { - // cterm={attr-list} - // Color termination attribute list. One or more of the - // following comma seperated values (without spaces), - // - // bold, underline, undercurl, none - // reverse, inverse, italic, standout, - // - // ctermfg={color} - // Color terminal foreground color. - // - // ctermbg={color} - // Color terminal background color. - // - switch(parts2[0]) { - case "cterm": sf = val; break; - case "ctermfg": fg = val; break; - case "ctermbg": bg = val; break; - case "gui": ++gui; break; - } - } else { - // gui={attr-list} - // Color termination attribute list. One or more of the - // following comma seperated values (without spaces). - // - // font={font-name} - // Font (ignored). - // - // guifg={color} - // Color terminal foreground color. - // - // guibg={color} - // Color terminal background color. - // - // guisp={color} - // Foregroud. background and special color. - // - switch(parts2[0]) { - case "gui": sf = val; break; - case "guifg": fg = val; break; - case "guibg": bg = val; break; - case "font": break; - case "guisp": break; - } - } - } - } - - if (strlen(fg) || strlen(bg)) { - dprintf("%s: attribute: %s=%s fg:%s, bg:%s, sf:%s", - label, parts[baseidx], ident, fg, bg, sf); - - switch (ident) { - case "normal": - if (bg) set_color_pair("background", bg); - if (fg) set_color_pair("normal", fg); - break; - case "hilite": - if (fg) { - if (bg) { - set_color_pair("hilite", fg, bg); - } else { - set_color_pair("hilite_fg", fg); - } - } else { - set_color_pair("hilite", "fg", bg); - } - break; - default: - if (0 == strlen(fg)) { - fg = "fg"; // current foreground - - } else if (0 == strlen(bg) || 0 == strcasecmp(bg, "NONE")) { - bg = "bg"; // current background - } - - if ("frame" == ident) sf = ""; // ignore underline etc - - set_color_pair(ident, fg, bg, sf); - break; - } - if (asgui) ++gui; - ++done; - } - } else { - dprintf("%s: attribute: %s=unknown", label, parts[baseidx]); - ++ignored; - } - } - } else { - dprintf("%s: <%s> in-active", label, value); - } - break; - - case "set_color": // set_color - // - // set_color - // - if (3 == length_of_list(parts)) { - set_color(parts[1], parts[2]); - } - break; - - case "if": // if - // - // if &background == "dark" - // if &background == "light" - // - // if &t_Co >= 8, 16, 88, 256 - // if &t_Co == 8, 16, 88, 256 - // - // note, other color condition expressions has been sighted yet the above - // represent 90% of all cases. - // - ifstack[ ++iflevel ] = ifactive; - - if (1 == ifactive) { - ifactive = 1; // unknown condition, assume active - - if (length_of_list(parts) >= 2) { - if (strstr(value, "&background")) { - if (strstr(value, "==")) { - if (strstr(value, "&background")) { - ifactive = (0 != strstr(value, base)); - } - - } else if (strstr(value, "!=")) { - if (strstr(value, "&background")) { - ifactive = (0 == strstr(value, base)); - } - } - - } else if (strstr(value, "&t_Co") && colors > 0) { - if (strstr(value, "==")) { - ifactive = (strstr(value, "" + colors)); - - } else if (strstr(value, ">=")) { - if (strstr(value, "256")) { - ifactive = (colors >= 256); - } else if (strstr(value, "88")) { - ifactive = (colors >= 88); - } else if (strstr(value, "16")) { - ifactive = (colors >= 16); - } else if (strstr(value, "8")) { - ifactive = (colors >= 8); - } - } - } - } - if (1 == ifactive) ++cond; - } else { - ifactive = 2; // inactive branch - } - dprintf("%s: COND/if (%d) %*s <%s> == %d\n", label, iflevel, iflevel*4, "", value, ifactive); - break; - - case "elseif": // elseif - if (0 == ifactive) { - if (length_of_list(parts) >= 2) { - if (strstr(value, "&background")) { - if (strstr(value, "==")) { - if (strstr(value, "&background")) { - ifactive = (0 != strstr(value, base)); - } - - } else if (strstr(value, "!=")) { - if (strstr(value, "&background")) { - ifactive = (0 == strstr(value, base)); - } - } - - } else if (strstr(value, "&t_Co")) { - if (strstr(value, "==")) { - ifactive = (0 == strstr(value, "" + colors)); - - } else if (strstr(value, ">=")) { - if (strstr(value, "256")) { - ifactive = (colors >= 256); - } else if (strstr(value, "88")) { - ifactive = (colors >= 88); - } else if (strstr(value, "16")) { - ifactive = (colors >= 16); - } else if (strstr(value, "8")) { - ifactive = (colors >= 8); - } - } - } - } - } else { - ifactive = 2; // inactive branch - } - dprintf("%s: COND/elseif (%d) %*s <%s> == %d\n", label, iflevel, iflevel*4, "", value, ifactive); - break; - - case "else": // else - if (0 == ifactive) { - ++ifactive; // default condition - } - dprintf("%s: COND/else (%d) %*s <%s> == %d\n", label, iflevel, iflevel*4, "", value, ifactive); - break; - - case "endif": // endif - if (iflevel >= 0) { // pop level - ifactive = ifstack[ iflevel ]; - } else { - ifactive = 1; - } - dprintf("%s: COND/endif (%d) %*s <%s> == %d\n", label, iflevel, iflevel*4, "", value, ifactive); - if (iflevel >= 0) iflevel--; - break; - - default: // unknown - break; - } - } - - if (done > 0) { - if (0 == asgui) gui = 0; - if (colors > 0) { - message("%s:%d(%d): gui=%d, links=%d, ignored=%d, cond=%d", label, colors, done, gui, links, ignored, cond); - } else { - message("%s(%d): gui=%d, links=%d, ignored=%d, cond=%d", label, done, gui, links, ignored, cond); - } - } - return done; -} - - -/* Function: vim_groupmap - * Setup the VIM style color links. - * - * Parameters: - * name - Groupname to be initialised, otherwise "". Note that highlight group names are not - * case sensitive. "String" and "string" can be used for the same group. - * - * Note: - * The names marked with '*' below are the preferred groups; the others are minor groups. - * - * Returns: - * nothing - */ -void -vim_groupmap(string name) -{ - // Constant [constant] - // *Constant any constant - // String a string constant: "this is a string" - // Character a character constant: 'c', '\n' - // Number a number constant: 234, 0xff - // Boolean a boolean constant: TRUE, false - // Float a floating point constant: 2.3e10 - // - if (0 == strlen(name) || 0 == strcasecmp(name, "Constant")) { - const string link = "=clear:link@constant"; - set_color("string" +link); - set_color("character"+link); - set_color("number" +link); - set_color("boolean" +link); - set_color("float" +link); - } - - // Identifier [n/a] - // *Identifier any variable name - // Function function name (also: methods for classes) - // - if (0 == strlen(name) || 0 == strcasecmp(name, "Identifier")) { - set_color("word=clear:link@normal"); - set_color("keyword_function=clear:link@normal"); - } - - // Statement [code] - // *Statement any statement - // Conditional if, then, else, endif, switch, etc. - // Repeat for, do, while, etc. - // Label case, default, etc. - // Operator "sizeof", "+", "*", etc. - // Keyword any other keyword - // Exception try, catch, throw - // - if (0 == strlen(name) || 0 == strcasecmp(name, "Statement")) { - const string link = "=clear:link@code"; - set_color("keyword" +link); - set_color("keyword_extension" +link); - set_color("keyword_definition" +link); - set_color("keyword_conditional"+link); - set_color("keyword_repeat" +link); - set_color("keyword_exception" +link); - set_color("keyword_label" +link); - } - - // PreProc [preprocessor] - // *PreProc generic Preprocessor - // Include preprocessor #include - // Define preprocessor #define - // Macro same as Define - // PreCondit preprocessor #if, #else, #endif, etc. - // - if (0 == strlen(name) || 0 == strcasecmp(name, "PreProc")) { - const string link = "=clear:link@preprocessor"; - set_color("preprocessor_include" +link); - set_color("preprocessor_define" +link); - set_color("preprocessor_keyword" +link); - set_color("preprocessor_conditional"+link); - } - - // Type [storageclass] - // *Type int, long, char, etc. - // StorageClass static, register, volatile, etc. - // Structure struct, union, enum, etc. - // Typedef A typedef - // - if (0 == strlen(name) || 0 == strcasecmp(name, "Type")) { - const string link = "=clear:link@keyword_type"; - set_color("keyword_storageclass" +link); - set_color("keyword_structure" +link); - set_color("keyword_typedef" +link); - } - - // Special [standout] - // *Special any special symbol - // SpecialChar special character in a constant - // Tag you can use CTRL-] on this - // Delimiter character that needs attention - // SpecialComment special things inside a comment - // Debug debugging statements - // - if (0 == strlen(name) || 0 == strcasecmp(name, "Special")) { - const string link = "=clear:link@standout"; - set_color("constant_standout" +link); - set_color("tag" +link); - set_color("delimiter" +link); - set_color("comment_standout" +link); - set_color("keyword_debug" +link); - } -} - - -/* Function: vim_attrmap - * Map a VIM style hi[ghlight] attribute to a GRIEF attribute. - * - * Many of the attributes are simple one-to-one mappings. Unsupported are simply ignored. - * - * Parameters: - * attr - VIM attribute name. - * - * Returns: - * Attribute name, otherwise an empty string. - */ -string -vim_attrmap(string attr) -{ - int idx; - - if ((idx = re_search(SF_NOT_REGEXP|SF_IGNORE_CASE, "=" + attr + "=", scheme_colors)) >= 0) { - return scheme_colors[idx + 1]; - } - return ""; -} /*eof*/ + diff --git a/macsrc/colors/README.md b/macsrc/colors/README.md new file mode 100644 index 00000000..b9c11f1e --- /dev/null +++ b/macsrc/colors/README.md @@ -0,0 +1,181 @@ +# Color Schemes + +Collection of color schemes for GriefEdit, most ported from thier vim counter-part. + +## Color Schemes + +| Scheme | Description | Terminal | GUI | +| ------------------------ | ------------|:--------:|:---:| + +| [Atom] | Designed to be very readable in both light and dark environments | | ✓ | + +| [autumn] | Autumn is a color scheme inspired by the colors you can find in the autumn. | ✓ | | + +| [blackdust] | Black-dust | ✓ | | + +| [busybee] | Busy bee | ✓ | | + +| [candle_grey] | Dark monochrome colorscheme with a simple accent color | ✓ | | + +| [candy] | Candy | ✓ | | + +| [clarity] | Clarity | ✓ | | + +| [cloudy] | Cloudy | ✓ | | + +| [codeschool] | Code school | ✓ | | + +| [corp] | Corporation | ✓ | | + +| [darcula] | Accurate Darcula color scheme | ✓ | | + +| [darktango] | Dark tango | ✓ | | + +| [desertEx] | Desert extended | ✓ | | + +| [distinguished] | Distinguised | ✓ | | + +| [github] | Based on Github's syntax highlighting | ✓ | ✓ | + +| [grb256] | Color scheme based on ir_black | ✓ | | + +| [gruvbox] | Retro groove color scheme | ✓ | ✓ | + +| [herald] | Easy-to-read dark color scheme | ✓ | | + +| [inkpot] | Ink pot color scheme | ✓ | | + +| [ir_black] | IR_Black color scheme | ✓ | | + +| [ir_blue] | IR_Blue color scheme | ✓ | | + +| [ir_dark] | IR_Dark color scheme | ✓ | | + +| [jellybeans] | Colorful, dark color scheme | ✓ | ✓ | + +| [lucius] | Lucius color scheme | ✓ | ✓ | + +| [molokai] | Molokai color scheme | ✓ | ✓ | + +| [molokai_rehash] | Molokai color scheme -- rehashed | ✓ | | + +| [one] | Adaptation of one-light and one-dark | ✓ | ✓ | + +| [papercolor] | Light and Dark color schemes inspired by Google's Material Design | ✓ | ✓ | + +| [phd] | Color theme with dark blue background for coding | ✓ | | + +| [railscasts] | Ruby on rails | ✓ | | + +| [solarized] | Precision colors for machines and people | ✓ | | + +| [sonofobsidian] | Son-of-Obisidian color scheme | ✓ | | + +| [tomorrow] | Tomorrow Theme | ✓ | | + +| [tomorrow_night] | Tomorrow Theme dark | ✓ | | + +| [twilight] | TextMate's Twilight theme | ✓ | | + +| [wombat256] | Wombat for 256 color xterms | ✓ | ✓ | + +| [zenbones] |A collection of schemes designed to highlight code using contrasts and font variations. | ✓ | ✓ | + +| [zenburn] | Zenburn is a low-contrast color scheme | ✓ | | + +--------------- + +[autumn]: https://github.com/YorickPeterse/Autumn.vim +[blackdust]: https://vimcolorschemes.com/voithos/vim-colorpack +[busybee]: https://vimcolorschemes.com/voithos/vim-colorpack +[candle_grey]: https://github.com/aditya-azad/candle-grey +[candy]: https://vimcolorschemes.com/voithos/vim-colorpack +[clarity]: https://vimcolorschemes.com/voithos/vim-colorpack +[cloudy]: https://vimcolorschemes.com/voithos/vim-colorpack +[codeschool]: http://astonj.com +[corp]: https://vimcolorschemes.com/voithos/vim-colorpack +[darcula]: https://github.com/blueshirts/darcula +[darktango]: https://vimcolorschemes.com/voithos/vim-colorpack +[desertEx]: https://vimcolorschemes.com/voithos/vim-colorpack +[distinguished]: https://github.com/Lokaltog/vim-distinguished +[grb256]: https://github.com/garybernhardt/dotfiles/ +[herald]: https://github.com/vim-scripts/herald.vim +[inkpot]: http://github.com/ciaranm/inkpot/ +[ir_black]: https://github.com/twerth/ir_black +[ir_blue]: https://github.com/twerth/ir_black +[ir_dark]: https://github.com/twerth/ir_black +[molokai_rehash]: https://github.com/tomasr/molokai +[phd]: https://github.com/vim-scripts/phd +[railscasts]: http://railscasts.com/about +[solarized]: http://ethanschoonover.com/solarized +[sonofobsidian]: https://vimcolorschemes.com/voithos/vim-colorpack +[tomorrow]: https://github.com/chriskempson/tomorrow-theme +[tomorrow_night]: https://github.com/chriskempson/tomorrow-theme +[twilight]: https://vimcolorschemes.com/matthewtodd/vim-twilight +[zenbones]: https://github.com/zenbones-theme/zenbones.nvim +[zenburn]: http://slinky.imukuppi.org/zenburnpage + +------------------- + +[256noir]: https://github.com/andreasvc/vim-256noir +[abstract]: https://github.com/jdsimcoe/abstract.vim +[afterglow]: https://github.com/danilo-augusto/vim-afterglow +[alduin]: https://github.com/AlessandroYorba/Alduin +[Apprentice]: https://github.com/romainl/Apprentice +[Archery]: https://github.com/Badacadabra/vim-archery +[anderson]: https://github.com/gilgigilgil/anderson.vim +[angr]: https://github.com/zacanger/angr.vim +[Atom]: https://github.com/gregsexton/Atom +[ayu-vim]: https://github.com/ayu-theme/ayu-vim +[carbonized]: https://github.com/nightsense/carbonized +[challenger-deep]: https://github.com/challenger-deep-theme/vim +[deep-space]: https://github.com/tyrannicaltoucan/vim-deep-space +[deus]: https://github.com/ajmwagar/vim-deus +[dogrun]: https://github.com/wadackel/vim-dogrun +[flattened]: https://github.com/romainl/flattened +[focuspoint]: https://github.com/chase/focuspoint-vim +[fogbell]: https://github.com/jaredgorski/fogbell.vim +[github]: https://github.com/endel/vim-github-colorscheme +[gotham]: https://github.com/whatyouhide/vim-gotham +[gruvbox]: https://github.com/morhetz/gruvbox +[happy hacking]: https://github.com/yorickpeterse/happy_hacking.vim +[papercolor]: https://github.com/NLKNguyen/papercolor-theme +[parsec]: https://github.com/keith/parsec.vim +[scheakur]: https://github.com/scheakur/vim-scheakur +[hybrid]: https://github.com/w0ng/vim-hybrid +[hybrid-material]: https://github.com/kristijanhusak/vim-hybrid-material +[Iceberg]: https://github.com/cocopon/iceberg.vim +[jellybeans]: https://github.com/nanotech/jellybeans.vim +[lightning]: https://github.com/wimstefan/Lightning +[lucid]: https://github.com/cseelus/vim-colors-lucid +[lucius]: https://github.com/jonathanfilip/vim-lucius +[materialbox]: https://github.com/mkarmona/materialbox +[meta5]: https://github.com/christophermca/meta5 +[minimalist]: https://github.com/dikiaap/minimalist +[molokai]: https://github.com/tomasr/molokai +[molokayo]: https://github.com/fmoralesc/molokayo +[mountaineer]: https://github.com/TheNiteCoder/mountaineer.vim +[nord]: https://github.com/arcticicestudio/nord-vim +[oceanicnext]: https://github.com/mhartington/oceanic-next +[oceanic-material]: https://github.com/hardcoreplayers/oceanic-material +[one]: https://github.com/rakr/vim-one +[onedark]: https://github.com/joshdick/onedark.vim +[onehalf]: https://github.com/sonph/onehalf +[orbital]: https://github.com/fcpg/vim-orbital +[paramount]: https://github.com/owickstrom/vim-colors-paramount +[pink-moon]: https://github.com/sts10/vim-pink-moon +[purify]: https://github.com/kyoz/purify +[pyte]: https://github.com/vim-scripts/pyte +[rdark-terminal2]: https://github.com/vim-scripts/rdark-terminal2.vim +[seoul256]: https://github.com/junegunn/seoul256.vim +[sierra]: https://github.com/AlessandroYorba/Sierra +[solarized8]: https://github.com/lifepillar/vim-solarized8 +[sonokai]: https://github.com/sainnhe/sonokai +[space-vim-dark]: https://github.com/liuchengxu/space-vim-dark +[spacecamp]: https://github.com/jaredgorski/SpaceCamp +[sunbather]: https://github.com/nikolvs/vim-sunbather +[tender]: https://github.com/jacoborus/tender.vim +[termschool]: https://github.com/marcopaganini/termschool-vim-theme +[twilight256]: https://github.com/vim-scripts/twilight256.vim +[two-firewatch]: https://github.com/rakr/vim-two-firewatch +[wombat256]: https://github.com/vim-scripts/wombat256.vim diff --git a/macsrc/colors/brief.cr b/macsrc/colors/brief.cr index 0f4ce775..97663f5e 100644 --- a/macsrc/colors/brief.cr +++ b/macsrc/colors/brief.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 8; -*- */ -/* $Id: brief.cr,v 1.8 2024/05/20 17:21:07 cvsuser Exp $ +/* $Id: brief.cr,v 1.9 2024/07/11 10:42:49 cvsuser Exp $ * Brief/Borland coloriser. * * @@ -19,18 +19,20 @@ brief16_colors = { /*basic brief coloriser specification*/ "hilite_fg=light-white", "standout=light-cyan", "frame=white", + "whitespace=white,light-red", + + "spell=red,underline", + "todo=brown", + "code=white", "string=light-magenta", "operator=yellow", "number=light-magenta", - "comment=white:italic", - "preprocessor=light-green", - "preprocessor_keyword=light-green", - "whitespace=white,light-red", "delimiter=cyan", - "code=white", "word=yellow", - "todo=brown", - "spell=red,underline" + + "preprocessor=light-green", + "preprocessor_keyword=light-green", + "keyword=white" }; void diff --git a/macsrc/colors/busybee.cr b/macsrc/colors/busybee.cr index 09a9105d..a3e9b362 100644 --- a/macsrc/colors/busybee.cr +++ b/macsrc/colors/busybee.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 8; -*- */ -/* $Id: busybee.cr,v 1.2 2014/11/27 15:54:10 ayoung Exp $ +/* $Id: busybee.cr,v 1.3 2024/07/06 18:03:26 cvsuser Exp $ * busybee coloriser, GRIEF port. * * Original: @@ -52,7 +52,7 @@ busybee_colors = { "hi PreProc guifg=#faf4c6 gui=none ctermfg=230", "hi Todo guifg=#ff9f00 guibg=#202020 gui=none", - // " Code-specific colors + // Code-specific colors "hi pythonImport guifg=#009000 gui=none ctermfg=255", "hi pythonException guifg=#f00000 gui=none ctermfg=200", "hi pythonOperator guifg=#7e8aa2 gui=none ctermfg=103", @@ -65,4 +65,5 @@ colorscheme_busybee(void) { vim_colorscheme("busybee", 0, NULL, busybee_colors, -1); } + /*end*/ diff --git a/macsrc/colors/candle_grey.cr b/macsrc/colors/candle_grey.cr new file mode 100644 index 00000000..5d7d92b4 --- /dev/null +++ b/macsrc/colors/candle_grey.cr @@ -0,0 +1,188 @@ +/* -*- mode: cr; indent-width: 4; -*- */ +// $Id: candle_grey.cr,v 1.2 2024/08/04 11:42:44 cvsuser Exp $ +// candle-grey, GriefEdit port - beta. +// +// A dark monochrome colorscheme with a hint of color +// Source: https://github.com/aditya-azad/candle-grey +// +// Colors used +// +// #0D0D0D +// #404040 +// #8C8C8C +// #F2F2F2 +// #D99962 +// +// MIT License +// +// Copyright (c) 2020-present Aditya Azad +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +// + +#include "../grief.h" + +void +colorscheme_candle_grey(~ list args) +{ + list x; + + UNUSED(args); + + x += "set background=dark"; + x += "hi clear"; + x += "syntax reset"; + + // -------------------------------- + // Editor settings + // -------------------------------- + x += "hi Normal ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi Cursor ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi CursorLine ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi LineNr ctermfg=DarkGray ctermbg=Black cterm=NONE guifg=#404040 guibg=#0D0D0D gui=NONE"; + x += "hi CursorLineNR ctermfg=DarkGray ctermbg=Black cterm=NONE guifg=#404040 guibg=#0D0D0D gui=NONE"; + + // ----------------- + // - Number column - + // ----------------- + x += "hi CursorColumn ctermfg=NONE ctermbg=Black cterm=NONE guifg=NONE guibg=#0D0D0D gui=NONE"; + x += "hi FoldColumn ctermfg=DarkGray ctermbg=Black cterm=NONE guifg=#404040 guibg=#0D0D0D gui=NONE"; + x += "hi SignColumn ctermfg=DarkGray ctermbg=Black cterm=NONE guifg=#404040 guibg=#0D0D0D gui=NONE"; + x += "hi Folded ctermfg=DarkGray ctermbg=Black cterm=NONE guifg=#404040 guibg=#0D0D0D gui=NONE"; + + // ------------------------- + // - Window/Tab delimiters - + // ------------------------- + x += "hi VertSplit ctermfg=Black ctermbg=Black cterm=NONE guifg=#0D0D0D guibg=#0D0D0D gui=NONE"; + x += "hi ColorColumn ctermfg=Black ctermbg=Black cterm=NONE guifg=#0D0D0D guibg=#0D0D0D gui=NONE"; + x += "hi TabLine ctermfg=Black ctermbg=Black cterm=NONE guifg=#0D0D0D guibg=#0D0D0D gui=NONE"; + x += "hi TabLineFill ctermfg=Black ctermbg=Black cterm=NONE guifg=#0D0D0D guibg=#0D0D0D gui=NONE"; + x += "hi TabLineSel ctermfg=Black ctermbg=Black cterm=NONE guifg=#0D0D0D guibg=#0D0D0D gui=NONE"; + + // ------------------------------- + // - File Navigation / Searching - + // ------------------------------- + x += "hi Directory ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi Search ctermfg=White ctermbg=210 cterm=NONE guifg=#0D0D0D guibg=#D99962 gui=NONE"; + x += "hi IncSearch ctermfg=White ctermbg=210 cterm=NONE guifg=#0D0D0D guibg=#D99962 gui=NONE"; + + // ----------------- + // - Prompt/Status - + // ----------------- + x += "hi StatusLine ctermfg=210 ctermbg=Black cterm=NONE guifg=#D99962 guibg=#0D0D0D gui=NONE"; + x += "hi StatusLineNC ctermfg=Black ctermbg=Black cterm=NONE guifg=#0D0D0D guibg=#0D0D0D gui=NONE"; + x += "hi WildMenu ctermfg=210 ctermbg=Black cterm=NONE guifg=#D99962 guibg=#0D0D0D gui=NONE"; + x += "hi Question ctermfg=DarkGray ctermbg=Black cterm=NONE guifg=#404040 guibg=#0D0D0D gui=NONE"; + x += "hi Title ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi ModeMsg ctermfg=DarkGray ctermbg=Black cterm=NONE guifg=#404040 guibg=#0D0D0D gui=NONE"; + x += "hi MoreMsg ctermfg=210 ctermbg=Black cterm=NONE guifg=#D99962 guibg=#0D0D0D gui=NONE"; + + // -------------- + // - Visual aid - + // -------------- + x += "hi MatchParen ctermfg=210 ctermbg=DarkGray cterm=NONE guifg=#D99962 guibg=#404040 gui=NONE"; + x += "hi Visual ctermfg=White ctermbg=DarkGray cterm=NONE guifg=#F2F2F2 guibg=#404040 gui=NONE"; + x += "hi VisualNOS ctermfg=White ctermbg=DarkGray cterm=NONE guifg=#F2F2F2 guibg=#404040 gui=NONE"; + x += "hi NonText ctermfg=Black ctermbg=Black cterm=NONE guifg=#0D0D0D guibg=#0D0D0D gui=NONE"; + + x += "hi Todo ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi Underlined ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi Error ctermfg=DarkGray ctermbg=Black cterm=NONE guifg=#404040 guibg=#0D0D0D gui=NONE"; + x += "hi ErrorMsg ctermfg=DarkGray ctermbg=Black cterm=NONE guifg=#404040 guibg=#0D0D0D gui=NONE"; + x += "hi WarningMsg ctermfg=DarkGray ctermbg=Black cterm=NONE guifg=#404040 guibg=#0D0D0D gui=NONE"; + x += "hi Ignore ctermfg=DarkGray ctermbg=Black cterm=NONE guifg=#404040 guibg=#0D0D0D gui=NONE"; + x += "hi SpecialKey ctermfg=DarkGray ctermbg=Black cterm=NONE guifg=#404040 guibg=#0D0D0D gui=NONE"; + x += "hi WhiteSpaceChar ctermfg=DarkGray ctermbg=Black cterm=NONE guifg=#404040 guibg=#0D0D0D gui=NONE"; + x += "hi WhiteSpace ctermfg=DarkGray ctermbg=Black cterm=NONE guifg=#404040 guibg=#0D0D0D gui=NONE"; + + // -------------------------------- + // Variable types + // -------------------------------- + x += "hi Constant ctermfg=Gray ctermbg=Black cterm=NONE guifg=#8C8C8C guibg=#0D0D0D gui=NONE"; + x += "hi String ctermfg=Gray ctermbg=Black cterm=NONE guifg=#8C8C8C guibg=#0D0D0D gui=NONE"; + x += "hi StringDelimiter ctermfg=Gray ctermbg=Black cterm=NONE guifg=#8C8C8C guibg=#0D0D0D gui=NONE"; + x += "hi Character ctermfg=Gray ctermbg=Black cterm=NONE guifg=#8C8C8C guibg=#0D0D0D gui=NONE"; + x += "hi Number ctermfg=Gray ctermbg=Black cterm=NONE guifg=#8C8C8C guibg=#0D0D0D gui=NONE"; + x += "hi Boolean ctermfg=Gray ctermbg=Black cterm=NONE guifg=#8C8C8C guibg=#0D0D0D gui=NONE"; + x += "hi Float ctermfg=Gray ctermbg=Black cterm=NONE guifg=#8C8C8C guibg=#0D0D0D gui=NONE"; + + x += "hi Identifier ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi Function ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + + // -------------------------------- + // Language constructs + // -------------------------------- + x += "hi Statement ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi Conditional ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi Repeat ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi Label ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi Operator ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi Keyword ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi Exception ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi Comment ctermfg=DarkGray ctermbg=Black cterm=NONE guifg=#404040 guibg=#0D0D0D gui=NONE"; + + x += "hi Special ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi SpecialChar ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi Tag ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi Delimiter ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi SpecialComment ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi Debug ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + + // ---------- + // - C like - + // ---------- + x += "hi PreProc ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi Include ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi Define ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi Macro ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi PreCondit ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + + x += "hi Type ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi StorageClass ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi Structure ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi Typedef ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + + // -------------------------------- + // Diff + // -------------------------------- + x += "hi DiffAdd ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi DiffChange ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi DiffDelete ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi DiffText ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + + // -------------------------------- + // Completion menu + // -------------------------------- + x += "hi Pmenu ctermfg=Gray ctermbg=Black cterm=NONE guifg=#8C8C8C guibg=#0D0D0D gui=NONE"; + x += "hi PmenuSel ctermfg=Gray ctermbg=Black cterm=NONE guifg=#8C8C8C guibg=#0D0D0D gui=NONE"; + x += "hi PmenuSbar ctermfg=Gray ctermbg=Black cterm=NONE guifg=#8C8C8C guibg=#0D0D0D gui=NONE"; + x += "hi PmenuThumb ctermfg=Gray ctermbg=Black cterm=NONE guifg=#8C8C8C guibg=#0D0D0D gui=NONE"; + + // -------------------------------- + // Spelling + // -------------------------------- + x += "hi SpellBad ctermfg=210 ctermbg=Black cterm=NONE guifg=#D99962 guibg=#0D0D0D gui=NONE"; + x += "hi SpellCap ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi SpellLocal ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + x += "hi SpellRare ctermfg=White ctermbg=Black cterm=NONE guifg=#F2F2F2 guibg=#0D0D0D gui=NONE"; + + vim_colorscheme("candle_grey", 0, NULL, x, -1); +} + +//end diff --git a/macsrc/colors/corp.cr b/macsrc/colors/corp.cr index f690930d..7269d914 100644 --- a/macsrc/colors/corp.cr +++ b/macsrc/colors/corp.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 8; -*- */ -/* $Id: corp.cr,v 1.3 2014/11/27 15:54:12 ayoung Exp $ +/* $Id: corp.cr,v 1.5 2024/08/25 11:41:52 cvsuser Exp $ * corp coloriser, GRIEF port. * */ @@ -11,33 +11,33 @@ corp_256 = { "set background=dark", "hi clear", - "hi Comment gui=italic guifg=#5E6C70", - "hi Constant guifg=#A1A6A8", - "hi Cursor guifg=#192224 guibg=#F9F9F9", - "hi CursorColumn guibg=#222E30", - "hi CursorIM guifg=#192224 guibg=#536991", - "hi DiffAdd guibg=#193224", - "hi DiffChange guibg=#492224", - "hi DiffDelete guibg=#192224", - "hi DiffText guibg=#492224", - "hi Error guifg=#A1A6A8 guibg=#912C00", - "hi FoldColumn gui=italic guifg=#192224 guibg=#A1A6A8", - "hi Identifier guifg=#BD9800", - "hi ModeMsg gui=bold guifg=#F9F9F9 guibg=#192224", - "hi Normal guifg=#F9F9FF guibg=#192224", - "hi PreProc guifg=#BD9800", - "hi Search guifg=#192224 guibg=#BD9800", - "hi SignColumn guifg=#192224 guibg=#536991", - "hi Statement gui=bold guifg=#BD9800", - "hi StatusLine gui=bold guifg=#192224 guibg=#BD9800", - "hi StatusLineNC gui=bold guifg=#192224 guibg=#5E6C70", - "hi Title gui=bold guifg=#F9F9FF guibg=#192224", - "hi Todo guifg=#F9F9FF guibg=#BD9800", - "hi Type gui=bold guifg=#536991", - "hi Underlined gui=underline guifg=#F9F9FF guibg=#192224", - "hi Visual guifg=#192224 guibg=#F9F9FF", - "hi VisualNOS gui=underline guifg=#192224 guibg=#F9F9FF", - "hi WildMenu guibg=#A1A6A8", + "hi Comment guifg=#5E6C70 gui=italic", + "hi Constant guifg=#A1A6A8", + "hi Cursor guifg=#192224 guibg=#F9F9F9", + "hi CursorColumn guibg=#222E30", + "hi CursorIM guifg=#192224 guibg=#536991", + "hi DiffAdd guibg=#193224", + "hi DiffChange guibg=#492224", + "hi DiffDelete guibg=#192224", + "hi DiffText guibg=#492224", + "hi Error guifg=#A1A6A8 guibg=#912C00", + "hi FoldColumn guifg=#192224 guibg=#A1A6A8 gui=italic", + "hi Identifier guifg=#BD9800", + "hi ModeMsg guifg=#F9F9F9 guibg=#192224 gui=bold", + "hi Normal guifg=#F9F9FF guibg=#192224", + "hi PreProc guifg=#BD9800", + "hi Search guifg=#192224 guibg=#BD9800", + "hi SignColumn guifg=#192224 guibg=#536991", + "hi Statement guifg=#BD9800 gui=bold", + "hi StatusLine guifg=#192224 guibg=#BD9800 gui=bold", + "hi StatusLineNC guifg=#192224 guibg=#5E6C70 gui=bold", + "hi Title guifg=#F9F9FF guibg=#192224 gui=bold", + "hi Todo guifg=#F9F9FF guibg=#BD9800", + "hi Type guifg=#536991 gui=bold", + "hi Underlined guifg=#F9F9FF guibg=#192224 gui=underline", + "hi Visual guifg=#192224 guibg=#F9F9FF", + "hi VisualNOS guifg=#192224 guibg=#F9F9FF gui=underline", + "hi WildMenu guibg=#A1A6A8", "hi link Boolean Constant", "hi link Character Constant", @@ -90,5 +90,7 @@ colorscheme_corp(void) { vim_colorscheme("corp", 256, NULL, corp_256, TRUE); } + /*end*/ + diff --git a/macsrc/colors/darcula.cr b/macsrc/colors/darcula.cr index e02a30e4..b5685204 100644 --- a/macsrc/colors/darcula.cr +++ b/macsrc/colors/darcula.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: darcula.cr,v 1.2 2021/04/16 15:24:58 cvsuser Exp $ +/* $Id: darcula.cr,v 1.3 2024/08/04 11:42:44 cvsuser Exp $ * Darcula colorscheme, GRIEF port. * * see https://github.com/blueshirts/darcula @@ -229,4 +229,3 @@ colorscheme_darcula(void) } /*end*/ - diff --git a/macsrc/colors/default.cr b/macsrc/colors/default.cr index daf3efd8..11fb37fb 100644 --- a/macsrc/colors/default.cr +++ b/macsrc/colors/default.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: default.cr,v 1.3 2014/11/24 03:56:36 ayoung Exp $ +/* $Id: default.cr,v 1.4 2024/07/11 10:42:49 cvsuser Exp $ * Default coloriser, GRIEF port. * * @@ -12,3 +12,5 @@ colorscheme_default(void) { set_color("clear=default"); } + +//end diff --git a/macsrc/colors/desertEx.cr b/macsrc/colors/desertEx.cr index 9cff77d1..e687b0e1 100644 --- a/macsrc/colors/desertEx.cr +++ b/macsrc/colors/desertEx.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 8; -*- */ -/* $Id: desertEx.cr,v 1.2 2014/11/27 15:54:12 ayoung Exp $ +/* $Id: desertEx.cr,v 1.3 2024/08/04 11:42:44 cvsuser Exp $ * desertEx coloriser, GRIEF port. * * Original: @@ -64,4 +64,3 @@ colorscheme_desertEx(void) vim_colorscheme("desertEx", 256, NULL, desertEx_colors, -1); } /*end*/ - diff --git a/macsrc/colors/distinguished.cr b/macsrc/colors/distinguished.cr index 99b42208..8f3aa8a2 100644 --- a/macsrc/colors/distinguished.cr +++ b/macsrc/colors/distinguished.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: distinguished.cr,v 1.3 2014/11/27 15:54:12 ayoung Exp $ +/* $Id: distinguished.cr,v 1.4 2024/08/04 11:42:44 cvsuser Exp $ * distinguished coloriser, GRIEF port. * * Original: @@ -174,4 +174,3 @@ colorscheme_distinguished(void) vim_colorscheme("distinguished", 0, NULL, distinguished_colors, -1); } /*end*/ - diff --git a/macsrc/colors/github.cr b/macsrc/colors/github.cr index 4f461088..123b7e69 100644 --- a/macsrc/colors/github.cr +++ b/macsrc/colors/github.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 8; -*- */ -/* $Id: github.cr,v 1.3 2014/11/27 15:54:12 ayoung Exp $ +/* $Id: github.cr,v 1.4 2024/08/04 11:42:44 cvsuser Exp $ * github coloriser, GRIEF port. * * Original: @@ -131,4 +131,3 @@ colorscheme_github(void) vim_colorscheme("github", 256, NULL, github_colors, TRUE); } /*end*/ - diff --git a/macsrc/colors/grb256.cr b/macsrc/colors/grb256.cr index f5b486d7..bc29de80 100644 --- a/macsrc/colors/grb256.cr +++ b/macsrc/colors/grb256.cr @@ -1,13 +1,13 @@ /* -*- mode: cr; indent-width: 8; -*- */ -/* $Id: grb256.cr,v 1.3 2014/11/27 15:54:12 ayoung Exp $ +/* $Id: grb256.cr,v 1.5 2024/08/04 11:42:44 cvsuser Exp $ * grb256 coloriser, GRIEF port. * * Original: * Name: grb256.vim * Source: https://github.com/garybernhardt/dotfiles/blob/master/.vim/colors * - * GRB256 is a color scheme based on ir_black by Gary Bernhardt. It feels really nice - * especially for Ruby on Rails development. + * GRB256 is a color scheme based on ir_black by Gary Bernhardt. + * It feels really nice especially for Ruby on Rails development. */ #include "../grief.h" @@ -41,8 +41,7 @@ grb256_cteam = { }; -extern void -colorscheme_ir_black(); +extern void colorscheme_ir_black(); void colorscheme_grb256(void) @@ -51,5 +50,5 @@ colorscheme_grb256(void) colorscheme_ir_black(); vim_colorscheme("grb256", 256, NULL, grb256_cteam, FALSE); } -/*end*/ +/*end*/ diff --git a/macsrc/colors/gruvbox.cr b/macsrc/colors/gruvbox.cr index 800964c4..9f622db9 100644 --- a/macsrc/colors/gruvbox.cr +++ b/macsrc/colors/gruvbox.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 8; -*- */ -/* $Id: gruvbox.cr,v 1.2 2014/11/27 15:54:12 ayoung Exp $ +/* $Id: gruvbox.cr,v 1.3 2024/07/06 18:03:26 cvsuser Exp $ * gruvbox coloriser, GRIEF port. * * Original: @@ -75,8 +75,8 @@ HL(string group, declare fg, ~declare bg, ~string gui, ~declare sp) histring += "guibg=NONE ctermbg=NONE "; } - // " Hotfixing #24; - // " TODO: get rid of this spaghetti + // Hotfixing #24; + // TODO: get rid of this spaghetti if (is_string(gui) && strlen(gui)) { if (gui == "none") { histring += "gui=NONE cterm=NONE "; @@ -204,30 +204,30 @@ gruvbox_colorscheme(void) list red, green, yellow, blue, purple, aqua, orange; if (is_dark) { - dark0 = quote_list("282828", 235); // " 40-40-40 - dark1 = quote_list("3c3836", 237); // " 60-56-54 - dark2 = quote_list("504945", 239); // " 80-73-69 - dark3 = quote_list("665c54", 241); // " 102-92-84 - dark4 = quote_list("7c6f64", 243); // " 124-111-100 + dark0 = quote_list("282828", 235); // 40-40-40 + dark1 = quote_list("3c3836", 237); // 60-56-54 + dark2 = quote_list("504945", 239); // 80-73-69 + dark3 = quote_list("665c54", 241); // 102-92-84 + dark4 = quote_list("7c6f64", 243); // 124-111-100 - medium = quote_list("928374", 245); // " 146-131-116 + medium = quote_list("928374", 245); // 146-131-116 - light0 = quote_list("fdf4c1", 229); // " 253-244-193 - light1 = quote_list("ebdbb2", 223); // " 235-219-178 - light2 = quote_list("d5c4a1", 250); // " 213-196-161 - light3 = quote_list("bdae93", 248); // " 189-174-147 - light4 = quote_list("a89984", 246); // " 168-153-132 + light0 = quote_list("fdf4c1", 229); // 253-244-193 + light1 = quote_list("ebdbb2", 223); // 235-219-178 + light2 = quote_list("d5c4a1", 250); // 213-196-161 + light3 = quote_list("bdae93", 248); // 189-174-147 + light4 = quote_list("a89984", 246); // 168-153-132 light4_256 - = quote_list("a89984", 246); // " 168-153-132 + = quote_list("a89984", 246); // 168-153-132 - red = quote_list("fb4934", 167); // " 251-73-52 - green = quote_list("b8bb26", 142); // " 184-187-38 - yellow = quote_list("fabd2f", 214); // " 250-189-47 - blue = quote_list("83a598", 109); // " 131-165-152 - purple = quote_list("d3869b", 175); // " 211-134-155 - aqua = quote_list("8ec07c", 108); // " 142-192-124 - orange = quote_list("fe8019", 208); // " 254-128-25 + red = quote_list("fb4934", 167); // 251-73-52 + green = quote_list("b8bb26", 142); // 184-187-38 + yellow = quote_list("fabd2f", 214); // 250-189-47 + blue = quote_list("83a598", 109); // 131-165-152 + purple = quote_list("d3869b", 175); // 211-134-155 + aqua = quote_list("8ec07c", 108); // 142-192-124 + orange = quote_list("fe8019", 208); // 254-128-25 if (gruvbox_termcolors == 16) { dark0 = quote_list("282828", 0); @@ -243,44 +243,44 @@ gruvbox_colorscheme(void) } if (gruvbox_contrast == "soft") { - dark0 = quote_list("32302f", 236); // " 50-48-47 + dark0 = quote_list("32302f", 236); // 50-48-47 } if (gruvbox_contrast == "hard") { - dark0 = quote_list("1d2021", 234); // " 29-32-33 + dark0 = quote_list("1d2021", 234); // 29-32-33 } if (gruvbox_contrast_dark == "soft") { - dark0 = quote_list("32302f", 236); // " 50-48-47 + dark0 = quote_list("32302f", 236); // 50-48-47 } if (gruvbox_contrast_dark == "hard") { - dark0 = quote_list("1d2021", 234); // " 29-32-33 + dark0 = quote_list("1d2021", 234); // 29-32-33 } } else { - dark0 = quote_list("fbf1c7", 229); // " 251-241-199 - dark1 = quote_list("ebdbb2", 223); // " 235-219-178 - dark2 = quote_list("d5c4a1", 250); // " 213-196-161 - dark3 = quote_list("bdae93", 248); // " 189-174-147 - dark4 = quote_list("a89984", 246); // " 168-153-132 - - medium = quote_list("928374", 244); // " 146-131-116 - - light0 = quote_list("282828", 235); // " 40-40-40 - light1 = quote_list("3c3836", 237); // " 60-56-54 - light2 = quote_list("504945", 239); // " 80-73-69 - light3 = quote_list("665c54", 241); // " 102-92-84 - light4 = quote_list("7c6f64", 243); // " 124-111-100 - - light4_256 = quote_list("7c6f64", 243); // " 124-111-100 - - red = quote_list("9d0006", 88); // " 157-0-6 - green = quote_list("79740e", 100); // " 121-116-14 - yellow = quote_list("b57614", 136); // " 181-118-20 - blue = quote_list("076678", 24); // " 7-102-120 - purple = quote_list("8f3f71", 96); // " 143-63-113 - aqua = quote_list("427b58", 66); // " 66-123-88 - orange = quote_list("af3a03", 130); // " 175-58-3 + dark0 = quote_list("fbf1c7", 229); // 251-241-199 + dark1 = quote_list("ebdbb2", 223); // 235-219-178 + dark2 = quote_list("d5c4a1", 250); // 213-196-161 + dark3 = quote_list("bdae93", 248); // 189-174-147 + dark4 = quote_list("a89984", 246); // 168-153-132 + + medium = quote_list("928374", 244); // 146-131-116 + + light0 = quote_list("282828", 235); // 40-40-40 + light1 = quote_list("3c3836", 237); // 60-56-54 + light2 = quote_list("504945", 239); // 80-73-69 + light3 = quote_list("665c54", 241); // 102-92-84 + light4 = quote_list("7c6f64", 243); // 124-111-100 + + light4_256 = quote_list("7c6f64", 243); // 124-111-100 + + red = quote_list("9d0006", 88); // 157-0-6 + green = quote_list("79740e", 100); // 121-116-14 + yellow = quote_list("b57614", 136); // 181-118-20 + blue = quote_list("076678", 24); // 7-102-120 + purple = quote_list("8f3f71", 96); // 143-63-113 + aqua = quote_list("427b58", 66); // 66-123-88 + orange = quote_list("af3a03", 130); // 175-58-3 if (gruvbox_termcolors == 16) { dark0 = quote_list("fbf1c7", 0); @@ -296,47 +296,47 @@ gruvbox_colorscheme(void) } if (gruvbox_contrast == "soft") { - dark0 = quote_list("f2e5bc", 228); // " 242-229-188 + dark0 = quote_list("f2e5bc", 228); // 242-229-188 } if (gruvbox_contrast == "hard") { - dark0 = quote_list("f9f5d7", 230); // " 249-245-215 + dark0 = quote_list("f9f5d7", 230); // 249-245-215 } if (gruvbox_contrast_light == "soft") { - dark0 = quote_list("f2e5bc", 228); // " 242-229-188 + dark0 = quote_list("f2e5bc", 228); // 242-229-188 } if (gruvbox_contrast_light == "hard") { - dark0 = quote_list("f9f5d7", 230); // " 249-245-215 + dark0 = quote_list("f9f5d7", 230); // 249-245-215 } } - // " Vanilla colorscheme --------------------------------------------------------- - // " General UI: {{{ + // Vanilla colorscheme --------------------------------------------------------- + // General UI: {{{ - // " Normal text + // Normal text colors += HL("Normal", light1, dark0); - // " Correct background (see issue #7): - // " --- Problem with changing between dark and light on 256 color terminal - // " --- https://github.com/morhetz/gruvbox/issues/7 + // Correct background (see issue #7): + // --- Problem with changing between dark and light on 256 color terminal + // --- https://github.com/morhetz/gruvbox/issues/7 if (is_dark) { colors += "set background=dark"; } else { colors += "set background=light"; } - // " Screen line that the cursor is + // Screen line that the cursor is colors += HL("CursorLine", "none", dark1); - // " Screen column that the cursor is + // Screen column that the cursor is colors += HL("CursorColumn", "none", dark1); - // " Tab pages line filler - // " Active tab page label - // " Not active tab page label + // Tab pages line filler + // Active tab page label + // Not active tab page label if (gruvbox_invert_tabline == 0) { colors += HL("TabLineFill", dark4, "bg"); colors += HL("TabLineSel", "bg", dark4, "bold"); @@ -347,16 +347,16 @@ gruvbox_colorscheme(void) colors += HL("TabLine", "bg", dark4); } - // " Match paired bracket under the cursor + // Match paired bracket under the cursor colors += HL("MatchParen", "none", dark3, "bold"); - // " Highlighted screen columns + // Highlighted screen columns colors += HL("ColorColumn", "none", CO(gruvbox_color_column)); - // " Concealed element: \lambda → λ + // Concealed element: \lambda → λ colors += HL("Conceal", blue, "none"); - // " Line number of CursorLine + // Line number of CursorLine colors += HL("CursorLineNr", yellow, dark1); colors += HL("NonText", dark2); @@ -378,57 +378,57 @@ gruvbox_colorscheme(void) colors += HL("StatusLine", dark4, dark0, "bold,inverse"); colors += HL("StatusLineNC", dark2, light4, "bold,inverse"); - // " The column separating vertically split windows + // The column separating vertically split windows colors += HL("VertSplit", light4, CO(gruvbox_vert_split)); - // " Current match in wildmenu completion + // Current match in wildmenu completion colors += HL("WildMenu", blue, dark2, "bold"); - // " Directory names, special names in listing + // Directory names, special names in listing colors += HL("Directory", green, "none", "bold"); - // " Titles for output from :set all, :autocmd, etc. + // Titles for output from :set all, :autocmd, etc. colors += HL("Title", green, "none", "bold"); - // " Error messages on the command line + // Error messages on the command line colors += HL("ErrorMsg", "bg", red, "bold"); - // " More prompt: -- More -- + // More prompt: -- More -- colors += HL("MoreMsg", yellow, "none", "bold"); - // " Current mode message: -- INSERT -- + // Current mode message: -- INSERT -- colors += HL("ModeMsg", yellow, "none", "bold"); - // " "Press enter" prompt and yes/no questions + // "Press enter" prompt and yes/no questions colors += HL("Question", orange, "none", "bold"); - // " Warning messages + // Warning messages colors += HL("WarningMsg", red, "none", "bold"); - // " }}} - // " Gutter: {{{ + // }}} + // Gutter: {{{ - // " Line number for :number and :# commands + // Line number for :number and :# commands colors += HL("LineNr", dark4); - // " Column where signs are displayed + // Column where signs are displayed colors += HL("SignColumn", "none", CO(gruvbox_sign_column)); - // " Line used for closed folds + // Line used for closed folds colors += HL("Folded", medium, dark1, "italic"); - // " Column where folds are displayed + // Column where folds are displayed colors += HL("FoldColumn", medium, dark1); - // " }}} - // " Cursor: {{{ + // }}} + // Cursor: {{{ - // " Character under cursor + // Character under cursor colors += HL("Cursor", "none", "none", "inverse"); - // " Visual mode cursor, selection + // Visual mode cursor, selection colors += HL("vCursor", "none", "none", "inverse"); - // " Input moder cursor + // Input moder cursor colors += HL("iCursor", "none", "none", "inverse"); - // " Language mapping cursor + // Language mapping cursor colors += HL("lCursor", "none", "none", "inverse"); - // " }}} - // " Syntax Highlightin {{{ + // }}} + // Syntax Highlightin {{{ colors += HL("Special", orange); if (gruvbox_italicize_comments == 0) { @@ -439,117 +439,117 @@ gruvbox_colorscheme(void) colors += HL("Todo","fg", "bg", "bold"); colors += HL("Error", "bg", red, "bold"); - // " Generic statement + // Generic statement colors += HL("Statement", red); - // " if, then, } else {, }, swicth, etc. + // if, then, } else {, }, swicth, etc. colors += HL("Conditional", red); - // " for, do, while, etc. + // for, do, while, etc. colors += HL("Repeat", red); - // " case, default, etc. + // case, default, etc. colors += HL("Label", red); - // " try, catch, throw + // try, catch, throw colors += HL("Exception", red); - // " sizeof, "+", "*", etc. + // sizeof, "+", "*", etc. colors += "hi link Operator Normal"; - // " Any other keyword + // Any other keyword colors += HL("Keyword", red); - // " Variable name + // Variable name colors += HL("Identifier", blue); - // " Function name + // Function name colors += HL("Function", green, "none", "bold"); - // " Generic preprocessor + // Generic preprocessor colors += HL("PreProc", aqua); - // " Preprocessor #include + // Preprocessor #include colors += HL("Include", aqua); - // " Preprocessor #define + // Preprocessor #define colors += HL("Define", aqua); - // " Same as Define + // Same as Define colors += HL("Macro", aqua); - // " Preprocessor #if, #} else {, #}, etc. + // Preprocessor #if, #} else {, #}, etc. colors += HL("PreCondit", aqua); - // " Generic constant + // Generic constant colors += HL("Constant",purple); - // " Character constant: "c", "/n" + // Character constant: "c", "/n" colors += HL("Character", purple); - // " String constant: "this is a string" + // String constant: "this is a string" if (gruvbox_italicize_strings == 0) { colors += HL("String", green); } else { colors += HL("String", green, "none", "italic"); } - // " Boolean constant: TRUE, false + // Boolean constant: TRUE, false colors += HL("Boolean", purple); - // " Number constant: 234, 0xff + // Number constant: 234, 0xff colors += HL("Number", purple); - // " Floating point constant: 2.3e10 + // Floating point constant: 2.3e10 colors += HL("Float", purple); - // " Generic type + // Generic type colors += HL("Type", yellow); - // " static, register, volatile, etc + // static, register, volatile, etc colors += HL("StorageClass", orange); - // " struct, union, enum, etc. + // struct, union, enum, etc. colors += HL("Structure", aqua); - // " typedef + // typedef colors += HL("Typedef", yellow); - // " }}} - // " Completion Menu: {{{ + // }}} + // Completion Menu: {{{ - // " Popup menu: normal item + // Popup menu: normal item colors += HL("Pmenu", light1, dark2); - // " Popup menu: selected item + // Popup menu: selected item colors += HL("PmenuSel", dark2, blue, "bold"); - // " Popup menu: scrollbar + // Popup menu: scrollbar colors += HL("PmenuSbar", "none", dark2); - // " Popup menu: scrollbar thumb + // Popup menu: scrollbar thumb colors += HL("PmenuThumb", "none", dark4); - // " }}} - // " Diffs: {{{ + // }}} + // Diffs: {{{ colors += HL("DiffDelete", dark0, red); colors += HL("DiffAdd", dark0, green); // "colors += HL("DiffChange", dark0, blue); // "colors += HL("DiffText", dark0, yellow); - // " Alternative setting + // Alternative setting colors += HL("DiffChange", dark0, aqua); colors += HL("DiffText", dark0, yellow); - // " }}} - // " Spellin {{{ + // }}} + // Spellin {{{ - // " Not capitalised word + // Not capitalised word colors += HL("SpellCap", "none", "none", "undercurl", red); - // " Not recognized word + // Not recognized word colors += HL("SpellBad", "none", "none", "undercurl", blue); - // " Wrong spelling for selected region + // Wrong spelling for selected region colors += HL("SpellLocal", "none", "none", "undercurl", aqua); - // " Rare word + // Rare word colors += HL("SpellRare", "none", "none", "undercurl", purple); - // " }}} + // }}} - // " Plugin specific ------------------------------------------------------------- - // " EasyMotion: {{{ + // Plugin specific ------------------------------------------------------------- + // EasyMotion: {{{ // colors += "hi! link EasyMotionTarget Search"; // colors += "hi! link EasyMotionShade Comment"; - // " }}} - // " Sneak: {{{ + // }}} + // Sneak: {{{ // colors += "hi! link SneakPluginTarget Search"; // colors += "hi! link SneakStreakTarget Search"; // colors += HL("SneakStreakMask", yellow, yellow); // hi! link SneakStreakStatusLine Search - // " }}} - // " Indent Guides: {{{ + // }}} + // Indent Guides: {{{ // // let indent_guides_auto_colors = 0 // @@ -561,14 +561,14 @@ gruvbox_colorscheme(void) // colors += HL("IndentGuidesEven", "bg", dark3, "inverse"); // } // - // " }}} - // " IndentLine: {{{ + // }}} + // IndentLine: {{{ // // string indentLine_color_term = dark2[1]; // string indentLine_color_gui = "#" + dark2[0]; // - // " }}} - // " Rainbow Parentheses: {{{ + // }}} + // Rainbow Parentheses: {{{ // // if (!exists("rbpt_colorpairs"); // let rbpt_colorpairs = @@ -595,7 +595,7 @@ gruvbox_colorscheme(void) // let niji_light_colours = rbpt_colorpairs // // "}}} - // " GitGutter: {{{ + // GitGutter: {{{ // // if (gruvbox_invert_signs == 0) { // colors += HL("GitGutterAdd", green, gruvbox_sign_column); @@ -609,8 +609,8 @@ gruvbox_colorscheme(void) // colors += HL("GitGutterChangeDelete", aqua, gruvbox_sign_column, "inverse"); // } // - // " }}} - // " Signify: {{{ + // }}} + // Signify: {{{ // // if (gruvbox_invert_signs == 0) { // colors += HL("SignifySignAdd", green, gruvbox_sign_column); @@ -622,8 +622,8 @@ gruvbox_colorscheme(void) // colors += HL("SignifySignDelete", red, gruvbox_sign_column, "inverse"); // } // - // " }}} - // " Syntastic: {{{ + // }}} + // Syntastic: {{{ // // colors += HL("SyntasticError", "none", "none", "undercurl", red); // colors += HL("SyntasticWarning", "none", "none", "undercurl", yellow); @@ -636,8 +636,8 @@ gruvbox_colorscheme(void) // colors += HL("SyntasticWarningSign", yellow, gruvbox_sign_column, "inverse"); // } // - // " }}} - // " Signature: {{{ + // }}} + // Signature: {{{ // // if (gruvbox_invert_signs == 0 // colors += HL("SignatureMarkerText", purple, gruvbox_sign_column); @@ -650,8 +650,8 @@ gruvbox_colorscheme(void) // let SignatureMarkerTextHL=""SignatureMarkerText"" // let SignatureMarkTextHL=""SignatureMarkText"" // - // " }}} - // " ShowMarks: {{{ + // }}} + // ShowMarks: {{{ // // if (gruvbox_invert_signs == 0 // colors += HL("ShowMarksHLl", blue, gruvbox_sign_column); @@ -665,8 +665,8 @@ gruvbox_colorscheme(void) // colors += HL("ShowMarksHLm", blue, gruvbox_sign_column, "inverse"); // } // - // " }}} - // " CtrlP: {{{ + // }}} + // CtrlP: {{{ // // colors += HL("CtrlPMatch", yellow); // colors += HL("CtrlPNoEntries", red); @@ -678,8 +678,8 @@ gruvbox_colorscheme(void) // colors += HL("CtrlPMode2", dark0, blue, "bold"); // colors += HL("CtrlPStats", light4, dark2, "bold"); // - // " }}} - // " Startify: {{{ + // }}} + // Startify: {{{ // // colors += HL("StartifyBracket", light3); // colors += HL("StartifyFile", light0); @@ -691,18 +691,18 @@ gruvbox_colorscheme(void) // colors += HL("StartifyHeader", orange); // colors += HL("StartifyFooter", dark2); // - // " }}} - // " Vimshell: {{{ + // }}} + // Vimshell: {{{ // // let vimshell_escape_colors = map(split( // \ "dark4 red green yellow blue purple aqua light4 " . // \ "dark0 red green orange blue purple aqua light0" // \ ), ""#" + s:gb[v:val][0]"); // - // " }}} + // }}} // - // " Filetype specific ----------------------------------------------------------- - // " Diff: {{{ + // Filetype specific ----------------------------------------------------------- + // Diff: {{{ colors += HL("diffAdded", green); colors += HL("diffRemoved", red); @@ -713,8 +713,8 @@ gruvbox_colorscheme(void) colors += HL("diffLine", blue); - // " }}} - // " Html: {{{ + // }}} + // Html: {{{ // // colors += HL("htmlTag", blue); // colors += HL("htmlEndTag", blue); @@ -739,8 +739,8 @@ gruvbox_colorscheme(void) // colors += HL("htmlUnderlineItalic", "fg", "bg", "underline,italic"); // colors += HL("htmlItalic", "fg", "bg", "italic"); // - // " }}} - // " Xml: {{{ + // }}} + // Xml: {{{ // // colors += HL("xmlTag", blue); // colors += HL("xmlEndTag", blue); @@ -763,8 +763,8 @@ gruvbox_colorscheme(void) // // colors += HL("xmlEntity", orange); // colors += HL("xmlEntityPunct", orange); - // " }}} - // " Vim: {{{ + // }}} + // Vim: {{{ // // if (gruvbox_italicize_comments == 0 // colors += HL("vimCommentTitle", light4_256, "none", "bold"); @@ -779,8 +779,8 @@ gruvbox_colorscheme(void) // colors += HL("vimSep", light3); // colors += HL("vimContinue", light3); // - // " }}} - // " Clojure: {{{ + // }}} + // Clojure: {{{ // // colors += HL("clojureKeyword", blue); // colors += HL("clojureCond", orange); @@ -809,14 +809,14 @@ gruvbox_colorscheme(void) // colors += HL("clojureQuote", yellow); // colors += HL("clojureUnquote", yellow); // - // " }}} - // " C: {{{ + // }}} + // C: {{{ // // colors += HL("cOperator", purple); // colors += HL("cStructure", orange); // - // " }}} - // " Python: {{{ + // }}} + // Python: {{{ // // colors += HL("pythonBuiltin", orange); // colors += HL("pythonBuiltinObj", orange); @@ -832,8 +832,8 @@ gruvbox_colorscheme(void) // colors += HL("pythonBoolean", purple); // colors += HL("pythonDot", light3); // - // " }}} - // " CSS: {{{ + // }}} + // CSS: {{{ // // colors += HL("cssBraces", blue); // colors += HL("cssFunctionName", yellow); @@ -867,8 +867,8 @@ gruvbox_colorscheme(void) // colors += HL("cssColorProp", aqua); // colors += HL("cssGeneratedContentProp", aqua); // - // " }}} - // " JavaScript: {{{ + // }}} + // JavaScript: {{{ // // colors += HL("javaScriptBraces", orange); // colors += HL("javaScriptFunction", aqua); @@ -878,8 +878,8 @@ gruvbox_colorscheme(void) // colors += HL("javaScriptNull", purple); // colors += HL("javaScriptParens", light3); // - // " }}} - // " CoffeeScript: {{{ + // }}} + // CoffeeScript: {{{ // // colors += HL("coffeeExtendedOp", light3); // colors += HL("coffeeSpecialOp", light3); @@ -887,20 +887,20 @@ gruvbox_colorscheme(void) // colors += HL("coffeeParen", light3); // colors += HL("coffeeBracket", orange); // - // " }}} - // " Ruby: {{{ + // }}} + // Ruby: {{{ // // colors += HL("rubyStringDelimiter", green); // colors += HL("rubyInterpolationDelimiter", aqua); // - // " }}} - // " ObjectiveC: {{{ + // }}} + // ObjectiveC: {{{ // // colors += HL("objcTypeModifier", red); // colors += HL("objcDirective", blue); // - // " }}} - // " Go: {{{ + // }}} + // Go: {{{ // // colors += HL("goDirective", aqua); // colors += HL("goConstants", purple); @@ -908,23 +908,23 @@ gruvbox_colorscheme(void) // colors += HL("goDeclType", blue); // colors += HL("goBuiltins", orange); // - // " }}} - // " Lua: {{{ + // }}} + // Lua: {{{ // // colors += HL("luaIn", red); // colors += HL("luaFunction", aqua); // colors += HL("luaTable", orange); // - // " }}} - // " MoonScript: {{{ + // }}} + // MoonScript: {{{ // // colors += HL("moonSpecialOp", light3); // colors += HL("moonExtendedOp", light3); // colors += HL("moonFunction", light3); // colors += HL("moonObject", yellow); // - // " }}} - // " Java: {{{ + // }}} + // Java: {{{ // // colors += HL("javaAnnotation", blue); // colors += HL("javaDocTags", aqua); @@ -939,18 +939,18 @@ gruvbox_colorscheme(void) // // colors += HL("javaVarArg", green); // - // " }}} - // " Elixir: {{{ + // }}} + // Elixir: {{{ // // colors += "hi! link elixirDocString Comment"; // // colors += HL("elixirStringDelimiter", green); // colors += HL("elixirInterpolationDelimiter", aqua); // - // " }}} - // " Scala: {{{ + // }}} + // Scala: {{{ // - // " NB: scala vim syntax file is kinda horrible + // NB: scala vim syntax file is kinda horrible // colors += HL("scalaNameDefinition", light1); // colors += HL("scalaCaseFollowing", light1); // colors += HL("scalaCapitalWord", light1); @@ -1125,4 +1125,5 @@ gruvbox_options(void) colorscheme_gruvbox(); } + /*end*/ diff --git a/macsrc/colors/herald.cr b/macsrc/colors/herald.cr index e3cfd715..3f41e217 100644 --- a/macsrc/colors/herald.cr +++ b/macsrc/colors/herald.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 8; -*- */ -/* $Id: herald.cr,v 1.3 2014/11/27 15:54:12 ayoung Exp $ +/* $Id: herald.cr,v 1.4 2024/08/04 11:42:44 cvsuser Exp $ * herald coloriser, GRIEF port. * * Original: @@ -340,4 +340,3 @@ colorscheme_herald(void) } } /*end*/ - diff --git a/macsrc/colors/inkpot.cr b/macsrc/colors/inkpot.cr index 2cad8498..77e37df1 100644 --- a/macsrc/colors/inkpot.cr +++ b/macsrc/colors/inkpot.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 8; -*- */ -/* $Id: inkpot.cr,v 1.2 2014/11/27 15:54:12 ayoung Exp $ +/* $Id: inkpot.cr,v 1.3 2024/08/04 11:42:44 cvsuser Exp $ * inkpot coloriser, GRIEF port. * * Original: @@ -247,6 +247,3 @@ colorscheme_inkpot(void) vim_colorscheme("inkpot", 0, NULL, colors, -1); } /*end*/ - - - diff --git a/macsrc/colors/ir_black.cr b/macsrc/colors/ir_black.cr index 5e41904b..0d9b4b0e 100644 --- a/macsrc/colors/ir_black.cr +++ b/macsrc/colors/ir_black.cr @@ -1,10 +1,10 @@ /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: ir_black.cr,v 1.2 2014/11/27 15:54:12 ayoung Exp $ +/* $Id: ir_black.cr,v 1.3 2024/07/04 11:49:13 cvsuser Exp $ * ir_black coloriser, GRIEF port. * * Original: * Name: ir_black.vim - * More at: http://blog.infinitered.com + * Source: https://github.com/twerth/ir_black */ #include "../grief.h" diff --git a/macsrc/colors/ir_blue.cr b/macsrc/colors/ir_blue.cr index 185e6e48..a48d052a 100644 --- a/macsrc/colors/ir_blue.cr +++ b/macsrc/colors/ir_blue.cr @@ -1,10 +1,10 @@ /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: ir_blue.cr,v 1.2 2014/11/27 15:54:13 ayoung Exp $ +/* $Id: ir_blue.cr,v 1.4 2024/08/04 11:42:44 cvsuser Exp $ * ir_blue coloriser, GRIEF port. * * Original: * Name: ir_blue.vim - * More at: http://blog.infinitered.com + * Source: https://github.com/twerth/ir_black */ #include "../grief.h" @@ -152,4 +152,3 @@ colorscheme_ir_blue(void) vim_colorscheme("ir_blue", 256, NULL, ir_blue_colors, TRUE); } /*end*/ - diff --git a/macsrc/colors/ir_dark.cr b/macsrc/colors/ir_dark.cr index 240ba143..09ef0bcf 100644 --- a/macsrc/colors/ir_dark.cr +++ b/macsrc/colors/ir_dark.cr @@ -1,10 +1,10 @@ /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: ir_dark.cr,v 1.2 2014/11/27 15:54:13 ayoung Exp $ +/* $Id: ir_dark.cr,v 1.3 2024/07/04 11:49:13 cvsuser Exp $ * ir_dark coloriser, GRIEF port. * * Original: * Name: ir_dark.vim - * More at: http://blog.infinitered.com + * Source: https://github.com/twerth/ir_black */ #include "../grief.h" diff --git a/macsrc/colors/jellybeans.cr b/macsrc/colors/jellybeans.cr index 47d6be18..902b91f9 100644 --- a/macsrc/colors/jellybeans.cr +++ b/macsrc/colors/jellybeans.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 8; -*- */ -/* $Id: jellybeans.cr,v 1.2 2014/11/27 15:54:13 ayoung Exp $ +/* $Id: jellybeans.cr,v 1.3 2024/08/04 11:42:44 cvsuser Exp $ * jellybean coloriser, GRIEF port. * * Original: @@ -352,4 +352,3 @@ colorscheme_jellybeans(void) vim_colorscheme("jellybeans", 0, NULL, colors, (!low_color ? TRUE : FALSE)); } /*end*/ - diff --git a/macsrc/colors/lucius.cr b/macsrc/colors/lucius.cr new file mode 100644 index 00000000..c39b95dc --- /dev/null +++ b/macsrc/colors/lucius.cr @@ -0,0 +1,885 @@ +/* -*- mode: cr; indent-width: 4; -*- */ +// $Id: lucius.cr,v 1.5 2024/07/06 18:03:27 cvsuser Exp $ +// lucius coloriser, GriefEdit port - beta. +// +// ============================================================================ +// Name: Lucius vim color scheme +// Author: Jonathan Filip +// Version: 8.1.7 +// Source: https://github.com/jonathanfilip/lucius +// ---------------------------------------------------------------------------- +// +// Light and dark color scheme for GUI and 256 color terminal. +// +// There are several options available to customize the color scheme to your +// own tastes. This is particularly useful when you have to work in different +// environments at different times (home, work, day, night, etc). +// +// The GUI and 256 color terminal versions of this color scheme are identical. +// +// Presets: +// +// There are several presets available that will set all the options for you. +// There are screenshots of each preset below: +// +// * lucius_dark (dark default): http://i.imgur.com/LsZbF.png +// * lucius_darkHighContrast: http://i.imgur.com/e70i9.png +// * lucius_darkLowContrast: http://i.imgur.com/Hmw8s.png +// +// * lucius_black: http://i.imgur.com/iD4ri.png +// * lucius_blackHighContrast: http://i.imgur.com/lHvTJ.png +// * lucius_blackLowContrast: http://i.imgur.com/oZLkg.png +// +// * lucius_light (light default): http://i.imgur.com/soYD8.png +// * lucius_lightLowContrast: http://i.imgur.com/95I86.png +// +// * lucius_white: http://i.imgur.com/wDzkz.png +// * lucius_whiteLowContrast: http://i.imgur.com/jlUf4.png +// +// Options [reference only]: +// +// The presets available cover most of the options. You can, however, customize +// things by setting the following variables yourself: +// +// lucius_style (default: 'dark') +// +// Set this option to either 'light' or 'dark' for your desired color scheme. +// It has the same effect as setting the background. +// +// lucius_contrast (default: 'normal') +// +// This option determines the contrast to use for text/ui elements. It can be +// set to 'low', 'normal', or 'high'. At this time there is no 'high' for the +// light scheme. +// +// lucius_contrast_bg (default: 'normal') +// +// Setting this option makes the background a higher contrast. Current settings +// are 'normal' and 'high'. +// +// lucius_use_bold (default: 1) +// +// Setting this will cause the color scheme to use bold fonts for some items. +// +// lucius_use_underline (default: 1) +// +// Setting this will cause the color scheme to use underlined fonts for some +// items. +// +// lucius_no_term_bg (default: 0) +// +// Setting this will cause the color scheme to not set a background color in +// the terminal (useful for transparency or terminals with different background +// colors). +// +// License: +// +// Copyright (c) 2015 Jonathan Filip +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +// ============================================================================ + +#include "../grief.h" +#include "rgbmap.h" + +void +main(void) +{ + require("colors/rgbmap"); +} + + +// ============================================================================ +// Functions: +// ============================================================================ + +static void +HI(int s, string name, ~string fg, ~string bg, ~string sp) +{ + declare value = get_property(s, name); + + if (is_null(value)) + value = "hi " + name; + + if (fg != "") value += " guifg=" + fg; + if (bg != "") value += " guibg=" + bg; + + UNUSED(sp); +// if (sp != "") value += " guisp=" + sp; + + set_property(s, name, value); +} + + +static string +color_map(string rgb) +{ + extern int colordepth; + return RGBMap(rgb, colordepth); +} + + +static void +AddCterm(int s, string name, ~string extra) +{ + declare value = get_property(s, name); + + if (is_null(value)) + return; + + // foreground + if (0 == strstr(value, "ctermfg=")) { + const int guifg = strstr(value, "guifg="); + + if (guifg) { // guifg=fg|bg|NONE|#rrggbb + value += " ctermfg=" + color_map(substr(value, guifg + 6, 7)); + } + } + + // background + if (0 == strstr(value, "ctermbg=")) { + const int guibg = strstr(value, "guibg="); + + if (guibg) { // guibg=fg|bg|NONE|#rrggbb + value += " ctermbg=" + color_map(substr(value, guibg + 6, 7)); + } + } + + // additional; optional + value += extra; + + set_property(s, name, value); +} + + +static void +AddSpCterm(int s, string name, ~string extra) +{ + UNUSED(s, name, extra); + //TODO +} + + +// ============================================================================ +// Text Groups: +// ============================================================================ + +static list normal_items = { + "ColorColumn", "Comment", "Conceal", "Constant", "Cursor", "CursorColumn", + "CursorIM", "CursorLine", "CursorLineNr", "DiffAdd", "DiffChange", + "DiffDelete", "Directory", "Error", "ErrorMsg", "Identifier", + "IncSearch", "LineNr", "MatchParen", "ModeMsg", "MoreMsg", + "NonText", "Pmenu", "PmenuSbar", "PmenuSel", + "PmenuThumb", "PreProc", "Question", "Search", "SignColumn", + "Special", "SpecialKey", "Statement", "StatusLineNC", "TabLine", + "TabLineFill", "Todo", "Type", "VertSplit", "Visual", + "WarningMsg", "WildMenu" + }; + +static list bold_items = { + "DiffText", "FoldColumn", "Folded", "StatusLine", "TabLineSel", + "Title", "CursorLineNr", + }; + +static list alternative_bold_items = { + "Identifier", "PreProc", "Statement", "Special", "Constant", "Type" + }; + +static list underline_items = { + "Underlined", "VisualNOS" + }; + +static list undercurl_items = { + "SpellBad", "SpellCap", "SpellLocal", "SpellRare" + }; + + +static void +lucius(string scheme, int dark, string contrast, string contrast_bg) +{ + int s = create_dictionary(); + list x; + + // ============================================================================ + // Color Definitions: + // ============================================================================ + + x += "hi clear"; + x += "set background=" + (dark ? "dark" : "light"); + x += "syntax reset"; + + // ---------------------------------------------------------------------------- + // 'Normal' Colors: + // ---------------------------------------------------------------------------- + + string fg, bg; + + if (dark == 0) { // light + if (contrast == "high") { + fg = "#000000"; + } else if (contrast == "low") { + fg = "#626262"; + } else { + fg = "#444444"; + } + } else { // dark + if (contrast == "high") { + fg = "#eeeeee"; + } else if (contrast == "low") { + fg = "#bcbcbc"; + } else { + fg = "#d7d7d7"; + } + } + + if (dark == 0) { // light + if (contrast_bg == "high") { + bg = "#ffffff"; + } else { + bg = "#eeeeee"; + } + } else { // dark + if (contrast_bg == "high") { + bg = "#121212"; + } else { + bg = "#303030"; + } + } + + // ---------------------------------------------------------------------------- + // Extra setup + // ---------------------------------------------------------------------------- + +// if (no_term_bg == 1) { +// x += "Normal ctermbg=NONE"; +// x += "hi Normal guifg=" + fg + " guibg=" + bg + " ctermfg=" + color_map(fg) + " ctermbg=NONE"; + +// } else { + x += "hi Normal guifg=" + fg + " guibg=" + bg + " ctermfg=" + color_map(fg) + " ctermbg=" + color_map(bg); +// } + + // ---------------------------------------------------------------------------- + // Text Markup: + // ---------------------------------------------------------------------------- + + if (dark == 0) { + HI(s, "NonText", "#afafd7", NULL); + HI(s, "SpecialKey", "#afd7af", NULL); + if (contrast == "low") { + HI(s, "Comment", "#9e9e9e", NULL); + HI(s, "Conceal", "#9e9e9e", NULL); + HI(s, "Constant", "#d78700", NULL); + HI(s, "Directory", "#00af87", NULL); + HI(s, "Identifier", "#00af00", NULL); + HI(s, "PreProc", "#00afaf", NULL); + HI(s, "Special", "#af00af", NULL); + HI(s, "Statement", "#0087d7", NULL); + HI(s, "Title", "#0087d7", NULL); + HI(s, "Type", "#0087af", NULL); + } else { + HI(s, "Comment", "#808080", NULL); + HI(s, "Conceal", "#808080", NULL); + HI(s, "Constant", "#af5f00", NULL); + HI(s, "Directory", "#00875f", NULL); + HI(s, "Identifier", "#008700", NULL); + HI(s, "PreProc", "#008787", NULL); + HI(s, "Special", "#870087", NULL); + HI(s, "Statement", "#005faf", NULL); + HI(s, "Title", "#005faf", NULL); + HI(s, "Type", "#005f87", NULL); + } + } else { + HI(s, "NonText", "#5f5f87", NULL); + HI(s, "SpecialKey", "#5f875f", NULL); + if (contrast == "low") { + HI(s, "Comment", "#6c6c6c", NULL); + HI(s, "Conceal", "#6c6c6c", NULL); + HI(s, "Constant", "#afaf87", NULL); + HI(s, "Directory", "#87af87", NULL); + HI(s, "Identifier", "#87af5f", NULL); + HI(s, "PreProc", "#5faf87", NULL); + HI(s, "Special", "#af87af", NULL); + HI(s, "Statement", "#5fafd7", NULL); + HI(s, "Title", "#00afd7", NULL); + HI(s, "Type", "#5fafaf", NULL); + } else if (contrast == "high") { + HI(s, "Comment", "#8a8a8a", NULL); + HI(s, "Conceal", "#8a8a8a", NULL); + HI(s, "Constant", "#ffffd7", NULL); + HI(s, "Directory", "#d7ffd7", NULL); + HI(s, "Identifier", "#d7ffaf", NULL); + HI(s, "PreProc", "#afffd7", NULL); + HI(s, "Special", "#ffd7ff", NULL); + HI(s, "Statement", "#afffff", NULL); + HI(s, "Title", "#87d7ff", NULL); + HI(s, "Type", "#afffff", NULL); + } else { + HI(s, "Comment", "#808080", NULL); + HI(s, "Conceal", "#808080", NULL); + HI(s, "Constant", "#d7d7af", NULL); + HI(s, "Directory", "#afd7af", NULL); + HI(s, "Identifier", "#afd787", NULL); + HI(s, "PreProc", "#87d7af", NULL); + HI(s, "Special", "#d7afd7", NULL); + HI(s, "Statement", "#87d7ff", NULL); + HI(s, "Title", "#5fafd7", NULL); + HI(s, "Type", "#87d7d7", NULL); + } + } + + // ---------------------------------------------------------------------------- + // Highlighting: + // ---------------------------------------------------------------------------- + + HI(s, "Cursor", bg, NULL); + HI(s, "CursorColumn", "NONE", NULL); + HI(s, "CursorIM", bg, NULL); + HI(s, "CursorLine", "NONE", NULL); + HI(s, "Visual", "NONE", NULL); + HI(s, "VisualNOS", fg, "NONE"); + if (dark == 0) { + HI(s, "CursorColumn", NULL, "#dadada"); + HI(s, "CursorLine", NULL, "#dadada"); + HI(s, "IncSearch", fg, "#5fd7d7"); + HI(s, "MatchParen", "NONE", "#5fd7d7"); + HI(s, "Search", fg, "#ffaf00"); + HI(s, "Visual", NULL, "#afd7ff"); + if (contrast == "low") { + HI(s, "Cursor", NULL, "#87afd7"); + HI(s, "CursorIM", NULL, "#87afd7"); + HI(s, "Error", "#d70000", "#ffd7d7"); + HI(s, "Todo", "#af8700", "#ffffaf"); + } else { + HI(s, "Cursor", NULL, "#5f87af"); + HI(s, "CursorIM", NULL, "#5f87af"); + HI(s, "Error", "#af0000", "#d7afaf"); + HI(s, "Todo", "#875f00", "#ffffaf"); + } + } else { + HI(s, "CursorColumn", NULL, "#444444"); + HI(s, "CursorLine", NULL, "#444444"); + HI(s, "IncSearch", bg, NULL); + HI(s, "MatchParen", fg, "#87af00"); + HI(s, "Search", bg, NULL); + HI(s, "Visual", NULL, "#005f87"); + if (contrast == "low") { + HI(s, "Cursor", NULL, "#5f87af"); + HI(s, "CursorIM", NULL, "#5f87af"); + HI(s, "Error", "#d75f5f", "#870000"); + HI(s, "IncSearch", NULL, "#00afaf"); + HI(s, "Search", NULL, "#d78700"); + HI(s, "Todo", "#afaf00", "#5f5f00"); + } else if (contrast == "high") { + HI(s, "Cursor", NULL, "#afd7ff"); + HI(s, "CursorIM", NULL, "#afd7ff"); + HI(s, "Error", "#ffafaf", "#af0000"); + HI(s, "IncSearch", NULL, "#87ffff"); + HI(s, "Search", NULL, "#ffaf5f"); + HI(s, "Todo", "#ffff87", "#87875f"); + } else { + HI(s, "Cursor", NULL, "#87afd7"); + HI(s, "CursorIM", NULL, "#87afd7"); + HI(s, "Error", "#ff8787", "#870000"); + HI(s, "IncSearch", NULL, "#5fd7d7"); + HI(s, "Search", NULL, "#d78700"); + HI(s, "Todo", "#d7d75f", "#5f5f00"); + } + } + + + // ---------------------------------------------------------------------------- + // Messages: + // ---------------------------------------------------------------------------- + + HI(s, "Question", fg, NULL); + if (dark == 0) { + if (contrast == "low") { + HI(s, "ErrorMsg", "#d70000", NULL); + HI(s, "ModeMsg", "#0087ff", NULL); + HI(s, "MoreMsg", "#0087ff", NULL); + HI(s, "WarningMsg", "#d78700", NULL); + } else { + HI(s, "ErrorMsg", "#af0000", NULL); + HI(s, "ModeMsg", "#005faf", NULL); + HI(s, "MoreMsg", "#005faf", NULL); + HI(s, "WarningMsg", "#af5f00", NULL); + } + } else { + if (contrast == "low") { + HI(s, "ErrorMsg", "#d75f5f", NULL); + HI(s, "ModeMsg", "#87afaf", NULL); + HI(s, "MoreMsg", "#87afaf", NULL); + HI(s, "WarningMsg", "#af875f", NULL); + } else if (contrast == "high") { + HI(s, "ErrorMsg", "#ff8787", NULL); + HI(s, "ModeMsg", "#afffff", NULL); + HI(s, "MoreMsg", "#afffff", NULL); + HI(s, "WarningMsg", "#ffaf87", NULL); + } else { + HI(s, "ErrorMsg", "#ff5f5f", NULL); + HI(s, "ModeMsg", "#afd7d7", NULL); + HI(s, "MoreMsg", "#afd7d7", NULL); + HI(s, "WarningMsg", "#d7875f", NULL); + } + } + + + // ---------------------------------------------------------------------------- + // UI: + // ---------------------------------------------------------------------------- + + HI(s, "ColorColumn", "NONE", NULL); + HI(s, "Pmenu", bg, NULL); + HI(s, "PmenuSel", fg, NULL); + HI(s, "PmenuThumb", fg, NULL); + HI(s, "StatusLine", bg, NULL); + HI(s, "TabLine", bg, NULL); + HI(s, "TabLineSel", fg, NULL); + HI(s, "WildMenu", fg, NULL); + if (dark == 0) { + HI(s, "ColorColumn", NULL, "#e4e4e4"); + HI(s, "CursorLineNr", "#626262", "#dadada"); + HI(s, "FoldColumn", NULL, "#bcbcbc"); + HI(s, "Folded", NULL, "#bcbcbc"); + HI(s, "LineNr", "#9e9e9e", "#dadada"); + HI(s, "PmenuSel", NULL, "#afd7ff"); + HI(s, "SignColumn", NULL, "#d0d0d0"); + HI(s, "StatusLineNC", "#dadada", NULL); + HI(s, "TabLineFill", "#dadada", NULL); + HI(s, "VertSplit", "#e4e4e4", NULL); + HI(s, "WildMenu", NULL, "#afd7ff"); + if (contrast == "low") { + HI(s, "FoldColumn", "#808080", NULL); + HI(s, "Folded", "#808080", NULL); + HI(s, "Pmenu", NULL, "#9e9e9e"); + HI(s, "PmenuSbar", "#9e9e9e", "#626262"); + HI(s, "PmenuThumb", NULL, "#9e9e9e"); + HI(s, "SignColumn", "#808080", NULL); + HI(s, "StatusLine", NULL, "#9e9e9e"); + HI(s, "StatusLineNC", NULL, "#9e9e9e"); + HI(s, "TabLine", NULL, "#9e9e9e"); + HI(s, "TabLineFill", NULL, "#9e9e9e"); + HI(s, "TabLineSel", NULL, "#afd7ff"); + HI(s, "VertSplit", NULL, "#9e9e9e"); + } else { + HI(s, "FoldColumn", "#626262", NULL); + HI(s, "Folded", "#626262", NULL); + HI(s, "Pmenu", NULL, "#808080"); + HI(s, "PmenuSbar", "#808080", "#444444"); + HI(s, "PmenuThumb", NULL, "#9e9e9e"); + HI(s, "SignColumn", "#626262", NULL); + HI(s, "StatusLine", NULL, "#808080"); + HI(s, "StatusLineNC", NULL, "#808080"); + HI(s, "TabLine", NULL, "#808080"); + HI(s, "TabLineFill", NULL, "#808080"); + HI(s, "TabLineSel", NULL, "#afd7ff"); + HI(s, "VertSplit", NULL, "#808080"); + } + } else { + HI(s, "ColorColumn", NULL, "#3a3a3a"); + HI(s, "CursorLineNr", "#9e9e9e", "#444444"); + HI(s, "FoldColumn", NULL, "#4e4e4e"); + HI(s, "Folded", NULL, "#4e4e4e"); + HI(s, "LineNr", "#626262", "#444444"); + HI(s, "PmenuSel", NULL, "#005f87"); + HI(s, "SignColumn", NULL, "#4e4e4e"); + HI(s, "StatusLineNC", "#4e4e4e", NULL); + HI(s, "TabLineFill", "#4e4e4e", NULL); + HI(s, "VertSplit", "#626262", NULL); + HI(s, "WildMenu", NULL, "#005f87"); + if (contrast == "low") { + HI(s, "FoldColumn", "#a8a8a8", NULL); + HI(s, "Folded", "#a8a8a8", NULL); + HI(s, "Pmenu", NULL, "#8a8a8a"); + HI(s, "PmenuSbar", "#8a8a8a", "#bcbcbc"); + HI(s, "PmenuThumb", NULL, "#585858"); + HI(s, "SignColumn", "#8a8a8a", NULL); + HI(s, "StatusLine", NULL, "#8a8a8a"); + HI(s, "StatusLineNC", NULL, "#8a8a8a"); + HI(s, "TabLine", NULL, "#8a8a8a"); + HI(s, "TabLineFill", NULL, "#8a8a8a"); + HI(s, "TabLineSel", NULL, "#005f87"); + HI(s, "VertSplit", NULL, "#8a8a8a"); + } else if (contrast == "high") { + HI(s, "FoldColumn", "#c6c6c6", NULL); + HI(s, "Folded", "#c6c6c6", NULL); + HI(s, "Pmenu", NULL, "#bcbcbc"); + HI(s, "PmenuSbar", "#bcbcbc", "#dadada"); + HI(s, "PmenuThumb", NULL, "#8a8a8a"); + HI(s, "SignColumn", "#bcbcbc", NULL); + HI(s, "StatusLine", NULL, "#bcbcbc"); + HI(s, "StatusLineNC", NULL, "#bcbcbc"); + HI(s, "TabLine", NULL, "#bcbcbc"); + HI(s, "TabLineFill", NULL, "#bcbcbc"); + HI(s, "TabLineSel", NULL, "#0087af"); + HI(s, "VertSplit", NULL, "#bcbcbc"); + } else { + HI(s, "FoldColumn", "#bcbcbc", NULL); + HI(s, "Folded", "#bcbcbc", NULL); + HI(s, "Pmenu", NULL, "#b2b2b2"); + HI(s, "PmenuSbar", "#b2b2b2", "#d0d0d0"); + HI(s, "PmenuThumb", NULL, "#808080"); + HI(s, "SignColumn", "#b2b2b2", NULL); + HI(s, "StatusLine", NULL, "#b2b2b2"); + HI(s, "StatusLineNC", NULL, "#b2b2b2"); + HI(s, "TabLine", NULL, "#b2b2b2"); + HI(s, "TabLineFill", NULL, "#b2b2b2"); + HI(s, "TabLineSel", NULL, "#005f87"); + HI(s, "VertSplit", NULL, "#b2b2b2"); + } + } + + + // ---------------------------------------------------------------------------- + // Diff: + // ---------------------------------------------------------------------------- + + HI(s, "DiffAdd", fg, NULL); + HI(s, "DiffChange", fg, NULL); + HI(s, "DiffDelete", fg, NULL); + + if (dark == 0) { + HI(s, "DiffAdd", NULL, "#afd7af"); + HI(s, "DiffChange", NULL, "#d7d7af"); + HI(s, "DiffDelete", NULL, "#d7afaf"); + HI(s, "DiffText", NULL, "#d7d7af"); + if (contrast == "low") { + HI(s, "DiffText", "#ff8700", NULL); + } else { + HI(s, "DiffText", "#d75f00", NULL); + } + } else { + HI(s, "DiffAdd", NULL, "#5f875f"); + HI(s, "DiffChange", NULL, "#87875f"); + HI(s, "DiffDelete", NULL, "#875f5f"); + HI(s, "DiffText", NULL, "#87875f"); + if (contrast == "low") { + HI(s, "DiffText", "#d7d75f", NULL); + } else { + HI(s, "DiffText", "#ffff87", NULL); + } + } + + + // ---------------------------------------------------------------------------- + // Spelling: + // ---------------------------------------------------------------------------- + + if (dark == 0) { + HI(s, "SpellBad", NULL, NULL, "#d70000"); + HI(s, "SpellCap", NULL, NULL, "#00afd7"); + HI(s, "SpellLocal", NULL, NULL, "#d7af00"); + HI(s, "SpellRare", NULL, NULL, "#5faf00"); + } else { + HI(s, "SpellBad", NULL, NULL, "#ff5f5f"); + HI(s, "SpellCap", NULL, NULL, "#5fafd7"); + HI(s, "SpellLocal", NULL, NULL, "#d7af5f"); + HI(s, "SpellRare", NULL, NULL, "#5faf5f"); + } + + + // ---------------------------------------------------------------------------- + // Miscellaneous: + // ---------------------------------------------------------------------------- + + HI(s, "Ignore", bg, NULL); + HI(s, "Underlined", fg, NULL); + + + // ============================================================================ + // Cterm Colors, plus Text Emphasis + // ============================================================================ + + string item; + + while (list_each(normal_items, item) >= 0) { + if (re_search(NULL, "^" + item + "$", alternative_bold_items) >= 0) { + AddCterm(s, item, " gui=bold cterm=bold term=none"); + } else { + AddCterm(s, item); + } + } + +// if (use_bold) { + while (list_each(bold_items, item) >= 0) { + AddCterm(s, item, " gui=bold cterm=bold term=none"); + } + +// } else { +// while (list_each(bold_items, value) >= 0) { +// AddCterm(s, item); +// } +// } + +// if (use_underline) { + while (list_each(underline_items, item) >= 0) { + AddCterm(s, item, " gui=underline cterm=underline term=none"); + } + + while (list_each(undercurl_items, item) >= 0) { + AddSpCterm(s, item, " gui=undercurl cterm=undercurl term=none"); + } + +// } else { +// while ((idx = list_each(underline_items, value)) >= 0) { +// AddCterm(s, item); +// } +// while (list_each(undercurl_items, item) >= 0) { +// AddSpCterm(s, item); +// } +// } + + + // ============================================================================ + // Alternative Bold Definitions: + // ============================================================================ + +// for item in alternative_bold_items +// let temp_gui_fg = synIDattr(synIDtrans(hlID('" . item . "')), 'fg', 'gui')" +// let temp_cterm_fg = synIDattr(synIDtrans(hlID('" . item . "')), 'fg', 'cterm')" +// HI(s, B" . item . " guifg=" . temp_gui_fg . " ctermfg=" . temp_cterm_fg . " gui=bold cterm=bold term=none" +// } + + x += dict_list(s, FALSE /*values*/); + delete_dictionary(s); + + // ============================================================================ + // Plugin Specific Colors: + // ============================================================================ + + // Tagbar: + x += "link TagbarAccessPublic Constant"; + x += "link TagbarAccessProtected Type"; + x += "link TagbarAccessPrivate PreProc"; + + // Vimwiki: + x += "link VimwikiHeader1 BIdentifier"; + x += "link VimwikiHeader2 BPreProc"; + x += "link VimwikiHeader3 BStatement"; + x += "link VimwikiHeader4 BSpecial"; + x += "link VimwikiHeader5 BConstant"; + x += "link VimwikiHeader6 BType"; + + // CoC: + x += "hi link CocErrorSign ErrorMsg"; + x += "hi link CocErrorFloat Pmenu"; + x += "hi link CocWarningSign WarningMsg"; + x += "hi link CocWarningFloat Pmenu"; + x += "hi link CocInfoSign MoreMsg"; + x += "hi link CocInfoFloat Pmenu"; + x += "hi link CocHintFloat Directory"; + x += "hi link CocHintFloat Pmenu"; + + vim_colorscheme(scheme, 0, NULL, x, -1); +} + + +// ============================================================================ +// Preset Commands: +// ============================================================================ + +#define LUCIUS_DEFAULT -1 +#define LUCIUS_LIGHT 0 +#define LUCIUS_DARK 1 + +/* + * lucius_set --- + * Lucuis colorscheme + * + * dark - default dark/light: default=-1, dark=1, light=0 + * contrast - default contrast; "normal", "low" or "high" + * contrast_bg - default contrast_bg "normal" or "high" + * args - optional arguments + * + */ +static int +lucius_set(int dark, string contrast, string contrast_bg, ~list args) +{ + string scheme = "lucius"; + int colordepth = -1; + + if (! is_null(args)) { + /* options */ + const list longoptions = { + /*0*/ "colors:n+", + /*1*/ "mode:s", // "dark" or "light" + /*2*/ "contrast:s", // "normal", "low" or "high" + /*3*/ "contrast_bg:s", // "normal" or "high" + /*4*/ "dark", // mode=dark [shortcut] + /*5*/ "light" // mode=light [shortcut] + }; + int optidx = 0, ch; + string value; + + if ((ch = getopt(value, NULL, longoptions, args, scheme)) >= 0) { + do { + ++optidx; + switch(ch) { + case 0: // colordepth + colordepth = atoi(value); + break; + case 1: // mode + if (value == "default") { /* dynamic dark or light */ + dark = -1; + } else { + dark = (value == "dark" ? 1 : 0); + } + break; + case 2: // contrast=normal|low|high + if (value != "normal" && value != "low" && value != "high") { + error("%s: invalid contrast <%s>", scheme, value); + return -1; + } + contrast = value; + break; + case 3: // contrast_bg=normal|high + if (value != "normal" && value != "high") { + error("%s: invalid contrast_bg <%s>", scheme, value); + return -1; + } + contrast_bg = value; + break; + case 4: // dark + dark = 1; + break; + case 5: // light + dark = 0; + break; + default: + error("%s: %s", scheme, value); + return -1; + } + } while ((ch = getopt(value)) >= 0); + } + + if (optidx < length_of_list(args)) { + if (args[optidx] == "show") { + message("%s: by %s, GriefEdit version", scheme, "Jonathan Filip"); + } else { + error("%s: unexpected option <%s>", scheme, args[optidx]); + } + return -1; + } + } + + if (colordepth <= 0) { + get_term_feature(TF_COLORDEPTH, colordepth); + } + if (colordepth != 16 && colordepth != 88 && colordepth != 256) { + error("%s: color depth not supported", scheme); + return -1; + } + + if (dark == -1) { + get_term_feature(TF_SCHEMEDARK, dark); /* default */ + } + + lucius(scheme, dark, contrast, contrast_bg); + return 0; +} + + +int +colorscheme_lucius(~list args) +{ + return lucius_set(LUCIUS_DEFAULT, "normal", "normal", args); +} + +/////////// + +int +colorscheme_lucius_light(~list args) +{ + return lucius_set(LUCIUS_LIGHT, "normal", "normal", args); +} + +int +colorscheme_lucius_lightLowContrast(~list args) +{ + return lucius_set(LUCIUS_LIGHT, "low", "normal", args); +} + +int +colorscheme_lucius_lightHighContrast(~list args) +{ + return lucius_set(LUCIUS_LIGHT, "high", "normal", args); +} + +/////////// + +int +colorscheme_lucius_white(~list args) +{ + return lucius_set(LUCIUS_LIGHT, "normal", "high", args); +} + +int +colorscheme_Lucius_whiteHighContrast(~list args) +{ + return lucius_set(LUCIUS_LIGHT, "high", "high", args); +} + +int +colorscheme_lucius_whiteLowContrast(~list args) +{ + return lucius_set(LUCIUS_LIGHT, "low", "high", args); +} + +/////////// + +int +colorscheme_lucius_dark(~list args) +{ + return lucius_set(LUCIUS_DARK, "normal", "normal", args); +} + +int +colorscheme_lucius_darkLowContrast(~list args) +{ + return lucius_set(LUCIUS_DARK, "low", "normal", args); +} + +int +colorscheme_lucius_darkHighContrast(~list args) +{ + return lucius_set(LUCIUS_DARK, "high", "normal", args); +} + +/////////// + +int +colorscheme_lucius_black(~list args) +{ + return lucius_set(LUCIUS_DARK, "normal", "high", args); +} + +int +colorscheme_lucius_blackLowContrast(~list args) +{ + return lucius_set(LUCIUS_DARK, "low", "high", args); +} + +int +colorscheme_lucius_blackHighContrast(~list args) +{ + return lucius_set(LUCIUS_DARK, "high", "high", args); +} + +//end diff --git a/macsrc/colors/molokai.cr b/macsrc/colors/molokai.cr index 988fda16..92309f68 100644 --- a/macsrc/colors/molokai.cr +++ b/macsrc/colors/molokai.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 8; -*- */ -/* $Id: molokai.cr,v 1.2 2014/11/27 15:54:13 ayoung Exp $ +/* $Id: molokai.cr,v 1.3 2024/08/04 11:42:44 cvsuser Exp $ * molokai coloriser, GRIEF port. * * Original: @@ -238,4 +238,3 @@ colorscheme_molokai(void) } } /*end*/ - diff --git a/macsrc/colors/one.cr b/macsrc/colors/one.cr new file mode 100644 index 00000000..4efb62ca --- /dev/null +++ b/macsrc/colors/one.cr @@ -0,0 +1,771 @@ +/* -*- mode: cr; indent-width: 4; -*- */ +/* $Id: one.cr,v 1.4 2024/07/06 18:03:27 cvsuser Exp $ + + Source: https://github.com/rakr/vim-one/ + Version: 1.1.1-pre + + Light and dark vim/style colorscheme, shamelessly stolen from atom (another excellent text editor). + One supports true colors and falls back gracefully and automatically if your environment does not support this feature. + + Author: Ramzi Akremi + + ================================================================================= + + The MIT License (MIT) + + Copyright (c) 2016 Ramzi Akremi + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + + ================================================================================= +*/ + +#include "../grief.h" +#include "rgbmap.h" + +void +main(void) +{ + require("colors/rgbmap"); +} + + +string +rbg_map(string rgb) +{ + extern int colordepth; + int r,g,b; + + sscanf(rgb, "#%2x%2x%2x", r, g, b); + return RGBPaletteIndex(r, g, b, colordepth); +} + + +// Highlight function +static string +X(string group, ~list fg, ~list bg, ~string attr) +{ + extern int colordepth; + string s, guisp; + + s = "hi " + group; + + if (colordepth < 256) { + if (! is_null(fg)) { + if (length_of_list(fg)) { + s += " guifg=" + fg[0]; + s += " ctermfg=" + rbg_map(fg[0]); + if (length_of_list(fg) >= 3) { + guisp = fg[2]; + } + } + } + + if (! is_null(bg)) { + if (length_of_list(bg)) { + s += " guibg=" + bg[0]; + s += " ctermbg=" + rbg_map(bg[0]); + if (length_of_list(bg) >= 3) { + guisp = bg[2]; + } + } + } + + } else { + if (! is_null(fg)) { + if (length_of_list(fg)) { + s += " guifg=" + fg[0]; + s += " ctermfg=" + fg[1]; + if (length_of_list(fg) >= 3) { + guisp = fg[2]; + } + } + } + + if (! is_null(bg)) { + if (length_of_list(bg)) { + s += " guibg=" + bg[0]; + s += " ctermbg=" + bg[1]; + if (length_of_list(bg) >= 3) { + guisp = bg[2]; + } + } + } + } + + if (is_string(attr)) { + if (attr) { + s += " gui=" + attr; + s += " cterm=" + attr; + } + } + + // TODO: "guisp" is used for undercurl and strikethrough. + // if (guisp) + // s += " guisp=" + guisp; + + return s; +} + + +static void +one(string scheme, int dark, int italic) +{ + int gui_running = 0; // TODO: TF_GUI + + list kmono_1; + list kmono_2; + list kmono_3; + list kmono_4; + list khue_1; + list khue_2; + list khue_3; + list khue_4; + list khue_5; + list khue_5_2; + list khue_6; + list khue_6_2; + list ksyn_bg; + list ksyn_gutter; + list ksyn_cursor; + list ksyn_accent; + list ksyn_accent_2; + list kvertsplit; + list kspecial_grey; + list kvisual_grey; + list kpmenu; + + // Color definition + // -------------------------------------------------------- + if (dark) { + kmono_1 = quote_list("#abb2bf", "145"); + kmono_2 = quote_list("#828997", "102"); + kmono_3 = quote_list("#5c6370", "59"); + kmono_4 = quote_list("#4b5263", "59"); + + khue_1 = quote_list("#56b6c2", "73", "cyan"); + khue_2 = quote_list("#61afef", "75", "blue"); + khue_3 = quote_list("#c678dd", "176", "purple"); + khue_4 = quote_list("#98c379", "114", "green"); + + khue_5 = quote_list("#e06c75", "168", "red 1"); + khue_5_2 = quote_list("#be5046", "130", "red 2"); + + khue_6 = quote_list("#d19a66", "173", "orange 1"); + khue_6_2 = quote_list("#e5c07b", "180", "orange 2"); + + ksyn_bg = quote_list("#282c34", "16"); + ksyn_gutter = quote_list("#636d83", "60"); + ksyn_cursor = quote_list("#2c323c", "16"); + ksyn_accent = quote_list("#528bff", "69"); + + kvertsplit = quote_list("#181a1f", "233"); + kspecial_grey = quote_list("#3b4048", "16"); + kvisual_grey = quote_list("#3e4452", "17"); + kpmenu = quote_list("#333841", "16"); + + } else { + kmono_1 = quote_list("#494b53", "23"); + kmono_2 = quote_list("#696c77", "60"); + kmono_3 = quote_list("#a0a1a7", "145"); + kmono_4 = quote_list("#c2c2c3", "250"); + + khue_1 = quote_list("#0184bc", "31", "cyan"); + khue_2 = quote_list("#4078f2", "33", "blue"); + khue_3 = quote_list("#a626a4", "127", "purple"); + khue_4 = quote_list("#50a14f", "71", "green"); + + khue_5 = quote_list("#e45649", "166", "red 1"); + khue_5_2 = quote_list("#ca1243", "160", "red 2"); + + khue_6 = quote_list("#986801", "94", "orange 1"); + khue_6_2 = quote_list("#c18401", "136", "orange 2"); + + ksyn_bg = quote_list("#fafafa", "255"); + ksyn_gutter = quote_list("#9e9e9e", "247"); + ksyn_cursor = quote_list("#f0f0f0", "254"); + + ksyn_accent = quote_list("#526fff", "63"); + ksyn_accent_2 = quote_list("#0083be", "31"); + + kvertsplit = quote_list("#e7e9e1", "188"); + kspecial_grey = quote_list("#d3d3d3", "251"); + kvisual_grey = quote_list("#d0d0d0", "251"); + kpmenu = quote_list("#dfdfdf", "253"); + } + + const string kitalic = (italic ? "italic" : ""); + list ksyn_fg = kmono_1; + list x; + + x += "hi clear"; + x += "syntax reset"; + + // Vim editor color -------------------------------------------------------- + x += X("Normal", ksyn_fg, ksyn_bg, NULL); + x += X("bold", NULL, NULL, "bold"); + x += X("ColorColumn", NULL, ksyn_cursor, NULL); + x += X("Conceal", kmono_4, ksyn_bg, NULL); + x += X("Cursor", NULL, ksyn_accent, NULL); + x += X("CursorIM", NULL, NULL, NULL); + x += X("CursorColumn", NULL, ksyn_cursor, NULL); + x += X("CursorLine", NULL, ksyn_cursor, "none"); + x += X("Directory", khue_2, NULL, NULL); + x += X("ErrorMsg", khue_5, ksyn_bg, "none"); + x += X("VertSplit", ksyn_cursor, ksyn_cursor, "none"); + x += X("Folded", ksyn_fg, ksyn_bg, "none"); + x += X("FoldColumn", kmono_3, ksyn_cursor, NULL); + x += X("IncSearch", khue_6, NULL, NULL); + x += X("LineNr", kmono_4, NULL, NULL); + x += X("CursorLineNr", ksyn_fg, ksyn_cursor, "none"); + x += X("MatchParen", khue_5, ksyn_cursor, "underline,bold"); + x += X("Italic", NULL, NULL, kitalic); + x += X("ModeMsg", ksyn_fg, NULL, NULL); + x += X("MoreMsg", ksyn_fg, NULL, NULL); + x += X("NonText", kmono_3, NULL, "none"); + x += X("PMenu", NULL, kpmenu, NULL); + x += X("PMenuSel", NULL, kmono_4, NULL); + x += X("PMenuSbar", NULL, ksyn_bg, NULL); + x += X("PMenuThumb", NULL, kmono_1, NULL); + x += X("Question", khue_2, NULL, NULL); + x += X("Search", ksyn_bg, khue_6_2, NULL); + x += X("SpecialKey", kspecial_grey, NULL, "none"); + x += X("Whitespace", kspecial_grey, NULL, "none"); + x += X("StatusLine", ksyn_fg, ksyn_cursor, "none"); + x += X("StatusLineNC", kmono_3, NULL, NULL); + x += X("TabLine", kmono_2, kvisual_grey, "none"); + x += X("TabLineFill", kmono_3, kvisual_grey, "none"); + x += X("TabLineSel", ksyn_bg, khue_2, NULL); + x += X("Title", ksyn_fg, NULL, "bold"); + x += X("Visual", NULL, kvisual_grey, NULL); + x += X("VisualNOS", NULL, kvisual_grey, NULL); + x += X("WarningMsg", khue_5, NULL, NULL); + x += X("TooLong", khue_5, NULL, NULL); + x += X("WildMenu", ksyn_fg, kmono_3, NULL); + x += X("SignColumn", NULL, ksyn_bg, NULL); + x += X("Special", khue_2, NULL, NULL); + + // Vim Help highlighting --------------------------------------------------- + x += X("helpCommand", khue_6_2, NULL, NULL); + x += X("helpExample", khue_6_2, NULL, NULL); + x += X("helpHeader", kmono_1, NULL, "bold"); + x += X("helpSectionDelim", kmono_3, NULL, NULL); + + // Standard syntax highlighting -------------------------------------------- + x += X("Comment", kmono_3, NULL, kitalic); + x += X("Constant", khue_4, NULL, NULL); + x += X("String", khue_4, NULL, NULL); + x += X("Character", khue_4, NULL, NULL); + x += X("Number", khue_6, NULL, NULL); + x += X("Boolean", khue_6, NULL, NULL); + x += X("Float", khue_6, NULL, NULL); + x += X("Identifier", khue_5, NULL, "none"); + x += X("Function", khue_2, NULL, NULL); + x += X("Statement", khue_3, NULL, "none"); + x += X("Conditional", khue_3, NULL, NULL); + x += X("Repeat", khue_3, NULL, NULL); + x += X("Label", khue_3, NULL, NULL); + x += X("Operator", ksyn_accent, NULL, "none"); + x += X("Keyword", khue_5, NULL, NULL); + x += X("Exception", khue_3, NULL, NULL); + x += X("PreProc", khue_6_2, NULL, NULL); + x += X("Include", khue_2, NULL, NULL); + x += X("Define", khue_3, NULL, "none"); + x += X("Macro", khue_3, NULL, NULL); + x += X("PreCondit", khue_6_2, NULL, NULL); + x += X("Type", khue_6_2, NULL, "none"); + x += X("StorageClass", khue_6_2, NULL, NULL); + x += X("Structure", khue_6_2, NULL, NULL); + x += X("Typedef", khue_6_2, NULL, NULL); + x += X("Special", khue_2, NULL, NULL); + x += X("SpecialChar", NULL, NULL, NULL); + x += X("Tag", NULL, NULL, NULL); + x += X("Delimiter", NULL, NULL, NULL); + x += X("SpecialComment", NULL, NULL, NULL); + x += X("Debug", NULL, NULL, NULL); + x += X("Underlined", NULL, NULL, "underline"); + x += X("Ignore", NULL, NULL, NULL); + x += X("Error", khue_5, ksyn_bg, "bold"); + x += X("Todo", khue_3, ksyn_bg, NULL); + + // Diff highlighting ------------------------------------------------------- + x += X("DiffAdd", khue_4, kvisual_grey, NULL); + x += X("DiffChange", khue_6, kvisual_grey, NULL); + x += X("DiffDelete", khue_5, kvisual_grey, NULL); + x += X("DiffText", khue_2, kvisual_grey, NULL); + x += X("DiffAdded", khue_4, kvisual_grey, NULL); + x += X("DiffFile", khue_5, kvisual_grey, NULL); + x += X("DiffNewFile", khue_4, kvisual_grey, NULL); + x += X("DiffLine", khue_2, kvisual_grey, NULL); + x += X("DiffRemoved", khue_5, kvisual_grey, NULL); + + // Asciidoc highlighting --------------------------------------------------- + x += X("asciidocListingBlock", kmono_2, NULL, NULL); + + // C/C++ highlighting ------------------------------------------------------ + x += X("cInclude", khue_3, NULL, NULL); + x += X("cPreCondit", khue_3, NULL, NULL); + x += X("cPreConditMatch", khue_3, NULL, NULL); + + x += X("cType", khue_3, NULL, NULL); + x += X("cStorageClass", khue_3, NULL, NULL); + x += X("cStructure", khue_3, NULL, NULL); + x += X("cOperator", khue_3, NULL, NULL); + x += X("cStatement", khue_3, NULL, NULL); + x += X("cTODO", khue_3, NULL, NULL); + x += X("cConstant", khue_6, NULL, NULL); + x += X("cSpecial", khue_1, NULL, NULL); + x += X("cSpecialCharacter", khue_1, NULL, NULL); + x += X("cString", khue_4, NULL, NULL); + + x += X("cppType", khue_3, NULL, NULL); + x += X("cppStorageClass", khue_3, NULL, NULL); + x += X("cppStructure", khue_3, NULL, NULL); + x += X("cppModifier", khue_3, NULL, NULL); + x += X("cppOperator", khue_3, NULL, NULL); + x += X("cppAccess", khue_3, NULL, NULL); + x += X("cppStatement", khue_3, NULL, NULL); + x += X("cppConstant", khue_5, NULL, NULL); + x += X("cCppString", khue_4, NULL, NULL); + + // Cucumber highlighting --------------------------------------------------- + x += X("cucumberGiven", khue_2, NULL, NULL); + x += X("cucumberWhen", khue_2, NULL, NULL); + x += X("cucumberWhenAnd", khue_2, NULL, NULL); + x += X("cucumberThen", khue_2, NULL, NULL); + x += X("cucumberThenAnd", khue_2, NULL, NULL); + x += X("cucumberUnparsed", khue_6, NULL, NULL); + x += X("cucumberFeature", khue_5, NULL, "bold"); + x += X("cucumberBackground", khue_3, NULL, "bold"); + x += X("cucumberScenario", khue_3, NULL, "bold"); + x += X("cucumberScenarioOutline", khue_3, NULL, "bold"); + x += X("cucumberTags", kmono_3, NULL, "bold"); + x += X("cucumberDelimiter", kmono_3, NULL, "bold"); + + // CSS/Sass highlighting --------------------------------------------------- + x += X("cssAttrComma", khue_3, NULL, NULL); + x += X("cssAttributeSelector", khue_4, NULL, NULL); + x += X("cssBraces", kmono_2, NULL, NULL); + x += X("cssClassName", khue_6, NULL, NULL); + x += X("cssClassNameDot", khue_6, NULL, NULL); + x += X("cssDefinition", khue_3, NULL, NULL); + x += X("cssFontAttr", khue_6, NULL, NULL); + x += X("cssFontDescriptor", khue_3, NULL, NULL); + x += X("cssFunctionName", khue_2, NULL, NULL); + x += X("cssIdentifier", khue_2, NULL, NULL); + x += X("cssImportant", khue_3, NULL, NULL); + x += X("cssInclude", kmono_1, NULL, NULL); + x += X("cssIncludeKeyword", khue_3, NULL, NULL); + x += X("cssMediaType", khue_6, NULL, NULL); + x += X("cssProp", khue_1, NULL, NULL); + x += X("cssPseudoClassId", khue_6, NULL, NULL); + x += X("cssSelectorOp", khue_3, NULL, NULL); + x += X("cssSelectorOp2", khue_3, NULL, NULL); + x += X("cssStringQ", khue_4, NULL, NULL); + x += X("cssStringQQ", khue_4, NULL, NULL); + x += X("cssTagName", khue_5, NULL, NULL); + x += X("cssAttr", khue_6, NULL, NULL); + + x += X("sassAmpersand", khue_5, NULL, NULL); + x += X("sassClass", khue_6_2, NULL, NULL); + x += X("sassControl", khue_3, NULL, NULL); + x += X("sassExtend", khue_3, NULL, NULL); + x += X("sassFor", kmono_1, NULL, NULL); + x += X("sassProperty", khue_1, NULL, NULL); + x += X("sassFunction", khue_1, NULL, NULL); + x += X("sassId", khue_2, NULL, NULL); + x += X("sassInclude", khue_3, NULL, NULL); + x += X("sassMedia", khue_3, NULL, NULL); + x += X("sassMediaOperators", kmono_1, NULL, NULL); + x += X("sassMixin", khue_3, NULL, NULL); + x += X("sassMixinName", khue_2, NULL, NULL); + x += X("sassMixing", khue_3, NULL, NULL); + + x += X("scssSelectorName", khue_6_2, NULL, NULL); + + // Elixir highlighting------------------------------------------------------ + x += "hi link elixirModuleDefine Define"; + x += X("elixirAlias", khue_6_2, NULL, NULL); + x += X("elixirAtom", khue_1, NULL, NULL); + x += X("elixirBlockDefinition", khue_3, NULL, NULL); + x += X("elixirModuleDeclaration", khue_6, NULL, NULL); + x += X("elixirInclude", khue_5, NULL, NULL); + x += X("elixirOperator", khue_6, NULL, NULL); + + // Git and git related plugins highlighting-------------------------------- + x += X("gitcommitComment", kmono_3, NULL, NULL); + x += X("gitcommitUnmerged", khue_4, NULL, NULL); + x += X("gitcommitOnBranch", NULL, NULL, NULL); + x += X("gitcommitBranch", khue_3, NULL, NULL); + x += X("gitcommitDiscardedType", khue_5, NULL, NULL); + x += X("gitcommitSelectedType", khue_4, NULL, NULL); + x += X("gitcommitHeader", NULL, NULL, NULL); + x += X("gitcommitUntrackedFile", khue_1, NULL, NULL); + x += X("gitcommitDiscardedFile", khue_5, NULL, NULL); + x += X("gitcommitSelectedFile", khue_4, NULL, NULL); + x += X("gitcommitUnmergedFile", khue_6_2, NULL, NULL); + x += X("gitcommitFile", NULL, NULL, NULL); + + x += "hi link gitcommitNoBranch gitcommitBranch"; + x += "hi link gitcommitUntracked gitcommitComment"; + x += "hi link gitcommitDiscarded gitcommitComment"; + x += "hi link gitcommitSelected gitcommitComment"; + x += "hi link gitcommitDiscardedArrow gitcommitDiscardedFile"; + x += "hi link gitcommitSelectedArrow gitcommitSelectedFile"; + x += "hi link gitcommitUnmergedArrow gitcommitUnmergedFile"; + + x += X("SignifySignAdd", khue_4, NULL, NULL); + x += X("SignifySignChange", khue_6_2, NULL, NULL); + x += X("SignifySignDelete", khue_5, NULL, NULL); + + x += "hi link GitGutterAdd SignifySignAdd"; + x += "hi link GitGutterChange SignifySignChange"; + x += "hi link GitGutterDelete SignifySignDelete"; + + x += X("diffAdded", khue_4, NULL, NULL); + x += X("diffRemoved", khue_5, NULL, NULL); + + // Go highlighting --------------------------------------------------------- + x += X("goDeclaration", khue_3, NULL, NULL); + x += X("goField", khue_5, NULL, NULL); + x += X("goMethod", khue_1, NULL, NULL); + x += X("goType", khue_3, NULL, NULL); + x += X("goUnsignedInts", khue_1, NULL, NULL); + + // Haskell highlighting ---------------------------------------------------- + x += X("haskellDeclKeyword", khue_2, NULL, NULL); + x += X("haskellType", khue_4, NULL, NULL); + x += X("haskellWhere", khue_5, NULL, NULL); + x += X("haskellImportKeywords", khue_2, NULL, NULL); + x += X("haskellOperators", khue_5, NULL, NULL); + x += X("haskellDelimiter", khue_2, NULL, NULL); + x += X("haskellIdentifier", khue_6, NULL, NULL); + x += X("haskellKeyword", khue_5, NULL, NULL); + x += X("haskellNumber", khue_1, NULL, NULL); + x += X("haskellString", khue_1, NULL, NULL); + + // HTML highlighting ------------------------------------------------------- + x += X("htmlArg", khue_6, NULL, NULL); + x += X("htmlTagName", khue_5, NULL, NULL); + x += X("htmlTagN", khue_5, NULL, NULL); + x += X("htmlSpecialTagName", khue_5, NULL, NULL); + x += X("htmlTag", kmono_2, NULL, NULL); + x += X("htmlEndTag", kmono_2, NULL, NULL); + + x += X("MatchTag", khue_5, ksyn_cursor, "underline,bold"); + + // JavaScript highlighting ------------------------------------------------- + x += X("coffeeString", khue_4, NULL, NULL); + + x += X("javaScriptBraces", kmono_2, NULL, NULL); + x += X("javaScriptFunction", khue_3, NULL, NULL); + x += X("javaScriptIdentifier", khue_3, NULL, NULL); + x += X("javaScriptNull", khue_6, NULL, NULL); + x += X("javaScriptNumber", khue_6, NULL, NULL); + x += X("javaScriptRequire", khue_1, NULL, NULL); + x += X("javaScriptReserved", khue_3, NULL, NULL); + + // httpk//github.com/pangloss/vim-javascript + x += X("jsArrowFunction", khue_3, NULL, NULL); + x += X("jsBraces", kmono_2, NULL, NULL); + x += X("jsClassBraces", kmono_2, NULL, NULL); + x += X("jsClassKeywords", khue_3, NULL, NULL); + x += X("jsDocParam", khue_2, NULL, NULL); + x += X("jsDocTags", khue_3, NULL, NULL); + x += X("jsFuncBraces", kmono_2, NULL, NULL); + x += X("jsFuncCall", khue_2, NULL, NULL); + x += X("jsFuncParens", kmono_2, NULL, NULL); + x += X("jsFunction", khue_3, NULL, NULL); + x += X("jsGlobalObjects", khue_6_2, NULL, NULL); + x += X("jsModuleWords", khue_3, NULL, NULL); + x += X("jsModules", khue_3, NULL, NULL); + x += X("jsNoise", kmono_2, NULL, NULL); + x += X("jsNull", khue_6, NULL, NULL); + x += X("jsOperator", khue_3, NULL, NULL); + x += X("jsParens", kmono_2, NULL, NULL); + x += X("jsStorageClass", khue_3, NULL, NULL); + x += X("jsTemplateBraces", khue_5_2, NULL, NULL); + x += X("jsTemplateVar", khue_4, NULL, NULL); + x += X("jsThis", khue_5, NULL, NULL); + x += X("jsUndefined", khue_6, NULL, NULL); + x += X("jsObjectValue", khue_2, NULL, NULL); + x += X("jsObjectKey", khue_1, NULL, NULL); + x += X("jsReturn", khue_3, NULL, NULL); + + // httpk//github.com/othree/yajs.vim + x += X("javascriptArrowFunc", khue_3, NULL, NULL); + x += X("javascriptClassExtends", khue_3, NULL, NULL); + x += X("javascriptClassKeyword", khue_3, NULL, NULL); + x += X("javascriptDocNotation", khue_3, NULL, NULL); + x += X("javascriptDocParamName", khue_2, NULL, NULL); + x += X("javascriptDocTags", khue_3, NULL, NULL); + x += X("javascriptEndColons", kmono_3, NULL, NULL); + x += X("javascriptExport", khue_3, NULL, NULL); + x += X("javascriptFuncArg", kmono_1, NULL, NULL); + x += X("javascriptFuncKeyword", khue_3, NULL, NULL); + x += X("javascriptIdentifier", khue_5, NULL, NULL); + x += X("javascriptImport", khue_3, NULL, NULL); + x += X("javascriptObjectLabel", kmono_1, NULL, NULL); + x += X("javascriptOpSymbol", khue_1, NULL, NULL); + x += X("javascriptOpSymbols", khue_1, NULL, NULL); + x += X("javascriptPropertyName", khue_4, NULL, NULL); + x += X("javascriptTemplateSB", khue_5_2, NULL, NULL); + x += X("javascriptVariable", khue_3, NULL, NULL); + + // JSON highlighting ------------------------------------------------------- + x += X("jsonCommentError", kmono_1, NULL, NULL); + x += X("jsonKeyword", khue_5, NULL, NULL); + x += X("jsonQuote", kmono_3, NULL, NULL); + x += X("jsonTrailingCommaError", khue_5, NULL, "reverse"); + x += X("jsonMissingCommaError", khue_5, NULL, "reverse"); + x += X("jsonNoQuotesError", khue_5, NULL, "reverse"); + x += X("jsonNumError", khue_5, NULL, "reverse"); + x += X("jsonString", khue_4, NULL, NULL); + x += X("jsonBoolean", khue_3, NULL, NULL); + x += X("jsonNumber", khue_6, NULL, NULL); + x += X("jsonStringSQError", khue_5, NULL, "reverse"); + x += X("jsonSemicolonError", khue_5, NULL, "reverse"); + + // Markdown highlighting --------------------------------------------------- + x += X("markdownUrl", kmono_3, NULL, NULL); + x += X("markdownBold", khue_6, NULL, "bold"); + x += X("markdownItalic", khue_6, NULL, "bold"); + x += X("markdownCode", khue_4, NULL, NULL); + x += X("markdownCodeBlock", khue_5, NULL, NULL); + x += X("markdownCodeDelimiter", khue_4, NULL, NULL); + x += X("markdownHeadingDelimiter", khue_5_2, NULL, NULL); + x += X("markdownH1", khue_5, NULL, NULL); + x += X("markdownH2", khue_5, NULL, NULL); + x += X("markdownH3", khue_5, NULL, NULL); + x += X("markdownH3", khue_5, NULL, NULL); + x += X("markdownH4", khue_5, NULL, NULL); + x += X("markdownH5", khue_5, NULL, NULL); + x += X("markdownH6", khue_5, NULL, NULL); + x += X("markdownListMarker", khue_5, NULL, NULL); + + // Perl highlighting ------------------------------------------------------- + x += X("perlFunction", khue_3, NULL, NULL); + x += X("perlMethod", ksyn_fg, NULL, NULL); + x += X("perlPackageConst", khue_3, NULL, NULL); + x += X("perlPOD", kmono_3, NULL, NULL); + x += X("perlSubName", ksyn_fg, NULL, NULL); + x += X("perlSharpBang", kmono_3, NULL, NULL); + x += X("perlSpecialString", khue_4, NULL, NULL); + x += X("perlVarPlain", khue_2, NULL, NULL); + x += X("podCommand", kmono_3, NULL, NULL); + + // PHP highlighting -------------------------------------------------------- + x += X("phpClass", khue_6_2, NULL, NULL); + x += X("phpFunction", khue_2, NULL, NULL); + x += X("phpFunctions", khue_2, NULL, NULL); + x += X("phpInclude", khue_3, NULL, NULL); + x += X("phpKeyword", khue_3, NULL, NULL); + x += X("phpParent", kmono_3, NULL, NULL); + x += X("phpType", khue_3, NULL, NULL); + x += X("phpSuperGlobals", khue_5, NULL, NULL); + + // Pug (Formerly Jade) highlighting ---------------------------------------- + x += X("pugAttributesDelimiter", khue_6, NULL, NULL); + x += X("pugClass", khue_6, NULL, NULL); + x += X("pugDocType", kmono_3, NULL, kitalic); + x += X("pugTag", khue_5, NULL, NULL); + + // PureScript highlighting ------------------------------------------------- + x += X("purescriptKeyword", khue_3, NULL, NULL); + x += X("purescriptModuleName", ksyn_fg, NULL, NULL); + x += X("purescriptIdentifier", ksyn_fg, NULL, NULL); + x += X("purescriptType", khue_6_2, NULL, NULL); + x += X("purescriptTypeVar", khue_5, NULL, NULL); + x += X("purescriptConstructor", khue_5, NULL, NULL); + x += X("purescriptOperator", ksyn_fg, NULL, NULL); + + // Python highlighting ----------------------------------------------------- + x += X("pythonImport", khue_3, NULL, NULL); + x += X("pythonBuiltin", khue_1, NULL, NULL); + x += X("pythonStatement", khue_3, NULL, NULL); + x += X("pythonParam", khue_6, NULL, NULL); + x += X("pythonEscape", khue_5, NULL, NULL); + x += X("pythonSelf", kmono_2, NULL, kitalic); + x += X("pythonClass", khue_2, NULL, NULL); + x += X("pythonOperator", khue_3, NULL, NULL); + x += X("pythonEscape", khue_5, NULL, NULL); + x += X("pythonFunction", khue_2, NULL, NULL); + x += X("pythonKeyword", khue_2, NULL, NULL); + x += X("pythonModule", khue_3, NULL, NULL); + x += X("pythonStringDelimiter", khue_4, NULL, NULL); + x += X("pythonSymbol", khue_1, NULL, NULL); + + // Ruby highlighting ------------------------------------------------------- + x += X("rubyBlock", khue_3, NULL, NULL); + x += X("rubyBlockParameter", khue_5, NULL, NULL); + x += X("rubyBlockParameterList", khue_5, NULL, NULL); + x += X("rubyCapitalizedMethod", khue_3, NULL, NULL); + x += X("rubyClass", khue_3, NULL, NULL); + x += X("rubyConstant", khue_6_2, NULL, NULL); + x += X("rubyControl", khue_3, NULL, NULL); + x += X("rubyDefine", khue_3, NULL, NULL); + x += X("rubyEscape", khue_5, NULL, NULL); + x += X("rubyFunction", khue_2, NULL, NULL); + x += X("rubyGlobalVariable", khue_5, NULL, NULL); + x += X("rubyInclude", khue_2, NULL, NULL); + x += X("rubyIncluderubyGlobalVariable", khue_5, NULL, NULL); + x += X("rubyInstanceVariable", khue_5, NULL, NULL); + x += X("rubyInterpolation", khue_1, NULL, NULL); + x += X("rubyInterpolationDelimiter", khue_5, NULL, NULL); + x += X("rubyKeyword", khue_2, NULL, NULL); + x += X("rubyModule", khue_3, NULL, NULL); + x += X("rubyPseudoVariable", khue_5, NULL, NULL); + x += X("rubyRegexp", khue_1, NULL, NULL); + x += X("rubyRegexpDelimiter", khue_1, NULL, NULL); + x += X("rubyStringDelimiter", khue_4, NULL, NULL); + x += X("rubySymbol", khue_1, NULL, NULL); + + // Spelling highlighting --------------------------------------------------- + x += X("SpellBad", NULL, ksyn_bg, "undercurl"); + x += X("SpellLocal", NULL, ksyn_bg, "undercurl"); + x += X("SpellCap", NULL, ksyn_bg, "undercurl"); + x += X("SpellRare", NULL, ksyn_bg, "undercurl"); + + // Vim highlighting -------------------------------------------------------- + x += X("vimCommand", khue_3, NULL, NULL); + x += X("vimCommentTitle", kmono_3, NULL, "bold"); + x += X("vimFunction", khue_1, NULL, NULL); + x += X("vimFuncName", khue_3, NULL, NULL); + x += X("vimHighlight", khue_2, NULL, NULL); + x += X("vimLineComment", kmono_3, NULL, kitalic); + x += X("vimParenSep", kmono_2, NULL, NULL); + x += X("vimSep", kmono_2, NULL, NULL); + x += X("vimUserFunc", khue_1, NULL, NULL); + x += X("vimVar", khue_5, NULL, NULL); + + //XML highlighting -------------------------------------------------------- + x += X("xmlAttrib", khue_6_2, NULL, NULL); + x += X("xmlEndTag", khue_5, NULL, NULL); + x += X("xmlTag", khue_5, NULL, NULL); + x += X("xmlTagName", khue_5, NULL, NULL); + + // ZSH highlighting -------------------------------------------------------- + x += X("zshCommands", ksyn_fg, NULL, NULL); + x += X("zshDeref", khue_5, NULL, NULL); + x += X("zshShortDeref", khue_5, NULL, NULL); + x += X("zshFunction", khue_1, NULL, NULL); + x += X("zshKeyword", khue_3, NULL, NULL); + x += X("zshSubst", khue_5, NULL, NULL); + x += X("zshSubstDelim", kmono_3, NULL, NULL); + x += X("zshTypes", khue_3, NULL, NULL); + x += X("zshVariableDef", khue_6, NULL, NULL); + + // Rust highlighting ------------------------------------------------------- + x += X("rustExternCrate", khue_5, NULL, "bold"); + x += X("rustIdentifier", khue_2, NULL, NULL); + x += X("rustDeriveTrait", khue_4, NULL, NULL); + x += X("SpecialComment", kmono_3, NULL, NULL); + x += X("rustCommentLine", kmono_3, NULL, NULL); + x += X("rustCommentLineDoc", kmono_3, NULL, NULL); + x += X("rustCommentLineDocError", kmono_3, NULL, NULL); + x += X("rustCommentBlock", kmono_3, NULL, NULL); + x += X("rustCommentBlockDoc", kmono_3, NULL, NULL); + x += X("rustCommentBlockDocError", kmono_3, NULL, NULL); + + // man highlighting -------------------------------------------------------- + x += "hi link manTitle String"; + x += X("manFooter", kmono_3, NULL, NULL); + + // ALE (Asynchronous Lint Engine) highlighting ----------------------------- + x += X("ALEWarningSign", khue_6_2, NULL, NULL); + x += X("ALEErrorSign", khue_5, NULL, NULL); + + // Neovim NERDTree Background fix ------------------------------------------ + x += X("NERDTreeFile", ksyn_fg, NULL, NULL); + + vim_colorscheme(scheme, 0, NULL, x, gui_running); +} + + +int +colorscheme_one(~list args) +{ + string scheme = "one"; + int colordepth = -1, dark = -1, italic = 1; + + if (! is_null(args)) { + /* options */ + const list longoptions = { + "colors:d", + "mode:s", + "dark", + "light", + "italic:b", + }; + string value; + int optidx = 0, ch; + + if ((ch = getopt(value, NULL, longoptions, args, scheme)) >= 0) { + do { + ++optidx; + switch(ch) { + case 0: // colordepth + colordepth = atoi(value); + break; + case 1: // mode + if (value == "default") { /* dynamic dark or light */ + dark = -1; + } else { + dark = (value == "dark" ? 1 : 0); + } + break; + case 2: // dark + dark = 1; + break; + case 3: // light + dark = 0; + break; + case 4: // italic + italic = value; + break; + default: + error("%s: %s", scheme, value); + return -1; + } + } while ((ch = getopt(value)) >= 0); + } + + if (optidx < length_of_list(args)) { + error("%s: invalid option <%s>", scheme, args[optidx]); + return -1; + } + } + + if (colordepth <= 0) { + get_term_feature(TF_COLORDEPTH, colordepth); + } + if (colordepth < 88) { + error("%s: color depth not supported", scheme); + return -1; + } + + if (dark == -1) { + get_term_feature(TF_SCHEMEDARK, dark); /* default */ + } + + one(scheme, dark, italic); + return 0; +} + +//end diff --git a/macsrc/colors/papercolor.cr b/macsrc/colors/papercolor.cr new file mode 100644 index 00000000..a0a157d7 --- /dev/null +++ b/macsrc/colors/papercolor.cr @@ -0,0 +1,2644 @@ +/* -*- mode: cr; indent-width: 4; -*- */ +// $Id: papercolor.cr,v 1.3 2024/08/04 11:42:44 cvsuser Exp $ +// papercolor coloriser, GriefEdit port. +// +// Theme: PaperColor +// Description : The original PaperColor Theme, inspired by Google Material Design. +// +// Version: 0.9.x +// Author: Nikyle Nguyen +// License: MIT +// Source: http://github.com/NLKNguyen/papercolor-theme +// +// The MIT License (MIT) +// +// Copyright (c) 2015-2020 Nikyle Nguyen +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +// + +#include "../grief.h" + +// ============================ THEMES ==================================== + +// Theme can have 'light' and/or 'dark' color palette. +// +// Color values can be HEX and/or 256-color. Use empty string '' if not provided. +// Only color00 -> color15 are required. The rest are optional. +// + +static int +acquire_theme() +{ + int h = create_dictionary(); + + h.NO_CONVERSION = 1; + h.TEST_256_COLOR_CONSISTENCY = 1; + h.original_source = "http://github.com/NLKNguyen/papercolor-theme"; + h.description = "The original PaperColor Theme, inspired by Google Material Design"; + h.allow_bold = 1; + + return h; +} + + +static int +palette_light() +{ + int s = create_dictionary(); + + s.color00 = quote_list("#eeeeee", "255"); + s.color01 = quote_list("#af0000", "124"); + s.color02 = quote_list("#008700", "28"); + s.color03 = quote_list("#5f8700", "64"); + s.color04 = quote_list("#0087af", "31"); + s.color05 = quote_list("#878787", "102"); + s.color06 = quote_list("#005f87", "24"); + s.color07 = quote_list("#444444", "238"); + s.color08 = quote_list("#bcbcbc", "250"); + s.color09 = quote_list("#d70000", "160"); + s.color10 = quote_list("#d70087", "162"); + s.color11 = quote_list("#8700af", "91"); + s.color12 = quote_list("#d75f00", "166"); + s.color13 = quote_list("#d75f00", "166"); + s.color14 = quote_list("#005faf", "25"); + s.color15 = quote_list("#005f87", "24"); + s.color16 = quote_list("#0087af", "31"); + s.color17 = quote_list("#008700", "28"); + s.cursor_fg = quote_list("#eeeeee", "255"); + s.cursor_bg = quote_list("#005f87", "24"); + s.cursorline = quote_list("#e4e4e4", "254"); + s.cursorcolumn = quote_list("#e4e4e4", "254"); + s.cursorlinenr_fg = quote_list("#af5f00", "130"); + s.cursorlinenr_bg = quote_list("#eeeeee", "255"); + s.popupmenu_fg = quote_list("#444444", "238"); + s.popupmenu_bg = quote_list("#d0d0d0", "252"); + s.search_fg = quote_list("#444444", "238"); + s.search_bg = quote_list("#ffff5f", "227"); + s.incsearch_fg = quote_list("#ffff5f", "227"); + s.incsearch_bg = quote_list("#444444", "238"); + s.linenumber_fg = quote_list("#b2b2b2", "249"); + s.linenumber_bg = quote_list("#eeeeee", "255"); + s.vertsplit_fg = quote_list("#005f87", "24"); + s.vertsplit_bg = quote_list("#eeeeee", "255"); + s.statusline_active_fg = quote_list("#e4e4e4", "254"); + s.statusline_active_bg = quote_list("#005f87", "24"); + s.statusline_inactive_fg = quote_list("#444444", "238"); + s.statusline_inactive_bg = quote_list("#d0d0d0", "252"); + s.todo_fg = quote_list("#00af5f", "35"); + s.todo_bg = quote_list("#eeeeee", "255"); + s.error_fg = quote_list("#af0000", "124"); + s.error_bg = quote_list("#ffd7ff", "225"); + s.matchparen_bg = quote_list("#c6c6c6", "251"); + s.matchparen_fg = quote_list("#005f87", "24"); + s.visual_fg = quote_list("#eeeeee", "255"); + s.visual_bg = quote_list("#0087af", "31"); + s.folded_fg = quote_list("#0087af", "31"); + s.folded_bg = quote_list("#afd7ff", "153"); + s.wildmenu_fg = quote_list("#444444", "238"); + s.wildmenu_bg = quote_list("#ffff00", "226"); + s.spellbad = quote_list("#ffafd7", "218"); + s.spellcap = quote_list("#ffffaf", "229"); + s.spellrare = quote_list("#afff87", "156"); + s.spelllocal = quote_list("#d7d7ff", "189"); + s.diffadd_fg = quote_list("#008700", "28"); + s.diffadd_bg = quote_list("#afffaf", "157"); + s.diffdelete_fg = quote_list("#af0000", "124"); + s.diffdelete_bg = quote_list("#ffd7ff", "225"); + s.difftext_fg = quote_list("#0087af", "31"); + s.difftext_bg = quote_list("#ffffd7", "230"); + s.diffchange_fg = quote_list("#444444", "238"); + s.diffchange_bg = quote_list("#ffd787", "222"); + s.tabline_bg = quote_list("#005f87", "24O"); + s.tabline_active_fg = quote_list("#444444", "238"); + s.tabline_active_bg = quote_list("#e4e4e4", "254"); + s.tabline_inactive_fg = quote_list("#eeeeee", "255"); + s.tabline_inactive_bg = quote_list("#0087af", "31"); + s.buftabline_bg = quote_list("#005f87", "24"); + s.buftabline_current_fg = quote_list("#444444", "238"); + s.buftabline_current_bg = quote_list("#e4e4e4", "254"); + s.buftabline_active_fg = quote_list("#eeeeee", "255"); + s.buftabline_active_bg = quote_list("#005faf", "25"); + s.buftabline_inactive_fg = quote_list("#eeeeee", "255"); + s.buftabline_inactive_bg = quote_list("#0087af", "31"); + + return s; +} + + +static int +palette_dark() +{ + int s = create_dictionary(); + + s.color00 = quote_list("#1c1c1c", "234"); + s.color01 = quote_list("#af005f", "125"); + s.color02 = quote_list("#5faf00", "70"); + s.color03 = quote_list("#d7af5f", "179"); + s.color04 = quote_list("#5fafd7", "74"); + s.color05 = quote_list("#808080", "244"); + s.color06 = quote_list("#d7875f", "173"); + s.color07 = quote_list("#d0d0d0", "252"); + s.color08 = quote_list("#585858", "240"); + s.color09 = quote_list("#5faf5f", "71"); + s.color10 = quote_list("#afd700", "148"); + s.color11 = quote_list("#af87d7", "140"); + s.color12 = quote_list("#ffaf00", "214"); + s.color13 = quote_list("#ff5faf", "205"); + s.color14 = quote_list("#00afaf", "37"); + s.color15 = quote_list("#5f8787", "66"); + s.color16 = quote_list("#5fafd7", "74"); + s.color17 = quote_list("#d7af00", "178"); + s.cursor_fg = quote_list("#1c1c1c", "234"); + s.cursor_bg = quote_list("#c6c6c6", "251"); + s.cursorline = quote_list("#303030", "236"); + s.cursorcolumn = quote_list("#303030", "236"); + s.cursorlinenr_fg = quote_list("#ffff00", "226"); + s.cursorlinenr_bg = quote_list("#1c1c1c", "234"); + s.popupmenu_fg = quote_list("#c6c6c6", "251"); + s.popupmenu_bg = quote_list("#303030", "236"); + s.search_fg = quote_list("#000000", "16"); + s.search_bg = quote_list("#00875f", "29"); + s.incsearch_fg = quote_list("#00875f", "29"); + s.incsearch_bg = quote_list("#000000", "16"); + s.linenumber_fg = quote_list("#585858", "240"); + s.linenumber_bg = quote_list("#1c1c1c", "234"); + s.vertsplit_fg = quote_list("#5f8787", "66"); + s.vertsplit_bg = quote_list("#1c1c1c", "234"); + s.statusline_active_fg = quote_list("#1c1c1c", "234"); + s.statusline_active_bg = quote_list("#5f8787", "66"); + s.statusline_inactive_fg = quote_list("#bcbcbc", "250"); + s.statusline_inactive_bg = quote_list("#3a3a3a", "237"); + s.todo_fg = quote_list("#ff8700", "208"); + s.todo_bg = quote_list("#1c1c1c", "234"); + s.error_fg = quote_list("#af005f", "125"); + s.error_bg = quote_list("#5f0000", "52"); + s.matchparen_bg = quote_list("#4e4e4e", "239"); + s.matchparen_fg = quote_list("#c6c6c6", "251"); + s.visual_fg = quote_list("#000000", "16"); + s.visual_bg = quote_list("#8787af", "103"); + s.folded_fg = quote_list("#d787ff", "177"); + s.folded_bg = quote_list("#5f005f", "53"); + s.wildmenu_fg = quote_list("#1c1c1c", "234"); + s.wildmenu_bg = quote_list("#afd700", "148"); + s.spellbad = quote_list("#5f0000", "52"); + s.spellcap = quote_list("#5f005f", "53"); + s.spellrare = quote_list("#005f00", "22"); + s.spelllocal = quote_list("#00005f", "17"); + s.diffadd_fg = quote_list("#87d700", "112"); + s.diffadd_bg = quote_list("#005f00", "22"); + s.diffdelete_fg = quote_list("#af005f", "125"); + s.diffdelete_bg = quote_list("#5f0000", "52"); + s.difftext_fg = quote_list("#5fffff", "87"); + s.difftext_bg = quote_list("#008787", "30"); + s.diffchange_fg = quote_list("#d0d0d0", "252"); + s.diffchange_bg = quote_list("#005f5f", "23"); + s.tabline_bg = quote_list("#262626", "235"); + s.tabline_active_fg = quote_list("#121212", "233"); + s.tabline_active_bg = quote_list("#00afaf", "37"); + s.tabline_inactive_fg = quote_list("#bcbcbc", "250"); + s.tabline_inactive_bg = quote_list("#585858", "240"); + s.buftabline_bg = quote_list("#262626", "235"); + s.buftabline_current_fg = quote_list("#121212", "233"); + s.buftabline_current_bg = quote_list("#00afaf", "37"); + s.buftabline_active_fg = quote_list("#00afaf", "37"); + s.buftabline_active_bg = quote_list("#585858", "240"); + s.buftabline_inactive_fg = quote_list("#bcbcbc", "250"); + s.buftabline_inactive_bg = quote_list("#585858", "240"); + + return s; +} + +// ============================ THEME REGISTER ================================= + +static int +acquire_pallette(int dark) +{ + if (dark) return palette_dark(); + return palette_light(); +} + + +// ============================ OPTION HANDLER ================================= + +// Generate Them Option Variables: + +static void +generate_theme_option_variables(int h) +{ + UNUSED(h); + +#if (TODO) + + // 0. All possible theme option names must be registered here + list available_theme_options = { + 'allow_bold', + 'allow_italic', + 'transparent_background', + }; + + // 1. Generate variables and set to default value + for l:option in l:available_theme_options + let s:{'themeOpt_' . l:option} = 0 + endfor + + let s:themeOpt_override = {} // special case, this has to be a dictionary + + // 2. Reassign value to the above variables based on theme settings + + // 2.1 In case the theme has top-level options + if has_key(s:selected_theme, 'options') + let l:theme_options = s:selected_theme['options'] + for l:opt_name in keys(l:theme_options) + let s:{'themeOpt_' . l:opt_name} = l:theme_options[l:opt_name] + // echo 's:themeOpt_' . l:opt_name . ' = ' . s:{'themeOpt_' . l:opt_name} + endfor + endif + + // 2.2 In case the theme has specific variant options + if has_key(s:selected_theme[s:selected_variant], 'options') + let l:theme_options = s:selected_theme[s:selected_variant]['options'] + for l:opt_name in keys(l:theme_options) + let s:{'themeOpt_' . l:opt_name} = l:theme_options[l:opt_name] + // echo 's:themeOpt_' . l:opt_name . ' = ' . s:{'themeOpt_' . l:opt_name} + endfor + endif + + + // 3. Reassign value to the above variables which the user customizes + // Part of user-config options + let s:theme_options = {} + if has_key(s:options, 'theme') + let s:theme_options = s:options['theme'] + endif + + // 3.1 In case user sets for a theme without specifying which variant + if has_key(s:theme_options, s:theme_name) + let l:theme_options = s:theme_options[s:theme_name] + for l:opt_name in keys(l:theme_options) + let s:{'themeOpt_' . l:opt_name} = l:theme_options[l:opt_name] + // echo 's:themeOpt_' . l:opt_name . ' = ' . s:{'themeOpt_' . l:opt_name} + endfor + endif + + + // 3.2 In case user sets for a specific variant of a theme + + // Create the string that the user might have set for this theme variant + // for example, 'default.dark' + let l:specific_theme_variant = s:theme_name . '.' . s:selected_variant + + if has_key(s:theme_options, l:specific_theme_variant) + let l:theme_options = s:theme_options[l:specific_theme_variant] + for l:opt_name in keys(l:theme_options) + let s:{'themeOpt_' . l:opt_name} = l:theme_options[l:opt_name] + // echo 's:themeOpt_' . l:opt_name . ' = ' . s:{'themeOpt_' . l:opt_name} + endfor + endif + +#endif + +} + + +// Check If Theme Has Hint: +// +// Brief: +// Function to Check if the selected theme and variant has a hint +// +// Details: +// A hint is a known key that has value 1 +// It is not part of theme design but is used for technical purposes +// +// Example: +// If a theme has hint 'NO_CONVERSION', then we can assume that every +// color value is a complete pair, so we don't have to check. + +// Set Overriding Colors: + +static void +set_overriding_colors(int s, int h) +{ + UNUSED(h); + UNUSED(s); + +#if (TODO) + + if *h.NO_CONVERSION) { + + // s:convert_colors will not do anything, so we take care of conversion + // for the overriding colors that need to be converted + + if (h.mode == MODE_GUI_COLOR) { + + // if GUI color is not provided, convert from 256 color that must be available + if !empty(s:themeOpt_override) + load_256_to_GUI_converter() + endif + + for l:color in keys(s:themeOpt_override) + let l:value = s:themeOpt_override[l:color] + if l:value[0] == '' + let l:value[0] = s:to_HEX[l:value[1]] + endif + let s:palette[l:color] = l:value + endfor + + } else if (h.mode == MODE_256_COLOR) { + + // if 256 color is not provided, convert from GUI color that must be available + if !empty(s:themeOpt_override) + load_GUI_to_256_converter() + endif + + for l:color in keys(s:themeOpt_override) + let l:value = s:themeOpt_override[l:color] + if l:value[1] == '' + let l:value[1] = s:to_256(l:value[0]) + endif + let s:palette[l:color] = l:value + endfor + } + + } else { + + // simply set the colors and let s:convert_colors() take care of conversion + + for l:color in keys(s:themeOpt_override) + let s:palette[l:color] = s:themeOpt_override[l:color] + endfor + } + +#endif +} + + +// Generate Language Option Variables: + +// Brief: +// Function to generate language option variables so that there is no need to +// look up from the dictionary every time the option value is checked in the +// function s:apply_syntax_highlightings() +// +// Require: +// s:options user options +// +// Require Optionally: +// g:PaperColor_Theme_Options user option config in .vimrc +// +// Expose: +// s:langOpt_[LANGUAGE]__[OPTION] variables for language options +// +// Example: +// g:PaperColor_Theme_Options has something like this: +// 'language': { +// \ 'python': { +// \ 'highlight_builtins': 1 +// \ } +// } +// The following variable will be generated: +// s:langOpt_python__highlight_builtins = 1 +// + +static void +generate_language_option_variables(int h) +{ + UNUSED(h); + +#if (TODO) + + // Possible theme option names must be registered here + list available_language_options = { + 'c__highlight_builtins', + 'cpp__highlight_standard_library', + 'python__highlight_builtins', + 'haskell__no_bold_types' + }; + + // Generate variables and set to default value + for l:option in l:available_language_options + let s:{'langOpt_' . l:option} = 0 + endfor + + // Part of user-config options + if has_key(s:options, 'language') + let l:language_options = s:options['language'] + // echo l:language_options + for l:lang in keys(l:language_options) + let l:options = l:language_options[l:lang] + // echo l:lang + // echo l:options + for l:option in keys(l:options) + let s:{'langOpt_' . l:lang . '__' . l:option} = l:options[l:option] + // echo 's:langOpt_' . l:lang . '__' . l:option . ' = ' . l:options[l:option] + endfor + endfor + + endif + +#endif +} + +// =========================== COLOR CONVERTER ================================= + +// ========================== ENVIRONMENT ADAPTER ============================== + +// Set Format Attributes: + +static void +set_format_attributes(int s, int h) +{ + extern int colordepth; + + UNUSED(h); + + // These are the default + + if (colordepth >= 256) { + s.ft_bold = " cterm=bold gui=bold " + " cterm=bold "; + s.ft_none = " cterm=none gui=none " + " cterm=none "; + s.ft_reverse = " cterm=reverse gui=reverse " + " cterm=reverse "; + s.ft_italic = " cterm=italic gui=italic " + " cterm=italic "; + s.ft_italic_bold = " cterm=italic,bold gui=italic,bold " + " cterm=italic,bold "; + + } else { + s.ft_bold = ""; + s.ft_none = " cterm=none "; + s.ft_reverse = " cterm=reverse "; + s.ft_italic = ""; + s.ft_italic_bold = ""; + } + + // Unless instructed otherwise either by theme setting or user overriding + + //TODO +} + + +// Convert Colors If Needed: + +static void +convert_colors(int s, int h) +{ + UNUSED(s); + UNUSED(h); + + //TODO +} + + +// ============================ COLOR POPULARIZER =============================== + +// Helper: +// ------- +// Function to dynamically generate variables that store the color strings +// for setting highlighting. Each color name will have 2 variables with prefix +// +// s:fg_ and s:bg_. +// +// For example: +// +// if a:color_name is 'Normal' and a:color_value is ['#000000", "0', 'Black"); +// the following 2 variables will be created: +// +// s:fg_Normal that stores the string ' guifg=#000000 ' +// s:bg_Normal that stores the string ' guibg=#000000 ' +// +// Depending on the color mode, ctermfg and ctermbg will be either 0 or Black +// +// Rationale: +// The whole purpose is for speed. We generate these ahead of time so that we +// don't have to do look up or do any if-branch when we set the highlightings. +// + +static void +pset(int s, string color_name, list rich_color, string term_color) +{ + extern int colordepth; + + if (colordepth >= 256) { + set_property(s, "fg_"+color_name, " guifg="+rich_color[0] + " ctermfg="+rich_color[1]); + set_property(s, "bg_"+color_name, " guibg="+rich_color[0] + " ctermbg="+rich_color[1]); +//TODO set_property(s, "sp_"+color_name, " guisp="+rich_color[0]); + set_property(s, "sp_"+color_name, ""); + + } else { + set_property(s, "fg_"+color_name, " ctermfg="+term_color); + set_property(s, "bg_"+color_name, " ctermbg="+term_color); + set_property(s, "sp_"+color_name, ""); + } +} + + +static list +pget(int s, string name, ~list defvalue) +{ + declare value = get_property(s, name); + if (is_null(value)) return defvalue; + return value; +} + +// ========================== ENVIRONMENT ADAPTER ============================== + +// Set Color Variables: + +static void +set_color_variables(int s) +{ + // Color value format: Array [, <256-Base>, <16-Base>] + // 16-Base is terminal"s native color palette that can be alternated through + // the terminal settings. The 16-color names are according to `:h cterm-colors` + + // BASIC COLORS: + // color00-15 are required by all themes. + // These are also how the terminal color palette for the target theme should be. + // See README for theme design guideline + // + // An example format of the below variable's value: ['#262626', '234', 'Black'] + // Where the 1st value is HEX color for GUI Vim, 2nd value is for 256-color terminal, + // and the color name on the right is for 16-color terminal (the actual terminal colors + // can be different from what the color names suggest). See :h cterm-colors + // + // Depending on the provided color palette and current Vim, the 1st and 2nd + // parameter might not exist, for example, on 16-color terminal, the variables below + // only store the color names to use the terminal color palette which is the only + // thing available therefore no need for GUI-color or 256-color. + + list color00 = pget(s, "color00"); + list color01 = pget(s, "color01"); + list color02 = pget(s, "color02"); + list color03 = pget(s, "color03"); + list color04 = pget(s, "color04"); + list color05 = pget(s, "color05"); + list color06 = pget(s, "color06"); + list color07 = pget(s, "color07"); + list color08 = pget(s, "color08"); + list color09 = pget(s, "color09"); + list color10 = pget(s, "color10"); + list color11 = pget(s, "color11"); + list color12 = pget(s, "color12"); + list color13 = pget(s, "color13"); + list color14 = pget(s, "color14"); + list color15 = pget(s, "color15"); + + pset(s, "background", color00, "Black"); + pset(s, "negative", color01, "DarkRed"); + pset(s, "positive", color02, "DarkGreen"); + pset(s, "olive", color03, "DarkYellow"); + pset(s, "neutral", color04, "DarkBlue"); + pset(s, "comment", color05, "DarkMagenta"); + pset(s, "navy", color06, "DarkCyan"); + pset(s, "foreground", color07, "LightGray"); + + pset(s, "nontext", color08, "DarkGray"); + pset(s, "red", color09, "LightRed"); + pset(s, "pink", color10, "LightGreen"); + pset(s, "purple", color11, "LightYellow"); + pset(s, "accent", color12, "LightBlue"); + pset(s, "orange", color13, "LightMagenta"); + pset(s, "blue", color14, "LightCyan"); + pset(s, "highlight", color15, "White"); + + // Note: special case for FoldColumn grous. I want to get rid of this case. + pset(s, "transparent", quote_list(color00[0], "none"), "none"); + + // EXTENDED COLORS: + // + // From here on, all colors are optional and must have default values (3rd parameter of the + // `get` command) that point to the above basic colors in case the target theme doesn"t + // provide the extended colors. The default values should be reasonably sensible. + // The terminal color must be provided also. + + pset(s, "aqua", pget(s, "color16", color14), "LightCyan"); + pset(s, "green", pget(s, "color17", color13), "LightMagenta"); + pset(s, "wine", pget(s, "color18", color11), "LightYellow"); + + // LineNumber: when set number + pset(s, "linenumber_fg", pget(s, "linenumber_fg", color08), "DarkGray"); + pset(s, "linenumber_bg", pget(s, "linenumber_bg", color00), "Black"); + + // Vertical Split: when there are more than 1 window side by side, ex: + pset(s, "vertsplit_fg", pget(s, "vertsplit_fg", color15), "White"); + pset(s, "vertsplit_bg", pget(s, "vertsplit_bg", color00), "Black"); + + // Statusline: when set status=2 + pset(s, "statusline_active_fg", pget(s, "statusline_active_fg", color00), "Black"); + pset(s, "statusline_active_bg", pget(s, "statusline_active_bg", color15), "White"); + pset(s, "statusline_inactive_fg", pget(s, "statusline_inactive_fg", color07), "LightGray"); + pset(s, "statusline_inactive_bg", pget(s, "statusline_inactive_bg", color08), "DarkGray"); + + // Cursor: in normal mode + pset(s, "cursor_fg", pget(s, "cursor_fg", color00), "Black"); + pset(s, "cursor_bg", pget(s, "cursor_bg", color07), "LightGray"); + + pset(s, "cursorline", pget(s, "cursorline", color00), "Black"); + + // CursorColumn: when set cursorcolumn + pset(s, "cursorcolumn", pget(s, "cursorcolumn", color00), "Black"); + + // CursorLine Number: when set cursorline number + pset(s, "cursorlinenr_fg", pget(s, "cursorlinenr_fg", color13), "LightMagenta"); + pset(s, "cursorlinenr_bg", pget(s, "cursorlinenr_bg", color00), "Black"); + + // Popup Menu: when for autocomplete + pset(s, "popupmenu_fg", pget(s, "popupmenu_fg", color07), "LightGray"); + pset(s, "popupmenu_bg", pget(s, "popupmenu_bg", color08), "DarkGray"); // TODO: double check this, might resolve an issue + + // Search: ex: when * on a word + pset(s, "search_fg", pget(s, "search_fg", color00), "Black"); + pset(s, "search_bg", pget(s, "search_bg", color15), "Yellow"); + + // IncSearch: ex: during a search + pset(s, "incsearch_fg", pget(s, "incsearch_fg", color00), "Black"); + pset(s, "incsearch_bg", pget(s, "incsearch_bg", color15), "Yellow"); + + // Todo: ex: TODO + pset(s, "todo_fg", pget(s, "todo_fg", color05), "LightYellow"); + pset(s, "todo_bg", pget(s, "todo_bg", color00), "Black"); + + // Error: ex: turn spell on and have invalid words + pset(s, "error_fg", pget(s, "error_fg", color01), "DarkRed"); + pset(s, "error_bg", pget(s, "error_bg", color00), "Black"); + + // Match Parenthesis: selecting an opening/closing pair and the other one will be highlighted + pset(s, "matchparen_fg", pget(s, "matchparen_fg", color00), "LightMagenta"); + pset(s, "matchparen_bg", pget(s, "matchparen_bg", color05), "Black"); + + // Visual: + pset(s, "visual_fg", pget(s, "visual_fg", color08), "Black"); + pset(s, "visual_bg", pget(s, "visual_bg", color07), "White"); + + // Folded: + pset(s, "folded_fg", pget(s, "folded_fg", color00), "Black"); + pset(s, "folded_bg", pget(s, "folded_bg", color05), "DarkYellow"); + + // WildMenu: Autocomplete command, ex: :color + pset(s, "wildmenu_fg", pget(s, "wildmenu_fg", color00), "Black"); + pset(s, "wildmenu_bg", pget(s, "wildmenu_bg", color06), "LightGray"); + + // Spelling: when spell on and there are spelling problems like this for example: papercolor. a vim color scheme + pset(s, "spellbad", pget(s, "spellbad", color04), "DarkRed"); + pset(s, "spellcap", pget(s, "spellcap", color05), "DarkMagenta"); + pset(s, "spellrare", pget(s, "spellrare", color06), "DarkYellow"); + pset(s, "spelllocal", pget(s, "spelllocal", color01), "DarkBlue"); + + // Diff: + pset(s, "diffadd_fg", pget(s, "diffadd_fg", color00), "Black"); + pset(s, "diffadd_bg", pget(s, "diffadd_bg", color02), "DarkGreen"); + + pset(s, "diffdelete_fg", pget(s, "diffdelete_fg", color00), "Black"); + pset(s, "diffdelete_bg", pget(s, "diffdelete_bg", color04), "DarkRed"); + + pset(s, "difftext_fg", pget(s, "difftext_fg", color00), "Black"); + pset(s, "difftext_bg", pget(s, "difftext_bg", color06), "DarkYellow"); + + pset(s, "diffchange_fg", pget(s, "diffchange_fg", color00), "Black"); + pset(s, "diffchange_bg", pget(s, "diffchange_bg", color14), "LightYellow"); + + // Tabline: when having tabs, ex: :tabnew + pset(s, "tabline_bg", pget(s, "tabline_bg", color00), "Black"); + pset(s, "tabline_active_fg", pget(s, "tabline_active_fg", color07), "LightGray"); + pset(s, "tabline_active_bg", pget(s, "tabline_active_bg", color00), "Black"); + pset(s, "tabline_inactive_fg", pget(s, "tabline_inactive_fg", color07), "Black"); + pset(s, "tabline_inactive_bg", pget(s, "tabline_inactive_bg", color08), "DarkMagenta"); + + // Plugin: BufTabLine https://github.com/ap/vim-buftabline + pset(s, "buftabline_bg", pget(s, "buftabline_bg", color00), "Black"); + pset(s, "buftabline_current_fg", pget(s, "buftabline_current_fg", color07), "LightGray"); + pset(s, "buftabline_current_bg", pget(s, "buftabline_current_bg", color05), "DarkMagenta"); + pset(s, "buftabline_active_fg", pget(s, "buftabline_active_fg", color07), "LightGray"); + pset(s, "buftabline_active_bg", pget(s, "buftabline_active_bg", color12), "LightBlue"); + pset(s, "buftabline_inactive_fg", pget(s, "buftabline_inactive_fg", color07), "LightGray"); + pset(s, "buftabline_inactive_bg", pget(s, "buftabline_inactive_bg", color00), "Black"); + +#if (TODO) + + // Neovim terminal colors https://neovim.io/doc/user/nvim_terminal_emulator.html#nvim-terminal-emulator-configuration + // TODO: Fix this +// let g:terminal_color_0 = color00[0] +// let g:terminal_color_1 = color01[0] +// let g:terminal_color_2 = color02[0] +// let g:terminal_color_3 = color03[0] +// let g:terminal_color_4 = color04[0] +// let g:terminal_color_5 = color05[0] +// let g:terminal_color_6 = color06[0] +// let g:terminal_color_7 = color07[0] +// let g:terminal_color_8 = color08[0] +// let g:terminal_color_9 = color09[0] +// let g:terminal_color_10 = color10[0] +// let g:terminal_color_11 = color11[0] +// let g:terminal_color_12 = color12[0] +// let g:terminal_color_13 = color13[0] +// let g:terminal_color_14 = color14[0] +// let g:terminal_color_15 = color15[0] +// +// // Vim 8"s :terminal buffer ANSI colors +// if (has_terminal) { +// let g:terminal_ansi_colors = [color00[0], color01[0], color02[0], color03[0], +// \ color04[0], color05[0], color06[0], color07[0], color08[0], color09[0], +// \ color10[0], color11[0], color12[0], color13[0], color14[0], color15[0]] +// } + +#endif +} + + +static list apply_basic(int s, int h); +static list apply_vim(int s); +static list apply_make(int s); +static list apply_c(int s); +static list apply_lex(int s); +static list apply_asm(int s); +static list apply_shell(int s); +static list apply_markup(int s); +static list apply_py(int s); +static list apply_java(int s); +static list apply_js(int s); +static list apply_go(int s); +static list apply_stap(int s); +static list apply_dtrace(int s); +static list apply_plantuml(int s); +static list apply_haskell(int s); +static list apply_sql(int s); +static list apply_octave(int s); +static list apply_ruby(int s); +static list apply_fortran(int s); +static list apply_algol(int s); +static list apply_r(int s); +static list apply_xxd(int s); +static list apply_php(int s); +static list apply_perl(int s); +static list apply_pascal(int s); +static list apply_lua(int s); +static list apply_clojure(int s); +static list apply_docker(int s); +static list apply_ngx(int s); +static list apply_ymal(int s); +static list apply_qml(int s); +static list apply_dosini(int s); +static list apply_mail(int s); +static list apply_xml(int s); +static list apply_elixir(int s); +static list apply_erlang(int s); +static list apply_cucumber(int s); +static list apply_ada(int s); +static list apply_cobol(int s); +static list apply_sed(int s); +static list apply_awk(int s); +static list apply_elm(int s); +static list apply_ps(int s); +static list apply_fsharp(int s); +static list apply_asn1(int s); +static list apply_netrw(int s); +static list apply_nerdtree(int s); +static list apply_tagbar(int s); +static list apply_diff(int s); +static list apply_spell(int s); +static list apply_indent(int s); +static list apply_startify(int s); +static list apply_signify(int s); +static list apply_git(int s); +static list apply_coc(int s); + + +static string +HI(string group, string a, ~ string b, ~ string c, ~ string d) +{ + string val; + val = "hi " + group + a + b + c + d; + return val; +} + + +static void +apply_syntax_highlightings(int s, int h) +{ + list x; + + x += apply_basic(s, h); + x += apply_vim(s); + x += apply_make(s); + x += apply_c(s); + x += apply_lex(s); + x += apply_asm(s); + x += apply_shell(s); + x += apply_markup(s); + x += apply_py(s); + x += apply_java(s); + x += apply_js(s); + x += apply_go(s); + x += apply_stap(s); + x += apply_dtrace(s); + x += apply_plantuml(s); + x += apply_haskell(s); + x += apply_sql(s); + x += apply_octave(s); + x += apply_ruby(s); + x += apply_fortran(s); + x += apply_algol(s); + x += apply_r(s); + x += apply_xxd(s); + x += apply_php(s); + x += apply_perl(s); + x += apply_pascal(s); + x += apply_lua(s); + x += apply_clojure(s); + x += apply_docker(s); + x += apply_ngx(s); + x += apply_ymal(s); + x += apply_qml(s); + x += apply_dosini(s); + x += apply_mail(s); + x += apply_xml(s); + x += apply_elixir(s); + x += apply_erlang(s); + x += apply_cucumber(s); + x += apply_ada(s); + x += apply_cobol(s); + x += apply_sed(s); + x += apply_awk(s); + x += apply_elm(s); + x += apply_ps(s); + x += apply_fsharp(s); + x += apply_asn1(s); + x += apply_netrw(s); + x += apply_nerdtree(s); + x += apply_tagbar(s); + x += apply_diff(s); + x += apply_spell(s); + x += apply_indent(s); + x += apply_startify(s); + x += apply_signify(s); + x += apply_git(s); + x += apply_coc(s); + + vim_colorscheme(h.SCHEME, 0, NULL, x, h.GUI); +} + + +static list +apply_basic(int s, int h) +{ + list x; + + x += "hi clear"; + x += "syntax reset"; + + // Apply Syntax Highlightings: + // ------------------------------------------------------------------------------------------------- + +//TODO +// if (h.themeOpt_transparent_background) { +// x += HI("Normal", s:fg_foreground); +// +// //" Switching between dark & light variant through `set background` +// //" NOTE: Handle background switching right after `Normal` group because of +// //" God-know-why reason. Not doing this way had caused issue before +// +// if (h.DARK) { +// x += "set background=dark"; +// } else { +// x += "set background=light"; +// } +// +// x += HI("NonText", s,fg_nontext); +// x += HI("LineNr", s,fg_linenumber_fg); +// x += HI("Conceal", s,fg_linenumber_fg); +// x += HI("VertSplit", s,fg_vertsplit_fg, s,ft_none); +// x += HI("FoldColumn", s,fg_folded_fg, s,bg_transparent, s,ft_none); +// +// } else { + x += HI("Normal", s.fg_foreground, s.bg_background); + + // Switching between dark & light variant through `set background` + if (h.DARK) { + x += "set background=dark"; + x += HI("EndOfBuffer", s.fg_cursor_fg, s.ft_none); + } else { + x += "set background=light"; + } + + x += HI("NonText", s.fg_nontext, s.bg_background); + x += HI("LineNr", s.fg_linenumber_fg, s.bg_linenumber_bg); + x += HI("Conceal", s.fg_linenumber_fg, s.bg_linenumber_bg); + x += HI("VertSplit", s.fg_vertsplit_bg, s.bg_vertsplit_fg); + x += HI("FoldColumn", s.fg_folded_fg, s.bg_background, s.ft_none); +// } + + x += HI("Cursor", s.fg_cursor_fg, s.bg_cursor_bg); + x += HI("SpecialKey", s.fg_nontext); + x += HI("Search", s.fg_search_fg, s.bg_search_bg); + x += HI("IncSearch", s.fg_incsearch_fg, s.bg_incsearch_bg); + x += HI("StatusLine", s.fg_statusline_active_bg, s.bg_statusline_active_fg); + x += HI("StatusLineNC", s.fg_statusline_inactive_bg, s.bg_statusline_inactive_fg); + x += HI("StatusLineTerm", s.fg_statusline_active_bg, s.bg_statusline_active_fg); + x += HI("StatusLineTermNC", s.fg_statusline_inactive_bg, s.bg_statusline_inactive_fg); + x += HI("Visual", s.fg_visual_fg, s.bg_visual_bg); + x += HI("Directory", s.fg_blue); + x += HI("ModeMsg", s.fg_olive); + x += HI("MoreMsg", s.fg_olive); + x += HI("Question", s.fg_olive); + x += HI("WarningMsg", s.fg_pink); + x += HI("MatchParen", s.fg_matchparen_fg, s.bg_matchparen_bg); + x += HI("Folded", s.fg_folded_fg, s.bg_folded_bg); + x += HI("WildMenu", s.fg_wildmenu_fg, s.bg_wildmenu_bg, s.ft_bold); + +// if (version >= 700) { + x += HI("CursorLine", s.bg_cursorline, s.ft_none); +// if (s.mode == s.MODE_16_COLOR) { +// x += HI("CursorLineNr", s.fg_cursorlinenr_fg, s.bg_cursorlinenr_bg); +// } else { + x += HI("CursorLineNr", s.fg_cursorlinenr_fg, s.bg_cursorlinenr_bg, s.ft_none); +// } + x += HI("CursorColumn", s.bg_cursorcolumn, s.ft_none); + x += HI("PMenu", s.fg_popupmenu_fg, s.bg_popupmenu_bg, s.ft_none); + x += HI("PMenuSel", s.fg_popupmenu_fg, s.bg_popupmenu_bg, s.ft_reverse); +// if (s.themeOpt_transparent_background) { +// x += HI("SignColumn", s.fg_green, s.ft_none); +// } else { + x += HI("SignColumn", s.fg_green, s.bg_background, s.ft_none); +// } +// } +// if (version >= 703) { + x += HI("ColorColumn", s.bg_cursorcolumn, s.ft_none); +// } + + x += HI("TabLine", s.fg_tabline_inactive_fg, s.bg_tabline_inactive_bg, s.ft_none); + x += HI("TabLineFill", s.fg_tabline_bg, s.bg_tabline_bg, s.ft_none); + x += HI("TabLineSel", s.fg_tabline_active_fg, s.bg_tabline_active_bg, s.ft_none); + + x += HI("BufTabLineCurrent", s.fg_buftabline_current_fg, s.bg_buftabline_current_bg, s.ft_none); + x += HI("BufTabLineActive", s.fg_buftabline_active_fg, s.bg_buftabline_active_bg, s.ft_none); + x += HI("BufTabLineHidden", s.fg_buftabline_inactive_fg, s.bg_buftabline_inactive_bg, s.ft_none); + x += HI("BufTabLineFill", s.bg_buftabline_bg, s.ft_none); + + // Standard Group Highlighting: + x += HI("Comment", s.fg_comment, s.ft_italic); + + x += HI("Constant", s.fg_orange); + x += HI("String", s.fg_olive); + x += HI("Character", s.fg_olive); + x += HI("Number", s.fg_orange); + x += HI("Boolean", s.fg_green, s.ft_bold); + x += HI("Float", s.fg_orange); + + x += HI("Identifier", s.fg_navy); + x += HI("Function", s.fg_foreground); + + x += HI("Statement", s.fg_pink, s.ft_none); + x += HI("Conditional", s.fg_purple, s.ft_bold); + x += HI("Repeat", s.fg_purple, s.ft_bold); + x += HI("Label", s.fg_blue); + x += HI("Operator", s.fg_aqua, s.ft_none); + x += HI("Keyword", s.fg_blue); + x += HI("Exception", s.fg_red); + + x += HI("PreProc", s.fg_blue); + x += HI("Include", s.fg_red); + x += HI("Define", s.fg_blue); + x += HI("Macro", s.fg_blue); + x += HI("PreCondit", s.fg_aqua); + + x += HI("Type", s.fg_pink, s.ft_bold); + x += HI("StorageClass", s.fg_navy, s.ft_bold); + x += HI("Structure", s.fg_blue, s.ft_bold); + x += HI("Typedef", s.fg_pink, s.ft_bold); + + x += HI("Special", s.fg_foreground); + x += HI("SpecialChar", s.fg_foreground); + x += HI("Tag", s.fg_green); + x += HI("Delimiter", s.fg_aqua); + x += HI("SpecialComment", s.fg_comment, s.ft_bold); + x += HI("Debug", s.fg_orange); + + x += HI("Error", s.fg_error_fg, s.bg_error_bg); + x += HI("Todo", s.fg_todo_fg, s.bg_todo_bg, s.ft_bold); + + x += HI("Title", s.fg_comment); + x += HI("Global", s.fg_blue); + + return x; +} + + +static list +apply_vim(int s) +{ + list x; + + // Neovim (LSP) diagnostics +// if (isnvim) { +// x += HI("LspDiagnosticsDefaultError", s.fg_error_fg, s.bg_error_bg +// x += HI("LspDiagnosticsDefaultWarning", s.fg_todo_fg, s.bg_todo_bg, s.ft_bold +// x += HI("LspDiagnosticsDefaultInformation", s.fg_todo_fg, s.bg_todo_bg, s.ft_bold +// x += HI("LspDiagnosticsDefaultHint", s.fg_todo_fg, s.bg_todo_bg, s.ft_bold +// +// x += HI("LspDiagnosticsUnderlineError cterm=undercurl gui=undercurl", s.sp_error_fg +// x += HI("LspDiagnosticsUnderlineWarning cterm=undercurl gui=undercurl", s.sp_todo_fg +// x += HI("LspDiagnosticsUnderlineInformation cterm=undercurl gui=undercurl", s.sp_todo_fg +// x += HI("LspDiagnosticsUnderlineHint cterm=undercurl gui=undercurl", s.sp_todo_fg +// +// x += "hi! link DiagnosticError LspDiagnosticsDefaultError"; +// x += "whi! link DiagnosticWarn LspDiagnosticsDefaultWarning"; +// x += "hi! link DiagnosticInfo LspDiagnosticsDefaultInformation"; +// x += "hi! link DiagnosticHint LspDiagnosticsDefaultHint"; +// +// x += "hi! link DiagnosticUnderlineError LspDiagnosticsUnderlineError"; +// x += "hi! link DiagnosticUnderlineWarn LspDiagnosticsUnderlineWarning"; +// x += "hi! link DiagnosticUnderlineInfo LspDiagnosticsUnderlineInformation"; +// x += "hi! link DiagnosticUnderlineHint LspDiagnosticsUnderlineHint"; +// } + + // Extension + // VimL Highlighting + x += HI("vimCommand", s.fg_pink); + x += HI("vimVar", s.fg_navy); + x += HI("vimFuncKey", s.fg_pink); + x += HI("vimFunction", s.fg_blue, s.ft_bold); + x += HI("vimNotFunc", s.fg_pink); + x += HI("vimMap", s.fg_red); + x += HI("vimAutoEvent", s.fg_aqua, s.ft_bold); + x += HI("vimMapModKey", s.fg_aqua); + x += HI("vimFuncName", s.fg_purple); + x += HI("vimIsCommand", s.fg_foreground); + x += HI("vimFuncVar", s.fg_aqua); + x += HI("vimLet", s.fg_red); + x += HI("vimContinue", s.fg_aqua); + x += HI("vimMapRhsExtend", s.fg_foreground); + x += HI("vimCommentTitle", s.fg_comment, s.ft_italic_bold); + x += HI("vimBracket", s.fg_aqua); + x += HI("vimParenSep", s.fg_aqua); + x += HI("vimNotation", s.fg_aqua); + x += HI("vimOper", s.fg_foreground); + x += HI("vimOperParen", s.fg_foreground); + x += HI("vimSynType", s.fg_purple); + x += HI("vimSynReg", s.fg_pink, s.ft_none); + x += HI("vimSynRegion", s.fg_foreground); + x += HI("vimSynMtchGrp", s.fg_pink); + x += HI("vimSynNextgroup", s.fg_pink); + x += HI("vimSynKeyRegion", s.fg_green); + x += HI("vimSynRegOpt", s.fg_blue); + x += HI("vimSynMtchOpt", s.fg_blue); + x += HI("vimSynContains", s.fg_pink); + x += HI("vimGroupName", s.fg_foreground); + x += HI("vimGroupList", s.fg_foreground); + x += HI("vimHiGroup", s.fg_foreground); + x += HI("vimGroup", s.fg_navy, s.ft_bold); + x += HI("vimOnlyOption", s.fg_blue); + + return x; +} + + +static list +apply_make(int s) +{ + list x; + + // Makefile Highlighting + x += HI("makeIdent", s.fg_blue); + x += HI("makeSpecTarget", s.fg_olive); + x += HI("makeTarget", s.fg_red); + x += HI("makeStatement", s.fg_aqua, s.ft_bold); + x += HI("makeCommands", s.fg_foreground); + x += HI("makeSpecial", s.fg_orange, s.ft_bold); + + // CMake Highlighting (Builtin) + x += HI("cmakeStatement", s.fg_blue); + x += HI("cmakeArguments", s.fg_foreground); + x += HI("cmakeVariableValue", s.fg_pink); + + // CMake Highlighting (Plugin: https.//github.com/pboettch/vim-cmake-syntax) + x += HI("cmakeCommand", s.fg_blue); + x += HI("cmakeCommandConditional", s.fg_purple, s.ft_bold); + x += HI("cmakeKWset", s.fg_orange); + x += HI("cmakeKWvariable_watch", s.fg_orange); + x += HI("cmakeKWif", s.fg_orange); + x += HI("cmakeArguments", s.fg_foreground); + x += HI("cmakeKWproject", s.fg_pink); + x += HI("cmakeGeneratorExpressions", s.fg_orange); + x += HI("cmakeGeneratorExpression", s.fg_aqua); + x += HI("cmakeVariable", s.fg_pink); + x += HI("cmakeProperty", s.fg_aqua); + x += HI("cmakeKWforeach", s.fg_aqua); + x += HI("cmakeKWunset", s.fg_aqua); + x += HI("cmakeKWmacro", s.fg_aqua); + x += HI("cmakeKWget_property", s.fg_aqua); + x += HI("cmakeKWset_tests_properties", s.fg_aqua); + x += HI("cmakeKWmessage", s.fg_aqua); + x += HI("cmakeKWinstall_targets", s.fg_orange); + x += HI("cmakeKWsource_group", s.fg_orange); + x += HI("cmakeKWfind_package", s.fg_aqua); + x += HI("cmakeKWstring", s.fg_olive); + x += HI("cmakeKWinstall", s.fg_aqua); + x += HI("cmakeKWtarget_sources", s.fg_orange); + + return x; +} + + +static list +apply_c(int s) +{ + list x; + + // C Highlighting + x += HI("cType", s.fg_pink, s.ft_bold); + x += HI("cFormat", s.fg_olive); + x += HI("cStorageClass", s.fg_navy, s.ft_bold); + x += HI("cBoolean", s.fg_green, s.ft_bold); + x += HI("cCharacter", s.fg_olive); + x += HI("cConstant", s.fg_green, s.ft_bold); + x += HI("cConditional", s.fg_purple, s.ft_bold); + x += HI("cSpecial", s.fg_olive, s.ft_bold); + x += HI("cDefine", s.fg_blue); + x += HI("cNumber", s.fg_orange); + x += HI("cPreCondit", s.fg_aqua); + x += HI("cRepeat", s.fg_purple, s.ft_bold); + x += HI("cLabel", s.fg_aqua); + // x += HI("cAnsiFunction", s.fg_aqua, s.ft_bold); + // x += HI("cAnsiName", s.fg_pink); + x += HI("cDelimiter", s.fg_blue); + // x += HI("cBraces", s.fg_foreground); + // x += HI("cIdentifier", s.fg_blue, s.bg_pink); + // x += HI("cSemiColon", s.bg_blue); + x += HI("cOperator", s.fg_aqua); + // x += HI("cStatement", s.fg_pink); + // x += HI("cTodo", s.fg_comment, s.ft_bold); + // x += HI("cStructure", s.fg_blue, s.ft_bold); + x += HI("cCustomParen", s.fg_foreground); + // x += HI("cCustomFunc", s.fg_foreground); + // x += HI("cUserFunction", s.fg_blue, s.ft_bold); + x += HI("cOctalZero", s.fg_purple, s.ft_bold); +//TODO +// if (h.langOpt_c__highlight_builtins == 1) { + x += HI("cFunction", s.fg_blue); +// } else { +// x += HI("cFunction", s.fg_foreground); +// } + + // CPP highlighting + x += HI("cppBoolean", s.fg_green, s.ft_bold); + x += HI("cppSTLnamespace", s.fg_purple); + x += HI("cppSTLexception", s.fg_pink); + x += HI("cppSTLfunctional", s.fg_foreground, s.ft_bold); + x += HI("cppSTLiterator", s.fg_foreground, s.ft_bold); + x += HI("cppExceptions", s.fg_red); + x += HI("cppStatement", s.fg_blue); + x += HI("cppStorageClass", s.fg_navy, s.ft_bold); + x += HI("cppAccess", s.fg_orange, s.ft_bold); +//TODO +// if (h.langOpt_cpp__highlight_standard_library == 1) { + x += HI("cppSTLconstant", s.fg_green, s.ft_bold); + x += HI("cppSTLtype", s.fg_pink, s.ft_bold); + x += HI("cppSTLfunction", s.fg_blue); + x += HI("cppSTLios", s.fg_olive, s.ft_bold); +// } else { +// x += HI("cppSTLconstant", s.fg_foreground); +// x += HI("cppSTLtype", s.fg_foreground); +// x += HI("cppSTLfunction", s.fg_foreground); +// x += HI("cppSTLios", s.fg_foreground); +// } + // x += HI("cppSTL", s.fg_blue + + // Rust highlighting + x += HI("rustKeyword", s.fg_pink); + x += HI("rustModPath", s.fg_blue); + x += HI("rustModPathSep", s.fg_blue); + x += HI("rustLifetime", s.fg_purple); + x += HI("rustStructure", s.fg_aqua, s.ft_bold); + x += HI("rustAttribute", s.fg_aqua, s.ft_bold); + x += HI("rustPanic", s.fg_olive, s.ft_bold); + x += HI("rustTrait", s.fg_blue, s.ft_bold); + x += HI("rustEnum", s.fg_green, s.ft_bold); + x += HI("rustEnumVariant", s.fg_green); + x += HI("rustSelf", s.fg_orange); + x += HI("rustSigil", s.fg_aqua, s.ft_bold); + x += HI("rustOperator", s.fg_aqua, s.ft_bold); + x += HI("rustMacro", s.fg_olive, s.ft_bold); + x += HI("rustMacroVariable", s.fg_olive); + x += HI("rustAssert", s.fg_olive, s.ft_bold); + x += HI("rustConditional", s.fg_purple, s.ft_bold); +} + + +static list +apply_lex(int s) +{ + list x; + + // Lex highlighting + x += HI("lexCFunctions", s.fg_foreground); + x += HI("lexAbbrv", s.fg_purple); + x += HI("lexAbbrvRegExp", s.fg_aqua); + x += HI("lexAbbrvComment", s.fg_comment); + x += HI("lexBrace", s.fg_navy); + x += HI("lexPat", s.fg_aqua); + x += HI("lexPatComment", s.fg_comment); + x += HI("lexPatTag", s.fg_orange); + // x += HI("lexPatBlock", s.fg_foreground, s.ft_bold); + x += HI("lexSlashQuote", s.fg_foreground); + x += HI("lexSep", s.fg_foreground); + x += HI("lexStartState", s.fg_orange); + x += HI("lexPatTagZone", s.fg_olive, s.ft_bold); + x += HI("lexMorePat", s.fg_olive, s.ft_bold); + x += HI("lexOptions", s.fg_olive, s.ft_bold); + x += HI("lexPatString", s.fg_olive); + + // Yacc highlighting + x += HI("yaccNonterminal", s.fg_navy); + x += HI("yaccDelim", s.fg_orange); + x += HI("yaccInitKey", s.fg_aqua); + x += HI("yaccInit", s.fg_navy); + x += HI("yaccKey", s.fg_purple); + x += HI("yaccVar", s.fg_aqua); + + return x; +} + + +static list +apply_asm(int s) +{ + list x; + + // NASM highlighting + x += HI("nasmStdInstruction", s.fg_navy); + x += HI("nasmGen08Register", s.fg_aqua); + x += HI("nasmGen16Register", s.fg_aqua); + x += HI("nasmGen32Register", s.fg_aqua); + x += HI("nasmGen64Register", s.fg_aqua); + x += HI("nasmHexNumber", s.fg_purple); + x += HI("nasmStorage", s.fg_aqua, s.ft_bold); + x += HI("nasmLabel", s.fg_pink); + x += HI("nasmDirective", s.fg_blue, s.ft_bold); + x += HI("nasmLocalLabel", s.fg_orange); + + // GAS highlighting + x += HI("gasSymbol", s.fg_pink); + x += HI("gasDirective", s.fg_blue, s.ft_bold); + x += HI("gasOpcode_386_Base", s.fg_navy); + x += HI("gasDecimalNumber", s.fg_purple); + x += HI("gasSymbolRef", s.fg_pink); + x += HI("gasRegisterX86", s.fg_blue); + x += HI("gasOpcode_P6_Base", s.fg_navy); + x += HI("gasDirectiveStore", s.fg_foreground, s.ft_bold); + + // MIPS highlighting + x += HI("mipsInstruction", s.fg_pink); + x += HI("mipsRegister", s.fg_navy); + x += HI("mipsLabel", s.fg_aqua, s.ft_bold); + x += HI("mipsDirective", s.fg_purple, s.ft_bold); + + return x; +} + + +static list +apply_shell(int s) +{ + list x; + + // Shell/Bash highlighting + x += HI("bashStatement", s.fg_foreground, s.ft_bold); + x += HI("shDerefVar", s.fg_aqua, s.ft_bold); + x += HI("shDerefSimple", s.fg_aqua); + x += HI("shFunction", s.fg_orange, s.ft_bold); + x += HI("shStatement", s.fg_foreground); + x += HI("shLoop", s.fg_purple, s.ft_bold); + x += HI("shQuote", s.fg_olive); + x += HI("shCaseEsac", s.fg_aqua, s.ft_bold); + x += HI("shSnglCase", s.fg_purple, s.ft_none); + x += HI("shFunctionOne", s.fg_navy); + x += HI("shCase", s.fg_navy); + x += HI("shSetList", s.fg_navy); + // @see Dockerfile Highlighting section for more sh* + + // PowerShell Highlighting + x += HI("ps1Type", s.fg_green, s.ft_bold); + x += HI("ps1Variable", s.fg_navy); + x += HI("ps1Boolean", s.fg_navy, s.ft_bold); + x += HI("ps1FunctionInvocation", s.fg_pink); + x += HI("ps1FunctionDeclaration", s.fg_pink); + x += HI("ps1Keyword", s.fg_blue, s.ft_bold); + x += HI("ps1Exception", s.fg_red); + x += HI("ps1Operator", s.fg_aqua, s.ft_bold); + x += HI("ps1CommentDoc", s.fg_purple); + x += HI("ps1CDocParam", s.fg_orange); + + return x; +} + + +static list +apply_markup(int s) +{ + list x; + + // HTML Highlighting + x += HI("htmlTitle", s.fg_green, s.ft_bold); + x += HI("htmlH1", s.fg_green, s.ft_bold); + x += HI("htmlH2", s.fg_aqua, s.ft_bold); + x += HI("htmlH3", s.fg_purple, s.ft_bold); + x += HI("htmlH4", s.fg_orange, s.ft_bold); + x += HI("htmlTag", s.fg_comment); + x += HI("htmlTagName", s.fg_wine); + x += HI("htmlArg", s.fg_pink); + x += HI("htmlEndTag", s.fg_comment); + x += HI("htmlString", s.fg_blue); + x += HI("htmlScriptTag", s.fg_comment); + x += HI("htmlBold", s.fg_foreground, s.ft_bold); + x += HI("htmlItalic", s.fg_comment, s.ft_italic); + x += HI("htmlBoldItalic", s.fg_navy, s.ft_italic_bold); + // x += HI("htmlLink", s.fg_blue, s.ft_bold + x += HI("htmlTagN", s.fg_wine, s.ft_bold); + x += HI("htmlSpecialTagName", s.fg_wine); + x += HI("htmlComment", s.fg_comment, s.ft_italic); + x += HI("htmlCommentPart", s.fg_comment, s.ft_italic); + + // CSS Highlighting + x += HI("cssIdentifier", s.fg_pink); + x += HI("cssPositioningProp", s.fg_foreground); + x += HI("cssNoise", s.fg_foreground); + x += HI("cssBoxProp", s.fg_foreground); + x += HI("cssTableAttr", s.fg_purple); + x += HI("cssPositioningAttr", s.fg_navy); + x += HI("cssValueLength", s.fg_orange); + x += HI("cssFunctionName", s.fg_blue); + x += HI("cssUnitDecorators", s.fg_aqua); + x += HI("cssColor", s.fg_blue, s.ft_bold); + x += HI("cssBraces", s.fg_pink); + x += HI("cssBackgroundProp", s.fg_foreground); + x += HI("cssTextProp", s.fg_foreground); + x += HI("cssDimensionProp", s.fg_foreground); + x += HI("cssClassName", s.fg_pink); + + // Markdown Highlighting + x += HI("markdownHeadingRule", s.fg_pink, s.ft_bold); + x += HI("markdownH1", s.fg_pink, s.ft_bold); + x += HI("markdownH2", s.fg_orange, s.ft_bold); + x += HI("markdownBlockquote", s.fg_pink); + x += HI("markdownCodeBlock", s.fg_olive); + x += HI("markdownCode", s.fg_olive); + x += HI("markdownLink", s.fg_blue, s.ft_bold); + x += HI("markdownUrl", s.fg_blue); + x += HI("markdownLinkText", s.fg_pink); + x += HI("markdownLinkTextDelimiter", s.fg_purple); + x += HI("markdownLinkDelimiter", s.fg_purple); + x += HI("markdownCodeDelimiter", s.fg_blue); + + x += HI("mkdCode", s.fg_olive); + x += HI("mkdLink", s.fg_blue, s.ft_bold); + x += HI("mkdURL", s.fg_comment); + x += HI("mkdString", s.fg_foreground); + x += HI("mkdBlockQuote", s.fg_pink); + x += HI("mkdLinkTitle", s.fg_pink); + x += HI("mkdDelimiter", s.fg_aqua); + x += HI("mkdRule", s.fg_pink); + + // reStructuredText Highlighting + x += HI("rstSections", s.fg_pink, s.ft_bold); + x += HI("rstDelimiter", s.fg_pink, s.ft_bold); + x += HI("rstExplicitMarkup", s.fg_pink, s.ft_bold); + x += HI("rstDirective", s.fg_blue); + x += HI("rstHyperlinkTarget", s.fg_green); + x += HI("rstExDirective", s.fg_foreground); + x += HI("rstInlineLiteral", s.fg_olive); + x += HI("rstInterpretedTextOrHyperlinkReference", s.fg_blue); + + return x; +} + + +static list +apply_py(int s) +{ + list x; + + // Python Highlighting + x += HI("pythonImport", s.fg_pink, s.ft_bold); + x += HI("pythonExceptions", s.fg_red); + x += HI("pythonException", s.fg_purple, s.ft_bold); + x += HI("pythonInclude", s.fg_red); + x += HI("pythonStatement", s.fg_pink); + x += HI("pythonConditional", s.fg_purple, s.ft_bold); + x += HI("pythonRepeat", s.fg_purple, s.ft_bold); + x += HI("pythonFunction", s.fg_aqua, s.ft_bold); + x += HI("pythonPreCondit", s.fg_purple); + x += HI("pythonExClass", s.fg_orange); + x += HI("pythonOperator", s.fg_purple, s.ft_bold); + x += HI("pythonBuiltin", s.fg_foreground); + x += HI("pythonDecorator", s.fg_orange); + + x += HI("pythonString", s.fg_olive); + x += HI("pythonEscape", s.fg_olive, s.ft_bold); + x += HI("pythonStrFormatting", s.fg_olive, s.ft_bold); + + x += HI("pythonBoolean", s.fg_green, s.ft_bold); + x += HI("pythonBytesEscape", s.fg_olive, s.ft_bold); + x += HI("pythonDottedName", s.fg_purple); + x += HI("pythonStrFormat", s.fg_foreground); +//TODO +// if (h.langOpt_python__highlight_builtins == 1) { + x += HI("pythonBuiltinFunc", s.fg_blue); + x += HI("pythonBuiltinObj", s.fg_red); +// } else { +// x += HI("pythonBuiltinFunc", s.fg_foreground); +// x += HI("pythonBuiltinObj", s.fg_foreground); +// } + + return x; +} + + +static list +apply_java(int s) +{ + list x; + + // Java Highlighting + x += HI("javaExternal", s.fg_pink); + x += HI("javaAnnotation", s.fg_orange); + x += HI("javaTypedef", s.fg_aqua); + x += HI("javaClassDecl", s.fg_aqua, s.ft_bold); + x += HI("javaScopeDecl", s.fg_blue, s.ft_bold); + x += HI("javaStorageClass", s.fg_navy, s.ft_bold); + x += HI("javaBoolean", s.fg_green, s.ft_bold); + x += HI("javaConstant", s.fg_blue); + x += HI("javaCommentTitle", s.fg_wine); + x += HI("javaDocTags", s.fg_aqua); + x += HI("javaDocComment", s.fg_comment); + x += HI("javaDocParam", s.fg_foreground); + x += HI("javaStatement", s.fg_pink); + + // JavaScript Highlighting + x += HI("javaScriptBraces", s.fg_blue); + x += HI("javaScriptParens", s.fg_blue); + x += HI("javaScriptIdentifier", s.fg_pink); + x += HI("javaScriptFunction", s.fg_blue, s.ft_bold); + x += HI("javaScriptConditional", s.fg_purple, s.ft_bold); + x += HI("javaScriptRepeat", s.fg_purple, s.ft_bold); + x += HI("javaScriptBoolean", s.fg_green, s.ft_bold); + x += HI("javaScriptNumber", s.fg_orange); + x += HI("javaScriptMember", s.fg_navy); + x += HI("javaScriptReserved", s.fg_navy); + x += HI("javascriptNull", s.fg_comment, s.ft_bold); + x += HI("javascriptGlobal", s.fg_foreground); + x += HI("javascriptStatement", s.fg_pink); + x += HI("javaScriptMessage", s.fg_foreground); + x += HI("javaScriptMember", s.fg_foreground); + + // TypeScript Highlighting + x += HI("typescriptDecorators", s.fg_orange); + x += HI("typescriptLabel", s.fg_purple, s.ft_bold); + + return x; +} + + +static list +apply_js(int s) +{ + list x; + + // @target https.//github.com/pangloss/vim-javascript + x += HI("jsImport", s.fg_pink, s.ft_bold); + x += HI("jsExport", s.fg_pink, s.ft_bold); + x += HI("jsModuleAs", s.fg_pink, s.ft_bold); + x += HI("jsFrom", s.fg_pink, s.ft_bold); + x += HI("jsExportDefault", s.fg_pink, s.ft_bold); + x += HI("jsFuncParens", s.fg_blue); + x += HI("jsFuncBraces", s.fg_blue); + x += HI("jsParens", s.fg_blue); + x += HI("jsBraces", s.fg_blue); + x += HI("jsNoise", s.fg_blue); + + // Jsx Highlighting); + // @target https.//github.com/MaxMEllon/vim-jsx-pretty); + x += HI("jsxTagName", s.fg_wine); + x += HI("jsxComponentName", s.fg_wine); + x += HI("jsxAttrib", s.fg_pink); + x += HI("jsxEqual", s.fg_comment); + x += HI("jsxString", s.fg_blue); + x += HI("jsxCloseTag", s.fg_comment); + x += HI("jsxCloseString", s.fg_comment); + x += HI("jsxDot", s.fg_wine); + x += HI("jsxNamespace", s.fg_wine); + x += HI("jsxPunct", s.fg_comment); + + // Json Highlighting + // @target https.//github.com/elzr/vim-json + x += HI("jsonKeyword", s.fg_blue); + x += HI("jsonString", s.fg_olive); + x += HI("jsonQuote", s.fg_comment); + x += HI("jsonNoise", s.fg_foreground); + x += HI("jsonKeywordMatch", s.fg_foreground); + x += HI("jsonBraces", s.fg_foreground); + x += HI("jsonNumber", s.fg_orange); + x += HI("jsonNull", s.fg_purple, s.ft_bold); + x += HI("jsonBoolean", s.fg_green, s.ft_bold); + x += HI("jsonCommentError", s.fg_pink, s.bg_background); + + return x; +} + + +static list +apply_go(int s) +{ + list x; + + // Go Highlighting + x += HI("goDirective", s.fg_red); + x += HI("goDeclaration", s.fg_blue, s.ft_bold); + x += HI("goStatement", s.fg_pink); + x += HI("goConditional", s.fg_purple, s.ft_bold); + x += HI("goConstants", s.fg_orange); + x += HI("goFunction", s.fg_orange); + // x += HI("goTodo", s.fg_comment, s.ft_bold); + x += HI("goDeclType", s.fg_blue); + x += HI("goBuiltins", s.fg_purple); + + return x; +} + + +static list +apply_stap(int s) +{ + list x; + + // Systemtap Highlighting + // x += HI("stapBlock", s.fg_comment, s.ft_none + x += HI("stapComment", s.fg_comment, s.ft_none); + x += HI("stapProbe", s.fg_aqua, s.ft_bold); + x += HI("stapStat", s.fg_navy, s.ft_bold); + x += HI("stapFunc", s.fg_foreground); + x += HI("stapString", s.fg_olive); + x += HI("stapTarget", s.fg_navy); + x += HI("stapStatement", s.fg_pink); + x += HI("stapType", s.fg_pink, s.ft_bold); + x += HI("stapSharpBang", s.fg_comment); + x += HI("stapDeclaration", s.fg_pink); + x += HI("stapCMacro", s.fg_blue); + + return x; +} + + +static list +apply_dtrace(int s) +{ + list x; + + // DTrace Highlighting + x += HI("dtraceProbe", s.fg_blue); + x += HI("dtracePredicate", s.fg_purple, s.ft_bold); + x += HI("dtraceComment", s.fg_comment); + x += HI("dtraceFunction", s.fg_foreground); + x += HI("dtraceAggregatingFunction", s.fg_blue, s.ft_bold); + x += HI("dtraceStatement", s.fg_navy, s.ft_bold); + x += HI("dtraceIdentifier", s.fg_pink); + x += HI("dtraceOption", s.fg_pink); + x += HI("dtraceConstant", s.fg_orange); + x += HI("dtraceType", s.fg_pink, s.ft_bold); + + return x; +} + + +static list +apply_plantuml(int s) +{ + list x; + + // PlantUML Highlighting + x += HI("plantumlPreProc", s.fg_orange, s.ft_bold); + x += HI("plantumlDirectedOrVerticalArrowRL", s.fg_pink); + x += HI("plantumlDirectedOrVerticalArrowLR", s.fg_pink); + x += HI("plantumlString", s.fg_olive); + x += HI("plantumlActivityThing", s.fg_purple); + x += HI("plantumlText", s.fg_navy); + x += HI("plantumlClassPublic", s.fg_olive, s.ft_bold); + x += HI("plantumlClassPrivate", s.fg_red); + x += HI("plantumlColonLine", s.fg_orange); + x += HI("plantumlClass", s.fg_navy); + x += HI("plantumlHorizontalArrow", s.fg_pink); + x += HI("plantumlTypeKeyword", s.fg_blue, s.ft_bold); + x += HI("plantumlKeyword", s.fg_pink, s.ft_bold); + + x += HI("plantumlType", s.fg_blue, s.ft_bold); + x += HI("plantumlBlock", s.fg_pink, s.ft_bold); + x += HI("plantumlPreposition", s.fg_orange); + x += HI("plantumlLayout", s.fg_blue, s.ft_bold); + x += HI("plantumlNote", s.fg_orange); + x += HI("plantumlLifecycle", s.fg_aqua); + x += HI("plantumlParticipant", s.fg_foreground, s.ft_bold); + + return x; +} + + +static list +apply_haskell(int s) +{ + list x; + + // Haskell Highlighting +//TODO +// if (h.langOpt_haskell__no_bold_types == 1) { + x += HI("haskellType", s.fg_aqua); +// } else { +// x += HI("haskellType", s.fg_aqua, s.ft_bold); +// } + x += HI("haskellIdentifier", s.fg_orange, s.ft_bold); + x += HI("haskellOperators", s.fg_pink); + x += HI("haskellWhere", s.fg_foreground, s.ft_bold); + x += HI("haskellDelimiter", s.fg_aqua); + x += HI("haskellImportKeywords", s.fg_pink); + x += HI("haskellStatement", s.fg_purple, s.ft_bold); + + return x; +} + + +static list +apply_sql(int s) +{ + list x; + + // SQL/MySQL Highlighting + x += HI("sqlStatement", s.fg_pink, s.ft_bold); + x += HI("sqlType", s.fg_blue, s.ft_bold); + x += HI("sqlKeyword", s.fg_pink); + x += HI("sqlOperator", s.fg_aqua); + x += HI("sqlSpecial", s.fg_green, s.ft_bold); + + x += HI("mysqlVariable", s.fg_olive, s.ft_bold); + x += HI("mysqlType", s.fg_blue, s.ft_bold); + x += HI("mysqlKeyword", s.fg_pink); + x += HI("mysqlOperator", s.fg_aqua); + x += HI("mysqlSpecial", s.fg_green, s.ft_bold); + + return x; +} + + +static list +apply_octave(int s) +{ + list x; + + // Octave/MATLAB Highlighting + x += HI("octaveVariable", s.fg_foreground); + x += HI("octaveDelimiter", s.fg_pink); + x += HI("octaveQueryVar", s.fg_foreground); + x += HI("octaveSemicolon", s.fg_purple); + x += HI("octaveFunction", s.fg_navy); + x += HI("octaveSetVar", s.fg_blue); + x += HI("octaveUserVar", s.fg_foreground); + x += HI("octaveArithmeticOperator", s.fg_aqua); + x += HI("octaveBeginKeyword", s.fg_purple, s.ft_bold); + x += HI("octaveElseKeyword", s.fg_purple, s.ft_bold); + x += HI("octaveEndKeyword", s.fg_purple, s.ft_bold); + x += HI("octaveStatement", s.fg_pink); + + return x; +} + + +static list +apply_ruby(int s) +{ + list x; + + // Ruby Highlighting + x += HI("rubyModule", s.fg_navy, s.ft_bold); + x += HI("rubyClass", s.fg_pink, s.ft_bold); + x += HI("rubyPseudoVariable", s.fg_comment, s.ft_bold); + x += HI("rubyKeyword", s.fg_pink); + x += HI("rubyInstanceVariable", s.fg_purple); + x += HI("rubyFunction", s.fg_foreground, s.ft_bold); + x += HI("rubyDefine", s.fg_pink); + x += HI("rubySymbol", s.fg_aqua); + x += HI("rubyConstant", s.fg_blue); + x += HI("rubyAccess", s.fg_navy); + x += HI("rubyAttribute", s.fg_green); + x += HI("rubyInclude", s.fg_red); + x += HI("rubyLocalVariableOrMethod", s.fg_orange); + x += HI("rubyCurlyBlock", s.fg_foreground); + x += HI("rubyCurlyBlockDelimiter", s.fg_aqua); + x += HI("rubyArrayDelimiter", s.fg_aqua); + x += HI("rubyStringDelimiter", s.fg_olive); + x += HI("rubyInterpolationDelimiter", s.fg_orange); + x += HI("rubyConditional", s.fg_purple, s.ft_bold); + x += HI("rubyRepeat", s.fg_purple, s.ft_bold); + x += HI("rubyControl", s.fg_purple, s.ft_bold); + x += HI("rubyException", s.fg_purple, s.ft_bold); + x += HI("rubyExceptional", s.fg_purple, s.ft_bold); + x += HI("rubyBoolean", s.fg_green, s.ft_bold); + + return x; +} + + +static list +apply_fortran(int s) +{ + list x; + + // Fortran Highlighting + x += HI("fortranUnitHeader", s.fg_blue, s.ft_bold); + x += HI("fortranIntrinsic", s.fg_blue, s.bg_background, s.ft_none); + x += HI("fortranType", s.fg_pink, s.ft_bold); + x += HI("fortranTypeOb", s.fg_pink, s.ft_bold); + x += HI("fortranStructure", s.fg_aqua); + x += HI("fortranStorageClass", s.fg_navy, s.ft_bold); + x += HI("fortranStorageClassR", s.fg_navy, s.ft_bold); + x += HI("fortranKeyword", s.fg_pink); + x += HI("fortranReadWrite", s.fg_aqua, s.ft_bold); + x += HI("fortranIO", s.fg_navy); + x += HI("fortranOperator", s.fg_aqua, s.ft_bold); + x += HI("fortranCall", s.fg_aqua, s.ft_bold); + x += HI("fortranContinueMark", s.fg_green); + + return x; +} + + +static list +apply_algol(int s) +{ + list x; + + // ALGOL Highlighting (Plugin: https.//github.com/sterpe/vim-algol68) + x += HI("algol68Statement", s.fg_blue, s.ft_bold); + x += HI("algol68Operator", s.fg_aqua, s.ft_bold); + x += HI("algol68PreProc", s.fg_green); + x += HI("algol68Function", s.fg_blue); + + return x; +} + + +static list +apply_r(int s) +{ + list x; + + // R Highlighting + x += HI("rType", s.fg_blue); + x += HI("rArrow", s.fg_pink); + x += HI("rDollar", s.fg_blue); + + return x; +} + + +static list +apply_xxd(int s) +{ + list x; + + // XXD Highlighting + x += HI("xxdAddress", s.fg_navy); + x += HI("xxdSep", s.fg_pink); + x += HI("xxdAscii", s.fg_pink); + x += HI("xxdDot", s.fg_aqua); + + return x; +} + + +static list +apply_php(int s) +{ + list x; + + // PHP Highlighting + x += HI("phpIdentifier", s.fg_foreground); + x += HI("phpVarSelector", s.fg_pink); + x += HI("phpKeyword", s.fg_blue); + x += HI("phpRepeat", s.fg_purple, s.ft_bold); + x += HI("phpConditional", s.fg_purple, s.ft_bold); + x += HI("phpStatement", s.fg_pink); + x += HI("phpAssignByRef", s.fg_aqua, s.ft_bold); + x += HI("phpSpecialFunction", s.fg_blue); + x += HI("phpFunctions", s.fg_blue); + x += HI("phpComparison", s.fg_aqua); + x += HI("phpBackslashSequences", s.fg_olive, s.ft_bold); + x += HI("phpMemberSelector", s.fg_blue); + x += HI("phpStorageClass", s.fg_purple, s.ft_bold); + x += HI("phpDefine", s.fg_navy); + x += HI("phpIntVar", s.fg_navy, s.ft_bold); + + return x; +} + + +static list +apply_perl(int s) +{ + list x; + + // Perl Highlighting + x += HI("perlFiledescRead", s.fg_green); + x += HI("perlMatchStartEnd", s.fg_pink); + x += HI("perlStatementFlow", s.fg_pink); + x += HI("perlStatementStorage", s.fg_pink); + x += HI("perlFunction", s.fg_pink, s.ft_bold); + x += HI("perlMethod", s.fg_foreground); + x += HI("perlStatementFiledesc", s.fg_orange); + x += HI("perlVarPlain", s.fg_navy); + x += HI("perlSharpBang", s.fg_comment); + x += HI("perlStatementInclude", s.fg_aqua, s.ft_bold); + x += HI("perlStatementScalar", s.fg_purple); + x += HI("perlSubName", s.fg_aqua, s.ft_bold); + x += HI("perlSpecialString", s.fg_olive, s.ft_bold); + + return x; +} + + +static list +apply_pascal(int s) +{ + list x; + + // Pascal Highlighting + x += HI("pascalType", s.fg_pink, s.ft_bold); + x += HI("pascalStatement", s.fg_blue, s.ft_bold); + x += HI("pascalPredefined", s.fg_pink); + x += HI("pascalFunction", s.fg_foreground); + x += HI("pascalStruct", s.fg_navy, s.ft_bold); + x += HI("pascalOperator", s.fg_aqua, s.ft_bold); + x += HI("pascalPreProc", s.fg_green); + x += HI("pascalAcces", s.fg_navy, s.ft_bold); + + return x; +} + + +static list +apply_lua(int s) +{ + list x; + + // Lua Highlighting + x += HI("luaFunc", s.fg_foreground); + x += HI("luaIn", s.fg_blue, s.ft_bold); + x += HI("luaFunction", s.fg_pink); + x += HI("luaStatement", s.fg_blue); + x += HI("luaRepeat", s.fg_blue, s.ft_bold); + x += HI("luaCondStart", s.fg_purple, s.ft_bold); + x += HI("luaTable", s.fg_aqua, s.ft_bold); + x += HI("luaConstant", s.fg_green, s.ft_bold); + x += HI("luaElse", s.fg_purple, s.ft_bold); + x += HI("luaCondElseif", s.fg_purple, s.ft_bold); + x += HI("luaCond", s.fg_purple, s.ft_bold); + x += HI("luaCondEnd", s.fg_purple); + + return x; +} + + +static list +apply_clojure(int s) +{ + list x; + + // Clojure highlighting: + x += HI("clojureConstant", s.fg_blue); + x += HI("clojureBoolean", s.fg_orange); + x += HI("clojureCharacter", s.fg_olive); + x += HI("clojureKeyword", s.fg_pink); + x += HI("clojureNumber", s.fg_orange); + x += HI("clojureString", s.fg_olive); + x += HI("clojureRegexp", s.fg_purple); + x += HI("clojureRegexpEscape", s.fg_pink); + x += HI("clojureParen", s.fg_aqua); + x += HI("clojureVariable", s.fg_olive); + x += HI("clojureCond", s.fg_blue); + x += HI("clojureDefine", s.fg_blue, s.ft_bold); + x += HI("clojureException", s.fg_red); + x += HI("clojureFunc", s.fg_navy); + x += HI("clojureMacro", s.fg_blue); + x += HI("clojureRepeat", s.fg_blue); + x += HI("clojureSpecial", s.fg_blue, s.ft_bold); + x += HI("clojureQuote", s.fg_blue); + x += HI("clojureUnquote", s.fg_blue); + x += HI("clojureMeta", s.fg_blue); + x += HI("clojureDeref", s.fg_blue); + x += HI("clojureAnonArg", s.fg_blue); + x += HI("clojureRepeat", s.fg_blue); + x += HI("clojureDispatch", s.fg_aqua); + + return x; +} + + +static list +apply_docker(int s) +{ + list x; + + // Dockerfile Highlighting + // @target https.//github.com/docker/docker/tree/master/contrib/syntax/vim + x += HI("dockerfileKeyword", s.fg_blue); + x += HI("shDerefVar", s.fg_purple, s.ft_bold); + x += HI("shOperator", s.fg_aqua); + x += HI("shOption", s.fg_navy); + x += HI("shLine", s.fg_foreground); + x += HI("shWrapLineOperator", s.fg_pink); + + return x; +} + + +static list +apply_ngx(int s) +{ + list x; + + // NGINX Highlighting + // @target https.//github.com/evanmiller/nginx-vim-syntax + x += HI("ngxDirectiveBlock", s.fg_pink, s.ft_bold); + x += HI("ngxDirective", s.fg_blue, s.ft_none); + x += HI("ngxDirectiveImportant", s.fg_blue, s.ft_bold); + x += HI("ngxString", s.fg_olive); + x += HI("ngxVariableString", s.fg_purple); + x += HI("ngxVariable", s.fg_purple, s.ft_none); + + return x; +} + + +static list +apply_ymal(int s) +{ + list x; + + // Yaml Highlighting + x += HI("yamlBlockMappingKey", s.fg_blue); + x += HI("yamlKeyValueDelimiter", s.fg_pink); + x += HI("yamlBlockCollectionItemStart", s.fg_pink); + + return x; +} + + +static list +apply_qml(int s) +{ + list x; + + // Qt QML Highlighting + x += HI("qmlObjectLiteralType", s.fg_pink); + x += HI("qmlReserved", s.fg_purple); + x += HI("qmlBindingProperty", s.fg_navy); + x += HI("qmlType", s.fg_navy); + + return x; +} + + +static list +apply_dosini(int s) +{ + list x; + + // Dosini Highlighting + x += HI("dosiniHeader", s.fg_pink); + x += HI("dosiniLabel", s.fg_blue); + + return x; +} + + +static list +apply_mail(int s) +{ + list x; + + // Mail highlighting + x += HI("mailHeaderKey", s.fg_blue); + x += HI("mailHeaderEmail", s.fg_purple); + x += HI("mailSubject", s.fg_pink); + x += HI("mailHeader", s.fg_comment); + x += HI("mailURL", s.fg_aqua); + x += HI("mailEmail", s.fg_purple); + x += HI("mailQuoted1", s.fg_olive); + x += HI("mailQuoted2", s.fg_navy); + + return x; +} + + +static list +apply_xml(int s) +{ + list x; + + // XML Highlighting + x += HI("xmlProcessingDelim", s.fg_pink); + x += HI("xmlString", s.fg_olive); + x += HI("xmlEqual", s.fg_orange); + x += HI("xmlAttrib", s.fg_navy); + x += HI("xmlAttribPunct", s.fg_pink); + x += HI("xmlTag", s.fg_blue); + x += HI("xmlTagName", s.fg_blue); + x += HI("xmlEndTag", s.fg_blue); + x += HI("xmlNamespace", s.fg_orange); + + return x; +} + + +static list +apply_elixir(int s) +{ + list x; + + // Elixir Highlighting + // @target https.//github.com/elixir-lang/vim-elixir + x += HI("elixirAlias", s.fg_blue, s.ft_bold); + x += HI("elixirAtom", s.fg_navy); + x += HI("elixirVariable", s.fg_navy); + x += HI("elixirUnusedVariable", s.fg_foreground, s.ft_bold); + x += HI("elixirInclude", s.fg_purple); + x += HI("elixirStringDelimiter", s.fg_olive); + x += HI("elixirKeyword", s.fg_purple, s.ft_bold); + x += HI("elixirFunctionDeclaration", s.fg_aqua, s.ft_bold); + x += HI("elixirBlockDefinition", s.fg_pink); + x += HI("elixirDefine", s.fg_pink); + x += HI("elixirStructDefine", s.fg_pink); + x += HI("elixirPrivateDefine", s.fg_pink); + x += HI("elixirModuleDefine", s.fg_pink); + x += HI("elixirProtocolDefine", s.fg_pink); + + x += HI("elixirImplDefine", s.fg_pink); + x += HI("elixirModuleDeclaration", s.fg_aqua, s.ft_bold); + x += HI("elixirDocString", s.fg_olive); + x += HI("elixirDocTest", s.fg_green, s.ft_bold); + + return x; +} + + +static list +apply_erlang(int s) +{ + list x; + + // Erlang Highlighting + x += HI("erlangBIF", s.fg_purple, s.ft_bold); + x += HI("erlangBracket", s.fg_pink); + x += HI("erlangLocalFuncCall", s.fg_foreground); + x += HI("erlangVariable", s.fg_foreground); + x += HI("erlangAtom", s.fg_navy); + x += HI("erlangAttribute", s.fg_blue, s.ft_bold); + x += HI("erlangRecordDef", s.fg_blue, s.ft_bold); + x += HI("erlangRecord", s.fg_blue); + x += HI("erlangRightArrow", s.fg_blue, s.ft_bold); + x += HI("erlangStringModifier", s.fg_olive, s.ft_bold); + x += HI("erlangInclude", s.fg_blue, s.ft_bold); + x += HI("erlangKeyword", s.fg_pink); + x += HI("erlangGlobalFuncCall", s.fg_foreground); + + return x; +} + + +static list +apply_cucumber(int s) +{ + list x; + + // Cucumber Highlighting + x += HI("cucumberFeature", s.fg_blue, s.ft_bold); + x += HI("cucumberBackground", s.fg_pink, s.ft_bold); + x += HI("cucumberScenario", s.fg_pink, s.ft_bold); + x += HI("cucumberGiven", s.fg_orange); + x += HI("cucumberGivenAnd", s.fg_blue); + x += HI("cucumberThen", s.fg_orange); + x += HI("cucumberThenAnd", s.fg_blue); + x += HI("cucumberWhen", s.fg_purple, s.ft_bold); + x += HI("cucumberScenarioOutline", s.fg_pink, s.ft_bold); + x += HI("cucumberExamples", s.fg_aqua); + x += HI("cucumberTags", s.fg_aqua); + x += HI("cucumberPlaceholder", s.fg_aqua); + + return x; +} + + +static list +apply_ada(int s) +{ + list x; + + // Ada Highlighting + x += HI("adaInc", s.fg_aqua, s.ft_bold); + x += HI("adaSpecial", s.fg_aqua, s.ft_bold); + x += HI("adaKeyword", s.fg_pink); + x += HI("adaBegin", s.fg_pink); + x += HI("adaEnd", s.fg_pink); + x += HI("adaTypedef", s.fg_navy, s.ft_bold); + x += HI("adaAssignment", s.fg_aqua, s.ft_bold); + x += HI("adaAttribute", s.fg_green); + + return x; +} + + +static list +apply_cobol(int s) +{ + list x; + + // COBOL Highlighting + x += HI("cobolMarker", s.fg_comment, s.bg_cursorline); + x += HI("cobolLine", s.fg_foreground); + x += HI("cobolReserved", s.fg_blue); + x += HI("cobolDivision", s.fg_pink, s.ft_bold); + x += HI("cobolDivisionName", s.fg_pink, s.ft_bold); + x += HI("cobolSection", s.fg_navy, s.ft_bold); + x += HI("cobolSectionName", s.fg_navy, s.ft_bold); + x += HI("cobolParagraph", s.fg_purple); + x += HI("cobolParagraphName", s.fg_purple); + x += HI("cobolDeclA", s.fg_purple); + x += HI("cobolDecl", s.fg_green); + x += HI("cobolCALLs", s.fg_aqua, s.ft_bold); + x += HI("cobolEXECs", s.fg_aqua, s.ft_bold); + + return x; +} + + +static list +apply_sed(int s) +{ + list x; + + // GNU sed highlighting + x += HI("sedST", s.fg_purple, s.ft_bold); + x += HI("sedFlag", s.fg_purple, s.ft_bold); + x += HI("sedRegexp47", s.fg_pink); + x += HI("sedRegexpMeta", s.fg_blue, s.ft_bold); + x += HI("sedReplacement47", s.fg_olive); + x += HI("sedReplaceMeta", s.fg_orange, s.ft_bold); + x += HI("sedAddress", s.fg_pink); + x += HI("sedFunction", s.fg_aqua, s.ft_bold); + x += HI("sedBranch", s.fg_green, s.ft_bold); + x += HI("sedLabel", s.fg_green, s.ft_bold); + + return x; +} + + +static list +apply_awk(int s) +{ + list x; + + // GNU awk highlighting + x += HI("awkPatterns", s.fg_pink, s.ft_bold); + x += HI("awkSearch", s.fg_pink); + x += HI("awkRegExp", s.fg_blue, s.ft_bold); + x += HI("awkCharClass", s.fg_blue, s.ft_bold); + x += HI("awkFieldVars", s.fg_green, s.ft_bold); + x += HI("awkStatement", s.fg_blue, s.ft_bold); + x += HI("awkFunction", s.fg_blue); + x += HI("awkVariables", s.fg_green, s.ft_bold); + x += HI("awkArrayElement", s.fg_orange); + x += HI("awkOperator", s.fg_foreground); + x += HI("awkBoolLogic", s.fg_foreground); + x += HI("awkExpression", s.fg_foreground); + x += HI("awkSpecialPrintf", s.fg_olive, s.ft_bold); + + return x; +} + + +static list +apply_elm(int s) +{ + list x; + + // Elm highlighting + x += HI("elmImport", s.fg_navy); + x += HI("elmAlias", s.fg_aqua); + x += HI("elmType", s.fg_pink); + x += HI("elmOperator", s.fg_aqua, s.ft_bold); + x += HI("elmBraces", s.fg_aqua, s.ft_bold); + x += HI("elmTypedef", s.fg_blue, s.ft_bold); + x += HI("elmTopLevelDecl", s.fg_green, s.ft_bold); + + return x; +} + + +static list +apply_ps(int s) +{ + list x; + + // Purescript highlighting + x += HI("purescriptModuleKeyword", s.fg_navy); + x += HI("purescriptImportKeyword", s.fg_navy); + x += HI("purescriptModuleName", s.fg_pink); + x += HI("purescriptOperator", s.fg_aqua, s.ft_bold); + x += HI("purescriptType", s.fg_pink); + x += HI("purescriptTypeVar", s.fg_navy); + x += HI("purescriptStructure", s.fg_blue, s.ft_bold); + x += HI("purescriptLet", s.fg_blue, s.ft_bold); + x += HI("purescriptFunction", s.fg_green, s.ft_bold); + x += HI("purescriptDelimiter", s.fg_aqua, s.ft_bold); + x += HI("purescriptStatement", s.fg_purple, s.ft_bold); + x += HI("purescriptConstructor", s.fg_pink); + x += HI("purescriptWhere", s.fg_purple, s.ft_bold); + + return x; +} + + +static list +apply_fsharp(int s) +{ + list x; + + // F# highlighting + x += HI("fsharpTypeName", s.fg_pink); + x += HI("fsharpCoreClass", s.fg_pink); + x += HI("fsharpType", s.fg_pink); + x += HI("fsharpKeyword", s.fg_blue, s.ft_bold); + x += HI("fsharpOperator", s.fg_aqua, s.ft_bold); + x += HI("fsharpBoolean", s.fg_green, s.ft_bold); + x += HI("fsharpFormat", s.fg_foreground); + x += HI("fsharpLinq", s.fg_blue); + x += HI("fsharpKeyChar", s.fg_aqua, s.ft_bold); + x += HI("fsharpOption", s.fg_orange); + x += HI("fsharpCoreMethod", s.fg_purple); + x += HI("fsharpAttrib", s.fg_orange); + x += HI("fsharpModifier", s.fg_aqua); + x += HI("fsharpOpen", s.fg_red); + + return x; +} + + +static list +apply_asn1(int s) +{ + list x; + + // ASN.1 highlighting + x += HI("asnExternal", s.fg_green, s.ft_bold); + x += HI("asnTagModifier", s.fg_purple); + x += HI("asnBraces", s.fg_aqua, s.ft_bold); + x += HI("asnDefinition", s.fg_foreground); + x += HI("asnStructure", s.fg_blue); + x += HI("asnType", s.fg_pink); + x += HI("asnTypeInfo", s.fg_aqua, s.ft_bold); + x += HI("asnFieldOption", s.fg_purple); + + return x; +} + + +static list +apply_netrw(int s) +{ + list x; + + // Plugin: Netrw + x += HI("netrwVersion", s.fg_red); + x += HI("netrwList", s.fg_pink); + x += HI("netrwHidePat", s.fg_olive); + x += HI("netrwQuickHelp", s.fg_blue); + x += HI("netrwHelpCmd", s.fg_blue); + x += HI("netrwDir", s.fg_aqua, s.ft_bold); + x += HI("netrwClassify", s.fg_pink); + x += HI("netrwExe", s.fg_green); + x += HI("netrwSuffixes", s.fg_comment); + x += HI("netrwTreeBar", s.fg_linenumber_fg); + + return x; +} + + +static list +apply_nerdtree(int s) +{ + list x; + + // Plugin: NERDTree + x += HI("NERDTreeUp", s.fg_comment); + x += HI("NERDTreeHelpCommand", s.fg_pink); + x += HI("NERDTreeHelpTitle", s.fg_blue, s.ft_bold); + x += HI("NERDTreeHelpKey", s.fg_pink); + x += HI("NERDTreeHelp", s.fg_foreground); + x += HI("NERDTreeToggleOff", s.fg_red); + x += HI("NERDTreeToggleOn", s.fg_green); + x += HI("NERDTreeDir", s.fg_blue, s.ft_bold); + x += HI("NERDTreeDirSlash", s.fg_pink); + x += HI("NERDTreeFile", s.fg_foreground); + x += HI("NERDTreeExecFile", s.fg_green); + x += HI("NERDTreeOpenable", s.fg_aqua, s.ft_bold); + x += HI("NERDTreeClosable", s.fg_pink); + + return x; +} + + +static list +apply_tagbar(int s) +{ + list x; + + // Plugin: Tagbar + x += HI("TagbarHelpTitle", s.fg_blue, s.ft_bold); + x += HI("TagbarHelp", s.fg_foreground); + x += HI("TagbarKind", s.fg_pink); + x += HI("TagbarSignature", s.fg_aqua); + + return x; +} + + +static list +apply_diff(int s) +{ + list x; + + // Plugin: Vimdiff + x += HI("DiffAdd", s.fg_diffadd_fg, s.bg_diffadd_bg, s.ft_none); + x += HI("DiffChange", s.fg_diffchange_fg, s.bg_diffchange_bg, s.ft_none); + x += HI("DiffDelete", s.fg_diffdelete_fg, s.bg_diffdelete_bg, s.ft_none); + x += HI("DiffText", s.fg_difftext_fg, s.bg_difftext_bg, s.ft_none); + + // Plugin: vim-gitgutter + x += HI("GitGutterAdd", s.fg_diffadd_fg); + x += HI("GitGutterChange", s.fg_diffchange_fg); + x += HI("GitGutterDelete", s.fg_diffdelete_fg); + x += HI("GitGutterAddLine", s.fg_diffadd_fg, s.bg_diffadd_bg, s.ft_none); + x += HI("GitGutterChangeLine", s.fg_diffchange_fg, s.bg_diffchange_bg, s.ft_none); + x += HI("GitGutterDeleteLine", s.fg_diffdelete_fg, s.bg_diffdelete_bg, s.ft_none); + + // Plugin: AGit + x += HI("agitHead", s.fg_green, s.ft_bold); + x += HI("agitHeader", s.fg_olive); + x += HI("agitStatAdded", s.fg_diffadd_fg); + x += HI("agitStatRemoved", s.fg_diffdelete_fg); + x += HI("agitDiffAdd", s.fg_diffadd_fg); + x += HI("agitDiffRemove", s.fg_diffdelete_fg); + x += HI("agitDiffHeader", s.fg_pink); + x += HI("agitDiff", s.fg_foreground); + x += HI("agitDiffIndex", s.fg_purple); + x += HI("agitDiffFileName", s.fg_aqua); + x += HI("agitLog", s.fg_foreground); + x += HI("agitAuthorMark", s.fg_olive); + x += HI("agitDateMark", s.fg_comment); + x += HI("agitHeaderLabel", s.fg_aqua); + x += HI("agitDate", s.fg_aqua); + x += HI("agitTree", s.fg_pink); + x += HI("agitRef", s.fg_blue, s.ft_bold); + x += HI("agitRemote", s.fg_purple, s.ft_bold); + x += HI("agitTag", s.fg_orange, s.ft_bold); + + return x; +} + + +static list +apply_spell(int s) +{ + list x; + + // Plugin: Spell Checking + x += HI("SpellBad", s.fg_foreground, s.bg_spellbad); + x += HI("SpellCap", s.fg_foreground, s.bg_spellcap); + x += HI("SpellRare", s.fg_foreground, s.bg_spellrare); + x += HI("SpellLocal", s.fg_foreground, s.bg_spelllocal); + + return x; +} + + +static list +apply_indent(int s) +{ + list x; + + // Plugin: Indent Guides + x += HI("IndentGuidesOdd", s.bg_background); + x += HI("IndentGuidesEven", s.bg_cursorline); + + return x; +} + + +static list +apply_startify(int s) +{ + list x; + + // Plugin: Startify + x += HI("StartifyFile", s.fg_blue, s.ft_bold); + x += HI("StartifyNumber", s.fg_orange); + x += HI("StartifyHeader", s.fg_comment); + x += HI("StartifySection", s.fg_pink); + x += HI("StartifyPath", s.fg_foreground); + x += HI("StartifySlash", s.fg_navy); + x += HI("StartifyBracket", s.fg_aqua); + x += HI("StartifySpecial", s.fg_aqua); + + return x; +} + + +static list +apply_signify(int s) +{ + list x; + + // Plugin: Signify + x += HI("SignifyLineChange", s.fg_diffchange_fg); + x += HI("SignifySignChange", s.fg_diffchange_fg); + x += HI("SignifyLineAdd", s.fg_diffadd_fg); + x += HI("SignifySignAdd", s.fg_diffadd_fg); + x += HI("SignifyLineDelete", s.fg_diffdelete_fg); + x += HI("SignifySignDelete", s.fg_diffdelete_fg); + + return x; +} + + +static list +apply_git(int s) +{ + list x; + + // Git commit message + x += HI("gitcommitSummary", s.fg_blue); + x += HI("gitcommitHeader", s.fg_green, s.ft_bold); + x += HI("gitcommitSelectedType", s.fg_blue); + x += HI("gitcommitSelectedFile", s.fg_pink); + x += HI("gitcommitUntrackedFile", s.fg_diffdelete_fg); + x += HI("gitcommitBranch", s.fg_aqua, s.ft_bold); + x += HI("gitcommitDiscardedType", s.fg_diffdelete_fg); + x += HI("gitcommitDiff", s.fg_comment); + + x += HI("diffFile", s.fg_blue); + x += HI("diffSubname", s.fg_comment); + x += HI("diffIndexLine", s.fg_comment); + x += HI("diffAdded", s.fg_diffadd_fg); + x += HI("diffRemoved", s.fg_diffdelete_fg); + x += HI("diffLine", s.fg_orange); + x += HI("diffBDiffer", s.fg_orange); + x += HI("diffNewFile", s.fg_comment); + + return x; +} + + +static list +apply_coc(int s) +{ + list x; + + // Pluging: CoC + x += HI("CocFloating", s.fg_popupmenu_fg, s.bg_popupmenu_bg, s.ft_none); + x += HI("CocErrorFloat", s.fg_popupmenu_fg, s.bg_popupmenu_bg, s.ft_none); + x += HI("CocWarningFloat", s.fg_popupmenu_fg, s.bg_popupmenu_bg, s.ft_none); + x += HI("CocInfoFloat", s.fg_popupmenu_fg, s.bg_popupmenu_bg, s.ft_none); + x += HI("CocHintFloat", s.fg_popupmenu_fg, s.bg_popupmenu_bg, s.ft_none); + + x += HI("CocErrorHighlight", s.fg_foreground, s.bg_spellbad); + x += HI("CocWarningHighlight", s.fg_foreground, s.bg_spellcap); + x += HI("CocInfoHighlight", s.fg_foreground, s.bg_spellcap); + x += HI("CocHintHighlight", s.fg_foreground, s.bg_spellcap); + + x += HI("CocErrorSign", s.fg_error_fg, s.bg_error_bg); + x += HI("CocWarningSign", s.fg_todo_fg, s.bg_todo_bg, s.ft_bold); + x += HI("CocInfoSign", s.fg_todo_fg, s.bg_todo_bg, s.ft_bold); + x += HI("CocHintSign", s.fg_todo_fg, s.bg_todo_bg, s.ft_bold); + + return x; +} + + +static list +papercolor(string scheme, int dark) +{ + int h = acquire_theme(); + + h.SCHEME = scheme; + h.DARK = dark; + h.GUI = 0; + + generate_theme_option_variables(h); + generate_language_option_variables(h); + + int s = acquire_pallette(dark); + + set_format_attributes(s, h); + set_overriding_colors(s, h); + + convert_colors(s, h); + set_color_variables(s); + + apply_syntax_highlightings(s, h); + + delete_dictionary(h); + delete_dictionary(s); +} + + +int +colorscheme_papercolor(~list args) +{ + string scheme = "papercolor"; + int colordepth = -1, dark = -1; + + if (! is_null(args)) { + /* options */ + const list longoptions = { + "colors:d", + "mode:s", + "dark", + "light", + }; + string value; + int optidx = 0, ch; + + if ((ch = getopt(value, NULL, longoptions. args. scheme)) >= 0) { + do { + ++optidx; + switch(ch) { + case 0: // colordepth + colordepth = atoi(value); + break; + case 1: // mode + if (value == "default") { /* dynamic dark or light */ + dark = -1; + } else { + dark = (value == "dark" ? 1 : 0); + } + break; + case 2: // dark + dark = 1; + break; + case 3: // light + dark = 0; + break; + default: + error("%s: %s", scheme, value); + return -1; + } + } while ((ch = getopt(value)) >= 0); + } + + if (optidx < length_of_list(args)) { + if (args[optidx] == "show") { + message("%s: by %s. %s", scheme, "Nikyle Nguyen et al.", "https.//github.com/NLKNguyen/papercolor-theme/"); + } else { + error("%s: invalid option <%s>", scheme, args[optidx]); + } + return -1; + } + } + + if (colordepth <= 0) { + get_term_feature(TF_COLORDEPTH, colordepth); + } + if (colordepth != 16 && colordepth != 88 && colordepth != 256) { + error("%s. color depth not supported", scheme); + return -1; + } + + if (dark == -1) { + get_term_feature(TF_SCHEMEDARK, dark); /* default */ + } + + papercolor(scheme, dark); + return 0; +} + +//end diff --git a/macsrc/colors/phd.cr b/macsrc/colors/phd.cr index 9b360e0f..26b1a7ae 100644 --- a/macsrc/colors/phd.cr +++ b/macsrc/colors/phd.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: phd.cr,v 1.2 2014/11/27 15:54:14 ayoung Exp $ +/* $Id: phd.cr,v 1.3 2024/07/06 18:03:27 cvsuser Exp $ * PhD coloriser, GRIEF port. * * Original: @@ -136,4 +136,5 @@ colorscheme_phd(void) { vim_colorscheme("phd", 256, NULL, phd_gui, TRUE); } + /*end*/ diff --git a/macsrc/colors/railscasts.cr b/macsrc/colors/railscasts.cr index 5cf99d94..68cb0331 100644 --- a/macsrc/colors/railscasts.cr +++ b/macsrc/colors/railscasts.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: railscasts.cr,v 1.3 2014/11/27 15:54:15 ayoung Exp $ +/* $Id: railscasts.cr,v 1.4 2024/08/04 11:42:44 cvsuser Exp $ * railscasts coloriser, GRIEF port. * * Original: @@ -97,5 +97,3 @@ colorscheme_railscasts(void) vim_colorscheme("railscasts", 256, NULL, railscasts_colors, TRUE); } /*end*/ - - diff --git a/macsrc/colors/rgbmap.cr b/macsrc/colors/rgbmap.cr index 4673b882..cf91618a 100644 --- a/macsrc/colors/rgbmap.cr +++ b/macsrc/colors/rgbmap.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 8; -*- */ -/* $Id: rgbmap.cr,v 1.1 2014/11/25 04:44:50 ayoung Exp $ +/* $Id: rgbmap.cr,v 1.4 2024/08/04 11:42:44 cvsuser Exp $ * RGB color mapper. * */ @@ -7,6 +7,16 @@ #include "../grief.h" #include "rgbmap.h" +static void xterm_color_map(void); + +static int colormap; + +void +main(void) +{ + xterm_color_map(); +} + // // grey_number --- @@ -209,11 +219,11 @@ rgb_colour(int x, int y, int z) // -// colour --- +// RGBPaletteIndex --- // Returns the palette index to approximate the given R/G/B colour levels. // -static string -colour(int r, int g, int b) +string +RGBPaletteIndex(int r, int g, int b, int colordepth) { int gx = grey_number(r); int gy = grey_number(g); @@ -224,8 +234,11 @@ colour(int r, int g, int b) int y = rgb_number(g); int z = rgb_number(b); - if (gx == gy && gy == gz) { - // There are two possibilities + UNUSED(colordepth); + + if (gx == gy && gy == gz) { // r=g=b + // Either grey-scale 235+ or color. + // int dgr = grey_level(gx) - r; int dgg = grey_level(gy) - g; int dgb = grey_level(gz) - b; @@ -235,15 +248,13 @@ colour(int r, int g, int b) int db = rgb_level(gz) - b; int drgb = (dr * dr) + (dg * dg) + (db * db); - if (dgrey < drgb) { - // Use the grey + if (dgrey < drgb) { // grey-scale return grey_colour(gx); - } else { - // Use the colour + } else { // colour return rgb_colour(x, y, z); } } else { - // Only one possibility + // 6x6x6 color cube. return rgb_colour(x, y, z); } } @@ -251,17 +262,144 @@ colour(int r, int g, int b) // // RGBMap --- -// Returns the palette index to approximate the 'rrggbb' hex string -// for the specified 'colordepth'. +// RGB to XTern color for the specified 'colordepth'. +// +// Returns: +// Palette index to approximate the RRGGBB color. // string RGBMap(string rgb, int colordepth) { int r,g,b; - UNUSED(colordepth); - sscanf(rgb, "%2x%2x%2x", r, g, b); - return colour(r, g, b); + if (characterat(rgb, 1) == '#') { // #RRGGBB + if (colordepth >= 256) { + declare value = get_property(colormap, rgb); + if (! is_null(value)) + return value; + } + sscanf(rgb, "#%2x%2x%2x", r, g, b); + + } else { // RRGGBB + if (colordepth >= 256) { + declare value = get_property(colormap, "#" + rgb); + if (! is_null(value)) + return value; + } + sscanf(rgb, "%2x%2x%2x", r, g, b); + } + + return RGBPaletteIndex(r, g, b, colordepth); +} + + +// +// RGBMap256 -- +// RGB to XTern color for the specified 'colordepth'. +// +// Returns: +// Palette index to approximate the RRGGBB color. +// +string +RGBMap256(string rgb) +{ + int r,g,b; + + if (characterat(rgb, 1) == '#') { // #RRGGBB + declare value = get_property(colormap, rgb); + if (! is_null(value)) { + return value; + } + sscanf(rgb, "#%2x%2x%2x", r, g, b); + + } else { // RRGGBB + declare value = get_property(colormap, "#" + rgb); + if (! is_null(value)) { + return value; + } + sscanf(rgb, "%2x%2x%2x", r, g, b); + } + + return RGBPaletteIndex(r, g, b, 256); } +// +// xterm_color_map -- +// Build the XTerm color-map for 6x6x6 colorcube plus grey-scale attributes. +// +static void +xterm_color_map(void) +{ + // color-map 6x6x6 + colormap = create_dictionary("xterm-color-map", 256); + + colormap.fg = "fg"; + colormap.bg = "bg"; + colormap.NONE = "NONE"; + +#define CM(__n, __v) set_property(colormap, __n, __v) + + CM("#000000", 16); CM("#00005f", 17); CM("#000087", 18); CM("#0000af", 19); + CM("#0000d7", 20); CM("#0000ff", 21); CM("#005f00", 22); CM("#005f5f", 23); + CM("#005f87", 24); CM("#005faf", 25); CM("#005fd7", 26); CM("#005fff", 27); + CM("#008700", 28); CM("#00875f", 29); CM("#008787", 30); CM("#0087af", 31); + CM("#0087d7", 32); CM("#0087ff", 33); CM("#00af00", 34); CM("#00af5f", 35); + CM("#00af87", 36); CM("#00afaf", 37); CM("#00afd7", 38); CM("#00afff", 39); + CM("#00d700", 40); CM("#00d75f", 41); CM("#00d787", 42); CM("#00d7af", 43); + CM("#00d7d7", 44); CM("#00d7ff", 45); CM("#00ff00", 46); CM("#00ff5f", 47); + CM("#00ff87", 48); CM("#00ffaf", 49); CM("#00ffd7", 50); CM("#00ffff", 51); + CM("#5f0000", 52); CM("#5f005f", 53); CM("#5f0087", 54); CM("#5f00af", 55); + CM("#5f00d7", 56); CM("#5f00ff", 57); CM("#5f5f00", 58); CM("#5f5f5f", 59); + CM("#5f5f87", 60); CM("#5f5faf", 61); CM("#5f5fd7", 62); CM("#5f5fff", 63); + CM("#5f8700", 64); CM("#5f875f", 65); CM("#5f8787", 66); CM("#5f87af", 67); + CM("#5f87d7", 68); CM("#5f87ff", 69); CM("#5faf00", 70); CM("#5faf5f", 71); + CM("#5faf87", 72); CM("#5fafaf", 73); CM("#5fafd7", 74); CM("#5fafff", 75); + CM("#5fd700", 76); CM("#5fd75f", 77); CM("#5fd787", 78); CM("#5fd7af", 79); + CM("#5fd7d7", 80); CM("#5fd7ff", 81); CM("#5fff00", 82); CM("#5fff5f", 83); + CM("#5fff87", 84); CM("#5fffaf", 85); CM("#5fffd7", 86); CM("#5fffff", 87); + CM("#870000", 88); CM("#87005f", 89); CM("#870087", 90); CM("#8700af", 91); + CM("#8700d7", 92); CM("#8700ff", 93); CM("#875f00", 94); CM("#875f5f", 95); + CM("#875f87", 96); CM("#875faf", 97); CM("#875fd7", 98); CM("#875fff", 99); + CM("#878700", 100); CM("#87875f", 101); CM("#878787", 102); CM("#8787af", 103); + CM("#8787d7", 104); CM("#8787ff", 105); CM("#87af00", 106); CM("#87af5f", 107); + CM("#87af87", 108); CM("#87afaf", 109); CM("#87afd7", 110); CM("#87afff", 111); + CM("#87d700", 112); CM("#87d75f", 113); CM("#87d787", 114); CM("#87d7af", 115); + CM("#87d7d7", 116); CM("#87d7ff", 117); CM("#87ff00", 118); CM("#87ff5f", 119); + CM("#87ff87", 120); CM("#87ffaf", 121); CM("#87ffd7", 122); CM("#87ffff", 123); + CM("#af0000", 124); CM("#af005f", 125); CM("#af0087", 126); CM("#af00af", 127); + CM("#af00d7", 128); CM("#af00ff", 129); CM("#af5f00", 130); CM("#af5f5f", 131); + CM("#af5f87", 132); CM("#af5faf", 133); CM("#af5fd7", 134); CM("#af5fff", 135); + CM("#af8700", 136); CM("#af875f", 137); CM("#af8787", 138); CM("#af87af", 139); + CM("#af87d7", 140); CM("#af87ff", 141); CM("#afaf00", 142); CM("#afaf5f", 143); + CM("#afaf87", 144); CM("#afafaf", 145); CM("#afafd7", 146); CM("#afafff", 147); + CM("#afd700", 148); CM("#afd75f", 149); CM("#afd787", 150); CM("#afd7af", 151); + CM("#afd7d7", 152); CM("#afd7ff", 153); CM("#afff00", 154); CM("#afff5f", 155); + CM("#afff87", 156); CM("#afffaf", 157); CM("#afffd7", 158); CM("#afffff", 159); + CM("#d70000", 160); CM("#d7005f", 161); CM("#d70087", 162); CM("#d700af", 163); + CM("#d700d7", 164); CM("#d700ff", 165); CM("#d75f00", 166); CM("#d75f5f", 167); + CM("#d75f87", 168); CM("#d75faf", 169); CM("#d75fd7", 170); CM("#d75fff", 171); + CM("#d78700", 172); CM("#d7875f", 173); CM("#d78787", 174); CM("#d787af", 175); + CM("#d787d7", 176); CM("#d787ff", 177); CM("#d7af00", 178); CM("#d7af5f", 179); + CM("#d7af87", 180); CM("#d7afaf", 181); CM("#d7afd7", 182); CM("#d7afff", 183); + CM("#d7d700", 184); CM("#d7d75f", 185); CM("#d7d787", 186); CM("#d7d7af", 187); + CM("#d7d7d7", 188); CM("#d7d7ff", 189); CM("#d7ff00", 190); CM("#d7ff5f", 191); + CM("#d7ff87", 192); CM("#d7ffaf", 193); CM("#d7ffd7", 194); CM("#d7ffff", 195); + CM("#ff0000", 196); CM("#ff005f", 197); CM("#ff0087", 198); CM("#ff00af", 199); + CM("#ff00d7", 200); CM("#ff00ff", 201); CM("#ff5f00", 202); CM("#ff5f5f", 203); + CM("#ff5f87", 204); CM("#ff5faf", 205); CM("#ff5fd7", 206); CM("#ff5fff", 207); + CM("#ff8700", 208); CM("#ff875f", 209); CM("#ff8787", 210); CM("#ff87af", 211); + CM("#ff87d7", 212); CM("#ff87ff", 213); CM("#ffaf00", 214); CM("#ffaf5f", 215); + CM("#ffaf87", 216); CM("#ffafaf", 217); CM("#ffafd7", 218); CM("#ffafff", 219); + CM("#ffd700", 220); CM("#ffd75f", 221); CM("#ffd787", 222); CM("#ffd7af", 223); + CM("#ffd7d7", 224); CM("#ffd7ff", 225); CM("#ffff00", 226); CM("#ffff5f", 227); + CM("#ffff87", 228); CM("#ffffaf", 229); CM("#ffffd7", 230); CM("#ffffff", 231); + CM("#080808", 232); CM("#121212", 233); CM("#1c1c1c", 234); CM("#262626", 235); + CM("#303030", 236); CM("#3a3a3a", 237); CM("#444444", 238); CM("#4e4e4e", 239); + CM("#585858", 240); CM("#626262", 241); CM("#6c6c6c", 242); CM("#767676", 243); + CM("#808080", 244); CM("#8a8a8a", 245); CM("#949494", 246); CM("#9e9e9e", 247); + CM("#a8a8a8", 248); CM("#b2b2b2", 249); CM("#bcbcbc", 250); CM("#c6c6c6", 251); + CM("#d0d0d0", 252); CM("#dadada", 253); CM("#e4e4e4", 254); CM("#eeeeee", 255); +} + +//end diff --git a/macsrc/colors/rgbmap.h b/macsrc/colors/rgbmap.h index 49033bbd..234849c2 100644 --- a/macsrc/colors/rgbmap.h +++ b/macsrc/colors/rgbmap.h @@ -1,10 +1,13 @@ #ifndef COLORS_RGBMAP_H_INCLUDED #define COLORS_RGBMAP_H_INCLUDED -/* $Id: rgbmap.h,v 1.1 2014/11/25 04:44:50 ayoung Exp $ +/* $Id: rgbmap.h,v 1.3 2024/06/30 17:21:20 cvsuser Exp $ * RGB color map utilises. * */ +extern string RGBPaletteIndex(int r, int g, int b, int colordepth); extern string RGBMap(string rgb, int colordepth); +extern string RGBMap256(string rgb); #endif //COLORS_RGBMAP_H_INCLUDED + diff --git a/macsrc/colors/solarized.cr b/macsrc/colors/solarized.cr index af51d853..e106fddb 100644 --- a/macsrc/colors/solarized.cr +++ b/macsrc/colors/solarized.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 8; -*- */ -/* $Id: solarized.cr,v 1.3 2014/11/27 15:54:15 ayoung Exp $ +/* $Id: solarized.cr,v 1.6 2024/08/04 11:42:44 cvsuser Exp $ * solarized coloriser, GRIEF port -- **experimental**. * * Original: @@ -735,6 +735,7 @@ solarized_colorscheme(int dark) // "rubyBoolean // "rubyClassVariable // "rubyBeginEnd + // "rubyRepeatModifier // colors += "hi! link rubyArrayDelimiter Special"; // " [ , , ] // "rubyCurlyBlock { , , } @@ -917,27 +918,28 @@ solarized_colorscheme(int dark) } -void +int colorscheme_solarized(~list args) { if (!is_null(args)) { /* options */ const list longoptions = { - "mode:s", - "termtrans:b", - "degrade:b", - "bold:b", - "underline:b", - "italic:b", - "termcolors:i", - "contrast:s", - "visibility:s", - "diffmode:s" + /*0*/ "mode:s", + /*1*/ "termtrans:b", + /*2*/ "degrade:b", + /*3*/ "bold:b", + /*4*/ "underline:b", + /*5*/ "italic:b", + /*6*/ "termcolors:i", + /*7*/ "contrast:s", + /*8*/ "visibility:s", + /*9*/ "diffmode:s" }; string value; - int ch; + int optidx = 0, ch; - if ((ch = getopt(value, NULL, longoptions, args, "colorarized")) >= 0) { + if ((ch = getopt(value, NULL, longoptions, args, "solorarized")) >= 0) { do { + ++optidx; switch(ch) { case 0: solarized_mode = value; break; case 1: solarized_termtrans = atoi(value); break; @@ -952,6 +954,11 @@ colorscheme_solarized(~list args) } } while ((ch = getopt(value)) >= 0); } + + if (optidx < length_of_list(args)) { + error("solorarized: invalid option <" + args[optidx] + ">"); + return -1; + } } int dark; @@ -962,6 +969,7 @@ colorscheme_solarized(~list args) dark = (solarized_mode == "dark" ? 1 : 0); } solarized_colorscheme(dark); + return 0; } diff --git a/macsrc/colors/tomorrow.cr b/macsrc/colors/tomorrow.cr new file mode 100644 index 00000000..1cfa16cc --- /dev/null +++ b/macsrc/colors/tomorrow.cr @@ -0,0 +1,189 @@ +/* -*- mode: cr; indent-width: 8; -*- */ +/* $Id: tomorrow.cr,v 1.3 2024/08/04 11:42:44 cvsuser Exp $ + * Tomorrow coloriser, GriefEdit port - beta. + * + * Original: + * Name: Tomorrow.vim + * https://github.com/chriskempson + */ + +#include "../grief.h" +#include "rgbmap.h" + + +void +main(void) +{ + require("colors/rgbmap"); +} + + +static string +HI(string group, string fg, string bg, string at) +{ + extern int colordepth; + string val; + + val = "hi " + group; + if (fg != "") val += " guifg=#" + fg + " ctermfg=" + RGBMap(fg, colordepth); + if (bg != "") val += " guibg=#" + bg + " ctermbg=" + RGBMap(bg, colordepth); + if (at != "") val += " gui=" + at + " cterm=" + at; + return val; +} + + +void +colorscheme_tomorrow(void) +{ + const string scheme = "Tomorrow"; + + string foreground = "4d4d4c"; + string background = "fafafa"; + string selection = "d6d6d6"; + string line = "efefef"; + string comment = "8e908c"; + string red = "c82829"; + string orange = "f5871f"; + string yellow = "eab700"; + string green = "718c00"; + string aqua = "3e999f"; + string blue = "4271ae"; + string purple = "8959a8"; + string window = "efefef"; + + list colors[] = { + "set background=dark", + "hi clear", + "syntax reset" + }; + int colordepth; + + // Depth >= 88 + get_term_feature(TF_COLORDEPTH, colordepth); + if (colordepth < 88) { + error("%s: color depth not supported", scheme); + return; + } + + // Vim Highlighting + colors += HI("Normal", foreground, background, ""); + colors += "highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE"; + colors += HI("NonText", selection, "", ""); + colors += HI("SpecialKey", selection, "", ""); + colors += HI("Search", foreground, yellow, ""); + colors += HI("TabLine", foreground, background, "reverse"); + colors += HI("StatusLine", window, yellow, "reverse"); + colors += HI("StatusLineNC", window, foreground, "reverse"); + colors += HI("VertSplit", window, window, "none"); + colors += HI("Visual", "", selection, ""); + colors += HI("Directory", blue, "", ""); + colors += HI("ModeMsg", green, "", ""); + colors += HI("MoreMsg", green, "", ""); + colors += HI("Question", green, "", ""); + colors += HI("WarningMsg", red, "", ""); + colors += HI("MatchParen", "", selection, ""); + colors += HI("Folded", comment, background, ""); + colors += HI("FoldColumn", comment, background, ""); +// if version >= 700 + colors += HI("CursorLine", "", line, "none"); + colors += HI("CursorColumn", "", line, "none"); + colors += HI("PMenu", foreground, selection, "none"); + colors += HI("PMenuSel", foreground, selection, "reverse"); + colors += HI("SignColumn", "", background, "none"); +// end +// if version >= 703 + colors += HI("ColorColumn", "", line, "none"); +// end + + // Standard Highlighting + colors += HI("Comment", comment, "", ""); + colors += HI("Todo", comment, background, ""); + colors += HI("Title", comment, "", ""); + colors += HI("Identifier", red, "", "none"); + colors += HI("Statement", foreground, "", ""); + colors += HI("Conditional", foreground, "", ""); + colors += HI("Repeat", foreground, "", ""); + colors += HI("Structure", purple, "", ""); + colors += HI("Function", blue, "", ""); + colors += HI("Constant", orange, "", ""); + colors += HI("String", green, "", ""); + colors += HI("Special", foreground, "", ""); + colors += HI("PreProc", purple, "", ""); + colors += HI("Operator", aqua, "", "none"); + colors += HI("Type", blue, "", "none"); + colors += HI("Define", purple, "", "none"); + colors += HI("Include", blue, "", ""); + //colors += HI("Ignore", "666666", "", ""); + + // Vim Highlighting + colors += HI("vimCommand", red, "", "none"); + + // C Highlighting + colors += HI("cType", yellow, "", ""); + colors += HI("cStorageClass", purple, "", ""); + colors += HI("cConditional", purple, "", ""); + colors += HI("cRepeat", purple, "", ""); + + // PHP Highlighting + colors += HI("phpVarSelector", red, "", ""); + colors += HI("phpKeyword", purple, "", ""); + colors += HI("phpRepeat", purple, "", ""); + colors += HI("phpConditional", purple, "", ""); + colors += HI("phpStatement", purple, "", ""); + colors += HI("phpMemberSelector", foreground, "", ""); + + // Ruby Highlighting + colors += HI("rubySymbol", green, "", ""); + colors += HI("rubyConstant", yellow, "", ""); + colors += HI("rubyAttribute", blue, "", ""); + colors += HI("rubyInclude", blue, "", ""); + colors += HI("rubyLocalVariableOrMethod", orange, "", ""); + colors += HI("rubyCurlyBlock", orange, "", ""); + colors += HI("rubyStringDelimiter", green, "", ""); + colors += HI("rubyInterpolationDelimiter", orange, "", ""); + colors += HI("rubyConditional", purple, "", ""); + colors += HI("rubyRepeat", purple, "", ""); + + // Python Highlighting + colors += HI("pythonInclude", purple, "", ""); + colors += HI("pythonStatement", purple, "", ""); + colors += HI("pythonConditional", purple, "", ""); + colors += HI("pythonRepeat", purple, "", ""); + colors += HI("pythonException", purple, "", ""); + colors += HI("pythonFunction", blue, "", ""); + + // Go Highlighting + colors += HI("goStatement", purple, "", ""); + colors += HI("goConditional", purple, "", ""); + colors += HI("goRepeat", purple, "", ""); + colors += HI("goException", purple, "", ""); + colors += HI("goDeclaration", blue, "", ""); + colors += HI("goConstants", yellow, "", ""); + colors += HI("goBuiltins", orange, "", ""); + + // CoffeeScript Highlighting + colors += HI("coffeeKeyword", purple, "", ""); + colors += HI("coffeeConditional", purple, "", ""); + + // JavaScript Highlighting + colors += HI("javaScriptBraces", foreground, "", ""); + colors += HI("javaScriptFunction", purple, "", ""); + colors += HI("javaScriptConditional", purple, "", ""); + colors += HI("javaScriptRepeat", purple, "", ""); + colors += HI("javaScriptNumber", orange, "", ""); + colors += HI("javaScriptMember", orange, "", ""); + + // HTML Highlighting + colors += HI("htmlTag", red, "", ""); + colors += HI("htmlTagName", red, "", ""); + colors += HI("htmlArg", red, "", ""); + colors += HI("htmlScriptTag", red, "", ""); + + // Diff Highlighting + colors += HI("diffAdded", green, "", ""); + colors += HI("diffRemoved", red, "", ""); + + vim_colorscheme(scheme, 0, NULL, colors, -1); +} + +//end diff --git a/macsrc/colors/tomorrow_night.cr b/macsrc/colors/tomorrow_night.cr index 0ae17fb7..892634bd 100644 --- a/macsrc/colors/tomorrow_night.cr +++ b/macsrc/colors/tomorrow_night.cr @@ -1,10 +1,10 @@ -/* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: tomorrow_night.cr,v 1.2 2014/11/25 04:44:50 ayoung Exp $ - * Tomorrow_Night coloriser, GRIEF port. +/* -*- mode: cr; indent-width: 8; -*- */ +/* $Id: tomorrow_night.cr,v 1.4 2024/08/04 11:42:44 cvsuser Exp $ + * Tomorrow_Night coloriser, GriefEdit port. * * Original: * Name: Tomorrow_Night.vim - * Maintainer: http://chriskempson.com + * https://github.com/chriskempson */ #include "../grief.h" @@ -32,9 +32,11 @@ HI(string group, string fg, string bg, string at) } -void +int colorscheme_tomorrow_night(void) { + const string scheme = "Tomorrow-Night"; + string foreground = "c5c8c6"; string background = "1d1f21"; string selection = "373b41"; @@ -48,7 +50,7 @@ colorscheme_tomorrow_night(void) string blue = "81a2be"; string purple = "b294bb"; string window = "4d5057"; - list colors[] = { + list colors[] = { "set background=dark", "hi clear" }; @@ -57,8 +59,8 @@ colorscheme_tomorrow_night(void) // Depth >= 88 get_term_feature(TF_COLORDEPTH, colordepth); if (colordepth < 88) { - error("Tomorrow-Night, color depth not supported"); - return; + error("%s: color depth not supported", scheme); + return -1; } if (colordepth <= 256) { background = "303030"; @@ -93,8 +95,18 @@ colorscheme_tomorrow_night(void) colors += HI("PMenuSel", foreground, selection, "reverse"); colors += HI("SignColumn", "", background, "none"); colors += HI("ColorColumn", "", line, "none"); +// if version >= 700 + colors += HI("CursorLine", "", line, "none"); + colors += HI("CursorColumn", "", line, "none"); + colors += HI("PMenu", foreground, selection, "none"); + colors += HI("PMenuSel", foreground, selection, "reverse"); + colors += HI("SignColumn", "", background, "none"); +// end +// if version >= 703 + colors += HI("ColorColumn", "", line, "none"); +// end - // Standard Highlighting + // Standard Highlighting colors += HI("Comment", comment, "", ""); colors += HI("Todo", comment, background, ""); colors += HI("Title", comment, "", ""); @@ -112,17 +124,18 @@ colorscheme_tomorrow_night(void) colors += HI("Type", blue, "", "none"); colors += HI("Define", purple, "", "none"); colors += HI("Include", blue, "", ""); + // colors += HI("Ignore", "666666", "", ""); - // Vim Highlighting + // Vim Highlighting colors += HI("vimCommand", red, "", "none"); - // C Highlighting + // C Highlighting colors += HI("cType", yellow, "", ""); colors += HI("cStorageClass", purple, "", ""); colors += HI("cConditional", purple, "", ""); colors += HI("cRepeat", purple, "", ""); - // PHP Highlighting + // PHP Highlighting colors += HI("phpVarSelector", red, "", ""); colors += HI("phpKeyword", purple, "", ""); colors += HI("phpRepeat", purple, "", ""); @@ -130,7 +143,7 @@ colorscheme_tomorrow_night(void) colors += HI("phpStatement", purple, "", ""); colors += HI("phpMemberSelector", foreground, "", ""); - // Ruby Highlighting + // Ruby Highlighting colors += HI("rubySymbol", green, "", ""); colors += HI("rubyConstant", yellow, "", ""); colors += HI("rubyAccess", yellow, "", ""); @@ -145,7 +158,7 @@ colorscheme_tomorrow_night(void) colors += HI("rubyControl", purple, "", ""); colors += HI("rubyException", purple, "", ""); - // Python Highlighting + // Python Highlighting colors += HI("pythonInclude", purple, "", ""); colors += HI("pythonStatement", purple, "", ""); colors += HI("pythonConditional", purple, "", ""); @@ -156,7 +169,11 @@ colorscheme_tomorrow_night(void) colors += HI("pythonRepeat", aqua, "", ""); colors += HI("pythonExClass", orange, "", ""); - // JavaScript Highlighting + // CoffeeScript Highlighting + colors += HI("coffeeKeyword", purple, "", ""); + colors += HI("coffeeConditional", purple, "", ""); + + // JavaScript Highlighting colors += HI("javaScriptBraces", foreground, "", ""); colors += HI("javaScriptFunction", purple, "", ""); colors += HI("javaScriptConditional", purple, "", ""); @@ -167,27 +184,32 @@ colorscheme_tomorrow_night(void) colors += HI("javascriptGlobal", blue, "", ""); colors += HI("javascriptStatement", red, "", ""); - // HTML Highlighting + // HTML Highlighting colors += HI("htmlTag", red, "", ""); colors += HI("htmlTagName", red, "", ""); colors += HI("htmlArg", red, "", ""); colors += HI("htmlScriptTag", red, "", ""); - // Diff Highlighting + // Diff Highlighting + string diffbackground = "494e56"; colors += HI("diffAdded", green, "", ""); colors += HI("diffRemoved", red, "", ""); + colors += HI("DiffAdd", green, diffbackground, ""); + colors += HI("DiffDelete", red, diffbackground, ""); + colors += HI("DiffChange", yellow, diffbackground, ""); + colors += HI("DiffText", diffbackground, orange, ""); - // ShowMarks Highlighting + // ShowMarks Highlighting colors += HI("ShowMarksHLl", orange, background, "none"); colors += HI("ShowMarksHLo", purple, background, "none"); colors += HI("ShowMarksHLu", yellow, background, "none"); colors += HI("ShowMarksHLm", aqua, background, "none"); - // Cucumber Highlighting + // Cucumber Highlighting colors += HI("cucumberGiven", blue, "", ""); colors += HI("cucumberGivenAnd", blue, "", ""); - // Go Highlighting + // Go Highlighting colors += HI("goDirective", purple, "", ""); colors += HI("goDeclaration", purple, "", ""); colors += HI("goStatement", purple, "", ""); @@ -197,7 +219,7 @@ colorscheme_tomorrow_night(void) colors += HI("goDeclType", blue, "", ""); colors += HI("goBuiltins", purple, "", ""); - // Lua Highlighting + // Lua Highlighting colors += HI("luaStatement", purple, "", ""); colors += HI("luaRepeat", purple, "", ""); colors += HI("luaCondStart", purple, "", ""); @@ -205,7 +227,7 @@ colorscheme_tomorrow_night(void) colors += HI("luaCond", purple, "", ""); colors += HI("luaCondEnd", purple, "", ""); - // Clojure highlighting + // Clojure highlighting colors += HI("clojureConstant", orange, "", ""); colors += HI("clojureBoolean", orange, "", ""); colors += HI("clojureCharacter", orange, "", ""); @@ -230,7 +252,7 @@ colorscheme_tomorrow_night(void) colors += HI("clojureRepeat", blue, "", ""); colors += HI("clojureDispatch", blue, "", ""); - // Scala highlighting + // Scala highlighting colors += HI("scalaKeyword", purple, "", ""); colors += HI("scalaKeywordModifier", purple, "", ""); colors += HI("scalaOperator", blue, "", ""); @@ -274,7 +296,8 @@ colorscheme_tomorrow_night(void) colors += HI("scalaConstructorSpecializer", yellow, "", ""); colors += HI("scalaBackTick", blue, "", ""); - vim_colorscheme("Tomorrow-Night", 0, NULL, colors, -1); + vim_colorscheme(scheme, 0, NULL, colors, -1); + return 0; } -/*end*/ +/*end*/ diff --git a/macsrc/colors/wombat.cr b/macsrc/colors/wombat.cr index baa6ad68..1d32df67 100644 --- a/macsrc/colors/wombat.cr +++ b/macsrc/colors/wombat.cr @@ -1,11 +1,12 @@ /* -*- mode: cr; indent-width: 8; -*- */ -/* $Id: wombat.cr,v 1.2 2014/11/24 04:11:15 ayoung Exp $ - * wombat coloriser, GRIEF port. +/* $Id: wombat.cr,v 1.4 2024/08/04 11:42:44 cvsuser Exp $ + * wombat coloriser, GriefEdit port. * * Original: * Name: wombat256.vim * Original Maintainer: Lars H. Nielsen (dengmao@gmail.com) - * Last Change: 2010-07-23 + * Last Change: 2010-07-23 + * * Converting for 256-color terminals by * Danila Bespalov (danila.bespalov@gmail.com) * with great help of tool by Wolfgang Frisch (xororand@frexx.de) @@ -19,41 +20,41 @@ wombat_colors[] = { "set background=dark", "hi clear", - // " General colors - "hi Normal ctermfg=254 ctermbg=234 cterm=none guifg=#f6f3e8 guibg=#242424 gui=none", - "hi Cursor ctermfg=none ctermbg=241 cterm=none guifg=NONE guibg=#656565 gui=none", - "hi Visual ctermfg=7 ctermbg=238 cterm=none guifg=#f6f3e8 guibg=#444444 gui=none", - // " hi VisualNOS - // " hi Search - "hi Folded ctermfg=103 ctermbg=238 cterm=none guifg=#a0a8b0 guibg=#384048 gui=none", - "hi Title ctermfg=7 ctermbg=none cterm=bold guifg=#f6f3e8 guibg=NONE gui=bold", - "hi StatusLine ctermfg=7 ctermbg=238 cterm=none guifg=#f6f3e8 guibg=#444444 gui=italic", - "hi VertSplit ctermfg=238 ctermbg=238 cterm=none guifg=#444444 guibg=#444444 gui=none", - "hi StatusLineNC ctermfg=243 ctermbg=238 cterm=none guifg=#857b6f guibg=#444444 gui=none", - "hi LineNr ctermfg=243 ctermbg=0 cterm=none guifg=#857b6f guibg=#000000 gui=none", - "hi SpecialKey ctermfg=244 ctermbg=236 cterm=none guifg=#808080 guibg=#343434 gui=none", - "hi NonText ctermfg=244 ctermbg=236 cterm=none guifg=#808080 guibg=#303030 gui=none", + // General colors + "hi Normal ctermfg=254 ctermbg=234 cterm=none guifg=#f6f3e8 guibg=#242424 gui=none", + "hi Cursor ctermfg=none ctermbg=241 cterm=none guifg=NONE guibg=#656565 gui=none", + "hi Visual ctermfg=7 ctermbg=238 cterm=none guifg=#f6f3e8 guibg=#444444 gui=none", + // hi VisualNOS + // hi Search + "hi Folded ctermfg=103 ctermbg=238 cterm=none guifg=#a0a8b0 guibg=#384048 gui=none", + "hi Title ctermfg=7 ctermbg=none cterm=bold guifg=#f6f3e8 guibg=NONE gui=bold", + "hi StatusLine ctermfg=7 ctermbg=238 cterm=none guifg=#f6f3e8 guibg=#444444 gui=italic", + "hi VertSplit ctermfg=238 ctermbg=238 cterm=none guifg=#444444 guibg=#444444 gui=none", + "hi StatusLineNC ctermfg=243 ctermbg=238 cterm=none guifg=#857b6f guibg=#444444 gui=none", + "hi LineNr ctermfg=243 ctermbg=0 cterm=none guifg=#857b6f guibg=#000000 gui=none", + "hi SpecialKey ctermfg=244 ctermbg=236 cterm=none guifg=#808080 guibg=#343434 gui=none", + "hi NonText ctermfg=244 ctermbg=236 cterm=none guifg=#808080 guibg=#303030 gui=none", - "hi CursorLine ctermbg=236 cterm=none guibg=#2d2d2d", - "hi MatchParen ctermfg=7 ctermbg=243 cterm=bold guifg=#f6f3e8 guibg=#857b6f gui=bold", - "hi Pmenu ctermfg=7 ctermbg=238 guifg=#f6f3e8 guibg=#444444", - "hi PmenuSel ctermfg=0 ctermbg=192 guifg=#000000 guibg=#cae682", + "hi CursorLine ctermbg=236 cterm=none guibg=#2d2d2d", + "hi MatchParen ctermfg=7 ctermbg=243 cterm=bold guifg=#f6f3e8 guibg=#857b6f gui=bold", + "hi Pmenu ctermfg=7 ctermbg=238 guifg=#f6f3e8 guibg=#444444", + "hi PmenuSel ctermfg=0 ctermbg=192 guifg=#000000 guibg=#cae682", - // " Syntax highlighting - "hi Keyword ctermfg=111 cterm=none guifg=#8ac6f2 gui=none", - "hi Statement ctermfg=111 cterm=none guifg=#8ac6f2 gui=none", - "hi Constant ctermfg=173 cterm=none guifg=#e5786d gui=none", - "hi Number ctermfg=173 cterm=none guifg=#e5786d gui=none", - "hi PreProc ctermfg=173 cterm=none guifg=#e5786d gui=none", - "hi Function ctermfg=192 cterm=none guifg=#cae682 gui=none", - "hi Identifier ctermfg=192 cterm=none guifg=#cae682 gui=none", - "hi Type ctermfg=192 cterm=none guifg=#cae682 gui=none", - "hi Special ctermfg=194 cterm=none guifg=#e7f6da gui=none", - "hi String ctermfg=113 cterm=none guifg=#95e454 gui=italic", - "hi Comment ctermfg=246 cterm=none guifg=#99968b gui=italic", - "hi Todo ctermfg=245 cterm=none guifg=#8f8f8f gui=italic", + // Syntax highlighting + "hi Keyword ctermfg=111 cterm=none guifg=#8ac6f2 gui=none", + "hi Statement ctermfg=111 cterm=none guifg=#8ac6f2 gui=none", + "hi Constant ctermfg=173 cterm=none guifg=#e5786d gui=none", + "hi Number ctermfg=173 cterm=none guifg=#e5786d gui=none", + "hi PreProc ctermfg=173 cterm=none guifg=#e5786d gui=none", + "hi Function ctermfg=192 cterm=none guifg=#cae682 gui=none", + "hi Identifier ctermfg=192 cterm=none guifg=#cae682 gui=none", + "hi Type ctermfg=192 cterm=none guifg=#cae682 gui=none", + "hi Special ctermfg=194 cterm=none guifg=#e7f6da gui=none", + "hi String ctermfg=113 cterm=none guifg=#95e454 gui=italic", + "hi Comment ctermfg=246 cterm=none guifg=#99968b gui=italic", + "hi Todo ctermfg=245 cterm=none guifg=#8f8f8f gui=italic", - // " Links + // Links "hi link FoldColumn Folded", "hi link CursorColumn CursorLine" }; @@ -64,5 +65,3 @@ colorscheme_wombat(void) vim_colorscheme("wombat", 256, NULL, wombat_colors, -1); } /*end*/ - - diff --git a/macsrc/colors/zenburn.cr b/macsrc/colors/zenburn.cr index 791069c5..b00747a8 100644 --- a/macsrc/colors/zenburn.cr +++ b/macsrc/colors/zenburn.cr @@ -1,10 +1,10 @@ /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: zenburn.cr,v 1.7 2022/08/10 15:44:58 cvsuser Exp $ - * zenburn coloriser, GRIEF port. - * - * Original author Jani Numinen in 2002 - * see http://slinky.imukuppi.org/zenburnpage +/* $Id: zenburn.cr,v 1.12 2024/09/15 13:51:00 cvsuser Exp $ + * zenburn coloriser, GriefEdit port. * + * References: + * https://en.wikipedia.org/wiki/Wikipedia:Zenburn + * https://kippura.org/zenburnpage/ * */ @@ -13,124 +13,249 @@ static list zenburn_spec[] = { - //[0] |[1] |[2] |[3] | || |[4] |[5] |[6] | - //|Highlight group | CTFG | CTBG | CTAttributes | || | GUIFG | GUIBG | GUIAttributes | - //|---------------------------------|-------|-------|-----------------| || |---------|----------|-----------------| - - { "Boolean", 181, NULL, NULL }, - { "Character", 181, NULL, "bold" }, - { "Comment", 108, NULL, NULL }, - { "Conditional", 223, NULL, "bold" }, - { "Constant", 181, NULL, "bold" }, - { "Cursor", 233, 109, "bold" }, - { "Debug", 181, NULL, "bold" }, - { "Define", 223, NULL, "bold" }, - { "Delimiter", 245, NULL, NULL }, - { "DiffAdd", 66, 237, "bold" }, - { "DiffChange", 236, NULL, NULL }, - { "DiffDelete", 236, 238, NULL }, - { "DiffText", 217, 237, "bold" }, - { "Directory", 109, NULL, "bold" }, - { "ErrorMsg", 115, 236, "bold" }, - { "Exception", 249, NULL, "bold" }, - { "Float", 251, NULL, NULL }, - { "Function", 228, NULL, NULL }, - { "Identifier", 223, NULL, NULL }, - { "IncSearch", 228, 238, NULL }, - { "Keyword", 223, NULL, "bold" }, - { "Label", 187, NULL, "underline" }, - { "LineNr", 248, 233, NULL }, - { "Macro", 223, NULL, "bold" }, - { "ModeMsg", 223, NULL, "none" }, - { "MoreMsg", 15, NULL, "bold" }, - { "Number", 116, NULL, NULL }, - { "Operator", 230, NULL, NULL }, - { "PreCondit", 180, NULL, "bold" }, - { "PreProc", 223, NULL, "bold" }, - { "Question", 15, NULL, "bold" }, - { "Repeat", 223, NULL, "bold" }, - { "Search", 230, 236, NULL }, - { "SpecialChar", 181, NULL, "bold" }, - { "SpecialComment", 181, NULL, "bold" }, - { "Special", 181, NULL, NULL }, - { "SpecialKey", 151, NULL, NULL }, - { "Statement", 187, 234, "none" }, - { "StatusLine", 236, 186, NULL }, - { "StatusLineNC", 235, 108, NULL }, - { "StorageClass", 249, NULL, "bold" }, - { "String", 174, NULL, NULL }, - { "Structure", 229, NULL, "bold" }, - { "Tag", 181, NULL, "bold" }, - { "Title", 7, 234, "bold" }, - { "Todo", 108, 234, "bold" }, - { "Typedef", 253, NULL, "bold" }, - { "Type", 187, NULL, "bold" }, - { "Underlined", 188, 234, "bold" }, - { "VertSplit", 236, 65, NULL }, - { "VisualNOS", 236, 210, "bold" }, - { "WarningMsg", 15, 236, "bold" }, - { "WildMenu", 236, 194, "bold" }, -// { "SpellBad", 9, 237, NULL }, -// { "SpellCap", 12, 237, NULL }, -// { "SpellLocal", 14, 237, NULL }, -// { "SpellRare", 13, 237, NULL }, - { "Spell", 108, NULL, "underline" }, - - { "PMenu", 248, 0, NULL }, - { "PMenuSel", 223, 235, NULL }, - -// { "TabLine", 187, 235, "none" }, -// { "TabLineSel", 229, 236, "bold" }, -// { "TabLineFill", 188, 233, "none" }, - - { "HTMLLink", 181, NULL, "underline" }, - - { "Error", 167, 236, "bold" }, -// { "Include", -// { "Label", }, -// { "Ignore", }, - - // Tag support -// { NULL, "Class", "Function", NULL }, -// { NULL, "Import", "PythonInclude", NULL }, -// { NULL, "Member", "Function", NULL }, -// { NULL, "GlobalVariable", "Normal", NULL }, -// { NULL, "GlobalConstant", "Constant", NULL }, -// { NULL, "EnumerationValue", "Float", NULL }, -// { NULL, "EnumerationName", "Identifier", NULL }, -// { NULL, "DefinedName", "WarningMsg", NULL }, -// { NULL, "LocalVariable", "WarningMsg", NULL }, -// { NULL, "Structure", "WarningMsg", NULL }, -// { NULL, "Union", "WarningMsg", NULL } + //[0] |[1] |[2] |[3] |[4] |[5] |[6] |[7] |[8] | + //Mode |Highlight group | CTFG | CTBG | CTAttributes | GUIFG | GUIBG | GUIAttributes |GUISubscript | + //------|-------------------------------|-------|-------|-------------------|-----------|-----------|-------------------|---------------| + + // High contrast + + { 2|4, "Normal", 188, 234, NULL, "#dcdccc", "#1f1f1f", NULL, NULL }, + { 2, "NonText", 238, NULL, NULL, "#404040", NULL, "bold", NULL }, + { 2, "CursorLine", NULL, 233, NULL, NULL, "#121212", "bold", NULL }, + { 2, "CursorColumn", NULL, 235, NULL, NULL, "#2b2b2b", NULL, NULL }, + { 2, "LineNr", 248, 233, NULL, "#9fafaf", "#161616", NULL, NULL }, + { 2, "Visual", 236, 210, "bold", "#333333", "#0f0f0f", "bold,underline", NULL }, + { 2, "VisualNOS", 236, 210, "bold", "#333333", "#0f0f0f", "bold,underline", NULL }, + + // Normal contrast + + { 1|4, "Normal", 188, 237, NULL, "#dcdccc", "#3f3f3f", NULL, NULL }, + { 1, "NonText", 240, NULL, NULL, "#5b605e", NULL, "bold", NULL }, + { 1, "CursorLine", NULL, 238, NULL, NULL, "#434443", NULL, NULL }, + { 1, "CursorColumn", NULL, 239, NULL, NULL, "#4f4f4f", NULL, NULL }, + { 1, "LineNr", 248, 233, NULL, "#9fafaf", "#262626", NULL, NULL }, + { 1, "Visual", 235, 210, "bold", "#333333", "#2f2f2f", "bold,underline", NULL }, + { 1, "VisualNOS", 235, 210, "bold", "#333333", "#2f2f2f", "bold,underline", NULL }, + + // Context-less + + { 0, "Boolean", 181, NULL, NULL, "#dca3a3", NULL, NULL, NULL }, + { 0, "Character", 181, NULL, "bold", "#dca3a3", NULL, "bold", NULL }, + { 0, "Comment", 108, NULL, NULL, "#7f9f7f", NULL, "italic", NULL }, + { 0, "Conditional", 223, NULL, "bold", "#f0dfaf", NULL, "bold", NULL }, + { 0, "Constant", 181, NULL, "bold", "#dca3a3", NULL, "bold", NULL }, + { 0, "Cursor", 233, 109, "bold", "#000d18", "#8faf9f", "bold", NULL }, + { 0, "Debug", 181, NULL, "bold", "#bca3a3", NULL, "bold", NULL }, + { 0, "Define", 223, NULL, "bold", "#ffcfaf", NULL, "bold", NULL }, + { 0, "Delimiter", 245, NULL, NULL, "#8f8f8f", NULL, NULL, NULL }, + { 0, "DiffAdd", 66, 237, "bold", "#709080", "#313c36", "bold", NULL }, + { 0, "DiffChange", NULL, 236, NULL, NULL, "#333333", NULL, NULL }, + { 0, "DiffDelete", 236, 238, NULL, "#333333", "#464646", NULL, NULL }, + { 0, "DiffText", 217, 237, "bold", "#ecbcbc", "#41363c", "bold", NULL }, + { 0, "Directory", 109, NULL, "bold", "#9fafaf", NULL, "bold", NULL }, + { 0, "ErrorMsg", 115, 236, "bold", "#80d4aa", "#2f2f2f", "bold", NULL }, + { 0, "Exception", 249, NULL, "bold", "#c3bf9f", NULL, "bold", NULL }, + { 0, "Float", 251, NULL, NULL, "#c0bed1", NULL, NULL, NULL }, + { 0, "FoldColumn", 109, 233, NULL, "#93b3a3", "#3f4040", NULL, NULL }, + { 0, "Folded", 109, 233, NULL, "#93b3a3", "#3f4040", NULL, NULL }, + { 0, "Function", 228, NULL, NULL, "#efef8f", NULL, NULL, NULL }, + { 0, "Identifier", 223, NULL, NULL, "#efdcbc", NULL, NULL, NULL }, + { 0, "IncSearch", 228, 238, NULL, "#385f38", "#f8f893", NULL, NULL }, + { 0, "Keyword", 223, NULL, "bold", "#f0dfaf", NULL, "bold", NULL }, + { 0, "Label", 187, NULL, "underline", "#dfcfaf", NULL, "underline", NULL }, + { 0, "Macro", 223, NULL, "bold", "#ffcfaf", NULL, "bold", NULL }, + { 0, "ModeMsg", 223, NULL, "none", "#ffcfaf", NULL, "none", NULL }, + { 0, "MoreMsg", 15, NULL, "bold", "#ffffff", NULL, "bold", NULL }, + { 0, "Number", 116, NULL, NULL, "#8cd0d3", NULL, NULL, NULL }, + { 0, "Operator", 230, NULL, NULL, "#f0efd0", NULL, NULL, NULL }, + { 0, "PreCondit", 180, NULL, "bold", "#dfaf8f", NULL, "bold", NULL }, + { 0, "PreProc", 223, NULL, "bold", "#ffcfaf", NULL, "bold", NULL }, + { 0, "Question", 15, NULL, "bold", "#ffffff", NULL, "bold", NULL }, + { 0, "Repeat", 223, NULL, "bold", "#ffd7a7", NULL, "bold", NULL }, + { 0, "Search", 230, 236, NULL, "#ffffe0", "#284f28", NULL, NULL }, + { 0, "Special", 181, NULL, NULL, "#cfbfaf", NULL, NULL, NULL }, + { 0, "SpecialChar", 181, NULL, "bold", "#dca3a3", NULL, "bold", NULL }, + { 0, "SpecialComment", 181, NULL, "bold", "#82a282", NULL, "bold", NULL }, + { 0, "SpecialKey", 151, NULL, NULL, "#9ece9e", NULL, NULL, NULL }, + { 0, "Spell", 108, NULL, "underline", "#dc8c6c", NULL, "underline", NULL }, + { 0, "SpellBad", 9, 237, NULL, "#dc8c6c", NULL, NULL, "#bc6c4c" }, + { 0, "SpellCap", 12, 237, NULL, "#8c8cbc", NULL, NULL, "#6c6c9c" }, + { 0, "SpellLocal", 14, 237, NULL, "#9ccc9c", NULL, NULL, "#7cac7c" }, + { 0, "SpellRare", 13, 237, NULL, "#bc8cbc", NULL, NULL, "#bc6c9c" }, + { 0, "Statement", 187, 234, "none", "#e3ceab", NULL, "none", NULL }, + { 0, "StatusLine", 236, 186, NULL, "#313633", "#ccdc90", NULL, NULL }, + { 0, "StatusLineNC", 235, 108, NULL, "#2e3330", "#88b090", NULL, NULL }, + { 0, "StorageClass", 249, NULL, "bold", "#c3bf9f", NULL, "bold", NULL }, + { 0, "String", 174, NULL, NULL, "#cc9393", NULL, NULL, NULL }, + { 0, "Structure", 229, NULL, "bold", "#efefaf", NULL, "bold", NULL }, + { 0, "Tag", 181, NULL, "bold", "#e89393", NULL, "bold", NULL }, + { 0, "Title", 7, 234, "bold", "#efefef", NULL, "bold", NULL }, + { 0, "Todo", 108, 234, "bold", "#dfdfdf", "bg", "bold", NULL }, + { 0, "Type", 187, NULL, "bold", "#dfdfbf", NULL, "bold", NULL }, + { 0, "Typedef", 253, NULL, "bold", "#dfe4cf", NULL, "bold", NULL }, + { 0, "Underlined", 188, 234, "bold", "#dcdccc", NULL, "underline", NULL }, + // { 0, "VertSplit", 236, 65, NULL, "#2e3330", "#688060", NULL, NULL }, + { 0, "Frame", /*GRIEF*/ 188, 237, NULL, "#2e3330", "#688060", NULL, NULL }, + + { 0, "WarningMsg", 15, 236, "bold", "#ffffff", "#333333", "bold", NULL }, + { 0, "WildMenu", 236, 194, "bold", "#cbecd0", "#2c302d", "underline", NULL }, + + { 0, "Error", 228, 95, "bold", "#e37170", "#3d3535", NULL, NULL }, + { 0, "HTMLLink", 181, NULL, "underline", NULL, NULL, NULL, NULL }, + + // High contrast + + // { 2, "Include", NULL, "#dfaf8f", NULL, "bold", NULL }, + // { 2, "Ignore", 238 NULL, "#545a4f", NULL, NULL, NULL }, + { 2, "PMenu", 248, 0, NULL, "#ccccbc", "#242424", NULL, NULL }, + { 2, "PMenuSel", 223, 235, NULL, "#ccdc90", "#353a37", "bold", NULL }, + // { 2, "PmenuSbar NULL, "#000000", "#2e3330", NULL, NULL }, + // { 2, "PMenuThumb NULL, "#040404", "#a0afa0", NULL, NULL }, + // { 2, "MatchParen NULL, "#f0f0c0", "#383838", "bold" NULL }, + // { 2, "SignColumn NULL, "#9fafaf", "#181818", "bold" NULL }, + { 2, "FoldColumn", 109, 233, NULL, "#161616", NULL, NULL, NULL }, + { 2, "Folded", 109, 233, NULL, "#161616", NULL, NULL, NULL }, + { 2, "TabLine", 108, 236, "none", "#88b090", "#313633", "none", NULL }, + { 2, "TabLineSel", 186, 235, "bold", "#ccd990", "#222222", NULL, NULL }, + { 2, "TabLineFill", 236, 236, NULL, "#88b090", "#313633", "none", NULL }, + { 2, "SpecialKey", 152, NULL, NULL, NULL, "#242424", NULL, NULL }, + + // Normal contrast + + // { 1, "Include", NULL, "#dfaf8f", NULL, "bold", NULL }, + // { 1, "Ignore", 240 NULL, "#545a4f", NULL, NULL, NULL }, + { 1, "PMenu", 248, 0, NULL, "#9f9f9f", "#2c2e2e", NULL, NULL }, + { 1, "PMenuSel", 223, 235, NULL, "#d0d0a0", "#242424", "bold", NULL }, + // { 1, "PmenuSbar NULL, "#000000", "#2e3330", NULL, NULL }, + // { 1, "PMenuThumb NULL, "#040404", "#a0afa0", NULL, NULL }, + // { 1, "MatchParen NULL, "#b2b2a0", "#2e2e2e", "bold", NULL }, + // { 1, "SignColumn NULL, "#9fafaf", "#343434", "bold", NULL }, + { 1, "FoldColumn", 109, 236, NULL, NULL, "#333333", NULL, NULL }, + { 1, "Folded", 109, 236, NULL, NULL, "#333333", NULL, NULL }, + { 1, "TabLine", 187, 235, "none", "#d0d0b8", "#222222", "none", NULL }, + { 1, "TabLineSel", 229, 236, "bold", "#f0f0b0", "#333333", "bold", NULL }, + { 1, "TabLineFill", 233, 233, NULL, "#dccdcc", "#101010", "none", NULL }, + { 1, "SpecialKey", 151, NULL, NULL, NULL, "#444444", NULL, NULL }, + + // Links + +//TODO +// { -1, NULL, "Class", "Function" }, +// { -1, NULL, "Import", "PythonInclude" }, +// { -1, NULL, "Member", "Function" }, +// { -1, NULL, "GlobalVariable", "Normal" }, +// { -1, NULL, "GlobalConstant", "Constant" }, +// { -1, NULL, "EnumerationValue", "Float" }, +// { -1, NULL, "EnumerationName", "Identifier" }, +// { -1, NULL, "DefinedName", "WarningMsg" }, +// { -1, NULL, "LocalVariable", "WarningMsg" }, +// { -1, NULL, "Structure", "WarningMsg" }, +// { -1, NULL, "Union", "WarningMsg" }, }; -void -colorscheme_zenburn(void) +int +colorscheme_zenburn(~list args) { + const string scheme = "zenburn"; + int contrast = 1; // normal=1, high=2 + int colordepth = -1; + int black = 0; + + // options + if (! is_null(args)) { + const list longoptions = { + /*0*/ "colors:n+", // color depth + /*1*/ "contrast:s", // "normal", "high" + /*2*/ "black_bg", // black background + }; + int optidx = 0, ch; + string value; + + if ((ch = getopt(value, NULL, longoptions, args, scheme)) >= 0) { + do { + ++optidx; + switch(ch) { + case 0: // colordepth + colordepth = atoi(value); + break; + case 1: // contrast=normal|high + if (value == "normal") { + contrast = 1; + } else if (value == "high") { + contrast = 2; + } else { + error("%s: invalid contrast <%s>", scheme, value); + return -1; + } + break; + case 2: // black_bg + black = 1; + break; + default: + error("%s: %s", scheme, value); + return -1; + } + } while ((ch = getopt(value)) >= 0); + } + + if (optidx < length_of_list(args)) { + if (args[optidx] == "show") { + message("%s: by %s, GriefEdit version", scheme, "Jonathan Filip"); + } else { + error("%s: unexpected option <%s>", scheme, args[optidx]); + } + return -1; + } + } + + if (colordepth <= 0) { + get_term_feature(TF_COLORDEPTH, colordepth); + } + if (colordepth < 256) { + error("%s: color depth not supported", scheme); + return -1; + } + + // build list zenburn_colors = { "set background=dark", - "hi clear" + "hi clear", + "syntax reset" }; list spec; while (list_each(zenburn_spec, spec) >= 0) { + const int mode = spec[0]; string val; - if (typeof(spec[1]) == "NULL") { - // links - val = "hi link " + spec[1] + " " + spec[2]; + if (mode == 0 || (mode & contrast)) { + // + // colors + // + val = "hi " + spec[1]; + if (typeof(spec[2]) != "NULL") val += format(" ctermfg=%d", spec[2]); + if (typeof(spec[3]) != "NULL") { + if (0 == (mode & 4) || 0 == black) { // black background + val += format(" ctermbg=%d", spec[3]); + } + } + if (typeof(spec[4]) != "NULL") val += format( " cterm=%s", spec[4]); + if (typeof(spec[5]) != "NULL") val += format( " guifg=%s", spec[5]); + if (typeof(spec[6]) != "NULL") { + if (0 == (mode & 4) || 0 == black) { // black background + val += format( " guibg=%s", spec[6]); + } + } + if (typeof(spec[7]) != "NULL") val += format( " gui=%s", spec[7]); + zenburn_colors += val; - } else { - // colors - val = "hi " + spec[0]; - if (typeof(spec[1]) != "NULL") val += format(" ctermfg=%d", spec[1]); - if (typeof(spec[2]) != "NULL") val += format(" ctermbg=%d", spec[2]); - if (typeof(spec[3]) != "NULL") val += format( " cterm=%s", spec[3]); -// if (typeof(spec[4]) != "NULL") val += format( " guifg=#%s", spec[4]); -// if (typeof(spec[5]) != "NULL") val += format( " guibg=#%s", spec[5]); -// if (typeof(spec[6]) != "NULL") val += format( " gui=%s", spec[6]); + } else if (mode == -1) { + // + // links + // + val = "hi link " + spec[1] + " " + spec[2]; + zenburn_colors += val; } - zenburn_colors += val; } vim_colorscheme("zenburn", 256, NULL, zenburn_colors, -1); diff --git a/macsrc/colorsvim.cr b/macsrc/colorsvim.cr new file mode 100644 index 00000000..cadaaeba --- /dev/null +++ b/macsrc/colorsvim.cr @@ -0,0 +1,973 @@ +/* -*- mode: cr; indent-width: 4; -*- */ +/* $Id: colorsvim.cr,v 1.5 2024/09/24 16:39:18 cvsuser Exp $ + * Enhanced colour/colorscheme support. + * + * + */ + +#include "grief.h" +#include "colorsvim.h" + +static void groupclear(string name); +static void syntaxreset(void); +static string attrmap(string attr); + +static list scheme_colors = { + // + // VIM to GRIEF attribute (where possible) + // + // default highlighting groups. + // + // Reference: https://vimhelp.org/syntax.txt.html#highlight-groups + // Online editor: https://sputnick.fr/scripts/vim-color.html + // + "=ColorColumn=", "ruler_column", // Used for the columns set with 'colorcolumn'. (ie. colorcolumn=80) + + "=Conceal=", "", // Place-holder characters substituted for concealed text. + + "=Cursor=", "cursor", // Character under the cursor. + "=lCursor=", "", // Character under the cursor when language-mapping is used. + "=CursorIM=", "", // Like Cursor, but used when in IME mode. + "=CursorColumn=", "cursor_col", // Screen column that the cursor is in when 'cursorcolumn' is set. + "=CursorLine=", "cursor_row", // Screen line that the cursor is in when 'cursorline' is set. + + "=Directory=", "lsdirectory", // Directory names (and other special names in listings). + + "=DiffAdd=", "additional", // Diff: added line. + "=DiffChange=", "modified", // Diff: changed line. + "=DiffDelete=", "diffdelete", // Diff: deleted line. + "=DiffText=", "difftext", // Diff: changed text within a changed line. + + "=ModeMsg=", "", // 'showmode' message. + "=MoreMsg=", "message", // |more-prompt|. + "=WarningMsg=", "", // warning messages. + "=ErrorMsg=", "error", // error messages on the command line. + + "=MessageWindow=", "", // Messages popup window. + + "=VertSplit=", "frame", // the column separating vertically split windows. + + "=Folded=", "", // Fold: line used for closed folds. + "=FoldColumn=", "", // Fold: column. + "=CursorLineFold=", "", // Fole: like FoldColumn when 'cursorline' is set for the cursor line. + + "=SignColumn=", "column_status", // column where *signs* are displayed. + "=CursorLineSign=", "", // Like SignColumn when 'cursorline' is set for the cursor line. + "=LineNr=", "column_lineno", // Line number. + "=LineNrAbove=", "", // Line number for when the 'relativenumber' option is set, above the cursor line. + "=LineNrBelow", "", // Line number for when the 'relativenumber' option is set, below the cursor line. + + "=IncSearch=", "search_inc", // 'incsearch' highlighting; also used for the text replaced with. + "=MatchParen=", "search_match", // a paired character (matching parenthesis). + + "=EndOfBuffer=", "", // Filler lines (~) after the last line in the buffer. + "=NonText=", "nonbuffer", // '~' and '@' at the end of the window. + + "=Normal=", "normal", // normal text. + + "=Pmenu=", "popup_normal", // Popup: normal item. + "=PmenuKind=", "", // Popup: Normal item "kind". + "=PmenuKindSel=", "", // Popup: Selected item "kind". + "=PmenuExtra=", "", // Popup: Normal item "extra text". + "=PmenuExtraSel=", "", // Popup: selected item "extra text". + "=PmenuSel=", "popup_hilite", // Popup: elected item. + "=PmenuSbar=", "scrollbar", // Popup: scrollbar. + "=PmenuThumb=", "scrollbar_thumb", // Popup: thumb of the scrollbar. + "=PmenuMatch=", "", // Popup: Matched text in normal item. + "=PmenuMatchSel=", "", // Popup: Matched text in selected item. + + "=PopupNotification=", "", // Popup window created with popup_notification(). + + "=QuickFixLine=", "", // Current quickfix item in the quickfix window. + + "=Question=", "prompt", // prompt and yes/no questions. + + "=Search=", "search", // Last search pattern highlighting. + "=CurSearch=", "", // Current match for the last search pattern. + + "=SpecialKey=", "", // Meta and special keys listed with ":map", also unprintable characters. + + "=Todo=", "todo", // Anything that needs extra attention; mostly the keywords TODO FIXME and XXX. + + "=SpellBad=", "spell", // Spell: recognized word. + "=SpellCap=", "", // Spell: word that should start with a capital. + "=SpellLocal=", "", // Spell: recognized word as one that is used in another region. + "=SpellRare=", "", // Spell: recognized word as one that is hardly ever used. + "=Spell=", "spell", + + "=StatusLine=", "echo_line", // Status line of current window. + "=StatusLineNC=", "", // Status lines of not-current windows. + "=StatusLineTerm=", "", // Status line of current window, if it is a terminal window. + "=StatusLineTermNC=", "", // Status lines of not-current windows that is a terminal window. + + "=Terminal=", "", // Terminal window (see terminal-size-color). + + "=TabLine=", "", // tab pages line, not active tab page label. + "=TabLineFill=", "", // tab pages line, where there are no labels. + "=TabLineSel=", "", // tab pages line, active tab page label. + + "=Title=", "select", // titles for output from ":set all", ":autocmd" etc. + + "=Visual=", "hilite", // visual mode selection. + "=VisualNOS=", "", // visual mode selection when vim is "Not Owning the Selection". + + "=WildMenu=", "prompt_complete", // current match in 'wildmenu' completion. + + // syntax groups/ + // naming conventions. + // + "=Comment=", "comment", // any comment. + + "=Constant=", "constant", // any constant. + "=String=", "string", // a string constant: "this is a string" + "=Character=", "character", // a character constant: 'c', '\n' + "=Number=", "number", // a number constant: 123, 012, 0x12 + "=Boolean=", "boolean", // a boolean constant: TRUE, false + "=Float=", "float", // a floating constant: 2.3e10 + + // TODO ==> identifier + "=Identifier=", "keyword_definition", // any variable name. + "=Function=", "keyword_function", // function name (also: methods for classes). + + "=PreProc=", "preprocessor", // preprocessor. + "=Include=", "preprocessor_include", // preprocessor #include + "=Define=", "preprocessor_define", // preprocessor #define + "=Macro=", "preprocessor_keyword", // same as Define + "=PreCondit=", "preprocessor_conditional", // preprocessor #if, #else, #endif, etc. + + "=Statement=", "code", // any statement. + "=Conditional=", "keyword_conditional", // if, then, else, endif, switch, etc. + "=Repeat=", "keyword_repeat", // for, do, while, etc. + "=Label=", "keyword_label", // case, default, etc. + "=Operator=", "operator", // operators [non-standard] + "=Keyword=", "keyword", // any other keyword + "=Exception=", "keyword_exception", // try, catch, throw + + "=Type=", "keyword_type", // int, long, char, etc. + "=StorageClass=", "keyword_storageclass", // static, register, volatile, etc. + "=Structure=", "keyword_structure", // struct, union, enum, etc. + "=Typedef=", "keyword_typedef", // Atypedef. + + "=Special=", "standout", // any special symbol. + "=SpecialChar=", "constant_standout", // special character in a constant. + "=Tag=", "tag", // you can use CTRL-] on this. + "=Delimiter=", "delimiter", // character that needs attention. + "=SpecialComment=", "comment_standout", // special things inside a comment. + "=Debug=", "keyword_debug", // debugging statements. + + "=Underlined=", "link", // text that stands out. + + "=Ignore=", "", // left blank, hidden. + + "=Error=", "alert", // any erroneous construct. + + // misc/ + // + "=Tab=", "whitespace", + "=Space=", "", + }; + + +/* Function: vim_colorscript + * Load a VIM style colorscheme. + * + * This interface is simple and requires a strict structure yet follows many of the + * basic colour schemas reviewed. + * + * See blackdust for an example schema. + * + * The latest top 100 VIM color schemes are www.vim.org are available as a single + * package "Color Scheme Pack", which generally fit the required structure for a + * successful import. + * + * In additional are a number of sites which demo the colorschemes, to name a few. + * + * http://www.vi-improved.org/color_sampler_pack/ + * http://vimcolorschemetest.googlecode.com/svn/html/index-c.html + * + * Color-Scheme editor + * + * http://bytefluent.com/vivify/ + * + * Parameters: + * scheme - Scheme name. + * base - "light" or "dark". + * flags - Color flags. + * file - Scheme source script. + * + * Returns: + * nothing + */ + +static int condition(list parts); + +void +vim_colorscript(string scheme, string base, int flags, string file) +{ + int buf, curbuf = inq_buffer(); + + // + // Load vim-script. + // + message("loading: %s", file); + if ((buf = create_buffer("-colorscheme-vim-", file, TRUE)) < 0) { + return; + } + + // + // Parse conditional blocks/comments. + // + // best effort load logic, with weak condition expression evaluation (TODO/FIXME). + // + int colordepth, iflevel = -1, ifactive = 1; + list ifstack, spec; + string ln; + + get_term_feature(TF_COLORDEPTH, colordepth); + if (SCHEME_GUIONLY & flags) { + if (colordepth < 256) { + message("%s: GUI color depth not available", scheme); + return; + } + + } else if (SCHEME_CTERMONLY & flags) { + if (colordepth > 256) { + colordepth = 256; // limit + } + } + + if (base) { // dark or light base + base = lower(base); + } else { + int isdark; + get_term_feature(TF_SCHEMEDARK, isdark); + base = (isdark ? "dark" : "light"); + } + + set_buffer(buf); + top_of_buffer(); + do { + ln = compress(read(), TRUE); // line, compress white-space and trimmed. + + // comments + if ('"' == characterat(ln, 1)) { + continue; + } + + // set or let and conditionals + if (re_search(0, "^{if}|{else}|{endif}", ln) > 0) { + const list parts = + tokenize(ln, " ", TOK_DOUBLE_QUOTES|TOK_PRESERVE_QUOTES|TOK_WHITESPACE|TOK_COLLAPSE_MULTIPLE|TOK_TRIM); + + switch (parts[0]) { + case "if": // if + ifstack[ ++iflevel ] = ifactive; + + if (1 == ifactive) { + ifactive = condition(parts); + } else { + ifactive = 2; // inactive branch + } + break; + + case "elseif": // elseif + if (0 == ifactive) { + ifactive = condition(parts); + } else { + ifactive = 2; // inactive branch + } + break; + + case "else": // else + if (0 == ifactive) { + ++ifactive; // default condition + } + break; + + case "endif": // endif + if (iflevel >= 0) { // pop level + ifactive = ifstack[ iflevel ]; + } else { + ifactive = 1; + } + if (iflevel >= 0) { + iflevel--; + } + break; + } + + dprintf("vim: COND/%5s (%d) %*s <%s> == %d\n", parts[0], iflevel, iflevel*4, "", ln, ifactive); + + } else { + if (ifactive) { + dprintf("vim: COND/line (%d) %*s <%s> == %d\n", iflevel, iflevel*4, "", ln, ifactive); + spec == ln; + } + } + + } while (down()); + + set_buffer(curbuf); + delete_buffer(buf); + + // + // Parse hightlights + // + vim_colorscheme(scheme, -1, base, spec, -1); +} + + +static int +condition(list parts) +{ + // + // Conditions: + // + // if &background == "dark" + // if &background ==# 'dark' + // if &background == "light" + // if &background ==# 'light' + // + // if &t_Co >= 8, 16, 88, 256 + // if &t_Co == 8, 16, 88, 256 + // + // if has("gui_running") || &t_Co == 88 || &t_Co == 256 + // + // if exists("syntax_on") + // endif + // + // if version > xxx + // endif + // + // Notes: + // o Parser is very crude, logical AND/OR ignored. + // o Other color condition expressions has been sighted yet the above represent 90% of all cases. + // + extern string base; // "light" or "dark" + extern int colordepth; + + string word, lhs, op; + int ret = 0; + + while (list_each(parts, word) >= 0 && 0 == ret) { + + // left-hand side + if (characterat(word, 1) == '&') { + lhs = word; // variable + op = ""; + continue; + + } else if (word == "||" || word == "&&") { + lhs = ""; // logical operators + continue; + + } else if (strstr(word, "has(")) { // has(xxx) function + if (strstr(word, "gui_running")) { + if (colordepth > 256) { + ret = 1; + break; + } + } + lhs = ""; + continue; + + } else if (word == "exists(\"syntax_on\")") { + ret = 1; // enable "syntax reset" + break; + + } else if (word == "version") { + ret = 1; // enable version'ed code; unsupported feature are ignored. + break; + + } else if (lhs) { + if (!op) { + op = word; // operators + continue; + } + } else { + op = ""; + continue; + } + + // comparisions + switch (op) { + case "==": // equals + if (lhs == "&background") { // word contains "base" + ret = (0 != strstr(word, base)); + + } else if (lhs == "&t_Co") { + if (strstr(word, "256")) { + ret = (colordepth == 256); + } else if (strstr(word, "88")) { + ret = (colordepth == 88); + } else if (strstr(word, "16")) { + ret = (colordepth == 16); + } else if (strstr(word, "8")) { + ret = (colordepth == 8); + } + } + break; + case "==#": // strcasecmp + if (lhs == "&background") { // word contains "base" + ret = (0 != strstr(lower(word), lower(base))); + } + break; + case "!=": // non-equals + if (lhs == "&background") { // word doesnt-contains "base" + ret = (0 == strstr(word, base)); + + } else if (lhs == "&t_Co") { + if (strstr(word, "256")) { + ret = (colordepth != 256); + } else if (strstr(word, "88")) { + ret = (colordepth != 88); + } else if (strstr(word, "16")) { + ret = (colordepth != 16); + } else if (strstr(word, "8")) { + ret = (colordepth != 8); + } + } + break; + case ">=": // greater-then-or-equals + if (lhs == "&t_Co") { + if (strstr(word, "256")) { + ret = (colordepth >= 256); + } else if (strstr(word, "88")) { + ret = (colordepth >= 88); + } else if (strstr(word, "16")) { + ret = (colordepth >= 16); + } else if (strstr(word, "8")) { + ret = (colordepth >= 8); + } + } + break; + } + dprintf("vim: ==> %s %s %s := %d\n", lhs, op, word, ret); + } + list_reset(parts); + return ret; +} + + +/* Function: vim_colorscheme + * VIM colorscheme. + * + * Parameters: + * label - Colorscheme name. + * colors - Supported colors (8, 16, 88 or 256), otherwise -1. + * base - Optional base color scheme "dark" or "light"; current if omitted. + * spec - highlight command list. + * asgui - TRUE utilise gui colors, FALSE terminal, otherwise -1 dynamic. + * + * Returns: + * Imported color count. + */ + +int +vim_colorscheme(string label, int colors, ~string base, list spec, int asgui) +{ + string background; // scheme background. + int colordepth, done, links, ignored; + declare value; + + // verify colors against current display environment + get_term_feature(TF_COLORDEPTH, colordepth); + if (colors > 0) { + if (colordepth != colors) { + message("%s: color depth %d not available (%d)", label, colors, colordepth); + return -1; + } + } + + if (-1 == asgui) { // dynamic + asgui = (colordepth > 256 ? TRUE : FALSE); + } + + if (0 == strlen(base)) { // dark or light base + int isdark; + get_term_feature(TF_SCHEMEDARK, isdark); + base = (isdark ? "dark" : "light"); + } + + set_term_feature(TF_COLORSCHEME, label); + background = base; + + // load schema + while (list_each(spec, value) >= 0) { + const list parts = + tokenize(value, " ", TOK_DOUBLE_QUOTES|TOK_PRESERVE_QUOTES|TOK_WHITESPACE|TOK_COLLAPSE_MULTIPLE|TOK_TRIM); + + switch (parts[0]) { + case "hi": + case "hi!": + case "highlight": + case "highlight!": // hi[ghtlight] command + if (length_of_list(parts) >= 2) { + if ("clear" == parts[1]) { + // + // clear + // Reset all highlighting to the defaults. Removes all highlighting for groups + // added by the user. Uses the current value of 'background' to decide which + // default colors to use. + // + // clear {group-name} + // Disable the highlighting for the specified highlight group. It is *not* set + // wback to the default colors. + // + const string groupname = + (length_of_list(parts) == 3 ? parts[2] : ""); + + if (0 == strlen(groupname)) // scheme=dark|light|default + set_color("scheme=" + background); + + groupclear(groupname); + + } else if ("default" == parts[1] && length_of_list(parts) >= 3 && "link" == parts[2]) { + // + // [default] link {from-group} {to-group} + // Setup an attribute link. + // + // [default] link {from-group} NONE + // Remove an attribute link. + // + string link; + + if (5 == length_of_list(parts)) { + string id1 = attrmap(parts[3]), id2 = attrmap(parts[4]); + + if (strlen(id1) && strlen(id2)) { + sprintf(link, "%s=none:sticky@%s", id1, id2); + set_color(link); + ++links; + } + } + if (!link) ++ignored; + + } else if ("link" == parts[1]) { + string link; + + if (4 == length_of_list(parts)) { + string id1 = attrmap(parts[2]), id2 = attrmap(parts[3]); + + if (strlen(id1) && strlen(id2)) { + sprintf(link, "%s=none:link@%s", id1, id2); + set_color(link); + ++links; + } + } + if (!link) ++ignored; + + } else { + // + // [default] {group-name} key=arg + // State an attributes color specification. + // + int baseidx = ("default" == parts[1] ? 2 : 1); + string fg, bg, sf, ident = attrmap(parts[baseidx]); + int i; + + if (ident) { + for (i = baseidx + 1; i < length_of_list(parts); ++i) { + const list parts2 = + tokenize(parts[i], "=", TOK_DOUBLE_QUOTES|TOK_WHITESPACE|TOK_TRIM); + + if (length_of_list(parts2) >= 2) { + string val = parts2[1]; + + if (0 == asgui) { + // cterm={attr-list} + // Color termination attribute list. + // One or more of the following comma seperated values (without spaces). + // + // bold, underline, undercurl, none, reverse, inverse, italic, standout + // + // ctermfg={color} + // Color terminal foreground color. + // + // ctermbg={color} + // Color terminal background color. + // + switch (parts2[0]) { + case "cterm": sf = val; break; + case "ctermfg": fg = val; break; + case "ctermbg": bg = val; break; + } + + } else { + // gui={attr-list} + // Color termination attribute list. + // One or more of the following comma seperated values (without spaces). + // + // font={font-name} + // Font (ignored). + // + // guifg={color} + // Color terminal foreground color. + // + // guibg={color} + // Color terminal background color. + // + // guisp={color} + // Foregroud. background and special color. + // + switch (parts2[0]) { + case "gui": sf = val; break; + case "guifg": fg = val; break; + case "guibg": bg = val; break; + case "font": break; + case "guisp": break; + } + } + } + } + + if (strlen(fg) || strlen(bg)) { + dprintf("%s: attribute: %s=%s fg:%s, bg:%s, sf:%s", + label, parts[baseidx], ident, fg, bg, sf); + + switch (ident) { + case "normal": + if (bg) set_color_pair("background", bg); + if (fg) set_color_pair("normal", fg); + break; + case "hilite": + if (fg) { + if (bg) { + set_color_pair("hilite", fg, bg); + } else { + set_color_pair("hilite_fg", fg); + } + } else { + set_color_pair("hilite", "fg", bg); + } + break; + default: + if (0 == strlen(fg)) { + fg = "fg"; // current foreground + + } else if (0 == strlen(bg) || 0 == strcasecmp(bg, "NONE")) { + bg = "bg"; // current background (TODO: NONE=transparent) + } + + if ("frame" == ident) + sf = ""; // ignore underline etc + + set_color_pair(ident, fg, bg, sf); + break; + } + ++done; + } + + } else { + dprintf("%s: attribute: %s=unknown", label, parts[baseidx]); + ++ignored; + } + } + } + break; + + case "let": + case "set": // set command + // + // set bg=[dark|light]/ + // set background=[dark|light]/ + // When set to "dark", use colors that look good on a dark background. + // When set to "light", try to use colors that look good on a light background. + // Any other value is illegal. + // + // let g:colors_name = 'duckbones' + // Scheme name. + // + if (length_of_list(parts) >= 2) { + const list parts2 = + tokenize(parts[1], "=", TOK_DOUBLE_QUOTES|TOK_WHITESPACE|TOK_TRIM); + + if (length_of_list(parts2) >= 2) { + if ("bg" == parts2[0] || "background" == parts2[0]) { + const string arg = parts2[1]; + + if (0 == strcasecmp("dark", arg) || 0 == strcasecmp("light", arg) || 0 == strcasecmp("default", arg)) { + background = arg; + } + } + } + } + break; + + case "syntax": // syntax command + // + // syntax reset + // Resets the colors for: + // + // Comment, Constant, Special, Identifier, Statement, PreProc, Type, Underline, Ignore + // + // according to the selected background (dark or light). + // Links that point to these colors (String, Number, etc.) are also reset. + // + if (length_of_list(parts) >= 2) { + if (parts[1] == "reset") { + syntaxreset(); + } + } + break; + + case "set_color": // set_color + // + // set_color + // + if (3 == length_of_list(parts)) { + set_color(parts[1], parts[2]); + } + break; + + default: // unknown + dprintf("%s: attribute: %s=unknown", label, value); + ++ignored; + break; + } + } + + if (done > 0) { + if (colors > 0) { + message("%s:%d(%d): links=%d, ignored=%d", label, colors, done, links, ignored); + } else { + message("%s(%d): links=%d, ignored=%d", label, done, links, ignored); + } + } + return done; +} + + +/* Function: groupclear + * Setup the VIM style color links. + * + * Parameters: + * name - Groupname to be initialised, otherwise "". Note that highlight group names are not + * case sensitive. "String" and "string" can be used for the same group. + * + * Note: + * The names marked with '*' below are the preferred groups; the others are minor groups. + * + * Returns: + * nothing + */ +static void +groupclear(string name) +{ + const int all = (0 == strlen(name)); + + // Constant [constant] + // *Constant any constant + // String a string constant: "this is a string" + // Character a character constant: 'c', '\n' + // Number a number constant: 234, 0xff + // Boolean a boolean constant: TRUE, false + // Float a floating point constant: 2.3e10 + // + if (all || 0 == strcasecmp(name, "Constant")) { + const string link = "=clear:link@constant"; + set_color("string" + link); + set_color("character" + link); + set_color("number" + link); + set_color("boolean" + link); + set_color("float" + link); + } + + // Identifier [n/a] + // *Identifier any variable name + // Function function name (also: methods for classes) + // + if (all || 0 == strcasecmp(name, "Identifier")) { + set_color("word=clear:link@normal"); + set_color("keyword_function=clear:link@normal"); + } + + // Statement [code] + // *Statement any statement + // Conditional if, then, else, endif, switch, etc. + // Repeat for, do, while, etc. + // Label case, default, etc. + // Operator "sizeof", "+", "*", etc. + // Keyword any other keyword + // Exception try, catch, throw + // + if (all || 0 == strcasecmp(name, "Statement")) { + const string link = "=clear:link@code"; + set_color("keyword" + link); + set_color("keyword_extension" + link); + set_color("keyword_definition" + link); + set_color("keyword_conditional" + link); + set_color("keyword_repeat" + link); + set_color("keyword_exception" + link); + set_color("keyword_label" + link); + } + + // PreProc [preprocessor] + // *PreProc generic Preprocessor + // Include preprocessor #include + // Define preprocessor #define + // Macro same as Define + // PreCondit preprocessor #if, #else, #endif, etc. + // + if (all || 0 == strcasecmp(name, "PreProc")) { + const string link = "=clear:link@preprocessor"; + set_color("preprocessor_include" + link); + set_color("preprocessor_define" + link); + set_color("preprocessor_keyword" + link); + set_color("preprocessor_conditional" + link); + } + + // Type [storageclass] + // *Type int, long, char, etc. + // StorageClass static, register, volatile, etc. + // Structure struct, union, enum, etc. + // Typedef A typedef + // + if (all || 0 == strcasecmp(name, "Type")) { + const string link = "=clear:link@keyword_type"; + set_color("keyword_storageclass" + link); + set_color("keyword_structure" + link); + set_color("keyword_typedef" + link); + } + + // Special [standout] + // *Special any special symbol + // SpecialChar special character in a constant + // Tag you can use CTRL-] on this + // Delimiter character that needs attention + // SpecialComment special things inside a comment + // Debug debugging statements + // + if (all || 0 == strcasecmp(name, "Special")) { + const string link = "=clear:link@standout"; + set_color("constant_standout" + link); + set_color("tag" + link); + set_color("delimiter" + link); + set_color("comment_standout" + link); + set_color("keyword_debug" + link); + } +} + + +static void +syntaxlink(string from, string to) +{ + from = attrmap(from); + if (from) { + to = attrmap(to); + if (to) { + set_color(from + "=clear:link@" + to); + } + } +} + + +static void +syntaxreset(void) +{ + // TODO: review + syntaxlink("Boolean", "Constant"); + syntaxlink("Character", "Constant"); + syntaxlink("Conditional", "Statement"); + syntaxlink("Debug", "Special"); + syntaxlink("Define", "PreProc"); + syntaxlink("Delimiter", "Special"); + syntaxlink("Exception", "Statement"); + syntaxlink("Float", "Constant"); + //syntaxlink("Function", "Identifier"); + syntaxlink("Include", "PreProc"); + syntaxlink("Keyword", "Statement"); + syntaxlink("Label", "Statement"); + syntaxlink("Macro", "PreProc"); + syntaxlink("Number", "Constant"); + syntaxlink("Operator", "Statement"); + syntaxlink("PreCondit", "PreProc"); + syntaxlink("Repeat", "Statement"); + syntaxlink("SpecialChar", "Special"); + syntaxlink("SpecialComment", "Special"); + syntaxlink("StorageClass", "Type"); + syntaxlink("String", "Constant"); + syntaxlink("Structure", "Type"); + syntaxlink("Tag", "Special"); + syntaxlink("Typedef", "Type"); +} + + +/* Function: attrmap + * Map a VIM style hi[ghlight] attribute to a GRIEF attribute. + * + * Many of the attributes are simple one-to-one mappings. Unsupported are simply ignored. + * + * Parameters: + * attr - VIM attribute name. + * + * Returns: + * Attribute name, otherwise an empty string. + */ +string +attrmap(string attr) +{ + int idx; + + if ((idx = re_search(SF_NOT_REGEXP|SF_IGNORE_CASE, "=" + attr + "=", scheme_colors)) >= 0) { + return scheme_colors[idx + 1]; + } + return ""; +} + + +/* + * Basic unit-testing ----- + * + */ + +static void +condtest(string line, string base, int colordepth, int ret) +{ + const list parts = + tokenize(line, " ", TOK_DOUBLE_QUOTES|TOK_PRESERVE_QUOTES|TOK_WHITESPACE|TOK_COLLAPSE_MULTIPLE|TOK_TRIM); + + int t_ret = condition(parts); + dprintf("vimtest: [%s] %s/%s <%s> := %d", (t_ret == ret ? "OK" : "BAD"), base, colordepth, line); +} + + +void +vim_condition_tests() +{ + condtest("if &background == \"dark\"", "dark", -1, 1); + condtest("if &background ==# 'dark'", "DARK", -1, 1); + condtest("if &background == \"dark\"", "light", -1, 0); + condtest("if &background ==# 'dark'", "light", -1, 0); + + condtest("if &background == \"light\"", "light", -1, 1); + condtest("if &background ==# 'light'", "Light", -1, 1); + condtest("if &background == \"light\"", "dark", -1, 0); + condtest("if &background ==# 'light'", "dark", -1, 0); + + condtest("if has(\"gui_running\")", "", 256, 0); + condtest("if has(\"gui_running\")", "", 1024, 1); + + condtest("if exists(\"syntax_on\")", "", -1, 1); + + condtest("if version > 700", "", -1, 1); + + condtest("if &t_Co == 16, 88, 256", "", 8, 0); + condtest("if &t_Co == 16, 88, 256", "", 16, 1); + condtest("if &t_Co == 16, 88, 256", "", 88, 1); + condtest("if &t_Co == 16, 88, 256", "", 256, 1); + + condtest("if &t_Co >= 16, 88, 256", "", 15, 0); + condtest("if &t_Co >= 16, 88, 256", "", 16, 1); + condtest("if &t_Co >= 16, 88, 256", "", 17, 1); + condtest("if &t_Co >= 16, 88, 256", "", 88, 1); + condtest("if &t_Co >= 16, 88, 256", "", 89, 1); + condtest("if &t_Co >= 16, 88, 256", "", 256, 1); + condtest("if &t_Co >= 16, 88, 256", "", 257, 1); + + condtest("if has(\"gui_running\") || &t_Co == 88 || &t_Co == 256", "", 16, 0); + condtest("if has(\"gui_running\") || &t_Co == 88 || &t_Co == 256", "", 88, 1); + condtest("if has(\"gui_running\") || &t_Co == 88 || &t_Co == 256", "", 256, 1); +} + +/*eof*/ diff --git a/macsrc/colorsvim.h b/macsrc/colorsvim.h new file mode 100644 index 00000000..98775930 --- /dev/null +++ b/macsrc/colorsvim.h @@ -0,0 +1,14 @@ +/* -*- mode: cr; indent-width: 4; -*- */ +/* $Id: colorsvim.h,v 1.1 2024/07/05 18:41:55 cvsuser Exp $ + * Enhanced colour/colorscheme support. + * + * + */ + +#define SCHEME_CTERMONLY 0x0001 +#define SCHEME_GUIONLY 0x0002 + +void vim_colorscript(string scheme, string base, int flags, string file); +int vim_colorscheme(string label, int colors, ~string base, list spec, int asgui); + +/*eof*/ diff --git a/macsrc/demos/dialogtest.cr b/macsrc/demos/dialogtest.cr index d6c0cb06..00bcf4cf 100644 --- a/macsrc/demos/dialogtest.cr +++ b/macsrc/demos/dialogtest.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: dialogtest.cr,v 1.6 2014/10/22 02:34:29 ayoung Exp $ +/* $Id: dialogtest.cr,v 1.8 2024/09/12 17:11:03 cvsuser Exp $ * * This file is used when debugging and fixing CRISP to aid in regression * testing - catching bugs introduced inadvertently. This script does not @@ -8,7 +8,7 @@ * * The tests in this file are mainly to do with tty dialog interface. * - * This file can also be run after porting CRISP, to ensure that these tests + * This file can also be run after porting GRIEF, to ensure that these tests * work as expected. If anything doesn't work that should, the porter will * have to check for portability problems. These tests attempt to do things in * order of complexity. @@ -74,6 +74,7 @@ dialogmake() dialog_tst = dialog_create( make_list( DLGA_TITLE, "dialog test", DLGA_CALLBACK, "::callback", // global call-back + DLGA_STYLES, DLGS_CAPTION|DLGS_SYSCLOSE, DLGC_CONTAINER, DLGA_ATTACH_TOP, @@ -336,21 +337,32 @@ dialogmake() DLGA_ATTACH_LEFT, DLGA_LABEL, "&OK", DLGA_NAME, "ok", + DLGC_PUSH_BUTTON, + DLGA_ATTACH_LEFT, + DLGA_LABEL, "e&Xit", + DLGA_NAME, "exit", DLGC_PUSH_BUTTON, DLGA_ATTACH_RIGHT, DLGA_LABEL, "&Cancel", DLGA_NAME, "cancel", - DLGA_ATTACH_RIGHT, DLGA_CANCEL_BUTTON, DLGA_DEFAULT_BUTTON, - DLGA_ATTACH_RIGHT, DLGC_END )); } -static void +static int callback(int ident, string name, int p1, int p2) { message("ident=0x%x, name=%s, p1=%d/0x%x, p2=%d/0x%x", ident, name, p1, p1, p2, p2); + if (name == "exit") { + dialog_exit(); + return TRUE; + } + return FALSE; } + +//end + + diff --git a/macsrc/demos/regress.cr b/macsrc/demos/regress.cr index 43521cab..25dc772a 100644 --- a/macsrc/demos/regress.cr +++ b/macsrc/demos/regress.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: regress.cr,v 1.40 2024/05/11 16:37:49 cvsuser Exp $ +/* $Id: regress.cr,v 1.44 2024/08/02 12:59:02 cvsuser Exp $ * * This set of macros are used when debugging and fixing CRISP to aid in regression testing and * catching bugs introduced inadvertently. These tests dont attempt an exhaustive test, yet @@ -1153,46 +1153,47 @@ test_string(void) // operations on string scalars TEST(246, !empty); // undocumented feature, scalar reference. - TEST(247, nonempty); // only function as 'single' expression NOT within compound + TEST(247, !empty && !empty); // may only function as 'single' expression NOT within compound + TEST(248, nonempty); // string addition s1 = "xyz"; s1 += "abc"; - TEST(248, s1 == "xyzabc"); + TEST(249, s1 == "xyzabc"); s1 = "xyz"; s2 = "abc"; s1 += s2; - TEST(249, s1 == "xyzabc"); + TEST(250, s1 == "xyzabc"); s1 = "xyz"; s2 = s1; s1 += s2; - TEST(250, s1 == "xyzxyz"); + TEST(251, s1 == "xyzxyz"); s1 = "xyz"; - TEST(251, (s1 += "abc") == "xyzabc"); + TEST(252, (s1 += "abc") == "xyzabc"); s1 = "xyz"; - TEST(252, (s1 += s1) == "xyzxyz"); + TEST(253, (s1 += s1) == "xyzxyz"); s1 = "xyz"; - TEST(253, (s1 = s1) == "xyz"); + TEST(254, (s1 = s1) == "xyz"); // numeric conversion i = 99; s1 = "abc"; s1 = s1 + i; - TEST(254, s1 == "abc99"); + TEST(255, s1 == "abc99"); i = 99; s1 = "abc"; s1 = i + s1; - TEST(255, s1 == "99abc"); + TEST(256, s1 == "99abc"); s1 = "abc"; s1 += 0; - TEST(256, s1 == "abc0"); + TEST(257, s1 == "abc0"); f = 1.234; s1 = "abc"; s1 = f + s1; - TEST(257, s1 == "1.234abc"); + TEST(258, s1 == "1.234abc"); // string multipler // trailing or leading @@ -1200,96 +1201,96 @@ test_string(void) // i = 0; s1 = "xyz" * i; - TEST(258, s1 == ""); - s1 = i * "xyz"; TEST(259, s1 == ""); + s1 = i * "xyz"; + TEST(260, s1 == ""); i = 1; s1 = "xyz" * i; - TEST(260, s1 == "xyz"); - s1 = i * "xyz"; TEST(261, s1 == "xyz"); + s1 = i * "xyz"; + TEST(262, s1 == "xyz"); i = 2; s1 = "xyz" * i; - TEST(262, s1 == "xyzxyz"); - s1 = i * "xyz"; TEST(263, s1 == "xyzxyz"); + s1 = i * "xyz"; + TEST(264, s1 == "xyzxyz"); f = 1.1; s1 = "xyz" * f; f = 2.2; s1 = "xyz" * f; - TEST(264, s1 == "xyzxyz"); + TEST(265, s1 == "xyzxyz"); // string accumulator tests - TEST(265, "abc" + "def" == "abcdef"); - TEST(266, 1 + "def" == "1def"); - TEST(267, "abc" + 1 == "abc1"); - TEST(268, 1.2 + "def" == "1.2def"); - TEST(269, "abc" + 1.2 == "abc1.2"); + TEST(266, "abc" + "def" == "abcdef"); + TEST(267, 1 + "def" == "1def"); + TEST(268, "abc" + 1 == "abc1"); + TEST(269, 1.2 + "def" == "1.2def"); + TEST(270, "abc" + 1.2 == "abc1.2"); // string primitives - TEST(270, trim(" harry ") == "harry"); - TEST(271, rtrim("harry ") == "harry"); - TEST(272, ltrim(" harry") == "harry"); + TEST(271, trim(" harry ") == "harry"); + TEST(272, rtrim("harry ") == "harry"); + TEST(273, ltrim(" harry") == "harry"); s1 = " harry "; - TEST(273, rtrim(s1) == " harry"); - TEST(274, ltrim(s1) == "harry "); + TEST(274, rtrim(s1) == " harry"); + TEST(275, ltrim(s1) == "harry "); - TEST(275, atoi("98") == 98); - TEST(276, strlen("abcd") == 4); + TEST(276, atoi("98") == 98); + TEST(277, strlen("abcd") == 4); s1 = "abcd" + " "; - TEST(277, strlen(s1) == 5); + TEST(278, strlen(s1) == 5); - TEST(278, strlen("nothing") == 7); + TEST(279, strlen("nothing") == 7); s1 = "1234554321"; - TEST(279, index(s1, "4") == 4); - TEST(280, index(s1, "") == 11); - TEST(281, rindex(s1, "5") == 6); + TEST(280, index(s1, "4") == 4); + TEST(281, index(s1, "") == 11); + TEST(282, rindex(s1, "5") == 6); s1 = ""; s1 = substr(s1, index(s1, ";") + 1); - TEST(282, s1 == ""); + TEST(283, s1 == ""); gs1 = ""; get_parm(2, gs1); gs1 = substr(gs1, index(gs1, ";") + 1); - TEST(283, gs1 == ""); + TEST(284, gs1 == ""); - TEST(284, upper("aBc") == "ABC"); - TEST(285, lower("AbC") == "abc"); - TEST(286, 5 == string_count("axba bax", "abz")); + TEST(285, upper("aBc") == "ABC"); + TEST(286, lower("AbC") == "abc"); + TEST(287, 5 == string_count("axba bax", "abz")); - TEST(287, 0 == strcasecmp("AaA", "aAa")); - TEST(288, strerror(0) == "Success"); + TEST(288, 0 == strcasecmp("AaA", "aAa")); + TEST(289, strerror(0) == "Success"); s1 = "abAB"; - TEST(289, "a" == strpop(s1)); - TEST(290, "b" == strpop(s1)); - TEST(291, "AB" == strpop(s1, 2)); - TEST(292, "" == strpop(s1)); + TEST(290, "a" == strpop(s1)); + TEST(291, "b" == strpop(s1)); + TEST(292, "AB" == strpop(s1, 2)); + TEST(293, "" == strpop(s1)); s1 = "abcdefg"; - TEST(293, 3 == strpbrk(s1, "dc")); + TEST(294, 3 == strpbrk(s1, "dc")); // strstr, strrstr and strcasestr s1 = "abcmandefg"; - TEST(294, 4 == strstr(s1, "man")); - TEST(295, 4 == strrstr(s1, "man")); - TEST(296, 4 == strcasestr(s1, "MAN")); + TEST(295, 4 == strstr(s1, "man")); + TEST(296, 4 == strrstr(s1, "man")); + TEST(297, 4 == strcasestr(s1, "MAN")); s1 = "abcmanmandefg"; - TEST(297, 4 == strstr(s1, "man")); - TEST(298, 7 == strrstr(s1, "man")); + TEST(298, 4 == strstr(s1, "man")); + TEST(299, 7 == strrstr(s1, "man")); - TEST(299, 0 == strstr(s1, "ban")); - TEST(300, 0 == strrstr(s1, "ban")); + TEST(300, 0 == strstr(s1, "ban")); + TEST(301, 0 == strrstr(s1, "ban")); - TEST(301, 1 == strstr(s1, "")); - TEST(302, 0 == strrstr(s1, "")); + TEST(302, 1 == strstr(s1, "")); + TEST(303, 0 == strrstr(s1, "")); } @@ -1309,66 +1310,66 @@ test_regexp(void) // test offset and length returns. // i = -1; - TEST(303, 6 == search_string(" [worl]+", s1, i, -2 /*MAXIMUM*/, FALSE)); - TEST(304, 5 == i); + TEST(304, 6 == search_string(" [worl]+", s1, i, -2 /*MAXIMUM*/, FALSE)); + TEST(305, 5 == i); i = -1; /* FIXME/XXX - Brief minimal logic needs reviewing */ - TEST(305, 6 == re_search(SF_BRIEF|SF_IGNORE_CASE, " [worl]+", s1, NULL, i)); - TEST(306, 2 == i); + TEST(306, 6 == re_search(SF_BRIEF|SF_IGNORE_CASE, " [worl]+", s1, NULL, i)); + TEST(307, 2 == i); i = -1; - TEST(307, 6 == re_search(SF_BRIEF|SF_MAXIMAL|SF_IGNORE_CASE, " [worl]+", s1, NULL, i)); - TEST(308, 5 == i); + TEST(308, 6 == re_search(SF_BRIEF|SF_MAXIMAL|SF_IGNORE_CASE, " [worl]+", s1, NULL, i)); + TEST(309, 5 == i); i = -1; - TEST(309, 6 == re_search(SF_UNIX|SF_IGNORE_CASE, " [worl]+", s1, NULL, i)); - TEST(310, 5 == i); + TEST(310, 6 == re_search(SF_UNIX|SF_IGNORE_CASE, " [worl]+", s1, NULL, i)); + TEST(311, 5 == i); i = -1; - TEST(311, 6 == re_search(SF_EXTENDED|SF_IGNORE_CASE, " [worl]+", s1, NULL, i)); - TEST(312, 5 == i); + TEST(312, 6 == re_search(SF_EXTENDED|SF_IGNORE_CASE, " [worl]+", s1, NULL, i)); + TEST(313, 5 == i); i = -1; - TEST(313, 6 == re_search(SF_PERL|SF_IGNORE_CASE, " [worl]+", s1, NULL, i)); - TEST(314, 5 == i); + TEST(314, 6 == re_search(SF_PERL|SF_IGNORE_CASE, " [worl]+", s1, NULL, i)); + TEST(315, 5 == i); i = -1; - TEST(315, 6 == re_search(SF_TRE|SF_IGNORE_CASE, " [worl]+", s1, NULL, i)); - TEST(316, 5 == i); + TEST(316, 6 == re_search(SF_TRE|SF_IGNORE_CASE, " [worl]+", s1, NULL, i)); + TEST(317, 5 == i); - TEST(317, 6 == re_search(SF_PERL|SF_IGNORE_CASE, " [worl]+", s1, NULL, i)); - TEST(318, 5 == i); + TEST(318, 6 == re_search(SF_PERL|SF_IGNORE_CASE, " [worl]+", s1, NULL, i)); + TEST(319, 5 == i); s1 = "Hello World"; - TEST(319, 6 == re_search(SF_PERL|SF_IGNORE_CASE, " ([worl]+)", s1, NULL, i)); - TEST(320, 5 == i); + TEST(320, 6 == re_search(SF_PERL|SF_IGNORE_CASE, " ([worl]+)", s1, NULL, i)); + TEST(321, 5 == i); // captures // s1 = "y aabbccddee z"; s2 = "y XaabbccddeeX z"; - TEST(321, re_search(SF_BRIEF, " {[abcde]+} ", s1, NULL, i) == 2); + TEST(322, re_search(SF_BRIEF, " {[abcde]+} ", s1, NULL, i) == 2); - TEST(322, re_search(SF_UNIX, " \\([abcde]+\\) ", s1, NULL, i) == 2); + TEST(323, re_search(SF_UNIX, " \\([abcde]+\\) ", s1, NULL, i) == 2); - TEST(323, re_search(SF_EXTENDED, " ([abcde]+) ", s1, NULL, i) == 2); + TEST(324, re_search(SF_EXTENDED, " ([abcde]+) ", s1, NULL, i) == 2); - TEST(324, re_search(SF_PERL, " ([abcde]+) ", s1, NULL, i) == 2); + TEST(325, re_search(SF_PERL, " ([abcde]+) ", s1, NULL, i) == 2); - TEST(325, re_translate(SF_BRIEF|SF_MAXIMAL, "{[abcde]+}", "X\\0X", s1) == s2); + TEST(326, re_translate(SF_BRIEF|SF_MAXIMAL, "{[abcde]+}", "X\\0X", s1) == s2); - TEST(326, re_translate(SF_UNIX, "\\([abcde]+\\)", "X\\0X", s1) == s2); + TEST(327, re_translate(SF_UNIX, "\\([abcde]+\\)", "X\\0X", s1) == s2); - TEST(327, re_translate(SF_EXTENDED, "([abcde]+)", "X\\0X", s1) == s2); + TEST(328, re_translate(SF_EXTENDED, "([abcde]+)", "X\\0X", s1) == s2); - TEST(328, re_translate(SF_PERL, "([abcde]+)", "X$1X", s1) == s2); + TEST(329, re_translate(SF_PERL, "([abcde]+)", "X$1X", s1) == s2); - TEST(329, re_translate(SF_PERL, "([abcde]+)", "$`", s1) == "y y z"); + TEST(330, re_translate(SF_PERL, "([abcde]+)", "$`", s1) == "y y z"); - TEST(330, re_translate(SF_PERL, "([abcde]+)", "$'", s1) == "y z z"); + TEST(331, re_translate(SF_PERL, "([abcde]+)", "$'", s1) == "y z z"); - TEST(331, re_translate(SF_TRE, "([abcde]+)", "X$1X", s1) == s2); + TEST(332, re_translate(SF_TRE, "([abcde]+)", "X$1X", s1) == s2); } @@ -1379,20 +1380,20 @@ test_regexp(void) static void test_sub(void) { - TEST(332, gsub("ana", "anda", "banana") == "bandana"); - TEST(333, gsub("a", "-&-", "banana") == "b-a-n-a-n-a-"); - TEST(334, gsub("a+", "-&-", "banana") == "b-a-n-a-n-a-"); - TEST(335, gsub("a+", "-a-", "baaaanaaaaanaaaa") == "b-a-n-a-n-a-"); - TEST(336, sub("ana", "anda", "banana") == "bandana"); - TEST(337, sub("a", "-&-", "banana") == "b-a-nana"); - TEST(338, sub("a+", "-&-", "banana") == "b-a-nana"); - TEST(339, sub("a+", "-a-", "baaaanaaaaanaaaa") == "b-a-naaaaanaaaa"); - TEST(340, sub("na$", "na.", "banana") == "banana."); - TEST(341, gsub("^a", "A", "anana") == "Anana"); - TEST(342, gsub("n.n", "[&]", "banana") == "ba[nan]a"); - TEST(343, gsub("a|n", "z", "anna") == "zzzz"); + TEST(333, gsub("ana", "anda", "banana") == "bandana"); + TEST(334, gsub("a", "-&-", "banana") == "b-a-n-a-n-a-"); + TEST(335, gsub("a+", "-&-", "banana") == "b-a-n-a-n-a-"); + TEST(336, gsub("a+", "-a-", "baaaanaaaaanaaaa") == "b-a-n-a-n-a-"); + TEST(337, sub("ana", "anda", "banana") == "bandana"); + TEST(338, sub("a", "-&-", "banana") == "b-a-nana"); + TEST(339, sub("a+", "-&-", "banana") == "b-a-nana"); + TEST(340, sub("a+", "-a-", "baaaanaaaaanaaaa") == "b-a-naaaaanaaaa"); + TEST(341, sub("na$", "na.", "banana") == "banana."); + TEST(342, gsub("^a", "A", "anana") == "Anana"); + TEST(343, gsub("n.n", "[&]", "banana") == "ba[nan]a"); + TEST(344, gsub("a|n", "z", "anna") == "zzzz"); - TEST(344, sub("f\\(.*\\)t", "F\\1T", "first:second") == "FirsT:second"); + TEST(345, sub("f\\(.*\\)t", "F\\1T", "first:second") == "FirsT:second"); } @@ -1407,37 +1408,37 @@ test_substr(void) string s1; s1 = substr("ABC", 0, 3); - TEST(345, s1 == "ABC"); + TEST(346, s1 == "ABC"); s1 = substr("ABC", -1000, 1000); - TEST(346, s1 == "ABC"); + TEST(347, s1 == "ABC"); s1 = substr("ABC", 1000, 1000); - TEST(347, s1 == ""); + TEST(348, s1 == ""); s1 = substr("ABC", 1, 0); - TEST(348, s1 == ""); + TEST(349, s1 == ""); s1 = substr("ABC", 1, 1); - TEST(349, s1 == "A"); + TEST(350, s1 == "A"); s1 = substr("ABC", 1, 2); - TEST(350, s1 == "AB"); + TEST(351, s1 == "AB"); s1 = substr("ABC", 1, 3); - TEST(351, s1 == "ABC"); + TEST(352, s1 == "ABC"); s1 = substr("ABC", 1, 100); - TEST(352, s1 == "ABC"); + TEST(353, s1 == "ABC"); s1 = substr("ABC", 3, 0); - TEST(353, s1 == ""); + TEST(354, s1 == ""); s1 = substr("ABC", 3, 1); - TEST(354, s1 == "C"); + TEST(355, s1 == "C"); s1 = substr("ABC", 3, 100); - TEST(355, s1 == "C"); + TEST(356, s1 == "C"); } @@ -1449,15 +1450,15 @@ static void test_compress(void) { // basic - TEST(356, compress(" harry ", 0) == " harry "); - TEST(357, compress(" harry ", 1) == "harry"); - TEST(358, compress(" h a r r y ", 0) == " h a r r y "); - TEST(359, compress(" h a r r y ", 0) == " h a r r y "); - TEST(360, compress(" h a r r y ", 1) == "h a r r y"); + TEST(357, compress(" harry ", 0) == " harry "); + TEST(358, compress(" harry ", 1) == "harry"); + TEST(359, compress(" h a r r y ", 0) == " h a r r y "); + TEST(360, compress(" h a r r y ", 0) == " h a r r y "); + TEST(361, compress(" h a r r y ", 1) == "h a r r y"); // extended features - TEST(361, compress(" harry ", 0, " r") == " ha y "); - TEST(362, compress(" harry ", 0, " r", 'x') == "xhaxyx"); + TEST(362, compress(" harry ", 0, " r") == " ha y "); + TEST(363, compress(" harry ", 0, " r", 'x') == "xhaxyx"); } @@ -1474,199 +1475,207 @@ test_list(void) declare d1; // 1. - l1 = quote_list(123, 1.23, "xyz", hello()); /* int, float, string and symbol */ - TEST(363, length_of_list(l1) == 4); + l1 = quote_list(123, 1.23, "xyz", hello(), NULL); /* int, float, string, symbol and NULL */ + TEST(364, length_of_list(l1) == 5); + + TEST(365, quote_list("111", "222", "333")[0] == "111"); /* return-value/accumulator references */ + TEST(366, quote_list("111", "222", "333")[1] == "222"); + TEST(367, quote_list("111", "222", "333")[2] == "333"); l2 = l1; - TEST(364, length_of_list(l2) == 4); - TEST(365, l1[0] == l2[0]); - TEST(366, l1[1] == l2[1]); - TEST(367, l1[2] == l2[2]); + TEST(368, length_of_list(l2) == 5); + TEST(369, l1[0] == l2[0]); + TEST(370, l1[1] == l2[1]); + TEST(371, l1[2] == l2[2]); d1 = l1[0]; - TEST(368, is_integer(d1)); /* 123 */ - TEST(369, is_type(d1, "integer")); + TEST(372, is_integer(d1)); /* 123 */ + TEST(373, is_type(d1, "integer")); d1 = l1[1]; - TEST(370, is_float(d1)); /* 1.23 */ - TEST(371, is_type(d1, "float")); + TEST(374, is_float(d1)); /* 1.23 */ + TEST(375, is_type(d1, "float")); d1 = l1[2]; - TEST(372, is_string(d1)); /* "xyz" */ - TEST(373, is_type(d1, "string")); + TEST(376, is_string(d1)); /* "xyz" */ + TEST(377, is_type(d1, "string")); d1 = l1[3]; - TEST(374, is_list(d1)); /* hello() */ - TEST(375, is_type(d1, "list")); + TEST(378, is_list(d1)); /* hello() */ + TEST(379, is_type(d1, "list")); + + d1 = l1[4]; + TEST(380, is_null(d1)); /* NULL */ + TEST(381, is_type(d1, "NULL")); pause_on_error(0, FALSE); - d1 = l1[4]; /* range error */ + d1 = l1[5]; /* range error */ pause_on_error(1, FALSE); - TEST(376, is_null(d1)); - TEST(377, is_type(d1, "null")); + TEST(382, is_null(d1)); + TEST(383, is_type(d1, "null")); // 2. l1 = quote_list(1); l1[0] = 2; - TEST(378, l1[0] == 2); + TEST(384, l1[0] == 2); l1 = quote_list(1, "abc"); l1[0] = 2; - TEST(379, l1[0] == 2); + TEST(385, l1[0] == 2); l1 = quote_list("abc"); l1[0] = 2; - TEST(380, l1[0] == 2); + TEST(386, l1[0] == 2); l1 = quote_list("abc", 1); l1[1] = 2; - TEST(381, l1[1] == 2); + TEST(387, l1[1] == 2); l1 = quote_list(1, "abc", 3); l1[1] = 2; - TEST(382, l1[1] == 2); + TEST(388, l1[1] == 2); l1 = quote_list(1, 2, 3); l1[1] = "abc"; - TEST(383, l1[1] == "abc"); + TEST(389, l1[1] == "abc"); l1 = quote_list(1, 2, 3); l2 = l1; l1[1] = l2; - TEST(384, length_of_list(l1) == 5); + TEST(390, length_of_list(l1) == 5); l1 = quote_list(1, 2, 3); l1[1] = quote_list(1, 2, 3); - TEST(385, length_of_list(l1) == 5); + TEST(391, length_of_list(l1) == 5); - TEST(386, 1. == 1); + TEST(392, 1. == 1); l1 = quote_list(1, 2, 3); l1[1] = make_list(quote_list(1, 2, 3)); l1[3] = "end"; - TEST(387, l1[3] == "end"); - TEST(388, length_of_list(l1) == 4); + TEST(393, l1[3] == "end"); + TEST(394, length_of_list(l1) == 4); l3[0] = 0; l3[1] = 1; l3[2] = 2; - TEST(389, l3[0] == 0); - TEST(390, l3[1] == 1); - TEST(391, l3[2] == 2); + TEST(395, l3[0] == 0); + TEST(396, l3[1] == 1); + TEST(397, l3[2] == 2); l1 = NULL; - TEST(392, length_of_list(l1) == 0); + TEST(398, length_of_list(l1) == 0); l1[0] = "hello"; - TEST(393, l1[0] == "hello"); + TEST(399, l1[0] == "hello"); s1 = "abc"; l1[0] = s1; - TEST(394, l1[0] == "abc"); + TEST(400, l1[0] == "abc"); s1 = "abc"; l1[0] = s1; s1 = "123456789"; - TEST(395, l1[0] == "abc"); + TEST(401, l1[0] == "abc"); b57 = "hello"; a57 = b57; - TEST(396, a57 == "hello"); + TEST(402, a57 == "hello"); - TEST(397, test_6() == 99); + TEST(403, test_6() == 99); l1 = quote_list("one", "", "three"); s1 = "TWO"; l1[1] = s1; l1[1] = s1; - TEST(398, l1[1] == "TWO"); + TEST(404, l1[1] == "TWO"); l1 = quote_list(1, 2, 3); l2 = make_list(l1); l1[1] = l2; - TEST(399, length_of_list(l1) == 3); + TEST(405, length_of_list(l1) == 3); l1 = quote_list("hello", "list", 1, NULL, 2.3); l2 = make_list(l1); l1[1] = l2; - TEST(400, length_of_list(l1) == 5); + TEST(406, length_of_list(l1) == 5); l1 = quote_list(1, 2, 3); l1[1] = make_list(quote_list(1, 2, 3)); - TEST(401, length_of_list(l1) == 3); + TEST(407, length_of_list(l1) == 3); l1 = quote_list(1, 2, 3); l1[2] = make_list(quote_list(1, 2, 3)); - TEST(402, length_of_list(l1) == 3); + TEST(408, length_of_list(l1) == 3); l1 = quote_list(1, 2, 3); l1[0] = make_list(quote_list(1, 2, 3)); - TEST(403, length_of_list(l1) == 3); + TEST(409, length_of_list(l1) == 3); l1 = make_list(quote_list(1, 2, 3)); l1 += "abc"; l1 += "def"; l1[1] = 1; - TEST(404, length_of_list(l1) == 3); + TEST(410, length_of_list(l1) == 3); l1 = make_list(quote_list(1, 2, 3), quote_list(1, 2, 3)); - TEST(405, car(car(l1)) == 1); - TEST(406, length_of_list(l1) == 2); + TEST(411, car(car(l1)) == 1); + TEST(412, length_of_list(l1) == 2); l1 = NULL; - TEST(407, length_of_list(l1) == 0); + TEST(413, length_of_list(l1) == 0); pause_on_error(0, FALSE); nth(l1, 99); /* subscript out of range */ pause_on_error(1, FALSE); // list functions l1 = command_list(); - TEST(408, is_list(l1)); + TEST(414, is_list(l1)); l1 = macro_list(); - TEST(409, is_list(l1)); + TEST(415, is_list(l1)); l1 = get_term_keyboard(); - TEST(410, is_list(l1)); + TEST(416, is_list(l1)); l1 = key_list(); - TEST(411, is_list(l1)); + TEST(417, is_list(l1)); l1 = bookmark_list(); - TEST(412, is_list(l1)); + TEST(418, is_list(l1)); l1 = macro_list(); - TEST(413, strlen(l1) != 0); - TEST(414, length_of_list(cdr(macro_list())) > 0); - TEST(415, search_list(NULL, "def", quote_list("abc", "def", "ghi")) == 1); + TEST(419, strlen(l1) != 0); + TEST(420, length_of_list(cdr(macro_list())) > 0); + TEST(421, search_list(NULL, "def", quote_list("abc", "def", "ghi")) == 1); l1 = quote_list("abc"); l1 += "def"; l1 += "ghi"; - TEST(416, search_list(NULL, "def", l1) == 1); + TEST(422, search_list(NULL, "def", l1) == 1); // features l1 = inq_feature(); - TEST(417, is_list(l1)); + TEST(423, is_list(l1)); // list concat l1 = quote_list(1, "2", 3.0); l1 = l1 + l1; - TEST(418, length_of_list(l1) == 6); + TEST(424, length_of_list(l1) == 6); l2 = l1; // element insert l1[3] = quote_list("a", "b", "c"); - TEST(419, length_of_list(l1) == 8); + TEST(425, length_of_list(l1) == 8); // element replace l1[0] = 99; - TEST(420, l1[0] != l2[0]); + TEST(426, l1[0] != l2[0]); // re_search l1 = quote_list("abc"); l1 += "def"; l1 += "ghi"; - TEST(421, re_search(NULL, "def", l1) == 1); + TEST(427, re_search(NULL, "def", l1) == 1); } @@ -1679,27 +1688,27 @@ test_list2(void) { list l1 = {"one", "two", "three", "four"}; - TEST(422, shift(l1) == "one"); - TEST(423, 3 == length_of_list(l1)); // two, three, four + TEST(428, shift(l1) == "one"); + TEST(429, 3 == length_of_list(l1)); // two, three, four - TEST(424, 5 == unshift(l1, "first", "second")); - TEST(425, 5 == length_of_list(l1)); // first, second, two, three, four + TEST(430, 5 == unshift(l1, "first", "second")); + TEST(431, 5 == length_of_list(l1)); // first, second, two, three, four - TEST(426, pop(l1) == "four"); // first, second, two, three - TEST(427, 4 == length_of_list(l1)); + TEST(432, pop(l1) == "four"); // first, second, two, three + TEST(433, 4 == length_of_list(l1)); - TEST(428, shift(l1) == "first" && shift(l1) == "second"); - TEST(429, 2 == length_of_list(l1)); // two, three + TEST(434, shift(l1) == "first" && shift(l1) == "second"); + TEST(435, 2 == length_of_list(l1)); // two, three - TEST(430, pop(l1) == "three"); // two - TEST(431, 1 == length_of_list(l1)); + TEST(436, pop(l1) == "three"); // two + TEST(437, 1 == length_of_list(l1)); - TEST(432, shift(l1) == "two"); // null - TEST(433, 0 == length_of_list(l1)); - TEST(434, is_null(l1)); + TEST(438, shift(l1) == "two"); // null + TEST(439, 0 == length_of_list(l1)); + TEST(440, is_null(l1)); push(l1, "five", "six"); - TEST(435, 2 == length_of_list(l1)); + TEST(441, 2 == length_of_list(l1)); } @@ -1717,27 +1726,27 @@ test_list3(void) while ((idx = list_each(l1, value)) >= 0) { switch(idx) { case 0: - TEST(436, 1 == value); + TEST(442, 1 == value); break; case 1: - TEST(437, "2" == value); + TEST(443, "2" == value); break; case 2: - TEST(438, 3.3 == value); + TEST(444, 3.3 == value); break; case 3: - TEST(439, 4 == value); + TEST(445, 4 == value); break; case 4: - TEST(440, "5" == value); + TEST(446, "5" == value); break; case 5: - TEST(441, 6.6 == value); + TEST(447, 6.6 == value); break; } ++count; } - TEST(442, length_of_list(l1) == count); + TEST(448, length_of_list(l1) == count); } @@ -1751,16 +1760,16 @@ test_nth(void) declare d1; gl1[1] = "TWO"; - TEST(443, gl1[1] == "TWO"); - TEST(444, gl1[3][0] == "x"); - TEST(445, gl1[3][1] == "y"); - TEST(446, gl1[2][1][1] == "2.1.1"); - TEST(447, gl1[gl2[0]][gl2[1]][gl2[2]] == "2.1.1"); - TEST(448, gl1[test_10(2)][test_10(1)][test_10(1)] == "2.1.1"); + TEST(449, gl1[1] == "TWO"); + TEST(450, gl1[3][0] == "x"); + TEST(451, gl1[3][1] == "y"); + TEST(452, gl1[2][1][1] == "2.1.1"); + TEST(453, gl1[gl2[0]][gl2[1]][gl2[2]] == "2.1.1"); + TEST(454, gl1[test_10(2)][test_10(1)][test_10(1)] == "2.1.1"); pause_on_error(0, FALSE); d1 = gl1[2][1][4]; /* range error */ pause_on_error(1, FALSE); - TEST(449, is_null(d1)); + TEST(455, is_null(d1)); } @@ -1786,23 +1795,23 @@ splice_1(void) /* [a, b, a, b] */ l += l; - TEST(450, length_of_list(l) == 4 && l[0] == "a" && l[1] == "b" && l[2] == "a" && l[3] == "b"); + TEST(456, length_of_list(l) == 4 && l[0] == "a" && l[1] == "b" && l[2] == "a" && l[3] == "b"); /* [x, x, b, a, b] */ l[0] = x; - TEST(451, length_of_list(l) == 5 && l[0] == "x" && l[1] == "x"); + TEST(457, length_of_list(l) == 5 && l[0] == "x" && l[1] == "x"); /* [x, x, b, a, b, Nul, Nul, Nul, Nul, x, x] */ l[9] = x; - TEST(452, length_of_list(l) == 11 && l[9] == "x"); + TEST(458, length_of_list(l) == 11 && l[9] == "x"); /* Join */ l = splice_l1 + splice_l1; - TEST(453, length_of_list(l) == 6); + TEST(459, length_of_list(l) == 6); /* Append */ l += splice_l1; - TEST(454, length_of_list(l) == 9); + TEST(460, length_of_list(l) == 9); } @@ -1824,22 +1833,22 @@ splice_2(void) list l = quote_list("red", "green", "blue"); splice(l, -1); - TEST(455, length_of_list(l) == 3 && l[2] == "blue"); + TEST(461, length_of_list(l) == 3 && l[2] == "blue"); splice(l, 999); - TEST(456, length_of_list(l) == 3 && l[2] == "blue"); + TEST(462, length_of_list(l) == 3 && l[2] == "blue"); splice(l, 3); - TEST(457, length_of_list(l) == 3 && l[2] == "blue"); + TEST(463, length_of_list(l) == 3 && l[2] == "blue"); splice(l, 2); - TEST(458, length_of_list(l) == 2 && l[1] == "green"); + TEST(464, length_of_list(l) == 2 && l[1] == "green"); splice(l, 0); - TEST(459, length_of_list(l) == 0); + TEST(465, length_of_list(l) == 0); splice(l, 0); - TEST(460, length_of_list(l) == 0); + TEST(466, length_of_list(l) == 0); } @@ -1850,13 +1859,13 @@ splice_3(void) list l2 = quote_list("red", "green", "blue"); splice(l1, 1, 2, "yellow", "orange", "pink"); - TEST(461, length_of_list(l1) == 4 && l1[0] == "red" && l1[1] == "yellow" && l1[2] == "orange" && l1[3] == "pink"); + TEST(467, length_of_list(l1) == 4 && l1[0] == "red" && l1[1] == "yellow" && l1[2] == "orange" && l1[3] == "pink"); splice(l2, 1, 2, "yellow"); - TEST(462, length_of_list(l2) == 2 && l2[0] == "red" && l2[1] == "yellow"); + TEST(468, length_of_list(l2) == 2 && l2[0] == "red" && l2[1] == "yellow"); splice(l2, -1, 0, "orange"); - TEST(463, length_of_list(l2) == 3 && l2[0] == "red" && l2[1] == "yellow" && l2[2] == "orange"); + TEST(469, length_of_list(l2) == 3 && l2[0] == "red" && l2[1] == "yellow" && l2[2] == "orange"); } @@ -1870,13 +1879,13 @@ splice_4(void) list l0 = quote_list(l1, l2, l3); splice(l0, 0, 3, l1, l2, l3, l4); - TEST(464, length_of_list(l0) == 4); + TEST(470, length_of_list(l0) == 4); splice(l0, 0, 0, l1, l2, l3, l4, l1, l2, l3, l4, l1, l2, l3, l4, l1, l2, l3, l4); - TEST(465, length_of_list(l0) == 20); + TEST(471, length_of_list(l0) == 20); splice(l0, -1, 0, l0); /* self reference */ - TEST(466, length_of_list(l0) == 21); + TEST(472, length_of_list(l0) == 21); } @@ -1909,49 +1918,49 @@ test_sort_list(void) list r; r = sort_list(NULL); // error - TEST(467, is_null(r)); + TEST(473, is_null(r)); r = sort_list(list_0); - TEST(468, is_null(r)); + TEST(474, is_null(r)); r = sort_list(list_1); - TEST(469, length_of_list(r) == 1 && r[0] == "a"); + TEST(475, length_of_list(r) == 1 && r[0] == "a"); r = sort_list(list_2); - TEST(470, length_of_list(r) == 2 && r[0] == "a"); + TEST(476, length_of_list(r) == 2 && r[0] == "a"); r = sort_list(list_3); - TEST(471, length_of_list(r) == 3 && r[0] == "a"); + TEST(477, length_of_list(r) == 3 && r[0] == "a"); r = sort_list(list_7); - TEST(472, length_of_list(r) == 7 && r[0] == "a"); + TEST(478, length_of_list(r) == 7 && r[0] == "a"); r = sort_list(list_2, 0); // forward - TEST(473, length_of_list(r) == 2 && r[0] == "a"); + TEST(479, length_of_list(r) == 2 && r[0] == "a"); r = sort_list(list_7, 0); - TEST(474, length_of_list(r) == 7 && r[0] == "a"); + TEST(480, length_of_list(r) == 7 && r[0] == "a"); r = sort_list(list_2, 1); // backwards - TEST(475, length_of_list(r) == 2 && r[0] == "b"); + TEST(481, length_of_list(r) == 2 && r[0] == "b"); r = sort_list(list_7, 1); - TEST(476, length_of_list(r) == 7 && r[0] == "z"); + TEST(482, length_of_list(r) == 7 && r[0] == "z"); r = sort_list(list_2, "::sort_forward"); - TEST(477, length_of_list(r) == 2 && r[0] == "a"); + TEST(483, length_of_list(r) == 2 && r[0] == "a"); r = sort_list(list_7, "::sort_forward"); - TEST(478, length_of_list(r) == 7 && r[0] == "a"); + TEST(484, length_of_list(r) == 7 && r[0] == "a"); r = sort_list(list_2, "::sort_backward"); - TEST(479, length_of_list(r) == 2 && r[0] == "b"); + TEST(485, length_of_list(r) == 2 && r[0] == "b"); r = sort_list(list_7, "::sort_backward"); - TEST(480, length_of_list(r) == 7 && r[0] == "z"); + TEST(486, length_of_list(r) == 7 && r[0] == "z"); // qsort r = sort_list(list_7, NULL, 1); - TEST(481, length_of_list(r) == 7 && r[0] == "a"); + TEST(487, length_of_list(r) == 7 && r[0] == "a"); // mergesort r = sort_list(list_7, NULL, 2); - TEST(482, length_of_list(r) == 7 && r[0] == "a"); + TEST(488, length_of_list(r) == 7 && r[0] == "a"); // heapsort r = sort_list(list_7, NULL, 3); - TEST(483, length_of_list(r) == 7 && r[0] == "a"); + TEST(489, length_of_list(r) == 7 && r[0] == "a"); } @@ -1966,56 +1975,56 @@ test_sprintf(void) int i; // numeric padding - TEST(484, format("%4d", 12) == " 12"); // padded - TEST(485, format("%-4d", 12) == "12 "); // padded, left justify - TEST(486, format("%-4d", 12345) == "12345"); // untruncated + TEST(490, format("%4d", 12) == " 12"); // padded + TEST(491, format("%-4d", 12) == "12 "); // padded, left justify + TEST(492, format("%-4d", 12345) == "12345"); // untruncated // string padding - TEST(487, format("%4s", "12") == " 12"); // padded - TEST(488, format("%-4s", "12") == "12 "); // padded, left justify - TEST(489, format("%-4s", "12345") == "12345"); // untruncated + TEST(493, format("%4s", "12") == " 12"); // padded + TEST(494, format("%-4s", "12") == "12 "); // padded, left justify + TEST(495, format("%-4s", "12345") == "12345"); // untruncated // string truncation - TEST(490, format("%.4s", "12") == "12"); // padded - TEST(491, format("%.4s", "12345") == "1234"); // truncated + TEST(496, format("%.4s", "12") == "12"); // padded + TEST(497, format("%.4s", "12345") == "1234"); // truncated // enhanced features - TEST(492, sprintf(s1, "Hello world") == 11); - TEST(493, sprintf(s1, "%*s", 20, "") == 20); - TEST(494, sprintf(s1, "%b", 0xf3) == 8 && s1 == "11110011"); - TEST(495, sprintf(s1, "val=%B", 3, "\10\2BITTWO\1BITONE") == 20 && + TEST(498, sprintf(s1, "Hello world") == 11); + TEST(499, sprintf(s1, "%*s", 20, "") == 20); + TEST(500, sprintf(s1, "%b", 0xf3) == 8 && s1 == "11110011"); + TEST(501, sprintf(s1, "val=%B", 3, "\10\2BITTWO\1BITONE") == 20 && s1 == "val=3"); - TEST(496, sprintf(s1, "12345%n6", "i") == 6 && i == 5); + TEST(502, sprintf(s1, "12345%n6", "i") == 6 && i == 5); // error cases - TEST(497, sprintf(s1, "%s", NULL) && s1 == ""); - TEST(498, sprintf(s1, "%s") && s1 == ""); - TEST(499, sprintf(s1, "%d", NULL) && s1 == "0"); - TEST(500, sprintf(s1, "%c", NULL) && s1 == " "); - TEST(501, sprintf(s1, "%.2f", NULL) && s1 == "0.00"); - TEST(502, sprintf(s1, "%y") && s1 == "y"); + TEST(503, sprintf(s1, "%s", NULL) && s1 == ""); + TEST(504, sprintf(s1, "%s") && s1 == ""); + TEST(505, sprintf(s1, "%d", NULL) && s1 == "0"); + TEST(506, sprintf(s1, "%c", NULL) && s1 == " "); + TEST(507, sprintf(s1, "%.2f", NULL) && s1 == "0.00"); + TEST(508, sprintf(s1, "%y") && s1 == "y"); // format - TEST(503, format("Hello World") == "Hello World"); - TEST(504, format("%b", 0xf3) == "11110011"); + TEST(509, format("Hello World") == "Hello World"); + TEST(510, format("%b", 0xf3) == "11110011"); // large argument list - TEST(505, format("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", + TEST(511, format("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", "1.", "2.", "3.", "4.", "5.", "6.", "7.", "8.", "9.", "10.", "11.", "12.", "13.", "14.", "15.", "16.") == "1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16."); - TEST(506, format("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", + TEST(512, format("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", "1.", "2.", "3.", "4.", "5.", "6.", "7.", "8.", "9.", "10.", "11.", "12.", "13.", "14.", "15.", "16.", "1.", "2.", "3.", "4.", "5.", "6.", "7.", "8.", "9.", "10.", "11.", "12.", "13.", "14.", "15.", "16.") == "1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16."); - TEST(507, format("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", + TEST(513, format("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", "1.", "2.", "3.", "4.", "5.", "6.", "7.", "8.", "9.", "10.", "11.", "12.", "13.", "14.", "15.", "16.", "1.", "2.", "3.", "4.", "5.", "6.", "7.", "8.", "9.", "10.", "11.", "12.", "13.", "14.", "15.", "16.", "1.", "2.", "3.", "4.", "5.", "6.", "7.", "8.", "9.", "10.", "11.", "12.", "13.", "14.", "15.", "16.") == "1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16."); - TEST(508, format("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", + TEST(514, format("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", "1.", "2.", "3.", "4.", "5.", "6.", "7.", "8.", "9.", "10.", "11.", "12.", "13.", "14.", "15.", "16.", "1.", "2.", "3.", "4.", "5.", "6.", "7.", "8.", "9.", "10.", "11.", "12.", "13.", "14.", "15.", "16.", "1.", "2.", "3.", "4.", "5.", "6.", "7.", "8.", "9.", "10.", "11.", "12.", "13.", "14.", "15.", "16.", @@ -2043,35 +2052,35 @@ __regress_replacement(int x, // return original 2th parameter // ret = __regress_replacement(2, a, b, c, d); - TEST(509, ret == a); + TEST(515, ret == a); break; case 2: // return original 2th parameter // ret = __regress_replacement(2, NULL, b, c, d); - TEST(510, ret == a); + TEST(516, ret == a); break; case 3: // return override 2th parameter // ret = __regress_replacement(2, 999, b, c, d); - TEST(511, ret == 999); + TEST(517, ret == 999); break; case 4: // return original 6th parameter // ret = __regress_replacement(6, a, b, c, d); - TEST(512, ret == e); + TEST(518, ret == e); break; case 5: // return original 6th parameter // ret = __regress_replacement(6, a, b, c, d, NULL); - TEST(513, ret == e); + TEST(519, ret == e); } return 42; } @@ -2089,7 +2098,7 @@ test_replacement(void) ret = __regress_replacement(3, 1, "2", l3, 4, 5, "6", l7, 8); ret = __regress_replacement(4, 1, "2", l3, 4, 5, "6", l7, 8); ret = __regress_replacement(5, 1, "2", l3, 4, 5, "6", l7, 8); - TEST(514, ret == 42); + TEST(520, ret == 42); } @@ -2100,21 +2109,21 @@ test_replacement(void) static void test_isa(void) { - TEST(515, isalpha('A')); - TEST(516, isascii('A')); - TEST(517, iscntrl(0x01)); - TEST(518, iscsym('_')); - TEST(519, isgraph('A')); - TEST(520, isprint('A')); - TEST(521, ispunct('!')); + TEST(521, isalpha('A')); + TEST(522, isascii('A')); + TEST(523, iscntrl(0x01)); + TEST(524, iscsym('_')); + TEST(525, isgraph('A')); + TEST(526, isprint('A')); + TEST(527, ispunct('!')); - TEST(522, isdigit('1') && isdigit(0x30) && isdigit("a1a", 2)); - TEST(523, isdigit("1a1") && isdigit("a1a", 2) && !isdigit("a1a", -1) && !isdigit("", 1)); - TEST(524, islower('a') && !islower('A')); - TEST(525, isupper('A') && !isupper('a')); - TEST(526, isalnum('Z') && !isalnum('*')); - TEST(527, isxdigit('f') && isxdigit('F') && isxdigit('1')); - TEST(528, isspace(' ') && isspace('\t') && isspace('\n') && !isspace('a')); + TEST(528, isdigit('1') && isdigit(0x30) && isdigit("a1a", 2)); + TEST(529, isdigit("1a1") && isdigit("a1a", 2) && !isdigit("a1a", -1) && !isdigit("", 1)); + TEST(530, islower('a') && !islower('A')); + TEST(531, isupper('A') && !isupper('a')); + TEST(532, isalnum('Z') && !isalnum('*')); + TEST(533, isxdigit('f') && isxdigit('F') && isxdigit('1')); + TEST(534, isspace(' ') && isspace('\t') && isspace('\n') && !isspace('a')); } @@ -2125,23 +2134,23 @@ test_isa(void) static void test_basedir(void) { - TEST(529, basename("dir/file") == "file"); - TEST(530, basename("dir/file.c", ".c") == "file"); - TEST(531, basename("", "") == ""); - TEST(532, basename("//", "") == "/"); - TEST(533, basename("dir/file/") == "file"); - TEST(534, basename("dir\\file/") == "file"); - TEST(535, basename("/x/") == "x"); - TEST(536, basename("x/") == "x"); - TEST(537, basename("/x") == "x"); + TEST(535, basename("dir/file") == "file"); + TEST(536, basename("dir/file.c", ".c") == "file"); + TEST(537, basename("", "") == ""); + TEST(538, basename("//", "") == "/"); + TEST(539, basename("dir/file/") == "file"); + TEST(540, basename("dir\\file/") == "file"); + TEST(541, basename("/x/") == "x"); + TEST(542, basename("x/") == "x"); + TEST(543, basename("/x") == "x"); - TEST(538, dirname(".") == "."); - TEST(539, dirname("/") == "/"); - TEST(540, dirname("//") == "/"); - TEST(541, dirname("/xx") == "/"); - TEST(542, dirname("//xx") == "/"); - TEST(543, dirname("aaa/bbb") == "aaa"); - TEST(544, dirname("aaaa//bbb/cccc///") == "aaaa//bbb" ); + TEST(544, dirname(".") == "."); + TEST(545, dirname("/") == "/"); + TEST(546, dirname("//") == "/"); + TEST(547, dirname("/xx") == "/"); + TEST(548, dirname("//xx") == "/"); + TEST(549, dirname("aaa/bbb") == "aaa"); + TEST(550, dirname("aaaa//bbb/cccc///") == "aaaa//bbb" ); } @@ -2153,21 +2162,21 @@ static void test_env(void) { putenv("GRREGRESS", "home"); - TEST(545, getenv("GRREGRESS") == "home"); - TEST(546, expandpath("$$/filename", 0x3) == "$/filename"); - TEST(547, expandpath("$GRREGRESS", 0x3) == "home"); - TEST(548, expandpath("$GRREGRESS/", 0x3) == "home/"); - TEST(549, expandpath("${GRREGRESS}xxx/", 0x3) == "homexxx/"); - TEST(550, expandpath("$(GRREGRESS)xxx/", 0x3) == "homexxx/"); + TEST(551, getenv("GRREGRESS") == "home"); + TEST(552, expandpath("$$/filename", 0x3) == "$/filename"); + TEST(553, expandpath("$GRREGRESS", 0x3) == "home"); + TEST(554, expandpath("$GRREGRESS/", 0x3) == "home/"); + TEST(555, expandpath("${GRREGRESS}xxx/", 0x3) == "homexxx/"); + TEST(556, expandpath("$(GRREGRESS)xxx/", 0x3) == "homexxx/"); /*invalid*/ - TEST(551, expandpath("${GRREGRESSxxx/", 0x3) == "${GRREGRESSxxx/"); - TEST(552, expandpath("$(GRREGRESSxxx/", 0x3) == "$(GRREGRESSxxx/"); - TEST(553, expandpath("${GRREGRESSxxx", 0x3) == "${GRREGRESSxxx"); - TEST(554, expandpath("$(GRREGRESSxxx", 0x3) == "$(GRREGRESSxxx"); - TEST(555, expandpath("$UNKNOWN/", 0x3) == "/"); - TEST(556, expandpath("$(UNKNOWN)xxx/", 0x3) == "xxx/"); - TEST(557, expandpath("${UNKNOWN}xxx/", 0x3) == "xxx/"); + TEST(557, expandpath("${GRREGRESSxxx/", 0x3) == "${GRREGRESSxxx/"); + TEST(558, expandpath("$(GRREGRESSxxx/", 0x3) == "$(GRREGRESSxxx/"); + TEST(559, expandpath("${GRREGRESSxxx", 0x3) == "${GRREGRESSxxx"); + TEST(560, expandpath("$(GRREGRESSxxx", 0x3) == "$(GRREGRESSxxx"); + TEST(561, expandpath("$UNKNOWN/", 0x3) == "/"); + TEST(562, expandpath("$(UNKNOWN)xxx/", 0x3) == "xxx/"); + TEST(563, expandpath("${UNKNOWN}xxx/", 0x3) == "xxx/"); } @@ -2182,22 +2191,22 @@ test_register(void) register_macro(REG_REGRESS, "__regress_event"); call_registered_macro(REG_REGRESS); - TEST(558, 1 == event); + TEST(564, 1 == event); event = 0; register_macro(REG_REGRESS, "__regress_event"); reregister_macro(REG_REGRESS, "__regress_event"); call_registered_macro(REG_REGRESS); - TEST(559, 2 == event); + TEST(565, 2 == event); event = 0; unregister_macro(REG_REGRESS, "__regress_event"); call_registered_macro(REG_REGRESS); - TEST(560, 1 == event); + TEST(566, 1 == event); event = 0; unregister_macro(REG_REGRESS, "__regress_event"); - TEST(561, 0 == event); + TEST(567, 0 == event); } @@ -2220,13 +2229,13 @@ test_buffer(void) if ((buf = create_buffer("-regress-buffer-", NULL, TRUE)) == -1) { return; } - TEST(562, curbuf == inq_buffer()); - TEST(563, curbuf == set_buffer(buf)); - TEST(564, buf == inq_buffer()); - TEST(565, 0 != inq_system()); - TEST(566, (inq_buffer_flags(buf) & BF_SYSBUF) == BF_SYSBUF); - TEST(567, 0 != inq_buffer_flags(NULL, "sysbuf")); - TEST(568, 0 == inq_modified()); + TEST(568, curbuf == inq_buffer()); + TEST(569, curbuf == set_buffer(buf)); + TEST(570, buf == inq_buffer()); + TEST(571, 0 != inq_system()); + TEST(572, (inq_buffer_flags(buf) & BF_SYSBUF) == BF_SYSBUF); + TEST(573, 0 != inq_buffer_flags(NULL, "sysbuf")); + TEST(574, 0 == inq_modified()); //TODO // set_attribute() // inq_attribute() @@ -2242,40 +2251,40 @@ test_buffer(void) top_of_buffer(); count = insert(sval); - TEST(569, slen == count); - TEST(570, slen == inq_line_length()); + TEST(575, slen == count); + TEST(576, slen == inq_line_length()); top_of_buffer(); line = read(NULL, status); - TEST(571, status == 1); /* EOF */ - TEST(572, line == sval); + TEST(577, status == 1); /* EOF */ + TEST(578, line == sval); line = read(slen, status); - TEST(573, status == 1); /* EOF */ - TEST(574, line == sval); + TEST(579, status == 1); /* EOF */ + TEST(580, line == sval); line = read(1, status); - TEST(575, status == 0); /* partial */ - TEST(576, line == "1"); + TEST(581, status == 0); /* partial */ + TEST(582, line == "1"); line = read(9, status); - TEST(577, status == 0); /* partial */ - TEST(578, line == "123456789"); + TEST(583, status == 0); /* partial */ + TEST(584, line == "123456789"); top_of_buffer(); count = insertf("%s\n", "abcdefg1234567890"); - TEST(579, 18 == count); - TEST(580, slen == inq_line_length()); + TEST(585, 18 == count); + TEST(586, slen == inq_line_length()); top_of_buffer(); line = read(NULL, status); - TEST(581, status == 1); /* EOF */ - TEST(582, line == "abcdefg1234567890\n"); + TEST(587, status == 1); /* EOF */ + TEST(588, line == "abcdefg1234567890\n"); } restore_position(2); - TEST(583, curbuf == inq_buffer()); - TEST(584, curwin == inq_window()); + TEST(589, curbuf == inq_buffer()); + TEST(590, curwin == inq_window()); delete_buffer(buf); } @@ -2294,44 +2303,44 @@ test_edit(void) ///////////////////////////////////////////////////// ret = edit_file(EDIT_SYSTEM, junk); - TEST(585, ret == -1); // unable to create + TEST(591, ret == -1); // unable to create ret = edit_file(EDIT_SYSTEM, temp1); - TEST(586, ret == 1); // open, standard return + TEST(592, ret == 1); // open, standard return delete_buffer(inq_buffer()); remove(temp1); remove(temp2); ret = edit_file(EDIT_SYSTEM|EDIT_RC, temp2); - TEST(587, ret == 2); // created, extended + TEST(593, ret == 2); // created, extended ret = edit_file(EDIT_SYSTEM|EDIT_RC, temp2); - TEST(588, ret == 3); // reopen, extended + TEST(594, ret == 3); // reopen, extended delete_buffer(inq_buffer()); remove(temp2); ///////////////////////////////////////////////////// files = -1; ret = edit_file2(files, NULL, EDIT_SYSTEM, junk); - TEST(589, ret == -1); // unable to create - TEST(590, files == 0); + TEST(595, ret == -1); // unable to create + TEST(596, files == 0); files = -1; ret = edit_file2(files, NULL, EDIT_SYSTEM, temp1); - TEST(591, ret == 1); // open, standard return - TEST(592, files == 1); + TEST(597, ret == 1); // open, standard return + TEST(598, files == 1); delete_buffer(inq_buffer()); remove(temp1); files = -1; ret = edit_file2(files, NULL, EDIT_SYSTEM|EDIT_RC, temp2); - TEST(593, ret == 2); // created, extended - TEST(594, files == 1); + TEST(599, ret == 2); // created, extended + TEST(600, files == 1); files = -1; ret = edit_file2(files, NULL, EDIT_SYSTEM|EDIT_RC, temp2); - TEST(595, ret == 3); // reopen, extended - TEST(596, files == 1); + TEST(601, ret == 3); // reopen, extended + TEST(602, files == 1); delete_buffer(inq_buffer()); remove(temp2); @@ -2342,7 +2351,7 @@ test_edit(void) static void test_key(void) { - TEST(597, int_to_key(key_to_int("")) == ""); + TEST(603, int_to_key(key_to_int("")) == ""); } @@ -2352,11 +2361,11 @@ test_debug(void) list l1; l1 = debug_support(DBG_INQ_VARS, 0); - TEST(598, is_list(l1)); + TEST(604, is_list(l1)); l1 = debug_support(DBG_STACK_TRACE, NULL, ""); - TEST(599, is_list(l1)); + TEST(605, is_list(l1)); l1 = debug_support(DBG_INQ_VAR_INFO, 0, "l1"); - TEST(600, is_list(l1)); + TEST(606, is_list(l1)); } @@ -2366,27 +2375,27 @@ test_strtol(void) int ret, endp; ret = strtol("xxx"); /* basic */ - TEST(601, ret == 0); + TEST(607, ret == 0); ret = strtol("1"); /* dec */ - TEST(602, ret == 1); + TEST(608, ret == 1); ret = strtol("01"); /* oct */ - TEST(603, ret == 1); + TEST(609, ret == 1); ret = strtol("0x1"); /* hex */ - TEST(604, ret == 1); + TEST(610, ret == 1); ret = strtol("g", NULL, 36); /* base 36 (0123456789abc...) */ - TEST(605, ret == 16); + TEST(611, ret == 16); ret = strtol("xxx", endp); /* invalid */ - TEST(606, ret == 0); - TEST(607, endp == 0); + TEST(612, ret == 0); + TEST(613, endp == 0); ret = strtol("12", endp); - TEST(608, ret == 12); - TEST(609, endp == 3); + TEST(614, ret == 12); + TEST(615, endp == 3); } @@ -2397,24 +2406,24 @@ test_strtof(void) int endp; ret = strtof("0.0"); /* dec */ - TEST(610, ret == 0.0); + TEST(616, ret == 0.0); ret = strtof("1.0"); /* dec */ - TEST(611, ret == 1.0); + TEST(617, ret == 1.0); ret = strtof("xxx", endp); /* invalid */ - TEST(612, ret == 0); - TEST(613, endp == 0); + TEST(618, ret == 0); + TEST(619, endp == 0); ret = strtof("0.0"); /* dec */ - TEST(614, ret == 0.0); + TEST(620, ret == 0.0); ret = strtof("1.0"); /* dec */ - TEST(615, ret == 1.0); + TEST(621, ret == 1.0); ret = strtof("xxx", endp); /* invalid */ - TEST(616, ret == 0); - TEST(617, endp == 0); + TEST(622, ret == 0); + TEST(623, endp == 0); } @@ -2425,45 +2434,45 @@ test_strtod(void) int endp; ret = strtod("0.0"); /* dec */ - TEST(618, ret == 0.0); + TEST(624, ret == 0.0); ret = strtod("1.0"); /* dec */ - TEST(619, ret == 1.0); + TEST(625, ret == 1.0); ret = strtod("xxx", endp); /* invalid */ - TEST(620, ret == 0); - TEST(621, endp == 0); + TEST(626, ret == 0); + TEST(627, endp == 0); ret = strtod("0.0"); /* dec */ - TEST(622, ret == 0.0); + TEST(628, ret == 0.0); ret = strtod("1.0"); /* dec */ - TEST(623, ret == 1.0); + TEST(629, ret == 1.0); ret = strtod("xxx", endp); /* invalid */ - TEST(624, ret == 0); - TEST(625, endp == 0); + TEST(630, ret == 0); + TEST(631, endp == 0); } static void test_defaults1(int value = 666) { - TEST(626, value == 666); + TEST(632, value == 666); } static void test_defaults2(string value = "666") { - TEST(627, value == "666"); + TEST(633, value == "666"); } static void test_defaults3(string value = 1.1) { - TEST(628, value == 1.1); + TEST(634, value == 1.1); } @@ -2505,11 +2514,11 @@ test_reference(void) float fvalue = 1; test_reference1(ivalue); - TEST(629, ivalue == 2); + TEST(635, ivalue == 2); test_reference2(svalue); - TEST(630, svalue == "two"); + TEST(636, svalue == "two"); test_reference3(fvalue); - TEST(631, fvalue == 2); + TEST(637, fvalue == 2); } @@ -2529,7 +2538,7 @@ test_pushpop(void) sprintf(msg, "work%04d", i); push(l, msg); } - TEST(632, length_of_list(l) == 1000); + TEST(638, length_of_list(l) == 1000); for (i = i-1; i >= 0; --i) { sprintf(msg, "work%04d", i); @@ -2538,13 +2547,13 @@ test_pushpop(void) break; } } - TEST(633, success); + TEST(639, success); - TEST(634, length_of_list(l) == 0); + TEST(640, length_of_list(l) == 0); pause_on_error(0, FALSE); r = pop(l); pause_on_error(1, FALSE); - TEST(635, is_null(r)); /* FIXME/XXX - is_null(pop(l)) broken/limitation of LVAL's */ + TEST(641, is_null(r)); /* FIXME/XXX - is_null(pop(l)) broken/limitation of LVAL's */ } @@ -2553,12 +2562,12 @@ test_globals(void) { int line, col; - TEST(636, inq_window() == current_window); - TEST(637, inq_buffer() == current_buffer); + TEST(642, inq_window() == current_window); + TEST(643, inq_buffer() == current_buffer); inq_position(line, col); - TEST(638, line == current_line); + TEST(644, line == current_line); inq_position(line, col); - TEST(639, col == current_col); + TEST(645, col == current_col); } @@ -2569,7 +2578,7 @@ test_globals(void) static void test_search(void) { - TEST(640, quote_regexp("<>") == "\\<\\>"); + TEST(646, quote_regexp("<>") == "\\<\\>"); // search string // search buffer } @@ -2587,17 +2596,17 @@ test_search(void) static void test_called(void) { - TEST(641, "test_called" == caller()); + TEST(647, "test_called" == caller()); set_calling_name(""); - TEST(642, "" == caller()); + TEST(648, "" == caller()); set_calling_name("test_called"); - TEST(643, "test_called" == caller()); + TEST(649, "test_called" == caller()); set_calling_name("hello_world"); - TEST(644, "hello_world" == caller()); + TEST(650, "hello_world" == caller()); set_calling_name(inq_called()); - TEST(645, "regress" == caller()); + TEST(651, "regress" == caller()); set_calling_name(NULL); /* extension, reset/clear */ - TEST(646, "test_called" == caller()); + TEST(652, "test_called" == caller()); } @@ -2618,16 +2627,16 @@ test_macro(void) int ret; ret = inq_macro("regress"); /* defined */ - TEST(647, ret == 1); + TEST(653, ret == 1); ret = inq_macro("list_of_dictionaries"); /* builtin */ - TEST(648, ret == 0); + TEST(654, ret == 0); ret = inq_macro("cut"); /* replacement */ - TEST(649, ret == 2); + TEST(655, ret == 2); ret = inq_macro("this_should_not_be_undefined"); - TEST(650, ret == -1); /* undefined */ + TEST(656, ret == -1); /* undefined */ } @@ -2643,12 +2652,12 @@ test_undef(void) // // control how 'undefines' are handled?? // try { if (1) { - TEST(651, inq_symbol("undefined_ival") == 0); - TEST(652, inq_symbol("undefined_fval") == 0); - TEST(653, inq_symbol("undefined_sval") == 0); - TEST(654, undefined_ival == 0); /* wont be executed! */ - TEST(655, undefined_fval == 0); /* wont be executed! */ - TEST(656, undefined_sval == ""); /* wont be executed! */ + TEST(657, inq_symbol("undefined_ival") == 0); + TEST(658, inq_symbol("undefined_fval") == 0); + TEST(659, inq_symbol("undefined_sval") == 0); + TEST(660, undefined_ival == 0); /* wont be executed! */ + TEST(661, undefined_fval == 0); /* wont be executed! */ + TEST(662, undefined_sval == ""); /* wont be executed! */ } // } catch { // } finally { @@ -2667,12 +2676,12 @@ test_history(void) const string top = inq_macro_history(0); /* or from features */ - TEST(657, top == "execute_macro" || top == "sel_list"); - TEST(658, inq_command() == inq_macro_history()); + TEST(663, top == "execute_macro" || top == "sel_list"); + TEST(664, inq_command() == inq_macro_history()); set_macro_history(0, "function1"); set_macro_history(1, "function2"); - TEST(659, "function1" == inq_macro_history()); - TEST(660, "function2" == inq_macro_history(1)); + TEST(665, "function1" == inq_macro_history()); + TEST(666, "function2" == inq_macro_history(1)); } @@ -2684,27 +2693,26 @@ static void test_scope(void) { if (first_time()) { /* can only be run once */ - TEST(661, 1 == scope_1()); - TEST(662, 2 == scope_1()); - TEST(663, 3 == scope_1()); + TEST(667, 1 == scope_1()); + TEST(668, 2 == scope_1()); + TEST(669, 3 == scope_1()); - TEST(664, 1 == scope_2()); - TEST(665, 2 == scope_2()); - TEST(666, 3 == scope_2()); + TEST(670, 1 == scope_2()); + TEST(671, 2 == scope_2()); + TEST(672, 3 == scope_2()); - TEST(667, 1 == scope_3()); - TEST(668, 2 == scope_3()); - TEST(669, 3 == scope_3()); + TEST(673, 1 == scope_3()); + TEST(674, 2 == scope_3()); + TEST(675, 3 == scope_3()); } else { /* emulate */ extern int num_passed; num_passed += 9; } - TESTASYNC(670, 0 == inq_symbol("x_extern_dontexist")); - TEST(671, 0 != inq_symbol("x_static")); + TESTASYNC(676, 0 == inq_symbol("x_extern_dontexist")); + TEST(677, 0 != inq_symbol("x_static")); } - static int scope_1(void) { @@ -2757,38 +2765,38 @@ test_dict(void) /* create dictionaries */ dict = create_dictionary(); - TEST(672, dict); + TEST(678, dict); dict2 = create_dictionary("namedict"); - TEST(673, dict2); + TEST(679, dict2); /* basic set/get primitives */ set_property(dict, "property", 1234); var = get_property(dict, "property"); - TEST(674, 1234 == var); + TEST(680, 1234 == var); set_property(dict, "property", "hello world"); var = get_property(dict, "property"); - TEST(675, "hello world" == var); + TEST(681, "hello world" == var); /* indirection operators */ dict.value = "value1"; /* FIXME/XXX - compiler issues yet resolved */ - TEST(676, "value1" == dict.value); + TEST(682, "value1" == dict.value); dict2.value = "value2"; dict.indirect = dict2; /* FIXME/XXX - reference count issues */ - TEST(677, "value2" == dict.indirect.value); + TEST(683, "value2" == dict.indirect.value); ret = dict_exists(dict, "property"); - TEST(678, ret); + TEST(684, ret); l1 = dict_list(dict); - TEST(679, is_list(l1)); - TEST(680, 3 == length_of_list(l1)); + TEST(685, is_list(l1)); + TEST(686, 3 == length_of_list(l1)); set_property(dict, "property2", 1234); set_property(dict, "property3", 5678); l1 = dict_list(dict); - TEST(681, 5 == length_of_list(l1)); + TEST(687, 5 == length_of_list(l1)); // FIXME/XXX -- // compiler bug, allows declare when string expected. @@ -2801,36 +2809,36 @@ test_dict(void) while ((idx = dict_each(dict, key, value)) >= 0) { switch(key) { case "property": - TESTASYNC(682, "hello world" == value); + TESTASYNC(688, "hello world" == value); ++count; break; case "property2": - TESTASYNC(683, 1234 == value); + TESTASYNC(689, 1234 == value); ++count; break; case "property3": - TESTASYNC(684, 5678 == value); + TESTASYNC(690, 5678 == value); ++count; break; } } - TESTASYNC(685, 3 == count); + TESTASYNC(691, 3 == count); ret = dict_delete(dict, "property"); - TEST(686, 0 == ret); + TEST(692, 0 == ret); l1 = dict_list(dict); - TEST(687, is_list(l1)); - TEST(688, 4 == length_of_list(l1)); + TEST(693, is_list(l1)); + TEST(694, 4 == length_of_list(l1)); l1 = list_of_dictionaries(); - TEST(689, is_list(l1)); - TEST(690, length_of_list(l1) >= 2); /* all dictionaries */ + TEST(695, is_list(l1)); + TEST(696, length_of_list(l1) >= 2); /* all dictionaries */ ret = delete_dictionary(dict); - TEST(691, 0 == ret); + TEST(697, 0 == ret); ret = delete_dictionary(dict2); - TEST(692, 0 == ret); + TEST(698, 0 == ret); } @@ -2842,7 +2850,7 @@ test_dict(void) static int test_leaks(void) { - TEST(693, leak_1(1000) == 1000); /* list are limited 2^16 atoms */ + TEST(699, leak_1(1000) == 1000); /* list are limited 2^16 atoms */ } @@ -2947,8 +2955,8 @@ regress_renumber(void) while (re_search(0, "TES[A-Z]+([0-9]+,") > 0) { /* * examples: - * TEST(694, - * TESTASYNC(695, + * TEST(700, + * TESTASYNC(701, */ line = read(18); delete_char(index(line, ",")); @@ -2967,4 +2975,3 @@ regress_renumber(void) } /*end*/ - diff --git a/macsrc/demos/regress2.cr b/macsrc/demos/regress2.cr index 23b27505..47e4ebb5 100644 --- a/macsrc/demos/regress2.cr +++ b/macsrc/demos/regress2.cr @@ -1,6 +1,6 @@ /* -*- mode: cr; indent-width: 4; -*- */ /* charset=utf8 - * $Id: regress2.cr,v 1.26 2024/05/24 17:57:08 cvsuser Exp $ + * $Id: regress2.cr,v 1.30 2024/08/02 12:59:02 cvsuser Exp $ * Regression tests ... part2. * * @@ -47,6 +47,7 @@ static void test_getsubopt(void); static void test_parsename(void); static void test_command_list(void); static void test_file(void); +static void test_splitpath(void); static void test_module(void); static void test_misc(void); static void test_try(void); @@ -55,6 +56,7 @@ static void test_ruler(void); static void test_datetime(void); static void test_sysinfo(void); static void test_ini(void); +static void test_block(void); static void test_register_int(void); static void test_unicode_version(void); @@ -140,6 +142,7 @@ regress2(void) test_parsename(); test_command_list(); test_file(); + test_splitpath(); test_module(); test_misc(); // test_try(); @@ -334,31 +337,44 @@ test_split(void) l = split("a||b", "|"); TEST(1026, length_of_list(l) == 2); + /* limit */ + l = split("a|b", "|", NULL, NULL, NULL, 1); + TEST(1027, l[0] == "a|b"); + + l = split("a|b", "|", NULL, NULL, NULL, 2); + TEST(1028, l[0] == "a" && l[1] == "b"); + + l = split("a|b|c", "|", NULL, NULL, NULL, 3); + TEST(1029, l[0] == "a" && l[1] == "b" && l[2] == "c"); + + l = split("a|b|c", "|", NULL, NULL, NULL, 2); + TEST(1030, l[0] == "a" && l[1] == "b|c"); + /* numeric */ l = split("a|16|b|32", "|", 1); - TEST(1027, l[1] == 16 && l[3] == 32); + TEST(1031, l[1] == 16 && l[3] == 32); /* numeric, enhanced */ l = split("a|0x10|b|020|c|0b10000", "|", 2); - TEST(1028, l[1] == 16 && l[3] == 16 && l[5] == 16); + TEST(1032, l[1] == 16 && l[3] == 16 && l[5] == 16); /* empties */ l = split("a||b", "|", NULL, NULL, TRUE); - TEST(1029, length_of_list(l) == 3); + TEST(1033, length_of_list(l) == 3); l = split("a|b|", "|", NULL, NULL, TRUE); - TEST(1030, length_of_list(l) == 3); + TEST(1034, length_of_list(l) == 3); /* character mode */ l = split("a|b|c", '|'); - TEST(1031, length_of_list(l) == 3); + TEST(1035, length_of_list(l) == 3); /* quoted */ l = split("a,\" b \",c", ",\""); - TEST(1032, length_of_list(l) == 3 && l[1] == " b "); + TEST(1036, length_of_list(l) == 3 && l[1] == " b "); l = split("a,\" b' \",' c\" '", ",\"'"); - TEST(1033, length_of_list(l) == 3 && l[1] == " b' " && l[2] == " c\" "); + TEST(1037, length_of_list(l) == 3 && l[1] == " b' " && l[2] == " c\" "); } @@ -372,16 +388,16 @@ test_split_arguments(void) list l; l = split_arguments("aaa"); - TEST(1034, 1 == length_of_list(l)); + TEST(1038, 1 == length_of_list(l)); l = split_arguments("aaa bbb ccc ddd eee"); - TEST(1035, 5 == length_of_list(l)); + TEST(1039, 5 == length_of_list(l)); l = split_arguments("\"aaa bbb\" \"ccc ddd\" eee"); - TEST(1036, 3 == length_of_list(l)); + TEST(1040, 3 == length_of_list(l)); l = split_arguments(""); - TEST(1037, 0 == length_of_list(l)); + TEST(1041, 0 == length_of_list(l)); } @@ -395,19 +411,19 @@ test_tokenize(void) list l; l = tokenize("hello world", ""); - TEST(1038, length_of_list(l) == 0); + TEST(1042, length_of_list(l) == 0); l = tokenize("hello world", " "); - TEST(1039, length_of_list(l) == 2 && "hello" == l[0] && "world" == l[1]); + TEST(1043, length_of_list(l) == 2 && "hello" == l[0] && "world" == l[1]); l = tokenize("hello world", ' '); - TEST(1040, length_of_list(l) == 2 && "hello" == l[0] && "world" == l[1]); + TEST(1044, length_of_list(l) == 2 && "hello" == l[0] && "world" == l[1]); l = tokenize("' hello ' ' world '", ' ', TOK_SINGLE_QUOTES); - TEST(1041, length_of_list(l) == 2 && " hello " == l[0] && " world " == l[1]); + TEST(1045, length_of_list(l) == 2 && " hello " == l[0] && " world " == l[1]); l = tokenize("\" hello \" \" world \"", ' ', TOK_DOUBLE_QUOTES); - TEST(1042, length_of_list(l) == 2 && " hello " == l[0] && " world " == l[1]); + TEST(1046, length_of_list(l) == 2 && " hello " == l[0] && " world " == l[1]); } @@ -422,29 +438,29 @@ test_string2(void) //firstof ret = firstof("abcedf", "", result); - TEST(1043, 0 == ret && 0 == result); + TEST(1047, 0 == ret && 0 == result); ret = firstof("abcedf", "1234", result); - TEST(1044, 0 == ret && 0 == result); + TEST(1048, 0 == ret && 0 == result); ret = firstof("abcedf", "12ab", result); - TEST(1045, 1 == ret && 'a' == result); + TEST(1049, 1 == ret && 'a' == result); ret = firstof("abcedf", "1f2", result); - TEST(1046, 6 == ret && 'f' == result); + TEST(1050, 6 == ret && 'f' == result); //lastof ret = lastof("abcedf", "", result); - TEST(1047, 0 == ret && 0 == result); + TEST(1051, 0 == ret && 0 == result); ret = lastof("abcedf", "1234", result); - TEST(1048, 0 == ret && 0 == result); + TEST(1052, 0 == ret && 0 == result); ret = lastof("abcedf", "1abf", result); - TEST(1049, 6 == ret && 'f' == result); + TEST(1053, 6 == ret && 'f' == result); ret = lastof("abcedf", "1a2", result); - TEST(1050, 1 == ret && 'a' == result); + TEST(1054, 1 == ret && 'a' == result); } @@ -457,14 +473,14 @@ test_regexp2(void) { string s; - TEST(1051, 6 == re_search(SF_BRIEF|SF_MAXIMAL|SF_IGNORE_CASE|SF_CAPTURES, "{[0-9]+}", "Hello1234World")); - TEST(1052, re_result(1, s) == 4 && s == "1234"); - TEST(1053, re_result(2, s) == -1); + TEST(1055, 6 == re_search(SF_BRIEF|SF_MAXIMAL|SF_IGNORE_CASE|SF_CAPTURES, "{[0-9]+}", "Hello1234World")); + TEST(1056, re_result(1, s) == 4 && s == "1234"); + TEST(1057, re_result(2, s) == -1); - TEST(1054, re_search(SF_BRIEF|SF_MAXIMAL|SF_CAPTURES, "{[A-Za-z]+} {[A-Za-z]+}", "Hello World") > 0); - TEST(1055, re_result(1, s) == 5 && s == "Hello"); - TEST(1056, re_result(2, s) == 5 && s == "World"); - TEST(1057, re_result(3, s) == -1); + TEST(1058, re_search(SF_BRIEF|SF_MAXIMAL|SF_CAPTURES, "{[A-Za-z]+} {[A-Za-z]+}", "Hello World") > 0); + TEST(1059, re_result(1, s) == 5 && s == "Hello"); + TEST(1060, re_result(2, s) == 5 && s == "World"); + TEST(1061, re_result(3, s) == -1); } @@ -476,63 +492,79 @@ static void test_scanf(void) { string s1, s2; - int i1, i2, i3; + int r, i1, i2, i3; + + /*strings: %s*/ + r = sscanf("hello1 world1", "%s %s", s1, s2); + TEST(1062, r == 2 && s1 == "hello1" && s2 == "world1"); + + r = sscanf("hello2world2", "%6s%6s", s1, s2); + TEST(1063, r == 2 && s1 == "hello2" && s2 == "world2"); + + r = sscanf("aaAhello", "%[a]", s1); + TEST(1064, r == 1 && s1 == "aa"); + + r = sscanf("hello world", "%[a-z]", s1); + TEST(1065, r == 1 && s1 == "hello"); - /*strings %s*/ - sscanf("hello1 world1", "%s %s", s1, s2); - TEST(1058, s1 == "hello1" && s2 == "world1"); + r = sscanf("\t hello", "%[^a-z]", s1); + TEST(1066, r == 1 && s1 == "\t "); - sscanf("hello2world2", "%6s%6s", s1, s2); - TEST(1059, s1 == "hello2" && s2 == "world2"); + r = sscanf("hello-world", "%[^-]", s1); + TEST(1067, r == 1 && s1 == "hello"); - sscanf("aaAhello", "%[a]", s1); - TEST(1060, s1 == "aa"); + r = sscanf("hello]", "%[^]]", s1); + TEST(1068, r == 1 && s1 == "hello"); - sscanf("hello world", "%[a-z]", s1); - TEST(1061, s1 == "hello"); + r = sscanf("aa-hello", "%[a-]", s1); + TEST(1069, r == 1 && s1 == "aa-"); - sscanf("\t hello", "%[^a-z]", s1); - TEST(1062, s1 == "\t "); + r = sscanf("abchello", "%[a-bb-c]", s1); + TEST(1070, r == 1 && s1 == "abc"); - sscanf("hello-world", "%[^-]", s1); - TEST(1063, s1 == "hello"); + /* character: %c */ + r = sscanf("hello", "%c%c", i1, i2); + TEST(1071, r == 2 && i1 == 'h' && i2 == 'e'); - sscanf("hello]", "%[^]]", s1); - TEST(1064, s1 == "hello"); + /* numeric: %d,%u,%i,%x */ + r = sscanf("1234 -5678 +9010", "%d%d%d", i1, i2, i3); + TEST(1072, r == 3 && 1234 == i1 && -5678 == i2 && 9010 == i3); - sscanf("aa-hello", "%[a-]", s1); - TEST(1065, s1 == "aa-"); + r = sscanf("56781234", "%4d%4d", i1, i2); + TEST(1073, r == 2 && 1234 == i2 && i1 == 5678); - sscanf("abchello", "%[a-bb-c]", s1); - TEST(1066, s1 == "abc"); + r = sscanf("5678 1234 ", "%u%u", i1, i2); + TEST(1074, r == 2 && 5678 == i1 && 1234 == i2); - /* character %c */ - sscanf("hello", "%c%c", i1, i2); - TEST(1067, i1 == 'h' && i2 == 'e'); + r = sscanf("1234 -5678 +9010", "%i%i%i", i1, i2, i3); + TEST(1075, r == 3 && 1234 == i1 && -5678 == i2 && 9010 == i3); - /* numeric %d,%u,%i */ - sscanf("1234 -5678 +9010", "%d%d%d", i1, i2, i3); - TEST(1068, 1234 == i1 && -5678 == i2 && 9010 == i3); - sscanf("56781234", "%4d%4d", i1, i2); - TEST(1069, 1234 == i2 && i1 == 5678); + r = sscanf("1010 101010", "%b%b", i1, i2); /*binary*/ + TEST(1076, r == 2 && 0b1010 == i1 && 0b101010 == i2); - sscanf("5678 1234 ", "%u%u", i1, i2); - TEST(1070, 5678 == i1 && 1234 == i2); + r = sscanf("01010 0101010", "%b%b", i1, i2); /*binary; leading zeros*/ + TEST(1077, r == 2 && 0b01010 == i1 && 0b101010 == i2); - sscanf("1234 -5678 +9010", "%i%i%i", i1, i2, i3); - TEST(1071, 1234 == i1 && -5678 == i2 && 9010 == i3); + r = sscanf("0b01010 0b101010", "%b%b", i1, i2); /*binary; prefix*/ + TEST(1078, r == 2 && 0b01010 == i1 && 0b101010 == i2); - sscanf("0b01010 0b101010", "%b%b", i1, i2); /*binary*/ - TEST(1072, 0b01010 == i1 && 0b101010 == i2); + r = sscanf("01234 0567", "%o%o", i1, i2); /*oct*/ + TEST(1079, r == 2 && 01234 == i1 && 0567 == i2); - sscanf("01234 0567", "%o%o", i1, i2); /*oct*/ - TEST(1073, 01234 == i1 && 0567 == i2); + r = sscanf("01 009", "%d%d", i1, i2); /*dec: leading zeros*/ + TEST(1080, r == 2 && 1 == i1 && 9 == i2); - sscanf("0xABCD 0xFEA1", "%x%x", i1, i2); /*hex*/ - TEST(1074, 0xABCD == i1 && 0xFEA1 == i2); + r = sscanf("0xABCD 0xFEA1", "%x%x", i1, i2); /*hex: prefix*/ + TEST(1081, r == 2 && 0xABCD == i1 && 0xFEA1 == i2); - sscanf("FEDB ABCD", "%x%x", i1, i2); /*hex*/ - TEST(1075, 0xFEDB == i1 && 0xABCD == i2); + r = sscanf("FEDB ABCD", "%x%x", i1, i2); /*hex: upper*/ + TEST(1082, r == 2 && 0xFEDB == i1 && 0xABCD == i2); + + r = sscanf("fedb abcd", "%x%x", i1, i2); /*hex; lower*/ + TEST(1083, r == 2 && 0xfedb == i1 && 0xabcd == i2); + + r = sscanf("0D 0BAD", "%x%x", i1, i2); /*hex: leading zeros*/ + TEST(1084, r == 2 && 0xD == i1 && 0xBAD == i2); /* classes * @@ -552,44 +584,44 @@ test_scanf(void) * "word" A "word" character (alphanumeric plus "_"). * "xdigit" A hexadecimal digit. */ - sscanf(" Aabcyz123zZ0 -=()_", " %[[:ascii:]]", s1); - TEST(1076, s1 == "Aabcyz123zZ0 -=()_"); + r = sscanf(" Aabcyz123zZ0 -=()_", " %[[:ascii:]]", s1); + TEST(1085, r == 1 && s1 == "Aabcyz123zZ0 -=()_"); - sscanf(" Aabcyz123zZ0 -=()_", " %[[:alnum:]]", s1); - TEST(1077, s1 == "Aabcyz123zZ0"); + r = sscanf(" Aabcyz123zZ0 -=()_", " %[[:alnum:]]", s1); + TEST(1086, r == 1 && s1 == "Aabcyz123zZ0"); - sscanf(" Aabcyz123zZ0 -=()_", " %[[:alpha:]]", s1); - TEST(1078, s1 == "Aabcyz"); + r = sscanf(" Aabcyz123zZ0 -=()_", " %[[:alpha:]]", s1); + TEST(1087, r == 1 && s1 == "Aabcyz"); - sscanf("\t \nAabcyz123zZ0 -=()_", "%[[:blank:]]", s1); - TEST(1079, s1 == "\t "); + r = sscanf("\t \nAabcyz123zZ0 -=()_", "%[[:blank:]]", s1); + TEST(1088, r == 1 && s1 == "\t "); - sscanf(" \a\b\f\v\e", " %[[:cntrl:]]", s1); - TEST(1080, s1 == "\a\b\f\v\e"); + r = sscanf(" \a\b\f\v\e", " %[[:cntrl:]]", s1); + TEST(1089, r == 1 && s1 == "\a\b\f\v\e"); - sscanf(" Aabcyz123_zZ0 -=()_", " %[[:csym:]]", s1); - TEST(1081, s1 == "Aabcyz123_zZ0"); + r = sscanf(" Aabcyz123_zZ0 -=()_", " %[[:csym:]]", s1); + TEST(1090, r == 1 && s1 == "Aabcyz123_zZ0"); - sscanf(" 9876abcyz ", " %[[:digit:]]", s1); - TEST(1082, s1 == "9876"); + r = sscanf(" 9876abcyz ", " %[[:digit:]]", s1); + TEST(1091, r == 1 && s1 == "9876"); - sscanf(" abcyzABCYZ987 ", " %[[:lower:]]", s1); - TEST(1083, s1 == "abcyz"); + r = sscanf(" abcyzABCYZ987 ", " %[[:lower:]]", s1); + TEST(1092, r == 1 && s1 == "abcyz"); - sscanf(" 9876abcyz ", " %[[:print:]]", s1); - TEST(1084, s1 == "9876abcyz "); + r = sscanf(" 9876abcyz ", " %[[:print:]]", s1); + TEST(1093, r == 1 && s1 == "9876abcyz "); - sscanf(" \t9876abcyz ", "%[[:space:]]", s1); - TEST(1085, s1 == " \t"); + r = sscanf(" \t9876abcyz ", "%[[:space:]]", s1); + TEST(1094, r == 1 && s1 == " \t"); - sscanf(" ABCYZabcyz9876abcyz ", " %[[:upper:]]", s1); - TEST(1086, s1 == "ABCYZ") + r = sscanf(" ABCYZabcyz9876abcyz ", " %[[:upper:]]", s1); + TEST(1095, r == 1 && s1 == "ABCYZ") - sscanf(" 9876_abcyzABCYZ ", " %[[:word:]]", s1); - TEST(1087, s1 == "9876_abcyzABCYZ"); + r = sscanf(" 9876_abcyzABCYZ ", " %[[:word:]]", s1); + TEST(1096, r == 1 && s1 == "9876_abcyzABCYZ"); - sscanf(" 9876abcfABCYZ ", " %[[:xdigit:]]", s1); - TEST(1088, s1 == "9876abcfABC"); + r = sscanf(" 9876abcfABCYZ ", " %[[:xdigit:]]", s1); + TEST(1097, r == 1 && s1 == "9876abcfABC"); /*%v*/ @@ -636,22 +668,22 @@ test_arg_list1() // (int iarg, float farg, string sarg, list larg, declar string str; l = arg_list(0); // not eval'ed - TEST(1089, 8 == length_of_list(l)); - TEST(1090, l[0] == "iarg" && l[3] == "larg"); - TEST(1091, l[5][0] == "atoi"); // (atoi "5") - TEST(1092, l[6] == "rarg"); // register - TEST(1093, l[7][0] == "test_arg_fn"); // (test_arg_fn 1 "2" larg rarg) - TEST(1094, l[7][1] == 1); - TEST(1095, l[7][2] == "2"); - TEST(1096, l[7][3] == "larg"); - TEST(1097, l[7][4] == "rarg"); + TEST(1098, 8 == length_of_list(l)); + TEST(1099, l[0] == "iarg" && l[3] == "larg"); + TEST(1100, l[5][0] == "atoi"); // (atoi "5") + TEST(1101, l[6] == "rarg"); // register + TEST(1102, l[7][0] == "test_arg_fn"); // (test_arg_fn 1 "2" larg rarg) + TEST(1103, l[7][1] == 1); + TEST(1104, l[7][2] == "2"); + TEST(1105, l[7][3] == "larg"); + TEST(1106, l[7][4] == "rarg"); l = arg_list(0, 1, 3); // not eval'ed, limited selection - TEST(1098, 3 == length_of_list(l)); - TEST(1099, l[0] == "farg" && l[2] == "larg"); + TEST(1107, 3 == length_of_list(l)); + TEST(1108, l[0] == "farg" && l[2] == "larg"); sprintf(str, "%s", l); // sprintf list support - TEST(1100, strlen(str) >= 5*2); + TEST(1109, strlen(str) >= 5*2); } @@ -661,15 +693,15 @@ test_arg_list2() // (int iarg, float farg, string sarg, list larg, declar list l; l = arg_list(1); // eval'ed - TEST(1101, 8 == length_of_list(l)); - TEST(1102, l[0] == 1 && l[2] == "3"); - TEST(1103, l[5] == "5"); // atoi() - TEST(1104, l[6] == 6); // register - TEST(1105, l[7] == "7"); // test_arg_fn() + TEST(1110, 8 == length_of_list(l)); + TEST(1111, l[0] == 1 && l[2] == "3"); + TEST(1112, l[5] == "5"); // atoi() + TEST(1113, l[6] == 6); // register + TEST(1114, l[7] == "7"); // test_arg_fn() l = arg_list(1, 1, 3); // eval'ed, limited selection - TEST(1106, 3 == length_of_list(l)); - TEST(1107, l[0] == 2 && l[1] == "3"); + TEST(1115, 3 == length_of_list(l)); + TEST(1116, l[0] == 2 && l[1] == "3"); } @@ -715,41 +747,41 @@ test_getopt(void) switch(ch) { case 'h': // -h or --help option if (1 == match) { - TEST(1108, 1 == match & value == ""); + TEST(1117, 1 == match & value == ""); } else { - TEST(1109, 2 == match && value == ""); + TEST(1118, 2 == match && value == ""); } break; case 2: // --option2 - TEST(1110, 3 == match && value == ""); + TEST(1119, 3 == match && value == ""); break; case 3: // --option3 - TEST(1111, 4 == match && value == ""); + TEST(1120, 4 == match && value == ""); break; case 'i': // --integer= - TEST(1112, 5 == match && value == "1234"); + TEST(1121, 5 == match && value == "1234"); break; case 's': // --string= - TEST(1113, 6 == match && value == "56 78"); + TEST(1122, 6 == match && value == "56 78"); break; case 'b': // --bool= switch (++booltest) { - case 1: TEST(1114, value == "1"); break; - case 2: TEST(1115, value == "1"); break; - case 3: TEST(1116, value == "1"); break; - case 4: TEST(1117, value == "1"); break; - case 5: TEST(1118, value == "1"); break; - - case 6: TEST(1119, value == "0"); break; - case 7: TEST(1120, value == "0"); break; - case 8: TEST(1121, value == "0"); break; - case 9: TEST(1122, value == "0"); break; - case 10: TEST(1123, value == "0"); break; + case 1: TEST(1123, value == "1"); break; + case 2: TEST(1124, value == "1"); break; + case 3: TEST(1125, value == "1"); break; + case 4: TEST(1126, value == "1"); break; + case 5: TEST(1127, value == "1"); break; + + case 6: TEST(1128, value == "0"); break; + case 7: TEST(1129, value == "0"); break; + case 8: TEST(1130, value == "0"); break; + case 9: TEST(1131, value == "0"); break; + case 10: TEST(1132, value == "0"); break; } break; @@ -765,9 +797,9 @@ test_getopt(void) } while ((ch = getopt(value)) >= 0); } - TEST(1124, match == 16); - TEST(1125, value == "910 11 \"22 22\""); - TEST(1126, -1 == getopt(value)); + TEST(1133, match == 16); + TEST(1134, value == "910 11 \"22 22\""); + TEST(1135, -1 == getopt(value)); } @@ -796,23 +828,23 @@ test_getsubopt(void) ++match; switch (ch) { case 'h': // 'help' option - TEST(1127, 1 == match && value == ""); + TEST(1136, 1 == match && value == ""); break; case 2: // 'option2' - TEST(1128, 2 == match && value == ""); + TEST(1137, 2 == match && value == ""); break; case 3: // 'option3' - TEST(1129, 3 == match && value == ""); + TEST(1138, 3 == match && value == ""); break; case 'i': // 'integer=' - TEST(1130, 4 == match && value == "1234"); + TEST(1139, 4 == match && value == "1234"); break; case 's': // 'string=' - TEST(1131, 5 == match && value == "56 78"); + TEST(1140, 5 == match && value == "56 78"); break; default: @@ -830,9 +862,9 @@ test_getsubopt(void) } } - TEST(1132, 5 == match); - TEST(1133, -1 == getsubopt(value)); - TEST(1134, "" == value); + TEST(1141, 5 == match); + TEST(1142, -1 == getsubopt(value)); + TEST(1143, "" == value); } @@ -851,16 +883,16 @@ test_parsename(void) string drive, path, fname, ext; parse_filename("c://subdir\\subdir\\fname.ext", drive, path, fname, ext); - TEST(1135, 0 == strcmp(drive, "c:")); - TEST(1136, 0 == strcmp(path, "//subdir\\subdir\\")); - TEST(1137, 0 == strcmp(fname, "fname")); - TEST(1138, 0 == strcmp(ext, "ext")); + TEST(1144, 0 == strcmp(drive, "c:")); + TEST(1145, 0 == strcmp(path, "//subdir\\subdir\\")); + TEST(1146, 0 == strcmp(fname, "fname")); + TEST(1147, 0 == strcmp(ext, "ext")); parse_filename("z:fname.ext1.ext2", drive, path, fname, ext); - TEST(1139, 0 == strcmp(drive, "z:")); - TEST(1140, 0 == strcmp(path, "")); - TEST(1141, 0 == strcmp(fname, "fname.ext1")); - TEST(1142, 0 == strcmp(ext, "ext2")); // last extension + TEST(1148, 0 == strcmp(drive, "z:")); + TEST(1149, 0 == strcmp(path, "")); + TEST(1150, 0 == strcmp(fname, "fname.ext1")); + TEST(1151, 0 == strcmp(ext, "ext2")); // last extension } @@ -872,10 +904,10 @@ static void test_command_list(void) { list cmd = command_list(TRUE /*builtins-only*/, "*float"); - TEST(1143, 3 == length_of_list(cmd)); // float, is_float and cast_float + TEST(1152, 3 == length_of_list(cmd)); // float, is_float and cast_float list macros = macro_list("regress"); - TEST(1144, 1 == length_of_list(macros)); // regress() + TEST(1153, 1 == length_of_list(macros)); // regress() } @@ -887,11 +919,11 @@ static void test_file(void) { // mkdir/rmdir - TEST(1145, 0 != access("./grregress")); - TEST(1146, 0 == mkdir("./grregress", 0666)); - TEST(1147, 0 == access("./grregress")); - TEST(1148, 0 == rmdir("./grregress")); - TEST(1149, 0 != access("./grregress")); + TEST(1154, 0 != access("./grregress")); + TEST(1155, 0 == mkdir("./grregress", 0666)); + TEST(1156, 0 == access("./grregress")); + TEST(1157, 0 == rmdir("./grregress")); + TEST(1158, 0 != access("./grregress")); // mktemp // rename @@ -903,29 +935,29 @@ test_file(void) temp2 = temp + "2"; int size = -1, mtime, ctime, atime, mode; - TEST(1150, 0 == access(temp)); - - TEST(1151, 0 == stat(temp, size, mtime, ctime, atime, mode)); - TEST(1152, 0 == size); - TEST(1153, mtime >= now && ctime >= now && atime >= now); - TEST(1154, (S_IFMT & mode) == S_IFREG); - TEST(1155, (S_IFMT & mode) != S_IFCHR); - TEST(1156, (S_IFMT & mode) != S_IFDIR); - TEST(1157, (S_IFMT & mode) != S_IFIFO); - TEST(1158, (S_IFMT & mode) != S_IFLNK); - TEST(1159, (S_IFMT & mode) != S_IFSOCK); - TEST(1160, (S_IFMT & mode) != S_ISVTX || S_ISVTX == 0); - TEST(1161, (S_IRUSR & mode) == S_IRUSR); - TEST(1162, (S_IWUSR & mode) == S_IWUSR); - TEST(1163, (S_IXGRP & mode) == 0); - TEST(1164, (S_IXOTH & mode) == 0); - TEST(1165, (S_IXUSR & mode) == 0); - - TEST(1166, 0 == rename(temp, temp2)); - TEST(1167, 0 == access(temp2)); - TEST(1168, 0 == remove(temp2)); - TEST(1169, 0 != access(temp2)); - TEST(1170, 0 != stat(temp2)); + TEST(1159, 0 == access(temp)); + + TEST(1160, 0 == stat(temp, size, mtime, ctime, atime, mode)); + TEST(1161, 0 == size); + TEST(1162, mtime >= now && ctime >= now && atime >= now); + TEST(1163, (S_IFMT & mode) == S_IFREG); + TEST(1164, (S_IFMT & mode) != S_IFCHR); + TEST(1165, (S_IFMT & mode) != S_IFDIR); + TEST(1166, (S_IFMT & mode) != S_IFIFO); + TEST(1167, (S_IFMT & mode) != S_IFLNK); + TEST(1168, (S_IFMT & mode) != S_IFSOCK); + TEST(1169, (S_IFMT & mode) != S_ISVTX || S_ISVTX == 0); + TEST(1170, (S_IRUSR & mode) == S_IRUSR); + TEST(1171, (S_IWUSR & mode) == S_IWUSR); + TEST(1172, (S_IXGRP & mode) == 0); + TEST(1173, (S_IXOTH & mode) == 0); + TEST(1174, (S_IXUSR & mode) == 0); + + TEST(1175, 0 == rename(temp, temp2)); + TEST(1176, 0 == access(temp2)); + TEST(1177, 0 == remove(temp2)); + TEST(1178, 0 != access(temp2)); + TEST(1179, 0 != stat(temp2)); //TODO // lstat @@ -948,6 +980,50 @@ test_file(void) } +/* + * test_splitpath --- + * splitpath functionality. + */ +static void +test_splitpath(void) +{ + string dir, name, ext, drive; + + splitpath("x/y", dir, name, ext, drive); + TEST(1180, dir == "x/" && name == "y" && ext == "" && drive == ""); + + splitpath("x/", dir, name, ext, drive); + TEST(1181, dir == "x/" && name == "" && ext == "" && drive == ""); + + splitpath("/x", dir, name, ext, drive); + TEST(1182, dir == "/" && name == "x" && ext == "" && drive == ""); + + splitpath("x", dir, name, ext, drive); + TEST(1183, dir == "" && name == "x" && ext == "" && drive == ""); + + splitpath("", dir, name, ext, drive); + TEST(1184, dir == "" && name == "" && ext == "" && drive == ""); + + splitpath(".x", dir, name, ext, drive); + TEST(1185, dir == "" && name == "" && ext == ".x" && drive == ""); + + splitpath("a.b.c", dir, name, ext, drive); + TEST(1186, dir == "" && name == "a.b" && ext == ".c" && drive == ""); + + splitpath(":x", dir, name, ext, drive); + TEST(1187, dir == "" && name == ":x" && ext == "" && drive == ""); + + splitpath("a:x", dir, name, ext, drive); + TEST(1188, dir == "" && name == "x" && ext == "" && drive == "a:"); + + splitpath("a.b:x", dir, name, ext, drive); + TEST(1189, dir == "" && name == "a" && ext == ".b:x" && drive == ""); + + splitpath("C:/dos/command.com", dir, name, ext, drive); + TEST(1190, dir == "/dos/" && name == "command" && ext == ".com" && drive == "C:"); +} + + /* * test_module --- * module functionality. @@ -955,11 +1031,11 @@ test_file(void) static void test_module(void) { - TEST(1171, inq_module() == "regress"); // current association - TEST(1172, inq_macro("test_module", 2) == inq_macro("test_misc", 2)); - TEST(1173, inq_macro("test_module", 2) != inq_macro("crisp", 2)); - TEST(1174, 2 == module("regress")); // pre-existing association - TEST(1175, -1 == module("newmodule")); // re-assignment, error + TEST(1191, inq_module() == "regress"); // current association + TEST(1192, inq_macro("test_module", 2) == inq_macro("test_misc", 2)); + TEST(1193, inq_macro("test_module", 2) != inq_macro("crisp", 2)); + TEST(1194, 2 == module("regress")); // pre-existing association + TEST(1195, -1 == module("newmodule")); // re-assignment, error } @@ -974,7 +1050,7 @@ test_misc(void) int vmajor, vminor, vedit; string vmachtype, vcompiled; - TEST(1176, version(vmajor, vminor, vedit, NULL, vmachtype, vcompiled) >= 302 && \ + TEST(1196, version(vmajor, vminor, vedit, NULL, vmachtype, vcompiled) >= 302 && \ vmajor >= 3 && vminor >= 0 && vedit >= 0); switch (vmachtype) { case "VMS": @@ -987,17 +1063,17 @@ test_misc(void) vmachtype = ""; break; } - TEST(1177, "" == vmachtype); // defined + TEST(1197, "" == vmachtype); // defined // srand()/rand() const int seed = 1234; srand(seed); int rand1 = rand(); srand(seed); - TEST(1178, rand1 == rand()); + TEST(1198, rand1 == rand()); // strerror - need EINVAL etc - TEST(1179, "Success" == strerror(0)); - TEST(1180, "Unknown error" == strerror(-1)); + TEST(1199, "Success" == strerror(0)); + TEST(1200, "Unknown error" == strerror(-1)); } @@ -1045,10 +1121,10 @@ test_try(void) static void test_display(void) { - TEST(1181, inq_display_mode("scroll_cols") == display_mode(NULL, NULL, -1)); - TEST(1182, inq_display_mode("scroll_rows") == display_mode(NULL, NULL, NULL, -1)); - TEST(1183, inq_display_mode("visible_cols") == display_mode(NULL, NULL, NULL, NULL, -1)); - TEST(1184, inq_display_mode("visible_rows") == display_mode(NULL, NULL, NULL, NULL, NULL, -1)); + TEST(1201, inq_display_mode("scroll_cols") == display_mode(NULL, NULL, -1)); + TEST(1202, inq_display_mode("scroll_rows") == display_mode(NULL, NULL, NULL, -1)); + TEST(1203, inq_display_mode("visible_cols") == display_mode(NULL, NULL, NULL, NULL, -1)); + TEST(1204, inq_display_mode("visible_rows") == display_mode(NULL, NULL, NULL, NULL, NULL, -1)); } @@ -1066,33 +1142,33 @@ test_ruler(void) /* tabs */ tabs(8, 17); - TEST(1185, inq_tabs() == "8 17"); + TEST(1205, inq_tabs() == "8 17"); tabs("9 17"); - TEST(1186, inq_tabs() == "9 17"); - TEST(1187, 8 == inq_tab()); /* default */ + TEST(1206, inq_tabs() == "9 17"); + TEST(1207, 8 == inq_tab()); /* default */ tabs(""); - TEST(1188, inq_tabs() == ""); + TEST(1208, inq_tabs() == ""); execute_macro("tabs " + saved_tabs); - TEST(1189, inq_tabs() == saved_tabs); + TEST(1209, inq_tabs() == saved_tabs); /* indent */ set_indent(5); - TEST(1190, inq_indent() == 5); /* indent builds simple ruler */ + TEST(1210, inq_indent() == 5); /* indent builds simple ruler */ set_indent(0); - TEST(1191, inq_indent() == 0); + TEST(1211, inq_indent() == 0); set_indent(saved_indent); - TEST(1192, inq_indent() == saved_indent); + TEST(1212, inq_indent() == saved_indent); /* ruler */ set_ruler(NULL, ruler); - TEST(1193, inq_ruler(NULL, 5) == "5 9 20 25 30"); + TEST(1213, inq_ruler(NULL, 5) == "5 9 20 25 30"); r = inq_ruler(NULL, 10, TRUE); - TEST(1194, r[0] == 5 && r[1] == 9 && r[4] == 30); + TEST(1214, r[0] == 5 && r[1] == 9 && r[4] == 30); set_ruler(NULL, NULL); /* clear */ } @@ -1108,22 +1184,22 @@ test_datetime(void) int curtime = time(); sleep(1); - TEST(1195, time() > curtime); + TEST(1215, time() > curtime); sleep(1); - TEST(1196, time() > ++curtime); + TEST(1216, time() > ++curtime); sleep(1); - TEST(1197, time() > ++curtime); + TEST(1217, time() > ++curtime); // inq_idle_time/sleep - TEST(1198, inq_idle_time() >= 1); + TEST(1218, inq_idle_time() >= 1); sleep(1); - TEST(1199, inq_idle_time() > 1); + TEST(1219, inq_idle_time() > 1); // inq_clock/sleep(ms) int clock1 = inq_clock(); for (curtime = time(); curtime == time();) { } - TEST(1200, inq_clock() > clock1); + TEST(1220, inq_clock() > clock1); // localtime/date int year1, mon1, mday1, hour1, min1, sec1; @@ -1137,11 +1213,11 @@ test_datetime(void) gmtime(curtime, year2, mon2, mday2, monname2, dayname2, hour2, min2, sec2); date(year3, mon3, mday3, monname3, dayname3); - TEST(1201, year1 >= 2020 && mon1 >= 1 && mon1 <= 12 && mday1 >= 1 && mday1 <= 31); - TEST(1202, year2 >= 2020 && mon2 >= 1 && mon2 <= 12 && mday2 >= 1 && mday2 <= 31); - TEST(1203, year3 >= 2020 && mon3 >= 1 && mon3 <= 12 && mday3 >= 1 && mday3 <= 31); - TEST(1204, year1 == year2 && year2 == year3); - TEST(1205, mon1 == mon2 && mon2 == mon3); + TEST(1221, year1 >= 2020 && mon1 >= 1 && mon1 <= 12 && mday1 >= 1 && mday1 <= 31); + TEST(1222, year2 >= 2020 && mon2 >= 1 && mon2 <= 12 && mday2 >= 1 && mday2 <= 31); + TEST(1223, year3 >= 2020 && mon3 >= 1 && mon3 <= 12 && mday3 >= 1 && mday3 <= 31); + TEST(1224, year1 == year2 && year2 == year3); + TEST(1225, mon1 == mon2 && mon2 == mon3); //TEST(XXXX, mday1 == mday2 && mday2 == mday3); //TODO @@ -1160,19 +1236,19 @@ test_sysinfo(void) profiledir = inq_profile(), tmpdir = inq_tmpdir(); - TEST(1206, 0 == access(homedir)); - TEST(1207, strlen(profiledir)); - TEST(1208, 0 == access(tmpdir)); + TEST(1226, 0 == access(homedir)); + TEST(1227, strlen(profiledir)); + TEST(1228, 0 == access(tmpdir)); string username = inq_username(), hostname = inq_hostname(); - TEST(1209, username); - TEST(1210, hostname); + TEST(1229, username); + TEST(1230, hostname); string usysname, unodename, uversion, urelease, umachine; - TEST(1211, 0 == uname(usysname, unodename, uversion, urelease, umachine) && \ + TEST(1231, 0 == uname(usysname, unodename, uversion, urelease, umachine) && \ strlen(usysname) && strlen(unodename) && strlen(uversion) && strlen(urelease) && strlen(umachine)); } @@ -1192,7 +1268,7 @@ test_ini(void) // export // fd = iniopen(); - TEST(1212, fd >= 0); + TEST(1232, fd >= 0); inipush(fd, section, "zzz", "9999", "comment 1"); inipush(fd, section, "zzz", "8888", "comment 2"); @@ -1205,16 +1281,16 @@ test_ini(void) ret = ininext(fd, sect, key, value)) { switch (++cnt) { case 1: - TEST(1213, sect == section); - TEST(1214, key == "zzz" && value == "8888"); + TEST(1233, sect == section); + TEST(1234, key == "zzz" && value == "8888"); break; case 2: - TEST(1215, sect == section); - TEST(1216, key == "xxx" && value == "5555"); + TEST(1235, sect == section); + TEST(1236, key == "xxx" && value == "5555"); break; } } - TEST(1217, 2 == cnt); + TEST(1237, 2 == cnt); iniexport(fd, inifile); iniclose(fd); @@ -1224,23 +1300,23 @@ test_ini(void) // int fd2 = iniopen(inifile, IFILE_STANDARD|IFILE_STANDARDEOL); - TEST(1218, fd2 >= 0); - TEST(1219, fd2 != fd); + TEST(1238, fd2 >= 0); + TEST(1239, fd2 != fd); for (cnt = 0, ret = inifirst(fd2, sect, key, value); 1 == ret; ret = ininext(fd2, sect, key, value)) { switch (++cnt) { case 1: - TEST(1220, sect == section); - TEST(1221, key == "zzz" && value == "8888"); + TEST(1240, sect == section); + TEST(1241, key == "zzz" && value == "8888"); break; case 2: - TEST(1222, sect == section); - TEST(1223, key == "xxx" && value == "5555"); + TEST(1242, sect == section); + TEST(1243, key == "xxx" && value == "5555"); break; } } - TEST(1224, 2 == cnt); + TEST(1244, 2 == cnt); iniclose(fd2); remove(inifile); @@ -1261,6 +1337,46 @@ test_ini(void) #define REGISTER #endif +static void +test_block0(~ int) +{ + extern int x; + int y; + + get_parm(1, y); + TEST(1245, x == 42); + TEST(1246, y == 42); + { + int x = 1; + TEST(1247, x == 1); + { + int x = 2; + TEST(1248, x == 2); + { + int x = 3; + TEST(1249, x == 3); + { + int x = 4; + TEST(1250, x == 4); + } + TEST(1251, x == 3); + } + TEST(1252, x == 2); + } + TEST(1253, x == 1); + } + TEST(1254, x == 42); +} + + +static void +test_block(void) +{ + int x = 42; + scope_block0(x); +} + + static int test_register_int2(int level = 0) { @@ -1277,47 +1393,47 @@ test_register_int(void) { REGISTER int i1 = 1234; - TEST(1225, 1234 == i1); + TEST(1255, 1234 == i1); i1 += 10; - TEST(1226, 1244 == i1); + TEST(1256, 1244 == i1); i1 -= 10; - TEST(1227, 1234 == i1); + TEST(1257, 1234 == i1); i1 += i1; - TEST(1228, 2468 == i1); + TEST(1258, 2468 == i1); i1 = i1 - 1234; - TEST(1229, 1234 == i1); + TEST(1259, 1234 == i1); { /*nesting*/ REGISTER int i2 = 4567; /* additional */ - TEST(1230, 1234 == i1); - TEST(1231, 4567 == i2); + TEST(1260, 1234 == i1); + TEST(1261, 4567 == i2); { /*nesting*/ REGISTER int i1 = 8901; /* hidden */ - TEST(1232, 8901 == i1); - TEST(1233, 4567 == i2); + TEST(1262, 8901 == i1); + TEST(1263, 4567 == i2); { REGISTER int i1 = 101234; /* hidden */ - TEST(1234, 101234 == i1); + TEST(1264, 101234 == i1); } - TEST(1235, 8901 == i1); - TEST(1236, 4567 == i2); + TEST(1265, 8901 == i1); + TEST(1266, 4567 == i2); } - TEST(1237, 1234 == i1); + TEST(1267, 1234 == i1); } - TEST(1238, 1234 == i1); + TEST(1268, 1234 == i1); - TEST(1239, 7890 == test_register_int2()); /* nested calls */ - TEST(1240, 1234 == i1); + TEST(1269, 7890 == test_register_int2()); /* nested calls */ + TEST(1270, 1234 == i1); } #if defined(__REGISTERS__) @@ -1329,9 +1445,9 @@ static void test_unicode_version(void) { string uv = inq_unicode_version(); - TEST(1241, set_unicode_version("11.0.0") == 110000); //match - TEST(1242, set_unicode_version("13.0.0") == 130000); //match - TEST(1243, set_unicode_version("19.0.0") == 150100); //closest (15.1.0, current upper) + TEST(1271, set_unicode_version("11.0.0") == 110000); //match + TEST(1272, set_unicode_version("13.0.0") == 130000); //match + TEST(1273, set_unicode_version("19.0.0") == 150100); //closest (15.1.0, current upper) set_unicode_version(uv); } @@ -1339,88 +1455,88 @@ test_unicode_version(void) static void test_wcwidth(void) { - TEST(1244, wcwidth("") == 0); - TEST(1245, wcwidth("a") == 1); - TEST(1246, wcwidth("The quick brown fox jumps over the lazy dog") == 43); - TEST(1247, wcwidth("ξεσκεπάζω την ψυχοφθόÏα βδελυγμία") == 33); + TEST(1274, wcwidth("") == 0); + TEST(1275, wcwidth("a") == 1); + TEST(1276, wcwidth("The quick brown fox jumps over the lazy dog") == 43); + TEST(1277, wcwidth("ξεσκεπάζω την ψυχοφθόÏα βδελυγμία") == 33); } static void test_wstrlen(void) { - TEST(1248, wstrlen("") == 0); - TEST(1249, wstrlen("a") == 1); - TEST(1250, wstrlen("The quick brown fox jumps over the lazy dog") == 43); - TEST(1251, wstrlen("ξεσκεπάζω την ψυχοφθόÏα βδελυγμία") == 33); + TEST(1278, wstrlen("") == 0); + TEST(1279, wstrlen("a") == 1); + TEST(1280, wstrlen("The quick brown fox jumps over the lazy dog") == 43); + TEST(1281, wstrlen("ξεσκεπάζω την ψυχοφθόÏα βδελυγμία") == 33); } static void test_wstrnlen(void) { - TEST(1252, wstrnlen("", 0) == 0); - TEST(1253, wstrnlen("a", 1) == 1); - TEST(1254, wstrnlen("The quick brown fox jumps over the lazy dog", 30) == 30); - TEST(1255, wstrnlen("ξεσκεπάζω την ψυχοφθόÏα βδελυγμία", 34) == 33); + TEST(1282, wstrnlen("", 0) == 0); + TEST(1283, wstrnlen("a", 1) == 1); + TEST(1284, wstrnlen("The quick brown fox jumps over the lazy dog", 30) == 30); + TEST(1285, wstrnlen("ξεσκεπάζω την ψυχοφθόÏα βδελυγμία", 34) == 33); } static void test_wcharacterat(void) { - TEST(1256, wcharacterat("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", 1) == L'Ð') - TEST(1257, wcharacterat("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", 7) == L'Ж') - TEST(1258, wcharacterat("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", 33) == -1) + TEST(1286, wcharacterat("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", 1) == L'Ð') + TEST(1287, wcharacterat("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", 7) == L'Ж') + TEST(1288, wcharacterat("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", 33) == -1) } static void test_wstrstr(void) { - TEST(1259, 4 == wstrstr("abcmandefg", "man")); - TEST(1260, 4 == wstrstr("abcmanmandefg", "man")); - TEST(1261, 0 == wstrstr("abcmanmandefg", "ban")); - TEST(1262, 1 == wstrstr("abcmanmandefg", "")); - - TEST(1263, wstrstr("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "БВ") == 2) - TEST(1264, wstrstr("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "A") == 0) - TEST(1265, wstrstr("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "") == 1) + TEST(1289, 4 == wstrstr("abcmandefg", "man")); + TEST(1290, 4 == wstrstr("abcmanmandefg", "man")); + TEST(1291, 0 == wstrstr("abcmanmandefg", "ban")); + TEST(1292, 1 == wstrstr("abcmanmandefg", "")); + + TEST(1293, wstrstr("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "БВ") == 2) + TEST(1294, wstrstr("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "A") == 0) + TEST(1295, wstrstr("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "") == 1) } static void test_wstrrstr(void) { - TEST(1266, 4 == wstrrstr("abcmandefg", "man")); - TEST(1267, 7 == wstrrstr("abcmanmandefg", "man")); - TEST(1268, 0 == wstrrstr("abcmanmandefg", "ban")); - TEST(1269, 0 == wstrrstr("abcmanmandefg", "")); - - TEST(1270, wstrrstr("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "БВ") == 34) - TEST(1271, wstrrstr("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "A") == 0) - TEST(1272, wstrrstr("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "") == 0) + TEST(1296, 4 == wstrrstr("abcmandefg", "man")); + TEST(1297, 7 == wstrrstr("abcmanmandefg", "man")); + TEST(1298, 0 == wstrrstr("abcmanmandefg", "ban")); + TEST(1299, 0 == wstrrstr("abcmanmandefg", "")); + + TEST(1300, wstrrstr("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "БВ") == 34) + TEST(1301, wstrrstr("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "A") == 0) + TEST(1302, wstrrstr("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "") == 0) } static void test_wsubstr(void) { - TEST(1273, wsubstr("ABC", 0, 3) == "ABC"); - TEST(1274, wsubstr("ABC", -1000, 1000) == "ABC"); - TEST(1275, wsubstr("ABC", 1000, 1000) == ""); - TEST(1276, wsubstr("ABC", 1, 0) == ""); - TEST(1277, wsubstr("ABC", 1, 1) == "A"); - TEST(1278, wsubstr("ABC", 1, 2) == "AB"); - TEST(1279, wsubstr("ABC", 1, 3) == "ABC"); - TEST(1280, wsubstr("ABC", 1, 100) == "ABC"); - TEST(1281, wsubstr("ABC", 3, 0) == ""); - TEST(1282, wsubstr("ABC", 3, 1) == "C"); - TEST(1283, wsubstr("ABC", 3, 100) == "C"); - - TEST(1284, wsubstr("ξεσκεπάζω την ψυχοφθόÏα βδελυγμία", 33, 0) == ""); - TEST(1285, wsubstr("ξεσκεπάζω την ψυχοφθόÏα βδελυγμία", 1, 9) == "ξεσκεπάζω"); - TEST(1286, wsubstr("ξεσκεπάζω την ψυχοφθόÏα βδελυγμία", 11, 3) == "την"); + TEST(1303, wsubstr("ABC", 0, 3) == "ABC"); + TEST(1304, wsubstr("ABC", -1000, 1000) == "ABC"); + TEST(1305, wsubstr("ABC", 1000, 1000) == ""); + TEST(1306, wsubstr("ABC", 1, 0) == ""); + TEST(1307, wsubstr("ABC", 1, 1) == "A"); + TEST(1308, wsubstr("ABC", 1, 2) == "AB"); + TEST(1309, wsubstr("ABC", 1, 3) == "ABC"); + TEST(1310, wsubstr("ABC", 1, 100) == "ABC"); + TEST(1311, wsubstr("ABC", 3, 0) == ""); + TEST(1312, wsubstr("ABC", 3, 1) == "C"); + TEST(1313, wsubstr("ABC", 3, 100) == "C"); + + TEST(1314, wsubstr("ξεσκεπάζω την ψυχοφθόÏα βδελυγμία", 33, 0) == ""); + TEST(1315, wsubstr("ξεσκεπάζω την ψυχοφθόÏα βδελυγμία", 1, 9) == "ξεσκεπάζω"); + TEST(1316, wsubstr("ξεσκεπάζω την ψυχοφθόÏα βδελυγμία", 11, 3) == "την"); } @@ -1428,19 +1544,19 @@ static void test_wfirstof(void) { int wch; - TEST(1287, wfirstof("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "БВ", wch) == 2 && wch == L'Б') - TEST(1288, wfirstof("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "CФВ", wch) == 3 && wch == L'Ð’') - TEST(1289, wfirstof("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "XBC", wch) == 0 && wch == 0) + TEST(1317, wfirstof("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "БВ", wch) == 2 && wch == L'Б') + TEST(1318, wfirstof("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "CФВ", wch) == 3 && wch == L'Ð’') + TEST(1319, wfirstof("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "XBC", wch) == 0 && wch == 0) } static void test_wstrpbrk(void) { - TEST(1290, 3 == wstrpbrk("abcdefg", "dc")); - TEST(1291, wfirstof("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "БВ") == 2) - TEST(1292, wfirstof("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "CФВ") == 3) - TEST(1293, wfirstof("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "XBC") == 0) + TEST(1320, 3 == wstrpbrk("abcdefg", "dc")); + TEST(1321, wfirstof("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "БВ") == 2) + TEST(1322, wfirstof("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "CФВ") == 3) + TEST(1323, wfirstof("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "XBC") == 0) } @@ -1448,45 +1564,45 @@ static void test_wlastof(void) { int wch; - TEST(1294, wlastof("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "БВ", wch) == 35 && wch == L'Ð’') - TEST(1295, wlastof("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "CФВ", wch) == 53 && wch == L'Ф') - TEST(1296, wlastof("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "XBC", wch) == 0 && wch == 0) + TEST(1324, wlastof("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "БВ", wch) == 35 && wch == L'Ð’') + TEST(1325, wlastof("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "CФВ", wch) == 53 && wch == L'Ф') + TEST(1326, wlastof("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "XBC", wch) == 0 && wch == 0) } static void test_wstrcmp(void) { - TEST(1297, 0 == wstrcmp("aaa", "aaa")); - TEST(1298, 0 == wstrcmp("aaa", "aaa")); - TEST(1299, 0 == wstrcmp("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ")); - TEST(1300, 0 == wstrcmp("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯYYYY", "ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯXXXX", 32)); + TEST(1327, 0 == wstrcmp("aaa", "aaa")); + TEST(1328, 0 == wstrcmp("aaa", "aaa")); + TEST(1329, 0 == wstrcmp("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯ")); + TEST(1330, 0 == wstrcmp("ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯYYYY", "ÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯXXXX", 32)); } static void test_wstrcasecmp(void) { - TEST(1301, 0 == wstrcasecmp("AaA", "aAa")); - TEST(1302, 0 == wstrcasecmp("AaAXXX", "aAaYYY", 3)); + TEST(1331, 0 == wstrcasecmp("AaA", "aAa")); + TEST(1332, 0 == wstrcasecmp("AaAXXX", "aAaYYY", 3)); } static void test_wlower(void) { - TEST(1303, wlower("AbC") == "abc"); - TEST(1304, wlower("ÓÓ") == "óó"); - TEST(1305, wlower(L'Ó') == L'ó'); + TEST(1333, wlower("AbC") == "abc"); + TEST(1334, wlower("ÓÓ") == "óó"); + TEST(1335, wlower(L'Ó') == L'ó'); } static void test_wupper(void) { - TEST(1306, wupper("aBc") == "ABC"); - TEST(1307, wupper("óó") == "ÓÓ"); - TEST(1308, wupper(L'ó') == L'Ó'); + TEST(1336, wupper("aBc") == "ABC"); + TEST(1337, wupper("óó") == "ÓÓ"); + TEST(1338, wupper(L'ó') == L'Ó'); } @@ -1509,23 +1625,23 @@ test_wread(void) insert(sval); top_of_buffer(); line = read(NULL, status); - TEST(1309, status == 1); /* EOF */ - TEST(1310, line == sval); + TEST(1339, status == 1); /* EOF */ + TEST(1340, line == sval); top_of_buffer(); insert(wval); top_of_buffer(); line = read(NULL, status); - TEST(1311, status == 1); /* EOF */ - TEST(1312, line == wval); + TEST(1341, status == 1); /* EOF */ + TEST(1342, line == wval); line = read(wlen, status); - TEST(1313, status == 1); /* EOF */ - TEST(1314, line == wval); + TEST(1343, status == 1); /* EOF */ + TEST(1344, line == wval); line = read(10, status); - TEST(1315, status == 0); /* partial */ - TEST(1316, line == wsubstr(line, 1, 10)); + TEST(1345, status == 0); /* partial */ + TEST(1346, line == wsubstr(line, 1, 10)); restore_position(2); delete_buffer(buf); @@ -1542,14 +1658,13 @@ test_wsprintf(void) int wc; wc = sprintf(buffer, "%s", sval); // string, by length. - TEST(1317, wc == strlen(sval)); + TEST(1347, wc == strlen(sval)); wc = sprintf(buffer, "%S", wval); // wide-string, by length. - TEST(1318, wc == wstrlen(wval)); + TEST(1348, wc == wstrlen(wval)); wc = sprintf(buffer, "%W", dval); // by width - TEST(1319, wc == wcwidth(dval)); + TEST(1349, wc == wcwidth(dval)); } /*end*/ - diff --git a/macsrc/demos/snake.cr b/macsrc/demos/snake.cr index 0c19fee2..a87456e0 100644 --- a/macsrc/demos/snake.cr +++ b/macsrc/demos/snake.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: snake.cr,v 1.4 2014/10/27 23:28:32 ayoung Exp $ +/* $Id: snake.cr,v 1.6 2024/08/02 12:59:02 cvsuser Exp $ * Game of Snake. * * @@ -19,8 +19,9 @@ #define FOODMAX 10 #define TMUNIT 800 // milliseconds -#define TMFRAME 50 // frame per speed increment -#define SPEEDMAX 15 // (TMFRAME * SPEEDMAX) < TMUNIT +#define TMFRAME 80 // frame per speed increment +#define SPEEDBASE 3 +#define SPEEDMAX 10 // (TMFRAME * (SPEEDMAX+1)) < TMUNIT (default=BASE) enum { LEFT, @@ -138,7 +139,7 @@ snake_play(void) extern int score, bx, by; list body, food; // body/food elements. - int size, speed, moves; // statistics. + int size, speed, hits, moves; // statistics. int sx, sy, sd; // snake position and direction. int ftm, ctm; // time references. int ch; @@ -148,14 +149,14 @@ snake_play(void) srand(time()); UNUSED(body, food); - UNUSED(size, speed, moves); + UNUSED(size, speed, hits, moves); UNUSED(bx, by); UNUSED(sx, sy, sd); moves = 0; while (1) { move_abs(sy, sx); - // message("Score: %d, Moves: %d, Speed: %d, Size: %d", score, moves, speed, size); +// message("Score: %d, Moves: %d, Speed: %d, Hits: %d, Size: %d", score, moves, speed, hits, size); ch = read_char(TMUNIT / TMFRAME); keyboard_flush(); @@ -224,15 +225,16 @@ snake_play(void) static void snake_init(void) { - extern int score, size, speed, moves; // statistics + extern int score, hits, size, speed, moves; // statistics extern int sx, sy, sd; // snake position and direction extern int bx, by; // bounds extern int ftm; // time references ftm = snake_time() + 1000; score = 0; + hits = 0; size = SIZEMIN; - speed = 1; + speed = SPEEDBASE; moves = 0; sx = bx/2; sy = by/2; @@ -251,7 +253,7 @@ snake_time(void) static int snake_move(void) { - extern int score, size, speed, moves; // statistics. + extern int score, hits, size, speed, moves; // statistics. extern int sx, sy, sd; // snake position and direction. extern int bx, by; // bounds. @@ -287,17 +289,19 @@ snake_move(void) if (food_hit(sx, sy, TRUE)) { // grow new food food_generate(1); + ++hits; - if (speed < SPEEDMAX) { - ++speed; // increase speed + int factor = 3 + (hits / 8); + if (0 == (hits % factor)) { // hits=3,6,10,13,17 .. + if (speed < SPEEDMAX) { + ++speed; // increase speed + } } if (size < SIZEMAX) { size += 2; // increase size } - message("Score: %d", ++score); - } else if (speed < SPEEDMAX) { if (0 == (moves % (SPEEDMAX - speed))) { if (size < SIZEMAX) { @@ -305,6 +309,13 @@ snake_move(void) } } } + + int newscore = (hits * 10) + (size * 2); + if (newscore != score) + { + message("Scoore: %d", newscore); + score = newscore; + } /* erase trailing image */ snake_tail(); @@ -409,9 +420,5 @@ food_hit(int x, int y, int rm) } return FALSE; } -/*end*/ - - - - +/*end*/ diff --git a/macsrc/dispinfo.cr b/macsrc/dispinfo.cr index ee5fe01b..859d669e 100644 --- a/macsrc/dispinfo.cr +++ b/macsrc/dispinfo.cr @@ -1,5 +1,5 @@ /* -*- indent-width: 4; -*-/ - * $Id: dispinfo.cr,v 1.6 2014/10/27 23:28:20 ayoung Exp $ + * $Id: dispinfo.cr,v 1.8 2024/09/25 15:52:03 cvsuser Exp $ * Display information/configuration. * * @@ -92,6 +92,12 @@ main() DLGC_LABEL, DLGA_LABEL, "Encoding", DLGA_ALIGN_W, + DLGC_LABEL, + DLGA_LABEL, "Scheme", + DLGA_ALIGN_W, + DLGC_LABEL, + DLGA_LABEL, "KBProtocol", + DLGA_ALIGN_W, DLGC_END, DLGC_CONTAINER, DLGA_ATTACH_RIGHT, @@ -116,6 +122,16 @@ main() DLGA_NAME, "encoding", DLGA_ROWS, 1, DLGA_ALLOW_FILLX, + DLGC_LABEL, + DLGA_ALIGN_E, + DLGA_NAME, "scheme", + DLGA_ROWS, 1, + DLGA_ALLOW_FILLX, + DLGC_LABEL, + DLGA_ALIGN_E, + DLGA_NAME, "kbprotocol", + DLGA_ROWS, 1, + DLGA_ALLOW_FILLX, DLGC_END, DLGC_END, @@ -219,7 +235,7 @@ main() DLGC_LABEL, DLGA_LABEL, "Scroll row/cols:", DLGA_ATTACH_LEFT, - DLGA_COLS, 20, + DLGA_COLS, 18, DLGC_EDIT_FIELD, DLGA_NAME, "scroll_rows", DLGA_ATTACH_LEFT, @@ -239,7 +255,7 @@ main() DLGC_LABEL, DLGA_LABEL, "Visible row/cols:", DLGA_ATTACH_LEFT, - DLGA_COLS, 20, + DLGA_COLS, 18, DLGC_EDIT_FIELD, DLGA_NAME, "visible_rows", DLGA_ATTACH_LEFT, @@ -258,8 +274,9 @@ main() DLGC_END, DLGC_GROUP, DLGA_TITLE, "Scroll Bars", + DLGA_ATTACH_LEFT, + DLGA_PADX, 1, DLGA_ALIGN_W, - DLGA_PADY, 1, DLGC_CHECK_BOX, DLGA_LABEL, "Vertical", DLGA_ATTACH_TOP, @@ -271,31 +288,27 @@ main() DLGA_ALIGN_W, DLGA_NAME, "sb_horz", DLGC_END, // GROUP - DLGC_END, // CONTAINER - - DLGC_CONTAINER, - DLGA_ATTACH_TOP, - DLGA_ALIGN_W, DLGC_GROUP, DLGA_TITLE, "Columns", - DLGA_ATTACH_LEFT, + DLGA_ATTACH_RIGHT, DLGA_ALIGN_W, + DLGA_PADX, 1, DLGC_CONTAINER, - DLGA_ALIGN_W, - DLGC_LABEL, + DLGA_ALIGN_W, + DLGC_LABEL, DLGA_LABEL, "Number:", DLGA_ATTACH_LEFT, - DLGA_COLS, 20, - DLGC_EDIT_FIELD, + DLGA_COLS, 12, + DLGC_EDIT_FIELD, DLGA_NAME, "number_cols", DLGA_ATTACH_LEFT, DLGA_ROWS, 1, - DLGA_COLS, 5, + DLGA_COLS, 4, DLGC_END, DLGC_END, // GROUP - DLGC_END, // CONTAINER + DLGC_END, // CONTAINER - DLGC_CONTAINER, + DLGC_CONTAINER, DLGA_ATTACH_BOTTOM, DLGC_PUSH_BUTTON, DLGA_LABEL, "&Done", @@ -329,22 +342,32 @@ di_callback(int ident, string name, int p1, int p2) UNUSED(ident, p2); switch (p1) { case DLGE_INIT: { - string feature, encoding; - int lines, cols, colors, escsource; + string feature, encoding, colorscheme, scheme, kbprotocol; + int isdark, lines, cols, colors, escsource; int i; inq_screen_size(lines, cols); // display get_term_feature(TF_NAME, feature); get_term_feature(TF_COLORDEPTH, colors); get_term_feature(TF_ENCODING, encoding); + get_term_feature(TF_SCHEMEDARK, isdark); + get_term_feature(TF_COLORSCHEME, colorscheme); + get_term_feature(TF_KBPROTOCOL, kbprotocol); sprintf(feature, "%dx%d-%d (%s)", cols, lines, colors, feature); + if (colorscheme == "") + scheme += (isdark ? "dark" : "light"); + else + sprintf(scheme, "%s (%s)", colorscheme, (isdark ? "dark" : "light")); + widget_set(NULL, "display", feature); inq_font(feature); widget_set(NULL, "font", feature); sprintf(feature, "%dms (%d)", inq_char_timeout(escsource), escsource); widget_set(NULL, "escdelay", feature); widget_set(NULL, "encoding", encoding); + widget_set(NULL, "scheme", scheme); + widget_set(NULL, "kbprotocol", kbprotocol); // scroll parameters, plus line-number column. widget_set(NULL, "scroll_cols", inq_display_mode("scroll_cols")); @@ -404,3 +427,7 @@ di_callback(int ident, string name, int p1, int p2) } /*eof*/ + + + + diff --git a/macsrc/grief.cr b/macsrc/grief.cr index 93336369..697c96ba 100644 --- a/macsrc/grief.cr +++ b/macsrc/grief.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: grief.cr,v 1.90 2024/05/20 17:04:23 cvsuser Exp $ +/* $Id: grief.cr,v 1.97 2024/09/08 16:25:51 cvsuser Exp $ * GRIEF startup macro. * * @@ -42,6 +42,8 @@ void _griset_colorscheme16(string arg); string _griget_colorscheme16(void); void _griset_colorscheme(string arg); string _griget_colorscheme(void); + +void console_detect(void); #endif /*__PROTOTYPES__*/ /* @@ -185,9 +187,7 @@ main(void) void grief(void) { - string envvar, term; - list suf_list; - int i, len; + string envvar; /* * Inform GRIEF where to find macros, done prior 2 keyboard mapping to allow @@ -227,8 +227,7 @@ grief(void) autoload("colors", "coloriser", "inq_coloriser", - "colorscheme", - "vim_colorscheme"); + "colorscheme"); autoload("compile", "_griset_load", "load", @@ -295,8 +294,9 @@ grief(void) "_open_line"); autoload("key", "key", - "keyx", + "key_code", "key_test", + "key_trace", "key_map", "key_val", "key_learn_menu", @@ -342,6 +342,8 @@ grief(void) "delete_character", "delete_blank_lines", "hex", "dec"); + autoload("popup", + "popup_mouse"); autoload("print", "_griget_print", "_griset_print"); autoload("options", @@ -615,30 +617,17 @@ grief(void) register_macro(REG_ALT_H, "prompt_help"); /* - * Determine the terminal type, and initialise the terminal characteristics. - * - * First test whether GRTERM is set. If it is, then load tty/$GRTERM; - * If not, use TERM, and test to see if tty/$TERM exists. Otherwise, - * default to tty.m. - * - * If the GRTERM environment variable is of the form: - * - * type-type1-type2, - * - * then load tty/type.m and execute macros 'type1', 'type2', ... This is to - * avoid exceeding the 14 character filename limit on Sys V, and also to keep - * terminal definitions which are similar in the same tty file - * + * Determine the interface type, and initialise. */ if (display_mode() & DC_WINDOW) { /* * Windowed environment */ - int maj, min, edit; + int maj, min, edit, rel; string buf, buf1; - version(maj, min, edit); - sprintf(buf, "%s v%d.%d%c", APPNAME, maj, min, edit); + version(maj, min, edit, rel); + sprintf(buf, "%s v%d.%d.%d.%d", APPNAME, maj, min, edit, rel); sprintf(buf1, "v%d.%d%c", maj, min, edit); set_wm_name(buf, buf1); set_term_feature(TF_COLOR, TRUE); @@ -647,38 +636,8 @@ grief(void) /* * Console */ - term = lower(getenv("GRTERM")); /* TERM override ? */ - if (term == "") { - term = lower(getenv("TERM")); - } - - if (term == "") { - load_macro("tty/tty"); /* default */ - } else { - suf_list = split(term, "-"); /* split */ - if (! load_macro("tty/" + suf_list[0])) { - load_macro("tty/tty"); /* default */ - } - term = suf_list[0]; - } - - /* - * Process attributes (XXX - should limit to a set of well known features) - * - * Examples: - * xterm-ansi_arrows - */ - len = length_of_list(suf_list); - for (i = 1; i < len; ++i) { - string func = term + "_" + suf_list[i]; - - if (inq_macro(func) > 0) { - execute_macro(func); /* ie. xterm_ansi_arrows */ - - } else if (inq_macro(suf_list[i]) > 0) { - execute_macro(suf_list[i]); /* ie. ansi_arrows */ - } - } + load_macro("tty/console"); + console_detect(); } /* Display,mouse */ @@ -734,19 +693,6 @@ _chg_properties(void) } -/* - * ansi_arrows --- - * Following macro used for setting arrow keys to standard ANSI sequences. - */ -void -ansi_arrows(void) -{ - set_term_keyboard( - KEY_UP, "\x1b[A", KEY_DOWN, "\x1b[B", - KEY_LEFT, "\x1b[D", KEY_RIGHT, "\x1b[C"); -} - - void shell_pop(string command) { @@ -959,8 +905,16 @@ grinit_onload(void) // const string sect = "GRIEF", inifile = inq_grinit(); + string grscheme; int ifd; + grscheme = getenv("GRCOLORSCHEME"); // env/cmdline override, use unconditionally. + if (grscheme) { + if (colorscheme(grscheme) == TRUE) { + coloriserenv = TRUE; + } + } + if (! exist(inifile)) { // apply defaults string pkg = getenv("BPACKAGES"); // user BPACKAGES specification, import @@ -976,14 +930,6 @@ grinit_onload(void) return; } - string arg; - arg = getenv("GRCOLORSCHEME"); // user override, use unconditionally. - if (arg) { - if (colorscheme(arg) == TRUE) { - coloriserenv = TRUE; - } - } - if ((ifd = iniopen(inifile, IFILE_STANDARD|IFILE_COLON)) >= 0) { string key, value, fn; int p, ret; @@ -1615,4 +1561,3 @@ clear_buffer(void) /*end*/ - diff --git a/macsrc/grief.h b/macsrc/grief.h index cf4fb592..79b4d215 100644 --- a/macsrc/grief.h +++ b/macsrc/grief.h @@ -60,12 +60,14 @@ #define TF_DEFAULT_FG 32 /* default foreground color */ #define TF_DEFAULT_BG 33 /* default background color */ #define TF_SCHEMEDARK 34 /* *true* if the default color is "dark" */ -#define TF_COLORSETFGBG 35 -#define TF_COLORSET_FG 36 /* color set foreground control sequence */ -#define TF_COLORSET_BG 37 /* color set background control sequence */ +#define TF_COLORRGB 35 /* *true* if RGB colors are supported */ +#define TF_COLORSET_FG 36 /* color set foreground control sequence (ANSI colors) */ +#define TF_COLORSET_BG 37 /* color set background control sequence (ANSI colors) */ #define TF_COLORMAP 38 /* color map (terminal) */ #define TF_COLORPALETTE 39 /* color palette (driver) */ -#define TF_COLORSCHEME 40 /* current scheme dark or light */ +#define TF_COLORSCHEME 40 /* current color-scheme */ +#define TF_COLORSETRGB_FG 41 /* color set foreground control sequence (RGB colors) */ +#define TF_COLORSETRGB_BG 42 /* color set background control sequence (RGB colors) */ #define TF_CLEAR_IS_BLACK 50 /* clear is black */ #define TF_DISABLE_INSDEL 51 /* disable ins/del scrolling method */ @@ -80,6 +82,7 @@ #define TF_ATTRIBUTES 60 /* terminal attribute flags */ #define TF_TTY_FAST 62 /* fast tty optimisations */ #define TF_TTY_GRAPHICSBOX 63 /* graphics mode required for box characters */ +#define TF_KBPROTOCOL 64 /* kbprotocol */ #define TF_SCREEN_ROWS 70 /* screen rows */ #define TF_SCREEN_COLS 71 /* screen cols */ @@ -92,8 +95,9 @@ #define TF_XTERM_COMPAT 82 /* XTERM compatible termuinal */ #define TF_XTERM_PALETTE 83 /* XTERM palette control */ -#define TF_VT_DATYPE 90 /* VT/XTERM Devive Attribute Type */ -#define TF_VT_DAVERSION 91 /* VT/XTERM Devive Attribute Version */ +#define TF_VT_DATYPE 90 /* VT/XTERM Device Attribute Type */ +#define TF_VT_DAVERSION 91 /* VT/XTERM Device Attribute Version */ +#define TF_VT_DAOPTIONS 92 /* VT/XTERM Device Attribute Options */ #define TF_ENCODING 100 /* terminal character encoding */ #define TF_ENCODING_GUESS 101 /* text encoding guess specification */ @@ -125,6 +129,9 @@ #define TF_AUTF8ENCODING 0x0000010 /* UTF8 character encoding, Unicode implied */ #define TF_AUNICODEENCODING 0x0000020 /* Unicode character encoding */ #define TF_AMETAKEY 0x0000100 /* Meta keys */ +#define TF_AXTERMKEYS 0x0000200 /* XTerm modifyOtherKeys */ +#define TF_AKITTYKEYS 0x0000400 /* Kitty extended keycodes */ +#define TF_AMSTERMINALKEYS 0x0000800 /* MS-Terminal extended keycodes */ /* * Registered macro types @@ -847,6 +854,7 @@ #define DLGC_CONTAINER 0x2001 /* Widget container */ #define DLGC_GROUP 0x2002 /* Group start */ #define DLGC_TAB 0x2003 /* Tab panel */ +#define DLGC_MENU 0x2004 /* Menu */ #define DLGC_END 0x200f /* End of current container */ #define DLGC_PUSH_BUTTON 0x2011 /* Push button */ @@ -858,17 +866,21 @@ #define DLGC_EDIT_FIELD 0x2017 /* Edit field */ #define DLGC_NUMERIC_FIELD 0x2018 /* Numeric edit field */ #define DLGC_COMBO_FIELD 0x2019 /* Edit field and drop list */ +#define DLGC_GAUGE 0x201a /* Gauge */ #define DLGC_SPACER 0x2030 /* Display spacer */ #define DLGC_SEPARATOR_HORIZONTAL 0x2031 #define DLGC_SEPARATOR_VERTICAL 0x2032 -#define DLGC_TREE 0x2040 /* *not* implemented */ -#define DLGC_GAUGE 0x2041 /* *not* implemented */ -#define DLGC_SLIDER 0x2042 /* *not* implemented */ -#define DLGC_VSCROLLBAR 0x2043 /* *not* implemented */ -#define DLGC_HSCROLLBAR 0x2044 /* *not* implemented */ -#define DLGC_GRID 0x2070 /* *not* implemented */ +#define DLGC_MENU_ITEM 0x2041 +#define DLGC_MENU_SEPARATOR 0x2042 + +#define DLGC_TREE 0x20f0 /* *not* implemented */ +#define DLGC_TABLE 0x20f1 /* *not* implemented */ +#define DLGC_SLIDER 0x20f2 /* *not* implemented */ +#define DLGC_VSCROLLBAR 0x20f3 /* *not* implemented */ +#define DLGC_HSCROLLBAR 0x20f4 /* *not* implemented */ +#define DLGC_GRID 0x20f5 /* *not* implemented */ #define DLGC_MAX 0x2100 /* @@ -888,6 +900,7 @@ #define DLGA_COLS 0x3009 #define DLGA_ROWS 0x300a #define DLGA_VERSION 0x300b /* Wiget specific version/feature set identifier */ +#define DLGA_STYLES 0x300c #define DLGA_ATTACH_BOTTOM 0x3010 /* Attachment of widget within dialog box. */ #define DLGA_ATTACH_TOP 0x3011 @@ -1015,6 +1028,20 @@ #define DLGA_GAUGEMAX 0x30e1 /* Maximum value. */ +/* + * Dialog styles. + */ +#define DLGS_BORDER 0x0001 +#define DLGS_CAPTION 0x0002 + +#define DLGS_MAXIMIZE 0x0100 +#define DLGS_MINIMIZE 0x0200 +#define DLGS_RESTORE 0x0400 +#define DLGS_SYSCLOSE 0x1000 +#define DLGS_SYSMOVE 0x2000 +#define DLGS_SYSSIZE 0x4000 +#define DLGS_SYSMENU 0x8000 + /* * Dialog callback events @@ -1034,10 +1061,10 @@ DLGE_HELP Indicates that the user pressed the F1 key. - If a menu is active when F1 is pressed, WM_HELP is sent to the - window associated with the menu; otherwise, WM_HELP is sent to + If a menu is active when F1 is pressed, DLGE_HELP is sent to the + window associated with the menu; otherwise, DLGE_HELP is sent to the widget that has the keyboard focus. If no widget has the - focus, WM_HELP is sent to the currently active window. + focus, DLGE_HELP is sent to the currently active window. */ #define DLGE_INIT 0 /* Initlisation */ @@ -1049,6 +1076,17 @@ #define DLGE_KEYDOWN 6 /* Keydown event */ #define DLGE_COMMAND 7 /* Accelerator/Menu command */ #define DLGE_HELP 8 /* Help event */ +#define DLGE_SYSCOMMAND 9 /* System command */ + +/* + * System commands. + */ +#define DLSC_CLOSE 0xf010 +#define DLSC_TITLE 0xf020 +#define DLSC_MOVE 0xf100 +#define DLSC_SIZE 0xf120 +#define DLSC_MAXIMIZE 0xf200 +#define DLSC_MINIMIZE 0xf210 /* * create_notice @@ -1464,13 +1502,8 @@ extern void coloriser(~ string); extern int colorscheme(~ string scheme, ...); extern string inq_coloriser(void); -#define VIM_16DEPTH (1 << 1) -#define VIM_88DEPTH (1 << 2) -#define VIM_256DEPTH (1 << 3) -#define VIM_GUIDEPTH (1 << 4) - + /*colorsvim.cr*/ extern int vim_colorscheme(string label, int colors, ~string base, list spec, int asgui); -extern int vim_colorschemex(string label, int colors, ~string base, list spec, int asgui, int &gui); /*command.cr*/ extern string fixslash(string str); diff --git a/macsrc/grief_tail.h b/macsrc/grief_tail.h index f672a1c3..66540a30 100644 --- a/macsrc/grief_tail.h +++ b/macsrc/grief_tail.h @@ -1,5 +1,5 @@ /* -*- mode: cr; tabs: 4; -*- */ -/* $Id: grief_tail.h,v 1.23 2021/04/15 15:44:59 cvsuser Exp $ +/* $Id: grief_tail.h,v 1.24 2024/07/05 18:41:55 cvsuser Exp $ * Common GRIEF macro definitions -- tail. * Utilised by the makeinc.pl script. * @@ -176,13 +176,8 @@ extern void coloriser(~ string); extern int colorscheme(~ string scheme, ...); extern string inq_coloriser(void); -#define VIM_16DEPTH (1 << 1) -#define VIM_88DEPTH (1 << 2) -#define VIM_256DEPTH (1 << 3) -#define VIM_GUIDEPTH (1 << 4) - + /*colorsvim.cr*/ extern int vim_colorscheme(string label, int colors, ~string base, list spec, int asgui); -extern int vim_colorschemex(string label, int colors, ~string base, list spec, int asgui, int &gui); /*command.cr*/ extern string fixslash(string str); @@ -416,3 +411,5 @@ extern void unzoom(void); /*end*/ #endif /*MACSRC_GRIEF_H_INCLUDED*/ /*--end--*/ + + diff --git a/macsrc/help.cr b/macsrc/help.cr index b8ee97a3..1085b701 100644 --- a/macsrc/help.cr +++ b/macsrc/help.cr @@ -1,4 +1,4 @@ -/* $Id: help.cr,v 1.51 2014/10/27 23:28:22 ayoung Exp $ +/* $Id: help.cr,v 1.52 2024/09/06 14:35:57 cvsuser Exp $ * Help subsystem. * * @@ -179,15 +179,15 @@ void help_about(void) { string machtype, compiled; - int curbuf; - int buf, win, lines, width; + int curbuf, aboutbuf, aboutwin; + int lines, width; int maj, min, edit, rel, cmver; curbuf = inq_buffer(); - if ((buf = create_buffer("About", NULL, 1)) < 0) { + if ((aboutbuf = create_buffer("About", NULL, 1)) < 0) { return; } - set_buffer(buf); + set_buffer(aboutbuf); insert("\n"); version(maj, min, edit, rel, machtype, compiled, cmver); insertf("%s %s v%d.%d.%d (%d)\n\n", APPNAME, machtype, maj, min, edit, cmver); @@ -195,9 +195,9 @@ help_about(void) lines = inq_lines() + 1; width = inq_line_length() + 2; set_buffer(curbuf); /* restore buffer */ - win = sized_window(lines, width, ""); - select_buffer(buf, win, SEL_CENTER, "", NULL, NULL); - delete_buffer(buf); /* release local buffer */ + aboutwin = sized_window(lines, width, ""); + select_buffer(aboutbuf, aboutwin, SEL_CENTER, "", NULL, NULL); + delete_buffer(aboutbuf); /* release local buffer */ } @@ -936,7 +936,7 @@ help_sumlist(string title, list l) string s; int i; - insert("\t\t[[ " + title + " ]]\n\n"); + insert("\t\t[[ " + title + " ]]\n\n"); drop_anchor(MK_LINE); for (i = 0; i < length_of_list(l); i += 2) { s = l[i]; @@ -1060,9 +1060,9 @@ mapcs() string help_window(int type, int buf, int lines, int width, int initial_line, ~int, ~string) { -#define HR_ELEMS 3 /* text,line,col */ +#define HR_ELEMS 4 /* text,line,col,lenw */ - list refer_list; /* refer elements [name,start,end] */ + list refer_list; /* refer elements [name,line,col1,col2] */ list unique_refer_list; /* unique refer names */ string refer; @@ -1071,7 +1071,7 @@ help_window(int type, int buf, int lines, int width, int initial_line, ~int, ~st string msg, pattern, entry, c; int sbuf, sline, scol; /* buffer for striping \b's */ - int curbuf, win; + int curbuf, hlpwin; int ret; UNUSED(unique_refer_list); @@ -1230,7 +1230,7 @@ help_window(int type, int buf, int lines, int width, int initial_line, ~int, ~st tabs(8); /* defacto terminal standard */ set_buffer(curbuf); /* restore buffer */ - win = sized_window( lines, width, + hlpwin = sized_window( lines, width, ((msg != "" ? msg : help_level > 1 ? " exit, " : " exit")) + (help_ret == HR_INACTIVE ? @@ -1238,7 +1238,7 @@ help_window(int type, int buf, int lines, int width, int initial_line, ~int, ~st (type == HELP_MAN ? ", " : "") ); cursor(0); - ret = select_buffer(buf, win, SEL_NORMAL, + ret = select_buffer(buf, hlpwin, SEL_NORMAL, "help_winkeys", NULL, NULL, initial_line); cursor(1); if (help_level > 0) { @@ -1369,6 +1369,7 @@ help_rpush(string entry) refer_list += entry; /* non-unique references */ refer_list += sline; refer_list += col; + refer_list += col + strlen(entry); if (-1 == re_search(SF_IGNORE_CASE, /* unique references */ "<" + entry + ">", unique_refer_list)) { @@ -1412,20 +1413,20 @@ help_winkeys() replace_assigned_keys("search__back", "::help_search_back"); } #endif - assign_to_key("^G", "routines hlp"); - assign_to_key("", "::help_refer"); + assign_to_key("^G", "routines hlp"); + assign_to_key("", "::help_refer"); if (help_type == HELP_MAN) { - assign_to_key("", "::help_list"); + assign_to_key("", "::help_list"); } - assign_to_key("", "::help_esc"); - assign_to_key("", "::help_space"); - assign_to_key("", "::help_prev"); - // assign_to_key("", "::help_item"); - assign_to_key("", "::help_exit"); - assign_to_key("", "::help_tab 1"); - assign_to_key("", "::help_tab 1"); - assign_to_key("", "::help_tab 0"); - assign_to_key("", "::help_tab 0"); + assign_to_key("", "::help_esc"); + assign_to_key("", "::help_space"); + assign_to_key("", "::help_prev"); + assign_to_key("", "::help_exit"); + assign_to_key("", "::help_tab 1"); + assign_to_key("", "::help_tab 1"); + assign_to_key("", "::help_tab 0"); + assign_to_key("", "::help_tab 0"); + assign_to_key("", "::help_link"); } @@ -1503,8 +1504,8 @@ help_refer() extern int window_offset, top_line; /* sized_window() globals */ extern list refer_list, unique_refer_list; /* refer lists */ - int o_window_offset = window_offset; - int o_top_line = top_line; + int owindow_offset = window_offset; + int otop_line = top_line; int ret; if (0 == length_of_list(refer_list)) { /* list length */ @@ -1515,8 +1516,8 @@ help_refer() inq_window_info(NULL, NULL, window_offset, NULL, NULL, top_line); window_offset += 10, top_line += 2; ret = select_slim_list("refer", "", unique_refer_list, SEL_CENTER, NULL, NULL, 1); - window_offset = o_window_offset; - top_line = o_top_line; + window_offset = owindow_offset; + top_line = otop_line; if (ret > 0) { if ((ret = re_search(SF_IGNORE_CASE, /* map unique to first refer element */ @@ -1527,6 +1528,20 @@ help_refer() } } +static void +refer_highlight() +{ + extern list refer_list; + + raise_anchor(); + if (help_ret >= 0) { + move_abs( refer_list[ help_ret+1 ], refer_list[ help_ret+2 ] ); + re_search( SF_NOT_REGEXP, refer_list[ help_ret ] ); + drop_anchor( MK_COLUMN ); + next_char( strlen(refer_list[ help_ret ])-1 ); + } +} + static void help_list() @@ -1535,8 +1550,8 @@ help_list() extern list flist; /* see man.cr */ extern int fidx; /* see man.cr */ - int o_window_offset = window_offset; - int o_top_line = top_line; + int owindow_offset = window_offset; + int otop_line = top_line; int ret; if (0 == length_of_list(flist)) { /* list length */ @@ -1547,8 +1562,8 @@ help_list() inq_window_info( NULL, NULL, window_offset, NULL, NULL, top_line ); window_offset += 10, top_line += 2; ret = select_slim_list("apropos", "", flist, 0, NULL, NULL, 1); - window_offset = o_window_offset; - top_line = o_top_line; + window_offset = owindow_offset; + top_line = otop_line; if (ret > 0 && fidx != (ret - 1)) { fidx = ret - 1; @@ -1618,7 +1633,6 @@ help_tab() return; len = length_of_list(refer_list); /* list length */ - inq_position(curline); get_parm(0, fwd); /* direction */ @@ -1652,13 +1666,42 @@ help_tab() } } } + refer_highlight(); +} - /* locate and hilight text */ - raise_anchor(); - move_abs( refer_list[ help_ret+1 ], refer_list[ help_ret+2 ] ); - re_search( SF_NOT_REGEXP, refer_list[ help_ret ] ); - drop_anchor( MK_COLUMN ); - next_char( strlen(refer_list[ help_ret ])-1 ); + +static void +help_link() +{ + extern list refer_list; /* refer list */ + extern int hlpwin; + + int i, cwin, line, col, where; + + get_mouse_pos(NULL, NULL, cwin, line, col, where, NULL, NULL); + if (cwin == hlpwin) { + switch (where) { + case MOBJ_INSIDE: + help_ret = HR_INACTIVE; + for (i = 0; i < length_of_list(refer_list); i += HR_ELEMS) { + if (refer_list[i + 1] == line) { + if (col >= refer_list[i + 2] && col <= refer_list[i + 3]) { + help_ret = i; + sel_enter(); + break; + } + } + } + refer_highlight(); + break; + case MOBJ_TOP_EDGE: + case MOBJ_BOTTOM_EDGE: + case MOBJ_TITLE: + case MOBJ_CLOSE: + sel_esc(); + break; + } + } } diff --git a/macsrc/key.cr b/macsrc/key.cr index 3f944293..44d5b254 100644 --- a/macsrc/key.cr +++ b/macsrc/key.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: key.cr,v 1.24 2021/07/11 10:59:08 cvsuser Exp $ +/* $Id: key.cr,v 1.25 2024/08/25 06:02:04 cvsuser Exp $ * Key definition tools. * * @@ -134,7 +134,7 @@ key(void) } -/* Function: keyx +/* Function: key_code * Retrieve the "key-code" for the next input event, including mouse. * * Parameters: @@ -144,13 +144,13 @@ key(void) * none */ void -keyx() +key_code() { string description; int seq = 7; while (--seq > 0) { - message("keyx (%d): %s", seq, description); + message("key_code (%d): %s", seq, description); int key = read_char(1000, -1); /* next event */ if (key >= 0) { if (IsMouse(key)) { @@ -221,6 +221,7 @@ key_test(void) ascii = ""; while (1) { + // TODO: CSI/OSC detection sprintf(tmp, "%c", ch); escseq += tmp; /* raw esc sequence */ @@ -254,6 +255,68 @@ key_test(void) } +/* Function: key_trace + * Keyboard diagnostics + * + * Parameters: + * none + * + * Returns: + * none + */ +void +key_trace() +{ + int buf, curbuf; + + if ((buf = create_buffer("key_trace")) < 0) { + return; + } + + curbuf = inq_buffer(); + set_buffer(buf); + attach_buffer(buf); + + keyboard_push(); + assign_to_key("", "exit"); + assign_to_key("", "exit"); + assign_to_key("", "::_key_trace {}"); // + + message("key_trace: or to exit"); + process(); + message(""); + keyboard_pop(1); + + delete_buffer(buf); + set_buffer(curbuf); + attach_buffer(curbuf); +} + + +static void +_key_trace(string seq, int key) +{ + int hour, min, sec, msec, line; + + inq_position(line); + time(hour, min, sec, msec); + + insertf("%6u: %02d:%02d:%02d.%03d: ", line, hour, min, sec, msec); + if (IsMouse(key)) { + int x, y, where, region, event; + + get_mouse_pos(x, y, NULL, NULL, NULL, where, region, event); + insertf("0x%08x/%-9u %-32s (x=%u, y=%u, where=%u, region=%u, event=0x%x) [%s]\n", + key, key, int_to_key(key), x, y, where, region, event, seq); + + } else { + insertf("0x%08x/%-9d %-32s [%s]\n", + key, key, int_to_key(key), seq); + } +} + + + /* Function: key_map * Display the current keyboard mapping * @@ -266,14 +329,13 @@ key_test(void) void key_map() { - int curbuf = inq_buffer(), - curwin = inq_window(); - int i, len, buf, win; - list lst; + int curbuf = inq_buffer(), curwin = inq_window(); + int i, len, buf, win; + list lst; - lst = key_list(NULL, NULL, NULL); - len = length_of_list(lst); - buf = create_buffer("Key Map", NULL, 1); + lst = key_list(NULL, NULL, NULL); + len = length_of_list(lst); + buf = create_buffer("Key Map", NULL, 1); set_buffer(buf); for (i = 0; i < len; i += 2) { insert(lst[i]); @@ -282,7 +344,6 @@ key_map() insert("\n"); } delete_line(); - // sort_buffer(); win = sized_window(inq_lines(), inq_line_length() + 1); select_buffer(buf, win, SEL_NORMAL); @@ -629,3 +690,7 @@ key_termmapping(void) } /*end*/ + + + + diff --git a/macsrc/license.cr b/macsrc/license.cr index e808b0d6..e3b3dc33 100644 --- a/macsrc/license.cr +++ b/macsrc/license.cr @@ -1,5 +1,5 @@ /* -*- indent-width: 4; -*- */ -/* $Id: license.cr,v 1.18 2024/05/12 17:13:18 cvsuser Exp $ +/* $Id: license.cr,v 1.19 2024/08/04 10:07:57 cvsuser Exp $ * License information. * * @@ -58,11 +58,11 @@ main() }; license_text += license_import(); - int maj, min, edit; + int maj, min, edit, rel; string verbuf; - version(maj, min, edit); - sprintf(verbuf, "%s v%d.%d.%d", APPNAME, maj, min, edit); + version(maj, min, edit, rel); + sprintf(verbuf, "%s v%d.%d.%d.%d", APPNAME, maj, min, edit, rel); dialog = dialog_create( make_list( diff --git a/macsrc/modes/cmake.cr b/macsrc/modes/cmake.cr index 5396f3db..743318b0 100644 --- a/macsrc/modes/cmake.cr +++ b/macsrc/modes/cmake.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 4; -*- - * $Id: cmake.cr,v 1.3 2022/07/10 13:08:02 cvsuser Exp $ + * $Id: cmake.cr,v 1.4 2024/07/30 16:29:20 cvsuser Exp $ * 'cmake' language mode. * * @@ -22,7 +22,7 @@ main() syntax_token(SYNT_BRACKET, "([{", ")]}"); syntax_token(SYNT_DELIMITER, ",;.?:$"); syntax_token(SYNT_OPERATOR, "-+/&*=<>|!~^%"); - syntax_token(SYNT_KEYWORD, "A-Za-z0-9_"); + syntax_token(SYNT_KEYWORD, "a-zA-Z_", "0-9a-zA-Z_"); syntax_token(SYNT_NUMERIC, "-+.0-9_xa-fA-F"); // comments diff --git a/macsrc/modes/modes.cr b/macsrc/modes/modes.cr index 3a7ef45f..948f46bc 100644 --- a/macsrc/modes/modes.cr +++ b/macsrc/modes/modes.cr @@ -27,8 +27,8 @@ static list xlist = { // mode extension map */ "awk", ".awk.", "c", ".c.C.h.", - "cplusplus", ".cpp.cc.c++.cxx.hpp.h++.hxx.", "cmake", ".cmake.", + "cplusplus", ".cpp.cc.c++.cxx.hpp.h++.hxx.", "cr", ".cr.", "csharp", ".cs.", "dosbatch", ".bat.BAT.cmd.CMD.", @@ -40,6 +40,7 @@ static list xlist = { // mode extension map "masm", ".asm.", "perl", ".pl.pm.", "python", ".py.", + "rust", ".rs.", "sh", ".sh.csh.tcsh.zsh.bash.ash.rsh.", "slang", ".sl.", "txt", ".txt.", @@ -93,6 +94,10 @@ main(void) autoload("modes/protobuf", "_protobuf_mode"); + autoload("modes/python", "_python_mode"); + + autoload("modes/rust", "_rust_mode"); + autoload("modes/sh", "_sh_mode"); autoload("modes/slang", "_slang_mode"); diff --git a/macsrc/modes/perltest.txt b/macsrc/modes/perltest.txt deleted file mode 100644 index c7c02327..00000000 --- a/macsrc/modes/perltest.txt +++ /dev/null @@ -1,122 +0,0 @@ -# -*- mode: perl; -*- - -### - -if -eq ge gt le lt ne or -for -carp,else -croak,elsif,until,while -unless -foreach - -##### - - # Functions for SCALARs or strings - # -chomp, chop, chr, crypt, hex, index, lc, lcfirst, length, oct, ord, pack -q/STRING/, qq/STRING/, reverse, rindex, sprintf, substr, tr///, uc, ucfirst -y/// - -# Regular expressions and pattern matching -# -m//, pos, quotemeta, s///, split, study, qr// - - #.. Numeric functions - # -abs, atan2, cos, exp, hex, int, log, oct, rand, sin, sqrt, srand - - #.. Functions for real @ARRAYs - # -pop, push, shift, splice, unshift - - #.. Functions for list data - # -grep, join, map, qw/STRING/, reverse, sort, unpack - - #.. Functions for real %HASHes - # -delete, each, exists, keys, values - - #.. Input and output functions - # -binmode, close, closedir, dbmclose, dbmopen, die, eof, fileno, flock -format, getc, print, printf, read, readdir, rewinddir, seek, seekdir -select, syscall, sysread, sysseek, syswrite, tell, telldir, truncate -warn, write - - #.. Functions for fixed length data or records - # -pack, read, syscall, sysread, syswrite, unpack, vec - - # Functions for filehandles, files, or directories - # -chdir, chmod, chown, chroot, fcntl, glob, ioctl, link, lstat -mkdir, open, opendir, readlink, rename, rmdir, stat, symlink, sysopen -umask, unlink, utime - - #.. Keywords related to the control flow of your perl program - # -caller, continue, die, do, dump, eval, exit, goto, last, next, redo, return -sub, wantarray - - #.. Keywords related to scoping - # -caller, import, local, my, our, package, use - - #... Miscellaneous functions - # -defined, dump, eval, formline, local, my, our, reset, scalar, undef -wantarray - - #.. Functions for processes and process groups - # -alarm, exec, fork, getpgrp, getppid, getpriority, kill, pipe -qx/STRING/, setpgrp, setpriority, sleep, system, times, wait, waitpid - - #.. Keywords related to perl modules - # -do, import, no, package, require, use - - #.. Keywords related to classes and object-orientedness - # -bless, dbmclose, dbmopen, package, ref, tie, tied, untie, use - - #.. Low-level socket functions - # -accept, bind, connect, getpeername, getsockname, getsockopt, listen -recv, send, setsockopt, shutdown, socket, socketpair - - #.. System V interprocess communication functions - # -msgctl, msgget, msgrcv, msgsnd, semctl, semget, semop, shmctl, shmget -shmread, shmwrite - - #.. Fetching user and group info - # -endgrent, endhostent, endnetent, endpwent, getgrent, getgrgid, getgrnam -getlogin, getpwent, getpwnam, getpwuid, setgrent, setpwent - - #.. Fetching network info - # -endprotoent, endservent, gethostbyaddr, gethostbyname, gethostent -getnetbyaddr, getnetbyname, getnetent, getprotobyname, getprotobynumber -getprotoent, getservbyname, getservbyport, getservent, sethostent, setnetent -setprotoent, setservent - - #.. Time-related functions - # -gmtime, localtime, time, times - - -# Perl 5 functions -# - -lc,my,no,qw,qx -abs,chr,map,our,ref,sub -glob,tied -bless,chomp -exists,import -lcfirst,sysopen -formline,readline,readpipe -prototype diff --git a/macsrc/modes/rust.cr b/macsrc/modes/rust.cr new file mode 100644 index 00000000..6fc6f3a2 --- /dev/null +++ b/macsrc/modes/rust.cr @@ -0,0 +1,196 @@ +/* -*- mode: cr; indent-width: 4; -*- */ +/* $Id: rust.cr,v 1.1 2024/08/01 14:08:10 cvsuser Exp $ + * GRIEF/rust syntax definition mode. + * + * + */ + +#include "../grief.h" +#include "../mode.h" + +#define MODENAME "rust" + +void +main(void) +{ + /* + * Syntax lexer/ + * utilised during basic line pre-processing. + */ + create_syntax(MODENAME); + syntax_token(SYNT_COMMENT, "/*", "*/"); + syntax_token(SYNT_COMMENT, "//"); + //syntax_token(SYNT_CHARACTER, "\'"); + syntax_token(SYNT_STRING, "\""); + syntax_token(SYNT_QUOTE, "\\"); + syntax_token(SYNT_LINECONT, "\\"); + //syntax_token(SYNT_PREPROCESSOR, "#"); + syntax_token(SYNT_BRACKET, "([{<", ")]}>"); + syntax_token(SYNT_KEYWORD, "a-zA-Z_", "0-9a-zA-Z_"); + syntax_token(SYNT_WORD, "a-zA-Z_"); + + /* + * Options/ + * SYNF_COMMENTS_CSTYLE + * Ignore leading white-space on comments. + * + * SYNF_COMMENTS_QUOTE + * Allow quoting of comment terminator. + * + * SYNF_LINECONT_WS + * Continuation, allows trailing white-space. + */ + set_syntax_flags(SYNF_COMMENTS_CSTYLE|SYNF_COMMENTS_QUOTE|SYNF_LINECONT_WS); + + /* + * Syntax engine rules + */ + // comments (open, block, block-unmatched and eol) + syntax_rule("/\\*.*$", "spell,todo:comment"); + syntax_rule("/\\*.*\\*/", "spell,todo,quick:comment"); + syntax_rule("//.*$", "spell,todo:comment"); + + syntax_rule("\\*/", "quick:alert"); // unmatched block comment. + + // keywords and preprocessor directives + syntax_rule("[A-Za-z_][A-Za-z_0-9]*", "keyword,directive:normal"); + + // numeric constants + syntax_rule("[0-9]+(\\.[0-9]*)?([Ee][-+]?[0-9]*)?", "number"); + syntax_rule("0[xX][0-9A-Fa-f]+[LlUu]*", "number"); + + // strings + syntax_rule("\"(\\\\.|[^\\\"])*\"", "string"); + syntax_rule("\"(\\\\.|[^\\\\\"])*[^\\\\ \\\"\t\n]+", "string"); + + syntax_rule("r#\"(\\\\.|[^\\\"])*\"#", "string"); // raw-string + syntax_rule("br#\"(\\\\.|[^\\\"])*\"#", "string"); // raw-byte-string + syntax_rule("c\"(\\\\.|[^\\\"])*\"#", "string"); // c-string + syntax_rule("cr\"(\\\\.|[^\\\"])*\"#", "string"); // raw-c-string + + // characters + syntax_rule("\'[^\']\'", "character"); // character + syntax_rule("b\'[^\']\'", "character"); // byte + syntax_rule("\'\\\\[\\\']\'", "character"); // '\\', '\'' + syntax_rule("\'\\u{A-Za-z0-9]+}\'", "character"); // '\u{xxxx}' + + // delimiters/operators + syntax_rule("[()\\[\\]{},;.?:]", "delimiter"); + syntax_rule("[-%" + "+/&*=<>|!~^]+", "operator"); + + // macros + // +! + // $+ + + syntax_rule("\\\\[ \t]+$", "whitespace"); // trailing white-space after continuation + + // string elements + syntax_rule("\\\\x[A-Za-z0-9][A-Za-z0-9]", // hexadecimal escapes \xAA. + "group=string:operator"); + + syntax_rule("\\\\x[^A-Za-z0-9]", // illegal hexadecimal escapes \xXX. + "group=string:alert"); + syntax_rule("\\\\x[A-Za-z0-9][^A-Za-z0-9]", + "group=string:alert"); + + syntax_rule("\\\\u{A-Za-z0-9]+}", // unicode character escapes \u{XXXX} + "group=string:operator"); + + syntax_rule("\\\\u{[^A-Za-z0-9]+}?", // illegal unicode character escapes. + "group=string:alert"); + + syntax_rule("\\\\[0-7]+", // octal escapes. + "group=string:operator"); + + syntax_rule("\\\\[0-7]+", // binary escapes. + "group=string:operator"); + + syntax_rule("\\\\['\"?\\\\abefnrtv]", // character escapes (includes known extensions). + "group=string:operator"); + + syntax_rule("\\\\[^'\"?\\\\abefnrtvux0]", // illegal character escapes. + "group=string:alert"); + + syntax_rule("\\\\", // omitted character escapes. + "group=string:alert"); + + syntax_rule("{{", // escaped format. + "group=string,quick:operator"); + + syntax_rule("}}", // escaped format. + "group=string,quick:operator"); + + syntax_rule("{[^}]+}", // format + "group=string,quick:operator"); + + syntax_build(__COMPILETIME__); // build and auto-cache. + + /* + * Keywords + * + * "as,break,const,continue,crate,else,enum,extern,false,fn,for,if,impl,in,let,loop,match,mod,move,mut,pub,ref,return,self,Self,static,struct,super,trait,true,type,unsafe,use,where,while + * "async,await,dyn" + * + * "abstract,become,box,do,final,macro,override,priv,typeof,unsized,virtual,yield" + * "try" + */ + define_keywords(SYNK_PRIMARY, + "break,continue,crate,extern,for,impl,in,let,mod,pub,return,self,Self,super,trait,unsafe,use,where"); + define_keywords(SYNK_PRIMARY, + "async,await"); + + define_keywords(SYNK_PRIMARY, + "abstract,become,box,do,final,macro,override,priv,typeof,unsized,virtual,yield"); + define_keywords(SYNK_PRIMARY, + "try"); + + define_keywords(SYNK_STRUCTURE, + "struct,enum,union,static,dyn"); + define_keywords(SYNK_STORAGECLASS, + "fn,type"); + define_keywords(SYNK_STORAGECLASS, + "move,mut,ref,static,const"); + define_keywords(SYNK_CONDITIONAL, + "match,if,else"); + define_keywords(SYNK_REPEAT, + "loop,while"); + define_keywords(SYNK_OPERATOR, + "as"); + + define_keywords(SYNK_TYPE, + "bool,char,isize,usize"); + define_keywords(SYNK_TYPE, + "i8,i16,i32,i64,u8,u16,u32,u64,isize,usize,f32,f64"); + + define_keywords(SYNK_TYPE, + "str,String,Vec,Option,Result"); + + define_keywords(SYNK_BOOLEAN, + "false,true"); + define_keywords(SYNK_CONSTANT, + "Some,None,Ok,Err"); + + define_keywords(SYNK_TODO, + "XXX,TODO,FIXME,DEPRECATED,MAGIC,HACK,NB,NOTE,SAFETY"); +} + + +/* + * Modeline/package support + */ +string +_rust_mode(void) +{ + return "rs"; /* return package extension */ +} + + +string +_rust_highlight_first(void) +{ + attach_syntax(MODENAME); /* attach colorizer */ + return ""; +} + +/*end*/ + diff --git a/macsrc/mouse.cr b/macsrc/mouse.cr index 6bf01cd8..8d60cbad 100644 --- a/macsrc/mouse.cr +++ b/macsrc/mouse.cr @@ -1,28 +1,16 @@ /* -*- mode: cr; tabs: 4; -*- */ -/* $Id: mouse.cr,v 1.9 2024/05/15 08:22:44 cvsuser Exp $ - * Mouse driver macros - * - * This file contains code to support the mouse. - * - * Refer to the user guide for information on using the mouse. This code is - * experimental and subject to change but is designed to be more or less usable even if - * not fully functional. +/* $Id: mouse.cr,v 1.12 2024/09/08 16:25:51 cvsuser Exp $ + * Mouse support. * * */ #include "grief.h" -#define MOUSE_MIDDLE_IGNORE 0x0001 -#define MOUSE_WINDOWS_MOUSE_STYLE 0x0002 -#define MOUSE_RIGHT_COL_SELECT 0x0004 -#define MOUSE_PASTE_AT_CURSOR 0x0008 -#define MOUSE_DISABLE_TIME_PANEL 0x0010 -#define MOUSE_NO_COPY_CLIPBOARD 0x0020 -#define MOUSE_DISABLE_DND 0x0040 - -#define POINTY_MODE 0x01 -#define BORDER_MODE 0x02 +#define MODE_NONE 0x00 +#define MODE_DROP 0x01 // cursor dropped/move +#define MODE_DRAG 0x02 // drag mode +#define MODE_EDGE 0x10 // edge mode #ifndef EDGE_UP #define EDGE_UP 0 @@ -31,35 +19,10 @@ #define EDGE_LEFT 3 #endif -/* TRUE if within a selection popup - */ -extern int sel_warpable; - -/* Popup nesting level, 0 if non are active - */ -extern int popup_level; - - int mouse_style = 0; -static int mouse_mode = POINTY_MODE; -//static int mouse_object; +static int mouse_mode = MODE_NONE; -static int last_mx, last_my; -static int last_mwin; -static int last_line; +extern void popup_mouse(~ int x, ~ int y); // popup.cr -static int num_motion; -static int dragging; -static int num_clicks; - -/* This variable is essentially read-only. The variable is overloaded in select_buffer() - * for popups where the current line must always be hilighted. - */ -static void mouse_move_cursor(int down_button); -static int delete_window_borders(int type); -static void try_delete_edge(int e1, int e2, int e3, int e4); - -static void drag_start(void); -static void drag_release(int is_ctrl); void main(void) @@ -69,51 +32,34 @@ main(void) /* * mouse_button_enable --- - * This macro is called on startup and by popup macros to define - * the mouse key events. + * Mouse startup registration + * + * Mouse Element Action Purpose + * ------------------------------------------------------------------------------- + * Left mouse button Click Moves the cursor. + * + * Left mouse button Double-click Highlights a word. + * + * Left mouse button Drag Drops and drags the associated anchor. */ void mouse_button_enable(void) { - assign_to_key("", "::but1_down 1 1"); - assign_to_key("", "::but1_down 2 1"); - assign_to_key("", "::but1_down 0 1"); - assign_to_key("", "::but1_up 0"); - -// assign_to_key("", "::but1_s_down"); -// assign_to_key("", "::but1_s_motion"); -// assign_to_key("", "::but1_s_up"); - -// assign_to_key("", "::but1_down 1 2"); -// assign_to_key("", "::but1_down 0 2"); -// assign_to_key("", "::but1_down 1 3"); -// assign_to_key("", "::but1_down 0 3"); - - if (mouse_style & MOUSE_MIDDLE_IGNORE) { - /* - * Ignore - */ - - } else if (mouse_style & MOUSE_WINDOWS_MOUSE_STYLE) { - /* - * Windows style - */ -// assign_to_key("", "::but2_up"); -// assign_to_key("", "::but2_down"); -// assign_to_key("", "::but2_motion"); -// assign_to_key("", "::button_down 3"); - - } else { - /* - * Unix/Motif style - */ -// assign_to_key("", "::but1_up"); -// assign_to_key("", "::mouse_move_cursor 1"); -// assign_to_key("", "::mouse_move_cursor 0"); -// assign_to_key("", "::mouse_popup"); - } + assign_to_key("", "::button1_down 1 " + MK_NORMAL); + assign_to_key("", "::button1_down 2 " + MK_NORMAL); + assign_to_key("", "::button1_down 0 " + MK_NORMAL); + assign_to_key("", "::button1_up"); + assign_to_key("", "::button3_down 1"); + + assign_to_key("", "::button1_down 1 " + MK_COLUMN); + assign_to_key("", "::button1_down 2 " + MK_COLUMN); + assign_to_key("", "::button1_down 0 " + MK_COLUMN); + assign_to_key("", "::button1_up"); + + assign_to_key("", "::button1_down 1 " + MK_LINE); + assign_to_key("", "::button1_down 2 " + MK_LINE); + assign_to_key("", "::button1_down 0 " + MK_LINE); + assign_to_key("", "::button1_up"); } @@ -128,26 +74,20 @@ void mouse_disable(void) { assign_to_key("", "nothing"); + assign_to_key("", "nothing"); assign_to_key("", "nothing"); -// assign_to_key("", "nothing"); -// assign_to_key("", "nothing"); -// assign_to_key("", "nothing"); -// assign_to_key("", "nothing"); -// assign_to_key("", "nothing"); -// assign_to_key("", "nothing"); -// assign_to_key("", "nothing"); -// assign_to_key("", "nothing"); -// assign_to_key("", "nothing"); -// assign_to_key("", "nothing"); -// assign_to_key("", "nothing"); -// assign_to_key("", "nothing"); -// assign_to_key("", "nothing"); -// assign_to_key("", "nothing"); -// assign_to_key("", "nothing"); -// assign_to_key("", "nothing"); -// assign_to_key("", "nothing"); -// assign_to_key("", "nothing"); + assign_to_key("", "nothing"); + + assign_to_key("", "nothing"); + assign_to_key("", "nothing"); + assign_to_key("", "nothing"); + assign_to_key("", "nothing"); + + assign_to_key("", "nothing"); + assign_to_key("", "nothing"); + assign_to_key("", "nothing"); + assign_to_key("", "nothing"); } @@ -157,177 +97,106 @@ mouse_disable(void) * Handle the left hand button being pressed. * * If pressed in conjunction with the Ctrl or Alt key, then do a column hilight. + * + * Parameters: + * click - Active click count, otherwise 0 for up. + * + * Returns: + * void */ static void -but1_down(int down_button, int anchor_type) +button1_down(int clicks, int anchor_type) { - int tm, x, y, win, buf, line, col, where, region, event; - - tm = get_mouse_pos(x, y, win, line, col, where, region, event); - - /* - * Count clicks - */ - if (1 == down_button) { - if (tm < 0 || tm > CLICK_TIME_MS) { - num_clicks = 1; /* click window expired */ - } else { - ++num_clicks; - } - - } else if (2 == down_button) { - ++num_clicks; /* double click */ + extern int popup_level; // grief.cr + int x, y, win, buf, line, col, where, region, event; - } - - /* - * If a popup is active, - * validate if the click is within the current bounders otherwise exit. - */ + // modal popup active; ignore. + get_mouse_pos(x, y, win, line, col, where, region, event); if (popup_level && (win != inq_window())) { return; } + // within a window, make active. if (win >= 0) { - /* - * Within a window, make active - */ inq_top_left(NULL, NULL, win, NULL, NULL, buf); - if (buf <= 0) + if (buf <= 0) { return; + } set_buffer(buf); set_window(win); } - /* Process event */ -// if (mouse_mode == BORDER_MODE) { /* border gran in progress */ -// where = mouse_object; -// } - + // region operations switch (where) { case MOBJ_INSIDE: - /* - * Are we starting a drag? - */ - if (down_button) { - if (region == 2 && !sel_warpable && num_clicks == 1) { - drag_start(); - } - } - /* - * Let cursor follow the mouse so we can see where to drop. - */ - if (dragging) { - if (inq_marked() == MK_LINE) { - col = 1; - } - move_abs(line, col); - return; - } + // inside window + switch (clicks) { + case 0: // motion + // active region, motion + if (mouse_mode == MODE_DROP) { // initial move + if (0 == region) { + drop_anchor(anchor_type); + } else { + end_anchor(); + } + mouse_mode = MODE_DRAG; + } - /* - * If user hits the mouse button and we have a region hilighted, - * and cursor is inside the region then do a drag - * operation; otherwise, unhilight it. - */ - if (down_button && inq_marked()) { - raise_anchor(); - - /* - * See if user is dragging the mouse button. If we've just started - * dragging it, then drop an anchor. - */ - } else if (! down_button && ! inq_marked()) { - drop_anchor(anchor_type); - } + if (mouse_mode == MODE_DRAG) { + if (inq_marked() == MK_LINE) { + col = 1; // column mode, col=1 + } + move_abs(line, col); + end_anchor(line, col); + return; + } + break; - /* - * Inside a selection box - */ - if (sel_warpable) { - move_abs(line, col); /* move selection */ - sel_warp(); - if (line == last_line && num_clicks == 2) { - push_back(key_to_int("")); - break; /* double-clicks */ + case 1: // click + // initial click, enable drag mode + if (mouse_mode != MODE_EDGE) { + if (region) { + raise_anchor(); + } + move_abs(line, col); + mouse_mode = MODE_DROP; } - last_line = line; - return; - } + break; - /* - * Handle multiple clicks here. - */ - switch (num_clicks) { - case 2: + case 2: // double-click + // select word + if (inq_marked()) { + raise_anchor(); + } next_char(); re_search(SF_UNIX | SF_BACKWARDS, "\\<"); - if (! inq_marked()) - drop_anchor(MK_NONINC); + drop_anchor(MK_NONINC); re_search(SF_UNIX, "\\>"); break; - case 3: - if (! inq_marked()) - drop_anchor(MK_LINE); - break; - case 4: -// if (inq_marked()) -// raise_anchor(); -// select_all(); /* TODO */ - break; - } - break; - - case MOBJ_TITLE: - if (down_button) { - if (popup_level == 0) { - edit_next_buffer(); /* next buffer */ - } else { - push_back(key_to_int("")); /* exit popup */ - } } break; case MOBJ_LEFT_EDGE: case MOBJ_RIGHT_EDGE: - /* - * Split a window, creating a new window boundary where the mouse is. - * - * Its too easy to split a window when you didnt mean to. So - * user has to double click to do this. - */ - if (popup_level == 0 && num_clicks >= 2) { - int ml, wy, i, j; - - ml = inq_msg_level(); /* quiet now */ - set_msg_level(3); - - if (down_button) { - /* - * Attempt to create a new edge - */ - create_edge(EDGE_DOWN); - inq_window_info(NULL, NULL, NULL, NULL, NULL, wy); + // window edge. + if (popup_level == 0 && clicks >= 2) { + int wy, ml = inq_msg_level(); - j = y - wy + 1; - i = move_edge(EDGE_UP, j); - if (j < 0) - j = -j; - if (i != j) { /* too close - undo */ - change_window(EDGE_UP); - delete_edge(EDGE_DOWN); - } else { - mouse_mode = BORDER_MODE; -// mouse_object = where; + set_msg_level(3); + switch (mouse_mode) { + case MODE_NONE: + // attempt to create a new edge. + if (create_edge(EDGE_DOWN) <= 0) { + mouse_mode = MODE_EDGE; } + break; - } else if (mouse_mode == BORDER_MODE) { - /* - * Drop the edge - */ + case MODE_EDGE: + // move edge. inq_window_info(NULL, NULL, NULL, NULL, NULL, wy); move_edge(EDGE_UP, y - wy + 1); + break; } set_msg_level(ml); } @@ -335,461 +204,68 @@ but1_down(int down_button, int anchor_type) case MOBJ_TOP_EDGE: case MOBJ_BOTTOM_EDGE: - /* - * Split a window, creating a new window boundary where the mouse is. - * - * Its too easy to split a window when you didnt mean to. So - * user has to double click to do this. - */ - if (popup_level == 0 && num_clicks >= 2) { - int ml, wx, i, j; - - ml = inq_msg_level(); /* quiet now */ - set_msg_level(3); + // window edge. + if (popup_level == 0 && clicks >= 2) { + int wx, ml = inq_msg_level(); - if (down_button) { - /* - * Attempt to create a new edge - */ - create_edge(EDGE_LEFT); - inq_window_info(NULL, NULL, NULL, NULL, wx); - j = x - wx - 1; - i = move_edge(EDGE_RIGHT, j); - if (i != j) { /* too close - undo */ - change_window(EDGE_RIGHT); - delete_edge(EDGE_LEFT); - } else { - mouse_mode = BORDER_MODE; -// mouse_object = where; + set_msg_level(3); + switch (mouse_mode) { + case MODE_NONE: + // attempt to create a new edge. + if (create_edge(EDGE_LEFT) <= 0) { + mouse_mode = MODE_EDGE; } + break; - } else if (mouse_mode == BORDER_MODE) { - /* - * Drop the edge - */ - inq_window_info(NULL, NULL, NULL, NULL, wx); + case MODE_EDGE: + // move edge. + inq_window_info(NULL, NULL, NULL, NULL, wx, NULL); if (move_edge(EDGE_RIGHT, x - wx - 1) <= 0) { inq_window_info(NULL, NULL, wx); move_edge(EDGE_LEFT, x - wx); } + break; } set_msg_level(ml); } break; } - last_line = -1; } -/* - * but1_up --- - * Handle the left hand button being release. - */ static void -but1_up(int is_ctrl) +button3_down(int clicks) { - /* - * Restore mouse mode so that normal pointy type things can occur. - */ - mouse_mode = POINTY_MODE; - - /* - * Handle where we are going to drag text to. - */ - if (! inq_marked()) { - /* - * If in column select mode then do the context popup. - */ - dragging = FALSE; -// if (is_ctrl) { -// popup(); -// } - return; - } - - if (dragging) { - drag_release(is_ctrl); - return; - } -} - - -/* - * but1_s_down --- - * Handle the left hand button being pressed in conjunction with - * the Shift key. - */ -static void -but1_s_down(void) -{ - int x, y, win, buf, line, col, where; - - get_mouse_pos(x, y, win, line, col, where); - - last_mx = x; - last_my = y; - last_mwin = win; - - num_motion = 0; - if (win >= 0) { - inq_top_left(NULL, NULL, win, NULL, NULL, buf); - set_window(win); - set_buffer(buf); - move_abs(line, col); - if (inq_marked()) { - num_motion = -1; - } else { - drop_anchor(MK_NORMAL); - } - } - last_line = -1; -} - - -/* - * but1_s_down --- - * Handle mouse movements with the left hand button being pressed - * in conjunction with the Shift key. - */ -static void -but1_s_motion(void) -{ - int x, y, win, buf, line, col, where; + extern int popup_level; // grief.cr + int x, y, win, line, col, where; + // modal popup active; ignore. get_mouse_pos(x, y, win, line, col, where); - - if (num_motion >= 0) { - ++num_motion; - } - - if (win == last_mwin && win >= 0) { - /* - * Same window, reposition cursor - */ - inq_top_left(NULL, NULL, win, NULL, NULL, buf); - set_window(win); - set_buffer(buf); - move_abs(line, col); - - } else { - /* - * Mouse no longer in same window so we calculate what to do - * ourselves. Simply go up or down a line. - */ - if (y > last_my) { - down(); - } else if (y < last_my) { - up(); - } - } - last_mx = x; - last_my = y; - last_line = -1; -} - - -/* - * but1_s_up --- - * Handle the left hand button being released in conjunction with - * the Shift key. - */ -static void -but1_s_up(void) -{ - if (0 == num_motion) { - raise_anchor(); - } - mouse_mode = POINTY_MODE; -} - - -static void -but2_down(void) -{ - if (0 == (mouse_style & MOUSE_MIDDLE_IGNORE)) { - mouse_move_cursor(1); - } -} - - -static void -but2_motion(void) -{ - if (0 == (mouse_style & MOUSE_MIDDLE_IGNORE)) { - mouse_move_cursor(0); - } -} - - -static void -but2_up(void) -{ - if (0 == (mouse_style & MOUSE_MIDDLE_IGNORE)) { - but1_up(0); - } -} - - -/* - * mouse_move_cursor --- - * Function called when user hits the middle (2nd) mouse button. Just - * move cursor keeping hilight if any. - */ -static void -mouse_move_cursor(int down_button) -{ - int x, y, win, buf, line, col, where; - - /* - * If in border grab mode then keep dragging the border. - */ - if (mouse_mode == BORDER_MODE) { - but1_down(down_button, 1); + if (popup_level && (win != inq_window())) { return; } - get_mouse_pos(x, y, win, line, col, where); - - if (popup_level && win != inq_window()) { - return; /* within popup ? */ - } - - if (win >= 0) { /* new window */ - inq_top_left(NULL, NULL, win, NULL, NULL, buf); - set_window(win); - set_buffer(buf); - } - + // region operations switch (where) { case MOBJ_INSIDE: - /* - * If no region hilighted then hilight it. - */ - if (inq_marked() == 0) { - drop_anchor(MK_NORMAL); - } - move_abs(line, col); - if (sel_warpable) { - sel_warp(); - } - break; - - case MOBJ_LEFT_EDGE: - case MOBJ_RIGHT_EDGE: - case MOBJ_TOP_EDGE: - case MOBJ_BOTTOM_EDGE: - delete_window_borders(where); - break; - } - last_line = -1; -} - - -static void -drag_start(void) -{ - int sline, scol, eline, ecol; - - dragging = TRUE; - switch (inq_marked(sline, scol, eline, ecol)) { - case MK_COLUMN: - case MK_NORMAL: - case MK_LINE: - inq_position(current_line, current_col); - if (current_line == sline && current_col == scol) { - end_anchor(sline, scol); - } else { - end_anchor(eline, ecol); - } - break; - default: - end_anchor(eline, ecol + 1); - break; - } -} - - -/* - * drag_release --- - * We started dragging some text so handle the button being released. - */ -static void -drag_release(int is_ctrl) -{ - int x, y, win, line, col, where; - int type, sline, scol, eline, ecol; - - type = inq_marked(sline, scol, eline, ecol); - get_mouse_pos(x, y, win, line, col, where); - - /* If in line mode, make sure we paste at the start of the line. */ - if (type == MK_LINE) - col = 1; - - if (where == MOBJ_INSIDE) { - int i, i0; - - i0 = i = inside_region(NULL, line, col); /*???*/ - if (type == MK_COLUMN && i == 3) - i = 5; - - switch (i) { - case 0: - /***********************************************/ - /* No region. */ - /***********************************************/ + // inside window + switch (clicks) { + case 1: // click + popup_mouse(x - 1, y - 1); break; - - case 1: - /***********************************************/ - /* Before the region. Need to delete and */ - /* then paste. */ - /***********************************************/ - if (is_ctrl) - copy(); - else - cut(); - - set_window(win); - set_buffer(inq_window_buf()); - move_abs(line, col); - - paste(); - break; - - case 2: - /***********************************************/ - /* Inside the region - ignore the drop. */ - /***********************************************/ - if (num_clicks == 1) - raise_anchor(); - break; - - case 3: - /***********************************************/ - /* After the region. The following code */ - /* attempts handle the fact that we are */ - /* trying to move a block of code possible */ - /* earlier on in the same line, and keeping */ - /* the final cursor position where we */ - /* expect it to be. */ - /***********************************************/ - if (is_ctrl) { - copy(); - set_window(win); - set_buffer(inq_window_buf()); - move_abs(line, col); - paste(); - break; - } - - {string s = get_region(); - int mtype = inq_marked(); - - if (mtype == MK_NONINC) - end_anchor(eline, ecol + 1); - else - end_anchor(eline, ecol); - - set_window(win); - set_buffer(inq_window_buf()); - move_abs(line, col); - if (inq_marked() != MK_LINE) - insert("\n"); - drop_bookmark(1000, "y"); - insert(s); - delete_block(); - goto_bookmark(1000); - delete_bookmark(1000); - if (mtype != MK_LINE) { - backspace(); - next_char(strlen(s)); - } - } - break; - case 4: - /***********************************************/ - /* Pasting to the left. */ - /***********************************************/ - if (is_ctrl) - copy(); - else - cut(); - set_window(win); - set_buffer(inq_window_buf()); - move_abs(line, col); - paste(); - break; - - case 5: - /***********************************************/ - /* Pasting to the right. */ - /***********************************************/ - if (is_ctrl) - copy(); - else - cut(); - set_window(win); - set_buffer(inq_window_buf()); - if (i0 == 3) - move_abs(line, col - (ecol - scol) - 1); - else - move_abs(line, col); -// do_paste(2); - break; - } - } - - dragging = FALSE; -} - - -/* - * delete_window_borders --- - * Routine to delete a window border depending on where we clicked. - */ -static int -delete_window_borders(int where) -{ - int msg_level; - - msg_level = inq_msg_level(); - set_msg_level(3); - - switch (where) { - case MOBJ_LEFT_EDGE: - case MOBJ_RIGHT_EDGE: - if (! popup_level) - try_delete_edge(EDGE_UP, EDGE_DOWN, EDGE_LEFT, EDGE_RIGHT); - set_msg_level(msg_level); - return 1; - - case MOBJ_TOP_EDGE: - case MOBJ_BOTTOM_EDGE: - if (! popup_level) - try_delete_edge(EDGE_LEFT, EDGE_RIGHT, EDGE_UP, EDGE_DOWN); - set_msg_level(msg_level); - return 1; + } } - - set_msg_level(msg_level); - return 0; } /* - * try_delete_edge --- - * Try and delete an edge. Because we may be at an intersection - * determining the 'correct' edge may be tricky so try in all - * directions based on a preference scale. + * button1_up --- + * Button1 up event handler */ static void -try_delete_edge(int e1, int e2, int e3, int e4) +button1_up() { - if (delete_edge(e1)) - if (delete_edge(e2)) - if (delete_edge(e3)) - delete_edge(e4); + mouse_mode = MODE_NONE; } /*end*/ diff --git a/macsrc/nc.cr b/macsrc/nc.cr index b9a0da26..34d791d1 100644 --- a/macsrc/nc.cr +++ b/macsrc/nc.cr @@ -1,8 +1,8 @@ /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: nc.cr,v 1.35 2021/07/11 08:26:12 cvsuser Exp $ - * Norton Commander (NC) style directory services - * +/* $Id: nc.cr,v 1.38 2024/09/26 12:15:32 cvsuser Exp $ + * Norton Commander (NC)/Midnight Commander style directory services * + * TODO: retain marked/position post command. */ #include "grief.h" @@ -21,11 +21,10 @@ #define BACKWARD_SLASH '\\' #define WILD "?*" #define SMINCOLUMNS 62 /* screen width */ -#define SMAXCOLUMNS 90 +#define SMAXCOLUMNS 142 #define SFILECOLUMNS (nc_fwidth) #define SINFOCOLUMNS 38 #define TYPEPOS(__base) (__base + 1) -#define NAMEPOS(__base) (__base + 2) #if defined(MSDOS) #define MARKER "\xfe" @@ -53,43 +52,47 @@ /* Functions */ #if defined(__PROTOTYPES__) -void mc(void); -void nc(void); +int mc(~ string); +int nc(~ string); static void NcSize(void); -static int NcPosition(int line); -static void NcPrompt(void); +static string NcParts(string line, int &type, int &size, int &mtime); static void NcCd(~ string); -static void NcDirectory(string cwd); -static int sort_versions(int i1, string s1, int l2, string s2); -static void NcSelMsg(void); -static void NcSelSpace(void); -static void NcSelBack(void); -static void NcSel(string); -static int NcSelFind(string fname, int dir); -static int NcSelSearch(int next, string pattern); +static void NcRead(string cwd); +static void NcMessage(void); +static void NcSpace(void); +static void NcBack(void); +static void NcMatch(string); +static int NcNext(string fname, int dir); +static int NcSearch(int next, string pattern); + +static void NcRename(void); static void NcMkdir(void); static void NcChdir(void); -static void NcUpdir(void); -static void NcTree(void); static void NcDelete(void); -static void NcRemove(void); -static void NcEdit(void); -static void NcExit(void); +static void NcUpdir(void); +static void NcEscape(void); +static void NcAction(void); + static int NcPosition(int line); +static void NcDiagnostics(void); static void NcPrompt(void); + static void NcHome(void); static void NcUp(void); static void NcDown(void); static void NcEnd(void); static void NcPgup(void); static void NcPgdn(void); -static int NcMark(void); -static void NcMarkSet(void); -static void NcMarkClr(void); -static void NcMarkInv(void); -static void NcMarkMultiple(int); -#endif /*__PROTOTYPES__*/ + +static int NcToggle(void); +static void NcSelect(void); +static void NcUnselect(void); +static void NcInverse(void); +static void NcMultiple(int); + +static void NcSort(~ string); +#endif /*__PROTOTYPES__*/ static string ncsortorder = "Name"; static int nckeymap; /* keyboard map */ @@ -98,9 +101,9 @@ static int ncrows, nccols; /* screen rows/cols */ static int ncwidth, ncfwidth; static int nclineno; /* current line count */ -static string nclinebuf; /* line buffer */ -static string ncfilebuf; /* file buffer */ -static string ncselpattern; /* selection pattern */ +static int ncactiveno; /* selected count */ +static string ncexitname; /* file buffer */ +static string ncpattern; /* selection pattern */ static list ncdirlist = { /* Mkdir/Chdir */ "Name: ", "" @@ -115,9 +118,9 @@ static list ncsortlist = { /* Sort order */ }; + /* - * main --- - * Run-time initialisation. + * Run-time initialisation. */ void main() @@ -138,9 +141,8 @@ main() keyboard_typeables(); /* keys 0...127 */ assign_to_key("", "::NcEnter"); - assign_to_key("", "::NcSelBack"); - assign_to_key("", "::NcSelSpace"); - /* assign_to_key("", "::NcSelEsc"); -- exit. */ + assign_to_key("", "::NcBack"); + assign_to_key("", "::NcSpace"); assign_to_key("", "::NcHome"); assign_to_key("", "::NcEnd"); assign_to_key("", "::NcUp"); @@ -156,30 +158,30 @@ main() /* assign_to_key("", "::NcView"); -- Viewer. */ assign_to_key("", "::NcEdit"); /* assign_to_key("", "::NcCopy"); -- Copy. */ - /* assign_to_key("", "::NcRename"); -- Rename/move. */ + assign_to_key("", "::NcRename"); assign_to_key("", "::NcMkdir"); assign_to_key("", "::NcDelete"); - assign_to_key("", "::NcSort"); /* Sort order. */ - assign_to_key("", "::NcExit"); - assign_to_key("", "::NcExit"); - assign_to_key("", "::NcChdir"); /* Change directory. */ - assign_to_key("", "::NcCd"); /* Reread. */ + assign_to_key("", "::NcDelete"); + assign_to_key("", "::NcSort"); + assign_to_key("", "::NcAction"); + assign_to_key("", "::NcEscape"); + assign_to_key("", "::NcChdir"); + assign_to_key("", "::NcCd"); assign_to_key("", "::NcUpdir"); - assign_to_key("", "::NcSort F"); /* Filename. */ - assign_to_key("", "::NcSort E"); /* Extension. */ - assign_to_key("", "::NcSort T"); /* Time. */ - assign_to_key("", "::NcSort S"); /* Size. */ - assign_to_key("", "::NcSort U"); /* Unsorted. */ + assign_to_key("", "::NcSort Name"); + assign_to_key("", "::NcSort Extension"); + assign_to_key("", "::NcSort Time"); + assign_to_key("", "::NcSort Size"); + assign_to_key("", "::NcSort Unsorted"); #if defined(MSDOS) - assign_to_key("", "::NcDrive"); /* DOS special. */ + assign_to_key("", "::NcDrive"); #endif - assign_to_key("", "ff"); + assign_to_key("", "ff"); assign_to_key("", "::NcTree"); - assign_to_key("", "::NcDelete"); - assign_to_key("", "::NcMark"); - assign_to_key("", "::NcMarkClr"); - assign_to_key("", "::NcMarkSet"); - assign_to_key("", "::NcMarkInv"); + assign_to_key("", "::NcToggle"); + assign_to_key("", "::NcSelect"); + assign_to_key("", "::NcUnselect"); + assign_to_key("", "::NcInverse"); nckeymap = inq_keyboard(); keyboard_pop(1); /* save keyboard */ @@ -187,32 +189,16 @@ main() } -static void -NcSize(void) -{ - inq_screen_size(ncrows, nccols); - if (nccols > SMINCOLUMNS + 2) { - if ((ncwidth = nccols - 6) > SMAXCOLUMNS) { - ncwidth = SMAXCOLUMNS; - } - } else { - ncwidth = SMINCOLUMNS; /* center window */ - } - ncfwidth = ncwidth - SINFOCOLUMNS; - nccols -= (ncwidth + 2); /* center window */ - nccols /= 2; - ncrows -= 10; /* rows-10 screen size */ -} - - /* * mc --- * Directory services (NC/Midnight commander style). */ -void -mc(void) +int +mc(~ string) { - nc(); + string dir; + get_parm(0, dir); + nc(dir); } @@ -220,34 +206,36 @@ mc(void) * nc --- * Directory services (NC/Midnight commander style). */ -void -nc(void) +int +nc(~ string) { - string cwd; /* saved directory */ + string dir, cwd; /* saved directory */ int old_buffer, old_window; + int new_buffer = -1; int dir_buffer; - int base; /* Initialise directory */ old_buffer = inq_buffer(); old_window = inq_window(); - dir_buffer = create_buffer("NC", NULL, 1); - if (dir_buffer == -1) { - return; /* template missing */ + if ((dir_buffer = create_buffer("nc", NULL, 1)) < 0) { + return -1; } - NcSize(); getwd(NULL, cwd); /* current working dir */ + if (! get_parm(0, dir) || 0 == strlen(dir) || dir == ".") + dir = cwd; + + NcSize(); set_buffer(dir_buffer); attach_syntax(SYNTAX); set_buffer_type(NULL, BFTYP_UTF8); - NcDirectory(cwd); + NcRead(dir); create_window(nccols, ncrows + 4, nccols + ncwidth, 3, - " Help, to select, to exit"); + " Help, select, action/exit"); attach_buffer(dir_buffer); NcPosition(1); - ncselpattern = ""; + ncpattern = ""; /* User process */ keyboard_push(nckeymap); @@ -258,27 +246,33 @@ nc(void) delete_window(); /* Load selected files */ - if (strlen(ncfilebuf)) { /* F10 or Esc ? */ - if (ncfilebuf == MARKER) { + if (strlen(ncexitname)) { /* exit condition */ + if (ncexitname == MARKER) { /* Load all marked files */ + string name; + int type, size, mtime; + top_of_buffer(); while (search_fwd("<\\c" + MARKER)) { - nclinebuf = read(); - base = index(nclinebuf, '\t'); /* delimiter */ - ncfilebuf = "./" + trim(substr(nclinebuf, NAMEPOS(base))); + name = NcParts(read(), type, size, mtime); + ncexitname = "./" + name; down(); - message("Loading \"%s\" for editing...", ncfilebuf); - if (edit_file(ncfilebuf) > 0) { - old_buffer = inq_buffer(); + message("Loading \"%s\" for editing...", ncexitname); + if (edit_file(ncexitname) > 0) { + if (new_buffer == -1) { /* first */ + new_buffer = inq_buffer(); + } } set_buffer(dir_buffer); /* for next search */ } } else { /* Load specified file */ - message("Loading \"%s\" for editing...", ncfilebuf); - if (edit_file(ncfilebuf) > 0) { - old_buffer = inq_buffer(); + message("Loading \"%s\" for editing...", ncexitname); + if (edit_file(ncexitname) > 0) { + if (new_buffer == -1) { + new_buffer = inq_buffer(); + } } } display_file_name(); @@ -287,10 +281,41 @@ nc(void) cd(cwd); /* restore cwd */ delete_buffer(dir_buffer); - - set_buffer(old_buffer); + if (new_buffer == -1) + new_buffer = old_buffer; + set_buffer(new_buffer); set_window(old_window); - attach_buffer(old_buffer); + attach_buffer(new_buffer); + return (new_buffer == -1 ? 0 : 1); +} + + +static void +NcSize(void) +{ + inq_screen_size(ncrows, nccols); + if (nccols > SMINCOLUMNS + 2) { + ncwidth = (nccols / 3) * 2; /* 2/3 width */ + if (ncwidth >SMAXCOLUMNS) { + ncwidth = SMAXCOLUMNS; + } + } else { + ncwidth = SMINCOLUMNS; /* center window */ + } + + ncfwidth = ncwidth - SINFOCOLUMNS; + nccols -= (ncwidth + 2); /* center window */ + nccols /= 2; + ncrows -= 10; /* rows-10 screen size */ +} + + +static string +NcParts(string line, int &type, int &size, int &mtime) +{ + string name; + sscanf(substr(line, index(line, '\t') + 1), "%c|%[^/]/%d/%d", type, name, size, mtime); + return trim(name); } @@ -306,10 +331,10 @@ NcBadkey() left(); c = read(1); delete_char(); - if (c == "/") { + if (c == "/" || c == "\\") { NcCd("/"); } else { - NcSel(lower(c)); + NcMatch(lower(c)); } return ""; } @@ -338,103 +363,88 @@ NcForeach(string funcname) /* - * NcSelMsg --- - * Display the current selected file name, APY 06/12/90 + * NcMessage --- + * Display the current selected file name. */ static void -NcSelMsg(void) +NcMessage(void) { - message("File: %s", ncselpattern); + message("File: %s", ncpattern); } /* - * NcSelSpace --- - * called whenever the user presses a key. Finds the next file name match - * ensuring the user does not go past the end of the buffer. + * NcSpace --- + * Called whenever the user presses a key. + * Finds the next file name match ensuring the user does not go past the end of the buffer. */ static void -NcSelSpace(void) +NcSpace(void) { - if (ncselpattern == "") { - if (NcMark() != 0) { + if (ncpattern == "") { + if (NcToggle() != 0) { NcDown(); } } else { - if (NcSelFind(ncselpattern, SEL_NEXT) == -1) { - NcSelFind(ncselpattern, SEL_TOP); + if (NcNext(ncpattern, SEL_NEXT) == -1) { + NcNext(ncpattern, SEL_TOP); } } } /* - * NcSelBack --- - * called whenever the user presses a key. Removes the last key from the - * buf search fname. + * NcBack --- + * Called whenever the user presses a key. + * Removes the last key from the buffer search filename. */ static void -NcSelBack(void) +NcBack(void) { int len; - if ((len = strlen(ncselpattern)) > 0) { - ncselpattern = substr(ncselpattern, 1, len - 1); - if (strlen(ncselpattern) == 0) { + if ((len = strlen(ncpattern)) > 0) { + ncpattern = substr(ncpattern, 1, len - 1); + if (strlen(ncpattern) == 0) { NcPosition(1); } else { - if (NcSelFind(ncselpattern, SEL_TOP) == -1) { + if (NcNext(ncpattern, SEL_TOP) == -1) { beep(); } } - NcSelMsg(); + NcMessage(); } } /* - * NcSelEsc --- - * called whenever the user presses a (key. Clears the search file-name - * - static void - NcSelEsc(void) - { - if (ncselpattern != "") { - ncselpattern = ""; - NcSelMsg(); - } - } - */ - - -/* - * NcSel --- + * NcMatch --- * Select engine. */ static void -NcSel(string new_key) +NcMatch(string new_key) { string new_pattern; - new_pattern = ncselpattern; + new_pattern = ncpattern; new_pattern += new_key; - if (strlen(new_pattern) == 1 || NcSelFind(new_pattern, SEL_NEXT) == -1) { - if (NcSelFind(new_pattern, SEL_TOP) == -1) { + if (strlen(new_pattern) == 1 || NcNext(new_pattern, SEL_NEXT) == -1) { + if (NcNext(new_pattern, SEL_TOP) == -1) { beep(); return; } } - ncselpattern = new_pattern; - NcSelMsg(); + ncpattern = new_pattern; + NcMessage(); } /* - * NcSelFind --- + * NcNext --- * Finds the next matching file name. */ static int -NcSelFind(string fname, int dir) +NcNext(string fname, int dir) { save_position(); /* Save the current position. */ @@ -450,7 +460,7 @@ NcSelFind(string fname, int dir) break; } - if (NcSelSearch(dir, "<" + MARKER + "| "+fname) <= 0) { + if (NcSearch(dir, "<" + MARKER + "| "+fname) <= 0) { /* not found, restore position */ restore_position(); return -1; @@ -461,12 +471,12 @@ NcSelFind(string fname, int dir) /* - * NcSelSearch --- + * NcSearch --- * Searches forward and back depending on first parameter if that parameter is not * zero it searches forward else back. */ static int -NcSelSearch(int next, string pattern) +NcSearch(int next, string pattern) { return (next ? search_fwd(pattern, 1, 0, 0) : search_back(pattern, 1, 0, 0)); } @@ -475,7 +485,7 @@ NcSelSearch(int next, string pattern) #if defined(MSDOS) /* * NcDrive --- - * called whenever the user presses the key, "change current working drive". + * Change-drive */ static void NcDrive(void) @@ -503,9 +513,35 @@ NcDrive(void) #endif /*MSDOS*/ +/* + * NcRename --- + * Rename directory/file command + */ +static void +NcRename(void) +{ + string name; + int type, size, mtime; + list result; + + name = NcParts(read(), type, size, mtime); + result[0] = name; + result = field_list("Rename", result, ncdirlist, TRUE); + if (result[0] == "") { + NcPrompt(); + } else { + message("Renaming \"%s\" to \"%s\"...", name, result[0]); + if (rename(name, result[0]) == -1) { + error("Unable to rename \"%s\" : %d (%s)", name, errno, strerror(errno)); + } else { + NcCd(); + } + } +} + /* * NcMkdir --- - * called whenever the user presses the key, "make directory". + * Make directory command. */ static void NcMkdir(void) @@ -529,7 +565,7 @@ NcMkdir(void) /* * NcChdir --- - * called whenever the user presses the key, "change directory". + * Change-directory command. */ static void NcChdir(void) @@ -548,7 +584,7 @@ NcChdir(void) /* * NcUpdir --- - * Process "up directory" key request + * Process "up directory" key request. */ static void NcUpdir(void) @@ -566,7 +602,7 @@ NcUpdir(void) /* * NcTree --- - * called whenever the user presses the key, "directory tree". + * Directory tree command. */ static void NcTree(void) @@ -586,20 +622,20 @@ NcTree(void) /* * NcDelete --- - * called whenever the user presses the or key, "delete". + * Delete file/directory command. */ static void NcDelete(void) { - string answer; - int line, base; + string linebuf, name, answer; + int line, type, size, mtime; inq_position(line); raise_anchor(); top_of_buffer(); if (search_fwd("<\\c" + MARKER)) { answer = "?"; - while (upper(answer) != "Y" && upper (answer) != "N") { + while (answer != "Y" && answer != "N") { if (answer != "?") { beep(); } @@ -609,37 +645,32 @@ NcDelete(void) answer = "N"; } else if (answer == "?") { beep(); + } else { + answer = upper(answer); } } - if (upper(answer) == "Y") { + if (answer == "Y") { top_of_buffer(); while (search_fwd("<\\c" + MARKER)) { - nclinebuf = read(); beginning_of_line(); + linebuf = read(); down(); - base = index(nclinebuf, '\t'); /* delimiter */ - - if (substr(nclinebuf, TYPEPOS(base), 1) == "D") { - /* directory */ - ncfilebuf = trim(substr(nclinebuf, NAMEPOS(base))); - if (ncfilebuf != "..") { - error("%s", nclinebuf); - message("Deleting Directory \"%s\"...", ncfilebuf); - if (-1 == rmdir(ncfilebuf)) { - error("Unable to rmdir \"%s\" : %d (%s)", - ncfilebuf, errno, strerror(errno)); + name = NcParts(linebuf, type, size, mtime); + if (type == 'D') { /* directory */ + if (name != "..") { + message("Deleting Directory \"%s\"...", name); + if (rmdir(name) == -1) { + error("Unable to rmdir \"%s\" : %d (%s)", name, errno, strerror(errno)); } } - } else if (substr(nclinebuf, TYPEPOS(base), 1) == "F") { - /* file */ - ncfilebuf = "./" + trim(substr(nclinebuf, NAMEPOS(base))); - message("Deleting \"%s\"...", ncfilebuf); - if (remove(ncfilebuf) == -1) { - error("Unable to delete \"%s\" : %d (%s) - Press any key", - ncfilebuf, errno, strerror(errno)); + } else if (type == 'F') { /* file */ + name = "./" + name; + message("Deleting \"%s\"...", name); + if (remove(name) == -1) { + error("Unable to delete \"%s\" : %d (%s) - Press any key", name, errno, strerror(errno)); beep(); while (!inq_kbd_char()) ; @@ -655,44 +686,39 @@ NcDelete(void) } else { NcPosition(line); - nclinebuf = read(); + linebuf = read(); beginning_of_line(); answer = "?"; - while (upper(answer) != "Y" && upper(answer) != "N") { + while (answer != "Y" && answer != "N") { if (answer != "?") beep(); answer = ""; - get_parm(NULL, answer, - "Delete 'highlighted' file [yn]? ", 1); + get_parm(NULL, answer, "Delete 'highlighted' file [yn]? ", 1); if (answer == "") { answer = "N"; } else if (answer == "?") { beep(); + } else { + answer = upper(answer); } } - if (upper(answer) == "Y") { - base = index(nclinebuf, '\t'); /* delimiter */ - - if (substr(nclinebuf, TYPEPOS(base), 1) == "D") { - /* directory */ - ncfilebuf = trim(substr(nclinebuf, NAMEPOS(base))); - if (ncfilebuf != "..") { - message("Deleting Directory \"%s\"...", ncfilebuf); - if (-1 == rmdir(ncfilebuf)) { - error("Unable to rmdir \"%s\" : %d (%s)", - ncfilebuf, errno, strerror(errno)); + if (answer == "Y") { + name = NcParts(linebuf, type, size, mtime); + if (type == 'D') { /* directory */ + if (name != "..") { + message("Deleting Directory \"%s\"...", name); + if (rmdir(name) == -1) { + error("Unable to rmdir \"%s\" : %d (%s)", name, errno, strerror(errno)); } } - } else if (substr(nclinebuf, TYPEPOS(base), 1) == "F") { - /* file */ - ncfilebuf = "./" + trim(substr(nclinebuf, NAMEPOS(base))); - message("Deleting \"%s\"...", ncfilebuf); - if (remove(ncfilebuf) == -1) { - error("Unable to delete \"%s\" : %d (%s) - Press any key", - ncfilebuf, errno, strerror(errno)); + } else if (type == 'F') { /* file */ + name = "./" + name; + message("Deleting \"%s\"...", name); + if (remove(name) == -1) { + error("Unable to delete \"%s\" : %d (%s) - Press any key", name, errno, strerror(errno)); beep(); while(!inq_kbd_char()) ; @@ -709,38 +735,49 @@ NcDelete(void) /* - * NcEdit --- - * called whenever the user presses the , "edit". + * NcEscape/ESC --- + * Escape, without action. + */ +static void +NcEscape(void) +{ + ncexitname = ""; + exit(); +} + + +/* + * NcEdit/F4 --- + * Edit command. */ static void NcEdit(void) { - int line, base; + string linebuf, name; + int line, size, type, mtime; inq_position(line); - nclinebuf = read(); + linebuf = read(); raise_anchor(); top_of_buffer(); if (search_fwd("<\\c" + MARKER)) { - ncfilebuf = MARKER; + ncexitname = MARKER; } else { - base = index(nclinebuf, '\t'); /* delimiter */ - - /* directory */ - if (substr(nclinebuf, TYPEPOS(base), 1) == "D") { + name = NcParts(linebuf, type, size, mtime); + if (type == 'D') { /* directory */ error("Cannot edit directory, press any key..."); beep(); - while(!inq_kbd_char()) - ; - read_char(); NcPosition(line); return; - /* file */ - } else if (substr(nclinebuf, TYPEPOS(base), 1) == "F") { - ncfilebuf = "./" + trim(substr(nclinebuf, NAMEPOS(base))); + } else if (type == 'F') { /* file */ + ncexitname = "./" + name; + + } else { + NcPrompt(); + return; } } exit(); /* exit 'nc' */ @@ -748,14 +785,18 @@ NcEdit(void) /* - * NcExit --- + * NcExit/F10 --- * Exit. */ static void NcExit(void) { - ncfilebuf = ""; - exit(); + if (ncactiveno) { + ncexitname = MARKER; + exit(); + } else { + beep(); + } } @@ -774,10 +815,23 @@ NcPosition(int line) move_abs(line, 1); drop_anchor(ANCHOR_LINE); refresh(); +// NcDiagnostics(); return line; } +static void +NcDiagnostics(void) +{ + string linebuf, name; + int type, size, mtime; + + linebuf = read(); + name = NcParts(linebuf, type, size, mtime); + message("type=%c,name=%s,size=%d,mtime=%d", type, name, size, mtime); +} + + /* * NcPrompt --- * Update command prompt. @@ -810,8 +864,8 @@ NcHome(void) static void NcUp(void) { - up(); - NcPosition(0); + up(); + NcPosition(0); } @@ -888,57 +942,60 @@ NcPgdn(void) /* - * NcMarkSet --- + * NcSelect --- * Multiple file marking. */ static void -NcMarkSet(void) +NcSelect(void) { - NcMarkMultiple(MARK_SELECT); + NcMultiple(MARK_SELECT); } /* - * NcMarkClr --- + * NcUnselect --- * Multiple file unmarking. */ static void -NcMarkClr(void) +NcUnselect(void) { - NcMarkMultiple(MARK_UNSELECT); + NcMultiple(MARK_UNSELECT); } /* - * NcMarkInv --- + * NcInverse --- * Invert file marking. */ static void -NcMarkInv(void) +NcInverse(void) { - NcMarkMultiple(MARK_INVERT); + NcMultiple(MARK_INVERT); } /* - * NcMark --- + * NcToggle --- * Toggle file mark of current file */ static int -NcMark(void) +NcToggle(void) { + string linebuf; int base; - nclinebuf = read(); - base = index(nclinebuf, '\t'); /* delimiter */ - if (substr(nclinebuf, TYPEPOS(base), 1) != "F") { + linebuf = read(); + base = index(linebuf, '\t'); /* delimiter */ + if (substr(linebuf, TYPEPOS(base), 1) != "F") { return (-1); } delete_char(); - if (substr(nclinebuf,1,1) == MARKER) { + if (substr(linebuf,1,1) == MARKER) { + --ncactiveno; insert(" "); } else { insert(MARKER); + ++ncactiveno; } beginning_of_line(); NcDown(); @@ -947,18 +1004,17 @@ NcMark(void) /* - * NcMarkMultiple --- + * NcMultiple --- * Multiple file marking engine */ static void -NcMarkMultiple( int mark_typ ) +NcMultiple(int mark_type) { list result; - int base; - result[0] =""; - result = field_list((mark_typ == MARK_SELECT ? "Select" : - (mark_typ == MARK_UNSELECT ? "Unselect" : "Invert")), + result[0] = ""; + result = field_list((mark_type == MARK_SELECT ? "Select" : + (mark_type == MARK_UNSELECT ? "Unselect" : "Invert")), result, ncpatlist, TRUE); if (result[0] == "") { @@ -966,7 +1022,8 @@ NcMarkMultiple( int mark_typ ) } else { int line_no, line; - string pat; + string linebuf, pat, name; + int type, size, mtime; pat = result[0]; message("Marking specified files... (%s)", pat); @@ -975,28 +1032,38 @@ NcMarkMultiple( int mark_typ ) line_no = nclineno; while (line_no) { move_abs(line_no, 1); - nclinebuf = read(); - base = index(nclinebuf, '\t'); /* delimiter */ - - if (substr(nclinebuf, TYPEPOS(base), 1) == "F" && - re_search(NULL, pat, ncfilebuf) > 0) { - message(".. %s", trim(substr(nclinebuf, NAMEPOS(base)))); - - delete_char(); - switch (mark_typ) { - case MARK_INVERT: - if (substr(nclinebuf,1,1) == MARKER) { - insert(" "); - } else { - insert(MARKER); + linebuf = read(); + name = NcParts(linebuf, type, size, mtime); + if (type == 'F') + { + if (re_search(NULL, pat, name) > 0) { + message(".. %s", name); + switch (mark_type) { + case MARK_INVERT: + delete_char(); + if (substr(linebuf,1,1) == MARKER) { + --ncactiveno; + insert(" "); + } else { + ++ncactiveno; + insert(MARKER); + } + break; + case MARK_SELECT: + if (substr(linebuf,1,1) != MARKER) { + delete_char(); + ++ncactiveno; + insert(MARKER); + } + break; + case MARK_UNSELECT: + if (substr(linebuf,1,1) == MARKER) { + delete_char(); + --ncactiveno; + insert(" "); + } + break; } - break; - case MARK_SELECT: - insert(MARKER); - break; - case MARK_UNSELECT: - insert(" "); - break; } beginning_of_line(); } @@ -1015,23 +1082,25 @@ NcMarkMultiple( int mark_typ ) static void NcEnter(void) { - int base; + string linebuf, name; + int type, size, mtime; - nclinebuf = read(); - base = index(nclinebuf, '\t'); /* delimiter */ - - if (substr(nclinebuf, TYPEPOS(base), 1) == "D") { /* Directory selection */ - ncfilebuf = trim(substr(nclinebuf, NAMEPOS(base))); - if (ncfilebuf == "..") { + linebuf = read(); + name = NcParts(linebuf, type, size, mtime); + if (type == 'D') { /* directory */ + if (name == "..") { NcCd(DIR_UP); + } else { + NcCd(DIR_DOWN + name); + } + } else if (type == 'F') { /* file */ + if (0 == ncactiveno) { + ncexitname = "./" + name; + exit(); } else { - NcCd(DIR_DOWN + ncfilebuf); + NcToggle(); } - /* File selection */ - } else if (substr(nclinebuf, TYPEPOS(base), 1) == "F") { - ncfilebuf = "./" + trim(substr(nclinebuf, NAMEPOS(base))); - exit(); } } @@ -1060,8 +1129,8 @@ NcCd(~ string) } /* Refresh directory list */ - ncselpattern = ""; - NcDirectory(cwd); + ncpattern = ""; + NcRead(cwd); /* Position cursor at parent directory */ pos = 1; @@ -1091,15 +1160,15 @@ NcCd(~ string) /* - * NcDirectory --- - * Read the current. + * NcRead --- + * Read the current directory. */ static void -NcDirectory(string cwd) +NcRead(string cwd) { int cyear, year, day, hour, min; int bytes, mtime, mode; - int pass, lines; + int pass, dirs, lines; string name, mon, size; string buffer; @@ -1110,17 +1179,16 @@ NcDirectory(string cwd) message("Reading disk directory..."); nclineno = 0; /* line count */ + ncactiveno = 0; clear_buffer(); for (pass = 1; pass <= 2; pass++) { - int start = nclineno; /* first line-index of section 0... */ - if (ncsortorder == "Unsorted" && 2 == pass) { break; /* unsorted is single pass */ } file_pattern(WILD); while (find_file(name, bytes, mtime, NULL, mode)) { - if (S_IFDIR & mode) { + if (S_IFDIR & mode) { /* * Directories */ @@ -1128,8 +1196,9 @@ NcDirectory(string cwd) name == "." ) { /* skip on 2nd sort pass */ continue; /* or if '.' directory */ } - sprintf(buffer, " /%-*.*W| |", ncfwidth, ncfwidth, name); + bytes = 0; + ++dirs; } else { /* @@ -1150,34 +1219,41 @@ NcDirectory(string cwd) } sprintf(buffer, " %s%-*.*W|%7s|", - substr(mode_string(mode, cwd+"/"+name, TRUE), 1, 1), ncfwidth, ncfwidth, name, size); + substr(mode_string(mode, cwd + "/" + name, TRUE), 1, 1), ncfwidth, ncfwidth, name, size); } buffer += mode_string(mode); /* decode mode */ localtime(mtime, year, NULL, day, mon, NULL, hour, min, NULL); if (cyear == year) { - sprintf(buffer, "%s|%s %2d %02d:%02d ?", buffer, substr(mon,1,3), day, hour, min); + sprintf(buffer, "%s|%s %2d %02d:%02d ", buffer, substr(mon,1,3), day, hour, min); } else { - sprintf(buffer, "%s|%s %2d %04d ?", buffer, substr(mon,1,3), day, year); + sprintf(buffer, "%s|%s %2d %04d ", buffer, substr(mon,1,3), day, year); } - insert(buffer); - if (mode & S_IFDIR) { /* */ - insert(" \tD" + name + "\n"); - } else { - insert(" \tF" + name + "\n"); - } + insertf("%s\t%c|%s/%d/%d\n", /* |// */ + buffer, ((mode & S_IFDIR) ? 'D' : 'F'), name, bytes, mtime); ++nclineno; } - /* - * Sort current section - * TODO - sort order - */ - if (nclineno > start) { /* sort section to end-of-buffer */ - delete_line(); - sort_buffer(NULL, "::sort_versions", start + 1); + delete_line(); + if (ncsortorder != "Unsorted") { + string sortby; + if (dirs > 1) + sortby = "::sort_names"; + if (ncsortorder == "Name") { + sortby = "::sort_names"; + } else if (ncsortorder == "Extension") { + sortby = "::sort_extensions"; + } else if (ncsortorder == "Time") { + sortby = "::sort_times"; + } else if (ncsortorder == "Size") { + sortby = "::sort_sizes"; + } + if (sortby) { + sort_buffer(NULL, sortby, 1, dirs); + sort_buffer(NULL, sortby, dirs + 1); + } } } @@ -1193,26 +1269,80 @@ NcDirectory(string cwd) static int -sort_versions(int l1, string s1, int l2, string s2) +sort_names(int l1, string s1, int l2, string s2) { + int type, size, mtime; + + UNUSED(l1, l2); + s1 = NcParts(s1, type, size, mtime); + s2 = NcParts(s2, type, size, mtime); + return strfilecmp(s1, s2); +} + + +static int +sort_extensions(int l1, string s1, int l2, string s2) +{ + int type, size, mtime, ext; + UNUSED(l1, l2); - return strverscmp(substr(s1, 3), substr(s2, 3)); + s1 = NcParts(s1, type, size, mtime); + ext = rindex(s1, '.'); + if (ext) s1 = substr(s1, ext + 1); + + s2 = NcParts(s2, type, size, mtime); + ext = rindex(s2, '.'); + if (ext) s2 = substr(s2, ext + 1); + + return strfilecmp(s1, s2); +} + + +static int +sort_times(int l1, string s1, int l2, string s2) +{ + int type, size, mtime1, mtime2; + + UNUSED(l1, l2); + NcParts(s1, type, size, mtime1); + NcParts(s2, type, size, mtime2); + return mtime1 <=> mtime2; +} + + +static int +sort_sizes(int l1, string s1, int l2, string s2) +{ + int type, size1, size2, mtime; + + UNUSED(l1, l2); + NcParts(s1, type, size1, mtime); + NcParts(s2, type, size2, mtime); + return size1 <=> size2; } /* - * NcSort --- - * This routine is called whenever the user presses the , "sort". + * */ static void -NcSort(...) +NcSort(~ string) { - list result; + string sortorder; + + if (! get_parm(0, sortorder)) { + list result; + + result[0] = ncsortorder; + result = field_list("Sort Order", result, ncsortlist, TRUE); + if (result[0] != "" && result[0] != ncsortorder) { + sortorder = result[0]; + } + } - result[0] = ncsortorder; - result = field_list("Sort Order", result, ncsortlist, TRUE); - if (result[0] != "" && result[0] != ncsortorder) { - ncsortorder = result[0]; + if (sortorder) { + message("sorting by %s...", sortorder); + ncsortorder = sortorder; NcCd(); } } diff --git a/macsrc/opendir.cr b/macsrc/opendir.cr new file mode 100644 index 00000000..e7f82fae --- /dev/null +++ b/macsrc/opendir.cr @@ -0,0 +1,970 @@ +/* -*- mode: cr; indent-width: 4; -*- */ +/* $Id: opendir.cr,v 1.3 2024/07/28 12:27:44 cvsuser Exp $ + * opendir interface + * + * + */ + +#include "grief.h" +#include "dialog.h" /* dialog manager */ + +#if defined(DEBUG) +#define Debug(x) debug x; /* local debug diag's */ +#else +#define Debug(x) +#endif + +/* Constants */ +#define SYNTAX "opendir_coloriser" + +#define FORWARD_SLASH '/' +#define BACKWARD_SLASH '\\' +#define WILD "?*" +#define SMINCOLUMNS 62 /* screen width */ +#define SFILECOLUMNS (opendir_fwidth) +#define SINFOCOLUMNS 38 +#define TYPEPOS(__base) (__base + 1) +#define NAMEPOS(__base) (__base + 2) + +#if defined(MSDOS) +#define MARKER "\xfe" +#else +#define MARKER "=" +#endif + +/* Anchor types (See drop_anchor()) */ +#define ANCHOR_LINE 3 + +/* Directory movement */ +#define DIR_UP ".." +#define DIR_DOWN "./" + +/* Search modes */ +#define SEL_NEXT 1 +#define SEL_TOP 2 +#define SEL_PREV 0 + +/* Multiple file selection mode */ +#define MARK_SELECT 1 +#define MARK_UNSELECT 2 +#define MARK_INVERT 3 + + +/* Functions */ +#if defined(__PROTOTYPES__) +int opendir(~ string); + +static void OdSize(void); +static int OdPosition(int line); +static void OdPrompt(void); +static void OdCd(~ string); +static void OdRead(string cwd); +static int sort_versions(int i1, string s1, int l2, string s2); +static void OdMessage(void); +static void OdSpace(void); +static void OdBack(void); +static void OdMatch(string); +static int OdNext(string fname, int dir); +static int OdSearch(int next, string pattern); +static void OdChdir(void); +static void OdUpdir(void); +static void OdEscape(void); +static void OdAction(void); +static int OdPosition(int line); +static void OdPrompt(void); +static void OdHome(void); +static void OdUp(void); +static void OdDown(void); +static void OdEnd(void); +static void OdPgup(void); +static void OdPgdn(void); +static int OdToggle(void); +static void OdSelect(void); +static void OdUnselect(void); +static void OdInverse(void); +static void OdMultiple(int); +static void OdSort(~ string); +#endif /*__PROTOTYPES__*/ + +static int odkeymap; /* keyboard map */ + +static int odrows, odcols; /* screen rows/cols */ +static int odwidth, odfwidth; + +static int odlineno; /* current line count */ +static int odactiveno; /* selected count */ +static string odexitname; /* file buffer */ +static string odpattern; /* selection pattern */ + +static list oddirlist = { /* Mkdir/Chdir */ + "Name: ", "" + }; + +static list odpatlist = { /* Select/unselect */ + "Pattern: ", "" + }; + +static list odsortlist = { /* Sort order */ + "Sort by: ", {"Name", "Extension", "Unsorted"} + }; + +static string odsortorder = "Name"; + + +/* + * Run-time initialisation. + */ +void +main() +{ + /* syntax */ + create_syntax(SYNTAX); + syntax_rule("^[ =][/~][^ ]+", "lsdirectory"); + syntax_rule("^[ =]\\*[^ ]+", "lsexecute"); + syntax_rule("^[ =]\\@[^ ]+", "lssymlink"); + syntax_rule("^[ =]\\|[^ ]+", "lspipe"); + syntax_rule("^[ =]\\![^ ]+", "lserror"); /* broken link */ + syntax_rule("^[ =][-=S+][^ ]+", "lsspecial"); + syntax_rule("^[ =][^-/~@|!*=$+][^ ]+", "lsnormal"); + syntax_build(__COMPILETIME__); + + /* build keyboard definition */ + keyboard_push(); + keyboard_typeables(); /* keys 0...127 */ + + assign_to_key("", "::OdEnter"); + assign_to_key("", "::OdBack"); + assign_to_key("", "::OdSpace"); + assign_to_key("", "::OdHome"); + assign_to_key("", "::OdEnd"); + assign_to_key("", "::OdUp"); + assign_to_key("", "::OdDown"); + assign_to_key("", "::OdUp"); + assign_to_key("", "::OdDown"); + assign_to_key("", "::OdPgup"); + assign_to_key("", "::OdPgdn"); + assign_to_key("", "nothing"); + assign_to_key("", "help_display features/opendir.hlp"); + assign_to_key("", "help_display features/opendir.hlp"); + assign_to_key("", "::OdEscape"); + assign_to_key("", "::OdAction"); + assign_to_key("", "::OdAction"); + assign_to_key("", "::OdChdir"); + assign_to_key("", "::OdCd"); + assign_to_key("", "::OdUpdir"); +#if defined(MSDOS) + assign_to_key("", "::OdDrive"); +#endif + assign_to_key("", "ff"); + assign_to_key("", "::OdToggle"); + assign_to_key("", "::OdSelect"); + assign_to_key("", "::OdUnselect"); + assign_to_key("", "::OdInverse"); + assign_to_key("", "::OdSort Unsorted"); + assign_to_key("", "::OdSort Name"); + assign_to_key("", "::OdSort Extension"); + assign_to_key("", "::OdSort"); + + odkeymap = inq_keyboard(); + keyboard_pop(1); /* save keyboard */ + OdSize(); +} + + +/* + * Open directory interface, invoked on start upon a directory being presented for edit. + */ +int +opendir(~ string) +{ + string dir, cwd; /* saved directory */ + int old_buffer, old_window; + int new_buffer = -1; + int dir_buffer; + int base; + + /* Initialise directory */ + old_buffer = inq_buffer(); + old_window = inq_window(); + if ((dir_buffer = create_buffer("opendir", NULL, 1)) < 0) { + return -1; + } + + getwd(NULL, cwd); /* current working dir */ + if (! get_parm(0, dir) || 0 == strlen(dir) || dir == ".") + dir = cwd; + + OdSize(); + set_buffer(dir_buffer); + attach_syntax(SYNTAX); + set_buffer_type(NULL, BFTYP_UTF8); + OdRead(dir); + + create_window(odcols, odrows + 4, odcols + odwidth, 3, + " Help, select>, , to exit"); + attach_buffer(dir_buffer); + OdPosition(1); + odpattern = ""; + + /* User process */ + keyboard_push(odkeymap); + register_macro(0, "::OdBadkey", 1); /* local Bad key */ + process(); + unregister_macro(0, "::OdBadkey", 1); + keyboard_pop(1); /* pop, but retain */ + delete_window(); + + /* Load selected files */ + if (strlen(odexitname)) { /* exit condition */ + if (odexitname == MARKER) { + /* Load all marked files */ + string linebuf; + + top_of_buffer(); + while (search_fwd("<\\c" + MARKER)) { + linebuf = read(); + base = index(linebuf, '\t'); /* delimiter */ + odexitname = "./" + trim(substr(linebuf, NAMEPOS(base))); + down(); + + message("Loading \"%s\" for editing...", odexitname); + if (edit_file(odexitname) > 0) { + if (new_buffer == -1) { /* first */ + new_buffer = inq_buffer(); + } + } + set_buffer(dir_buffer); /* for next search */ + } + } else { + /* Load specified file */ + message("Loading \"%s\" for editing...", odexitname); + if (edit_file(odexitname) > 0) { + if (new_buffer == -1) { + new_buffer = inq_buffer(); + } + } + } + display_file_name(); + } + + cd(cwd); /* restore cwd */ + + delete_buffer(dir_buffer); + if (new_buffer == -1) + new_buffer = old_buffer; + set_buffer(new_buffer); + set_window(old_window); + attach_buffer(new_buffer); + return (new_buffer == -1 ? 0 : 1); +} + + +static void +OdSize(void) +{ + inq_screen_size(odrows, odcols); + if (odcols > SMINCOLUMNS + 2) { + odwidth = (odcols / 8) * 7; /* 7/8 width */ + } else { + odwidth = SMINCOLUMNS; /* center window */ + } + odfwidth = odwidth - SINFOCOLUMNS; + odcols -= (odwidth + 2); /* center window */ + odcols /= 2; + odrows -= 10; /* rows-10 screen size */ +} + + +static string +OdBadkey() +{ + string c; + + left(); + c = read(1); + delete_char(); + if (c == "/" || c == "\\") { + OdCd("/"); + } else { + OdMatch(lower(c)); + } + return ""; +} + + +static void +OdMessage(void) +{ + message("File: %s", odpattern); +} + + +static void +OdSpace(void) +{ + if (odpattern == "") { + if (OdToggle() != 0) { + OdDown(); + } + } else { + if (OdNext(odpattern, SEL_NEXT) == -1) { + OdNext(odpattern, SEL_TOP); + } + } +} + + +static void +OdBack(void) +{ + int len; + + if ((len = strlen(odpattern)) > 0) { + odpattern = substr(odpattern, 1, len - 1); + if (strlen(odpattern) == 0) { + OdPosition(1); + } else { + if (OdNext(odpattern, SEL_TOP) == -1) { + beep(); + } + } + OdMessage(); + } +} + + +static void +OdMatch(string new_key) +{ + string new_pattern; + + new_pattern = odpattern; + new_pattern += new_key; + if (strlen(new_pattern) == 1 || OdNext(new_pattern, SEL_NEXT) == -1) { + if (OdNext(new_pattern, SEL_TOP) == -1) { + beep(); + return; + } + } + odpattern = new_pattern; + OdMessage(); +} + + +/* + * Finds the next matching file name. + */ +static int +OdNext(string fname, int dir) +{ + save_position(); /* Save the current position. */ + + switch(dir) { + case SEL_TOP: /* From top of buffer. */ + top_of_buffer(); + break; + case SEL_NEXT: /* Next match. */ + down(); + break; + case SEL_PREV: /* Prev match. */ + up(); + break; + } + + if (OdSearch(dir, "<" + MARKER + "| "+fname) <= 0) { + /* not found, restore position */ + restore_position(); + return -1; + } + restore_position(0); /* found, eat position. */ + return OdPosition(0); +} + + +/* + * Searches forward and back depending on first parameter if that parameter is not zero it searches forward else back. + */ +static int +OdSearch(int next, string pattern) +{ + return (next ? search_fwd(pattern, 1, 0, 0) : search_back(pattern, 1, 0, 0)); +} + + +#if defined(MSDOS) +/* + * Change-drive + */ +static void +OdDrive(void) +{ + string drive; + + drive = "?"; + while (drive != "" && (drive < "A" || drive > "Z")) { + if (drive != "?") + beep(); + drive = ""; + get_parm(NULL, drive, "New Drive Letter? ", 1); + if (drive == "?") + beep(); + drive = upper(drive); + } + + if (drive >= "A" && drive <= "Z") { + OdCd(drive + ":"); + } else { + beep(); + OdPrompt(); + } +} +#endif /*MSDOS*/ + + +/* + * Change-directory + */ +static void +OdChdir(void) +{ + list result; + + result[0] = ""; + result = field_list("Chdir", result, oddirlist, TRUE); + if (result[0] == "") { + OdPrompt(); + } else { + OdCd(result[0]); + } +} + + +/* + * Up-directory + */ +static void +OdUpdir(void) +{ + string curdir; + + getwd(NULL, curdir); + if (strlen(curdir) > 3) { + OdCd(DIR_UP); + } else { + beep(); + } +} + + +/* + * escape. + */ +static void +OdEscape(void) +{ + odexitname = ""; + exit(); +} + + +/* + * , action selection. + */ +static void +OdAction(void) +{ + if (odactiveno) { + odexitname = MARKER; + exit(); + } else { + beep(); + } +} + + +/* + * Position the cursor. + */ +static int +OdPosition(int line) +{ + raise_anchor(); + if (line == 0) + inq_position(line); + if (line > odlineno) + line = odlineno; + move_abs(line, 1); + drop_anchor(ANCHOR_LINE); + refresh(); + return line; +} + + +/* + * Update command prompt. + */ +static void +OdPrompt(void) +{ + string currdir; + + getwd(NULL, currdir); + message("%s", currdir); +} + + +/* + * Cursor controls. + */ +static void +OdHome(void) +{ + OdPosition(1); +} + + +static void +OdUp(void) +{ + up(); + OdPosition(0); +} + + +static void +OdDown(void) +{ + int line; + + inq_position(line); + if (line < odlineno) { + beginning_of_line(); + down(); + OdPosition(0); + } +} + + +static void +OdEnd(void) +{ + OdPosition(odlineno); +} + + +static void +OdPgup(void) +{ + int count, line; + + inq_position(line); + count = odrows; + line -= count; + if (line <= 1) + line = 1; /* HOME */ + else while (count) + --count; + OdPosition(line); +} + + +static void +OdPgdn(void) +{ + int count, line; + + inq_position(line); + count = odrows; + line += count; + if (line <= odlineno) { + while (count) { + --count; + } + } else { + line = odlineno; /* END */ + } + OdPosition(line); +} + + +/* + * Multiple file marking. + */ +static void +OdSelect(void) +{ + OdMultiple(MARK_SELECT); +} + + +/* + * Multiple file unmarking. + */ +static void +OdUnselect(void) +{ + OdMultiple(MARK_UNSELECT); +} + + +/* + * Invert file marking. + */ +static void +OdInverse(void) +{ + OdMultiple(MARK_INVERT); +} + + +/* + * Toggle file mark of current file + */ +static int +OdToggle(void) +{ + string linebuf; + int base; + + linebuf = read(); + base = index(linebuf, '\t'); /* delimiter */ + if (substr(linebuf, TYPEPOS(base), 1) != "F") { + return (-1); + } + delete_char(); + if (substr(linebuf,1,1) == MARKER) { + --odactiveno; + insert(" "); + } else { + insert(MARKER); + ++odactiveno; + } + beginning_of_line(); + OdDown(); + return (0); +} + + +/* + * Multiple file marking engine + */ +static void +OdMultiple(int mark_type) +{ + list result; + int base; + + result[0] = ""; + result = field_list((mark_type == MARK_SELECT ? "Select" : + (mark_type == MARK_UNSELECT ? "Unselect" : "Invert")), + result, odpatlist, TRUE); + + if (result[0] == "") { + OdPrompt(); + + } else { + int line_no, line; + string linebuf, pat; + + pat = result[0]; + message("Marking specified files... (%s)", pat); + + inq_position(line); + line_no = odlineno; + while (line_no) { + move_abs(line_no, 1); + linebuf = read(); + base = index(linebuf, '\t'); /* delimiter */ + if (substr(linebuf, TYPEPOS(base), 1) == "F") + { + string name = trim(substr(linebuf, NAMEPOS(base))); + if (re_search(NULL, pat, name) > 0) { + message(".. %s", name); + switch (mark_type) { + case MARK_INVERT: + delete_char(); + if (substr(linebuf,1,1) == MARKER) { + --odactiveno; + insert(" "); + } else { + ++odactiveno; + insert(MARKER); + } + break; + case MARK_SELECT: + if (substr(linebuf,1,1) != MARKER) { + delete_char(); + ++odactiveno; + insert(MARKER); + } + break; + case MARK_UNSELECT: + if (substr(linebuf,1,1) == MARKER) { + delete_char(); + --odactiveno; + insert(" "); + } + break; + } + } + beginning_of_line(); + } + --line_no; + } + OdPosition(line); + } + OdPrompt(); +} + + +/* + * processing + */ +static void +OdEnter(void) +{ + string linebuf; + int base; + + linebuf = read(); + base = index(linebuf, '\t'); /* delimiter */ + + if (substr(linebuf, TYPEPOS(base), 1) == "D") { + /* + * Directory, move up/down. + */ + string name = trim(substr(linebuf, NAMEPOS(base))); + if (name == "..") { + OdCd(DIR_UP); + } else { + OdCd(DIR_DOWN + name); + } + + } else if (substr(linebuf, TYPEPOS(base), 1) == "F") { + /* + * File, either action or toggle. + */ + if (0 == odactiveno) { + odexitname = "./" + trim(substr(linebuf, NAMEPOS(base))); + exit(); + } else { + OdToggle(); + } + } +} + + +/* + * DIR selection. + */ +static void +OdCd(~ string) +{ + string cwd, olddir; + int idx, pos; + + /* Retrieve parameters (option path) */ + if (! get_parm(0, cwd)) { + cwd = ""; + } + + /* Change DIRECTORY */ + getwd(NULL, olddir); + if (strlen(cwd)) { + cd(cwd); + } else { + cwd = olddir; + } + + /* Refresh directory list */ + odpattern = ""; + OdRead(cwd); + + /* Position cursor at parent directory */ + pos = 1; + getwd(NULL, cwd); + idx = strlen(cwd); + if (idx < strlen(olddir)) { + int dot; + + if (idx > 3) { + ++idx; + } + ++idx; + olddir = substr(olddir, idx); + dot = index(olddir, "."); + if (dot) { + olddir = substr(olddir, 1, dot-1) + " +" + substr(olddir, dot+1); + } + if (search_fwd("< /"+olddir+"[ ]+") > 0) { + inq_position(pos); + } + } + + /* directory position restore */ + OdPosition(pos); + OdPrompt(); +} + + +/* + * Read the current directory. + */ +static void +OdRead(string cwd) +{ + int cyear, year, day, hour, min; + int bytes, mtime, mode; + int pass, lines; + string name, mon, size; + string buffer; + + /* + * read directory + */ + date(cyear, NULL, NULL); + message("Reading disk directory..."); + + odlineno = 0; /* line count */ + odactiveno = 0; + clear_buffer(); + for (pass = 1; pass <= 2; pass++) { + int start = odlineno; /* first line-index of section 0... */ + + if (odsortorder == "Unsorted" && 2 == pass) { + break; /* unsorted is single pass */ + } + + file_pattern(WILD); + while (find_file(name, bytes, mtime, NULL, mode)) { + if (S_IFDIR & mode) { + /* + * Directories + */ + if ((odsortorder != "Unsorted" && 2 == pass) || + name == "." ) { /* skip on 2nd sort pass */ + continue; /* or if '.' directory */ + } + sprintf(buffer, " /%-*.*W| |", odfwidth, odfwidth, name); + + } else { + /* + * Files etc + */ + if (odsortorder != "Unsorted" && 1 == pass) { + continue; /* skip on 1st sort pass */ + } + + if (bytes < 9999999) { + sprintf(size, "%d", bytes); + } else if ((bytes /= 1024) < 999999) { + sprintf(size, "%dK", bytes); + } else if ((bytes /= 1024) < 999999) { + sprintf(size, "%dM", bytes); + } else { + sprintf(size, "%dG", bytes/1024); + } + + sprintf(buffer, " %s%-*.*W|%7s|", + substr(mode_string(mode, cwd+"/"+name, TRUE), 1, 1), odfwidth, odfwidth, name, size); + } + + buffer += mode_string(mode); /* decode mode */ + + localtime(mtime, year, NULL, day, mon, NULL, hour, min, NULL); + if (cyear == year) { + sprintf(buffer, "%s|%s %2d %02d:%02d ?", buffer, substr(mon,1,3), day, hour, min); + } else { + sprintf(buffer, "%s|%s %2d %04d ?", buffer, substr(mon,1,3), day, year); + } + insert(buffer); + + if (mode & S_IFDIR) { /* */ + insert(" \tD" + name + "\n"); + } else { + insert(" \tF" + name + "\n"); + } + ++odlineno; + } + + delete_line(); + if (odsortorder != "Unsorted") { + if (odsortorder == "Name") { + sort_buffer(NULL, "::sort_names", start + 1); + } else if (odsortorder == "Extension") { + sort_buffer(NULL, "::sort_extensions", start + 1); + } + } + } + + inq_screen_size(NULL, lines); /* pad image */ + sprintf(buffer, " %-*s|%7s|%10s|%12s\n", odfwidth, "", "", "", ""); + while (lines-- > 0) { + insert(buffer); + } + + top_of_buffer(); + message("done..."); +} + + +static int +sort_names(int l1, string s1, int l2, string s2) +{ + int base = index(s1, '\t'); /* delimiter */ + + UNUSED(l1, l2); + s1 = substr(s1, NAMEPOS(base)); + s2 = substr(s2, NAMEPOS(base)); + return strfilecmp(s1, s2); +} + + +static int +sort_extensions(int l1, string s1, int l2, string s2) +{ + int ext, base = index(s1, '\t'); /* delimiter */ + + UNUSED(l1, l2); + ext = rindex(s1, '.'); + if (ext > base) + s1 = substr(s1, ext + 1); + else + s1 = ""; + + ext = rindex(s2, '.'); + if (ext > base) + s2 = substr(s2, ext + 1); + else + s2 = ""; + + return strfilecmp(s1, s2); +} + + +/* + * + */ +static void +OdSort(~ string) +{ + string sortorder; + + if (! get_parm(0, sortorder)) { + list result; + + result[0] = odsortorder; + result = field_list("Sort Order", result, odsortlist, TRUE); + if (result[0] != "" && result[0] != odsortorder) { + sortorder = result[0]; + } + } + + if (sortorder) { + message("sorting by %s...", sortorder); + odsortorder = sortorder; + OdCd(); + } +} + +/*end*/ diff --git a/macsrc/popup.cr b/macsrc/popup.cr new file mode 100644 index 00000000..43fd21a2 --- /dev/null +++ b/macsrc/popup.cr @@ -0,0 +1,142 @@ +/* -*- mode: cr; indent-width: 4; -*- */ +/* $Id: popup.cr,v 1.2 2024/09/12 17:08:28 cvsuser Exp $ + * + * Mouse popup + */ + +#include "grief.h" + +static list elements = + quote_list( + "Copy", "Cut", "Paste", + "Left-Shift", "Right-Shift", + "Exit" + ); + +void +popup_mouse(~ int x, ~ int y) +{ + int popup_buf; + +#if (0) // work-in-progress + int handle = + dialog_create( make_list( + DLGA_CALLBACK, "::popup_callback", + DLGA_STYLES, DLGS_BORDER|DLGS_SYSCLOSE, + DLGC_MENU, + DLGA_NAME, "popup", + DLGC_MENU_ITEM, + DLGA_ICON, 0x2398, // Next Page + DLGA_NAME, "Copy", + DLGA_CALLBACK, "::popup_copy", + DLGC_MENU_ITEM, + DLGA_ICON, 0x2702, // Black Scissors + DLGA_NAME, "Cut", + DLGA_CALLBACK, "::popup_cut", + DLGC_MENU_SEPARATOR, + DLGC_MENU_ITEM, + DLGA_ICON, 0x1f4cb, // Clipboard + DLGA_NAME, "Paste", + DLGA_CALLBACK, "::popup_paste" + DLGC_MENU_ITEM, + DLGA_NAME, "Left-Shift", + DLGA_CALLBACK, "::popup_shift" + DLGA_GREYED, + DLGC_MENU_ITEM, + DLGA_NAME, "Right-Shift", + DLGA_CALLBACK, "::popup_shift" + DLGA_GREYED, + DLGC_MENU_ITEM, + DLGA_NAME, "Exit", + DLGA_CALLBACK, "::popup_exit" + )); +#else + int handle = + dialog_create( make_list( + DLGA_CALLBACK, "::popup_listbox", + DLGA_STYLES, DLGS_BORDER|DLGS_SYSCLOSE, + DLGC_LIST_BOX, + DLGA_NAME, "popup", + DLGA_KEYDOWN, 1, + DLGA_ROWS, length_of_list(elements), + DLGA_COLS, 12, + DLGA_LBELEMENTS, elements + )); +#endif + + if (get_parm(0, x) <= 0) x = -1; + if (get_parm(1, y) <= 0) y = -1; + + popup_buf = inq_buffer(); + dialog_run(handle, x, y); + dialog_delete(handle); +} + + +static int +popup_listbox(int ident, string name, int p1, int p2) +{ + extern int popup_buf; + string action; + + switch (p1) { + case DLGE_INIT: + if (inq_marked() == MK_NONE) { + widget_set(NULL, "popup", NULL, DLGA_LBREMOVE, 3); + widget_set(NULL, "popup", NULL, DLGA_LBREMOVE, 3); + } + break; + case DLGE_CHANGE: + action = widget_get(NULL, "popup", DLGA_LBTEXT, p2); + switch (action) { + case "Copy": + set_buffer(popup_buf); + copy(); + break; + case "Cut": + set_buffer(popup_buf); + cut(); + break; + case "Paste": + set_buffer(popup_buf); + paste(); + break; + case "Left-Shift": + set_buffer(popup_buf); + if (inq_marked()) { + shiftl(); + } + break; + case "Right-Shift": + set_buffer(popup_buf); + if (inq_marked()) { + shiftr(); + } + break; + case "Exit": + exit(); + break; + } + dialog_exit(); + break; +// case DLGE_SYSCOMMAND: +// if (p2 == DLSC_CLOSE) { +// dialog_exit(); +// return TRUE; +// } +// break; + case DLGE_KEYDOWN: + if (p2 == key_to_int("")) { + dialog_exit(); + return TRUE; + } + break; + default: + message("ident=0x%x, name=%s, p1=%d/0x%x, p2=%d/0x%x", ident, name, p1, p1, p2, p2); + break; + } + return FALSE; // default action +} + +//end + diff --git a/macsrc/scrblank.cr b/macsrc/scrblank.cr index d5ac7c95..fbc9fbed 100644 --- a/macsrc/scrblank.cr +++ b/macsrc/scrblank.cr @@ -1,4 +1,4 @@ -/* $Id: scrblank.cr,v 1.8 2014/10/27 23:28:26 ayoung Exp $ +/* $Id: scrblank.cr,v 1.9 2024/07/28 11:56:29 cvsuser Exp $ * Screen blank utility. * * @@ -51,35 +51,23 @@ screen_blank_idle(void) void screen_blank(void) { - int curwin, curbuf; - int buf; - int win; - int lines, cols; - int echo_status; - int background, normal, selected, messages, errors, hi_fg, hi_bg, frame; - int i = 0; - int color_screen; + int curwin = inq_window(), curbuf = inq_buffer(); + int echo_status = echo_line(0); + int lines, cols, cmode; + int buf, win; + string bg; string esc; + int i = 0; - /* Save colors so we can go for a darker one. */ - inq_color(background, normal, selected, messages, errors, hi_bg, hi_fg, frame); - - curwin = inq_window(); - curbuf = inq_buffer(); - - /* Save status of echo line flags and clear them from the screen at the same time. */ - echo_status = echo_line(0); - - /* Create a window which overlaps the whole screen, so we can play inside it. */ - color_screen = inq_screen_size(lines, cols); + cmode = inq_screen_size(lines, cols); buf = create_buffer("Blanker", NULL, TRUE); win = create_window(0, lines - 1, cols - 1, 0, NULL); set_window(win); attach_buffer(buf); set_buffer_flags(NULL, BF_ANSI); - /* Wait for key strokes, and every now and again do something interesting. */ - color(BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK); + get_color_pair("background", bg); + color(BLACK); cursor(0); do { @@ -87,23 +75,25 @@ screen_blank(void) if ((i = ++i % 8) == 0) { ++i; } - if (color_screen) { - sprintf(esc, "\x1b[%dm", 30 + i); /* FIXME - buffer attributes */ + + if (cmode) { + sprintf(esc, "\x1b[%dm", 30 + i); /* FIXME - buffer attributes */ } + insert("\n", rand(lines - 2)); insert(" ", rand(cols - 22)); insert(esc + "GRIEF Screen Blanker"); } while (read_char(TIMEOUT) == -1); cursor(1); + set_color_pair("background", bg); + delete_window(win); delete_buffer(buf); set_window(curwin); set_buffer(curbuf); attach_buffer(curbuf); echo_line(echo_status); - - color(background, normal, selected, messages, errors, hi_bg, hi_fg, frame); } /*end*/ diff --git a/macsrc/select.cr b/macsrc/select.cr index 5b17d52e..43257305 100644 --- a/macsrc/select.cr +++ b/macsrc/select.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: select.cr,v 1.45 2024/05/15 08:22:45 cvsuser Exp $ +/* $Id: select.cr,v 1.46 2024/09/06 14:35:57 cvsuser Exp $ * Selection macros implementing buffer based popup user interface. * * @@ -894,7 +894,7 @@ select_list(string title, string message_string, int step, /* * select_slim_list --- - * This function is similar to select_list() but we assume that the list is + * Similar to select_list() but we assume that the list is * unstructured -- there are no actions or help associated with each element. */ int @@ -987,7 +987,7 @@ int select_buffer(int buf, int win, ~int flags, ~declare, ~list do_list, ~declare help_list, ~int start_line, ~int keep_window) { - int but_clicks, but_line; + int last_but_line; int old_buf, old_win; int list_items, width, depth, retval; int selection, selection_flags; @@ -996,10 +996,7 @@ select_buffer(int buf, int win, ~int flags, ~declare, ~list do_list, UNUSED(do_list); /* used by lower level functions */ UNUSED(help_list); /* used by lower level functions */ - UNUSED(but_clicks, but_line); - - but_clicks = but_line = 0; - + last_but_line = 0; old_buf = inq_buffer(); old_win = inq_window(); @@ -1155,32 +1152,20 @@ sel_copy(void) static void sel_button1(int type) { - extern int but_clicks, but_line, win; - int tm, x, y, cwin, line, col, where, region, event; - - /* Count clicks */ - tm = get_mouse_pos(x, y, cwin, line, col, where, region, event); - if (1 == type) { - if (tm < 0 || tm > CLICK_TIME_MS) { - but_clicks = 1; // click window expired - } else { - ++but_clicks; - } - } else if (2 == type) { - ++but_clicks; // double click - } + extern int last_but_line, win; + int x, y, cwin, line, col, where, region, event; - /* Process event */ + get_mouse_pos(x, y, cwin, line, col, where, region, event); if (win == cwin) { switch (where) { case MOBJ_INSIDE: move_abs(line, 1); // move selection sel_warp(); - if (line == but_line && 2 == but_clicks) { + if (line == last_but_line && 2 == type) { push_back(key_to_int("")); - break; // double-clicks + break; // double-click } - but_line = line; + last_but_line = line; break; case MOBJ_TOP_EDGE: case MOBJ_BOTTOM_EDGE: @@ -1468,8 +1453,7 @@ sel_timer(int reset) /* * sel_list --- - * This function is called when user selects an item in a list, returning the item - * (line number) selected. + * Called when user selects an item in a list, returning the item (line number) selected. */ void sel_list(void) @@ -1495,16 +1479,15 @@ sel_list(void) } else { execute_macro(function); } - } else { - select_list("XYZ", "ABC", 1, function); /* ??? */ + select_list("XYZ", "ABC", 1, function); /* ??? */ } } /* * sel_warp --- - * This function called by the mouse code to 'warp' the cursor. + * Called by the mouse code to 'warp' the cursor. * * The user clicked on an entry and we want to unhilight the old entry and hilight * the currrent. diff --git a/macsrc/sysinfo.cr b/macsrc/sysinfo.cr index e9492a79..12733e33 100644 --- a/macsrc/sysinfo.cr +++ b/macsrc/sysinfo.cr @@ -1,5 +1,5 @@ /* -*- indent-width: 4; -*- */ -/* $Id: sysinfo.cr,v 1.15 2014/10/27 23:28:29 ayoung Exp $ +/* $Id: sysinfo.cr,v 1.16 2024/08/04 10:07:57 cvsuser Exp $ * System information Dialog. * * @@ -145,7 +145,7 @@ sysinfo_cb(int ident, string name, int p1, int p2) string buf; version(maj, min, edit, rel, machtype, compiled, cmver, NULL, build); - sprintf(buf, "%s v%d.%d.%d (%d)", APPNAME, maj, min, edit, cmver); + sprintf(buf, "%s v%d.%d.%d.%d (%d)", APPNAME, maj, min, edit, cmver); widget_set(ident, "version", buf); widget_set(ident, "compiled", compiled); widget_set(ident, "build", build); diff --git a/macsrc/tty/console.cr b/macsrc/tty/console.cr new file mode 100644 index 00000000..1683ddee --- /dev/null +++ b/macsrc/tty/console.cr @@ -0,0 +1,165 @@ +/* -*- mode: cr; indent-width: 4; -*- */ +/* + * Determine the console type, and initialise the terminal characteristics. + * + * Firstly utilise GRTERM otherwise system TERM. + * If "tty/$TERM" exists load, otherwise, default to "tty/tty". + * + * If the GRTERM environment variables ate of the form: + * + * type-type1-type2, + */ + +#include "tty.h" + +#if defined(__PROTOTYPES__) +static string iscolor(string); +extern void ansi_arrows(void); +#endif + +void +console_detect() +{ + string btermspec, termspec, term, name; + list btermpts, termpts; + + /* + * GRTERM/TERM + */ + btermspec = lower(getenv("GRTERM")); + if (strlen(btermspec)) { + btermpts = split(btermspec, "-"); + if (length_of_list(btermpts)) { /* GRTERM primary */ + term = btermpts[0]; + } + } + + termspec = lower(getenv("TERM")); + if (strlen(termspec)) { + termpts = split(termspec, "-"); + if (term == "") { /* TERM secondary */ + if (length_of_list(termpts)) { + term = termpts[0]; + } + } + } + + if (0 == load_macro("tty/" + term)) { /* xterm etc */ + load_macro("tty/tty"); + term = "tty"; + + } else { /* retrieve derived/detected name */ + if (0 == get_term_feature(TF_NAME, name)) { + name = re_translate(SF_GLOBAL, "[ -]+", "_", name); + } + } + + /* + * Color attribute. + */ + const string colorterm = getenv("COLORTERM"); + string colorname, var, fn; + + if (colorterm == "truecolor" || colorterm == "24bit") { + colorname = "256color"; + + } else { + int i; + + for (i = 1; (i < length_of_list(btermpts)) && (colorname == ""); i++) { + colorname = iscolor(btermpts[i]); + } + + for (i = 1; (i < length_of_list(termpts)) && (colorname == ""); i++) { + colorname = iscolor(termpts[i]); + } + } + + if (strlen(colorname)) { + fn = name + "_" + colorname; /* xterm_gnome_xxx */ + if (inq_macro(fn) > 0) { + execute_macro(fn); + + } else if (term != name) { + fn = term + "_" + colorname; /* xterm_xxx */ + if (inq_macro(fn) > 0) { + execute_macro(fn); + } + } + } + + /* + * Additional attributes, example "GRTERM=xterm-arrows" + * + * Note: + * tty/xterm_xxx macros contain a void xxx macro, as such term_xxx calls shall have no effect. + */ + while (list_each(btermpts, var) >= 0) { + if (var == term || iscolor(var) != "") + continue; + + fn = name + "_" + var; /* xterm_gnome_xxx */ + if (inq_macro(fn, 0x01) > 0) { + execute_macro(fn); + continue; + } + + if (term != name) { + fn = term + "_" + var; /* xterm_xxx */ + if (inq_macro(fn, 0x01) > 0) { + execute_macro(fn); + continue; + } + } + + if (var == "ansi_arrows" > 0) { /* global options, restricted set */ + ansi_arrows(); + } + } +} + + +/* + * iscolor --- + * Determine whether a colorname attribute. + */ +static string +iscolor(string name) +{ + if (name == "256color" || name == "256" /*legacy*/) { + return "256color"; + + } else if (name == "88color" || name == "88" /*legacy*/) { + return "88color"; + + } else if (name == "color" || name == "16color" || name == "16" /*legacy*/) { + return "color"; + + } else if (name == "mono" || name == "m") { + return "mono"; + } + + return ""; /*not-color*/ +} + + +void +console() +{ + /*NOTHING*/ +} + + +/* + * ansi_arrows --- + * Following macro used for setting arrow keys to standard ANSI sequences. + */ +void +ansi_arrows(void) +{ + set_term_keyboard( + KEY_UP, "\x1b[A", KEY_DOWN, "\x1b[B", + KEY_LEFT, "\x1b[D", KEY_RIGHT, "\x1b[C"); +} + +/*end*/ diff --git a/macsrc/tty/ctlseqs.txt b/macsrc/tty/ctlseqs.txt index 09976370..66362afa 100644 --- a/macsrc/tty/ctlseqs.txt +++ b/macsrc/tty/ctlseqs.txt @@ -2,1259 +2,3592 @@ - Xterm Control Sequences - Edward2 Moy - University of California, Berkeley - Revised by - Stephen2 Gildea - X Consortium (1994) - Thomas2 Dickey - XFree86 Project (1996-2005) + XTerm Control Sequences + Edward Moy + University of California, Berkeley -** Definitions + Revised by -c2 The literal character c2. + Stephen Gildea + X Consortium (1994) -C2 A single (required) character. + Thomas Dickey + XFree86 Project (1996-2006) + invisible-island.net (2006-2024) + updated for XTerm Patch #392 (2024/05/22) -Ps2 A single (usually optional) numeric parameter, composed of one of - more digits. -Pm2 A multiple numeric parameter composed of any number of single - numeric parameters, separated by ; character(s). Individual val- - ues for the parameters are listed with Ps2 . -Pt2 A text parameter composed of printable characters. +Definitions -** C1 (8-Bit) Control Characters +Many controls use parameters, shown in italics. If a control uses a +single parameter, only one parameter name is listed. Some parameters +(along with separating ; characters) may be optional. Other characters +in the control are required. -The xterm2 program recognizes both 8-bit and 7-bit control characters. It generates -7-bit controls (by default) or 8-bit if S8C1T is enabled. The following pairs of 7-bit -and 8-bit control characters are equiva- lent: +C A single (required) character. -ESC D Index (IND is 0x84) +Ps A single (usually optional) numeric parameter, composed of one or + more digits. -ESC E Next Line (NEL is 0x85) +Pm Any number of single numeric parameters, separated by ; + character(s). Individual values for the parameters are listed with + Ps . -ESC H Tab Set (HTS is 0x88) +Pt A text parameter composed of printable characters. -ESC M Reverse Index (RI is 0x8d) -ESC N Single Shift Select of G2 Character Set (SS2 is 0x8e): affects - next character only +Control Bytes, Characters, and Sequences -ESC O Single Shift Select of G3 Character Set (SS3 is 0x8f): affects - next character only +ECMA-48 (aka "ISO 6429") documents C1 (8-bit) and C0 (7-bit) codes. +Those are respectively codes 128 to 159 and 0 to 31. ECMA-48 avoids +referring to these codes as characters, because that term is associated +with graphic characters. Instead, it uses "bytes" and "codes", with +occasional lapses to "characters" where the meaning cannot be mistaken. -ESC P Device Control String (DCS is 0x90) +Controls (including the escape code 27) are processed once: -ESC V Start of Guarded Area (SPA is 0x96) +o This means that a C1 control can be mistaken for badly-formed UTF-8 + when the terminal runs in UTF-8 mode because C1 controls are valid + continuation bytes of a UTF-8 encoded (multibyte) value. -ESC W End of Guarded Area (EPA is 0x97) +o It is not possible to use a C1 control obtained from decoding the + UTF-8 text, because that would require reprocessing the data. + Consequently there is no ambiguity in the way this document uses the + term "character" to refer to bytes in a control sequence. -ESC X Start of String (SOS is 0x98) +The order of processing is a necessary consequence of the way ECMA-48 is +designed: -ESC Z Return Terminal ID (DECID is 0x9a). Obsolete form of CSI c (DA). +o Each byte sent to the terminal can be unambiguously determined to + fall into one of a few categories (C0, C1 and graphic characters). -ESC [ Control Sequence Introducer (CSI is 0x9b) +o ECMA-48 is modal; once it starts processing a control sequence, the + terminal continues until the sequence is complete, or some byte is + found which is not allowed in the sequence. -ESC \ String Terminator (ST is 0x9c) +o Intermediate, parameter and final bytes may use the same codes as + graphic characters, but they are processed as part of a control + sequence and are not actually graphic characters. -ESC ] Operating System Command (OSC is 0x9d) +o Eight-bit controls can have intermediate, etc., bytes in the range + 160 to 255. Those can be treated as their counterparts in the range + 32 to 127. -ESC ^ Privacy Message (PM is 0x9e) +o Single-byte controls can be handled separately from multi-byte + control sequences because ECMA-48's rules are unambiguous. -ESC _ Application Program Command (APC is 0x9f) + As a special case, ECMA-48 (section 9) mentions that the control + functions shift-in and shift-out are allowed to occur within a 7-bit + multibyte control sequence because those cannot alter the meaning of + the control sequence. + +o Some controls (such as OSC ) introduce a string mode, which is ended + on a ST (string terminator). + + ECMA-48 describes only correct behavior, telling what types of + characters are expected at each stage of the control sequences. It + says that the action taken in error recovery is implementation- + dependent. XTerm decodes control sequences using a state machine. + It handles errors in decoding i.e., unexpected characters, by + resetting to the initial (ground) state. That is different from the + treatment of unimplemented (but correctly formatted) features. + + If an application does not send the string terminator, that is also + an error from the standpoint of a user. To accommodate users of + those applications, xterm has resource settings which allow + workarounds: + + o The Linux console's palette sequences do not use a string + terminator. The brokenLinuxOSC resource setting tells xterm to + ignore those particular sequences. + + o The terminal should accept single-byte controls within the + string. But some applications omit a string terminator, like + the Linux console. The brokenStringTerm resource setting tells + xterm to exit string mode if it decodes a common control + character such as carriage return before the string terminator. + + +C1 (8-Bit) Control Characters + +The xterm program recognizes both 8-bit and 7-bit control characters. +It generates 7-bit controls (by default) or 8-bit if S8C1T is enabled. +The following pairs of 7-bit and 8-bit control characters are +equivalent: + +ESC D + Index (IND is 0x84). + +ESC E + Next Line (NEL is 0x85). + +ESC H + Tab Set (HTS is 0x88). + +ESC M + Reverse Index (RI is 0x8d). + +ESC N + Single Shift Select of G2 Character Set (SS2 is 0x8e), VT220. + This affects next character only. + +ESC O + Single Shift Select of G3 Character Set (SS3 is 0x8f), VT220. + This affects next character only. + +ESC P + Device Control String (DCS is 0x90). + +ESC V + Start of Guarded Area (SPA is 0x96). + +ESC W + End of Guarded Area (EPA is 0x97). + +ESC X + Start of String (SOS is 0x98). + +ESC Z + Return Terminal ID (DECID is 0x9a). Obsolete form of CSI c (DA). + +ESC [ + Control Sequence Introducer (CSI is 0x9b). + +ESC \ + String Terminator (ST is 0x9c). + +ESC ] + Operating System Command (OSC is 0x9d). + +ESC ^ + Privacy Message (PM is 0x9e). + +ESC _ + Application Program Command (APC is 0x9f). These control characters are used in the vtXXX emulation. + +VT100-related terminals + +In this document, "VT100" refers not only to VT100/VT102, but also to +the succession of upward-compatible terminals produced by DEC (Digital +Equipment Corporation) from the mid-1970s for about twenty years. For +brevity, the document refers to the related models: + "VT200" as VT220/VT240, + "VT300" as VT320/VT340, + "VT400" as VT420, and + "VT500" as VT510/VT520/VT525. + +Most of these control sequences are standard VT102 control sequences, +but there is support for later DEC VT terminals (i.e., VT220, VT320, +VT420, VT510), as well as ECMA-48 and aixterm color controls. The only +VT102 feature not supported is auto-repeat, since the only way X +provides for this will affect all windows. + +There are additional control sequences to provide xterm-dependent +functions, such as the scrollbar or window size. Where the function is +specified by DEC or ECMA-48, the mnemonic assigned to it is given in +parentheses. + +The escape codes to designate and invoke character sets are specified by +ISO 2022 (see that document for a discussion of character sets). + +Many of the features are optional; xterm can be configured and built +without support for them. + + VT100 Mode -Most of these control sequences are standard VT102 control sequences, but there is -support for later DEC VT terminals (i.e., VT220, VT320, VT420), as well as ISO 6429 and -aixterm2 color controls. The only VT102 features not supported is auto-repeat, -since the only way X provides for this will affect all windows. There are additional -control sequences to provide xterm-2dependent functions, such as the scrollbar or -window size. Where the function is specified by DEC or ISO 6429, the code assigned to -it is given in parentheses. The escape codes to designate and invoke character sets are -specified by ISO 2022; see that document for a dis- cussion of character sets. - -** Single-character functions - -BEL Bell (Ctrl-G) - -BS Backspace (Ctrl-H) - -CR Carriage Return (Ctrl-M) - -ENQ Return Terminal Status (Ctrl-E). Default response is an - empty string, but may be overridden by a resource answer- - backString. - -FF Form Feed or New Page (NP) (Ctrl-L) same as LF - -LF Line Feed or New Line (NL) (Ctrl-J) - -SO Shift Out (Ctrl-N) -> Switch to Alternate Character Set: - invokes the G1 character set. - -SP Space. - -TAB Horizontal Tab (HT) (Ctrl-I) - -VT Vertical Tab (Ctrl-K) same as LF - -SI Shift In (Ctrl-O) -> Switch to Standard Character Set: - invokes the G0 character set (the default). - -Controls beginning with ESC (other than those where ESC is part of a 7-bit equivalent -to 8-bit C1 controls), ordered by the final charac- ter(s). - -ESC SP F 7-bit controls (S7C1T). -ESC SP G 8-bit controls (S8C1T). -ESC SP L Set ANSI conformance level 1 (dpANS X3.134.1). -ESC SP M Set ANSI conformance level 2 (dpANS X3.134.1). -ESC SP N Set ANSI conformance level 3 (dpANS X3.134.1). -ESC # 3 DEC double-height line, top half (DECDHL) -ESC # 4 DEC double-height line, bottom half (DECDHL) -ESC # 5 DEC single-width line (DECSWL) -ESC # 6 DEC double-width line (DECDWL) -ESC # 8 DEC Screen Alignment Test (DECALN) -ESC % @ Select default character set, ISO 8859-1 (ISO 2022) -ESC % G Select UTF-8 character set (ISO 2022) -ESC ( C2 Designate G0 Character Set (ISO 2022) -ESC ) C2 Designate G1 Character Set (ISO 2022) -ESC * C2 Designate G2 Character Set (ISO 2022) -ESC + C2 Designate G3 Character Set (ISO 2022) - Final character C2 for designating character sets (0 , A - and B apply to VT100 and up, the remainder to VT220 and - up): - C2 = 0 -> DEC Special Character and Line Drawing Set - C2 = A -> United Kingdom (UK) - C2 = B -> United States (USASCII) - C2 = 4 -> Dutch - C2 = C or 5 -> Finnish - C2 = R -> French - C2 = Q -> French Canadian - C2 = K -> German - C2 = Y -> Italian - C2 = E or 6 -> Norwegian/Danish - C2 = Z -> Spanish - C2 = H or 7 -> Swedish - C2 = = -> Swiss -ESC 7 Save Cursor (DECSC) -ESC 8 Restore Cursor (DECRC) -ESC = Application Keypad (DECPAM) -ESC > Normal Keypad (DECPNM) -ESC F Cursor to lower left corner of screen (if enabled by the - hpLowerleftBugCompat resource). -ESC c Full Reset (RIS) -ESC l Memory Lock (per HP terminals). Locks memory above the - cursor. -ESC m Memory Unlock (per HP terminals) -ESC n Invoke the G2 Character Set as GL (LS2). -ESC o Invoke the G3 Character Set as GL (LS3). -ESC | Invoke the G3 Character Set as GR (LS3R). -ESC } Invoke the G2 Character Set as GR (LS2R). -ESC ~ Invoke the G1 Character Set as GR (LS1R). +Single-character functions + +BEL Bell (BEL is Ctrl-G). + +BS Backspace (BS is Ctrl-H). + +CR Carriage Return (CR is Ctrl-M). + +ENQ Return Terminal Status (ENQ is Ctrl-E). Default response is + an empty string, but may be overridden by a resource + answerbackString. + +FF Form Feed or New Page (NP ). (FF is Ctrl-L). FF is treated + the same as LF . + +LF Line Feed or New Line (NL). (LF is Ctrl-J). + +SI Switch to Standard Character Set (Ctrl-O is Shift In or LS0). + This invokes the G0 character set (the default) as GL. + VT200 and up implement LS0. + +SO Switch to Alternate Character Set (Ctrl-N is Shift Out or + LS1). This invokes the G1 character set as GL. + VT200 and up implement LS1. + +SP Space. + +TAB Horizontal Tab (HTS is Ctrl-I). + +VT Vertical Tab (VT is Ctrl-K). This is treated the same as LF. + + +Controls beginning with ESC + +This excludes controls where ESC is part of a 7-bit equivalent to 8-bit +C1 controls, ordered by the final character(s). + +ESC SP F 7-bit controls (S7C1T), VT220. This tells the terminal to + send C1 control characters as 7-bit sequences, e.g., its + responses to queries. DEC VT200 and up always accept 8-bit + control sequences except when configured for VT100 mode. + +ESC SP G 8-bit controls (S8C1T), VT220. This tells the terminal to + send C1 control characters as 8-bit sequences, e.g., its + responses to queries. DEC VT200 and up always accept 8-bit + control sequences except when configured for VT100 mode. + +ESC SP L Set ANSI conformance level 1, ECMA-43. + +ESC SP M Set ANSI conformance level 2, ECMA-43. + +ESC SP N Set ANSI conformance level 3, ECMA-43. + +ESC # 3 DEC double-height line, top half (DECDHL), VT100. + +ESC # 4 DEC double-height line, bottom half (DECDHL), VT100. + +ESC # 5 DEC single-width line (DECSWL), VT100. + +ESC # 6 DEC double-width line (DECDWL), VT100. + +ESC # 8 DEC Screen Alignment Test (DECALN), VT100. + +ESC % @ Select default character set. That is ISO 8859-1 (ISO 2022). + +ESC % G Select UTF-8 character set, ISO 2022. + +ESC ( C Designate G0 Character Set, VT100, ISO 2022. + Final character C for designating 94-character sets. In this + list, + o 0 , A and B were introduced in the VT100, + o most were introduced in the VT200 series, + o a few were introduced in the VT300 series, and + o a few more were introduced in the VT500 series. + The VT220 character sets, together with a few others (such as + Portuguese) are activated by the National Replacement + Character Set (NRCS) controls. The term "replacement" says + that the character set is formed by replacing some of the + characters in a set (termed the Multinational Character Set) + with more useful ones for a given language. The ASCII and DEC + Supplemental character sets make up the two halves of the + Multinational Character set, initially mapped to GL and GR. + The valid final characters C for this control are: + C = A -> United Kingdom (UK), VT100. + C = B -> United States (USASCII), VT100. + C = C or 5 -> Finnish, VT200. + C = H or 7 -> Swedish, VT200. + C = K -> German, VT200. + C = Q or 9 -> French Canadian, VT200. + C = R or f -> French, VT200. + C = Y -> Italian, VT200. + C = Z -> Spanish, VT200. + C = 4 -> Dutch, VT200. + C = " > -> Greek, VT500. + C = % 2 -> Turkish, VT500. + C = % 6 -> Portuguese, VT300. + C = % = -> Hebrew, VT500. + C = = -> Swiss, VT200. + C = ` , E or 6 -> Norwegian/Danish, VT200. + The final character A is a special case, since the same final + character is used by the VT300-control for the 96-character + British Latin-1. + There are a few other 94-character sets: + C = 0 -> DEC Special Character and Line Drawing Set, VT100. + C = < -> DEC Supplemental, VT200. + C = < -> User Preferred Selection Set, VT300. + C = > -> DEC Technical, VT300. + These are documented as 94-character sets (like USASCII) + without NRCS: + C = " 4 -> DEC Hebrew, VT500. + C = " ? -> DEC Greek, VT500. + C = % 0 -> DEC Turkish, VT500. + C = % 5 -> DEC Supplemental Graphics, VT300. + C = & 4 -> DEC Cyrillic, VT500. + The VT520 reference manual lists a few more, but no + documentation has been found for the mappings: + C = % 3 -> SCS NRCS, VT500. + C = & 5 -> DEC Russian, VT500. + +ESC ) C Designate G1 Character Set, ISO 2022, VT100. + The same character sets apply as for ESC ( C. + +ESC * C Designate G2 Character Set, ISO 2022, VT220. + The same character sets apply as for ESC ( C. + +ESC + C Designate G3 Character Set, ISO 2022, VT220. + The same character sets apply as for ESC ( C. + +ESC - C Designate G1 Character Set, VT300. + These controls apply only to 96-character sets. Unlike the + 94-character sets, these can have different values than ASCII + space and DEL for the mapping of 0x20 and 0x7f. The valid + final characters C for this control are: + C = A -> ISO Latin-1 Supplemental, VT300. + C = B -> ISO Latin-2 Supplemental, VT500. + C = F -> ISO Greek Supplemental, VT500. + C = H -> ISO Hebrew Supplemental, VT500. + C = L -> ISO Latin-Cyrillic, VT500. + C = M -> ISO Latin-5 Supplemental, VT500. + +ESC . C Designate G2 Character Set, VT300. + The same character sets apply as for ESC - C. + +ESC / C Designate G3 Character Set, VT300. + The same character sets apply as for ESC - C. + +ESC 6 Back Index (DECBI), VT420 and up. + +ESC 7 Save Cursor (DECSC), VT100. + +ESC 8 Restore Cursor (DECRC), VT100. + +ESC 9 Forward Index (DECFI), VT420 and up. + +ESC = Application Keypad (DECKPAM). + +ESC > Normal Keypad (DECKPNM), VT100. + +ESC F Cursor to lower left corner of screen. This is enabled by the + hpLowerleftBugCompat resource. + +ESC c Full Reset (RIS), VT100. + +ESC l Memory Lock (per HP terminals). Locks memory above the + cursor. + +ESC m Memory Unlock (per HP terminals). + +ESC n Invoke the G2 Character Set as GL (LS2). + +ESC o Invoke the G3 Character Set as GL (LS3). + +ESC | Invoke the G3 Character Set as GR (LS3R). + +ESC } Invoke the G2 Character Set as GR (LS2R). + +ESC ~ Invoke the G1 Character Set as GR (LS1R), VT100. + + +Application Program-Command functions + +APC Pt ST None. xterm implements no APC functions; Pt is ignored. Pt + need not be printable characters. + + +Device-Control functions + +DCS Ps ; Ps | Pt ST + User-Defined Keys (DECUDK), VT220 and up. + + The first parameter: + Ps = 0 -> Clear all UDK definitions before starting + (default). + Ps = 1 -> Erase Below (default). + + The second parameter: + Ps = 0 <- Lock the keys (default). + Ps = 1 <- Do not lock. + + The third parameter is a ";"-separated list of strings + denoting the key-code separated by a "/" from the hex-encoded + key value. The key codes correspond to the DEC function-key + codes (e.g., F6=17). + +DCS Ps! u Pt ST + Assigning User-Preferred Supplemental Sets (DECAUPSS), VT320, + VT510. XTerm ignores this in UTF-8 mode, and uses the + preferLatin1 resource to choose the default setting. + VT320 provides these: + DCS 0 ! u % 5 ST -> DEC Supplemental Graphic + DCS 1 ! u A ST -> ISO Latin-1 supplemental + VT510 adds these: + DCS 0 ! u " ? ST -> DEC Greek + DCS 0 ! u " 4 ST -> DEC Hebrew + DCS 0 ! u % 0 ST -> DEC Turkish + DCS 0 ! u & 4 ST -> DEC Cyrillic + DCS 1 ! u B ST -> ISO Latin-2 Supplemental + DCS 1 ! u F ST -> ISO Greek Supplemental + DCS 1 ! u H ST -> ISO Hebrew Supplemental + DCS 1 ! u M ST -> ISO Latin-5 Supplemental + DCS 1 ! u L ST -> ISO Latin-Cyrillic + VT520 accepts a few others (undocumented); xterm adds these: + DCS 0 ! u B ST -> United States (USASCII). + DCS 0 ! u 0 ST -> DEC Special Character and Line Drawing + Set. + DCS 0 ! u > ST -> DEC Technical. + +DCS $ q Pt ST + Request Status String (DECRQSS), VT420 and up. + The string following the "q" is one of the following: + m -> SGR + " p -> DECSCL + SP q -> DECSCUSR + " q -> DECSCA + r -> DECSTBM + s -> DECSLRM + t -> DECSLPP + $ | -> DECSCPP + $ } -> DECSASD + $ ~ -> DECSSDT + * x -> DECSACE + * | -> DECSNLS + , | -> DECAC (VT525 only) + , } -> DECATC (VT525 only) + > Pm m -> XTQMODKEYS (xterm) + xterm responds with DCS 1 $ r Pt ST for valid requests, + replacing the Pt with the corresponding CSI string, or DCS 0 $ + r ST for invalid requests. + +DCS Ps $ t Pt ST + Restore presentation status (DECRSPS), VT320 and up. The + control can be converted from a response from DECCIR or + DECTABSR by changing the first "u" to a "t" + Ps = 1 -> DECCIR + Ps = 2 -> DECTABSR + +DCS + Q Pt ST + Request resource values (XTGETXRES), xterm. The string + following the "Q" is a list of names encoded in hexadecimal (2 + digits per character) separated by ; which correspond to xterm + resource names. + + xterm responds with + DCS 1 + R Pt ST for valid requests, adding to Pt an = , and + the value of the corresponding xterm resource, or + DCS 0 + R Pt ST for invalid requests. + The strings are encoded in hexadecimal (2 digits per + character). + + Only boolean, numeric and string resources for the VT100 + widget are supported by this query. XTerm evaluates resources + at startup time. Several of xterm's state variables use + resources to determine their initial value. Because the + resource variable may not reflect the current state, xterm + provides control sequences for querying the state directly: + + o XTQALLOWED + o XTQMODKEYS + + +DCS + p Pt ST + Set Termcap/Terminfo Data (XTSETTCAP), xterm. The string + following the "p" is encoded in hexadecimal. After decoding + it, xterm will use the name to retrieve data from the terminal + database. If successful, that overrides the termName resource + when handling the "tcap" keyboard configuration's function- + and special-keys, as well as by the Request Termcap/Terminfo + String control. + + +DCS + q Pt ST + Request Termcap/Terminfo String (XTGETTCAP), xterm. The + string following the "q" is a list of names encoded in + hexadecimal (2 digits per character) separated by ; which + correspond to termcap or terminfo key names. + A few special features are also recognized, which are not key + names: + + o Co for termcap colors (or colors for terminfo colors), and + + o TN for termcap name (or name for terminfo name). + + o RGB for the ncurses direct-color extension. + Only a terminfo name is provided, since termcap + applications cannot use this information. + + xterm responds with + DCS 1 + r Pt ST for valid requests, adding to Pt an = , and + the value of the corresponding string that xterm would send, + or + DCS 0 + r ST for invalid requests. + The strings are encoded in hexadecimal (2 digits per + character). If more than one name is given, xterm replies + with each name/value pair in the same response. An invalid + name (one not found in xterm's tables) ends processing of the + list of names. + + +Functions using CSI , ordered by the final character(s) + +CSI Ps @ Insert Ps (Blank) Character(s) (default = 1) (ICH). + +CSI Ps SP @ + Shift left Ps columns(s) (default = 1) (SL), ECMA-48. + +CSI Ps A Cursor Up Ps Times (default = 1) (CUU). + +CSI Ps SP A + Shift right Ps columns(s) (default = 1) (SR), ECMA-48. + +CSI Ps B Cursor Down Ps Times (default = 1) (CUD). + +CSI Ps C Cursor Forward Ps Times (default = 1) (CUF). + +CSI Ps D Cursor Backward Ps Times (default = 1) (CUB). + +CSI Ps E Cursor Next Line Ps Times (default = 1) (CNL). + +CSI Ps F Cursor Preceding Line Ps Times (default = 1) (CPL). + +CSI Ps G Cursor Character Absolute [column] (default = [row,1]) (CHA). + +CSI Ps ; Ps H + Cursor Position [row;column] (default = [1,1]) (CUP). + +CSI Ps I Cursor Forward Tabulation Ps tab stops (default = 1) (CHT). + +CSI Ps J Erase in Display (ED), VT100. + Ps = 0 -> Erase Below (default). + Ps = 1 -> Erase Above. + Ps = 2 -> Erase All. + Ps = 3 -> Erase Saved Lines, xterm. + +CSI ? Ps J + Erase in Display (DECSED), VT220. + Ps = 0 -> Selective Erase Below (default). + Ps = 1 -> Selective Erase Above. + Ps = 2 -> Selective Erase All. + Ps = 3 -> Selective Erase Saved Lines, xterm. + +CSI Ps K Erase in Line (EL), VT100. + Ps = 0 -> Erase to Right (default). + Ps = 1 -> Erase to Left. + Ps = 2 -> Erase All. + +CSI ? Ps K + Erase in Line (DECSEL), VT220. + Ps = 0 -> Selective Erase to Right (default). + Ps = 1 -> Selective Erase to Left. + Ps = 2 -> Selective Erase All. + +CSI Ps L Insert Ps Line(s) (default = 1) (IL). + +CSI Ps M Delete Ps Line(s) (default = 1) (DL). + +CSI Ps P Delete Ps Character(s) (default = 1) (DCH). + +CSI # P +CSI Pm # P + Push current dynamic- and ANSI-palette colors onto stack + (XTPUSHCOLORS), xterm. Parameters (integers in the range 1 + through 10, since the default 0 will push) may be used to + store the palette into the stack without pushing. + +CSI # Q +CSI Pm # Q + Pop stack to set dynamic- and ANSI-palette colors + (XTPOPCOLORS), xterm. Parameters (integers in the range 1 + through 10, since the default 0 will pop) may be used to + restore the palette from the stack without popping. + +CSI # R Report the current entry on the palette stack, and the number + of palettes stored on the stack, using the same form as + XTPOPCOLOR (default = 0) (XTREPORTCOLORS), xterm. + +CSI Ps S Scroll up Ps lines (default = 1) (SU), VT420, ECMA-48. + +CSI ? Pi ; Pa ; Pv S + Set or request graphics attribute (XTSMGRAPHICS), xterm. If + configured to support either Sixel Graphics or ReGIS Graphics, + xterm accepts a three-parameter control sequence, where Pi, Pa + and Pv are the item, action and value: + + Pi = 1 -> item is number of color registers. + Pi = 2 -> item is Sixel graphics geometry (in pixels). + Pi = 3 -> item is ReGIS graphics geometry (in pixels). + + Pa = 1 -> read attribute. + Pa = 2 -> reset to default. + Pa = 3 -> set to value in Pv. + Pa = 4 -> read the maximum allowed value. + + Pv is ignored by xterm except when setting (Pa == 3 ). + Pv = n <- A single integer is used for color registers. + Pv = width ; height <- Two integers for graphics geometry. + + xterm replies with a control sequence of the same form: + + CSI ? Pi ; Ps ; Pv S + + where Ps is the status: + Ps = 0 <- success. + Ps = 1 <- error in Pi. + Ps = 2 <- error in Pa. + Ps = 3 <- failure. + + On success, Pv represents the value read or set. + + Notes: + o The current implementation allows reading the graphics + sizes, but disallows modifying those sizes because that is + done once, using resource-values. + o Graphics geometry is not necessarily the same as "window + size" (see the XTWINOPS window manipulation extensions). + XTerm limits the maximum graphics geometry according to + the maxGraphicSize resource. + The maxGraphicSize resource can be either an explicit + heightxwidth (default: 1000x1000 as of version 328) or the + word "auto" (telling XTerm to use limits the decGraphicsID + or decTerminalID resource to determine the limits). + o XTerm uses the minimum of the window size and the graphic + size to obtain the maximum geometry. + o While resizing a window will always change the current + graphics geometry, the reverse is not true. Setting + graphics geometry does not affect the window size. + o If xterm is able to support graphics (compile-time), but + is not configured (runtime) for graphics, these responses + will indicate a failure. Other implementations which do + not use the maximum graphics dimensions but are configured + for graphics should report zeroes for the maximum geometry + rather than a failure. + +CSI Ps T Scroll down Ps lines (default = 1) (SD), VT420. + +CSI Ps ; Ps ; Ps ; Ps ; Ps T + Initiate highlight mouse tracking (XTHIMOUSE), xterm. + Parameters are [func;startx;starty;firstrow;lastrow]. See the + section Mouse Tracking. + +CSI > Pm T + Reset title mode features to default value (XTRMTITLE), xterm. + Normally, "reset" disables the feature. It is possible to + disable the ability to reset features by compiling a different + default for the title modes into xterm. + + Ps = 0 -> Do not set window/icon labels using hexadecimal. + Ps = 1 -> Do not query window/icon labels using + hexadecimal. + Ps = 2 -> Do not set window/icon labels using UTF-8. + Ps = 3 -> Do not query window/icon labels using UTF-8. + + (See discussion of Title Modes). + +CSI ? 5 W Reset tab stops to start with column 9, every 8 columns + (DECST8C), VT510. + +CSI Ps X Erase Ps Character(s) (default = 1) (ECH). + +CSI Ps Z Cursor Backward Tabulation Ps tab stops (default = 1) (CBT). + +CSI Ps ^ Scroll down Ps lines (default = 1) (SD), ECMA-48. + This was a publication error in the original ECMA-48 5th + edition (1991) corrected in 2003. + +CSI Ps ` Character Position Absolute [column] (default = [row,1]) + (HPA). + +CSI Ps a Character Position Relative [columns] (default = [row,col+1]) + (HPR). + +CSI Ps b Repeat the preceding graphic character Ps times (REP). + +CSI Ps c Send Device Attributes (Primary DA). + Ps = 0 or omitted -> request attributes from terminal. The + response depends on the decTerminalID resource setting. + -> CSI ? 1 ; 2 c ("VT100 with Advanced Video Option") + -> CSI ? 1 ; 0 c ("VT101 with No Options") + -> CSI ? 4 ; 6 c ("VT132 with Advanced Video and Graphics") + -> CSI ? 6 c ("VT102") + -> CSI ? 7 c ("VT131") + -> CSI ? 1 2 ; Ps c ("VT125") + -> CSI ? 6 2 ; Ps c ("VT220") + -> CSI ? 6 3 ; Ps c ("VT320") + -> CSI ? 6 4 ; Ps c ("VT420") + -> CSI ? 6 5 ; Ps c ("VT510" to ("VT525") + + The VT100-style response parameters do not mean anything by + themselves. VT220 (and higher) parameters do, telling the + host what features the terminal supports: + Ps = 1 -> 132-columns. + Ps = 2 -> Printer. + Ps = 3 -> ReGIS graphics. + Ps = 4 -> Sixel graphics. + Ps = 6 -> Selective erase. + Ps = 8 -> User-defined keys. + Ps = 9 -> National Replacement Character sets. + Ps = 1 5 -> Technical characters. + Ps = 1 6 -> Locator port. + Ps = 1 7 -> Terminal state interrogation. + Ps = 1 8 -> User windows. + Ps = 2 1 -> Horizontal scrolling. + Ps = 2 2 -> ANSI color, e.g., VT525. + Ps = 2 8 -> Rectangular editing. + Ps = 2 9 -> ANSI text locator (i.e., DEC Locator mode). + + XTerm supports part of the User windows feature, providing a + single page (which corresponds to its visible window). Rather + than resizing the font to change the number of lines/columns + in a fixed-size display, xterm uses the window extension + controls (DECSNLS, DECSCPP, DECSLPP) to adjust its visible + window's size. The "cursor coupling" controls (DECHCCM, + DECPCCM, DECVCCM) are ignored. + +CSI = Ps c + Send Device Attributes (Tertiary DA). + Ps = 0 -> report Terminal Unit ID (default), VT400. XTerm + uses zeros for the site code and serial number in its DECRPTUI + response. + +CSI > Ps c + Send Device Attributes (Secondary DA). + Ps = 0 or omitted -> request the terminal's identification + code. The response depends on the decTerminalID resource + setting. It should apply only to VT220 and up, but xterm + extends this to VT100. + -> CSI > Pp ; Pv ; Pc c + where Pp denotes the terminal type + Pp = 0 -> "VT100". + Pp = 1 -> "VT220". + Pp = 2 -> "VT240" or "VT241". + Pp = 1 8 -> "VT330". + Pp = 1 9 -> "VT340". + Pp = 2 4 -> "VT320". + Pp = 3 2 -> "VT382". + Pp = 4 1 -> "VT420". + Pp = 6 1 -> "VT510". + Pp = 6 4 -> "VT520". + Pp = 6 5 -> "VT525". + + and Pv is the firmware version (for xterm, this was originally + the XFree86 patch number, starting with 95). In a DEC + terminal, Pc indicates the ROM cartridge registration number + and is always zero. + +CSI Ps d Line Position Absolute [row] (default = [1,column]) (VPA). + +CSI Ps e Line Position Relative [rows] (default = [row+1,column]) + (VPR). + +CSI Ps ; Ps f + Horizontal and Vertical Position [row;column] (default = + [1,1]) (HVP). + +CSI Ps g Tab Clear (TBC). ECMA-48 defines additional codes, but the + VT100 user manual notes that it ignores other codes. DEC's + later terminals (and xterm) do the same, for compatibility. + Ps = 0 -> Clear Current Column (default). + Ps = 3 -> Clear All. + +CSI Pm h Set Mode (SM). + Ps = 2 -> Keyboard Action Mode (KAM). + Ps = 4 -> Insert Mode (IRM). + Ps = 1 2 -> Send/receive (SRM). + Ps = 2 0 -> Automatic Newline (LNM). + +CSI ? Pm h + DEC Private Mode Set (DECSET). + Ps = 1 -> Application Cursor Keys (DECCKM), VT100. + Ps = 2 -> Designate USASCII for character sets G0-G3 + (DECANM), VT100, and set VT100 mode. + Ps = 3 -> 132 Column Mode (DECCOLM), VT100. + Ps = 4 -> Smooth (Slow) Scroll (DECSCLM), VT100. + Ps = 5 -> Reverse Video (DECSCNM), VT100. + Ps = 6 -> Origin Mode (DECOM), VT100. + Ps = 7 -> Auto-Wrap Mode (DECAWM), VT100. + Ps = 8 -> Auto-Repeat Keys (DECARM), VT100. + Ps = 9 -> Send Mouse X & Y on button press. See the + section Mouse Tracking. This is the X10 xterm mouse protocol. + Ps = 1 0 -> Show toolbar (rxvt). + Ps = 1 2 -> Start blinking cursor (AT&T 610). + Ps = 1 3 -> Start blinking cursor (set only via resource or + menu). + Ps = 1 4 -> Enable XOR of blinking cursor control sequence + and menu. + Ps = 1 8 -> Print Form Feed (DECPFF), VT220. + Ps = 1 9 -> Set print extent to full screen (DECPEX), + VT220. + Ps = 2 5 -> Show cursor (DECTCEM), VT220. + Ps = 3 0 -> Show scrollbar (rxvt). + Ps = 3 5 -> Enable font-shifting functions (rxvt). + Ps = 3 8 -> Enter Tektronix mode (DECTEK), VT240, xterm. + Ps = 4 0 -> Allow 80 -> 132 mode, xterm. + Ps = 4 1 -> more(1) fix (see curses resource). + Ps = 4 2 -> Enable National Replacement Character sets + (DECNRCM), VT220. + Ps = 4 3 -> Enable Graphic Expanded Print Mode (DECGEPM), + VT340. + Ps = 4 4 -> Turn on margin bell, xterm. + Ps = 4 4 -> Enable Graphic Print Color Mode (DECGPCM), + VT340. + Ps = 4 5 -> Reverse-wraparound mode (XTREVWRAP), xterm. + Ps = 4 5 -> Enable Graphic Print Color Syntax (DECGPCS), + VT340. + Ps = 4 6 -> Start logging (XTLOGGING), xterm. This is + normally disabled by a compile-time option. + Ps = 4 6 -> Graphic Print Background Mode, VT340. + Ps = 4 7 -> Use Alternate Screen Buffer, xterm. This may + be disabled by the titeInhibit resource. + Ps = 4 7 -> Enable Graphic Rotated Print Mode (DECGRPM), + VT340. + Ps = 6 6 -> Application keypad mode (DECNKM), VT320. + Ps = 6 7 -> Backarrow key sends backspace (DECBKM), VT340, + VT420. This sets the backarrowKey resource to "true". + Ps = 6 9 -> Enable left and right margin mode (DECLRMM), + VT420 and up. + Ps = 8 0 -> Enable Sixel Display Mode (DECSDM), VT330, + VT340, VT382. + Ps = 9 5 -> Do not clear screen when DECCOLM is set/reset + (DECNCSM), VT510 and up. + Ps = 1 0 0 0 -> Send Mouse X & Y on button press and + release. See the section Mouse Tracking. This is the X11 + xterm mouse protocol. + Ps = 1 0 0 1 -> Use Hilite Mouse Tracking, xterm. + Ps = 1 0 0 2 -> Use Cell Motion Mouse Tracking, xterm. See + the section Button-event tracking. + Ps = 1 0 0 3 -> Use All Motion Mouse Tracking, xterm. See + the section Any-event tracking. + Ps = 1 0 0 4 -> Send FocusIn/FocusOut events, xterm. + Ps = 1 0 0 5 -> Enable UTF-8 Mouse Mode, xterm. + Ps = 1 0 0 6 -> Enable SGR Mouse Mode, xterm. + Ps = 1 0 0 7 -> Enable Alternate Scroll Mode, xterm. This + corresponds to the alternateScroll resource. + Ps = 1 0 1 0 -> Scroll to bottom on tty output (rxvt). + This sets the scrollTtyOutput resource to "true". + Ps = 1 0 1 1 -> Scroll to bottom on key press (rxvt). This + sets the scrollKey resource to "true". + Ps = 1 0 1 4 -> Enable fastScroll resource, xterm. + Ps = 1 0 1 5 -> Enable urxvt Mouse Mode. + Ps = 1 0 1 6 -> Enable SGR Mouse PixelMode, xterm. + Ps = 1 0 3 4 -> Interpret "meta" key, xterm. This sets the + eighth bit of keyboard input (and enables the eightBitInput + resource). + Ps = 1 0 3 5 -> Enable special modifiers for Alt and + NumLock keys, xterm. This enables the numLock resource. + Ps = 1 0 3 6 -> Send ESC when Meta modifies a key, xterm. + This enables the metaSendsEscape resource. + Ps = 1 0 3 7 -> Send DEL from the editing-keypad Delete + key, xterm. + Ps = 1 0 3 9 -> Send ESC when Alt modifies a key, xterm. + This enables the altSendsEscape resource, xterm. + Ps = 1 0 4 0 -> Keep selection even if not highlighted, + xterm. This enables the keepSelection resource. + Ps = 1 0 4 1 -> Use the CLIPBOARD selection, xterm. This + enables the selectToClipboard resource. + Ps = 1 0 4 2 -> Enable Urgency window manager hint when + Control-G is received, xterm. This enables the bellIsUrgent + resource. + Ps = 1 0 4 3 -> Enable raising of the window when Control-G + is received, xterm. This enables the popOnBell resource. + Ps = 1 0 4 4 -> Reuse the most recent data copied to + CLIPBOARD, xterm. This enables the keepClipboard resource. + Ps = 1 0 4 5 -> Extended Reverse-wraparound mode + (XTREVWRAP2), xterm. + Ps = 1 0 4 6 -> Enable switching to/from Alternate Screen + Buffer, xterm. This works for terminfo-based systems, + updating the titeInhibit resource. + Ps = 1 0 4 7 -> Use Alternate Screen Buffer, xterm. This + may be disabled by the titeInhibit resource. + Ps = 1 0 4 8 -> Save cursor as in DECSC, xterm. This may + be disabled by the titeInhibit resource. + Ps = 1 0 4 9 -> Save cursor as in DECSC, xterm. After + saving the cursor, switch to the Alternate Screen Buffer, + clearing it first. This may be disabled by the titeInhibit + resource. This control combines the effects of the 1 0 4 7 + and 1 0 4 8 modes. Use this with terminfo-based applications + rather than the 4 7 mode. + Ps = 1 0 5 0 -> Set terminfo/termcap function-key mode, + xterm. + Ps = 1 0 5 1 -> Set Sun function-key mode, xterm. + Ps = 1 0 5 2 -> Set HP function-key mode, xterm. + Ps = 1 0 5 3 -> Set SCO function-key mode, xterm. + Ps = 1 0 6 0 -> Set legacy keyboard emulation, i.e, X11R6, + xterm. + Ps = 1 0 6 1 -> Set VT220 keyboard emulation, xterm. + Ps = 2 0 0 1 -> Enable readline mouse button-1, xterm. + Ps = 2 0 0 2 -> Enable readline mouse button-2, xterm. + Ps = 2 0 0 3 -> Enable readline mouse button-3, xterm. + Ps = 2 0 0 4 -> Set bracketed paste mode, xterm. + Ps = 2 0 0 5 -> Enable readline character-quoting, xterm. + Ps = 2 0 0 6 -> Enable readline newline pasting, xterm. + +CSI Ps i Media Copy (MC). + Ps = 0 -> Print screen (default). + Ps = 4 -> Turn off printer controller mode. + Ps = 5 -> Turn on printer controller mode. + Ps = 1 0 -> HTML screen dump, xterm. + Ps = 1 1 -> SVG screen dump, xterm. + +CSI ? Ps i + Media Copy (MC), DEC-specific. + Ps = 1 -> Print line containing cursor. + Ps = 4 -> Turn off autoprint mode. + Ps = 5 -> Turn on autoprint mode. + Ps = 1 0 -> Print composed display, ignores DECPEX. + Ps = 1 1 -> Print all pages. + +CSI Pm l Reset Mode (RM). + Ps = 2 -> Keyboard Action Mode (KAM). + Ps = 4 -> Replace Mode (IRM). + Ps = 1 2 -> Send/receive (SRM). + Ps = 2 0 -> Normal Linefeed (LNM). + +CSI ? Pm l + DEC Private Mode Reset (DECRST). + Ps = 1 -> Normal Cursor Keys (DECCKM), VT100. + Ps = 2 -> Designate VT52 mode (DECANM), VT100. + Ps = 3 -> 80 Column Mode (DECCOLM), VT100. + Ps = 4 -> Jump (Fast) Scroll (DECSCLM), VT100. + Ps = 5 -> Normal Video (DECSCNM), VT100. + Ps = 6 -> Normal Cursor Mode (DECOM), VT100. + Ps = 7 -> No Auto-Wrap Mode (DECAWM), VT100. + Ps = 8 -> No Auto-Repeat Keys (DECARM), VT100. + Ps = 9 -> Don't send Mouse X & Y on button press, xterm. + Ps = 1 0 -> Hide toolbar (rxvt). + Ps = 1 2 -> Stop blinking cursor (AT&T 610). + Ps = 1 3 -> Disable blinking cursor (reset only via + resource or menu). + Ps = 1 4 -> Disable XOR of blinking cursor control sequence + and menu. + Ps = 1 8 -> Don't Print Form Feed (DECPFF), VT220. + Ps = 1 9 -> Limit print to scrolling region (DECPEX), + VT220. + Ps = 2 5 -> Hide cursor (DECTCEM), VT220. + Ps = 3 0 -> Don't show scrollbar (rxvt). + Ps = 3 5 -> Disable font-shifting functions (rxvt). + Ps = 4 0 -> Disallow 80 -> 132 mode, xterm. + Ps = 4 1 -> No more(1) fix (see curses resource). + Ps = 4 2 -> Disable National Replacement Character sets + (DECNRCM), VT220. + Ps = 4 3 -> Disable Graphic Expanded Print Mode (DECGEPM), + VT340. + Ps = 4 4 -> Turn off margin bell, xterm. + Ps = 4 4 -> Disable Graphic Print Color Mode (DECGPCM), + VT340. + Ps = 4 5 -> No Reverse-wraparound mode (XTREVWRAP), xterm. + Ps = 4 5 -> Disable Graphic Print Color Syntax (DECGPCS), + VT340. + Ps = 4 6 -> Stop logging (XTLOGGING), xterm. This is + normally disabled by a compile-time option. + Ps = 4 7 -> Use Normal Screen Buffer, xterm. + Ps = 4 7 -> Disable Graphic Rotated Print Mode (DECGRPM), + VT340. + Ps = 6 6 -> Numeric keypad mode (DECNKM), VT320. + Ps = 6 7 -> Backarrow key sends delete (DECBKM), VT340, + VT420. This sets the backarrowKey resource to "false". + Ps = 6 9 -> Disable left and right margin mode (DECLRMM), + VT420 and up. + Ps = 8 0 -> Disable Sixel Display Mode (DECSDM), VT330, + VT340, VT382. Turns on "Sixel Scrolling". See the section + Sixel Graphics and mode 8 4 5 2 . + Ps = 9 5 -> Clear screen when DECCOLM is set/reset + (DECNCSM), VT510 and up. + Ps = 1 0 0 0 -> Don't send Mouse X & Y on button press and + release. See the section Mouse Tracking. + Ps = 1 0 0 1 -> Don't use Hilite Mouse Tracking, xterm. + Ps = 1 0 0 2 -> Don't use Cell Motion Mouse Tracking, + xterm. See the section Button-event tracking. + Ps = 1 0 0 3 -> Don't use All Motion Mouse Tracking, xterm. + See the section Any-event tracking. + Ps = 1 0 0 4 -> Don't send FocusIn/FocusOut events, xterm. + Ps = 1 0 0 5 -> Disable UTF-8 Mouse Mode, xterm. + Ps = 1 0 0 6 -> Disable SGR Mouse Mode, xterm. + Ps = 1 0 0 7 -> Disable Alternate Scroll Mode, xterm. This + corresponds to the alternateScroll resource. + Ps = 1 0 1 0 -> Don't scroll to bottom on tty output + (rxvt). This sets the scrollTtyOutput resource to "false". + Ps = 1 0 1 1 -> Don't scroll to bottom on key press (rxvt). + This sets the scrollKey resource to "false". + Ps = 1 0 1 4 -> Disable fastScroll resource, xterm. + Ps = 1 0 1 5 -> Disable urxvt Mouse Mode. + Ps = 1 0 1 6 -> Disable SGR Mouse Pixel-Mode, xterm. + Ps = 1 0 3 4 -> Don't interpret "meta" key, xterm. This + disables the eightBitInput resource. + Ps = 1 0 3 5 -> Disable special modifiers for Alt and + NumLock keys, xterm. This disables the numLock resource. + Ps = 1 0 3 6 -> Don't send ESC when Meta modifies a key, + xterm. This disables the metaSendsEscape resource. + Ps = 1 0 3 7 -> Send VT220 Remove from the editing-keypad + Delete key, xterm. + Ps = 1 0 3 9 -> Don't send ESC when Alt modifies a key, + xterm. This disables the altSendsEscape resource. + Ps = 1 0 4 0 -> Do not keep selection when not highlighted, + xterm. This disables the keepSelection resource. + Ps = 1 0 4 1 -> Use the PRIMARY selection, xterm. This + disables the selectToClipboard resource. + Ps = 1 0 4 2 -> Disable Urgency window manager hint when + Control-G is received, xterm. This disables the bellIsUrgent + resource. + Ps = 1 0 4 3 -> Disable raising of the window when Control- + G is received, xterm. This disables the popOnBell resource. + Ps = 1 0 4 5 -> No Extended Reverse-wraparound mode + (XTREVWRAP2), xterm. + Ps = 1 0 4 6 -> Disable switching to/from Alternate Screen + Buffer, xterm. This works for terminfo-based systems, + updating the titeInhibit resource. If currently using the + Alternate Screen Buffer, xterm switches to the Normal Screen + Buffer. + Ps = 1 0 4 7 -> Use Normal Screen Buffer, xterm. Clear the + screen first if in the Alternate Screen Buffer. This may be + disabled by the titeInhibit resource. + Ps = 1 0 4 8 -> Restore cursor as in DECRC, xterm. This + may be disabled by the titeInhibit resource. + Ps = 1 0 4 9 -> Use Normal Screen Buffer and restore cursor + as in DECRC, xterm. This may be disabled by the titeInhibit + resource. This combines the effects of the 1 0 4 7 and 1 0 4 + 8 modes. Use this with terminfo-based applications rather + than the 4 7 mode. + Ps = 1 0 5 0 -> Reset terminfo/termcap function-key mode, + xterm. + Ps = 1 0 5 1 -> Reset Sun function-key mode, xterm. + Ps = 1 0 5 2 -> Reset HP function-key mode, xterm. + Ps = 1 0 5 3 -> Reset SCO function-key mode, xterm. + Ps = 1 0 6 0 -> Reset legacy keyboard emulation, i.e, + X11R6, xterm. + Ps = 1 0 6 1 -> Reset keyboard emulation to Sun/PC style, + xterm. + Ps = 2 0 0 1 -> Disable readline mouse button-1, xterm. + Ps = 2 0 0 2 -> Disable readline mouse button-2, xterm. + Ps = 2 0 0 3 -> Disable readline mouse button-3, xterm. + Ps = 2 0 0 4 -> Reset bracketed paste mode, xterm. + Ps = 2 0 0 5 -> Disable readline character-quoting, xterm. + Ps = 2 0 0 6 -> Disable readline newline pasting, xterm. + +CSI Pm m Character Attributes (SGR). + Ps = 0 -> Normal (default), VT100. + Ps = 1 -> Bold, VT100. + Ps = 2 -> Faint, decreased intensity, ECMA-48 2nd. + Ps = 3 -> Italicized, ECMA-48 2nd. + Ps = 4 -> Underlined, VT100. + Ps = 5 -> Blink, VT100. + This appears as Bold in X11R6 xterm. + Ps = 7 -> Inverse, VT100. + Ps = 8 -> Invisible, i.e., hidden, ECMA-48 2nd, VT300. + Ps = 9 -> Crossed-out characters, ECMA-48 3rd. + Ps = 2 1 -> Doubly-underlined, ECMA-48 3rd. + Ps = 2 2 -> Normal (neither bold nor faint), ECMA-48 3rd. + Ps = 2 3 -> Not italicized, ECMA-48 3rd. + Ps = 2 4 -> Not underlined, ECMA-48 3rd. + Ps = 2 5 -> Steady (not blinking), ECMA-48 3rd. + Ps = 2 7 -> Positive (not inverse), ECMA-48 3rd. + Ps = 2 8 -> Visible, i.e., not hidden, ECMA-48 3rd, VT300. + Ps = 2 9 -> Not crossed-out, ECMA-48 3rd. + Ps = 3 0 -> Set foreground color to Black. + Ps = 3 1 -> Set foreground color to Red. + Ps = 3 2 -> Set foreground color to Green. + Ps = 3 3 -> Set foreground color to Yellow. + Ps = 3 4 -> Set foreground color to Blue. + Ps = 3 5 -> Set foreground color to Magenta. + Ps = 3 6 -> Set foreground color to Cyan. + Ps = 3 7 -> Set foreground color to White. + Ps = 3 9 -> Set foreground color to default, ECMA-48 3rd. + Ps = 4 0 -> Set background color to Black. + Ps = 4 1 -> Set background color to Red. + Ps = 4 2 -> Set background color to Green. + Ps = 4 3 -> Set background color to Yellow. + Ps = 4 4 -> Set background color to Blue. + Ps = 4 5 -> Set background color to Magenta. + Ps = 4 6 -> Set background color to Cyan. + Ps = 4 7 -> Set background color to White. + Ps = 4 9 -> Set background color to default, ECMA-48 3rd. + + Some of the above note the edition of ECMA-48 which first + describes a feature. In its successive editions from 1979 to + 1991 (2nd 1979, 3rd 1984, 4th 1986, and 5th 1991), ECMA-48 + listed codes through 6 5 (skipping several toward the end of + the range). Most of the ECMA-48 codes not implemented in + xterm were never implemented in a hardware terminal. Several + (such as 3 9 and 4 9 ) are either noted in ECMA-48 as + implementation defined, or described in vague terms. + + The successive editions of ECMA-48 give little attention to + changes from one edition to the next, except to comment on + features which have become obsolete. ECMA-48 1st (1976) is + unavailable; there is no reliable source of information which + states whether "ANSI" color was defined in that edition, or + later (1979). The VT100 (1978) implemented the most commonly + used non-color video attributes which are given in the 2nd + edition. + + While 8-color support is described in ECMA-48 2nd edition, the + VT500 series (introduced in 1993) were the first DEC terminals + implementing "ANSI" color. The DEC terminal's use of color is + known to differ from xterm; useful documentation on this + series became available too late to influence xterm. + + If 16-color support is compiled, the following aixterm + controls apply. Assume that xterm's resources are set so that + the ISO color codes are the first 8 of a set of 16. Then the + aixterm colors are the bright versions of the ISO colors: + + Ps = 9 0 -> Set foreground color to Black. + Ps = 9 1 -> Set foreground color to Red. + Ps = 9 2 -> Set foreground color to Green. + Ps = 9 3 -> Set foreground color to Yellow. + Ps = 9 4 -> Set foreground color to Blue. + Ps = 9 5 -> Set foreground color to Magenta. + Ps = 9 6 -> Set foreground color to Cyan. + Ps = 9 7 -> Set foreground color to White. + Ps = 1 0 0 -> Set background color to Black. + Ps = 1 0 1 -> Set background color to Red. + Ps = 1 0 2 -> Set background color to Green. + Ps = 1 0 3 -> Set background color to Yellow. + Ps = 1 0 4 -> Set background color to Blue. + Ps = 1 0 5 -> Set background color to Magenta. + Ps = 1 0 6 -> Set background color to Cyan. + Ps = 1 0 7 -> Set background color to White. + + If xterm is compiled with the 16-color support disabled, it + supports the following, from rxvt: + Ps = 1 0 0 -> Set foreground and background color to + default. + + XTerm maintains a color palette whose entries are identified + by an index beginning with zero. If 88- or 256-color support + is compiled, the following apply: + o All parameters are decimal integers. + o RGB values range from zero (0) to 255. + o The 88- and 256-color support uses subparameters described + in ISO-8613-6 for indexed color. ISO-8613-6 also mentions + direct color, using a similar scheme. xterm supports + that, too. + o xterm allows either colons (standard) or semicolons + (legacy) to separate the subparameters (but after the + first colon, colons must be used). + + The indexed- and direct-color features are summarized in the + FAQ, which explains why semicolon is accepted as a + subparameter delimiter: + + Can I set a color by its number? + + + These ISO-8613-6 controls (marked in ECMA-48 5th edition as + "reserved for future standardization") are supported by xterm: + Ps = 3 8 : 2 : Pi : Pr : Pg : Pb -> Set foreground color + using RGB values. If xterm is not compiled with direct-color + support, it uses the closest match in its palette for the + given RGB Pr/Pg/Pb. The color space identifier Pi is ignored. + Ps = 3 8 : 5 : Ps -> Set foreground color to Ps, using + indexed color. + Ps = 4 8 : 2 : Pi : Pr : Pg : Pb -> Set background color + using RGB values. If xterm is not compiled with direct-color + support, it uses the closest match in its palette for the + given RGB Pr/Pg/Pb. The color space identifier Pi is ignored. + Ps = 4 8 : 5 : Ps -> Set background color to Ps, using + indexed color. + + This variation on ISO-8613-6 is supported for compatibility + with KDE konsole: + Ps = 3 8 ; 2 ; Pr ; Pg ; Pb -> Set foreground color using + RGB values. If xterm is not compiled with direct-color + support, it uses the closest match in its palette for the + given RGB Pr/Pg/Pb. + Ps = 4 8 ; 2 ; Pr ; Pg ; Pb -> Set background color using + RGB values. If xterm is not compiled with direct-color + support, it uses the closest match in its palette for the + given RGB Pr/Pg/Pb. + + In each case, if xterm is compiled with direct-color support, + and the resource directColor is true, then rather than + choosing the closest match, xterm asks the X server to + directly render a given color. + +CSI > Pp ; Pv m +CSI > Pp m + Set/reset key modifier options (XTMODKEYS), xterm. Set or + reset resource-values used by xterm to decide whether to + construct escape sequences holding information about the + modifiers pressed with a given key. + + The first parameter Pp identifies the resource to set/reset. + The second parameter Pv is the value to assign to the + resource. + + If the second parameter is omitted, the resource is reset to + its initial value. Values 3 and 5 are reserved for keypad- + keys and string-keys. + + Pp = 0 -> modifyKeyboard. + Pp = 1 -> modifyCursorKeys. + Pp = 2 -> modifyFunctionKeys. + Pp = 4 -> modifyOtherKeys. + + If no parameters are given, all resources are reset to their + initial values. + +CSI ? Pp m + Query key modifier options (XTQMODKEYS), xterm. + + The parameter Pp identifies the resource to query. + + Pp = 0 -> modifyKeyboard. + Pp = 1 -> modifyCursorKeys. + Pp = 2 -> modifyFunctionKeys. + Pp = 4 -> modifyOtherKeys. + + XTerm's response can be used to restore this state, because it + is formatted as an XTMODKEYS control, i.e., + + CSI > Pp m + + where + + Pp = 0 -> modifyKeyboard. + Pp = 1 -> modifyCursorKeys. + Pp = 2 -> modifyFunctionKeys. + Pp = 4 -> modifyOtherKeys. + +CSI Ps n Device Status Report (DSR). + Ps = 5 -> Status Report. + Result ("OK") is CSI 0 n + Ps = 6 -> Report Cursor Position (CPR) [row;column]. + Result is CSI r ; c R + + Note: it is possible for this sequence to be sent by a + function key. For example, with the default keyboard + configuration the shifted F1 key may send (with shift-, + control-, alt-modifiers) + + CSI 1 ; 2 R , or + CSI 1 ; 5 R , or + CSI 1 ; 6 R , etc. + + The second parameter encodes the modifiers; values range from + 2 to 16. See the section PC-Style Function Keys for the + codes. The modifyFunctionKeys and modifyKeyboard resources + can change the form of the string sent from the modified F1 + key. + +CSI > Ps n + Disable key modifier options, xterm. These modifiers may be + enabled via the CSI > Pm m sequence. This control sequence + corresponds to a resource value of "-1", which cannot be set + with the other sequence. + + The parameter identifies the resource to be disabled: + + Ps = 0 -> modifyKeyboard. + Ps = 1 -> modifyCursorKeys. + Ps = 2 -> modifyFunctionKeys. + Ps = 4 -> modifyOtherKeys. + + If the parameter is omitted, modifyFunctionKeys is disabled. + When modifyFunctionKeys is disabled, xterm uses the modifier + keys to make an extended sequence of function keys rather than + adding a parameter to each function key to denote the + modifiers. + +CSI ? Ps n + Device Status Report (DSR, DEC-specific). + Ps = 6 -> Report Cursor Position (DECXCPR). The response + [row;column] is returned as + CSI ? r ; c R + (assumes the default page, i.e., "1"). + Ps = 1 5 -> Report Printer status. The response is + CSI ? 1 0 n (ready). or + CSI ? 1 1 n (not ready). + Ps = 2 5 -> Report UDK status. The response is + CSI ? 2 0 n (unlocked) + or + CSI ? 2 1 n (locked). + Ps = 2 6 -> Report Keyboard status. The response is + CSI ? 2 7 ; 1 ; 0 ; 0 n (North American). + + The last two parameters apply to VT300 & up (keyboard ready) + and VT400 & up (LK01) respectively. + + Ps = 5 5 -> Report Locator status. The response is CSI ? 5 + 3 n Locator available, if compiled-in, or CSI ? 5 0 n No + Locator, if not. + Ps = 5 6 -> Report Locator type. The response is CSI ? 5 7 + ; 1 n Mouse, if compiled-in, or CSI ? 5 7 ; 0 n Cannot + identify, if not. + Ps = 6 2 -> Report macro space (DECMSR). The response is + CSI Pn * { . + Ps = 6 3 -> Report memory checksum (DECCKSR), VT420 and up. + The response is DCS Pt ! ~ x x x x ST . + Pt is the request id (from an optional parameter to the + request). + The x's are hexadecimal digits 0-9 and A-F. + Ps = 7 5 -> Report data integrity. The response is CSI ? 7 + 0 n (ready, no errors). + Ps = 8 5 -> Report multi-session configuration. The + response is CSI ? 8 3 n (not configured for multiple-session + operation). + +CSI > Ps p + Set resource value pointerMode (XTSMPOINTER), xterm. This is + used by xterm to decide whether to hide the pointer cursor as + the user types. + + Valid values for the parameter: + Ps = 0 -> never hide the pointer. + Ps = 1 -> hide if the mouse tracking mode is not enabled. + Ps = 2 -> always hide the pointer, except when leaving the + window. + Ps = 3 -> always hide the pointer, even if leaving/entering + the window. + + If no parameter is given, xterm uses the default, which is 1 . + +CSI ! p Soft terminal reset (DECSTR), VT220 and up. + +CSI Pl ; Pc " p + Set conformance level (DECSCL), VT220 and up. + + The first parameter selects the conformance level. Valid + values are: + Pl = 6 1 -> level 1, e.g., VT100. + Pl = 6 2 -> level 2, e.g., VT200. + Pl = 6 3 -> level 3, e.g., VT300. + Pl = 6 4 -> level 4, e.g., VT400. + Pl = 6 5 -> level 5, e.g., VT500. + + The second parameter selects the C1 control transmission mode. + This is an optional parameter, ignored in conformance level 1. + Valid values are: + Pc = 0 -> 8-bit controls. + Pc = 1 -> 7-bit controls (DEC factory default). + Pc = 2 -> 8-bit controls. + + The 7-bit and 8-bit control modes can also be set by S7C1T and + S8C1T, but DECSCL is preferred. + +CSI Ps $ p + Request ANSI mode (DECRQM). For VT300 and up, reply DECRPM is + CSI Ps; Pm $ y + where Ps is the mode number as in SM/RM, and Pm is the mode + value: + 0 - not recognized + 1 - set + 2 - reset + 3 - permanently set + 4 - permanently reset + +CSI ? Ps $ p + Request DEC private mode (DECRQM). For VT300 and up, reply + DECRPM is + CSI ? Ps; Pm $ y + where Ps is the mode number as in DECSET/DECSET, Pm is the + mode value as in the ANSI DECRQM. + Two private modes are read-only (i.e., 1 3 and 1 4 ), + provided only for reporting their values using this control + sequence. They correspond to the resources cursorBlink and + cursorBlinkXOR. +CSI # p +CSI Pm # p + Push video attributes onto stack (XTPUSHSGR), xterm. This is + an alias for CSI # { , used to work around language + limitations of C#. + +CSI > Ps q + Ps = 0 -> Report xterm name and version (XTVERSION). + The response is a DSR sequence identifying the version: + DCS > | text ST + +CSI Ps q Load LEDs (DECLL), VT100. + Ps = 0 -> Clear all LEDS (default). + Ps = 1 -> Light Num Lock. + Ps = 2 -> Light Caps Lock. + Ps = 3 -> Light Scroll Lock. + Ps = 2 1 -> Extinguish Num Lock. + Ps = 2 2 -> Extinguish Caps Lock. + Ps = 2 3 -> Extinguish Scroll Lock. + +CSI Ps SP q + Set cursor style (DECSCUSR), VT520. + Ps = 0 -> blinking block. + Ps = 1 -> blinking block (default). + Ps = 2 -> steady block. + Ps = 3 -> blinking underline. + Ps = 4 -> steady underline. + Ps = 5 -> blinking bar, xterm. + Ps = 6 -> steady bar, xterm. + +CSI Ps " q + Select character protection attribute (DECSCA), VT220. Valid + values for the parameter: + Ps = 0 -> DECSED and DECSEL can erase (default). + Ps = 1 -> DECSED and DECSEL cannot erase. + Ps = 2 -> DECSED and DECSEL can erase. + +CSI # q Pop video attributes from stack (XTPOPSGR), xterm. This is an + alias for CSI # } , used to work around language limitations + of C#. + +CSI Ps ; Ps r + Set Scrolling Region [top;bottom] (default = full size of + window) (DECSTBM), VT100. + +CSI ? Pm r + Restore DEC Private Mode Values (XTRESTORE), xterm. The value + of Ps previously saved is restored. Ps values are the same as + for DECSET. + + Like Restore Cursor (DECRC), this uses a one-level cache. + Unlike Restore Cursor, specific settings can be saved and + restored independently. Only those modes listed as parameters + are restored. + +CSI Pt ; Pl ; Pb ; Pr ; Pm $ r + Change Attributes in Rectangular Area (DECCARA), VT400 and up. + Pt ; Pl ; Pb ; Pr denotes the rectangle. + Pm denotes the SGR attributes to change: 0, 1, 4, 5, 7. + +CSI s Save cursor, available only when DECLRMM is disabled (SCOSC, + also ANSI.SYS). + +CSI Pl ; Pr s + Set left and right margins (DECSLRM), VT420 and up. This is + available only when DECLRMM is enabled. + +CSI > Ps s + Set/reset shift-escape options (XTSHIFTESCAPE), xterm. This + corresponds to the shiftEscape resource. + + Valid values for the parameter: + Ps = 0 -> allow shift-key to override mouse protocol. + Ps = 1 -> conditionally allow shift-key as modifier in + mouse protocol. + + These resource values are disallowed in the control sequence: + Ps = 2 -> always allow shift-key as modifier in mouse + protocol. + Ps = 3 -> never allow shift-key as modifier in mouse + protocol. + + If no parameter is given, xterm uses the default, which is 0 . + +CSI ? Pm s + Save DEC Private Mode Values (XTSAVE), xterm. Ps values are + the same as for DECSET. + + Like Save Cursor (DECSC), this uses a one-level cache. Unlike + Save Cursor, specific settings can be saved and restored + independently. Only those modes listed as parameters are + saved. + +CSI Ps ; Ps ; Ps t + Window manipulation (XTWINOPS), dtterm, extended by xterm. + These controls may be disabled using the allowWindowOps + resource. + + xterm uses Extended Window Manager Hints (EWMH) to maximize + the window. Some window managers have incomplete support for + EWMH. For instance, fvwm, flwm and quartz-wm advertise + support for maximizing windows horizontally or vertically, but + in fact equate those to the maximize operation. + + Valid values for the first (and any additional parameters) + are: + Ps = 1 -> De-iconify window. + Ps = 2 -> Iconify window. + Ps = 3 ; x ; y -> Move window to [x, y]. + Ps = 4 ; height ; width -> Resize the xterm window to + given height and width in pixels. Omitted parameters reuse + the current height or width. Zero parameters use the + display's height or width. + Ps = 5 -> Raise the xterm window to the front of the + stacking order. + Ps = 6 -> Lower the xterm window to the bottom of the + stacking order. + Ps = 7 -> Refresh the xterm window. + Ps = 8 ; height ; width -> Resize the text area to given + height and width in characters. Omitted parameters reuse the + current height or width. Zero parameters use the display's + height or width. + Ps = 9 ; 0 -> Restore maximized window. + Ps = 9 ; 1 -> Maximize window (i.e., resize to screen + size). + Ps = 9 ; 2 -> Maximize window vertically. + Ps = 9 ; 3 -> Maximize window horizontally. + Ps = 1 0 ; 0 -> Undo full-screen mode. + Ps = 1 0 ; 1 -> Change to full-screen. + Ps = 1 0 ; 2 -> Toggle full-screen. + Ps = 1 1 -> Report xterm window state. + If the xterm window is non-iconified, it returns CSI 1 t . + If the xterm window is iconified, it returns CSI 2 t . + Ps = 1 3 -> Report xterm window position. + Note: X Toolkit positions can be negative, but the reported + values are unsigned, in the range 0-65535. Negative values + correspond to 32768-65535. + Result is CSI 3 ; x ; y t + Ps = 1 3 ; 2 -> Report xterm text-area position. + Result is CSI 3 ; x ; y t + Ps = 1 4 -> Report xterm text area size in pixels. + Result is CSI 4 ; height ; width t + Ps = 1 4 ; 2 -> Report xterm window size in pixels. + Normally xterm's window is larger than its text area, since it + includes the frame (or decoration) applied by the window + manager, as well as the area used by a scroll-bar. + Result is CSI 4 ; height ; width t + Ps = 1 5 -> Report size of the screen in pixels. + Result is CSI 5 ; height ; width t + Ps = 1 6 -> Report xterm character cell size in pixels. + Result is CSI 6 ; height ; width t + Ps = 1 8 -> Report the size of the text area in characters. + Result is CSI 8 ; height ; width t + Ps = 1 9 -> Report the size of the screen in characters. + Result is CSI 9 ; height ; width t + Ps = 2 0 -> Report xterm window's icon label. + Result is OSC L label ST + Ps = 2 1 -> Report xterm window's title. + Result is OSC l label ST + Ps = 2 2 ; 0 -> Save xterm icon and window title on stack. + Ps = 2 2 ; 1 -> Save xterm icon title on stack. + Ps = 2 2 ; 2 -> Save xterm window title on stack. + Ps = 2 3 ; 0 -> Restore xterm icon and window title from + stack. + Ps = 2 3 ; 1 -> Restore xterm icon title from stack. + Ps = 2 3 ; 2 -> Restore xterm window title from stack. + Ps >= 2 4 -> Resize to Ps lines (DECSLPP), VT340 and VT420. + xterm adapts this by resizing its window. + + XTWINOPS 2 2 (save/push title) and 2 3 (restore/pop title) + accept an optional third parameter for direct access to the + stack. Parameters in the range 1 through 10, may be used to + store the title into the stack or retrieve the title from the + stack without pushing/popping. + +CSI > Pm t + This xterm control sets one or more features of the title + modes (XTSMTITLE), xterm. Each parameter enables a single + feature. + Ps = 0 -> Set window/icon labels using hexadecimal. + Ps = 1 -> Query window/icon labels using hexadecimal. + Ps = 2 -> Set window/icon labels using UTF-8. + Ps = 3 -> Query window/icon labels using UTF-8. (See + discussion of Title Modes) + +CSI Ps SP t + Set warning-bell volume (DECSWBV), VT520. + Ps = 0 or 1 -> off. + Ps = 2 , 3 or 4 -> low. + Ps = 5 , 6 , 7 , or 8 -> high. + +CSI Pt ; Pl ; Pb ; Pr ; Pm $ t + Reverse Attributes in Rectangular Area (DECRARA), VT400 and + up. + Pt ; Pl ; Pb ; Pr denotes the rectangle. + Pm denotes the attributes to reverse, i.e., 1, 4, 5, 7. + +CSI u Restore cursor (SCORC, also ANSI.SYS). + +CSI & u User-Preferred Supplemental Set (DECRQUPSS), VT320, VT510. + Response is DECAUPSS. + +CSI Ps SP u + Set margin-bell volume (DECSMBV), VT520. + Ps = 0 , 5 , 6 , 7 , or 8 -> high. + Ps = 1 -> off. + Ps = 2 , 3 or 4 -> low. + +CSI " v Request Displayed Extent (DECRQDE), VT340, VT420. + Response is + CSI Ph; Pw; Pc; Pr; Pp " v + where + Ph is the number of lines of the current page + Pw is the number of columns of the current page + Pc is the column number at the top-left of the window + Pr is the row number at the top-left of the window + Pp is the current page number + +CSI Pt ; Pl ; Pb ; Pr ; Pp ; Pt ; Pl ; Pp $ v + Copy Rectangular Area (DECCRA), VT400 and up. + Pt ; Pl ; Pb ; Pr denotes the rectangle. + Pp denotes the source page. + Pt ; Pl denotes the target location. + Pp denotes the target page. + +CSI Ps $ w + Request presentation state report (DECRQPSR), VT320 and up. + Ps = 0 -> error. + Ps = 1 -> cursor information report (DECCIR). + Response is + DCS 1 $ u Pt ST + Refer to the VT420 programming manual, which requires six + pages to document the data string Pt, + Ps = 2 -> tab stop report (DECTABSR). + Response is + DCS 2 $ u Pt ST + The data string Pt is a list of the tab-stops, separated by + "/" characters. + +CSI Pt ; Pl ; Pb ; Pr ' w + Enable Filter Rectangle (DECEFR), VT420 and up. + Parameters are [top;left;bottom;right]. + Defines the coordinates of a filter rectangle and activates + it. Anytime the locator is detected outside of the filter + rectangle, an outside rectangle event is generated and the + rectangle is disabled. Filter rectangles are always treated + as "one-shot" events. Any parameters that are omitted default + to the current locator position. If all parameters are + omitted, any locator motion will be reported. DECELR always + cancels any previous rectangle definition. + +CSI Ps x Request Terminal Parameters (DECREQTPARM). + if Ps is a "0" (default) or "1", and xterm is emulating VT100, + the control sequence elicits a response of the same form whose + parameters describe the terminal: + Ps -> the given Ps incremented by 2. + Pn = 1 <- no parity. + Pn = 1 <- eight bits. + Pn = 1 <- 2 8 transmit 38.4k baud. + Pn = 1 <- 2 8 receive 38.4k baud. + Pn = 1 <- clock multiplier. + Pn = 0 <- STP flags. + +CSI Ps * x + Select Attribute Change Extent (DECSACE), VT420 and up. + Ps = 0 -> from start to end position, wrapped. + Ps = 1 -> from start to end position, wrapped. + Ps = 2 -> rectangle (exact). + +CSI Pc ; Pt ; Pl ; Pb ; Pr $ x + Fill Rectangular Area (DECFRA), VT420 and up. + Pc is the character to use. + Pt ; Pl ; Pb ; Pr denotes the rectangle. + +CSI Ps # y + Select checksum extension (XTCHECKSUM), xterm. The bits of Ps + modify the calculation of the checksum returned by DECRQCRA: + 0 -> do not negate the result. + 1 -> do not report the VT100 video attributes. + 2 -> do not omit checksum for blanks. + 3 -> omit checksum for cells not explicitly initialized. + 4 -> do not mask cell value to 8 bits or ignore combining + characters. + +CSI Pi ; Pg ; Pt ; Pl ; Pb ; Pr * y + Request Checksum of Rectangular Area (DECRQCRA), VT420 and up. + Response is + DCS Pi ! ~ x x x x ST + Pi is the request id. + Pg is the page number. + Pt ; Pl ; Pb ; Pr denotes the rectangle. + The x's are hexadecimal digits 0-9 and A-F. + +CSI Ps ; Pu ' z + Enable Locator Reporting (DECELR). + Valid values for the first parameter: + Ps = 0 -> Locator disabled (default). + Ps = 1 -> Locator enabled. + Ps = 2 -> Locator enabled for one report, then disabled. + The second parameter specifies the coordinate unit for locator + reports. + Valid values for the second parameter: + Pu = 0 or omitted -> default to character cells. + Pu = 1 <- device physical pixels. + Pu = 2 <- character cells. + +CSI Pt ; Pl ; Pb ; Pr $ z + Erase Rectangular Area (DECERA), VT400 and up. + Pt ; Pl ; Pb ; Pr denotes the rectangle. + +CSI Pm ' { + Select Locator Events (DECSLE). + Valid values for the first (and any additional parameters) + are: + Ps = 0 -> only respond to explicit host requests (DECRQLP). + This is default. It also cancels any filter rectangle. + Ps = 1 -> report button down transitions. + Ps = 2 -> do not report button down transitions. + Ps = 3 -> report button up transitions. + Ps = 4 -> do not report button up transitions. + +CSI # { +CSI Pm # { + Push video attributes onto stack (XTPUSHSGR), xterm. The + optional parameters correspond to the SGR encoding for video + attributes, except for colors (which do not have a unique SGR + code): + Ps = 1 -> Bold. + Ps = 2 -> Faint. + Ps = 3 -> Italicized. + Ps = 4 -> Underlined. + Ps = 5 -> Blink. + Ps = 7 -> Inverse. + Ps = 8 -> Invisible. + Ps = 9 -> Crossed-out characters. + Ps = 2 1 -> Doubly-underlined. + Ps = 3 0 -> Foreground color. + Ps = 3 1 -> Background color. + + If no parameters are given, all of the video attributes are + saved. The stack is limited to 10 levels. + +CSI Pt ; Pl ; Pb ; Pr $ { + Selective Erase Rectangular Area (DECSERA), VT400 and up. + Pt ; Pl ; Pb ; Pr denotes the rectangle. + +CSI Pt ; Pl ; Pb ; Pr # | + Report selected graphic rendition (XTREPORTSGR), xterm. The + response is an SGR sequence which contains the attributes + which are common to all cells in a rectangle. + Pt ; Pl ; Pb ; Pr denotes the rectangle. + +CSI Ps $ | + Select columns per page (DECSCPP), VT340. + Ps = 0 -> 80 columns, default if Ps omitted. + Ps = 8 0 -> 80 columns. + Ps = 1 3 2 -> 132 columns. + +CSI Ps ' | + Request Locator Position (DECRQLP). + Valid values for the parameter are: + Ps = 0 , 1 or omitted -> transmit a single DECLRP locator + report. + + If Locator Reporting has been enabled by a DECELR, xterm will + respond with a DECLRP Locator Report. This report is also + generated on button up and down events if they have been + enabled with a DECSLE, or when the locator is detected outside + of a filter rectangle, if filter rectangles have been enabled + with a DECEFR. + + <- CSI Pe ; Pb ; Pr ; Pc ; Pp & w + + Parameters are [event;button;row;column;page]. + Valid values for the event: + Pe = 0 <- locator unavailable - no other parameters sent. + Pe = 1 <- request - xterm received a DECRQLP. + Pe = 2 <- left button down. + Pe = 3 <- left button up. + Pe = 4 <- middle button down. + Pe = 5 <- middle button up. + Pe = 6 <- right button down. + Pe = 7 <- right button up. + Pe = 8 <- M4 button down. + Pe = 9 <- M4 button up. + Pe = 1 0 <- locator outside filter rectangle. + The "button" parameter is a bitmask indicating which buttons + are pressed: + Pb = 0 <- no buttons down. + Pb & 1 <- right button down. + Pb & 2 <- middle button down. + Pb & 4 <- left button down. + Pb & 8 <- M4 button down. + The "row" and "column" parameters are the coordinates of the + locator position in the xterm window, encoded as ASCII + decimal. + The "page" parameter is not used by xterm. + +CSI Ps * | + Select number of lines per screen (DECSNLS), VT420 and up. + +CSI # } Pop video attributes from stack (XTPOPSGR), xterm. Popping + restores the video-attributes which were saved using XTPUSHSGR + to their previous state. + +CSI Ps; Pf; Pb, | + Assign Color (DECAC), VT525 only. + Ps selects the color item + Pf is the foreground color index 0..15 + Pb is the background color index 0..15 + Color items: + Ps = 1 -> normal text + Ps = 2 -> window frame + xterm uses the SGR color palette with DECAC color item 1 to + update the VT100 window colors, like OSC 1 0 and 1 1 . + +CSI Ps; Pf; Pb, } + Alternate Text Color (DECATC), VT525 only. This feature + specifies the colors to use when DECSTGLT is selected to 1 or + 2. + Ps selects attribute combinations + Pf is the foreground color index 0..15 + Pb is the background color index 0..15 + Attribute combinations: + Ps = 0 -> normal text + Ps = 1 -> bold + Ps = 2 -> reverse + Ps = 3 -> underline + Ps = 4 -> blink + Ps = 5 -> bold reverse + Ps = 6 -> bold underline + Ps = 7 -> bold blink + Ps = 8 -> reverse underline + Ps = 9 -> reverse blink + Ps = 1 0 -> underline blink + Ps = 1 1 -> bold reverse underline + Ps = 1 2 -> bold reverse blink + Ps = 1 3 -> bold underline blink + Ps = 1 4 -> reverse underline blink + Ps = 1 5 -> bold reverse underline blink + +CSI Ps ' } + Insert Ps Column(s) (default = 1) (DECIC), VT420 and up. + +CSI Ps $ } + Select active status display (DECSASD), VT320 and up. + Ps = 0 -> main (default) + Ps = 1 -> status line + +CSI Ps ' ~ + Delete Ps Column(s) (default = 1) (DECDC), VT420 and up. + +CSI Ps $ ~ + Select status line type (DECSSDT), VT320 and up. + Ps = 0 -> none + Ps = 1 -> indicator (default) + Ps = 2 -> host-writable. + + +Operating System Commands + +OSC Ps ; Pt BEL + +OSC Ps ; Pt ST + Set Text Parameters, xterm. Some control sequences return + information: + o For colors and font, if Pt is a "?", the control sequence + elicits a response which consists of the control sequence + which would set the corresponding value. + o A few of these control sequences began with dtterm (codes + 0 , 1 , and 2 ). Code 3 in dtterm sets the working + directory for the next session. XTerm does that with the + spawn-new-terminal action. + + XTerm accepts either BEL or ST for terminating OSC + sequences, and when returning information, uses the same + terminator used in a query. While the latter is preferred, + the former is supported for legacy applications: + o Although documented in the changes for X.V10R4 (December + 1986), BEL as a string terminator dates from X11R4 + (December 1989). + o Since XFree86-3.1.2Ee (August 1996), xterm has accepted ST + (the documented string terminator in ECMA-48). + + Ps specifies the type of operation to perform: + Ps = 0 -> Change Icon Name and Window Title to Pt. + Ps = 1 -> Change Icon Name to Pt. + Ps = 2 -> Change Window Title to Pt. + Ps = 3 -> Set X property on top-level window. Pt should be + in the form "prop=value", or just "prop" to delete the + property. + Ps = 4 ; c ; spec -> Change Color Number c to the color + specified by spec. + + The spec can be a name or RGB specification as per + XParseColor. Any number of c/spec pairs may be given. The + color numbers correspond to the ANSI colors 0-7, their bright + versions 8-15, and if supported, the remainder of the 88-color + or 256-color table. + + If a "?" is given rather than a name or RGB specification, + xterm replies with a control sequence of the same form which + can be used to set the corresponding color. Because more than + one pair of color number and specification can be given in one + control sequence, xterm can make more than one reply. + + Ps = 5 ; c ; spec -> Change Special Color Number c to the + color specified by spec. + + The spec parameter can be a name or RGB specification as per + XParseColor. Any number of c/spec pairs may be given. The + special colors can also be set by adding the maximum number of + colors (e.g., 88 or 256) to these codes in an OSC 4 control: + + Pc = 0 <- resource colorBD (BOLD). + Pc = 1 <- resource colorUL (UNDERLINE). + Pc = 2 <- resource colorBL (BLINK). + Pc = 3 <- resource colorRV (REVERSE). + Pc = 4 <- resource colorIT (ITALIC). + + Ps = 6 ; c ; f -> Enable/disable Special Color Number c. + The second parameter tells xterm to enable the corresponding + color mode if nonzero, disable it if zero. OSC 6 is the same + as OSC 1 0 6 . + + If no parameters are given, this control has no effect. + + The 10 colors (below) which may be set or queried using 1 0 + through 1 9 are denoted dynamic colors, since the + corresponding control sequences were the first means for + setting xterm's colors dynamically, i.e., after it was + started. They are not the same as the ANSI colors (however, + the dynamic text foreground and background colors are used + when ANSI colors are reset using SGR 3 9 and 4 9 , + respectively). These controls may be disabled using the + allowColorOps resource. At least one parameter is expected + for Pt. Each successive parameter changes the next color in + the list. The value of Ps tells the starting point in the + list. The colors are specified by name or RGB specification + as per XParseColor. + + Resource Description + -----------------------+----------------------------- + foreground | VT100 text foreground color + background | VT100 text background color + cursorColor | text cursor color + pointerColor | pointer foreground color + pointerColorBackground | pointer background + (foreground) | Tektronix foreground color + (background) | Tektronix background color + highlightColor | highlight background color + (cursorColor) | Tektronix cursor color + highlightTextColor | highlight foreground color + -----------------------+----------------------------- + + + The Tektronix colors are initially set from the VT100 colors, + but after that can be set independently using these control + sequences. + + If a "?" is given rather than a name or RGB specification, + xterm replies with a control sequence of the same form which + can be used to set the corresponding dynamic color. Because + more than one pair of color number and specification can be + given in one control sequence, xterm can make more than one + reply. + + Ps = 1 0 -> Change VT100 text foreground color to Pt. + Ps = 1 1 -> Change VT100 text background color to Pt. + Ps = 1 2 -> Change text cursor color to Pt. + Ps = 1 3 -> Change pointer foreground color to Pt. + Ps = 1 4 -> Change pointer background color to Pt. + Ps = 1 5 -> Change Tektronix foreground color to Pt. + Ps = 1 6 -> Change Tektronix background color to Pt. + Ps = 1 7 -> Change highlight background color to Pt. + Ps = 1 8 -> Change Tektronix cursor color to Pt. + Ps = 1 9 -> Change highlight foreground color to Pt. + + Ps = 2 2 -> Change pointer cursor shape to Pt. The + parameter Pt sets the pointerShape resource. If Pt is empty, + or does not match any of the standard names, n uses the + resource's default "xterm" shape. + + Ps = 4 6 -> Change Log File to Pt. The parameter Pt sets + the logFile resource. Logging is normally disabled by a + compile-time option. + + Ps = 5 0 -> Set Font to Pt. These controls may be disabled + using the allowFontOps resource. If Pt begins with a "#", + index in the font menu, relative (if the next character is a + plus or minus sign) or absolute. A number is expected but not + required after the sign (the default is the current entry for + relative, zero for absolute indexing). + + The same rule (plus or minus sign, optional number) is used + when querying the font. The remainder of Pt is ignored. + + A font can be specified after a "#" index expression, by + adding a space and then the font specifier. + + If the TrueType Fonts menu entry is set (the renderFont + resource), then this control sets/queries the faceName + resource. + + Ps = 5 1 -> reserved for Emacs shell. + + Ps = 5 2 -> Manipulate Selection Data. These controls may + be disabled using the allowWindowOps resource. The parameter + Pt is parsed as + Pc ; Pd + + The first, Pc, may contain zero or more characters from the + set c , p , q , s , 0 , 1 , 2 , 3 , 4 , 5 , 6 , and 7 . It is + used to construct a list of selection parameters for + clipboard, primary, secondary, select, or cut-buffers 0 + through 7 respectively, in the order given. If the parameter + is empty, xterm uses s 0 , to specify the configurable + primary/clipboard selection and cut-buffer 0. + + The second parameter, Pd, gives the selection data. Normally + this is a string encoded in base64 (RFC-4648). The data + becomes the new selection, which is then available for pasting + by other applications. + + If the second parameter is a ? , xterm replies to the host + with the selection data encoded using the same protocol. It + uses the first selection found by asking successively for each + item from the list of selection parameters. + + If the second parameter is neither a base64 string nor ? , + then the selection is cleared. + + Ps = 6 0 -> Query allowed features (XTQALLOWED). XTerm + replies with + + OSC 6 0 ; Pt ST + + where Pt is a comma-separated list of the allowed optional + runtime features, i.e., zero or more of these resource names: + + allowColorOps + allowFontOps + allowMouseOps + allowPasteControls + allowTcapOps + allowTitleOps + allowWindowOps + + Ps = 6 1 -> Query disallowed features (XTQDISALLOWED). The + second parameter (i.e., the main feature) must be one of the + resource names returned by OSC 6 0 . XTerm replies with + + OSC 6 1 ; Pt ST + + where Pt is a comma-separated list of the optional runtime + features which would be disallowed if the main feature is + disabled. + + Ps = 1 0 4 ; c -> Reset Color Number c. It is reset to the + color specified by the corresponding X resource. Any number + of c parameters may be given. These parameters correspond to + the ANSI colors 0-7, their bright versions 8-15, and if + supported, the remainder of the 88-color or 256-color table. + If no parameters are given, the entire table will be reset. + + Ps = 1 0 5 ; c -> Reset Special Color Number c. It is reset + to the color specified by the corresponding X resource. Any + number of c parameters may be given. These parameters + correspond to the special colors which can be set using an OSC + 5 control (or by adding the maximum number of colors using an + OSC 4 control). + + If no parameters are given, all special colors will be reset. + + Ps = 1 0 6 ; c ; f -> Enable/disable Special Color Number c. + The second parameter tells xterm to enable the corresponding + color mode if nonzero, disable it if zero. + + Pc = 0 <- resource colorBDMode (BOLD). + Pc = 1 <- resource colorULMode (UNDERLINE). + Pc = 2 <- resource colorBLMode (BLINK). + Pc = 3 <- resource colorRVMode (REVERSE). + Pc = 4 <- resource colorITMode (ITALIC). + Pc = 5 <- resource colorAttrMode (Override ANSI). + + If no parameters are given, this control has no effect. + + The dynamic colors can also be reset to their default + (resource) values: + Ps = 1 1 0 -> Reset VT100 text foreground color. + Ps = 1 1 1 -> Reset VT100 text background color. + Ps = 1 1 2 -> Reset text cursor color. + Ps = 1 1 3 -> Reset pointer foreground color. + Ps = 1 1 4 -> Reset pointer background color. + Ps = 1 1 5 -> Reset Tektronix foreground color. + Ps = 1 1 6 -> Reset Tektronix background color. + Ps = 1 1 7 -> Reset highlight color. + Ps = 1 1 8 -> Reset Tektronix cursor color. + Ps = 1 1 9 -> Reset highlight foreground color. + + Ps = I ; c -> Set icon to file. Sun shelltool, CDE dtterm. + The file is expected to be XPM format, and uses the same + search logic as the iconHint resource. + + Ps = l ; c -> Set window title. Sun shelltool, CDE dtterm. + + Ps = L ; c -> Set icon label. Sun shelltool, CDE dtterm. + + +Privacy Message + +PM Pt ST xterm implements no PM functions; Pt is ignored. Pt need not + be printable characters. + + +Special Keyboard Keys + +Terminal keyboards have two types of keys: + +o ordinary keys, which you would use as data, e.g., in a text file, + and + +o special keys, which you would use to tell xterm to perform some + action. -** Application Program-Control functions - -APC Pt2 ST xterm2 implements no APC functions; Pt2 is ignored. Pt - need not be printable characters. +XTerm detects all of these keys via X key-press and key-release events. +It uses the translations resource to decide what to do with these +events. +o Ordinary keys are handled with the insert-seven-bit action, or the + insert-eight-bit action. -** Device-Control functions +o Special keys may be handled with other resources. However, xterm + also has built-in logic to map commonly-used special keys into + characters which your keypress sends to the application running in + xterm. -DCS Ps2; Ps2| Pt2 ST User-Defined Keys (DECUDK). +Special keyboard keys send control characters or escape sequences. This +is a convention, making it convenient for applications to detect these +keys, rather than a standard. - The first parameter: - Ps2 = 0 -> Clear all UDK definitions before starting (default) - Ps2 = 1 -> Erase Below (default) - - The second parameter: - Ps2 = 0 -> Lock the keys (default) - Ps2 = 1 -> Do not lock. - - The third parameter is a ';'-separated list of strings - denoting the key-code separated by a '/' from the hex- - encoded key value. The key codes correspond to the DEC - function-key codes (e.g., F6=17). -DCS $ q Pt2 ST Request Status String (DECRQSS). The string following - the "q" is one of the following: - - " q -> DECSCA - " p -> DECSCL - r -> DECSTBM - m -> SGR - - xterm2 responds with DCS 1 $ r Pt2 ST for valid requests, - replacing the Pt2 with the corresponding CSI string, or DCS 0 $ - r Pt2 ST for invalid requests. - -DCS + q Pt2 ST Request Termcap/Terminfo String (xterm, experimental). The - string following the "q" is a list of names encoded in - hexadecimal (2 digits per character) separated by ; which - correspond to termcap or terminfo key names. xterm2 responds - with DCS 1 + r Pt2 ST for valid requests, adding to Pt2 an = , - and the value of the corresponding string that xterm would - send, or DCS 0 + r Pt2 ST for invalid requests. The strings are - encoded in hexadecimal (2 digits per character). - - -** Functions using CSI , ordered by the final character(s) - -CSI Ps2 @ Insert Ps2 (Blank) Character(s) (default = 1) (ICH) - -CSI Ps2 A Cursor Up Ps2 Times (default = 1) (CUU) - -CSI Ps2 B Cursor Down Ps2 Times (default = 1) (CUD) - -CSI Ps2 C Cursor Forward Ps2 Times (default = 1) (CUF) - -CSI Ps2 D Cursor Backward Ps2 Times (default = 1) (CUB) - -CSI Ps2 E Cursor Next Line Ps2 Times (default = 1) (CNL) - -CSI Ps2 F Cursor Preceding Line Ps2 Times (default = 1) (CPL) - -CSI Ps2 G Cursor Character Absolute [column] (default = [row,1]) (CHA) - -CSI Ps2 ; Ps2 H Cursor Position [row;column] (default = [1,1]) (CUP) - -CSI Ps2 I Cursor Forward Tabulation Ps2 tab stops (default = 1) (CHT) - -CSI Ps2 J Erase in Display (ED) - Ps2 = 0 -> Erase Below (default) - Ps2 = 1 -> Erase Above - Ps2 = 2 -> Erase All - Ps2 = 3 -> Erase Saved Lines (xterm) - -CSI ? Ps2 J Erase in Display (DECSED) - Ps2 = 0 -> Selective Erase Below (default) - Ps2 = 1 -> Selective Erase Above - Ps2 = 2 -> Selective Erase All - -CSI Ps2 K Erase in Line (EL) - Ps2 = 0 -> Erase to Right (default) - Ps2 = 1 -> Erase to Left - Ps2 = 2 -> Erase All - -CSI ? Ps2 K Erase in Line (DECSEL) - - Ps2 = 0 -> Selective Erase to Right (default) - Ps2 = 1 -> Selective Erase to Left - Ps2 = 2 -> Selective Erase All - -CSI Ps2 L Insert Ps2 Line(s) (default = 1) (IL) - -CSI Ps2 M Delete Ps2 Line(s) (default = 1) (DL) - -CSI Ps2 P Delete Ps2 Character(s) (default = 1) (DCH) - -CSI Ps2 S Scroll up Ps2 lines (default = 1) (SU) - -CSI Ps2 T Scroll down Ps2 lines (default = 1) (SD) - -CSI Ps2 ; Ps2 ; Ps2 ; Ps2 ; Ps2 T - Initiate highlight mouse tracking. Parameters are - [func;startx;starty;firstrow;lastrow]. See the section - Mouse Tracking. - -CSI Ps2 X Erase Ps2 Character(s) (default = 1) (ECH) - -CSI Ps2 Z Cursor Backward Tabulation Ps2 tab stops (default = 1) (CBT) - -CSI Pm2 ` Character Position Absolute [column] (default = [row,1]) (HPA) - -CSI Ps2 b Repeat the preceding graphic character Ps2 times (REP) - -CSI Ps2 c Send Device Attributes (Primary DA) - - Ps2 = 0 or omitted -> request attributes from terminal. The - response depends on the decTerminalID resource set- ting. - - -> CSI ? 1 ; 2 c (``VT100 with Advanced Video Option'') - -> CSI ? 1 ; 0 c (``VT101 with No Options'') - -> CSI ? 6 c (``VT102'') - -> CSI ? 6 0 ; 1 ; 2 ; 6 ; 8 ; 9 ; 1 5 ; c (``VT220'') - - The VT100-style response parameters do not mean anything - by themselves. VT220 parameters do, telling the host - what features the terminal supports: - - -> 1 132-columns - -> 2 Printer - -> 6 Selective erase - -> 8 User-defined keys - -> 9 National replacement character sets - -> 1 5 Technical characters - -> 2 2 ANSI color, e.g., VT525 - -> 2 9 ANSI text locator (i.e., DEC Locator mode) - -CSI > Ps2 c Send Device Attributes (Secondary DA) - Ps2 = 0 or omitted -> request the terminal's identifi- - cation code. The response depends on the decTerminalID - resource setting. It should apply only to VT220 and up, - but xterm2 extends this to VT100. - -> CSI > Pp2 ; Pv2 ; Pc2 c - where Pp2 denotes the terminal type - -> 0 (``VT100'') - -> 1 (``VT220'') - and Pv2 is the firmware version (for xterm2, this is the - XFree86 patch number, starting with 95). In a DEC termi- - nal, Pc2 indicates the ROM cartridge registration number - and is always zero. - -CSI Pm2 d Line Position Absolute [row] (default = [1,column]) (VPA) - -CSI Ps2 ; Ps2 f Horizontal and Vertical Position [row;column] (default = [1,1]) (HVP) - -CSI Ps2 g Tab Clear (TBC) - Ps2 = 0 -> Clear Current Column (default) - Ps2 = 3 -> Clear All - -CSI Pm2 h Set Mode (SM) - Ps2 = 2 -> Keyboard Action Mode (AM) - Ps2 = 4 -> Insert Mode (IRM) - Ps2 = 1 2 -> Send/receive (SRM) - Ps2 = 2 0 -> Automatic Newline (LNM) - -CSI ? Pm2 h DEC Private Mode Set (DECSET) - Ps2 = 1 -> Application Cursor Keys (DECCKM) - Ps2 = 2 -> Designate USASCII for character sets G0-G3 - (DECANM), and set VT100 mode. - Ps2 = 3 -> 132 Column Mode (DECCOLM) - Ps2 = 4 -> Smooth (Slow) Scroll (DECSCLM) - Ps2 = 5 -> Reverse Video (DECSCNM) - Ps2 = 6 -> Origin Mode (DECOM) - Ps2 = 7 -> Wraparound Mode (DECAWM) - Ps2 = 8 -> Auto-repeat Keys (DECARM) - Ps2 = 9 -> Send Mouse X & Y on button press. See the - section Mouse Tracking. - Ps2 = 1 0 -> Show toolbar (rxvt) - Ps2 = 1 2 -> Start Blinking Cursor (att610) - Ps2 = 1 8 -> Print form feed (DECPFF) - Ps2 = 1 9 -> Set print extent to full screen (DECPEX) - Ps2 = 2 5 -> Show Cursor (DECTCEM) - Ps2 = 3 0 -> Show scrollbar (rxvt). - Ps2 = 3 5 -> Enable font-shifting functions (rxvt). - Ps2 = 3 8 -> Enter Tektronix Mode (DECTEK) - Ps2 = 4 0 -> Allow 80 -> 132 Mode - Ps2 = 4 1 -> more2(1) fix (see curses resource) - Ps2 = 4 2 -> Enable Nation Replacement Character sets (DECNRCM) - Ps2 = 4 4 -> Turn On Margin Bell - Ps2 = 4 5 -> Reverse-wraparound Mode - Ps2 = 4 6 -> Start Logging (normally disabled by a - compile-time option) - Ps2 = 4 7 -> Use Alternate Screen Buffer (unless dis- - abled by the titeInhibit resource) - Ps2 = 6 6 -> Application keypad (DECNKM) - Ps2 = 6 7 -> Backarrow key sends backspace (DECBKM) - Ps2 = 1 0 0 0 -> Send Mouse X & Y on button press and - release. See the section Mouse Tracking. - Ps2 = 1 0 0 1 -> Use Hilite Mouse Tracking. - Ps2 = 1 0 0 2 -> Use Cell Motion Mouse Tracking. - Ps2 = 1 0 0 3 -> Use All Motion Mouse Tracking. - Ps2 = 1 0 1 0 -> Scroll to bottom on tty output (rxvt). - Ps2 = 1 0 1 1 -> Scroll to bottom on key press (rxvt). - Ps2 = 1 0 3 5 -> Enable special modifiers for Alt and - NumLock keys. - Ps2 = 1 0 3 6 -> Send ESC when Meta modifies a key - (enables the metaSendsEscape resource). - Ps2 = 1 0 3 7 -> Send DEL from the editing-keypad Delete key - Ps2 = 1 0 4 7 -> Use Alternate Screen Buffer (unless - disabled by the titeInhibit resource) - Ps2 = 1 0 4 8 -> Save cursor as in DECSC (unless disabled by the - titeInhibit resource) - Ps2 = 1 0 4 9 -> Save cursor as in DECSC and use Alternate Screen - Buffer, clearing it first (unless disabled by - the titeInhibit resource). This combines the effects of - the 1047 and 1048 modes. Use this with terminfo- - based applications rather than the 4 7 mode. - Ps2 = 1 0 5 1 -> Set Sun function-key mode. - Ps2 = 1 0 5 2 -> Set HP function-key mode. - Ps2 = 1 0 5 3 -> Set SCO function-key mode. - Ps2 = 1 0 6 0 -> Set legacy keyboard emulation (X11R6). - Ps2 = 1 0 6 1 -> Set Sun/PC keyboard emulation of VT220 - keyboard. - Ps2 = 2 0 0 4 -> Set bracketed paste mode. -CSI Pm2 i Media Copy (MC) - Ps2 = 0 -> Print screen (default) - Ps2 = 4 -> Turn off printer controller mode - Ps2 = 5 -> Turn on printer controller mode - -CSI ? Pm2 i Media Copy (MC, DEC-specific) - Ps2 = 1 -> Print line containing cursor - Ps2 = 4 -> Turn off autoprint mode - Ps2 = 5 -> Turn on autoprint mode - Ps2 = 1 0 -> Print composed display, ignores DECPEX - Ps2 = 1 1 -> Print all pages - -CSI Pm2 l Reset Mode (RM) - Ps2 = 2 -> Keyboard Action Mode (AM) - Ps2 = 4 -> Replace Mode (IRM) - Ps2 = 1 2 -> Send/receive (SRM) - Ps2 = 2 0 -> Normal Linefeed (LNM) - -CSI ? Pm2 l DEC Private Mode Reset (DECRST) - Ps2 = 1 -> Normal Cursor Keys (DECCKM) - Ps2 = 2 -> Designate VT52 mode (DECANM). - Ps2 = 3 -> 80 Column Mode (DECCOLM) - Ps2 = 4 -> Jump (Fast) Scroll (DECSCLM) - Ps2 = 5 -> Normal Video (DECSCNM) - Ps2 = 6 -> Normal Cursor Mode (DECOM) - Ps2 = 7 -> No Wraparound Mode (DECAWM) - Ps2 = 8 -> No Auto-repeat Keys (DECARM) - Ps2 = 9 -> Don't Send Mouse X & Y on button press - Ps2 = 1 0 -> Hide toolbar (rxvt) - Ps2 = 1 2 -> Stop Blinking Cursor (att610) - Ps2 = 1 8 -> Don't print form feed (DECPFF) - Ps2 = 1 9 -> Limit print to scrolling region (DECPEX) - Ps2 = 2 5 -> Hide Cursor (DECTCEM) - Ps2 = 3 0 -> Don't show scrollbar (rxvt). - Ps2 = 3 5 -> Disable font-shifting functions (rxvt). - Ps2 = 4 0 -> Disallow 80 -> 132 Mode - Ps2 = 4 1 -> No more2(1) fix (see curses resource) - Ps2 = 4 2 -> Disable Nation Replacement Character sets (DECNRCM) - Ps2 = 4 4 -> Turn Off Margin Bell - Ps2 = 4 5 -> No Reverse-wraparound Mode - Ps2 = 4 6 -> Stop Logging (normally disabled by a compile-time option) - Ps2 = 4 7 -> Use Normal Screen Buffer - Ps2 = 6 6 -> Numeric keypad (DECNKM) - Ps2 = 6 7 -> Backarrow key sends delete (DECBKM) - Ps2 = 1 0 0 0 -> Don't Send Mouse X & Y on button press and release. See the section Mouse Tracking. - Ps2 = 1 0 0 1 -> Don't Use Hilite Mouse Tracking - Ps2 = 1 0 0 2 -> Don't Use Cell Motion Mouse Tracking - Ps2 = 1 0 0 3 -> Don't Use All Motion Mouse Tracking - Ps2 = 1 0 1 0 -> Don't scroll to bottom on tty output (rxvt). - Ps2 = 1 0 1 1 -> Don't scroll to bottom on key press (rxvt). - Ps2 = 1 0 3 5 -> Disable special modifiers for Alt and NumLock keys. - Ps2 = 1 0 3 6 -> Don't send ESC when Meta modifies a key (disables the metaSendsEscape resource). - Ps2 = 1 0 3 7 -> Send VT220 Remove from the editing keypad Delete key - Ps2 = 1 0 4 7 -> Use Normal Screen Buffer, clearing screen first if in - the Alternate Screen (unless disabled by the titeInhibit resource) - Ps2 = 1 0 4 8 -> Restore cursor as in DECRC (unless disabled by the - titeInhibit resource) - Ps2 = 1 0 4 9 -> Use Normal Screen Buffer and restore cursor as in - DECRC (unless disabled by the titeInhibit resource). - This combines the effects of the 1047 and - 1048 modes. Use this with terminfo-based applications - rather than the 47 mode. - - Ps2 = 1 0 5 1 -> Reset Sun function-key mode. - Ps2 = 1 0 5 2 -> Reset HP function-key mode. - Ps2 = 1 0 5 3 -> Reset SCO function-key mode. - Ps2 = 1 0 6 0 -> Reset legacy keyboard emulation (X11R6). - Ps2 = 1 0 6 1 -> Reset Sun/PC keyboard emulation of VT220 keyboard. - Ps2 = 2 0 0 4 -> Reset bracketed paste mode. - -CSI Pm2 m Character Attributes (SGR) - Ps2 = 0 -> Normal (default) - Ps2 = 1 -> Bold - Ps2 = 4 -> Underlined - Ps2 = 5 -> Blink (appears as Bold) - Ps2 = 7 -> Inverse - Ps2 = 8 -> Invisible, i.e., hidden (VT300) - Ps2 = 2 2 -> Normal (neither bold nor faint) - Ps2 = 2 4 -> Not underlined - Ps2 = 2 5 -> Steady (not blinking) - Ps2 = 2 7 -> Positive (not inverse) - Ps2 = 2 8 -> Visible, i.e., not hidden (VT300) - Ps2 = 3 0 -> Set foreground color to Black - Ps2 = 3 1 -> Set foreground color to Red - Ps2 = 3 2 -> Set foreground color to Green - Ps2 = 3 3 -> Set foreground color to Yellow - Ps2 = 3 4 -> Set foreground color to Blue - Ps2 = 3 5 -> Set foreground color to Magenta - Ps2 = 3 6 -> Set foreground color to Cyan - Ps2 = 3 7 -> Set foreground color to White - Ps2 = 3 9 -> Set foreground color to default (original) - Ps2 = 4 0 -> Set background color to Black - Ps2 = 4 1 -> Set background color to Red - Ps2 = 4 2 -> Set background color to Green - Ps2 = 4 3 -> Set background color to Yellow - Ps2 = 4 4 -> Set background color to Blue - Ps2 = 4 5 -> Set background color to Magenta - Ps2 = 4 6 -> Set background color to Cyan - Ps2 = 4 7 -> Set background color to White - Ps2 = 4 9 -> Set background color to default (original). - - If 16-color support is compiled, the following apply. Assume - that xterm2's resources are set so that the ISO color codes are - the first 8 of a set of 16. Then the aixterm2 colors are the - bright versions of the ISO colors: - - Ps2 = 9 0 -> Set foreground color to Black - Ps2 = 9 1 -> Set foreground color to Red - Ps2 = 9 2 -> Set foreground color to Green - Ps2 = 9 3 -> Set foreground color to Yellow - Ps2 = 9 4 -> Set foreground color to Blue - Ps2 = 9 5 -> Set foreground color to Magenta - Ps2 = 9 6 -> Set foreground color to Cyan - Ps2 = 9 7 -> Set foreground color to White - Ps2 = 1 0 0 -> Set background color to Black - Ps2 = 1 0 1 -> Set background color to Red - Ps2 = 1 0 2 -> Set background color to Green - Ps2 = 1 0 3 -> Set background color to Yellow - Ps2 = 1 0 4 -> Set background color to Blue - Ps2 = 1 0 5 -> Set background color to Magenta - Ps2 = 1 0 6 -> Set background color to Cyan - Ps2 = 1 0 7 -> Set background color to White - - If xterm2 is compiled with the 16-color support disabled, it - supports the following, from rxvt2: - - Ps2 = 1 0 0 -> Set foreground and background color to default - - If 88- or 256-color support is compiled, the following apply. - - Ps2 = 3 8 ; 5 ; Ps2 -> Set foreground color to the second Ps - Ps2 = 4 8 ; 5 ; Ps2 -> Set background color to the second Ps - -CSI Ps2 n Device Status Report (DSR) - Ps2 = 5 -> Status Report CSI 0 n (``OK'') - Ps2 = 6 -> Report Cursor Position (CPR) [row;column] as - CSI r2 ; c2 R - -CSI ? Ps2 n Device Status Report (DSR, DEC-specific) - Ps2 = 6 -> Report Cursor Position (CPR) [row;column] as - CSI ? r2 ; c2 R (assumes page is zero). - Ps2 = 1 5 -> Report Printer status as CSI ? 1 0 n - (ready) or CSI ? 1 1 n (not ready) - Ps2 = 2 5 -> Report UDK status as CSI ? 2 0 n - (unlocked) or CSI ? 2 1 n (locked) - Ps2 = 2 6 -> Report Keyboard status as - CSI ? 2 7 ; 1 ; 0 ; 0 n (North American) - The last two parameters apply to VT400 & up, and denote - keyboard ready and LK01 respectively. - Ps2 = 5 3 -> Report Locator status as - CSI ? 5 3 n Locator available, if compiled-in, or - CSI ? 5 0 n No Locator, if not. - -CSI ! p Soft terminal reset (DECSTR) - -CSI Ps2 ; Ps2 " p` Set conformance level (DECSCL) Valid values for the first - parameter: - Ps2 = 6 1 -> VT100 - Ps2 = 6 2 -> VT200 - Ps2 = 6 3 -> VT300 - - Valid values for the second parameter: - Ps2 = 0 -> 8-bit controls - Ps2 = 1 -> 7-bit controls (always set for VT100) - Ps2 = 2 -> 8-bit controls - -CSI Ps2 " q Select character protection attribute (DECSCA). Valid - values for the parameter: - - Ps2 = 0 -> DECSED and DECSEL can erase (default) - Ps2 = 1 -> DECSED and DECSEL cannot erase - Ps2 = 2 -> DECSED and DECSEL can erase - -CSI Ps2 ; Ps2 r Set Scrolling Region [top;bottom] (default = full size of - window) (DECSTBM) - -CSI ? Pm2 r Restore DEC Private Mode Values. The value of Ps2 previ- - ously saved is restored. Ps2 values are the same as for - DECSET. - -CSI Pt2; Pl2; Pb2; Pr2; Ps2$ r - Change Attributes in Rectangular Area (DECCARA). - Pt2; Pl2; Pb2; Pr2 denotes the rectangle. - Ps2 denotes the SGR attributes to change: 0, 1, 4, 5, 7 - -CSI s Save cursor (ANSI.SYS) - -CSI ? Pm2 s Save DEC Private Mode Values. Ps2 values are the same as for DECSET. - -CSI Ps2 ; Ps2 ; Ps2 t - Window manipulation (from dtterm2, as well as extensions). - These controls may be disabled using the allowWindowOps - resource. Valid values for the first (and any additional - parameters) are: - - Ps2 = 1 -> De-iconify window. - Ps2 = 2 -> Iconify window. - Ps2 = 3 ; x2 ;2 y2 -> Move window to [x, y]. - Ps2 = 4 ; height2 ;2 width2 -> Resize the xterm2 window to - height and width in pixels. - Ps2 = 5 - -> Raise the xterm2 window to the front of the - stacking order. - Ps2 = 6 -> Lower the xterm2 window to the bottom of the - stacking order. - Ps2 = 7 -> Refresh the xterm2 window. - Ps2 = 8 ; height2 ;2 width2 -> Resize the text area to - [height;width] in characters. - Ps2 = 9 ; 0 -> Restore maximized window. - Ps2 = 9 ; 1 -> Maximize window (i.e., resize to screen - size). - Ps2 = 1 1 -> Report xterm2 window state. If the xterm - window is open (non-iconified), it returns CSI 1 t . If - the xterm2 window is iconified, it returns CSI 2 t . - Ps2 = 1 3 -> Report xterm2 window position as CSI 3 ; x2; - y2t - Ps2 = 1 4 -> Report xterm2 window in pixels as CSI 4 ; height2 ; width2 t - Ps2 = 1 8 -> Report the size of the text area in characters as CSI 8 ; height2 ; width2 t - Ps2 = 1 9 -> Report the size of the screen in characters as CSI 9 ; height2 ; width2 t - Ps2 = 2 0 -> Report xterm2 window's icon label as OSC L - label2 ST - Ps2 = 2 1 -> Report xterm2 window's title as OSC l title2 ST - Ps2 >= 2 4 -> Resize to Ps2 lines (DECSLPP) -CSI Pt2; Pl2; Pb2; Pr2; Ps2$ t - Reverse Attributes in Rectangular Area (DECRARA). - Pt2; Pl2; Pb2; Pr2 denotes the rectangle. - Ps2 denotes the attributes to reverse. 1, 4, 5, 7 -CSI u Save cursor (ANSI.SYS) -CSI Pt2; Pl2; Pb2; Pr2; Pp2; Pt2; Pl2; Pp2$ v - Copy Rectangular Area (DECCRA) - Pt2; Pl2; Pb2; Pr2 denotes the rectangle. - Pp2 denotes the source page. - Pt2; Pl2 denotes the target location. - Pp2 denotes the target page. - -CSI Pt2 ; Pl2 ; Pb2 ; Pr2 ' w - Enable Filter Rectangle (DECEFR) Parameters are - [top;left;bottom;right]. Defines the coordinates of a filter - rectangle and acti- vates it. Anytime the locator is detected - outside of the filter rectangle, an outside rectangle event is - generated and the rectangle is disabled. Filter rectangles are - always treated as "one-shot" events. Any parameters that are - omitted default to the current locator position. If all - parameters are omitted, any locator motion will be reported. - DECELR always cancels any prevous rectangle definition. - -CSI Ps2 x Request Terminal Parameters (DECREQTPARM) - if Ps2 is a "0" (default) or "1", and xterm is emulating - VT100, the control sequence elicits a response of the - same form whose parameters describe the terminal: - - Ps2 -> the given Ps2 incremented by 2. - 1 -> no parity - 1 -> eight bits - 1 2 8 -> transmit 38.4k baud - 1 2 8 -> receive 38.4k baud - 1 -> clock multiplier - 0 -> STP flags - -CSI Ps2 x Select Attribute Change Extent (DECSACE). - Ps2 = 0 -> from start to end position, wrapped - Ps2 = 1 -> from start to end position, wrapped - Ps2 = 2 -> rectangle (exact). -CSI Pc2; Pt2; Pl2; Pb2; Pr2$ x - Fill Rectangular Area (DECFRA). - Pc2 is the character to use. - Pt2; Pl2; Pb2; Pr2 denotes the rectangle. - -CSI Ps2 ; Pu2 ' z - Enable Locator Reporting (DECELR) - Valid values for the first parameter: - Ps2 = 0 -> Locator disabled (default) - Ps2 = 1 -> Locator enabled - Ps2 = 2 -> Locator enabled for one report, then disabled - - The second parameter specifies the coordinate unit for - locator reports. - - Valid values for the second parameter: - - Pu2 = 0 or omitted -> default to character cells - Pu2 = 1 -> device physical pixels - Pu2 = 2 -> character cells - -CSI Pt2; Pl2; Pb2; Pr2$ z - Erase Rectangular Area (DECERA). - Pt2; Pl2; Pb2; Pr2 denotes the rectangle. - -CSI Pm2 ' { Select Locator Events (DECSLE) - Valid values for the first (and any additional parame- - ters) are: - Ps2 = 0 -> only respond to explicit host requests(DECRQLP) - (default) also cancels any filter rectangle - Ps2 = 1 -> report button down transitions - Ps2 = 2 -> do not report button down transitions - Ps2 = 3 -> report button up transitions - Ps2 = 4 -> do not report button up transitions - -CSI Pt2; Pl2; Pb2; Pr2$ { - Selective Erase Rectangular Area (DECSERA). - Pt2; Pl2; Pb2; Pr2 denotes the rectangle. - -CSI Ps2 ' | Request Locator Position (DECRQLP) - Valid values for the parameter are: - Ps2 = 0 , 1 or omitted -> transmit a single DECLRP locator report - - If Locator Reporting has been enabled by a DECELR, xterm will respond with a - DECLRP Locator Report. This report is also generated on button up and down - events if they have been enabled with a DECSLE, or when the locator is - detected outside of a filter rectangle, if filter rectan- gles have been - enabled with a DECEFR. - - -> CSI Pe2 ; Pb2 ; Pr2 ; Pc2 ; Pp2 & w - - Parameters are [event;button;row;column;page]. - Valid values for the event: - Pe2 = 0 -> locator unavailable - no other parameters sent - Pe2 = 1 -> request - xterm received a DECRQLP - Pe2 = 2 -> left button down - Pe2 = 3 -> left button up - Pe2 = 4 -> middle button down - Pe2 = 5 -> middle button up - Pe2 = 6 -> right button down - Pe2 = 7 -> right button up - Pe2 = 8 -> M4 button down - Pe2 = 9 -> M4 button up - Pe2 = 1 0 -> locator outside filter rectangle - ``button'' parameter is a bitmask indicating which but- - tons are pressed: - Pb2 = 0 -> no buttons down - Pb2 & 1 -> right button down - Pb2 & 2 -> middle button down - Pb2 & 4 -> left button down - Pb2 & 8 -> M4 button down - - ``row'' and ``column'' parameters are the coordinates of the - locator position in the xterm window, encoded as ASCII decimal. - - The ``page'' parameter is not used by xterm, and will be omitted. - - -** Operating System Controls - -OSC Ps2 ; Pt2 ST - -OSC Ps2 ; Pt2 BEL Set Text Parameters. For colors and font, if Pt2 is a "?", the - control sequence elicits a response which con- sists of the - control sequence which would set the corre- sponding value. The - dtterm2 control sequences allow you to determine the icon name - and window title. - - Ps2 = 0 -> Change Icon Name and Window Title to Pt - Ps2 = 1 -> Change Icon Name to Pt - Ps2 = 2 -> Change Window Title to Pt - Ps2 = 3 -> Set X property on top-level window. - - Pt should be in the form "prop=value2", or just "prop2" to - delete the property - - Ps2 = 4 ; c2 ;2 spec2 -> Change Color Number c2 to the - - color specified by spec2, i.e., a name or RGB specifica- tion - as per XParseColor2. Any number of c2 name2 pairs may be given. - The color numbers correspond to the ANSI col- ors 0-7, their - bright versions 8-15, and if supported, the remainder of the - 88-color or 256-color table. - - If a "?" is given rather than a name or RGB specifica- tion, - xterm replies with a control sequence of the same form which - can be used to set the corresponding color. Because more than - one pair of color number and specifica- tion can be given in - one control sequence, xterm can make more than one reply. - - The 8 colors which may be set using 1 0 through 1 7 are denoted - dynamic2 colors2, since the corresponding control sequences - were the first means for setting xterm's colors dynamically, - i.e., after it was started. They are not the same as the ANSI - colors. One or more parameters is expected for Pt2. Each - successive parameter changes the next color in the list. The - value of Ps2 tells the start- ing point in the list. The colors - are specified by name or RGB specification as per XParseColor2. - - If a "?" is given rather than a name or RGB specifica- tion, - xterm replies with a control sequence of the same form which - can be used to set the corresponding dynamic color. Because - more than one pair of color number and specification can be - given in one control sequence, xterm can make more than one - reply. - - Ps2 = 1 0 -> Change VT100 text foreground color to Pt - Ps2 = 1 1 -> Change VT100 text background color to Pt - Ps2 = 1 2 -> Change text cursor color to Pt - Ps2 = 1 3 -> Change mouse foreground color to Pt - Ps2 = 1 4 -> Change mouse background color to Pt - Ps2 = 1 5 -> Change Tektronix foreground color to Pt - Ps2 = 1 6 -> Change Tektronix background color to Pt - Ps2 = 1 7 -> Change highlight color to Pt - Ps2 = 1 8 -> Change Tektronix cursor color to Pt - - Ps2 = 4 6 -> Change Log File to Pt2 (normally disabled - by a compile-time option) - - Ps2 = 5 0 -> Set Font to Pt2 If Pt2 begins with a "#", - index in the font menu, relative (if the next character - is a plus or minus sign) or absolute. A number is - expected but not required after the sign (the default is - the current entry for relative, zero for absolute index- - ing). - - Ps2 = 5 1 (reserved for Emacs shell) - - Ps2 = 5 2 -> Manipulate Selection Data. These controls - may be disabled using the allowWindowOps2 resource. The - parameter Pt2 is parsed as - Pc2; Pd - The first, Pc2, may contain any character from the set c - p s 0 1 2 3 4 5 6 7 . - - It is used to construct a - list of selection parameters for clipboard, primary, - select, or cut buffers 0 through 8 respectively, in the - order given. If the parameter is empty, xterm2 uses s 0 , - to specify the configurable primary/clipboard selection - and cut buffer 0. - - The second parameter, Pd2, gives the selection data. Normally - this is a string encoded in base64. The data becomes the new - selection, which is then available for pasting by other - applications. - - If the second parameter is a ? , xterm2 replies to the host - with the selection data encoded using the same pro- tocol. - -** Privacy Message - -PM Pt2 ST xterm2 implements no PM functions; Pt2 is ignored. - Ptneed not be printable characters. - -** PC-Style Function Keys - -If xterm2 does minimal translation of the function keys, it usually does this with a -PC-style keyboard, so PC-style function keys result. Sun keyboards are similar to PC -keyboards. Both have cursor and scrolling operations printed on the keypad, which -duplicate the smaller cursor and scrolling keypads. - -X does not predefine NumLock (used for VT220 keyboards) or Alt (used as an extension -for the Sun/PC keyboards) as modifiers. These keys are recognized as modifiers when -enabled by the numLock resource, or by the DECSET 1 0 3 5 control sequence. The -cursor keys transmit the following escape sequences depending on the mode specified via -the DECCKM escape sequence. - - Key Normal Application - -------------------------------------- - Cursor Up CSI A SS3 A - Cursor Down CSI B SS3 B - Cursor Right CSI C SS3 C - Cursor Left CSI D SS3 D - -------------------------------------- - -The home- and end-keys (unlike PageUp and other keys also on the 6-key editing keypad) -are considered "cursor keys" by xterm2. Their mode is also controlled by the DECCKM -escape sequence: - - Key Normal Application - ---------------------------------- - Home CSI H SS3 H - End CSI F SS3 F - ---------------------------------- - -The application keypad transmits the following escape sequences depend- ing on the mode -specified via the DECPNM and DECPAM escape sequences. Use the NumLock key to -override the application mode. Not all keys are present on the Sun/PC keypad (e.g., -PF1, Tab), but are supported by the program. - - Key Numeric Application Terminfo Termcap - -------------------------------------------------------------- - Space SP SS3 SP - - - Tab TAB SS3 I - - - Enter CR SS3 M kent @8 - PF1 SS3 P SS3 P kf1 k1 - PF2 SS3 Q SS3 Q kf2 k2 - PF3 SS3 R SS3 R kf3 k3 - PF4 SS3 S SS3 S kf4 k4 - * (multiply) * SS3 j - - - + (add) + SS3 k - - - , (comma) , SS3 l - - - - (minus) - SS3 m - - - . (Delete) . CSI 3 ~ - - - / (divide) / SS3 o - - - 0 (Insert) 0 CSI 2 ~ - - - 1 (End) 1 SS3 F kc1 K4 - 2 (DownArrow) 2 CSI B - - - 3 (PageDown) 3 CSI 6 ~ kc3 K5 - 4 (LeftArrow) 4 CSI D - - - 5 (Begin) 5 CSI E kb2 K2 - 6 (RightArrow) 6 CSI C - - - 7 (Home) 7 SS3 H ka1 K1 - 8 (UpArrow) 8 CSI A - - - 9 (PageUp) 9 CSI 5 ~ ka3 K3 - = (equal) = SS3 X - - - -------------------------------------------------------------- - -They also provide 12 function keys, as well as a few other special-pur- pose keys. - - Key Escape Sequence - --------------------------- - F1 SS3 P - F2 SS3 Q - F3 SS3 R - F4 SS3 S - F5 CSI 1 5 ~ - F6 CSI 1 7 ~ - F7 CSI 1 8 ~ - F8 CSI 1 9 ~ - F9 CSI 2 0 ~ - F10 CSI 2 1 ~ - F11 CSI 2 3 ~ - F12 CSI 2 4 ~ - --------------------------- - -Older versions of xterm2 implement different escape sequences for F1 through F4. These -can be activated by setting the oldXtermFKeys resource. However, since they do not -correspond to any hardware termi- nal, they have been deprecated. (The DEC VT220 -reserves F1 through F5 for local functions such as Setup). - - Key Escape Sequence - --------------------------- - F1 CSI 1 1 ~ - F2 CSI 1 2 ~ - F3 CSI 1 3 ~ - F4 CSI 1 4 ~ - --------------------------- - -In normal mode, i.e., a Sun/PC keyboard when the sunKeyboard resource is false, -xterm2 recognizes function key modifiers which are parameters appended before the final -character of the control sequence. - - Code Modifiers - --------------------------------- - 2 Shift - 3 Alt - 4 Shift + Alt - 5 Control - 6 Shift + Control - 7 Alt + Control - 8 Shift + Alt + Control - --------------------------------- +Alt and Meta Keys + +Many keyboards have keys labeled "Alt". Few have keys labeled "Meta". +However, xterm's default translations use the Meta modifier. Common +keyboard configurations assign the Meta modifier to an "Alt" key. By +using xmodmap one may have the modifier assigned to a different key, and +have "real" alt and meta keys. Here is an example: + + ! put meta on mod3 to distinguish it from alt + keycode 64 = Alt_L + clear mod1 + add mod1 = Alt_L + keycode 115 = Meta_L + clear mod3 + add mod3 = Meta_L + + +The metaSendsEscape resource (and altSendsEscape if altIsNotMeta is set) +can be used to control the way the Meta modifier applies to ordinary +keys unless the modifyOtherKeys resource is set: + +o prefix a key with the ESC character. + +o shift the key from codes 0-127 to 128-255 by adding 128. + +When modifyOtherKeys is set, ordinary keys may be sent as escape +sequences: + +o When modifyOtherKeys is set to 1, only the alt- and meta-modifiers + apply. For example, alt-Tab sends CSI 2 7 ; 3 ; 9 ~ (the second + parameter is "3" for alt, and the third parameter is the ASCII value + of tab, "9"). + +o When modifyOtherKeys is set to 2, all of the modifiers apply. For + example, shift-Tab sends CSI 2 7 ; 2 ; 9 ~ rather than CSI Z (the + second parameter is "2" for shift). + +The formatOtherKeys resource tells n to change the format of the escape +sequences sent when modifyOtherKeys applies. When modifyOtherKeys is +set to 1, for example alt-Tab sends CSI 9 ; 3 u (changing the order of +parameters). One drawback to this format is that applications may +confuse it with CSI u (restore-cursor). + +The xterm FAQ sections + + How can my program distinguish control-I from tab? + + XTerm - "Other" Modified Keys + +go into greater detail on this topic. + +The table shows the result for a given character "x" with modifiers +according to the default translations with the resources set on or off. +This assumes altIsNotMeta is set: + + key altSendsEscape metaSendsEscape result + -----------+----------------+-----------------+------------ + x | off | off | x + Meta-x | off | off | shift + Alt-x | off | off | shift + Alt+Meta-x | off | off | shift + x | ON | off | x + Meta-x | ON | off | shift + Alt-x | ON | off | ESC x + Alt+Meta-x | ON | off | ESC shift + x | off | ON | x + Meta-x | off | ON | ESC x + Alt-x | off | ON | shift + Alt+Meta-x | off | ON | ESC shift + x | ON | ON | x + Meta-x | ON | ON | ESC x + Alt-x | ON | ON | ESC x + Alt+Meta-x | ON | ON | ESC x + -----------+----------------+-----------------+------------ + + + +PC-Style Function Keys + +If xterm does minimal translation of the function keys, it usually does +this with a PC-style keyboard, so PC-style function keys result. Sun +keyboards are similar to PC keyboards. Both have cursor and scrolling +operations printed on the keypad, which duplicate the smaller cursor and +scrolling keypads. + +X does not predefine NumLock (used for VT220 keyboards) or Alt (used as +an extension for the Sun/PC keyboards) as modifiers. These keys are +recognized as modifiers when enabled by the numLock resource, or by the +"DECSET 1 0 3 5 " control sequence. + +The cursor keys transmit the following escape sequences depending on the +mode specified via the DECCKM escape sequence. + + Key Normal Application + -------------+----------+------------- + Cursor Up | CSI A | SS3 A + Cursor Down | CSI B | SS3 B + Cursor Right | CSI C | SS3 C + Cursor Left | CSI D | SS3 D + -------------+----------+------------- + +The home- and end-keys (unlike PageUp and other keys also on the 6-key +editing keypad) are considered "cursor keys" by xterm. Their mode is +also controlled by the DECCKM escape sequence: + + Key Normal Application + ---------+----------+------------- + Home | CSI H | SS3 H + End | CSI F | SS3 F + ---------+----------+------------- + + +The application keypad transmits the following escape sequences +depending on the mode specified via the DECKPNM and DECKPAM escape +sequences. Use the NumLock key to override the application mode. + +Not all keys are present on the Sun/PC keypad (e.g., PF1, Tab), but are +supported by the program. + + Key Numeric Application Terminfo Termcap + ---------------+----------+-------------+----------+---------- + Space | SP | SS3 SP | - | - + Tab | TAB | SS3 I | - | - + Enter | CR | SS3 M | kent | @8 + PF1 | SS3 P | SS3 P | kf1 | k1 + PF2 | SS3 Q | SS3 Q | kf2 | k2 + PF3 | SS3 R | SS3 R | kf3 | k3 + PF4 | SS3 S | SS3 S | kf4 | k4 + * (multiply) | * | SS3 j | - | - + + (add) | + | SS3 k | - | - + , (comma) | , | SS3 l | - | - + - (minus) | - | SS3 m | - | - + . (Delete) | . | CSI 3 ~ | - | - + / (divide) | / | SS3 o | - | - + 0 (Insert) | 0 | CSI 2 ~ | - | - + 1 (End) | 1 | SS3 F | kc1 | K4 + 2 (DownArrow) | 2 | CSI B | - | - + 3 (PageDown) | 3 | CSI 6 ~ | kc3 | K5 + 4 (LeftArrow) | 4 | CSI D | - | - + 5 (Begin) | 5 | CSI E | kb2 | K2 + 6 (RightArrow) | 6 | CSI C | - | - + 7 (Home) | 7 | SS3 H | ka1 | K1 + 8 (UpArrow) | 8 | CSI A | - | - + 9 (PageUp) | 9 | CSI 5 ~ | ka3 | K3 + = (equal) | = | SS3 X | - | - + ---------------+----------+-------------+----------+---------- + +They also provide 12 function keys, as well as a few other special- +purpose keys: + + Key Escape Sequence + ---------+----------------- + F1 | SS3 P + F2 | SS3 Q + F3 | SS3 R + F4 | SS3 S + F5 | CSI 1 5 ~ + F6 | CSI 1 7 ~ + F7 | CSI 1 8 ~ + F8 | CSI 1 9 ~ + F9 | CSI 2 0 ~ + F10 | CSI 2 1 ~ + F11 | CSI 2 3 ~ + F12 | CSI 2 4 ~ + ---------+----------------- + + +Note that F1 through F4 are prefixed with SS3 , while the other keys are +prefixed with CSI . Older versions of xterm implement different escape +sequences for F1 through F4, with a CSI prefix. These can be activated +by setting the oldXtermFKeys resource. However, since they do not +correspond to any hardware terminal, they have been deprecated. (The +DEC VT220 reserves F1 through F5 for local functions such as Setup). + + Key Escape Sequence + ---------+----------------- + F1 | CSI 1 1 ~ + F2 | CSI 1 2 ~ + F3 | CSI 1 3 ~ + F4 | CSI 1 4 ~ + ---------+----------------- + +In normal mode, i.e., a Sun/PC keyboard when the sunKeyboard resource is +false (and none of the other keyboard resources such as oldXtermFKeys +resource is set), xterm encodes function key modifiers as parameters +appended before the final character of the control sequence. As a +special case, the SS3 sent before F1 through F4 is altered to CSI when +sending a function key modifier as a parameter. + + Code Modifiers + ---------+--------------------------- + 2 | Shift + 3 | Alt + 4 | Shift + Alt + 5 | Control + 6 | Shift + Control + 7 | Alt + Control + 8 | Shift + Alt + Control + 9 | Meta + 10 | Meta + Shift + 11 | Meta + Alt + 12 | Meta + Alt + Shift + 13 | Meta + Ctrl + 14 | Meta + Ctrl + Shift + 15 | Meta + Ctrl + Alt + 16 | Meta + Ctrl + Alt + Shift + ---------+--------------------------- For example, shift-F5 would be sent as CSI 1 5 ; 2 ~ -If the alwaysUseMods resource is set, the Meta modifier also is recog- nized, making -parameters 9 through 16. +If the alwaysUseMods resource is set, the Meta modifier also is +recognized, making parameters 9 through 16. + +The codes used for the PC-style function keys were inspired by a feature +of the VT510, referred to in its reference manual as DECFNK. In the +DECFNK scheme, codes 2-8 identify modifiers for function-keys and +cursor-, editing-keypad keys. Unlike xterm, the VT510 limits the +modifiers which can be used with cursor- and editing-keypad keys. +Although the name "DECFNK" implies that it is a mode, the VT510 manual +mentions it only as a feature, which (like xterm) interacts with the +DECUDK feature. Unlike xterm, VT510/VT520 provide an extension to +DECUDK (DECPFK and DECPAK) which apparently was the reason for the +feature in those terminals, i.e., for identifying a programmable key +rather than making it simple for applications to obtain modifier +information. It is not described in the related VT520 manual. Neither +manual was readily available at the time the feature was added to xterm. + +On the other hand, the VT510 and VT520 reference manuals do document a +related feature. That is its emulation of the SCO console, which is +similar to the "xterm-sco" terminal description. The SCO console +function-keys are less useful to applications developers than the +approach used by xterm because + +o the relationship between modifiers and the characters sent by + function-keys is not readily apparent, and + +o the scheme is not extensible, i.e., it is an ad hoc assignment + limited to two modifiers (shift and control). + VT220-Style Function Keys -However, xterm2 is most useful as a DEC VT102 or VT220 emulator. Set the sunKeyboard -resource to true to force a Sun/PC keyboard to act like a VT220 keyboard. - -The VT102/VT220 application keypad transmits unique escape sequences in application -mode, which are distinct from the cursor and scrolling key- pad: - - Key Numeric Application - -------------------------------------- - Space SP SS3 SP - Tab TAB SS3 I - Enter CR SS3 M - PF1 SS3 P SS3 P - PF2 SS3 Q SS3 Q - PF3 SS3 R SS3 R - PF4 SS3 S SS3 S - * (multiply) * SS3 j - + (add) + SS3 k - , (comma) , SS3 l - - (minus) - SS3 m - . (period) . SS3 n - / (divide) / SS3 o - 0 0 SS3 p - 1 1 SS3 q - 2 2 SS3 r - 3 3 SS3 s - 4 4 SS3 t - 5 5 SS3 u - 6 6 SS3 v - 7 7 SS3 w - 8 8 SS3 x - 9 9 SS3 y - = (equal) = SS3 X - -------------------------------------- - -The VT220 provides a 6-key editing keypad, which is analogous to that on the PC -keyboard. It is not affected by DECCKM or DECPNM/DECPAM: - - Key Normal Application - ---------------------------------- - Insert CSI 2 ~ CSI 2 ~ - Delete CSI 3 ~ CSI 3 ~ - Home CSI 1 ~ CSI 1 ~ - End CSI 4 ~ CSI 4 ~ - PageUp CSI 5 ~ CSI 5 ~ - PageDown CSI 6 ~ CSI 6 ~ - ---------------------------------- - -The VT220 provides 8 additional function keys. With a Sun/PC keyboard, access these -keys by Control/F1 for F13, etc. - - Key Escape Sequence - --------------------------- - F13 CSI 2 5 ~ - F14 CSI 2 6 ~ - F15 CSI 2 8 ~ - F16 CSI 2 9 ~ - F17 CSI 3 1 ~ - F18 CSI 3 2 ~ - F19 CSI 3 3 ~ - F20 CSI 3 4 ~ - --------------------------- +However, xterm is most useful as a DEC VT102 or VT220 emulator. Set the +sunKeyboard resource to true to force a Sun/PC keyboard to act like a +VT220 keyboard. + +The VT102/VT220 application keypad transmits unique escape sequences in +application mode, which are distinct from the cursor and scrolling +keypad: + + Key Numeric Application VT100? + -------------+----------+-------------+---------- + Space | SP | SS3 SP | no + Tab | TAB | SS3 I | no + Enter | CR | SS3 M | yes + PF1 | SS3 P | SS3 P | yes + PF2 | SS3 Q | SS3 Q | yes + PF3 | SS3 R | SS3 R | yes + PF4 | SS3 S | SS3 S | yes + * (multiply) | * | SS3 j | no + + (add) | + | SS3 k | no + , (comma) | , | SS3 l | yes + - (minus) | - | SS3 m | yes + . (period) | . | SS3 n | yes + / (divide) | / | SS3 o | no + 0 | 0 | SS3 p | yes + 1 | 1 | SS3 q | yes + 2 | 2 | SS3 r | yes + 3 | 3 | SS3 s | yes + 4 | 4 | SS3 t | yes + 5 | 5 | SS3 u | yes + 6 | 6 | SS3 v | yes + 7 | 7 | SS3 w | yes + 8 | 8 | SS3 x | yes + 9 | 9 | SS3 y | yes + = (equal) | = | SS3 X | no + -------------+----------+-------------+---------- + + +The VT100/VT220 keypad did not have all of those keys. They were +implemented in xterm in X11R1 (1987), defining a mapping of all X11 keys +which might be provided on a keypad. For instance, a Sun4/II type-4 +keyboard provided "=" (equal), "/" (divide), and "*" (multiply). + +While the VT420 provided the same keypad, the VT520 used a PC-keyboard. +Because that keyboard's keypad lacks the "," (comma), it was not +possible to use EDT's delete-character function with the keypad. XTerm +solves that problem for the VT220-keyboard configuration by mapping + + Ctrl + to , and + Ctrl - to - + +The VT220 provides a 6-key editing keypad, which is analogous to that on +the PC keyboard. It is not affected by DECCKM or DECKPNM/DECKPAM: + + Key Normal Application + ---------+----------+------------- + Insert | CSI 2 ~ | CSI 2 ~ + Delete | CSI 3 ~ | CSI 3 ~ + Home | CSI 1 ~ | CSI 1 ~ + End | CSI 4 ~ | CSI 4 ~ + PageUp | CSI 5 ~ | CSI 5 ~ + PageDown | CSI 6 ~ | CSI 6 ~ + ---------+----------+------------- + + +The VT220 provides 8 additional function keys. With a Sun/PC keyboard, +access these keys by Control/F1 for F13, etc. + + Key Escape Sequence + ---------+----------------- + F13 | CSI 2 5 ~ + F14 | CSI 2 6 ~ + F15 | CSI 2 8 ~ + F16 | CSI 2 9 ~ + F17 | CSI 3 1 ~ + F18 | CSI 3 2 ~ + F19 | CSI 3 3 ~ + F20 | CSI 3 4 ~ + ---------+----------------- + VT52-Style Function Keys -A VT52 does not have function keys, but it does have a numeric keypad and cursor keys. -They differ from the other emulations by the prefix. Also, the cursor keys do not change: +A VT52 does not have function keys, but it does have a numeric keypad +and cursor keys. They differ from the other emulations by the prefix. +Also, the cursor keys do not change: - Key Normal/Application - ---------------------------------- - Cursor Up ESC A - Cursor Down ESC B - Cursor Right ESC C - Cursor Left ESC D - ---------------------------------- + Key Normal/Application + -------------+-------------------- + Cursor Up | ESC A + Cursor Down | ESC B + Cursor Right | ESC C + Cursor Left | ESC D + -------------+-------------------- The keypad is similar: - Key Numeric Application - -------------------------------------- - Space SP ESC ? SP - Tab TAB ESC ? I - Enter CR ESC ? M - PF1 ESC P ESC P - PF2 ESC Q ESC Q - PF3 ESC R ESC R - PF4 ESC S ESC S - * (multiply) * ESC ? j - + (add) + ESC ? k - , (comma) , ESC ? l - - (minus) - ESC ? m - . (period) . ESC ? n - / (divide) / ESC ? o - 0 0 ESC ? p - 1 1 ESC ? q - 2 2 ESC ? r - 3 3 ESC ? s - 4 4 ESC ? t - 5 5 ESC ? u - 6 6 ESC ? v - 7 7 ESC ? w - 8 8 ESC ? x - 9 9 ESC ? y - = (equal) = ESC ? X - -------------------------------------- + Key Numeric Application VT52? + -------------+----------+-------------+---------- + Space | SP | ESC ? SP | no + Tab | TAB | ESC ? I | no + Enter | CR | ESC ? M | no + PF1 | ESC P | ESC P | yes + PF2 | ESC Q | ESC Q | yes + PF3 | ESC R | ESC R | yes + PF4 | ESC S | ESC S | no + * (multiply) | * | ESC ? j | no + + (add) | + | ESC ? k | no + , (comma) | , | ESC ? l | no + - (minus) | - | ESC ? m | no + . (period) | . | ESC ? n | yes + / (divide) | / | ESC ? o | no + 0 | 0 | ESC ? p | yes + 1 | 1 | ESC ? q | yes + 2 | 2 | ESC ? r | yes + 3 | 3 | ESC ? s | yes + 4 | 4 | ESC ? t | yes + 5 | 5 | ESC ? u | yes + 6 | 6 | ESC ? v | yes + 7 | 7 | ESC ? w | yes + 8 | 8 | ESC ? x | yes + 9 | 9 | ESC ? y | yes + = (equal) | = | ESC ? X | no + -------------+----------+-------------+---------- + Sun-Style Function Keys -The xterm2 program provides support for Sun keyboards more directly, by a menu toggle -that causes it to send Sun-style function key codes rather than VT220. Note, however, -that the sun2 and VT1002 emulations are not really compatible. For example, their -wrap-margin behavior differs. Only function keys are altered; keypad and cursor keys -are the same. The emulation responds identically. See the xterm-sun terminfo entry for -details. +The xterm program provides support for Sun keyboards more directly, by a +menu toggle that causes it to send Sun-style function key codes rather +than VT220. Note, however, that the sun and VT100 emulations are not +really compatible. For example, their wrap-margin behavior differs. + +Only function keys are altered; keypad and cursor keys are the same. +The emulation responds identically. See the xterm-sun terminfo entry +for details. + HP-Style Function Keys -Similarly, xterm2 can be compiled to support HP keyboards. See the xterm-hp terminfo -entry for details. +Similarly, xterm can be compiled to support HP keyboards. See the +xterm-hp terminfo entry for details. + + +Non-Function Keys + +On a DEC terminal keyboard, some of the keys which one would expect to +see labeled as function keys had special names. The keys actually send +character sequences as if they were the expected function keys, but the +special names are used in documentation. Because other keyboards may +use those names, xterm maps the X key symbols which have the +corresponding names into the character sequences which the original DEC +keyboard would send. + +These mappings are used for the DEC (VT220) and other keyboards: + + Label DEC SUN HP SCO + --------------+------------+--------------+----------+---------- + Up | SS3 A | SS3 A | ESC A | CSI A + Down | SS3 B | SS3 B | ESC B | CSI B + Right | SS3 C | SS3 C | ESC C | CSI C + Left | SS3 D | SS3 D | ESC D | CSI D + Clear | - | - | ESC J | - + Find | CSI 1 ~ | CSI 1 z | ESC h | - + Insert | CSI 2 ~ | CSI 2 z | ESC Q | CSI L + Delete | CSI 3 ~ | CSI 3 z | ESC P | - + Keypad Insert | CSI 2 ~ | CSI 2 z | ESC Q | CSI L + Keypad Delete | CSI 3 ~ | CSI 3 z | ESC P | - + Remove | CSI 3 ~ | CSI 3 z | ESC P | - + Select | CSI 4 ~ | CSI 4 z | ESC F | - + Prior | CSI 5 ~ | CSI 2 1 6 z | ESC T | CSI I + Next | CSI 6 ~ | CSI 2 2 2 z | ESC S | CSI G + Help | CSI 2 8 ~ | CSI 1 9 6 z | - | - + Menu | CSI 2 9 ~ | CSI 1 9 7 z | - | - + Home | - | CSI 2 1 4 z | ESC h | CSI H + End | - | CSI 2 2 0 z | ESC F | CSI F + Begin | - | CSI 2 1 8 z | - | CSI E + --------------+------------+--------------+----------+---------- + + The Alternate Screen Buffer -Xterm maintains two screen buffers. The normal screen buffer allows you to scroll -back to view saved lines of output up to the maximum set by the saveLines resource. -The alternate screen buffer is exactly as large as the display, contains no additional -saved lines. When the alternate screen buffer is active, you cannot scroll back to view -saved lines. Xterm provides control sequences and menu entries for switching between -the two. Most full-screen applications use terminfo or termcap to obtain strings used -to start/stop full-screen mode, i.e., smcup2 and rmcup2 for terminfo, or the -corresponding ti2 and te2 for termcap. The titeInhibit resource removes the ti2 and -te2 strings from the TERMCAP string which is set in the environment for some platforms. -That is not done when xterm is built with terminfo libraries because terminfo does -not provide the whole text of the termcap data in one piece. It would not work for ter- -minfo anyway, since terminfo data is not passed in environment vari- ables; setting an -environment variable in this manner would have no effect on the application's ability -to switch between normal and alter- nate screen buffers. Instead, the newer private -mode controls (such as 1 0 4 9 ) for switching between normal and alternate screen -buffers sim- ply disable the switching. They add other features such as clearing the -display for the same reason: to make the details of switching indepen- dent of the -application that requests the switch. +XTerm maintains two screen buffers. The Normal Screen Buffer allows you +to scroll back to view saved lines of output up to the maximum set by +the saveLines resource. The Alternate Screen Buffer is exactly as large +as the display, contains no additional saved lines. When the Alternate +Screen Buffer is active, you cannot scroll back to view saved lines. +XTerm provides control sequences and menu entries for switching between +the two. + +Most full-screen applications use terminfo or termcap to obtain strings +used to start/stop full-screen mode, i.e., smcup and rmcup for terminfo, +or the corresponding ti and te for termcap. The titeInhibit resource +removes the ti and te strings from the TERMCAP string which is set in +the environment for some platforms. That is not done when xterm is +built with terminfo libraries because terminfo does not provide the +whole text of the termcap data in one piece. It would not work for +terminfo anyway, since terminfo data is not passed in environment +variables; setting an environment variable in this manner would have no +effect on the application's ability to switch between Normal and +Alternate Screen buffers. Instead, the newer private mode controls +(such as 1 0 4 9 ) for switching between Normal and Alternate Screen +buffers simply disable the switching. They add other features such as +clearing the display for the same reason: to make the details of +switching independent of the application that requests the switch. + Bracketed Paste Mode -When bracketed paste mode is set, pasted text is bracketed with control sequences so -that the program can differentiate pasted text from typed- in text. When bracketed -paste mode is set, the program will receive: ESC [ 200 ~, followed by the pasted text, -followed by ESC [ 201 ~. +When bracketed paste mode is set, pasted text is bracketed with control +sequences so that the program can differentiate pasted text from typed- +in text. When bracketed paste mode is set, the program will receive: + ESC [ 2 0 0 ~ , +followed by the pasted text, followed by + ESC [ 2 0 1 ~ . +For background and discussion, see the FAQ: + + XTerm - bracketed-paste + + + +Readline Modes + +Several modes provide support for mouse button events in readline. +Bracketed paste is one of these readline modes, but is used more widely. + +Some assumptions (particular mouse buttons) and limitations (the mouse +is clicked on the current row on the screen) apply: + +2 0 0 1 If mouse button 1 is used to end or extend a selection (the + select-end action), and if the cursor position is on the same + row as the mouse-click, send left/right cursor control + sequences to the host to adjust the cursor position to match + the mouse click. + +2 0 0 2 When pasting text (the insert-selection action which is + normally bound to mouse button 2), if mouse protocol is not + enabled, and if the cursor position is on the same row as the + mouse-click, send left/right cursor control sequences to the + host to adjust the cursor position to match the mouse click. + +2 0 0 3 If mouse button 3 is double-clicked when ending or extending a + selection, (the select-end action), and if the cursor position + is on the same line as the mouse-click: + + o Send left/right cursor control sequences to the host to + adjust the cursor position to match the mouse click. + + o In addition to the same row, the selection may be part of + a wrapped line as in other xterm selections (see the + Selection Functions section in the manual page). + + o After adjusting the cursor position, xterm sends erase- + characters (one for each character in the selection) to + tell the host to delete the selected text. + +2 0 0 5 When writing a selection to the host (i.e., pasting text), + escape each character with the literal-next (Ctrl-V) + character. + +2 0 0 6 Normally when xterm writes selections to the host, it + translates newlines to carriage returns. This mode disables + the translation, passing newlines literally. + + +Title Modes + +The window- and icon-labels can be set or queried using control +sequences. As a VT220-emulator, xterm "should" limit the character +encoding for the corresponding strings to ISO-8859-1. Indeed, it used +to be the case (and was documented) that window titles had to be +ISO-8859-1. This is no longer the case. However, there are many +applications which still assume that titles are set using ISO-8859-1. +So that is the default behavior. + +If xterm is running with UTF-8 encoding, it is possible to use window- +and icon-labels encoded using UTF-8. That is because the underlying X +libraries (and many, but not all) window managers support this feature. + +The utf8Title X resource setting tells xterm to disable a reconversion +of the title string back to ISO-8859-1, allowing the title strings to be +interpreted as UTF-8. The same feature can be enabled using the title +mode control sequence described in this summary. + +Separate from the ability to set the titles, xterm provides the ability +to query the titles, returning them either in ISO-8859-1 or UTF-8. This +choice is available only while xterm is using UTF-8 encoding. + +Finally, the characters sent to, or returned by a title control are less +constrained than the rest of the control sequences. To make them more +manageable (and constrained), for use in shell scripts, xterm has an +optional feature which decodes the string from hexadecimal (for setting +titles) or for encoding the title into hexadecimal when querying the +value. + Mouse Tracking -The VT widget can be set to send the mouse position and other informa- tion on button -presses. These modes are typically used by editors and other full-screen applications -that want to make use of the mouse. +The VT widget can be set to send the mouse position and other +information on button presses. These modes are typically used by +editors and other full-screen applications that want to make use of the +mouse. + +There are two sets of mutually exclusive modes: + +o mouse protocol + +o protocol encoding -There are six mutually exclusive modes. One is DEC Locator mode, enabled by the DECELR -CSI Ps2 ; Ps2 ´z control sequence, and is not described here (control sequences are -summarized above). The remaining five modes are each enabled (or disabled) by a -different parameter in DECSET CSI ? Pm2 h or DECRST CSI ? Pm2 l control sequence. +The mouse protocols include DEC Locator mode, enabled by the DECELR CSI +Ps ; Ps ' z control sequence, and is not described here (control +sequences are summarized above). The remaining five modes of the mouse +protocols are each enabled (or disabled) by a different parameter in the +"DECSET CSI ? Pm h " or "DECRST CSI ? Pm l " control sequence. Manifest constants for the parameter values are defined in xcharmouse.h as follows: - #define SET_X10_MOUSE 9 - #define SET_VT200_MOUSE 1000 - #define SET_VT200_HIGHLIGHT_MOUSE 1001 - #define SET_BTN_EVENT_MOUSE 1002 - #define SET_ANY_EVENT_MOUSE 1003 + #define SET_X10_MOUSE 9 + #define SET_VT200_MOUSE 1000 + #define SET_VT200_HIGHLIGHT_MOUSE 1001 + #define SET_BTN_EVENT_MOUSE 1002 + #define SET_ANY_EVENT_MOUSE 1003 + + #define SET_FOCUS_EVENT_MOUSE 1004 + + #define SET_ALTERNATE_SCROLL 1007 + + #define SET_EXT_MODE_MOUSE 1005 + #define SET_SGR_EXT_MODE_MOUSE 1006 + #define SET_URXVT_EXT_MODE_MOUSE 1015 + #define SET_PIXEL_POSITION_MOUSE 1016 + +The motion reporting modes are strictly xterm extensions, and are not +part of any standard, though they are analogous to the DEC VT200 DECELR +locator reports. + +Normally, parameters (such as pointer position and button number) for +all mouse tracking escape sequences generated by xterm encode numeric +parameters in a single character as value+32. For example, ! specifies +the value 1. The upper left character position on the terminal is +denoted as 1,1. This scheme dates back to X10, though the normal mouse- +tracking (from X11) is more elaborate. -The motion reporting modes are strictly xterm2 extensions, and are not part of any -standard, though they are analogous to the DEC VT200 DECELR locator reports. -Parameters (such as pointer position and button number) for all mouse tracking escape -sequences generated by xterm2 encode numeric parameters in a single character as -value2+32. For example, ! specifies the value 1. The upper left character position on -the terminal is denoted as 1,1. +X10 compatibility mode -X10 compatibility mode sends an escape sequence only on button press, encoding the -location and the mouse button pressed. It is enabled by specifying parameter 9 to -DECSET. On button press, xterm2 sends CSI M CbCxCy2 (6 characters). Cb2 is button-1. -Cx2 and Cy2 are the x and y coor- dinates of the mouse when the button was pressed. +X10 compatibility mode sends an escape sequence only on button press, +encoding the location and the mouse button pressed. It is enabled by +specifying parameter 9 to DECSET. On button press, xterm sends CSI M +CbCxCy (6 characters). + +o Cb is button-1, where button is 1, 2 or 3. + +o Cx and Cy are the x and y coordinates of the mouse when the button + was pressed. + + +Normal tracking mode Normal tracking mode sends an escape sequence on both button press and -release. Modifier key (shift, ctrl, meta) information is also sent. It is enabled by -specifying parameter 1000 to DECSET. On button press or release, xterm2 sends CSI M -CbCxCy2. The low two bits of Cb2 encode button information: 0=MB1 pressed, 1=MB2 -pressed, 2=MB3 pressed, 3=release. The next three bits encode the modifiers which were -down when the button was pressed and are added together: 4=Shift, 8=Meta, 16=Control. -Note however that the shift and control bits are normally unavailable because xterm2 -uses the control modifier with mouse for popup menus, and the shift modifier is used in -the default translations for button events. The Meta2 modifier recognized by xterm2 is -the mod12 mask, and is not nec- essarily the "Meta" key (see xmodmap2). Cx2 and Cy2 are -the x and y coor- dinates of the mouse event, encoded as in X10 mode. - -Wheel mice may return buttons 4 and 5. Those buttons are represented by the same event -codes as buttons 1 and 2 respectively, except that 64 is added to the event code. -Release events for the wheel buttons are not reported. - -Mouse highlight tracking notifies a program of a button press, receives a range of -lines from the program, highlights the region covered by the mouse within that range -until button release, and then sends the program the release coordinates. It is enabled -by specifying parameter 1001 to DECSET. Highlighting is performed only for button 1, -though other but- ton events can be received. Warning: use of this mode requires a -coop- erating program or it will hang xterm.2 On button press, the same infor- mation -as for normal tracking is generated; xterm2 then waits for the program to send mouse -tracking information. All2 X2 events2 are2 ignored until2 the2 proper2 escape2 -sequence2 is2 received2 from2 the2 pty:2 CSI Ps2 ; Ps2 ; Ps2 ; Ps2 ; Ps2 T . The -parameters are func,2 startx,2 starty,2 firstrow,2 and lastrow.2 func2 is non-zero to -initiate highlight tracking and zero to abort. startx2 and starty2 give the starting x -and y location for the highlighted region. The ending location tracks the mouse, but -will never be above row firstrow2 and will always be above row lastrow.2 (The top of -the screen is row 1.) When the button is released, xterm2 reports the ending position -one of two ways: if the start and end coordinates are valid text locations: CSI t -CxCy2. If either coordinate is past the end of the line: CSI T CxCyCxCyCxCy2. The -parameters are startx,2 starty, endx,2 endy,2 mousex,2 and mousey.2 startx,2 starty,2 -endx,2 and endy2 give the starting and ending character positions of the region. -mousex2 and mousey2 give the location of the mouse at button up, which may not be over -a character. - -Button-event tracking is essentially the same as normal tracking, but xterm2 also -reports button-motion events. Motion events are reported only if the mouse pointer has -moved to a different character cell. It is enabled by specifying parameter 1002 to -DECSET. On button press or release, xterm2 sends the same codes used by normal tracking -mode. On button-motion events, xterm2 adds 32 to the event code (the third charac- ter, -Cb2). The other bits of the event code specify button and modifier keys as in normal -mode. For example, motion into cell x,y with button 1 down is reported as CSI M @ -CxCy2. ( @ = 32 + 0 (button 1) + 32 (motion indicator) ). Similarly, motion with button -3 down is reported as CSI M B CxCy2. ( B = 32 + 2 (button 3) + 32 (motion indicator) ). - -Any-event mode is the same as button-event mode, except that all motion events are -reported, even if no mouse button is down. It is enabled by specifying 1003 to DECSET. +release. Modifier key (shift, ctrl, meta) information is also sent. It +is enabled by specifying parameter 1000 to DECSET. On button press or +release, xterm sends CSI M CbCxCy. + +o The low two bits of Cb encode button information: + + 0=MB1 pressed, + 1=MB2 pressed, + 2=MB3 pressed, and + 3=release. + +o The next three bits encode the modifiers which were down when the + button was pressed and are added together: + + 4=Shift, + 8=Meta, and + 16=Control. + + The shift and control modifiers are normally irrelevant because + xterm uses the control modifier with mouse for popup menus, and the + shift modifier is used in the default translations for button + events. + + There is no predefined meta modifier. XTerm checks first if the + keysyms listed in the predefined modifiers include Meta_L or Meta_R. + If found, xterm uses that modifier for meta. Next, it tries Alt_L + or Alt_R. If none of those are found, xterm uses the mod1 modifier, + This is not necessarily the "Meta" key according to xmodmap(1). + +o Cx and Cy are the x and y coordinates of the mouse event, encoded as + in X10 mode. + + +Wheel mice + +Wheel mice may return buttons 4 and 5. Those buttons are represented by +the same event codes as buttons 1 and 2 respectively, except that 64 is +added to the event code. Release events for the wheel buttons are not +reported. + +By default, the wheel mouse events (buttons 4 and 5) are translated to +scroll-back and scroll-forw actions, respectively. Those actions +normally scroll the whole window, as if the scrollbar was used. + +However if Alternate Scroll mode is set, then cursor up/down controls +are sent when the terminal is displaying the Alternate Screen Buffer. +The initial state of Alternate Scroll mode is set using the +alternateScroll resource. + + +Other buttons + +Some wheel mice can send additional button events, e.g., by tilting the +scroll wheel left and right. + +Additional buttons are encoded like the wheel mice, + +o by adding 64 (for buttons 6 and 7), or + +o by adding 128 (for buttons 8 through 11). + +Past button 11, the encoding is ambiguous because the same code may +correspond to different button/modifier combinations. + +It is not possible to use these buttons (6-11) in xterm's translations +resource because their names are not in the X Toolkit's symbol table. +However, applications can check for the reports, e.g., button 7 (left) +and button 6 (right) with a Logitech mouse. + + +Highlight tracking + +Mouse highlight tracking notifies a program of a button press, receives +a range of lines from the program, highlights the region covered by the +mouse within that range until button release, and then sends the program +the release coordinates. It is enabled by specifying parameter 1001 to +DECSET. Highlighting is performed only for button 1, though other +button events can be received. + +Warning: this mode requires a cooperating program, else xterm will hang. + +On button press, the same information as for normal tracking is +generated; xterm then waits for the program to send mouse tracking +information. All X events are ignored until the proper escape sequence +is received from the pty: +CSI Ps ; Ps ; Ps ; Ps ; Ps T + +The parameters are func, startx, starty, firstrow, and lastrow: + +o func is non-zero to initiate highlight tracking and zero to abort. + +o startx and starty give the starting x and y location for the + highlighted region. + +o The ending location tracks the mouse, but will never be above row + firstrow and will always be above row lastrow. (The top of the + screen is row 1.) + +When the button is released, xterm reports the ending position one of +two ways: + +o if the start and end coordinates are the same locations: + + CSI t CxCy + +o otherwise: + + CSI T CxCyCxCyCxCy + +The parameters are startx, starty, endx, endy, mousex, and mousey: + +o startx, starty, endx, and endy give the starting and ending + character positions of the region. + +o mousex and mousey give the location of the mouse at button up, which + may not be over a character. + + +Button-event tracking + +Button-event tracking is essentially the same as normal tracking, but +xterm also reports button-motion events. Motion events are reported +only if the mouse pointer has moved to a different character cell. It +is enabled by specifying parameter 1002 to DECSET. On button press or +release, xterm sends the same codes used by normal tracking mode. + +o On button-motion events, xterm adds 32 to the event code (the third + character, Cb). + +o The other bits of the event code specify button and modifier keys as + in normal mode. For example, motion into cell x,y with button 1 + down is reported as + + CSI M @ CxCy + + ( @ = 32 + 0 (button 1) + 32 (motion indicator) ). Similarly, + motion with button 3 down is reported as + + CSI M B CxCy + + ( B = 32 + 2 (button 3) + 32 (motion indicator) ). + + +Any-event tracking + +Any-event mode is the same as button-event mode, except that all motion +events are reported, even if no mouse button is down. It is enabled by +specifying 1003 to DECSET. + + +FocusIn/FocusOut + +FocusIn/FocusOut can be combined with any of the mouse events since it +uses a different protocol. When set, it causes xterm to send CSI I +when the terminal gains focus, and CSI O when it loses focus. + + +Extended coordinates + +The original X10 mouse protocol limits the Cx and Cy ordinates to 223 +(=255 - 32). XTerm supports more than one scheme for extending this +range, by changing the protocol encoding: + +UTF-8 (1005) + This enables UTF-8 encoding for Cx and Cy under all tracking + modes, expanding the maximum encodable position from 223 to + 2015. For positions less than 95, the resulting output is + identical under both modes. Under extended mouse mode, + positions greater than 95 generate "extra" bytes which will + confuse applications which do not treat their input as a UTF-8 + stream. Likewise, Cb will be UTF-8 encoded, to reduce + confusion with wheel mouse events. + + Under normal mouse mode, positions outside (160,94) result in + byte pairs which can be interpreted as a single UTF-8 + character; applications which do treat their input as UTF-8 + will almost certainly be confused unless extended mouse mode + is active. + + This scheme has the drawback that the encoded coordinates will + not pass through luit(1) unchanged, e.g., for locales using + non-UTF-8 encoding. + +SGR (1006) + The normal mouse response is altered to use + + o CSI < followed by semicolon-separated + + o encoded button value, + + o Px and Py ordinates and + + o a final character which is M for button press and m for + button release. + + The encoded button value in this case does not add 32 since + that was useful only in the X10 scheme for ensuring that the + byte containing the button value is a printable code. + + o The modifiers are encoded in the same way. + + o A different final character is used for button release to + resolve the X10 ambiguity regarding which button was + released. + + The highlight tracking responses are also modified to an SGR- + like format, using the same SGR-style scheme and button- + encodings. + +URXVT (1015) + The normal mouse response is altered to use + + o CSI followed by semicolon-separated + + o encoded button value, + + o the Px and Py ordinates and final character M . + + This uses the same button encoding as X10, but printing it as + a decimal integer rather than as a single byte. + + However, CSI M can be mistaken for DL (delete lines), while + the highlight tracking CSI T can be mistaken for SD (scroll + down), and the Window manipulation controls. For these + reasons, the 1015 control is not recommended; it is not an + improvement over 1006. + +SGR-Pixels (1016) + Use the same mouse response format as the 1006 control, but + report position in pixels rather than character cells. + + +Graphics + + +Sixel Graphics + +If xterm is configured as VT240, VT241, VT330, VT340 or VT382 using the +decTerminalID or decGraphicsID resource, it supports Sixel Graphics +controls, a paletted bitmap graphics system using sets of six vertical +pixels as the basic element. + +CSI Ps c Send Device Attributes (Primary DA), DEC graphics terminals, + xterm. xterm responds to Send Device Attributes (Primary DA) + with these additional codes: + Ps = 4 -> Sixel graphics. + +CSI ? Pm h + Set Mode (with corresponding Reset Mode CSI ? Pm l ): + Ps = 8 0 -> Sixel Display Mode (DECSDM), VT330, VT340, + VT382. + Ps = 1 0 7 0 -> use private color registers for each + graphic, xterm. + Ps = 8 4 5 2 -> Sixel scrolling leaves cursor to right of + graphic, RLogin, xterm. + +DCS Pa ; Pb ; Ph q Ps..Ps ST + Send SIXEL image, DEC graphics terminals, VT330, VT340, VT382. + See: + + VT330/VT340 Programmer Reference Manual Volume 2: + Graphics Programming + Chapter 14 Graphics Programming + + The sixel data device control string has three positional + parameters, following the q with sixel data. + Pa -> pixel aspect ratio + Pb -> background color option + Ph -> horizontal grid size (ignored). + Ps -> sixel data + + +ReGIS Graphics + +If xterm is configured as VT125, VT240, VT241, VT330 or VT340 using the +decTerminalID or decGraphicsID resource, it supports Remote Graphic +Instruction Set, a graphics description language. + +CSI Ps c Send Device Attributes (Primary DA), DEC graphics terminals, + xterm. xterm responds to Send Device Attributes (Primary DA) + with these additional codes: + Ps = 3 -> ReGIS graphics. + +CSI ? Pm h + Set Mode, xterm. xterm has these additional private Set Mode + values: + Ps = 1 0 7 0 -> use private color registers for each + graphic. + +DCS Pm p Pr..Pr ST + Enter or exit ReGIS, VT300, xterm. See: + + VT330/VT340 Programmer Reference Manual Volume 2: + Graphics Programming + Chapter 1 Introduction to ReGIS + + The ReGIS data device control string has one positional + parameter with four possible values: + Pm = 0 -> resume command, use fullscreen mode. + Pm = 1 -> start new command, use fullscreen mode. + Pm = 2 -> resume command, use command display mode. + Pm = 3 -> start new command, use command display mode. + +A few of the VT330/VT340 private modes conflict with xterm. Codes 4 0 +to 4 7 were first used by xterm in X10R4 (December 1986). While X11R1 +xterm dropped codes 4 1 and 4 2 , the remaining ones are still used. +The VT330/VT340 introduced in April 1987 uses 4 4 to 4 7 for color +graphics printing controls. When configured for ReGIS, xterm uses the +VT330/VT340 interpretation of these private modes. + + +Non-VT100 Modes + Tektronix 4014 Mode -Most of these sequences are standard Tektronix 4014 control sequences. Graph mode -supports the 12-bit addressing of the Tektronix 4014. The major features missing are -the write-through and defocused modes. This document does not describe the commands -used in the various Tektronix plotting modes but does describe the commands to switch -modes. - -BEL Bell (Ctrl-G) -BS Backspace (Ctrl-H) -TAB Horizontal Tab (Ctrl-I) -LF Line Feed or New Line (Ctrl-J) -VT Cursor up (Ctrl-K) -FF Form Feed or New Page (Ctrl-L) -CR Carriage Return (Ctrl-M) -ESC ETX Switch to VT100 Mode (ESC Ctrl-C) -ESC ENQ Return Terminal Status (ESC Ctrl-E) -ESC FF PAGE (Clear Screen) (ESC Ctrl-L) -ESC SO Begin 4015 APL mode (ignored by xterm2) (ESC Ctrl-N) -ESC SI End 4015 APL mode (ignored by xterm2) (ESC Ctrl-O) -ESC ETB COPY (Save Tektronix Codes to file COPYyyyy-mm- - dd.hh:mm:ss) (ESC Ctrl-W) -ESC CAN Bypass Condition (ESC Ctrl-X) -ESC SUB GIN mode (ESC Ctrl-Z) -ESC FS Special Point Plot Mode (ESC Ctrl-\) -ESC 8 Select Large Character Set -ESC 9 Select #2 Character Set -ESC : Select #3 Character Set -ESC ; Select Small Character Set -OSC Ps2 ; Pt2 BEL - Set Text Parameters of VT window - Ps2 = 0 -> Change Icon Name and Window Title to Pt - Ps2 = 1 -> Change Icon Name to Pt - Ps2 = 2 -> Change Window Title to Pt - Ps2 = 4 6 -> Change Log File to Pt2 (normally disabled - by a compile-time option) -ESC ` Normal Z Axis and Normal (solid) Vectors -ESC a Normal Z Axis and Dotted Line Vectors -ESC b Normal Z Axis and Dot-Dashed Vectors -ESC c Normal Z Axis and Short-Dashed Vectors -ESC d Normal Z Axis and Long-Dashed Vectors -ESC h Defocused Z Axis and Normal (solid) Vectors -ESC i Defocused Z Axis and Dotted Line Vectors -ESC j Defocused Z Axis and Dot-Dashed Vectors -ESC k Defocused Z Axis and Short-Dashed Vectors -ESC l Defocused Z Axis and Long-Dashed Vectors -ESC p Write-Thru Mode and Normal (solid) Vectors -ESC q Write-Thru Mode and Dotted Line Vectors -ESC r Write-Thru Mode and Dot-Dashed Vectors -ESC s Write-Thru Mode and Short-Dashed Vectors -ESC t Write-Thru Mode and Long-Dashed Vectors -FS Point Plot Mode (Ctrl-\) -GS Graph Mode (Ctrl-]) -RS Incremental Plot Mode (Ctrl-^) -US Alpha Mode (Ctrl-_) +Most of these sequences are standard Tektronix 4014 control sequences. +Graph mode supports the 12-bit addressing of the Tektronix 4014. The +major features missing are the write-through and defocused modes. This +document does not describe the commands used in the various Tektronix +plotting modes but does describe the commands to switch modes. + +Some of the sequences are specific to xterm. The Tektronix emulation +was added in X10R4 (1986). The VT240, introduced two years earlier, +also supported Tektronix 4010/4014. Unlike xterm, the VT240 +documentation implies (there is an obvious error in section 6.9 +"Entering and Exiting 4010/4014 Mode") that exiting back to ANSI mode is +done by resetting private mode 3 8 (DECTEK) rather than ESC ETX . A +real Tektronix 4014 would not respond to either. + +BEL Bell (Ctrl-G). + +BS Backspace (Ctrl-H). + +TAB Horizontal Tab (Ctrl-I). + +LF Line Feed or New Line (Ctrl-J). + +VT Cursor up (Ctrl-K). + +FF Form Feed or New Page (Ctrl-L). + +CR Carriage Return (Ctrl-M). + +ESC ETX Switch to VT100 Mode (ESC Ctrl-C). + +ESC ENQ Return Terminal Status (ESC Ctrl-E). + +ESC FF PAGE (Clear Screen) (ESC Ctrl-L). + +ESC SO Begin 4015 APL mode (ESC Ctrl-N). This is ignored by xterm. + +ESC SI End 4015 APL mode (ESC Ctrl-O). This is ignored by xterm. + +ESC ETB COPY (Save Tektronix Codes to file COPYyyyy-mm-dd.hh:mm:ss). + ETB (end transmission block) is the same as Ctrl-W. + +ESC CAN Bypass Condition (ESC Ctrl-X). + +ESC SUB GIN mode (ESC Ctrl-Z). + +ESC FS Special Point Plot Mode (ESC Ctrl-\). + +ESC 8 Select Large Character Set. + +ESC 9 Select #2 Character Set. + +ESC : Select #3 Character Set. + +ESC ; Select Small Character Set. + +OSC Ps ; Pt BEL + Set Text Parameters of VT window. + Ps = 0 -> Change Icon Name and Window Title to Pt. + Ps = 1 -> Change Icon Name to Pt. + Ps = 2 -> Change Window Title to Pt. + Ps = 4 6 -> Change Log File to Pt. This is normally + disabled by a compile-time option. + +ESC ` Normal Z Axis and Normal (solid) Vectors. + +ESC a Normal Z Axis and Dotted Line Vectors. + +ESC b Normal Z Axis and Dot-Dashed Vectors. + +ESC c Normal Z Axis and Short-Dashed Vectors. + +ESC d Normal Z Axis and Long-Dashed Vectors. + +ESC h Defocused Z Axis and Normal (solid) Vectors. + +ESC i Defocused Z Axis and Dotted Line Vectors. + +ESC j Defocused Z Axis and Dot-Dashed Vectors. + +ESC k Defocused Z Axis and Short-Dashed Vectors. + +ESC l Defocused Z Axis and Long-Dashed Vectors. + +ESC p Write-Thru Mode and Normal (solid) Vectors. + +ESC q Write-Thru Mode and Dotted Line Vectors. + +ESC r Write-Thru Mode and Dot-Dashed Vectors. + +ESC s Write-Thru Mode and Short-Dashed Vectors. + +ESC t Write-Thru Mode and Long-Dashed Vectors. + +FS Point Plot Mode (Ctrl-\). + +GS Graph Mode (Ctrl-]). + +RS Incremental Plot Mode (Ctrl-^ ). + +US Alpha Mode (Ctrl-_). + VT52 Mode -Parameters for cursor movement are at the end of the ESC Y escape sequence. Each -ordinate is encoded in a single character as value2+32. For example, ! is 1. The screen -coordinate system is 0-based. - -ESC A Cursor up. -ESC B Cursor down. -ESC C Cursor right. -ESC D Cursor left. -ESC F Enter graphics mode. -ESC G Exit graphics mode. -ESC H Move the cursor to the home position. -ESC I Reverse line feed. -ESC J Erase from the cursor to the end of the screen. -ESC K Erase from the cursor to the end of the line. -ESC Y Ps2 Ps2 Move the cursor to given row and column. -ESC Z Identify - -> ESC / Z (``I am a VT52.'') -ESC = Enter alternate keypad mode. -ESC > Exit alternate keypad mode. -ESC < Exit VT52 mode (Enter VT100 mode). +Parameters for cursor movement are at the end of the ESC Y escape +sequence. Each ordinate is encoded in a single character as value+32. +For example, ! is 1. The screen coordinate system is 0-based. + +ESC < Exit VT52 mode (Enter VT100 mode). + +ESC = Enter alternate keypad mode. + +ESC > Exit alternate keypad mode. + +ESC A Cursor up. + +ESC B Cursor down. + +ESC C Cursor right. + +ESC D Cursor left. + +ESC F Enter graphics mode. + +ESC G Exit graphics mode. + +ESC H Move the cursor to the home position. + +ESC I Reverse line feed. + +ESC J Erase from the cursor to the end of the screen. + +ESC K Erase from the cursor to the end of the line. + +ESC Y Ps Ps + Move the cursor to given row and column. + +ESC Z Identify. + -> ESC / Z ("I am a VT52."). + + +Further reading + + +Technical manuals + +Manuals for hardware terminals are more readily available than +similarly-detailed documentation for terminal emulators such as aixterm, +shelltool, dtterm. + +However long, the technical manuals have problems: + +o DEC's manuals did not provide a comprehensive comparison of the + features in different model. + + Host Interface Functions Checklist by Peter Sichel (January 12, + 1994) is helpful. This spreadsheet is useful for noting which model + introduced a given feature (although there are a few apparent errors + such as the DECRQSS feature cited for VT320 whereas the technical + manual omits it). + +o Sometimes the manuals disagree. For example, DEC's standard + document (DEC STD 070) for terminals says that DECSCL performs a + soft reset (DECSTR), while the VT420 manual says it does a hard + reset (RIS). + +o Sometimes the manuals are simply incorrect. For example, testing a + DEC VT420 in 1996 showed that the documented code for a valid or + invalid response to DECRQSS was reversed. + + The VT420 test results were incorporated into the vttest program. + At the time, DEC STD 070 was not available, but it also agrees with + vttest. Later, documentation for the DEC VT525 was shown to have + the same flaw. + +o The VT330/VT340 reference manual for graphics programming documents + sixel graphics in some detail in chapter 14. Overlooked in the + first edition, the second edition mentions Sixel Scrolling. The + VT382 Kanji and Thai manuals provide less information, about sixel + graphics, but do mention DECSDM. They differ in their comment about + the private mode DECSDM (CSI ? 8 0 h ), which each manual agrees + should set the Sixel Scrolling feature. The VT330/VT340 graphics + programming manual (second edition, March 1988) says + + When sixel display mode is set, the Sixel Scrolling feature is + enabled. + When sixel display mode is reset, the Sixel Scrolling feature is + disabled. + + while the VT382 Kanji manual (page 6-6, undated) says + + Disable sixel scroll + + and the VT382 Thai manual (page C-30, August 1989) says + + No Sixel scrolling + + The standard (DEC STD 070) in chapter 9 (August 3, 1990) states on + page 17 that video devices will scroll when advancing the Sixel + active position past the bottom margin, but on page 19, in the + section on deviations, states that VT125 and VT240 did not scroll in + this situation. The standard does not mention VT330/VT340 or VT382. + Nor does it document DECSDM. + +o Not all details are clear even in DEC STD 070 (which is more than + twice the length of the VT520 programmer's reference manual, and + almost three times longer than the VT420 reference manual). + However, as an internal standards document, DEC STD 070 is more + likely to describe the actual behavior of DEC's terminals than the + more polished user's guides. + +That said, here are technical manuals which have been used in developing +xterm. Not all were available initially. In August 1996 for instance, +the technical references were limited to EK-VT220-HR-002 and EK- +VT420-UG.002. Shortly after, Richard Shuford sent a copy of EK-VT3XX- +TP-001. Still later (beginning in 2003), Paul Williams' vt100.net site +provided EK-VT102-UG-003, EK-VT220-RM-002, EK-VT420-RM-002, EK-VT520-RM +A01, EK-VT100-TM-003, and EK-VT102-UG-003. In addition, several +documents were found on the bitsavers site. + +o DECscope User's Manual. + Digital Equipment Corporation (EK-VT5X-OP-001 1975). + +o VT100 Series Video Terminal Technical Manual. + Digital Equipment Corporation (EK-VT100-TM-003, July 1982). + +o VT100 User Guide. + Digital Equipment Corporation (EK-VT100-UG-003, June 1981). + +o VT102 User Guide. + Digital Equipment Corporation (EK-VT102-UG-003, February 1982). + +o VT220 Programmer Pocket Guide. + Digital Equipment Corporation (EK-VT220-HR-002, July 1984). + +o VT220 Programmer Reference Manual. + Digital Equipment Corporation (EK-VT220-RM-002, August 1984). + +o VT240 Programmer Reference Manual. + Digital Equipment Corporation (EK-VT240-RM-002, October 1984). + +o VT330/VT340 Programmer Reference Manual + Volume 1: Text Programming. + Digital Equipment Corporation (EK-VT3XX-TP-001, March 1987). + +o VT330/VT340 Programmer Reference Manual + Volume 2: Graphics Programming. + Digital Equipment Corporation (EK-VT3XX-GP-001, March 1987). + +o VT330/VT340 Programmer Reference Manual + Volume 2: Graphics Programming. + Digital Equipment Corporation (EK-VT3XX-GP-002, May 1988). + +o VT382 Kanji Display Terminal + Programmer Reference Manual. + Digital Equipment Corporation (EK-VT382-RM-001, undated). + +o VT382 Thai Display Terminal + Installing and Using Manual. + Digital Equipment Corporation (EK-VT38T-UG-001, August 1989). + +o Installing and Using + The VT420 Video Terminal + (North American Model). + Digital Equipment Corporation (EK-VT420-UG.002, February 1990). + +o VT420 Programmer Reference Manual. + Digital Equipment Corporation (EK-VT420-RM-002, February 1992). + +o VT510 Video Terminal + Programmer Information. + Digital Equipment Corporation (EK-VT510-RM B01, November 1993). + +o VT520/VT525 Video Terminal + Programmer Information. + Digital Equipment Corporation (EK-VT520-RM A01, July 1994). + +o Digital ANSI-Compliant Printing Protocol + Level 2 Programming Reference Manual + Digital Equipment Corporation (EK-PPLV2-PM B01, August 1994). + +o Disk Operating System + DOS 2.00 + Microsoft, Inc. + First edition, January 1983. + +o 4014 and 4014-1 Computer Display Terminal + User's Manual. + Tektronix, Inc. (070-1647-00, November 1979). + + +Standards + +The DEC terminal family (VT100 through VT525) is upward-compatible, +using standards plus extensions, e.g., "private modes". Not all +commonly-used features are standard. For example, scrolling regions are +not found in ECMA-48. On the other hand, ECMA-48 was not intended to be +all-encompassing. Quoting from the second edition: + + Full conformance to a standard means that all its requirements are + met. For such conformance to be unique the standard must contain no + options. This is typically the case for hardware standards, for + instance Standard ECMA-10 for data interchange on punched tapes. + + This Standard ECMA-48 is of a different nature and as a result, it + is only practicable to envisage limited conformance to it, as + defined hereunder. + + This Standard addresses a whole class of devices which can vary + greatly from each other depending on the application for which a + device has been specifically designed. Obviously, a product which + implements all facilities described in this standard - thus being in + "full conformance" with it - whilst theoretically possible, would be + technically and economically unthinkable. + +Again, it is possible to find discrepancies in the standards: + +o The printed ECMA-48 5th edition (1991) and the first PDF produced + for that edition (April 1998) state that SD (scroll down) ends with + 05/14, i.e., ^ , which disagrees with DEC's VT420 hardware + implementation and DEC's manuals which use 05/04 T . (A few other + terminals such as AT&T 5620 and IBM 5151 also used 05/04, but the + documentation and dates are lacking). + ECMA created a new PDF in April 2003 which changed that detail to + use T , and later in 2008 provided PDFs of the earlier editions + which used T . +o The first edition of ECMA-48 has not been available, to compare. As + of September 2021, ECMA's website provides a copy of ECMA-46 in its + place. + Earlier versions of ISO 6429 have never been available. The first + three editions of ISO 6429 were issued in 1983, 1988, and 1992. + +o ANSI X3.64-1979 does not list color as a feature of the SGR sequence + (page 49). + + In Appendix A, it mentions ECMA-48: + + (8) This document represents a coordinated effort to develop a + single technical standard in the United States and Europe (see + ECMA-48 standard entitled Additional Controls for Character + Imaging Input/Output Devices). + + Appendix H clarifies the relationship between these documents + somewhat though it confuses the first two editions of ECMA-48. The + typo for "work" versus "owkr" appears in the original document: + + ANSI X3.64-1979, and ECMA-48, Additional Controls for Character- + Imaging I/O Devices, were developed in parallel, with close + liaison. ISO DP 6429, Additional Control Functions for + Character-Imaging Devices, was developed as a synthesis of X3.64 + and ECMA-48. During this process, some control functions as + well as additional selective parameters were added. Except for + point 1 below, X3.64 is a subset of ISO 6429. Although the two + standards use different language, the intent is that the subset + is technically identical. X3.64 was balloted and forwarded + prior to the final resolution of ISO 6429 and does not + incorporate the owkr of IS0/TC97/SC2 in completing ISO 6429. + Revision of X3.64 will attempt to incorporate those elements and + assumptions of X3.64. + + ANSI X3.64 goes on to say that the SGR codes 8, 30-47 are in ISO + 6429. It includes 38 and 39, but omits 48 and 49. At the time, ISO + 6429's first edition was still four years in the future. The writer + probably was referring to the ongoing process of making ECMA-48 + second edition into the ISO standard. + +o The VT320, VT420, VT520 manuals claim that DECSCL does a hard reset + (RIS). + + Both the VT220 manual and DEC STD 070 (which documents levels 1-4 in + detail) state that it is a soft reset, e.g., DECSTR. + +Here are the relevant standards: + +o Additional Controls for Use with American National Standard Code for + Information Interchange, ANSI X3.64-1979 + FIPS Publication 86. July 18, 1979. + American National Standards Institute, Inc. + +o ECMA-35: Character Code Structure and Extension Techniques + (6th Edition, December 1994). + +o ECMA-43: 8-bit Coded Character Set Structure and Rules + (3rd Edition, December 1991). + +o ECMA-48: Control Functions for Coded Character Sets + (5th Edition, June 1991). + +o DEC STD 070 Video Systems Reference Manual. + Digital Equipment Corporation (A-MN-ELSM070-00-0000 Rev H, December + 3, 1991). + + +Miscellaneous + +A few hardware terminals survived into the 1990s only as terminal +emulators. Documentation for these and other terminal emulators which +have influenced xterm are generally available only in less-accessible +and less-detailed manual pages. + +o XTerm supports control sequences for manipulating its window which + were implemented by Sun's shelltool program. This was part of + SunView (SunOS 3.0, 1986). The change-notes for xterm's resize + program in X10.4 (1986) mention its use of these "Sun tty emulation + escape sequences" for resizing the window. The X10.4 xterm program + recognized these sequences for resizing the terminal, except for the + iconify/deiconify pair. SunView also introduced the SIGWINCH + signal, used by the X10.4 xterm and mentioned in its CHANGES file: + + The window size is passed to the operating system via TIOCSWINSZ + (4.3) or TIOCSSIZE (sun). A SIGWINCH signal is sent if the + vtXXX window is resized. + + While support for the Sun control-sequences remained in resize, the + next release of xterm (X11R1 in 1987) omitted the code for + interpreting them. + + Later, the SunView program was adapted for the OPEN LOOK environment + introduced 1988-1990. + + Still later, in 1995, OPEN LOOK was abandoned in favor of CDE. The + CDE terminal emulator dtterm implemented those controls, with a + couple of additions. + + Starting in July 1996, xterm re-implemented those control sequences + (based on the dtterm manual pages) and further extended the group of + window controls. + + There were two sets of controls (CSI Ps [ ; Pm ; Pm ] t , and OSC Ps + text ST ) implemented by shelltool, documented in appendix E of both + PHIGS Programming Manual (1992), and the unpublished X Window System + User's Guide (OPEN LOOK Edition) (1995). The CDE program kept + those, and added a few new ones. + + Code Sun CDE XTerm Description + -----------+-----+-----+-------+--------------------------------- + CSI 1 t | yes | yes | yes | de-iconify + CSI 2 t | yes | yes | yes | iconify + CSI 3 t | yes | yes | yes | move window to pixel-position + CSI 4 t | yes | yes | yes | resize window in pixels + CSI 5 t | yes | yes | yes | raise window to front of stack + CSI 6 t | yes | yes | yes | raise window to back of stack + CSI 7 t | yes | yes | yes | refresh window + CSI 8 t | yes | yes | yes | resize window in chars + CSI 9 t | - | - | yes | maximize/unmaximize window + CSI 1 0 t | - | - | yes | to/from full-screen + CSI 1 1 t | yes | yes | yes | report if window is iconified + CSI 1 2 t | - | - | - | - + CSI 1 3 t | yes | yes | yes | report window position + CSI 1 4 t | yes | yes | yes | report window size in pixels + CSI 1 5 t | - | - | yes | report screen size in pixels + CSI 1 6 t | - | - | yes | report character cell in pixels + CSI 1 7 t | - | - | - | - + CSI 1 8 t | yes | yes | yes | report window size in chars + CSI 1 9 t | - | - | yes | report screen size in chars + CSI 2 0 t | - | yes | yes | report icon label + CSI 2 1 t | - | yes | yes | report window title + CSI 2 2 t | - | - | yes | save window/icon title + CSI 2 3 t | - | - | yes | restore window/icon title + CSI 2 4 t | - | - | yes | resize window (DECSLPP) + OSC 0 ST | - | yes | yes | set window and icon title + OSC 1 ST | - | yes | yes | set icon label + OSC 2 ST | - | yes | yes | set window title + OSC 3 ST | - | n/a | yes | set X server property + OSC I ST | yes | yes | yes | set icon to file + OSC l ST | yes | yes | yes | set window title + OSC L ST | yes | yes | yes | set icon label + -----------+-----+-----+-------+--------------------------------- + + Besides the Sun-derived OSC controls for setting window title and + icon label, dtterm also supported the xterm controls for the same + feature. + + The CDE source was unavailable for inspection until 2012, so that + clarification of the details of the window operations relied upon + vttest. + +o The SCOSC/SCORC control sequences for saving/restoring the cursor + and for saving/restoring "DEC Private Mode Values" (XTSAVE and + XTRESTORE) may appear to be related (since the "save" controls both + end with s ), but that is coincidental. The latter was introduced + in X10.4 (December 1986): + + Most Dec Private mode settings can be saved away internally + using \E[?ns, where n is the same number to set or reset the Dec + Private mode. The mode can be restored using \E[?nr. This can + be used in termcap for vi(1), for example, to turn off saving of + lines, but restore whatever the original state was on exit. + + while the SCOSC/SCORC pair was added in 1995 by XFree86 (and + documented long afterwards). + + The SCO ANSI console terminal descriptions did not use these + controls (they used the VT100-compatible SC/RC pair). SCOSC/SCORC + were an artifact of DOS 2.00 (January 1983), by Microsoft and later + supported by SCO and other vendors. + + The SCOSC/SCORC pair is considered a private mode because the final + characters (s and u ) fall in the range from "`" to "~" (octal 0140 + to octal 0176). Other private control sequences can be constructed + by using octets 074 to 077 (characters "<", "=", ">", or "?") at the + beginning of the parameter string. The XTSAVE and XTRESTORE + controls use "?") in this manner. + + Because the XTSAVE and XTRESTORE controls are private, other + terminals may behave differently. For example, DEC (a contributor + to the early xterm as well as a manufacturer of terminals) used an + incompatible private control in one of its terminals more than five + years later (for the VT420 PCTerm, announced in February 1992). + + In that model of the VT420, CSI ? Pm; Pc r selects the PC TERM + emulation mode. When this mode is enabled, the keyboard sends scan + codes rather than characters (analogous to X keyboard events). The + first parameter of this private control enables or disables PC TERM + mode, while the second selects a character set. An ambiguity arises + if an application omits the second parameter. In that special case, + it cannot be distinguished from XTRESTORE. DEC did not take this + into account when designing the feature. + + If there were potential users, xterm could accommodate this by a + resource setting. In retrospect (thirty years later), there have + been no uses of PC TERM, while the XTRESTORE feature is still in + use. + +o The aixterm manual page gives the format of the control sequence for + foreground and background colors 8-15, but does not specify what + those colors are. That is implied by the description's mention of + HFT: + + The aixterm command provides a standard terminal type for + programs that do not interact directly with Enhanced X-Windows. + This command provides an emulation for a VT102 terminal or a + high function terminal (HFT). The VT102 mode is activated by + the -v flag. + + Unlike xterm, there are no resource names for the 16 colors, leaving + the reader to assume that the mapping is hard-coded. The control + sequences for colors 8-15 are not specified by ECMA-48, but rather + (as done in other instances by xterm) chosen to not conflict with + current or future standards. diff --git a/macsrc/tty/cygwin.cr b/macsrc/tty/cygwin.cr index a24bae81..5176df26 100644 --- a/macsrc/tty/cygwin.cr +++ b/macsrc/tty/cygwin.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: cygwin.cr,v 1.13 2014/10/22 02:34:39 ayoung Exp $ +/* $Id: cygwin.cr,v 1.14 2024/06/18 16:26:25 cvsuser Exp $ * terminal description for the cygwin window * * @@ -175,7 +175,7 @@ main() /* - * cygwin_colour256 --- + * cygwin_256color --- * Color terminal. * * Usage: @@ -189,3 +189,4 @@ cygwin_256color(void) } + diff --git a/macsrc/tty/sun.cr b/macsrc/tty/sun.cr index 4265b78f..abbc516a 100644 --- a/macsrc/tty/sun.cr +++ b/macsrc/tty/sun.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: sun.cr,v 1.8 2014/10/27 23:28:33 ayoung Exp $ +/* $Id: sun.cr,v 1.9 2024/09/20 12:15:15 cvsuser Exp $ * terminal description for variety of Sun based applications. * * The GRTERM entry should start with 'sun', and then you can append 'type3' if you have an old @@ -73,8 +73,8 @@ main() NULL, "\x1B[209z", NULL, NULL, "\x1B[231z"), ALT_0_9, quote_list( - "\xB0", "\xB1", "\xB2", "\xB3", "\xB4", - "\xB5", "\xB6", "\xB7", "\xB8", "\xB9") + "\xB0", "\xB1", "\xB2", "\xB3", "\xB4", /* ALT-0..4 */ + "\xB5", "\xB6", "\xB7", "\xB8", "\xB9") /* ALT-5..9 */ ); } @@ -229,3 +229,4 @@ xmodmap() } /*end*/ + diff --git a/macsrc/tty/suncmd.cr b/macsrc/tty/suncmd.cr index fb38dc2e..5b76348d 100644 --- a/macsrc/tty/suncmd.cr +++ b/macsrc/tty/suncmd.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: suncmd.cr,v 1.3 2014/06/27 19:22:21 ayoung Exp $ +/* $Id: suncmd.cr,v 1.4 2024/09/20 12:15:15 cvsuser Exp $ * This file can be used for a variety of Sun based applications. * * The GRTERM entry should start with 'sun', and then you can append 'type3' if you have an old @@ -76,8 +76,8 @@ main() NULL, "\x1B[231z"), ALT_0_9, quote_list( - "\xB0", "\xB1", "\xB2", "\xB3", "\xB4", - "\xB5", "\xB6", "\xB7", "\xB8", "\xB9") + "\xB0", "\xB1", "\xB2", "\xB3", "\xB4", /* ALT-0..4 */ + "\xB5", "\xB6", "\xB7", "\xB8", "\xB9") /* ALT-5..9 */ ); } diff --git a/macsrc/tty/tty.h b/macsrc/tty/tty.h index a1366123..b03ff357 100644 --- a/macsrc/tty/tty.h +++ b/macsrc/tty/tty.h @@ -1,31 +1,35 @@ #ifndef TTY_TTY_H_INCLUDDED #define TTY_TTY_H_INCLUDDED /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: tty.h,v 1.5 2014/07/11 21:25:50 ayoung Exp $ +/* $Id: tty.h,v 1.7 2024/09/21 17:02:02 cvsuser Exp $ * Keyboard definitions for use in the tty-*.m macros * - * $Id: tty.h,v 1.5 2014/07/11 21:25:50 ayoung Exp $ + * $Id: tty.h,v 1.7 2024/09/21 17:02:02 cvsuser Exp $ * */ -#include "../crisp.h" +#include "../grief.h" #include "../alt.h" -#define CTRL_A_Z 1 -#define F1_F12 F(1) -#define SHIFT_F1_F12 SF(1) -#define CTRL_F1_F12 CF(1) -#define CTRLSHIFT_F1_F12 CSF(1) -#define ALT_F1_F12 AF(1) -#define ALT_A_Z ALT_A -#define ALT_0_9 ALT_0 -#define KEYPAD_0_9 KEYPAD_0 -#define CTRL_KEYPAD_0_9 CTRL_KEYPAD_0 -#define SHIFT_KEYPAD_0_9 SHIFT_KEYPAD_0 -#define ALT_KEYPAD_0_9 ALT_KEYPAD_0 -#define DEL KEY_DEL -#define COPY KEY_COPY -#define CUT KEY_CUT +#define CTRL_A_Z 1 +#define F1_F12 F(1) +#define SHIFT_F1_F12 SF(1) +#define CTRL_F1_F12 CF(1) +#define CTRLSHIFT_F1_F12 CSF(1) +#define ALT_F1_F12 AF(1) +#define ALT_A_Z ALT_A +#define ALT_0_9 ALT_0 +#define KEYPAD_0_9 KEYPAD_0 +#define SHIFT_KEYPAD_0_9 SHIFT_KEYPAD_0 +#define CTRL_KEYPAD_0_9 CTRL_KEYPAD_0 +#define CTRLSHIFT_KEYPAD_0_9 CTRLSHIFT_KEYPAD_0 +#define ALT_KEYPAD_0_9 ALT_KEYPAD_0 +#define ALTSHIFT_KEYPAD_0_9 ALTSHIFT_KEYPAD_0 +#define ALTCTRL_KEYPAD_0_9 ALTCTRL_KEYPAD_0 +#define ALTCTRLSHIFT_KEYPAD_0_9 ALTCTRLSHIFT_KEYPAD_0 +#define DEL KEY_DEL +#define COPY KEY_COPY +#define CUT KEY_CUT #if defined(__PROTOTYPES__) extern void ansi_arrows(void); @@ -34,3 +38,4 @@ extern void ansi_arrows(void); #endif /*TTY_TTY_XTERM_H_INCLUDED*/ + diff --git a/macsrc/tty/tty_xterm.h b/macsrc/tty/tty_xterm.h index 723ddcf0..b2dddf09 100644 --- a/macsrc/tty/tty_xterm.h +++ b/macsrc/tty/tty_xterm.h @@ -1,7 +1,7 @@ #ifndef TTY_TTY_XTERM_H_INCLUDDED #define TTY_TTY_XTERM_H_INCLUDDED /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: tty_xterm.h,v 1.4 2014/10/22 02:34:41 ayoung Exp $ +/* $Id: tty_xterm.h,v 1.5 2024/06/18 16:26:25 cvsuser Exp $ * xterm tty features ... * * @@ -13,11 +13,6 @@ extern void xterm_graphic(void); extern void xterm_color(void); extern void xterm_mono(void); extern void xterm_pccolors(void); -extern void xterm_colour88(void); -extern void xterm_color88(void); -extern void xterm_88colour(void); -extern void xterm_colour256(void); -extern void xterm_color256(void); extern void xterm_256color(void); extern void xterm_88color(void); extern void xterm_standard(void); diff --git a/macsrc/tty/xterm.cr b/macsrc/tty/xterm.cr index cc55c469..bf3ce3b9 100644 --- a/macsrc/tty/xterm.cr +++ b/macsrc/tty/xterm.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 4; tabs: 8; -*- - * $Id: xterm.cr,v 1.23 2024/05/03 00:13:04 cvsuser Exp $ + * $Id: xterm.cr,v 1.30 2024/09/20 12:15:16 cvsuser Exp $ * terminal description file for the xterm window under X11, an VT-100 like emulator. * * @@ -16,13 +16,13 @@ Xterm*colormode: on XTerm*VT100.Translations: #override \ ~ShiftHome: string(\033[1~)\n\ - ~ShiftEnd: string(\033[4~)\n\ + ~ShiftEnd: string(\033[4~)\n\ ~ShiftPrior: string(\033[5~)\n\ ~ShiftNext: string(\033[6~)\n\ - ShiftHome: scroll-back(100,page)\n\ + ShiftHome: scroll-back(100,page)\n\ ShiftEnd: scroll-forw(100,page)\n\ ShiftTab: string("\033 ")\n\ - ~ShiftTab: string(" ")\n\ + ~ShiftTab: string(" ")\n\ Ctrl=: string(\033[C=)\n\ Ctrl-: string(\033[C-)\n\ CtrlInsert: string(\033[CR0~)\n\ @@ -32,7 +32,7 @@ XTerm*VT100.Translations: #override \ CtrlLeft: string(\033[Ot)\n\ CtrlDown: string(\033[Or)\n\ CtrlUp: string(\033[Ox)\n\ - CtrlRight: string(\033[Ov)\n\ + CtrlRight: string(\033[Ov)\n\ ShiftF1: string(\033[SF1~)\n\ ShiftF2: string(\033[SF2~)\n\ ShiftF3: string(\033[SF3~)\n\ @@ -56,28 +56,28 @@ XTerm*VT100.Translations: #override \ CtrlF10: string(\033[CF10~)\n\ CtrlF11: string(\033[CF11~)\n\ CtrlF12: string(\033[CF12~)\n\ - MetaF1: string(\033[MF1~)\n\ - MetaF2: string(\033[MF2~)\n\ - MetaF3: string(\033[MF3~)\n\ - MetaF4: string(\033[MF4~)\n\ - MetaF5: string(\033[MF5~)\n\ - MetaF6: string(\033[MF6~)\n\ - MetaF7: string(\033[MF7~)\n\ - MetaF8: string(\033[MF8~)\n\ - MetaF9: string(\033[MF9~)\n\ - MetaF10: string(\033[MF10~)\n\ - MetaF11: string(\033[MF11~)\n\ - MetaF12: string(\033[MF12~)\n\ - ShiftKP_0: string(\033OP)\n\ - ShiftKP_1: string(\033OQ)\n\ - ShiftKP_2: string(\033OR)\n\ - ShiftKP_3: string(\033OS)\n\ - ShiftKP_4: string(\033OT)\n\ - ShiftKP_5: string(\033OU)\n\ - ShiftKP_6: string(\033OV)\n\ - ShiftKP_7: string(\033OW)\n\ - ShiftKP_8: string(\033OX)\n\ - ShiftKP_9: string(\033OY)\n\ + MetaF1: string(\033[AF1~)\n\ + MetaF2: string(\033[AF2~)\n\ + MetaF3: string(\033[AF3~)\n\ + MetaF4: string(\033[AF4~)\n\ + MetaF5: string(\033[AF5~)\n\ + MetaF6: string(\033[AF6~)\n\ + MetaF7: string(\033[AF7~)\n\ + MetaF8: string(\033[AF8~)\n\ + MetaF9: string(\033[AF9~)\n\ + MetaF10: string(\033[AF10~)\n\ + MetaF11: string(\033[AF11~)\n\ + MetaF12: string(\033[AF12~)\n\ + ShiftKP_0: string(\033OP)\n\ + ShiftKP_1: string(\033OQ)\n\ + ShiftKP_2: string(\033OR)\n\ + ShiftKP_3: string(\033OS)\n\ + ShiftKP_4: string(\033OT)\n\ + ShiftKP_5: string(\033OU)\n\ + ShiftKP_6: string(\033OV)\n\ + ShiftKP_7: string(\033OW)\n\ + ShiftKP_8: string(\033OX)\n\ + ShiftKP_9: string(\033OY)\n\ CtrlKP_0: string(\033Op)\n\ CtrlKP_1: string(\033Oq)\n\ CtrlKP_2: string(\033Or)\n\ @@ -119,24 +119,27 @@ XTerm*VT100.Translations: #override \ #include "tty.h" #include "tty_xterm.h" -static void xterm_locale(); +static int xterm_load(string name); +static void xterm_locale(); void -main() +main(void) { - string t_grterm, bterm, ostype, colorterm, sysname; + string bterm, ostype, colorterm, sysname; int datype = -1, daversion = -1; - list bterm_parts; - /* - * Auto-configure with specialised term spec. - */ - t_grterm = getenv("GRTERM"); /* term override */ - if (strlen(t_grterm)) { - bterm_parts = split(t_grterm, "-"); - if (length_of_list(bterm_parts)) { - if ("xterm" == bterm_parts[0]) { - bterm = bterm_parts[1]; /* xterm-rxvt */ + // Auto-configure with specialised term spec. + // + // Note, either GRTERM=xterm or TERM=xterm was set. + // + bterm = lower(getenv("GRTERM")); + if (strlen(bterm)) { + list termpts = split(bterm, "-"); + + bterm = ""; + if (length_of_list(termpts) > 1) { + if ("xterm" == termpts[0]) { /* assume: xterm-xxx, for example xterm-rxvt */ + bterm = termpts[1]; lower(bterm); } } @@ -150,146 +153,233 @@ main() load_macro("tty/xterm_util", FALSE); } - // TERM/GRTERM + // GRTERM/TERM // if (bterm == "gnome" || - (bterm == "" && colorterm == "gnome-terminal")) { - message("xterm_gnome"); - load_macro("tty/xterm_gnome"); + (bterm == "" && colorterm == "gnome-terminal") /*legacy*/) { + xterm_load("xterm-gnome"); return; } -//TODO -// if (bterm == "konsole" || -// getenv("KONSOLE_DCOP") != "") || -// getenv("KONSOLE_DBUS_SESSION") != "") { -// message("xterm_konsole"); -// load_macro("tty/xterm_konsole"); -// return; -// } - if (bterm == "aix" || bterm == "aixterm" || (bterm == "" && sysname == "AIX")) { + // + // xterm-aixterm or AIX host. + // message("xterm_aix"); xterm_arrow(); bterm = "aix"; } else if (bterm == "linux" || (bterm == "" && (ostype == "linux" || ostype == "linux-gnu" || sysname == "Linux"))) { - message("xterm_linux"); + // + // xterm-linux or linux host. + // xterm_locale(); - load_macro("tty/xterm_linux"); + xterm_load("xterm-linux"); return; } else if (bterm == "mrxvt" || (bterm == "rxvt" && getenv("MRXVT_TABTITLE") != "")) { + // + // xterm-mrxvt or xterm-rxvt // // MRXVT_TABTITLE // Set to the initial tab title of each terminal. Notice that its value will not be // altered if the user uses a shortcut or escape sequence to change the tab title; // the user must modify manually after doing so. // - message("xterm-mrxvt"); /* 05/01/10 */ - load_macro("tty/xterm_mrxvt"); + xterm_load("xterm-mrxvt"); return; - } else if (bterm == "rxvt" || colorterm == "rxvt" || colorterm == "rxvt-xpm") { - message("xterm-rxvt"); - load_macro("tty/xterm_rxvt"); + } else if (bterm == "rxvt" || bterm == "urxvt" || + colorterm == "rxvt" || colorterm == "rxvt-xpm") { + // + // term-rxvt, term-urxvt or + // COLORTERM=rxvt/rxvt-xpm + // + xterm_load("xterm-rxvt"); return; - } else if (bterm == "rxvt" || bterm == "urxvt" || bterm == "mintty") { - message("xterm-" + bterm); - if (load_macro("tty/xterm_" + bterm)) { + } else if (bterm == "mrxvt" || bterm == "mintty") { + // + // xterm-mrxvt or xterm-mintty + // + if (xterm_load("xterm_" + bterm)) { return; } } + //TODO/TEST + // COLORTERM=xfce4-terminal + + //TODO/TEST + // if (bterm == "konsole" || + // getenv("KONSOLE_DCOP") != "") || + // getenv("KONSOLE_DBUS_SESSION") != "") { + // message("xterm_konsole"); + // load_macro("tty/xterm_konsole"); + // return; + // } + // Device Attribute Tests // + // DECDA2R (CSI > 65 ; FIRMWARE ; KEYBOARD [; OPTION]* c) + // + // Firmware: + // + // 1 = VT220 + // 2 = VT240 + // 3 = DECmate II + // 18 = VT330 + // 19 = VT340 + // 24 = VT320 + // 28 = DECterm + // 32 = VT382J + // 41 = VTV420 + // 42 = VT1000 + // 44 = VT382T + // 61 = VT510 + // 64 = VT520 + // 65 = VT525 + // 66 = VTStar + // // A number of xterm compatible terminals normally run under the generic TERM // identifier "xterm" yet can be derived using the "VT/XTERM Device Attribute", // these include. // - // Terminal Type Version - // - // gnone-terminal 0/1 >= 1115 - // PuTTY 0/1 136 - // rxvt 82 - // urxvt 83 - // MinTTY 77 - // xterm -2(a) + // Terminal Type Version Example + // ------------------------------------------------------------------------- + // Gnome-terminal (legacy) 1 >= 1115 1;3801;0 + // Gnome-terminal 65 >= 6001 65;6001;1 + // PuTTY 0 136 0;136;0 + // kconsole 0;115;0 + // Terminal.app 1 95 1;95;0 + // iTerm2 0 95 0;95;0 + // minTTY 77(M) 77;20005;0c ("20000" == 2.0.0) + // rxvt 82(R) 82;20703;0c ("20703" == 2.7.3) + // screen 83(S) 83;40500;0 (added "30600" == 3.6.0) + // urxvt 85(U) + // libvterm 0;100;0 + // msterminal 0 10 0;10;1c + // xterm -2(a) // // Notes: - // a) Sourced from XTERM_VERSION not DA values. + // a) Sourced from XTERM_VERSION not DA values. + // + // https://invisible-island.net/xterm/ctlseqs/ctlseqs.pdf // bterm = "xterm"; /* default */ get_term_feature(TF_VT_DATYPE, datype); get_term_feature(TF_VT_DAVERSION, daversion); +#if defined(TF_VT_HARDWARE) + get_term_feature(TF_VT_HARDWARE, dahardware); +#endif if (datype >= 0) { - if ((datype | 1) == 1) { - if (daversion >= 1115) { /* gnome, hopefully */ - message("xterm_gnome"); - load_macro("tty/xterm_gnome"); + switch (datype) { + case 0: + if (daversion == 115) { /* kconsole */ + bterm = "xterm-kconsole"; + + } else if (daversion == 136) { /* PuTTY (mintty) */ + xterm_load("xterm-mintty"); return; - } else if (136 == daversion) { /* MinTTY/PuTTY */ - bterm = "mintty"; + } else { + if (daversion == 10) { + /* https://github.com/microsoft/terminal/pull/6850/files */ + if (getenv("WT_SESSION")) { /* msterminal "0;10;1c" */ + xterm_load("xterm-msterminal"); + return; + } + } + } + break; - } else if (83 == datype) { /* urxvt */ - message("xterm-urxvt"); -//TODO load_macro("tty/xterm_rxvt"); -// return; + case 1: + if (daversion >= 1115) { /* gnome, hopefully */ + xterm_load("xterm-gnome"); + return; } + break; - } else if (82 == datype) { /* rxvt */ - message("xterm-rxvt"); - load_macro("tty/xterm_rxvt"); - return; + case 61: /* see: https://github.com/GNOME/vte/blob/master/src/vteseq.cc */ + case 65: + if (daversion >= 6001) { + xterm_load("xterm-gnome"); + return; + } + break; + + case 77: /* minTTY (ASCII=M) */ + xterm_load("xterm-mintty"); + return; + + case 82: /* rxvt (ASCII=R) */ + xterm_load("xterm-rxvt"); + return; - } else if (77 == datype) { /* MinTTY */ - bterm = "mintty"; + case 83: /* TODO/screen (ASCII=S) */ + bterm = "xterm-screen"; + break; + case 85: /* TODO/urxvt (ASCII=U) */ + bterm = "xterm-urxvt"; + break; } } set_term_feature(TF_NAME, bterm); xterm_graphic(); - if ("mintty" == bterm) { - if (load_macro("tty/xterm_mintty")) { - return; - } - } - if (-2 == datype) { - if (daversion > 0 && daversion < 166) { + if (daversion > 0 && daversion < 166) { /* legacy unicode */ set_term_feature(TF_UNICODE_VERSION, "3.0.0"); } xterm_locale(); } - /* - * Color suffix - */ - if (index(colorterm, "-256") > 0 || colorterm == "truecolor") { - xterm_256color(); /* 256[color] */ - - } else if (index(colorterm, "-88") > 0) { - xterm_88color(); /* 88[color] */ - - } else if (index(colorterm, "-m") > 0) { - xterm_mono(); /* m[ono] */ - - } else { - xterm_color(); /* 16 colour by default */ - } - xterm_standard(); /* * Define keyboard layout for non-ascii characters. + * + * https://invisible-island.net/xterm/xterm-function-keys.html + * + * NAME vt100 vt220 scoansi xterm-r5 xterm-r6 xterm-vt220 xterm-xf86 xterm-new rxvt mgt screen + * kcub1 \EOD \E[D \E[D \EOD \EOD \EOD \EOD \EOD \E[D \EOD \EOD + * kcud1 \EOB \E[B \E[B \EOB \EOB \EOB \EOB \EOB \E[B \EOB \EOB + * kcuf1 \EOC \E[C \E[C \EOC \EOC \EOC \EOC \EOC \E[C \EOC \EOC + * kcuu1 \EOA \E[A \E[A \EOA \EOA \EOA \EOA \EOA \E[A \EOA \EOA + * kf0 \EOy \EOq \E[21~ + * kf1 \EOP \EOP \E[M \E[11~ \E[11~ \EOP \EOP \EOP \E[11~ \EOP \EOP + * kf2 \EOQ \EOQ \E[N \E[12~ \E[12~ \EOQ \EOQ \EOQ \E[12~ \EOQ \EOQ + * kf3 \EOR \EOR \E[O \E[13~ \E[13~ \EOR \EOR \EOR \E[13~ \EOR \EOR + * kf4 \EOS \EOS \E[P \E[14~ \E[14~ \EOS \EOS \EOS \E[14~ \EOS \EOS + * kf5 \EOt \E[Q \E[15~ \E[15~ \E[15~ \E[15~ \E[15~ \E[15~ \E[15~ \E[15~ + * kf6 \EOu \E[17~ \E[R \E[17~ \E[17~ \E[17~ \E[17~ \E[17~ \E[17~ \E[17~ \E[17~ + * kf7 \EOv \E[18~ \E[S \E[18~ \E[18~ \E[18~ \E[18~ \E[18~ \E[18~ \E[18~ \E[18~ + * kf8 \EOl \E[19~ \E[T \E[19~ \E[19~ \E[19~ \E[19~ \E[19~ \E[19~ \E[19~ \E[19~ + * kf9 \EOw \E[20~ \E[U \E[20~ \E[20~ \E[20~ \E[20~ \E[20~ \E[20~ \E[20~ \E[20~ + * kf10 \EOx \E[21~ \E[V \E[21~ \E[21~ \E[21~ \E[21~ \E[21~ \E[21~ \E[21~ \E[21~ + * kf11 \E[23~ \E[W \E[23~ \E[23~ \E[23~ \E[23~ \E[23~ \E[23~ \E[23~ \E[23~ + * kf12 \E[24~ \E[X \E[24~ \E[24~ \E[24~ \E[24~ \E[24~ \E[24~ \E[24~ \E[24 + * + * kDC \E[3;2~ \E[3;2~ \E[3$ + * kEND \E[1;2F \E[1;2F \E[8$ + * kHOM \E[1;2H \E[1;2H \E[7$ + * kIC \E[2;2~ \E[2;2~ \E[2$ + * kLFT \E[1;2D \E[1;2D \E[d + * kNXT \E[6;2~ \E[6;2~ \E[6$ + * kPRV \E[5;2~ \E[5;2~ \E[5$ + * kRIT \E[1;2C \E[1;2C \E[c + * + * kend \E[F \E[4~ \E[4~ \EOF \EOF \E[8~ \EOF \E[4~ + * khome \E[H \E[1~ \E[1~ \EOH \EOH \E[7~ \EOH \E[1~ + * + * kDN \E[1;2B \E[b + * kUP \E[1;2A \E[a */ set_term_keyboard( F1_F12, quote_list( /* standard */ @@ -313,9 +403,9 @@ main() "\x1b[CF9~", "\x1b[CF10~", "\x1b[CF11~", "\x1b[CF12~"), ALT_F1_F12, quote_list( /* VT100.Trans */ - "\x1b[MF1~", "\x1b[MF2~", "\x1b[MF3~", "\x1b[MF4~", - "\x1b[MF5~", "\x1b[MF6~", "\x1b[MF7~", "\x1b[MF8~", - "\x1b[MF9~", "\x1b[MF10~", "\x1b[MF11~", "\x1b[MF12~"), + "\x1b[AF1~", "\x1b[AF2~", "\x1b[AF3~", "\x1b[AF4~", + "\x1b[AF5~", "\x1b[AF6~", "\x1b[AF7~", "\x1b[AF8~", + "\x1b[AF9~", "\x1b[AF10~", "\x1b[AF11~", "\x1b[AF12~"), ALT_A_Z, quote_list( /* X.Org (7bit) (lower case) */ "\xC3\xA1", "\xC3\xA2", "\xC3\xA3", "\xC3\xA4", "\xC3\xA5", @@ -349,14 +439,6 @@ main() "\x1bU", "\x1bV", "\x1bW", "\x1bX", "\x1bY", "\x1bZ"), - ALT_A_Z, quote_list( /* ??? */ - "\xE1", "\xE2", "\xE3", "\xE4", "\xE5", - "\xE6", "\xE7", "\xE8", "\xE9", "\xEa", - "\xEb", "\xEc", "\xED", "\xEe", "\xEf", - "\xF0", "\xF1", "\xF2", "\xF3", "\xF4", - "\xF5", "\xF6", "\xF7", "\xF8", "\xF9", - "\xFa"), - // Ins/0 End/1 Down/2 PgDn/3 Left/4 // 5 Right/6 Home/7 Up/8 PgUp/9 // Del/. Plus Minus Star Divide @@ -364,10 +446,11 @@ main() // NumLock // KEYPAD_0_9, quote_list( /* Standard (Application mode) */ - "\x1b[2~", "\x1bOw", "\x1bOB", "\x1b[6~", "\x1bOD", + "\x1b[2~", "\x1bOF", "\x1bOB", "\x1b[6~", "\x1bOD", "\x1bOE", "\x1bOC", "\x1bOH", "\x1bOA", "\x1b[5~", "\x1b[3~", "\x1bOk", "\x1bOm", "\x1bOj", "\x1bOo", - NULL, "\x1bOM"), + NULL, "\x1bOM", NULL, NULL, NULL, + NULL), ALT_0_9, quote_list( /* X.Org (7bit) */ "\xC2\xB0", "\xC2\xB1", "\xC2\xB2", "\xC2\xB3", "\xC2\xB4", @@ -377,14 +460,10 @@ main() "\x1b0", "\x1b1", "\x1b2", "\x1b3", "\x1b4", "\x1b5", "\x1b6", "\x1b7", "\x1b8", "\x1b9" ), - ALT_0_9, quote_list( /* ??? */ + ALT_0_9, quote_list( /* Meta-Numeric */ "\x1ba0", "\x1ba1", "\x1ba2", "\x1ba3", "\x1ba4", "\x1ba5", "\x1ba6", "\x1ba7", "\x1ba8", "\x1ba9"), - ALT_0_9, quote_list( /* ??? */ - "\xB0", "\xB1", "\xC0", "\xA4", "\xA4", - "\xB5", "\xB6", "\xB7", "\xB8", "\xB9" ), - SHIFT_KEYPAD_0_9, quote_list( /* VT100.Trans */ "\x1bOP", "\x1bOQ", "\x1bOR", "\x1bOS", "\x1bOT", "\x1bOU", "\x1bOV", "\x1bOW", @@ -428,6 +507,21 @@ main() } +static int +xterm_load(string name) +{ + string macroname; + + macroname = "tty/" + name; + macroname = re_translate(SF_GLOBAL, "[ -]+", "_", macroname); + + message(name); + set_term_feature(TF_NAME, name); + + return load_macro(macroname); +} + + static void xterm_locale() { @@ -445,3 +539,5 @@ xterm(void) { /*NOTHING*/ } + +/*end*/ diff --git a/macsrc/tty/xterm_gnome.cr b/macsrc/tty/xterm_gnome.cr index f959366a..6eb5170d 100644 --- a/macsrc/tty/xterm_gnome.cr +++ b/macsrc/tty/xterm_gnome.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: xterm_gnome.cr,v 1.7 2014/10/22 02:34:43 ayoung Exp $ +/* $Id: xterm_gnome.cr,v 1.8 2024/06/18 16:26:25 cvsuser Exp $ * terminal description file for the xterm window under Gnome-terminal. * * @@ -24,7 +24,7 @@ main(void) * drawing windows. */ xterm_graphic(); - xterm_colour256(); /* full 256 color is available */ + xterm_256color(); /* full 256 color is available */ /* * Define escape sequences used for special optimisations on output. @@ -143,28 +143,4 @@ gnome(void) /*gnome*/ } - - - - - - - - - - - - - - - - - - - - - - - - - +/*end*/ diff --git a/macsrc/tty/xterm_linux.cr b/macsrc/tty/xterm_linux.cr index 438bc86b..8b5aab75 100644 --- a/macsrc/tty/xterm_linux.cr +++ b/macsrc/tty/xterm_linux.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: xterm_linux.cr,v 1.23 2021/07/11 08:26:12 cvsuser Exp $ +/* $Id: xterm_linux.cr,v 1.26 2024/09/20 12:15:16 cvsuser Exp $ * terminal description file for the xterm window under X11/Linux. * * @@ -72,6 +72,9 @@ main() * Define keyboard layout for non-ascii characters. */ set_term_keyboard( + // + // Function keys + // F1_F12, quote_list( "\x1bOP", "\x1bOQ", "\x1bOR", "\x1bOS", "\x1b[15~", "\x1b[17~", "\x1b[18~", "\x1b[19~", @@ -116,15 +119,15 @@ main() "\xC3\x9A" ), ALT_0_9, quote_list( /*X.Org (7bit)*/ - "\xC2\xB0", "\xC2\xB1", "\xC2\xB2", "\xC2\xB3", "\xC2\xB4", - "\xC2\xB5", "\xC2\xB6", "\xC2\xB7", "\xC2\xB8", "\xC2\xB9" ), + "\xC2\xB0", "\xC2\xB1", "\xC2\xB2", "\xC2\xB3", "\xC2\xB4", + "\xC2\xB5", "\xC2\xB6", "\xC2\xB7", "\xC2\xB8", "\xC2\xB9" ), // Ins/0 End/1 Down/2 PgDn/3 Left/4 // 5 Right/6 Home/7 Up/8 PgUp/9 - // + // KEYPAD_0_9, quote_list( - "\x1b[2~", "\x1bOF", "\x1bOB", "\x1b[6~", "\x1bOD", - "\x1bOE", "\x1bOC", "\x1bOH", "\x1bOA", "\x1b[5~"), + "\x1b[2~", "\x1bOF", "\x1bOB", "\x1b[6~", "\x1bOD", + "\x1bOE", "\x1bOC", "\x1bOH", "\x1bOA", "\x1b[5~"), KEYPAD_DIV, "\x1bOo", /* Keypad-/ */ KEYPAD_STAR, "\x1bOj", /* Keypad-* */ @@ -189,3 +192,6 @@ linux_standard() set_term_feature(TF_GRAPHIC_MODE, "\x1B(0"); /* Enter graphics mode. */ set_term_feature(TF_TEXT_MODE, "\x1B(B"); /* Exit graphics mode. */ } + +/*end*/ + diff --git a/macsrc/tty/xterm_mintty.cr b/macsrc/tty/xterm_mintty.cr index 71116776..37afea90 100644 --- a/macsrc/tty/xterm_mintty.cr +++ b/macsrc/tty/xterm_mintty.cr @@ -1,6 +1,7 @@ /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: xterm_mintty.cr,v 1.5 2021/07/11 08:26:12 cvsuser Exp $ +/* $Id: xterm_mintty.cr,v 1.10 2024/09/21 17:02:02 cvsuser Exp $ * Mintty terminal profile. + * See: https://github.com/mintty/mintty/wiki/CtrlSeqs * * * @@ -26,14 +27,40 @@ main() */ xterm_standard(); xterm_graphic(); - xterm_colour256(); /* full 256 color is available */ - - /*UTF8*/ + xterm_256color(); /* full 256 color is available */ /* * Terminal map */ set_term_keyboard( + // https://github.com/mintty/mintty/wiki/Keycodes#modifier-key-encodings + // + // Function keys: + // + // Key plain modified + // ------------------------------------------------- + // F1 ^[OP ^[[1;mP + // F2 ^[OQ ^[[1;mQ + // F3 ^[OR ^[[1;mR + // F4 ^[OS ^[[1;mS + // F5 ^[[15~ ^[[15;m~ + // F6 ^[[17~ ^[[17;m~ + // F7 ^[[18~ ^[[18;m~ + // F8 ^[[19~ ^[[19;m~ + // F9 ^[[20~ ^[[20;m~ + // F10 ^[[21~ ^[[21;m~ + // F11 ^[[23~ ^[[23;m~ + // F12 ^[[24~ ^[[24;m~ + // + // Modifiers: + // + // Modifier m + // ------------------------------------------------- + // Shift 1 + // Alt 2 + // Ctrl 4 + // Meta (Win key) 8 + // F1_F12, quote_list( /* xterm */ "\x1bOP", "\x1bOQ", "\x1bOR", "\x1bOS", "\x1b[15~", "\x1b[17~", "\x1b[18~", "\x1b[19~", "\x1b[20~", "\x1b[21~", @@ -54,6 +81,7 @@ main() "\x1b[17;6~", "\x1b[18;6~", "\x1b[19;6~", "\x1b[20;6~", "\x1b[21;6~", "\x1b[23;6~", "\x1b[24;6~"), + // // , , , , , // , , , , , // , , , , , @@ -77,6 +105,48 @@ main() "\x1bU", "\x1bV", "\x1bW", "\x1bX", "\x1bY", "\x1bZ"), + // Cursor keys: + // + // Key plain app modified + // ------------------------------------------------- + // Up ^[[A ^[OA ^[[1;mA + // Down ^[[B ^[OB ^[[1;mB + // Left ^[[D ^[OD ^[[1;mD + // Right ^[[C ^[OC ^[[1;mC + // Home ^[[H ^[OH ^[[1;mH + // End ^[[F ^[OF ^[[1;mF + // + // Editing keys: + // + // + // Key plain modified + // ------------------------------------------------- + // Ins ^[[2~ ^[[2;m~ + // Del ^[[3~ ^[[3;m~ + // PgUp ^[[5~ ^[[5;m~ + // PgDn ^[[6~ ^[[6;m~ + // Home ^[[1~ ^[[1;m~ + // End ^[[4~ ^[[4;m~ + // + // Number and symbol keys: + // + // Key modified appl keypad modified + // ------------------------------------------------- + // / ^[[1;mo ^[Omo + // * ^[[1;mj ^[Omj + // - ^[[1;mm ^[Omm + // + ^[[1;mk ^[Omk + // Enter ^[OmM + // , ^[[1;ml + // VT220 appl keypad modified + // . ^[[1;mn ^[Omn + // 0 ^[[1;mp ^[Omp + // 1 ^[[1;mq ^[Omq + // ... + // 8 ^[[1;mx ^[Omx + // 9 ^[[1;my ^[Omy + // + // Ins/0 End/1 Down/2 PgDn/3 Left/4 // 5 Right/6 Home/7 Up/8 PgUp/9 // Del/. Plus Minus Star Divide @@ -87,7 +157,8 @@ main() "\x1b[2~", "\x1bOF", "\x1bOB", "\x1b[6~", "\x1bOD", "\x1bOE", "\x1bOC", "\x1bOH", "\x1bOA", "\x1b[5~", "\x1b[3~", "\x1bOk", "\x1bOm", "\x1bOj", "\x1bOo", - NULL, "\x1bOM"), + NULL, "\x1bOM", NULL, NULL, NULL, + NULL), // Ins, End, Down, PgDn, Left, // 5, Right, Home, Up, PgUp, @@ -95,20 +166,55 @@ main() // Equals, Enter, Pause, PrtSc, Scroll, // NumLock // - SHIFT_KEYPAD_0_9, quote_list( /* mintty */ - NULL, "\x1b[1;2F", "\x1b[1;2B", "\x1b[6;2~", "\x1b[1;2D", + SHIFT_KEYPAD_0_9, quote_list( /* xterm/mintty */ + "\x1b[2;2~", "\x1b[1;2F", "\x1b[1;2B", "\x1b[6;2~", "\x1b[1;2D", NULL, "\x1b[1;2C", "\x1b[1;2H", "\x1b[1;2A", "\x1b[5;2~", - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, + "\x1b[3;2~", NULL, NULL, "\x1b[1;2j", NULL, + NULL, "\x1b[1;2M", NULL, NULL, NULL, NULL), - CTRL_KEYPAD_0_9, quote_list( /* mintty */ - NULL, "\x1b[1;5F", "\x1b[1;5B", "\x1b[6;5~", "\x1b[1;5D", + CTRL_KEYPAD_0_9, quote_list( /* xterm/mintty */ + "\x1b[2;5~", "\x1b[1;5F", "\x1b[1;5B", "\x1b[6;5~", "\x1b[1;5D", NULL, "\x1b[1;5C", "\x1b[1;5H", "\x1b[1;5A", "\x1b[5;5~", "\x1b[3;5~", NULL, NULL, "\x1b[1;5j", NULL, NULL, "\x1b[1;5M", "\x1c", NULL, NULL, NULL), + CTRLSHIFT_KEYPAD_0_9, quote_list( /* xterm/mintty */ + "\x1b[2;6~", "\x1b[1;6F", "\x1b[1;6B", "\x1b[6;6~", "\x1b[1;6D", + NULL, "\x1b[1;6C", "\x1b[1;6H", "\x1b[1;6A", "\x1b[5;6~", + "\x1b[3;6~", NULL, NULL, "\x1b[1;6j", NULL, + NULL, "\x1b[1;6M", NULL, NULL, NULL, + NULL), + + ALT_KEYPAD_0_9, quote_list( /* xterm/mintty */ + "\x1b[2;3~", "\x1b[1;3F", "\x1b[1;3B", "\x1b[6;3~", "\x1b[1;3D", + NULL, "\x1b[1;3C", "\x1b[1;3H", "\x1b[1;3A", "\x1b[5;3~", + "\x1b[3;3~", NULL, NULL, "\x1b[1;3j", NULL, + NULL, "\x1b[1;3M", NULL, NULL, NULL, + NULL), + + ALTSHIFT_KEYPAD_0_9, quote_list( /* xterm/mintty */ + "\x1b[2;4~", "\x1b[1;4F", "\x1b[1;4B", "\x1b[6;4~", "\x1b[1;4D", + NULL, "\x1b[1;4C", "\x1b[1;4H", "\x1b[1;4A", "\x1b[5;4~", + "\x1b[3;4~", NULL, NULL, "\x1b[1;4j", NULL, + NULL, "\x1b[1;4M", NULL, NULL, NULL, + NULL), + + ALTCTRL_KEYPAD_0_9, quote_list( /* xterm/mintty */ + "\x1b[2;7~", "\x1b[1;7F", "\x1b[1;7B", "\x1b[6;7~", "\x1b[1;7D", + NULL, "\x1b[1;7C", "\x1b[1;7H", "\x1b[1;7A", "\x1b[5;7~", + "\x1b[3;7~", NULL, NULL, "\x1b[1;7j", NULL, + NULL, "\x1b[1;7M", NULL, NULL, NULL, + NULL), + + ALTCTRLSHIFT_KEYPAD_0_9, quote_list( /* xterm/mintty */ + "\x1b[2;8~", "\x1b[1;8F", "\x1b[1;8B", "\x1b[6;8~", "\x1b[1;8D", + NULL, "\x1b[1;8C", "\x1b[1;8H", "\x1b[1;8A", "\x1b[5;8~", + "\x1b[3;8~", NULL, NULL, "\x1b[1;8j", NULL, + NULL, "\x1b[1;8M", NULL, NULL, NULL, + NULL), + // Miscellous keys // BACK_TAB, "\x1b[Z", @@ -123,3 +229,4 @@ mintty(void) /*NOTHING*/ } +/*end*/ diff --git a/macsrc/tty/xterm_mrxvt.cr b/macsrc/tty/xterm_mrxvt.cr index 0d43c7de..1656e38b 100644 --- a/macsrc/tty/xterm_mrxvt.cr +++ b/macsrc/tty/xterm_mrxvt.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: xterm_mrxvt.cr,v 1.4 2021/07/11 08:26:12 cvsuser Exp $ +/* $Id: xterm_mrxvt.cr,v 1.6 2024/07/12 16:33:22 cvsuser Exp $ * mrxvt terminal * * The mrxvt program is a terminal emulator for X Window System. It provides DEC VT102 @@ -76,6 +76,9 @@ main() * keyboard for non-ascii characters. */ set_term_keyboard( /* Function keys */ + // + // Function keys + // SHIFT_F1_F12, quote_list( "\x1b[11;2~", "\x1b[12;2~", "\x1b[13;2~", "\x1b[14;2~", "\x1b[15;2~", "\x1b[17;2~", "\x1b[18;2~", "\x1b[19;2~", "\x1b[20;2~", "\x1b[21;2~", @@ -183,3 +186,4 @@ mrxvt() /*NOTHING*/ } +/*end*/ diff --git a/macsrc/tty/xterm_msterminal.cr b/macsrc/tty/xterm_msterminal.cr new file mode 100644 index 00000000..6f08a1a8 --- /dev/null +++ b/macsrc/tty/xterm_msterminal.cr @@ -0,0 +1,126 @@ +/* -*- mode: cr; indent-width: 4; -*- */ +/* $Id: xterm_msterminal.cr,v 1.3 2024/09/19 15:10:54 cvsuser Exp $ + * msterminal terminal profile. + * https://learn.microsoft.com/en-us/windows/terminal/ + * + * + */ + +#include "tty.h" +#include "tty_xterm.h" + + +void +main() +{ + /* + * Load support functions + */ + set_term_feature(TF_NAME, "xterm-msterminal"); + if (inq_macro("xterm_util") <= 0) { + load_macro("tty/xterm_util", FALSE); + } + + /* + * Basic/common configuration + */ +// set_term_feature(TF_INIT, "\x1b="); /* DECKPAM Enable Keypad Application Mode */ +// set_term_feature(TF_INIT, "\x1b[?1h"); /* DECCKM - Enable Cursor Keys Application Mode */ +// set_term_feature(TF_RESET, "\x1b>"); /* DECKPNM Enable Keypad Numeric Mode */ + +// set_term_feature(TF_INIT, "\x1b[?9001h"); /* enable win32-input-mode */ +// set_term_feature(TF_RESET, "\x1b[?9001l"); /* disable win32-input-mode */ + + xterm_graphic(); + xterm_256color(); /* full 256 color is available */ + + /* + * Terminal map + */ + set_term_keyboard( + // + // Function keys + // + F1_F12, quote_list( /* xterm */ + "\x1bOP", "\x1bOQ", "\x1bOR", "\x1bOS", "\x1b[15~", + "\x1b[17~", "\x1b[18~", "\x1b[19~", "\x1b[20~", "\x1b[21~", + "\x1b[23~", "\x1b[24~"), + + SHIFT_F1_F12, quote_list( /* xterm */ + "\x1b[1;2P", "\x1b[1;2Q", "\x1b[1;2R", "\x1b[1;2S", "\x1b[15;2~", + "\x1b[17;2~", "\x1b[18;2~", "\x1b[19;2~", "\x1b[20;2~", "\x1b[21;2~", + "\x1b[23;2~", "\x1b[24;2~"), + + CTRL_F1_F12, quote_list( /* xterm */ + "\x1b[1;5P", "\x1b[1;5Q", "\x1b[1;5R", "\x1b[1;5S", "\x1b[15;5~", + "\x1b[17;5~", "\x1b[18;5~", "\x1b[19;5~", "\x1b[20;5~", "\x1b[21;5~", + "\x1b[23;5~", "\x1b[24;5~"), + + CTRLSHIFT_F1_F12, quote_list( /* msterminal/mintty */ + "\x1b[1;6P", "\x1b[1;6Q", "\x1b[1;6R", "\x1b[1;6S", "\x1b[15;6~", + "\x1b[17;6~", "\x1b[18;6~", "\x1b[19;6~", "\x1b[20;6~", "\x1b[21;6~", + "\x1b[23;6~", "\x1b[24;6~"), + + ALT_F1_F12, quote_list( /* msterminal */ + "\x1b[1;3P", "\x1b[1;3Q", "\x1b[1;3R", "\x1b[1;3S", "\x1b[15;3~", + "\x1b[17;3~", "\x1b[18;3~", "\x1b[19;3~", "\x1b[20;3~", "\x1b[21;3~", + "\x1b[23;3~", "\x1b[24;3~"), + + // + // Ins/0 End/1 Down/2 PgDn/3 Left/4 + // 5 Right/6 Home/7 Up/8 PgUp/9 + // Del/. Plus Minus Star Divide + // Equals Enter Pause PrtSc Scroll + // NumLock + // + KEYPAD_0_9, quote_list( /* Standard (Application mode) */ + "\x1b[2~", "\x1bOF", "\x1bOB", "\x1b[6~", "\x1bOD", + "\x1bOE", "\x1bOC", "\x1bOH", "\x1bOA", "\x1b[5~", + "\x1b[3~", "\x1bOk", "\x1bOm", "\x1bOj", "\x1bOo", + NULL, "\x1bOM"), + + // + // Ins, End, Down, PgDn, Left, + // 5, Right, Home, Up, PgUp, + // Del, Plus, Minus, Star, Divide, + // Equals, Enter, Pause, PrtSc, Scroll, + // NumLock + // + SHIFT_KEYPAD_0_9, quote_list( /* msterminal */ + NULL, "\x1b[1;2F", "\x1b[1;2B", "\x1b[6;2~", "\x1b[1;2D", + NULL, "\x1b[1;2C", "\x1b[1;2H", "\x1b[1;2A", "\x1b[5;2~", + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL), + + CTRL_KEYPAD_0_9, quote_list( /* msterminal */ + NULL, "\x1b[1;5F", "\x1b[1;5B", "\x1b[6;5~", "\x1b[1;5D", + NULL, "\x1b[1;5C", "\x1b[1;5H", "\x1b[1;5A", "\x1b[5;5~", + "\x1b[3;5~", NULL, NULL, "\x1b[1;5j", NULL, + NULL, "\x1b[1;5M", "\x1c", NULL, NULL, + NULL), + + // + // Miscellous keys + // + ALT_KEYPAD_2, "\x1b[1;3B", /* Alt-Down */ + ALT_KEYPAD_4, "\x1b[1;3D", /* Alt-Left */ + ALT_KEYPAD_6, "\x1b[1;3C", /* Alt-Right */ + ALT_KEYPAD_8, "\x1b[1;3A", /* Alt-Up */ + + BACK_TAB, "\x1b[Z", + KEY_BACKSPACE, "\x7f" + ); + + xterm_altmeta_keys(); +} + + +void +msterminal(void) +{ + /*NOTHING*/ +} + +/*end*/ + diff --git a/macsrc/tty/xterm_rxvt.cr b/macsrc/tty/xterm_rxvt.cr index 4c9eec0d..f61c6876 100644 --- a/macsrc/tty/xterm_rxvt.cr +++ b/macsrc/tty/xterm_rxvt.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: xterm_rxvt.cr,v 1.10 2021/07/11 08:26:12 cvsuser Exp $ +/* $Id: xterm_rxvt.cr,v 1.12 2024/07/12 16:33:22 cvsuser Exp $ * rxvt is a very popular xterm replacement. @@ -185,6 +185,9 @@ main() * Define keyboard layout for non-ascii characters. */ set_term_keyboard( /* Function keys */ + // + // Function keys + // SHIFT_F1_F12, quote_list( "\x1b[23~", "\x1b[24~", "\x1b[25~", "\x1b[26~", "\x1b[28~", "\x1b[29~", "\x1b[31~", "\x1b[32~", "\x1b[33~", "\x1b[34~", @@ -211,6 +214,7 @@ main() "\x1b\xda", NULL, NULL, NULL, NULL, NULL), + // // Ins/0 End/1 Down/2 PgDn/3 Left/4 // 5 Right/6 Home/7 Up/8 PgUp/9 // Del/. Plus Minus Star Divide @@ -281,3 +285,5 @@ rxvt() /*NOTHING*/ } +/*end*/ + diff --git a/macsrc/tty/xterm_sun.cr b/macsrc/tty/xterm_sun.cr index 28f81989..ca48fbb2 100644 --- a/macsrc/tty/xterm_sun.cr +++ b/macsrc/tty/xterm_sun.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: xterm_sun.cr,v 1.11 2014/10/22 02:34:43 ayoung Exp $ +/* $Id: xterm_sun.cr,v 1.13 2024/07/12 16:33:22 cvsuser Exp $ * terminal description file for the xterm window under X11 which is a VT-100 like emulator * * @@ -93,3 +93,5 @@ main() ); } +/*end*/ + diff --git a/macsrc/tty/xterm_util.cr b/macsrc/tty/xterm_util.cr index ab8656ff..69062fcc 100644 --- a/macsrc/tty/xterm_util.cr +++ b/macsrc/tty/xterm_util.cr @@ -1,5 +1,5 @@ /* -*- mode: cr; indent-width: 4; -*- */ -/* $Id: xterm_util.cr,v 1.10 2014/10/22 02:34:43 ayoung Exp $ +/* $Id: xterm_util.cr,v 1.13 2024/09/20 12:15:16 cvsuser Exp $ * Standard Xterm features ... * * @@ -71,15 +71,62 @@ xterm_graphic(void) */ void xterm_color(void) -{ +{ set_term_feature(TF_COLOR, TRUE); /* Terminal supports color. */ } +/* + * xterm_alt8bit_keys --- + * Legacy Alt-X key encoding; not-compatible with UTF8 encoding. + */ +void +xterm_alt8bit_keys(void) +{ + set_term_keyboard( + // + // , , , , , + // , , , , , + // , , , , , + // , , , , , + // , , , , , + // + // + ALT_A_Z, quote_list( /* 8bit-Meta-Alpha/remove */ + "\xE1", "\xE2", "\xE3", "\xE4", "\xE5", + "\xE6", "\xE7", "\xE8", "\xE9", "\xEa", + "\xEb", "\xEc", "\xED", "\xEe", "\xEf", + "\xF0", "\xF1", "\xF2", "\xF3", "\xF4", + "\xF5", "\xF6", "\xF7", "\xF8", "\xF9", + "\xFa"), + + // + // , , , , , + // , , , , + // + ALT_0_9, quote_list( /* 8bit-Meta-Numeric/remove */ + "\xB0", "\xB1", "\xC0", "\xA4", "\xA4", + "\xB5", "\xB6", "\xB7", "\xB8", "\xB9" ) + ); +} + + +/* + * xterm_altmetas --- + * Escape Alt-X key encoding. + */ void xterm_altmeta_keys(void) { set_term_keyboard( + // + // , , , , , + // , , , , , + // , , , , , + // , , , , , + // , , , , , + // + // ALT_A_Z, quote_list( /*lower case*/ "\x1ba", "\x1bb", "\x1bc", "\x1bd", "\x1be", "\x1bf", "\x1bg", "\x1bh", "\x1bi", "\x1bj", @@ -139,67 +186,35 @@ xterm_altmeta_keys(void) /* - * xterm_colour256 --- + * xterm_256color --- * Color terminal. * * Usage: - * GRTERM=xterm-colour256 - * GRTERM=xterm-color256 * GRTERM=xterm-256color */ void -xterm_colour256(void) +xterm_256color(void) { set_term_feature(TF_COLOR, TRUE); /* Terminal supports color. */ set_term_feature(TF_COLORDEPTH, 256); /* using a colour depth of 256. */ } -void -xterm_color256(void) -{ - xterm_colour256(); -} - - -void -xterm_256color(void) -{ - xterm_colour256(); -} - - /* - * xterm_colour88 --- + * xterm_88color * Color terminal. * * Usage: - * GRTERM=xterm-colour88 - * GRTERM=xterm-color88 * GRTERM=xterm-88colour */ void -xterm_colour88(void) +xterm_88color(void) { set_term_feature(TF_COLOR, TRUE); /* terminal supports color. */ set_term_feature(TF_COLORDEPTH, 88); /* using a colour depth of 88. */ } -void -xterm_color88(void) -{ - xterm_colour88(); -} - - -void -xterm_88color(void) -{ - xterm_colour88(); -} - - /* * xterm_pccolours --- * Enforce a standard (PC style) colour map. @@ -215,6 +230,13 @@ xterm_pccolours(void) } +/* + * xterm_pccolors + * Color terminal attribute. + * + * Usage: + * GRTERM=xterm-pccolors + */ void xterm_pccolors(void) { @@ -222,13 +244,27 @@ xterm_pccolors(void) } +/* + * xterm_unicode + * Unicode terminal. + * + * Usage: + * GRTERM=xterm-unicode + */ +void +xterm_unicode(void) +{ + //TODO + //set_term_feature(TF_UNICODE_VERSION, "15.0.0"); +} + + /* * xterm_mono --- * Mono terminal. * * Usage: * GRTERM=xterm-mono - * GRTERM=xterm-m */ void xterm_mono(void) diff --git a/makelib.in b/makelib.in index 2ee4b11a..f7759792 100644 --- a/makelib.in +++ b/makelib.in @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $Id: makelib.in,v 1.20 2024/05/24 16:03:54 cvsuser Exp $ +# $Id: makelib.in,v 1.22 2024/06/16 16:31:42 cvsuser Exp $ # -*- mode: perl; tabs: 8; indent-width: 4; -*- # makelib configuration # @@ -98,9 +98,8 @@ $PACKAGE_FILE = 'edpackage.h'; '!^contrib/libiconv', # optional/recursive '^contrib/libintl', '^contrib/hunspell', - # '^contrib/liblua', - # '^contrib/libssh2', '!^contrib/icu', # optional local ICU installation + '^libfltk', 'libduktape', 'libvfs', 'libchartable', @@ -194,7 +193,10 @@ Configure() remove_define('WIN32'); add_define('HAVE_CONFIG_H'); add_define('LIBW32_DYNAMIC'); + add_define('_WIN32_WINNT=0x501'); # Windows SDK + add_define('WINVER=0x501'); + add_define('_CRT_SECURE_NO_WARNINGS'); add_define('_CRT_SECURE_NO_DEPRECATE'); add_define('_CRT_NONSTDC_NO_DEPRECATE'); @@ -212,7 +214,10 @@ Configure() remove_define('WIN32'); add_define('HAVE_CONFIG_H'); add_define('LIBW32_DYNAMIC'); + add_define('_WIN32_WINNT=0x501'); # Windows SDK + add_define('WINVER=0x501'); + add_define('__STDC_WANT_LIB_EXT1__'); add_xinclude('$(ROOT)/libw32'); @@ -227,8 +232,9 @@ Configure() remove_define('WIN32'); add_define('HAVE_CONFIG_H'); add_define('LIBW32_DYNAMIC'); + add_define('_WIN32_WINNT=0x501'); # Windows SDK - add_define('_WIN32_VER=0x501'); + add_define('WINVER=0x501'); add_define('__USE_MINGW_ANSI_STDIO=1'); # printf() ANSI C99 compatible implementation @@ -242,6 +248,7 @@ Configure() } add_system_library('-lComctl32'); # updater, common controls + add_system_library('-lComdlg32'); add_system_library('-lOleAut32'); add_system_library('-lMswsock'); diff --git a/makelib.pl b/makelib.pl index 37d568a9..fe5affc7 100644 --- a/makelib.pl +++ b/makelib.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $Id: makelib.pl,v 1.146 2024/05/27 15:19:56 cvsuser Exp $ +# $Id: makelib.pl,v 1.148 2024/07/13 13:11:12 cvsuser Exp $ # Makefile generation under WIN32 (MSVC/WATCOMC/MINGW) and DJGPP. # -*- perl; tabs: 8; indent-width: 4; -*- # Automake emulation for non-unix environments. @@ -750,6 +750,7 @@ BEGIN CP => '@BINPATH@cp.exe', TAR => '@BINPATH@tar.exe', MKDIR => '@BINPATH@mkdir.exe', + MKDIR_P => '@PERLPATH@perl '."${CWD}/win32/mkdir_p.pl", RMDIR => '@BINPATH@rmdir.exe', ISWIN32 => 'yes', @@ -842,6 +843,7 @@ BEGIN MV => 'mv', TAR => 'tar', MKDIR => 'mkdir', + MKDIR_P => 'mkdir -p', RMDIR => 'rmdir', INSTALL => 'install.pl', @@ -887,6 +889,8 @@ BEGIN LIBCURL_CPPFLAGS => '', + CURSES_CFLAGS => '', + LIBICU_CFLAGS => '', LIBICU_CXXFLAGS => '', LIBICU_VERSION => '', diff --git a/util/Makefile.in b/util/Makefile.in index 794cf7df..4469f3b6 100644 --- a/util/Makefile.in +++ b/util/Makefile.in @@ -1,5 +1,5 @@ # -*- mode: mak; -*- -# $Id: Makefile.in,v 1.16 2024/05/03 14:35:16 cvsuser Exp $ +# $Id: Makefile.in,v 1.22 2024/09/02 13:40:21 cvsuser Exp $ # GRIEF utilities makefile. # # @@ -45,6 +45,7 @@ XCLEAN= CC= @CC@ RM= @RM@ +RC= @RC@ PERL= @PERL@ LIBTOOL= @LIBTOOL@ @@ -78,7 +79,7 @@ D_GR= $(ROOT)/gr # Common flags -XFLAGS= +XFLAGS= CFLAGS= @CFLAGS@ CWARN= @CWARN@ $(CWALL) CDEBUG= @CDEBUG@ @@ -107,19 +108,38 @@ RMDFLAGS= -rf ######################################################################################### # Targets +ifeq ("win32","@build_os@") +ifeq (mingw,$(findstring mingw,"@TOOLCHAIN@")) +define Resource +$(2)+= $(addprefix $(D_OBJ)/,$(subst .rc,_res.o,$(1))) +endef +else +define Resource +$(2)+= $(addprefix $(D_OBJ)/,$(subst .rc,.res,$(1))) +endef +endif +else +define Resource +endef +endif #build_os + GRTAGS= $(D_BIN)/grtags$(E) GRTAGSOBJS= $(D_OBJ)/grtags$(O) \ $(D_OBJ)/arg$(O) \ $(D_OBJ)/tagsex$(O) \ $(D_OBJ)/tagse$(O) +$(eval $(call Resource,grtags.rc,GRTAGSOBJS)) GRWC= $(D_BIN)/grwc$(E) GRWCOBJS= $(D_OBJ)/grwc$(O) \ $(D_OBJ)/fmt_scaled$(O) \ $(D_OBJ)/err$(O) +$(eval $(call Resource,grwc.rc,GRWCOBJS)) GRKEYTEST= $(D_BIN)/grkeytest$(E) -GRKEYTESTOBJS= $(D_OBJ)/grkeytest$(O) +GRKEYTESTOBJS= $(D_OBJ)/grkeytest$(O) \ + $(D_OBJ)/conkey$(O) +$(eval $(call Resource,grkeytest.rc,GRKEYTESTOBJS)) TARGETS= $(GRTAGS) \ $(GRWC) \ @@ -129,6 +149,7 @@ OBJS= $(GRTAGSOBJS) \ $(GRWCOBJS) \ $(GRKEYTESTOBJS) + ######################################################################################### # Rules @@ -149,9 +170,15 @@ $(GRWC): $(D_OBJ)/.created $(GRWCOBJS) $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ $(GRWCOBJS) $(LDLIBS) $(GRKEYTEST): LINKLIBS=-lmisc -lllist +ifeq ("cygwin","@build_os@") + # libiberty has a local implementation of getopt; an invalid optarg binding results, conflicting local/dllexport usage, filter-out. +$(GRKEYTEST): LDLIBS:=$(filter-out -liberty, $(LDLIBS)) +endif $(GRKEYTEST): $(D_OBJ)/.created $(GRKEYTESTOBJS) $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ $(GRKEYTESTOBJS) $(LDLIBS) +$(D_OBJ)/grkeytest$(O): w32keytest.c conkeytest.c + $(D_OBJ)/.created: -@mkdir $(D_OBJ) @echo "do not delete" > $@ @@ -170,4 +197,10 @@ $(D_OBJ)/%$(O): %$(C) $(D_OBJ)/%$(O): $(D_GR)/%$(C) $(CC) $(CFLAGS) -o $@ -c -DGRTAGS $< +$(D_OBJ)/%.res: %.rc + $(RC) -fo $@ $< + +$(D_OBJ)/%_res.o: %.rc + $(RC) -o $@ $< + #end diff --git a/util/conkey.c b/util/conkey.c new file mode 100644 index 00000000..465a3956 --- /dev/null +++ b/util/conkey.c @@ -0,0 +1,629 @@ +/* -*- mode: c; indent-width: 4; -*- */ +/* $Id: conkey.c,v 1.8 2024/09/20 14:51:42 cvsuser Exp $ + * console key util, support. + * + * + * This file is part of the GRIEF Editor. + * + * The GRIEF Editor is free software: you can redistribute it + * and/or modify it under the terms of the GRIEF Editor License. + * + * The GRIEF Editor is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * License for more details. + * ==end== + */ + +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif + +#include +#include +#include +#include +#if defined(_MSC_VER) && (_MSC_VER <= 1600 /*2010*/) +#define snprintf _snprintf +#endif + +#if defined(_WIN32) +#define WINDOWS_MEAN_AND_LEAN +#include +#else +#include "conkeywin.h" +#endif + +#include "conkey.h" + +static unsigned XTermModifiers(unsigned n); + + +// +// Mouse event description +// +const char * +mouse_description(const MOUSE_EVENT_RECORD *me) +{ + static char t_buffer[200]; // local description buffer + + const DWORD dwControlKeyState = me->dwControlKeyState, + dwEventFlags = me->dwEventFlags, dwButtonState = me->dwButtonState; + const BOOL release = (dwEventFlags & (MOUSE_RELEASED|MOUSE_RELEASE_ALL)) ? 1 : 0; + char* cursor = t_buffer, * end = cursor + sizeof(t_buffer); + + // controls + if (dwControlKeyState & ALT_PRESSED) + cursor += snprintf(cursor, end - cursor, "Alt-"); + if (dwControlKeyState & CTRL_PRESSED) + cursor += snprintf(cursor, end - cursor, "Ctrl-"); + if (dwControlKeyState & CTRL_PRESSED) + cursor += snprintf(cursor, end - cursor, "Shift-"); + + // buttons + if (dwButtonState & FROM_LEFT_1ST_BUTTON_PRESSED) + cursor += snprintf(cursor, end - cursor, "Button1"); + else if (dwButtonState & RIGHTMOST_BUTTON_PRESSED) + cursor += snprintf(cursor, end - cursor, "Button2"); + else if (dwButtonState & FROM_LEFT_2ND_BUTTON_PRESSED) + cursor += snprintf(cursor, end - cursor, "Button3"); + // else if (dwButtonState & FROM_LEFT_3RD_BUTTON_PRESSED) + // cursor += snprintf(cursor, end - cursor, "Button4"); + // else if (dwButtonState & FROM_LEFT_4TH_BUTTON_PRESSED) + // cursor += snprintf(cursor, end - cursor, "Button5"); + + // actions + if (release) { + cursor += snprintf(cursor, end - cursor, (cursor > t_buffer ? "-Release" : "Release")); + } else { + if (cursor > t_buffer) + *cursor++ = '-'; + + if (dwEventFlags & MOUSE_WHEELED) { + cursor += snprintf(cursor, end - cursor, "Wheel-%s", + (0xFF000000 & me->dwButtonState ? "Down" : "Up")); + + } else if (dwEventFlags & MOUSE_HWHEELED) { + cursor += snprintf(cursor, end - cursor, "Wheel-%s", + (0xFF000000 & me->dwButtonState ? "Right" : "Left")); + + } else if (dwEventFlags & (MOUSE_WHEELED | MOUSE_HWHEELED)) { + cursor += snprintf(cursor, end - cursor, "Wheel"); + + } else if (dwEventFlags & MOUSE_MOVED) { + cursor += snprintf(cursor, end - cursor, "Motion"); + + } else if (dwEventFlags & DOUBLE_CLICK) { + cursor += snprintf(cursor, end - cursor, "Double"); + + } else if (0 == dwEventFlags || (dwEventFlags & MOUSE_PRESSED)) { + cursor += snprintf(cursor, end - cursor, "Press"); + } + } + + // position + switch (dwEventFlags) + { + case MOUSE_WHEELED: // vertical + case MOUSE_HWHEELED: // horizontal + break; + default: + cursor += snprintf(cursor, end - cursor, ", X:%u, Y:%u", + (unsigned)me->dwMousePosition.X, (unsigned)me->dwMousePosition.Y); + break; + } + + return (cursor > t_buffer ? t_buffer : NULL); +} + + +const char * +key_description(const KEY_EVENT_RECORD *ke) +{ +#if defined(META_PRESSED) +#define CTRLSTATUSMASK (META_PRESSED|ALT_PRESSED|CTRL_PRESSED||SHIFT_PRESSED) +#else +#define CTRLSTATUSMASK (ALT_PRESSED|CTRL_PRESSED||SHIFT_PRESSED) +#endif + + static char t_buffer[200]; // local description buffer + + const DWORD dwControlKeyState = ke->dwControlKeyState; +// const WORD wVirtualKeyCode = ke->wVirtualKeyCode; + char* cursor = t_buffer, * end = cursor + sizeof(t_buffer); + + // Control states +#if defined(META_PRESSED) + if (dwControlKeyState & META_PRESSED) + cursor += snprintf(cursor, end - cursor, "Meta-"); +#endif + + if (dwControlKeyState & ALT_PRESSED) + cursor += snprintf(cursor, end - cursor, "Alt-"); + + if (dwControlKeyState & CTRL_PRESSED) + cursor += snprintf(cursor, end - cursor, "Ctrl-"); + + if (dwControlKeyState & SHIFT_PRESSED) + cursor += snprintf(cursor, end - cursor, "Shift-"); + + // Key code + if (ke->uChar.UnicodeChar) { + const WORD uc = ke->uChar.UnicodeChar; + const char *desc = NULL; + + switch (uc) { + case '\a': desc = "Alert"; break; + case '\b': desc = "Backspace"; break; + case '\n': desc = "Newline"; break; + case '\r': desc = "Enter"; break; + case '\t': desc = "Tab"; break; + case '\v': desc = "Vtab"; break; + case '\f': desc = "Formfeed"; break; + case 0x1b: desc = "Esc"; break; + case ' ': + if (dwControlKeyState & CTRLSTATUSMASK) { + desc = "Space"; + } + break; + } + + if (desc) { + cursor += snprintf(cursor, end - cursor, "%s", desc); + } else { + if (uc > ' ' && uc < 0xff) { + // ASCII + if ((dwControlKeyState & CTRLSTATUSMASK) && uc >= 'a' && uc <= 'z') { + *cursor++ = (char)(uc - 'a' + 'A'); // upper-case meta controls. + } else { + *cursor++ = (char)uc; + } + *cursor++ = 0; + + } else if (uc < ' ' && (dwControlKeyState & CTRL_PRESSED)) { + // Controls + *cursor++ = (char)(('A' - 1) + uc); + *cursor++ = 0; + + } else { + // Unicode + cursor += snprintf(cursor, end - cursor, "#%u", uc); + } + } + } + + return (cursor > t_buffer ? t_buffer : NULL); +} + + +// +// Decode a cygwin specific key escape sequence into our internal key-code. +// + +const char * +DecodeCygwinKey(INPUT_RECORD *ir, const char *buf, const char *end) +{ + enum { + cwKeyDown, + cwRepeatCount, + cwVirtualKeyCode, + cwVirtualScanCode, + cwUnicodeChar, + cwControlKeyState, + cwArgumentMax + }; + + if ((buf + 8) < end && buf[0] == '\033' && buf[1] == '{') { + /* + * \033[2000h - turn on raw keyboard mode, + * \033[2000l - turn off raw keyboard mode. + * + * Format: + * {Kd;Rc;Vk;Sc;Uc;CsK + * + * Kd: the value of bKeyDown. + * Rc: the value of wRepeatCount. + * Vk: the value of wVirtualKeyCode. + * Sc: the value of wVirtualScanCode. + * Uc: the decimal value of UnicodeChar. + * Cs: the value of dwControlKeyState. + * + * Example: + * {0;1;13;28;13;0K + */ + unsigned args[cwArgumentMax] = { 0, 0, 0, 0, 0, 0 }; + const char *cursor; + + if (NULL != (cursor = DecodeKeyArguments(args, cwArgumentMax, 'K', buf + 2, end))) { + KEY_EVENT_RECORD* ke = &ir->Event.KeyEvent; + + memset(ke, 0, sizeof(*ke)); + ke->bKeyDown = (args[cwKeyDown] ? 1U : 0U); + ke->wRepeatCount = (WORD)(args[cwRepeatCount]); + ke->wVirtualKeyCode = (WORD)(args[cwVirtualKeyCode]); + ke->wVirtualScanCode = (WORD)(args[cwVirtualScanCode]); + ke->uChar.UnicodeChar = (WCHAR)(args[cwUnicodeChar]); + ke->dwControlKeyState = (DWORD)(args[cwControlKeyState]); + ir->EventType = KEY_EVENT; + return cursor; + } + } + return NULL; +} + + +// +// Decode a MSTerminal specific key escape sequence into our internal key-code. +// + +const char * +DecodeMSTerminalKey(INPUT_RECORD *ir, const char *buf, const char *end) +{ + enum { + msVirtualKeyCode, + msVirtualScanCode, + msUnicodeChar, + msKeyDown, + msControlKeyState, + msRepeatCount, + msArgumentMax + }; + + if ((buf + 8) < end && buf[0] == '\033' && buf[1] == '[') { + /* + * Terminal win32-input-mode + * + * [17;29;0;1;8;1_ + * + * Format: + * + * [Vk;Sc;Uc;Kd;Cs;Rc_ + * + * Vk: the value of wVirtualKeyCode - any number. If omitted, defaults to '0'. + * Sc: the value of wVirtualScanCode - any number. If omitted, defaults to '0'. + * Uc: the decimal value of UnicodeChar - for example, NUL is "0", LF is + * "10", the character 'A' is "65". If omitted, defaults to '0'. + * Kd: the value of bKeyDown - either a '0' or '1'. If omitted, defaults to '0'. + * Cs: the value of dwControlKeyState - any number. If omitted, defaults to '0'. + * Rc: the value of wRepeatCount - any number. If omitted, defaults to '1'. + * + * Reference + * https://github.com/microsoft/terminal/blob/main/doc/specs/%234999%20-%20Improved%20keyboard%20handling%20in%20Conpty.md + */ + unsigned args[msArgumentMax] = { 0, 0, 0, 0, 0, 1 }; + const char *cursor; + + if (NULL != (cursor = DecodeKeyArguments(args, msArgumentMax, '_', buf + 2, end))) { + KEY_EVENT_RECORD* ke = &ir->Event.KeyEvent; + + memset(ke, 0, sizeof(*ke)); + ke->bKeyDown = (args[msKeyDown] ? 1U : 0U); + ke->wRepeatCount = (WORD)(args[msRepeatCount]); + ke->wVirtualKeyCode = (WORD)(args[msVirtualKeyCode]); + ke->wVirtualScanCode = (WORD)(args[msVirtualScanCode]); + ke->uChar.UnicodeChar = (WCHAR)(args[msUnicodeChar]); + ke->dwControlKeyState = (DWORD)(args[msControlKeyState]); + ir->EventType = KEY_EVENT; + return cursor; + } + } + ir->EventType = 0; + return NULL; +} + + +const char * +DecodeXTermKey(INPUT_RECORD *ir, const char *buf, const char *end) +{ + if ((buf + 6) < end && buf[0] == '\033' && buf[1] == '[') { + /* + * \e[27;;~ or xterm + * \e[;u formatOtherKeys=1 in xterm; which is the mintty default. + * + * https://invisible-island.net/xterm/modified-keys-gb-altgr-intl.html#other_modifiable_keycodes + */ + unsigned args[3] = { 0, 0, 0 }; + const char *cursor; + + if (buf[2] == '2' && buf[3] == '7') { + if (NULL != (cursor = DecodeKeyArguments(args, 3, '~', buf + 2, end))) { + if (args[0] == 27) { + KEY_EVENT_RECORD* ke = &ir->Event.KeyEvent; + const unsigned modifiers = XTermModifiers(args[1]); + WCHAR key = (WCHAR)args[2]; + + if ((modifiers & SHIFT_PRESSED) && key >= 'a' && key <= 'z') + key += (WCHAR)('A' - 'a'); + + memset(ke, 0, sizeof(*ke)); + ke->bKeyDown = 1U; + ke->wRepeatCount = 1; + ke->wVirtualKeyCode = (WORD)(0); + ke->wVirtualScanCode = (WORD)(0); + ke->uChar.UnicodeChar = (WCHAR)(key); + ke->dwControlKeyState = (DWORD)(modifiers); + ir->EventType = KEY_EVENT; + return cursor; + } + } + } + + if (NULL != (cursor = DecodeKeyArguments(args, 2, 'u', buf + 2, end))) { + KEY_EVENT_RECORD* ke = &ir->Event.KeyEvent; + const unsigned modifiers = XTermModifiers(args[1]); + WCHAR key = (WCHAR)args[0]; + + if ((modifiers & SHIFT_PRESSED) && key >= 'a' && key <= 'z') + key += (WCHAR)('A' - 'a'); + + memset(ke, 0, sizeof(*ke)); + ke->bKeyDown = 1U; + ke->wRepeatCount = 1; + ke->wVirtualKeyCode = (WORD)(0); + ke->wVirtualScanCode = (WORD)(0); + ke->uChar.UnicodeChar = (WCHAR)(key); + ke->dwControlKeyState = (DWORD)(modifiers); + ir->EventType = KEY_EVENT; + return cursor; + } + } + ir->EventType = 0; + return NULL; +} + + +static unsigned +XTermModifiers(unsigned n) +{ + unsigned code = n - 1, modifiers = 0; + + if (code & 1) + modifiers |= SHIFT_PRESSED; + if (code & 2) + modifiers |= ALT_PRESSED; + if (code & 4) + modifiers |= CTRL_PRESSED; +#if defined(META_PRESSED) + if (code & 8) + modifiers |= META_PRESSED; +#endif + // others? + return modifiers; +} + + + +const void * +DecodeKeyArguments(unsigned arguments[], unsigned maxargs, char terminator, const void *buffer, const void *end) +{ + const char *cursor = (const char *)buffer; + unsigned args = 0, digits = 0; + + while (cursor < (const char *)end && *cursor) { + const unsigned char c = *cursor++; + + if (c >= '0' && c <= '9') { + if (0 == digits++) { + if (args >= maxargs) { + break; // overflow + } + arguments[args] = (c - '0'); + } else { + arguments[args] = (arguments[args] * 10) + (c - '0'); + } + } else if (c == ';' || c == terminator) { + digits = 0; + ++args; + if (c == terminator) { // terminator + return (args >= 1 ? cursor : NULL); + } + + } else { + args = 0; // non-digit + break; + } + } + return NULL; +} + + +// DecodeXTermMouse +// Parse a xterm (X10 compatibility mode) mouse encoded event. +// +// Normal tracking mode sends an escape sequence on both button press and +// release. Modifier key (shift, ctrl, meta) information is also sent. It +// is enabled by specifying parameter 1000 to DECSET. +// +// On button press or release, xterm sends CSI M Cb Cx Cy . +// +// o The low two bits of C b encode button information: +// +// 0=MB1 pressed, +// 1=MB2 pressed, +// 2=MB3 pressed, +// 3=release. +// +// o The next three bits encode the modifiers which were down when the +// button was pressed and are added together: +// +// 4=Shift, 8=Meta, 16=Control. +// +// Note however that the shift and control bits are normally unavailable +// because xterm uses the control modifier with mouse for popup menus, and +// the shift modifier is used in the default translations for button events. +// The Meta modifier recognized by xterm is the mod1 mask, and is not +// necessarily the "Meta" key (see xmodmap). +// +// o C x and C y are the x and y coordinates of the mouse event, encoded as +// in X10 mode. x = (Cx - 33), y = (Cy - 33) +// +// Wheel mice may return buttons 4 and 5. Those buttons are represented by +// the same event codes as buttons 1 and 2 respectively, except that 64 is +// added to the event code. Release events for the wheel buttons are not +// reported. By default, the wheel mouse events are translated to scroll-back +// and scroll-forw actions. Those actions normally scroll the whole window, +// as if the scrollbar was used. However if Alternate Scroll mode is set, +// then cursor up/down controls are sent when the terminal is displaying the +// alternate screen. +// +// Notes: +// o msterminal wont report motion beyond x or y value of 94 (127 - 33). +// o mintty reports x/y values upto 224, which is (224 + 32) == 256/0x100, represented by a nul. +// +const void * +DecodeXTermMouse(INPUT_RECORD *ir, const void *spec, const void *end) +{ + const BYTE *cursor = (const BYTE *)spec; + unsigned arguments[3] = {0}, nargs = 0; + + // + // \x1B[Mabc", where: + // a: Button number plus 32. + // b: Column number (one-based) plus 32. + // c: Row number (one-based) plus 32. + // + if ((cursor + 6) > (const BYTE *)end || + cursor[0] != 0x1b || cursor[1] != '[' || cursor[2] != 'M') { + return NULL; // CSI + } + + // parameters + for (cursor += 3; cursor != (const BYTE *)end && (*cursor >= ' ' || 0 == *cursor) && nargs < 3;) { + arguments[nargs++] = *cursor++; // mintty, allow NUL + } + + // decode + if (3 == nargs) { + MOUSE_EVENT_RECORD* me = &ir->Event.MouseEvent; + const unsigned button = arguments[0]; + + memset(me, 0, sizeof(*me)); + + if (0x60 == (0x60 & button)) { // 0110 000x + me->dwEventFlags = MOUSE_WHEELED; + me->dwButtonState = + (button & 0x1) ? 0xFF000000 /*down*/ : 0x00000000 /*up*/; + + } else { + me->dwEventFlags = ((button & 64) ? MOUSE_MOVED : 0); // 1002 mode + switch (button & 0x3) { // 000x 00xx + case 0: // button-1 + me->dwButtonState = FROM_LEFT_1ST_BUTTON_PRESSED; + break; + case 1: // button-2 + me->dwButtonState = RIGHTMOST_BUTTON_PRESSED; + break; + case 2: // button-3 + me->dwButtonState = FROM_LEFT_2ND_BUTTON_PRESSED; + break; + case 3: + me->dwEventFlags |= MOUSE_RELEASE_ALL; + break; + } + } + me->dwControlKeyState = // 000x xx00 + (-!!(button & 16) & CTRL_PRESSED) | + (-!!(button & 8) & ALT_PRESSED) | + (-!!(button & 4) & SHIFT_PRESSED); + me->dwMousePosition.X = (short)(arguments[1] - 32) + 1; + me->dwMousePosition.Y = (short)(arguments[2] - 32) + 1; + ir->EventType = MOUSE_EVENT; + return cursor; + } + ir->EventType = 0; + return NULL; +} + + +// SGR Mouse event +// +// SGR(1006) The normal mouse response is altered to use "CSI <" followed by semicolon separated numbers: / +// +// o Button value +// o Px and Py ordinates and +// o Final character which is M for button press and m for button release. +// +const void * +DecodeSGRMouse(INPUT_RECORD *ir, const void *spec, const void *end) +{ + const BYTE *cursor = spec; + unsigned arguments[3] = {0}, args = 0; + int digits = 0, press = -1; + + // + // \x1B[ (const BYTE *)end || + cursor[0] != 0x1b || cursor[1] != '[' || cursor[2] != '<') { + return NULL; // CSI + } + + // parameters + for (cursor += 3; *cursor;) { + const BYTE c = *cursor++; + + if (c >= '0' && c <= '9') { + if (0 == digits++) { + if (args > 3) { + break; // overflow + } + arguments[args] = (c- '0'); + } else { + arguments[args] = (arguments[args] * 10) + (c - '0'); + } + } else if (c == ';' || c == 'M' || c == 'm') { + digits = 0; + ++args; + if (c != ';') { + press = (c == 'M'); + break; // terminator + } + } + } + + // buttons, position + if (args == 3 && press != -1) { + MOUSE_EVENT_RECORD* me = &ir->Event.MouseEvent; + const unsigned button = arguments[0]; + + memset(me, 0, sizeof(*me)); + if (button & 64) { + me->dwEventFlags = MOUSE_WHEELED; + me->dwButtonState = + (button & 0x1) ? 0xFF000000 /*down*/ : 0x00000000 /*up*/; + + } else { + me->dwEventFlags = ((button & 64) ? MOUSE_MOVED : 0); // 1002 mode + me->dwEventFlags |= (press ? MOUSE_PRESSED : MOUSE_RELEASED); + switch (button & 0x3) { + case 0: // button-1 + me->dwButtonState = FROM_LEFT_1ST_BUTTON_PRESSED; + break; + case 1: // button-2 + me->dwButtonState = RIGHTMOST_BUTTON_PRESSED; + break; + case 2: // button-3 + me->dwButtonState = FROM_LEFT_2ND_BUTTON_PRESSED; + break; + case 3: + break; + } + } + me->dwControlKeyState = + (-!!(button & 16) & ALT_PRESSED) | + (-!!(button & 8) & CTRL_PRESSED) | + (-!!(button & 4) & SHIFT_PRESSED); + me->dwMousePosition.X = (WORD)(arguments[1]); + me->dwMousePosition.Y = (WORD)(arguments[2]); + ir->EventType = MOUSE_EVENT; + return cursor; + } + ir->EventType = 0; + return NULL; +} + +//end \ No newline at end of file diff --git a/util/conkey.h b/util/conkey.h new file mode 100644 index 00000000..665de82f --- /dev/null +++ b/util/conkey.h @@ -0,0 +1,41 @@ +/* -*- mode: c; indent-width: 4; -*- */ +/* $Id: conkey.h,v 1.3 2024/09/16 16:20:36 cvsuser Exp $ + * console key support + * + * + * This file is part of the GRIEF Editor. + * + * The GRIEF Editor is free software: you can redistribute it + * and/or modify it under the terms of the GRIEF Editor License. + * + * The GRIEF Editor is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * License for more details. + * ==end== + */ + +#define ALT_PRESSED (LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED) +#define CTRL_PRESSED (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED) + +#define MOUSE_PRESSED 0x1000 // extension +#define MOUSE_RELEASED 0x2000 // extension +#define MOUSE_RELEASE_ALL 0x4000 // extension + +#if !defined(MOUSE_HWHEELED) +#define MOUSE_HWHEELED 0x0008 +#endif + +const char *mouse_description(const MOUSE_EVENT_RECORD* mer); +const char *key_description(const KEY_EVENT_RECORD *ke); + +const char *DecodeCygwinKey(INPUT_RECORD *ir, const char *spec, const char *end); +const char *DecodeMSTerminalKey(INPUT_RECORD *ir, const char *spec, const char *end); +const char *DecodeXTermKey(INPUT_RECORD *ir, const char *spec, const char *end); + +const void *DecodeKeyArguments(unsigned arguments[], unsigned maxargs, char terminator, const void *buffer, const void *end); + +const void *DecodeXTermMouse(INPUT_RECORD *ir, const void *spec, const void *end); +const void *DecodeSGRMouse(INPUT_RECORD *ir, const void *spec, const void *end); + +//end diff --git a/util/conkeytest.c b/util/conkeytest.c new file mode 100644 index 00000000..e4be68ad --- /dev/null +++ b/util/conkeytest.c @@ -0,0 +1,489 @@ +/* -*- mode: c; indent-width: 4; -*- */ +/* $Id: conkeytest.c,v 1.11 2024/09/20 03:21:34 cvsuser Exp $ + * console key-test -- ttyconsole + * Build: gcc -o conkeytest conkeytest.c conkey.c + * + * + * This file is part of the GRIEF Editor. + * + * The GRIEF Editor is free software: you can redistribute it + * and/or modify it under the terms of the GRIEF Editor License. + * + * The GRIEF Editor is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * License for more details. + * ==end== + */ + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "conkeywin.h" +#include "conkey.h" + +enum KeyboardMode { + KEYBOARD_STANDARD, + KEYBOARD_CYGWIN, + KEYBOARD_MSTERMINAL, + KEYBOARD_XTERM_META, + KEYBOARD_XTERM_MOK2, + KEYBOARD_KITTY +}; + +enum MouseMode { + MOUSE_OFF, + MOUSE_XTERM, + MOUSE_XTERM_X11, + MOUSE_XTERM_SGR +}; + +struct uversion { +#define UVERSION_CYGWIN 0x01 +#define UVERSION_LINUX 0x02 + unsigned umajor; + unsigned uminor; + unsigned upatch; +}; + +static void usage(void); +static const char *progname_get(const char *argv0); + +static void runner(const enum MouseMode mmode, const enum KeyboardMode kmode); +static void hex(const void *buf, unsigned len); +static void prints(const char *str); +static void mouse_mode(const enum MouseMode mode, int state); +static void keyboard_mode(const enum KeyboardMode mode, int state); + +static int uversion_get(struct uversion *uv); +static int uversion_cmp(const struct uversion *uv, unsigned umajor, unsigned uminor, unsigned upatch); + +static const char *progname = ""; +static const char *short_options = "k:m:b:qh"; +static struct option long_options[] = { + {"key", required_argument, NULL, 'k'}, + {"mouse", required_argument, NULL, 'm'}, + {"bufsiz", required_argument, NULL, 'b'}, + {"quiet", no_argument, NULL, 'q'}, + {"help", no_argument, NULL, 'h'}, + {NULL} +}; + +static unsigned overbose = 1; +static size_t obufsiz = 128; + + +int +main(int argc, char **argv) +{ + enum MouseMode mmode = MOUSE_OFF; + enum KeyboardMode kmode = KEYBOARD_STANDARD; + int optidx = 0, c; + + progname = progname_get(argv[0]); + while ((c = getopt_long(argc, argv, short_options, long_options, &optidx)) != EOF) { + switch (c) { + case 'v': // -v,--verbose + break; + + case 'k': // -k,--key= + if (0 == strcmp(optarg, "standard")) { + kmode = KEYBOARD_STANDARD; + } else if (0 == strcmp(optarg, "cygwin")) { + kmode = KEYBOARD_CYGWIN; + } else if (0 == strcmp(optarg, "msterminal")) { + struct uversion uv = {0}; + + if (UVERSION_CYGWIN == uversion_get(&uv) && uversion_cmp(&uv, 3, 5, 5) < 0) { + printf("cygwin: %u.%u.%u, wont correctly support win-input-mode\n", + uv.umajor, uv.uminor, uv.upatch); + return EXIT_FAILURE; + } + kmode = KEYBOARD_MSTERMINAL; + } else if (0 == strcmp(optarg, "xterm-meta")) { + kmode = KEYBOARD_XTERM_META; + } else if (0 == strcmp(optarg, "xterm-mok2")) { + kmode = KEYBOARD_XTERM_MOK2; + } else if (0 == strcmp(optarg, "kitty")) { + kmode = KEYBOARD_KITTY; + } else { + printf("%s: unexpected raw-mode <%s>\n", progname, optarg); + usage(); + } + break; + + case 'm': // -m,--mouse= + if (0 == strcmp(optarg, "off")) { + mmode = MOUSE_OFF; + } else if (0 == strcmp(optarg, "xterm")) { + mmode = MOUSE_XTERM; + } else if (0 == strcmp(optarg, "x11")) { + mmode = MOUSE_XTERM_X11; + } else if (0 == strcmp(optarg, "sgr")) { + mmode = MOUSE_XTERM_SGR; + } else { + printf("%s: unexpected mouse-mode <%s>\n", progname, optarg); + usage(); + } + break; + + case 'q': // -q,--quiet + overbose = 0; + break; + + case 'b': // -b,--bufsize=bytes + if ((obufsiz = strtoul(optarg, NULL, 0)) < 16) { + obufsiz = 16; + } + break; + + case 'h': // -h,--help + usage(); + return EXIT_FAILURE; + + default: + return EXIT_FAILURE; + } + } + + argv += optind; + if ((argc -= optind) != 0) { + printf("%s: unexpected argument(s) %s\n", progname, argv[0]); + usage(); + } + + runner(mmode, kmode); + return 0; +} + + +static void +usage(void) +{ + static const char *options[] = { + "", + "Options:", + " -k,--key= Keyboard mode (standard [default],cygwin,msterminal,xterm-meta,xterm-mok2,kitty)", + " -m,--mouse= Mouse mode (off [default],xterm,x11,sgr)", + "", + " -h,--help Command line usage", + "" + }; + + printf("\n%s [options]\n", progname); + for (unsigned i = 0; i != (sizeof(options)/sizeof(options[0])); ++i) + printf("%s\n", options[i]); + exit(EXIT_FAILURE); +} + + +static const char * +progname_get(const char *argv0) +{ + const char *s1 = rindex(argv0 , '/'), + *s2 = rindex(argv0, '\\'); + + return (s1 > s2 ? (s1 + 1) : (s2 ? (s2 + 1) : argv0)); +} + + +/* + * key poller + */ +static void +runner(const enum MouseMode mmode, const enum KeyboardMode kmode) +{ + struct termios bak, cfg; + + char *buf = malloc(obufsiz); + unsigned event_count = 0; + INPUT_RECORD ir; + const char *cursor, *end; + int cnt, q; + + tcgetattr(STDIN_FILENO, &cfg); + bak = cfg; + cfmakeraw(&cfg); + cfg.c_lflag &= ~ECHO; + tcsetattr(STDIN_FILENO, TCSADRAIN, &cfg); + + mouse_mode(mmode, 1); + keyboard_mode(kmode, 1); + + printf("\n\rkey-test (press 'q' twice to exit, kmode=%u, mmode=%u, bufsiz=%u, verbose=%u):\n\r", + (unsigned)kmode, (unsigned)mmode, obufsiz, overbose); + fflush(stdout); + + for (q = 0; (cnt = read(STDIN_FILENO, buf, obufsiz)) > 0;) { + WCHAR firstchar = (cnt == 1 ? buf[0] : 0); + + if (overbose) { + hex(buf, cnt); + } + + for (cursor = buf, end = cursor + cnt; cursor < end; ) { + if (kmode) { // key events + if (cursor[0] == 0x1b && (cursor[1] == '{' || cursor[1] == '[')) { + const char *term; + + if (NULL != (term = DecodeCygwinKey(&ir, cursor, end)) || + NULL != (term = DecodeMSTerminalKey(&ir, cursor, end)) || + NULL != (term = DecodeXTermKey(&ir, cursor, end))) { + const KEY_EVENT_RECORD* ke = &ir.Event.KeyEvent; + const WCHAR ch = ke->uChar.UnicodeChar; + + printf("%4d: %s %02u VC=0x%04x/%u, SC=0x%04x/%u, KEY=0x%x/'%c', CTRL=%08llx %s\n\r", + event_count, (ke->bKeyDown ? "Dn" : "Up"), (unsigned)ke->wRepeatCount, + (unsigned)ke->wVirtualKeyCode, (unsigned)ke->wVirtualKeyCode, + (unsigned)ke->wVirtualScanCode, (unsigned)ke->wVirtualScanCode, + (unsigned)ch, (ch >= ' ' && ch < 0x7f ? ch : '.'), (unsigned long long)ke->dwControlKeyState, + key_description(ke)); + if (ke->bKeyDown && 0 == firstchar) { + firstchar = ch; + } + ++event_count; + cursor = term; + continue; + } + } + } + if (mmode) { // mouse events + if (cursor[0] == 0x1b && cursor[1] == '[') { + const char *term; + + if (NULL != (term = DecodeXTermMouse(&ir, cursor, end)) || + NULL != (term = DecodeSGRMouse(&ir, cursor, end))) { + const MOUSE_EVENT_RECORD* me = &ir.Event.MouseEvent; + + printf("%4d: %03u %04u %03u %s\n\r", + event_count, (unsigned)me->dwEventFlags, + (unsigned)LOWORD(me->dwButtonState), (unsigned)me->dwControlKeyState, + mouse_description(me)); + ++event_count; + cursor = term; + continue; + } + } + } + ++cursor; + } + + if (firstchar) { + if (firstchar == 'q' || firstchar == 'Q') { + if (++q == 2) + break; + } else { + q = 0; + } + } + + //prints("\n\r"); + } + + keyboard_mode(kmode, 0); + mouse_mode(mmode, 0); + fflush(stdout); + + tcsetattr(STDIN_FILENO, TCSADRAIN, &bak); +} + + +/* + * Buffer hex dump. + */ +static void +hex(const void *buf, unsigned len) +{ +#define HEXWIDTH 16 +#define HEXCOLUMN 4 + const unsigned char *cursor = buf, *end = cursor + len; + unsigned offset = 0; + + for (offset = 0; cursor != end; offset += HEXWIDTH) { + const unsigned char *data = cursor; + + printf("%04x: ", offset); + for (unsigned col = 0; col < HEXWIDTH; ++col) { + if ((col % HEXCOLUMN) == 0 && col) + prints(" |"); + if (data == end) { + prints(" "); + } else { + printf(" %02x", *data++); + } + } + + prints(" "); + for (unsigned col = 0; col < HEXWIDTH; ++col) { + if (cursor == end) { + printf("%*s", HEXWIDTH - col, ""); + break; + } else { + const unsigned char c = *cursor++; + printf("%c", (c >= ' ' && c < 0x7f ? c : '.')); + } + } + prints("\n\r"); + } +} + + +static void +prints(const char *str) +{ + fputs(str, stdout); +} + + +/* + * Mouse mode configuration. + */ +static void +mouse_mode(const enum MouseMode mode, int state) +{ + if (mode == MOUSE_OFF) + return; + + if (state) { + if (mode == MOUSE_XTERM) { + prints("\033[?1000h"); // enable mouse presses. + + } else { // XTERM X11 & SGR + prints("\033[?1002h"); // enable cell-motion tracking tracking. + if (mode == MOUSE_XTERM_SGR) { + prints("\033[?1006h"); // enable SGR extended mouse mode. + } + prints("\033[?1004h"); // enable mouse focus events. + } + } else { + if (mode == MOUSE_XTERM) { + prints("\033[?1000l"); // disable mouse presses. + + } else { // XTERM X11 & SGR + prints("\033[?1004l"); // disable mouse focus events. + if (mode == MOUSE_XTERM_SGR) { + prints("\033[?1006l"); // disable SGR extended mouse mode. + } + prints("\033[?1002l"); // disable cell-motion tracking tracking. + } + } +} + + +/* + * Keyboard mode configuration. + */ +static void +keyboard_mode(const enum KeyboardMode mode, int state) +{ + if (mode == KEYBOARD_STANDARD) + return; + + if (state) { + if (mode == KEYBOARD_CYGWIN) { + prints("\033[?2000h"); // enable cygwin-raw-mode. + + } else if (mode == KEYBOARD_MSTERMINAL) { + prints("\033[?9001h"); // enable win32-input-mode. + + } else if (mode == KEYBOARD_XTERM_META) { + prints("\033[?1034h"); // enable meta-8bit-mode. + + } else if (mode == KEYBOARD_XTERM_MOK2) { + // + // \e[27;;~ or xterm + // \e[;u formatOtherKeys=1 in xterm; which is the mintty default. + // + // https://invisible-island.net/xterm/modified-keys-gb-altgr-intl.html#other_modifiable_keycodes + // + prints("\033[>4;2m"); // enable modifyOtherKeys + + } else if (mode == KEYBOARD_KITTY) { + // + // \e[ number ; modifiers [u~] + // \e[ 1; modifiers [ABCDEFHPQS] + // 0x0d - for the Enter key + // 0x7f or 0x08 - for Backspace + // 0x09 - for Tab + // + // https://sw.kovidgoyal.net/kitty/keyboard-protocol/ + // http://www.leonerd.org.uk/hacks/fixterms/ + // + prints("\033[>1u"); // enable kitty-keyboard-protocol + } + } else { + if (mode == KEYBOARD_CYGWIN) { + prints("\033[?2000l"); // disable cygwin-raw-mode. + + } else if (mode == KEYBOARD_MSTERMINAL) { + prints("\033[?9001l"); // disable win32-input-mode. + + } else if (mode == KEYBOARD_XTERM_META) { + prints("\033[?1034l"); // disable meta-8bit-mode. + + } else if (mode == KEYBOARD_XTERM_MOK2) { + prints("\033[>4;0m"); // disable modifyOtherKeys + + } else if (mode == KEYBOARD_KITTY) { + prints("\033[ + +static int +uversion_get(struct uversion *uv) +{ + struct utsname uts = {0}; + int fd; + + if (0 == uname(&uts)) { + if (0 == memcmp(uts.sysname, "CYGWIN", 6)) { + if (3 == sscanf(uts.release, "%u.%u.%u", &uv->umajor, &uv->uminor, &uv->upatch)) { + return UVERSION_CYGWIN; + } + + } else if (0 == memcmp(uts.sysname, "Linux", 5)) { + if (3 == sscanf(uts.release, "%u.%u.%u", &uv->umajor, &uv->uminor, &uv->upatch)) { + return UVERSION_LINUX; + } + } + return 0; + } + return -1; +} + + +static int +uversion_cmp(const struct uversion *uv, unsigned umajor, unsigned uminor, unsigned upatch) +{ + if (uv->umajor > umajor) + return 1; // greater + if (uv->umajor == umajor) { + if (uv->uminor > uminor) + return 1; // greater + if (uv->uminor == uminor) { + if (uv->upatch > upatch) + return 1; // greater + if (uv->upatch == upatch) + return 0; // equal + } + } + return -1; +} + +//end + diff --git a/util/conkeywin.h b/util/conkeywin.h new file mode 100644 index 00000000..82004825 --- /dev/null +++ b/util/conkeywin.h @@ -0,0 +1,83 @@ +/* + * console key test -- window style definitions. + */ + +typedef unsigned char BOOL; +typedef unsigned char BYTE; +typedef unsigned short WORD; +typedef unsigned long DWORD; +#define LOWORD(__x) ((WORD)((__x) >> 0)) +#define HIWORD(__x) ((WORD)((__x) >> 16)) +typedef unsigned char CHAR; +typedef unsigned short WCHAR; + +#if !defined(TRUE) +#define TRUE 1 +#define FALSE 0 +#endif +#if !defined(_countof) +#define _countof(__x) (sizeof(__x)/sizeof(__x[0])) +#endif + + ///////////////////////////////////////////////////// + +typedef struct _KEY_EVENT_RECORD { + BOOL bKeyDown; + WORD wRepeatCount; + WORD wVirtualKeyCode; + WORD wVirtualScanCode; + union { + WCHAR UnicodeChar; + CHAR AsciiChar; + } uChar; + DWORD dwControlKeyState; +#define CAPSLOCK_ON 0x0080 +#define ENHANCED_KEY 0x0100 +#define LEFT_ALT_PRESSED 0x0002 +#define LEFT_CTRL_PRESSED 0x0008 +#define NUMLOCK_ON 0x0020 +#define RIGHT_ALT_PRESSED 0x0001 +#define RIGHT_CTRL_PRESSED 0x0004 +#define SCROLLLOCK_ON 0x0040 +#define SHIFT_PRESSED 0x0010 +#define META_PRESSED 0x1000 /*extension*/ +} KEY_EVENT_RECORD; + + ///////////////////////////////////////////////////// + +typedef struct _MOUSE_EVENT_RECORD { + DWORD dwEventFlags; +#define MOUSE_MOVED 0x01 +#define DOUBLE_CLICK 0x02 +#define MOUSE_WHEELED 0x04 +#define MOUSE_HWHEELED 0x08 + + DWORD dwButtonState; +#define FROM_LEFT_1ST_BUTTON_PRESSED 0x01 +#define FROM_LEFT_2ND_BUTTON_PRESSED 0x02 +#define RIGHTMOST_BUTTON_PRESSED 0x04 + + DWORD dwControlKeyState; + + struct MouseCoord { + WORD X, Y; + } dwMousePosition; +} MOUSE_EVENT_RECORD; + + //////////////////////////////////////////////////// + +typedef struct INPUT_RECORD { + DWORD EventType; +#define VOID_EVENT 0x00 // extension +#define KEY_EVENT 0x0001 +#define MOUSE_EVENT 0x0002 +#define FOCUS_EVENT 0x0010 + + union { + KEY_EVENT_RECORD KeyEvent; + MOUSE_EVENT_RECORD MouseEvent; + } Event; + +} INPUT_RECORD; + +/*end*/ diff --git a/util/fmt_scaled.c b/util/fmt_scaled.c index bfced5e1..6853d929 100644 --- a/util/fmt_scaled.c +++ b/util/fmt_scaled.c @@ -36,6 +36,8 @@ * Scanning code written for OpenBSD libutil. */ +#include + #include #include #include @@ -235,9 +237,13 @@ fmt_scaled(long long number, char *result) fract = 0; } - if (number == 0) + if (number == 0) { +#if defined(HAVE_STRLCPY) strlcpy(result, "0B", FMT_SCALED_STRSIZE); - else if (unit == NONE || number >= 100 || number <= -100) { +#else + strcpy(result, "0B"); +#endif + } else if (unit == NONE || number >= 100 || number <= -100) { if (fract >= 5) { if (number >= 0) number++; @@ -252,3 +258,6 @@ fmt_scaled(long long number, char *result) return 0; } + +//end + diff --git a/util/getopt.h b/util/getopt.h new file mode 100644 index 00000000..d0daedcb --- /dev/null +++ b/util/getopt.h @@ -0,0 +1,34 @@ +#pragma once +// +// getopt/getopt_long +// + +#ifdef __cplusplus +extern "C" { +#endif + +extern int opterr; /* if error message should be printed */ +extern int optind; /* index into parent argv vector */ +extern int optopt; /* character checked for validity */ +extern int optreset; /* reset getopt */ +extern const char *optarg; /* argument associated with option */ + +struct option { + const char *name; + int has_arg; +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 + + int *flag; + int val; +}; + +int getopt(int nargc, const char * const nargv[], const char *ostr); +int getopt_long(int nargc, const char * const * nargv, const char * options, const struct option * long_options, int * index, int retval); + +#ifdef __cplusplus +} +#endif + +/*end*/ diff --git a/util/getoptlong.c b/util/getoptlong.c new file mode 100644 index 00000000..4d7ca91c --- /dev/null +++ b/util/getoptlong.c @@ -0,0 +1,222 @@ +/* + * Copyright (c) 1987, 1993, 1994, 1996 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS + * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "getopt.h" + +#include +#include +#include +#include +#include + +#define WINDOWS_MEAN_AND_LEAN +#include + +int opterr = 1; /* if error message should be printed */ +int optind = 1; /* index into parent argv vector */ +int optopt = 0; /* character checked for validity */ +int optreset = 0; /* reset getopt */ +const char *optarg = NULL; /* argument associated with option */ + +static const char *__progname (const char *); +static const char *__sysprogname (void); +static int getopt_internal (int, const char * const *, const char *); + + +static const char * +__progname(const char * nargv0) +{ + const char * tmp, *tmp2, *tmp1; + + if (NULL == nargv0) { + return __sysprogname(); + } + + tmp1 = strrchr(nargv0, '/'); + tmp2 = strrchr(nargv0, '\\'); + tmp = (tmp2 > tmp1 ? tmp2 : tmp2); + if (tmp) return tmp + 1; + return nargv0; +} + + +static const char * +__sysprogname(void) +{ + static const char *progname = NULL; + + if (NULL == progname) { + char t_buffer[1024]; + DWORD buflen; + + if ((buflen = GetModuleFileNameA(NULL, t_buffer, sizeof(t_buffer)-1)) > 0) { + t_buffer[buflen] = 0; + progname = _strdup(t_buffer); + } else { + progname = "program"; + } + } + return progname; +} + + +#define BADCH (int)'?' +#define BADARG (int)':' +#define EMSG "" + + +static int +getopt_internal(int nargc, const char * const *nargv, const char *ostr) +{ + static const char *place = EMSG; /* option letter processing */ + char *oli; /* option letter list index */ + + assert(nargv != NULL); + assert(ostr != NULL); + + if (optreset || !*place) { /* update scanning pointer */ + optreset = 0; + if (optind >= nargc || *(place = nargv[optind]) != '-') { + place = EMSG; + return (-1); + } + if (place[1] && *++place == '-') { /* found "--" */ + /* ++optind; */ + place = EMSG; + return (-2); + } + } /* option letter okay? */ + if ((optopt = (int)*place++) == (int)':' || + !(oli = strchr(ostr, optopt))) { + /* + * if the user didn't specify '-' as an option, + * assume it means -1. + */ + if (optopt == (int)'-') + return (-1); + if (!*place) + ++optind; + if (opterr && *ostr != ':') + (void)fprintf(stderr, + "%s: illegal option -- %c\n", __progname(nargv[0]), optopt); + return (BADCH); + } + if (*++oli != ':') { /* don't need argument */ + optarg = NULL; + if (!*place) + ++optind; + } else { /* need an argument */ + if (*place) /* no white space */ + optarg = place; + else if (nargc <= ++optind) { /* no arg */ + place = EMSG; + if ((opterr) && (*ostr != ':')) + (void)fprintf(stderr, + "%s: option requires an argument -- %c\n", __progname(nargv[0]), optopt); + return (BADARG); + } else /* white space */ + optarg = nargv[optind]; + place = EMSG; + ++optind; + } + return (optopt); /* dump back option letter */ +} + + + +int +getopt_long(int nargc, const char * const * nargv, const char * options, const struct option * long_options, int * index, int retval) +{ + assert(nargv != NULL); + assert(options != NULL); + assert(long_options != NULL); + /* index may be NULL */ + + if ((retval = getopt_internal(nargc, nargv, options)) == -2) { + const char *current_argv = nargv[optind++] + 2, *has_equal; + int i, match = -1; + size_t current_argv_len; + + if (*current_argv == '\0') { + return(-1); + } + if ((has_equal = strchr(current_argv, '=')) != NULL) { + current_argv_len = has_equal - current_argv; + has_equal++; + } else + current_argv_len = strlen(current_argv); + + for (i = 0; long_options[i].name; i++) { + if (strncmp(current_argv, long_options[i].name, current_argv_len)) + continue; + + if (strlen(long_options[i].name) == current_argv_len) { + match = i; + break; + } + if (match == -1) + match = i; + } + if (match != -1) { + if (long_options[match].has_arg == required_argument || + long_options[match].has_arg == optional_argument) { + if (has_equal) + optarg = has_equal; + else + optarg = nargv[optind++]; + } + if ((long_options[match].has_arg == required_argument) + && (optarg == NULL)) { + /* + * Missing argument, leading : + * indicates no error should be generated + */ + if ((opterr) && (*options != ':')) + (void)fprintf(stderr, + "%s: option requires an argument -- %s\n", __progname(nargv[0]), current_argv); + return (BADARG); + } + } else { /* No matching argument */ + if ((opterr) && (*options != ':')) + (void)fprintf(stderr, + "%s: illegal option -- %s\n", __progname(nargv[0]), current_argv); + return (BADCH); + } + if (long_options[match].flag) { + *long_options[match].flag = long_options[match].val; + retval = 0; + } else + retval = long_options[match].val; + if (index) + *index = match; + } + return(retval); +} + +/*end*/ diff --git a/util/grkeytest.c b/util/grkeytest.c index 998f97ea..30b6e971 100644 --- a/util/grkeytest.c +++ b/util/grkeytest.c @@ -1,5 +1,18 @@ -/* - * console key-test +/* -*- mode: c; indent-width: 4; -*- */ +/* $Id: grkeytest.c,v 1.4 2024/08/30 15:11:38 cvsuser Exp $ + * console key-test + * + * + * This file is part of the GRIEF Editor. + * + * The GRIEF Editor is free software: you can redistribute it + * and/or modify it under the terms of the GRIEF Editor License. + * + * The GRIEF Editor is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * License for more details. + * ==end== */ #if defined(HAVE_CONFIG_H) @@ -15,18 +28,16 @@ #undef _WIN32_WINNT #define _WIN32_WINNT 0x601 #endif -#undef WINVER +#undef WINVER #define WINVER _WIN32_WINNT + #include "w32keytest.c" +#include "getoptlong.c" #else -#include -int -main(void) -{ - printf("not implemented\n"); - return 3; -} +#include "conkeytest.c" #endif + +//end diff --git a/util/grkeytest.rc b/util/grkeytest.rc new file mode 100644 index 00000000..a9f21508 --- /dev/null +++ b/util/grkeytest.rc @@ -0,0 +1,121 @@ +/* -*- mode: c; indent-width: 4; -*- + * + * windows resource file + * + * This file is part of the GRIEF Editor. + * + * The GRIEF Editor is free software: you can redistribute it + * and/or modify it under the terms of the GRIEF Editor License. + * + * Redistributions of source code must retain the above copyright + * notice, and must be distributed with the license document above. + * + * Redistributions in binary form must reproduce the above copyright + * notice, and must include the license document above in + * the documentation and/or other materials provided with the + * distribution. + * + * The GRIEF Editor is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * License for more details. + * ==end== + */ + +#include "../include/edbuildinfo.h" + +#define RC_PRODUCTVERSION GR_VERSION_1 , GR_VERSION_2 , GR_VERSION_3 , GR_VERSION_4 +#define RC_FILEVERSION GR_VERSION_1 , GR_VERSION_2 , GR_VERSION_3 , GR_VERSION_4 + +#ifndef WINDRES +#include "windows.h" +#include "winver.h" +#endif + +/* + * English (U.S.) resources + */ + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) + +#ifdef _WIN32 +#ifndef WINDRES +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#endif +#pragma code_page(1252) +#endif /* _WIN32 */ + +/* + * Manifest + */ + +#ifndef RT_MANIFEST +#define RT_MANIFEST 24 +#endif +#ifndef CREATEPROCESS_MANIFEST_RESOURCE_ID +#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1 +#endif +CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "../gr/gr.manifest.xml" + +/* + * Updater Meta Data + * nameID typeID { raw data } + */ + +UPDATER HostURL { "\0" } +UPDATER Channel { "release\0" } + + +/* + * Version Information + */ + +VS_VERSION_INFO VERSIONINFO + FILEVERSION RC_FILEVERSION + PRODUCTVERSION RC_PRODUCTVERSION + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS (VS_FF_SPECIALBUILD|VS_FF_DEBUG) +#else + FILEFLAGS (VS_FF_SPECIALBUILD) +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE VFT2_UNKNOWN + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + BEGIN + VALUE "CompanyName", "" + VALUE "FileDescription", "GRIEF Editor, grkeytest" + VALUE "FileVersion", GR_VERSION ", Build:" GR_BUILD_DATE "-" GR_BUILD_NUMBER + VALUE "InternalName", "grkeytest" + VALUE "Copyright", + "Copyright (C) 2014 - " GR_BUILD_YEAR ", Adam Young. \n" + "Copyright (c) 1980, 1987, 1991, 1993, The Regents of the University of California. All rights reserved. \n" + "Licensed under the Grief License.\n " + "This is free software; see the source for copying conditions. \n" + "There is NO warranty; not even for MERCHANTABILITY \n" + "or FITNESS FOR A PARTICULAR PURPOSE. \0" + VALUE "Maintainers", "https://github.com/adamyg/grief\n" + VALUE "LegalTrademarks", "see GRIEF License" + VALUE "OriginalFilename", "grkeytest.exe" + VALUE "ProductName", "GRIEF" + END + END + + /* The following line should only be modified for localized versions. */ + /* It consists of any number of WORD,WORD pairs, with each pair */ + /* describing a language,codepage combination supported by the file. */ + /* */ + /* For example, a file might have values "0x409,1252" indicating that it */ + /* supports English language (0x409) in the Windows ANSI codepage (1252). */ + + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END + END + +#endif /* English (U.S.) resources */ diff --git a/util/grtags.rc b/util/grtags.rc new file mode 100644 index 00000000..23ffee1d --- /dev/null +++ b/util/grtags.rc @@ -0,0 +1,121 @@ +/* -*- mode: c; indent-width: 4; -*- + * + * windows resource file + * + * This file is part of the GRIEF Editor. + * + * The GRIEF Editor is free software: you can redistribute it + * and/or modify it under the terms of the GRIEF Editor License. + * + * Redistributions of source code must retain the above copyright + * notice, and must be distributed with the license document above. + * + * Redistributions in binary form must reproduce the above copyright + * notice, and must include the license document above in + * the documentation and/or other materials provided with the + * distribution. + * + * The GRIEF Editor is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * License for more details. + * ==end== + */ + +#include "../include/edbuildinfo.h" + +#define RC_PRODUCTVERSION GR_VERSION_1 , GR_VERSION_2 , GR_VERSION_3 , GR_VERSION_4 +#define RC_FILEVERSION GR_VERSION_1 , GR_VERSION_2 , GR_VERSION_3 , GR_VERSION_4 + +#ifndef WINDRES +#include "windows.h" +#include "winver.h" +#endif + +/* + * English (U.S.) resources + */ + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) + +#ifdef _WIN32 +#ifndef WINDRES +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#endif +#pragma code_page(1252) +#endif /* _WIN32 */ + +/* + * Manifest + */ + +#ifndef RT_MANIFEST +#define RT_MANIFEST 24 +#endif +#ifndef CREATEPROCESS_MANIFEST_RESOURCE_ID +#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1 +#endif +CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "../gr/gr.manifest.xml" + +/* + * Updater Meta Data + * nameID typeID { raw data } + */ + +UPDATER HostURL { "\0" } +UPDATER Channel { "release\0" } + + +/* + * Version Information + */ + +VS_VERSION_INFO VERSIONINFO + FILEVERSION RC_FILEVERSION + PRODUCTVERSION RC_PRODUCTVERSION + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS (VS_FF_SPECIALBUILD|VS_FF_DEBUG) +#else + FILEFLAGS (VS_FF_SPECIALBUILD) +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE VFT2_UNKNOWN + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + BEGIN + VALUE "CompanyName", "" + VALUE "FileDescription", "GRIEF Editor, grtags" + VALUE "FileVersion", GR_VERSION ", Build:" GR_BUILD_DATE "-" GR_BUILD_NUMBER + VALUE "InternalName", "grtags" + VALUE "Copyright", + "Copyright (C) 2014 - " GR_BUILD_YEAR ", Adam Young. \n" + "Copyright (c) 1980, 1987, 1991, 1993, The Regents of the University of California. All rights reserved. \n" + "Licensed under the Grief License.\n " + "This is free software; see the source for copying conditions. \n" + "There is NO warranty; not even for MERCHANTABILITY \n" + "or FITNESS FOR A PARTICULAR PURPOSE. \0" + VALUE "Maintainers", "https://github.com/adamyg/grief\n" + VALUE "LegalTrademarks", "see GRIEF License" + VALUE "OriginalFilename", "grtags.exe" + VALUE "ProductName", "GRIEF" + END + END + + /* The following line should only be modified for localized versions. */ + /* It consists of any number of WORD,WORD pairs, with each pair */ + /* describing a language,codepage combination supported by the file. */ + /* */ + /* For example, a file might have values "0x409,1252" indicating that it */ + /* supports English language (0x409) in the Windows ANSI codepage (1252). */ + + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END + END + +#endif /* English (U.S.) resources */ diff --git a/util/grwc.c b/util/grwc.c index 21c183ba..706e566b 100644 --- a/util/grwc.c +++ b/util/grwc.c @@ -37,9 +37,17 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif + +#if defined(linux) +#ifndef _DEFAULT_SOURCE +#define _DEFAULT_SOURCE +#endif +#else #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif +#endif + #include #include #include @@ -273,3 +281,5 @@ print_counts(int64_t lines, int64_t words, int64_t chars, char *name) (void)printf(" %s\n", name); } + +/*end*/ diff --git a/util/grwc.rc b/util/grwc.rc new file mode 100644 index 00000000..4faa3020 --- /dev/null +++ b/util/grwc.rc @@ -0,0 +1,121 @@ +/* -*- mode: c; indent-width: 4; -*- + * + * windows resource file + * + * This file is part of the GRIEF Editor. + * + * The GRIEF Editor is free software: you can redistribute it + * and/or modify it under the terms of the GRIEF Editor License. + * + * Redistributions of source code must retain the above copyright + * notice, and must be distributed with the license document above. + * + * Redistributions in binary form must reproduce the above copyright + * notice, and must include the license document above in + * the documentation and/or other materials provided with the + * distribution. + * + * The GRIEF Editor is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * License for more details. + * ==end== + */ + +#include "../include/edbuildinfo.h" + +#define RC_PRODUCTVERSION GR_VERSION_1 , GR_VERSION_2 , GR_VERSION_3 , GR_VERSION_4 +#define RC_FILEVERSION GR_VERSION_1 , GR_VERSION_2 , GR_VERSION_3 , GR_VERSION_4 + +#ifndef WINDRES +#include "windows.h" +#include "winver.h" +#endif + +/* + * English (U.S.) resources + */ + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) + +#ifdef _WIN32 +#ifndef WINDRES +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#endif +#pragma code_page(1252) +#endif /* _WIN32 */ + +/* + * Manifest + */ + +#ifndef RT_MANIFEST +#define RT_MANIFEST 24 +#endif +#ifndef CREATEPROCESS_MANIFEST_RESOURCE_ID +#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1 +#endif +CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "../gr/gr.manifest.xml" + +/* + * Updater Meta Data + * nameID typeID { raw data } + */ + +UPDATER HostURL { "\0" } +UPDATER Channel { "release\0" } + + +/* + * Version Information + */ + +VS_VERSION_INFO VERSIONINFO + FILEVERSION RC_FILEVERSION + PRODUCTVERSION RC_PRODUCTVERSION + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS (VS_FF_SPECIALBUILD|VS_FF_DEBUG) +#else + FILEFLAGS (VS_FF_SPECIALBUILD) +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE VFT2_UNKNOWN + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + BEGIN + VALUE "CompanyName", "" + VALUE "FileDescription", "GRIEF Editor, grwc" + VALUE "FileVersion", GR_VERSION ", Build:" GR_BUILD_DATE "-" GR_BUILD_NUMBER + VALUE "InternalName", "grwc" + VALUE "Copyright", + "Copyright (C) 2014 - " GR_BUILD_YEAR ", Adam Young. \n" + "Copyright (c) 1980, 1987, 1991, 1993, The Regents of the University of California. All rights reserved. \n" + "Licensed under the Grief License.\n " + "This is free software; see the source for copying conditions. \n" + "There is NO warranty; not even for MERCHANTABILITY \n" + "or FITNESS FOR A PARTICULAR PURPOSE. \0" + VALUE "Maintainers", "https://github.com/adamyg/grief\n" + VALUE "LegalTrademarks", "see GRIEF License" + VALUE "OriginalFilename", "grwc.exe" + VALUE "ProductName", "GRIEF" + END + END + + /* The following line should only be modified for localized versions. */ + /* It consists of any number of WORD,WORD pairs, with each pair */ + /* describing a language,codepage combination supported by the file. */ + /* */ + /* For example, a file might have values "0x409,1252" indicating that it */ + /* supports English language (0x409) in the Windows ANSI codepage (1252). */ + + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END + END + +#endif /* English (U.S.) resources */ diff --git a/util/w32keytest.c b/util/w32keytest.c index 1d801866..8fbb3f2d 100644 --- a/util/w32keytest.c +++ b/util/w32keytest.c @@ -1,13 +1,33 @@ -/* - * win32 console key-test +/* -*- mode: c; indent-width: 4; -*- */ +/* $Id: w32keytest.c,v 1.33 2024/09/20 14:51:42 cvsuser Exp $ + * console key-test -- win32 + * + * + * This file is part of the GRIEF Editor. + * + * The GRIEF Editor is free software: you can redistribute it + * and/or modify it under the terms of the GRIEF Editor License. + * + * The GRIEF Editor is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * License for more details. + * ==end== */ +#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) +#define _CRT_SECURE_NO_WARNINGS +#endif + #include #include + #include +#include + +#include "getopt.h" +#include "conkey.h" -#define ALT_PRESSED (LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED) -#define CTRL_PRESSED (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED) #define APP_PRESSED 0x0200 /* APPS enabled, extension */ #if defined(__WATCOMC__) || defined(__MINGW32__) @@ -16,10 +36,6 @@ #endif #endif -//#if defined(__MINGW32__) /*older mingw*/ -//#define swprintf _swprintf -//#endif - #define CTRLSTATUSMASK (LEFT_ALT_PRESSED|LEFT_CTRL_PRESSED|RIGHT_ALT_PRESSED|RIGHT_CTRL_PRESSED|SHIFT_PRESSED|APP_PRESSED) static const struct w32key { @@ -133,45 +149,169 @@ static const struct w32key { #define ISHEX(_uc) \ ((_uc >= '0' && _uc <= '9') || (_uc >= 'a' && _uc <= 'f') || (_uc >= 'A' && _uc <= 'F') ? 1 : 0) -static void Process(HANDLE in); +static void Usage(); +static void Process(HANDLE in, int rawmode); +static int ReadConsoleInputRaw(HANDLE hConsoleInput, PINPUT_RECORD ir); + static BOOL WINAPI CtrlHandler(DWORD fdwCtrlType); -static int AltPlusEvent(const KEY_EVENT_RECORD *ke, int offset); static int AltPlusEnabled(void); -static const wchar_t *key_description(const KEY_EVENT_RECORD *ker); -static const wchar_t *control_state(DWORD dwControlKeyState); -static const wchar_t *virtual_description(WORD wVirtualKeyCode); +static int AltPlusEvent(const KEY_EVENT_RECORD *ke, int offset); +static DWORD AltGrEvent(const KEY_EVENT_RECORD* key); +static const wchar_t* wkey_description(const KEY_EVENT_RECORD* ker); +static const wchar_t *wcontrol_state(DWORD dwControlKeyState); +static const wchar_t *wvirtual_description(WORD wVirtualKeyCode); + +static int cprinta(const char* fmt, ...); +static int cprintw(const wchar_t* fmt, ...); + +static int xf_verbose = 0; +static int xf_rawmode = -1; static int xf_altcode = -1; /* 1=enable,0=disable,-1=auto */ static int xf_mouse = 1; +static int xf_tracking = 0; +static int xf_paste = 1; +static int x_break = 0; + +static struct option long_options[] = { + {"verbose", no_argument, NULL, 'v'}, + {"rawmode", no_argument, NULL, 'r'}, + {"norawmode", no_argument, NULL, 'R'}, + {"nomouse", no_argument, NULL, 'm'}, + {"nomouse", no_argument, NULL, 'M'}, + {"tracking", no_argument, NULL, 't'}, + {"altcode", no_argument, NULL, 'a'}, + {"noaltcode", no_argument, NULL, 'A'}, + {"help", no_argument, 0, 'h'}, + {0} +}; int -main(void) +main(int argc, char **argv) { HANDLE in = GetStdHandle(STD_INPUT_HANDLE); DWORD mode = 0; + int optidx = 0, c; + int rawmode = 0; + + // arguments + xf_tracking = 1000; + while ((c = getopt_long(argc, (const char * const *)argv, "vrRmMtaAh", long_options, &optidx, -1)) != -1) { + switch (c) { + case 'v': // -v,--verbose + ++xf_verbose; + break; + case 'r': // -r,--rawmode + xf_rawmode = 1; + break; + case 'R': // -R,--norawmode + xf_rawmode = 0; + break; + case 'm': // -m,--mouse + xf_mouse = 1; + break; + case 'M': // -M,--nomouse + xf_mouse = 0; + break; + case 't': // -t,--tracking + // 1000 -> only listen to button press and release + // 1002 -> listen to button press and release + mouse motion only while pressing button + // 1003 -> listen to button press and release + mouse motion at all times + if (1000 == xf_tracking) + xf_tracking = 1002; + else if (1002 == xf_tracking) + xf_tracking = 1003; + break; + case 'a': // -a,--altmode + xf_altcode = 1; + break; + case 'A': // -A,--noaltmode + xf_altcode = 0; + break; + case 'h': // -h,--help + Usage(); + return EXIT_FAILURE; + default: + assert('?' == c || ':' == c); + return EXIT_FAILURE; + } + } + + if (xf_rawmode == -1) { // running under MsTerminal? + xf_rawmode = (getenv("WT_SESSION") != NULL); + } GetConsoleMode(in, &mode); - if (xf_mouse) { /* mouse enabled */ - if (! SetConsoleMode(in, ENABLE_EXTENDED_FLAGS|\ - ENABLE_WINDOW_INPUT|ENABLE_MOUSE_INPUT/*|ENABLE_PROCESSED_INPUT*/)) { - // Note: Stating ENABLE_EXTENDED_FLAGS disables ENABLE_INSERT_MODE and/or ENABLE_QUICK_EDIT_MODE. - // required for correct mouse operation; restored within sys_shutdown(). - SetConsoleMode(in, ENABLE_WINDOW_INPUT|ENABLE_MOUSE_INPUT/*|ENABLE_PROCESSED_INPUT*/); - // No extended support/XP. + if (xf_rawmode) { +#if !defined(ENABLE_VIRTUAL_TERMINAL_PROCESSING) +#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004 +#endif +#if !defined(ENABLE_VIRTUAL_TERMINAL_INPUT) +#define ENABLE_VIRTUAL_TERMINAL_INPUT 0x0200 +#endif + DWORD nmode; + + nmode = mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING; + if ((ENABLE_VIRTUAL_TERMINAL_PROCESSING & mode) || + SetConsoleMode(in, mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING)) { + + SetConsoleMode(in, (nmode & ~ENABLE_LINE_INPUT) | ENABLE_VIRTUAL_TERMINAL_INPUT); + cprinta("\x1b[4:3mVT Processing enabled:\x1b[0m\n"); + cprinta("\x1b[?9001h"); // enable win32-input-mode. + + if (xf_mouse) { + cprinta("\x1b[?%uh", xf_tracking); // enable X11 mouse mode. + cprinta("\x1b[?1006h"); // enable SGR extended mouse mode. + } + + if (xf_paste) { + cprinta("\x1B[?2004s"); // save bracketed paste. + cprinta("\x1B[?2004h"); // enable bracketed paste. + } + rawmode = 1; + + } else { + cprinta("error: Could not enable VT Processing - please update to a recent Windows 10 build\n"); + return 3; } + } else { - SetConsoleMode(in, ENABLE_WINDOW_INPUT/*|ENABLE_PROCESSED_INPUT*/); + if (xf_mouse) { // mouse enabled. + if (!SetConsoleMode(in, ENABLE_EXTENDED_FLAGS | \ + ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT/*|ENABLE_PROCESSED_INPUT*/)) { + // Note: Stating ENABLE_EXTENDED_FLAGS disables ENABLE_INSERT_MODE and/or ENABLE_QUICK_EDIT_MODE. + // required for correct mouse operation; restored within sys_shutdown(). + SetConsoleMode(in, ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT /*|ENABLE_PROCESSED_INPUT*/); + // No extended support/XP. + } + } else { + SetConsoleMode(in, ENABLE_WINDOW_INPUT /*|ENABLE_PROCESSED_INPUT*/); + } } // The ENABLE_LINE_INPUT and ENABLE_ECHO_INPUT modes only affect processes that use ReadFile or ReadConsole - // to read from the console's input buffer. Similarly, the ENABLE_PROCESSED_INPUT mode primarily affects - // ReadFile and ReadConsole users, except that it also determines whether CTRL+C input is reported in the + // to read from the console's input buffer. Similarly, the ENABLE_PROCESSED_INPUT mode primarily affects + // ReadFile and readReadConsole users, except that it also determines whether CTRL+C input is reported in the // input buffer (to be read by the ReadConsoleInput function) or is passed to a function defined by // the application. SetConsoleCtrlHandler(CtrlHandler, TRUE); - Process(in); + Process(in, rawmode); + + if (rawmode) { + if (xf_paste) { + cprinta("\x1B[?2004l"); // disable bracketed paste. + cprinta("\x1B[?2004r"); // restore bracketed paste. + } + + if (xf_mouse) { + cprinta("\x1b[?1006l"); // disable extended mouse mode. + cprinta("\x1b[?%ul", xf_tracking); // disable mouse tracking. + } + + cprinta("\x1b[?9001l"); // disable win32-input-mode. + } SetConsoleMode(in, mode); return 0; @@ -179,37 +319,82 @@ main(void) static void -Process(HANDLE in) +Usage() +{ + static const char usage[] = { + "\n" \ + "Options:\n" \ + " -v,--verbose increased disgnostics.\n" \ + "\n" \ + " -r,--rawmode enable win32-input-mode; default auto\n" \ + " -R,--norawmode disable win32-input-mode.\n" \ + "\n" \ + " -m,--mouse enable mouse events\n" \ + " -M,--nomouse disable mouse events.\n" \ + " -t,--tracking extended mouse tracking.\n" \ + "\n" \ + " -a,--altmode enable Alt + Numpad mode.\n" \ + " -A,--noaltmode disable alt-numpad mode.\n" \ + "\n" \ + " -h,--help command line usage.\n" \ + "\n" + }; + + printf("w32keytest [options]\n%s", usage); +} + + +static void +Process(HANDLE in, int rawmode) { int alt_state = 0, esc_state = 0, event_count = 0; DWORD apps_control = 0; int offset = 0; -#define COLUMN1 100 +#define COLUMN1 100 - printf("\nConsole input test, ESC+ESC to quit."); + cprinta("\nConsole input test, ESC+ESC to quit."); if (xf_altcode < 0) { - if (0 == xf_altcode || - (xf_altcode < 0 && ! AltPlusEnabled())) { - wprintf(L"\nAlt-Plus-KeyCode not enabled"); + if (0 == xf_altcode ||(xf_altcode < 0 && ! AltPlusEnabled())) { + cprintw(L"\nAlt-Plus-KeyCode not enabled"); xf_altcode = 0; } else { - wprintf(L"\nAlt-Plus-KeyCode enabled"); + cprintw(L"\nAlt-Plus-KeyCode enabled"); xf_altcode = 1; } } - printf("\n\n# UC Chr Dir Rpt VK SC State\n"); - fflush(stdout); + cprinta("\n\n# UC Chr Dir Rpt VK SC State\n"); // nnnn U+uuuu c 1111 111 111111111111 1111 1111 xxxxxxxxxxxxxxx for (;;) { INPUT_RECORD ir[1] = {0}; DWORD i, cEventsRead = 0; - if (! ReadConsoleInputW(in, ir, 1, &cEventsRead)) { - puts("ReadConsoleInput failed!"); - return; + if (rawmode) { + for (;;) { + const int ret = ReadConsoleInputRaw(in, ir); + if (x_break >= 3) { + cprinta("\nbye..."); + return; + } + if (ret == 1) { + cEventsRead = 1; + break; + } else if (ret == -1) { + cprinta("ReadConsoleInput failed!"); + return; + } + } + } else { + if (! ReadConsoleInputW(in, ir, 1, &cEventsRead)) { + cprinta("ReadConsoleInput failed!"); + return; + } + if (x_break >= 3) { + cprinta("\nbye..."); + return; + } } for (i = 0; i < cEventsRead; ++i, ++event_count) { @@ -231,13 +416,13 @@ Process(HANDLE in) // Key details - wprintf(L"\n"); - offset = wprintf(L"%4d: U+%04x %c %s %03u %04x %-12s %04x %08x %s = %d", + cprintw(L"\n"); + offset = cprintw(L"%4d: U+%04x %c %s %03u %04x %-12s %04x %08x %s = %d", event_count, (WORD) ker->uChar.UnicodeChar, (ker->uChar.UnicodeChar > 32 ? ker->uChar.UnicodeChar : ' '), - (ker->bKeyDown ? L"down" : L" up "), ker->wRepeatCount, - ker->wVirtualKeyCode, virtual_description(ker->wVirtualKeyCode), ker->wVirtualScanCode, - ker->dwControlKeyState, control_state(ker->dwControlKeyState|apps_control), + (ker->bKeyDown ? L"down" : L" up "), ker->wRepeatCount, + ker->wVirtualKeyCode, wvirtual_description(ker->wVirtualKeyCode), ker->wVirtualScanCode, + ker->dwControlKeyState, wcontrol_state(ker->dwControlKeyState|apps_control), alt_state); if (ker->bKeyDown) { @@ -245,9 +430,10 @@ Process(HANDLE in) KEY_EVENT_RECORD t_ker = *ker; const wchar_t *kd; + t_ker.dwControlKeyState = AltGrEvent(&t_ker); t_ker.dwControlKeyState |= apps_control; - if (NULL != (kd = key_description(&t_ker))) { - wprintf(L"%*s<%s>", COLUMN1 - offset, L"", kd); + if (NULL != (kd = wkey_description(&t_ker))) { + cprintw(L"%*s<%s>", COLUMN1 - offset, L"", kd); offset = COLUMN1; } } @@ -255,16 +441,246 @@ Process(HANDLE in) if (0 == (CTRLSTATUSMASK & ker->dwControlKeyState) && 0x1b == ker->uChar.UnicodeChar) { if (++esc_state >= 2) { // Escape - puts("\nbye..."); + cprinta("\nbye..."); return; } } else { esc_state = 0; } } + + } else if (ir[i].EventType & MOUSE_EVENT) { + const MOUSE_EVENT_RECORD* me = &ir[i].Event.MouseEvent; + + cprinta("\n"); + offset = cprinta("%4d: %03u %04u %03u %s", + event_count, (unsigned)me->dwEventFlags, + (unsigned)LOWORD(me->dwButtonState), (unsigned)me->dwControlKeyState, + mouse_description(me)); + } + } + } +} + + +static int +ReadConsoleInputRaw(HANDLE hConsoleInput, PINPUT_RECORD ir) +{ + static BYTE cached[128] = {0}; + static unsigned cache_length = 0; + + BYTE buffer[128]; + DWORD timeout = INFINITE; + unsigned length = 0; + WCHAR ch = 0; + + for (;;) { + for (;;) { + DWORD dwRead = 0; + + memset(ir, 0, sizeof(*ir)); + if (WaitForSingleObject(hConsoleInput, timeout) != WAIT_OBJECT_0 || + ! ReadConsoleInputA(hConsoleInput, ir, 1, &dwRead) || 1 != dwRead) { + cprinta("\nerror: i/o error (timeout=%u, error=%u, read=%u)\n", + timeout, GetLastError(), dwRead); + break; + } + + if (ir->EventType == KEY_EVENT) { + KEY_EVENT_RECORD *ker = &ir->Event.KeyEvent; + + if (xf_verbose >= 2) { + cprintw(L" RAW %4d: U+%04x %c %s %03u %04x %04x %08x\n", + length, (WORD) ker->uChar.UnicodeChar, + (ker->uChar.UnicodeChar > 32 ? ker->uChar.UnicodeChar : ' '), + (ker->bKeyDown ? L"down" : L" up "), + ker->wRepeatCount, ker->wVirtualKeyCode, ker->wVirtualScanCode, ker->dwControlKeyState); + } + + if (ker->bKeyDown) { // down event + ch = ker->uChar.UnicodeChar; + break; + } else { + if (1 == length) { // true ESC, return + if (ker->uChar.UnicodeChar == 0x1b) { + ker->bKeyDown = 1; + return TRUE; + } + } + } + } + } + + if (0 == length) { // first character + if (ch == '\x1b') { + buffer[length++] = 0x1b; + timeout = 500; + continue; + } + return TRUE; + } + + if (ch < ' ' || ch > 0xff) { + cprinta("\nerror: unexpected character 0X%x/'%c'\n", ch, isprint(ch) ? ch : ' '); + break; + } + + if (1 == length) { // second character + if (ch == '[') { + buffer[length++] = (char)ch; + timeout = 100; + continue; + } + cprinta("\nerror: expected character 0X%x/'%c'\n", ch, isprint(ch) ? ch : ' '); + break; + } + + if (length == (_countof(buffer) - 1)) { + cprinta("\nerror: buffer overflow <%.*s>.\n", length, buffer); + break; + } + + buffer[length++] = (char)ch; + if (ch != '_') { + continue; + } + buffer[length] = 0; + + // https://github.com/microsoft/terminal/blob/main/doc/specs/%234999%20-%20Improved%20keyboard%20handling%20in%20Conpty.md + // + // ^ [[ Vk; Sc; Uc; Kd; Cs; Rc _ + // + // Vk : the value of wVirtualKeyCode - any number. If omitted, defaults to '0'. + // Sc : the value of wVirtualScanCode - any number. If omitted, defaults to '0'. + // Uc : the decimal value of UnicodeChar - for example, NUL is "0", LF is + // "10", the character 'A' is "65". If omitted, defaults to '0'. + // Kd : the value of bKeyDown - either a '0' or '1'. If omitted, defaults to '0'. + // Cs : the value of dwControlKeyState - any number. If omitted, defaults to '0'. + // Rc : the value of wRepeatCount - any number. If omitted, defaults to '1'. + // + { + unsigned arguments[6] = { 0, 0, 0, 0, 0, 1 }; + + if (NULL == DecodeKeyArguments(arguments, _countof(arguments), '_', buffer + 2, buffer + length)) { + const BYTE *cursor, *end; + + cprinta("\nerror: buffer format, length=%u [", length); + for (cursor = buffer, end = cursor + length; cursor != end; ++cursor) { + cprinta("0x%x/%c", *cursor, isprint(*cursor) ? *cursor: ' '); + } + cprinta("] ==> %u;%u;%u;%u;%lu;%u_\n", arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]); + break; + } + + if (0 == arguments[0] && 0 == arguments[1] && arguments[2] == 0x1b) { + if (arguments[3]) { + // ESC (special VK=SC=0) + down + cache_length = 0; + cached[cache_length++] = 0x1b; + if (xf_verbose) { + cprinta("\nESC: [%s] ==> %u;%u;%u;%u;%lu;%u_", + buffer + 2, arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]); + cprinta(": %u, <\\x1b%.*s>", cache_length, cache_length - 1, cached + 1); + } + return FALSE; + } } + + if (cache_length) { + if (arguments[2] && arguments[3]) { + // unicode + down + cached[cache_length++] = (BYTE)arguments[2]; + if (xf_verbose) { + cprinta("\nADD: [%s] ==> %u;%u;%u;%u;%lu;%u_", + buffer + 2, arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]); + cprinta(": %u, <\\x1b%.*s>", cache_length, cache_length - 1, cached + 1); + } + } + + if (cache_length >= 6) { + if (cached[1] == '[' && cached[2] == 'M') { + // + // \x1B[Mabc", where: + // a: Button number plus 32. + // b: Column number (one-based) plus 32. + // c: Row number (one-based) plus 32. + // + const void* end = cached + cache_length; + + cache_length = 0; + return (DecodeXTermMouse(ir, cached, end) != NULL); + + } else if (cached[1] == '[' && cached[2] == '<') { + // + // \x1B[, ESC[201~ + // + cache_length = 0; + + } else if (0 == memcmp(cached, "\x1b[201~", 6)) { + cache_length = 0; + + } else { + const BYTE *cursor, *end; + + cprinta("\nerror: unexpected escape, length=%u [", cache_length); + for (cursor = cached, end = cursor + cache_length; cursor != end; ++cursor) { + cprinta("0x%x/%c", *cursor, isprint(*cursor) ? *cursor : ' '); + } + cprinta("]\n"); + return FALSE; + } + } + + if (0 == arguments[2] || 0 == arguments[3]) + goto ignored; // non-unicode or up + return FALSE; + } + + if (xf_verbose) { + cprinta("\nKEY: [%s] ==> %u;%u;%u;%u;%lu;%u_", + buffer + 2, arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]); + } + + { + KEY_EVENT_RECORD* ke = &ir->Event.KeyEvent; + ke->wVirtualKeyCode = (WORD)arguments[0]; + ke->wVirtualScanCode = (WORD)arguments[1]; + ke->uChar.UnicodeChar = (WCHAR)arguments[2]; + ke->bKeyDown = (arguments[3] ? TRUE : FALSE); + ke->dwControlKeyState = (DWORD)arguments[4]; + ke->wRepeatCount = (WORD)arguments[5]; + ir->EventType = KEY_EVENT; + } + return TRUE; + + ignored:; + if (xf_verbose) { + cprinta("\nNUL: [%s] ==> %u;%u;%u;%u;%lu;%u_", + buffer + 2, arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]); + } + return FALSE; } } + return -1; } @@ -273,21 +689,22 @@ CtrlHandler(DWORD fdwCtrlType) { switch (fdwCtrlType) { case CTRL_C_EVENT: // Ctrl-C signal. - printf("\nCtrl-C event\n"); + cprinta("\nCtrl-C event\n"); return TRUE; case CTRL_BREAK_EVENT: // Ctrl-Break signal. - printf("\nCtrl-Break event\n"); + cprinta("\nCtrl-Break event\n"); + ++x_break; return TRUE; case CTRL_CLOSE_EVENT: // Ctrl-Close: confirm that the user wants to exit. - printf("\nCtrl-Close event\n"); + cprinta("\nCtrl-Close event\n"); Beep(600, 200); return TRUE; case CTRL_LOGOFF_EVENT: - printf("\nCtrl-Logoff event\n"); + cprinta("\nCtrl-Logoff event\n"); Beep(1000, 200); return FALSE; case CTRL_SHUTDOWN_EVENT: - printf("\nCtrl-Shutdown event\n"); + cprinta("\nCtrl-Shutdown event\n"); Beep(750, 500); return FALSE; default: @@ -311,69 +728,136 @@ CtrlHandler(DWORD fdwCtrlType) // given, the key-code is invalidated and UnicodeChar=0 is returned on the ALT release. // // Notes: -// o Requires the registry REG_SZ value "EnableHexNumpad" under -// "HKEY_Current_User/Control Panel/Input Method" to be "1". +// o To enable requires the registry REG_SZ value "EnableHexNumpad" under +// "HKEY_Current_User/Control Panel/Input Method" to be "1". // -// o Hex-value overflow goes unreported, limiting input to a 16-bit result. +// o Hex-value overflow goes unreported, limiting input to a 16-bit unicode result. // + +#pragma comment(lib, "Imm32.lib") + static int -AltPlusEvent(const KEY_EVENT_RECORD *ke, int offset) +AltPlusEnabled(void) +{ + static int state = -1; + + if (-1 == state) { + HKEY hKey = 0; + + state = 0; + if (RegOpenKeyExA(HKEY_CURRENT_USER, + "Control Panel\\Input Method", 0, KEY_READ, &hKey) == ERROR_SUCCESS) { + char szEnableHexNumpad[100] = { 0 }; + DWORD dwSize = _countof(szEnableHexNumpad); + if (RegQueryValueExA(hKey, "EnableHexNumpad", NULL, NULL, (LPBYTE)szEnableHexNumpad, &dwSize) == ERROR_SUCCESS) { + if (szEnableHexNumpad[0] == '1' && szEnableHexNumpad[1] == 0) { + state = 1; + } + } + RegCloseKey(hKey); + } + } + return state; +} + + +static int +AltPlusEvent(const KEY_EVENT_RECORD* ke, /*struct IOEvent* evt*/ int offset) { #define ISXDIGIT(_uc) \ ((_uc >= '0' && _uc <= '9') || (_uc >= 'a' && _uc <= 'f') || (_uc >= 'A' && _uc <= 'F') ? 1 : 0) - static int alt_code = 0; + static unsigned alt_code = 0; // >0=active static DWORD alt_control = 0; - wchar_t completion[64]; - if (! xf_altcode) return -1; // enabled? + const unsigned wVirtualKeyCode = ke->wVirtualKeyCode, + dwControlKeyState = (CTRLSTATUSMASK & ke->dwControlKeyState), + dwEnhanced = (ENHANCED_KEY & ke->dwControlKeyState); + wchar_t completion[64] = { 0 }; completion[0] = 0; + + if (xf_verbose >= 2) { + cprinta(" Key: %s-%s%s%s%s%s%sVK=0x%02x/%u, UC=0x%04x/%u/%c, SC=0x%x/%u\n", + (ke->bKeyDown ? "DN" : "UP"), + (dwEnhanced ? "Enh-" : ""), + (dwControlKeyState & LEFT_ALT_PRESSED) ? "LAlt-" : "", + (dwControlKeyState & RIGHT_ALT_PRESSED) ? "RAlt-" : "", + (dwControlKeyState & LEFT_CTRL_PRESSED) ? "LCtrl-" : "", + (dwControlKeyState & RIGHT_CTRL_PRESSED) ? "RCtrl-" : "", + (dwControlKeyState & SHIFT_PRESSED) ? "Shift-" : "", + wVirtualKeyCode, wVirtualKeyCode, + ke->uChar.UnicodeChar, ke->uChar.UnicodeChar, + (ke->uChar.UnicodeChar && ke->uChar.UnicodeChar < 255 ? ke->uChar.UnicodeChar : ' '), + ke->wVirtualScanCode, ke->wVirtualScanCode); + } + if (ke->bKeyDown) { // down event - const unsigned controlKeyState = (CTRLSTATUSMASK & ke->dwControlKeyState); - if (VK_ADD == ke->wVirtualKeyCode && - (LEFT_ALT_PRESSED == controlKeyState || RIGHT_ALT_PRESSED == controlKeyState)) { - // "Alt + ..." event - alt_control = controlKeyState; - if (alt_code == 0) { + if ((wVirtualKeyCode >= VK_NUMPAD0 && wVirtualKeyCode <= VK_NUMPAD9) && + 0 == dwEnhanced && (LEFT_ALT_PRESSED == dwControlKeyState || RIGHT_ALT_PRESSED == dwControlKeyState)) { + // "Alt NumPad ..." event + // Note: + // o NumLock is required to be enabled for NUMPAD key reporting. + // o Non-enhanced, NumPad verses 101 cursor-keys; same VK codes. + if (0 == alt_code) { + alt_control = dwControlKeyState; alt_code = 1; } return 1; // consume + } + + if (VK_ADD == wVirtualKeyCode && + (LEFT_ALT_PRESSED == dwControlKeyState || RIGHT_ALT_PRESSED == dwControlKeyState)) { + // "Alt + Hex" event + if (0 == AltPlusEnabled()) + return -1; // enabled? + if (0 == alt_code) { + alt_control = dwControlKeyState; + alt_code = 0x101; + } + return 1; // consume + } - } else if (alt_code) { - if (alt_control != controlKeyState || + if (alt_code) { + if (alt_control != dwControlKeyState || (ke->uChar.UnicodeChar && 0 == ISXDIGIT(ke->uChar.UnicodeChar))) { // new control status or non-hex, emit "Alt-Plus" and reset state - swprintf(completion, _countof(completion), L"Alt-Plus"); + // TODO/XXX - or should these consumed + swprintf(completion, _countof(completion), L"Alt-Plus (error)"); alt_code = 0; } else { ++alt_code; // associated key count - return alt_code; // consume + return 1; // consume } } } else if (alt_code) { // up event - if (VK_MENU == ke->wVirtualKeyCode && + if (VK_MENU == wVirtualKeyCode && (0 == (ke->dwControlKeyState & ALT_PRESSED))) { // Alt completion - const int oalt_code = alt_code; + const WCHAR UnicodeChar = ke->uChar.UnicodeChar; + const int alt_old = alt_code; alt_code = 0; - if (1 == oalt_code && 0 == ke->uChar.UnicodeChar) { - // "Alt-Plus" only, emit + if (1 == (alt_old & 0xff) && 0 == UnicodeChar) { + // Alt only, emit. swprintf(completion, _countof(completion), L"Alt-Plus"); - } else if (ke->uChar.UnicodeChar) { - // "Alt-Plus keycode", return keycode. - swprintf(completion, _countof(completion), L"Alt-Plus-#%d", ke->uChar.UnicodeChar); + } else if (UnicodeChar) { + // Alt keycode, return keycode. + if (alt_old & 0x100) { + swprintf(completion, _countof(completion), L"Alt-Plus-#0x%x", UnicodeChar); + } else { + swprintf(completion, _countof(completion), L"Alt-#%d", UnicodeChar); + } } } } if (completion[0]) { // completion - wprintf(L"%*s<%s>", COLUMN1 - offset, L"", completion); + cprintw(L"%*s<%s>", COLUMN1 - offset, L"", completion); return 0; } @@ -381,29 +865,59 @@ AltPlusEvent(const KEY_EVENT_RECORD *ke, int offset) } -static int -AltPlusEnabled(void) +/* Function: AltGrEvent + * Filter AtrGr events from modifiers; attempt to allow: + * + * Left-Alt + AltGr, + * Right-Ctrl + AltGr, + * Left-Alt + Right-Ctrl + AltGr. + */ +static DWORD +AltGrEvent(const KEY_EVENT_RECORD* key) { - HKEY hKey = 0; - int enabled = 0; - - if (RegOpenKeyExA(HKEY_CURRENT_USER, - "Control Panel\\Input Method", 0, KEY_READ, &hKey) == ERROR_SUCCESS) { - char szEnableHexNumpad[100] = { 0 }; - DWORD dwSize = _countof(szEnableHexNumpad); - if (RegQueryValueExA(hKey, "EnableHexNumpad", NULL, NULL, (LPBYTE) szEnableHexNumpad, &dwSize) == ERROR_SUCCESS) { - if (szEnableHexNumpad[0] == '1') { - enabled = 1; - } + DWORD state = key->dwControlKeyState; + + // AltGr condition (LCtrl + RAlt) + if (0 == (state & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED))) + return state; + + if (0 == (state & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED))) + return state; + + if (0 == key->uChar.UnicodeChar) + return state; + + if (state & RIGHT_ALT_PRESSED) { + // Remove Right-Alt. + state &= ~RIGHT_ALT_PRESSED; + + // As a character was presented, Left-Ctrl is almost always set, + // except if the user presses Right-Ctrl, then AltGr (in that specific order) for whatever reason. + // At any rate, make sure the bit is not set. + state &= ~LEFT_CTRL_PRESSED; + + } else if (state & LEFT_ALT_PRESSED) { + // Remove Left-Alt. + state &= ~LEFT_ALT_PRESSED; + + // Whichever Ctrl key is down, remove it from the state. + // We only remove one key, to improve our chances of detecting the corner-case of Left-Ctrl + Left-Alt + Right-Ctrl. + if ((state & LEFT_CTRL_PRESSED) != 0) { + // Remove Left-Ctrl. + state &= ~LEFT_CTRL_PRESSED; + + } else if ((state & RIGHT_CTRL_PRESSED) != 0) { + // Remove Right-Ctrl. + state &= ~RIGHT_CTRL_PRESSED; } - RegCloseKey(hKey); } - return enabled; + return state; } + static const wchar_t * -key_description(const KEY_EVENT_RECORD *ker) +wkey_description(const KEY_EVENT_RECORD *ker) { static wchar_t t_buffer[200]; wchar_t *cursor = t_buffer, *end = cursor + _countof(t_buffer); @@ -447,12 +961,12 @@ key_description(const KEY_EVENT_RECORD *ker) } // Control states + if (dwControlKeyState & APP_PRESSED) // special + cursor += swprintf(cursor, end - cursor, L"App-"); + if (dwControlKeyState & ALT_PRESSED) cursor += swprintf(cursor, end - cursor, L"Alt-"); - if (dwControlKeyState & APP_PRESSED) - cursor += swprintf(cursor, end - cursor, L"App-"); - if (dwControlKeyState & CTRL_PRESSED) cursor += swprintf(cursor, end - cursor, L"Ctrl-"); @@ -505,7 +1019,7 @@ key_description(const KEY_EVENT_RECORD *ker) static const wchar_t * -control_state(DWORD dwControlKeyState) +wcontrol_state(DWORD dwControlKeyState) { static wchar_t t_buffer[200]; wchar_t *cursor = t_buffer; @@ -528,9 +1042,9 @@ control_state(DWORD dwControlKeyState) static const wchar_t * -virtual_description(WORD wVirtualKeyCode) +wvirtual_description(WORD wVirtualKeyCode) { - switch(wVirtualKeyCode) { + switch (wVirtualKeyCode) { case VK_LBUTTON : /*0x01*/ return L"LBUTTON"; case VK_RBUTTON : /*0x02*/ return L"RBUTTON"; case VK_CANCEL : /*0x03*/ return L"CANCEL"; @@ -552,12 +1066,12 @@ virtual_description(WORD wVirtualKeyCode) case VK_CAPITAL : /*0x14*/ return L"CAPITAL"; case VK_KANA : /*0x15*/ return L"KANA"; -// case VK_HANGEUL : /*0x15*/ return L"HANGEUL"; -// case VK_HANGUL : /*0x15*/ return L"HANGUL"; + //case VK_HANGEUL : /*0x15*/ return L"HANGEUL"; + //case VK_HANGUL : /*0x15*/ return L"HANGUL"; case VK_JUNJA : /*0x17*/ return L"JUNJA"; case VK_FINAL : /*0x18*/ return L"FINAL"; case VK_HANJA : /*0x19*/ return L"HANJA"; -// case VK_KANJI : /*0x19*/ return L"KANJI"; + //case VK_KANJI : /*0x19*/ return L"KANJI"; case VK_ESCAPE : /*0x1B*/ return L"ESCAPE"; @@ -638,7 +1152,7 @@ virtual_description(WORD wVirtualKeyCode) #endif #if defined(VK_OEM_FJ_MASSHOU) -// case VK_OEM_FJ_JISHO : /*0x92*/ return L"OEM_FJ_JISHO"; + //case VK_OEM_FJ_JISHO : /*0x92*/ return L"OEM_FJ_JISHO"; case VK_OEM_FJ_MASSHOU : /*0x93*/ return L"OEM_FJ_MASSHOU"; case VK_OEM_FJ_TOUROKU : /*0x94*/ return L"OEM_FJ_TOUROKU"; case VK_OEM_FJ_LOYA : /*0x95*/ return L"OEM_FJ_LOYA"; @@ -720,7 +1234,7 @@ virtual_description(WORD wVirtualKeyCode) case VK_OEM_ENLW : /*0xF4*/ return L"OEM_ENLW"; case VK_OEM_BACKTAB : /*0xF5*/ return L"OEM_BACKTAB"; #endif - + case VK_ATTN : /*0xF6*/ return L"ATTN"; case VK_CRSEL : /*0xF7*/ return L"CRSEL"; case VK_EXSEL : /*0xF8*/ return L"EXSEL"; @@ -737,6 +1251,66 @@ virtual_description(WORD wVirtualKeyCode) } +/* + * Console formatted output + */ +static int +cprinta(const char* fmt, ...) +{ + HANDLE cout = GetStdHandle(STD_OUTPUT_HANDLE); + char* cursor, * nl; + char buffer[512]; + int total, len; + va_list ap; + + va_start(ap, fmt); + total = len = vsnprintf(buffer, _countof(buffer), fmt, ap); + buffer[_countof(buffer) - 1] = 0; + va_end(ap); + + cursor = buffer; + while ((nl = strchr(cursor, '\n')) != NULL) { + const int part = (nl - cursor) + 1; + WriteConsoleA(cout, cursor, part - 1, NULL, NULL); + WriteConsoleA(cout, "\n\r", 2, NULL, NULL); + cursor += part; + len -= part; + } + WriteConsoleA(cout, cursor, len, NULL, NULL); + + return total; +} + + +static int +cprintw(const wchar_t* fmt, ...) +{ + HANDLE cout = GetStdHandle(STD_OUTPUT_HANDLE); + wchar_t* cursor, * nl; + wchar_t buffer[512]; + int total, len; + va_list ap; + + va_start(ap, fmt); + total = len = vswprintf(buffer, _countof(buffer)-1, fmt, ap); + buffer[_countof(buffer) - 1] = 0; + va_end(ap); + + cursor = buffer; + while ((nl = wcschr(cursor, '\n')) != NULL) { + const int part = (nl - cursor) + 1; + WriteConsoleW(cout, cursor, part - 1, NULL, NULL); + WriteConsoleA(cout, "\n\r", 2, NULL, NULL); + cursor += part; + len -= part; + } + WriteConsoleW(cout, cursor, len, NULL, NULL); + + return total; +} + + + #if (0) #pragma comment(lib, "Imm32.lib") static int @@ -755,5 +1329,8 @@ ImmTest(void) ImmReleaseContext(hWnd, imc); Sleep(100); } + #endif +/*end*/ +