Compare commits
7 Commits
Author | SHA1 | Date |
---|---|---|
Markus Gans | 54e4dec4a2 | |
Markus Gans | c52b22b4a1 | |
Markus Gans | 09d494cb65 | |
Markus Gans | 5149301d29 | |
Markus Gans | 8784a4c925 | |
Markus Gans | cd5f7ae16e | |
Markus Gans | 9b6f0d5951 |
|
@ -1,38 +0,0 @@
|
|||
---
|
||||
name: Bug report
|
||||
about: Create a bug report
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
## Describe the bug
|
||||
|
||||
Give a detailed description of what the bug is.
|
||||
|
||||
|
||||
## How to reproduce the bug?
|
||||
|
||||
Explain step-by-step the procedure to reproduce this behavior.
|
||||
|
||||
|
||||
## What behavior did you expect?
|
||||
|
||||
Describe what you would expect instead.
|
||||
|
||||
|
||||
## In which environment did the bug occur?
|
||||
* Which operating system do you use?<br />
|
||||
Linux, FreeBSD, NetBSD, OpenBSD, macOS, Cygwin, or Solaris
|
||||
|
||||
* Which distribution do you use?
|
||||
|
||||
* On which CPU architecture did you test?
|
||||
|
||||
* Which compiler in which version did you use?
|
||||
|
||||
* Which terminal do you use?
|
||||
|
||||
* What does the environment variable $TERM contain?
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
---
|
||||
name: Feature request
|
||||
about: Make a suggestion for this project
|
||||
title: ''
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
## Feature Request
|
||||
|
||||
|
||||
**Do you want to solve a problem with your feature request? Please describe it.**
|
||||
|
||||
Describe clearly and precisely what the problem is.
|
||||
Example: I have an issue when [...]
|
||||
|
||||
|
||||
**Your desired solution**
|
||||
|
||||
Describe clearly and concisely what you want to reach.
|
||||
|
||||
|
||||
**Alternatives you have considered**
|
||||
|
||||
Describe clearly and concisely the other solutions you considered.
|
||||
|
||||
|
||||
**Additional context**
|
||||
|
||||
Add additional context or screenshots to your feature request here.
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
name: "ARM build"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, actions-test ]
|
||||
pull_request:
|
||||
branches: [ main, actions-test ]
|
||||
schedule:
|
||||
- cron: '0 7 * * 2'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
name: Build on ${{ matrix.arch }}
|
||||
|
||||
# Run steps on a matrix of 3 arch/distro combinations
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- arch: aarch64
|
||||
- arch: armv7
|
||||
|
||||
steps:
|
||||
- name: Repository checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Before_install
|
||||
run: |
|
||||
lsb_release -a
|
||||
uname -a
|
||||
whoami
|
||||
tty || echo
|
||||
pwd
|
||||
|
||||
- name: Install dependencies via apt-get
|
||||
run: |
|
||||
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
|
||||
sudo apt-get update
|
||||
sudo apt-get -y install \
|
||||
ca-certificates \
|
||||
gcc \
|
||||
g++ \
|
||||
gpm \
|
||||
libgpm-dev \
|
||||
libcppunit-dev \
|
||||
autoconf-archive
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
autoreconf -v --install --force
|
||||
./configure --prefix=/usr
|
||||
make -j10
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
name: "CodeQL analysis"
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
name: "Code coverage"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, actions-test ]
|
||||
pull_request:
|
||||
branches: [ main, actions-test ]
|
||||
schedule:
|
||||
- cron: '0 7 * * 2'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
env:
|
||||
COVERALLS_REPO_TOKEN: "${{ secrets.COVERALLS_REPO_TOKEN }}"
|
||||
|
||||
steps:
|
||||
- name: Repository checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Before_install
|
||||
run: |
|
||||
lsb_release -a
|
||||
uname -a
|
||||
whoami
|
||||
tty || echo
|
||||
pwd
|
||||
|
||||
- name: Install dependencies via apt-get
|
||||
run: |
|
||||
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
|
||||
sudo apt-get update
|
||||
sudo apt-get -y install \
|
||||
ca-certificates \
|
||||
gcc \
|
||||
g++ \
|
||||
gpm \
|
||||
libgpm-dev \
|
||||
libcppunit-dev \
|
||||
autoconf-archive
|
||||
|
||||
- name: Download coderalls
|
||||
run: pip install --user cpp-coveralls
|
||||
|
||||
- name: Download codecov
|
||||
run: sudo pip install codecov
|
||||
|
||||
- name: Build with with gcov
|
||||
run: script -e -c "./build.sh coverage"
|
||||
|
||||
- name: Coveralls
|
||||
run: coveralls --gcov-options '\-lp' -e debian -e doc -e icon -e logo -e m4 -e scripts -e examples
|
||||
|
||||
- name: Codecov
|
||||
run: bash <(curl -s https://codecov.io/bash)
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
name: "Coverity Scan"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, actions-test ]
|
||||
pull_request:
|
||||
branches: [ main, actions-test ]
|
||||
schedule:
|
||||
- cron: '0 7 * * 2'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
# Ubuntu 16.04 LTS will be removed on September 20, 2021
|
||||
runs-on: ubuntu-16.04
|
||||
#runs-on: ubuntu-18.04
|
||||
|
||||
env:
|
||||
COVERITY_SCAN_BRANCH_PATTERN: "${{ github.ref}}"
|
||||
COVERITY_SCAN_NOTIFICATION_EMAIL: "guru.mail@muenster.de"
|
||||
COVERITY_SCAN_PROJECT_NAME: "${{ github.repository }}"
|
||||
# Set in repo settings -> secrets -> repository secrets
|
||||
COVERITY_SCAN_TOKEN: "${{ secrets.COVERITY_SCAN_TOKEN }}"
|
||||
CURRENT_REF: "${{ github.ref }}"
|
||||
|
||||
steps:
|
||||
- name: Repository checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Before_install
|
||||
run: |
|
||||
lsb_release -a
|
||||
uname -a
|
||||
whoami
|
||||
tty || echo
|
||||
pwd
|
||||
|
||||
- name: Download coverity scan build tool
|
||||
run: |
|
||||
wget -q https://scan.coverity.com/download/cxx/linux64 \
|
||||
--post-data "token=$COVERITY_SCAN_TOKEN&project=gansm%2Ffinalcut" \
|
||||
-O cov-analysis-linux64.tar.gz
|
||||
mkdir cov-analysis-linux64
|
||||
tar xzf cov-analysis-linux64.tar.gz --strip 1 -C cov-analysis-linux64
|
||||
|
||||
- name: Install dependencies via apt-get
|
||||
run: |
|
||||
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
|
||||
sudo apt-get update
|
||||
sudo apt-get -y install \
|
||||
ca-certificates \
|
||||
gcc \
|
||||
g++ \
|
||||
gpm \
|
||||
libgpm-dev \
|
||||
libcppunit-dev \
|
||||
autoconf-archive
|
||||
|
||||
- name: Build with cov-build
|
||||
run: |
|
||||
export PATH=`pwd`/cov-analysis-linux64/bin:$PATH
|
||||
cat cov-int/scm_log.txt || echo
|
||||
autoreconf -v --install --force
|
||||
./configure --prefix=/usr \
|
||||
CPPFLAGS="-DDEBUG" \
|
||||
CXXFLAGS="-g -O0 -DDEBUG -DUNIT_TEST" \
|
||||
--with-unit-test
|
||||
cov-build --dir cov-int make V=1 -j10
|
||||
|
||||
- name: Submit the result to Coverity Scan
|
||||
run: |
|
||||
tar czvf finalcut.tgz cov-int
|
||||
curl \
|
||||
--form token=$COVERITY_SCAN_TOKEN \
|
||||
--form email=$COVERITY_SCAN_NOTIFICATION_EMAIL \
|
||||
--form file=@finalcut.tgz \
|
||||
--form version="main" \
|
||||
--form description="Build submitted via github action" \
|
||||
https://scan.coverity.com/builds?project=gansm%2Ffinalcut
|
||||
|
||||
- name: Make unit test
|
||||
run: |
|
||||
script -e -c "make check" && RET=$? || RET=$?
|
||||
cat test/*.log || echo
|
||||
echo "Exit status: $RET"
|
||||
exit "$RET"
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
name: "Cygwin build"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, actions-test ]
|
||||
pull_request:
|
||||
branches: [ main, actions-test ]
|
||||
schedule:
|
||||
- cron: '0 7 * * 2'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-latest
|
||||
name: Build on ${{ matrix.platform }}
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
platform: [x86, x64]
|
||||
|
||||
steps:
|
||||
- name: Install Cygwin
|
||||
uses: egor-tensin/setup-cygwin@v3
|
||||
with:
|
||||
platform: ${{ matrix.platform }}
|
||||
install-dir: C:\cygwin
|
||||
packages: git grep make libncurses-devel gcc-core gcc-g++ automake autoconf autoconf-archive libtool pkgconf cppunit
|
||||
|
||||
- name: Test on Cygwin environment
|
||||
run: |
|
||||
uname -a
|
||||
whoami
|
||||
pwd
|
||||
cygcheck -c -d # Show installed Cygwin packages
|
||||
g++ --version
|
||||
mkdir src && cd src
|
||||
git clone git://github.com/gansm/finalcut.git
|
||||
cd finalcut || echo "The source code directory was not found!"
|
||||
autoreconf --force --install --verbose --warnings=all
|
||||
automake --add-missing --copy
|
||||
./configure --prefix=/usr
|
||||
make -j10
|
||||
shell: C:\cygwin\bin\bash.exe --login '{0}'
|
||||
env:
|
||||
SHELLOPTS: igncr
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
name: "FreeBSD build"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, actions-test ]
|
||||
pull_request:
|
||||
branches: [ main, actions-test ]
|
||||
schedule:
|
||||
- cron: '0 7 * * 2'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: macos-10.15
|
||||
|
||||
steps:
|
||||
- name: Repository checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Test on FreeBSD 12.2
|
||||
uses: cross-platform-actions/action@v0.0.1
|
||||
with:
|
||||
operating_system: freebsd
|
||||
version: 12.2
|
||||
shell: bash
|
||||
run: |
|
||||
uname -a
|
||||
freebsd-version
|
||||
whoami
|
||||
pwd
|
||||
sudo pkg update
|
||||
sudo pkg install -y lang/gcc devel/autotools autotools automake autoconf autoconf-archive libtool pkgconf devel/ncurses devel/cppunit cppunit
|
||||
g++ --version
|
||||
autoreconf -v --install --force
|
||||
./configure --prefix=/usr
|
||||
make -j10
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
name: "macOS build"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, actions-test ]
|
||||
pull_request:
|
||||
branches: [ main, actions-test ]
|
||||
schedule:
|
||||
- cron: '0 7 * * 2'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- name: Repository checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Before_install
|
||||
run: |
|
||||
uname -a
|
||||
g++ --version
|
||||
whoami
|
||||
pwd
|
||||
|
||||
- name: Install dependencies via homebrew
|
||||
run: |
|
||||
brew update
|
||||
brew install automake
|
||||
brew install autoconf-archive
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
autoreconf -v --install --force
|
||||
./configure --prefix=/usr
|
||||
make -j10
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
name: "OpenBSD build"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, actions-test ]
|
||||
pull_request:
|
||||
branches: [ main, actions-test ]
|
||||
schedule:
|
||||
- cron: '0 7 * * 2'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: macos-10.15
|
||||
|
||||
steps:
|
||||
- name: Repository checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Test on OpenBSD 6.8
|
||||
uses: cross-platform-actions/action@v0.0.1
|
||||
with:
|
||||
operating_system: openbsd
|
||||
version: 6.8
|
||||
shell: bash
|
||||
run: |
|
||||
uname -a
|
||||
whoami
|
||||
pwd
|
||||
# http://ftp.openbsd.org/pub/OpenBSD/6.8/packages/amd64/
|
||||
sudo pkg_add gcc-8.4.0 g++-8.4.0 automake-1.16.2 autoconf-2.69p3 autoconf-archive libtool pkgconf cppunit
|
||||
export CXX=eg++
|
||||
export AUTOCONF_VERSION=2.69
|
||||
export AUTOMAKE_VERSION=1.16
|
||||
eg++ --version
|
||||
autoreconf -v --install --force
|
||||
./configure --prefix=/usr
|
||||
make -j10
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
name: "Solaris build"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, actions-test ]
|
||||
pull_request:
|
||||
branches: [ main, actions-test ]
|
||||
schedule:
|
||||
- cron: '0 7 * * 2'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- name: Repository checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Test on Solaris 11.4
|
||||
uses: vmactions/solaris-vm@v0.0.3
|
||||
with:
|
||||
prepare: pkgutil -y -i gcc5g++ automake autoconf autoconf_archive libtool pkgconfig libcppunit1_12_1 libcppunit_dev
|
||||
run: |
|
||||
uname -a
|
||||
whoami
|
||||
pwd
|
||||
cat /etc/release
|
||||
PATH=/opt/csw/bin:$PATH
|
||||
export PATH
|
||||
autoreconf -v --install --force
|
||||
./configure --prefix=/usr
|
||||
make
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
name: "SonarCloud analysis"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, actions-test ]
|
||||
pull_request:
|
||||
branches: [ main, actions-test ]
|
||||
schedule:
|
||||
- cron: '0 7 * * 2'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
env:
|
||||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
||||
SONAR_TOKEN: "${{ secrets.SONAR_TOKEN }}"
|
||||
|
||||
steps:
|
||||
- name: Repository checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
||||
|
||||
- name: Before_install
|
||||
run: |
|
||||
lsb_release -a
|
||||
uname -a
|
||||
whoami
|
||||
tty || echo
|
||||
pwd
|
||||
|
||||
- name: Install dependencies via apt-get
|
||||
run: |
|
||||
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
|
||||
sudo apt-get update
|
||||
sudo apt-get -y install \
|
||||
ca-certificates \
|
||||
gcc \
|
||||
g++ \
|
||||
gpm \
|
||||
wget \
|
||||
unzip \
|
||||
libgpm-dev \
|
||||
libcppunit-dev \
|
||||
autoconf-archive
|
||||
|
||||
- name: Build with SonarCloud
|
||||
run: |
|
||||
wget -q "https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip"
|
||||
unzip -q "build-wrapper-linux-x86.zip" -d "/tmp" || echo
|
||||
LATEST_VERSION=$(wget -O- https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/ 2>/dev/null | grep 'linux.zip"' | cut -d\" -f2 | tail -n1)
|
||||
wget -q "https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/$LATEST_VERSION"
|
||||
unzip -q "$LATEST_VERSION" -d "/tmp" || echo
|
||||
echo "sonar.host.url=https://sonarcloud.io" >> /tmp/sonar-scanner-*/conf/sonar-scanner.properties
|
||||
mkdir /tmp/sonar-cache
|
||||
autoreconf -v --install --force
|
||||
./configure --prefix=/usr
|
||||
/tmp/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output make all
|
||||
/tmp/sonar-scanner-4.6.2.2472-linux/bin/sonar-scanner
|
||||
|
|
@ -0,0 +1,187 @@
|
|||
language: cpp
|
||||
dist: xenial
|
||||
compiler:
|
||||
- gcc
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++
|
||||
- autotools-dev
|
||||
- automake
|
||||
- autoconf
|
||||
- autoconf-archive
|
||||
- libtool
|
||||
- pkg-config
|
||||
- libglib2.0-dev
|
||||
- libncurses5-dev
|
||||
- gpm
|
||||
- libgpm-dev
|
||||
- gperf
|
||||
- libcppunit-dev
|
||||
homebrew:
|
||||
packages:
|
||||
- autoconf-archive
|
||||
update: true
|
||||
|
||||
env:
|
||||
global:
|
||||
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
|
||||
# via the "travis encrypt" command using the project repo's public key
|
||||
- secure: |-
|
||||
wvCvMaIm7LoSyWHmpRXvJIetdMnJKsLLxuon6r6BSfpyimoz5FIMEhNhfSt2psv8tJHZgN
|
||||
/FcMcLhnTuTMIjvtlEtb3syfHDaNs7S2q3rm6LCmuIUU4ECAwAorkMQbXcyh5rgPlDMDiw
|
||||
CyBE8O1yFQebAFxRoP181+0uI2IiIP/8EW3P5PDSQzds+9fnnwrFS+OeBoUZfxT0F2kj2f
|
||||
kMXZN4+KmeVIrkqtj8hlRcicLgBPm4hrK5IEUcFLtAbzPj72wkV1duiYG6kqDsATmzMK0m
|
||||
5EuMhQ/nL/rbSjhrcRZzPFQ7P31ToSwg1I6cyhMjyXSbpwdppZ/RSwTpqDCdq9l4bDDmvI
|
||||
qizdwYZKcDtyHxm4Zl/LZKwWDsGEelcmuJKfdu+QuTgInGNlqulmDykvbsrk9jTimIzHTb
|
||||
F8TOn9IpANlTWmvunGeOarvR9qJReZcwSMq41hdMbsUdHiC1arZjKvINcPVuwikzaNq4iA
|
||||
te6mtSdrfdx1wLxQ6ZYNgKd9hz+uUTlBYl80hkATmq0NPnPQw2KzyG9E6nLrKOy2M0ozO8
|
||||
bL/epiiMBKJ37X1UcRU4WZYq+peLME8EefcPcXOSWNLwJtR7mtON8uMBrLL9CWmRMFD5Hy
|
||||
lQYALW2DhCnDBROKB3gxB/VkBGFNE0IPGeDtBGbLqDtKWPQoL125I=
|
||||
|
||||
jobs:
|
||||
include:
|
||||
#
|
||||
# Coverity Scan
|
||||
#
|
||||
- os: linux
|
||||
env:
|
||||
- TEST="Coverity Scan"
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- ca-certificates
|
||||
- gcc
|
||||
- g++
|
||||
- gpm
|
||||
- libgpm-dev
|
||||
- libcppunit-dev
|
||||
- autoconf-archive
|
||||
coverity_scan:
|
||||
project:
|
||||
name: gansm/finalcut
|
||||
description: Build submitted via Travis CI
|
||||
notification_email: guru.mail@muenster.de
|
||||
build_command_prepend: "autoreconf -v --install --force && ./configure --prefix=/usr CPPFLAGS='-DDEBUG' CXXFLAGS='-g -O0 -DDEBUG -DUNIT_TEST' --with-unit-test && make clean"
|
||||
build_command: "make V=1 -j10"
|
||||
branch_pattern: main
|
||||
before_install:
|
||||
- lsb_release -a
|
||||
- uname -a
|
||||
- whoami
|
||||
- echo -n | openssl s_client -CApath /etc/ssl/certs/ -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-certificates.crt
|
||||
script:
|
||||
- cat /home/travis/build/gansm/finalcut/cov-int/scm_log.txt || echo
|
||||
- autoreconf -v --install --force
|
||||
- ./configure --prefix=/usr CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -DUNIT_TEST" --with-unit-test
|
||||
- make V=1 -j10
|
||||
- make check
|
||||
- cat test/*.log || echo
|
||||
|
||||
#
|
||||
# Coveralls + Codecov
|
||||
#
|
||||
- os: linux
|
||||
env:
|
||||
- TEST="Coveralls"
|
||||
before_install:
|
||||
- lsb_release -a
|
||||
- uname -a
|
||||
- pip install --user cpp-coveralls
|
||||
- sudo pip install codecov
|
||||
script:
|
||||
- ./build.sh coverage
|
||||
after_success:
|
||||
- coveralls --gcov-options '\-lp' -e debian -e doc -e icon -e logo -e m4 -e scripts -e examples
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
|
||||
#
|
||||
# SonarCloud
|
||||
#
|
||||
- os: linux
|
||||
env:
|
||||
- TEST="sonarcloud"
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- ca-certificates
|
||||
- gcc
|
||||
- g++
|
||||
- gpm
|
||||
- libgpm-dev
|
||||
- libcppunit-dev
|
||||
- autoconf-archive
|
||||
sonarcloud:
|
||||
organization: "gansm"
|
||||
token:
|
||||
secure: |-
|
||||
Vai4Z9BoLsCdrtra5bP/xM8uZnMLKXWS3AH0Z6NnP6bBIa7o9i44Hg5b80P5yL3w
|
||||
22NgZcX5BrPNhTFbbsulw+F8OdnDETV1bxrDkAVaLGlw+pVjBFNhwXZzyHTx7rsX
|
||||
GQ/5ry1gIclRlyUO6atW5zQsImAPkTuMv6fFzjgiN1z5vheOTjOKpKqVZNWOURJT
|
||||
kKgSqiPgHMlR8JLqlHJ/322YVjOOwTLNPrHV6/TrWFrIHI3nChYYX60394sTzKrv
|
||||
XkU0uvoiJts0cEk97AWcWEfq5TkF1X9604UOZRifNps9kfNZOHjgUuFUvvo3WE8W
|
||||
ek9LU/0Ec9kViJEASsSE6VzNXWDqu+VkqisJwchUkn6OxoDILSkJpceco/Rx4dAO
|
||||
phMSgXjCCsvz5igniVyFUixoBvGo4D1bLO6zZPDVxXMDMhpzQKqwqkJo6FYcl109
|
||||
rni9IuLvMFDAwUuzCbXlbjSPvdOoDiq+8NY1A0TOtTp4z4q9NCPr6TlCcKrazqnN
|
||||
Xz4Nxo8xZCHxaH7CaXjBmh91Wp5aIzbwJS9fg6A7e2Is1HJm9YW1j3akBjzT//kE
|
||||
GhOEiXesrPvH5c9XxyO8ZgnkYjNBAES/9aUn8NZBPgQqcUhWAAe1r9fH4iy3Zj+/
|
||||
26IUvLfJ05uf1yEAzR9/xDIJFF7Heg1FRtzd6IiAdQ4=
|
||||
script:
|
||||
- autoreconf -v --install --force
|
||||
- ./configure --prefix=/usr
|
||||
- build-wrapper-linux-x86-64 --out-dir bw-output make all
|
||||
- sonar-scanner
|
||||
cache:
|
||||
directories:
|
||||
- '$HOME/.sonar/cache'
|
||||
|
||||
#
|
||||
# macOS
|
||||
#
|
||||
- os: osx
|
||||
osx_image: xcode11
|
||||
env:
|
||||
- TEST="macOS"
|
||||
before_install:
|
||||
- uname -a
|
||||
- g++ --version
|
||||
script:
|
||||
- autoreconf -v --install --force
|
||||
- ./configure --prefix=/usr
|
||||
- make -j10
|
||||
|
||||
#
|
||||
# FreeBSD
|
||||
#
|
||||
- os: freebsd
|
||||
env:
|
||||
- TEST="FreeBSD"
|
||||
before_install:
|
||||
- uname -a
|
||||
- g++ --version
|
||||
- sudo pkg install -y autoconf-archive
|
||||
script:
|
||||
- autoreconf -v --install --force
|
||||
- ./configure --prefix=/usr
|
||||
- make -j10
|
||||
|
||||
#
|
||||
# Linux ARM64 build
|
||||
#
|
||||
- arch: arm64
|
||||
os: linux
|
||||
env:
|
||||
- TEST="ARM64"
|
||||
before_install:
|
||||
- uname -a
|
||||
- g++ --version
|
||||
script:
|
||||
- autoreconf -v --install --force
|
||||
- ./configure --prefix=/usr
|
||||
- make -j10
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
# Code of Conduct
|
||||
|
||||
The FINAL CUT Project aims to be a welcoming place and we ask that everyone
|
||||
who interacts with the project and the larger community treat each other
|
||||
with dignity and respect. Individuals who do not behave in this manner will
|
||||
be warned and asked to adjust their behavior; in extreme cases, individuals
|
||||
could get excluded from the project.
|
||||
|
||||
Examples of inappropriate behavior include profane, offensive, or
|
||||
prejudicial language directed at another person, vandalism, or spam.
|
||||
|
30
ChangeLog
30
ChangeLog
|
@ -1,33 +1,3 @@
|
|||
2021-06-26 Markus Gans <guru.mail@muenster.de>
|
||||
* Global non-constant variables are now encapsulated in classes
|
||||
|
||||
2021-06-19 Markus Gans <guru.mail@muenster.de>
|
||||
* Moving the creator methods from FTerm to its own class
|
||||
|
||||
2021-06-16 Markus Gans <guru.mail@muenster.de>
|
||||
* Converted the internal timer from timeval
|
||||
to std::chrono::time_point<system_clock>
|
||||
|
||||
2021-06-06 Markus Gans <guru.mail@muenster.de>
|
||||
* Bug fixing in FString and FTermDetection
|
||||
* FTermDetection now has clean code by using FString instead of char*
|
||||
* Replace std::strlen with stringLength
|
||||
|
||||
2021-06-03 Markus Gans <guru.mail@muenster.de>
|
||||
* Some FString optimizations
|
||||
|
||||
2021-05-30 Markus Gans <guru.mail@muenster.de>
|
||||
* FString internally changed from wchar_t* to std::wstring
|
||||
|
||||
2021-05-24 Markus Gans <guru.mail@muenster.de>
|
||||
* Using std::string for the attribute buffer
|
||||
|
||||
2021-05-22 Markus Gans <guru.mail@muenster.de>
|
||||
* Convert FOptiMove from char[] to std::string
|
||||
|
||||
2021-05-13 Markus Gans <guru.mail@muenster.de>
|
||||
* Prevent duplicate widget in the close widget list
|
||||
|
||||
2021-05-07 Markus Gans <guru.mail@muenster.de>
|
||||
* Some pointers were replaced by references
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ The structure of the Qt framework was originally the inspiration for the C++ cla
|
|||
| *Latest release* | [![Latest Release](https://img.shields.io/github/release/gansm/finalcut.svg)](https://github.com/gansm/finalcut/releases) |
|
||||
| *License* | [![license](https://img.shields.io/github/license/gansm/finalcut.svg?colorA=#333)](COPYING) |
|
||||
| *Class Reference* | [![documented](https://codedocs.xyz/gansm/finalcut.svg)](https://codedocs.xyz/gansm/finalcut/hierarchy.html) |
|
||||
| *Travis CI* | [![Build Status](https://travis-ci.com/gansm/finalcut.svg?branch=main)](https://travis-ci.com/gansm/finalcut)
|
||||
| *Travis CI* | [![Build Status](https://travis-ci.org/gansm/finalcut.svg?branch=main)](https://travis-ci.org/gansm/finalcut)
|
||||
| *Coverity Scan* | [![Coverity Scan Status](https://img.shields.io/coverity/scan/6508.svg)](https://scan.coverity.com/projects/6508 )|
|
||||
| *LGTM* | [![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/gansm/finalcut.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/gansm/finalcut/context:cpp) |
|
||||
| *SonarCloud* | [![Quality gate](https://sonarcloud.io/api/project_badges/measure?project=gansm_finalcut&metric=alert_status)](https://sonarcloud.io/dashboard?id=gansm_finalcut) |
|
||||
|
|
12
SECURITY.md
12
SECURITY.md
|
@ -1,12 +0,0 @@
|
|||
# Security policy
|
||||
|
||||
## Dealing with security vulnerabilities
|
||||
|
||||
There is no separate process for handling security vulnerabilities in FINAL CUT. Security vulnerabilities are fixed and published like all other bugs. Nevertheless, from the moment they are brought to our attention, we try to close them as soon as possible.
|
||||
|
||||
## Reporting a security vulnerability
|
||||
|
||||
Preferably report a vulnerability via email to "guru.mail" + "@" + "muenster.de" or open an issue in the GitHub repository, the latter meaning that you made the vulnerability public before it was fixed.
|
||||
|
||||
If you already have a solution for the security problem, please submit a pull request.
|
||||
|
2
build.sh
2
build.sh
|
@ -43,7 +43,7 @@ fi
|
|||
# Build commands
|
||||
case "$1" in
|
||||
"--release"|"release")
|
||||
if ! ./configure --prefix="$PREFIX" CXXFLAGS="-O3" # "-flto -fno-rtti"
|
||||
if ! ./configure --prefix="$PREFIX" CXXFLAGS="-O3" # "-fno-rtti"
|
||||
then
|
||||
echo "${RED}Configure failed!${NORMAL}" 1>&2
|
||||
exit 255
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
coverage:
|
||||
status:
|
||||
project: on
|
||||
patch: off
|
||||
|
|
@ -185,7 +185,7 @@ void SegmentView::get7Segment (const wchar_t c)
|
|||
//----------------------------------------------------------------------
|
||||
void SegmentView::draw()
|
||||
{
|
||||
std::vector<finalcut::FTermBuffer> tbuffer(3);
|
||||
std::vector<finalcut::FTermBuffer> tbuffer{3};
|
||||
finalcut::FTermBuffer left_space{};
|
||||
|
||||
FDialog::draw();
|
||||
|
|
|
@ -385,7 +385,7 @@ void Calc::drawDispay()
|
|||
{
|
||||
finalcut::FString display{input};
|
||||
|
||||
if ( display.isEmpty() )
|
||||
if ( display.isNull() || display.isEmpty() )
|
||||
display = L'0';
|
||||
|
||||
if ( display.right(3) == L"-0." )
|
||||
|
@ -651,6 +651,7 @@ void Calc::radix_point (const lDouble&)
|
|||
return;
|
||||
|
||||
if ( isDataEntryKey(last_key)
|
||||
&& ! input.isNull()
|
||||
&& ! input.isEmpty()
|
||||
&& ! input.includes('.') )
|
||||
input += '.';
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
using finalcut::FPoint;
|
||||
|
@ -60,16 +61,10 @@ class Listview final : public finalcut::FDialog
|
|||
|
||||
// Callback method
|
||||
void cb_showInMessagebox();
|
||||
void cb_showIndexInMessagebox();
|
||||
void cb_doit();
|
||||
void cb_doit2();
|
||||
|
||||
// Data members
|
||||
finalcut::FListView listview{this};
|
||||
finalcut::FButton quit{this};
|
||||
finalcut::FButton Mark{this};
|
||||
finalcut::FButton Index{this};
|
||||
finalcut::FButton GIndex{this};
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -105,11 +100,10 @@ Listview::Listview (finalcut::FWidget* parent)
|
|||
|
||||
// Populate FListView with a list of items
|
||||
populate();
|
||||
|
||||
// Quit button
|
||||
quit.setText (L"&Quit");
|
||||
Mark.setText("&Mark");
|
||||
Index.setText("&Getindex");
|
||||
GIndex.setText("&Index");
|
||||
|
||||
// Add some function callbacks
|
||||
quit.addCallback
|
||||
(
|
||||
|
@ -124,24 +118,6 @@ Listview::Listview (finalcut::FWidget* parent)
|
|||
"clicked",
|
||||
this, &Listview::cb_showInMessagebox
|
||||
);
|
||||
Mark.addCallback
|
||||
(
|
||||
"clicked",
|
||||
this, &Listview::cb_doit
|
||||
);
|
||||
|
||||
Index.addCallback
|
||||
(
|
||||
"clicked",
|
||||
this, &Listview::cb_showIndexInMessagebox
|
||||
);
|
||||
|
||||
GIndex.addCallback
|
||||
(
|
||||
"clicked",
|
||||
this, &Listview::cb_doit2
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -205,10 +181,7 @@ void Listview::initLayout()
|
|||
// Set FListView geometry
|
||||
listview.setGeometry(FPoint{2, 1}, FSize{33, 14});
|
||||
// Set quit button geometry
|
||||
quit.setGeometry(FPoint{30, 16}, FSize{10, 1});
|
||||
Index.setGeometry(FPoint{13, 16}, FSize{10, 1});
|
||||
Mark.setGeometry(FPoint{1, 15}, FSize{10, 1});
|
||||
GIndex.setGeometry(FPoint{1, 17}, FSize{10, 1});
|
||||
quit.setGeometry(FPoint{24, 16}, FSize{10, 1});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
|
@ -218,16 +191,6 @@ void Listview::onClose (finalcut::FCloseEvent* ev)
|
|||
finalcut::FApplication::closeConfirmationDialog (this, ev);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Listview::cb_doit()
|
||||
{
|
||||
listview.setmark(listview.getindex());
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
void Listview::cb_doit2()
|
||||
{
|
||||
listview.setindex(17);
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
void Listview::cb_showInMessagebox()
|
||||
{
|
||||
|
@ -243,18 +206,7 @@ void Listview::cb_showInMessagebox()
|
|||
, this );
|
||||
info.show();
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
void Listview::cb_showIndexInMessagebox()
|
||||
{
|
||||
finalcut::FString index;
|
||||
index.setNumber(listview.getindex());
|
||||
finalcut::FMessageBox info ( "Test","The Index is :"+index
|
||||
, finalcut::FMessageBox::ButtonType::Ok
|
||||
, finalcut::FMessageBox::ButtonType::Reject
|
||||
, finalcut::FMessageBox::ButtonType::Reject
|
||||
, this );
|
||||
info.show();
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// main part
|
||||
|
|
|
@ -203,7 +203,7 @@ DirectLogger::~DirectLogger() noexcept = default; // destructor
|
|||
int main (int argc, char* argv[])
|
||||
{
|
||||
// Disable mouse, color palette changes and terminal data requests
|
||||
auto& start_options = finalcut::FStartOptions::getInstance();
|
||||
auto& start_options = finalcut::FStartOptions::getFStartOptions();
|
||||
start_options.mouse_support = false;
|
||||
start_options.color_change = false;
|
||||
start_options.terminal_data_request = false;
|
||||
|
@ -265,7 +265,7 @@ int main (int argc, char* argv[])
|
|||
std::cout << "\r" << line << std::flush;
|
||||
// Generation of a logger in a shared_ptr via a pointer
|
||||
finalcut::FApplication::setLog(std::make_shared<DirectLogger>());
|
||||
const auto& opti_move = finalcut::FOptiMove::getInstance();
|
||||
const auto& opti_move = finalcut::FTerm::getFOptiMove();
|
||||
finalcut::printDurations(opti_move);
|
||||
|
||||
// Waiting for keypress
|
||||
|
|
|
@ -190,7 +190,7 @@ void RotoZoomer::generateReport()
|
|||
finalcut::FStringStream rep;
|
||||
dimension_str << getDesktopWidth()
|
||||
<< "x" << getDesktopHeight();
|
||||
auto elapsed_ms = int(duration_cast<milliseconds>(end - start).count());
|
||||
int elapsed_ms = int(duration_cast<milliseconds>(end - start).count());
|
||||
time_str << double(elapsed_ms) / 1000 << "s";
|
||||
fps_str << double(loops) * 1000.0 / double(elapsed_ms);
|
||||
|
||||
|
@ -308,7 +308,7 @@ int main (int argc, char* argv[])
|
|||
{
|
||||
benchmark = true;
|
||||
// Disable terminal data requests
|
||||
auto& start_options = finalcut::FStartOptions::getInstance();
|
||||
auto& start_options = finalcut::FStartOptions::getFStartOptions();
|
||||
start_options.terminal_data_request = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -287,7 +287,7 @@ void AttribDemo::printAltCharset()
|
|||
if ( ! finalcut::FTerm::isMonochron() )
|
||||
setColor (wc->label_fg, wc->label_bg);
|
||||
|
||||
print() << FPoint{1, 1} << "Alternate charset: ";
|
||||
print() << FPoint{1, 1} << "alternate charset: ";
|
||||
|
||||
if ( parent->getBGColor() == FColor::Default )
|
||||
{
|
||||
|
|
|
@ -33,7 +33,7 @@ using finalcut::Termcap;
|
|||
void tcapBoolean (const std::string&, bool);
|
||||
void tcapNumeric (const std::string&, int);
|
||||
void tcapString (const std::string&, const char[]);
|
||||
void debug();
|
||||
void debug (const finalcut::FApplication&);
|
||||
void booleans();
|
||||
void numeric();
|
||||
void string();
|
||||
|
@ -167,21 +167,22 @@ void tcapNumeric (const std::string& name, int cap_num)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void tcapString (const std::string& name, const char cap_string[])
|
||||
void tcapString (const std::string& name, const char cap_str[])
|
||||
{
|
||||
std::string sequence{};
|
||||
std::string cap_str{cap_string ? cap_string : std::string{}};
|
||||
std::cout << name << ": ";
|
||||
|
||||
if ( cap_str.empty() )
|
||||
if ( cap_str == nullptr )
|
||||
{
|
||||
std::cout << "\r\n";
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto&& ch : cap_str)
|
||||
const auto len = uInt(std::strlen(cap_str));
|
||||
|
||||
for (uInt i{0}; i < len; i++)
|
||||
{
|
||||
const auto c = uChar(ch);
|
||||
const auto c = uChar(cap_str[i]);
|
||||
|
||||
if ( c > 127 )
|
||||
{
|
||||
|
@ -210,9 +211,10 @@ void tcapString (const std::string& name, const char cap_string[])
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
#if DEBUG
|
||||
void showDebug()
|
||||
void debug (const finalcut::FApplication& TermApp)
|
||||
{
|
||||
auto& debug_data = finalcut::FTermDebugData::getInstance();
|
||||
const auto& fterm = TermApp.getFTerm();
|
||||
auto& debug_data = fterm.getFTermDebugData();
|
||||
const auto& ab_s = debug_data.getAnswerbackString();
|
||||
const auto& sec_da = debug_data.getSecDAString();
|
||||
std::cout << "\n.------------------- debug -------------------\r\n";
|
||||
|
@ -238,14 +240,14 @@ void showDebug()
|
|||
std::cout << "`------------------- debug -------------------\r\n";
|
||||
}
|
||||
#else
|
||||
void showDebug()
|
||||
void debug (const finalcut::FApplication&)
|
||||
{
|
||||
// FINAL CUT was compiled without debug option
|
||||
}
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void showBooleans()
|
||||
void booleans()
|
||||
{
|
||||
std::cout << "\r\n[Booleans]\r\n";
|
||||
tcapBoolean ( "background_color_erase"
|
||||
|
@ -273,7 +275,7 @@ void showBooleans()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void showNumeric()
|
||||
void numeric()
|
||||
{
|
||||
std::cout << "\r\n[Numeric]\r\n";
|
||||
tcapNumeric ("max_color"
|
||||
|
@ -287,7 +289,7 @@ void showNumeric()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void showString()
|
||||
void string()
|
||||
{
|
||||
std::cout << "\r\n[String]\r\n";
|
||||
const auto& tcap_strings = finalcut::FTermcap::strings;
|
||||
|
@ -309,7 +311,7 @@ int main (int argc, char* argv[])
|
|||
finalcut::FTerm::useAlternateScreen(false);
|
||||
|
||||
// Disable color palette changes and terminal data requests
|
||||
auto& start_options = finalcut::FStartOptions::getInstance();
|
||||
auto& start_options = finalcut::FStartOptions::getFStartOptions();
|
||||
start_options.color_change = false;
|
||||
start_options.terminal_data_request = false;
|
||||
|
||||
|
@ -325,9 +327,10 @@ int main (int argc, char* argv[])
|
|||
std::cout << "--------\r\nFTermcap\r\n--------\r\n\n";
|
||||
std::cout << "Terminal: " << finalcut::FTerm::getTermType() << "\r\n";
|
||||
|
||||
showDebug();
|
||||
showBooleans();
|
||||
showNumeric();
|
||||
showString();
|
||||
debug (term_app);
|
||||
|
||||
booleans();
|
||||
numeric();
|
||||
string();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -427,7 +427,7 @@ void MyDialog::initMenu()
|
|||
Drive.setStatusbarMessage ("Show drive symbols");
|
||||
Line3.setSeparator();
|
||||
|
||||
if ( finalcut::FStartOptions::getInstance().dark_theme )
|
||||
if ( finalcut::FStartOptions::getFStartOptions().dark_theme )
|
||||
Theme.setChecked();
|
||||
}
|
||||
|
||||
|
@ -1013,7 +1013,7 @@ void MyDialog::cb_view (const finalcut::FMenuItem* item)
|
|||
else
|
||||
file = finalcut::FFileDialog::fileOpenChooser (this);
|
||||
|
||||
if ( file.isEmpty() )
|
||||
if ( file.isNull() )
|
||||
return;
|
||||
|
||||
const auto& view = new TextWindow(this);
|
||||
|
|
|
@ -110,15 +110,15 @@ Watch::Watch (FWidget* parent)
|
|||
void Watch::printTime()
|
||||
{
|
||||
finalcut::FString str{};
|
||||
struct tm local_tm;
|
||||
using namespace std::chrono;
|
||||
auto now = system_clock::to_time_t(system_clock::now());
|
||||
auto lt = *localtime_r(&now, &local_tm);
|
||||
std::tm now{};
|
||||
|
||||
const std::time_t t = std::time(nullptr); // get current time
|
||||
localtime_r(&t, &now);
|
||||
|
||||
if ( sec )
|
||||
str.sprintf("%02d:%02d:%02d", lt.tm_hour, lt.tm_min, lt.tm_sec);
|
||||
str.sprintf("%02d:%02d:%02d", now.tm_hour, now.tm_min, now.tm_sec);
|
||||
else
|
||||
str.sprintf("%02d:%02d ", lt.tm_hour, lt.tm_min);
|
||||
str.sprintf("%02d:%02d ", now.tm_hour, now.tm_min);
|
||||
|
||||
time_str = str;
|
||||
time_str.redraw();
|
||||
|
|
|
@ -103,7 +103,7 @@ Special X11 bitmap font used by FINAL CUT to display graphic objects.
|
|||
|
||||
%build
|
||||
autoreconf -vif
|
||||
export CPPFLAGS="%{optflags} -Wall -Wextra -Wpedantic -flto"
|
||||
export CPPFLAGS="%{optflags} -Wall -Wextra -Wpedantic"
|
||||
%ifnarch %ix86 x86_64
|
||||
export CPPFLAGS="$CPPFLAGS -Wno-error=unused-parameter"
|
||||
%endif
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
sonar.organization=gansm
|
||||
sonar.projectKey=gansm_finalcut
|
||||
sonar.projectName=finalcut
|
||||
sonar.projectVersion=0.7.2
|
||||
|
@ -17,9 +16,6 @@ sonar.links.issue=https://github.com/gansm/finalcut/issues
|
|||
#----------------------------------------------------------------------
|
||||
sonar.sources=.
|
||||
sonar.cfamily.build-wrapper-output=bw-output
|
||||
sonar.cfamily.threads=2
|
||||
sonar.cfamily.cache.enabled=true
|
||||
sonar.cfamily.cache.path=/tmp/sonar-cache
|
||||
sonar.exclusions=src/include/final/fconfig.h
|
||||
sonar.coverage.exclusions=**/**
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ int FApplication::loop_level {0}; // event loop level
|
|||
int FApplication::quit_code {EXIT_SUCCESS};
|
||||
bool FApplication::quit_now {false};
|
||||
uInt64 FApplication::next_event_wait {5000}; // 5 ms (200 Hz)
|
||||
TimeValue FApplication::time_last_event {};
|
||||
struct timeval FApplication::time_last_event {};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -90,7 +90,7 @@ FApplication::FApplication (const int& arg_c, char* arg_v[])
|
|||
|
||||
if ( internal::var::app_object )
|
||||
{
|
||||
auto& fterm_data = FTermData::getInstance();
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
fterm_data.setExitMessage("FApplication: There should be "
|
||||
"only one application object");
|
||||
FApplication::exit(EXIT_FAILURE);
|
||||
|
@ -339,7 +339,7 @@ void FApplication::setLogFile (const FString& filename)
|
|||
}
|
||||
else
|
||||
{
|
||||
auto& fterm_data = FTermData::getInstance();
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
fterm_data.setExitMessage ( "Could not open log file \""
|
||||
+ filename + "\"" );
|
||||
exit(EXIT_FAILURE);
|
||||
|
@ -392,10 +392,11 @@ void FApplication::init()
|
|||
setMaxChildren(1);
|
||||
|
||||
// Initialize the last event time
|
||||
time_last_event = TimeValue{};
|
||||
time_last_event.tv_sec = 0;
|
||||
time_last_event.tv_usec = 0;
|
||||
|
||||
// Initialize keyboard
|
||||
auto& keyboard = FKeyboard::getInstance();
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
auto cmd1 = [this] () { this->keyPressed(); };
|
||||
auto cmd2 = [this] () { this->keyReleased(); };
|
||||
auto cmd3 = [this] () { this->escapeKeyPressed(); };
|
||||
|
@ -412,7 +413,7 @@ void FApplication::init()
|
|||
keyboard.setKeypressTimeout (key_timeout);
|
||||
|
||||
// Initialize mouse control
|
||||
auto& mouse = FMouseControl::getInstance();
|
||||
auto& mouse = FTerm::getFMouseControl();
|
||||
auto cmd = [this] (const FMouseData& md) { this->mouseEvent(md); };
|
||||
FMouseCommand mouse_cmd (cmd);
|
||||
mouse.setEventCommand (mouse_cmd);
|
||||
|
@ -443,7 +444,7 @@ void FApplication::setTerminalEncoding (const FString& enc_str)
|
|||
showParameterUsage();
|
||||
else
|
||||
{
|
||||
auto& fterm_data = FTermData::getInstance();
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
fterm_data.setExitMessage ( "Unknown encoding \"" + enc_str
|
||||
+ "\"\n(Valid encodings are utf8, "
|
||||
+ "vt100, pc and ascii)" );
|
||||
|
@ -562,7 +563,7 @@ void FApplication::cmdOptions (const Args& args)
|
|||
//----------------------------------------------------------------------
|
||||
inline FStartOptions& FApplication::getStartOptions()
|
||||
{
|
||||
return FStartOptions::getInstance();
|
||||
return FStartOptions::getFStartOptions();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -657,8 +658,8 @@ inline void FApplication::findKeyboardWidget() const
|
|||
//----------------------------------------------------------------------
|
||||
inline bool FApplication::isKeyPressed() const
|
||||
{
|
||||
auto& mouse = FMouseControl::getInstance();
|
||||
auto& keyboard = FKeyboard::getInstance();
|
||||
auto& mouse = FTerm::getFMouseControl();
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
|
||||
if ( mouse.isGpmMouseEnabled() )
|
||||
return mouse.getGpmKeyPressed(keyboard.hasUnprocessedInput());
|
||||
|
@ -693,7 +694,7 @@ void FApplication::mouseTracking() const
|
|||
//----------------------------------------------------------------------
|
||||
inline void FApplication::performKeyboardAction()
|
||||
{
|
||||
const auto& keyboard = FKeyboard::getInstance();
|
||||
const auto& keyboard = FTerm::getFKeyboard();
|
||||
|
||||
if ( keyboard.getKey() == FKey::Ctrl_l ) // Ctrl-L (redraw the screen)
|
||||
{
|
||||
|
@ -712,8 +713,8 @@ inline void FApplication::performKeyboardAction()
|
|||
//----------------------------------------------------------------------
|
||||
inline void FApplication::performMouseAction() const
|
||||
{
|
||||
auto& mouse = FMouseControl::getInstance();
|
||||
auto& keyboard = FKeyboard::getInstance();
|
||||
auto& mouse = FTerm::getFMouseControl();
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
const auto key = keyboard.getKey();
|
||||
auto& buffer = keyboard.getKeyBuffer();
|
||||
|
||||
|
@ -760,7 +761,7 @@ inline void FApplication::sendEscapeKeyPressEvent() const
|
|||
inline bool FApplication::sendKeyDownEvent (FWidget* widget) const
|
||||
{
|
||||
// Send key down event
|
||||
const auto& keyboard = FKeyboard::getInstance();
|
||||
const auto& keyboard = FTerm::getFKeyboard();
|
||||
FKeyEvent k_down_ev (Event::KeyDown, keyboard.getKey());
|
||||
sendEvent (widget, &k_down_ev);
|
||||
return k_down_ev.isAccepted();
|
||||
|
@ -770,7 +771,7 @@ inline bool FApplication::sendKeyDownEvent (FWidget* widget) const
|
|||
inline bool FApplication::sendKeyPressEvent (FWidget* widget) const
|
||||
{
|
||||
// Send key press event
|
||||
const auto& keyboard = FKeyboard::getInstance();
|
||||
const auto& keyboard = FTerm::getFKeyboard();
|
||||
FKeyEvent k_press_ev (Event::KeyPress, keyboard.getKey());
|
||||
sendEvent (widget, &k_press_ev);
|
||||
return k_press_ev.isAccepted();
|
||||
|
@ -780,7 +781,7 @@ inline bool FApplication::sendKeyPressEvent (FWidget* widget) const
|
|||
inline bool FApplication::sendKeyUpEvent (FWidget* widget) const
|
||||
{
|
||||
// Send key up event
|
||||
const auto& keyboard = FKeyboard::getInstance();
|
||||
const auto& keyboard = FTerm::getFKeyboard();
|
||||
FKeyEvent k_up_ev (Event::KeyUp, keyboard.getKey());
|
||||
sendEvent (widget, &k_up_ev);
|
||||
return k_up_ev.isAccepted();
|
||||
|
@ -817,8 +818,8 @@ inline void FApplication::sendKeyboardAccelerator()
|
|||
//----------------------------------------------------------------------
|
||||
inline bool FApplication::hasDataInQueue() const
|
||||
{
|
||||
const auto& keyboard = FKeyboard::getInstance();
|
||||
const auto& mouse = FMouseControl::getInstance();
|
||||
const auto& keyboard = FTerm::getFKeyboard();
|
||||
const auto& mouse = FTerm::getFMouseControl();
|
||||
|
||||
if ( keyboard.hasDataInQueue()
|
||||
|| mouse.hasDataInQueue()
|
||||
|
@ -837,7 +838,7 @@ void FApplication::queuingKeyboardInput() const
|
|||
return;
|
||||
|
||||
findKeyboardWidget();
|
||||
auto& keyboard = FKeyboard::getInstance();
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
keyboard.escapeKeyHandling(); // special case: Esc key
|
||||
keyboard.clearKeyBufferOnTimeout();
|
||||
|
||||
|
@ -848,7 +849,7 @@ void FApplication::queuingKeyboardInput() const
|
|||
//----------------------------------------------------------------------
|
||||
void FApplication::queuingMouseInput() const
|
||||
{
|
||||
auto& mouse = FMouseControl::getInstance();
|
||||
auto& mouse = FTerm::getFMouseControl();
|
||||
|
||||
if ( quit_now
|
||||
|| internal::var::exit_loop
|
||||
|
@ -856,8 +857,8 @@ void FApplication::queuingMouseInput() const
|
|||
|| FTerm::hasChangedTermSize() )
|
||||
return;
|
||||
|
||||
auto& keyboard = FKeyboard::getInstance();
|
||||
auto time_keypressed = keyboard.getKeyPressedTime();
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
struct timeval* time_keypressed = keyboard.getKeyPressedTime();
|
||||
mouse.processEvent (time_keypressed);
|
||||
keyboard.hasUnprocessedInput() = mouse.hasUnprocessedInput();
|
||||
mouse.clearEvent();
|
||||
|
@ -871,7 +872,7 @@ void FApplication::processKeyboardEvent() const
|
|||
|| FTerm::hasChangedTermSize() )
|
||||
return;
|
||||
|
||||
auto& keyboard = FKeyboard::getInstance();
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
keyboard.processQueuedInput();
|
||||
}
|
||||
|
||||
|
@ -883,13 +884,13 @@ void FApplication::processMouseEvent() const
|
|||
|| FTerm::hasChangedTermSize() )
|
||||
return;
|
||||
|
||||
FMouseControl::getInstance().processQueuedInput();
|
||||
FTerm::getFMouseControl().processQueuedInput();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FApplication::processDialogSwitchAccelerator() const
|
||||
{
|
||||
const auto& keyboard = FKeyboard::getInstance();
|
||||
const auto& keyboard = FTerm::getFKeyboard();
|
||||
|
||||
if ( keyboard.getKey() >= FKey::Meta_1
|
||||
&& keyboard.getKey() <= FKey::Meta_9 )
|
||||
|
@ -927,7 +928,7 @@ bool FApplication::processAccelerator (const FWidget& widget) const
|
|||
|
||||
for (auto&& item : widget.getAcceleratorList())
|
||||
{
|
||||
if ( item.key == FKeyboard::getInstance().getKey() )
|
||||
if ( item.key == FTerm::getFKeyboard().getKey() )
|
||||
{
|
||||
// unset the move/size mode
|
||||
auto move_size = getMoveSizeWidget();
|
||||
|
@ -1257,7 +1258,7 @@ void FApplication::processResizeEvent() const
|
|||
return;
|
||||
|
||||
FTerm::detectTermSize(); // Detect and save the current terminal size
|
||||
auto& mouse = FMouseControl::getInstance();
|
||||
auto& mouse = FTerm::getFMouseControl();
|
||||
mouse.setMaxWidth (uInt16(getDesktopWidth()));
|
||||
mouse.setMaxHeight (uInt16(getDesktopHeight()));
|
||||
FResizeEvent r_ev(Event::Resize);
|
||||
|
@ -1307,7 +1308,7 @@ bool FApplication::processNextEvent()
|
|||
|
||||
if ( is_timeout || hasDataInQueue() )
|
||||
{
|
||||
time_last_event = FObject::getCurrentTime();
|
||||
FObject::getCurrentTime (&time_last_event);
|
||||
queuingKeyboardInput();
|
||||
queuingMouseInput();
|
||||
processKeyboardEvent();
|
||||
|
@ -1400,7 +1401,7 @@ bool FApplication::isEventProcessable ( FObject* receiver
|
|||
//----------------------------------------------------------------------
|
||||
bool FApplication::isNextEventTimeout()
|
||||
{
|
||||
return FObject::isTimeout (time_last_event, next_event_wait);
|
||||
return FObject::isTimeout (&time_last_event, next_event_wait);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2012-2021 Markus Gans *
|
||||
* Copyright 2012-2020 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -209,7 +209,11 @@ bool FButton::setDown (bool enable)
|
|||
//----------------------------------------------------------------------
|
||||
void FButton::setText (const FString& txt)
|
||||
{
|
||||
if ( txt.isNull() )
|
||||
text.setString("");
|
||||
else
|
||||
text.setString(txt);
|
||||
|
||||
detectHotkey();
|
||||
}
|
||||
|
||||
|
@ -319,12 +323,6 @@ void FButton::onMouseMove (FMouseEvent* ev)
|
|||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FButton::onWheel (FWheelEvent*)
|
||||
{
|
||||
setUp();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FButton::onTimer (FTimerEvent* ev)
|
||||
{
|
||||
|
|
|
@ -361,7 +361,7 @@ void FButtonGroup::draw()
|
|||
//----------------------------------------------------------------------
|
||||
void FButtonGroup::drawLabel()
|
||||
{
|
||||
if ( text.isEmpty() )
|
||||
if ( text.isNull() || text.isEmpty() )
|
||||
return;
|
||||
|
||||
FString label_text{};
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2015-2021 Markus Gans *
|
||||
* Copyright 2015-2020 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -29,47 +29,10 @@
|
|||
namespace finalcut
|
||||
{
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
auto FCharMap::getInstance() -> FCharMap&
|
||||
namespace fc
|
||||
{
|
||||
static const auto& char_map = make_unique<FCharMap>();
|
||||
return *char_map;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
wchar_t& FCharMap::getCharacter ( CharEncodeMap& char_enc
|
||||
, const Encoding& enc )
|
||||
{
|
||||
const auto array = reinterpret_cast<wchar_t*>(&char_enc);
|
||||
return array[std::size_t(enc)];
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FCharMap::CharEncodeType& FCharMap::getCharEncodeMap()
|
||||
{
|
||||
return character;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const FCharMap::DECGraphicsType& FCharMap::getDECSpecialGraphics()
|
||||
{
|
||||
return dec_special_graphics;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const FCharMap::Cp437UcsType& FCharMap::getCP437UCSMap()
|
||||
{
|
||||
return cp437_ucs;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const FCharMap::HalfFullWidthType& FCharMap::getHalfFullWidthMap()
|
||||
{
|
||||
return halfwidth_fullwidth;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FCharMap::CharEncodeType FCharMap::character =
|
||||
std::array<CharEncodeMap, 115> character =
|
||||
{{
|
||||
// .--------------------- Unicode (UTF-8)
|
||||
// | .--------------- VT100
|
||||
|
@ -198,8 +161,8 @@ FCharMap::CharEncodeType FCharMap::character =
|
|||
* (2) Only supported in use with newfont
|
||||
*/
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
constexpr FCharMap::DECGraphicsType FCharMap::dec_special_graphics =
|
||||
|
||||
constexpr std::array<DECSpecialGraphics, 39> dec_special_graphics =
|
||||
{{
|
||||
{VT100Key::rarrow , UniChar::BlackRightPointingPointer}, // ►
|
||||
{VT100Key::larrow , UniChar::BlackLeftPointingPointer}, // ◄
|
||||
|
@ -242,8 +205,7 @@ constexpr FCharMap::DECGraphicsType FCharMap::dec_special_graphics =
|
|||
{VT100Key::diamond , UniChar::Bullet} // ◆
|
||||
}};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
constexpr FCharMap::Cp437UcsType FCharMap::cp437_ucs =
|
||||
constexpr std::array<std::array<wchar_t, 2>, 256> cp437_ucs =
|
||||
{{
|
||||
{{0x00, 0x0000}}, // null
|
||||
{{0x01, 0x263a}}, // white smiling face
|
||||
|
@ -503,9 +465,8 @@ constexpr FCharMap::Cp437UcsType FCharMap::cp437_ucs =
|
|||
{{0xff, 0x00a0}} // no-break space
|
||||
}};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Based on http://www.unicode.org/charts/PDF/UFF00.pdf
|
||||
constexpr FCharMap::HalfFullWidthType FCharMap::halfwidth_fullwidth =
|
||||
constexpr std::array<std::array<wchar_t, 2>, 227> halfwidth_fullwidth =
|
||||
{{
|
||||
// Fullwidth ASCII variants
|
||||
{{0x0020, 0x3000}}, // ' ' -> ' '
|
||||
|
@ -743,4 +704,7 @@ constexpr FCharMap::HalfFullWidthType FCharMap::halfwidth_fullwidth =
|
|||
{{0xffee, 0x25cb}} // ○ -> ○
|
||||
}};
|
||||
|
||||
} // namespace fc
|
||||
|
||||
} // namespace finalcut
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2020-2021 Markus Gans *
|
||||
* Copyright 2020 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -39,15 +39,6 @@ FColorPalette::FColorPalette (const FSetPalette& f)
|
|||
FColorPalette::~FColorPalette() noexcept = default; // destructor
|
||||
|
||||
|
||||
// public methods of FColorPalette
|
||||
//----------------------------------------------------------------------
|
||||
auto FColorPalette::getInstance() -> std::shared_ptr<FColorPalette>&
|
||||
{
|
||||
static const auto& color_theme = make_unique<std::shared_ptr<FColorPalette>>();
|
||||
return *color_theme.get();
|
||||
}
|
||||
|
||||
|
||||
// protected methods of FColorPalette
|
||||
//----------------------------------------------------------------------
|
||||
void FColorPalette::setPalette (FColor index, int r, int g, int b) const
|
||||
|
|
|
@ -611,7 +611,7 @@ void FComboBox::cb_closeComboBox()
|
|||
//----------------------------------------------------------------------
|
||||
void FComboBox::cb_inputFieldSwitch()
|
||||
{
|
||||
auto& mouse = FMouseControl::getInstance();
|
||||
auto& mouse = FTerm::getFMouseControl();
|
||||
|
||||
if ( ! mouse.isLeftButtonPressed() )
|
||||
return;
|
||||
|
@ -630,7 +630,7 @@ void FComboBox::cb_inputFieldSwitch()
|
|||
//----------------------------------------------------------------------
|
||||
void FComboBox::cb_inputFieldHandOver()
|
||||
{
|
||||
auto& mouse = FMouseControl::getInstance();
|
||||
auto& mouse = FTerm::getFMouseControl();
|
||||
|
||||
if ( list_window.isHidden() )
|
||||
return;
|
||||
|
|
|
@ -100,7 +100,7 @@ bool FDialog::setModal (bool enable)
|
|||
if ( enable )
|
||||
{
|
||||
setModalDialogCounter()++;
|
||||
FKeyboard::getInstance().clearKeyBuffer();
|
||||
FTerm::getFKeyboard().clearKeyBuffer();
|
||||
}
|
||||
else
|
||||
setModalDialogCounter()--;
|
||||
|
|
|
@ -65,15 +65,15 @@ FString fileChooser ( FWidget* parent
|
|||
FString path{dirname};
|
||||
FString file_filter{filter};
|
||||
|
||||
if ( path.isEmpty() )
|
||||
if ( path.isNull() || path.isEmpty() )
|
||||
{
|
||||
path.setString(FFileDialog::getHomeDir());
|
||||
|
||||
if ( path.isEmpty() )
|
||||
if ( path.isNull() || path.isEmpty() )
|
||||
path.setString("/");
|
||||
}
|
||||
|
||||
if ( file_filter.isEmpty() )
|
||||
if ( file_filter.isNull() || file_filter.isEmpty() )
|
||||
file_filter.setString("*");
|
||||
|
||||
FFileDialog fileopen ( path
|
||||
|
@ -111,7 +111,7 @@ FFileDialog::FFileDialog ( const FString& dirname
|
|||
, filter_pattern{filter}
|
||||
, dlg_type{type}
|
||||
{
|
||||
if ( ! dirname.isEmpty() )
|
||||
if ( ! dirname.isNull() )
|
||||
setPath(dirname);
|
||||
|
||||
init();
|
||||
|
@ -162,7 +162,7 @@ void FFileDialog::setPath (const FString& dir)
|
|||
return;
|
||||
}
|
||||
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
|
||||
if ( fsystem->realpath(dir.c_str(), resolved_path.data()) != nullptr )
|
||||
r_dir.setString(resolved_path.data());
|
||||
|
@ -372,16 +372,18 @@ void FFileDialog::initCallbacks()
|
|||
inline bool FFileDialog::patternMatch ( const char* const pattern
|
||||
, const char fname[] ) const
|
||||
{
|
||||
std::string search{};
|
||||
search.reserve(128);
|
||||
std::array<char, 128> search{};
|
||||
|
||||
if ( show_hidden && fname[0] == '.' && fname[1] != '\0' ) // hidden files
|
||||
{
|
||||
search = ".";
|
||||
search.append(pattern);
|
||||
search[0] = '.';
|
||||
search[1] = '\0';
|
||||
std::strncat(search.data(), pattern, search.size() - std::strlen(search.data()) - 1);
|
||||
}
|
||||
else
|
||||
search = pattern;
|
||||
std::strncpy(search.data(), pattern, search.size() - 1);
|
||||
|
||||
search[search.size() - 1] = '\0';
|
||||
|
||||
if ( fnmatch (search.data(), fname, FNM_PERIOD) == 0 )
|
||||
return true;
|
||||
|
@ -478,13 +480,15 @@ int FFileDialog::readDir()
|
|||
|
||||
getEntry(dir, next);
|
||||
}
|
||||
else
|
||||
else if ( errno != 0 )
|
||||
{
|
||||
if ( errno != 0 )
|
||||
FMessageBox::error (this, "Reading directory\n" + directory);
|
||||
|
||||
if ( errno == EOVERFLOW ) // Value too large to be stored in data type
|
||||
break;
|
||||
}
|
||||
else
|
||||
break;
|
||||
} // end while
|
||||
|
||||
if ( closedir(directory_stream) != 0 )
|
||||
|
@ -546,11 +550,16 @@ void FFileDialog::followSymLink (const char* const dir, FDirEntry& entry) const
|
|||
return; // No symbolic link
|
||||
|
||||
std::array<char, MAXPATHLEN> resolved_path{};
|
||||
std::string symLink{};
|
||||
symLink.reserve(MAXPATHLEN);
|
||||
std::array<char, MAXPATHLEN> symLink{};
|
||||
struct stat sb{};
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
symLink = dir + entry.name;
|
||||
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
std::strncpy (symLink.data(), dir, symLink.size() - 1);
|
||||
symLink[symLink.size() - 1] = '\0';
|
||||
std::strncat ( symLink.data()
|
||||
, entry.name.c_str()
|
||||
, symLink.size() - std::strlen(symLink.data()) - 1);
|
||||
symLink[symLink.size() - 1] = '\0';
|
||||
|
||||
if ( fsystem->realpath(symLink.data(), resolved_path.data()) == nullptr )
|
||||
return; // Cannot follow the symlink
|
||||
|
@ -682,7 +691,7 @@ FString FFileDialog::getHomeDir()
|
|||
struct passwd* pwd_ptr{};
|
||||
std::array<char, 1024> buf{};
|
||||
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
const uid_t euid = fsystem->geteuid();
|
||||
|
||||
if ( fsystem->getpwuid_r(euid, &pwd, buf.data(), buf.size(), &pwd_ptr) )
|
||||
|
@ -726,7 +735,7 @@ void FFileDialog::cb_processActivate()
|
|||
{
|
||||
return ! entry.name.empty()
|
||||
&& input
|
||||
&& ! input.isEmpty()
|
||||
&& ! input.isNull()
|
||||
&& std::strcmp(entry.name.c_str(), input.c_str()) == 0
|
||||
&& entry.directory;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2018-2021 Markus Gans *
|
||||
* Copyright 2018-2020 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -28,33 +28,10 @@
|
|||
namespace finalcut
|
||||
{
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
auto FKeyMap::getInstance() -> FKeyMap&
|
||||
namespace fc
|
||||
{
|
||||
static const auto& key_map = make_unique<FKeyMap>();
|
||||
return *key_map;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FKeyMap::KeyCapMapType& FKeyMap::getKeyCapMap()
|
||||
{
|
||||
return fkey_cap_table;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const FKeyMap::KeyMapType& FKeyMap::getKeyMap()
|
||||
{
|
||||
return fkey_table;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const FKeyMap::KeyNameType& FKeyMap::getKeyName()
|
||||
{
|
||||
return fkeyname;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FKeyMap::KeyCapMapType FKeyMap::fkey_cap_table
|
||||
std::array<FKeyCapMap, 188> fkey_cap_table
|
||||
{{
|
||||
{ FKey::Backspace , nullptr, "kb" }, // Backspace key
|
||||
{ FKey::Clear_all_tabs , nullptr, "ka" }, // Clear-all-tabs key
|
||||
|
@ -251,8 +228,7 @@ FKeyMap::KeyCapMapType FKeyMap::fkey_cap_table
|
|||
{ FKey::Lower_right , ESC "Os", "K5x"} // Keypad Lower right
|
||||
}};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
constexpr FKeyMap::KeyMapType FKeyMap::fkey_table =
|
||||
constexpr std::array<FKeyMap, 232> fkey_table =
|
||||
{{
|
||||
{ FKey::Meta_insert , "\033[2;3~" }, // M-Insert
|
||||
{ FKey::Meta_insert , "\033\033[2~" }, // M-Insert
|
||||
|
@ -488,8 +464,7 @@ constexpr FKeyMap::KeyMapType FKeyMap::fkey_table =
|
|||
{ FKey::Meta_tilde , "\033~" } // M-~
|
||||
}};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
constexpr FKeyMap::KeyNameType FKeyMap::fkeyname =
|
||||
constexpr std::array<FKeyName, 388> fkeyname =
|
||||
{{
|
||||
{ FKey::Ctrl_a , "Ctrl+A" },
|
||||
{ FKey::Ctrl_b , "Ctrl+B" },
|
||||
|
@ -881,4 +856,6 @@ constexpr FKeyMap::KeyNameType FKeyMap::fkeyname =
|
|||
{ FKey::Incomplete , "incomplete key string" }
|
||||
}};
|
||||
|
||||
} // namespace fc
|
||||
|
||||
} // namespace finalcut
|
||||
|
|
|
@ -51,7 +51,7 @@ uInt64 FKeyboard::key_timeout{100000}; // 100 ms (10 Hz)
|
|||
uInt64 FKeyboard::read_blocking_time{100000}; // 100 ms (10 Hz)
|
||||
uInt64 FKeyboard::read_blocking_time_short{5000}; // 5 ms (200 Hz)
|
||||
bool FKeyboard::non_blocking_input_support{true};
|
||||
TimeValue FKeyboard::time_keypressed{};
|
||||
struct timeval FKeyboard::time_keypressed{};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -63,7 +63,8 @@ TimeValue FKeyboard::time_keypressed{};
|
|||
FKeyboard::FKeyboard()
|
||||
{
|
||||
// Initialize keyboard values
|
||||
time_keypressed = TimeValue{}; // Set to epoch time
|
||||
time_keypressed.tv_sec = 0;
|
||||
time_keypressed.tv_usec = 0;
|
||||
|
||||
// Get the stdin file status flags
|
||||
stdin_status_flags = fcntl(FTermios::getStdIn(), F_GETFL);
|
||||
|
@ -74,13 +75,6 @@ FKeyboard::FKeyboard()
|
|||
|
||||
|
||||
// public methods of FKeyboard
|
||||
//----------------------------------------------------------------------
|
||||
auto FKeyboard::getInstance() -> FKeyboard&
|
||||
{
|
||||
static const auto& keyboard = make_unique<FKeyboard>();
|
||||
return *keyboard;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FKeyboard::fetchKeyCode()
|
||||
{
|
||||
|
@ -91,18 +85,17 @@ void FKeyboard::fetchKeyCode()
|
|||
//----------------------------------------------------------------------
|
||||
FString FKeyboard::getKeyName (const FKey keynum) const
|
||||
{
|
||||
const auto& fkeyname = FKeyMap::getKeyName();
|
||||
const auto& found_key = std::find_if
|
||||
(
|
||||
fkeyname.cbegin(),
|
||||
fkeyname.cend(),
|
||||
[&keynum] (const FKeyMap::KeyName& kn)
|
||||
fc::fkeyname.cbegin(),
|
||||
fc::fkeyname.cend(),
|
||||
[&keynum] (const fc::FKeyName& kn)
|
||||
{
|
||||
return ( kn.num != FKey::None && kn.num == keynum );
|
||||
}
|
||||
);
|
||||
|
||||
if ( found_key != fkeyname.end() )
|
||||
if ( found_key != fc::fkeyname.end() )
|
||||
return {found_key->string};
|
||||
|
||||
if ( keynum > 32 && keynum < 127 )
|
||||
|
@ -256,7 +249,7 @@ inline FKey FKeyboard::getMouseProtocolKey() const
|
|||
if ( ! mouse_support )
|
||||
return NOT_SET;
|
||||
|
||||
const std::size_t buf_len = stringLength(fifo_buf);
|
||||
const std::size_t buf_len = std::strlen(fifo_buf);
|
||||
|
||||
// x11 mouse tracking
|
||||
if ( buf_len >= 6 && fifo_buf[1] == '[' && fifo_buf[2] == 'M' )
|
||||
|
@ -289,7 +282,7 @@ inline FKey FKeyboard::getTermcapKey()
|
|||
for (auto&& entry : *key_map)
|
||||
{
|
||||
const char* kstr = entry.string;
|
||||
const std::size_t len = kstr ? stringLength(kstr) : 0;
|
||||
const std::size_t len = kstr ? std::strlen(kstr) : 0;
|
||||
|
||||
if ( kstr && std::strncmp(kstr, fifo_buf, len) == 0 ) // found
|
||||
{
|
||||
|
@ -316,10 +309,10 @@ inline FKey FKeyboard::getKnownKey()
|
|||
|
||||
assert ( FIFO_BUF_SIZE > 0 );
|
||||
|
||||
for (auto&& entry : FKeyMap::getKeyMap())
|
||||
for (auto&& entry : fc::fkey_table)
|
||||
{
|
||||
const char* kstr = entry.string; // The string is never null
|
||||
const std::size_t len = stringLength(kstr);
|
||||
const std::size_t len = std::strlen(kstr);
|
||||
|
||||
if ( std::strncmp(kstr, fifo_buf, len) == 0 ) // found
|
||||
{
|
||||
|
@ -362,7 +355,7 @@ inline FKey FKeyboard::getSingleKey()
|
|||
if ( utf8_input && (firstchar & 0xc0) == 0xc0 )
|
||||
{
|
||||
std::array<char, 5> utf8char{}; // Init array with '\0'
|
||||
const std::size_t buf_len = stringLength(fifo_buf);
|
||||
const std::size_t buf_len = std::strlen(fifo_buf);
|
||||
|
||||
if ( (firstchar & 0xe0) == 0xc0 )
|
||||
len = 2;
|
||||
|
@ -399,22 +392,22 @@ inline FKey FKeyboard::getSingleKey()
|
|||
//----------------------------------------------------------------------
|
||||
inline bool FKeyboard::isKeypressTimeout()
|
||||
{
|
||||
return FObject::isTimeout (time_keypressed, key_timeout);
|
||||
return FObject::isTimeout (&time_keypressed, key_timeout);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FKey FKeyboard::UTF8decode (const std::string& utf8) const
|
||||
FKey FKeyboard::UTF8decode (const char utf8[]) const
|
||||
{
|
||||
using distance_type = std::string::difference_type;
|
||||
FKey ucs{FKey::None}; // Universal coded character
|
||||
constexpr std::size_t max = 4;
|
||||
const auto len = utf8.length();
|
||||
auto end = utf8.begin()
|
||||
+ static_cast<distance_type>(std::min(len, max));
|
||||
std::size_t len = std::strlen(utf8);
|
||||
|
||||
for (auto iter{utf8.begin()}; iter < end; ++iter)
|
||||
if ( len > max )
|
||||
len = max;
|
||||
|
||||
for (std::size_t i{0}; i < len; ++i)
|
||||
{
|
||||
const auto ch = uChar(*iter);
|
||||
const auto ch = uChar(utf8[i]);
|
||||
|
||||
if ( (ch & 0xc0) == 0x80 )
|
||||
{
|
||||
|
@ -464,7 +457,7 @@ inline ssize_t FKeyboard::readKey()
|
|||
void FKeyboard::parseKeyBuffer()
|
||||
{
|
||||
ssize_t bytesread{};
|
||||
time_keypressed = FObject::getCurrentTime();
|
||||
FObject::getCurrentTime (&time_keypressed);
|
||||
|
||||
while ( (bytesread = readKey()) > 0 )
|
||||
{
|
||||
|
@ -489,14 +482,14 @@ void FKeyboard::parseKeyBuffer()
|
|||
{
|
||||
key = fkey;
|
||||
mouseTracking();
|
||||
fifo_offset = int(stringLength(fifo_buf));
|
||||
fifo_offset = int(std::strlen(fifo_buf));
|
||||
break;
|
||||
}
|
||||
|
||||
if ( fkey != FKey::Incomplete )
|
||||
{
|
||||
fkey_queue.push(fkey);
|
||||
fifo_offset = int(stringLength(fifo_buf));
|
||||
fifo_offset = int(std::strlen(fifo_buf));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -544,7 +537,7 @@ FKey FKeyboard::keyCorrection (const FKey& keycode) const
|
|||
#if defined(__linux__)
|
||||
if ( FTerm::isLinuxTerm() )
|
||||
{
|
||||
auto& linux_console = FTermLinux::getInstance();
|
||||
auto& linux_console = FTerm::getFTermLinux();
|
||||
key_correction = linux_console.modifierKeyCorrection(keycode);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -141,7 +141,7 @@ bool FLabel::setEnable (bool enable)
|
|||
void FLabel::setText (const FString& txt)
|
||||
{
|
||||
text.setString(txt);
|
||||
multiline_text = text.split("\n");
|
||||
multiline_text = text.split("\r\n");
|
||||
|
||||
if ( int(multiline_text.size()) > 1 )
|
||||
multiline = true;
|
||||
|
|
|
@ -749,7 +749,7 @@ void FListBox::drawScrollbars() const
|
|||
//----------------------------------------------------------------------
|
||||
void FListBox::drawHeadline()
|
||||
{
|
||||
if ( text.isEmpty() )
|
||||
if ( text.isNull() || text.isEmpty() )
|
||||
return;
|
||||
|
||||
const FString txt{" " + text + " "};
|
||||
|
@ -1678,7 +1678,7 @@ void FListBox::changeOnResize() const
|
|||
//----------------------------------------------------------------------
|
||||
void FListBox::lazyConvert(FListBoxItems::iterator iter, std::size_t y)
|
||||
{
|
||||
if ( conv_type != ConvertType::Lazy || ! iter->getText().isEmpty() )
|
||||
if ( conv_type != ConvertType::Lazy || ! iter->getText().isNull() )
|
||||
return;
|
||||
|
||||
lazy_inserter (*iter, source_container, y + std::size_t(yoffset));
|
||||
|
|
|
@ -910,7 +910,6 @@ void FListView::clear()
|
|||
{
|
||||
itemlist.clear();
|
||||
current_iter = getNullIterator();
|
||||
mark_iter = getNullIterator();
|
||||
first_visible_line = getNullIterator();
|
||||
last_visible_line = getNullIterator();
|
||||
recalculateVerticalBar (0);
|
||||
|
@ -1428,60 +1427,6 @@ inline void FListView::mapKeyFunctions()
|
|||
key_map_result[FKey('-')] = [this] { return collapseSubtree(); };
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::vector<int> FListView::getmultimark()
|
||||
{
|
||||
std::vector<int> list;
|
||||
for(FListViewIterator item: multi)
|
||||
list.push_back(item.getPosition());
|
||||
return list;
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
void FListView::setmultimark(std::vector<int> list)
|
||||
{
|
||||
multi.clear();
|
||||
for(int mark: list)
|
||||
{
|
||||
|
||||
FListViewIterator newiterator=itemlist.begin();
|
||||
newiterator+=mark;
|
||||
multi.push_back(newiterator);
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
void FListView::setindex(int index)
|
||||
{
|
||||
if (index<0)
|
||||
current_iter=getNullIterator();
|
||||
else
|
||||
{
|
||||
current_iter=itemlist.begin();
|
||||
current_iter+=index;
|
||||
}
|
||||
draw();
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
void FListView::setmark(int index)
|
||||
{
|
||||
if (index<0)
|
||||
current_iter=getNullIterator();
|
||||
else
|
||||
{
|
||||
mark_iter=itemlist.begin();
|
||||
mark_iter+=index;
|
||||
}
|
||||
draw();
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
int FListView::getmark()
|
||||
{
|
||||
return mark_iter.getPosition();
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
int FListView::getindex()
|
||||
{
|
||||
return current_iter.getPosition();
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
void FListView::processKeyAction (FKeyEvent* ev)
|
||||
{
|
||||
|
@ -1663,14 +1608,6 @@ void FListView::drawList()
|
|||
while ( iter != path_end && iter != itemlist_end && y < page_height )
|
||||
{
|
||||
const bool is_current_line( iter == current_iter );
|
||||
const bool is_current_mark( iter == mark_iter );
|
||||
bool is_current_selected=false;
|
||||
for(FListViewIterator item: multi)
|
||||
if (item==iter)
|
||||
{
|
||||
is_current_selected=true;
|
||||
break;
|
||||
}
|
||||
const auto& item = static_cast<FListViewItem*>(*iter);
|
||||
const int tree_offset = tree_view ? int(item->getDepth() << 1) + 1 : 0;
|
||||
const int checkbox_offset = item->isCheckable() ? 1 : 0;
|
||||
|
@ -1678,7 +1615,7 @@ void FListView::drawList()
|
|||
print() << FPoint{2, 2 + int(y)};
|
||||
|
||||
// Draw one FListViewItem
|
||||
drawListLine (item, getFlags().focus, is_current_line, is_current_mark, is_current_selected);
|
||||
drawListLine (item, getFlags().focus, is_current_line);
|
||||
|
||||
if ( getFlags().focus && is_current_line )
|
||||
{
|
||||
|
@ -1714,10 +1651,10 @@ void FListView::drawList()
|
|||
//----------------------------------------------------------------------
|
||||
void FListView::drawListLine ( const FListViewItem* item
|
||||
, bool is_focus
|
||||
, bool is_current, bool is_mark, bool is_selected )
|
||||
, bool is_current )
|
||||
{
|
||||
// Set line color and attributes
|
||||
setLineAttributes (is_current, is_focus, is_mark, is_selected);
|
||||
setLineAttributes (is_current, is_focus);
|
||||
|
||||
// Print the entry
|
||||
const std::size_t indent = item->getDepth() << 1; // indent = 2 * depth
|
||||
|
@ -1821,13 +1758,12 @@ void FListView::clearList()
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FListView::setLineAttributes ( bool is_current
|
||||
, bool is_focus, bool is_mark, bool is_selected ) const
|
||||
, bool is_focus ) const
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
setColor (wc->list_fg, wc->list_bg);
|
||||
if ( is_mark )
|
||||
setColor ( FColor::White, FColor::Red );
|
||||
else if ( is_current )
|
||||
|
||||
if ( is_current )
|
||||
{
|
||||
if ( is_focus && FTerm::getMaxColor() < 16 )
|
||||
setBold();
|
||||
|
@ -1847,8 +1783,6 @@ inline void FListView::setLineAttributes ( bool is_current
|
|||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
}
|
||||
else if ( is_selected )
|
||||
setColor ( FColor::White , FColor::Green );
|
||||
else
|
||||
{
|
||||
if ( FTerm::isMonochron() )
|
||||
|
|
|
@ -281,7 +281,7 @@ void FMessageBox::calculateDimensions()
|
|||
if ( text_num_lines == 0 )
|
||||
return;
|
||||
|
||||
if ( ! headline_text.isEmpty() )
|
||||
if ( ! headline_text.isNull() )
|
||||
headline_height = 2;
|
||||
|
||||
for (auto&& line : text_components)
|
||||
|
|
|
@ -196,37 +196,37 @@ FString FMouse::getClassName() const
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouse::clearEvent()
|
||||
inline void FMouse::clearEvent()
|
||||
{
|
||||
mouse_event_occurred = false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouse::setMaxWidth (uInt16 x_max)
|
||||
inline void FMouse::setMaxWidth (uInt16 x_max)
|
||||
{
|
||||
max_width = x_max;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouse::setMaxHeight (uInt16 y_max)
|
||||
inline void FMouse::setMaxHeight (uInt16 y_max)
|
||||
{
|
||||
max_height = y_max;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouse::setDblclickInterval (const uInt64 timeout)
|
||||
inline void FMouse::setDblclickInterval (const uInt64 timeout)
|
||||
{
|
||||
dblclick_interval = timeout;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouse::hasEvent() const
|
||||
inline bool FMouse::hasEvent() const
|
||||
{
|
||||
return mouse_event_occurred;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouse::hasUnprocessedInput() const
|
||||
inline bool FMouse::hasUnprocessedInput() const
|
||||
{
|
||||
return unprocessed_buffer_data;
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ bool FMouse::hasUnprocessedInput() const
|
|||
|
||||
// protected methods of FMouse
|
||||
//----------------------------------------------------------------------
|
||||
const FPoint& FMouse::getNewPos() const
|
||||
inline const FPoint& FMouse::getNewPos() const
|
||||
{
|
||||
return new_mouse_position;
|
||||
}
|
||||
|
@ -258,9 +258,9 @@ uInt64 FMouse::getDblclickInterval() const
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
TimeValue FMouse::getMousePressedTime() const
|
||||
timeval* FMouse::getMousePressedTime()
|
||||
{
|
||||
return time_mousepressed;
|
||||
return &time_mousepressed;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -276,15 +276,16 @@ void FMouse::setPending (bool is_pending)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouse::setMousePressedTime (const TimeValue& time)
|
||||
void FMouse::setMousePressedTime (const timeval* time)
|
||||
{
|
||||
time_mousepressed = time;
|
||||
time_mousepressed = *time;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouse::resetMousePressedTime()
|
||||
{
|
||||
time_mousepressed = TimeValue{}; // Set to epoch time
|
||||
time_mousepressed.tv_sec = 0;
|
||||
time_mousepressed.tv_usec = 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -294,7 +295,7 @@ void FMouse::setEvent()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouse::isDblclickTimeout (const TimeValue& time) const
|
||||
bool FMouse::isDblclickTimeout (const timeval* time) const
|
||||
{
|
||||
return FObject::isTimeout (time, dblclick_interval);
|
||||
}
|
||||
|
@ -340,7 +341,7 @@ void FMouseGPM::setRawData (FKeyboard::keybuffer&)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouseGPM::processEvent (const TimeValue&)
|
||||
void FMouseGPM::processEvent (struct timeval*)
|
||||
{
|
||||
clearButtonState();
|
||||
|
||||
|
@ -581,7 +582,7 @@ void FMouseX11::setRawData (FKeyboard::keybuffer& fifo_buf)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouseX11::processEvent (const TimeValue& time)
|
||||
void FMouseX11::processEvent (struct timeval* time)
|
||||
{
|
||||
// Parse and interpret the X11 xterm mouse string
|
||||
|
||||
|
@ -640,7 +641,7 @@ void FMouseX11::setMoveState (const FPoint& mouse_position, int btn)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouseX11::setButtonState (const int btn, const TimeValue& time)
|
||||
void FMouseX11::setButtonState (const int btn, const struct timeval* time)
|
||||
{
|
||||
// Get the x11 mouse button state
|
||||
|
||||
|
@ -738,7 +739,7 @@ void FMouseSGR::setRawData (FKeyboard::keybuffer& fifo_buf)
|
|||
// Import the X11 xterm mouse protocol (SGR-Mode) raw mouse data
|
||||
|
||||
const std::size_t fifo_buf_size = sizeof(fifo_buf);
|
||||
std::size_t len = stringLength(fifo_buf);
|
||||
std::size_t len = std::strlen(fifo_buf);
|
||||
std::size_t n{3};
|
||||
|
||||
while ( n < len && n <= MOUSE_BUF_SIZE + 1 )
|
||||
|
@ -764,7 +765,7 @@ void FMouseSGR::setRawData (FKeyboard::keybuffer& fifo_buf)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouseSGR::processEvent (const TimeValue& time)
|
||||
void FMouseSGR::processEvent (struct timeval* time)
|
||||
{
|
||||
const auto& mouse_position = getPos();
|
||||
uInt16 x{0};
|
||||
|
@ -866,7 +867,7 @@ void FMouseSGR::setMoveState (const FPoint& mouse_position, int btn)
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouseSGR::setPressedButtonState ( const int btn
|
||||
, const TimeValue& time )
|
||||
, const struct timeval* time )
|
||||
{
|
||||
// Gets the extended x11 mouse mode (SGR) status for pressed buttons
|
||||
|
||||
|
@ -968,7 +969,7 @@ void FMouseUrxvt::setRawData (FKeyboard::keybuffer& fifo_buf)
|
|||
// Import the X11 xterm mouse protocol (Urxvt-Mode) raw mouse data
|
||||
|
||||
const std::size_t fifo_buf_size = sizeof(fifo_buf);
|
||||
std::size_t len = stringLength(fifo_buf);
|
||||
std::size_t len = std::strlen(fifo_buf);
|
||||
std::size_t n{2};
|
||||
|
||||
while ( n < len && n <= MOUSE_BUF_SIZE )
|
||||
|
@ -994,7 +995,7 @@ void FMouseUrxvt::setRawData (FKeyboard::keybuffer& fifo_buf)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouseUrxvt::processEvent (const TimeValue& time)
|
||||
void FMouseUrxvt::processEvent (struct timeval* time)
|
||||
{
|
||||
// Parse and interpret the X11 xterm mouse string (Urxvt-Mode)
|
||||
|
||||
|
@ -1121,7 +1122,7 @@ void FMouseUrxvt::setMoveState (const FPoint& mouse_position, int btn)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouseUrxvt::setButtonState (const int btn, const TimeValue& time)
|
||||
void FMouseUrxvt::setButtonState (const int btn, const struct timeval* time)
|
||||
{
|
||||
// Get the urxvt mouse button state
|
||||
|
||||
|
@ -1204,16 +1205,14 @@ void FMouseUrxvt::setButtonState (const int btn, const TimeValue& time)
|
|||
//----------------------------------------------------------------------
|
||||
FMouseControl::FMouseControl()
|
||||
{
|
||||
using mt = FMouse::MouseType;
|
||||
|
||||
#ifdef F_HAVE_LIBGPM
|
||||
if ( FTermLinux::isLinuxConsole() )
|
||||
mouse_protocol[mt::Gpm].reset(FMouse::createMouseObject<FMouseGPM>());
|
||||
mouse_protocol[FMouse::MouseType::Gpm].reset(FMouse::createMouseObject<FMouseGPM>());
|
||||
#endif
|
||||
|
||||
mouse_protocol[mt::X11].reset(FMouse::createMouseObject<FMouseX11>());
|
||||
mouse_protocol[mt::Sgr].reset(FMouse::createMouseObject<FMouseSGR>());
|
||||
mouse_protocol[mt::Urxvt].reset(FMouse::createMouseObject<FMouseUrxvt>());
|
||||
mouse_protocol[FMouse::MouseType::X11].reset(FMouse::createMouseObject<FMouseX11>());
|
||||
mouse_protocol[FMouse::MouseType::Sgr].reset(FMouse::createMouseObject<FMouseSGR>());
|
||||
mouse_protocol[FMouse::MouseType::Urxvt].reset(FMouse::createMouseObject<FMouseUrxvt>());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -1221,13 +1220,6 @@ FMouseControl::~FMouseControl() = default; // destructor
|
|||
|
||||
|
||||
// public methods of FMouseControl
|
||||
//----------------------------------------------------------------------
|
||||
auto FMouseControl::getInstance() -> FMouseControl&
|
||||
{
|
||||
static const auto& mouse = make_unique<FMouseControl>();
|
||||
return *mouse;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const FPoint& FMouseControl::getPos()
|
||||
{
|
||||
|
@ -1569,7 +1561,7 @@ void FMouseControl::processQueuedInput()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouseControl::processEvent (const TimeValue& time)
|
||||
void FMouseControl::processEvent (struct timeval* time)
|
||||
{
|
||||
auto mtype = getMouseWithData();
|
||||
auto mouse_object = mouse_protocol[mtype].get();
|
||||
|
|
104
src/fobject.cpp
104
src/fobject.cpp
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2015-2021 Markus Gans *
|
||||
* Copyright 2015-2020 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -21,7 +21,6 @@
|
|||
***********************************************************************/
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
#include "final/fevent.h"
|
||||
#include "final/fc.h"
|
||||
|
@ -30,17 +29,8 @@
|
|||
namespace finalcut
|
||||
{
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
struct var
|
||||
{
|
||||
static std::mutex timer_mutex;
|
||||
};
|
||||
|
||||
std::mutex var::timer_mutex{};
|
||||
|
||||
} // namespace internal
|
||||
// static class attributes
|
||||
bool FObject::timer_modify_lock;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -54,6 +44,8 @@ FObject::FObject (FObject* parent)
|
|||
{
|
||||
if ( parent ) // add object to parent
|
||||
parent->addChild(this);
|
||||
else
|
||||
timer_modify_lock = false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -187,24 +179,54 @@ bool FObject::event (FEvent* ev)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
TimeValue FObject::getCurrentTime()
|
||||
void FObject::getCurrentTime (timeval* time)
|
||||
{
|
||||
return system_clock::now(); // Get the current time
|
||||
// Get the current time as timeval struct
|
||||
|
||||
gettimeofday(time, nullptr);
|
||||
|
||||
// NTP fix
|
||||
while ( time->tv_usec >= 1000000 )
|
||||
{
|
||||
time->tv_usec -= 1000000;
|
||||
time->tv_sec++;
|
||||
}
|
||||
|
||||
while ( time->tv_usec < 0 )
|
||||
{
|
||||
if ( time->tv_sec > 0 )
|
||||
{
|
||||
time->tv_usec += 1000000;
|
||||
time->tv_sec--;
|
||||
}
|
||||
else
|
||||
{
|
||||
time->tv_usec = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FObject::isTimeout (const TimeValue& time, uInt64 timeout)
|
||||
bool FObject::isTimeout (const timeval* time, uInt64 timeout)
|
||||
{
|
||||
// Checks whether the specified time span (timeout in µs) has elapsed
|
||||
// Checks whether the specified time span (timeout in µs) has elapse
|
||||
|
||||
const auto now = getCurrentTime();
|
||||
struct timeval now{};
|
||||
struct timeval diff{};
|
||||
|
||||
if ( now < time )
|
||||
return false;
|
||||
FObject::getCurrentTime(&now);
|
||||
diff.tv_sec = now.tv_sec - time->tv_sec;
|
||||
diff.tv_usec = now.tv_usec - time->tv_usec;
|
||||
|
||||
const auto diff = now - time;
|
||||
const auto diff_usec = uInt64(duration_cast<microseconds>(diff).count());
|
||||
return diff_usec > timeout;
|
||||
if ( diff.tv_usec < 0 )
|
||||
{
|
||||
diff.tv_sec--;
|
||||
diff.tv_usec += 1000000;
|
||||
}
|
||||
|
||||
const auto diff_usec = uInt64((diff.tv_sec * 1000000) + diff.tv_usec);
|
||||
return ( diff_usec > timeout );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -213,8 +235,10 @@ int FObject::addTimer (int interval)
|
|||
// Create a timer and returns the timer identifier number
|
||||
// (interval in ms)
|
||||
|
||||
timeval time_interval{};
|
||||
timeval currentTime{};
|
||||
int id{1};
|
||||
std::lock_guard<std::mutex> lock_guard(internal::var::timer_mutex);
|
||||
timer_modify_lock = true;
|
||||
auto& timer_list = globalTimerList();
|
||||
|
||||
// find an unused timer id
|
||||
|
@ -238,8 +262,10 @@ int FObject::addTimer (int interval)
|
|||
if ( id <= 0 || id > int(timer_list->size() + 1) )
|
||||
return 0;
|
||||
|
||||
const auto time_interval = milliseconds(interval);
|
||||
const auto timeout = getCurrentTime() + time_interval;
|
||||
time_interval.tv_sec = interval / 1000;
|
||||
time_interval.tv_usec = (interval % 1000) * 1000;
|
||||
getCurrentTime (¤tTime);
|
||||
timeval timeout = currentTime + time_interval;
|
||||
FTimerData t{ id, time_interval, timeout, this };
|
||||
|
||||
// insert in list sorted by timeout
|
||||
|
@ -250,6 +276,7 @@ int FObject::addTimer (int interval)
|
|||
++iter;
|
||||
|
||||
timer_list->insert (iter, t);
|
||||
timer_modify_lock = false;
|
||||
return id;
|
||||
}
|
||||
|
||||
|
@ -261,7 +288,7 @@ bool FObject::delTimer (int id) const
|
|||
if ( id <= 0 )
|
||||
return false;
|
||||
|
||||
std::lock_guard<std::mutex> lock_guard(internal::var::timer_mutex);
|
||||
timer_modify_lock = true;
|
||||
auto& timer_list = globalTimerList();
|
||||
auto iter = timer_list->begin();
|
||||
const auto& last = timer_list->end();
|
||||
|
@ -272,9 +299,11 @@ bool FObject::delTimer (int id) const
|
|||
if ( iter != last )
|
||||
{
|
||||
timer_list->erase(iter);
|
||||
timer_modify_lock = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
timer_modify_lock = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -283,7 +312,6 @@ bool FObject::delOwnTimers() const
|
|||
{
|
||||
// Deletes all timers of this object
|
||||
|
||||
std::lock_guard<std::mutex> lock_guard(internal::var::timer_mutex);
|
||||
auto& timer_list = globalTimerList();
|
||||
|
||||
if ( ! timer_list )
|
||||
|
@ -292,6 +320,7 @@ bool FObject::delOwnTimers() const
|
|||
if ( timer_list->empty() )
|
||||
return false;
|
||||
|
||||
timer_modify_lock = true;
|
||||
auto iter = timer_list->begin();
|
||||
|
||||
while ( iter != timer_list->end() )
|
||||
|
@ -302,6 +331,7 @@ bool FObject::delOwnTimers() const
|
|||
++iter;
|
||||
}
|
||||
|
||||
timer_modify_lock = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -310,7 +340,6 @@ bool FObject::delAllTimers() const
|
|||
{
|
||||
// Deletes all timers of all objects
|
||||
|
||||
std::lock_guard<std::mutex> lock_guard(internal::var::timer_mutex);
|
||||
auto& timer_list = globalTimerList();
|
||||
|
||||
if ( ! timer_list )
|
||||
|
@ -319,8 +348,10 @@ bool FObject::delAllTimers() const
|
|||
if ( timer_list->empty() )
|
||||
return false;
|
||||
|
||||
timer_modify_lock = true;
|
||||
timer_list->clear();
|
||||
timer_list->shrink_to_fit();
|
||||
timer_modify_lock = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -343,17 +374,20 @@ void FObject::onUserEvent (FUserEvent*)
|
|||
//----------------------------------------------------------------------
|
||||
uInt FObject::processTimerEvent()
|
||||
{
|
||||
timeval currentTime{};
|
||||
uInt activated{0};
|
||||
std::unique_lock<std::mutex> unique_lock( internal::var::timer_mutex
|
||||
, std::defer_lock );
|
||||
|
||||
if ( ! unique_lock.try_lock() )
|
||||
getCurrentTime (¤tTime);
|
||||
|
||||
if ( isTimerInUpdating() )
|
||||
return 0;
|
||||
|
||||
auto currentTime = getCurrentTime();
|
||||
auto& timer_list = globalTimerList();
|
||||
|
||||
if ( ! timer_list || timer_list->empty() )
|
||||
if ( ! timer_list )
|
||||
return 0;
|
||||
|
||||
if ( timer_list->empty() )
|
||||
return 0;
|
||||
|
||||
for (auto&& timer : *timer_list)
|
||||
|
@ -368,7 +402,7 @@ uInt FObject::processTimerEvent()
|
|||
if ( timer.timeout < currentTime )
|
||||
timer.timeout = currentTime + timer.interval;
|
||||
|
||||
if ( timer.interval > microseconds(0) )
|
||||
if ( timer.interval.tv_usec > 0 || timer.interval.tv_sec > 0 )
|
||||
activated++;
|
||||
|
||||
FTimerEvent t_ev(Event::Timer, timer.id);
|
||||
|
|
|
@ -39,8 +39,6 @@ namespace finalcut
|
|||
//----------------------------------------------------------------------
|
||||
FOptiAttr::FOptiAttr()
|
||||
{
|
||||
attr_buf.reserve(SGRoptimizer::ATTR_BUF_SIZE);
|
||||
|
||||
// Set bits that must not be reset
|
||||
reset_byte_mask.attr.bit.transparent = true;
|
||||
reset_byte_mask.attr.bit.color_overlay = true;
|
||||
|
@ -51,13 +49,6 @@ FOptiAttr::FOptiAttr()
|
|||
|
||||
|
||||
// public methods of FOptiAttr
|
||||
//----------------------------------------------------------------------
|
||||
auto FOptiAttr::getInstance() -> FOptiAttr&
|
||||
{
|
||||
static const auto& opti_attr = make_unique<FOptiAttr>();
|
||||
return *opti_attr;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FOptiAttr::setTermEnvironment (const TermEnv& term_env)
|
||||
{
|
||||
|
@ -552,11 +543,11 @@ FColor FOptiAttr::vga2ansi (FColor color)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::string FOptiAttr::changeAttribute (FChar& term, FChar& next)
|
||||
const char* FOptiAttr::changeAttribute (FChar& term, FChar& next)
|
||||
{
|
||||
const bool next_has_color = hasColor(next);
|
||||
fake_reverse = false;
|
||||
attr_buf.clear();
|
||||
attr_buf[0] = '\0';
|
||||
prevent_no_color_video_attributes (term, next_has_color);
|
||||
prevent_no_color_video_attributes (next);
|
||||
detectSwitchOn (term, next);
|
||||
|
@ -568,7 +559,7 @@ std::string FOptiAttr::changeAttribute (FChar& term, FChar& next)
|
|||
|
||||
// Look for no changes
|
||||
if ( ! (switchOn() || switchOff() || hasColorChanged(term, next)) )
|
||||
return {};
|
||||
return nullptr;
|
||||
|
||||
if ( hasNoAttribute(next) )
|
||||
{
|
||||
|
@ -584,10 +575,10 @@ std::string FOptiAttr::changeAttribute (FChar& term, FChar& next)
|
|||
changeAttributeSeparately (term, next);
|
||||
}
|
||||
|
||||
if ( FStartOptions::getInstance().sgr_optimizer )
|
||||
if ( FStartOptions::getFStartOptions().sgr_optimizer )
|
||||
sgr_optimizer.optimize();
|
||||
|
||||
return attr_buf;
|
||||
return attr_buf.data();
|
||||
}
|
||||
|
||||
|
||||
|
@ -888,31 +879,34 @@ inline bool FOptiAttr::unsetTermDoubleUnderline (FChar& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FOptiAttr::setTermAttributes (FChar& term, const TCapAttributes& attr)
|
||||
bool FOptiAttr::setTermAttributes ( FChar& term
|
||||
, bool p1, bool p2, bool p3
|
||||
, bool p4, bool p5, bool p6
|
||||
, bool p7, bool p8, bool p9 )
|
||||
{
|
||||
if ( F_set_attributes.cap )
|
||||
{
|
||||
const auto sgr = FTermcap::encodeParameter ( F_set_attributes.cap
|
||||
, attr.p1 && ! fake_reverse
|
||||
, attr.p2
|
||||
, attr.p3 && ! fake_reverse
|
||||
, attr.p4
|
||||
, attr.p5
|
||||
, attr.p6
|
||||
, attr.p7
|
||||
, attr.p8
|
||||
, attr.p9 );
|
||||
, p1 && ! fake_reverse
|
||||
, p2
|
||||
, p3 && ! fake_reverse
|
||||
, p4
|
||||
, p5
|
||||
, p6
|
||||
, p7
|
||||
, p8
|
||||
, p9 );
|
||||
append_sequence (sgr.data());
|
||||
resetColor(term);
|
||||
term.attr.bit.standout = attr.p1;
|
||||
term.attr.bit.underline = attr.p2;
|
||||
term.attr.bit.reverse = attr.p3;
|
||||
term.attr.bit.blink = attr.p4;
|
||||
term.attr.bit.dim = attr.p5;
|
||||
term.attr.bit.bold = attr.p6;
|
||||
term.attr.bit.invisible = attr.p7;
|
||||
term.attr.bit.protect = attr.p8;
|
||||
term.attr.bit.alt_charset = attr.p9;
|
||||
term.attr.bit.standout = p1;
|
||||
term.attr.bit.underline = p2;
|
||||
term.attr.bit.reverse = p3;
|
||||
term.attr.bit.blink = p4;
|
||||
term.attr.bit.dim = p5;
|
||||
term.attr.bit.bold = p6;
|
||||
term.attr.bit.invisible = p7;
|
||||
term.attr.bit.protect = p8;
|
||||
term.attr.bit.alt_charset = p9;
|
||||
term.attr.bit.pc_charset = false;
|
||||
term.attr.bit.italic = false;
|
||||
term.attr.bit.crossed_out = false;
|
||||
|
@ -1240,7 +1234,7 @@ inline void FOptiAttr::changeAttributeSGR (FChar& term, FChar& next)
|
|||
|
||||
if ( switchOn() || switchOff() )
|
||||
setTermAttributes ( term
|
||||
, { next.attr.bit.standout
|
||||
, next.attr.bit.standout
|
||||
, next.attr.bit.underline
|
||||
, next.attr.bit.reverse
|
||||
, next.attr.bit.blink
|
||||
|
@ -1248,7 +1242,7 @@ inline void FOptiAttr::changeAttributeSGR (FChar& term, FChar& next)
|
|||
, next.attr.bit.bold
|
||||
, next.attr.bit.invisible
|
||||
, next.attr.bit.protect
|
||||
, next.attr.bit.alt_charset } );
|
||||
, next.attr.bit.alt_charset );
|
||||
|
||||
if ( alt_equal_pc_charset
|
||||
&& F_enter_pc_charset_mode.cap
|
||||
|
@ -1543,7 +1537,9 @@ inline bool FOptiAttr::append_sequence (const char seq[])
|
|||
if ( ! seq )
|
||||
return false;
|
||||
|
||||
attr_buf.append(seq);
|
||||
char* attr_ptr{attr_buf.data()};
|
||||
std::strncat (attr_ptr, seq, attr_buf.size() - std::strlen(attr_ptr));
|
||||
attr_buf[attr_buf.size() - 1] = '\0';
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@ FOptiMove::FOptiMove (int baud)
|
|||
{
|
||||
assert ( baud >= 0 );
|
||||
|
||||
move_buf.reserve(BUF_SIZE);
|
||||
calculateCharDuration();
|
||||
|
||||
// ANSI set cursor address preset for undefined terminals
|
||||
|
@ -55,13 +54,6 @@ FOptiMove::FOptiMove (int baud)
|
|||
|
||||
|
||||
// public methods of FOptiMove
|
||||
//----------------------------------------------------------------------
|
||||
auto FOptiMove::getInstance() -> FOptiMove&
|
||||
{
|
||||
static const auto& opti_move = make_unique<FOptiMove>();
|
||||
return *opti_move;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FOptiMove::setBaudRate (int baud)
|
||||
{
|
||||
|
@ -489,7 +481,7 @@ void FOptiMove::check_boundaries ( int& xold, int& yold
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::string FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew)
|
||||
const char* FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew)
|
||||
{
|
||||
int method{0};
|
||||
int move_time{LONG_DURATION};
|
||||
|
@ -502,7 +494,7 @@ std::string FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew)
|
|||
|| yold < 0
|
||||
|| isWideMove (xold, yold, xnew, ynew) ) )
|
||||
{
|
||||
return ( move_time < LONG_DURATION ) ? move_buf : std::string{};
|
||||
return ( move_time < LONG_DURATION ) ? move_buf : nullptr;
|
||||
}
|
||||
|
||||
// Method 1: local movement
|
||||
|
@ -531,7 +523,7 @@ std::string FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew)
|
|||
if ( move_time < LONG_DURATION )
|
||||
return move_buf;
|
||||
else
|
||||
return {};
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -611,23 +603,30 @@ int FOptiMove::capDurationToLength (int duration) const
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int FOptiMove::repeatedAppend ( std::string& dst
|
||||
, const Capability& o
|
||||
, int count ) const
|
||||
int FOptiMove::repeatedAppend ( const Capability& o
|
||||
, int count
|
||||
, char* dst ) const
|
||||
{
|
||||
const std::size_t src_len = stringLength(o.cap);
|
||||
const std::size_t dst_len = dst.length();
|
||||
const std::size_t src_len = std::strlen(o.cap);
|
||||
const std::size_t dst_len = ( dst != nullptr ) ? std::strlen(dst) : 0;
|
||||
int total{0};
|
||||
|
||||
if ( (dst_len + uInt(count) * src_len) < BUF_SIZE - 1 )
|
||||
{
|
||||
total += count * o.duration;
|
||||
|
||||
if ( dst )
|
||||
{
|
||||
dst += dst_len;
|
||||
std::size_t free = BUF_SIZE - dst_len - 2;
|
||||
int cnt = count;
|
||||
|
||||
while ( cnt > 0 )
|
||||
while ( cnt-- > 0 )
|
||||
{
|
||||
cnt--;
|
||||
dst.append(o.cap);
|
||||
std::strncpy (dst, o.cap, free);
|
||||
dst += src_len;
|
||||
free -= src_len;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -637,15 +636,15 @@ int FOptiMove::repeatedAppend ( std::string& dst
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int FOptiMove::relativeMove ( std::string& move
|
||||
int FOptiMove::relativeMove ( char move[]
|
||||
, int from_x, int from_y
|
||||
, int to_x, int to_y ) const
|
||||
{
|
||||
int vtime{0};
|
||||
int htime{0};
|
||||
|
||||
if ( ! move.empty() )
|
||||
move.clear();
|
||||
if ( move )
|
||||
move[0] = '\0';
|
||||
|
||||
if ( to_y != from_y ) // vertical move
|
||||
{
|
||||
|
@ -657,30 +656,41 @@ int FOptiMove::relativeMove ( std::string& move
|
|||
|
||||
if ( to_x != from_x ) // horizontal move
|
||||
{
|
||||
std::string hmove{};
|
||||
char hmove[BUF_SIZE]{};
|
||||
htime = horizontalMove (hmove, from_x, to_x);
|
||||
|
||||
if ( htime >= LONG_DURATION )
|
||||
return LONG_DURATION;
|
||||
|
||||
if ( ! move.empty() )
|
||||
move.append(hmove);
|
||||
if ( move )
|
||||
{
|
||||
if ( *move )
|
||||
std::strncat (move, hmove, BUF_SIZE - std::strlen(move));
|
||||
else
|
||||
move = hmove;
|
||||
std::strncpy (move, hmove, BUF_SIZE);
|
||||
|
||||
move[BUF_SIZE - 1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
return vtime + htime;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline int FOptiMove::verticalMove (std::string& move, int from_y, int to_y) const
|
||||
inline int FOptiMove::verticalMove (char move[], int from_y, int to_y) const
|
||||
{
|
||||
int vtime{LONG_DURATION};
|
||||
|
||||
if ( F_row_address.cap )
|
||||
{
|
||||
// Move to fixed row position
|
||||
move = FTermcap::encodeParameter(F_row_address.cap, to_y);
|
||||
if ( move )
|
||||
{
|
||||
std::strncpy ( move
|
||||
, FTermcap::encodeParameter(F_row_address.cap, to_y).data()
|
||||
, BUF_SIZE );
|
||||
move[BUF_SIZE - 1] = '\0';
|
||||
}
|
||||
|
||||
vtime = F_row_address.duration;
|
||||
}
|
||||
|
||||
|
@ -693,56 +703,73 @@ inline int FOptiMove::verticalMove (std::string& move, int from_y, int to_y) con
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FOptiMove::downMove ( std::string& move, int& vtime
|
||||
inline void FOptiMove::downMove ( char move[], int& vtime
|
||||
, int from_y, int to_y ) const
|
||||
{
|
||||
const int num = to_y - from_y;
|
||||
|
||||
if ( F_parm_down_cursor.cap && F_parm_down_cursor.duration < vtime )
|
||||
{
|
||||
move = FTermcap::encodeParameter(F_parm_down_cursor.cap, num);
|
||||
if ( move )
|
||||
{
|
||||
std::strncpy ( move
|
||||
, FTermcap::encodeParameter(F_parm_down_cursor.cap, num).data()
|
||||
, BUF_SIZE );
|
||||
move[BUF_SIZE - 1] = '\0';
|
||||
}
|
||||
|
||||
vtime = F_parm_down_cursor.duration;
|
||||
}
|
||||
|
||||
if ( F_cursor_down.cap && (num * F_cursor_down.duration < vtime) )
|
||||
{
|
||||
if ( ! move.empty() )
|
||||
move.clear();
|
||||
if ( move )
|
||||
move[0] = '\0';
|
||||
|
||||
vtime = repeatedAppend (move, F_cursor_down, num);
|
||||
vtime = repeatedAppend (F_cursor_down, num, move);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FOptiMove::upMove ( std::string& move, int& vtime
|
||||
inline void FOptiMove::upMove ( char move[], int& vtime
|
||||
, int from_y, int to_y ) const
|
||||
{
|
||||
const int num = from_y - to_y;
|
||||
|
||||
if ( F_parm_up_cursor.cap && F_parm_up_cursor.duration < vtime )
|
||||
{
|
||||
move = FTermcap::encodeParameter(F_parm_up_cursor.cap, num);
|
||||
if ( move )
|
||||
{
|
||||
std::strncpy ( move
|
||||
, FTermcap::encodeParameter(F_parm_up_cursor.cap, num).data()
|
||||
, BUF_SIZE );
|
||||
move[BUF_SIZE - 1] = '\0';
|
||||
}
|
||||
|
||||
vtime = F_parm_up_cursor.duration;
|
||||
}
|
||||
|
||||
if ( F_cursor_up.cap && (num * F_cursor_up.duration < vtime) )
|
||||
{
|
||||
if ( ! move.empty() )
|
||||
move.clear();
|
||||
if ( move )
|
||||
move[0] = '\0';
|
||||
|
||||
vtime = repeatedAppend (move, F_cursor_up, num);
|
||||
vtime = repeatedAppend (F_cursor_up, num, move);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline int FOptiMove::horizontalMove (std::string& hmove, int from_x, int to_x) const
|
||||
inline int FOptiMove::horizontalMove (char hmove[], int from_x, int to_x) const
|
||||
{
|
||||
int htime{LONG_DURATION};
|
||||
|
||||
if ( F_column_address.cap )
|
||||
{
|
||||
// Move to fixed column position
|
||||
hmove = FTermcap::encodeParameter(F_column_address.cap, to_x);
|
||||
// Move to fixed column position1
|
||||
std::strncat ( hmove
|
||||
, FTermcap::encodeParameter(F_column_address.cap, to_x).data()
|
||||
, BUF_SIZE - std::strlen(hmove) - 1 );
|
||||
hmove[BUF_SIZE - 1] = '\0';
|
||||
htime = F_column_address.duration;
|
||||
}
|
||||
|
||||
|
@ -755,21 +782,25 @@ inline int FOptiMove::horizontalMove (std::string& hmove, int from_x, int to_x)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FOptiMove::rightMove ( std::string& hmove, int& htime
|
||||
inline void FOptiMove::rightMove ( char hmove[], int& htime
|
||||
, int from_x, int to_x ) const
|
||||
{
|
||||
int num = to_x - from_x;
|
||||
|
||||
if ( F_parm_right_cursor.cap && F_parm_right_cursor.duration < htime )
|
||||
{
|
||||
hmove = FTermcap::encodeParameter(F_parm_right_cursor.cap, num);
|
||||
std::strncpy ( hmove
|
||||
, FTermcap::encodeParameter(F_parm_right_cursor.cap, num).data()
|
||||
, BUF_SIZE - 1);
|
||||
hmove[BUF_SIZE - 1] = '\0';
|
||||
htime = F_parm_right_cursor.duration;
|
||||
}
|
||||
|
||||
if ( F_cursor_right.cap )
|
||||
{
|
||||
std::string str{};
|
||||
std::array<char, BUF_SIZE> str{};
|
||||
int htime_r{0};
|
||||
str[0] = '\0';
|
||||
|
||||
// try to use tab
|
||||
if ( tabstop > 0 && F_tab.cap )
|
||||
|
@ -783,7 +814,7 @@ inline void FOptiMove::rightMove ( std::string& hmove, int& htime
|
|||
if ( tab_pos > to_x )
|
||||
break;
|
||||
|
||||
htime_r += repeatedAppend (str, F_tab, 1);
|
||||
htime_r += repeatedAppend (F_tab, 1, str.data());
|
||||
|
||||
if ( htime_r >= LONG_DURATION )
|
||||
break;
|
||||
|
@ -794,32 +825,37 @@ inline void FOptiMove::rightMove ( std::string& hmove, int& htime
|
|||
num = to_x - pos;
|
||||
}
|
||||
|
||||
htime_r += repeatedAppend (str, F_cursor_right, num);
|
||||
htime_r += repeatedAppend (F_cursor_right, num, str.data());
|
||||
|
||||
if ( htime_r < htime )
|
||||
{
|
||||
hmove = str;
|
||||
std::strncpy (hmove, str.data(), BUF_SIZE);
|
||||
hmove[BUF_SIZE - 1] = '\0';
|
||||
htime = htime_r;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FOptiMove::leftMove ( std::string& hmove, int& htime
|
||||
inline void FOptiMove::leftMove ( char hmove[], int& htime
|
||||
, int from_x, int to_x ) const
|
||||
{
|
||||
int num = from_x - to_x;
|
||||
|
||||
if ( F_parm_left_cursor.cap && F_parm_left_cursor.duration < htime )
|
||||
{
|
||||
hmove = FTermcap::encodeParameter(F_parm_left_cursor.cap, num);
|
||||
std::strncpy ( hmove
|
||||
, FTermcap::encodeParameter(F_parm_left_cursor.cap, num).data()
|
||||
, BUF_SIZE - 1);
|
||||
hmove[BUF_SIZE - 1] = '\0';
|
||||
htime = F_parm_left_cursor.duration;
|
||||
}
|
||||
|
||||
if ( F_cursor_left.cap )
|
||||
{
|
||||
std::string str{};
|
||||
std::array<char, BUF_SIZE> str{};
|
||||
int htime_l{0};
|
||||
str[0] = '\0';
|
||||
|
||||
// try to use backward tab
|
||||
if ( tabstop > 0 && F_back_tab.cap )
|
||||
|
@ -833,7 +869,7 @@ inline void FOptiMove::leftMove ( std::string& hmove, int& htime
|
|||
if ( tab_pos < to_x )
|
||||
break;
|
||||
|
||||
htime_l += repeatedAppend (str, F_back_tab, 1);
|
||||
htime_l += repeatedAppend (F_back_tab, 1, str.data());
|
||||
|
||||
if ( htime_l >= LONG_DURATION )
|
||||
break;
|
||||
|
@ -844,11 +880,12 @@ inline void FOptiMove::leftMove ( std::string& hmove, int& htime
|
|||
num = pos - to_x;
|
||||
}
|
||||
|
||||
htime_l += repeatedAppend (str, F_cursor_left, num);
|
||||
htime_l += repeatedAppend (F_cursor_left, num, str.data());
|
||||
|
||||
if ( htime_l < htime )
|
||||
{
|
||||
hmove = str;
|
||||
std::strncpy (hmove, str.data(), BUF_SIZE);
|
||||
hmove[BUF_SIZE - 1] = '\0';
|
||||
htime = htime_l;
|
||||
}
|
||||
}
|
||||
|
@ -877,7 +914,9 @@ inline bool FOptiMove::isMethod0Faster ( int& move_time
|
|||
|
||||
if ( ! move_xy.empty() )
|
||||
{
|
||||
move_buf = move_xy;
|
||||
std::strncpy ( static_cast<char*>(move_buf)
|
||||
, move_xy.data(), BUF_SIZE - 1 );
|
||||
move_buf[BUF_SIZE - 1] = '\0';
|
||||
move_time = F_cursor_address.duration;
|
||||
return true;
|
||||
}
|
||||
|
@ -894,8 +933,8 @@ inline bool FOptiMove::isMethod1Faster ( int& move_time
|
|||
|
||||
if ( xold >= 0 && yold >= 0 )
|
||||
{
|
||||
std::string null_result{};
|
||||
const int new_time = relativeMove (null_result, xold, yold, xnew, ynew);
|
||||
std::array<char, BUF_SIZE> null_result{};
|
||||
const int new_time = relativeMove (null_result.data(), xold, yold, xnew, ynew);
|
||||
|
||||
if ( new_time < LONG_DURATION && new_time < move_time )
|
||||
{
|
||||
|
@ -916,8 +955,8 @@ inline bool FOptiMove::isMethod2Faster ( int& move_time
|
|||
|
||||
if ( yold >= 0 && F_carriage_return.cap )
|
||||
{
|
||||
std::string null_result{};
|
||||
const int new_time = relativeMove (null_result, 0, yold, xnew, ynew);
|
||||
std::array<char, BUF_SIZE> null_result{};
|
||||
const int new_time = relativeMove (null_result.data(), 0, yold, xnew, ynew);
|
||||
|
||||
if ( new_time < LONG_DURATION
|
||||
&& F_carriage_return.duration + new_time < move_time )
|
||||
|
@ -938,8 +977,8 @@ inline bool FOptiMove::isMethod3Faster ( int& move_time
|
|||
|
||||
if ( F_cursor_home.cap )
|
||||
{
|
||||
std::string null_result{};
|
||||
const int new_time = relativeMove (null_result, 0, 0, xnew, ynew);
|
||||
std::array<char, BUF_SIZE> null_result{};
|
||||
const int new_time = relativeMove (null_result.data(), 0, 0, xnew, ynew);
|
||||
|
||||
if ( new_time < LONG_DURATION
|
||||
&& F_cursor_home.duration + new_time < move_time )
|
||||
|
@ -959,9 +998,10 @@ inline bool FOptiMove::isMethod4Faster ( int& move_time
|
|||
// Test method 4: home-down + local movement
|
||||
if ( F_cursor_to_ll.cap )
|
||||
{
|
||||
std::string null_result{};
|
||||
int down = int(screen_height) - 1;
|
||||
const int new_time = relativeMove (null_result, 0, down, xnew, ynew);
|
||||
std::array<char, BUF_SIZE> null_result{};
|
||||
const int new_time = relativeMove ( null_result.data()
|
||||
, 0, int(screen_height) - 1
|
||||
, xnew, ynew );
|
||||
|
||||
if ( new_time < LONG_DURATION
|
||||
&& F_cursor_to_ll.duration + new_time < move_time )
|
||||
|
@ -985,10 +1025,10 @@ inline bool FOptiMove::isMethod5Faster ( int& move_time
|
|||
&& yold > 0
|
||||
&& F_cursor_left.cap )
|
||||
{
|
||||
std::string null_result{};
|
||||
int x = int(screen_width) - 1;
|
||||
int y = yold - 1;
|
||||
const int new_time = relativeMove (null_result, x, y, xnew, ynew);
|
||||
std::array<char, BUF_SIZE> null_result{};
|
||||
const int new_time = relativeMove ( null_result.data()
|
||||
, int(screen_width) - 1, yold - 1
|
||||
, xnew, ynew );
|
||||
|
||||
if ( new_time < LONG_DURATION
|
||||
&& F_carriage_return.cap
|
||||
|
@ -997,6 +1037,7 @@ inline bool FOptiMove::isMethod5Faster ( int& move_time
|
|||
{
|
||||
move_time = F_carriage_return.duration
|
||||
+ F_cursor_left.duration + new_time;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1009,55 +1050,52 @@ void FOptiMove::moveByMethod ( int method
|
|||
, int xold, int yold
|
||||
, int xnew, int ynew )
|
||||
{
|
||||
char* move_ptr = move_buf;
|
||||
|
||||
switch ( method )
|
||||
{
|
||||
case 1:
|
||||
relativeMove (move_buf, xold, yold, xnew, ynew);
|
||||
relativeMove (move_ptr, xold, yold, xnew, ynew);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if ( F_carriage_return.cap )
|
||||
{
|
||||
move_buf = F_carriage_return.cap;
|
||||
std::string s{};
|
||||
relativeMove (s, 0, yold, xnew, ynew);
|
||||
move_buf.append(s);
|
||||
std::strncpy (move_ptr, F_carriage_return.cap, BUF_SIZE - 1);
|
||||
move_ptr[BUF_SIZE - 1] ='\0';
|
||||
move_ptr += F_carriage_return.length;
|
||||
relativeMove (move_ptr, 0, yold, xnew, ynew);
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
move_buf = F_cursor_home.cap;
|
||||
{
|
||||
std::string s{};
|
||||
relativeMove (s, 0, 0, xnew, ynew);
|
||||
move_buf.append(s);
|
||||
}
|
||||
std::strncpy (move_ptr, F_cursor_home.cap, BUF_SIZE - 1);
|
||||
move_ptr[BUF_SIZE - 1] ='\0';
|
||||
move_ptr += F_cursor_home.length;
|
||||
relativeMove (move_ptr, 0, 0, xnew, ynew);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
move_buf = F_cursor_to_ll.cap;
|
||||
{
|
||||
std::string s{};
|
||||
int down = int(screen_height) - 1;
|
||||
relativeMove (s, 0, down, xnew, ynew);
|
||||
move_buf.append(s);
|
||||
}
|
||||
std::strncpy (move_ptr, F_cursor_to_ll.cap, BUF_SIZE - 1);
|
||||
move_ptr[BUF_SIZE - 1] ='\0';
|
||||
move_ptr += F_cursor_to_ll.length;
|
||||
relativeMove (move_ptr, 0, int(screen_height) - 1, xnew, ynew);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
if ( xold >= 0 )
|
||||
move_buf = F_carriage_return.cap;
|
||||
else
|
||||
move_buf.clear();
|
||||
move_buf[0] = '\0';
|
||||
|
||||
move_buf.append(F_cursor_left.cap);
|
||||
{
|
||||
std::string s{};
|
||||
int x = int(screen_width) - 1;
|
||||
int y = yold - 1;
|
||||
relativeMove (s, x, y, xnew, ynew);
|
||||
move_buf.append(s);
|
||||
}
|
||||
if ( xold >= 0 )
|
||||
std::strncat ( move_ptr
|
||||
, F_carriage_return.cap
|
||||
, BUF_SIZE - std::strlen(move_ptr) - 1 );
|
||||
|
||||
std::strncat ( move_ptr
|
||||
, F_cursor_left.cap
|
||||
, BUF_SIZE - std::strlen(move_ptr) - 1);
|
||||
move_ptr[BUF_SIZE - 1] ='\0';
|
||||
move_ptr += std::strlen(move_buf);
|
||||
relativeMove (move_ptr, int(screen_width) - 1, yold - 1, xnew, ynew);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2019-2021 Markus Gans *
|
||||
* Copyright 2019-2020 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -54,7 +54,7 @@ FStartOptions::FStartOptions()
|
|||
|
||||
// public methods of FStartOptions
|
||||
//----------------------------------------------------------------------
|
||||
auto FStartOptions::getInstance() -> FStartOptions&
|
||||
FStartOptions& FStartOptions::getFStartOptions()
|
||||
{
|
||||
static const auto& start_options = make_unique<FStartOptions>();
|
||||
return *start_options;
|
||||
|
|
799
src/fstring.cpp
799
src/fstring.cpp
File diff suppressed because it is too large
Load Diff
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2019-2021 Markus Gans *
|
||||
* Copyright 2019-2020 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -21,7 +21,6 @@
|
|||
***********************************************************************/
|
||||
|
||||
#include "final/fsystem.h"
|
||||
#include "final/fsystemimpl.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
@ -34,14 +33,5 @@ namespace finalcut
|
|||
//----------------------------------------------------------------------
|
||||
FSystem::~FSystem() noexcept = default; // destructor
|
||||
|
||||
|
||||
// public methods of FSystem
|
||||
//----------------------------------------------------------------------
|
||||
auto FSystem::getInstance() -> std::unique_ptr<FSystem>&
|
||||
{
|
||||
static const auto& fsys = make_unique<std::unique_ptr<FSystem>>(make_unique<FSystemImpl>());
|
||||
return *fsys.get();
|
||||
}
|
||||
|
||||
} // namespace finalcut
|
||||
|
||||
|
|
490
src/fterm.cpp
490
src/fterm.cpp
File diff suppressed because it is too large
Load Diff
|
@ -53,6 +53,9 @@ enum class FullWidthSupport
|
|||
// Constant
|
||||
constexpr std::size_t NOT_FOUND = static_cast<std::size_t>(-1);
|
||||
|
||||
// global state
|
||||
static FullWidthSupport has_fullwidth_support = FullWidthSupport::Unknown;
|
||||
|
||||
// Function prototypes
|
||||
bool hasAmbiguousWidth (wchar_t);
|
||||
|
||||
|
@ -196,9 +199,9 @@ constexpr std::array<UniChar, 20> reverse_newfont_list =
|
|||
|
||||
// FTerm non-member functions
|
||||
//----------------------------------------------------------------------
|
||||
uInt env2uint (const std::string& env)
|
||||
uInt env2uint (const char* env)
|
||||
{
|
||||
const FString str{getenv(env.data())};
|
||||
const FString str{getenv(env)};
|
||||
|
||||
if ( str.isEmpty() )
|
||||
return 0;
|
||||
|
@ -256,9 +259,6 @@ bool hasFullWidthSupports()
|
|||
{
|
||||
// Checks if the terminal has full-width character support
|
||||
|
||||
// global state
|
||||
static FullWidthSupport has_fullwidth_support = FullWidthSupport::Unknown;
|
||||
|
||||
if ( has_fullwidth_support == FullWidthSupport::Unknown )
|
||||
{
|
||||
if ( ! FTerm::isInitialized() )
|
||||
|
@ -284,16 +284,15 @@ wchar_t cp437_to_unicode (uChar c)
|
|||
{
|
||||
constexpr std::size_t CP437 = 0;
|
||||
constexpr std::size_t UNICODE = 1;
|
||||
const auto& cp437_ucs = FCharMap::getCP437UCSMap();
|
||||
wchar_t ucs = c;
|
||||
auto found = std::find_if ( cp437_ucs.begin()
|
||||
, cp437_ucs.end()
|
||||
auto found = std::find_if ( fc::cp437_ucs.begin()
|
||||
, fc::cp437_ucs.end()
|
||||
, [&c] (const std::array<wchar_t, 2>& entry)
|
||||
{
|
||||
return entry[CP437] == c;
|
||||
} );
|
||||
|
||||
if ( found != cp437_ucs.end() )
|
||||
if ( found != fc::cp437_ucs.end() )
|
||||
ucs = (*found)[UNICODE];
|
||||
|
||||
return ucs;
|
||||
|
@ -304,16 +303,16 @@ uChar unicode_to_cp437 (wchar_t ucs)
|
|||
{
|
||||
constexpr std::size_t CP437 = 0;
|
||||
constexpr std::size_t UNICODE = 1;
|
||||
const auto& cp437_ucs = FCharMap::getCP437UCSMap();
|
||||
uChar c{'?'};
|
||||
auto found = std::find_if ( cp437_ucs.begin()
|
||||
, cp437_ucs.end()
|
||||
|
||||
auto found = std::find_if ( fc::cp437_ucs.begin()
|
||||
, fc::cp437_ucs.end()
|
||||
, [&ucs] (const std::array<wchar_t, 2>& entry)
|
||||
{
|
||||
return entry[UNICODE] == ucs;
|
||||
} );
|
||||
|
||||
if ( found != cp437_ucs.end() )
|
||||
if ( found != fc::cp437_ucs.end() )
|
||||
c = static_cast<uChar>((*found)[CP437]);
|
||||
|
||||
return c;
|
||||
|
@ -327,17 +326,16 @@ FString getFullWidth (const FString& str)
|
|||
FString s{str};
|
||||
auto table_search = [] (wchar_t& c)
|
||||
{
|
||||
const auto& halfwidth_fullwidth = FCharMap::getHalfFullWidthMap();
|
||||
constexpr std::size_t HALF = 0;
|
||||
constexpr std::size_t FULL = 1;
|
||||
auto found = std::find_if ( halfwidth_fullwidth.begin()
|
||||
, halfwidth_fullwidth.end()
|
||||
auto found = std::find_if ( fc::halfwidth_fullwidth.begin()
|
||||
, fc::halfwidth_fullwidth.end()
|
||||
, [&c] (const std::array<wchar_t, 2>& entry)
|
||||
{
|
||||
return entry[HALF] == c;
|
||||
} );
|
||||
|
||||
if ( found != halfwidth_fullwidth.end() )
|
||||
if ( found != fc::halfwidth_fullwidth.end() )
|
||||
c = (*found)[FULL];
|
||||
};
|
||||
|
||||
|
@ -360,17 +358,16 @@ FString getHalfWidth (const FString& str)
|
|||
FString s{str};
|
||||
auto table_search = [] (wchar_t& c)
|
||||
{
|
||||
const auto& halfwidth_fullwidth = FCharMap::getHalfFullWidthMap();
|
||||
constexpr std::size_t HALF = 0;
|
||||
constexpr std::size_t FULL = 1;
|
||||
auto found = std::find_if ( halfwidth_fullwidth.begin()
|
||||
, halfwidth_fullwidth.end()
|
||||
auto found = std::find_if ( fc::halfwidth_fullwidth.begin()
|
||||
, fc::halfwidth_fullwidth.end()
|
||||
, [&c] (const std::array<wchar_t, 2>& entry)
|
||||
{
|
||||
return entry[FULL] == c;
|
||||
} );
|
||||
|
||||
if ( found != halfwidth_fullwidth.end() )
|
||||
if ( found != fc::halfwidth_fullwidth.end() )
|
||||
c = (*found)[HALF];
|
||||
};
|
||||
|
||||
|
@ -692,10 +689,10 @@ FPoint readCursorPos()
|
|||
const int stdout_no{FTermios::getStdOut()};
|
||||
fd_set ifds{};
|
||||
struct timeval tv{};
|
||||
const std::string DECXCPR{ESC "[6n"};
|
||||
constexpr auto& DECXCPR{ESC "[6n"};
|
||||
|
||||
// Report Cursor Position (DECXCPR)
|
||||
if ( write(stdout_no, DECXCPR.data(), DECXCPR.length()) < 1 )
|
||||
if ( write(stdout_no, DECXCPR, std::strlen(DECXCPR)) < 1 )
|
||||
return {x, y};
|
||||
|
||||
std::fflush(stdout);
|
||||
|
|
|
@ -66,6 +66,7 @@ FString FTermBuffer::toString() const
|
|||
//----------------------------------------------------------------------
|
||||
int FTermBuffer::write (const FString& string)
|
||||
{
|
||||
assert ( ! string.isNull() );
|
||||
data.reserve(data.size() + string.getLength());
|
||||
const auto last = string.end();
|
||||
auto begin = string.begin();
|
||||
|
@ -151,7 +152,7 @@ void FTermBuffer::write (const FColorPair& pair) const
|
|||
// private methods of FTermBuffer
|
||||
//----------------------------------------------------------------------
|
||||
void FTermBuffer::add ( FString::const_iterator& begin
|
||||
, const FString::const_iterator& end
|
||||
, FString::const_iterator& end
|
||||
, int& char_width )
|
||||
{
|
||||
if ( begin == end )
|
||||
|
|
|
@ -251,8 +251,8 @@ void FTermcap::termcap()
|
|||
static char term_buffer[BUF_SIZE]{};
|
||||
std::vector<std::string> terminals{};
|
||||
int status = uninitialized;
|
||||
auto& fterm_data = FTermData::getInstance();
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
const bool color256 = term_detection.canDisplay256Colors();
|
||||
baudrate = int(fterm_data.getBaudrate());
|
||||
|
||||
|
@ -301,7 +301,7 @@ void FTermcap::termcapError (int status)
|
|||
|
||||
if ( status == no_entry || status == uninitialized )
|
||||
{
|
||||
const auto& termtype = FTermData::getInstance().getTermType();
|
||||
const auto& termtype = FTerm::getFTermData().getTermType();
|
||||
std::clog << FLog::LogLevel::Error
|
||||
<< "Unknown terminal: \"" << termtype << "\". "
|
||||
<< "Check the TERM environment variable. "
|
||||
|
@ -376,7 +376,7 @@ void FTermcap::termcapNumerics()
|
|||
{
|
||||
// Get termcap numerics
|
||||
|
||||
auto& fterm_data = FTermData::getInstance();
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
|
||||
// Maximum number of colors on screen
|
||||
max_color = std::max(max_color, getNumber("Co"));
|
||||
|
@ -426,7 +426,7 @@ void FTermcap::termcapKeys()
|
|||
// Get termcap keys
|
||||
|
||||
// Read termcap key sequences up to the self-defined values
|
||||
for (auto&& entry : FKeyMap::getKeyCapMap())
|
||||
for (auto&& entry : fc::fkey_cap_table)
|
||||
{
|
||||
if ( entry.string != nullptr ) // String is already set
|
||||
break;
|
||||
|
@ -437,8 +437,10 @@ void FTermcap::termcapKeys()
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
std::string FTermcap::encodeParams ( const std::string& cap
|
||||
, const std::array<int, 9>& params )
|
||||
, const std::vector<int>& param_vec )
|
||||
{
|
||||
std::array<int, 9> params{{ 0, 0, 0, 0, 0, 0, 0, 0, 0 }};
|
||||
std::copy (param_vec.begin(), param_vec.end(), params.begin());
|
||||
auto str = ::tparm ( C_STR(cap.data()), params[0], params[1]
|
||||
, params[2], params[3], params[4], params[5]
|
||||
, params[6], params[7], params[8] );
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace finalcut
|
|||
//----------------------------------------------------------------------
|
||||
void FTermcapQuirks::terminalFixup()
|
||||
{
|
||||
const auto& td = FTermDetection::getInstance();
|
||||
const auto& td = FTerm::getFTermDetection();
|
||||
|
||||
if ( td.isCygwinTerminal() )
|
||||
{
|
||||
|
@ -228,7 +228,7 @@ void FTermcapQuirks::xterm()
|
|||
void FTermcapQuirks::rxvt()
|
||||
{
|
||||
// Set enter/exit alternative charset mode for rxvt terminal
|
||||
const auto& termtype = FTermData::getInstance().getTermType();
|
||||
const auto& termtype = FTerm::getFTermData().getTermType();
|
||||
|
||||
if ( termtype.substr(0,12) == "rxvt-16color" )
|
||||
{
|
||||
|
@ -237,7 +237,7 @@ void FTermcapQuirks::rxvt()
|
|||
}
|
||||
|
||||
// Set ansi foreground and background color
|
||||
if ( ! FTermDetection::getInstance().isUrxvtTerminal() )
|
||||
if ( ! FTerm::getFTermDetection().isUrxvtTerminal() )
|
||||
{
|
||||
TCAP(t_set_a_foreground) = \
|
||||
CSI "%?%p1%{8}%<%t%p1%{30}%+%e%p1%'R'%+%;%dm";
|
||||
|
@ -249,7 +249,7 @@ void FTermcapQuirks::rxvt()
|
|||
//----------------------------------------------------------------------
|
||||
void FTermcapQuirks::vte()
|
||||
{
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
|
||||
// gnome-terminal has NC=16 however, it can use the dim attribute
|
||||
FTermcap::attr_without_color = 0;
|
||||
|
@ -370,74 +370,73 @@ void FTermcapQuirks::sunConsole()
|
|||
TCAP(t_parm_down_cursor) = CSI "%p1%dB";
|
||||
TCAP(t_parm_right_cursor) = CSI "%p1%dC";
|
||||
TCAP(t_parm_left_cursor) = CSI "%p1%dD";
|
||||
auto& fkey_cap_table = FKeyMap::getKeyCapMap();
|
||||
|
||||
// Sun Microsystems workstation console keys
|
||||
for (std::size_t i{0}; fkey_cap_table[i].tname[0] != 0; i++)
|
||||
for (std::size_t i{0}; fc::fkey_cap_table[i].tname[0] != 0; i++)
|
||||
{
|
||||
if ( std::strncmp(fkey_cap_table[i].tname, "K2", 2) == 0 )
|
||||
fkey_cap_table[i].string = CSI "218z"; // center of keypad
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "K2", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "218z"; // center of keypad
|
||||
|
||||
if ( std::strncmp(fkey_cap_table[i].tname, "kb", 2) == 0 )
|
||||
fkey_cap_table[i].string = "\b"; // backspace key
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "kb", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = "\b"; // backspace key
|
||||
|
||||
if ( std::strncmp(fkey_cap_table[i].tname, "kD", 2) == 0
|
||||
&& stringLength(fkey_cap_table[i].tname) == 2 )
|
||||
fkey_cap_table[i].string = "\177"; // delete-character key
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "kD", 2) == 0
|
||||
&& std::strlen(fc::fkey_cap_table[i].tname) == 2 )
|
||||
fc::fkey_cap_table[i].string = "\177"; // delete-character key
|
||||
|
||||
if ( std::strncmp(fkey_cap_table[i].tname, "@7", 2) == 0 )
|
||||
fkey_cap_table[i].string = CSI "220z"; // end key
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "@7", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "220z"; // end key
|
||||
|
||||
if ( std::strncmp(fkey_cap_table[i].tname, "k;", 2) == 0 )
|
||||
fkey_cap_table[i].string = CSI "233z"; // F10 function key
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "k;", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "233z"; // F10 function key
|
||||
|
||||
if ( std::strncmp(fkey_cap_table[i].tname, "F1", 2) == 0 )
|
||||
fkey_cap_table[i].string = CSI "234z"; // F11 function key
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "F1", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "234z"; // F11 function key
|
||||
|
||||
if ( std::strncmp(fkey_cap_table[i].tname, "F2", 2) == 0 )
|
||||
fkey_cap_table[i].string = CSI "235z"; // F12 function key
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "F2", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "235z"; // F12 function key
|
||||
|
||||
if ( std::strncmp(fkey_cap_table[i].tname, "kh", 2) == 0 )
|
||||
fkey_cap_table[i].string = CSI "214z"; // home key
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "kh", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "214z"; // home key
|
||||
|
||||
if ( std::strncmp(fkey_cap_table[i].tname, "kI", 2) == 0 )
|
||||
fkey_cap_table[i].string = CSI "247z"; // insert-character key
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "kI", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "247z"; // insert-character key
|
||||
|
||||
if ( std::strncmp(fkey_cap_table[i].tname, "kN", 2) == 0 )
|
||||
fkey_cap_table[i].string = CSI "222z"; // next-page key
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "kN", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "222z"; // next-page key
|
||||
|
||||
if ( std::strncmp(fkey_cap_table[i].tname, "%7", 2) == 0 )
|
||||
fkey_cap_table[i].string = CSI "194z"; // options key
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "%7", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "194z"; // options key
|
||||
|
||||
if ( std::strncmp(fkey_cap_table[i].tname, "kP", 2) == 0 )
|
||||
fkey_cap_table[i].string = CSI "216z"; // prev-page key
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "kP", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "216z"; // prev-page key
|
||||
|
||||
if ( std::strncmp(fkey_cap_table[i].tname, "&5", 2) == 0 )
|
||||
fkey_cap_table[i].string = CSI "193z"; // resume key
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "&5", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "193z"; // resume key
|
||||
|
||||
if ( std::strncmp(fkey_cap_table[i].tname, "&8", 2) == 0 )
|
||||
fkey_cap_table[i].string = CSI "195z"; // undo key
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "&8", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "195z"; // undo key
|
||||
|
||||
if ( std::strncmp(fkey_cap_table[i].tname, "K2", 2) == 0 )
|
||||
fkey_cap_table[i].string = CSI "218z"; // center of keypad
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "K2", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "218z"; // center of keypad
|
||||
|
||||
if ( std::strncmp(fkey_cap_table[i].tname, "kDx", 3) == 0 )
|
||||
fkey_cap_table[i].string = CSI "249z"; // keypad delete
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "kDx", 3) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "249z"; // keypad delete
|
||||
|
||||
if ( std::strncmp(fkey_cap_table[i].tname, "@8x", 3) == 0 )
|
||||
fkey_cap_table[i].string = CSI "250z"; // enter/send key
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "@8x", 3) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "250z"; // enter/send key
|
||||
|
||||
if ( std::strncmp(fkey_cap_table[i].tname, "KP1", 3) == 0 )
|
||||
fkey_cap_table[i].string = CSI "212z"; // keypad slash
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "KP1", 3) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "212z"; // keypad slash
|
||||
|
||||
if ( std::strncmp(fkey_cap_table[i].tname, "KP2", 3) == 0 )
|
||||
fkey_cap_table[i].string = CSI "213z"; // keypad asterisk
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "KP2", 3) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "213z"; // keypad asterisk
|
||||
|
||||
if ( std::strncmp(fkey_cap_table[i].tname, "KP3", 3) == 0 )
|
||||
fkey_cap_table[i].string = CSI "254z"; // keypad minus sign
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "KP3", 3) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "254z"; // keypad minus sign
|
||||
|
||||
if ( std::strncmp(fkey_cap_table[i].tname, "KP4", 3) == 0 )
|
||||
fkey_cap_table[i].string = CSI "253z"; // keypad plus sign
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "KP4", 3) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "253z"; // keypad plus sign
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -449,7 +448,7 @@ void FTermcapQuirks::screen()
|
|||
{
|
||||
FTermcap::can_change_color_palette = true;
|
||||
|
||||
if ( FTermDetection::getInstance().isTmuxTerm() )
|
||||
if ( FTerm::getFTermDetection().isTmuxTerm() )
|
||||
{
|
||||
TCAP(t_initialize_color) = \
|
||||
ESC "Ptmux;" ESC OSC "4;%p1%d;rgb:"
|
||||
|
|
|
@ -36,45 +36,38 @@ namespace finalcut
|
|||
//----------------------------------------------------------------------
|
||||
|
||||
// public methods of FTermDebugData
|
||||
//----------------------------------------------------------------------
|
||||
auto FTermDebugData::getInstance() -> FTermDebugData&
|
||||
{
|
||||
static const auto& debug_data = make_unique<FTermDebugData>();
|
||||
return *debug_data;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const FString& FTermDebugData::getAnswerbackString()
|
||||
{
|
||||
auto& term_detection = FTermDetection::getInstance();
|
||||
auto& term_detection = FTerm::getFTermDetection();
|
||||
return term_detection.getAnswerbackString();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const FString& FTermDebugData::getSecDAString()
|
||||
{
|
||||
auto& term_detection = FTermDetection::getInstance();
|
||||
auto& term_detection = FTerm::getFTermDetection();
|
||||
return term_detection.getSecDAString();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const FString& FTermDebugData::getTermType_256color()
|
||||
const char* FTermDebugData::getTermType_256color()
|
||||
{
|
||||
auto& term_detection = FTermDetection::getInstance();
|
||||
auto& term_detection = FTerm::getFTermDetection();
|
||||
return term_detection.getTermType_256color();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const FString& FTermDebugData::getTermType_Answerback()
|
||||
const char* FTermDebugData::getTermType_Answerback()
|
||||
{
|
||||
auto& term_detection = FTermDetection::getInstance();
|
||||
auto& term_detection = FTerm::getFTermDetection();
|
||||
return term_detection.getTermType_Answerback();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const FString& FTermDebugData::getTermType_SecDA()
|
||||
const char* FTermDebugData::getTermType_SecDA()
|
||||
{
|
||||
auto& term_detection = FTermDetection::getInstance();
|
||||
auto& term_detection = FTerm::getFTermDetection();
|
||||
return term_detection.getTermType_SecDA();
|
||||
}
|
||||
|
||||
|
@ -82,7 +75,7 @@ const FString& FTermDebugData::getTermType_SecDA()
|
|||
#if defined(__linux__)
|
||||
int FTermDebugData::getFramebufferBpp()
|
||||
{
|
||||
auto& fterm_data = FTermData::getInstance();
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
return fterm_data.getFramebufferBpp();
|
||||
}
|
||||
#endif // defined(__linux__)
|
||||
|
|
|
@ -50,52 +50,88 @@
|
|||
namespace finalcut
|
||||
{
|
||||
|
||||
// static class attributes
|
||||
FTermDetection::FTerminalType FTermDetection::terminal_type{};
|
||||
FTermDetection::colorEnv FTermDetection::color_env{};
|
||||
FTermDetection::kittyVersion FTermDetection::kitty_version{};
|
||||
FTermDetection::secondaryDA FTermDetection::secondary_da{};
|
||||
char FTermDetection::termtype[256]{};
|
||||
char FTermDetection::ttytypename[256]{};
|
||||
bool FTermDetection::decscusr_support{};
|
||||
bool FTermDetection::terminal_detection{};
|
||||
bool FTermDetection::color256{};
|
||||
const FString* FTermDetection::answer_back{nullptr};
|
||||
const FString* FTermDetection::sec_da{nullptr};
|
||||
int FTermDetection::gnome_terminal_id{};
|
||||
|
||||
#if DEBUG
|
||||
char FTermDetection::termtype_256color[256]{};
|
||||
char FTermDetection::termtype_Answerback[256]{};
|
||||
char FTermDetection::termtype_SecDA[256]{};
|
||||
#endif // DEBUG
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FTermDetection
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FTermDetection::FTermDetection() = default;
|
||||
FTermDetection::FTermDetection()
|
||||
{
|
||||
// Preset to true
|
||||
terminal_detection = true;
|
||||
|
||||
// Preset to false
|
||||
decscusr_support = false;
|
||||
|
||||
// Gnome terminal id from SecDA
|
||||
// Example: vte version 0.40.0 = 0 * 100 + 40 * 100 + 0 = 4000
|
||||
// a.b.c = a * 100 + b * 100 + c
|
||||
gnome_terminal_id = 0;
|
||||
|
||||
// Set default ttytype file
|
||||
std::strncpy (ttytypename, "/etc/ttytype", sizeof(ttytypename));
|
||||
ttytypename[sizeof(ttytypename) - 1] = '\0';
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FTermDetection::~FTermDetection() = default; // destructor
|
||||
FTermDetection::~FTermDetection() // destructor
|
||||
{
|
||||
deallocation();
|
||||
}
|
||||
|
||||
|
||||
// public methods of FTermDetection
|
||||
//----------------------------------------------------------------------
|
||||
auto FTermDetection::getInstance() -> FTermDetection&
|
||||
{
|
||||
static const auto& term_detection = make_unique<FTermDetection>();
|
||||
return *term_detection;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
#if DEBUG
|
||||
const FString& FTermDetection::getAnswerbackString() const
|
||||
const FString& FTermDetection::getAnswerbackString()
|
||||
{
|
||||
return answer_back;
|
||||
return ( answer_back ) ? *answer_back : fc::emptyFString::get();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const FString& FTermDetection::getSecDAString() const
|
||||
const FString& FTermDetection::getSecDAString()
|
||||
{
|
||||
return sec_da;
|
||||
return ( sec_da ) ? *sec_da : fc::emptyFString::get();
|
||||
}
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermDetection::setTtyTypeFileName (const FString& ttytype_filename)
|
||||
void FTermDetection::setTtyTypeFileName (const char ttytype_filename[])
|
||||
{
|
||||
if ( ! ttytype_filename )
|
||||
return;
|
||||
|
||||
ttytypename = ttytype_filename;
|
||||
std::strncpy (ttytypename, ttytype_filename, sizeof(ttytypename));
|
||||
ttytypename[sizeof(ttytypename) - 1] = '\0';
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermDetection::detect()
|
||||
{
|
||||
deallocation();
|
||||
|
||||
// Set the variable 'termtype' to the predefined type of the terminal
|
||||
getSystemTermType();
|
||||
|
||||
|
@ -108,17 +144,28 @@ void FTermDetection::detect()
|
|||
|
||||
|
||||
// private methods of FTermDetection
|
||||
//----------------------------------------------------------------------
|
||||
void FTermDetection::deallocation()
|
||||
{
|
||||
if ( sec_da )
|
||||
delete sec_da;
|
||||
|
||||
if ( answer_back )
|
||||
delete answer_back;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermDetection::getSystemTermType()
|
||||
{
|
||||
// Import the untrusted environment variable TERM
|
||||
const auto& term_env = std::getenv("TERM");
|
||||
const auto& termfilename = FTermData::getInstance().getTermFileName();
|
||||
const auto& termfilename = FTerm::getFTermData().getTermFileName();
|
||||
|
||||
if ( term_env )
|
||||
{
|
||||
// Save name in termtype
|
||||
termtype = term_env;
|
||||
std::strncpy (termtype, term_env, sizeof(termtype));
|
||||
termtype[sizeof(termtype) - 1] = '\0';
|
||||
return;
|
||||
}
|
||||
else if ( ! termfilename.empty() ) // 1st fallback: use the teminal file name
|
||||
|
@ -133,7 +180,8 @@ void FTermDetection::getSystemTermType()
|
|||
}
|
||||
|
||||
// 2nd fallback: use vt100 if not found
|
||||
termtype = "vt100";
|
||||
std::strncpy (termtype, "vt100", sizeof(termtype));
|
||||
termtype[sizeof(termtype) - 1] = '\0';
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -149,7 +197,7 @@ bool FTermDetection::getTTYtype()
|
|||
// vt100 ttys0
|
||||
|
||||
// Get term basename
|
||||
const auto& termfilename = FTermData::getInstance().getTermFileName();
|
||||
const auto& termfilename = FTerm::getFTermData().getTermFileName();
|
||||
const char* term_basename = std::strrchr(termfilename.data(), '/');
|
||||
|
||||
if ( term_basename == nullptr )
|
||||
|
@ -159,9 +207,9 @@ bool FTermDetection::getTTYtype()
|
|||
|
||||
std::FILE* fp{};
|
||||
std::array<char, BUFSIZ> str{};
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
|
||||
if ( (fp = fsystem->fopen(ttytypename.c_str(), "r")) == nullptr )
|
||||
if ( (fp = fsystem->fopen(ttytypename, "r")) == nullptr )
|
||||
return false;
|
||||
|
||||
// Read and parse the file
|
||||
|
@ -186,7 +234,8 @@ bool FTermDetection::getTTYtype()
|
|||
if ( type != nullptr && name != nullptr && ! std::strcmp(name, term_basename) )
|
||||
{
|
||||
// Save name in termtype
|
||||
termtype = type;
|
||||
std::strncpy (termtype, type, sizeof(termtype));
|
||||
termtype[sizeof(termtype) - 1] = '\0';
|
||||
fsystem->fclose(fp);
|
||||
return true;
|
||||
}
|
||||
|
@ -203,7 +252,7 @@ bool FTermDetection::getTTYSFileEntry()
|
|||
// Analyse /etc/ttys and get the term name
|
||||
|
||||
// get term basename
|
||||
const auto& termfilename = FTermData::getInstance().getTermFileName();
|
||||
const auto& termfilename = FTerm::getFTermData().getTermFileName();
|
||||
const char* term_basename = std::strrchr(termfilename.data(), '/');
|
||||
|
||||
if ( term_basename == nullptr )
|
||||
|
@ -221,7 +270,8 @@ bool FTermDetection::getTTYSFileEntry()
|
|||
if ( type != nullptr )
|
||||
{
|
||||
// Save name in termtype
|
||||
termtype = type;
|
||||
std::strncpy (termtype, type, sizeof(termtype));
|
||||
termtype[sizeof(termtype) - 1] = '\0';
|
||||
endttyent();
|
||||
return true;
|
||||
}
|
||||
|
@ -236,67 +286,67 @@ bool FTermDetection::getTTYSFileEntry()
|
|||
void FTermDetection::termtypeAnalysis()
|
||||
{
|
||||
// Cygwin console
|
||||
|
||||
if ( termtype.left(6) == "cygwin" )
|
||||
if ( std::strncmp(termtype, "cygwin", 6) == 0 )
|
||||
terminal_type.cygwin = true;
|
||||
|
||||
// rxvt terminal emulator (native MS Window System port) on cygwin
|
||||
if ( termtype == "rxvt-cygwin-native" )
|
||||
if ( std::strncmp(termtype, "rxvt-cygwin-native", 18) == 0 )
|
||||
terminal_type.rxvt = true;
|
||||
|
||||
// Ansi terminal
|
||||
if ( termtype.left(4) == "ansi" )
|
||||
if ( std::strncmp(termtype, "ansi", 4) == 0 )
|
||||
{
|
||||
terminal_detection = false;
|
||||
terminal_type.ansi = true;
|
||||
}
|
||||
|
||||
// Sun Microsystems workstation console
|
||||
if ( termtype.left(3) == "sun" )
|
||||
if ( std::strncmp(termtype, "sun", 3) == 0 )
|
||||
{
|
||||
terminal_detection = false;
|
||||
terminal_type.sun_con = true;
|
||||
}
|
||||
|
||||
// Kterm
|
||||
if ( termtype.left(5) == "kterm" )
|
||||
if ( std::strncmp(termtype, "kterm", 5) == 0 )
|
||||
{
|
||||
terminal_detection = false;
|
||||
terminal_type.kterm = true;
|
||||
}
|
||||
|
||||
// mlterm
|
||||
if ( termtype.left(6) == "mlterm" )
|
||||
if ( std::strncmp(termtype, "mlterm", 6) == 0 )
|
||||
terminal_type.mlterm = true;
|
||||
|
||||
// rxvt
|
||||
if ( termtype.left(4) == "rxvt" )
|
||||
if ( std::strncmp(termtype, "rxvt", 4) == 0 )
|
||||
terminal_type.rxvt = true;
|
||||
|
||||
// urxvt
|
||||
if ( termtype.left(12) == "rxvt-unicode" )
|
||||
if ( std::strncmp(termtype, "rxvt-unicode", 12) == 0 )
|
||||
terminal_type.urxvt = true;
|
||||
|
||||
// screen/tmux
|
||||
if ( termtype.left(6) == "screen" )
|
||||
if ( std::strncmp(termtype, "screen", 6) == 0 )
|
||||
{
|
||||
terminal_type.screen = true;
|
||||
auto tmux = std::getenv("TMUX");
|
||||
const char* tmux = std::getenv("TMUX");
|
||||
|
||||
if ( tmux && tmux[0] != '\0' )
|
||||
if ( tmux && std::strlen(tmux) != 0 )
|
||||
terminal_type.tmux = true;
|
||||
}
|
||||
|
||||
// Linux console
|
||||
if ( termtype.left(5) == "linux" || termtype.left(3) == "con" )
|
||||
if ( std::strncmp(termtype, "linux", 5) == 0
|
||||
|| std::strncmp(termtype, "con", 3) == 0 )
|
||||
terminal_type.linux_con = true;
|
||||
|
||||
// NetBSD workstation console
|
||||
if ( termtype.left(6) == "wsvt25" )
|
||||
if ( std::strncmp(termtype, "wsvt25", 6) == 0 )
|
||||
terminal_type.netbsd_con = true;
|
||||
|
||||
// kitty
|
||||
if ( termtype.left(11) == "xterm-kitty" )
|
||||
if ( std::strncmp(termtype, "xterm-kitty", 11) == 0 )
|
||||
terminal_type.kitty = true;
|
||||
}
|
||||
|
||||
|
@ -305,12 +355,12 @@ void FTermDetection::detectTerminal()
|
|||
{
|
||||
// Terminal detection
|
||||
|
||||
FString new_termtype{};
|
||||
const char* new_termtype{nullptr};
|
||||
|
||||
if ( terminal_detection )
|
||||
{
|
||||
FTermios::setCaptureSendCharacters();
|
||||
auto& keyboard = FKeyboard::getInstance();
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
keyboard.setNonBlockingInput();
|
||||
|
||||
// Initialize 256 colors terminals
|
||||
|
@ -334,26 +384,28 @@ void FTermDetection::detectTerminal()
|
|||
//
|
||||
|
||||
// Test if the terminal is a xterm
|
||||
if ( termtype.left(5) == "xterm" || termtype.left(5) == "Eterm" )
|
||||
if ( std::strncmp(termtype, "xterm", 5) == 0
|
||||
|| std::strncmp(termtype, "Eterm", 5) == 0 )
|
||||
{
|
||||
terminal_type.xterm = true;
|
||||
|
||||
// Each xterm should be able to use at least 16 colors
|
||||
if ( ! new_termtype && termtype.getLength() == 5 )
|
||||
if ( ! new_termtype && std::strlen(termtype) == 5 )
|
||||
new_termtype = "xterm-16color";
|
||||
}
|
||||
else if ( termtype.left(4) == "ansi" ) // ANSI detection
|
||||
else if ( std::strncmp(termtype, "ansi", 4) == 0 ) // ANSI detection
|
||||
terminal_type.ansi = true;
|
||||
|
||||
// set the new environment variable TERM
|
||||
if ( new_termtype )
|
||||
{
|
||||
setenv("TERM", new_termtype.c_str(), 1);
|
||||
termtype = new_termtype;
|
||||
setenv("TERM", new_termtype, 1);
|
||||
std::strncpy (termtype, new_termtype, sizeof(termtype));
|
||||
termtype[sizeof(termtype) - 1] = '\0';
|
||||
}
|
||||
|
||||
#if defined(__CYGWIN__)
|
||||
auto& fterm_data = FTermData::getInstance();
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
const auto& termfilename = fterm_data.getTermFileName();
|
||||
|
||||
// Fixes problem with mouse input
|
||||
|
@ -363,13 +415,13 @@ void FTermDetection::detectTerminal()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString FTermDetection::init_256colorTerminal()
|
||||
const char* FTermDetection::init_256colorTerminal()
|
||||
{
|
||||
FString new_termtype{};
|
||||
const char* new_termtype{nullptr};
|
||||
|
||||
if ( get256colorEnvString() )
|
||||
color256 = true;
|
||||
else if ( termtype.includes("256color") )
|
||||
else if ( std::strstr (termtype, "256color") )
|
||||
color256 = true;
|
||||
else
|
||||
color256 = false;
|
||||
|
@ -377,8 +429,13 @@ FString FTermDetection::init_256colorTerminal()
|
|||
new_termtype = termtype_256color_quirks();
|
||||
|
||||
#if DEBUG
|
||||
if ( ! new_termtype.isEmpty() )
|
||||
termtype_256color = new_termtype;
|
||||
if ( new_termtype )
|
||||
{
|
||||
std::strncpy ( termtype_256color
|
||||
, new_termtype
|
||||
, sizeof(termtype_256color) );
|
||||
termtype_256color[sizeof(termtype_256color) - 1] = '\0';
|
||||
}
|
||||
#endif // DEBUG
|
||||
|
||||
return new_termtype;
|
||||
|
@ -395,28 +452,29 @@ bool FTermDetection::get256colorEnvString()
|
|||
color_env.string5 = std::getenv("KONSOLE_DBUS_SESSION");
|
||||
color_env.string6 = std::getenv("KONSOLE_DCOP");
|
||||
color_env.string7 = std::getenv("COLORFGBG");
|
||||
color_env.string8 = std::getenv("KITTY_WINDOW_ID");
|
||||
color_env.string7 = std::getenv("KITTY_WINDOW_ID");
|
||||
|
||||
if ( ! color_env.string1.isEmpty()
|
||||
|| ! color_env.string2.isEmpty()
|
||||
|| ! color_env.string3.isEmpty()
|
||||
|| ! color_env.string4.isEmpty()
|
||||
|| ! color_env.string5.isEmpty()
|
||||
|| ! color_env.string6.isEmpty()
|
||||
|| ! color_env.string7.isEmpty()
|
||||
|| ! color_env.string8.isEmpty() )
|
||||
if ( color_env.string1 != nullptr
|
||||
|| color_env.string2 != nullptr
|
||||
|| color_env.string3 != nullptr
|
||||
|| color_env.string4 != nullptr
|
||||
|| color_env.string5 != nullptr
|
||||
|| color_env.string6 != nullptr
|
||||
|| color_env.string7 != nullptr
|
||||
|| color_env.string8 != nullptr )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString FTermDetection::termtype_256color_quirks()
|
||||
const char* FTermDetection::termtype_256color_quirks()
|
||||
{
|
||||
FString new_termtype{};
|
||||
const char* new_termtype{nullptr};
|
||||
|
||||
if ( ! color_env.string2.isEmpty()
|
||||
|| color_env.string1 == "gnome-terminal" )
|
||||
if ( color_env.string2
|
||||
|| (color_env.string1
|
||||
&& std::strncmp(color_env.string1, "gnome-terminal", 14) == 0) )
|
||||
{
|
||||
terminal_type.gnome_terminal = true;
|
||||
// Each gnome-terminal should be able to use 256 colors
|
||||
|
@ -432,45 +490,46 @@ FString FTermDetection::termtype_256color_quirks()
|
|||
if ( ! color256 )
|
||||
return new_termtype;
|
||||
|
||||
if ( termtype.left(5) == "xterm" )
|
||||
if ( std::strncmp(termtype, "xterm", 5) == 0 )
|
||||
new_termtype = "xterm-256color";
|
||||
|
||||
if ( termtype.left(6) == "screen" )
|
||||
if ( std::strncmp(termtype, "screen", 6) == 0 )
|
||||
new_termtype = "screen-256color";
|
||||
|
||||
if ( termtype.left(5) == "Eterm" )
|
||||
if ( std::strncmp(termtype, "Eterm", 5) == 0 )
|
||||
new_termtype = "Eterm-256color";
|
||||
|
||||
if ( termtype.left(6) == "mlterm" )
|
||||
if ( std::strncmp(termtype, "mlterm", 6) == 0 )
|
||||
new_termtype = "mlterm-256color";
|
||||
|
||||
if ( termtype.left(4) == "rxvt"
|
||||
&& color_env.string1.left(8) == "rxvt-xpm" )
|
||||
if ( std::strncmp(termtype, "rxvt", 4) != 0
|
||||
&& color_env.string1
|
||||
&& std::strncmp(color_env.string1, "rxvt-xpm", 8) == 0 )
|
||||
{
|
||||
new_termtype = "rxvt-256color";
|
||||
terminal_type.rxvt = true;
|
||||
}
|
||||
|
||||
if ( color_env.string5.getLength() > 0
|
||||
|| color_env.string6.getLength() > 0 )
|
||||
if ( (color_env.string5 && std::strlen(color_env.string5) > 0)
|
||||
|| (color_env.string6 && std::strlen(color_env.string6) > 0) )
|
||||
{
|
||||
terminal_type.kde_konsole = true;
|
||||
new_termtype = "konsole-256color";
|
||||
}
|
||||
|
||||
if ( color_env.string3.getLength() > 0 )
|
||||
if ( color_env.string3 && std::strlen(color_env.string3) > 0 )
|
||||
decscusr_support = true;
|
||||
|
||||
return new_termtype;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString FTermDetection::determineMaxColor (const FString& current_termtype)
|
||||
const char* FTermDetection::determineMaxColor (const char current_termtype[])
|
||||
{
|
||||
// Determine xterm maximum number of colors via OSC 4
|
||||
|
||||
FString new_termtype{current_termtype};
|
||||
auto& keyboard = FKeyboard::getInstance();
|
||||
const char* new_termtype = current_termtype;
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
keyboard.setNonBlockingInput();
|
||||
|
||||
if ( ! color256
|
||||
|
@ -504,7 +563,7 @@ FString FTermDetection::determineMaxColor (const FString& current_termtype)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString FTermDetection::getXTermColorName (FColor color) const
|
||||
FString FTermDetection::getXTermColorName (FColor color)
|
||||
{
|
||||
FString color_str{""};
|
||||
std::array<char, 30> buf{};
|
||||
|
@ -543,7 +602,7 @@ FString FTermDetection::getXTermColorName (FColor color) const
|
|||
|
||||
if ( pos > 4 && std::sscanf(temp.data(), parse, &index, buf.data()) == 2 )
|
||||
{
|
||||
auto n = stringLength(buf.data());
|
||||
std::size_t n = std::strlen(buf.data());
|
||||
|
||||
// BEL + '\0' = string terminator
|
||||
if ( n >= 6 && buf[n - 1] == BEL[0] && buf[n] == '\0' )
|
||||
|
@ -560,16 +619,26 @@ FString FTermDetection::getXTermColorName (FColor color) const
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString FTermDetection::parseAnswerbackMsg (const FString& current_termtype)
|
||||
const char* FTermDetection::parseAnswerbackMsg (const char current_termtype[])
|
||||
{
|
||||
FString new_termtype{current_termtype};
|
||||
auto& keyboard = FKeyboard::getInstance();
|
||||
const char* new_termtype = current_termtype;
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
keyboard.setNonBlockingInput();
|
||||
// send ENQ and read the answerback message
|
||||
answer_back = getAnswerbackMsg();
|
||||
const auto& ans = getAnswerbackMsg();
|
||||
keyboard.unsetNonBlockingInput();
|
||||
|
||||
if ( answer_back == "PuTTY" )
|
||||
try
|
||||
{
|
||||
answer_back = new FString(ans);
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
badAllocOutput ("FString");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if ( *answer_back == "PuTTY" )
|
||||
{
|
||||
terminal_type.putty = true;
|
||||
|
||||
|
@ -585,15 +654,20 @@ FString FTermDetection::parseAnswerbackMsg (const FString& current_termtype)
|
|||
std::fflush (stdout);
|
||||
|
||||
#if DEBUG
|
||||
if ( ! new_termtype.isEmpty() )
|
||||
termtype_Answerback = new_termtype;
|
||||
if ( new_termtype )
|
||||
{
|
||||
std::strncpy ( termtype_Answerback
|
||||
, new_termtype
|
||||
, sizeof(termtype_Answerback) - 1);
|
||||
termtype_Answerback[sizeof(termtype_Answerback) - 1] = '\0';
|
||||
}
|
||||
#endif // DEBUG
|
||||
|
||||
return new_termtype;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString FTermDetection::getAnswerbackMsg() const
|
||||
FString FTermDetection::getAnswerbackMsg()
|
||||
{
|
||||
FString answerback{""};
|
||||
fd_set ifds{};
|
||||
|
@ -633,31 +707,45 @@ FString FTermDetection::getAnswerbackMsg() const
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString FTermDetection::parseSecDA (const FString& current_termtype)
|
||||
const char* FTermDetection::parseSecDA (const char current_termtype[])
|
||||
{
|
||||
// The Linux console and older cygwin terminals knows no Sec_DA
|
||||
if ( isLinuxTerm() || isCygwinTerminal() )
|
||||
return current_termtype;
|
||||
|
||||
// Secondary device attributes (SEC_DA) <- decTerminalID string
|
||||
sec_da = getSecDA();
|
||||
const auto& ans = getSecDA();
|
||||
|
||||
if ( sec_da.getLength() < 6 )
|
||||
try
|
||||
{
|
||||
// Secondary device attributes (SEC_DA) <- decTerminalID string
|
||||
sec_da = new FString(ans);
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
badAllocOutput ("FString");
|
||||
return current_termtype;
|
||||
}
|
||||
|
||||
if ( sec_da->getLength() < 6 )
|
||||
return current_termtype;
|
||||
|
||||
// remove the first 3 bytes ("\033[>")
|
||||
FString temp(sec_da.right(sec_da.getLength() - 3));
|
||||
FString temp{sec_da->right(sec_da->getLength() - 3)};
|
||||
// remove the last byte ("c")
|
||||
temp.remove(temp.getLength() - 1, 1);
|
||||
// split into components
|
||||
const auto sec_da_components = temp.split(';');
|
||||
const auto num_components = sec_da_components.size();
|
||||
const FStringList sec_da_list = temp.split(';');
|
||||
|
||||
const uLong num_components = sec_da_list.size();
|
||||
|
||||
// The second device attribute (SEC_DA) always has 3 parameters,
|
||||
// otherwise it usually has a copy of the device attribute (primary DA)
|
||||
if ( num_components < 3 )
|
||||
return current_termtype;
|
||||
|
||||
const FString* sec_da_components = &sec_da_list[0];
|
||||
|
||||
if ( sec_da_components[0].isEmpty() )
|
||||
return current_termtype;
|
||||
|
||||
|
@ -670,18 +758,21 @@ FString FTermDetection::parseSecDA (const FString& current_termtype)
|
|||
// Read the terminal hardware option
|
||||
secondary_da.terminal_id_hardware = str2int(sec_da_components[2]);
|
||||
|
||||
FString new_termtype = secDA_Analysis(current_termtype);
|
||||
const char* new_termtype = secDA_Analysis(current_termtype);
|
||||
|
||||
#if DEBUG
|
||||
if ( ! new_termtype.isEmpty() )
|
||||
termtype_SecDA = new_termtype;
|
||||
if ( new_termtype )
|
||||
{
|
||||
std::strncpy (termtype_SecDA, new_termtype, sizeof(termtype_SecDA));
|
||||
termtype_SecDA[sizeof(termtype_SecDA) - 1] = '\0';
|
||||
}
|
||||
#endif // DEBUG
|
||||
|
||||
return new_termtype;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int FTermDetection::str2int (const FString& s) const
|
||||
int FTermDetection::str2int (const FString& s)
|
||||
{
|
||||
// This is not a general string to integer conversion method.
|
||||
// It is only used in this class to convert the device attribute
|
||||
|
@ -689,7 +780,7 @@ int FTermDetection::str2int (const FString& s) const
|
|||
|
||||
constexpr int ERROR = -1;
|
||||
|
||||
if ( s.isEmpty() )
|
||||
if ( ! s )
|
||||
return ERROR;
|
||||
|
||||
try
|
||||
|
@ -711,7 +802,7 @@ int FTermDetection::str2int (const FString& s) const
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString FTermDetection::getSecDA() const
|
||||
FString FTermDetection::getSecDA()
|
||||
{
|
||||
FString sec_da_str{""};
|
||||
|
||||
|
@ -722,10 +813,10 @@ FString FTermDetection::getSecDA() const
|
|||
const int stdout_no{FTermios::getStdOut()};
|
||||
fd_set ifds{};
|
||||
struct timeval tv{};
|
||||
const std::string SECDA{ESC "[>c"};
|
||||
constexpr auto& SECDA{ESC "[>c"};
|
||||
|
||||
// Get the secondary device attributes
|
||||
if ( write(stdout_no, SECDA.data(), SECDA.length()) == -1 )
|
||||
if ( write(stdout_no, SECDA, std::strlen(SECDA)) == -1 )
|
||||
return sec_da_str;
|
||||
|
||||
std::fflush(stdout);
|
||||
|
@ -761,9 +852,9 @@ FString FTermDetection::getSecDA() const
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString FTermDetection::secDA_Analysis (const FString& current_termtype)
|
||||
const char* FTermDetection::secDA_Analysis (const char current_termtype[])
|
||||
{
|
||||
FString new_termtype{current_termtype};
|
||||
const char* new_termtype = current_termtype;
|
||||
|
||||
switch ( secondary_da.terminal_id_type )
|
||||
{
|
||||
|
@ -784,7 +875,7 @@ FString FTermDetection::secDA_Analysis (const FString& current_termtype)
|
|||
break;
|
||||
|
||||
case 32: // Tera Term
|
||||
new_termtype = secDA_Analysis_32();
|
||||
new_termtype = secDA_Analysis_32(current_termtype);
|
||||
break;
|
||||
|
||||
case 41: // DEC VT420
|
||||
|
@ -797,11 +888,11 @@ FString FTermDetection::secDA_Analysis (const FString& current_termtype)
|
|||
break;
|
||||
|
||||
case 67: // Cygwin
|
||||
new_termtype = secDA_Analysis_67();
|
||||
new_termtype = secDA_Analysis_67(current_termtype);
|
||||
break;
|
||||
|
||||
case 77: // mintty
|
||||
new_termtype = secDA_Analysis_77();
|
||||
new_termtype = secDA_Analysis_77(current_termtype);
|
||||
break;
|
||||
|
||||
case 82: // rxvt
|
||||
|
@ -837,11 +928,11 @@ FString FTermDetection::secDA_Analysis (const FString& current_termtype)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString FTermDetection::secDA_Analysis_0 (const FString& current_termtype)
|
||||
inline const char* FTermDetection::secDA_Analysis_0 (const char current_termtype[])
|
||||
{
|
||||
// Terminal ID 0 - DEC VT100
|
||||
|
||||
FString new_termtype{current_termtype};
|
||||
const char* new_termtype = current_termtype;
|
||||
|
||||
if ( secondary_da.terminal_id_version == 10
|
||||
&& secondary_da.terminal_id_hardware == 1 )
|
||||
|
@ -860,11 +951,11 @@ inline FString FTermDetection::secDA_Analysis_0 (const FString& current_termtype
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString FTermDetection::secDA_Analysis_1 (const FString& current_termtype)
|
||||
inline const char* FTermDetection::secDA_Analysis_1 (const char current_termtype[])
|
||||
{
|
||||
// Terminal ID 1 - DEC VT220
|
||||
|
||||
FString new_termtype{current_termtype};
|
||||
const char* new_termtype = current_termtype;
|
||||
|
||||
if ( isKittyTerminal() )
|
||||
new_termtype = secDA_Analysis_kitty(new_termtype);
|
||||
|
@ -875,11 +966,11 @@ inline FString FTermDetection::secDA_Analysis_1 (const FString& current_termtype
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString FTermDetection::secDA_Analysis_24 (const FString& current_termtype)
|
||||
inline const char* FTermDetection::secDA_Analysis_24 (const char current_termtype[])
|
||||
{
|
||||
// Terminal ID 24 - DEC VT320
|
||||
|
||||
FString new_termtype{current_termtype};
|
||||
const char* new_termtype = current_termtype;
|
||||
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
|
||||
|
||||
|
@ -887,9 +978,9 @@ inline FString FTermDetection::secDA_Analysis_24 (const FString& current_termtyp
|
|||
&& FTermOpenBSD::isBSDConsole() )
|
||||
{
|
||||
// NetBSD/OpenBSD workstation console
|
||||
if ( termtype.left(6) == "wsvt25" )
|
||||
if ( std::strncmp(termtype, "wsvt25", 6) == 0 )
|
||||
terminal_type.netbsd_con = true;
|
||||
else if ( termtype.left(5) == "vt220" )
|
||||
else if ( std::strncmp(termtype, "vt220", 5) == 0 )
|
||||
{
|
||||
terminal_type.openbsd_con = true;
|
||||
new_termtype = "pccon";
|
||||
|
@ -902,16 +993,17 @@ inline FString FTermDetection::secDA_Analysis_24 (const FString& current_termtyp
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString FTermDetection::secDA_Analysis_32()
|
||||
inline const char* FTermDetection::secDA_Analysis_32 (const char[])
|
||||
{
|
||||
// Terminal ID 32 - Tera Term
|
||||
|
||||
terminal_type.tera_term = true;
|
||||
return "teraterm";
|
||||
const char* new_termtype = "teraterm";
|
||||
return new_termtype;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString FTermDetection::secDA_Analysis_65 (const FString& current_termtype)
|
||||
inline const char* FTermDetection::secDA_Analysis_65 (const char current_termtype[])
|
||||
{
|
||||
// Terminal ID 65 - DEC VT525 and VTE >= 0.53.0
|
||||
|
||||
|
@ -919,35 +1011,37 @@ inline FString FTermDetection::secDA_Analysis_65 (const FString& current_termtyp
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString FTermDetection::secDA_Analysis_67()
|
||||
inline const char* FTermDetection::secDA_Analysis_67 (const char[])
|
||||
{
|
||||
// Terminal ID 67 - cygwin
|
||||
|
||||
terminal_type.cygwin = true;
|
||||
const char* new_termtype = "cygwin";
|
||||
std::fflush(stdout);
|
||||
return "cygwin";
|
||||
return new_termtype;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString FTermDetection::secDA_Analysis_77()
|
||||
inline const char* FTermDetection::secDA_Analysis_77 (const char[])
|
||||
{
|
||||
// Terminal ID 77 - mintty
|
||||
|
||||
terminal_type.mintty = true;
|
||||
decscusr_support = true;
|
||||
const char* new_termtype = "xterm-256color";
|
||||
std::fflush(stdout);
|
||||
return "xterm-256color";
|
||||
return new_termtype;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString FTermDetection::secDA_Analysis_82()
|
||||
inline const char* FTermDetection::secDA_Analysis_82()
|
||||
{
|
||||
// Terminal ID 82 - rxvt
|
||||
|
||||
FString new_termtype{};
|
||||
const char* new_termtype{};
|
||||
terminal_type.rxvt = true;
|
||||
|
||||
if ( termtype == "rxvt-cygwin-native" )
|
||||
if ( std::strncmp(termtype, "rxvt-cygwin-native", 18) == 0 )
|
||||
new_termtype = "rxvt-16color";
|
||||
else
|
||||
new_termtype = "rxvt";
|
||||
|
@ -956,34 +1050,36 @@ inline FString FTermDetection::secDA_Analysis_82()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString FTermDetection::secDA_Analysis_83 (const FString& current_termtype)
|
||||
inline const char* FTermDetection::secDA_Analysis_83 (const char current_termtype[])
|
||||
{
|
||||
// Terminal ID 83 - screen
|
||||
|
||||
const char* new_termtype = current_termtype;
|
||||
terminal_type.screen = true;
|
||||
return current_termtype;
|
||||
return new_termtype;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString FTermDetection::secDA_Analysis_84 (const FString& current_termtype)
|
||||
inline const char* FTermDetection::secDA_Analysis_84 (const char current_termtype[])
|
||||
{
|
||||
// Terminal ID 84 - tmux
|
||||
|
||||
const char* new_termtype = current_termtype;
|
||||
terminal_type.screen = true;
|
||||
terminal_type.tmux = true;
|
||||
return current_termtype;
|
||||
return new_termtype;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString FTermDetection::secDA_Analysis_85()
|
||||
inline const char* FTermDetection::secDA_Analysis_85()
|
||||
{
|
||||
// Terminal ID 85 - rxvt-unicode
|
||||
|
||||
FString new_termtype{};
|
||||
const char* new_termtype{};
|
||||
terminal_type.rxvt = true;
|
||||
terminal_type.urxvt = true;
|
||||
|
||||
if ( termtype.left(5) == "rxvt-" )
|
||||
if ( std::strncmp(termtype, "rxvt-", 5) != 0 )
|
||||
{
|
||||
if ( color256 )
|
||||
new_termtype = "rxvt-256color";
|
||||
|
@ -997,12 +1093,12 @@ inline FString FTermDetection::secDA_Analysis_85()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString FTermDetection::secDA_Analysis_vte (const FString& current_termtype)
|
||||
inline const char* FTermDetection::secDA_Analysis_vte (const char current_termtype[])
|
||||
{
|
||||
// VTE terminal library
|
||||
// (Since VTE ) the terminal ID has changed from 1 to 65)
|
||||
|
||||
FString new_termtype{current_termtype};
|
||||
const char* new_termtype = current_termtype;
|
||||
|
||||
if ( secondary_da.terminal_id_version > 1000 )
|
||||
{
|
||||
|
@ -1021,11 +1117,11 @@ inline FString FTermDetection::secDA_Analysis_vte (const FString& current_termty
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString FTermDetection::secDA_Analysis_kitty (const FString& current_termtype)
|
||||
inline const char* FTermDetection::secDA_Analysis_kitty (const char current_termtype[])
|
||||
{
|
||||
// kitty
|
||||
|
||||
FString new_termtype{current_termtype};
|
||||
const char* new_termtype = current_termtype;
|
||||
|
||||
if ( secondary_da.terminal_id_version > 3999 )
|
||||
{
|
||||
|
|
|
@ -46,13 +46,6 @@ bool FTermFreeBSD::meta_sends_escape{true};
|
|||
//----------------------------------------------------------------------
|
||||
|
||||
// public methods of FTermFreeBSD
|
||||
//----------------------------------------------------------------------
|
||||
auto FTermFreeBSD::getInstance() -> FTermFreeBSD&
|
||||
{
|
||||
static const auto& freebsd_console = make_unique<FTermFreeBSD>();
|
||||
return *freebsd_console;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FTermFreeBSD::CursorStyle FTermFreeBSD::getCursorStyle()
|
||||
{
|
||||
|
@ -68,7 +61,7 @@ bool FTermFreeBSD::setCursorStyle (CursorStyle style)
|
|||
return false;
|
||||
|
||||
cursor_style = style;
|
||||
auto& fterm_data = FTermData::getInstance();
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
|
||||
if ( fterm_data.isCursorHidden() )
|
||||
return false;
|
||||
|
@ -82,7 +75,7 @@ bool FTermFreeBSD::isFreeBSDConsole()
|
|||
// Check if it's a FreeBSD console
|
||||
|
||||
keymap_t keymap{};
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
|
||||
if ( fsystem->ioctl(0, GIO_KEYMAP, &keymap) == 0 )
|
||||
return true;
|
||||
|
@ -155,7 +148,7 @@ void FTermFreeBSD::initCharMap()
|
|||
if ( ! isFreeBSDConsole() )
|
||||
return;
|
||||
|
||||
for (auto&& entry : FCharMap::getCharEncodeMap())
|
||||
for (auto&& entry : fc::character)
|
||||
if ( entry.pc < 0x1c )
|
||||
entry.pc = entry.ascii;
|
||||
}
|
||||
|
@ -194,7 +187,7 @@ bool FTermFreeBSD::saveFreeBSDAltKey()
|
|||
static constexpr int left_alt = 0x38;
|
||||
int ret{-1};
|
||||
keymap_t keymap{};
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap);
|
||||
|
||||
if ( ret < 0 )
|
||||
|
@ -213,7 +206,7 @@ bool FTermFreeBSD::setFreeBSDAltKey (uInt key)
|
|||
static constexpr int left_alt = 0x38;
|
||||
int ret{-1};
|
||||
keymap_t keymap{};
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap);
|
||||
|
||||
if ( ret < 0 )
|
||||
|
@ -248,7 +241,7 @@ bool FTermFreeBSD::resetFreeBSDAlt2Meta()
|
|||
//----------------------------------------------------------------------
|
||||
bool FTermFreeBSD::setFreeBSDCursorStyle (CursorStyle style)
|
||||
{
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
|
||||
if ( fsystem->ioctl(0, CONS_CURSORTYPE, &style) == 0 )
|
||||
return true;
|
||||
|
|
|
@ -61,13 +61,6 @@ FTermLinux::~FTermLinux() // destructor
|
|||
}
|
||||
|
||||
// public methods of FTermLinux
|
||||
//----------------------------------------------------------------------
|
||||
auto FTermLinux::getInstance() -> FTermLinux&
|
||||
{
|
||||
static const auto& linux_console = make_unique<FTermLinux>();
|
||||
return *linux_console;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FTermLinux::CursorStyle FTermLinux::getCursorStyle() const
|
||||
{
|
||||
|
@ -97,7 +90,7 @@ bool FTermLinux::setCursorStyle (CursorStyle style)
|
|||
|
||||
linux_console_cursor_style = style;
|
||||
|
||||
if ( FTermData::getInstance().isCursorHidden() )
|
||||
if ( FTerm::getFTermData().isCursorHidden() )
|
||||
return false;
|
||||
|
||||
setLinuxCursorStyle(style);
|
||||
|
@ -141,7 +134,7 @@ bool FTermLinux::isLinuxConsole()
|
|||
|
||||
char arg{0};
|
||||
int fd_tty = FTerm::getTTYFileDescriptor();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
|
||||
if ( fd_tty < 0 ) // Undefined tty file descriptor
|
||||
fd_tty = 0;
|
||||
|
@ -157,7 +150,7 @@ void FTermLinux::init()
|
|||
{
|
||||
// Initialize Linux console
|
||||
|
||||
auto& fterm_data = FTermData::getInstance();
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
screen_unicode_map.entries = nullptr;
|
||||
screen_font.data = nullptr;
|
||||
fterm_data.supportShadowCharacter (true);
|
||||
|
@ -170,7 +163,7 @@ void FTermLinux::init()
|
|||
|
||||
if ( FTerm::openConsole() == 0 )
|
||||
{
|
||||
FTermDetection::getInstance().setLinuxTerm(isLinuxConsole());
|
||||
FTerm::getFTermDetection().setLinuxTerm (isLinuxConsole());
|
||||
|
||||
if ( FTerm::isLinuxTerm() )
|
||||
{
|
||||
|
@ -215,7 +208,7 @@ void FTermLinux::initCharMap() const
|
|||
|
||||
if ( screen_unicode_map.entry_ct > 0 && screen_unicode_map.entries )
|
||||
{
|
||||
for (auto&& entry : FCharMap::getCharEncodeMap())
|
||||
for (auto&& entry : fc::character)
|
||||
{
|
||||
const auto ucs = entry.unicode;
|
||||
const sInt16 fontpos = getFontPos(ucs);
|
||||
|
@ -289,7 +282,7 @@ bool FTermLinux::loadVGAFont()
|
|||
|
||||
if ( vga_font )
|
||||
{
|
||||
auto& fterm_data = FTermData::getInstance();
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
fterm_data.supportShadowCharacter (true);
|
||||
fterm_data.supportHalfBlockCharacter (true);
|
||||
}
|
||||
|
@ -337,7 +330,7 @@ bool FTermLinux::loadNewFont()
|
|||
|
||||
if ( new_font )
|
||||
{
|
||||
auto& fterm_data = FTermData::getInstance();
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
fterm_data.supportShadowCharacter (true);
|
||||
fterm_data.supportHalfBlockCharacter (true);
|
||||
}
|
||||
|
@ -469,7 +462,7 @@ int FTermLinux::getFramebuffer_bpp() const
|
|||
const char* fb = "/dev/fb/0";
|
||||
struct fb_var_screeninfo fb_var{};
|
||||
struct fb_fix_screeninfo fb_fix{};
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
|
||||
if ( (fd = fsystem->open(fb, O_RDWR)) < 0 )
|
||||
{
|
||||
|
@ -528,7 +521,7 @@ bool FTermLinux::getScreenFont()
|
|||
}
|
||||
|
||||
// Font operation
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
ret = fsystem->ioctl (fd_tty, KDFONTOP, &font);
|
||||
|
||||
if ( ret != 0 )
|
||||
|
@ -559,7 +552,7 @@ bool FTermLinux::getUnicodeMap()
|
|||
screen_unicode_map.entries = nullptr;
|
||||
|
||||
// Get count
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
ret = fsystem->ioctl (fd_tty, GIO_UNIMAP, &screen_unicode_map);
|
||||
|
||||
if ( ret != 0 )
|
||||
|
@ -599,7 +592,7 @@ FTermLinux::ModifierKey& FTermLinux::getModifierKey()
|
|||
// Fill bit field with 0
|
||||
std::memset (&mod_key, 0x00, sizeof(mod_key));
|
||||
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
|
||||
// TIOCLINUX, subcode = 6 (TIOCL_GETSHIFTSTATE)
|
||||
if ( fsystem->ioctl(0, TIOCLINUX, &subcode) >= 0 )
|
||||
|
@ -665,7 +658,7 @@ int FTermLinux::setScreenFont ( const uChar fontdata[], uInt count
|
|||
}
|
||||
|
||||
// Font operation
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
ret = fsystem->ioctl (fd_tty, KDFONTOP, &font);
|
||||
|
||||
if ( ret != 0 && errno != ENOSYS && errno != EINVAL )
|
||||
|
@ -702,7 +695,7 @@ int FTermLinux::setUnicodeMap (struct unimapdesc* unimap) const
|
|||
do
|
||||
{
|
||||
// Clear the unicode-to-font table
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
ret = fsystem->ioctl (fd_tty, PIO_UNIMAPCLR, &advice);
|
||||
|
||||
if ( ret != 0 )
|
||||
|
@ -734,7 +727,7 @@ inline uInt16 FTermLinux::getInputStatusRegisterOne() const
|
|||
{
|
||||
// Gets the VGA input-status-register-1
|
||||
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
|
||||
// Miscellaneous output (read port)
|
||||
static constexpr uInt16 misc_read = 0x3cc;
|
||||
|
@ -750,7 +743,7 @@ uChar FTermLinux::readAttributeController (uChar index) const
|
|||
{
|
||||
// Reads a byte from the attribute controller from a given index
|
||||
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
|
||||
// Attribute controller (write port)
|
||||
static constexpr uInt16 attrib_cntlr_write = 0x3c0;
|
||||
|
@ -776,7 +769,7 @@ void FTermLinux::writeAttributeController (uChar index, uChar data) const
|
|||
{
|
||||
// Writes a byte from the attribute controller from a given index
|
||||
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
|
||||
// Attribute controller (write port)
|
||||
static constexpr uInt16 attrib_cntlr_write = 0x3c0;
|
||||
|
@ -815,7 +808,7 @@ int FTermLinux::setBlinkAsIntensity (bool enable) const
|
|||
// Uses blink-bit as background intensity.
|
||||
// That permits 16 colors for background
|
||||
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
|
||||
const int fd_tty = FTerm::getTTYFileDescriptor();
|
||||
|
||||
|
@ -854,7 +847,7 @@ bool FTermLinux::has9BitCharacters() const
|
|||
// 0xc0...0xdf - copying the eighth pixel into the ninth pixel
|
||||
// The rest - the ninth pixel has the background color
|
||||
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
const int fd_tty = FTerm::getTTYFileDescriptor();
|
||||
|
||||
if ( fsystem->getuid() != 0 ) // Direct hardware access requires root privileges
|
||||
|
@ -879,7 +872,7 @@ bool FTermLinux::has9BitCharacters() const
|
|||
//----------------------------------------------------------------------
|
||||
void FTermLinux::getVGAPalette()
|
||||
{
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
|
||||
if ( fsystem->ioctl(0, GIO_CMAP, cmap.color.data()) != 0 )
|
||||
setVGADefaultPalette(); // Fallback, if GIO_CMAP does not work
|
||||
|
@ -924,7 +917,7 @@ bool FTermLinux::setVGAPalette (FColor index, int r, int g, int b)
|
|||
cmap.color[uInt16(index)].blue = uChar(b);
|
||||
}
|
||||
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
|
||||
if ( fsystem->ioctl(0, PIO_CMAP, cmap.color.data()) == 0 )
|
||||
return true;
|
||||
|
@ -937,7 +930,7 @@ bool FTermLinux::saveVGAPalette()
|
|||
{
|
||||
// Save the current vga color map
|
||||
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
|
||||
if ( fsystem->ioctl(0, GIO_CMAP, saved_color_map.color.data()) == 0 )
|
||||
has_saved_palette = true;
|
||||
|
@ -952,7 +945,7 @@ bool FTermLinux::resetVGAPalette()
|
|||
{
|
||||
// Reset the vga color map
|
||||
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
|
||||
if ( has_saved_palette )
|
||||
{
|
||||
|
@ -1135,7 +1128,7 @@ inline void FTermLinux::shiftCtrlAltKeyCorrection()
|
|||
//----------------------------------------------------------------------
|
||||
inline void FTermLinux::initSpecialCharacter() const
|
||||
{
|
||||
auto& fterm_data = FTermData::getInstance();
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
const auto c1 = wchar_t(UniChar::UpperHalfBlock); // ▀
|
||||
const auto c2 = wchar_t(UniChar::LowerHalfBlock); // ▄
|
||||
const auto c3 = wchar_t(UniChar::FullBlock); // █
|
||||
|
@ -1176,7 +1169,7 @@ void FTermLinux::characterFallback ( wchar_t ucs
|
|||
, const std::vector<wchar_t>& fallback ) const
|
||||
{
|
||||
constexpr sInt16 NOT_FOUND = -1;
|
||||
auto& fterm_data = FTermData::getInstance();
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
charSubstitution& sub_map = fterm_data.getCharSubstitutionMap();
|
||||
|
||||
if ( fallback.size() < 2 || ucs != fallback[0] )
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2018-2021 Markus Gans *
|
||||
* Copyright 2018-2020 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -41,20 +41,13 @@ bool FTermOpenBSD::meta_sends_escape{true};
|
|||
//----------------------------------------------------------------------
|
||||
|
||||
// public methods of FTermOpenBSD
|
||||
//----------------------------------------------------------------------
|
||||
auto FTermOpenBSD::getInstance() -> FTermOpenBSD&
|
||||
{
|
||||
static const auto& openbsd_console = make_unique<FTermOpenBSD>();
|
||||
return *openbsd_console;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FTermOpenBSD::isBSDConsole()
|
||||
{
|
||||
// Check if it's a NetBSD/OpenBSD workstation console
|
||||
|
||||
static kbd_t kbdencoding{};
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
|
||||
if ( fsystem->ioctl(0, WSKBDIO_GETENCODING, &kbdencoding) == 0 )
|
||||
return true;
|
||||
|
@ -109,7 +102,7 @@ bool FTermOpenBSD::setBeep (int Hz, int ms)
|
|||
bell.pitch = uInt(Hz);
|
||||
bell.period = uInt(ms);
|
||||
bell.volume = 50; // 50% volume
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
|
||||
if ( fsystem->ioctl(0, WSKBDIO_SETBELL, &bell) < 0 )
|
||||
return false;
|
||||
|
@ -121,7 +114,7 @@ bool FTermOpenBSD::setBeep (int Hz, int ms)
|
|||
bool FTermOpenBSD::resetBeep()
|
||||
{
|
||||
wskbd_bell_data default_bell;
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
|
||||
// Gets the default setting for the bell
|
||||
if ( fsystem->ioctl(0, WSKBDIO_GETDEFAULTBELL, &default_bell) < 0 )
|
||||
|
@ -154,7 +147,7 @@ bool FTermOpenBSD::saveBSDConsoleEncoding()
|
|||
static kbd_t k_encoding{};
|
||||
int ret{-1};
|
||||
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
ret = fsystem->ioctl (0, WSKBDIO_GETENCODING, &k_encoding);
|
||||
|
||||
if ( ret < 0 )
|
||||
|
@ -168,7 +161,7 @@ bool FTermOpenBSD::saveBSDConsoleEncoding()
|
|||
//----------------------------------------------------------------------
|
||||
bool FTermOpenBSD::setBSDConsoleEncoding (kbd_t k_encoding)
|
||||
{
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
|
||||
if ( fsystem->ioctl(0, WSKBDIO_SETENCODING, &k_encoding) < 0 )
|
||||
return false;
|
||||
|
|
|
@ -51,13 +51,6 @@ bool FTermXTerminal::mouse_support{false};
|
|||
//----------------------------------------------------------------------
|
||||
|
||||
// public methods of FTermXTerminal
|
||||
//----------------------------------------------------------------------
|
||||
auto FTermXTerminal::getInstance() -> FTermXTerminal&
|
||||
{
|
||||
static const auto& xterm = make_unique<FTermXTerminal>();
|
||||
return *xterm;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermXTerminal::setCursorStyle (XTermCursorStyle style)
|
||||
{
|
||||
|
@ -248,7 +241,7 @@ void FTermXTerminal::resetHighlightBackground()
|
|||
//----------------------------------------------------------------------
|
||||
void FTermXTerminal::resetDefaults()
|
||||
{
|
||||
if ( FTermDetection::getInstance().isPuttyTerminal() )
|
||||
if ( FTerm::getFTermDetection().isPuttyTerminal() )
|
||||
return;
|
||||
|
||||
// Redefines the cursor color if resetCursorColor() doesn't work
|
||||
|
@ -279,14 +272,14 @@ void FTermXTerminal::resetTitle()
|
|||
//----------------------------------------------------------------------
|
||||
void FTermXTerminal::captureFontAndTitle()
|
||||
{
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
|
||||
if ( ( term_detection.isXTerminal()
|
||||
|| term_detection.isUrxvtTerminal() )
|
||||
&& ! term_detection.isRxvtTerminal() )
|
||||
{
|
||||
FTermios::setCaptureSendCharacters();
|
||||
auto& keyboard = FKeyboard::getInstance();
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
keyboard.setNonBlockingInput();
|
||||
xterm_font = captureXTermFont();
|
||||
xterm_title = captureXTermTitle();
|
||||
|
@ -317,7 +310,7 @@ void FTermXTerminal::setXTermCursorStyle()
|
|||
return;
|
||||
#endif
|
||||
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
|
||||
if ( term_detection.isGnomeTerminal()
|
||||
&& ! term_detection.hasSetCursorStyleSupport() )
|
||||
|
@ -341,7 +334,7 @@ void FTermXTerminal::setXTermCursorStyle()
|
|||
void FTermXTerminal::setXTermTitle()
|
||||
{
|
||||
// Set the xterm title
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
|
||||
if ( term_detection.isXTerminal()
|
||||
|| term_detection.isScreenTerm()
|
||||
|
@ -352,6 +345,10 @@ void FTermXTerminal::setXTermTitle()
|
|||
|| FTermcap::osc_support )
|
||||
{
|
||||
oscPrefix();
|
||||
|
||||
if ( xterm_title.isNull() )
|
||||
xterm_title = "";
|
||||
|
||||
FTerm::putstringf (OSC "0;%s" BEL, xterm_title.c_str());
|
||||
oscPostfix();
|
||||
std::fflush(stdout);
|
||||
|
@ -362,7 +359,7 @@ void FTermXTerminal::setXTermTitle()
|
|||
//----------------------------------------------------------------------
|
||||
void FTermXTerminal::setXTermSize() const
|
||||
{
|
||||
if ( ! FTermDetection::getInstance().isXTerminal() )
|
||||
if ( ! FTerm::getFTermDetection().isXTerminal() )
|
||||
return;
|
||||
|
||||
FTerm::putstringf ( CSI "8;%lu;%lut"
|
||||
|
@ -376,7 +373,7 @@ void FTermXTerminal::setXTermFont()
|
|||
{
|
||||
// Change the XTerm font (needs the allowFontOps resource)
|
||||
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
|
||||
if ( term_detection.isXTerminal()
|
||||
|| term_detection.isScreenTerm()
|
||||
|
@ -394,7 +391,7 @@ void FTermXTerminal::setXTermForeground()
|
|||
{
|
||||
// Set the XTerm text foreground color
|
||||
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
|
||||
if ( term_detection.isXTerminal()
|
||||
|| term_detection.isScreenTerm()
|
||||
|
@ -414,7 +411,7 @@ void FTermXTerminal::setXTermBackground()
|
|||
{
|
||||
// Set the XTerm text background color
|
||||
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
|
||||
if ( term_detection.isXTerminal()
|
||||
|| term_detection.isScreenTerm()
|
||||
|
@ -434,7 +431,7 @@ void FTermXTerminal::setXTermCursorColor()
|
|||
{
|
||||
// Set the text cursor color
|
||||
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
|
||||
if ( term_detection.isXTerminal()
|
||||
|| term_detection.isScreenTerm()
|
||||
|
@ -454,7 +451,7 @@ void FTermXTerminal::setXTermMouseForeground()
|
|||
{
|
||||
// Set the mouse foreground color
|
||||
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
|
||||
if ( term_detection.isXTerminal()
|
||||
|| term_detection.isScreenTerm()
|
||||
|
@ -473,7 +470,7 @@ void FTermXTerminal::setXTermMouseBackground()
|
|||
{
|
||||
// Set the mouse background color
|
||||
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
|
||||
if ( term_detection.isXTerminal()
|
||||
|| term_detection.isScreenTerm()
|
||||
|
@ -491,7 +488,7 @@ void FTermXTerminal::setXTermHighlightBackground()
|
|||
{
|
||||
// Set the highlight background color
|
||||
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
|
||||
if ( term_detection.isXTerminal()
|
||||
|| term_detection.isScreenTerm()
|
||||
|
@ -511,7 +508,7 @@ void FTermXTerminal::setXTerm8ColorDefaults()
|
|||
// Redefinition of the XTerm default colors
|
||||
// for the final cut 8 color theme
|
||||
|
||||
if ( FTermDetection::getInstance().isPuttyTerminal() )
|
||||
if ( FTerm::getFTermDetection().isPuttyTerminal() )
|
||||
return;
|
||||
|
||||
setXTermDefaultsMouseCursor();
|
||||
|
@ -531,7 +528,7 @@ void FTermXTerminal::setXTerm16ColorDefaults()
|
|||
// Redefinition of the XTerm default colors
|
||||
// for the final cut 16 color theme
|
||||
|
||||
if ( FTermDetection::getInstance().isPuttyTerminal() )
|
||||
if ( FTerm::getFTermDetection().isPuttyTerminal() )
|
||||
return;
|
||||
|
||||
setXTermDefaultsMouseCursor();
|
||||
|
@ -551,14 +548,14 @@ inline void FTermXTerminal::setXTermDefaultsMouseCursor()
|
|||
setMouseBackground("rgb:ffff/ffff/ffff"); // white
|
||||
setMouseForeground ("rgb:0000/0000/0000"); // black
|
||||
|
||||
if ( ! FTermDetection::getInstance().isGnomeTerminal() )
|
||||
if ( ! FTerm::getFTermDetection().isGnomeTerminal() )
|
||||
setCursorColor("rgb:ffff/ffff/ffff"); // white
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermXTerminal::canSetXTermBackground() const
|
||||
{
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
|
||||
if ( xterm_default_colors
|
||||
&& ! (term_detection.isMinttyTerm()
|
||||
|
@ -575,7 +572,7 @@ void FTermXTerminal::resetXTermColorMap() const
|
|||
{
|
||||
// Reset the entire color table
|
||||
|
||||
if ( FTermDetection::getInstance().isMinttyTerm() )
|
||||
if ( FTerm::getFTermDetection().isMinttyTerm() )
|
||||
{
|
||||
FTerm::putstring (ESC "c"); // Full Reset (RIS)
|
||||
}
|
||||
|
@ -675,7 +672,7 @@ void FTermXTerminal::resetXTermHighlightBackground() const
|
|||
//----------------------------------------------------------------------
|
||||
bool FTermXTerminal::canResetColor() const
|
||||
{
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
|
||||
if ( term_detection.isGnomeTerminal()
|
||||
&& term_detection.getGnomeTerminalID() < 3502 )
|
||||
|
@ -696,7 +693,7 @@ bool FTermXTerminal::canResetColor() const
|
|||
//----------------------------------------------------------------------
|
||||
void FTermXTerminal::oscPrefix() const
|
||||
{
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
|
||||
if ( term_detection.isTmuxTerm() )
|
||||
{
|
||||
|
@ -713,7 +710,7 @@ void FTermXTerminal::oscPrefix() const
|
|||
//----------------------------------------------------------------------
|
||||
void FTermXTerminal::oscPostfix() const
|
||||
{
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
|
||||
if ( term_detection.isScreenTerm()
|
||||
|| term_detection.isTmuxTerm() )
|
||||
|
@ -726,7 +723,7 @@ void FTermXTerminal::oscPostfix() const
|
|||
//----------------------------------------------------------------------
|
||||
FString FTermXTerminal::captureXTermFont() const
|
||||
{
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
|
||||
if ( ! term_detection.isXTerminal()
|
||||
&& ! term_detection.isScreenTerm()
|
||||
|
@ -772,12 +769,12 @@ FString FTermXTerminal::captureXTermFont() const
|
|||
&& temp[3] == '0' && temp[4] == ';' )
|
||||
{
|
||||
// Skip leading Esc ] 5 0 ;
|
||||
std::string str = &temp[5];
|
||||
const std::size_t n = str.length();
|
||||
char* str = &temp[5];
|
||||
const std::size_t n = std::strlen(str);
|
||||
|
||||
// BEL + '\0' = string terminator
|
||||
if ( n >= 5 && str[n - 1] == BEL[0] && str[n] == '\0' )
|
||||
str.erase(n - 1);
|
||||
str[n - 1] = '\0';
|
||||
|
||||
return {str};
|
||||
}
|
||||
|
@ -788,7 +785,7 @@ FString FTermXTerminal::captureXTermFont() const
|
|||
//----------------------------------------------------------------------
|
||||
FString FTermXTerminal::captureXTermTitle() const
|
||||
{
|
||||
if ( FTermDetection::getInstance().isKdeTerminal() )
|
||||
if ( FTerm::getFTermDetection().isKdeTerminal() )
|
||||
return {};
|
||||
|
||||
fd_set ifds{};
|
||||
|
@ -825,8 +822,8 @@ FString FTermXTerminal::captureXTermTitle() const
|
|||
if ( pos > 6 && temp[0] == ESC[0] && temp[1] == ']' && temp[2] == 'l' )
|
||||
{
|
||||
// Skip leading Esc + ] + l = OSC l
|
||||
std::string str = &temp[3];
|
||||
const std::size_t n = str.length();
|
||||
char* str = &temp[3];
|
||||
const std::size_t n = std::strlen(str);
|
||||
|
||||
// Esc + \ = OSC string terminator
|
||||
if ( n >= 2 && str[n - 2] == ESC[0] && str[n - 1] == '\\' )
|
||||
|
@ -834,7 +831,7 @@ FString FTermXTerminal::captureXTermTitle() const
|
|||
if ( n < 4 )
|
||||
return {};
|
||||
|
||||
str.erase(n - 2);
|
||||
str[n - 2] = '\0';
|
||||
return {str};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -225,7 +225,7 @@ void FTextView::insert (const FString& str, int pos)
|
|||
else
|
||||
s = FString{str}.rtrim().expandTabs(FTerm::getTabstop());
|
||||
|
||||
auto text_split = s.split("\n");
|
||||
auto text_split = s.split("\r\n");
|
||||
|
||||
for (auto&& line : text_split) // Line loop
|
||||
{
|
||||
|
@ -274,27 +274,15 @@ void FTextView::insert (const FString& str, int pos)
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
void FTextView::replaceRange (const FString& str, int from, int to)
|
||||
{
|
||||
try
|
||||
{
|
||||
deleteRange (from, to);
|
||||
}
|
||||
catch (const std::out_of_range&)
|
||||
{
|
||||
throw std::out_of_range(""); // Invalid range
|
||||
}
|
||||
|
||||
insert(str, from);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTextView::deleteRange (int from, int to)
|
||||
{
|
||||
if ( from > to || from >= int(getRows()) || to >= int(getRows()) )
|
||||
throw std::out_of_range(""); // Invalid range
|
||||
return;
|
||||
|
||||
auto iter = data.begin();
|
||||
data.erase (iter + from, iter + to + 1);
|
||||
|
||||
if ( ! str.isNull() )
|
||||
insert(str, from);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2014-2021 Markus Gans *
|
||||
* Copyright 2014-2020 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -383,7 +383,7 @@ void FToggleButton::draw()
|
|||
//----------------------------------------------------------------------
|
||||
void FToggleButton::drawLabel()
|
||||
{
|
||||
if ( text.isEmpty() )
|
||||
if ( text.isNull() || text.isEmpty() )
|
||||
return;
|
||||
|
||||
const FString txt(text);
|
||||
|
|
|
@ -42,7 +42,7 @@ FToolTip::FToolTip (FWidget* parent)
|
|||
//----------------------------------------------------------------------
|
||||
FToolTip::FToolTip (const FString& txt, FWidget* parent)
|
||||
: FWindow{parent}
|
||||
, text{txt.trim()}
|
||||
, text{txt}
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ FToolTip::~FToolTip() // destructor
|
|||
//----------------------------------------------------------------------
|
||||
void FToolTip::setText (const FString& txt)
|
||||
{
|
||||
text.setString(txt.trim());
|
||||
text.setString(txt);
|
||||
calculateDimensions();
|
||||
}
|
||||
|
||||
|
|
|
@ -61,12 +61,14 @@ bool FVTerm::force_terminal_update{false};
|
|||
uInt64 FVTerm::flush_wait{MIN_FLUSH_WAIT};
|
||||
uInt64 FVTerm::flush_average{MIN_FLUSH_WAIT};
|
||||
uInt64 FVTerm::flush_median{MIN_FLUSH_WAIT};
|
||||
uInt64 FVTerm::term_size_check_timeout{500000}; // 500 ms
|
||||
uInt FVTerm::erase_char_length{};
|
||||
uInt FVTerm::repeat_char_length{};
|
||||
uInt FVTerm::clr_bol_length{};
|
||||
uInt FVTerm::clr_eol_length{};
|
||||
uInt FVTerm::cursor_address_length{};
|
||||
TimeValue FVTerm::time_last_flush{};
|
||||
struct timeval FVTerm::time_last_flush{};
|
||||
struct timeval FVTerm::last_term_size_check{};
|
||||
const FVTerm* FVTerm::init_object{nullptr};
|
||||
FVTerm::FTermArea* FVTerm::vterm{nullptr};
|
||||
FVTerm::FTermArea* FVTerm::vdesktop{nullptr};
|
||||
|
@ -183,9 +185,9 @@ void FVTerm::hideCursor (bool enable) const
|
|||
if ( ! cursor_hideable )
|
||||
return;
|
||||
|
||||
auto visibility_str = FTerm::cursorsVisibilityString (enable);
|
||||
const char* visibility_str = FTerm::cursorsVisibilityString (enable);
|
||||
|
||||
if ( visibility_str.empty() ) // Exit the function if the string is empty
|
||||
if ( ! visibility_str ) // Exit the function if the string is empty
|
||||
return;
|
||||
|
||||
appendOutputBuffer(FTermControl{visibility_str});
|
||||
|
@ -340,8 +342,8 @@ void FVTerm::delPreprocessingHandler (const FVTerm* instance)
|
|||
//----------------------------------------------------------------------
|
||||
int FVTerm::print (const FString& string)
|
||||
{
|
||||
if ( string.isEmpty() )
|
||||
return 0;
|
||||
if ( string.isNull() )
|
||||
return -1;
|
||||
|
||||
FTermBuffer term_buffer{};
|
||||
term_buffer.write(string);
|
||||
|
@ -351,7 +353,7 @@ int FVTerm::print (const FString& string)
|
|||
//----------------------------------------------------------------------
|
||||
int FVTerm::print (FTermArea* area, const FString& string)
|
||||
{
|
||||
if ( ! area || string.isEmpty() )
|
||||
if ( ! area || string.isNull() )
|
||||
return -1;
|
||||
|
||||
FTermBuffer term_buffer{};
|
||||
|
@ -599,9 +601,9 @@ void FVTerm::flush() const
|
|||
}
|
||||
|
||||
std::fflush(stdout);
|
||||
auto& mouse = FMouseControl::getInstance();
|
||||
auto& mouse = FTerm::getFMouseControl();
|
||||
mouse.drawPointer();
|
||||
time_last_flush = FObject::getCurrentTime();
|
||||
FObject::getCurrentTime (&time_last_flush);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1762,8 +1764,8 @@ FChar FVTerm::getCharacter ( CharacterType char_type
|
|||
|
||||
const int x = pos.getX();
|
||||
const int y = pos.getY();
|
||||
int xx = std::max(x, 0);
|
||||
int yy = std::max(y, 0);
|
||||
int xx = ( x > 0 ) ? x : 0;
|
||||
int yy = ( y > 0 ) ? y : 0;
|
||||
|
||||
if ( xx >= vterm->width )
|
||||
xx = vterm->width - 1;
|
||||
|
@ -1874,14 +1876,17 @@ void FVTerm::init()
|
|||
vdesktop->visible = true;
|
||||
active_area = vdesktop;
|
||||
|
||||
// Initialize the last flush time
|
||||
time_last_flush = TimeValue{};
|
||||
// Initialize the flush and last terminal size check time
|
||||
time_last_flush.tv_sec = 0;
|
||||
time_last_flush.tv_usec = 0;
|
||||
last_term_size_check.tv_sec = 0;
|
||||
last_term_size_check.tv_usec = 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FVTerm::init_characterLengths()
|
||||
{
|
||||
const auto& opti_move = FOptiMove::getInstance();
|
||||
const auto& opti_move = FTerm::getFOptiMove();
|
||||
cursor_address_length = opti_move.getCursorAddressLength();
|
||||
erase_char_length = opti_move.getEraseCharsLength();
|
||||
repeat_char_length = opti_move.getRepeatCharLength();
|
||||
|
@ -1915,7 +1920,7 @@ void FVTerm::init_combined_character()
|
|||
if ( FTerm::getEncoding() != Encoding::UTF8 )
|
||||
return;
|
||||
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
|
||||
if ( term_detection.isCygwinTerminal() )
|
||||
return;
|
||||
|
@ -1939,7 +1944,7 @@ void FVTerm::finish() const
|
|||
setNormal();
|
||||
|
||||
if ( FTerm::hasAlternateScreen()
|
||||
&& FTermData::getInstance().isInAlternateScreen() )
|
||||
&& FTerm::getFTermData().isInAlternateScreen() )
|
||||
clearTerm();
|
||||
|
||||
forceTerminalUpdate();
|
||||
|
@ -2874,13 +2879,33 @@ bool FVTerm::isInsideTerminal (const FPoint& pos) const
|
|||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FVTerm::isTermSizeChanged() const
|
||||
{
|
||||
if ( ! isTermSizeCheckTimeout() )
|
||||
return false;
|
||||
|
||||
FObject::getCurrentTime (&last_term_size_check);
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
const auto& old_term_geometry = fterm_data.getTermGeometry();
|
||||
FTerm::detectTermSize();
|
||||
auto term_geometry = fterm_data.getTermGeometry();
|
||||
term_geometry.move (-1, -1);
|
||||
|
||||
if ( old_term_geometry.getSize() != term_geometry.getSize() )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FVTerm::flushTimeAdjustment() const
|
||||
{
|
||||
const auto now = FObject::getCurrentTime();
|
||||
const auto diff = now - time_last_flush;
|
||||
timeval now;
|
||||
FObject::getCurrentTime(&now);
|
||||
timeval diff = now - time_last_flush;
|
||||
|
||||
if ( diff > milliseconds(400) )
|
||||
if ( diff.tv_sec > 0 || diff.tv_usec > 400000 )
|
||||
{
|
||||
flush_wait = MIN_FLUSH_WAIT; // Reset to minimum values after 400 ms
|
||||
flush_average = MIN_FLUSH_WAIT;
|
||||
|
@ -2888,7 +2913,7 @@ inline void FVTerm::flushTimeAdjustment() const
|
|||
}
|
||||
else
|
||||
{
|
||||
auto usec = uInt64(duration_cast<microseconds>(diff).count());
|
||||
auto usec = uInt64(diff.tv_usec);
|
||||
|
||||
if ( usec < MIN_FLUSH_WAIT )
|
||||
usec = MIN_FLUSH_WAIT;
|
||||
|
@ -2922,7 +2947,13 @@ inline void FVTerm::flushTimeAdjustment() const
|
|||
//----------------------------------------------------------------------
|
||||
inline bool FVTerm::isFlushTimeout()
|
||||
{
|
||||
return FObject::isTimeout (time_last_flush, flush_wait);
|
||||
return FObject::isTimeout (&time_last_flush, flush_wait);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FVTerm::isTermSizeCheckTimeout()
|
||||
{
|
||||
return FObject::isTimeout (&last_term_size_check, term_size_check_timeout);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -3049,7 +3080,7 @@ inline void FVTerm::appendAttributes (FChar& next_attr) const
|
|||
// generate attribute string for the next character
|
||||
const auto& attr_str = FTerm::changeAttribute (term_attribute, next_attr);
|
||||
|
||||
if ( ! attr_str.empty() )
|
||||
if ( attr_str )
|
||||
appendOutputBuffer (FTermControl{attr_str});
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
#include "final/fapplication.h"
|
||||
|
@ -85,7 +84,7 @@ FWidget::FWidget (FWidget* parent)
|
|||
{
|
||||
if ( internal::var::root_widget )
|
||||
{
|
||||
auto& fterm_data = FTermData::getInstance();
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
fterm_data.setExitMessage("FWidget: No parent defined! "
|
||||
"There should be only one root object");
|
||||
FApplication::exit(EXIT_FAILURE);
|
||||
|
@ -406,7 +405,7 @@ void FWidget::setPos (const FPoint& p, bool adjust)
|
|||
return;
|
||||
}
|
||||
|
||||
if ( ! isWindowWidget() ) // A widgets must be inside the client area
|
||||
if ( ! isWindowWidget() )
|
||||
{
|
||||
if ( pos.getX() < 1 )
|
||||
pos.setX(1);
|
||||
|
@ -431,7 +430,7 @@ void FWidget::setWidth (std::size_t width, bool adjust)
|
|||
if ( getWidth() == width && wsize.getWidth() == width )
|
||||
return;
|
||||
|
||||
if ( width < 1 ) // A width can never be narrower than 1 character
|
||||
if ( width < 1 )
|
||||
width = 1;
|
||||
|
||||
wsize.setWidth(width);
|
||||
|
@ -453,7 +452,7 @@ void FWidget::setHeight (std::size_t height, bool adjust)
|
|||
if ( getHeight() == height && wsize.getHeight() == height )
|
||||
return;
|
||||
|
||||
if ( height < 1 ) // A height can never be narrower than 1 character
|
||||
if ( height < 1 )
|
||||
height = 1;
|
||||
|
||||
wsize.setHeight(height);
|
||||
|
@ -480,10 +479,10 @@ void FWidget::setSize (const FSize& size, bool adjust)
|
|||
&& getHeight() == height && wsize.getHeight() == height )
|
||||
return;
|
||||
|
||||
if ( width < 1 ) // A width can never be narrower than 1 character
|
||||
if ( width < 1 )
|
||||
width = 1;
|
||||
|
||||
if ( height < 1 ) // A height can never be narrower than 1 character
|
||||
if ( height < 1 )
|
||||
height = 1;
|
||||
|
||||
wsize.setWidth(width);
|
||||
|
@ -625,19 +624,20 @@ void FWidget::setGeometry (const FPoint& p, const FSize& s, bool adjust)
|
|||
if ( getPos() == p && getWidth() == w && getHeight() == h )
|
||||
return;
|
||||
|
||||
if ( isWindowWidget() ) // A window widget can be outside
|
||||
if ( ! isWindowWidget() )
|
||||
{
|
||||
( x < 1 ) ? wsize.setX(1) : wsize.setX(x);
|
||||
( y < 1 ) ? wsize.setY(1) : wsize.setY(y);
|
||||
}
|
||||
else
|
||||
{
|
||||
wsize.setX(x);
|
||||
wsize.setY(y);
|
||||
}
|
||||
else // A normal widget must be inside the client area
|
||||
{
|
||||
wsize.setX(std::max(x, 1));
|
||||
wsize.setY(std::max(y, 1));
|
||||
}
|
||||
|
||||
wsize.setWidth(std::max(w, std::size_t(1u)));
|
||||
wsize.setHeight(std::max(h, std::size_t(1u)));
|
||||
( w < 1 ) ? wsize.setWidth(1) : wsize.setWidth(w);
|
||||
( h < 1 ) ? wsize.setHeight(1) : wsize.setHeight(h);
|
||||
|
||||
adjust_wsize = wsize;
|
||||
const int term_x = getTermX();
|
||||
const int term_y = getTermY();
|
||||
|
@ -851,7 +851,7 @@ bool FWidget::close()
|
|||
{
|
||||
hide();
|
||||
|
||||
if ( ! flags.modal && ! isInFWidgetList(close_widget, this) )
|
||||
if ( ! flags.modal )
|
||||
close_widget->push_back(this);
|
||||
}
|
||||
|
||||
|
@ -2082,7 +2082,7 @@ void FWidget::initColorTheme()
|
|||
if ( getColorTheme().use_count() > 0 && ! isDefaultTheme() )
|
||||
return; // A user theme is in use
|
||||
|
||||
if ( FStartOptions::getInstance().dark_theme )
|
||||
if ( FStartOptions::getFStartOptions().dark_theme )
|
||||
{
|
||||
if ( FTerm::getMaxColor() < 16 ) // for 8 color mode
|
||||
setColorTheme<default8ColorDarkTheme>();
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/fcolorpair.h"
|
||||
#include "final/fstatusbar.h"
|
||||
|
@ -55,16 +53,6 @@ bool isFocusPrevKey (const FKey key)
|
|||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool isInFWidgetList (const FWidget::FWidgetList* list, const FWidget* obj)
|
||||
{
|
||||
if ( ! list || ! obj )
|
||||
return false;
|
||||
|
||||
return std::any_of ( list->begin(), list->end()
|
||||
, [&obj] (const FWidget* w) { return w == obj; } );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FApplication* getFApplication()
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2013-2021 Markus Gans *
|
||||
* Copyright 2013-2020 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -238,7 +238,7 @@ class FApplication : public FWidget
|
|||
FWidget* clicked_widget{};
|
||||
FEventQueue event_queue{};
|
||||
static uInt64 next_event_wait;
|
||||
static TimeValue time_last_event;
|
||||
static timeval time_last_event;
|
||||
static int loop_level;
|
||||
static int quit_code;
|
||||
static bool quit_now;
|
||||
|
|
|
@ -120,7 +120,6 @@ class FButton : public FWidget
|
|||
void onMouseDown (FMouseEvent*) override;
|
||||
void onMouseUp (FMouseEvent*) override;
|
||||
void onMouseMove (FMouseEvent*) override;
|
||||
void onWheel (FWheelEvent*) override;
|
||||
void onTimer (FTimerEvent*) override;
|
||||
void onAccel (FAccelEvent*) override;
|
||||
void onFocusIn (FFocusEvent*) override;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2015-2021 Markus Gans *
|
||||
* Copyright 2015-2020 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -30,63 +30,43 @@
|
|||
#include <array>
|
||||
|
||||
#include "final/fc.h"
|
||||
#include "final/fstring.h"
|
||||
#include "final/ftypes.h"
|
||||
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
class FCharMap final
|
||||
namespace fc
|
||||
{
|
||||
|
||||
// Unicode fallback table for VT100, PC, and ASCII
|
||||
struct CharEncodeMap
|
||||
{
|
||||
public:
|
||||
// Unicode fallback table for VT100, PC, and ASCII
|
||||
struct CharEncodeMap
|
||||
{
|
||||
wchar_t unicode;
|
||||
wchar_t vt100;
|
||||
wchar_t pc;
|
||||
wchar_t ascii;
|
||||
};
|
||||
|
||||
// vt100 <-> utf-8
|
||||
struct DECSpecialGraphics
|
||||
{
|
||||
VT100Key key;
|
||||
UniChar unicode;
|
||||
};
|
||||
|
||||
// Using-declaration
|
||||
using CharEncodeType = std::array<CharEncodeMap, 115>;
|
||||
using DECGraphicsType = std::array<DECSpecialGraphics, 39>;
|
||||
using Cp437UcsType = std::array<std::array<wchar_t, 2>, 256>;
|
||||
using HalfFullWidthType = std::array<std::array<wchar_t, 2>, 227>;
|
||||
|
||||
// Constructors
|
||||
FCharMap() = default;
|
||||
|
||||
// Accessors
|
||||
FString getClassName() const;
|
||||
static auto getInstance() -> FCharMap&;
|
||||
static wchar_t& getCharacter ( CharEncodeMap& char_enc
|
||||
, const Encoding& enc );
|
||||
static CharEncodeType& getCharEncodeMap();
|
||||
static const DECGraphicsType& getDECSpecialGraphics();
|
||||
static const Cp437UcsType& getCP437UCSMap();
|
||||
static const HalfFullWidthType& getHalfFullWidthMap();
|
||||
|
||||
private:
|
||||
// Data members
|
||||
static CharEncodeType character;
|
||||
static const DECGraphicsType dec_special_graphics;
|
||||
static const Cp437UcsType cp437_ucs;
|
||||
static const HalfFullWidthType halfwidth_fullwidth;
|
||||
};
|
||||
|
||||
// FCharMap inline functions
|
||||
//----------------------------------------------------------------------
|
||||
inline FString FCharMap::getClassName() const
|
||||
{ return "FCharMap"; }
|
||||
extern std::array<CharEncodeMap, 115> character;
|
||||
|
||||
inline wchar_t& getCharacter (CharEncodeMap& char_enc, const Encoding& enc)
|
||||
{
|
||||
const auto array = reinterpret_cast<wchar_t*>(&char_enc);
|
||||
return array[std::size_t(enc)];
|
||||
}
|
||||
|
||||
// vt100 <-> utf-8
|
||||
struct DECSpecialGraphics
|
||||
{
|
||||
VT100Key key;
|
||||
UniChar unicode;
|
||||
};
|
||||
|
||||
extern const std::array<DECSpecialGraphics, 39> dec_special_graphics;
|
||||
extern const std::array<std::array<wchar_t, 2>, 256> cp437_ucs;
|
||||
extern const std::array<std::array<wchar_t, 2>, 227> halfwidth_fullwidth;
|
||||
|
||||
} // namespace fc
|
||||
|
||||
} // namespace finalcut
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2018-2021 Markus Gans *
|
||||
* Copyright 2018-2020 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -60,7 +60,6 @@ class FColorPalette
|
|||
|
||||
// Accessor
|
||||
virtual FString getClassName() const;
|
||||
static auto getInstance() -> std::shared_ptr<FColorPalette>&;
|
||||
|
||||
// Methods
|
||||
virtual void setColorPalette() = 0;
|
||||
|
|
|
@ -30,7 +30,9 @@
|
|||
#endif
|
||||
|
||||
/* Define to 1 if you have the `getttynam' function. */
|
||||
/* #undef HAVE_GETTTYNAM */
|
||||
#ifndef F_HAVE_GETTTYNAM
|
||||
#define F_HAVE_GETTTYNAM 1
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the `getuid' function. */
|
||||
#ifndef F_HAVE_GETUID
|
||||
|
@ -48,7 +50,9 @@
|
|||
#endif
|
||||
|
||||
/* Define to 1 if GPM mouse is enabled */
|
||||
/* #undef HAVE_LIBGPM */
|
||||
#ifndef F_HAVE_LIBGPM
|
||||
#define F_HAVE_LIBGPM 1
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the <linux/fb.h> header file. */
|
||||
#ifndef F_HAVE_LINUX_FB_H
|
||||
|
@ -140,7 +144,9 @@
|
|||
#endif
|
||||
|
||||
/* Define to 1 if you have the <ttyent.h> header file. */
|
||||
/* #undef HAVE_TTYENT_H */
|
||||
#ifndef F_HAVE_TTYENT_H
|
||||
#define F_HAVE_TTYENT_H 1
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#ifndef F_HAVE_UNISTD_H
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2015-2021 Markus Gans *
|
||||
* Copyright 2015-2020 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -29,7 +29,6 @@
|
|||
|
||||
#include <array>
|
||||
|
||||
#include "final/fstring.h"
|
||||
#include "final/ftypes.h"
|
||||
|
||||
namespace finalcut
|
||||
|
@ -37,54 +36,35 @@ namespace finalcut
|
|||
|
||||
enum class FKey : uInt32; // forward declaration
|
||||
|
||||
class FKeyMap final
|
||||
namespace fc
|
||||
{
|
||||
|
||||
struct FKeyCapMap
|
||||
{
|
||||
public:
|
||||
struct KeyCapMap
|
||||
{
|
||||
FKey num;
|
||||
const char* string;
|
||||
char tname[4];
|
||||
};
|
||||
|
||||
struct KeyMap
|
||||
{
|
||||
FKey num;
|
||||
char string[8];
|
||||
};
|
||||
|
||||
struct KeyName
|
||||
{
|
||||
FKey num;
|
||||
char string[26];
|
||||
};
|
||||
|
||||
// Using-declaration
|
||||
using KeyCapMapType = std::array<KeyCapMap, 188>;
|
||||
using KeyMapType = std::array<KeyMap, 232>;
|
||||
using KeyNameType = std::array<KeyName, 388>;
|
||||
|
||||
// Constructors
|
||||
FKeyMap() = default;
|
||||
|
||||
// Accessors
|
||||
FString getClassName() const;
|
||||
static auto getInstance() -> FKeyMap&;
|
||||
static KeyCapMapType& getKeyCapMap();
|
||||
static const KeyMapType& getKeyMap();
|
||||
static const KeyNameType& getKeyName();
|
||||
|
||||
private:
|
||||
// Data members
|
||||
static KeyCapMapType fkey_cap_table;
|
||||
static const KeyMapType fkey_table;
|
||||
static const KeyNameType fkeyname;
|
||||
};
|
||||
|
||||
// FKeyMap inline functions
|
||||
//----------------------------------------------------------------------
|
||||
inline FString FKeyMap::getClassName() const
|
||||
{ return "FKeyMap"; }
|
||||
extern std::array<FKeyCapMap, 188> fkey_cap_table;
|
||||
|
||||
struct FKeyMap
|
||||
{
|
||||
FKey num;
|
||||
char string[8];
|
||||
};
|
||||
|
||||
extern const std::array<FKeyMap, 232> fkey_table;
|
||||
|
||||
struct FKeyName
|
||||
{
|
||||
FKey num;
|
||||
char string[26];
|
||||
};
|
||||
|
||||
extern const std::array<FKeyName, 388> fkeyname;
|
||||
|
||||
} // namespace fc
|
||||
|
||||
} // namespace finalcut
|
||||
|
||||
|
|
|
@ -105,11 +105,10 @@ class FKeyboard final
|
|||
|
||||
// Accessors
|
||||
FString getClassName() const;
|
||||
static auto getInstance() -> FKeyboard&;
|
||||
FKey getKey() const;
|
||||
FString getKeyName (const FKey) const;
|
||||
keybuffer& getKeyBuffer();
|
||||
TimeValue getKeyPressedTime() const;
|
||||
timeval* getKeyPressedTime();
|
||||
static uInt64 getKeypressTimeout();
|
||||
static uInt64 getReadBlockingTime();
|
||||
|
||||
|
@ -146,7 +145,7 @@ class FKeyboard final
|
|||
|
||||
private:
|
||||
// Using-declaration
|
||||
using FKeyMapPtr = std::shared_ptr<FKeyMap::KeyCapMapType>;
|
||||
using FKeyMapPtr = std::shared_ptr<decltype(fc::fkey_cap_table)>;
|
||||
|
||||
// Constants
|
||||
static constexpr FKey NOT_SET = static_cast<FKey>(-1);
|
||||
|
@ -163,7 +162,7 @@ class FKeyboard final
|
|||
static bool isIntervalTimeout();
|
||||
|
||||
// Methods
|
||||
FKey UTF8decode (const std::string&) const;
|
||||
FKey UTF8decode (const char[]) const;
|
||||
ssize_t readKey();
|
||||
void parseKeyBuffer();
|
||||
FKey parseKeyString();
|
||||
|
@ -180,7 +179,7 @@ class FKeyboard final
|
|||
FKeyboardCommand escape_key_cmd{};
|
||||
FKeyboardCommand mouse_tracking_cmd{};
|
||||
|
||||
static TimeValue time_keypressed;
|
||||
static timeval time_keypressed;
|
||||
static uInt64 read_blocking_time;
|
||||
static uInt64 read_blocking_time_short;
|
||||
static uInt64 key_timeout;
|
||||
|
@ -215,8 +214,8 @@ inline FKeyboard::keybuffer& FKeyboard::getKeyBuffer()
|
|||
{ return fifo_buf; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline TimeValue FKeyboard::getKeyPressedTime() const
|
||||
{ return time_keypressed; }
|
||||
inline timeval* FKeyboard::getKeyPressedTime()
|
||||
{ return &time_keypressed; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline uInt64 FKeyboard::getKeypressTimeout()
|
||||
|
@ -234,8 +233,8 @@ inline void FKeyboard::setTermcapMap (const T& keymap)
|
|||
//----------------------------------------------------------------------
|
||||
inline void FKeyboard::setTermcapMap ()
|
||||
{
|
||||
using type = FKeyMap::KeyCapMapType;
|
||||
key_map = std::make_shared<type>(FKeyMap::getKeyCapMap());
|
||||
using type = decltype(fc::fkey_cap_table);
|
||||
key_map = std::make_shared<type>(fc::fkey_cap_table);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -178,7 +178,7 @@ class FListBox : public FWidget
|
|||
FListBox (Iterator, Iterator, InsertConverter, FWidget* = nullptr);
|
||||
template <typename Container
|
||||
, typename LazyConverter>
|
||||
FListBox (Container, LazyConverter&&, FWidget* = nullptr);
|
||||
FListBox (Container, LazyConverter, FWidget* = nullptr);
|
||||
|
||||
// Disable copy constructor
|
||||
FListBox (const FListBox&) = delete;
|
||||
|
@ -235,10 +235,10 @@ class FListBox : public FWidget
|
|||
template <typename Container
|
||||
, typename LazyConverter>
|
||||
void insert ( const Container&
|
||||
, LazyConverter&& );
|
||||
, const LazyConverter& );
|
||||
template <typename Container
|
||||
, typename LazyConverter>
|
||||
void insert (Container*, LazyConverter&&);
|
||||
void insert (Container*, const LazyConverter&);
|
||||
void insert (const FListBoxItem&);
|
||||
template <typename T
|
||||
, typename DT = std::nullptr_t>
|
||||
|
@ -417,12 +417,12 @@ inline FListBox::FListBox ( Iterator first
|
|||
template <typename Container
|
||||
, typename LazyConverter>
|
||||
inline FListBox::FListBox ( Container container
|
||||
, LazyConverter&& convert
|
||||
, LazyConverter convert
|
||||
, FWidget* parent )
|
||||
: FWidget{parent}
|
||||
{
|
||||
init();
|
||||
insert (container, std::forward<LazyConverter>(convert));
|
||||
insert (container, convert);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -550,11 +550,11 @@ inline void FListBox::insert ( Iterator first
|
|||
//----------------------------------------------------------------------
|
||||
template <typename Container
|
||||
, typename LazyConverter>
|
||||
void FListBox::insert (const Container& container, LazyConverter&& converter)
|
||||
void FListBox::insert (const Container& container, const LazyConverter& converter)
|
||||
{
|
||||
conv_type = ConvertType::Lazy;
|
||||
source_container = makeFData(container);
|
||||
lazy_inserter = std::forward<LazyConverter>(converter);
|
||||
lazy_inserter = converter;
|
||||
const std::size_t size = container.size();
|
||||
|
||||
if ( size > 0 )
|
||||
|
@ -566,9 +566,9 @@ void FListBox::insert (const Container& container, LazyConverter&& converter)
|
|||
//----------------------------------------------------------------------
|
||||
template <typename Container
|
||||
, typename LazyConverter>
|
||||
void FListBox::insert (Container* container, LazyConverter&& converter)
|
||||
void FListBox::insert (Container* container, const LazyConverter& converter)
|
||||
{
|
||||
insert (*container, std::forward<LazyConverter>(converter));
|
||||
insert (*container, converter);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -340,12 +340,6 @@ class FListView : public FWidget
|
|||
bool unsetTreeView();
|
||||
|
||||
// Methods
|
||||
int getindex();
|
||||
void setindex(int);
|
||||
int getmark();
|
||||
void setmark(int);
|
||||
std::vector<int> getmultimark();
|
||||
void setmultimark(std::vector<int> mark);
|
||||
virtual int addColumn (const FString&, int = USE_MAX_SIZE);
|
||||
void hide() override;
|
||||
iterator insert (FListViewItem*);
|
||||
|
@ -447,9 +441,9 @@ class FListView : public FWidget
|
|||
void drawScrollbars() const;
|
||||
void drawHeadlines();
|
||||
void drawList();
|
||||
void drawListLine (const FListViewItem*, bool, bool, bool, bool);
|
||||
void drawListLine (const FListViewItem*, bool, bool);
|
||||
void clearList();
|
||||
void setLineAttributes (bool, bool, bool, bool) const;
|
||||
void setLineAttributes (bool, bool) const;
|
||||
FString getCheckBox (const FListViewItem* item) const;
|
||||
FString getLinePrefix (const FListViewItem*, std::size_t) const;
|
||||
void drawSortIndicator (std::size_t&, std::size_t);
|
||||
|
@ -504,7 +498,6 @@ class FListView : public FWidget
|
|||
FObjectList selflist{};
|
||||
FObjectList itemlist{};
|
||||
FListViewIterator current_iter{};
|
||||
FListViewIterator mark_iter{};
|
||||
FListViewIterator first_visible_line{};
|
||||
FListViewIterator last_visible_line{};
|
||||
HeaderItems header{};
|
||||
|
@ -530,7 +523,7 @@ class FListView : public FWidget
|
|||
bool tree_view{false};
|
||||
bool hide_sort_indicator{false};
|
||||
bool has_checkable_items{false};
|
||||
std::vector<FListViewIterator> multi;
|
||||
|
||||
// Function Pointer
|
||||
bool (*user_defined_ascending) (const FObject*, const FObject*){nullptr};
|
||||
bool (*user_defined_descending) (const FObject*, const FObject*){nullptr};
|
||||
|
|
|
@ -98,18 +98,12 @@ class FMouseData
|
|||
// Copy constructor
|
||||
FMouseData (const FMouseData&) = default;
|
||||
|
||||
// Move constructor
|
||||
FMouseData (FMouseData&&) noexcept = default;
|
||||
|
||||
// Destructor
|
||||
virtual ~FMouseData() noexcept;
|
||||
|
||||
// copy assignment operator (=)
|
||||
FMouseData& operator = (const FMouseData&) = default;
|
||||
|
||||
// Move assignment operator (=)
|
||||
FMouseData& operator = (FMouseData&&) noexcept = default;
|
||||
|
||||
// Accessors
|
||||
virtual FString getClassName() const;
|
||||
const FPoint& getPos() const;
|
||||
|
@ -207,7 +201,7 @@ class FMouse : public FMouseData
|
|||
template <typename ClassT>
|
||||
static FMouse* createMouseObject ();
|
||||
virtual void setRawData (FKeyboard::keybuffer&) = 0;
|
||||
virtual void processEvent (const TimeValue&) = 0;
|
||||
virtual void processEvent (struct timeval*) = 0;
|
||||
|
||||
protected:
|
||||
// Accessors
|
||||
|
@ -215,17 +209,17 @@ class FMouse : public FMouseData
|
|||
uInt16 getMaxWidth() const;
|
||||
uInt16 getMaxHeight() const;
|
||||
uInt64 getDblclickInterval() const;
|
||||
TimeValue getMousePressedTime() const;
|
||||
timeval* getMousePressedTime();
|
||||
|
||||
// Mutator
|
||||
void setNewPos (int, int);
|
||||
void setPending (bool = true);
|
||||
void setEvent();
|
||||
void setMousePressedTime (const TimeValue&);
|
||||
void setMousePressedTime (const timeval*);
|
||||
void resetMousePressedTime();
|
||||
|
||||
// Inquiry
|
||||
bool isDblclickTimeout (const TimeValue&) const;
|
||||
bool isDblclickTimeout (const timeval*) const;
|
||||
|
||||
private:
|
||||
// Data members
|
||||
|
@ -234,7 +228,7 @@ class FMouse : public FMouseData
|
|||
uInt16 max_width{80};
|
||||
uInt16 max_height{25};
|
||||
uInt64 dblclick_interval{500000}; // 500 ms
|
||||
TimeValue time_mousepressed{};
|
||||
struct timeval time_mousepressed{};
|
||||
FPoint new_mouse_position{};
|
||||
};
|
||||
|
||||
|
@ -269,7 +263,7 @@ class FMouseGPM final : public FMouse
|
|||
|
||||
// Methods
|
||||
void setRawData (FKeyboard::keybuffer&) override;
|
||||
void processEvent (const TimeValue&) override;
|
||||
void processEvent (struct timeval*) override;
|
||||
bool gpmMouse (bool = true);
|
||||
bool enableGpmMouse();
|
||||
bool disableGpmMouse();
|
||||
|
@ -327,7 +321,7 @@ class FMouseX11 final : public FMouse
|
|||
|
||||
// Methods
|
||||
void setRawData (FKeyboard::keybuffer&) override;
|
||||
void processEvent (const TimeValue&) override;
|
||||
void processEvent (struct timeval*) override;
|
||||
|
||||
private:
|
||||
// Enumeration
|
||||
|
@ -357,7 +351,7 @@ class FMouseX11 final : public FMouse
|
|||
// Methods
|
||||
void setKeyState (int);
|
||||
void setMoveState (const FPoint&, int);
|
||||
void setButtonState (const int, const TimeValue&);
|
||||
void setButtonState (const int, const struct timeval*);
|
||||
|
||||
// Data member
|
||||
char x11_mouse[MOUSE_BUF_SIZE]{'\0'};
|
||||
|
@ -380,7 +374,7 @@ class FMouseSGR final : public FMouse
|
|||
|
||||
// Methods
|
||||
void setRawData (FKeyboard::keybuffer&) override;
|
||||
void processEvent (const TimeValue&) override;
|
||||
void processEvent (struct timeval*) override;
|
||||
|
||||
private:
|
||||
// Enumeration
|
||||
|
@ -409,7 +403,7 @@ class FMouseSGR final : public FMouse
|
|||
// Methods
|
||||
void setKeyState (int);
|
||||
void setMoveState (const FPoint&, int);
|
||||
void setPressedButtonState (const int, const TimeValue&);
|
||||
void setPressedButtonState (const int, const struct timeval*);
|
||||
void setReleasedButtonState (const int);
|
||||
|
||||
// Data members
|
||||
|
@ -433,7 +427,7 @@ class FMouseUrxvt final : public FMouse
|
|||
|
||||
// Methods
|
||||
void setRawData (FKeyboard::keybuffer&) override;
|
||||
void processEvent (const TimeValue&) override;
|
||||
void processEvent (struct timeval*) override;
|
||||
|
||||
private:
|
||||
// Enumeration
|
||||
|
@ -463,7 +457,7 @@ class FMouseUrxvt final : public FMouse
|
|||
// Methods
|
||||
void setKeyState (int);
|
||||
void setMoveState (const FPoint&, int);
|
||||
void setButtonState (const int, const TimeValue&);
|
||||
void setButtonState (const int, const struct timeval*);
|
||||
|
||||
// Data members
|
||||
char urxvt_mouse[MOUSE_BUF_SIZE]{'\0'};
|
||||
|
@ -512,7 +506,6 @@ class FMouseControl
|
|||
|
||||
// Accessors
|
||||
virtual FString getClassName() const;
|
||||
static auto getInstance() -> FMouseControl&;
|
||||
const FPoint& getPos();
|
||||
void clearEvent();
|
||||
|
||||
|
@ -550,7 +543,7 @@ class FMouseControl
|
|||
void disable();
|
||||
virtual void setRawData ( FMouse::MouseType
|
||||
, FKeyboard::keybuffer& );
|
||||
virtual void processEvent (const TimeValue&);
|
||||
virtual void processEvent (struct timeval* time);
|
||||
void processQueuedInput();
|
||||
bool getGpmKeyPressed (bool = true);
|
||||
void drawPointer();
|
||||
|
|
|
@ -44,24 +44,15 @@
|
|||
#include <sys/time.h> // need for gettimeofday
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <chrono>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "final/fstring.h"
|
||||
#include "final/ftypes.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
using std::chrono::duration_cast;
|
||||
using std::chrono::seconds;
|
||||
using std::chrono::milliseconds;
|
||||
using std::chrono::microseconds;
|
||||
using std::chrono::system_clock;
|
||||
using std::chrono::time_point;
|
||||
|
||||
// class forward declaration
|
||||
class FEvent;
|
||||
class FKeyEvent;
|
||||
|
@ -131,6 +122,7 @@ class FObject
|
|||
bool isDirectChild (const FObject*) const;
|
||||
bool isWidget() const;
|
||||
bool isInstanceOf (const FString&) const;
|
||||
bool isTimerInUpdating() const;
|
||||
|
||||
// Methods
|
||||
void removeParent();
|
||||
|
@ -142,8 +134,8 @@ class FObject
|
|||
virtual bool event (FEvent*);
|
||||
|
||||
// Timer methods
|
||||
static TimeValue getCurrentTime();
|
||||
static bool isTimeout (const TimeValue&, uInt64);
|
||||
static void getCurrentTime (timeval*);
|
||||
static bool isTimeout (const timeval*, uInt64);
|
||||
int addTimer (int);
|
||||
bool delTimer (int) const;
|
||||
bool delOwnTimers() const;
|
||||
|
@ -153,8 +145,8 @@ class FObject
|
|||
struct FTimerData
|
||||
{
|
||||
int id;
|
||||
milliseconds interval;
|
||||
TimeValue timeout;
|
||||
timeval interval;
|
||||
timeval timeout;
|
||||
FObject* object;
|
||||
};
|
||||
|
||||
|
@ -186,6 +178,7 @@ class FObject
|
|||
std::size_t max_children{UNLIMITED};
|
||||
bool has_parent{false};
|
||||
bool widget_object{false};
|
||||
static bool timer_modify_lock;
|
||||
};
|
||||
|
||||
|
||||
|
@ -269,6 +262,10 @@ inline bool FObject::isWidget() const
|
|||
inline bool FObject::isInstanceOf (const FString& classname) const
|
||||
{ return classname == getClassName(); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FObject::isTimerInUpdating() const
|
||||
{ return timer_modify_lock; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FObject::FTimerList* FObject::getTimerList() const
|
||||
{ return globalTimerList().get(); }
|
||||
|
@ -277,6 +274,61 @@ inline FObject::FTimerList* FObject::getTimerList() const
|
|||
inline void FObject::setWidgetProperty (bool property)
|
||||
{ widget_object = property; }
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Operator functions for timeval
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
static inline timeval operator + (const timeval& t1, const timeval& t2)
|
||||
{
|
||||
timeval tmp{};
|
||||
tmp.tv_sec = t1.tv_sec + t2.tv_sec;
|
||||
|
||||
if ( (tmp.tv_usec = t1.tv_usec + t2.tv_usec) >= 1000000 )
|
||||
{
|
||||
tmp.tv_sec++;
|
||||
tmp.tv_usec -= 1000000;
|
||||
}
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
static inline timeval operator - (const timeval& t1, const timeval& t2)
|
||||
{
|
||||
timeval tmp{};
|
||||
tmp.tv_sec = t1.tv_sec - t2.tv_sec;
|
||||
|
||||
if ( (tmp.tv_usec = t1.tv_usec - t2.tv_usec) < 0 )
|
||||
{
|
||||
tmp.tv_sec--;
|
||||
tmp.tv_usec += 1000000;
|
||||
}
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
static inline timeval& operator += (timeval& t1, const timeval& t2)
|
||||
{
|
||||
t1.tv_sec += t2.tv_sec;
|
||||
|
||||
if ( (t1.tv_usec += t2.tv_usec) >= 1000000 )
|
||||
{
|
||||
t1.tv_sec++;
|
||||
t1.tv_usec -= 1000000;
|
||||
}
|
||||
|
||||
return t1;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
static inline bool operator < (const timeval& t1, const timeval& t2)
|
||||
{
|
||||
return (t1.tv_sec < t2.tv_sec)
|
||||
|| (t1.tv_sec == t2.tv_sec && t1.tv_usec < t2.tv_usec);
|
||||
}
|
||||
|
||||
} // namespace finalcut
|
||||
|
||||
#endif // FOBJECT_H
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2016-2021 Markus Gans *
|
||||
* Copyright 2016-2020 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -39,7 +39,6 @@
|
|||
#include <algorithm> // need for std::swap
|
||||
|
||||
#include "final/fstring.h"
|
||||
#include "final/ftypes.h"
|
||||
#include "final/sgr_optimizer.h"
|
||||
|
||||
namespace finalcut
|
||||
|
@ -108,7 +107,6 @@ class FOptiAttr final
|
|||
|
||||
// Accessors
|
||||
FString getClassName() const;
|
||||
static auto getInstance() -> FOptiAttr&;
|
||||
|
||||
// Mutators
|
||||
void setTermEnvironment (const TermEnv&);
|
||||
|
@ -158,7 +156,7 @@ class FOptiAttr final
|
|||
// Methods
|
||||
void initialize();
|
||||
static FColor vga2ansi (FColor);
|
||||
std::string changeAttribute (FChar&, FChar&);
|
||||
const char* changeAttribute (FChar&, FChar&);
|
||||
|
||||
private:
|
||||
struct Capability
|
||||
|
@ -167,6 +165,9 @@ class FOptiAttr final
|
|||
bool caused_reset;
|
||||
};
|
||||
|
||||
// Using-declaration
|
||||
using AttributeBuffer = SGRoptimizer::AttributeBuffer;
|
||||
|
||||
// Enumerations
|
||||
enum init_reset_tests
|
||||
{
|
||||
|
@ -223,7 +224,10 @@ class FOptiAttr final
|
|||
bool unsetTermCrossedOut (FChar&);
|
||||
bool setTermDoubleUnderline (FChar&);
|
||||
bool unsetTermDoubleUnderline (FChar&);
|
||||
bool setTermAttributes (FChar&, const TCapAttributes&);
|
||||
bool setTermAttributes ( FChar&
|
||||
, bool, bool, bool
|
||||
, bool, bool, bool
|
||||
, bool, bool, bool );
|
||||
bool unsetTermAttributes (FChar&);
|
||||
bool setTermAltCharset (FChar&);
|
||||
bool unsetTermAltCharset (FChar&);
|
||||
|
@ -299,8 +303,8 @@ class FOptiAttr final
|
|||
FChar off{};
|
||||
FChar reset_byte_mask{};
|
||||
|
||||
std::string attr_buf{};
|
||||
SGRoptimizer sgr_optimizer{attr_buf};
|
||||
AttributeBuffer attr_buf{};
|
||||
|
||||
int max_color{1};
|
||||
int attr_without_color{0};
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "final/fstring.h"
|
||||
|
||||
|
@ -93,7 +92,6 @@ class FOptiMove final
|
|||
|
||||
// Accessors
|
||||
FString getClassName() const;
|
||||
static auto getInstance() -> FOptiMove&;
|
||||
uInt getCursorHomeLength() const;
|
||||
uInt getCarriageReturnLength() const;
|
||||
uInt getCursorToLLLength() const;
|
||||
|
@ -145,7 +143,7 @@ class FOptiMove final
|
|||
|
||||
// Methods
|
||||
void check_boundaries (int&, int&, int&, int&) const;
|
||||
std::string moveCursor (int, int, int, int);
|
||||
const char* moveCursor (int, int, int, int);
|
||||
|
||||
private:
|
||||
struct Capability
|
||||
|
@ -156,7 +154,7 @@ class FOptiMove final
|
|||
};
|
||||
|
||||
// Constant
|
||||
static constexpr std::string::size_type BUF_SIZE{512u};
|
||||
static constexpr std::size_t BUF_SIZE{512};
|
||||
|
||||
// Constants
|
||||
static constexpr int LONG_DURATION{INT_MAX};
|
||||
|
@ -168,14 +166,14 @@ class FOptiMove final
|
|||
void calculateCharDuration();
|
||||
int capDuration (const char[], int) const;
|
||||
int capDurationToLength (int) const;
|
||||
int repeatedAppend (std::string&, const Capability&, int) const;
|
||||
int relativeMove (std::string&, int, int, int, int) const;
|
||||
int verticalMove (std::string&, int, int) const;
|
||||
void downMove (std::string&, int&, int, int) const;
|
||||
void upMove (std::string&, int&, int, int) const;
|
||||
int horizontalMove (std::string&, int, int) const;
|
||||
void rightMove (std::string&, int&, int, int) const;
|
||||
void leftMove (std::string&, int&, int, int) const;
|
||||
int repeatedAppend (const Capability&, int, char*) const;
|
||||
int relativeMove (char[], int, int, int, int) const;
|
||||
int verticalMove (char[], int, int) const;
|
||||
void downMove (char[], int&, int, int) const;
|
||||
void upMove (char[], int&, int, int) const;
|
||||
int horizontalMove (char[], int, int) const;
|
||||
void rightMove (char[], int&, int, int) const;
|
||||
void leftMove (char[], int&, int, int) const;
|
||||
|
||||
bool isWideMove (int, int, int, int) const;
|
||||
bool isMethod0Faster (int&, int, int);
|
||||
|
@ -213,7 +211,7 @@ class FOptiMove final
|
|||
int char_duration{1};
|
||||
int baudrate{9600};
|
||||
int tabstop{0};
|
||||
std::string move_buf{};
|
||||
char move_buf[BUF_SIZE]{'\0'};
|
||||
bool automatic_left_margin{false};
|
||||
bool eat_nl_glitch{false};
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2019-2021 Markus Gans *
|
||||
* Copyright 2019-2020 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -66,7 +66,7 @@ class FStartOptions final
|
|||
|
||||
// Accessors
|
||||
static FString getClassName();
|
||||
static auto getInstance() -> FStartOptions&;
|
||||
static FStartOptions& getFStartOptions();
|
||||
|
||||
// Mutator
|
||||
void setDefault();
|
||||
|
|
|
@ -80,11 +80,10 @@ class FString
|
|||
{
|
||||
public:
|
||||
// Using-declarations
|
||||
using iterator = std::wstring::iterator;
|
||||
using const_iterator = std::wstring::const_iterator;
|
||||
using reference = std::wstring::reference;
|
||||
using const_reference = std::wstring::const_reference;
|
||||
using difference_type = std::wstring::difference_type;
|
||||
using iterator = wchar_t*;
|
||||
using const_iterator = const wchar_t*;
|
||||
using reference = wchar_t&;
|
||||
using const_reference = const wchar_t&;
|
||||
|
||||
// Constructors
|
||||
FString () = default;
|
||||
|
@ -168,7 +167,7 @@ class FString
|
|||
virtual FString getClassName() const;
|
||||
|
||||
// inquiries
|
||||
bool isNull() const noexcept; // deprecated
|
||||
bool isNull() const noexcept;
|
||||
bool isEmpty() const noexcept;
|
||||
|
||||
// Methods
|
||||
|
@ -246,16 +245,24 @@ class FString
|
|||
|
||||
private:
|
||||
// Constants
|
||||
static constexpr uInt FWDBUFFER = 15;
|
||||
static constexpr uInt INPBUFFER = 200;
|
||||
|
||||
// Methods
|
||||
void _assign (std::wstring&);
|
||||
std::string _toCharString (const std::wstring&) const;
|
||||
std::wstring _toWideString (const std::string&) const;
|
||||
void _initLength (std::size_t);
|
||||
void _assign (const wchar_t[]);
|
||||
void _insert (std::size_t, const wchar_t[]);
|
||||
void _insert (std::size_t, std::size_t, const wchar_t[]);
|
||||
void _remove (std::size_t, std::size_t);
|
||||
const char* _to_cstring (const wchar_t[]) const;
|
||||
const wchar_t* _to_wcstring (const char[]) const;
|
||||
const wchar_t* _extractToken (wchar_t*[], const wchar_t[], const wchar_t[]) const;
|
||||
|
||||
// Data members
|
||||
std::wstring string{};
|
||||
mutable std::string char_string{};
|
||||
wchar_t* string{nullptr};
|
||||
std::size_t length{0};
|
||||
std::size_t bufsize{0};
|
||||
mutable char* c_string{nullptr};
|
||||
static wchar_t null_char;
|
||||
static const wchar_t const_null_char;
|
||||
|
||||
|
@ -281,7 +288,7 @@ template <typename NumT
|
|||
inline FString& FString::operator << (const NumT val)
|
||||
{
|
||||
const FString numstr(FString().setNumber(val));
|
||||
string.append(numstr.string);
|
||||
_insert (length, numstr.length, numstr.string);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -289,10 +296,10 @@ inline FString& FString::operator << (const NumT val)
|
|||
template <typename IndexT>
|
||||
inline FString::reference FString::operator [] (const IndexT pos)
|
||||
{
|
||||
if ( isNegative(pos) || pos > IndexT(string.length()) )
|
||||
if ( isNegative(pos) || pos > IndexT(length) )
|
||||
throw std::out_of_range(""); // Invalid index position
|
||||
|
||||
if ( std::size_t(pos) == string.length() )
|
||||
if ( std::size_t(pos) == length )
|
||||
return null_char;
|
||||
|
||||
return string[std::size_t(pos)];
|
||||
|
@ -302,10 +309,10 @@ inline FString::reference FString::operator [] (const IndexT pos)
|
|||
template <typename IndexT>
|
||||
inline FString::const_reference FString::operator [] (const IndexT pos) const
|
||||
{
|
||||
if ( isNegative(pos) || pos > IndexT(string.length()) )
|
||||
if ( isNegative(pos) || pos > IndexT(length) )
|
||||
throw std::out_of_range(""); // Invalid index position
|
||||
|
||||
if ( std::size_t(pos) == string.length() )
|
||||
if ( std::size_t(pos) == length )
|
||||
return const_null_char;
|
||||
|
||||
return string[std::size_t(pos)];
|
||||
|
@ -364,63 +371,63 @@ inline FString FString::getClassName() const
|
|||
{ return "FString"; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FString::isNull() const noexcept // deprecated
|
||||
{ return false; }
|
||||
inline bool FString::isNull() const noexcept
|
||||
{ return ( bufsize == 0 || (bufsize > 0 && ! string) ); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FString::isEmpty() const noexcept
|
||||
{ return string.empty(); }
|
||||
{ return ( length == 0 || (length > 0 && string[0] == L'\0') ); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline std::size_t FString::getLength() const noexcept
|
||||
{ return string.length(); }
|
||||
{ return length; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline std::size_t FString::capacity() const noexcept
|
||||
{ return string.capacity(); }
|
||||
{ return ( length > 0 ) ? bufsize - 1 : 0; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString::iterator FString::begin() noexcept
|
||||
{ return string.begin(); }
|
||||
{ return string; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString::iterator FString::end() noexcept
|
||||
{ return string.end(); }
|
||||
{ return string + length; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString::const_iterator FString::begin() const noexcept
|
||||
{ return string.cbegin(); }
|
||||
{ return string; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString::const_iterator FString::end() const noexcept
|
||||
{ return string.cend(); }
|
||||
{ return string + length; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString::reference FString::front()
|
||||
{
|
||||
assert ( ! isEmpty() );
|
||||
return string.front();
|
||||
return (*this)[0];
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString::reference FString::back()
|
||||
{
|
||||
assert( ! isEmpty() );
|
||||
return string.back();
|
||||
return (*this)[length - 1];
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString::const_reference FString::front() const
|
||||
{
|
||||
assert ( ! isEmpty() );
|
||||
return string.front();
|
||||
return (*this)[0];
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString::const_reference FString::back() const
|
||||
{
|
||||
assert( ! isEmpty() );
|
||||
return string.back();
|
||||
return (*this)[length - 1];
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -437,7 +444,7 @@ inline FString& FString::sprintf (const FString& format, Args&&... args)
|
|||
|
||||
std::swprintf ( buf.data(), buf.size(), format.wc_str()
|
||||
, std::forward<Args>(args)... );
|
||||
setString(buf.data());
|
||||
_assign(buf.data());
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,9 +57,6 @@ class FSystem
|
|||
// Destructor
|
||||
virtual ~FSystem() noexcept;
|
||||
|
||||
// Accessor
|
||||
static auto getInstance() -> std::unique_ptr<FSystem>&;
|
||||
|
||||
// Methods
|
||||
virtual uChar inPortByte (uShort) = 0;
|
||||
virtual void outPortByte (uChar, uShort) = 0;
|
||||
|
|
|
@ -127,12 +127,31 @@ namespace finalcut
|
|||
|
||||
// class forward declaration
|
||||
class FColorPalette;
|
||||
class FKeyboard;
|
||||
class FMouseControl;
|
||||
class FOptiAttr;
|
||||
class FOptiMove;
|
||||
class FPoint;
|
||||
class FStartOptions;
|
||||
class FSize;
|
||||
class FString;
|
||||
class FTermBuffer;
|
||||
class FTermData;
|
||||
class FTermDebugData;
|
||||
class FTermDetection;
|
||||
class FTermXTerminal;
|
||||
|
||||
#if defined(__linux__) || defined(UNIT_TEST)
|
||||
class FTermLinux;
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
||||
class FTermFreeBSD;
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
|
||||
class FTermOpenBSD;
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FTerm
|
||||
|
@ -168,6 +187,31 @@ class FTerm final
|
|||
static std::string getTermFileName();
|
||||
static int getTabstop();
|
||||
static int getMaxColor();
|
||||
static auto getColorPaletteTheme() -> std::shared_ptr<FColorPalette>&;
|
||||
static auto getFSystem() -> std::unique_ptr<FSystem>&;
|
||||
static auto getFTermData() -> FTermData&;
|
||||
static auto getFOptiMove() -> FOptiMove&;
|
||||
static auto getFOptiAttr() -> FOptiAttr&;
|
||||
static auto getFTermDetection() -> FTermDetection&;
|
||||
static auto getFTermXTerminal() -> FTermXTerminal&;
|
||||
static auto getFKeyboard() -> FKeyboard&;
|
||||
static auto getFMouseControl() -> FMouseControl&;
|
||||
|
||||
#if defined(__linux__) || defined(UNIT_TEST)
|
||||
static auto getFTermLinux() -> FTermLinux&;
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
||||
static auto getFTermFreeBSD() -> FTermFreeBSD&;
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
|
||||
static auto getFTermOpenBSD() -> FTermOpenBSD&;
|
||||
#endif
|
||||
|
||||
#if DEBUG
|
||||
static auto getFTermDebugData() -> FTermDebugData&;
|
||||
#endif
|
||||
|
||||
// Inquiries
|
||||
static bool isNormal (const FChar&);
|
||||
|
@ -224,7 +268,7 @@ class FTerm final
|
|||
static int openConsole();
|
||||
static int closeConsole();
|
||||
static std::string moveCursorString (int, int, int, int);
|
||||
static std::string cursorsVisibilityString (bool = true);
|
||||
static const char* cursorsVisibilityString (bool = true);
|
||||
static void detectTermSize();
|
||||
static void setTermSize (const FSize&);
|
||||
static void setTermTitle (const FString&);
|
||||
|
@ -257,7 +301,7 @@ class FTerm final
|
|||
|
||||
void initTerminal();
|
||||
static void initScreenSettings();
|
||||
static std::string changeAttribute (FChar&, FChar&);
|
||||
static const char* changeAttribute (FChar&, FChar&);
|
||||
static void changeTermSizeFinished();
|
||||
|
||||
private:
|
||||
|
@ -292,8 +336,8 @@ class FTerm final
|
|||
static void restoreColorPalette();
|
||||
static void setInsertCursorStyle();
|
||||
static void setOverwriteCursorStyle();
|
||||
static std::string enableCursorString();
|
||||
static std::string disableCursorString();
|
||||
static const char* enableCursorString();
|
||||
static const char* disableCursorString();
|
||||
static void enableMouse();
|
||||
static void disableMouse();
|
||||
static void enableApplicationEscKey();
|
||||
|
@ -323,7 +367,7 @@ class FTerm final
|
|||
// non-member function forward declarations
|
||||
// implemented in fterm_functions.cpp
|
||||
//----------------------------------------------------------------------
|
||||
uInt env2uint (const std::string&);
|
||||
uInt env2uint (const char*);
|
||||
bool isReverseNewFontchar (wchar_t);
|
||||
bool hasFullWidthSupports();
|
||||
wchar_t cp437_to_unicode (uChar);
|
||||
|
@ -360,7 +404,7 @@ inline FString FTerm::getClassName()
|
|||
//----------------------------------------------------------------------
|
||||
inline void FTerm::setFSystem (std::unique_ptr<FSystem>& fsystem)
|
||||
{
|
||||
FSystem::getInstance().swap(fsystem);
|
||||
getFSystem().swap(fsystem);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -375,8 +419,8 @@ inline bool FTerm::unsetUTF8()
|
|||
template <typename ClassT>
|
||||
inline void FTerm::setColorPaletteTheme (const FSetPalette& f)
|
||||
{
|
||||
FColorPalette::getInstance() = std::make_shared<ClassT>(f); // Set instance
|
||||
FColorPalette::getInstance()->setColorPalette(); // Set palette
|
||||
getColorPaletteTheme() = std::make_shared<ClassT>(f);
|
||||
getColorPaletteTheme()->setColorPalette();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -111,7 +111,7 @@ class FTermBuffer
|
|||
private:
|
||||
FCharVector data{};
|
||||
void add ( FString::const_iterator&
|
||||
, const FString::const_iterator&
|
||||
, FString::const_iterator&
|
||||
, int& );
|
||||
|
||||
// Non-member operators
|
||||
|
|
|
@ -41,8 +41,6 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "final/ftypes.h"
|
||||
|
||||
// FTermcap string macro
|
||||
#define TCAP(...) FTermcap::strings[int(Termcap::__VA_ARGS__)].string
|
||||
|
||||
|
@ -131,7 +129,7 @@ class FTermcap final
|
|||
static void termcapStrings();
|
||||
static void termcapKeys();
|
||||
static std::string encodeParams ( const std::string&
|
||||
, const std::array<int, 9>& );
|
||||
, const std::vector<int>& );
|
||||
template<typename PutChar>
|
||||
static void delay_output (int, const PutChar&);
|
||||
|
||||
|
@ -151,9 +149,7 @@ inline FString FTermcap::getClassName() const
|
|||
template <typename... Args>
|
||||
std::string FTermcap::encodeParameter (const std::string& cap, Args&&... args)
|
||||
{
|
||||
std::array<int, 9> attr{{ 0, 0, 0, 0, 0, 0, 0, 0, 0 }};
|
||||
attr = {{static_cast<int>(args)...}};
|
||||
return encodeParams(cap, attr);
|
||||
return encodeParams(cap, {static_cast<int>(args)...});
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -72,7 +72,6 @@ class FTermData final
|
|||
|
||||
// Accessors
|
||||
FString getClassName() const;
|
||||
static auto getInstance() -> FTermData&;
|
||||
EncodingMap& getEncodingList();
|
||||
charSubstitution& getCharSubstitutionMap();
|
||||
Encoding getTermEncoding() const;
|
||||
|
@ -171,13 +170,6 @@ class FTermData final
|
|||
inline FString FTermData::getClassName() const
|
||||
{ return "FTermData"; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline auto FTermData::getInstance() -> FTermData&
|
||||
{
|
||||
static const auto& data = make_unique<FTermData>();
|
||||
return *data;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FTermData::EncodingMap& FTermData::getEncodingList()
|
||||
{ return encoding_list; }
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2018-2021 Markus Gans *
|
||||
* Copyright 2018-2020 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -35,13 +35,14 @@
|
|||
#error "Only <final/final.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include "final/fstring.h"
|
||||
|
||||
#if DEBUG
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
// class forward declaration
|
||||
class FTerm;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FTermDebugData
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -62,21 +63,16 @@ class FTermDebugData final
|
|||
FTermDebugData& operator = (const FTermDebugData&) = delete;
|
||||
|
||||
// Accessors
|
||||
static FString getClassName();
|
||||
static auto getInstance() -> FTermDebugData&;
|
||||
const FString& getAnswerbackString();
|
||||
const FString& getSecDAString();
|
||||
const FString& getTermType_256color();
|
||||
const FString& getTermType_Answerback();
|
||||
const FString& getTermType_SecDA();
|
||||
const char* getTermType_256color();
|
||||
const char* getTermType_Answerback();
|
||||
const char* getTermType_SecDA();
|
||||
#if defined(__linux__)
|
||||
int getFramebufferBpp();
|
||||
#endif
|
||||
};
|
||||
|
||||
inline FString FTermDebugData::getClassName()
|
||||
{ return "FTermDebugData"; }
|
||||
|
||||
} // namespace finalcut
|
||||
|
||||
#endif // DEBUG
|
||||
|
|
|
@ -79,12 +79,7 @@ class FTermDetection final
|
|||
uInt8 : 3; // padding bits
|
||||
};
|
||||
|
||||
struct kittyVersion
|
||||
{
|
||||
int primary{0};
|
||||
int secondary{0};
|
||||
};
|
||||
|
||||
struct kittyVersion; // forward declaration
|
||||
|
||||
// Constructors
|
||||
FTermDetection();
|
||||
|
@ -99,167 +94,183 @@ class FTermDetection final
|
|||
FTermDetection& operator = (const FTermDetection&) = delete;
|
||||
|
||||
// Accessor
|
||||
FString getClassName() const;
|
||||
static auto getInstance() -> FTermDetection&;
|
||||
const FString& getTermType() const;
|
||||
int getGnomeTerminalID() const;
|
||||
kittyVersion getKittyVersion() const;
|
||||
static FString getClassName();
|
||||
static const char* getTermType();
|
||||
static int getGnomeTerminalID();
|
||||
static kittyVersion getKittyVersion();
|
||||
FTerminalType& getTermTypeStruct();
|
||||
|
||||
#if DEBUG
|
||||
const FString& getAnswerbackString() const;
|
||||
const FString& getSecDAString() const;
|
||||
const FString& getTermType_256color() const;
|
||||
const FString& getTermType_Answerback() const;
|
||||
const FString& getTermType_SecDA() const;
|
||||
static const FString& getAnswerbackString();
|
||||
static const FString& getSecDAString();
|
||||
static const char* getTermType_256color();
|
||||
static const char* getTermType_Answerback();
|
||||
static const char* getTermType_SecDA();
|
||||
#endif
|
||||
|
||||
// Inquiries
|
||||
bool isAnsiTerminal() const;
|
||||
bool isXTerminal() const;
|
||||
bool isRxvtTerminal() const;
|
||||
bool isUrxvtTerminal() const;
|
||||
bool isKdeTerminal() const;
|
||||
bool isGnomeTerminal() const;
|
||||
bool isPuttyTerminal() const;
|
||||
bool isWindowsTerminal() const;
|
||||
bool isTeraTerm() const;
|
||||
bool isCygwinTerminal() const;
|
||||
bool isMinttyTerm() const;
|
||||
bool isLinuxTerm() const;
|
||||
bool isFreeBSDTerm() const;
|
||||
bool isNetBSDTerm() const;
|
||||
bool isOpenBSDTerm() const;
|
||||
bool isSunTerminal() const;
|
||||
bool isScreenTerm() const;
|
||||
bool isTmuxTerm() const;
|
||||
bool isKtermTerminal() const;
|
||||
bool isMltermTerminal() const;
|
||||
bool isKittyTerminal() const;
|
||||
bool canDisplay256Colors() const;
|
||||
bool hasTerminalDetection() const;
|
||||
bool hasSetCursorStyleSupport() const;
|
||||
static bool isAnsiTerminal();
|
||||
static bool isXTerminal();
|
||||
static bool isRxvtTerminal();
|
||||
static bool isUrxvtTerminal();
|
||||
static bool isKdeTerminal();
|
||||
static bool isGnomeTerminal();
|
||||
static bool isPuttyTerminal();
|
||||
static bool isWindowsTerminal();
|
||||
static bool isTeraTerm();
|
||||
static bool isCygwinTerminal();
|
||||
static bool isMinttyTerm();
|
||||
static bool isLinuxTerm();
|
||||
static bool isFreeBSDTerm();
|
||||
static bool isNetBSDTerm();
|
||||
static bool isOpenBSDTerm();
|
||||
static bool isSunTerminal();
|
||||
static bool isScreenTerm();
|
||||
static bool isTmuxTerm();
|
||||
static bool isKtermTerminal();
|
||||
static bool isMltermTerminal();
|
||||
static bool isKittyTerminal();
|
||||
static bool canDisplay256Colors();
|
||||
static bool hasTerminalDetection();
|
||||
static bool hasSetCursorStyleSupport();
|
||||
|
||||
// Mutators
|
||||
void setAnsiTerminal (bool = true);
|
||||
void setXTerminal (bool = true);
|
||||
void setRxvtTerminal (bool = true);
|
||||
void setUrxvtTerminal (bool = true);
|
||||
void setKdeTerminal (bool = true);
|
||||
void setGnomeTerminal (bool = true);
|
||||
void setPuttyTerminal (bool = true);
|
||||
void setWindowsTerminal (bool = true);
|
||||
void setTeraTerm (bool = true);
|
||||
void setCygwinTerminal (bool = true);
|
||||
void setMinttyTerm (bool = true);
|
||||
void setLinuxTerm (bool = true);
|
||||
void setFreeBSDTerm (bool = true);
|
||||
void setNetBSDTerm (bool = true);
|
||||
void setOpenBSDTerm (bool = true);
|
||||
void setSunTerminal (bool = true);
|
||||
void setScreenTerm (bool = true);
|
||||
void setTmuxTerm (bool = true);
|
||||
void setKtermTerminal (bool = true);
|
||||
void setMltermTerminal (bool = true);
|
||||
void setKittyTerminal (bool = true);
|
||||
void setTerminalDetection (bool = true);
|
||||
void setTtyTypeFileName (const FString&);
|
||||
static void setAnsiTerminal (bool = true);
|
||||
static void setXTerminal (bool = true);
|
||||
static void setRxvtTerminal (bool = true);
|
||||
static void setUrxvtTerminal (bool = true);
|
||||
static void setKdeTerminal (bool = true);
|
||||
static void setGnomeTerminal (bool = true);
|
||||
static void setPuttyTerminal (bool = true);
|
||||
static void setWindowsTerminal (bool = true);
|
||||
static void setTeraTerm (bool = true);
|
||||
static void setCygwinTerminal (bool = true);
|
||||
static void setMinttyTerm (bool = true);
|
||||
static void setLinuxTerm (bool = true);
|
||||
static void setFreeBSDTerm (bool = true);
|
||||
static void setNetBSDTerm (bool = true);
|
||||
static void setOpenBSDTerm (bool = true);
|
||||
static void setSunTerminal (bool = true);
|
||||
static void setScreenTerm (bool = true);
|
||||
static void setTmuxTerm (bool = true);
|
||||
static void setKtermTerminal (bool = true);
|
||||
static void setMltermTerminal (bool = true);
|
||||
static void setKittyTerminal (bool = true);
|
||||
static void setTerminalDetection (bool = true);
|
||||
static void setTtyTypeFileName (const char[]);
|
||||
|
||||
// Methods
|
||||
void detect();
|
||||
static void detect();
|
||||
|
||||
private:
|
||||
struct colorEnv
|
||||
{
|
||||
FString string1{};
|
||||
FString string2{};
|
||||
FString string3{};
|
||||
FString string4{};
|
||||
FString string5{};
|
||||
FString string6{};
|
||||
FString string7{};
|
||||
FString string8{};
|
||||
};
|
||||
|
||||
struct secondaryDA
|
||||
{
|
||||
int terminal_id_type{-1};
|
||||
int terminal_id_version{-1};
|
||||
int terminal_id_hardware{-1};
|
||||
};
|
||||
struct colorEnv; // forward declaration
|
||||
struct secondaryDA; // forward declaration
|
||||
|
||||
// Methods
|
||||
void getSystemTermType();
|
||||
bool getTTYtype();
|
||||
static void deallocation();
|
||||
static void getSystemTermType();
|
||||
static bool getTTYtype();
|
||||
#if F_HAVE_GETTTYNAM
|
||||
bool getTTYSFileEntry();
|
||||
static bool getTTYSFileEntry();
|
||||
#endif
|
||||
void termtypeAnalysis();
|
||||
void detectTerminal();
|
||||
FString init_256colorTerminal();
|
||||
bool get256colorEnvString();
|
||||
FString termtype_256color_quirks();
|
||||
FString determineMaxColor (const FString&);
|
||||
FString getXTermColorName (FColor) const;
|
||||
FString parseAnswerbackMsg (const FString&);
|
||||
FString getAnswerbackMsg() const;
|
||||
FString parseSecDA (const FString&);
|
||||
int str2int (const FString&) const;
|
||||
FString getSecDA() const;
|
||||
FString secDA_Analysis (const FString&);
|
||||
FString secDA_Analysis_0 (const FString&);
|
||||
FString secDA_Analysis_1 (const FString&);
|
||||
FString secDA_Analysis_24 (const FString&);
|
||||
FString secDA_Analysis_32 ();
|
||||
FString secDA_Analysis_65 (const FString&);
|
||||
FString secDA_Analysis_67 ();
|
||||
FString secDA_Analysis_77 ();
|
||||
FString secDA_Analysis_82 ();
|
||||
FString secDA_Analysis_83 (const FString&);
|
||||
FString secDA_Analysis_84 (const FString&);
|
||||
FString secDA_Analysis_85 ();
|
||||
FString secDA_Analysis_vte (const FString&);
|
||||
FString secDA_Analysis_kitty (const FString&);
|
||||
static void termtypeAnalysis();
|
||||
static void detectTerminal();
|
||||
static const char* init_256colorTerminal();
|
||||
static bool get256colorEnvString();
|
||||
static const char* termtype_256color_quirks();
|
||||
static const char* determineMaxColor (const char[]);
|
||||
static FString getXTermColorName (FColor);
|
||||
static const char* parseAnswerbackMsg (const char[]);
|
||||
static FString getAnswerbackMsg();
|
||||
static const char* parseSecDA (const char[]);
|
||||
static int str2int (const FString&);
|
||||
static FString getSecDA();
|
||||
static const char* secDA_Analysis (const char[]);
|
||||
static const char* secDA_Analysis_0 (const char[]);
|
||||
static const char* secDA_Analysis_1 (const char[]);
|
||||
static const char* secDA_Analysis_24 (const char[]);
|
||||
static const char* secDA_Analysis_32 (const char[]);
|
||||
static const char* secDA_Analysis_65 (const char[]);
|
||||
static const char* secDA_Analysis_67 (const char[]);
|
||||
static const char* secDA_Analysis_77 (const char[]);
|
||||
static const char* secDA_Analysis_82 ();
|
||||
static const char* secDA_Analysis_83 (const char[]);
|
||||
static const char* secDA_Analysis_84 (const char[]);
|
||||
static const char* secDA_Analysis_85 ();
|
||||
static const char* secDA_Analysis_vte (const char[]);
|
||||
static const char* secDA_Analysis_kitty (const char[]);
|
||||
|
||||
// Data members
|
||||
#if DEBUG
|
||||
FString termtype_256color{};
|
||||
FString termtype_Answerback{};
|
||||
FString termtype_SecDA{};
|
||||
static char termtype_256color[256];
|
||||
static char termtype_Answerback[256];
|
||||
static char termtype_SecDA[256];
|
||||
#endif
|
||||
FString termtype{};
|
||||
FString ttytypename{"/etc/ttytype"}; // Default ttytype file
|
||||
bool decscusr_support{false}; // Preset to false
|
||||
bool terminal_detection{true}; // Preset to true
|
||||
bool color256{};
|
||||
// Gnome terminal id from SecDA
|
||||
// Example: vte version 0.40.0 = 0 * 100 + 40 * 100 + 0 = 4000
|
||||
// a.b.c = a * 100 + b * 100 + c
|
||||
int gnome_terminal_id{0};
|
||||
FString answer_back{};
|
||||
FString sec_da{};
|
||||
FTerminalType terminal_type{};
|
||||
colorEnv color_env{};
|
||||
kittyVersion kitty_version{};
|
||||
secondaryDA secondary_da{};
|
||||
static char termtype[256];
|
||||
static char ttytypename[256];
|
||||
static bool decscusr_support;
|
||||
static bool terminal_detection;
|
||||
static bool color256;
|
||||
static int gnome_terminal_id;
|
||||
static const FString* answer_back;
|
||||
static const FString* sec_da;
|
||||
static FTerminalType terminal_type;
|
||||
static colorEnv color_env;
|
||||
static kittyVersion kitty_version;
|
||||
static secondaryDA secondary_da;
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// struct FTermDetection::colorEnv
|
||||
//----------------------------------------------------------------------
|
||||
struct FTermDetection::colorEnv
|
||||
{
|
||||
char* string1{nullptr};
|
||||
char* string2{nullptr};
|
||||
char* string3{nullptr};
|
||||
char* string4{nullptr};
|
||||
char* string5{nullptr};
|
||||
char* string6{nullptr};
|
||||
char* string7{nullptr};
|
||||
char* string8{nullptr};
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// struct FTermDetection::KittyVersion
|
||||
//----------------------------------------------------------------------
|
||||
struct FTermDetection::kittyVersion
|
||||
{
|
||||
int primary{0};
|
||||
int secondary{0};
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// struct FTermDetection::secondaryDA
|
||||
//----------------------------------------------------------------------
|
||||
struct FTermDetection::secondaryDA
|
||||
{
|
||||
int terminal_id_type{-1};
|
||||
int terminal_id_version{-1};
|
||||
int terminal_id_hardware{-1};
|
||||
};
|
||||
|
||||
|
||||
// FTermDetection inline functions
|
||||
//----------------------------------------------------------------------
|
||||
inline FString FTermDetection::getClassName() const
|
||||
inline FString FTermDetection::getClassName()
|
||||
{ return "FTermDetection"; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline const FString& FTermDetection::getTermType() const
|
||||
inline const char* FTermDetection::getTermType()
|
||||
{ return termtype; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline int FTermDetection::getGnomeTerminalID() const
|
||||
inline int FTermDetection::getGnomeTerminalID()
|
||||
{ return gnome_terminal_id; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FTermDetection::kittyVersion FTermDetection::getKittyVersion() const
|
||||
inline FTermDetection::kittyVersion FTermDetection::getKittyVersion()
|
||||
{ return kitty_version; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -268,112 +279,112 @@ inline FTermDetection::FTerminalType& FTermDetection::getTermTypeStruct()
|
|||
|
||||
#if DEBUG
|
||||
//----------------------------------------------------------------------
|
||||
inline const FString& FTermDetection::getTermType_256color() const
|
||||
inline const char* FTermDetection::getTermType_256color()
|
||||
{ return termtype_256color; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline const FString& FTermDetection::getTermType_Answerback() const
|
||||
inline const char* FTermDetection::getTermType_Answerback()
|
||||
{ return termtype_Answerback; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline const FString& FTermDetection::getTermType_SecDA() const
|
||||
inline const char* FTermDetection::getTermType_SecDA()
|
||||
{ return termtype_SecDA; }
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::canDisplay256Colors() const
|
||||
inline bool FTermDetection::canDisplay256Colors()
|
||||
{ return color256; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::hasSetCursorStyleSupport() const
|
||||
inline bool FTermDetection::hasSetCursorStyleSupport()
|
||||
{ return decscusr_support; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isXTerminal() const
|
||||
inline bool FTermDetection::isXTerminal()
|
||||
{ return terminal_type.xterm; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isAnsiTerminal() const
|
||||
inline bool FTermDetection::isAnsiTerminal()
|
||||
{ return terminal_type.ansi; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isRxvtTerminal() const
|
||||
inline bool FTermDetection::isRxvtTerminal()
|
||||
{ return terminal_type.rxvt; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isUrxvtTerminal() const
|
||||
inline bool FTermDetection::isUrxvtTerminal()
|
||||
{ return terminal_type.urxvt; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isMltermTerminal() const
|
||||
inline bool FTermDetection::isMltermTerminal()
|
||||
{ return terminal_type.mlterm; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isKittyTerminal() const
|
||||
inline bool FTermDetection::isKittyTerminal()
|
||||
{ return terminal_type.kitty; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isPuttyTerminal() const
|
||||
inline bool FTermDetection::isPuttyTerminal()
|
||||
{ return terminal_type.putty; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isWindowsTerminal() const
|
||||
inline bool FTermDetection::isWindowsTerminal()
|
||||
{ return terminal_type.win_terminal; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isKdeTerminal() const
|
||||
inline bool FTermDetection::isKdeTerminal()
|
||||
{ return terminal_type.kde_konsole; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isGnomeTerminal() const
|
||||
inline bool FTermDetection::isGnomeTerminal()
|
||||
{ return terminal_type.gnome_terminal; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isKtermTerminal() const
|
||||
inline bool FTermDetection::isKtermTerminal()
|
||||
{ return terminal_type.kterm; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isTeraTerm() const
|
||||
inline bool FTermDetection::isTeraTerm()
|
||||
{ return terminal_type.tera_term; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isCygwinTerminal() const
|
||||
inline bool FTermDetection::isCygwinTerminal()
|
||||
{ return terminal_type.cygwin; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isMinttyTerm() const
|
||||
inline bool FTermDetection::isMinttyTerm()
|
||||
{ return terminal_type.mintty; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isLinuxTerm() const
|
||||
inline bool FTermDetection::isLinuxTerm()
|
||||
{ return terminal_type.linux_con; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isFreeBSDTerm() const
|
||||
inline bool FTermDetection::isFreeBSDTerm()
|
||||
{ return terminal_type.freebsd_con; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isNetBSDTerm() const
|
||||
inline bool FTermDetection::isNetBSDTerm()
|
||||
{ return terminal_type.netbsd_con; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isOpenBSDTerm() const
|
||||
inline bool FTermDetection::isOpenBSDTerm()
|
||||
{ return terminal_type.openbsd_con; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isSunTerminal() const
|
||||
inline bool FTermDetection::isSunTerminal()
|
||||
{ return terminal_type.sun_con; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isScreenTerm() const
|
||||
inline bool FTermDetection::isScreenTerm()
|
||||
{ return terminal_type.screen; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isTmuxTerm() const
|
||||
inline bool FTermDetection::isTmuxTerm()
|
||||
{ return terminal_type.tmux; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::hasTerminalDetection() const
|
||||
inline bool FTermDetection::hasTerminalDetection()
|
||||
{ return terminal_detection; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -83,7 +83,6 @@ class FTermFreeBSD final
|
|||
|
||||
// Accessors
|
||||
FString getClassName() const;
|
||||
static auto getInstance() -> FTermFreeBSD&;
|
||||
static CursorStyle getCursorStyle();
|
||||
|
||||
// Inquiry
|
||||
|
|
|
@ -92,7 +92,6 @@ class FTermLinux final
|
|||
|
||||
// Accessors
|
||||
FString getClassName() const;
|
||||
static auto getInstance() -> FTermLinux&;
|
||||
CursorStyle getCursorStyle() const;
|
||||
char* getCursorStyleString();
|
||||
int getFramebufferBpp() const;
|
||||
|
|
|
@ -73,7 +73,6 @@ class FTermOpenBSD final
|
|||
public:
|
||||
// Accessor
|
||||
FString getClassName() const;
|
||||
static auto getInstance() -> FTermOpenBSD&;
|
||||
|
||||
// Inquiries
|
||||
static bool isBSDConsole();
|
||||
|
|
|
@ -66,7 +66,6 @@ class FTermXTerminal final
|
|||
|
||||
// Accessors
|
||||
FString getClassName() const;
|
||||
static auto getInstance() -> FTermXTerminal&;
|
||||
XTermCursorStyle getCursorStyle() const;
|
||||
FString getFont() const;
|
||||
FString getTitle() const;
|
||||
|
|
|
@ -251,6 +251,10 @@ void FTextView::insert (const std::initializer_list<T>& list, int pos)
|
|||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FTextView::deleteRange (int from, int to)
|
||||
{ replaceRange (FString(), from, to); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FTextView::deleteLine (int pos)
|
||||
{ deleteRange (pos, pos); }
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include <cstring>
|
||||
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
|
@ -69,7 +68,7 @@ using sInt32 = std::int32_t;
|
|||
using sInt64 = std::int64_t;
|
||||
|
||||
using lDouble = long double;
|
||||
using TimeValue = std::chrono::time_point<std::chrono::system_clock>;
|
||||
|
||||
using FCall = std::function<void()>;
|
||||
|
||||
namespace finalcut
|
||||
|
@ -120,34 +119,8 @@ std::unique_ptr<T> make_unique (Args&&... args)
|
|||
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
template <typename Iter>
|
||||
constexpr std::reverse_iterator<Iter> make_reverse_iterator (Iter iter)
|
||||
{
|
||||
return std::reverse_iterator<Iter>(iter);
|
||||
}
|
||||
|
||||
template <typename CharT>
|
||||
constexpr std::size_t stringLength (const CharT* s)
|
||||
{
|
||||
return std::char_traits<CharT>::length(s);
|
||||
}
|
||||
|
||||
using charSubstitution = std::unordered_map<wchar_t, wchar_t>;
|
||||
|
||||
struct TCapAttributes
|
||||
{
|
||||
uInt8 p1 : 1; // Standout
|
||||
uInt8 p2 : 1; // Underline
|
||||
uInt8 p3 : 1; // Reverse
|
||||
uInt8 p4 : 1; // Blink
|
||||
uInt8 p5 : 1; // Dim
|
||||
uInt8 p6 : 1; // Bold
|
||||
uInt8 p7 : 1; // Invisible
|
||||
uInt8 p8 : 1; // Protected
|
||||
uInt8 p9 : 1; // Alternate charset
|
||||
uInt8 : 7; // padding bits
|
||||
};
|
||||
|
||||
struct FCharAttribute
|
||||
{
|
||||
// Attribute byte #0
|
||||
|
|
|
@ -418,8 +418,10 @@ class FVTerm
|
|||
bool updateTerminalLine (uInt) const;
|
||||
bool updateTerminalCursor() const;
|
||||
bool isInsideTerminal (const FPoint&) const;
|
||||
bool isTermSizeChanged() const;
|
||||
void flushTimeAdjustment() const;
|
||||
static bool isFlushTimeout();
|
||||
static bool isTermSizeCheckTimeout();
|
||||
static bool hasPendingUpdates (const FTermArea*);
|
||||
static void markAsPrinted (uInt, uInt);
|
||||
static void markAsPrinted (uInt, uInt, uInt);
|
||||
|
@ -451,7 +453,8 @@ class FVTerm
|
|||
static FChar next_attribute;
|
||||
static FChar s_ch; // shadow character
|
||||
static FChar i_ch; // inherit background character
|
||||
static TimeValue time_last_flush;
|
||||
static timeval time_last_flush;
|
||||
static timeval last_term_size_check;
|
||||
static bool draw_completed;
|
||||
static bool combined_char_support;
|
||||
static bool no_terminal_updates;
|
||||
|
@ -459,6 +462,7 @@ class FVTerm
|
|||
static uInt64 flush_wait;
|
||||
static uInt64 flush_average;
|
||||
static uInt64 flush_median;
|
||||
static uInt64 term_size_check_timeout;
|
||||
static uInt erase_char_length;
|
||||
static uInt repeat_char_length;
|
||||
static uInt clr_bol_length;
|
||||
|
|
|
@ -507,7 +507,6 @@ class FWidget : public FVTerm, public FObject
|
|||
void detectTermSize();
|
||||
bool isFocusNextKey (const FKey);
|
||||
bool isFocusPrevKey (const FKey);
|
||||
bool isInFWidgetList (const FWidget::FWidgetList*, const FWidget*);
|
||||
FKey getHotkey (const FString&);
|
||||
std::size_t getHotkeyPos (const FString& src, FString& dest);
|
||||
void setHotkeyViaString (FWidget*, const FString&);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2019-2021 Markus Gans *
|
||||
* Copyright 2019-2020 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -49,10 +49,13 @@ class SGRoptimizer final
|
|||
{
|
||||
public:
|
||||
// Constants
|
||||
static constexpr std::string::size_type ATTR_BUF_SIZE{8192u};
|
||||
static constexpr std::size_t ATTR_BUF_SIZE{8192};
|
||||
|
||||
// Using-declaration
|
||||
using AttributeBuffer = std::array<char, ATTR_BUF_SIZE>;
|
||||
|
||||
// Constructors
|
||||
explicit SGRoptimizer (std::string&);
|
||||
explicit SGRoptimizer (AttributeBuffer&);
|
||||
|
||||
// Disable copy constructor
|
||||
SGRoptimizer (const SGRoptimizer&) = delete;
|
||||
|
@ -75,7 +78,7 @@ class SGRoptimizer final
|
|||
void combineParameter();
|
||||
|
||||
// Data member
|
||||
std::string& seq;
|
||||
AttributeBuffer& seq;
|
||||
|
||||
struct parameter
|
||||
{
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue