Compare commits
24 Commits
Author | SHA1 | Date |
---|---|---|
Nicolas H | 8d31ee3056 | |
Nicolas H | 79d4f6f7a9 | |
Nicolas H | ea7f53be41 | |
Markus Gans | cf37e826e9 | |
Markus Gans | 3bf9713d23 | |
Markus Gans | 45110c5b21 | |
Markus Gans | 7170fc846c | |
Markus Gans | 9931f75a51 | |
Markus Gans | 65c249dfe0 | |
Markus Gans | c4376bae3e | |
Markus Gans | 85ae1612fd | |
Markus Gans | de4ac269e4 | |
Markus Gans | 2dc8d7f2d3 | |
Markus Gans | e38d604544 | |
Markus Gans | 7d426ae25c | |
Markus Gans | 5336462e68 | |
Markus Gans | 7f9ba7464b | |
Markus Gans | 95c0717589 | |
Markus Gans | 920daaba1f | |
Markus Gans | f06ccc6495 | |
Markus Gans | 795ebcdea8 | |
Markus Gans | eacc857143 | |
Markus Gans | 7462c60cfd | |
Markus Gans | af5ec304d8 |
|
@ -0,0 +1,38 @@
|
|||
---
|
||||
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?
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
---
|
||||
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.
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
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"
|
||||
name: "CodeQL analysis"
|
||||
|
||||
on:
|
||||
push:
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
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)
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
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"
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
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
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
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
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
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
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
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
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
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
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
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
|
||||
|
187
.travis.yml
187
.travis.yml
|
@ -1,187 +0,0 @@
|
|||
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
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# 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,3 +1,33 @@
|
|||
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.org/gansm/finalcut.svg?branch=main)](https://travis-ci.org/gansm/finalcut)
|
||||
| *Travis CI* | [![Build Status](https://travis-ci.com/gansm/finalcut.svg?branch=main)](https://travis-ci.com/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) |
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
# 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" # "-fno-rtti"
|
||||
if ! ./configure --prefix="$PREFIX" CXXFLAGS="-O3" # "-flto -fno-rtti"
|
||||
then
|
||||
echo "${RED}Configure failed!${NORMAL}" 1>&2
|
||||
exit 255
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
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.isNull() || display.isEmpty() )
|
||||
if ( display.isEmpty() )
|
||||
display = L'0';
|
||||
|
||||
if ( display.right(3) == L"-0." )
|
||||
|
@ -651,7 +651,6 @@ void Calc::radix_point (const lDouble&)
|
|||
return;
|
||||
|
||||
if ( isDataEntryKey(last_key)
|
||||
&& ! input.isNull()
|
||||
&& ! input.isEmpty()
|
||||
&& ! input.includes('.') )
|
||||
input += '.';
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
using finalcut::FPoint;
|
||||
|
@ -61,10 +60,16 @@ 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};
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -100,10 +105,11 @@ 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
|
||||
(
|
||||
|
@ -118,6 +124,24 @@ 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
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -181,7 +205,10 @@ void Listview::initLayout()
|
|||
// Set FListView geometry
|
||||
listview.setGeometry(FPoint{2, 1}, FSize{33, 14});
|
||||
// Set quit button geometry
|
||||
quit.setGeometry(FPoint{24, 16}, FSize{10, 1});
|
||||
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});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
|
@ -191,6 +218,16 @@ 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()
|
||||
{
|
||||
|
@ -206,7 +243,18 @@ 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::getFStartOptions();
|
||||
auto& start_options = finalcut::FStartOptions::getInstance();
|
||||
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::FTerm::getFOptiMove();
|
||||
const auto& opti_move = finalcut::FOptiMove::getInstance();
|
||||
finalcut::printDurations(opti_move);
|
||||
|
||||
// Waiting for keypress
|
||||
|
|
|
@ -190,7 +190,7 @@ void RotoZoomer::generateReport()
|
|||
finalcut::FStringStream rep;
|
||||
dimension_str << getDesktopWidth()
|
||||
<< "x" << getDesktopHeight();
|
||||
int elapsed_ms = int(duration_cast<milliseconds>(end - start).count());
|
||||
auto 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::getFStartOptions();
|
||||
auto& start_options = finalcut::FStartOptions::getInstance();
|
||||
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 (const finalcut::FApplication&);
|
||||
void debug();
|
||||
void booleans();
|
||||
void numeric();
|
||||
void string();
|
||||
|
@ -167,22 +167,21 @@ void tcapNumeric (const std::string& name, int cap_num)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void tcapString (const std::string& name, const char cap_str[])
|
||||
void tcapString (const std::string& name, const char cap_string[])
|
||||
{
|
||||
std::string sequence{};
|
||||
std::string cap_str{cap_string ? cap_string : std::string{}};
|
||||
std::cout << name << ": ";
|
||||
|
||||
if ( cap_str == nullptr )
|
||||
if ( cap_str.empty() )
|
||||
{
|
||||
std::cout << "\r\n";
|
||||
return;
|
||||
}
|
||||
|
||||
const auto len = uInt(std::strlen(cap_str));
|
||||
|
||||
for (uInt i{0}; i < len; i++)
|
||||
for (auto&& ch : cap_str)
|
||||
{
|
||||
const auto c = uChar(cap_str[i]);
|
||||
const auto c = uChar(ch);
|
||||
|
||||
if ( c > 127 )
|
||||
{
|
||||
|
@ -211,10 +210,9 @@ void tcapString (const std::string& name, const char cap_str[])
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
#if DEBUG
|
||||
void debug (const finalcut::FApplication& TermApp)
|
||||
void showDebug()
|
||||
{
|
||||
const auto& fterm = TermApp.getFTerm();
|
||||
auto& debug_data = fterm.getFTermDebugData();
|
||||
auto& debug_data = finalcut::FTermDebugData::getInstance();
|
||||
const auto& ab_s = debug_data.getAnswerbackString();
|
||||
const auto& sec_da = debug_data.getSecDAString();
|
||||
std::cout << "\n.------------------- debug -------------------\r\n";
|
||||
|
@ -240,14 +238,14 @@ void debug (const finalcut::FApplication& TermApp)
|
|||
std::cout << "`------------------- debug -------------------\r\n";
|
||||
}
|
||||
#else
|
||||
void debug (const finalcut::FApplication&)
|
||||
void showDebug()
|
||||
{
|
||||
// FINAL CUT was compiled without debug option
|
||||
}
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void booleans()
|
||||
void showBooleans()
|
||||
{
|
||||
std::cout << "\r\n[Booleans]\r\n";
|
||||
tcapBoolean ( "background_color_erase"
|
||||
|
@ -275,7 +273,7 @@ void booleans()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void numeric()
|
||||
void showNumeric()
|
||||
{
|
||||
std::cout << "\r\n[Numeric]\r\n";
|
||||
tcapNumeric ("max_color"
|
||||
|
@ -289,7 +287,7 @@ void numeric()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void string()
|
||||
void showString()
|
||||
{
|
||||
std::cout << "\r\n[String]\r\n";
|
||||
const auto& tcap_strings = finalcut::FTermcap::strings;
|
||||
|
@ -311,7 +309,7 @@ int main (int argc, char* argv[])
|
|||
finalcut::FTerm::useAlternateScreen(false);
|
||||
|
||||
// Disable color palette changes and terminal data requests
|
||||
auto& start_options = finalcut::FStartOptions::getFStartOptions();
|
||||
auto& start_options = finalcut::FStartOptions::getInstance();
|
||||
start_options.color_change = false;
|
||||
start_options.terminal_data_request = false;
|
||||
|
||||
|
@ -327,10 +325,9 @@ int main (int argc, char* argv[])
|
|||
std::cout << "--------\r\nFTermcap\r\n--------\r\n\n";
|
||||
std::cout << "Terminal: " << finalcut::FTerm::getTermType() << "\r\n";
|
||||
|
||||
debug (term_app);
|
||||
|
||||
booleans();
|
||||
numeric();
|
||||
string();
|
||||
showDebug();
|
||||
showBooleans();
|
||||
showNumeric();
|
||||
showString();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -427,7 +427,7 @@ void MyDialog::initMenu()
|
|||
Drive.setStatusbarMessage ("Show drive symbols");
|
||||
Line3.setSeparator();
|
||||
|
||||
if ( finalcut::FStartOptions::getFStartOptions().dark_theme )
|
||||
if ( finalcut::FStartOptions::getInstance().dark_theme )
|
||||
Theme.setChecked();
|
||||
}
|
||||
|
||||
|
@ -1013,7 +1013,7 @@ void MyDialog::cb_view (const finalcut::FMenuItem* item)
|
|||
else
|
||||
file = finalcut::FFileDialog::fileOpenChooser (this);
|
||||
|
||||
if ( file.isNull() )
|
||||
if ( file.isEmpty() )
|
||||
return;
|
||||
|
||||
const auto& view = new TextWindow(this);
|
||||
|
|
|
@ -110,15 +110,15 @@ Watch::Watch (FWidget* parent)
|
|||
void Watch::printTime()
|
||||
{
|
||||
finalcut::FString str{};
|
||||
std::tm now{};
|
||||
|
||||
const std::time_t t = std::time(nullptr); // get current time
|
||||
localtime_r(&t, &now);
|
||||
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);
|
||||
|
||||
if ( sec )
|
||||
str.sprintf("%02d:%02d:%02d", now.tm_hour, now.tm_min, now.tm_sec);
|
||||
str.sprintf("%02d:%02d:%02d", lt.tm_hour, lt.tm_min, lt.tm_sec);
|
||||
else
|
||||
str.sprintf("%02d:%02d ", now.tm_hour, now.tm_min);
|
||||
str.sprintf("%02d:%02d ", lt.tm_hour, lt.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"
|
||||
export CPPFLAGS="%{optflags} -Wall -Wextra -Wpedantic -flto"
|
||||
%ifnarch %ix86 x86_64
|
||||
export CPPFLAGS="$CPPFLAGS -Wno-error=unused-parameter"
|
||||
%endif
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
sonar.organization=gansm
|
||||
sonar.projectKey=gansm_finalcut
|
||||
sonar.projectName=finalcut
|
||||
sonar.projectVersion=0.7.2
|
||||
|
@ -16,6 +17,9 @@ 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)
|
||||
struct timeval FApplication::time_last_event {};
|
||||
TimeValue 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 = FTerm::getFTermData();
|
||||
auto& fterm_data = FTermData::getInstance();
|
||||
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 = FTerm::getFTermData();
|
||||
auto& fterm_data = FTermData::getInstance();
|
||||
fterm_data.setExitMessage ( "Could not open log file \""
|
||||
+ filename + "\"" );
|
||||
exit(EXIT_FAILURE);
|
||||
|
@ -392,11 +392,10 @@ void FApplication::init()
|
|||
setMaxChildren(1);
|
||||
|
||||
// Initialize the last event time
|
||||
time_last_event.tv_sec = 0;
|
||||
time_last_event.tv_usec = 0;
|
||||
time_last_event = TimeValue{};
|
||||
|
||||
// Initialize keyboard
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
auto& keyboard = FKeyboard::getInstance();
|
||||
auto cmd1 = [this] () { this->keyPressed(); };
|
||||
auto cmd2 = [this] () { this->keyReleased(); };
|
||||
auto cmd3 = [this] () { this->escapeKeyPressed(); };
|
||||
|
@ -413,7 +412,7 @@ void FApplication::init()
|
|||
keyboard.setKeypressTimeout (key_timeout);
|
||||
|
||||
// Initialize mouse control
|
||||
auto& mouse = FTerm::getFMouseControl();
|
||||
auto& mouse = FMouseControl::getInstance();
|
||||
auto cmd = [this] (const FMouseData& md) { this->mouseEvent(md); };
|
||||
FMouseCommand mouse_cmd (cmd);
|
||||
mouse.setEventCommand (mouse_cmd);
|
||||
|
@ -444,7 +443,7 @@ void FApplication::setTerminalEncoding (const FString& enc_str)
|
|||
showParameterUsage();
|
||||
else
|
||||
{
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
auto& fterm_data = FTermData::getInstance();
|
||||
fterm_data.setExitMessage ( "Unknown encoding \"" + enc_str
|
||||
+ "\"\n(Valid encodings are utf8, "
|
||||
+ "vt100, pc and ascii)" );
|
||||
|
@ -563,7 +562,7 @@ void FApplication::cmdOptions (const Args& args)
|
|||
//----------------------------------------------------------------------
|
||||
inline FStartOptions& FApplication::getStartOptions()
|
||||
{
|
||||
return FStartOptions::getFStartOptions();
|
||||
return FStartOptions::getInstance();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -658,8 +657,8 @@ inline void FApplication::findKeyboardWidget() const
|
|||
//----------------------------------------------------------------------
|
||||
inline bool FApplication::isKeyPressed() const
|
||||
{
|
||||
auto& mouse = FTerm::getFMouseControl();
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
auto& mouse = FMouseControl::getInstance();
|
||||
auto& keyboard = FKeyboard::getInstance();
|
||||
|
||||
if ( mouse.isGpmMouseEnabled() )
|
||||
return mouse.getGpmKeyPressed(keyboard.hasUnprocessedInput());
|
||||
|
@ -694,7 +693,7 @@ void FApplication::mouseTracking() const
|
|||
//----------------------------------------------------------------------
|
||||
inline void FApplication::performKeyboardAction()
|
||||
{
|
||||
const auto& keyboard = FTerm::getFKeyboard();
|
||||
const auto& keyboard = FKeyboard::getInstance();
|
||||
|
||||
if ( keyboard.getKey() == FKey::Ctrl_l ) // Ctrl-L (redraw the screen)
|
||||
{
|
||||
|
@ -713,8 +712,8 @@ inline void FApplication::performKeyboardAction()
|
|||
//----------------------------------------------------------------------
|
||||
inline void FApplication::performMouseAction() const
|
||||
{
|
||||
auto& mouse = FTerm::getFMouseControl();
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
auto& mouse = FMouseControl::getInstance();
|
||||
auto& keyboard = FKeyboard::getInstance();
|
||||
const auto key = keyboard.getKey();
|
||||
auto& buffer = keyboard.getKeyBuffer();
|
||||
|
||||
|
@ -761,7 +760,7 @@ inline void FApplication::sendEscapeKeyPressEvent() const
|
|||
inline bool FApplication::sendKeyDownEvent (FWidget* widget) const
|
||||
{
|
||||
// Send key down event
|
||||
const auto& keyboard = FTerm::getFKeyboard();
|
||||
const auto& keyboard = FKeyboard::getInstance();
|
||||
FKeyEvent k_down_ev (Event::KeyDown, keyboard.getKey());
|
||||
sendEvent (widget, &k_down_ev);
|
||||
return k_down_ev.isAccepted();
|
||||
|
@ -771,7 +770,7 @@ inline bool FApplication::sendKeyDownEvent (FWidget* widget) const
|
|||
inline bool FApplication::sendKeyPressEvent (FWidget* widget) const
|
||||
{
|
||||
// Send key press event
|
||||
const auto& keyboard = FTerm::getFKeyboard();
|
||||
const auto& keyboard = FKeyboard::getInstance();
|
||||
FKeyEvent k_press_ev (Event::KeyPress, keyboard.getKey());
|
||||
sendEvent (widget, &k_press_ev);
|
||||
return k_press_ev.isAccepted();
|
||||
|
@ -781,7 +780,7 @@ inline bool FApplication::sendKeyPressEvent (FWidget* widget) const
|
|||
inline bool FApplication::sendKeyUpEvent (FWidget* widget) const
|
||||
{
|
||||
// Send key up event
|
||||
const auto& keyboard = FTerm::getFKeyboard();
|
||||
const auto& keyboard = FKeyboard::getInstance();
|
||||
FKeyEvent k_up_ev (Event::KeyUp, keyboard.getKey());
|
||||
sendEvent (widget, &k_up_ev);
|
||||
return k_up_ev.isAccepted();
|
||||
|
@ -818,8 +817,8 @@ inline void FApplication::sendKeyboardAccelerator()
|
|||
//----------------------------------------------------------------------
|
||||
inline bool FApplication::hasDataInQueue() const
|
||||
{
|
||||
const auto& keyboard = FTerm::getFKeyboard();
|
||||
const auto& mouse = FTerm::getFMouseControl();
|
||||
const auto& keyboard = FKeyboard::getInstance();
|
||||
const auto& mouse = FMouseControl::getInstance();
|
||||
|
||||
if ( keyboard.hasDataInQueue()
|
||||
|| mouse.hasDataInQueue()
|
||||
|
@ -838,7 +837,7 @@ void FApplication::queuingKeyboardInput() const
|
|||
return;
|
||||
|
||||
findKeyboardWidget();
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
auto& keyboard = FKeyboard::getInstance();
|
||||
keyboard.escapeKeyHandling(); // special case: Esc key
|
||||
keyboard.clearKeyBufferOnTimeout();
|
||||
|
||||
|
@ -849,7 +848,7 @@ void FApplication::queuingKeyboardInput() const
|
|||
//----------------------------------------------------------------------
|
||||
void FApplication::queuingMouseInput() const
|
||||
{
|
||||
auto& mouse = FTerm::getFMouseControl();
|
||||
auto& mouse = FMouseControl::getInstance();
|
||||
|
||||
if ( quit_now
|
||||
|| internal::var::exit_loop
|
||||
|
@ -857,8 +856,8 @@ void FApplication::queuingMouseInput() const
|
|||
|| FTerm::hasChangedTermSize() )
|
||||
return;
|
||||
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
struct timeval* time_keypressed = keyboard.getKeyPressedTime();
|
||||
auto& keyboard = FKeyboard::getInstance();
|
||||
auto time_keypressed = keyboard.getKeyPressedTime();
|
||||
mouse.processEvent (time_keypressed);
|
||||
keyboard.hasUnprocessedInput() = mouse.hasUnprocessedInput();
|
||||
mouse.clearEvent();
|
||||
|
@ -872,7 +871,7 @@ void FApplication::processKeyboardEvent() const
|
|||
|| FTerm::hasChangedTermSize() )
|
||||
return;
|
||||
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
auto& keyboard = FKeyboard::getInstance();
|
||||
keyboard.processQueuedInput();
|
||||
}
|
||||
|
||||
|
@ -884,13 +883,13 @@ void FApplication::processMouseEvent() const
|
|||
|| FTerm::hasChangedTermSize() )
|
||||
return;
|
||||
|
||||
FTerm::getFMouseControl().processQueuedInput();
|
||||
FMouseControl::getInstance().processQueuedInput();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FApplication::processDialogSwitchAccelerator() const
|
||||
{
|
||||
const auto& keyboard = FTerm::getFKeyboard();
|
||||
const auto& keyboard = FKeyboard::getInstance();
|
||||
|
||||
if ( keyboard.getKey() >= FKey::Meta_1
|
||||
&& keyboard.getKey() <= FKey::Meta_9 )
|
||||
|
@ -928,7 +927,7 @@ bool FApplication::processAccelerator (const FWidget& widget) const
|
|||
|
||||
for (auto&& item : widget.getAcceleratorList())
|
||||
{
|
||||
if ( item.key == FTerm::getFKeyboard().getKey() )
|
||||
if ( item.key == FKeyboard::getInstance().getKey() )
|
||||
{
|
||||
// unset the move/size mode
|
||||
auto move_size = getMoveSizeWidget();
|
||||
|
@ -1258,7 +1257,7 @@ void FApplication::processResizeEvent() const
|
|||
return;
|
||||
|
||||
FTerm::detectTermSize(); // Detect and save the current terminal size
|
||||
auto& mouse = FTerm::getFMouseControl();
|
||||
auto& mouse = FMouseControl::getInstance();
|
||||
mouse.setMaxWidth (uInt16(getDesktopWidth()));
|
||||
mouse.setMaxHeight (uInt16(getDesktopHeight()));
|
||||
FResizeEvent r_ev(Event::Resize);
|
||||
|
@ -1308,7 +1307,7 @@ bool FApplication::processNextEvent()
|
|||
|
||||
if ( is_timeout || hasDataInQueue() )
|
||||
{
|
||||
FObject::getCurrentTime (&time_last_event);
|
||||
time_last_event = FObject::getCurrentTime();
|
||||
queuingKeyboardInput();
|
||||
queuingMouseInput();
|
||||
processKeyboardEvent();
|
||||
|
@ -1401,7 +1400,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-2020 Markus Gans *
|
||||
* Copyright 2012-2021 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,11 +209,7 @@ bool FButton::setDown (bool enable)
|
|||
//----------------------------------------------------------------------
|
||||
void FButton::setText (const FString& txt)
|
||||
{
|
||||
if ( txt.isNull() )
|
||||
text.setString("");
|
||||
else
|
||||
text.setString(txt);
|
||||
|
||||
text.setString(txt);
|
||||
detectHotkey();
|
||||
}
|
||||
|
||||
|
@ -323,6 +319,12 @@ 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.isNull() || text.isEmpty() )
|
||||
if ( text.isEmpty() )
|
||||
return;
|
||||
|
||||
FString label_text{};
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2015-2020 Markus Gans *
|
||||
* Copyright 2015-2021 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,10 +29,47 @@
|
|||
namespace finalcut
|
||||
{
|
||||
|
||||
namespace fc
|
||||
//----------------------------------------------------------------------
|
||||
auto FCharMap::getInstance() -> FCharMap&
|
||||
{
|
||||
static const auto& char_map = make_unique<FCharMap>();
|
||||
return *char_map;
|
||||
}
|
||||
|
||||
std::array<CharEncodeMap, 115> character =
|
||||
//----------------------------------------------------------------------
|
||||
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 =
|
||||
{{
|
||||
// .--------------------- Unicode (UTF-8)
|
||||
// | .--------------- VT100
|
||||
|
@ -161,8 +198,8 @@ std::array<CharEncodeMap, 115> character =
|
|||
* (2) Only supported in use with newfont
|
||||
*/
|
||||
|
||||
|
||||
constexpr std::array<DECSpecialGraphics, 39> dec_special_graphics =
|
||||
//----------------------------------------------------------------------
|
||||
constexpr FCharMap::DECGraphicsType FCharMap::dec_special_graphics =
|
||||
{{
|
||||
{VT100Key::rarrow , UniChar::BlackRightPointingPointer}, // ►
|
||||
{VT100Key::larrow , UniChar::BlackLeftPointingPointer}, // ◄
|
||||
|
@ -205,7 +242,8 @@ constexpr std::array<DECSpecialGraphics, 39> dec_special_graphics =
|
|||
{VT100Key::diamond , UniChar::Bullet} // ◆
|
||||
}};
|
||||
|
||||
constexpr std::array<std::array<wchar_t, 2>, 256> cp437_ucs =
|
||||
//----------------------------------------------------------------------
|
||||
constexpr FCharMap::Cp437UcsType FCharMap::cp437_ucs =
|
||||
{{
|
||||
{{0x00, 0x0000}}, // null
|
||||
{{0x01, 0x263a}}, // white smiling face
|
||||
|
@ -465,8 +503,9 @@ constexpr std::array<std::array<wchar_t, 2>, 256> cp437_ucs =
|
|||
{{0xff, 0x00a0}} // no-break space
|
||||
}};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Based on http://www.unicode.org/charts/PDF/UFF00.pdf
|
||||
constexpr std::array<std::array<wchar_t, 2>, 227> halfwidth_fullwidth =
|
||||
constexpr FCharMap::HalfFullWidthType FCharMap::halfwidth_fullwidth =
|
||||
{{
|
||||
// Fullwidth ASCII variants
|
||||
{{0x0020, 0x3000}}, // ' ' -> ' '
|
||||
|
@ -704,7 +743,4 @@ constexpr std::array<std::array<wchar_t, 2>, 227> halfwidth_fullwidth =
|
|||
{{0xffee, 0x25cb}} // ○ -> ○
|
||||
}};
|
||||
|
||||
} // namespace fc
|
||||
|
||||
} // namespace finalcut
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2020 Markus Gans *
|
||||
* Copyright 2020-2021 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,6 +39,15 @@ 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 = FTerm::getFMouseControl();
|
||||
auto& mouse = FMouseControl::getInstance();
|
||||
|
||||
if ( ! mouse.isLeftButtonPressed() )
|
||||
return;
|
||||
|
@ -630,7 +630,7 @@ void FComboBox::cb_inputFieldSwitch()
|
|||
//----------------------------------------------------------------------
|
||||
void FComboBox::cb_inputFieldHandOver()
|
||||
{
|
||||
auto& mouse = FTerm::getFMouseControl();
|
||||
auto& mouse = FMouseControl::getInstance();
|
||||
|
||||
if ( list_window.isHidden() )
|
||||
return;
|
||||
|
|
|
@ -100,7 +100,7 @@ bool FDialog::setModal (bool enable)
|
|||
if ( enable )
|
||||
{
|
||||
setModalDialogCounter()++;
|
||||
FTerm::getFKeyboard().clearKeyBuffer();
|
||||
FKeyboard::getInstance().clearKeyBuffer();
|
||||
}
|
||||
else
|
||||
setModalDialogCounter()--;
|
||||
|
|
|
@ -65,15 +65,15 @@ FString fileChooser ( FWidget* parent
|
|||
FString path{dirname};
|
||||
FString file_filter{filter};
|
||||
|
||||
if ( path.isNull() || path.isEmpty() )
|
||||
if ( path.isEmpty() )
|
||||
{
|
||||
path.setString(FFileDialog::getHomeDir());
|
||||
|
||||
if ( path.isNull() || path.isEmpty() )
|
||||
if ( path.isEmpty() )
|
||||
path.setString("/");
|
||||
}
|
||||
|
||||
if ( file_filter.isNull() || file_filter.isEmpty() )
|
||||
if ( 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.isNull() )
|
||||
if ( ! dirname.isEmpty() )
|
||||
setPath(dirname);
|
||||
|
||||
init();
|
||||
|
@ -162,7 +162,7 @@ void FFileDialog::setPath (const FString& dir)
|
|||
return;
|
||||
}
|
||||
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
|
||||
if ( fsystem->realpath(dir.c_str(), resolved_path.data()) != nullptr )
|
||||
r_dir.setString(resolved_path.data());
|
||||
|
@ -372,18 +372,16 @@ void FFileDialog::initCallbacks()
|
|||
inline bool FFileDialog::patternMatch ( const char* const pattern
|
||||
, const char fname[] ) const
|
||||
{
|
||||
std::array<char, 128> search{};
|
||||
std::string search{};
|
||||
search.reserve(128);
|
||||
|
||||
if ( show_hidden && fname[0] == '.' && fname[1] != '\0' ) // hidden files
|
||||
{
|
||||
search[0] = '.';
|
||||
search[1] = '\0';
|
||||
std::strncat(search.data(), pattern, search.size() - std::strlen(search.data()) - 1);
|
||||
search = ".";
|
||||
search.append(pattern);
|
||||
}
|
||||
else
|
||||
std::strncpy(search.data(), pattern, search.size() - 1);
|
||||
|
||||
search[search.size() - 1] = '\0';
|
||||
search = pattern;
|
||||
|
||||
if ( fnmatch (search.data(), fname, FNM_PERIOD) == 0 )
|
||||
return true;
|
||||
|
@ -480,15 +478,13 @@ int FFileDialog::readDir()
|
|||
|
||||
getEntry(dir, next);
|
||||
}
|
||||
else if ( errno != 0 )
|
||||
{
|
||||
FMessageBox::error (this, "Reading directory\n" + directory);
|
||||
|
||||
if ( errno == EOVERFLOW ) // Value too large to be stored in data type
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( errno != 0 )
|
||||
FMessageBox::error (this, "Reading directory\n" + directory);
|
||||
|
||||
break;
|
||||
}
|
||||
} // end while
|
||||
|
||||
if ( closedir(directory_stream) != 0 )
|
||||
|
@ -550,16 +546,11 @@ void FFileDialog::followSymLink (const char* const dir, FDirEntry& entry) const
|
|||
return; // No symbolic link
|
||||
|
||||
std::array<char, MAXPATHLEN> resolved_path{};
|
||||
std::array<char, MAXPATHLEN> symLink{};
|
||||
std::string symLink{};
|
||||
symLink.reserve(MAXPATHLEN);
|
||||
struct stat sb{};
|
||||
|
||||
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';
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
symLink = dir + entry.name;
|
||||
|
||||
if ( fsystem->realpath(symLink.data(), resolved_path.data()) == nullptr )
|
||||
return; // Cannot follow the symlink
|
||||
|
@ -691,7 +682,7 @@ FString FFileDialog::getHomeDir()
|
|||
struct passwd* pwd_ptr{};
|
||||
std::array<char, 1024> buf{};
|
||||
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const uid_t euid = fsystem->geteuid();
|
||||
|
||||
if ( fsystem->getpwuid_r(euid, &pwd, buf.data(), buf.size(), &pwd_ptr) )
|
||||
|
@ -735,7 +726,7 @@ void FFileDialog::cb_processActivate()
|
|||
{
|
||||
return ! entry.name.empty()
|
||||
&& input
|
||||
&& ! input.isNull()
|
||||
&& ! input.isEmpty()
|
||||
&& 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-2020 Markus Gans *
|
||||
* Copyright 2018-2021 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,10 +28,33 @@
|
|||
namespace finalcut
|
||||
{
|
||||
|
||||
namespace fc
|
||||
//----------------------------------------------------------------------
|
||||
auto FKeyMap::getInstance() -> FKeyMap&
|
||||
{
|
||||
static const auto& key_map = make_unique<FKeyMap>();
|
||||
return *key_map;
|
||||
}
|
||||
|
||||
std::array<FKeyCapMap, 188> fkey_cap_table
|
||||
//----------------------------------------------------------------------
|
||||
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
|
||||
{{
|
||||
{ FKey::Backspace , nullptr, "kb" }, // Backspace key
|
||||
{ FKey::Clear_all_tabs , nullptr, "ka" }, // Clear-all-tabs key
|
||||
|
@ -228,7 +251,8 @@ std::array<FKeyCapMap, 188> fkey_cap_table
|
|||
{ FKey::Lower_right , ESC "Os", "K5x"} // Keypad Lower right
|
||||
}};
|
||||
|
||||
constexpr std::array<FKeyMap, 232> fkey_table =
|
||||
//----------------------------------------------------------------------
|
||||
constexpr FKeyMap::KeyMapType FKeyMap::fkey_table =
|
||||
{{
|
||||
{ FKey::Meta_insert , "\033[2;3~" }, // M-Insert
|
||||
{ FKey::Meta_insert , "\033\033[2~" }, // M-Insert
|
||||
|
@ -464,7 +488,8 @@ constexpr std::array<FKeyMap, 232> fkey_table =
|
|||
{ FKey::Meta_tilde , "\033~" } // M-~
|
||||
}};
|
||||
|
||||
constexpr std::array<FKeyName, 388> fkeyname =
|
||||
//----------------------------------------------------------------------
|
||||
constexpr FKeyMap::KeyNameType FKeyMap::fkeyname =
|
||||
{{
|
||||
{ FKey::Ctrl_a , "Ctrl+A" },
|
||||
{ FKey::Ctrl_b , "Ctrl+B" },
|
||||
|
@ -856,6 +881,4 @@ constexpr std::array<FKeyName, 388> 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};
|
||||
struct timeval FKeyboard::time_keypressed{};
|
||||
TimeValue FKeyboard::time_keypressed{};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -63,8 +63,7 @@ struct timeval FKeyboard::time_keypressed{};
|
|||
FKeyboard::FKeyboard()
|
||||
{
|
||||
// Initialize keyboard values
|
||||
time_keypressed.tv_sec = 0;
|
||||
time_keypressed.tv_usec = 0;
|
||||
time_keypressed = TimeValue{}; // Set to epoch time
|
||||
|
||||
// Get the stdin file status flags
|
||||
stdin_status_flags = fcntl(FTermios::getStdIn(), F_GETFL);
|
||||
|
@ -75,6 +74,13 @@ FKeyboard::FKeyboard()
|
|||
|
||||
|
||||
// public methods of FKeyboard
|
||||
//----------------------------------------------------------------------
|
||||
auto FKeyboard::getInstance() -> FKeyboard&
|
||||
{
|
||||
static const auto& keyboard = make_unique<FKeyboard>();
|
||||
return *keyboard;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FKeyboard::fetchKeyCode()
|
||||
{
|
||||
|
@ -85,17 +91,18 @@ void FKeyboard::fetchKeyCode()
|
|||
//----------------------------------------------------------------------
|
||||
FString FKeyboard::getKeyName (const FKey keynum) const
|
||||
{
|
||||
const auto& fkeyname = FKeyMap::getKeyName();
|
||||
const auto& found_key = std::find_if
|
||||
(
|
||||
fc::fkeyname.cbegin(),
|
||||
fc::fkeyname.cend(),
|
||||
[&keynum] (const fc::FKeyName& kn)
|
||||
fkeyname.cbegin(),
|
||||
fkeyname.cend(),
|
||||
[&keynum] (const FKeyMap::KeyName& kn)
|
||||
{
|
||||
return ( kn.num != FKey::None && kn.num == keynum );
|
||||
}
|
||||
);
|
||||
|
||||
if ( found_key != fc::fkeyname.end() )
|
||||
if ( found_key != fkeyname.end() )
|
||||
return {found_key->string};
|
||||
|
||||
if ( keynum > 32 && keynum < 127 )
|
||||
|
@ -249,7 +256,7 @@ inline FKey FKeyboard::getMouseProtocolKey() const
|
|||
if ( ! mouse_support )
|
||||
return NOT_SET;
|
||||
|
||||
const std::size_t buf_len = std::strlen(fifo_buf);
|
||||
const std::size_t buf_len = stringLength(fifo_buf);
|
||||
|
||||
// x11 mouse tracking
|
||||
if ( buf_len >= 6 && fifo_buf[1] == '[' && fifo_buf[2] == 'M' )
|
||||
|
@ -282,7 +289,7 @@ inline FKey FKeyboard::getTermcapKey()
|
|||
for (auto&& entry : *key_map)
|
||||
{
|
||||
const char* kstr = entry.string;
|
||||
const std::size_t len = kstr ? std::strlen(kstr) : 0;
|
||||
const std::size_t len = kstr ? stringLength(kstr) : 0;
|
||||
|
||||
if ( kstr && std::strncmp(kstr, fifo_buf, len) == 0 ) // found
|
||||
{
|
||||
|
@ -309,10 +316,10 @@ inline FKey FKeyboard::getKnownKey()
|
|||
|
||||
assert ( FIFO_BUF_SIZE > 0 );
|
||||
|
||||
for (auto&& entry : fc::fkey_table)
|
||||
for (auto&& entry : FKeyMap::getKeyMap())
|
||||
{
|
||||
const char* kstr = entry.string; // The string is never null
|
||||
const std::size_t len = std::strlen(kstr);
|
||||
const std::size_t len = stringLength(kstr);
|
||||
|
||||
if ( std::strncmp(kstr, fifo_buf, len) == 0 ) // found
|
||||
{
|
||||
|
@ -355,7 +362,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 = std::strlen(fifo_buf);
|
||||
const std::size_t buf_len = stringLength(fifo_buf);
|
||||
|
||||
if ( (firstchar & 0xe0) == 0xc0 )
|
||||
len = 2;
|
||||
|
@ -392,22 +399,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 char utf8[]) const
|
||||
FKey FKeyboard::UTF8decode (const std::string& utf8) const
|
||||
{
|
||||
using distance_type = std::string::difference_type;
|
||||
FKey ucs{FKey::None}; // Universal coded character
|
||||
constexpr std::size_t max = 4;
|
||||
std::size_t len = std::strlen(utf8);
|
||||
const auto len = utf8.length();
|
||||
auto end = utf8.begin()
|
||||
+ static_cast<distance_type>(std::min(len, max));
|
||||
|
||||
if ( len > max )
|
||||
len = max;
|
||||
|
||||
for (std::size_t i{0}; i < len; ++i)
|
||||
for (auto iter{utf8.begin()}; iter < end; ++iter)
|
||||
{
|
||||
const auto ch = uChar(utf8[i]);
|
||||
const auto ch = uChar(*iter);
|
||||
|
||||
if ( (ch & 0xc0) == 0x80 )
|
||||
{
|
||||
|
@ -457,7 +464,7 @@ inline ssize_t FKeyboard::readKey()
|
|||
void FKeyboard::parseKeyBuffer()
|
||||
{
|
||||
ssize_t bytesread{};
|
||||
FObject::getCurrentTime (&time_keypressed);
|
||||
time_keypressed = FObject::getCurrentTime();
|
||||
|
||||
while ( (bytesread = readKey()) > 0 )
|
||||
{
|
||||
|
@ -482,14 +489,14 @@ void FKeyboard::parseKeyBuffer()
|
|||
{
|
||||
key = fkey;
|
||||
mouseTracking();
|
||||
fifo_offset = int(std::strlen(fifo_buf));
|
||||
fifo_offset = int(stringLength(fifo_buf));
|
||||
break;
|
||||
}
|
||||
|
||||
if ( fkey != FKey::Incomplete )
|
||||
{
|
||||
fkey_queue.push(fkey);
|
||||
fifo_offset = int(std::strlen(fifo_buf));
|
||||
fifo_offset = int(stringLength(fifo_buf));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -537,7 +544,7 @@ FKey FKeyboard::keyCorrection (const FKey& keycode) const
|
|||
#if defined(__linux__)
|
||||
if ( FTerm::isLinuxTerm() )
|
||||
{
|
||||
auto& linux_console = FTerm::getFTermLinux();
|
||||
auto& linux_console = FTermLinux::getInstance();
|
||||
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("\r\n");
|
||||
multiline_text = text.split("\n");
|
||||
|
||||
if ( int(multiline_text.size()) > 1 )
|
||||
multiline = true;
|
||||
|
|
|
@ -749,7 +749,7 @@ void FListBox::drawScrollbars() const
|
|||
//----------------------------------------------------------------------
|
||||
void FListBox::drawHeadline()
|
||||
{
|
||||
if ( text.isNull() || text.isEmpty() )
|
||||
if ( 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().isNull() )
|
||||
if ( conv_type != ConvertType::Lazy || ! iter->getText().isEmpty() )
|
||||
return;
|
||||
|
||||
lazy_inserter (*iter, source_container, y + std::size_t(yoffset));
|
||||
|
|
|
@ -910,6 +910,7 @@ void FListView::clear()
|
|||
{
|
||||
itemlist.clear();
|
||||
current_iter = getNullIterator();
|
||||
mark_iter = getNullIterator();
|
||||
first_visible_line = getNullIterator();
|
||||
last_visible_line = getNullIterator();
|
||||
recalculateVerticalBar (0);
|
||||
|
@ -1427,6 +1428,60 @@ 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)
|
||||
{
|
||||
|
@ -1608,6 +1663,14 @@ 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;
|
||||
|
@ -1615,7 +1678,7 @@ void FListView::drawList()
|
|||
print() << FPoint{2, 2 + int(y)};
|
||||
|
||||
// Draw one FListViewItem
|
||||
drawListLine (item, getFlags().focus, is_current_line);
|
||||
drawListLine (item, getFlags().focus, is_current_line, is_current_mark, is_current_selected);
|
||||
|
||||
if ( getFlags().focus && is_current_line )
|
||||
{
|
||||
|
@ -1651,10 +1714,10 @@ void FListView::drawList()
|
|||
//----------------------------------------------------------------------
|
||||
void FListView::drawListLine ( const FListViewItem* item
|
||||
, bool is_focus
|
||||
, bool is_current )
|
||||
, bool is_current, bool is_mark, bool is_selected )
|
||||
{
|
||||
// Set line color and attributes
|
||||
setLineAttributes (is_current, is_focus);
|
||||
setLineAttributes (is_current, is_focus, is_mark, is_selected);
|
||||
|
||||
// Print the entry
|
||||
const std::size_t indent = item->getDepth() << 1; // indent = 2 * depth
|
||||
|
@ -1758,12 +1821,13 @@ void FListView::clearList()
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FListView::setLineAttributes ( bool is_current
|
||||
, bool is_focus ) const
|
||||
, bool is_focus, bool is_mark, bool is_selected ) const
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
setColor (wc->list_fg, wc->list_bg);
|
||||
|
||||
if ( is_current )
|
||||
if ( is_mark )
|
||||
setColor ( FColor::White, FColor::Red );
|
||||
else if ( is_current )
|
||||
{
|
||||
if ( is_focus && FTerm::getMaxColor() < 16 )
|
||||
setBold();
|
||||
|
@ -1783,6 +1847,8 @@ 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.isNull() )
|
||||
if ( ! headline_text.isEmpty() )
|
||||
headline_height = 2;
|
||||
|
||||
for (auto&& line : text_components)
|
||||
|
|
|
@ -196,37 +196,37 @@ FString FMouse::getClassName() const
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FMouse::clearEvent()
|
||||
void FMouse::clearEvent()
|
||||
{
|
||||
mouse_event_occurred = false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FMouse::setMaxWidth (uInt16 x_max)
|
||||
void FMouse::setMaxWidth (uInt16 x_max)
|
||||
{
|
||||
max_width = x_max;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FMouse::setMaxHeight (uInt16 y_max)
|
||||
void FMouse::setMaxHeight (uInt16 y_max)
|
||||
{
|
||||
max_height = y_max;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FMouse::setDblclickInterval (const uInt64 timeout)
|
||||
void FMouse::setDblclickInterval (const uInt64 timeout)
|
||||
{
|
||||
dblclick_interval = timeout;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FMouse::hasEvent() const
|
||||
bool FMouse::hasEvent() const
|
||||
{
|
||||
return mouse_event_occurred;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FMouse::hasUnprocessedInput() const
|
||||
bool FMouse::hasUnprocessedInput() const
|
||||
{
|
||||
return unprocessed_buffer_data;
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ inline bool FMouse::hasUnprocessedInput() const
|
|||
|
||||
// protected methods of FMouse
|
||||
//----------------------------------------------------------------------
|
||||
inline const FPoint& FMouse::getNewPos() const
|
||||
const FPoint& FMouse::getNewPos() const
|
||||
{
|
||||
return new_mouse_position;
|
||||
}
|
||||
|
@ -258,9 +258,9 @@ uInt64 FMouse::getDblclickInterval() const
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
timeval* FMouse::getMousePressedTime()
|
||||
TimeValue FMouse::getMousePressedTime() const
|
||||
{
|
||||
return &time_mousepressed;
|
||||
return time_mousepressed;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -276,16 +276,15 @@ void FMouse::setPending (bool is_pending)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouse::setMousePressedTime (const timeval* time)
|
||||
void FMouse::setMousePressedTime (const TimeValue& time)
|
||||
{
|
||||
time_mousepressed = *time;
|
||||
time_mousepressed = time;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouse::resetMousePressedTime()
|
||||
{
|
||||
time_mousepressed.tv_sec = 0;
|
||||
time_mousepressed.tv_usec = 0;
|
||||
time_mousepressed = TimeValue{}; // Set to epoch time
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -295,7 +294,7 @@ void FMouse::setEvent()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouse::isDblclickTimeout (const timeval* time) const
|
||||
bool FMouse::isDblclickTimeout (const TimeValue& time) const
|
||||
{
|
||||
return FObject::isTimeout (time, dblclick_interval);
|
||||
}
|
||||
|
@ -341,7 +340,7 @@ void FMouseGPM::setRawData (FKeyboard::keybuffer&)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouseGPM::processEvent (struct timeval*)
|
||||
void FMouseGPM::processEvent (const TimeValue&)
|
||||
{
|
||||
clearButtonState();
|
||||
|
||||
|
@ -582,7 +581,7 @@ void FMouseX11::setRawData (FKeyboard::keybuffer& fifo_buf)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouseX11::processEvent (struct timeval* time)
|
||||
void FMouseX11::processEvent (const TimeValue& time)
|
||||
{
|
||||
// Parse and interpret the X11 xterm mouse string
|
||||
|
||||
|
@ -641,7 +640,7 @@ void FMouseX11::setMoveState (const FPoint& mouse_position, int btn)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouseX11::setButtonState (const int btn, const struct timeval* time)
|
||||
void FMouseX11::setButtonState (const int btn, const TimeValue& time)
|
||||
{
|
||||
// Get the x11 mouse button state
|
||||
|
||||
|
@ -739,7 +738,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 = std::strlen(fifo_buf);
|
||||
std::size_t len = stringLength(fifo_buf);
|
||||
std::size_t n{3};
|
||||
|
||||
while ( n < len && n <= MOUSE_BUF_SIZE + 1 )
|
||||
|
@ -765,7 +764,7 @@ void FMouseSGR::setRawData (FKeyboard::keybuffer& fifo_buf)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouseSGR::processEvent (struct timeval* time)
|
||||
void FMouseSGR::processEvent (const TimeValue& time)
|
||||
{
|
||||
const auto& mouse_position = getPos();
|
||||
uInt16 x{0};
|
||||
|
@ -867,7 +866,7 @@ void FMouseSGR::setMoveState (const FPoint& mouse_position, int btn)
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouseSGR::setPressedButtonState ( const int btn
|
||||
, const struct timeval* time )
|
||||
, const TimeValue& time )
|
||||
{
|
||||
// Gets the extended x11 mouse mode (SGR) status for pressed buttons
|
||||
|
||||
|
@ -969,7 +968,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 = std::strlen(fifo_buf);
|
||||
std::size_t len = stringLength(fifo_buf);
|
||||
std::size_t n{2};
|
||||
|
||||
while ( n < len && n <= MOUSE_BUF_SIZE )
|
||||
|
@ -995,7 +994,7 @@ void FMouseUrxvt::setRawData (FKeyboard::keybuffer& fifo_buf)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouseUrxvt::processEvent (struct timeval* time)
|
||||
void FMouseUrxvt::processEvent (const TimeValue& time)
|
||||
{
|
||||
// Parse and interpret the X11 xterm mouse string (Urxvt-Mode)
|
||||
|
||||
|
@ -1122,7 +1121,7 @@ void FMouseUrxvt::setMoveState (const FPoint& mouse_position, int btn)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouseUrxvt::setButtonState (const int btn, const struct timeval* time)
|
||||
void FMouseUrxvt::setButtonState (const int btn, const TimeValue& time)
|
||||
{
|
||||
// Get the urxvt mouse button state
|
||||
|
||||
|
@ -1205,14 +1204,16 @@ void FMouseUrxvt::setButtonState (const int btn, const struct timeval* time)
|
|||
//----------------------------------------------------------------------
|
||||
FMouseControl::FMouseControl()
|
||||
{
|
||||
using mt = FMouse::MouseType;
|
||||
|
||||
#ifdef F_HAVE_LIBGPM
|
||||
if ( FTermLinux::isLinuxConsole() )
|
||||
mouse_protocol[FMouse::MouseType::Gpm].reset(FMouse::createMouseObject<FMouseGPM>());
|
||||
mouse_protocol[mt::Gpm].reset(FMouse::createMouseObject<FMouseGPM>());
|
||||
#endif
|
||||
|
||||
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>());
|
||||
mouse_protocol[mt::X11].reset(FMouse::createMouseObject<FMouseX11>());
|
||||
mouse_protocol[mt::Sgr].reset(FMouse::createMouseObject<FMouseSGR>());
|
||||
mouse_protocol[mt::Urxvt].reset(FMouse::createMouseObject<FMouseUrxvt>());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -1220,6 +1221,13 @@ 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()
|
||||
{
|
||||
|
@ -1561,7 +1569,7 @@ void FMouseControl::processQueuedInput()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouseControl::processEvent (struct timeval* time)
|
||||
void FMouseControl::processEvent (const TimeValue& 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-2020 Markus Gans *
|
||||
* Copyright 2015-2021 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,6 +21,7 @@
|
|||
***********************************************************************/
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
#include "final/fevent.h"
|
||||
#include "final/fc.h"
|
||||
|
@ -29,8 +30,17 @@
|
|||
namespace finalcut
|
||||
{
|
||||
|
||||
// static class attributes
|
||||
bool FObject::timer_modify_lock;
|
||||
namespace internal
|
||||
{
|
||||
|
||||
struct var
|
||||
{
|
||||
static std::mutex timer_mutex;
|
||||
};
|
||||
|
||||
std::mutex var::timer_mutex{};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -44,8 +54,6 @@ FObject::FObject (FObject* parent)
|
|||
{
|
||||
if ( parent ) // add object to parent
|
||||
parent->addChild(this);
|
||||
else
|
||||
timer_modify_lock = false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -179,54 +187,24 @@ bool FObject::event (FEvent* ev)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FObject::getCurrentTime (timeval* time)
|
||||
TimeValue FObject::getCurrentTime()
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
return system_clock::now(); // Get the current time
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FObject::isTimeout (const timeval* time, uInt64 timeout)
|
||||
bool FObject::isTimeout (const TimeValue& time, uInt64 timeout)
|
||||
{
|
||||
// Checks whether the specified time span (timeout in µs) has elapse
|
||||
// Checks whether the specified time span (timeout in µs) has elapsed
|
||||
|
||||
struct timeval now{};
|
||||
struct timeval diff{};
|
||||
const auto now = getCurrentTime();
|
||||
|
||||
FObject::getCurrentTime(&now);
|
||||
diff.tv_sec = now.tv_sec - time->tv_sec;
|
||||
diff.tv_usec = now.tv_usec - time->tv_usec;
|
||||
if ( now < time )
|
||||
return false;
|
||||
|
||||
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 );
|
||||
const auto diff = now - time;
|
||||
const auto diff_usec = uInt64(duration_cast<microseconds>(diff).count());
|
||||
return diff_usec > timeout;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -235,10 +213,8 @@ 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};
|
||||
timer_modify_lock = true;
|
||||
std::lock_guard<std::mutex> lock_guard(internal::var::timer_mutex);
|
||||
auto& timer_list = globalTimerList();
|
||||
|
||||
// find an unused timer id
|
||||
|
@ -262,10 +238,8 @@ int FObject::addTimer (int interval)
|
|||
if ( id <= 0 || id > int(timer_list->size() + 1) )
|
||||
return 0;
|
||||
|
||||
time_interval.tv_sec = interval / 1000;
|
||||
time_interval.tv_usec = (interval % 1000) * 1000;
|
||||
getCurrentTime (¤tTime);
|
||||
timeval timeout = currentTime + time_interval;
|
||||
const auto time_interval = milliseconds(interval);
|
||||
const auto timeout = getCurrentTime() + time_interval;
|
||||
FTimerData t{ id, time_interval, timeout, this };
|
||||
|
||||
// insert in list sorted by timeout
|
||||
|
@ -276,7 +250,6 @@ int FObject::addTimer (int interval)
|
|||
++iter;
|
||||
|
||||
timer_list->insert (iter, t);
|
||||
timer_modify_lock = false;
|
||||
return id;
|
||||
}
|
||||
|
||||
|
@ -288,7 +261,7 @@ bool FObject::delTimer (int id) const
|
|||
if ( id <= 0 )
|
||||
return false;
|
||||
|
||||
timer_modify_lock = true;
|
||||
std::lock_guard<std::mutex> lock_guard(internal::var::timer_mutex);
|
||||
auto& timer_list = globalTimerList();
|
||||
auto iter = timer_list->begin();
|
||||
const auto& last = timer_list->end();
|
||||
|
@ -299,11 +272,9 @@ 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;
|
||||
}
|
||||
|
||||
|
@ -312,6 +283,7 @@ 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 )
|
||||
|
@ -320,7 +292,6 @@ bool FObject::delOwnTimers() const
|
|||
if ( timer_list->empty() )
|
||||
return false;
|
||||
|
||||
timer_modify_lock = true;
|
||||
auto iter = timer_list->begin();
|
||||
|
||||
while ( iter != timer_list->end() )
|
||||
|
@ -331,7 +302,6 @@ bool FObject::delOwnTimers() const
|
|||
++iter;
|
||||
}
|
||||
|
||||
timer_modify_lock = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -340,6 +310,7 @@ 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 )
|
||||
|
@ -348,10 +319,8 @@ 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;
|
||||
}
|
||||
|
||||
|
@ -374,20 +343,17 @@ 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 );
|
||||
|
||||
getCurrentTime (¤tTime);
|
||||
|
||||
if ( isTimerInUpdating() )
|
||||
if ( ! unique_lock.try_lock() )
|
||||
return 0;
|
||||
|
||||
auto currentTime = getCurrentTime();
|
||||
auto& timer_list = globalTimerList();
|
||||
|
||||
if ( ! timer_list )
|
||||
return 0;
|
||||
|
||||
if ( timer_list->empty() )
|
||||
if ( ! timer_list || timer_list->empty() )
|
||||
return 0;
|
||||
|
||||
for (auto&& timer : *timer_list)
|
||||
|
@ -402,7 +368,7 @@ uInt FObject::processTimerEvent()
|
|||
if ( timer.timeout < currentTime )
|
||||
timer.timeout = currentTime + timer.interval;
|
||||
|
||||
if ( timer.interval.tv_usec > 0 || timer.interval.tv_sec > 0 )
|
||||
if ( timer.interval > microseconds(0) )
|
||||
activated++;
|
||||
|
||||
FTimerEvent t_ev(Event::Timer, timer.id);
|
||||
|
|
|
@ -39,6 +39,8 @@ 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;
|
||||
|
@ -49,6 +51,13 @@ 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)
|
||||
{
|
||||
|
@ -543,11 +552,11 @@ FColor FOptiAttr::vga2ansi (FColor color)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const char* FOptiAttr::changeAttribute (FChar& term, FChar& next)
|
||||
std::string FOptiAttr::changeAttribute (FChar& term, FChar& next)
|
||||
{
|
||||
const bool next_has_color = hasColor(next);
|
||||
fake_reverse = false;
|
||||
attr_buf[0] = '\0';
|
||||
attr_buf.clear();
|
||||
prevent_no_color_video_attributes (term, next_has_color);
|
||||
prevent_no_color_video_attributes (next);
|
||||
detectSwitchOn (term, next);
|
||||
|
@ -559,7 +568,7 @@ const char* FOptiAttr::changeAttribute (FChar& term, FChar& next)
|
|||
|
||||
// Look for no changes
|
||||
if ( ! (switchOn() || switchOff() || hasColorChanged(term, next)) )
|
||||
return nullptr;
|
||||
return {};
|
||||
|
||||
if ( hasNoAttribute(next) )
|
||||
{
|
||||
|
@ -575,10 +584,10 @@ const char* FOptiAttr::changeAttribute (FChar& term, FChar& next)
|
|||
changeAttributeSeparately (term, next);
|
||||
}
|
||||
|
||||
if ( FStartOptions::getFStartOptions().sgr_optimizer )
|
||||
if ( FStartOptions::getInstance().sgr_optimizer )
|
||||
sgr_optimizer.optimize();
|
||||
|
||||
return attr_buf.data();
|
||||
return attr_buf;
|
||||
}
|
||||
|
||||
|
||||
|
@ -879,34 +888,31 @@ inline bool FOptiAttr::unsetTermDoubleUnderline (FChar& term)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FOptiAttr::setTermAttributes ( FChar& term
|
||||
, bool p1, bool p2, bool p3
|
||||
, bool p4, bool p5, bool p6
|
||||
, bool p7, bool p8, bool p9 )
|
||||
bool FOptiAttr::setTermAttributes (FChar& term, const TCapAttributes& attr)
|
||||
{
|
||||
if ( F_set_attributes.cap )
|
||||
{
|
||||
const auto sgr = FTermcap::encodeParameter ( F_set_attributes.cap
|
||||
, p1 && ! fake_reverse
|
||||
, p2
|
||||
, p3 && ! fake_reverse
|
||||
, p4
|
||||
, p5
|
||||
, p6
|
||||
, p7
|
||||
, p8
|
||||
, p9 );
|
||||
, attr.p1 && ! fake_reverse
|
||||
, attr.p2
|
||||
, attr.p3 && ! fake_reverse
|
||||
, attr.p4
|
||||
, attr.p5
|
||||
, attr.p6
|
||||
, attr.p7
|
||||
, attr.p8
|
||||
, attr.p9 );
|
||||
append_sequence (sgr.data());
|
||||
resetColor(term);
|
||||
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.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.pc_charset = false;
|
||||
term.attr.bit.italic = false;
|
||||
term.attr.bit.crossed_out = false;
|
||||
|
@ -1234,15 +1240,15 @@ inline void FOptiAttr::changeAttributeSGR (FChar& term, FChar& next)
|
|||
|
||||
if ( switchOn() || switchOff() )
|
||||
setTermAttributes ( term
|
||||
, next.attr.bit.standout
|
||||
, next.attr.bit.underline
|
||||
, next.attr.bit.reverse
|
||||
, next.attr.bit.blink
|
||||
, next.attr.bit.dim
|
||||
, next.attr.bit.bold
|
||||
, next.attr.bit.invisible
|
||||
, next.attr.bit.protect
|
||||
, next.attr.bit.alt_charset );
|
||||
, { next.attr.bit.standout
|
||||
, next.attr.bit.underline
|
||||
, next.attr.bit.reverse
|
||||
, next.attr.bit.blink
|
||||
, next.attr.bit.dim
|
||||
, next.attr.bit.bold
|
||||
, next.attr.bit.invisible
|
||||
, next.attr.bit.protect
|
||||
, next.attr.bit.alt_charset } );
|
||||
|
||||
if ( alt_equal_pc_charset
|
||||
&& F_enter_pc_charset_mode.cap
|
||||
|
@ -1537,9 +1543,7 @@ inline bool FOptiAttr::append_sequence (const char seq[])
|
|||
if ( ! seq )
|
||||
return false;
|
||||
|
||||
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';
|
||||
attr_buf.append(seq);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ FOptiMove::FOptiMove (int baud)
|
|||
{
|
||||
assert ( baud >= 0 );
|
||||
|
||||
move_buf.reserve(BUF_SIZE);
|
||||
calculateCharDuration();
|
||||
|
||||
// ANSI set cursor address preset for undefined terminals
|
||||
|
@ -54,6 +55,13 @@ 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)
|
||||
{
|
||||
|
@ -481,7 +489,7 @@ void FOptiMove::check_boundaries ( int& xold, int& yold
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const char* FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew)
|
||||
std::string FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew)
|
||||
{
|
||||
int method{0};
|
||||
int move_time{LONG_DURATION};
|
||||
|
@ -494,7 +502,7 @@ const char* FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew)
|
|||
|| yold < 0
|
||||
|| isWideMove (xold, yold, xnew, ynew) ) )
|
||||
{
|
||||
return ( move_time < LONG_DURATION ) ? move_buf : nullptr;
|
||||
return ( move_time < LONG_DURATION ) ? move_buf : std::string{};
|
||||
}
|
||||
|
||||
// Method 1: local movement
|
||||
|
@ -523,7 +531,7 @@ const char* FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew)
|
|||
if ( move_time < LONG_DURATION )
|
||||
return move_buf;
|
||||
else
|
||||
return nullptr;
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
|
@ -603,30 +611,23 @@ int FOptiMove::capDurationToLength (int duration) const
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int FOptiMove::repeatedAppend ( const Capability& o
|
||||
, int count
|
||||
, char* dst ) const
|
||||
int FOptiMove::repeatedAppend ( std::string& dst
|
||||
, const Capability& o
|
||||
, int count ) const
|
||||
{
|
||||
const std::size_t src_len = std::strlen(o.cap);
|
||||
const std::size_t dst_len = ( dst != nullptr ) ? std::strlen(dst) : 0;
|
||||
const std::size_t src_len = stringLength(o.cap);
|
||||
const std::size_t dst_len = dst.length();
|
||||
int total{0};
|
||||
|
||||
if ( (dst_len + uInt(count) * src_len) < BUF_SIZE - 1 )
|
||||
{
|
||||
total += count * o.duration;
|
||||
int cnt = count;
|
||||
|
||||
if ( dst )
|
||||
while ( cnt > 0 )
|
||||
{
|
||||
dst += dst_len;
|
||||
std::size_t free = BUF_SIZE - dst_len - 2;
|
||||
int cnt = count;
|
||||
|
||||
while ( cnt-- > 0 )
|
||||
{
|
||||
std::strncpy (dst, o.cap, free);
|
||||
dst += src_len;
|
||||
free -= src_len;
|
||||
}
|
||||
cnt--;
|
||||
dst.append(o.cap);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -636,15 +637,15 @@ int FOptiMove::repeatedAppend ( const Capability& o
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int FOptiMove::relativeMove ( char move[]
|
||||
int FOptiMove::relativeMove ( std::string& move
|
||||
, int from_x, int from_y
|
||||
, int to_x, int to_y ) const
|
||||
{
|
||||
int vtime{0};
|
||||
int htime{0};
|
||||
|
||||
if ( move )
|
||||
move[0] = '\0';
|
||||
if ( ! move.empty() )
|
||||
move.clear();
|
||||
|
||||
if ( to_y != from_y ) // vertical move
|
||||
{
|
||||
|
@ -656,41 +657,30 @@ int FOptiMove::relativeMove ( char move[]
|
|||
|
||||
if ( to_x != from_x ) // horizontal move
|
||||
{
|
||||
char hmove[BUF_SIZE]{};
|
||||
std::string hmove{};
|
||||
htime = horizontalMove (hmove, from_x, to_x);
|
||||
|
||||
if ( htime >= LONG_DURATION )
|
||||
return LONG_DURATION;
|
||||
|
||||
if ( move )
|
||||
{
|
||||
if ( *move )
|
||||
std::strncat (move, hmove, BUF_SIZE - std::strlen(move));
|
||||
else
|
||||
std::strncpy (move, hmove, BUF_SIZE);
|
||||
|
||||
move[BUF_SIZE - 1] = '\0';
|
||||
}
|
||||
if ( ! move.empty() )
|
||||
move.append(hmove);
|
||||
else
|
||||
move = hmove;
|
||||
}
|
||||
|
||||
return vtime + htime;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline int FOptiMove::verticalMove (char move[], int from_y, int to_y) const
|
||||
inline int FOptiMove::verticalMove (std::string& move, int from_y, int to_y) const
|
||||
{
|
||||
int vtime{LONG_DURATION};
|
||||
|
||||
if ( F_row_address.cap )
|
||||
{
|
||||
if ( move )
|
||||
{
|
||||
std::strncpy ( move
|
||||
, FTermcap::encodeParameter(F_row_address.cap, to_y).data()
|
||||
, BUF_SIZE );
|
||||
move[BUF_SIZE - 1] = '\0';
|
||||
}
|
||||
|
||||
// Move to fixed row position
|
||||
move = FTermcap::encodeParameter(F_row_address.cap, to_y);
|
||||
vtime = F_row_address.duration;
|
||||
}
|
||||
|
||||
|
@ -703,73 +693,56 @@ inline int FOptiMove::verticalMove (char move[], int from_y, int to_y) const
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FOptiMove::downMove ( char move[], int& vtime
|
||||
inline void FOptiMove::downMove ( std::string& 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 )
|
||||
{
|
||||
if ( move )
|
||||
{
|
||||
std::strncpy ( move
|
||||
, FTermcap::encodeParameter(F_parm_down_cursor.cap, num).data()
|
||||
, BUF_SIZE );
|
||||
move[BUF_SIZE - 1] = '\0';
|
||||
}
|
||||
|
||||
move = FTermcap::encodeParameter(F_parm_down_cursor.cap, num);
|
||||
vtime = F_parm_down_cursor.duration;
|
||||
}
|
||||
|
||||
if ( F_cursor_down.cap && (num * F_cursor_down.duration < vtime) )
|
||||
{
|
||||
if ( move )
|
||||
move[0] = '\0';
|
||||
if ( ! move.empty() )
|
||||
move.clear();
|
||||
|
||||
vtime = repeatedAppend (F_cursor_down, num, move);
|
||||
vtime = repeatedAppend (move, F_cursor_down, num);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FOptiMove::upMove ( char move[], int& vtime
|
||||
inline void FOptiMove::upMove ( std::string& 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 )
|
||||
{
|
||||
if ( move )
|
||||
{
|
||||
std::strncpy ( move
|
||||
, FTermcap::encodeParameter(F_parm_up_cursor.cap, num).data()
|
||||
, BUF_SIZE );
|
||||
move[BUF_SIZE - 1] = '\0';
|
||||
}
|
||||
|
||||
move = FTermcap::encodeParameter(F_parm_up_cursor.cap, num);
|
||||
vtime = F_parm_up_cursor.duration;
|
||||
}
|
||||
|
||||
if ( F_cursor_up.cap && (num * F_cursor_up.duration < vtime) )
|
||||
{
|
||||
if ( move )
|
||||
move[0] = '\0';
|
||||
if ( ! move.empty() )
|
||||
move.clear();
|
||||
|
||||
vtime = repeatedAppend (F_cursor_up, num, move);
|
||||
vtime = repeatedAppend (move, F_cursor_up, num);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline int FOptiMove::horizontalMove (char hmove[], int from_x, int to_x) const
|
||||
inline int FOptiMove::horizontalMove (std::string& hmove, int from_x, int to_x) const
|
||||
{
|
||||
int htime{LONG_DURATION};
|
||||
|
||||
if ( F_column_address.cap )
|
||||
{
|
||||
// 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';
|
||||
// Move to fixed column position
|
||||
hmove = FTermcap::encodeParameter(F_column_address.cap, to_x);
|
||||
htime = F_column_address.duration;
|
||||
}
|
||||
|
||||
|
@ -782,25 +755,21 @@ inline int FOptiMove::horizontalMove (char hmove[], int from_x, int to_x) const
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FOptiMove::rightMove ( char hmove[], int& htime
|
||||
inline void FOptiMove::rightMove ( std::string& 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 )
|
||||
{
|
||||
std::strncpy ( hmove
|
||||
, FTermcap::encodeParameter(F_parm_right_cursor.cap, num).data()
|
||||
, BUF_SIZE - 1);
|
||||
hmove[BUF_SIZE - 1] = '\0';
|
||||
hmove = FTermcap::encodeParameter(F_parm_right_cursor.cap, num);
|
||||
htime = F_parm_right_cursor.duration;
|
||||
}
|
||||
|
||||
if ( F_cursor_right.cap )
|
||||
{
|
||||
std::array<char, BUF_SIZE> str{};
|
||||
std::string str{};
|
||||
int htime_r{0};
|
||||
str[0] = '\0';
|
||||
|
||||
// try to use tab
|
||||
if ( tabstop > 0 && F_tab.cap )
|
||||
|
@ -814,7 +783,7 @@ inline void FOptiMove::rightMove ( char hmove[], int& htime
|
|||
if ( tab_pos > to_x )
|
||||
break;
|
||||
|
||||
htime_r += repeatedAppend (F_tab, 1, str.data());
|
||||
htime_r += repeatedAppend (str, F_tab, 1);
|
||||
|
||||
if ( htime_r >= LONG_DURATION )
|
||||
break;
|
||||
|
@ -825,37 +794,32 @@ inline void FOptiMove::rightMove ( char hmove[], int& htime
|
|||
num = to_x - pos;
|
||||
}
|
||||
|
||||
htime_r += repeatedAppend (F_cursor_right, num, str.data());
|
||||
htime_r += repeatedAppend (str, F_cursor_right, num);
|
||||
|
||||
if ( htime_r < htime )
|
||||
{
|
||||
std::strncpy (hmove, str.data(), BUF_SIZE);
|
||||
hmove[BUF_SIZE - 1] = '\0';
|
||||
hmove = str;
|
||||
htime = htime_r;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FOptiMove::leftMove ( char hmove[], int& htime
|
||||
inline void FOptiMove::leftMove ( std::string& 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 )
|
||||
{
|
||||
std::strncpy ( hmove
|
||||
, FTermcap::encodeParameter(F_parm_left_cursor.cap, num).data()
|
||||
, BUF_SIZE - 1);
|
||||
hmove[BUF_SIZE - 1] = '\0';
|
||||
hmove = FTermcap::encodeParameter(F_parm_left_cursor.cap, num);
|
||||
htime = F_parm_left_cursor.duration;
|
||||
}
|
||||
|
||||
if ( F_cursor_left.cap )
|
||||
{
|
||||
std::array<char, BUF_SIZE> str{};
|
||||
std::string str{};
|
||||
int htime_l{0};
|
||||
str[0] = '\0';
|
||||
|
||||
// try to use backward tab
|
||||
if ( tabstop > 0 && F_back_tab.cap )
|
||||
|
@ -869,7 +833,7 @@ inline void FOptiMove::leftMove ( char hmove[], int& htime
|
|||
if ( tab_pos < to_x )
|
||||
break;
|
||||
|
||||
htime_l += repeatedAppend (F_back_tab, 1, str.data());
|
||||
htime_l += repeatedAppend (str, F_back_tab, 1);
|
||||
|
||||
if ( htime_l >= LONG_DURATION )
|
||||
break;
|
||||
|
@ -880,12 +844,11 @@ inline void FOptiMove::leftMove ( char hmove[], int& htime
|
|||
num = pos - to_x;
|
||||
}
|
||||
|
||||
htime_l += repeatedAppend (F_cursor_left, num, str.data());
|
||||
htime_l += repeatedAppend (str, F_cursor_left, num);
|
||||
|
||||
if ( htime_l < htime )
|
||||
{
|
||||
std::strncpy (hmove, str.data(), BUF_SIZE);
|
||||
hmove[BUF_SIZE - 1] = '\0';
|
||||
hmove = str;
|
||||
htime = htime_l;
|
||||
}
|
||||
}
|
||||
|
@ -914,9 +877,7 @@ inline bool FOptiMove::isMethod0Faster ( int& move_time
|
|||
|
||||
if ( ! move_xy.empty() )
|
||||
{
|
||||
std::strncpy ( static_cast<char*>(move_buf)
|
||||
, move_xy.data(), BUF_SIZE - 1 );
|
||||
move_buf[BUF_SIZE - 1] = '\0';
|
||||
move_buf = move_xy;
|
||||
move_time = F_cursor_address.duration;
|
||||
return true;
|
||||
}
|
||||
|
@ -933,8 +894,8 @@ inline bool FOptiMove::isMethod1Faster ( int& move_time
|
|||
|
||||
if ( xold >= 0 && yold >= 0 )
|
||||
{
|
||||
std::array<char, BUF_SIZE> null_result{};
|
||||
const int new_time = relativeMove (null_result.data(), xold, yold, xnew, ynew);
|
||||
std::string null_result{};
|
||||
const int new_time = relativeMove (null_result, xold, yold, xnew, ynew);
|
||||
|
||||
if ( new_time < LONG_DURATION && new_time < move_time )
|
||||
{
|
||||
|
@ -955,8 +916,8 @@ inline bool FOptiMove::isMethod2Faster ( int& move_time
|
|||
|
||||
if ( yold >= 0 && F_carriage_return.cap )
|
||||
{
|
||||
std::array<char, BUF_SIZE> null_result{};
|
||||
const int new_time = relativeMove (null_result.data(), 0, yold, xnew, ynew);
|
||||
std::string null_result{};
|
||||
const int new_time = relativeMove (null_result, 0, yold, xnew, ynew);
|
||||
|
||||
if ( new_time < LONG_DURATION
|
||||
&& F_carriage_return.duration + new_time < move_time )
|
||||
|
@ -977,8 +938,8 @@ inline bool FOptiMove::isMethod3Faster ( int& move_time
|
|||
|
||||
if ( F_cursor_home.cap )
|
||||
{
|
||||
std::array<char, BUF_SIZE> null_result{};
|
||||
const int new_time = relativeMove (null_result.data(), 0, 0, xnew, ynew);
|
||||
std::string null_result{};
|
||||
const int new_time = relativeMove (null_result, 0, 0, xnew, ynew);
|
||||
|
||||
if ( new_time < LONG_DURATION
|
||||
&& F_cursor_home.duration + new_time < move_time )
|
||||
|
@ -998,10 +959,9 @@ inline bool FOptiMove::isMethod4Faster ( int& move_time
|
|||
// Test method 4: home-down + local movement
|
||||
if ( F_cursor_to_ll.cap )
|
||||
{
|
||||
std::array<char, BUF_SIZE> null_result{};
|
||||
const int new_time = relativeMove ( null_result.data()
|
||||
, 0, int(screen_height) - 1
|
||||
, xnew, ynew );
|
||||
std::string null_result{};
|
||||
int down = int(screen_height) - 1;
|
||||
const int new_time = relativeMove (null_result, 0, down, xnew, ynew);
|
||||
|
||||
if ( new_time < LONG_DURATION
|
||||
&& F_cursor_to_ll.duration + new_time < move_time )
|
||||
|
@ -1025,10 +985,10 @@ inline bool FOptiMove::isMethod5Faster ( int& move_time
|
|||
&& yold > 0
|
||||
&& F_cursor_left.cap )
|
||||
{
|
||||
std::array<char, BUF_SIZE> null_result{};
|
||||
const int new_time = relativeMove ( null_result.data()
|
||||
, int(screen_width) - 1, yold - 1
|
||||
, xnew, ynew );
|
||||
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);
|
||||
|
||||
if ( new_time < LONG_DURATION
|
||||
&& F_carriage_return.cap
|
||||
|
@ -1037,7 +997,6 @@ inline bool FOptiMove::isMethod5Faster ( int& move_time
|
|||
{
|
||||
move_time = F_carriage_return.duration
|
||||
+ F_cursor_left.duration + new_time;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1050,52 +1009,55 @@ void FOptiMove::moveByMethod ( int method
|
|||
, int xold, int yold
|
||||
, int xnew, int ynew )
|
||||
{
|
||||
char* move_ptr = move_buf;
|
||||
|
||||
switch ( method )
|
||||
{
|
||||
case 1:
|
||||
relativeMove (move_ptr, xold, yold, xnew, ynew);
|
||||
relativeMove (move_buf, xold, yold, xnew, ynew);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if ( F_carriage_return.cap )
|
||||
{
|
||||
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);
|
||||
move_buf = F_carriage_return.cap;
|
||||
std::string s{};
|
||||
relativeMove (s, 0, yold, xnew, ynew);
|
||||
move_buf.append(s);
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
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);
|
||||
move_buf = F_cursor_home.cap;
|
||||
{
|
||||
std::string s{};
|
||||
relativeMove (s, 0, 0, xnew, ynew);
|
||||
move_buf.append(s);
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
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);
|
||||
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);
|
||||
}
|
||||
break;
|
||||
|
||||
case 5:
|
||||
move_buf[0] = '\0';
|
||||
|
||||
if ( xold >= 0 )
|
||||
std::strncat ( move_ptr
|
||||
, F_carriage_return.cap
|
||||
, BUF_SIZE - std::strlen(move_ptr) - 1 );
|
||||
move_buf = F_carriage_return.cap;
|
||||
else
|
||||
move_buf.clear();
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2019-2020 Markus Gans *
|
||||
* Copyright 2019-2021 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
|
||||
//----------------------------------------------------------------------
|
||||
FStartOptions& FStartOptions::getFStartOptions()
|
||||
auto FStartOptions::getInstance() -> FStartOptions&
|
||||
{
|
||||
static const auto& start_options = make_unique<FStartOptions>();
|
||||
return *start_options;
|
||||
|
|
795
src/fstring.cpp
795
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-2020 Markus Gans *
|
||||
* Copyright 2019-2021 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,6 +21,7 @@
|
|||
***********************************************************************/
|
||||
|
||||
#include "final/fsystem.h"
|
||||
#include "final/fsystemimpl.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
@ -33,5 +34,14 @@ 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,9 +53,6 @@ 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);
|
||||
|
||||
|
@ -199,9 +196,9 @@ constexpr std::array<UniChar, 20> reverse_newfont_list =
|
|||
|
||||
// FTerm non-member functions
|
||||
//----------------------------------------------------------------------
|
||||
uInt env2uint (const char* env)
|
||||
uInt env2uint (const std::string& env)
|
||||
{
|
||||
const FString str{getenv(env)};
|
||||
const FString str{getenv(env.data())};
|
||||
|
||||
if ( str.isEmpty() )
|
||||
return 0;
|
||||
|
@ -259,6 +256,9 @@ 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,15 +284,16 @@ 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 ( fc::cp437_ucs.begin()
|
||||
, fc::cp437_ucs.end()
|
||||
auto found = std::find_if ( cp437_ucs.begin()
|
||||
, cp437_ucs.end()
|
||||
, [&c] (const std::array<wchar_t, 2>& entry)
|
||||
{
|
||||
return entry[CP437] == c;
|
||||
} );
|
||||
|
||||
if ( found != fc::cp437_ucs.end() )
|
||||
if ( found != cp437_ucs.end() )
|
||||
ucs = (*found)[UNICODE];
|
||||
|
||||
return ucs;
|
||||
|
@ -303,16 +304,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 ( fc::cp437_ucs.begin()
|
||||
, fc::cp437_ucs.end()
|
||||
auto found = std::find_if ( cp437_ucs.begin()
|
||||
, cp437_ucs.end()
|
||||
, [&ucs] (const std::array<wchar_t, 2>& entry)
|
||||
{
|
||||
return entry[UNICODE] == ucs;
|
||||
} );
|
||||
|
||||
if ( found != fc::cp437_ucs.end() )
|
||||
if ( found != cp437_ucs.end() )
|
||||
c = static_cast<uChar>((*found)[CP437]);
|
||||
|
||||
return c;
|
||||
|
@ -326,16 +327,17 @@ 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 ( fc::halfwidth_fullwidth.begin()
|
||||
, fc::halfwidth_fullwidth.end()
|
||||
auto found = std::find_if ( halfwidth_fullwidth.begin()
|
||||
, halfwidth_fullwidth.end()
|
||||
, [&c] (const std::array<wchar_t, 2>& entry)
|
||||
{
|
||||
return entry[HALF] == c;
|
||||
} );
|
||||
|
||||
if ( found != fc::halfwidth_fullwidth.end() )
|
||||
if ( found != halfwidth_fullwidth.end() )
|
||||
c = (*found)[FULL];
|
||||
};
|
||||
|
||||
|
@ -358,16 +360,17 @@ 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 ( fc::halfwidth_fullwidth.begin()
|
||||
, fc::halfwidth_fullwidth.end()
|
||||
auto found = std::find_if ( halfwidth_fullwidth.begin()
|
||||
, halfwidth_fullwidth.end()
|
||||
, [&c] (const std::array<wchar_t, 2>& entry)
|
||||
{
|
||||
return entry[FULL] == c;
|
||||
} );
|
||||
|
||||
if ( found != fc::halfwidth_fullwidth.end() )
|
||||
if ( found != halfwidth_fullwidth.end() )
|
||||
c = (*found)[HALF];
|
||||
};
|
||||
|
||||
|
@ -689,10 +692,10 @@ FPoint readCursorPos()
|
|||
const int stdout_no{FTermios::getStdOut()};
|
||||
fd_set ifds{};
|
||||
struct timeval tv{};
|
||||
constexpr auto& DECXCPR{ESC "[6n"};
|
||||
const std::string DECXCPR{ESC "[6n"};
|
||||
|
||||
// Report Cursor Position (DECXCPR)
|
||||
if ( write(stdout_no, DECXCPR, std::strlen(DECXCPR)) < 1 )
|
||||
if ( write(stdout_no, DECXCPR.data(), DECXCPR.length()) < 1 )
|
||||
return {x, y};
|
||||
|
||||
std::fflush(stdout);
|
||||
|
|
|
@ -66,7 +66,6 @@ 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();
|
||||
|
@ -152,7 +151,7 @@ void FTermBuffer::write (const FColorPair& pair) const
|
|||
// private methods of FTermBuffer
|
||||
//----------------------------------------------------------------------
|
||||
void FTermBuffer::add ( FString::const_iterator& begin
|
||||
, FString::const_iterator& end
|
||||
, const 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 = FTerm::getFTermData();
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
auto& fterm_data = FTermData::getInstance();
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
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 = FTerm::getFTermData().getTermType();
|
||||
const auto& termtype = FTermData::getInstance().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 = FTerm::getFTermData();
|
||||
auto& fterm_data = FTermData::getInstance();
|
||||
|
||||
// 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 : fc::fkey_cap_table)
|
||||
for (auto&& entry : FKeyMap::getKeyCapMap())
|
||||
{
|
||||
if ( entry.string != nullptr ) // String is already set
|
||||
break;
|
||||
|
@ -437,10 +437,8 @@ void FTermcap::termcapKeys()
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
std::string FTermcap::encodeParams ( const std::string& cap
|
||||
, const std::vector<int>& param_vec )
|
||||
, const std::array<int, 9>& params )
|
||||
{
|
||||
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 = FTerm::getFTermDetection();
|
||||
const auto& td = FTermDetection::getInstance();
|
||||
|
||||
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 = FTerm::getFTermData().getTermType();
|
||||
const auto& termtype = FTermData::getInstance().getTermType();
|
||||
|
||||
if ( termtype.substr(0,12) == "rxvt-16color" )
|
||||
{
|
||||
|
@ -237,7 +237,7 @@ void FTermcapQuirks::rxvt()
|
|||
}
|
||||
|
||||
// Set ansi foreground and background color
|
||||
if ( ! FTerm::getFTermDetection().isUrxvtTerminal() )
|
||||
if ( ! FTermDetection::getInstance().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 = FTerm::getFTermDetection();
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
|
||||
// gnome-terminal has NC=16 however, it can use the dim attribute
|
||||
FTermcap::attr_without_color = 0;
|
||||
|
@ -370,73 +370,74 @@ 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}; fc::fkey_cap_table[i].tname[0] != 0; i++)
|
||||
for (std::size_t i{0}; fkey_cap_table[i].tname[0] != 0; i++)
|
||||
{
|
||||
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, "K2", 2) == 0 )
|
||||
fkey_cap_table[i].string = CSI "218z"; // center of keypad
|
||||
|
||||
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, "kb", 2) == 0 )
|
||||
fkey_cap_table[i].string = "\b"; // backspace 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, "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, "@7", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "220z"; // end 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, "k;", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "233z"; // F10 function 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, "F1", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "234z"; // F11 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, "F2", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "235z"; // F12 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, "kh", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "214z"; // home 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, "kI", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "247z"; // insert-character 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, "kN", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "222z"; // next-page 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, "%7", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "194z"; // options 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, "kP", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "216z"; // prev-page 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, "&5", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "193z"; // resume 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, "&8", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "195z"; // undo 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, "K2", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "218z"; // center of keypad
|
||||
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, "kDx", 3) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "249z"; // keypad delete
|
||||
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, "@8x", 3) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "250z"; // enter/send key
|
||||
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, "KP1", 3) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "212z"; // keypad slash
|
||||
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, "KP2", 3) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "213z"; // keypad asterisk
|
||||
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, "KP3", 3) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "254z"; // keypad minus sign
|
||||
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, "KP4", 3) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "253z"; // keypad plus sign
|
||||
if ( std::strncmp(fkey_cap_table[i].tname, "KP4", 3) == 0 )
|
||||
fkey_cap_table[i].string = CSI "253z"; // keypad plus sign
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -448,7 +449,7 @@ void FTermcapQuirks::screen()
|
|||
{
|
||||
FTermcap::can_change_color_palette = true;
|
||||
|
||||
if ( FTerm::getFTermDetection().isTmuxTerm() )
|
||||
if ( FTermDetection::getInstance().isTmuxTerm() )
|
||||
{
|
||||
TCAP(t_initialize_color) = \
|
||||
ESC "Ptmux;" ESC OSC "4;%p1%d;rgb:"
|
||||
|
|
|
@ -36,38 +36,45 @@ 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 = FTerm::getFTermDetection();
|
||||
auto& term_detection = FTermDetection::getInstance();
|
||||
return term_detection.getAnswerbackString();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const FString& FTermDebugData::getSecDAString()
|
||||
{
|
||||
auto& term_detection = FTerm::getFTermDetection();
|
||||
auto& term_detection = FTermDetection::getInstance();
|
||||
return term_detection.getSecDAString();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const char* FTermDebugData::getTermType_256color()
|
||||
const FString& FTermDebugData::getTermType_256color()
|
||||
{
|
||||
auto& term_detection = FTerm::getFTermDetection();
|
||||
auto& term_detection = FTermDetection::getInstance();
|
||||
return term_detection.getTermType_256color();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const char* FTermDebugData::getTermType_Answerback()
|
||||
const FString& FTermDebugData::getTermType_Answerback()
|
||||
{
|
||||
auto& term_detection = FTerm::getFTermDetection();
|
||||
auto& term_detection = FTermDetection::getInstance();
|
||||
return term_detection.getTermType_Answerback();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const char* FTermDebugData::getTermType_SecDA()
|
||||
const FString& FTermDebugData::getTermType_SecDA()
|
||||
{
|
||||
auto& term_detection = FTerm::getFTermDetection();
|
||||
auto& term_detection = FTermDetection::getInstance();
|
||||
return term_detection.getTermType_SecDA();
|
||||
}
|
||||
|
||||
|
@ -75,7 +82,7 @@ const char* FTermDebugData::getTermType_SecDA()
|
|||
#if defined(__linux__)
|
||||
int FTermDebugData::getFramebufferBpp()
|
||||
{
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
auto& fterm_data = FTermData::getInstance();
|
||||
return fterm_data.getFramebufferBpp();
|
||||
}
|
||||
#endif // defined(__linux__)
|
||||
|
|
|
@ -50,88 +50,52 @@
|
|||
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()
|
||||
{
|
||||
// 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;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FTermDetection::~FTermDetection() // destructor
|
||||
{
|
||||
deallocation();
|
||||
}
|
||||
FTermDetection::~FTermDetection() = default; // destructor
|
||||
|
||||
|
||||
// public methods of FTermDetection
|
||||
//----------------------------------------------------------------------
|
||||
#if DEBUG
|
||||
const FString& FTermDetection::getAnswerbackString()
|
||||
auto FTermDetection::getInstance() -> FTermDetection&
|
||||
{
|
||||
return ( answer_back ) ? *answer_back : fc::emptyFString::get();
|
||||
static const auto& term_detection = make_unique<FTermDetection>();
|
||||
return *term_detection;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const FString& FTermDetection::getSecDAString()
|
||||
#if DEBUG
|
||||
const FString& FTermDetection::getAnswerbackString() const
|
||||
{
|
||||
return ( sec_da ) ? *sec_da : fc::emptyFString::get();
|
||||
return answer_back;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const FString& FTermDetection::getSecDAString() const
|
||||
{
|
||||
return sec_da;
|
||||
}
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermDetection::setTtyTypeFileName (const char ttytype_filename[])
|
||||
void FTermDetection::setTtyTypeFileName (const FString& ttytype_filename)
|
||||
{
|
||||
if ( ! ttytype_filename )
|
||||
return;
|
||||
|
||||
std::strncpy (ttytypename, ttytype_filename, sizeof(ttytypename));
|
||||
ttytypename[sizeof(ttytypename) - 1] = '\0';
|
||||
ttytypename = ttytype_filename;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermDetection::detect()
|
||||
{
|
||||
deallocation();
|
||||
|
||||
// Set the variable 'termtype' to the predefined type of the terminal
|
||||
getSystemTermType();
|
||||
|
||||
|
@ -144,28 +108,17 @@ 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 = FTerm::getFTermData().getTermFileName();
|
||||
const auto& termfilename = FTermData::getInstance().getTermFileName();
|
||||
|
||||
if ( term_env )
|
||||
{
|
||||
// Save name in termtype
|
||||
std::strncpy (termtype, term_env, sizeof(termtype));
|
||||
termtype[sizeof(termtype) - 1] = '\0';
|
||||
termtype = term_env;
|
||||
return;
|
||||
}
|
||||
else if ( ! termfilename.empty() ) // 1st fallback: use the teminal file name
|
||||
|
@ -180,8 +133,7 @@ void FTermDetection::getSystemTermType()
|
|||
}
|
||||
|
||||
// 2nd fallback: use vt100 if not found
|
||||
std::strncpy (termtype, "vt100", sizeof(termtype));
|
||||
termtype[sizeof(termtype) - 1] = '\0';
|
||||
termtype = "vt100";
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -197,7 +149,7 @@ bool FTermDetection::getTTYtype()
|
|||
// vt100 ttys0
|
||||
|
||||
// Get term basename
|
||||
const auto& termfilename = FTerm::getFTermData().getTermFileName();
|
||||
const auto& termfilename = FTermData::getInstance().getTermFileName();
|
||||
const char* term_basename = std::strrchr(termfilename.data(), '/');
|
||||
|
||||
if ( term_basename == nullptr )
|
||||
|
@ -207,9 +159,9 @@ bool FTermDetection::getTTYtype()
|
|||
|
||||
std::FILE* fp{};
|
||||
std::array<char, BUFSIZ> str{};
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
|
||||
if ( (fp = fsystem->fopen(ttytypename, "r")) == nullptr )
|
||||
if ( (fp = fsystem->fopen(ttytypename.c_str(), "r")) == nullptr )
|
||||
return false;
|
||||
|
||||
// Read and parse the file
|
||||
|
@ -234,8 +186,7 @@ bool FTermDetection::getTTYtype()
|
|||
if ( type != nullptr && name != nullptr && ! std::strcmp(name, term_basename) )
|
||||
{
|
||||
// Save name in termtype
|
||||
std::strncpy (termtype, type, sizeof(termtype));
|
||||
termtype[sizeof(termtype) - 1] = '\0';
|
||||
termtype = type;
|
||||
fsystem->fclose(fp);
|
||||
return true;
|
||||
}
|
||||
|
@ -252,7 +203,7 @@ bool FTermDetection::getTTYSFileEntry()
|
|||
// Analyse /etc/ttys and get the term name
|
||||
|
||||
// get term basename
|
||||
const auto& termfilename = FTerm::getFTermData().getTermFileName();
|
||||
const auto& termfilename = FTermData::getInstance().getTermFileName();
|
||||
const char* term_basename = std::strrchr(termfilename.data(), '/');
|
||||
|
||||
if ( term_basename == nullptr )
|
||||
|
@ -270,8 +221,7 @@ bool FTermDetection::getTTYSFileEntry()
|
|||
if ( type != nullptr )
|
||||
{
|
||||
// Save name in termtype
|
||||
std::strncpy (termtype, type, sizeof(termtype));
|
||||
termtype[sizeof(termtype) - 1] = '\0';
|
||||
termtype = type;
|
||||
endttyent();
|
||||
return true;
|
||||
}
|
||||
|
@ -286,67 +236,67 @@ bool FTermDetection::getTTYSFileEntry()
|
|||
void FTermDetection::termtypeAnalysis()
|
||||
{
|
||||
// Cygwin console
|
||||
if ( std::strncmp(termtype, "cygwin", 6) == 0 )
|
||||
|
||||
if ( termtype.left(6) == "cygwin" )
|
||||
terminal_type.cygwin = true;
|
||||
|
||||
// rxvt terminal emulator (native MS Window System port) on cygwin
|
||||
if ( std::strncmp(termtype, "rxvt-cygwin-native", 18) == 0 )
|
||||
if ( termtype == "rxvt-cygwin-native" )
|
||||
terminal_type.rxvt = true;
|
||||
|
||||
// Ansi terminal
|
||||
if ( std::strncmp(termtype, "ansi", 4) == 0 )
|
||||
if ( termtype.left(4) == "ansi" )
|
||||
{
|
||||
terminal_detection = false;
|
||||
terminal_type.ansi = true;
|
||||
}
|
||||
|
||||
// Sun Microsystems workstation console
|
||||
if ( std::strncmp(termtype, "sun", 3) == 0 )
|
||||
if ( termtype.left(3) == "sun" )
|
||||
{
|
||||
terminal_detection = false;
|
||||
terminal_type.sun_con = true;
|
||||
}
|
||||
|
||||
// Kterm
|
||||
if ( std::strncmp(termtype, "kterm", 5) == 0 )
|
||||
if ( termtype.left(5) == "kterm" )
|
||||
{
|
||||
terminal_detection = false;
|
||||
terminal_type.kterm = true;
|
||||
}
|
||||
|
||||
// mlterm
|
||||
if ( std::strncmp(termtype, "mlterm", 6) == 0 )
|
||||
if ( termtype.left(6) == "mlterm" )
|
||||
terminal_type.mlterm = true;
|
||||
|
||||
// rxvt
|
||||
if ( std::strncmp(termtype, "rxvt", 4) == 0 )
|
||||
if ( termtype.left(4) == "rxvt" )
|
||||
terminal_type.rxvt = true;
|
||||
|
||||
// urxvt
|
||||
if ( std::strncmp(termtype, "rxvt-unicode", 12) == 0 )
|
||||
if ( termtype.left(12) == "rxvt-unicode" )
|
||||
terminal_type.urxvt = true;
|
||||
|
||||
// screen/tmux
|
||||
if ( std::strncmp(termtype, "screen", 6) == 0 )
|
||||
if ( termtype.left(6) == "screen" )
|
||||
{
|
||||
terminal_type.screen = true;
|
||||
const char* tmux = std::getenv("TMUX");
|
||||
auto tmux = std::getenv("TMUX");
|
||||
|
||||
if ( tmux && std::strlen(tmux) != 0 )
|
||||
if ( tmux && tmux[0] != '\0' )
|
||||
terminal_type.tmux = true;
|
||||
}
|
||||
|
||||
// Linux console
|
||||
if ( std::strncmp(termtype, "linux", 5) == 0
|
||||
|| std::strncmp(termtype, "con", 3) == 0 )
|
||||
if ( termtype.left(5) == "linux" || termtype.left(3) == "con" )
|
||||
terminal_type.linux_con = true;
|
||||
|
||||
// NetBSD workstation console
|
||||
if ( std::strncmp(termtype, "wsvt25", 6) == 0 )
|
||||
if ( termtype.left(6) == "wsvt25" )
|
||||
terminal_type.netbsd_con = true;
|
||||
|
||||
// kitty
|
||||
if ( std::strncmp(termtype, "xterm-kitty", 11) == 0 )
|
||||
if ( termtype.left(11) == "xterm-kitty" )
|
||||
terminal_type.kitty = true;
|
||||
}
|
||||
|
||||
|
@ -355,12 +305,12 @@ void FTermDetection::detectTerminal()
|
|||
{
|
||||
// Terminal detection
|
||||
|
||||
const char* new_termtype{nullptr};
|
||||
FString new_termtype{};
|
||||
|
||||
if ( terminal_detection )
|
||||
{
|
||||
FTermios::setCaptureSendCharacters();
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
auto& keyboard = FKeyboard::getInstance();
|
||||
keyboard.setNonBlockingInput();
|
||||
|
||||
// Initialize 256 colors terminals
|
||||
|
@ -384,28 +334,26 @@ void FTermDetection::detectTerminal()
|
|||
//
|
||||
|
||||
// Test if the terminal is a xterm
|
||||
if ( std::strncmp(termtype, "xterm", 5) == 0
|
||||
|| std::strncmp(termtype, "Eterm", 5) == 0 )
|
||||
if ( termtype.left(5) == "xterm" || termtype.left(5) == "Eterm" )
|
||||
{
|
||||
terminal_type.xterm = true;
|
||||
|
||||
// Each xterm should be able to use at least 16 colors
|
||||
if ( ! new_termtype && std::strlen(termtype) == 5 )
|
||||
if ( ! new_termtype && termtype.getLength() == 5 )
|
||||
new_termtype = "xterm-16color";
|
||||
}
|
||||
else if ( std::strncmp(termtype, "ansi", 4) == 0 ) // ANSI detection
|
||||
else if ( termtype.left(4) == "ansi" ) // ANSI detection
|
||||
terminal_type.ansi = true;
|
||||
|
||||
// set the new environment variable TERM
|
||||
if ( new_termtype )
|
||||
{
|
||||
setenv("TERM", new_termtype, 1);
|
||||
std::strncpy (termtype, new_termtype, sizeof(termtype));
|
||||
termtype[sizeof(termtype) - 1] = '\0';
|
||||
setenv("TERM", new_termtype.c_str(), 1);
|
||||
termtype = new_termtype;
|
||||
}
|
||||
|
||||
#if defined(__CYGWIN__)
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
auto& fterm_data = FTermData::getInstance();
|
||||
const auto& termfilename = fterm_data.getTermFileName();
|
||||
|
||||
// Fixes problem with mouse input
|
||||
|
@ -415,13 +363,13 @@ void FTermDetection::detectTerminal()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const char* FTermDetection::init_256colorTerminal()
|
||||
FString FTermDetection::init_256colorTerminal()
|
||||
{
|
||||
const char* new_termtype{nullptr};
|
||||
FString new_termtype{};
|
||||
|
||||
if ( get256colorEnvString() )
|
||||
color256 = true;
|
||||
else if ( std::strstr (termtype, "256color") )
|
||||
else if ( termtype.includes("256color") )
|
||||
color256 = true;
|
||||
else
|
||||
color256 = false;
|
||||
|
@ -429,13 +377,8 @@ const char* FTermDetection::init_256colorTerminal()
|
|||
new_termtype = termtype_256color_quirks();
|
||||
|
||||
#if DEBUG
|
||||
if ( new_termtype )
|
||||
{
|
||||
std::strncpy ( termtype_256color
|
||||
, new_termtype
|
||||
, sizeof(termtype_256color) );
|
||||
termtype_256color[sizeof(termtype_256color) - 1] = '\0';
|
||||
}
|
||||
if ( ! new_termtype.isEmpty() )
|
||||
termtype_256color = new_termtype;
|
||||
#endif // DEBUG
|
||||
|
||||
return new_termtype;
|
||||
|
@ -452,29 +395,28 @@ 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.string7 = std::getenv("KITTY_WINDOW_ID");
|
||||
color_env.string8 = std::getenv("KITTY_WINDOW_ID");
|
||||
|
||||
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 )
|
||||
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() )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const char* FTermDetection::termtype_256color_quirks()
|
||||
FString FTermDetection::termtype_256color_quirks()
|
||||
{
|
||||
const char* new_termtype{nullptr};
|
||||
FString new_termtype{};
|
||||
|
||||
if ( color_env.string2
|
||||
|| (color_env.string1
|
||||
&& std::strncmp(color_env.string1, "gnome-terminal", 14) == 0) )
|
||||
if ( ! color_env.string2.isEmpty()
|
||||
|| color_env.string1 == "gnome-terminal" )
|
||||
{
|
||||
terminal_type.gnome_terminal = true;
|
||||
// Each gnome-terminal should be able to use 256 colors
|
||||
|
@ -490,46 +432,45 @@ const char* FTermDetection::termtype_256color_quirks()
|
|||
if ( ! color256 )
|
||||
return new_termtype;
|
||||
|
||||
if ( std::strncmp(termtype, "xterm", 5) == 0 )
|
||||
if ( termtype.left(5) == "xterm" )
|
||||
new_termtype = "xterm-256color";
|
||||
|
||||
if ( std::strncmp(termtype, "screen", 6) == 0 )
|
||||
if ( termtype.left(6) == "screen" )
|
||||
new_termtype = "screen-256color";
|
||||
|
||||
if ( std::strncmp(termtype, "Eterm", 5) == 0 )
|
||||
if ( termtype.left(5) == "Eterm" )
|
||||
new_termtype = "Eterm-256color";
|
||||
|
||||
if ( std::strncmp(termtype, "mlterm", 6) == 0 )
|
||||
if ( termtype.left(6) == "mlterm" )
|
||||
new_termtype = "mlterm-256color";
|
||||
|
||||
if ( std::strncmp(termtype, "rxvt", 4) != 0
|
||||
&& color_env.string1
|
||||
&& std::strncmp(color_env.string1, "rxvt-xpm", 8) == 0 )
|
||||
if ( termtype.left(4) == "rxvt"
|
||||
&& color_env.string1.left(8) == "rxvt-xpm" )
|
||||
{
|
||||
new_termtype = "rxvt-256color";
|
||||
terminal_type.rxvt = true;
|
||||
}
|
||||
|
||||
if ( (color_env.string5 && std::strlen(color_env.string5) > 0)
|
||||
|| (color_env.string6 && std::strlen(color_env.string6) > 0) )
|
||||
if ( color_env.string5.getLength() > 0
|
||||
|| color_env.string6.getLength() > 0 )
|
||||
{
|
||||
terminal_type.kde_konsole = true;
|
||||
new_termtype = "konsole-256color";
|
||||
}
|
||||
|
||||
if ( color_env.string3 && std::strlen(color_env.string3) > 0 )
|
||||
if ( color_env.string3.getLength() > 0 )
|
||||
decscusr_support = true;
|
||||
|
||||
return new_termtype;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const char* FTermDetection::determineMaxColor (const char current_termtype[])
|
||||
FString FTermDetection::determineMaxColor (const FString& current_termtype)
|
||||
{
|
||||
// Determine xterm maximum number of colors via OSC 4
|
||||
|
||||
const char* new_termtype = current_termtype;
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
FString new_termtype{current_termtype};
|
||||
auto& keyboard = FKeyboard::getInstance();
|
||||
keyboard.setNonBlockingInput();
|
||||
|
||||
if ( ! color256
|
||||
|
@ -563,7 +504,7 @@ const char* FTermDetection::determineMaxColor (const char current_termtype[])
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString FTermDetection::getXTermColorName (FColor color)
|
||||
FString FTermDetection::getXTermColorName (FColor color) const
|
||||
{
|
||||
FString color_str{""};
|
||||
std::array<char, 30> buf{};
|
||||
|
@ -602,7 +543,7 @@ FString FTermDetection::getXTermColorName (FColor color)
|
|||
|
||||
if ( pos > 4 && std::sscanf(temp.data(), parse, &index, buf.data()) == 2 )
|
||||
{
|
||||
std::size_t n = std::strlen(buf.data());
|
||||
auto n = stringLength(buf.data());
|
||||
|
||||
// BEL + '\0' = string terminator
|
||||
if ( n >= 6 && buf[n - 1] == BEL[0] && buf[n] == '\0' )
|
||||
|
@ -619,26 +560,16 @@ FString FTermDetection::getXTermColorName (FColor color)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const char* FTermDetection::parseAnswerbackMsg (const char current_termtype[])
|
||||
FString FTermDetection::parseAnswerbackMsg (const FString& current_termtype)
|
||||
{
|
||||
const char* new_termtype = current_termtype;
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
FString new_termtype{current_termtype};
|
||||
auto& keyboard = FKeyboard::getInstance();
|
||||
keyboard.setNonBlockingInput();
|
||||
// send ENQ and read the answerback message
|
||||
const auto& ans = getAnswerbackMsg();
|
||||
answer_back = getAnswerbackMsg();
|
||||
keyboard.unsetNonBlockingInput();
|
||||
|
||||
try
|
||||
{
|
||||
answer_back = new FString(ans);
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
badAllocOutput ("FString");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if ( *answer_back == "PuTTY" )
|
||||
if ( answer_back == "PuTTY" )
|
||||
{
|
||||
terminal_type.putty = true;
|
||||
|
||||
|
@ -654,20 +585,15 @@ const char* FTermDetection::parseAnswerbackMsg (const char current_termtype[])
|
|||
std::fflush (stdout);
|
||||
|
||||
#if DEBUG
|
||||
if ( new_termtype )
|
||||
{
|
||||
std::strncpy ( termtype_Answerback
|
||||
, new_termtype
|
||||
, sizeof(termtype_Answerback) - 1);
|
||||
termtype_Answerback[sizeof(termtype_Answerback) - 1] = '\0';
|
||||
}
|
||||
if ( ! new_termtype.isEmpty() )
|
||||
termtype_Answerback = new_termtype;
|
||||
#endif // DEBUG
|
||||
|
||||
return new_termtype;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString FTermDetection::getAnswerbackMsg()
|
||||
FString FTermDetection::getAnswerbackMsg() const
|
||||
{
|
||||
FString answerback{""};
|
||||
fd_set ifds{};
|
||||
|
@ -707,45 +633,31 @@ FString FTermDetection::getAnswerbackMsg()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const char* FTermDetection::parseSecDA (const char current_termtype[])
|
||||
FString FTermDetection::parseSecDA (const FString& 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
|
||||
const auto& ans = getSecDA();
|
||||
sec_da = getSecDA();
|
||||
|
||||
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 )
|
||||
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 FStringList sec_da_list = temp.split(';');
|
||||
|
||||
const uLong num_components = sec_da_list.size();
|
||||
const auto sec_da_components = temp.split(';');
|
||||
const auto num_components = sec_da_components.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;
|
||||
|
||||
|
@ -758,21 +670,18 @@ const char* FTermDetection::parseSecDA (const char current_termtype[])
|
|||
// Read the terminal hardware option
|
||||
secondary_da.terminal_id_hardware = str2int(sec_da_components[2]);
|
||||
|
||||
const char* new_termtype = secDA_Analysis(current_termtype);
|
||||
FString new_termtype = secDA_Analysis(current_termtype);
|
||||
|
||||
#if DEBUG
|
||||
if ( new_termtype )
|
||||
{
|
||||
std::strncpy (termtype_SecDA, new_termtype, sizeof(termtype_SecDA));
|
||||
termtype_SecDA[sizeof(termtype_SecDA) - 1] = '\0';
|
||||
}
|
||||
if ( ! new_termtype.isEmpty() )
|
||||
termtype_SecDA = new_termtype;
|
||||
#endif // DEBUG
|
||||
|
||||
return new_termtype;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int FTermDetection::str2int (const FString& s)
|
||||
int FTermDetection::str2int (const FString& s) const
|
||||
{
|
||||
// This is not a general string to integer conversion method.
|
||||
// It is only used in this class to convert the device attribute
|
||||
|
@ -780,7 +689,7 @@ int FTermDetection::str2int (const FString& s)
|
|||
|
||||
constexpr int ERROR = -1;
|
||||
|
||||
if ( ! s )
|
||||
if ( s.isEmpty() )
|
||||
return ERROR;
|
||||
|
||||
try
|
||||
|
@ -802,7 +711,7 @@ int FTermDetection::str2int (const FString& s)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString FTermDetection::getSecDA()
|
||||
FString FTermDetection::getSecDA() const
|
||||
{
|
||||
FString sec_da_str{""};
|
||||
|
||||
|
@ -813,10 +722,10 @@ FString FTermDetection::getSecDA()
|
|||
const int stdout_no{FTermios::getStdOut()};
|
||||
fd_set ifds{};
|
||||
struct timeval tv{};
|
||||
constexpr auto& SECDA{ESC "[>c"};
|
||||
const std::string SECDA{ESC "[>c"};
|
||||
|
||||
// Get the secondary device attributes
|
||||
if ( write(stdout_no, SECDA, std::strlen(SECDA)) == -1 )
|
||||
if ( write(stdout_no, SECDA.data(), SECDA.length()) == -1 )
|
||||
return sec_da_str;
|
||||
|
||||
std::fflush(stdout);
|
||||
|
@ -852,9 +761,9 @@ FString FTermDetection::getSecDA()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const char* FTermDetection::secDA_Analysis (const char current_termtype[])
|
||||
FString FTermDetection::secDA_Analysis (const FString& current_termtype)
|
||||
{
|
||||
const char* new_termtype = current_termtype;
|
||||
FString new_termtype{current_termtype};
|
||||
|
||||
switch ( secondary_da.terminal_id_type )
|
||||
{
|
||||
|
@ -875,7 +784,7 @@ const char* FTermDetection::secDA_Analysis (const char current_termtype[])
|
|||
break;
|
||||
|
||||
case 32: // Tera Term
|
||||
new_termtype = secDA_Analysis_32(current_termtype);
|
||||
new_termtype = secDA_Analysis_32();
|
||||
break;
|
||||
|
||||
case 41: // DEC VT420
|
||||
|
@ -888,11 +797,11 @@ const char* FTermDetection::secDA_Analysis (const char current_termtype[])
|
|||
break;
|
||||
|
||||
case 67: // Cygwin
|
||||
new_termtype = secDA_Analysis_67(current_termtype);
|
||||
new_termtype = secDA_Analysis_67();
|
||||
break;
|
||||
|
||||
case 77: // mintty
|
||||
new_termtype = secDA_Analysis_77(current_termtype);
|
||||
new_termtype = secDA_Analysis_77();
|
||||
break;
|
||||
|
||||
case 82: // rxvt
|
||||
|
@ -928,11 +837,11 @@ const char* FTermDetection::secDA_Analysis (const char current_termtype[])
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline const char* FTermDetection::secDA_Analysis_0 (const char current_termtype[])
|
||||
inline FString FTermDetection::secDA_Analysis_0 (const FString& current_termtype)
|
||||
{
|
||||
// Terminal ID 0 - DEC VT100
|
||||
|
||||
const char* new_termtype = current_termtype;
|
||||
FString new_termtype{current_termtype};
|
||||
|
||||
if ( secondary_da.terminal_id_version == 10
|
||||
&& secondary_da.terminal_id_hardware == 1 )
|
||||
|
@ -951,11 +860,11 @@ inline const char* FTermDetection::secDA_Analysis_0 (const char current_termtype
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline const char* FTermDetection::secDA_Analysis_1 (const char current_termtype[])
|
||||
inline FString FTermDetection::secDA_Analysis_1 (const FString& current_termtype)
|
||||
{
|
||||
// Terminal ID 1 - DEC VT220
|
||||
|
||||
const char* new_termtype = current_termtype;
|
||||
FString new_termtype{current_termtype};
|
||||
|
||||
if ( isKittyTerminal() )
|
||||
new_termtype = secDA_Analysis_kitty(new_termtype);
|
||||
|
@ -966,11 +875,11 @@ inline const char* FTermDetection::secDA_Analysis_1 (const char current_termtype
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline const char* FTermDetection::secDA_Analysis_24 (const char current_termtype[])
|
||||
inline FString FTermDetection::secDA_Analysis_24 (const FString& current_termtype)
|
||||
{
|
||||
// Terminal ID 24 - DEC VT320
|
||||
|
||||
const char* new_termtype = current_termtype;
|
||||
FString new_termtype{current_termtype};
|
||||
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
|
||||
|
||||
|
@ -978,9 +887,9 @@ inline const char* FTermDetection::secDA_Analysis_24 (const char current_termtyp
|
|||
&& FTermOpenBSD::isBSDConsole() )
|
||||
{
|
||||
// NetBSD/OpenBSD workstation console
|
||||
if ( std::strncmp(termtype, "wsvt25", 6) == 0 )
|
||||
if ( termtype.left(6) == "wsvt25" )
|
||||
terminal_type.netbsd_con = true;
|
||||
else if ( std::strncmp(termtype, "vt220", 5) == 0 )
|
||||
else if ( termtype.left(5) == "vt220" )
|
||||
{
|
||||
terminal_type.openbsd_con = true;
|
||||
new_termtype = "pccon";
|
||||
|
@ -993,17 +902,16 @@ inline const char* FTermDetection::secDA_Analysis_24 (const char current_termtyp
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline const char* FTermDetection::secDA_Analysis_32 (const char[])
|
||||
inline FString FTermDetection::secDA_Analysis_32()
|
||||
{
|
||||
// Terminal ID 32 - Tera Term
|
||||
|
||||
terminal_type.tera_term = true;
|
||||
const char* new_termtype = "teraterm";
|
||||
return new_termtype;
|
||||
return "teraterm";
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline const char* FTermDetection::secDA_Analysis_65 (const char current_termtype[])
|
||||
inline FString FTermDetection::secDA_Analysis_65 (const FString& current_termtype)
|
||||
{
|
||||
// Terminal ID 65 - DEC VT525 and VTE >= 0.53.0
|
||||
|
||||
|
@ -1011,37 +919,35 @@ inline const char* FTermDetection::secDA_Analysis_65 (const char current_termtyp
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline const char* FTermDetection::secDA_Analysis_67 (const char[])
|
||||
inline FString FTermDetection::secDA_Analysis_67()
|
||||
{
|
||||
// Terminal ID 67 - cygwin
|
||||
|
||||
terminal_type.cygwin = true;
|
||||
const char* new_termtype = "cygwin";
|
||||
std::fflush(stdout);
|
||||
return new_termtype;
|
||||
return "cygwin";
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline const char* FTermDetection::secDA_Analysis_77 (const char[])
|
||||
inline FString FTermDetection::secDA_Analysis_77()
|
||||
{
|
||||
// Terminal ID 77 - mintty
|
||||
|
||||
terminal_type.mintty = true;
|
||||
decscusr_support = true;
|
||||
const char* new_termtype = "xterm-256color";
|
||||
std::fflush(stdout);
|
||||
return new_termtype;
|
||||
return "xterm-256color";
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline const char* FTermDetection::secDA_Analysis_82()
|
||||
inline FString FTermDetection::secDA_Analysis_82()
|
||||
{
|
||||
// Terminal ID 82 - rxvt
|
||||
|
||||
const char* new_termtype{};
|
||||
FString new_termtype{};
|
||||
terminal_type.rxvt = true;
|
||||
|
||||
if ( std::strncmp(termtype, "rxvt-cygwin-native", 18) == 0 )
|
||||
if ( termtype == "rxvt-cygwin-native" )
|
||||
new_termtype = "rxvt-16color";
|
||||
else
|
||||
new_termtype = "rxvt";
|
||||
|
@ -1050,36 +956,34 @@ inline const char* FTermDetection::secDA_Analysis_82()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline const char* FTermDetection::secDA_Analysis_83 (const char current_termtype[])
|
||||
inline FString FTermDetection::secDA_Analysis_83 (const FString& current_termtype)
|
||||
{
|
||||
// Terminal ID 83 - screen
|
||||
|
||||
const char* new_termtype = current_termtype;
|
||||
terminal_type.screen = true;
|
||||
return new_termtype;
|
||||
return current_termtype;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline const char* FTermDetection::secDA_Analysis_84 (const char current_termtype[])
|
||||
inline FString FTermDetection::secDA_Analysis_84 (const FString& current_termtype)
|
||||
{
|
||||
// Terminal ID 84 - tmux
|
||||
|
||||
const char* new_termtype = current_termtype;
|
||||
terminal_type.screen = true;
|
||||
terminal_type.tmux = true;
|
||||
return new_termtype;
|
||||
return current_termtype;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline const char* FTermDetection::secDA_Analysis_85()
|
||||
inline FString FTermDetection::secDA_Analysis_85()
|
||||
{
|
||||
// Terminal ID 85 - rxvt-unicode
|
||||
|
||||
const char* new_termtype{};
|
||||
FString new_termtype{};
|
||||
terminal_type.rxvt = true;
|
||||
terminal_type.urxvt = true;
|
||||
|
||||
if ( std::strncmp(termtype, "rxvt-", 5) != 0 )
|
||||
if ( termtype.left(5) == "rxvt-" )
|
||||
{
|
||||
if ( color256 )
|
||||
new_termtype = "rxvt-256color";
|
||||
|
@ -1093,12 +997,12 @@ inline const char* FTermDetection::secDA_Analysis_85()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline const char* FTermDetection::secDA_Analysis_vte (const char current_termtype[])
|
||||
inline FString FTermDetection::secDA_Analysis_vte (const FString& current_termtype)
|
||||
{
|
||||
// VTE terminal library
|
||||
// (Since VTE ) the terminal ID has changed from 1 to 65)
|
||||
|
||||
const char* new_termtype = current_termtype;
|
||||
FString new_termtype{current_termtype};
|
||||
|
||||
if ( secondary_da.terminal_id_version > 1000 )
|
||||
{
|
||||
|
@ -1117,11 +1021,11 @@ inline const char* FTermDetection::secDA_Analysis_vte (const char current_termty
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline const char* FTermDetection::secDA_Analysis_kitty (const char current_termtype[])
|
||||
inline FString FTermDetection::secDA_Analysis_kitty (const FString& current_termtype)
|
||||
{
|
||||
// kitty
|
||||
|
||||
const char* new_termtype = current_termtype;
|
||||
FString new_termtype{current_termtype};
|
||||
|
||||
if ( secondary_da.terminal_id_version > 3999 )
|
||||
{
|
||||
|
|
|
@ -46,6 +46,13 @@ 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()
|
||||
{
|
||||
|
@ -61,7 +68,7 @@ bool FTermFreeBSD::setCursorStyle (CursorStyle style)
|
|||
return false;
|
||||
|
||||
cursor_style = style;
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
auto& fterm_data = FTermData::getInstance();
|
||||
|
||||
if ( fterm_data.isCursorHidden() )
|
||||
return false;
|
||||
|
@ -75,7 +82,7 @@ bool FTermFreeBSD::isFreeBSDConsole()
|
|||
// Check if it's a FreeBSD console
|
||||
|
||||
keymap_t keymap{};
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
|
||||
if ( fsystem->ioctl(0, GIO_KEYMAP, &keymap) == 0 )
|
||||
return true;
|
||||
|
@ -148,7 +155,7 @@ void FTermFreeBSD::initCharMap()
|
|||
if ( ! isFreeBSDConsole() )
|
||||
return;
|
||||
|
||||
for (auto&& entry : fc::character)
|
||||
for (auto&& entry : FCharMap::getCharEncodeMap())
|
||||
if ( entry.pc < 0x1c )
|
||||
entry.pc = entry.ascii;
|
||||
}
|
||||
|
@ -187,7 +194,7 @@ bool FTermFreeBSD::saveFreeBSDAltKey()
|
|||
static constexpr int left_alt = 0x38;
|
||||
int ret{-1};
|
||||
keymap_t keymap{};
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap);
|
||||
|
||||
if ( ret < 0 )
|
||||
|
@ -206,7 +213,7 @@ bool FTermFreeBSD::setFreeBSDAltKey (uInt key)
|
|||
static constexpr int left_alt = 0x38;
|
||||
int ret{-1};
|
||||
keymap_t keymap{};
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap);
|
||||
|
||||
if ( ret < 0 )
|
||||
|
@ -241,7 +248,7 @@ bool FTermFreeBSD::resetFreeBSDAlt2Meta()
|
|||
//----------------------------------------------------------------------
|
||||
bool FTermFreeBSD::setFreeBSDCursorStyle (CursorStyle style)
|
||||
{
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
|
||||
if ( fsystem->ioctl(0, CONS_CURSORTYPE, &style) == 0 )
|
||||
return true;
|
||||
|
|
|
@ -61,6 +61,13 @@ 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
|
||||
{
|
||||
|
@ -90,7 +97,7 @@ bool FTermLinux::setCursorStyle (CursorStyle style)
|
|||
|
||||
linux_console_cursor_style = style;
|
||||
|
||||
if ( FTerm::getFTermData().isCursorHidden() )
|
||||
if ( FTermData::getInstance().isCursorHidden() )
|
||||
return false;
|
||||
|
||||
setLinuxCursorStyle(style);
|
||||
|
@ -134,7 +141,7 @@ bool FTermLinux::isLinuxConsole()
|
|||
|
||||
char arg{0};
|
||||
int fd_tty = FTerm::getTTYFileDescriptor();
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
|
||||
if ( fd_tty < 0 ) // Undefined tty file descriptor
|
||||
fd_tty = 0;
|
||||
|
@ -150,7 +157,7 @@ void FTermLinux::init()
|
|||
{
|
||||
// Initialize Linux console
|
||||
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
auto& fterm_data = FTermData::getInstance();
|
||||
screen_unicode_map.entries = nullptr;
|
||||
screen_font.data = nullptr;
|
||||
fterm_data.supportShadowCharacter (true);
|
||||
|
@ -163,7 +170,7 @@ void FTermLinux::init()
|
|||
|
||||
if ( FTerm::openConsole() == 0 )
|
||||
{
|
||||
FTerm::getFTermDetection().setLinuxTerm (isLinuxConsole());
|
||||
FTermDetection::getInstance().setLinuxTerm(isLinuxConsole());
|
||||
|
||||
if ( FTerm::isLinuxTerm() )
|
||||
{
|
||||
|
@ -208,7 +215,7 @@ void FTermLinux::initCharMap() const
|
|||
|
||||
if ( screen_unicode_map.entry_ct > 0 && screen_unicode_map.entries )
|
||||
{
|
||||
for (auto&& entry : fc::character)
|
||||
for (auto&& entry : FCharMap::getCharEncodeMap())
|
||||
{
|
||||
const auto ucs = entry.unicode;
|
||||
const sInt16 fontpos = getFontPos(ucs);
|
||||
|
@ -282,7 +289,7 @@ bool FTermLinux::loadVGAFont()
|
|||
|
||||
if ( vga_font )
|
||||
{
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
auto& fterm_data = FTermData::getInstance();
|
||||
fterm_data.supportShadowCharacter (true);
|
||||
fterm_data.supportHalfBlockCharacter (true);
|
||||
}
|
||||
|
@ -330,7 +337,7 @@ bool FTermLinux::loadNewFont()
|
|||
|
||||
if ( new_font )
|
||||
{
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
auto& fterm_data = FTermData::getInstance();
|
||||
fterm_data.supportShadowCharacter (true);
|
||||
fterm_data.supportHalfBlockCharacter (true);
|
||||
}
|
||||
|
@ -462,7 +469,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 = FTerm::getFSystem();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
|
||||
if ( (fd = fsystem->open(fb, O_RDWR)) < 0 )
|
||||
{
|
||||
|
@ -521,7 +528,7 @@ bool FTermLinux::getScreenFont()
|
|||
}
|
||||
|
||||
// Font operation
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
ret = fsystem->ioctl (fd_tty, KDFONTOP, &font);
|
||||
|
||||
if ( ret != 0 )
|
||||
|
@ -552,7 +559,7 @@ bool FTermLinux::getUnicodeMap()
|
|||
screen_unicode_map.entries = nullptr;
|
||||
|
||||
// Get count
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
ret = fsystem->ioctl (fd_tty, GIO_UNIMAP, &screen_unicode_map);
|
||||
|
||||
if ( ret != 0 )
|
||||
|
@ -592,7 +599,7 @@ FTermLinux::ModifierKey& FTermLinux::getModifierKey()
|
|||
// Fill bit field with 0
|
||||
std::memset (&mod_key, 0x00, sizeof(mod_key));
|
||||
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
|
||||
// TIOCLINUX, subcode = 6 (TIOCL_GETSHIFTSTATE)
|
||||
if ( fsystem->ioctl(0, TIOCLINUX, &subcode) >= 0 )
|
||||
|
@ -658,7 +665,7 @@ int FTermLinux::setScreenFont ( const uChar fontdata[], uInt count
|
|||
}
|
||||
|
||||
// Font operation
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
ret = fsystem->ioctl (fd_tty, KDFONTOP, &font);
|
||||
|
||||
if ( ret != 0 && errno != ENOSYS && errno != EINVAL )
|
||||
|
@ -695,7 +702,7 @@ int FTermLinux::setUnicodeMap (struct unimapdesc* unimap) const
|
|||
do
|
||||
{
|
||||
// Clear the unicode-to-font table
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
ret = fsystem->ioctl (fd_tty, PIO_UNIMAPCLR, &advice);
|
||||
|
||||
if ( ret != 0 )
|
||||
|
@ -727,7 +734,7 @@ inline uInt16 FTermLinux::getInputStatusRegisterOne() const
|
|||
{
|
||||
// Gets the VGA input-status-register-1
|
||||
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
|
||||
// Miscellaneous output (read port)
|
||||
static constexpr uInt16 misc_read = 0x3cc;
|
||||
|
@ -743,7 +750,7 @@ uChar FTermLinux::readAttributeController (uChar index) const
|
|||
{
|
||||
// Reads a byte from the attribute controller from a given index
|
||||
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
|
||||
// Attribute controller (write port)
|
||||
static constexpr uInt16 attrib_cntlr_write = 0x3c0;
|
||||
|
@ -769,7 +776,7 @@ void FTermLinux::writeAttributeController (uChar index, uChar data) const
|
|||
{
|
||||
// Writes a byte from the attribute controller from a given index
|
||||
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
|
||||
// Attribute controller (write port)
|
||||
static constexpr uInt16 attrib_cntlr_write = 0x3c0;
|
||||
|
@ -808,7 +815,7 @@ int FTermLinux::setBlinkAsIntensity (bool enable) const
|
|||
// Uses blink-bit as background intensity.
|
||||
// That permits 16 colors for background
|
||||
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
|
||||
const int fd_tty = FTerm::getTTYFileDescriptor();
|
||||
|
||||
|
@ -847,7 +854,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 = FTerm::getFSystem();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
const int fd_tty = FTerm::getTTYFileDescriptor();
|
||||
|
||||
if ( fsystem->getuid() != 0 ) // Direct hardware access requires root privileges
|
||||
|
@ -872,7 +879,7 @@ bool FTermLinux::has9BitCharacters() const
|
|||
//----------------------------------------------------------------------
|
||||
void FTermLinux::getVGAPalette()
|
||||
{
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
|
||||
if ( fsystem->ioctl(0, GIO_CMAP, cmap.color.data()) != 0 )
|
||||
setVGADefaultPalette(); // Fallback, if GIO_CMAP does not work
|
||||
|
@ -917,7 +924,7 @@ bool FTermLinux::setVGAPalette (FColor index, int r, int g, int b)
|
|||
cmap.color[uInt16(index)].blue = uChar(b);
|
||||
}
|
||||
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
|
||||
if ( fsystem->ioctl(0, PIO_CMAP, cmap.color.data()) == 0 )
|
||||
return true;
|
||||
|
@ -930,7 +937,7 @@ bool FTermLinux::saveVGAPalette()
|
|||
{
|
||||
// Save the current vga color map
|
||||
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
|
||||
if ( fsystem->ioctl(0, GIO_CMAP, saved_color_map.color.data()) == 0 )
|
||||
has_saved_palette = true;
|
||||
|
@ -945,7 +952,7 @@ bool FTermLinux::resetVGAPalette()
|
|||
{
|
||||
// Reset the vga color map
|
||||
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
|
||||
if ( has_saved_palette )
|
||||
{
|
||||
|
@ -1128,7 +1135,7 @@ inline void FTermLinux::shiftCtrlAltKeyCorrection()
|
|||
//----------------------------------------------------------------------
|
||||
inline void FTermLinux::initSpecialCharacter() const
|
||||
{
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
auto& fterm_data = FTermData::getInstance();
|
||||
const auto c1 = wchar_t(UniChar::UpperHalfBlock); // ▀
|
||||
const auto c2 = wchar_t(UniChar::LowerHalfBlock); // ▄
|
||||
const auto c3 = wchar_t(UniChar::FullBlock); // █
|
||||
|
@ -1169,7 +1176,7 @@ void FTermLinux::characterFallback ( wchar_t ucs
|
|||
, const std::vector<wchar_t>& fallback ) const
|
||||
{
|
||||
constexpr sInt16 NOT_FOUND = -1;
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
auto& fterm_data = FTermData::getInstance();
|
||||
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-2020 Markus Gans *
|
||||
* Copyright 2018-2021 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,13 +41,20 @@ 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 = FTerm::getFSystem();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
|
||||
if ( fsystem->ioctl(0, WSKBDIO_GETENCODING, &kbdencoding) == 0 )
|
||||
return true;
|
||||
|
@ -102,7 +109,7 @@ bool FTermOpenBSD::setBeep (int Hz, int ms)
|
|||
bell.pitch = uInt(Hz);
|
||||
bell.period = uInt(ms);
|
||||
bell.volume = 50; // 50% volume
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
|
||||
if ( fsystem->ioctl(0, WSKBDIO_SETBELL, &bell) < 0 )
|
||||
return false;
|
||||
|
@ -114,7 +121,7 @@ bool FTermOpenBSD::setBeep (int Hz, int ms)
|
|||
bool FTermOpenBSD::resetBeep()
|
||||
{
|
||||
wskbd_bell_data default_bell;
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
|
||||
// Gets the default setting for the bell
|
||||
if ( fsystem->ioctl(0, WSKBDIO_GETDEFAULTBELL, &default_bell) < 0 )
|
||||
|
@ -147,7 +154,7 @@ bool FTermOpenBSD::saveBSDConsoleEncoding()
|
|||
static kbd_t k_encoding{};
|
||||
int ret{-1};
|
||||
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
ret = fsystem->ioctl (0, WSKBDIO_GETENCODING, &k_encoding);
|
||||
|
||||
if ( ret < 0 )
|
||||
|
@ -161,7 +168,7 @@ bool FTermOpenBSD::saveBSDConsoleEncoding()
|
|||
//----------------------------------------------------------------------
|
||||
bool FTermOpenBSD::setBSDConsoleEncoding (kbd_t k_encoding)
|
||||
{
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
const auto& fsystem = FSystem::getInstance();
|
||||
|
||||
if ( fsystem->ioctl(0, WSKBDIO_SETENCODING, &k_encoding) < 0 )
|
||||
return false;
|
||||
|
|
|
@ -51,6 +51,13 @@ 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)
|
||||
{
|
||||
|
@ -241,7 +248,7 @@ void FTermXTerminal::resetHighlightBackground()
|
|||
//----------------------------------------------------------------------
|
||||
void FTermXTerminal::resetDefaults()
|
||||
{
|
||||
if ( FTerm::getFTermDetection().isPuttyTerminal() )
|
||||
if ( FTermDetection::getInstance().isPuttyTerminal() )
|
||||
return;
|
||||
|
||||
// Redefines the cursor color if resetCursorColor() doesn't work
|
||||
|
@ -272,14 +279,14 @@ void FTermXTerminal::resetTitle()
|
|||
//----------------------------------------------------------------------
|
||||
void FTermXTerminal::captureFontAndTitle()
|
||||
{
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
|
||||
if ( ( term_detection.isXTerminal()
|
||||
|| term_detection.isUrxvtTerminal() )
|
||||
&& ! term_detection.isRxvtTerminal() )
|
||||
{
|
||||
FTermios::setCaptureSendCharacters();
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
auto& keyboard = FKeyboard::getInstance();
|
||||
keyboard.setNonBlockingInput();
|
||||
xterm_font = captureXTermFont();
|
||||
xterm_title = captureXTermTitle();
|
||||
|
@ -310,7 +317,7 @@ void FTermXTerminal::setXTermCursorStyle()
|
|||
return;
|
||||
#endif
|
||||
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
|
||||
if ( term_detection.isGnomeTerminal()
|
||||
&& ! term_detection.hasSetCursorStyleSupport() )
|
||||
|
@ -334,7 +341,7 @@ void FTermXTerminal::setXTermCursorStyle()
|
|||
void FTermXTerminal::setXTermTitle()
|
||||
{
|
||||
// Set the xterm title
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
|
||||
if ( term_detection.isXTerminal()
|
||||
|| term_detection.isScreenTerm()
|
||||
|
@ -345,10 +352,6 @@ 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);
|
||||
|
@ -359,7 +362,7 @@ void FTermXTerminal::setXTermTitle()
|
|||
//----------------------------------------------------------------------
|
||||
void FTermXTerminal::setXTermSize() const
|
||||
{
|
||||
if ( ! FTerm::getFTermDetection().isXTerminal() )
|
||||
if ( ! FTermDetection::getInstance().isXTerminal() )
|
||||
return;
|
||||
|
||||
FTerm::putstringf ( CSI "8;%lu;%lut"
|
||||
|
@ -373,7 +376,7 @@ void FTermXTerminal::setXTermFont()
|
|||
{
|
||||
// Change the XTerm font (needs the allowFontOps resource)
|
||||
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
|
||||
if ( term_detection.isXTerminal()
|
||||
|| term_detection.isScreenTerm()
|
||||
|
@ -391,7 +394,7 @@ void FTermXTerminal::setXTermForeground()
|
|||
{
|
||||
// Set the XTerm text foreground color
|
||||
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
|
||||
if ( term_detection.isXTerminal()
|
||||
|| term_detection.isScreenTerm()
|
||||
|
@ -411,7 +414,7 @@ void FTermXTerminal::setXTermBackground()
|
|||
{
|
||||
// Set the XTerm text background color
|
||||
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
|
||||
if ( term_detection.isXTerminal()
|
||||
|| term_detection.isScreenTerm()
|
||||
|
@ -431,7 +434,7 @@ void FTermXTerminal::setXTermCursorColor()
|
|||
{
|
||||
// Set the text cursor color
|
||||
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
|
||||
if ( term_detection.isXTerminal()
|
||||
|| term_detection.isScreenTerm()
|
||||
|
@ -451,7 +454,7 @@ void FTermXTerminal::setXTermMouseForeground()
|
|||
{
|
||||
// Set the mouse foreground color
|
||||
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
|
||||
if ( term_detection.isXTerminal()
|
||||
|| term_detection.isScreenTerm()
|
||||
|
@ -470,7 +473,7 @@ void FTermXTerminal::setXTermMouseBackground()
|
|||
{
|
||||
// Set the mouse background color
|
||||
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
|
||||
if ( term_detection.isXTerminal()
|
||||
|| term_detection.isScreenTerm()
|
||||
|
@ -488,7 +491,7 @@ void FTermXTerminal::setXTermHighlightBackground()
|
|||
{
|
||||
// Set the highlight background color
|
||||
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
|
||||
if ( term_detection.isXTerminal()
|
||||
|| term_detection.isScreenTerm()
|
||||
|
@ -508,7 +511,7 @@ void FTermXTerminal::setXTerm8ColorDefaults()
|
|||
// Redefinition of the XTerm default colors
|
||||
// for the final cut 8 color theme
|
||||
|
||||
if ( FTerm::getFTermDetection().isPuttyTerminal() )
|
||||
if ( FTermDetection::getInstance().isPuttyTerminal() )
|
||||
return;
|
||||
|
||||
setXTermDefaultsMouseCursor();
|
||||
|
@ -528,7 +531,7 @@ void FTermXTerminal::setXTerm16ColorDefaults()
|
|||
// Redefinition of the XTerm default colors
|
||||
// for the final cut 16 color theme
|
||||
|
||||
if ( FTerm::getFTermDetection().isPuttyTerminal() )
|
||||
if ( FTermDetection::getInstance().isPuttyTerminal() )
|
||||
return;
|
||||
|
||||
setXTermDefaultsMouseCursor();
|
||||
|
@ -548,14 +551,14 @@ inline void FTermXTerminal::setXTermDefaultsMouseCursor()
|
|||
setMouseBackground("rgb:ffff/ffff/ffff"); // white
|
||||
setMouseForeground ("rgb:0000/0000/0000"); // black
|
||||
|
||||
if ( ! FTerm::getFTermDetection().isGnomeTerminal() )
|
||||
if ( ! FTermDetection::getInstance().isGnomeTerminal() )
|
||||
setCursorColor("rgb:ffff/ffff/ffff"); // white
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermXTerminal::canSetXTermBackground() const
|
||||
{
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
|
||||
if ( xterm_default_colors
|
||||
&& ! (term_detection.isMinttyTerm()
|
||||
|
@ -572,7 +575,7 @@ void FTermXTerminal::resetXTermColorMap() const
|
|||
{
|
||||
// Reset the entire color table
|
||||
|
||||
if ( FTerm::getFTermDetection().isMinttyTerm() )
|
||||
if ( FTermDetection::getInstance().isMinttyTerm() )
|
||||
{
|
||||
FTerm::putstring (ESC "c"); // Full Reset (RIS)
|
||||
}
|
||||
|
@ -672,7 +675,7 @@ void FTermXTerminal::resetXTermHighlightBackground() const
|
|||
//----------------------------------------------------------------------
|
||||
bool FTermXTerminal::canResetColor() const
|
||||
{
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
|
||||
if ( term_detection.isGnomeTerminal()
|
||||
&& term_detection.getGnomeTerminalID() < 3502 )
|
||||
|
@ -693,7 +696,7 @@ bool FTermXTerminal::canResetColor() const
|
|||
//----------------------------------------------------------------------
|
||||
void FTermXTerminal::oscPrefix() const
|
||||
{
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
|
||||
if ( term_detection.isTmuxTerm() )
|
||||
{
|
||||
|
@ -710,7 +713,7 @@ void FTermXTerminal::oscPrefix() const
|
|||
//----------------------------------------------------------------------
|
||||
void FTermXTerminal::oscPostfix() const
|
||||
{
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
|
||||
if ( term_detection.isScreenTerm()
|
||||
|| term_detection.isTmuxTerm() )
|
||||
|
@ -723,7 +726,7 @@ void FTermXTerminal::oscPostfix() const
|
|||
//----------------------------------------------------------------------
|
||||
FString FTermXTerminal::captureXTermFont() const
|
||||
{
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
|
||||
if ( ! term_detection.isXTerminal()
|
||||
&& ! term_detection.isScreenTerm()
|
||||
|
@ -769,12 +772,12 @@ FString FTermXTerminal::captureXTermFont() const
|
|||
&& temp[3] == '0' && temp[4] == ';' )
|
||||
{
|
||||
// Skip leading Esc ] 5 0 ;
|
||||
char* str = &temp[5];
|
||||
const std::size_t n = std::strlen(str);
|
||||
std::string str = &temp[5];
|
||||
const std::size_t n = str.length();
|
||||
|
||||
// BEL + '\0' = string terminator
|
||||
if ( n >= 5 && str[n - 1] == BEL[0] && str[n] == '\0' )
|
||||
str[n - 1] = '\0';
|
||||
str.erase(n - 1);
|
||||
|
||||
return {str};
|
||||
}
|
||||
|
@ -785,7 +788,7 @@ FString FTermXTerminal::captureXTermFont() const
|
|||
//----------------------------------------------------------------------
|
||||
FString FTermXTerminal::captureXTermTitle() const
|
||||
{
|
||||
if ( FTerm::getFTermDetection().isKdeTerminal() )
|
||||
if ( FTermDetection::getInstance().isKdeTerminal() )
|
||||
return {};
|
||||
|
||||
fd_set ifds{};
|
||||
|
@ -822,8 +825,8 @@ FString FTermXTerminal::captureXTermTitle() const
|
|||
if ( pos > 6 && temp[0] == ESC[0] && temp[1] == ']' && temp[2] == 'l' )
|
||||
{
|
||||
// Skip leading Esc + ] + l = OSC l
|
||||
char* str = &temp[3];
|
||||
const std::size_t n = std::strlen(str);
|
||||
std::string str = &temp[3];
|
||||
const std::size_t n = str.length();
|
||||
|
||||
// Esc + \ = OSC string terminator
|
||||
if ( n >= 2 && str[n - 2] == ESC[0] && str[n - 1] == '\\' )
|
||||
|
@ -831,7 +834,7 @@ FString FTermXTerminal::captureXTermTitle() const
|
|||
if ( n < 4 )
|
||||
return {};
|
||||
|
||||
str[n - 2] = '\0';
|
||||
str.erase(n - 2);
|
||||
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("\r\n");
|
||||
auto text_split = s.split("\n");
|
||||
|
||||
for (auto&& line : text_split) // Line loop
|
||||
{
|
||||
|
@ -274,15 +274,27 @@ 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()) )
|
||||
return;
|
||||
throw std::out_of_range(""); // Invalid range
|
||||
|
||||
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-2020 Markus Gans *
|
||||
* Copyright 2014-2021 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.isNull() || text.isEmpty() )
|
||||
if ( 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}
|
||||
, text{txt.trim()}
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ FToolTip::~FToolTip() // destructor
|
|||
//----------------------------------------------------------------------
|
||||
void FToolTip::setText (const FString& txt)
|
||||
{
|
||||
text.setString(txt);
|
||||
text.setString(txt.trim());
|
||||
calculateDimensions();
|
||||
}
|
||||
|
||||
|
|
|
@ -61,14 +61,12 @@ 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{};
|
||||
struct timeval FVTerm::time_last_flush{};
|
||||
struct timeval FVTerm::last_term_size_check{};
|
||||
TimeValue FVTerm::time_last_flush{};
|
||||
const FVTerm* FVTerm::init_object{nullptr};
|
||||
FVTerm::FTermArea* FVTerm::vterm{nullptr};
|
||||
FVTerm::FTermArea* FVTerm::vdesktop{nullptr};
|
||||
|
@ -185,9 +183,9 @@ void FVTerm::hideCursor (bool enable) const
|
|||
if ( ! cursor_hideable )
|
||||
return;
|
||||
|
||||
const char* visibility_str = FTerm::cursorsVisibilityString (enable);
|
||||
auto visibility_str = FTerm::cursorsVisibilityString (enable);
|
||||
|
||||
if ( ! visibility_str ) // Exit the function if the string is empty
|
||||
if ( visibility_str.empty() ) // Exit the function if the string is empty
|
||||
return;
|
||||
|
||||
appendOutputBuffer(FTermControl{visibility_str});
|
||||
|
@ -342,8 +340,8 @@ void FVTerm::delPreprocessingHandler (const FVTerm* instance)
|
|||
//----------------------------------------------------------------------
|
||||
int FVTerm::print (const FString& string)
|
||||
{
|
||||
if ( string.isNull() )
|
||||
return -1;
|
||||
if ( string.isEmpty() )
|
||||
return 0;
|
||||
|
||||
FTermBuffer term_buffer{};
|
||||
term_buffer.write(string);
|
||||
|
@ -353,7 +351,7 @@ int FVTerm::print (const FString& string)
|
|||
//----------------------------------------------------------------------
|
||||
int FVTerm::print (FTermArea* area, const FString& string)
|
||||
{
|
||||
if ( ! area || string.isNull() )
|
||||
if ( ! area || string.isEmpty() )
|
||||
return -1;
|
||||
|
||||
FTermBuffer term_buffer{};
|
||||
|
@ -601,9 +599,9 @@ void FVTerm::flush() const
|
|||
}
|
||||
|
||||
std::fflush(stdout);
|
||||
auto& mouse = FTerm::getFMouseControl();
|
||||
auto& mouse = FMouseControl::getInstance();
|
||||
mouse.drawPointer();
|
||||
FObject::getCurrentTime (&time_last_flush);
|
||||
time_last_flush = FObject::getCurrentTime();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1764,8 +1762,8 @@ FChar FVTerm::getCharacter ( CharacterType char_type
|
|||
|
||||
const int x = pos.getX();
|
||||
const int y = pos.getY();
|
||||
int xx = ( x > 0 ) ? x : 0;
|
||||
int yy = ( y > 0 ) ? y : 0;
|
||||
int xx = std::max(x, 0);
|
||||
int yy = std::max(y, 0);
|
||||
|
||||
if ( xx >= vterm->width )
|
||||
xx = vterm->width - 1;
|
||||
|
@ -1876,17 +1874,14 @@ void FVTerm::init()
|
|||
vdesktop->visible = true;
|
||||
active_area = vdesktop;
|
||||
|
||||
// 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;
|
||||
// Initialize the last flush time
|
||||
time_last_flush = TimeValue{};
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FVTerm::init_characterLengths()
|
||||
{
|
||||
const auto& opti_move = FTerm::getFOptiMove();
|
||||
const auto& opti_move = FOptiMove::getInstance();
|
||||
cursor_address_length = opti_move.getCursorAddressLength();
|
||||
erase_char_length = opti_move.getEraseCharsLength();
|
||||
repeat_char_length = opti_move.getRepeatCharLength();
|
||||
|
@ -1920,7 +1915,7 @@ void FVTerm::init_combined_character()
|
|||
if ( FTerm::getEncoding() != Encoding::UTF8 )
|
||||
return;
|
||||
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
const auto& term_detection = FTermDetection::getInstance();
|
||||
|
||||
if ( term_detection.isCygwinTerminal() )
|
||||
return;
|
||||
|
@ -1944,7 +1939,7 @@ void FVTerm::finish() const
|
|||
setNormal();
|
||||
|
||||
if ( FTerm::hasAlternateScreen()
|
||||
&& FTerm::getFTermData().isInAlternateScreen() )
|
||||
&& FTermData::getInstance().isInAlternateScreen() )
|
||||
clearTerm();
|
||||
|
||||
forceTerminalUpdate();
|
||||
|
@ -2879,33 +2874,13 @@ 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
|
||||
{
|
||||
timeval now;
|
||||
FObject::getCurrentTime(&now);
|
||||
timeval diff = now - time_last_flush;
|
||||
const auto now = FObject::getCurrentTime();
|
||||
const auto diff = now - time_last_flush;
|
||||
|
||||
if ( diff.tv_sec > 0 || diff.tv_usec > 400000 )
|
||||
if ( diff > milliseconds(400) )
|
||||
{
|
||||
flush_wait = MIN_FLUSH_WAIT; // Reset to minimum values after 400 ms
|
||||
flush_average = MIN_FLUSH_WAIT;
|
||||
|
@ -2913,7 +2888,7 @@ inline void FVTerm::flushTimeAdjustment() const
|
|||
}
|
||||
else
|
||||
{
|
||||
auto usec = uInt64(diff.tv_usec);
|
||||
auto usec = uInt64(duration_cast<microseconds>(diff).count());
|
||||
|
||||
if ( usec < MIN_FLUSH_WAIT )
|
||||
usec = MIN_FLUSH_WAIT;
|
||||
|
@ -2947,13 +2922,7 @@ inline void FVTerm::flushTimeAdjustment() const
|
|||
//----------------------------------------------------------------------
|
||||
inline bool FVTerm::isFlushTimeout()
|
||||
{
|
||||
return FObject::isTimeout (&time_last_flush, flush_wait);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FVTerm::isTermSizeCheckTimeout()
|
||||
{
|
||||
return FObject::isTimeout (&last_term_size_check, term_size_check_timeout);
|
||||
return FObject::isTimeout (time_last_flush, flush_wait);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -3080,7 +3049,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 )
|
||||
if ( ! attr_str.empty() )
|
||||
appendOutputBuffer (FTermControl{attr_str});
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
#include "final/fapplication.h"
|
||||
|
@ -84,7 +85,7 @@ FWidget::FWidget (FWidget* parent)
|
|||
{
|
||||
if ( internal::var::root_widget )
|
||||
{
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
auto& fterm_data = FTermData::getInstance();
|
||||
fterm_data.setExitMessage("FWidget: No parent defined! "
|
||||
"There should be only one root object");
|
||||
FApplication::exit(EXIT_FAILURE);
|
||||
|
@ -405,7 +406,7 @@ void FWidget::setPos (const FPoint& p, bool adjust)
|
|||
return;
|
||||
}
|
||||
|
||||
if ( ! isWindowWidget() )
|
||||
if ( ! isWindowWidget() ) // A widgets must be inside the client area
|
||||
{
|
||||
if ( pos.getX() < 1 )
|
||||
pos.setX(1);
|
||||
|
@ -430,7 +431,7 @@ void FWidget::setWidth (std::size_t width, bool adjust)
|
|||
if ( getWidth() == width && wsize.getWidth() == width )
|
||||
return;
|
||||
|
||||
if ( width < 1 )
|
||||
if ( width < 1 ) // A width can never be narrower than 1 character
|
||||
width = 1;
|
||||
|
||||
wsize.setWidth(width);
|
||||
|
@ -452,7 +453,7 @@ void FWidget::setHeight (std::size_t height, bool adjust)
|
|||
if ( getHeight() == height && wsize.getHeight() == height )
|
||||
return;
|
||||
|
||||
if ( height < 1 )
|
||||
if ( height < 1 ) // A height can never be narrower than 1 character
|
||||
height = 1;
|
||||
|
||||
wsize.setHeight(height);
|
||||
|
@ -479,10 +480,10 @@ void FWidget::setSize (const FSize& size, bool adjust)
|
|||
&& getHeight() == height && wsize.getHeight() == height )
|
||||
return;
|
||||
|
||||
if ( width < 1 )
|
||||
if ( width < 1 ) // A width can never be narrower than 1 character
|
||||
width = 1;
|
||||
|
||||
if ( height < 1 )
|
||||
if ( height < 1 ) // A height can never be narrower than 1 character
|
||||
height = 1;
|
||||
|
||||
wsize.setWidth(width);
|
||||
|
@ -624,20 +625,19 @@ void FWidget::setGeometry (const FPoint& p, const FSize& s, bool adjust)
|
|||
if ( getPos() == p && getWidth() == w && getHeight() == h )
|
||||
return;
|
||||
|
||||
if ( ! isWindowWidget() )
|
||||
{
|
||||
( x < 1 ) ? wsize.setX(1) : wsize.setX(x);
|
||||
( y < 1 ) ? wsize.setY(1) : wsize.setY(y);
|
||||
}
|
||||
else
|
||||
if ( isWindowWidget() ) // A window widget can be outside
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
( w < 1 ) ? wsize.setWidth(1) : wsize.setWidth(w);
|
||||
( h < 1 ) ? wsize.setHeight(1) : wsize.setHeight(h);
|
||||
|
||||
wsize.setWidth(std::max(w, std::size_t(1u)));
|
||||
wsize.setHeight(std::max(h, std::size_t(1u)));
|
||||
adjust_wsize = wsize;
|
||||
const int term_x = getTermX();
|
||||
const int term_y = getTermY();
|
||||
|
@ -851,7 +851,7 @@ bool FWidget::close()
|
|||
{
|
||||
hide();
|
||||
|
||||
if ( ! flags.modal )
|
||||
if ( ! flags.modal && ! isInFWidgetList(close_widget, this) )
|
||||
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::getFStartOptions().dark_theme )
|
||||
if ( FStartOptions::getInstance().dark_theme )
|
||||
{
|
||||
if ( FTerm::getMaxColor() < 16 ) // for 8 color mode
|
||||
setColorTheme<default8ColorDarkTheme>();
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/fcolorpair.h"
|
||||
#include "final/fstatusbar.h"
|
||||
|
@ -53,6 +55,16 @@ 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-2020 Markus Gans *
|
||||
* Copyright 2013-2021 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 timeval time_last_event;
|
||||
static TimeValue time_last_event;
|
||||
static int loop_level;
|
||||
static int quit_code;
|
||||
static bool quit_now;
|
||||
|
|
|
@ -120,6 +120,7 @@ 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-2020 Markus Gans *
|
||||
* Copyright 2015-2021 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,43 +30,63 @@
|
|||
#include <array>
|
||||
|
||||
#include "final/fc.h"
|
||||
#include "final/fstring.h"
|
||||
#include "final/ftypes.h"
|
||||
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
namespace fc
|
||||
class FCharMap final
|
||||
{
|
||||
public:
|
||||
// Unicode fallback table for VT100, PC, and ASCII
|
||||
struct CharEncodeMap
|
||||
{
|
||||
wchar_t unicode;
|
||||
wchar_t vt100;
|
||||
wchar_t pc;
|
||||
wchar_t ascii;
|
||||
};
|
||||
|
||||
// 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;
|
||||
};
|
||||
|
||||
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
|
||||
// FCharMap inline functions
|
||||
//----------------------------------------------------------------------
|
||||
inline FString FCharMap::getClassName() const
|
||||
{ return "FCharMap"; }
|
||||
|
||||
} // namespace finalcut
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2018-2020 Markus Gans *
|
||||
* Copyright 2018-2021 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,6 +60,7 @@ class FColorPalette
|
|||
|
||||
// Accessor
|
||||
virtual FString getClassName() const;
|
||||
static auto getInstance() -> std::shared_ptr<FColorPalette>&;
|
||||
|
||||
// Methods
|
||||
virtual void setColorPalette() = 0;
|
||||
|
|
|
@ -30,9 +30,7 @@
|
|||
#endif
|
||||
|
||||
/* Define to 1 if you have the `getttynam' function. */
|
||||
#ifndef F_HAVE_GETTTYNAM
|
||||
#define F_HAVE_GETTTYNAM 1
|
||||
#endif
|
||||
/* #undef HAVE_GETTTYNAM */
|
||||
|
||||
/* Define to 1 if you have the `getuid' function. */
|
||||
#ifndef F_HAVE_GETUID
|
||||
|
@ -50,9 +48,7 @@
|
|||
#endif
|
||||
|
||||
/* Define to 1 if GPM mouse is enabled */
|
||||
#ifndef F_HAVE_LIBGPM
|
||||
#define F_HAVE_LIBGPM 1
|
||||
#endif
|
||||
/* #undef HAVE_LIBGPM */
|
||||
|
||||
/* Define to 1 if you have the <linux/fb.h> header file. */
|
||||
#ifndef F_HAVE_LINUX_FB_H
|
||||
|
@ -144,9 +140,7 @@
|
|||
#endif
|
||||
|
||||
/* Define to 1 if you have the <ttyent.h> header file. */
|
||||
#ifndef F_HAVE_TTYENT_H
|
||||
#define F_HAVE_TTYENT_H 1
|
||||
#endif
|
||||
/* #undef HAVE_TTYENT_H */
|
||||
|
||||
/* 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-2020 Markus Gans *
|
||||
* Copyright 2015-2021 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,6 +29,7 @@
|
|||
|
||||
#include <array>
|
||||
|
||||
#include "final/fstring.h"
|
||||
#include "final/ftypes.h"
|
||||
|
||||
namespace finalcut
|
||||
|
@ -36,35 +37,54 @@ namespace finalcut
|
|||
|
||||
enum class FKey : uInt32; // forward declaration
|
||||
|
||||
namespace fc
|
||||
class FKeyMap final
|
||||
{
|
||||
public:
|
||||
struct KeyCapMap
|
||||
{
|
||||
FKey num;
|
||||
const char* string;
|
||||
char tname[4];
|
||||
};
|
||||
|
||||
struct FKeyCapMap
|
||||
{
|
||||
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;
|
||||
};
|
||||
|
||||
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
|
||||
// FKeyMap inline functions
|
||||
//----------------------------------------------------------------------
|
||||
inline FString FKeyMap::getClassName() const
|
||||
{ return "FKeyMap"; }
|
||||
|
||||
} // namespace finalcut
|
||||
|
||||
|
|
|
@ -105,10 +105,11 @@ class FKeyboard final
|
|||
|
||||
// Accessors
|
||||
FString getClassName() const;
|
||||
static auto getInstance() -> FKeyboard&;
|
||||
FKey getKey() const;
|
||||
FString getKeyName (const FKey) const;
|
||||
keybuffer& getKeyBuffer();
|
||||
timeval* getKeyPressedTime();
|
||||
TimeValue getKeyPressedTime() const;
|
||||
static uInt64 getKeypressTimeout();
|
||||
static uInt64 getReadBlockingTime();
|
||||
|
||||
|
@ -145,7 +146,7 @@ class FKeyboard final
|
|||
|
||||
private:
|
||||
// Using-declaration
|
||||
using FKeyMapPtr = std::shared_ptr<decltype(fc::fkey_cap_table)>;
|
||||
using FKeyMapPtr = std::shared_ptr<FKeyMap::KeyCapMapType>;
|
||||
|
||||
// Constants
|
||||
static constexpr FKey NOT_SET = static_cast<FKey>(-1);
|
||||
|
@ -162,7 +163,7 @@ class FKeyboard final
|
|||
static bool isIntervalTimeout();
|
||||
|
||||
// Methods
|
||||
FKey UTF8decode (const char[]) const;
|
||||
FKey UTF8decode (const std::string&) const;
|
||||
ssize_t readKey();
|
||||
void parseKeyBuffer();
|
||||
FKey parseKeyString();
|
||||
|
@ -179,7 +180,7 @@ class FKeyboard final
|
|||
FKeyboardCommand escape_key_cmd{};
|
||||
FKeyboardCommand mouse_tracking_cmd{};
|
||||
|
||||
static timeval time_keypressed;
|
||||
static TimeValue time_keypressed;
|
||||
static uInt64 read_blocking_time;
|
||||
static uInt64 read_blocking_time_short;
|
||||
static uInt64 key_timeout;
|
||||
|
@ -214,8 +215,8 @@ inline FKeyboard::keybuffer& FKeyboard::getKeyBuffer()
|
|||
{ return fifo_buf; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline timeval* FKeyboard::getKeyPressedTime()
|
||||
{ return &time_keypressed; }
|
||||
inline TimeValue FKeyboard::getKeyPressedTime() const
|
||||
{ return time_keypressed; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline uInt64 FKeyboard::getKeypressTimeout()
|
||||
|
@ -233,8 +234,8 @@ inline void FKeyboard::setTermcapMap (const T& keymap)
|
|||
//----------------------------------------------------------------------
|
||||
inline void FKeyboard::setTermcapMap ()
|
||||
{
|
||||
using type = decltype(fc::fkey_cap_table);
|
||||
key_map = std::make_shared<type>(fc::fkey_cap_table);
|
||||
using type = FKeyMap::KeyCapMapType;
|
||||
key_map = std::make_shared<type>(FKeyMap::getKeyCapMap());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -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&
|
||||
, const LazyConverter& );
|
||||
, LazyConverter&& );
|
||||
template <typename Container
|
||||
, typename LazyConverter>
|
||||
void insert (Container*, const LazyConverter&);
|
||||
void insert (Container*, 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, convert);
|
||||
insert (container, std::forward<LazyConverter>(convert));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -550,11 +550,11 @@ inline void FListBox::insert ( Iterator first
|
|||
//----------------------------------------------------------------------
|
||||
template <typename Container
|
||||
, typename LazyConverter>
|
||||
void FListBox::insert (const Container& container, const LazyConverter& converter)
|
||||
void FListBox::insert (const Container& container, LazyConverter&& converter)
|
||||
{
|
||||
conv_type = ConvertType::Lazy;
|
||||
source_container = makeFData(container);
|
||||
lazy_inserter = converter;
|
||||
lazy_inserter = std::forward<LazyConverter>(converter);
|
||||
const std::size_t size = container.size();
|
||||
|
||||
if ( size > 0 )
|
||||
|
@ -566,9 +566,9 @@ void FListBox::insert (const Container& container, const LazyConverter& converte
|
|||
//----------------------------------------------------------------------
|
||||
template <typename Container
|
||||
, typename LazyConverter>
|
||||
void FListBox::insert (Container* container, const LazyConverter& converter)
|
||||
void FListBox::insert (Container* container, LazyConverter&& converter)
|
||||
{
|
||||
insert (*container, converter);
|
||||
insert (*container, std::forward<LazyConverter>(converter));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -340,6 +340,12 @@ 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*);
|
||||
|
@ -441,9 +447,9 @@ class FListView : public FWidget
|
|||
void drawScrollbars() const;
|
||||
void drawHeadlines();
|
||||
void drawList();
|
||||
void drawListLine (const FListViewItem*, bool, bool);
|
||||
void drawListLine (const FListViewItem*, bool, bool, bool, bool);
|
||||
void clearList();
|
||||
void setLineAttributes (bool, bool) const;
|
||||
void setLineAttributes (bool, bool, 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);
|
||||
|
@ -498,6 +504,7 @@ class FListView : public FWidget
|
|||
FObjectList selflist{};
|
||||
FObjectList itemlist{};
|
||||
FListViewIterator current_iter{};
|
||||
FListViewIterator mark_iter{};
|
||||
FListViewIterator first_visible_line{};
|
||||
FListViewIterator last_visible_line{};
|
||||
HeaderItems header{};
|
||||
|
@ -523,7 +530,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};
|
||||
|
|
|
@ -72,23 +72,23 @@ class FLogger : public FLog
|
|||
~FLogger() noexcept override;
|
||||
|
||||
// Methods
|
||||
FString getClassName() const override;
|
||||
void info (const std::string&) override;
|
||||
void warn (const std::string&) override;
|
||||
void error (const std::string&) override;
|
||||
void debug (const std::string&) override;
|
||||
void flush() override;
|
||||
void setOutputStream (const std::ostream&) override;
|
||||
void setLineEnding (LineEnding) override;
|
||||
void enableTimestamp() override;
|
||||
void disableTimestamp() override;
|
||||
FString getClassName() const override;
|
||||
void info (const std::string&) override;
|
||||
void warn (const std::string&) override;
|
||||
void error (const std::string&) override;
|
||||
void debug (const std::string&) override;
|
||||
void flush() override;
|
||||
void setOutputStream (const std::ostream&) override;
|
||||
void setLineEnding (LineEnding) override;
|
||||
void enableTimestamp() override;
|
||||
void disableTimestamp() override;
|
||||
|
||||
private:
|
||||
// Methods
|
||||
void newlineReplace (std::string&, const std::string&) const;
|
||||
std::string getTimeString() const;
|
||||
std::string getEOL() const;
|
||||
void printLogLine (const std::string&);
|
||||
void newlineReplace (std::string&, const std::string&) const;
|
||||
std::string getTimeString() const;
|
||||
std::string getEOL() const;
|
||||
void printLogLine (const std::string&);
|
||||
|
||||
// Data member
|
||||
bool timestamp{false};
|
||||
|
|
|
@ -98,12 +98,18 @@ 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;
|
||||
|
@ -201,7 +207,7 @@ class FMouse : public FMouseData
|
|||
template <typename ClassT>
|
||||
static FMouse* createMouseObject ();
|
||||
virtual void setRawData (FKeyboard::keybuffer&) = 0;
|
||||
virtual void processEvent (struct timeval*) = 0;
|
||||
virtual void processEvent (const TimeValue&) = 0;
|
||||
|
||||
protected:
|
||||
// Accessors
|
||||
|
@ -209,17 +215,17 @@ class FMouse : public FMouseData
|
|||
uInt16 getMaxWidth() const;
|
||||
uInt16 getMaxHeight() const;
|
||||
uInt64 getDblclickInterval() const;
|
||||
timeval* getMousePressedTime();
|
||||
TimeValue getMousePressedTime() const;
|
||||
|
||||
// Mutator
|
||||
void setNewPos (int, int);
|
||||
void setPending (bool = true);
|
||||
void setEvent();
|
||||
void setMousePressedTime (const timeval*);
|
||||
void setMousePressedTime (const TimeValue&);
|
||||
void resetMousePressedTime();
|
||||
|
||||
// Inquiry
|
||||
bool isDblclickTimeout (const timeval*) const;
|
||||
bool isDblclickTimeout (const TimeValue&) const;
|
||||
|
||||
private:
|
||||
// Data members
|
||||
|
@ -228,7 +234,7 @@ class FMouse : public FMouseData
|
|||
uInt16 max_width{80};
|
||||
uInt16 max_height{25};
|
||||
uInt64 dblclick_interval{500000}; // 500 ms
|
||||
struct timeval time_mousepressed{};
|
||||
TimeValue time_mousepressed{};
|
||||
FPoint new_mouse_position{};
|
||||
};
|
||||
|
||||
|
@ -263,7 +269,7 @@ class FMouseGPM final : public FMouse
|
|||
|
||||
// Methods
|
||||
void setRawData (FKeyboard::keybuffer&) override;
|
||||
void processEvent (struct timeval*) override;
|
||||
void processEvent (const TimeValue&) override;
|
||||
bool gpmMouse (bool = true);
|
||||
bool enableGpmMouse();
|
||||
bool disableGpmMouse();
|
||||
|
@ -321,7 +327,7 @@ class FMouseX11 final : public FMouse
|
|||
|
||||
// Methods
|
||||
void setRawData (FKeyboard::keybuffer&) override;
|
||||
void processEvent (struct timeval*) override;
|
||||
void processEvent (const TimeValue&) override;
|
||||
|
||||
private:
|
||||
// Enumeration
|
||||
|
@ -351,7 +357,7 @@ class FMouseX11 final : public FMouse
|
|||
// Methods
|
||||
void setKeyState (int);
|
||||
void setMoveState (const FPoint&, int);
|
||||
void setButtonState (const int, const struct timeval*);
|
||||
void setButtonState (const int, const TimeValue&);
|
||||
|
||||
// Data member
|
||||
char x11_mouse[MOUSE_BUF_SIZE]{'\0'};
|
||||
|
@ -374,7 +380,7 @@ class FMouseSGR final : public FMouse
|
|||
|
||||
// Methods
|
||||
void setRawData (FKeyboard::keybuffer&) override;
|
||||
void processEvent (struct timeval*) override;
|
||||
void processEvent (const TimeValue&) override;
|
||||
|
||||
private:
|
||||
// Enumeration
|
||||
|
@ -403,7 +409,7 @@ class FMouseSGR final : public FMouse
|
|||
// Methods
|
||||
void setKeyState (int);
|
||||
void setMoveState (const FPoint&, int);
|
||||
void setPressedButtonState (const int, const struct timeval*);
|
||||
void setPressedButtonState (const int, const TimeValue&);
|
||||
void setReleasedButtonState (const int);
|
||||
|
||||
// Data members
|
||||
|
@ -427,7 +433,7 @@ class FMouseUrxvt final : public FMouse
|
|||
|
||||
// Methods
|
||||
void setRawData (FKeyboard::keybuffer&) override;
|
||||
void processEvent (struct timeval*) override;
|
||||
void processEvent (const TimeValue&) override;
|
||||
|
||||
private:
|
||||
// Enumeration
|
||||
|
@ -457,7 +463,7 @@ class FMouseUrxvt final : public FMouse
|
|||
// Methods
|
||||
void setKeyState (int);
|
||||
void setMoveState (const FPoint&, int);
|
||||
void setButtonState (const int, const struct timeval*);
|
||||
void setButtonState (const int, const TimeValue&);
|
||||
|
||||
// Data members
|
||||
char urxvt_mouse[MOUSE_BUF_SIZE]{'\0'};
|
||||
|
@ -506,6 +512,7 @@ class FMouseControl
|
|||
|
||||
// Accessors
|
||||
virtual FString getClassName() const;
|
||||
static auto getInstance() -> FMouseControl&;
|
||||
const FPoint& getPos();
|
||||
void clearEvent();
|
||||
|
||||
|
@ -543,7 +550,7 @@ class FMouseControl
|
|||
void disable();
|
||||
virtual void setRawData ( FMouse::MouseType
|
||||
, FKeyboard::keybuffer& );
|
||||
virtual void processEvent (struct timeval* time);
|
||||
virtual void processEvent (const TimeValue&);
|
||||
void processQueuedInput();
|
||||
bool getGpmKeyPressed (bool = true);
|
||||
void drawPointer();
|
||||
|
|
|
@ -44,15 +44,24 @@
|
|||
#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;
|
||||
|
@ -122,7 +131,6 @@ class FObject
|
|||
bool isDirectChild (const FObject*) const;
|
||||
bool isWidget() const;
|
||||
bool isInstanceOf (const FString&) const;
|
||||
bool isTimerInUpdating() const;
|
||||
|
||||
// Methods
|
||||
void removeParent();
|
||||
|
@ -134,8 +142,8 @@ class FObject
|
|||
virtual bool event (FEvent*);
|
||||
|
||||
// Timer methods
|
||||
static void getCurrentTime (timeval*);
|
||||
static bool isTimeout (const timeval*, uInt64);
|
||||
static TimeValue getCurrentTime();
|
||||
static bool isTimeout (const TimeValue&, uInt64);
|
||||
int addTimer (int);
|
||||
bool delTimer (int) const;
|
||||
bool delOwnTimers() const;
|
||||
|
@ -144,10 +152,10 @@ class FObject
|
|||
protected:
|
||||
struct FTimerData
|
||||
{
|
||||
int id;
|
||||
timeval interval;
|
||||
timeval timeout;
|
||||
FObject* object;
|
||||
int id;
|
||||
milliseconds interval;
|
||||
TimeValue timeout;
|
||||
FObject* object;
|
||||
};
|
||||
|
||||
// Using-declaration
|
||||
|
@ -178,7 +186,6 @@ class FObject
|
|||
std::size_t max_children{UNLIMITED};
|
||||
bool has_parent{false};
|
||||
bool widget_object{false};
|
||||
static bool timer_modify_lock;
|
||||
};
|
||||
|
||||
|
||||
|
@ -262,10 +269,6 @@ 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(); }
|
||||
|
@ -274,61 +277,6 @@ 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-2020 Markus Gans *
|
||||
* Copyright 2016-2021 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,6 +39,7 @@
|
|||
#include <algorithm> // need for std::swap
|
||||
|
||||
#include "final/fstring.h"
|
||||
#include "final/ftypes.h"
|
||||
#include "final/sgr_optimizer.h"
|
||||
|
||||
namespace finalcut
|
||||
|
@ -107,6 +108,7 @@ class FOptiAttr final
|
|||
|
||||
// Accessors
|
||||
FString getClassName() const;
|
||||
static auto getInstance() -> FOptiAttr&;
|
||||
|
||||
// Mutators
|
||||
void setTermEnvironment (const TermEnv&);
|
||||
|
@ -156,7 +158,7 @@ class FOptiAttr final
|
|||
// Methods
|
||||
void initialize();
|
||||
static FColor vga2ansi (FColor);
|
||||
const char* changeAttribute (FChar&, FChar&);
|
||||
std::string changeAttribute (FChar&, FChar&);
|
||||
|
||||
private:
|
||||
struct Capability
|
||||
|
@ -165,9 +167,6 @@ class FOptiAttr final
|
|||
bool caused_reset;
|
||||
};
|
||||
|
||||
// Using-declaration
|
||||
using AttributeBuffer = SGRoptimizer::AttributeBuffer;
|
||||
|
||||
// Enumerations
|
||||
enum init_reset_tests
|
||||
{
|
||||
|
@ -224,10 +223,7 @@ class FOptiAttr final
|
|||
bool unsetTermCrossedOut (FChar&);
|
||||
bool setTermDoubleUnderline (FChar&);
|
||||
bool unsetTermDoubleUnderline (FChar&);
|
||||
bool setTermAttributes ( FChar&
|
||||
, bool, bool, bool
|
||||
, bool, bool, bool
|
||||
, bool, bool, bool );
|
||||
bool setTermAttributes (FChar&, const TCapAttributes&);
|
||||
bool unsetTermAttributes (FChar&);
|
||||
bool setTermAltCharset (FChar&);
|
||||
bool unsetTermAltCharset (FChar&);
|
||||
|
@ -303,8 +299,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,6 +44,7 @@
|
|||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "final/fstring.h"
|
||||
|
||||
|
@ -92,6 +93,7 @@ class FOptiMove final
|
|||
|
||||
// Accessors
|
||||
FString getClassName() const;
|
||||
static auto getInstance() -> FOptiMove&;
|
||||
uInt getCursorHomeLength() const;
|
||||
uInt getCarriageReturnLength() const;
|
||||
uInt getCursorToLLLength() const;
|
||||
|
@ -143,7 +145,7 @@ class FOptiMove final
|
|||
|
||||
// Methods
|
||||
void check_boundaries (int&, int&, int&, int&) const;
|
||||
const char* moveCursor (int, int, int, int);
|
||||
std::string moveCursor (int, int, int, int);
|
||||
|
||||
private:
|
||||
struct Capability
|
||||
|
@ -154,7 +156,7 @@ class FOptiMove final
|
|||
};
|
||||
|
||||
// Constant
|
||||
static constexpr std::size_t BUF_SIZE{512};
|
||||
static constexpr std::string::size_type BUF_SIZE{512u};
|
||||
|
||||
// Constants
|
||||
static constexpr int LONG_DURATION{INT_MAX};
|
||||
|
@ -166,14 +168,14 @@ class FOptiMove final
|
|||
void calculateCharDuration();
|
||||
int capDuration (const char[], int) const;
|
||||
int capDurationToLength (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;
|
||||
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;
|
||||
|
||||
bool isWideMove (int, int, int, int) const;
|
||||
bool isMethod0Faster (int&, int, int);
|
||||
|
@ -211,7 +213,7 @@ class FOptiMove final
|
|||
int char_duration{1};
|
||||
int baudrate{9600};
|
||||
int tabstop{0};
|
||||
char move_buf[BUF_SIZE]{'\0'};
|
||||
std::string move_buf{};
|
||||
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-2020 Markus Gans *
|
||||
* Copyright 2019-2021 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 FStartOptions& getFStartOptions();
|
||||
static auto getInstance() -> FStartOptions&;
|
||||
|
||||
// Mutator
|
||||
void setDefault();
|
||||
|
|
|
@ -80,10 +80,11 @@ class FString
|
|||
{
|
||||
public:
|
||||
// Using-declarations
|
||||
using iterator = wchar_t*;
|
||||
using const_iterator = const wchar_t*;
|
||||
using reference = wchar_t&;
|
||||
using const_reference = const wchar_t&;
|
||||
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;
|
||||
|
||||
// Constructors
|
||||
FString () = default;
|
||||
|
@ -167,7 +168,7 @@ class FString
|
|||
virtual FString getClassName() const;
|
||||
|
||||
// inquiries
|
||||
bool isNull() const noexcept;
|
||||
bool isNull() const noexcept; // deprecated
|
||||
bool isEmpty() const noexcept;
|
||||
|
||||
// Methods
|
||||
|
@ -245,24 +246,16 @@ class FString
|
|||
|
||||
private:
|
||||
// Constants
|
||||
static constexpr uInt FWDBUFFER = 15;
|
||||
static constexpr uInt INPBUFFER = 200;
|
||||
|
||||
// Methods
|
||||
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;
|
||||
void _assign (std::wstring&);
|
||||
std::string _toCharString (const std::wstring&) const;
|
||||
std::wstring _toWideString (const std::string&) const;
|
||||
|
||||
// Data members
|
||||
wchar_t* string{nullptr};
|
||||
std::size_t length{0};
|
||||
std::size_t bufsize{0};
|
||||
mutable char* c_string{nullptr};
|
||||
std::wstring string{};
|
||||
mutable std::string char_string{};
|
||||
static wchar_t null_char;
|
||||
static const wchar_t const_null_char;
|
||||
|
||||
|
@ -288,7 +281,7 @@ template <typename NumT
|
|||
inline FString& FString::operator << (const NumT val)
|
||||
{
|
||||
const FString numstr(FString().setNumber(val));
|
||||
_insert (length, numstr.length, numstr.string);
|
||||
string.append(numstr.string);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -296,10 +289,10 @@ inline FString& FString::operator << (const NumT val)
|
|||
template <typename IndexT>
|
||||
inline FString::reference FString::operator [] (const IndexT pos)
|
||||
{
|
||||
if ( isNegative(pos) || pos > IndexT(length) )
|
||||
if ( isNegative(pos) || pos > IndexT(string.length()) )
|
||||
throw std::out_of_range(""); // Invalid index position
|
||||
|
||||
if ( std::size_t(pos) == length )
|
||||
if ( std::size_t(pos) == string.length() )
|
||||
return null_char;
|
||||
|
||||
return string[std::size_t(pos)];
|
||||
|
@ -309,10 +302,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(length) )
|
||||
if ( isNegative(pos) || pos > IndexT(string.length()) )
|
||||
throw std::out_of_range(""); // Invalid index position
|
||||
|
||||
if ( std::size_t(pos) == length )
|
||||
if ( std::size_t(pos) == string.length() )
|
||||
return const_null_char;
|
||||
|
||||
return string[std::size_t(pos)];
|
||||
|
@ -371,63 +364,63 @@ inline FString FString::getClassName() const
|
|||
{ return "FString"; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FString::isNull() const noexcept
|
||||
{ return ( bufsize == 0 || (bufsize > 0 && ! string) ); }
|
||||
inline bool FString::isNull() const noexcept // deprecated
|
||||
{ return false; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FString::isEmpty() const noexcept
|
||||
{ return ( length == 0 || (length > 0 && string[0] == L'\0') ); }
|
||||
{ return string.empty(); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline std::size_t FString::getLength() const noexcept
|
||||
{ return length; }
|
||||
{ return string.length(); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline std::size_t FString::capacity() const noexcept
|
||||
{ return ( length > 0 ) ? bufsize - 1 : 0; }
|
||||
{ return string.capacity(); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString::iterator FString::begin() noexcept
|
||||
{ return string; }
|
||||
{ return string.begin(); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString::iterator FString::end() noexcept
|
||||
{ return string + length; }
|
||||
{ return string.end(); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString::const_iterator FString::begin() const noexcept
|
||||
{ return string; }
|
||||
{ return string.cbegin(); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString::const_iterator FString::end() const noexcept
|
||||
{ return string + length; }
|
||||
{ return string.cend(); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString::reference FString::front()
|
||||
{
|
||||
assert ( ! isEmpty() );
|
||||
return (*this)[0];
|
||||
return string.front();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString::reference FString::back()
|
||||
{
|
||||
assert( ! isEmpty() );
|
||||
return (*this)[length - 1];
|
||||
return string.back();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString::const_reference FString::front() const
|
||||
{
|
||||
assert ( ! isEmpty() );
|
||||
return (*this)[0];
|
||||
return string.front();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString::const_reference FString::back() const
|
||||
{
|
||||
assert( ! isEmpty() );
|
||||
return (*this)[length - 1];
|
||||
return string.back();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -444,7 +437,7 @@ inline FString& FString::sprintf (const FString& format, Args&&... args)
|
|||
|
||||
std::swprintf ( buf.data(), buf.size(), format.wc_str()
|
||||
, std::forward<Args>(args)... );
|
||||
_assign(buf.data());
|
||||
setString(buf.data());
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,9 @@ 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,31 +127,12 @@ 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
|
||||
|
@ -187,31 +168,6 @@ 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&);
|
||||
|
@ -268,7 +224,7 @@ class FTerm final
|
|||
static int openConsole();
|
||||
static int closeConsole();
|
||||
static std::string moveCursorString (int, int, int, int);
|
||||
static const char* cursorsVisibilityString (bool = true);
|
||||
static std::string cursorsVisibilityString (bool = true);
|
||||
static void detectTermSize();
|
||||
static void setTermSize (const FSize&);
|
||||
static void setTermTitle (const FString&);
|
||||
|
@ -301,7 +257,7 @@ class FTerm final
|
|||
|
||||
void initTerminal();
|
||||
static void initScreenSettings();
|
||||
static const char* changeAttribute (FChar&, FChar&);
|
||||
static std::string changeAttribute (FChar&, FChar&);
|
||||
static void changeTermSizeFinished();
|
||||
|
||||
private:
|
||||
|
@ -336,8 +292,8 @@ class FTerm final
|
|||
static void restoreColorPalette();
|
||||
static void setInsertCursorStyle();
|
||||
static void setOverwriteCursorStyle();
|
||||
static const char* enableCursorString();
|
||||
static const char* disableCursorString();
|
||||
static std::string enableCursorString();
|
||||
static std::string disableCursorString();
|
||||
static void enableMouse();
|
||||
static void disableMouse();
|
||||
static void enableApplicationEscKey();
|
||||
|
@ -367,7 +323,7 @@ class FTerm final
|
|||
// non-member function forward declarations
|
||||
// implemented in fterm_functions.cpp
|
||||
//----------------------------------------------------------------------
|
||||
uInt env2uint (const char*);
|
||||
uInt env2uint (const std::string&);
|
||||
bool isReverseNewFontchar (wchar_t);
|
||||
bool hasFullWidthSupports();
|
||||
wchar_t cp437_to_unicode (uChar);
|
||||
|
@ -404,7 +360,7 @@ inline FString FTerm::getClassName()
|
|||
//----------------------------------------------------------------------
|
||||
inline void FTerm::setFSystem (std::unique_ptr<FSystem>& fsystem)
|
||||
{
|
||||
getFSystem().swap(fsystem);
|
||||
FSystem::getInstance().swap(fsystem);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -419,8 +375,8 @@ inline bool FTerm::unsetUTF8()
|
|||
template <typename ClassT>
|
||||
inline void FTerm::setColorPaletteTheme (const FSetPalette& f)
|
||||
{
|
||||
getColorPaletteTheme() = std::make_shared<ClassT>(f);
|
||||
getColorPaletteTheme()->setColorPalette();
|
||||
FColorPalette::getInstance() = std::make_shared<ClassT>(f); // Set instance
|
||||
FColorPalette::getInstance()->setColorPalette(); // Set palette
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -111,7 +111,7 @@ class FTermBuffer
|
|||
private:
|
||||
FCharVector data{};
|
||||
void add ( FString::const_iterator&
|
||||
, FString::const_iterator&
|
||||
, const FString::const_iterator&
|
||||
, int& );
|
||||
|
||||
// Non-member operators
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "final/ftypes.h"
|
||||
|
||||
// FTermcap string macro
|
||||
#define TCAP(...) FTermcap::strings[int(Termcap::__VA_ARGS__)].string
|
||||
|
||||
|
@ -129,7 +131,7 @@ class FTermcap final
|
|||
static void termcapStrings();
|
||||
static void termcapKeys();
|
||||
static std::string encodeParams ( const std::string&
|
||||
, const std::vector<int>& );
|
||||
, const std::array<int, 9>& );
|
||||
template<typename PutChar>
|
||||
static void delay_output (int, const PutChar&);
|
||||
|
||||
|
@ -149,7 +151,9 @@ inline FString FTermcap::getClassName() const
|
|||
template <typename... Args>
|
||||
std::string FTermcap::encodeParameter (const std::string& cap, Args&&... args)
|
||||
{
|
||||
return encodeParams(cap, {static_cast<int>(args)...});
|
||||
std::array<int, 9> attr{{ 0, 0, 0, 0, 0, 0, 0, 0, 0 }};
|
||||
attr = {{static_cast<int>(args)...}};
|
||||
return encodeParams(cap, attr);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -72,6 +72,7 @@ class FTermData final
|
|||
|
||||
// Accessors
|
||||
FString getClassName() const;
|
||||
static auto getInstance() -> FTermData&;
|
||||
EncodingMap& getEncodingList();
|
||||
charSubstitution& getCharSubstitutionMap();
|
||||
Encoding getTermEncoding() const;
|
||||
|
@ -170,6 +171,13 @@ 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-2020 Markus Gans *
|
||||
* Copyright 2018-2021 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,14 +35,13 @@
|
|||
#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
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -63,16 +62,21 @@ class FTermDebugData final
|
|||
FTermDebugData& operator = (const FTermDebugData&) = delete;
|
||||
|
||||
// Accessors
|
||||
static FString getClassName();
|
||||
static auto getInstance() -> FTermDebugData&;
|
||||
const FString& getAnswerbackString();
|
||||
const FString& getSecDAString();
|
||||
const char* getTermType_256color();
|
||||
const char* getTermType_Answerback();
|
||||
const char* getTermType_SecDA();
|
||||
const FString& getTermType_256color();
|
||||
const FString& getTermType_Answerback();
|
||||
const FString& getTermType_SecDA();
|
||||
#if defined(__linux__)
|
||||
int getFramebufferBpp();
|
||||
#endif
|
||||
};
|
||||
|
||||
inline FString FTermDebugData::getClassName()
|
||||
{ return "FTermDebugData"; }
|
||||
|
||||
} // namespace finalcut
|
||||
|
||||
#endif // DEBUG
|
||||
|
|
|
@ -79,7 +79,12 @@ class FTermDetection final
|
|||
uInt8 : 3; // padding bits
|
||||
};
|
||||
|
||||
struct kittyVersion; // forward declaration
|
||||
struct kittyVersion
|
||||
{
|
||||
int primary{0};
|
||||
int secondary{0};
|
||||
};
|
||||
|
||||
|
||||
// Constructors
|
||||
FTermDetection();
|
||||
|
@ -94,183 +99,167 @@ class FTermDetection final
|
|||
FTermDetection& operator = (const FTermDetection&) = delete;
|
||||
|
||||
// Accessor
|
||||
static FString getClassName();
|
||||
static const char* getTermType();
|
||||
static int getGnomeTerminalID();
|
||||
static kittyVersion getKittyVersion();
|
||||
FString getClassName() const;
|
||||
static auto getInstance() -> FTermDetection&;
|
||||
const FString& getTermType() const;
|
||||
int getGnomeTerminalID() const;
|
||||
kittyVersion getKittyVersion() const;
|
||||
FTerminalType& getTermTypeStruct();
|
||||
|
||||
#if DEBUG
|
||||
static const FString& getAnswerbackString();
|
||||
static const FString& getSecDAString();
|
||||
static const char* getTermType_256color();
|
||||
static const char* getTermType_Answerback();
|
||||
static const char* getTermType_SecDA();
|
||||
const FString& getAnswerbackString() const;
|
||||
const FString& getSecDAString() const;
|
||||
const FString& getTermType_256color() const;
|
||||
const FString& getTermType_Answerback() const;
|
||||
const FString& getTermType_SecDA() const;
|
||||
#endif
|
||||
|
||||
// Inquiries
|
||||
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();
|
||||
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;
|
||||
|
||||
// Mutators
|
||||
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[]);
|
||||
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&);
|
||||
|
||||
// Methods
|
||||
static void detect();
|
||||
void detect();
|
||||
|
||||
private:
|
||||
struct colorEnv; // forward declaration
|
||||
struct secondaryDA; // forward declaration
|
||||
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};
|
||||
};
|
||||
|
||||
// Methods
|
||||
static void deallocation();
|
||||
static void getSystemTermType();
|
||||
static bool getTTYtype();
|
||||
void getSystemTermType();
|
||||
bool getTTYtype();
|
||||
#if F_HAVE_GETTTYNAM
|
||||
static bool getTTYSFileEntry();
|
||||
bool getTTYSFileEntry();
|
||||
#endif
|
||||
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[]);
|
||||
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&);
|
||||
|
||||
// Data members
|
||||
#if DEBUG
|
||||
static char termtype_256color[256];
|
||||
static char termtype_Answerback[256];
|
||||
static char termtype_SecDA[256];
|
||||
FString termtype_256color{};
|
||||
FString termtype_Answerback{};
|
||||
FString termtype_SecDA{};
|
||||
#endif
|
||||
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};
|
||||
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{};
|
||||
};
|
||||
|
||||
|
||||
// FTermDetection inline functions
|
||||
//----------------------------------------------------------------------
|
||||
inline FString FTermDetection::getClassName()
|
||||
inline FString FTermDetection::getClassName() const
|
||||
{ return "FTermDetection"; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline const char* FTermDetection::getTermType()
|
||||
inline const FString& FTermDetection::getTermType() const
|
||||
{ return termtype; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline int FTermDetection::getGnomeTerminalID()
|
||||
inline int FTermDetection::getGnomeTerminalID() const
|
||||
{ return gnome_terminal_id; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FTermDetection::kittyVersion FTermDetection::getKittyVersion()
|
||||
inline FTermDetection::kittyVersion FTermDetection::getKittyVersion() const
|
||||
{ return kitty_version; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -279,112 +268,112 @@ inline FTermDetection::FTerminalType& FTermDetection::getTermTypeStruct()
|
|||
|
||||
#if DEBUG
|
||||
//----------------------------------------------------------------------
|
||||
inline const char* FTermDetection::getTermType_256color()
|
||||
inline const FString& FTermDetection::getTermType_256color() const
|
||||
{ return termtype_256color; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline const char* FTermDetection::getTermType_Answerback()
|
||||
inline const FString& FTermDetection::getTermType_Answerback() const
|
||||
{ return termtype_Answerback; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline const char* FTermDetection::getTermType_SecDA()
|
||||
inline const FString& FTermDetection::getTermType_SecDA() const
|
||||
{ return termtype_SecDA; }
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::canDisplay256Colors()
|
||||
inline bool FTermDetection::canDisplay256Colors() const
|
||||
{ return color256; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::hasSetCursorStyleSupport()
|
||||
inline bool FTermDetection::hasSetCursorStyleSupport() const
|
||||
{ return decscusr_support; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isXTerminal()
|
||||
inline bool FTermDetection::isXTerminal() const
|
||||
{ return terminal_type.xterm; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isAnsiTerminal()
|
||||
inline bool FTermDetection::isAnsiTerminal() const
|
||||
{ return terminal_type.ansi; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isRxvtTerminal()
|
||||
inline bool FTermDetection::isRxvtTerminal() const
|
||||
{ return terminal_type.rxvt; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isUrxvtTerminal()
|
||||
inline bool FTermDetection::isUrxvtTerminal() const
|
||||
{ return terminal_type.urxvt; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isMltermTerminal()
|
||||
inline bool FTermDetection::isMltermTerminal() const
|
||||
{ return terminal_type.mlterm; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isKittyTerminal()
|
||||
inline bool FTermDetection::isKittyTerminal() const
|
||||
{ return terminal_type.kitty; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isPuttyTerminal()
|
||||
inline bool FTermDetection::isPuttyTerminal() const
|
||||
{ return terminal_type.putty; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isWindowsTerminal()
|
||||
inline bool FTermDetection::isWindowsTerminal() const
|
||||
{ return terminal_type.win_terminal; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isKdeTerminal()
|
||||
inline bool FTermDetection::isKdeTerminal() const
|
||||
{ return terminal_type.kde_konsole; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isGnomeTerminal()
|
||||
inline bool FTermDetection::isGnomeTerminal() const
|
||||
{ return terminal_type.gnome_terminal; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isKtermTerminal()
|
||||
inline bool FTermDetection::isKtermTerminal() const
|
||||
{ return terminal_type.kterm; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isTeraTerm()
|
||||
inline bool FTermDetection::isTeraTerm() const
|
||||
{ return terminal_type.tera_term; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isCygwinTerminal()
|
||||
inline bool FTermDetection::isCygwinTerminal() const
|
||||
{ return terminal_type.cygwin; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isMinttyTerm()
|
||||
inline bool FTermDetection::isMinttyTerm() const
|
||||
{ return terminal_type.mintty; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isLinuxTerm()
|
||||
inline bool FTermDetection::isLinuxTerm() const
|
||||
{ return terminal_type.linux_con; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isFreeBSDTerm()
|
||||
inline bool FTermDetection::isFreeBSDTerm() const
|
||||
{ return terminal_type.freebsd_con; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isNetBSDTerm()
|
||||
inline bool FTermDetection::isNetBSDTerm() const
|
||||
{ return terminal_type.netbsd_con; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isOpenBSDTerm()
|
||||
inline bool FTermDetection::isOpenBSDTerm() const
|
||||
{ return terminal_type.openbsd_con; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isSunTerminal()
|
||||
inline bool FTermDetection::isSunTerminal() const
|
||||
{ return terminal_type.sun_con; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isScreenTerm()
|
||||
inline bool FTermDetection::isScreenTerm() const
|
||||
{ return terminal_type.screen; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::isTmuxTerm()
|
||||
inline bool FTermDetection::isTmuxTerm() const
|
||||
{ return terminal_type.tmux; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::hasTerminalDetection()
|
||||
inline bool FTermDetection::hasTerminalDetection() const
|
||||
{ return terminal_detection; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -83,6 +83,7 @@ class FTermFreeBSD final
|
|||
|
||||
// Accessors
|
||||
FString getClassName() const;
|
||||
static auto getInstance() -> FTermFreeBSD&;
|
||||
static CursorStyle getCursorStyle();
|
||||
|
||||
// Inquiry
|
||||
|
|
|
@ -92,6 +92,7 @@ class FTermLinux final
|
|||
|
||||
// Accessors
|
||||
FString getClassName() const;
|
||||
static auto getInstance() -> FTermLinux&;
|
||||
CursorStyle getCursorStyle() const;
|
||||
char* getCursorStyleString();
|
||||
int getFramebufferBpp() const;
|
||||
|
|
|
@ -73,6 +73,7 @@ class FTermOpenBSD final
|
|||
public:
|
||||
// Accessor
|
||||
FString getClassName() const;
|
||||
static auto getInstance() -> FTermOpenBSD&;
|
||||
|
||||
// Inquiries
|
||||
static bool isBSDConsole();
|
||||
|
|
|
@ -66,6 +66,7 @@ class FTermXTerminal final
|
|||
|
||||
// Accessors
|
||||
FString getClassName() const;
|
||||
static auto getInstance() -> FTermXTerminal&;
|
||||
XTermCursorStyle getCursorStyle() const;
|
||||
FString getFont() const;
|
||||
FString getTitle() const;
|
||||
|
|
|
@ -251,10 +251,6 @@ 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,6 +34,7 @@
|
|||
#include <cstring>
|
||||
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
|
@ -51,25 +52,25 @@
|
|||
<< " in " \
|
||||
<< __func__ << std::endl // ;
|
||||
|
||||
using uChar = unsigned char;
|
||||
using uShort = unsigned short;
|
||||
using uInt = unsigned int;
|
||||
using uLong = unsigned long;
|
||||
using uInt8 = std::uint8_t;
|
||||
using uInt16 = std::uint16_t;
|
||||
using uInt32 = std::uint32_t;
|
||||
using uInt64 = std::uint64_t;
|
||||
using uChar = unsigned char;
|
||||
using uShort = unsigned short;
|
||||
using uInt = unsigned int;
|
||||
using uLong = unsigned long;
|
||||
using uInt8 = std::uint8_t;
|
||||
using uInt16 = std::uint16_t;
|
||||
using uInt32 = std::uint32_t;
|
||||
using uInt64 = std::uint64_t;
|
||||
|
||||
using sInt = signed int;
|
||||
using sLong = signed long;
|
||||
using sInt8 = std::int8_t;
|
||||
using sInt16 = std::int16_t;
|
||||
using sInt32 = std::int32_t;
|
||||
using sInt64 = std::int64_t;
|
||||
using sInt = signed int;
|
||||
using sLong = signed long;
|
||||
using sInt8 = std::int8_t;
|
||||
using sInt16 = std::int16_t;
|
||||
using sInt32 = std::int32_t;
|
||||
using sInt64 = std::int64_t;
|
||||
|
||||
using lDouble = long double;
|
||||
|
||||
using FCall = std::function<void()>;
|
||||
using lDouble = long double;
|
||||
using TimeValue = std::chrono::time_point<std::chrono::system_clock>;
|
||||
using FCall = std::function<void()>;
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
@ -119,8 +120,34 @@ 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,10 +418,8 @@ 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);
|
||||
|
@ -453,8 +451,7 @@ class FVTerm
|
|||
static FChar next_attribute;
|
||||
static FChar s_ch; // shadow character
|
||||
static FChar i_ch; // inherit background character
|
||||
static timeval time_last_flush;
|
||||
static timeval last_term_size_check;
|
||||
static TimeValue time_last_flush;
|
||||
static bool draw_completed;
|
||||
static bool combined_char_support;
|
||||
static bool no_terminal_updates;
|
||||
|
@ -462,7 +459,6 @@ 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,6 +507,7 @@ 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&);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue