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,
|
# You may wish to alter this file to override the set of languages analyzed,
|
||||||
# or to provide custom queries or build logic.
|
# or to provide custom queries or build logic.
|
||||||
name: "CodeQL"
|
name: "CodeQL analysis"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
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>
|
2021-05-07 Markus Gans <guru.mail@muenster.de>
|
||||||
* Some pointers were replaced by references
|
* 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) |
|
| *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) |
|
| *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) |
|
| *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 )|
|
| *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) |
|
| *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) |
|
| *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
|
# Build commands
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"--release"|"release")
|
"--release"|"release")
|
||||||
if ! ./configure --prefix="$PREFIX" CXXFLAGS="-O3" # "-fno-rtti"
|
if ! ./configure --prefix="$PREFIX" CXXFLAGS="-O3" # "-flto -fno-rtti"
|
||||||
then
|
then
|
||||||
echo "${RED}Configure failed!${NORMAL}" 1>&2
|
echo "${RED}Configure failed!${NORMAL}" 1>&2
|
||||||
exit 255
|
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()
|
void SegmentView::draw()
|
||||||
{
|
{
|
||||||
std::vector<finalcut::FTermBuffer> tbuffer{3};
|
std::vector<finalcut::FTermBuffer> tbuffer(3);
|
||||||
finalcut::FTermBuffer left_space{};
|
finalcut::FTermBuffer left_space{};
|
||||||
|
|
||||||
FDialog::draw();
|
FDialog::draw();
|
||||||
|
|
|
@ -385,7 +385,7 @@ void Calc::drawDispay()
|
||||||
{
|
{
|
||||||
finalcut::FString display{input};
|
finalcut::FString display{input};
|
||||||
|
|
||||||
if ( display.isNull() || display.isEmpty() )
|
if ( display.isEmpty() )
|
||||||
display = L'0';
|
display = L'0';
|
||||||
|
|
||||||
if ( display.right(3) == L"-0." )
|
if ( display.right(3) == L"-0." )
|
||||||
|
@ -651,7 +651,6 @@ void Calc::radix_point (const lDouble&)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( isDataEntryKey(last_key)
|
if ( isDataEntryKey(last_key)
|
||||||
&& ! input.isNull()
|
|
||||||
&& ! input.isEmpty()
|
&& ! input.isEmpty()
|
||||||
&& ! input.includes('.') )
|
&& ! input.includes('.') )
|
||||||
input += '.';
|
input += '.';
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include <final/final.h>
|
#include <final/final.h>
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <final/final.h>
|
#include <final/final.h>
|
||||||
|
|
||||||
using finalcut::FPoint;
|
using finalcut::FPoint;
|
||||||
|
@ -61,10 +60,16 @@ class Listview final : public finalcut::FDialog
|
||||||
|
|
||||||
// Callback method
|
// Callback method
|
||||||
void cb_showInMessagebox();
|
void cb_showInMessagebox();
|
||||||
|
void cb_showIndexInMessagebox();
|
||||||
|
void cb_doit();
|
||||||
|
void cb_doit2();
|
||||||
|
|
||||||
// Data members
|
// Data members
|
||||||
finalcut::FListView listview{this};
|
finalcut::FListView listview{this};
|
||||||
finalcut::FButton quit{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 FListView with a list of items
|
||||||
populate();
|
populate();
|
||||||
|
|
||||||
// Quit button
|
// Quit button
|
||||||
quit.setText (L"&Quit");
|
quit.setText (L"&Quit");
|
||||||
|
Mark.setText("&Mark");
|
||||||
|
Index.setText("&Getindex");
|
||||||
|
GIndex.setText("&Index");
|
||||||
// Add some function callbacks
|
// Add some function callbacks
|
||||||
quit.addCallback
|
quit.addCallback
|
||||||
(
|
(
|
||||||
|
@ -118,6 +124,24 @@ Listview::Listview (finalcut::FWidget* parent)
|
||||||
"clicked",
|
"clicked",
|
||||||
this, &Listview::cb_showInMessagebox
|
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
|
// Set FListView geometry
|
||||||
listview.setGeometry(FPoint{2, 1}, FSize{33, 14});
|
listview.setGeometry(FPoint{2, 1}, FSize{33, 14});
|
||||||
// Set quit button geometry
|
// 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();
|
FDialog::initLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,6 +218,16 @@ void Listview::onClose (finalcut::FCloseEvent* ev)
|
||||||
finalcut::FApplication::closeConfirmationDialog (this, 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()
|
void Listview::cb_showInMessagebox()
|
||||||
{
|
{
|
||||||
|
@ -206,7 +243,18 @@ void Listview::cb_showInMessagebox()
|
||||||
, this );
|
, this );
|
||||||
info.show();
|
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
|
// main part
|
||||||
|
|
|
@ -203,7 +203,7 @@ DirectLogger::~DirectLogger() noexcept = default; // destructor
|
||||||
int main (int argc, char* argv[])
|
int main (int argc, char* argv[])
|
||||||
{
|
{
|
||||||
// Disable mouse, color palette changes and terminal data requests
|
// 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.mouse_support = false;
|
||||||
start_options.color_change = false;
|
start_options.color_change = false;
|
||||||
start_options.terminal_data_request = false;
|
start_options.terminal_data_request = false;
|
||||||
|
@ -265,7 +265,7 @@ int main (int argc, char* argv[])
|
||||||
std::cout << "\r" << line << std::flush;
|
std::cout << "\r" << line << std::flush;
|
||||||
// Generation of a logger in a shared_ptr via a pointer
|
// Generation of a logger in a shared_ptr via a pointer
|
||||||
finalcut::FApplication::setLog(std::make_shared<DirectLogger>());
|
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);
|
finalcut::printDurations(opti_move);
|
||||||
|
|
||||||
// Waiting for keypress
|
// Waiting for keypress
|
||||||
|
|
|
@ -190,7 +190,7 @@ void RotoZoomer::generateReport()
|
||||||
finalcut::FStringStream rep;
|
finalcut::FStringStream rep;
|
||||||
dimension_str << getDesktopWidth()
|
dimension_str << getDesktopWidth()
|
||||||
<< "x" << getDesktopHeight();
|
<< "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";
|
time_str << double(elapsed_ms) / 1000 << "s";
|
||||||
fps_str << double(loops) * 1000.0 / double(elapsed_ms);
|
fps_str << double(loops) * 1000.0 / double(elapsed_ms);
|
||||||
|
|
||||||
|
@ -308,7 +308,7 @@ int main (int argc, char* argv[])
|
||||||
{
|
{
|
||||||
benchmark = true;
|
benchmark = true;
|
||||||
// Disable terminal data requests
|
// Disable terminal data requests
|
||||||
auto& start_options = finalcut::FStartOptions::getFStartOptions();
|
auto& start_options = finalcut::FStartOptions::getInstance();
|
||||||
start_options.terminal_data_request = false;
|
start_options.terminal_data_request = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -287,7 +287,7 @@ void AttribDemo::printAltCharset()
|
||||||
if ( ! finalcut::FTerm::isMonochron() )
|
if ( ! finalcut::FTerm::isMonochron() )
|
||||||
setColor (wc->label_fg, wc->label_bg);
|
setColor (wc->label_fg, wc->label_bg);
|
||||||
|
|
||||||
print() << FPoint{1, 1} << "alternate charset: ";
|
print() << FPoint{1, 1} << "Alternate charset: ";
|
||||||
|
|
||||||
if ( parent->getBGColor() == FColor::Default )
|
if ( parent->getBGColor() == FColor::Default )
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,7 +33,7 @@ using finalcut::Termcap;
|
||||||
void tcapBoolean (const std::string&, bool);
|
void tcapBoolean (const std::string&, bool);
|
||||||
void tcapNumeric (const std::string&, int);
|
void tcapNumeric (const std::string&, int);
|
||||||
void tcapString (const std::string&, const char[]);
|
void tcapString (const std::string&, const char[]);
|
||||||
void debug (const finalcut::FApplication&);
|
void debug();
|
||||||
void booleans();
|
void booleans();
|
||||||
void numeric();
|
void numeric();
|
||||||
void string();
|
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 sequence{};
|
||||||
|
std::string cap_str{cap_string ? cap_string : std::string{}};
|
||||||
std::cout << name << ": ";
|
std::cout << name << ": ";
|
||||||
|
|
||||||
if ( cap_str == nullptr )
|
if ( cap_str.empty() )
|
||||||
{
|
{
|
||||||
std::cout << "\r\n";
|
std::cout << "\r\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto len = uInt(std::strlen(cap_str));
|
for (auto&& ch : cap_str)
|
||||||
|
|
||||||
for (uInt i{0}; i < len; i++)
|
|
||||||
{
|
{
|
||||||
const auto c = uChar(cap_str[i]);
|
const auto c = uChar(ch);
|
||||||
|
|
||||||
if ( c > 127 )
|
if ( c > 127 )
|
||||||
{
|
{
|
||||||
|
@ -211,10 +210,9 @@ void tcapString (const std::string& name, const char cap_str[])
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
void debug (const finalcut::FApplication& TermApp)
|
void showDebug()
|
||||||
{
|
{
|
||||||
const auto& fterm = TermApp.getFTerm();
|
auto& debug_data = finalcut::FTermDebugData::getInstance();
|
||||||
auto& debug_data = fterm.getFTermDebugData();
|
|
||||||
const auto& ab_s = debug_data.getAnswerbackString();
|
const auto& ab_s = debug_data.getAnswerbackString();
|
||||||
const auto& sec_da = debug_data.getSecDAString();
|
const auto& sec_da = debug_data.getSecDAString();
|
||||||
std::cout << "\n.------------------- debug -------------------\r\n";
|
std::cout << "\n.------------------- debug -------------------\r\n";
|
||||||
|
@ -240,14 +238,14 @@ void debug (const finalcut::FApplication& TermApp)
|
||||||
std::cout << "`------------------- debug -------------------\r\n";
|
std::cout << "`------------------- debug -------------------\r\n";
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void debug (const finalcut::FApplication&)
|
void showDebug()
|
||||||
{
|
{
|
||||||
// FINAL CUT was compiled without debug option
|
// FINAL CUT was compiled without debug option
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void booleans()
|
void showBooleans()
|
||||||
{
|
{
|
||||||
std::cout << "\r\n[Booleans]\r\n";
|
std::cout << "\r\n[Booleans]\r\n";
|
||||||
tcapBoolean ( "background_color_erase"
|
tcapBoolean ( "background_color_erase"
|
||||||
|
@ -275,7 +273,7 @@ void booleans()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void numeric()
|
void showNumeric()
|
||||||
{
|
{
|
||||||
std::cout << "\r\n[Numeric]\r\n";
|
std::cout << "\r\n[Numeric]\r\n";
|
||||||
tcapNumeric ("max_color"
|
tcapNumeric ("max_color"
|
||||||
|
@ -289,7 +287,7 @@ void numeric()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void string()
|
void showString()
|
||||||
{
|
{
|
||||||
std::cout << "\r\n[String]\r\n";
|
std::cout << "\r\n[String]\r\n";
|
||||||
const auto& tcap_strings = finalcut::FTermcap::strings;
|
const auto& tcap_strings = finalcut::FTermcap::strings;
|
||||||
|
@ -311,7 +309,7 @@ int main (int argc, char* argv[])
|
||||||
finalcut::FTerm::useAlternateScreen(false);
|
finalcut::FTerm::useAlternateScreen(false);
|
||||||
|
|
||||||
// Disable color palette changes and terminal data requests
|
// 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.color_change = false;
|
||||||
start_options.terminal_data_request = 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 << "--------\r\nFTermcap\r\n--------\r\n\n";
|
||||||
std::cout << "Terminal: " << finalcut::FTerm::getTermType() << "\r\n";
|
std::cout << "Terminal: " << finalcut::FTerm::getTermType() << "\r\n";
|
||||||
|
|
||||||
debug (term_app);
|
showDebug();
|
||||||
|
showBooleans();
|
||||||
booleans();
|
showNumeric();
|
||||||
numeric();
|
showString();
|
||||||
string();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -427,7 +427,7 @@ void MyDialog::initMenu()
|
||||||
Drive.setStatusbarMessage ("Show drive symbols");
|
Drive.setStatusbarMessage ("Show drive symbols");
|
||||||
Line3.setSeparator();
|
Line3.setSeparator();
|
||||||
|
|
||||||
if ( finalcut::FStartOptions::getFStartOptions().dark_theme )
|
if ( finalcut::FStartOptions::getInstance().dark_theme )
|
||||||
Theme.setChecked();
|
Theme.setChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1013,7 +1013,7 @@ void MyDialog::cb_view (const finalcut::FMenuItem* item)
|
||||||
else
|
else
|
||||||
file = finalcut::FFileDialog::fileOpenChooser (this);
|
file = finalcut::FFileDialog::fileOpenChooser (this);
|
||||||
|
|
||||||
if ( file.isNull() )
|
if ( file.isEmpty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto& view = new TextWindow(this);
|
const auto& view = new TextWindow(this);
|
||||||
|
|
|
@ -110,15 +110,15 @@ Watch::Watch (FWidget* parent)
|
||||||
void Watch::printTime()
|
void Watch::printTime()
|
||||||
{
|
{
|
||||||
finalcut::FString str{};
|
finalcut::FString str{};
|
||||||
std::tm now{};
|
struct tm local_tm;
|
||||||
|
using namespace std::chrono;
|
||||||
const std::time_t t = std::time(nullptr); // get current time
|
auto now = system_clock::to_time_t(system_clock::now());
|
||||||
localtime_r(&t, &now);
|
auto lt = *localtime_r(&now, &local_tm);
|
||||||
|
|
||||||
if ( sec )
|
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
|
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 = str;
|
||||||
time_str.redraw();
|
time_str.redraw();
|
||||||
|
|
|
@ -103,7 +103,7 @@ Special X11 bitmap font used by FINAL CUT to display graphic objects.
|
||||||
|
|
||||||
%build
|
%build
|
||||||
autoreconf -vif
|
autoreconf -vif
|
||||||
export CPPFLAGS="%{optflags} -Wall -Wextra -Wpedantic"
|
export CPPFLAGS="%{optflags} -Wall -Wextra -Wpedantic -flto"
|
||||||
%ifnarch %ix86 x86_64
|
%ifnarch %ix86 x86_64
|
||||||
export CPPFLAGS="$CPPFLAGS -Wno-error=unused-parameter"
|
export CPPFLAGS="$CPPFLAGS -Wno-error=unused-parameter"
|
||||||
%endif
|
%endif
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
sonar.organization=gansm
|
||||||
sonar.projectKey=gansm_finalcut
|
sonar.projectKey=gansm_finalcut
|
||||||
sonar.projectName=finalcut
|
sonar.projectName=finalcut
|
||||||
sonar.projectVersion=0.7.2
|
sonar.projectVersion=0.7.2
|
||||||
|
@ -16,6 +17,9 @@ sonar.links.issue=https://github.com/gansm/finalcut/issues
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
sonar.sources=.
|
sonar.sources=.
|
||||||
sonar.cfamily.build-wrapper-output=bw-output
|
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.exclusions=src/include/final/fconfig.h
|
||||||
sonar.coverage.exclusions=**/**
|
sonar.coverage.exclusions=**/**
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ int FApplication::loop_level {0}; // event loop level
|
||||||
int FApplication::quit_code {EXIT_SUCCESS};
|
int FApplication::quit_code {EXIT_SUCCESS};
|
||||||
bool FApplication::quit_now {false};
|
bool FApplication::quit_now {false};
|
||||||
uInt64 FApplication::next_event_wait {5000}; // 5 ms (200 Hz)
|
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 )
|
if ( internal::var::app_object )
|
||||||
{
|
{
|
||||||
auto& fterm_data = FTerm::getFTermData();
|
auto& fterm_data = FTermData::getInstance();
|
||||||
fterm_data.setExitMessage("FApplication: There should be "
|
fterm_data.setExitMessage("FApplication: There should be "
|
||||||
"only one application object");
|
"only one application object");
|
||||||
FApplication::exit(EXIT_FAILURE);
|
FApplication::exit(EXIT_FAILURE);
|
||||||
|
@ -339,7 +339,7 @@ void FApplication::setLogFile (const FString& filename)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto& fterm_data = FTerm::getFTermData();
|
auto& fterm_data = FTermData::getInstance();
|
||||||
fterm_data.setExitMessage ( "Could not open log file \""
|
fterm_data.setExitMessage ( "Could not open log file \""
|
||||||
+ filename + "\"" );
|
+ filename + "\"" );
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@ -392,11 +392,10 @@ void FApplication::init()
|
||||||
setMaxChildren(1);
|
setMaxChildren(1);
|
||||||
|
|
||||||
// Initialize the last event time
|
// Initialize the last event time
|
||||||
time_last_event.tv_sec = 0;
|
time_last_event = TimeValue{};
|
||||||
time_last_event.tv_usec = 0;
|
|
||||||
|
|
||||||
// Initialize keyboard
|
// Initialize keyboard
|
||||||
auto& keyboard = FTerm::getFKeyboard();
|
auto& keyboard = FKeyboard::getInstance();
|
||||||
auto cmd1 = [this] () { this->keyPressed(); };
|
auto cmd1 = [this] () { this->keyPressed(); };
|
||||||
auto cmd2 = [this] () { this->keyReleased(); };
|
auto cmd2 = [this] () { this->keyReleased(); };
|
||||||
auto cmd3 = [this] () { this->escapeKeyPressed(); };
|
auto cmd3 = [this] () { this->escapeKeyPressed(); };
|
||||||
|
@ -413,7 +412,7 @@ void FApplication::init()
|
||||||
keyboard.setKeypressTimeout (key_timeout);
|
keyboard.setKeypressTimeout (key_timeout);
|
||||||
|
|
||||||
// Initialize mouse control
|
// Initialize mouse control
|
||||||
auto& mouse = FTerm::getFMouseControl();
|
auto& mouse = FMouseControl::getInstance();
|
||||||
auto cmd = [this] (const FMouseData& md) { this->mouseEvent(md); };
|
auto cmd = [this] (const FMouseData& md) { this->mouseEvent(md); };
|
||||||
FMouseCommand mouse_cmd (cmd);
|
FMouseCommand mouse_cmd (cmd);
|
||||||
mouse.setEventCommand (mouse_cmd);
|
mouse.setEventCommand (mouse_cmd);
|
||||||
|
@ -444,7 +443,7 @@ void FApplication::setTerminalEncoding (const FString& enc_str)
|
||||||
showParameterUsage();
|
showParameterUsage();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto& fterm_data = FTerm::getFTermData();
|
auto& fterm_data = FTermData::getInstance();
|
||||||
fterm_data.setExitMessage ( "Unknown encoding \"" + enc_str
|
fterm_data.setExitMessage ( "Unknown encoding \"" + enc_str
|
||||||
+ "\"\n(Valid encodings are utf8, "
|
+ "\"\n(Valid encodings are utf8, "
|
||||||
+ "vt100, pc and ascii)" );
|
+ "vt100, pc and ascii)" );
|
||||||
|
@ -563,7 +562,7 @@ void FApplication::cmdOptions (const Args& args)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline FStartOptions& FApplication::getStartOptions()
|
inline FStartOptions& FApplication::getStartOptions()
|
||||||
{
|
{
|
||||||
return FStartOptions::getFStartOptions();
|
return FStartOptions::getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -658,8 +657,8 @@ inline void FApplication::findKeyboardWidget() const
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FApplication::isKeyPressed() const
|
inline bool FApplication::isKeyPressed() const
|
||||||
{
|
{
|
||||||
auto& mouse = FTerm::getFMouseControl();
|
auto& mouse = FMouseControl::getInstance();
|
||||||
auto& keyboard = FTerm::getFKeyboard();
|
auto& keyboard = FKeyboard::getInstance();
|
||||||
|
|
||||||
if ( mouse.isGpmMouseEnabled() )
|
if ( mouse.isGpmMouseEnabled() )
|
||||||
return mouse.getGpmKeyPressed(keyboard.hasUnprocessedInput());
|
return mouse.getGpmKeyPressed(keyboard.hasUnprocessedInput());
|
||||||
|
@ -694,7 +693,7 @@ void FApplication::mouseTracking() const
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FApplication::performKeyboardAction()
|
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)
|
if ( keyboard.getKey() == FKey::Ctrl_l ) // Ctrl-L (redraw the screen)
|
||||||
{
|
{
|
||||||
|
@ -713,8 +712,8 @@ inline void FApplication::performKeyboardAction()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FApplication::performMouseAction() const
|
inline void FApplication::performMouseAction() const
|
||||||
{
|
{
|
||||||
auto& mouse = FTerm::getFMouseControl();
|
auto& mouse = FMouseControl::getInstance();
|
||||||
auto& keyboard = FTerm::getFKeyboard();
|
auto& keyboard = FKeyboard::getInstance();
|
||||||
const auto key = keyboard.getKey();
|
const auto key = keyboard.getKey();
|
||||||
auto& buffer = keyboard.getKeyBuffer();
|
auto& buffer = keyboard.getKeyBuffer();
|
||||||
|
|
||||||
|
@ -761,7 +760,7 @@ inline void FApplication::sendEscapeKeyPressEvent() const
|
||||||
inline bool FApplication::sendKeyDownEvent (FWidget* widget) const
|
inline bool FApplication::sendKeyDownEvent (FWidget* widget) const
|
||||||
{
|
{
|
||||||
// Send key down event
|
// Send key down event
|
||||||
const auto& keyboard = FTerm::getFKeyboard();
|
const auto& keyboard = FKeyboard::getInstance();
|
||||||
FKeyEvent k_down_ev (Event::KeyDown, keyboard.getKey());
|
FKeyEvent k_down_ev (Event::KeyDown, keyboard.getKey());
|
||||||
sendEvent (widget, &k_down_ev);
|
sendEvent (widget, &k_down_ev);
|
||||||
return k_down_ev.isAccepted();
|
return k_down_ev.isAccepted();
|
||||||
|
@ -771,7 +770,7 @@ inline bool FApplication::sendKeyDownEvent (FWidget* widget) const
|
||||||
inline bool FApplication::sendKeyPressEvent (FWidget* widget) const
|
inline bool FApplication::sendKeyPressEvent (FWidget* widget) const
|
||||||
{
|
{
|
||||||
// Send key press event
|
// Send key press event
|
||||||
const auto& keyboard = FTerm::getFKeyboard();
|
const auto& keyboard = FKeyboard::getInstance();
|
||||||
FKeyEvent k_press_ev (Event::KeyPress, keyboard.getKey());
|
FKeyEvent k_press_ev (Event::KeyPress, keyboard.getKey());
|
||||||
sendEvent (widget, &k_press_ev);
|
sendEvent (widget, &k_press_ev);
|
||||||
return k_press_ev.isAccepted();
|
return k_press_ev.isAccepted();
|
||||||
|
@ -781,7 +780,7 @@ inline bool FApplication::sendKeyPressEvent (FWidget* widget) const
|
||||||
inline bool FApplication::sendKeyUpEvent (FWidget* widget) const
|
inline bool FApplication::sendKeyUpEvent (FWidget* widget) const
|
||||||
{
|
{
|
||||||
// Send key up event
|
// Send key up event
|
||||||
const auto& keyboard = FTerm::getFKeyboard();
|
const auto& keyboard = FKeyboard::getInstance();
|
||||||
FKeyEvent k_up_ev (Event::KeyUp, keyboard.getKey());
|
FKeyEvent k_up_ev (Event::KeyUp, keyboard.getKey());
|
||||||
sendEvent (widget, &k_up_ev);
|
sendEvent (widget, &k_up_ev);
|
||||||
return k_up_ev.isAccepted();
|
return k_up_ev.isAccepted();
|
||||||
|
@ -818,8 +817,8 @@ inline void FApplication::sendKeyboardAccelerator()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FApplication::hasDataInQueue() const
|
inline bool FApplication::hasDataInQueue() const
|
||||||
{
|
{
|
||||||
const auto& keyboard = FTerm::getFKeyboard();
|
const auto& keyboard = FKeyboard::getInstance();
|
||||||
const auto& mouse = FTerm::getFMouseControl();
|
const auto& mouse = FMouseControl::getInstance();
|
||||||
|
|
||||||
if ( keyboard.hasDataInQueue()
|
if ( keyboard.hasDataInQueue()
|
||||||
|| mouse.hasDataInQueue()
|
|| mouse.hasDataInQueue()
|
||||||
|
@ -838,7 +837,7 @@ void FApplication::queuingKeyboardInput() const
|
||||||
return;
|
return;
|
||||||
|
|
||||||
findKeyboardWidget();
|
findKeyboardWidget();
|
||||||
auto& keyboard = FTerm::getFKeyboard();
|
auto& keyboard = FKeyboard::getInstance();
|
||||||
keyboard.escapeKeyHandling(); // special case: Esc key
|
keyboard.escapeKeyHandling(); // special case: Esc key
|
||||||
keyboard.clearKeyBufferOnTimeout();
|
keyboard.clearKeyBufferOnTimeout();
|
||||||
|
|
||||||
|
@ -849,7 +848,7 @@ void FApplication::queuingKeyboardInput() const
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FApplication::queuingMouseInput() const
|
void FApplication::queuingMouseInput() const
|
||||||
{
|
{
|
||||||
auto& mouse = FTerm::getFMouseControl();
|
auto& mouse = FMouseControl::getInstance();
|
||||||
|
|
||||||
if ( quit_now
|
if ( quit_now
|
||||||
|| internal::var::exit_loop
|
|| internal::var::exit_loop
|
||||||
|
@ -857,8 +856,8 @@ void FApplication::queuingMouseInput() const
|
||||||
|| FTerm::hasChangedTermSize() )
|
|| FTerm::hasChangedTermSize() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto& keyboard = FTerm::getFKeyboard();
|
auto& keyboard = FKeyboard::getInstance();
|
||||||
struct timeval* time_keypressed = keyboard.getKeyPressedTime();
|
auto time_keypressed = keyboard.getKeyPressedTime();
|
||||||
mouse.processEvent (time_keypressed);
|
mouse.processEvent (time_keypressed);
|
||||||
keyboard.hasUnprocessedInput() = mouse.hasUnprocessedInput();
|
keyboard.hasUnprocessedInput() = mouse.hasUnprocessedInput();
|
||||||
mouse.clearEvent();
|
mouse.clearEvent();
|
||||||
|
@ -872,7 +871,7 @@ void FApplication::processKeyboardEvent() const
|
||||||
|| FTerm::hasChangedTermSize() )
|
|| FTerm::hasChangedTermSize() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto& keyboard = FTerm::getFKeyboard();
|
auto& keyboard = FKeyboard::getInstance();
|
||||||
keyboard.processQueuedInput();
|
keyboard.processQueuedInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -884,13 +883,13 @@ void FApplication::processMouseEvent() const
|
||||||
|| FTerm::hasChangedTermSize() )
|
|| FTerm::hasChangedTermSize() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FTerm::getFMouseControl().processQueuedInput();
|
FMouseControl::getInstance().processQueuedInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
bool FApplication::processDialogSwitchAccelerator() const
|
bool FApplication::processDialogSwitchAccelerator() const
|
||||||
{
|
{
|
||||||
const auto& keyboard = FTerm::getFKeyboard();
|
const auto& keyboard = FKeyboard::getInstance();
|
||||||
|
|
||||||
if ( keyboard.getKey() >= FKey::Meta_1
|
if ( keyboard.getKey() >= FKey::Meta_1
|
||||||
&& keyboard.getKey() <= FKey::Meta_9 )
|
&& keyboard.getKey() <= FKey::Meta_9 )
|
||||||
|
@ -928,7 +927,7 @@ bool FApplication::processAccelerator (const FWidget& widget) const
|
||||||
|
|
||||||
for (auto&& item : widget.getAcceleratorList())
|
for (auto&& item : widget.getAcceleratorList())
|
||||||
{
|
{
|
||||||
if ( item.key == FTerm::getFKeyboard().getKey() )
|
if ( item.key == FKeyboard::getInstance().getKey() )
|
||||||
{
|
{
|
||||||
// unset the move/size mode
|
// unset the move/size mode
|
||||||
auto move_size = getMoveSizeWidget();
|
auto move_size = getMoveSizeWidget();
|
||||||
|
@ -1258,7 +1257,7 @@ void FApplication::processResizeEvent() const
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FTerm::detectTermSize(); // Detect and save the current terminal size
|
FTerm::detectTermSize(); // Detect and save the current terminal size
|
||||||
auto& mouse = FTerm::getFMouseControl();
|
auto& mouse = FMouseControl::getInstance();
|
||||||
mouse.setMaxWidth (uInt16(getDesktopWidth()));
|
mouse.setMaxWidth (uInt16(getDesktopWidth()));
|
||||||
mouse.setMaxHeight (uInt16(getDesktopHeight()));
|
mouse.setMaxHeight (uInt16(getDesktopHeight()));
|
||||||
FResizeEvent r_ev(Event::Resize);
|
FResizeEvent r_ev(Event::Resize);
|
||||||
|
@ -1308,7 +1307,7 @@ bool FApplication::processNextEvent()
|
||||||
|
|
||||||
if ( is_timeout || hasDataInQueue() )
|
if ( is_timeout || hasDataInQueue() )
|
||||||
{
|
{
|
||||||
FObject::getCurrentTime (&time_last_event);
|
time_last_event = FObject::getCurrentTime();
|
||||||
queuingKeyboardInput();
|
queuingKeyboardInput();
|
||||||
queuingMouseInput();
|
queuingMouseInput();
|
||||||
processKeyboardEvent();
|
processKeyboardEvent();
|
||||||
|
@ -1401,7 +1400,7 @@ bool FApplication::isEventProcessable ( FObject* receiver
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
bool FApplication::isNextEventTimeout()
|
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 *
|
* 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 *
|
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU Lesser General Public License as *
|
* 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)
|
void FButton::setText (const FString& txt)
|
||||||
{
|
{
|
||||||
if ( txt.isNull() )
|
|
||||||
text.setString("");
|
|
||||||
else
|
|
||||||
text.setString(txt);
|
text.setString(txt);
|
||||||
|
|
||||||
detectHotkey();
|
detectHotkey();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,6 +319,12 @@ void FButton::onMouseMove (FMouseEvent* ev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FButton::onWheel (FWheelEvent*)
|
||||||
|
{
|
||||||
|
setUp();
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FButton::onTimer (FTimerEvent* ev)
|
void FButton::onTimer (FTimerEvent* ev)
|
||||||
{
|
{
|
||||||
|
|
|
@ -361,7 +361,7 @@ void FButtonGroup::draw()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FButtonGroup::drawLabel()
|
void FButtonGroup::drawLabel()
|
||||||
{
|
{
|
||||||
if ( text.isNull() || text.isEmpty() )
|
if ( text.isEmpty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FString label_text{};
|
FString label_text{};
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* *
|
* *
|
||||||
* This file is part of the FINAL CUT widget toolkit *
|
* 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 *
|
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU Lesser General Public License as *
|
* it under the terms of the GNU Lesser General Public License as *
|
||||||
|
@ -29,10 +29,47 @@
|
||||||
namespace finalcut
|
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)
|
// .--------------------- Unicode (UTF-8)
|
||||||
// | .--------------- VT100
|
// | .--------------- VT100
|
||||||
|
@ -161,8 +198,8 @@ std::array<CharEncodeMap, 115> character =
|
||||||
* (2) Only supported in use with newfont
|
* (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::rarrow , UniChar::BlackRightPointingPointer}, // ►
|
||||||
{VT100Key::larrow , UniChar::BlackLeftPointingPointer}, // ◄
|
{VT100Key::larrow , UniChar::BlackLeftPointingPointer}, // ◄
|
||||||
|
@ -205,7 +242,8 @@ constexpr std::array<DECSpecialGraphics, 39> dec_special_graphics =
|
||||||
{VT100Key::diamond , UniChar::Bullet} // ◆
|
{VT100Key::diamond , UniChar::Bullet} // ◆
|
||||||
}};
|
}};
|
||||||
|
|
||||||
constexpr std::array<std::array<wchar_t, 2>, 256> cp437_ucs =
|
//----------------------------------------------------------------------
|
||||||
|
constexpr FCharMap::Cp437UcsType FCharMap::cp437_ucs =
|
||||||
{{
|
{{
|
||||||
{{0x00, 0x0000}}, // null
|
{{0x00, 0x0000}}, // null
|
||||||
{{0x01, 0x263a}}, // white smiling face
|
{{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
|
{{0xff, 0x00a0}} // no-break space
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
// Based on http://www.unicode.org/charts/PDF/UFF00.pdf
|
// 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
|
// Fullwidth ASCII variants
|
||||||
{{0x0020, 0x3000}}, // ' ' -> ' '
|
{{0x0020, 0x3000}}, // ' ' -> ' '
|
||||||
|
@ -704,7 +743,4 @@ constexpr std::array<std::array<wchar_t, 2>, 227> halfwidth_fullwidth =
|
||||||
{{0xffee, 0x25cb}} // ○ -> ○
|
{{0xffee, 0x25cb}} // ○ -> ○
|
||||||
}};
|
}};
|
||||||
|
|
||||||
} // namespace fc
|
|
||||||
|
|
||||||
} // namespace finalcut
|
} // namespace finalcut
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* *
|
* *
|
||||||
* This file is part of the FINAL CUT widget toolkit *
|
* 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 *
|
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU Lesser General Public License as *
|
* 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
|
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
|
// protected methods of FColorPalette
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FColorPalette::setPalette (FColor index, int r, int g, int b) const
|
void FColorPalette::setPalette (FColor index, int r, int g, int b) const
|
||||||
|
|
|
@ -611,7 +611,7 @@ void FComboBox::cb_closeComboBox()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FComboBox::cb_inputFieldSwitch()
|
void FComboBox::cb_inputFieldSwitch()
|
||||||
{
|
{
|
||||||
auto& mouse = FTerm::getFMouseControl();
|
auto& mouse = FMouseControl::getInstance();
|
||||||
|
|
||||||
if ( ! mouse.isLeftButtonPressed() )
|
if ( ! mouse.isLeftButtonPressed() )
|
||||||
return;
|
return;
|
||||||
|
@ -630,7 +630,7 @@ void FComboBox::cb_inputFieldSwitch()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FComboBox::cb_inputFieldHandOver()
|
void FComboBox::cb_inputFieldHandOver()
|
||||||
{
|
{
|
||||||
auto& mouse = FTerm::getFMouseControl();
|
auto& mouse = FMouseControl::getInstance();
|
||||||
|
|
||||||
if ( list_window.isHidden() )
|
if ( list_window.isHidden() )
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -100,7 +100,7 @@ bool FDialog::setModal (bool enable)
|
||||||
if ( enable )
|
if ( enable )
|
||||||
{
|
{
|
||||||
setModalDialogCounter()++;
|
setModalDialogCounter()++;
|
||||||
FTerm::getFKeyboard().clearKeyBuffer();
|
FKeyboard::getInstance().clearKeyBuffer();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
setModalDialogCounter()--;
|
setModalDialogCounter()--;
|
||||||
|
|
|
@ -65,15 +65,15 @@ FString fileChooser ( FWidget* parent
|
||||||
FString path{dirname};
|
FString path{dirname};
|
||||||
FString file_filter{filter};
|
FString file_filter{filter};
|
||||||
|
|
||||||
if ( path.isNull() || path.isEmpty() )
|
if ( path.isEmpty() )
|
||||||
{
|
{
|
||||||
path.setString(FFileDialog::getHomeDir());
|
path.setString(FFileDialog::getHomeDir());
|
||||||
|
|
||||||
if ( path.isNull() || path.isEmpty() )
|
if ( path.isEmpty() )
|
||||||
path.setString("/");
|
path.setString("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( file_filter.isNull() || file_filter.isEmpty() )
|
if ( file_filter.isEmpty() )
|
||||||
file_filter.setString("*");
|
file_filter.setString("*");
|
||||||
|
|
||||||
FFileDialog fileopen ( path
|
FFileDialog fileopen ( path
|
||||||
|
@ -111,7 +111,7 @@ FFileDialog::FFileDialog ( const FString& dirname
|
||||||
, filter_pattern{filter}
|
, filter_pattern{filter}
|
||||||
, dlg_type{type}
|
, dlg_type{type}
|
||||||
{
|
{
|
||||||
if ( ! dirname.isNull() )
|
if ( ! dirname.isEmpty() )
|
||||||
setPath(dirname);
|
setPath(dirname);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
@ -162,7 +162,7 @@ void FFileDialog::setPath (const FString& dir)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& fsystem = FTerm::getFSystem();
|
const auto& fsystem = FSystem::getInstance();
|
||||||
|
|
||||||
if ( fsystem->realpath(dir.c_str(), resolved_path.data()) != nullptr )
|
if ( fsystem->realpath(dir.c_str(), resolved_path.data()) != nullptr )
|
||||||
r_dir.setString(resolved_path.data());
|
r_dir.setString(resolved_path.data());
|
||||||
|
@ -372,18 +372,16 @@ void FFileDialog::initCallbacks()
|
||||||
inline bool FFileDialog::patternMatch ( const char* const pattern
|
inline bool FFileDialog::patternMatch ( const char* const pattern
|
||||||
, const char fname[] ) const
|
, 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
|
if ( show_hidden && fname[0] == '.' && fname[1] != '\0' ) // hidden files
|
||||||
{
|
{
|
||||||
search[0] = '.';
|
search = ".";
|
||||||
search[1] = '\0';
|
search.append(pattern);
|
||||||
std::strncat(search.data(), pattern, search.size() - std::strlen(search.data()) - 1);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
std::strncpy(search.data(), pattern, search.size() - 1);
|
search = pattern;
|
||||||
|
|
||||||
search[search.size() - 1] = '\0';
|
|
||||||
|
|
||||||
if ( fnmatch (search.data(), fname, FNM_PERIOD) == 0 )
|
if ( fnmatch (search.data(), fname, FNM_PERIOD) == 0 )
|
||||||
return true;
|
return true;
|
||||||
|
@ -480,15 +478,13 @@ int FFileDialog::readDir()
|
||||||
|
|
||||||
getEntry(dir, next);
|
getEntry(dir, next);
|
||||||
}
|
}
|
||||||
else if ( errno != 0 )
|
else
|
||||||
{
|
{
|
||||||
|
if ( errno != 0 )
|
||||||
FMessageBox::error (this, "Reading directory\n" + directory);
|
FMessageBox::error (this, "Reading directory\n" + directory);
|
||||||
|
|
||||||
if ( errno == EOVERFLOW ) // Value too large to be stored in data type
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
break;
|
|
||||||
} // end while
|
} // end while
|
||||||
|
|
||||||
if ( closedir(directory_stream) != 0 )
|
if ( closedir(directory_stream) != 0 )
|
||||||
|
@ -550,16 +546,11 @@ void FFileDialog::followSymLink (const char* const dir, FDirEntry& entry) const
|
||||||
return; // No symbolic link
|
return; // No symbolic link
|
||||||
|
|
||||||
std::array<char, MAXPATHLEN> resolved_path{};
|
std::array<char, MAXPATHLEN> resolved_path{};
|
||||||
std::array<char, MAXPATHLEN> symLink{};
|
std::string symLink{};
|
||||||
|
symLink.reserve(MAXPATHLEN);
|
||||||
struct stat sb{};
|
struct stat sb{};
|
||||||
|
const auto& fsystem = FSystem::getInstance();
|
||||||
const auto& fsystem = FTerm::getFSystem();
|
symLink = dir + entry.name;
|
||||||
std::strncpy (symLink.data(), dir, symLink.size() - 1);
|
|
||||||
symLink[symLink.size() - 1] = '\0';
|
|
||||||
std::strncat ( symLink.data()
|
|
||||||
, entry.name.c_str()
|
|
||||||
, symLink.size() - std::strlen(symLink.data()) - 1);
|
|
||||||
symLink[symLink.size() - 1] = '\0';
|
|
||||||
|
|
||||||
if ( fsystem->realpath(symLink.data(), resolved_path.data()) == nullptr )
|
if ( fsystem->realpath(symLink.data(), resolved_path.data()) == nullptr )
|
||||||
return; // Cannot follow the symlink
|
return; // Cannot follow the symlink
|
||||||
|
@ -691,7 +682,7 @@ FString FFileDialog::getHomeDir()
|
||||||
struct passwd* pwd_ptr{};
|
struct passwd* pwd_ptr{};
|
||||||
std::array<char, 1024> buf{};
|
std::array<char, 1024> buf{};
|
||||||
|
|
||||||
const auto& fsystem = FTerm::getFSystem();
|
const auto& fsystem = FSystem::getInstance();
|
||||||
const uid_t euid = fsystem->geteuid();
|
const uid_t euid = fsystem->geteuid();
|
||||||
|
|
||||||
if ( fsystem->getpwuid_r(euid, &pwd, buf.data(), buf.size(), &pwd_ptr) )
|
if ( fsystem->getpwuid_r(euid, &pwd, buf.data(), buf.size(), &pwd_ptr) )
|
||||||
|
@ -735,7 +726,7 @@ void FFileDialog::cb_processActivate()
|
||||||
{
|
{
|
||||||
return ! entry.name.empty()
|
return ! entry.name.empty()
|
||||||
&& input
|
&& input
|
||||||
&& ! input.isNull()
|
&& ! input.isEmpty()
|
||||||
&& std::strcmp(entry.name.c_str(), input.c_str()) == 0
|
&& std::strcmp(entry.name.c_str(), input.c_str()) == 0
|
||||||
&& entry.directory;
|
&& entry.directory;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* *
|
* *
|
||||||
* This file is part of the FINAL CUT widget toolkit *
|
* 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 *
|
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU Lesser General Public License as *
|
* it under the terms of the GNU Lesser General Public License as *
|
||||||
|
@ -28,10 +28,33 @@
|
||||||
namespace finalcut
|
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::Backspace , nullptr, "kb" }, // Backspace key
|
||||||
{ FKey::Clear_all_tabs , nullptr, "ka" }, // Clear-all-tabs 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
|
{ 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[2;3~" }, // M-Insert
|
||||||
{ FKey::Meta_insert , "\033\033[2~" }, // 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-~
|
{ FKey::Meta_tilde , "\033~" } // M-~
|
||||||
}};
|
}};
|
||||||
|
|
||||||
constexpr std::array<FKeyName, 388> fkeyname =
|
//----------------------------------------------------------------------
|
||||||
|
constexpr FKeyMap::KeyNameType FKeyMap::fkeyname =
|
||||||
{{
|
{{
|
||||||
{ FKey::Ctrl_a , "Ctrl+A" },
|
{ FKey::Ctrl_a , "Ctrl+A" },
|
||||||
{ FKey::Ctrl_b , "Ctrl+B" },
|
{ FKey::Ctrl_b , "Ctrl+B" },
|
||||||
|
@ -856,6 +881,4 @@ constexpr std::array<FKeyName, 388> fkeyname =
|
||||||
{ FKey::Incomplete , "incomplete key string" }
|
{ FKey::Incomplete , "incomplete key string" }
|
||||||
}};
|
}};
|
||||||
|
|
||||||
} // namespace fc
|
|
||||||
|
|
||||||
} // namespace finalcut
|
} // 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{100000}; // 100 ms (10 Hz)
|
||||||
uInt64 FKeyboard::read_blocking_time_short{5000}; // 5 ms (200 Hz)
|
uInt64 FKeyboard::read_blocking_time_short{5000}; // 5 ms (200 Hz)
|
||||||
bool FKeyboard::non_blocking_input_support{true};
|
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()
|
FKeyboard::FKeyboard()
|
||||||
{
|
{
|
||||||
// Initialize keyboard values
|
// Initialize keyboard values
|
||||||
time_keypressed.tv_sec = 0;
|
time_keypressed = TimeValue{}; // Set to epoch time
|
||||||
time_keypressed.tv_usec = 0;
|
|
||||||
|
|
||||||
// Get the stdin file status flags
|
// Get the stdin file status flags
|
||||||
stdin_status_flags = fcntl(FTermios::getStdIn(), F_GETFL);
|
stdin_status_flags = fcntl(FTermios::getStdIn(), F_GETFL);
|
||||||
|
@ -75,6 +74,13 @@ FKeyboard::FKeyboard()
|
||||||
|
|
||||||
|
|
||||||
// public methods of FKeyboard
|
// public methods of FKeyboard
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
auto FKeyboard::getInstance() -> FKeyboard&
|
||||||
|
{
|
||||||
|
static const auto& keyboard = make_unique<FKeyboard>();
|
||||||
|
return *keyboard;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FKeyboard::fetchKeyCode()
|
void FKeyboard::fetchKeyCode()
|
||||||
{
|
{
|
||||||
|
@ -85,17 +91,18 @@ void FKeyboard::fetchKeyCode()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FString FKeyboard::getKeyName (const FKey keynum) const
|
FString FKeyboard::getKeyName (const FKey keynum) const
|
||||||
{
|
{
|
||||||
|
const auto& fkeyname = FKeyMap::getKeyName();
|
||||||
const auto& found_key = std::find_if
|
const auto& found_key = std::find_if
|
||||||
(
|
(
|
||||||
fc::fkeyname.cbegin(),
|
fkeyname.cbegin(),
|
||||||
fc::fkeyname.cend(),
|
fkeyname.cend(),
|
||||||
[&keynum] (const fc::FKeyName& kn)
|
[&keynum] (const FKeyMap::KeyName& kn)
|
||||||
{
|
{
|
||||||
return ( kn.num != FKey::None && kn.num == keynum );
|
return ( kn.num != FKey::None && kn.num == keynum );
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( found_key != fc::fkeyname.end() )
|
if ( found_key != fkeyname.end() )
|
||||||
return {found_key->string};
|
return {found_key->string};
|
||||||
|
|
||||||
if ( keynum > 32 && keynum < 127 )
|
if ( keynum > 32 && keynum < 127 )
|
||||||
|
@ -249,7 +256,7 @@ inline FKey FKeyboard::getMouseProtocolKey() const
|
||||||
if ( ! mouse_support )
|
if ( ! mouse_support )
|
||||||
return NOT_SET;
|
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
|
// x11 mouse tracking
|
||||||
if ( buf_len >= 6 && fifo_buf[1] == '[' && fifo_buf[2] == 'M' )
|
if ( buf_len >= 6 && fifo_buf[1] == '[' && fifo_buf[2] == 'M' )
|
||||||
|
@ -282,7 +289,7 @@ inline FKey FKeyboard::getTermcapKey()
|
||||||
for (auto&& entry : *key_map)
|
for (auto&& entry : *key_map)
|
||||||
{
|
{
|
||||||
const char* kstr = entry.string;
|
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
|
if ( kstr && std::strncmp(kstr, fifo_buf, len) == 0 ) // found
|
||||||
{
|
{
|
||||||
|
@ -309,10 +316,10 @@ inline FKey FKeyboard::getKnownKey()
|
||||||
|
|
||||||
assert ( FIFO_BUF_SIZE > 0 );
|
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 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
|
if ( std::strncmp(kstr, fifo_buf, len) == 0 ) // found
|
||||||
{
|
{
|
||||||
|
@ -355,7 +362,7 @@ inline FKey FKeyboard::getSingleKey()
|
||||||
if ( utf8_input && (firstchar & 0xc0) == 0xc0 )
|
if ( utf8_input && (firstchar & 0xc0) == 0xc0 )
|
||||||
{
|
{
|
||||||
std::array<char, 5> utf8char{}; // Init array with '\0'
|
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 )
|
if ( (firstchar & 0xe0) == 0xc0 )
|
||||||
len = 2;
|
len = 2;
|
||||||
|
@ -392,22 +399,22 @@ inline FKey FKeyboard::getSingleKey()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FKeyboard::isKeypressTimeout()
|
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
|
FKey ucs{FKey::None}; // Universal coded character
|
||||||
constexpr std::size_t max = 4;
|
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 )
|
for (auto iter{utf8.begin()}; iter < end; ++iter)
|
||||||
len = max;
|
|
||||||
|
|
||||||
for (std::size_t i{0}; i < len; ++i)
|
|
||||||
{
|
{
|
||||||
const auto ch = uChar(utf8[i]);
|
const auto ch = uChar(*iter);
|
||||||
|
|
||||||
if ( (ch & 0xc0) == 0x80 )
|
if ( (ch & 0xc0) == 0x80 )
|
||||||
{
|
{
|
||||||
|
@ -457,7 +464,7 @@ inline ssize_t FKeyboard::readKey()
|
||||||
void FKeyboard::parseKeyBuffer()
|
void FKeyboard::parseKeyBuffer()
|
||||||
{
|
{
|
||||||
ssize_t bytesread{};
|
ssize_t bytesread{};
|
||||||
FObject::getCurrentTime (&time_keypressed);
|
time_keypressed = FObject::getCurrentTime();
|
||||||
|
|
||||||
while ( (bytesread = readKey()) > 0 )
|
while ( (bytesread = readKey()) > 0 )
|
||||||
{
|
{
|
||||||
|
@ -482,14 +489,14 @@ void FKeyboard::parseKeyBuffer()
|
||||||
{
|
{
|
||||||
key = fkey;
|
key = fkey;
|
||||||
mouseTracking();
|
mouseTracking();
|
||||||
fifo_offset = int(std::strlen(fifo_buf));
|
fifo_offset = int(stringLength(fifo_buf));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( fkey != FKey::Incomplete )
|
if ( fkey != FKey::Incomplete )
|
||||||
{
|
{
|
||||||
fkey_queue.push(fkey);
|
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 defined(__linux__)
|
||||||
if ( FTerm::isLinuxTerm() )
|
if ( FTerm::isLinuxTerm() )
|
||||||
{
|
{
|
||||||
auto& linux_console = FTerm::getFTermLinux();
|
auto& linux_console = FTermLinux::getInstance();
|
||||||
key_correction = linux_console.modifierKeyCorrection(keycode);
|
key_correction = linux_console.modifierKeyCorrection(keycode);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -141,7 +141,7 @@ bool FLabel::setEnable (bool enable)
|
||||||
void FLabel::setText (const FString& txt)
|
void FLabel::setText (const FString& txt)
|
||||||
{
|
{
|
||||||
text.setString(txt);
|
text.setString(txt);
|
||||||
multiline_text = text.split("\r\n");
|
multiline_text = text.split("\n");
|
||||||
|
|
||||||
if ( int(multiline_text.size()) > 1 )
|
if ( int(multiline_text.size()) > 1 )
|
||||||
multiline = true;
|
multiline = true;
|
||||||
|
|
|
@ -749,7 +749,7 @@ void FListBox::drawScrollbars() const
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FListBox::drawHeadline()
|
void FListBox::drawHeadline()
|
||||||
{
|
{
|
||||||
if ( text.isNull() || text.isEmpty() )
|
if ( text.isEmpty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const FString txt{" " + text + " "};
|
const FString txt{" " + text + " "};
|
||||||
|
@ -1678,7 +1678,7 @@ void FListBox::changeOnResize() const
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FListBox::lazyConvert(FListBoxItems::iterator iter, std::size_t y)
|
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;
|
return;
|
||||||
|
|
||||||
lazy_inserter (*iter, source_container, y + std::size_t(yoffset));
|
lazy_inserter (*iter, source_container, y + std::size_t(yoffset));
|
||||||
|
|
|
@ -910,6 +910,7 @@ void FListView::clear()
|
||||||
{
|
{
|
||||||
itemlist.clear();
|
itemlist.clear();
|
||||||
current_iter = getNullIterator();
|
current_iter = getNullIterator();
|
||||||
|
mark_iter = getNullIterator();
|
||||||
first_visible_line = getNullIterator();
|
first_visible_line = getNullIterator();
|
||||||
last_visible_line = getNullIterator();
|
last_visible_line = getNullIterator();
|
||||||
recalculateVerticalBar (0);
|
recalculateVerticalBar (0);
|
||||||
|
@ -1427,6 +1428,60 @@ inline void FListView::mapKeyFunctions()
|
||||||
key_map_result[FKey('-')] = [this] { return collapseSubtree(); };
|
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)
|
void FListView::processKeyAction (FKeyEvent* ev)
|
||||||
{
|
{
|
||||||
|
@ -1608,6 +1663,14 @@ void FListView::drawList()
|
||||||
while ( iter != path_end && iter != itemlist_end && y < page_height )
|
while ( iter != path_end && iter != itemlist_end && y < page_height )
|
||||||
{
|
{
|
||||||
const bool is_current_line( iter == current_iter );
|
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 auto& item = static_cast<FListViewItem*>(*iter);
|
||||||
const int tree_offset = tree_view ? int(item->getDepth() << 1) + 1 : 0;
|
const int tree_offset = tree_view ? int(item->getDepth() << 1) + 1 : 0;
|
||||||
const int checkbox_offset = item->isCheckable() ? 1 : 0;
|
const int checkbox_offset = item->isCheckable() ? 1 : 0;
|
||||||
|
@ -1615,7 +1678,7 @@ void FListView::drawList()
|
||||||
print() << FPoint{2, 2 + int(y)};
|
print() << FPoint{2, 2 + int(y)};
|
||||||
|
|
||||||
// Draw one FListViewItem
|
// 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 )
|
if ( getFlags().focus && is_current_line )
|
||||||
{
|
{
|
||||||
|
@ -1651,10 +1714,10 @@ void FListView::drawList()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FListView::drawListLine ( const FListViewItem* item
|
void FListView::drawListLine ( const FListViewItem* item
|
||||||
, bool is_focus
|
, bool is_focus
|
||||||
, bool is_current )
|
, bool is_current, bool is_mark, bool is_selected )
|
||||||
{
|
{
|
||||||
// Set line color and attributes
|
// Set line color and attributes
|
||||||
setLineAttributes (is_current, is_focus);
|
setLineAttributes (is_current, is_focus, is_mark, is_selected);
|
||||||
|
|
||||||
// Print the entry
|
// Print the entry
|
||||||
const std::size_t indent = item->getDepth() << 1; // indent = 2 * depth
|
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
|
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();
|
const auto& wc = getColorTheme();
|
||||||
setColor (wc->list_fg, wc->list_bg);
|
setColor (wc->list_fg, wc->list_bg);
|
||||||
|
if ( is_mark )
|
||||||
if ( is_current )
|
setColor ( FColor::White, FColor::Red );
|
||||||
|
else if ( is_current )
|
||||||
{
|
{
|
||||||
if ( is_focus && FTerm::getMaxColor() < 16 )
|
if ( is_focus && FTerm::getMaxColor() < 16 )
|
||||||
setBold();
|
setBold();
|
||||||
|
@ -1783,6 +1847,8 @@ inline void FListView::setLineAttributes ( bool is_current
|
||||||
if ( FTerm::isMonochron() )
|
if ( FTerm::isMonochron() )
|
||||||
setReverse(false);
|
setReverse(false);
|
||||||
}
|
}
|
||||||
|
else if ( is_selected )
|
||||||
|
setColor ( FColor::White , FColor::Green );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( FTerm::isMonochron() )
|
if ( FTerm::isMonochron() )
|
||||||
|
|
|
@ -281,7 +281,7 @@ void FMessageBox::calculateDimensions()
|
||||||
if ( text_num_lines == 0 )
|
if ( text_num_lines == 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( ! headline_text.isNull() )
|
if ( ! headline_text.isEmpty() )
|
||||||
headline_height = 2;
|
headline_height = 2;
|
||||||
|
|
||||||
for (auto&& line : text_components)
|
for (auto&& line : text_components)
|
||||||
|
|
|
@ -196,37 +196,37 @@ FString FMouse::getClassName() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FMouse::clearEvent()
|
void FMouse::clearEvent()
|
||||||
{
|
{
|
||||||
mouse_event_occurred = false;
|
mouse_event_occurred = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FMouse::setMaxWidth (uInt16 x_max)
|
void FMouse::setMaxWidth (uInt16 x_max)
|
||||||
{
|
{
|
||||||
max_width = x_max;
|
max_width = x_max;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FMouse::setMaxHeight (uInt16 y_max)
|
void FMouse::setMaxHeight (uInt16 y_max)
|
||||||
{
|
{
|
||||||
max_height = y_max;
|
max_height = y_max;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FMouse::setDblclickInterval (const uInt64 timeout)
|
void FMouse::setDblclickInterval (const uInt64 timeout)
|
||||||
{
|
{
|
||||||
dblclick_interval = timeout;
|
dblclick_interval = timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FMouse::hasEvent() const
|
bool FMouse::hasEvent() const
|
||||||
{
|
{
|
||||||
return mouse_event_occurred;
|
return mouse_event_occurred;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FMouse::hasUnprocessedInput() const
|
bool FMouse::hasUnprocessedInput() const
|
||||||
{
|
{
|
||||||
return unprocessed_buffer_data;
|
return unprocessed_buffer_data;
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,7 @@ inline bool FMouse::hasUnprocessedInput() const
|
||||||
|
|
||||||
// protected methods of FMouse
|
// protected methods of FMouse
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const FPoint& FMouse::getNewPos() const
|
const FPoint& FMouse::getNewPos() const
|
||||||
{
|
{
|
||||||
return new_mouse_position;
|
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()
|
void FMouse::resetMousePressedTime()
|
||||||
{
|
{
|
||||||
time_mousepressed.tv_sec = 0;
|
time_mousepressed = TimeValue{}; // Set to epoch time
|
||||||
time_mousepressed.tv_usec = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -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);
|
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();
|
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
|
// 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
|
// 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
|
// Import the X11 xterm mouse protocol (SGR-Mode) raw mouse data
|
||||||
|
|
||||||
const std::size_t fifo_buf_size = sizeof(fifo_buf);
|
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};
|
std::size_t n{3};
|
||||||
|
|
||||||
while ( n < len && n <= MOUSE_BUF_SIZE + 1 )
|
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();
|
const auto& mouse_position = getPos();
|
||||||
uInt16 x{0};
|
uInt16 x{0};
|
||||||
|
@ -867,7 +866,7 @@ void FMouseSGR::setMoveState (const FPoint& mouse_position, int btn)
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FMouseSGR::setPressedButtonState ( const 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
|
// 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
|
// Import the X11 xterm mouse protocol (Urxvt-Mode) raw mouse data
|
||||||
|
|
||||||
const std::size_t fifo_buf_size = sizeof(fifo_buf);
|
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};
|
std::size_t n{2};
|
||||||
|
|
||||||
while ( n < len && n <= MOUSE_BUF_SIZE )
|
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)
|
// 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
|
// Get the urxvt mouse button state
|
||||||
|
|
||||||
|
@ -1205,14 +1204,16 @@ void FMouseUrxvt::setButtonState (const int btn, const struct timeval* time)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FMouseControl::FMouseControl()
|
FMouseControl::FMouseControl()
|
||||||
{
|
{
|
||||||
|
using mt = FMouse::MouseType;
|
||||||
|
|
||||||
#ifdef F_HAVE_LIBGPM
|
#ifdef F_HAVE_LIBGPM
|
||||||
if ( FTermLinux::isLinuxConsole() )
|
if ( FTermLinux::isLinuxConsole() )
|
||||||
mouse_protocol[FMouse::MouseType::Gpm].reset(FMouse::createMouseObject<FMouseGPM>());
|
mouse_protocol[mt::Gpm].reset(FMouse::createMouseObject<FMouseGPM>());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mouse_protocol[FMouse::MouseType::X11].reset(FMouse::createMouseObject<FMouseX11>());
|
mouse_protocol[mt::X11].reset(FMouse::createMouseObject<FMouseX11>());
|
||||||
mouse_protocol[FMouse::MouseType::Sgr].reset(FMouse::createMouseObject<FMouseSGR>());
|
mouse_protocol[mt::Sgr].reset(FMouse::createMouseObject<FMouseSGR>());
|
||||||
mouse_protocol[FMouse::MouseType::Urxvt].reset(FMouse::createMouseObject<FMouseUrxvt>());
|
mouse_protocol[mt::Urxvt].reset(FMouse::createMouseObject<FMouseUrxvt>());
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -1220,6 +1221,13 @@ FMouseControl::~FMouseControl() = default; // destructor
|
||||||
|
|
||||||
|
|
||||||
// public methods of FMouseControl
|
// public methods of FMouseControl
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
auto FMouseControl::getInstance() -> FMouseControl&
|
||||||
|
{
|
||||||
|
static const auto& mouse = make_unique<FMouseControl>();
|
||||||
|
return *mouse;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FPoint& FMouseControl::getPos()
|
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 mtype = getMouseWithData();
|
||||||
auto mouse_object = mouse_protocol[mtype].get();
|
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 *
|
* 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 *
|
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU Lesser General Public License as *
|
* it under the terms of the GNU Lesser General Public License as *
|
||||||
|
@ -21,6 +21,7 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
#include "final/fevent.h"
|
#include "final/fevent.h"
|
||||||
#include "final/fc.h"
|
#include "final/fc.h"
|
||||||
|
@ -29,8 +30,17 @@
|
||||||
namespace finalcut
|
namespace finalcut
|
||||||
{
|
{
|
||||||
|
|
||||||
// static class attributes
|
namespace internal
|
||||||
bool FObject::timer_modify_lock;
|
{
|
||||||
|
|
||||||
|
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
|
if ( parent ) // add object to parent
|
||||||
parent->addChild(this);
|
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
|
return system_clock::now(); // Get the current time
|
||||||
|
|
||||||
gettimeofday(time, nullptr);
|
|
||||||
|
|
||||||
// NTP fix
|
|
||||||
while ( time->tv_usec >= 1000000 )
|
|
||||||
{
|
|
||||||
time->tv_usec -= 1000000;
|
|
||||||
time->tv_sec++;
|
|
||||||
}
|
|
||||||
|
|
||||||
while ( time->tv_usec < 0 )
|
|
||||||
{
|
|
||||||
if ( time->tv_sec > 0 )
|
|
||||||
{
|
|
||||||
time->tv_usec += 1000000;
|
|
||||||
time->tv_sec--;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
time->tv_usec = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
bool FObject::isTimeout (const 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{};
|
const auto now = getCurrentTime();
|
||||||
struct timeval diff{};
|
|
||||||
|
|
||||||
FObject::getCurrentTime(&now);
|
if ( now < time )
|
||||||
diff.tv_sec = now.tv_sec - time->tv_sec;
|
return false;
|
||||||
diff.tv_usec = now.tv_usec - time->tv_usec;
|
|
||||||
|
|
||||||
if ( diff.tv_usec < 0 )
|
const auto diff = now - time;
|
||||||
{
|
const auto diff_usec = uInt64(duration_cast<microseconds>(diff).count());
|
||||||
diff.tv_sec--;
|
return diff_usec > timeout;
|
||||||
diff.tv_usec += 1000000;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto diff_usec = uInt64((diff.tv_sec * 1000000) + diff.tv_usec);
|
|
||||||
return ( diff_usec > timeout );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -235,10 +213,8 @@ int FObject::addTimer (int interval)
|
||||||
// Create a timer and returns the timer identifier number
|
// Create a timer and returns the timer identifier number
|
||||||
// (interval in ms)
|
// (interval in ms)
|
||||||
|
|
||||||
timeval time_interval{};
|
|
||||||
timeval currentTime{};
|
|
||||||
int id{1};
|
int id{1};
|
||||||
timer_modify_lock = true;
|
std::lock_guard<std::mutex> lock_guard(internal::var::timer_mutex);
|
||||||
auto& timer_list = globalTimerList();
|
auto& timer_list = globalTimerList();
|
||||||
|
|
||||||
// find an unused timer id
|
// find an unused timer id
|
||||||
|
@ -262,10 +238,8 @@ int FObject::addTimer (int interval)
|
||||||
if ( id <= 0 || id > int(timer_list->size() + 1) )
|
if ( id <= 0 || id > int(timer_list->size() + 1) )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
time_interval.tv_sec = interval / 1000;
|
const auto time_interval = milliseconds(interval);
|
||||||
time_interval.tv_usec = (interval % 1000) * 1000;
|
const auto timeout = getCurrentTime() + time_interval;
|
||||||
getCurrentTime (¤tTime);
|
|
||||||
timeval timeout = currentTime + time_interval;
|
|
||||||
FTimerData t{ id, time_interval, timeout, this };
|
FTimerData t{ id, time_interval, timeout, this };
|
||||||
|
|
||||||
// insert in list sorted by timeout
|
// insert in list sorted by timeout
|
||||||
|
@ -276,7 +250,6 @@ int FObject::addTimer (int interval)
|
||||||
++iter;
|
++iter;
|
||||||
|
|
||||||
timer_list->insert (iter, t);
|
timer_list->insert (iter, t);
|
||||||
timer_modify_lock = false;
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,7 +261,7 @@ bool FObject::delTimer (int id) const
|
||||||
if ( id <= 0 )
|
if ( id <= 0 )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
timer_modify_lock = true;
|
std::lock_guard<std::mutex> lock_guard(internal::var::timer_mutex);
|
||||||
auto& timer_list = globalTimerList();
|
auto& timer_list = globalTimerList();
|
||||||
auto iter = timer_list->begin();
|
auto iter = timer_list->begin();
|
||||||
const auto& last = timer_list->end();
|
const auto& last = timer_list->end();
|
||||||
|
@ -299,11 +272,9 @@ bool FObject::delTimer (int id) const
|
||||||
if ( iter != last )
|
if ( iter != last )
|
||||||
{
|
{
|
||||||
timer_list->erase(iter);
|
timer_list->erase(iter);
|
||||||
timer_modify_lock = false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
timer_modify_lock = false;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,6 +283,7 @@ bool FObject::delOwnTimers() const
|
||||||
{
|
{
|
||||||
// Deletes all timers of this object
|
// Deletes all timers of this object
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> lock_guard(internal::var::timer_mutex);
|
||||||
auto& timer_list = globalTimerList();
|
auto& timer_list = globalTimerList();
|
||||||
|
|
||||||
if ( ! timer_list )
|
if ( ! timer_list )
|
||||||
|
@ -320,7 +292,6 @@ bool FObject::delOwnTimers() const
|
||||||
if ( timer_list->empty() )
|
if ( timer_list->empty() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
timer_modify_lock = true;
|
|
||||||
auto iter = timer_list->begin();
|
auto iter = timer_list->begin();
|
||||||
|
|
||||||
while ( iter != timer_list->end() )
|
while ( iter != timer_list->end() )
|
||||||
|
@ -331,7 +302,6 @@ bool FObject::delOwnTimers() const
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
timer_modify_lock = false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,6 +310,7 @@ bool FObject::delAllTimers() const
|
||||||
{
|
{
|
||||||
// Deletes all timers of all objects
|
// Deletes all timers of all objects
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> lock_guard(internal::var::timer_mutex);
|
||||||
auto& timer_list = globalTimerList();
|
auto& timer_list = globalTimerList();
|
||||||
|
|
||||||
if ( ! timer_list )
|
if ( ! timer_list )
|
||||||
|
@ -348,10 +319,8 @@ bool FObject::delAllTimers() const
|
||||||
if ( timer_list->empty() )
|
if ( timer_list->empty() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
timer_modify_lock = true;
|
|
||||||
timer_list->clear();
|
timer_list->clear();
|
||||||
timer_list->shrink_to_fit();
|
timer_list->shrink_to_fit();
|
||||||
timer_modify_lock = false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,20 +343,17 @@ void FObject::onUserEvent (FUserEvent*)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
uInt FObject::processTimerEvent()
|
uInt FObject::processTimerEvent()
|
||||||
{
|
{
|
||||||
timeval currentTime{};
|
|
||||||
uInt activated{0};
|
uInt activated{0};
|
||||||
|
std::unique_lock<std::mutex> unique_lock( internal::var::timer_mutex
|
||||||
|
, std::defer_lock );
|
||||||
|
|
||||||
getCurrentTime (¤tTime);
|
if ( ! unique_lock.try_lock() )
|
||||||
|
|
||||||
if ( isTimerInUpdating() )
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
auto currentTime = getCurrentTime();
|
||||||
auto& timer_list = globalTimerList();
|
auto& timer_list = globalTimerList();
|
||||||
|
|
||||||
if ( ! timer_list )
|
if ( ! timer_list || timer_list->empty() )
|
||||||
return 0;
|
|
||||||
|
|
||||||
if ( timer_list->empty() )
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for (auto&& timer : *timer_list)
|
for (auto&& timer : *timer_list)
|
||||||
|
@ -402,7 +368,7 @@ uInt FObject::processTimerEvent()
|
||||||
if ( timer.timeout < currentTime )
|
if ( timer.timeout < currentTime )
|
||||||
timer.timeout = currentTime + timer.interval;
|
timer.timeout = currentTime + timer.interval;
|
||||||
|
|
||||||
if ( timer.interval.tv_usec > 0 || timer.interval.tv_sec > 0 )
|
if ( timer.interval > microseconds(0) )
|
||||||
activated++;
|
activated++;
|
||||||
|
|
||||||
FTimerEvent t_ev(Event::Timer, timer.id);
|
FTimerEvent t_ev(Event::Timer, timer.id);
|
||||||
|
|
|
@ -39,6 +39,8 @@ namespace finalcut
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FOptiAttr::FOptiAttr()
|
FOptiAttr::FOptiAttr()
|
||||||
{
|
{
|
||||||
|
attr_buf.reserve(SGRoptimizer::ATTR_BUF_SIZE);
|
||||||
|
|
||||||
// Set bits that must not be reset
|
// Set bits that must not be reset
|
||||||
reset_byte_mask.attr.bit.transparent = true;
|
reset_byte_mask.attr.bit.transparent = true;
|
||||||
reset_byte_mask.attr.bit.color_overlay = true;
|
reset_byte_mask.attr.bit.color_overlay = true;
|
||||||
|
@ -49,6 +51,13 @@ FOptiAttr::FOptiAttr()
|
||||||
|
|
||||||
|
|
||||||
// public methods of 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)
|
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);
|
const bool next_has_color = hasColor(next);
|
||||||
fake_reverse = false;
|
fake_reverse = false;
|
||||||
attr_buf[0] = '\0';
|
attr_buf.clear();
|
||||||
prevent_no_color_video_attributes (term, next_has_color);
|
prevent_no_color_video_attributes (term, next_has_color);
|
||||||
prevent_no_color_video_attributes (next);
|
prevent_no_color_video_attributes (next);
|
||||||
detectSwitchOn (term, next);
|
detectSwitchOn (term, next);
|
||||||
|
@ -559,7 +568,7 @@ const char* FOptiAttr::changeAttribute (FChar& term, FChar& next)
|
||||||
|
|
||||||
// Look for no changes
|
// Look for no changes
|
||||||
if ( ! (switchOn() || switchOff() || hasColorChanged(term, next)) )
|
if ( ! (switchOn() || switchOff() || hasColorChanged(term, next)) )
|
||||||
return nullptr;
|
return {};
|
||||||
|
|
||||||
if ( hasNoAttribute(next) )
|
if ( hasNoAttribute(next) )
|
||||||
{
|
{
|
||||||
|
@ -575,10 +584,10 @@ const char* FOptiAttr::changeAttribute (FChar& term, FChar& next)
|
||||||
changeAttributeSeparately (term, next);
|
changeAttributeSeparately (term, next);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( FStartOptions::getFStartOptions().sgr_optimizer )
|
if ( FStartOptions::getInstance().sgr_optimizer )
|
||||||
sgr_optimizer.optimize();
|
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 FOptiAttr::setTermAttributes (FChar& term, const TCapAttributes& attr)
|
||||||
, bool p1, bool p2, bool p3
|
|
||||||
, bool p4, bool p5, bool p6
|
|
||||||
, bool p7, bool p8, bool p9 )
|
|
||||||
{
|
{
|
||||||
if ( F_set_attributes.cap )
|
if ( F_set_attributes.cap )
|
||||||
{
|
{
|
||||||
const auto sgr = FTermcap::encodeParameter ( F_set_attributes.cap
|
const auto sgr = FTermcap::encodeParameter ( F_set_attributes.cap
|
||||||
, p1 && ! fake_reverse
|
, attr.p1 && ! fake_reverse
|
||||||
, p2
|
, attr.p2
|
||||||
, p3 && ! fake_reverse
|
, attr.p3 && ! fake_reverse
|
||||||
, p4
|
, attr.p4
|
||||||
, p5
|
, attr.p5
|
||||||
, p6
|
, attr.p6
|
||||||
, p7
|
, attr.p7
|
||||||
, p8
|
, attr.p8
|
||||||
, p9 );
|
, attr.p9 );
|
||||||
append_sequence (sgr.data());
|
append_sequence (sgr.data());
|
||||||
resetColor(term);
|
resetColor(term);
|
||||||
term.attr.bit.standout = p1;
|
term.attr.bit.standout = attr.p1;
|
||||||
term.attr.bit.underline = p2;
|
term.attr.bit.underline = attr.p2;
|
||||||
term.attr.bit.reverse = p3;
|
term.attr.bit.reverse = attr.p3;
|
||||||
term.attr.bit.blink = p4;
|
term.attr.bit.blink = attr.p4;
|
||||||
term.attr.bit.dim = p5;
|
term.attr.bit.dim = attr.p5;
|
||||||
term.attr.bit.bold = p6;
|
term.attr.bit.bold = attr.p6;
|
||||||
term.attr.bit.invisible = p7;
|
term.attr.bit.invisible = attr.p7;
|
||||||
term.attr.bit.protect = p8;
|
term.attr.bit.protect = attr.p8;
|
||||||
term.attr.bit.alt_charset = p9;
|
term.attr.bit.alt_charset = attr.p9;
|
||||||
term.attr.bit.pc_charset = false;
|
term.attr.bit.pc_charset = false;
|
||||||
term.attr.bit.italic = false;
|
term.attr.bit.italic = false;
|
||||||
term.attr.bit.crossed_out = false;
|
term.attr.bit.crossed_out = false;
|
||||||
|
@ -1234,7 +1240,7 @@ inline void FOptiAttr::changeAttributeSGR (FChar& term, FChar& next)
|
||||||
|
|
||||||
if ( switchOn() || switchOff() )
|
if ( switchOn() || switchOff() )
|
||||||
setTermAttributes ( term
|
setTermAttributes ( term
|
||||||
, next.attr.bit.standout
|
, { next.attr.bit.standout
|
||||||
, next.attr.bit.underline
|
, next.attr.bit.underline
|
||||||
, next.attr.bit.reverse
|
, next.attr.bit.reverse
|
||||||
, next.attr.bit.blink
|
, next.attr.bit.blink
|
||||||
|
@ -1242,7 +1248,7 @@ inline void FOptiAttr::changeAttributeSGR (FChar& term, FChar& next)
|
||||||
, next.attr.bit.bold
|
, next.attr.bit.bold
|
||||||
, next.attr.bit.invisible
|
, next.attr.bit.invisible
|
||||||
, next.attr.bit.protect
|
, next.attr.bit.protect
|
||||||
, next.attr.bit.alt_charset );
|
, next.attr.bit.alt_charset } );
|
||||||
|
|
||||||
if ( alt_equal_pc_charset
|
if ( alt_equal_pc_charset
|
||||||
&& F_enter_pc_charset_mode.cap
|
&& F_enter_pc_charset_mode.cap
|
||||||
|
@ -1537,9 +1543,7 @@ inline bool FOptiAttr::append_sequence (const char seq[])
|
||||||
if ( ! seq )
|
if ( ! seq )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
char* attr_ptr{attr_buf.data()};
|
attr_buf.append(seq);
|
||||||
std::strncat (attr_ptr, seq, attr_buf.size() - std::strlen(attr_ptr));
|
|
||||||
attr_buf[attr_buf.size() - 1] = '\0';
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ FOptiMove::FOptiMove (int baud)
|
||||||
{
|
{
|
||||||
assert ( baud >= 0 );
|
assert ( baud >= 0 );
|
||||||
|
|
||||||
|
move_buf.reserve(BUF_SIZE);
|
||||||
calculateCharDuration();
|
calculateCharDuration();
|
||||||
|
|
||||||
// ANSI set cursor address preset for undefined terminals
|
// ANSI set cursor address preset for undefined terminals
|
||||||
|
@ -54,6 +55,13 @@ FOptiMove::FOptiMove (int baud)
|
||||||
|
|
||||||
|
|
||||||
// public methods of FOptiMove
|
// public methods of FOptiMove
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
auto FOptiMove::getInstance() -> FOptiMove&
|
||||||
|
{
|
||||||
|
static const auto& opti_move = make_unique<FOptiMove>();
|
||||||
|
return *opti_move;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FOptiMove::setBaudRate (int baud)
|
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 method{0};
|
||||||
int move_time{LONG_DURATION};
|
int move_time{LONG_DURATION};
|
||||||
|
@ -494,7 +502,7 @@ const char* FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew)
|
||||||
|| yold < 0
|
|| yold < 0
|
||||||
|| isWideMove (xold, yold, xnew, ynew) ) )
|
|| 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
|
// 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 )
|
if ( move_time < LONG_DURATION )
|
||||||
return move_buf;
|
return move_buf;
|
||||||
else
|
else
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -603,30 +611,23 @@ int FOptiMove::capDurationToLength (int duration) const
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
int FOptiMove::repeatedAppend ( const Capability& o
|
int FOptiMove::repeatedAppend ( std::string& dst
|
||||||
, int count
|
, const Capability& o
|
||||||
, char* dst ) const
|
, int count ) const
|
||||||
{
|
{
|
||||||
const std::size_t src_len = std::strlen(o.cap);
|
const std::size_t src_len = stringLength(o.cap);
|
||||||
const std::size_t dst_len = ( dst != nullptr ) ? std::strlen(dst) : 0;
|
const std::size_t dst_len = dst.length();
|
||||||
int total{0};
|
int total{0};
|
||||||
|
|
||||||
if ( (dst_len + uInt(count) * src_len) < BUF_SIZE - 1 )
|
if ( (dst_len + uInt(count) * src_len) < BUF_SIZE - 1 )
|
||||||
{
|
{
|
||||||
total += count * o.duration;
|
total += count * o.duration;
|
||||||
|
|
||||||
if ( dst )
|
|
||||||
{
|
|
||||||
dst += dst_len;
|
|
||||||
std::size_t free = BUF_SIZE - dst_len - 2;
|
|
||||||
int cnt = count;
|
int cnt = count;
|
||||||
|
|
||||||
while ( cnt-- > 0 )
|
while ( cnt > 0 )
|
||||||
{
|
{
|
||||||
std::strncpy (dst, o.cap, free);
|
cnt--;
|
||||||
dst += src_len;
|
dst.append(o.cap);
|
||||||
free -= src_len;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
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 from_x, int from_y
|
||||||
, int to_x, int to_y ) const
|
, int to_x, int to_y ) const
|
||||||
{
|
{
|
||||||
int vtime{0};
|
int vtime{0};
|
||||||
int htime{0};
|
int htime{0};
|
||||||
|
|
||||||
if ( move )
|
if ( ! move.empty() )
|
||||||
move[0] = '\0';
|
move.clear();
|
||||||
|
|
||||||
if ( to_y != from_y ) // vertical move
|
if ( to_y != from_y ) // vertical move
|
||||||
{
|
{
|
||||||
|
@ -656,41 +657,30 @@ int FOptiMove::relativeMove ( char move[]
|
||||||
|
|
||||||
if ( to_x != from_x ) // horizontal move
|
if ( to_x != from_x ) // horizontal move
|
||||||
{
|
{
|
||||||
char hmove[BUF_SIZE]{};
|
std::string hmove{};
|
||||||
htime = horizontalMove (hmove, from_x, to_x);
|
htime = horizontalMove (hmove, from_x, to_x);
|
||||||
|
|
||||||
if ( htime >= LONG_DURATION )
|
if ( htime >= LONG_DURATION )
|
||||||
return LONG_DURATION;
|
return LONG_DURATION;
|
||||||
|
|
||||||
if ( move )
|
if ( ! move.empty() )
|
||||||
{
|
move.append(hmove);
|
||||||
if ( *move )
|
|
||||||
std::strncat (move, hmove, BUF_SIZE - std::strlen(move));
|
|
||||||
else
|
else
|
||||||
std::strncpy (move, hmove, BUF_SIZE);
|
move = hmove;
|
||||||
|
|
||||||
move[BUF_SIZE - 1] = '\0';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return vtime + htime;
|
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};
|
int vtime{LONG_DURATION};
|
||||||
|
|
||||||
if ( F_row_address.cap )
|
if ( F_row_address.cap )
|
||||||
{
|
{
|
||||||
if ( move )
|
// Move to fixed row position
|
||||||
{
|
move = FTermcap::encodeParameter(F_row_address.cap, to_y);
|
||||||
std::strncpy ( move
|
|
||||||
, FTermcap::encodeParameter(F_row_address.cap, to_y).data()
|
|
||||||
, BUF_SIZE );
|
|
||||||
move[BUF_SIZE - 1] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
vtime = F_row_address.duration;
|
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
|
, int from_y, int to_y ) const
|
||||||
{
|
{
|
||||||
const int num = to_y - from_y;
|
const int num = to_y - from_y;
|
||||||
|
|
||||||
if ( F_parm_down_cursor.cap && F_parm_down_cursor.duration < vtime )
|
if ( F_parm_down_cursor.cap && F_parm_down_cursor.duration < vtime )
|
||||||
{
|
{
|
||||||
if ( move )
|
move = FTermcap::encodeParameter(F_parm_down_cursor.cap, num);
|
||||||
{
|
|
||||||
std::strncpy ( move
|
|
||||||
, FTermcap::encodeParameter(F_parm_down_cursor.cap, num).data()
|
|
||||||
, BUF_SIZE );
|
|
||||||
move[BUF_SIZE - 1] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
vtime = F_parm_down_cursor.duration;
|
vtime = F_parm_down_cursor.duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( F_cursor_down.cap && (num * F_cursor_down.duration < vtime) )
|
if ( F_cursor_down.cap && (num * F_cursor_down.duration < vtime) )
|
||||||
{
|
{
|
||||||
if ( move )
|
if ( ! move.empty() )
|
||||||
move[0] = '\0';
|
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
|
, int from_y, int to_y ) const
|
||||||
{
|
{
|
||||||
const int num = from_y - to_y;
|
const int num = from_y - to_y;
|
||||||
|
|
||||||
if ( F_parm_up_cursor.cap && F_parm_up_cursor.duration < vtime )
|
if ( F_parm_up_cursor.cap && F_parm_up_cursor.duration < vtime )
|
||||||
{
|
{
|
||||||
if ( move )
|
move = FTermcap::encodeParameter(F_parm_up_cursor.cap, num);
|
||||||
{
|
|
||||||
std::strncpy ( move
|
|
||||||
, FTermcap::encodeParameter(F_parm_up_cursor.cap, num).data()
|
|
||||||
, BUF_SIZE );
|
|
||||||
move[BUF_SIZE - 1] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
vtime = F_parm_up_cursor.duration;
|
vtime = F_parm_up_cursor.duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( F_cursor_up.cap && (num * F_cursor_up.duration < vtime) )
|
if ( F_cursor_up.cap && (num * F_cursor_up.duration < vtime) )
|
||||||
{
|
{
|
||||||
if ( move )
|
if ( ! move.empty() )
|
||||||
move[0] = '\0';
|
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};
|
int htime{LONG_DURATION};
|
||||||
|
|
||||||
if ( F_column_address.cap )
|
if ( F_column_address.cap )
|
||||||
{
|
{
|
||||||
// Move to fixed column position1
|
// Move to fixed column position
|
||||||
std::strncat ( hmove
|
hmove = FTermcap::encodeParameter(F_column_address.cap, to_x);
|
||||||
, FTermcap::encodeParameter(F_column_address.cap, to_x).data()
|
|
||||||
, BUF_SIZE - std::strlen(hmove) - 1 );
|
|
||||||
hmove[BUF_SIZE - 1] = '\0';
|
|
||||||
htime = F_column_address.duration;
|
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 from_x, int to_x ) const
|
||||||
{
|
{
|
||||||
int num = to_x - from_x;
|
int num = to_x - from_x;
|
||||||
|
|
||||||
if ( F_parm_right_cursor.cap && F_parm_right_cursor.duration < htime )
|
if ( F_parm_right_cursor.cap && F_parm_right_cursor.duration < htime )
|
||||||
{
|
{
|
||||||
std::strncpy ( hmove
|
hmove = FTermcap::encodeParameter(F_parm_right_cursor.cap, num);
|
||||||
, FTermcap::encodeParameter(F_parm_right_cursor.cap, num).data()
|
|
||||||
, BUF_SIZE - 1);
|
|
||||||
hmove[BUF_SIZE - 1] = '\0';
|
|
||||||
htime = F_parm_right_cursor.duration;
|
htime = F_parm_right_cursor.duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( F_cursor_right.cap )
|
if ( F_cursor_right.cap )
|
||||||
{
|
{
|
||||||
std::array<char, BUF_SIZE> str{};
|
std::string str{};
|
||||||
int htime_r{0};
|
int htime_r{0};
|
||||||
str[0] = '\0';
|
|
||||||
|
|
||||||
// try to use tab
|
// try to use tab
|
||||||
if ( tabstop > 0 && F_tab.cap )
|
if ( tabstop > 0 && F_tab.cap )
|
||||||
|
@ -814,7 +783,7 @@ inline void FOptiMove::rightMove ( char hmove[], int& htime
|
||||||
if ( tab_pos > to_x )
|
if ( tab_pos > to_x )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
htime_r += repeatedAppend (F_tab, 1, str.data());
|
htime_r += repeatedAppend (str, F_tab, 1);
|
||||||
|
|
||||||
if ( htime_r >= LONG_DURATION )
|
if ( htime_r >= LONG_DURATION )
|
||||||
break;
|
break;
|
||||||
|
@ -825,37 +794,32 @@ inline void FOptiMove::rightMove ( char hmove[], int& htime
|
||||||
num = to_x - pos;
|
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 )
|
if ( htime_r < htime )
|
||||||
{
|
{
|
||||||
std::strncpy (hmove, str.data(), BUF_SIZE);
|
hmove = str;
|
||||||
hmove[BUF_SIZE - 1] = '\0';
|
|
||||||
htime = htime_r;
|
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 from_x, int to_x ) const
|
||||||
{
|
{
|
||||||
int num = from_x - to_x;
|
int num = from_x - to_x;
|
||||||
|
|
||||||
if ( F_parm_left_cursor.cap && F_parm_left_cursor.duration < htime )
|
if ( F_parm_left_cursor.cap && F_parm_left_cursor.duration < htime )
|
||||||
{
|
{
|
||||||
std::strncpy ( hmove
|
hmove = FTermcap::encodeParameter(F_parm_left_cursor.cap, num);
|
||||||
, FTermcap::encodeParameter(F_parm_left_cursor.cap, num).data()
|
|
||||||
, BUF_SIZE - 1);
|
|
||||||
hmove[BUF_SIZE - 1] = '\0';
|
|
||||||
htime = F_parm_left_cursor.duration;
|
htime = F_parm_left_cursor.duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( F_cursor_left.cap )
|
if ( F_cursor_left.cap )
|
||||||
{
|
{
|
||||||
std::array<char, BUF_SIZE> str{};
|
std::string str{};
|
||||||
int htime_l{0};
|
int htime_l{0};
|
||||||
str[0] = '\0';
|
|
||||||
|
|
||||||
// try to use backward tab
|
// try to use backward tab
|
||||||
if ( tabstop > 0 && F_back_tab.cap )
|
if ( tabstop > 0 && F_back_tab.cap )
|
||||||
|
@ -869,7 +833,7 @@ inline void FOptiMove::leftMove ( char hmove[], int& htime
|
||||||
if ( tab_pos < to_x )
|
if ( tab_pos < to_x )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
htime_l += repeatedAppend (F_back_tab, 1, str.data());
|
htime_l += repeatedAppend (str, F_back_tab, 1);
|
||||||
|
|
||||||
if ( htime_l >= LONG_DURATION )
|
if ( htime_l >= LONG_DURATION )
|
||||||
break;
|
break;
|
||||||
|
@ -880,12 +844,11 @@ inline void FOptiMove::leftMove ( char hmove[], int& htime
|
||||||
num = pos - to_x;
|
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 )
|
if ( htime_l < htime )
|
||||||
{
|
{
|
||||||
std::strncpy (hmove, str.data(), BUF_SIZE);
|
hmove = str;
|
||||||
hmove[BUF_SIZE - 1] = '\0';
|
|
||||||
htime = htime_l;
|
htime = htime_l;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -914,9 +877,7 @@ inline bool FOptiMove::isMethod0Faster ( int& move_time
|
||||||
|
|
||||||
if ( ! move_xy.empty() )
|
if ( ! move_xy.empty() )
|
||||||
{
|
{
|
||||||
std::strncpy ( static_cast<char*>(move_buf)
|
move_buf = move_xy;
|
||||||
, move_xy.data(), BUF_SIZE - 1 );
|
|
||||||
move_buf[BUF_SIZE - 1] = '\0';
|
|
||||||
move_time = F_cursor_address.duration;
|
move_time = F_cursor_address.duration;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -933,8 +894,8 @@ inline bool FOptiMove::isMethod1Faster ( int& move_time
|
||||||
|
|
||||||
if ( xold >= 0 && yold >= 0 )
|
if ( xold >= 0 && yold >= 0 )
|
||||||
{
|
{
|
||||||
std::array<char, BUF_SIZE> null_result{};
|
std::string null_result{};
|
||||||
const int new_time = relativeMove (null_result.data(), xold, yold, xnew, ynew);
|
const int new_time = relativeMove (null_result, xold, yold, xnew, ynew);
|
||||||
|
|
||||||
if ( new_time < LONG_DURATION && new_time < move_time )
|
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 )
|
if ( yold >= 0 && F_carriage_return.cap )
|
||||||
{
|
{
|
||||||
std::array<char, BUF_SIZE> null_result{};
|
std::string null_result{};
|
||||||
const int new_time = relativeMove (null_result.data(), 0, yold, xnew, ynew);
|
const int new_time = relativeMove (null_result, 0, yold, xnew, ynew);
|
||||||
|
|
||||||
if ( new_time < LONG_DURATION
|
if ( new_time < LONG_DURATION
|
||||||
&& F_carriage_return.duration + new_time < move_time )
|
&& F_carriage_return.duration + new_time < move_time )
|
||||||
|
@ -977,8 +938,8 @@ inline bool FOptiMove::isMethod3Faster ( int& move_time
|
||||||
|
|
||||||
if ( F_cursor_home.cap )
|
if ( F_cursor_home.cap )
|
||||||
{
|
{
|
||||||
std::array<char, BUF_SIZE> null_result{};
|
std::string null_result{};
|
||||||
const int new_time = relativeMove (null_result.data(), 0, 0, xnew, ynew);
|
const int new_time = relativeMove (null_result, 0, 0, xnew, ynew);
|
||||||
|
|
||||||
if ( new_time < LONG_DURATION
|
if ( new_time < LONG_DURATION
|
||||||
&& F_cursor_home.duration + new_time < move_time )
|
&& 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
|
// Test method 4: home-down + local movement
|
||||||
if ( F_cursor_to_ll.cap )
|
if ( F_cursor_to_ll.cap )
|
||||||
{
|
{
|
||||||
std::array<char, BUF_SIZE> null_result{};
|
std::string null_result{};
|
||||||
const int new_time = relativeMove ( null_result.data()
|
int down = int(screen_height) - 1;
|
||||||
, 0, int(screen_height) - 1
|
const int new_time = relativeMove (null_result, 0, down, xnew, ynew);
|
||||||
, xnew, ynew );
|
|
||||||
|
|
||||||
if ( new_time < LONG_DURATION
|
if ( new_time < LONG_DURATION
|
||||||
&& F_cursor_to_ll.duration + new_time < move_time )
|
&& F_cursor_to_ll.duration + new_time < move_time )
|
||||||
|
@ -1025,10 +985,10 @@ inline bool FOptiMove::isMethod5Faster ( int& move_time
|
||||||
&& yold > 0
|
&& yold > 0
|
||||||
&& F_cursor_left.cap )
|
&& F_cursor_left.cap )
|
||||||
{
|
{
|
||||||
std::array<char, BUF_SIZE> null_result{};
|
std::string null_result{};
|
||||||
const int new_time = relativeMove ( null_result.data()
|
int x = int(screen_width) - 1;
|
||||||
, int(screen_width) - 1, yold - 1
|
int y = yold - 1;
|
||||||
, xnew, ynew );
|
const int new_time = relativeMove (null_result, x, y, xnew, ynew);
|
||||||
|
|
||||||
if ( new_time < LONG_DURATION
|
if ( new_time < LONG_DURATION
|
||||||
&& F_carriage_return.cap
|
&& F_carriage_return.cap
|
||||||
|
@ -1037,7 +997,6 @@ inline bool FOptiMove::isMethod5Faster ( int& move_time
|
||||||
{
|
{
|
||||||
move_time = F_carriage_return.duration
|
move_time = F_carriage_return.duration
|
||||||
+ F_cursor_left.duration + new_time;
|
+ F_cursor_left.duration + new_time;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1050,52 +1009,55 @@ void FOptiMove::moveByMethod ( int method
|
||||||
, int xold, int yold
|
, int xold, int yold
|
||||||
, int xnew, int ynew )
|
, int xnew, int ynew )
|
||||||
{
|
{
|
||||||
char* move_ptr = move_buf;
|
|
||||||
|
|
||||||
switch ( method )
|
switch ( method )
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
relativeMove (move_ptr, xold, yold, xnew, ynew);
|
relativeMove (move_buf, xold, yold, xnew, ynew);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
if ( F_carriage_return.cap )
|
if ( F_carriage_return.cap )
|
||||||
{
|
{
|
||||||
std::strncpy (move_ptr, F_carriage_return.cap, BUF_SIZE - 1);
|
move_buf = F_carriage_return.cap;
|
||||||
move_ptr[BUF_SIZE - 1] ='\0';
|
std::string s{};
|
||||||
move_ptr += F_carriage_return.length;
|
relativeMove (s, 0, yold, xnew, ynew);
|
||||||
relativeMove (move_ptr, 0, yold, xnew, ynew);
|
move_buf.append(s);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
std::strncpy (move_ptr, F_cursor_home.cap, BUF_SIZE - 1);
|
move_buf = F_cursor_home.cap;
|
||||||
move_ptr[BUF_SIZE - 1] ='\0';
|
{
|
||||||
move_ptr += F_cursor_home.length;
|
std::string s{};
|
||||||
relativeMove (move_ptr, 0, 0, xnew, ynew);
|
relativeMove (s, 0, 0, xnew, ynew);
|
||||||
|
move_buf.append(s);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
std::strncpy (move_ptr, F_cursor_to_ll.cap, BUF_SIZE - 1);
|
move_buf = F_cursor_to_ll.cap;
|
||||||
move_ptr[BUF_SIZE - 1] ='\0';
|
{
|
||||||
move_ptr += F_cursor_to_ll.length;
|
std::string s{};
|
||||||
relativeMove (move_ptr, 0, int(screen_height) - 1, xnew, ynew);
|
int down = int(screen_height) - 1;
|
||||||
|
relativeMove (s, 0, down, xnew, ynew);
|
||||||
|
move_buf.append(s);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
move_buf[0] = '\0';
|
|
||||||
|
|
||||||
if ( xold >= 0 )
|
if ( xold >= 0 )
|
||||||
std::strncat ( move_ptr
|
move_buf = F_carriage_return.cap;
|
||||||
, F_carriage_return.cap
|
else
|
||||||
, BUF_SIZE - std::strlen(move_ptr) - 1 );
|
move_buf.clear();
|
||||||
|
|
||||||
std::strncat ( move_ptr
|
move_buf.append(F_cursor_left.cap);
|
||||||
, F_cursor_left.cap
|
{
|
||||||
, BUF_SIZE - std::strlen(move_ptr) - 1);
|
std::string s{};
|
||||||
move_ptr[BUF_SIZE - 1] ='\0';
|
int x = int(screen_width) - 1;
|
||||||
move_ptr += std::strlen(move_buf);
|
int y = yold - 1;
|
||||||
relativeMove (move_ptr, int(screen_width) - 1, yold - 1, xnew, ynew);
|
relativeMove (s, x, y, xnew, ynew);
|
||||||
|
move_buf.append(s);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* *
|
* *
|
||||||
* This file is part of the FINAL CUT widget toolkit *
|
* 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 *
|
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU Lesser General Public License as *
|
* it under the terms of the GNU Lesser General Public License as *
|
||||||
|
@ -54,7 +54,7 @@ FStartOptions::FStartOptions()
|
||||||
|
|
||||||
// public methods of FStartOptions
|
// public methods of FStartOptions
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FStartOptions& FStartOptions::getFStartOptions()
|
auto FStartOptions::getInstance() -> FStartOptions&
|
||||||
{
|
{
|
||||||
static const auto& start_options = make_unique<FStartOptions>();
|
static const auto& start_options = make_unique<FStartOptions>();
|
||||||
return *start_options;
|
return *start_options;
|
||||||
|
|
793
src/fstring.cpp
793
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 *
|
* 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 *
|
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU Lesser General Public License as *
|
* it under the terms of the GNU Lesser General Public License as *
|
||||||
|
@ -21,6 +21,7 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
#include "final/fsystem.h"
|
#include "final/fsystem.h"
|
||||||
|
#include "final/fsystemimpl.h"
|
||||||
|
|
||||||
namespace finalcut
|
namespace finalcut
|
||||||
{
|
{
|
||||||
|
@ -33,5 +34,14 @@ namespace finalcut
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FSystem::~FSystem() noexcept = default; // destructor
|
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
|
} // 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
|
// Constant
|
||||||
constexpr std::size_t NOT_FOUND = static_cast<std::size_t>(-1);
|
constexpr std::size_t NOT_FOUND = static_cast<std::size_t>(-1);
|
||||||
|
|
||||||
// global state
|
|
||||||
static FullWidthSupport has_fullwidth_support = FullWidthSupport::Unknown;
|
|
||||||
|
|
||||||
// Function prototypes
|
// Function prototypes
|
||||||
bool hasAmbiguousWidth (wchar_t);
|
bool hasAmbiguousWidth (wchar_t);
|
||||||
|
|
||||||
|
@ -199,9 +196,9 @@ constexpr std::array<UniChar, 20> reverse_newfont_list =
|
||||||
|
|
||||||
// FTerm non-member functions
|
// 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() )
|
if ( str.isEmpty() )
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -259,6 +256,9 @@ bool hasFullWidthSupports()
|
||||||
{
|
{
|
||||||
// Checks if the terminal has full-width character support
|
// 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 ( has_fullwidth_support == FullWidthSupport::Unknown )
|
||||||
{
|
{
|
||||||
if ( ! FTerm::isInitialized() )
|
if ( ! FTerm::isInitialized() )
|
||||||
|
@ -284,15 +284,16 @@ wchar_t cp437_to_unicode (uChar c)
|
||||||
{
|
{
|
||||||
constexpr std::size_t CP437 = 0;
|
constexpr std::size_t CP437 = 0;
|
||||||
constexpr std::size_t UNICODE = 1;
|
constexpr std::size_t UNICODE = 1;
|
||||||
|
const auto& cp437_ucs = FCharMap::getCP437UCSMap();
|
||||||
wchar_t ucs = c;
|
wchar_t ucs = c;
|
||||||
auto found = std::find_if ( fc::cp437_ucs.begin()
|
auto found = std::find_if ( cp437_ucs.begin()
|
||||||
, fc::cp437_ucs.end()
|
, cp437_ucs.end()
|
||||||
, [&c] (const std::array<wchar_t, 2>& entry)
|
, [&c] (const std::array<wchar_t, 2>& entry)
|
||||||
{
|
{
|
||||||
return entry[CP437] == c;
|
return entry[CP437] == c;
|
||||||
} );
|
} );
|
||||||
|
|
||||||
if ( found != fc::cp437_ucs.end() )
|
if ( found != cp437_ucs.end() )
|
||||||
ucs = (*found)[UNICODE];
|
ucs = (*found)[UNICODE];
|
||||||
|
|
||||||
return ucs;
|
return ucs;
|
||||||
|
@ -303,16 +304,16 @@ uChar unicode_to_cp437 (wchar_t ucs)
|
||||||
{
|
{
|
||||||
constexpr std::size_t CP437 = 0;
|
constexpr std::size_t CP437 = 0;
|
||||||
constexpr std::size_t UNICODE = 1;
|
constexpr std::size_t UNICODE = 1;
|
||||||
|
const auto& cp437_ucs = FCharMap::getCP437UCSMap();
|
||||||
uChar c{'?'};
|
uChar c{'?'};
|
||||||
|
auto found = std::find_if ( cp437_ucs.begin()
|
||||||
auto found = std::find_if ( fc::cp437_ucs.begin()
|
, cp437_ucs.end()
|
||||||
, fc::cp437_ucs.end()
|
|
||||||
, [&ucs] (const std::array<wchar_t, 2>& entry)
|
, [&ucs] (const std::array<wchar_t, 2>& entry)
|
||||||
{
|
{
|
||||||
return entry[UNICODE] == ucs;
|
return entry[UNICODE] == ucs;
|
||||||
} );
|
} );
|
||||||
|
|
||||||
if ( found != fc::cp437_ucs.end() )
|
if ( found != cp437_ucs.end() )
|
||||||
c = static_cast<uChar>((*found)[CP437]);
|
c = static_cast<uChar>((*found)[CP437]);
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
|
@ -326,16 +327,17 @@ FString getFullWidth (const FString& str)
|
||||||
FString s{str};
|
FString s{str};
|
||||||
auto table_search = [] (wchar_t& c)
|
auto table_search = [] (wchar_t& c)
|
||||||
{
|
{
|
||||||
|
const auto& halfwidth_fullwidth = FCharMap::getHalfFullWidthMap();
|
||||||
constexpr std::size_t HALF = 0;
|
constexpr std::size_t HALF = 0;
|
||||||
constexpr std::size_t FULL = 1;
|
constexpr std::size_t FULL = 1;
|
||||||
auto found = std::find_if ( fc::halfwidth_fullwidth.begin()
|
auto found = std::find_if ( halfwidth_fullwidth.begin()
|
||||||
, fc::halfwidth_fullwidth.end()
|
, halfwidth_fullwidth.end()
|
||||||
, [&c] (const std::array<wchar_t, 2>& entry)
|
, [&c] (const std::array<wchar_t, 2>& entry)
|
||||||
{
|
{
|
||||||
return entry[HALF] == c;
|
return entry[HALF] == c;
|
||||||
} );
|
} );
|
||||||
|
|
||||||
if ( found != fc::halfwidth_fullwidth.end() )
|
if ( found != halfwidth_fullwidth.end() )
|
||||||
c = (*found)[FULL];
|
c = (*found)[FULL];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -358,16 +360,17 @@ FString getHalfWidth (const FString& str)
|
||||||
FString s{str};
|
FString s{str};
|
||||||
auto table_search = [] (wchar_t& c)
|
auto table_search = [] (wchar_t& c)
|
||||||
{
|
{
|
||||||
|
const auto& halfwidth_fullwidth = FCharMap::getHalfFullWidthMap();
|
||||||
constexpr std::size_t HALF = 0;
|
constexpr std::size_t HALF = 0;
|
||||||
constexpr std::size_t FULL = 1;
|
constexpr std::size_t FULL = 1;
|
||||||
auto found = std::find_if ( fc::halfwidth_fullwidth.begin()
|
auto found = std::find_if ( halfwidth_fullwidth.begin()
|
||||||
, fc::halfwidth_fullwidth.end()
|
, halfwidth_fullwidth.end()
|
||||||
, [&c] (const std::array<wchar_t, 2>& entry)
|
, [&c] (const std::array<wchar_t, 2>& entry)
|
||||||
{
|
{
|
||||||
return entry[FULL] == c;
|
return entry[FULL] == c;
|
||||||
} );
|
} );
|
||||||
|
|
||||||
if ( found != fc::halfwidth_fullwidth.end() )
|
if ( found != halfwidth_fullwidth.end() )
|
||||||
c = (*found)[HALF];
|
c = (*found)[HALF];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -689,10 +692,10 @@ FPoint readCursorPos()
|
||||||
const int stdout_no{FTermios::getStdOut()};
|
const int stdout_no{FTermios::getStdOut()};
|
||||||
fd_set ifds{};
|
fd_set ifds{};
|
||||||
struct timeval tv{};
|
struct timeval tv{};
|
||||||
constexpr auto& DECXCPR{ESC "[6n"};
|
const std::string DECXCPR{ESC "[6n"};
|
||||||
|
|
||||||
// Report Cursor Position (DECXCPR)
|
// 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};
|
return {x, y};
|
||||||
|
|
||||||
std::fflush(stdout);
|
std::fflush(stdout);
|
||||||
|
|
|
@ -66,7 +66,6 @@ FString FTermBuffer::toString() const
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
int FTermBuffer::write (const FString& string)
|
int FTermBuffer::write (const FString& string)
|
||||||
{
|
{
|
||||||
assert ( ! string.isNull() );
|
|
||||||
data.reserve(data.size() + string.getLength());
|
data.reserve(data.size() + string.getLength());
|
||||||
const auto last = string.end();
|
const auto last = string.end();
|
||||||
auto begin = string.begin();
|
auto begin = string.begin();
|
||||||
|
@ -152,7 +151,7 @@ void FTermBuffer::write (const FColorPair& pair) const
|
||||||
// private methods of FTermBuffer
|
// private methods of FTermBuffer
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermBuffer::add ( FString::const_iterator& begin
|
void FTermBuffer::add ( FString::const_iterator& begin
|
||||||
, FString::const_iterator& end
|
, const FString::const_iterator& end
|
||||||
, int& char_width )
|
, int& char_width )
|
||||||
{
|
{
|
||||||
if ( begin == end )
|
if ( begin == end )
|
||||||
|
|
|
@ -251,8 +251,8 @@ void FTermcap::termcap()
|
||||||
static char term_buffer[BUF_SIZE]{};
|
static char term_buffer[BUF_SIZE]{};
|
||||||
std::vector<std::string> terminals{};
|
std::vector<std::string> terminals{};
|
||||||
int status = uninitialized;
|
int status = uninitialized;
|
||||||
auto& fterm_data = FTerm::getFTermData();
|
auto& fterm_data = FTermData::getInstance();
|
||||||
const auto& term_detection = FTerm::getFTermDetection();
|
const auto& term_detection = FTermDetection::getInstance();
|
||||||
const bool color256 = term_detection.canDisplay256Colors();
|
const bool color256 = term_detection.canDisplay256Colors();
|
||||||
baudrate = int(fterm_data.getBaudrate());
|
baudrate = int(fterm_data.getBaudrate());
|
||||||
|
|
||||||
|
@ -301,7 +301,7 @@ void FTermcap::termcapError (int status)
|
||||||
|
|
||||||
if ( status == no_entry || status == uninitialized )
|
if ( status == no_entry || status == uninitialized )
|
||||||
{
|
{
|
||||||
const auto& termtype = FTerm::getFTermData().getTermType();
|
const auto& termtype = FTermData::getInstance().getTermType();
|
||||||
std::clog << FLog::LogLevel::Error
|
std::clog << FLog::LogLevel::Error
|
||||||
<< "Unknown terminal: \"" << termtype << "\". "
|
<< "Unknown terminal: \"" << termtype << "\". "
|
||||||
<< "Check the TERM environment variable. "
|
<< "Check the TERM environment variable. "
|
||||||
|
@ -376,7 +376,7 @@ void FTermcap::termcapNumerics()
|
||||||
{
|
{
|
||||||
// Get termcap numerics
|
// Get termcap numerics
|
||||||
|
|
||||||
auto& fterm_data = FTerm::getFTermData();
|
auto& fterm_data = FTermData::getInstance();
|
||||||
|
|
||||||
// Maximum number of colors on screen
|
// Maximum number of colors on screen
|
||||||
max_color = std::max(max_color, getNumber("Co"));
|
max_color = std::max(max_color, getNumber("Co"));
|
||||||
|
@ -426,7 +426,7 @@ void FTermcap::termcapKeys()
|
||||||
// Get termcap keys
|
// Get termcap keys
|
||||||
|
|
||||||
// Read termcap key sequences up to the self-defined values
|
// 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
|
if ( entry.string != nullptr ) // String is already set
|
||||||
break;
|
break;
|
||||||
|
@ -437,10 +437,8 @@ void FTermcap::termcapKeys()
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
std::string FTermcap::encodeParams ( const std::string& cap
|
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]
|
auto str = ::tparm ( C_STR(cap.data()), params[0], params[1]
|
||||||
, params[2], params[3], params[4], params[5]
|
, params[2], params[3], params[4], params[5]
|
||||||
, params[6], params[7], params[8] );
|
, params[6], params[7], params[8] );
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace finalcut
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermcapQuirks::terminalFixup()
|
void FTermcapQuirks::terminalFixup()
|
||||||
{
|
{
|
||||||
const auto& td = FTerm::getFTermDetection();
|
const auto& td = FTermDetection::getInstance();
|
||||||
|
|
||||||
if ( td.isCygwinTerminal() )
|
if ( td.isCygwinTerminal() )
|
||||||
{
|
{
|
||||||
|
@ -228,7 +228,7 @@ void FTermcapQuirks::xterm()
|
||||||
void FTermcapQuirks::rxvt()
|
void FTermcapQuirks::rxvt()
|
||||||
{
|
{
|
||||||
// Set enter/exit alternative charset mode for rxvt terminal
|
// 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" )
|
if ( termtype.substr(0,12) == "rxvt-16color" )
|
||||||
{
|
{
|
||||||
|
@ -237,7 +237,7 @@ void FTermcapQuirks::rxvt()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set ansi foreground and background color
|
// Set ansi foreground and background color
|
||||||
if ( ! FTerm::getFTermDetection().isUrxvtTerminal() )
|
if ( ! FTermDetection::getInstance().isUrxvtTerminal() )
|
||||||
{
|
{
|
||||||
TCAP(t_set_a_foreground) = \
|
TCAP(t_set_a_foreground) = \
|
||||||
CSI "%?%p1%{8}%<%t%p1%{30}%+%e%p1%'R'%+%;%dm";
|
CSI "%?%p1%{8}%<%t%p1%{30}%+%e%p1%'R'%+%;%dm";
|
||||||
|
@ -249,7 +249,7 @@ void FTermcapQuirks::rxvt()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermcapQuirks::vte()
|
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
|
// gnome-terminal has NC=16 however, it can use the dim attribute
|
||||||
FTermcap::attr_without_color = 0;
|
FTermcap::attr_without_color = 0;
|
||||||
|
@ -370,73 +370,74 @@ void FTermcapQuirks::sunConsole()
|
||||||
TCAP(t_parm_down_cursor) = CSI "%p1%dB";
|
TCAP(t_parm_down_cursor) = CSI "%p1%dB";
|
||||||
TCAP(t_parm_right_cursor) = CSI "%p1%dC";
|
TCAP(t_parm_right_cursor) = CSI "%p1%dC";
|
||||||
TCAP(t_parm_left_cursor) = CSI "%p1%dD";
|
TCAP(t_parm_left_cursor) = CSI "%p1%dD";
|
||||||
|
auto& fkey_cap_table = FKeyMap::getKeyCapMap();
|
||||||
|
|
||||||
// Sun Microsystems workstation console keys
|
// 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 )
|
if ( std::strncmp(fkey_cap_table[i].tname, "K2", 2) == 0 )
|
||||||
fc::fkey_cap_table[i].string = CSI "218z"; // center of keypad
|
fkey_cap_table[i].string = CSI "218z"; // center of keypad
|
||||||
|
|
||||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "kb", 2) == 0 )
|
if ( std::strncmp(fkey_cap_table[i].tname, "kb", 2) == 0 )
|
||||||
fc::fkey_cap_table[i].string = "\b"; // backspace key
|
fkey_cap_table[i].string = "\b"; // backspace key
|
||||||
|
|
||||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "kD", 2) == 0
|
if ( std::strncmp(fkey_cap_table[i].tname, "kD", 2) == 0
|
||||||
&& std::strlen(fc::fkey_cap_table[i].tname) == 2 )
|
&& stringLength(fkey_cap_table[i].tname) == 2 )
|
||||||
fc::fkey_cap_table[i].string = "\177"; // delete-character key
|
fkey_cap_table[i].string = "\177"; // delete-character key
|
||||||
|
|
||||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "@7", 2) == 0 )
|
if ( std::strncmp(fkey_cap_table[i].tname, "@7", 2) == 0 )
|
||||||
fc::fkey_cap_table[i].string = CSI "220z"; // end key
|
fkey_cap_table[i].string = CSI "220z"; // end key
|
||||||
|
|
||||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "k;", 2) == 0 )
|
if ( std::strncmp(fkey_cap_table[i].tname, "k;", 2) == 0 )
|
||||||
fc::fkey_cap_table[i].string = CSI "233z"; // F10 function key
|
fkey_cap_table[i].string = CSI "233z"; // F10 function key
|
||||||
|
|
||||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "F1", 2) == 0 )
|
if ( std::strncmp(fkey_cap_table[i].tname, "F1", 2) == 0 )
|
||||||
fc::fkey_cap_table[i].string = CSI "234z"; // F11 function key
|
fkey_cap_table[i].string = CSI "234z"; // F11 function key
|
||||||
|
|
||||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "F2", 2) == 0 )
|
if ( std::strncmp(fkey_cap_table[i].tname, "F2", 2) == 0 )
|
||||||
fc::fkey_cap_table[i].string = CSI "235z"; // F12 function key
|
fkey_cap_table[i].string = CSI "235z"; // F12 function key
|
||||||
|
|
||||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "kh", 2) == 0 )
|
if ( std::strncmp(fkey_cap_table[i].tname, "kh", 2) == 0 )
|
||||||
fc::fkey_cap_table[i].string = CSI "214z"; // home key
|
fkey_cap_table[i].string = CSI "214z"; // home key
|
||||||
|
|
||||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "kI", 2) == 0 )
|
if ( std::strncmp(fkey_cap_table[i].tname, "kI", 2) == 0 )
|
||||||
fc::fkey_cap_table[i].string = CSI "247z"; // insert-character key
|
fkey_cap_table[i].string = CSI "247z"; // insert-character key
|
||||||
|
|
||||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "kN", 2) == 0 )
|
if ( std::strncmp(fkey_cap_table[i].tname, "kN", 2) == 0 )
|
||||||
fc::fkey_cap_table[i].string = CSI "222z"; // next-page key
|
fkey_cap_table[i].string = CSI "222z"; // next-page key
|
||||||
|
|
||||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "%7", 2) == 0 )
|
if ( std::strncmp(fkey_cap_table[i].tname, "%7", 2) == 0 )
|
||||||
fc::fkey_cap_table[i].string = CSI "194z"; // options key
|
fkey_cap_table[i].string = CSI "194z"; // options key
|
||||||
|
|
||||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "kP", 2) == 0 )
|
if ( std::strncmp(fkey_cap_table[i].tname, "kP", 2) == 0 )
|
||||||
fc::fkey_cap_table[i].string = CSI "216z"; // prev-page key
|
fkey_cap_table[i].string = CSI "216z"; // prev-page key
|
||||||
|
|
||||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "&5", 2) == 0 )
|
if ( std::strncmp(fkey_cap_table[i].tname, "&5", 2) == 0 )
|
||||||
fc::fkey_cap_table[i].string = CSI "193z"; // resume key
|
fkey_cap_table[i].string = CSI "193z"; // resume key
|
||||||
|
|
||||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "&8", 2) == 0 )
|
if ( std::strncmp(fkey_cap_table[i].tname, "&8", 2) == 0 )
|
||||||
fc::fkey_cap_table[i].string = CSI "195z"; // undo key
|
fkey_cap_table[i].string = CSI "195z"; // undo key
|
||||||
|
|
||||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "K2", 2) == 0 )
|
if ( std::strncmp(fkey_cap_table[i].tname, "K2", 2) == 0 )
|
||||||
fc::fkey_cap_table[i].string = CSI "218z"; // center of keypad
|
fkey_cap_table[i].string = CSI "218z"; // center of keypad
|
||||||
|
|
||||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "kDx", 3) == 0 )
|
if ( std::strncmp(fkey_cap_table[i].tname, "kDx", 3) == 0 )
|
||||||
fc::fkey_cap_table[i].string = CSI "249z"; // keypad delete
|
fkey_cap_table[i].string = CSI "249z"; // keypad delete
|
||||||
|
|
||||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "@8x", 3) == 0 )
|
if ( std::strncmp(fkey_cap_table[i].tname, "@8x", 3) == 0 )
|
||||||
fc::fkey_cap_table[i].string = CSI "250z"; // enter/send key
|
fkey_cap_table[i].string = CSI "250z"; // enter/send key
|
||||||
|
|
||||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "KP1", 3) == 0 )
|
if ( std::strncmp(fkey_cap_table[i].tname, "KP1", 3) == 0 )
|
||||||
fc::fkey_cap_table[i].string = CSI "212z"; // keypad slash
|
fkey_cap_table[i].string = CSI "212z"; // keypad slash
|
||||||
|
|
||||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "KP2", 3) == 0 )
|
if ( std::strncmp(fkey_cap_table[i].tname, "KP2", 3) == 0 )
|
||||||
fc::fkey_cap_table[i].string = CSI "213z"; // keypad asterisk
|
fkey_cap_table[i].string = CSI "213z"; // keypad asterisk
|
||||||
|
|
||||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "KP3", 3) == 0 )
|
if ( std::strncmp(fkey_cap_table[i].tname, "KP3", 3) == 0 )
|
||||||
fc::fkey_cap_table[i].string = CSI "254z"; // keypad minus sign
|
fkey_cap_table[i].string = CSI "254z"; // keypad minus sign
|
||||||
|
|
||||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "KP4", 3) == 0 )
|
if ( std::strncmp(fkey_cap_table[i].tname, "KP4", 3) == 0 )
|
||||||
fc::fkey_cap_table[i].string = CSI "253z"; // keypad plus sign
|
fkey_cap_table[i].string = CSI "253z"; // keypad plus sign
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,7 +449,7 @@ void FTermcapQuirks::screen()
|
||||||
{
|
{
|
||||||
FTermcap::can_change_color_palette = true;
|
FTermcap::can_change_color_palette = true;
|
||||||
|
|
||||||
if ( FTerm::getFTermDetection().isTmuxTerm() )
|
if ( FTermDetection::getInstance().isTmuxTerm() )
|
||||||
{
|
{
|
||||||
TCAP(t_initialize_color) = \
|
TCAP(t_initialize_color) = \
|
||||||
ESC "Ptmux;" ESC OSC "4;%p1%d;rgb:"
|
ESC "Ptmux;" ESC OSC "4;%p1%d;rgb:"
|
||||||
|
|
|
@ -36,38 +36,45 @@ namespace finalcut
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
// public methods of FTermDebugData
|
// public methods of FTermDebugData
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
auto FTermDebugData::getInstance() -> FTermDebugData&
|
||||||
|
{
|
||||||
|
static const auto& debug_data = make_unique<FTermDebugData>();
|
||||||
|
return *debug_data;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString& FTermDebugData::getAnswerbackString()
|
const FString& FTermDebugData::getAnswerbackString()
|
||||||
{
|
{
|
||||||
auto& term_detection = FTerm::getFTermDetection();
|
auto& term_detection = FTermDetection::getInstance();
|
||||||
return term_detection.getAnswerbackString();
|
return term_detection.getAnswerbackString();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const FString& FTermDebugData::getSecDAString()
|
const FString& FTermDebugData::getSecDAString()
|
||||||
{
|
{
|
||||||
auto& term_detection = FTerm::getFTermDetection();
|
auto& term_detection = FTermDetection::getInstance();
|
||||||
return term_detection.getSecDAString();
|
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();
|
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();
|
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();
|
return term_detection.getTermType_SecDA();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +82,7 @@ const char* FTermDebugData::getTermType_SecDA()
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
int FTermDebugData::getFramebufferBpp()
|
int FTermDebugData::getFramebufferBpp()
|
||||||
{
|
{
|
||||||
auto& fterm_data = FTerm::getFTermData();
|
auto& fterm_data = FTermData::getInstance();
|
||||||
return fterm_data.getFramebufferBpp();
|
return fterm_data.getFramebufferBpp();
|
||||||
}
|
}
|
||||||
#endif // defined(__linux__)
|
#endif // defined(__linux__)
|
||||||
|
|
|
@ -50,88 +50,52 @@
|
||||||
namespace finalcut
|
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
|
// class FTermDetection
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
// constructors and destructor
|
// constructors and destructor
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FTermDetection::FTermDetection()
|
FTermDetection::FTermDetection() = default;
|
||||||
{
|
|
||||||
// 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() // destructor
|
FTermDetection::~FTermDetection() = default; // destructor
|
||||||
{
|
|
||||||
deallocation();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// public methods of FTermDetection
|
// public methods of FTermDetection
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
#if DEBUG
|
auto FTermDetection::getInstance() -> FTermDetection&
|
||||||
const FString& FTermDetection::getAnswerbackString()
|
|
||||||
{
|
{
|
||||||
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
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermDetection::setTtyTypeFileName (const char ttytype_filename[])
|
void FTermDetection::setTtyTypeFileName (const FString& ttytype_filename)
|
||||||
{
|
{
|
||||||
if ( ! ttytype_filename )
|
if ( ! ttytype_filename )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::strncpy (ttytypename, ttytype_filename, sizeof(ttytypename));
|
ttytypename = ttytype_filename;
|
||||||
ttytypename[sizeof(ttytypename) - 1] = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermDetection::detect()
|
void FTermDetection::detect()
|
||||||
{
|
{
|
||||||
deallocation();
|
|
||||||
|
|
||||||
// Set the variable 'termtype' to the predefined type of the terminal
|
// Set the variable 'termtype' to the predefined type of the terminal
|
||||||
getSystemTermType();
|
getSystemTermType();
|
||||||
|
|
||||||
|
@ -144,28 +108,17 @@ void FTermDetection::detect()
|
||||||
|
|
||||||
|
|
||||||
// private methods of FTermDetection
|
// private methods of FTermDetection
|
||||||
//----------------------------------------------------------------------
|
|
||||||
void FTermDetection::deallocation()
|
|
||||||
{
|
|
||||||
if ( sec_da )
|
|
||||||
delete sec_da;
|
|
||||||
|
|
||||||
if ( answer_back )
|
|
||||||
delete answer_back;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermDetection::getSystemTermType()
|
void FTermDetection::getSystemTermType()
|
||||||
{
|
{
|
||||||
// Import the untrusted environment variable TERM
|
// Import the untrusted environment variable TERM
|
||||||
const auto& term_env = std::getenv("TERM");
|
const auto& term_env = std::getenv("TERM");
|
||||||
const auto& termfilename = FTerm::getFTermData().getTermFileName();
|
const auto& termfilename = FTermData::getInstance().getTermFileName();
|
||||||
|
|
||||||
if ( term_env )
|
if ( term_env )
|
||||||
{
|
{
|
||||||
// Save name in termtype
|
// Save name in termtype
|
||||||
std::strncpy (termtype, term_env, sizeof(termtype));
|
termtype = term_env;
|
||||||
termtype[sizeof(termtype) - 1] = '\0';
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if ( ! termfilename.empty() ) // 1st fallback: use the teminal file name
|
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
|
// 2nd fallback: use vt100 if not found
|
||||||
std::strncpy (termtype, "vt100", sizeof(termtype));
|
termtype = "vt100";
|
||||||
termtype[sizeof(termtype) - 1] = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -197,7 +149,7 @@ bool FTermDetection::getTTYtype()
|
||||||
// vt100 ttys0
|
// vt100 ttys0
|
||||||
|
|
||||||
// Get term basename
|
// Get term basename
|
||||||
const auto& termfilename = FTerm::getFTermData().getTermFileName();
|
const auto& termfilename = FTermData::getInstance().getTermFileName();
|
||||||
const char* term_basename = std::strrchr(termfilename.data(), '/');
|
const char* term_basename = std::strrchr(termfilename.data(), '/');
|
||||||
|
|
||||||
if ( term_basename == nullptr )
|
if ( term_basename == nullptr )
|
||||||
|
@ -207,9 +159,9 @@ bool FTermDetection::getTTYtype()
|
||||||
|
|
||||||
std::FILE* fp{};
|
std::FILE* fp{};
|
||||||
std::array<char, BUFSIZ> str{};
|
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;
|
return false;
|
||||||
|
|
||||||
// Read and parse the file
|
// Read and parse the file
|
||||||
|
@ -234,8 +186,7 @@ bool FTermDetection::getTTYtype()
|
||||||
if ( type != nullptr && name != nullptr && ! std::strcmp(name, term_basename) )
|
if ( type != nullptr && name != nullptr && ! std::strcmp(name, term_basename) )
|
||||||
{
|
{
|
||||||
// Save name in termtype
|
// Save name in termtype
|
||||||
std::strncpy (termtype, type, sizeof(termtype));
|
termtype = type;
|
||||||
termtype[sizeof(termtype) - 1] = '\0';
|
|
||||||
fsystem->fclose(fp);
|
fsystem->fclose(fp);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -252,7 +203,7 @@ bool FTermDetection::getTTYSFileEntry()
|
||||||
// Analyse /etc/ttys and get the term name
|
// Analyse /etc/ttys and get the term name
|
||||||
|
|
||||||
// get term basename
|
// get term basename
|
||||||
const auto& termfilename = FTerm::getFTermData().getTermFileName();
|
const auto& termfilename = FTermData::getInstance().getTermFileName();
|
||||||
const char* term_basename = std::strrchr(termfilename.data(), '/');
|
const char* term_basename = std::strrchr(termfilename.data(), '/');
|
||||||
|
|
||||||
if ( term_basename == nullptr )
|
if ( term_basename == nullptr )
|
||||||
|
@ -270,8 +221,7 @@ bool FTermDetection::getTTYSFileEntry()
|
||||||
if ( type != nullptr )
|
if ( type != nullptr )
|
||||||
{
|
{
|
||||||
// Save name in termtype
|
// Save name in termtype
|
||||||
std::strncpy (termtype, type, sizeof(termtype));
|
termtype = type;
|
||||||
termtype[sizeof(termtype) - 1] = '\0';
|
|
||||||
endttyent();
|
endttyent();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -286,67 +236,67 @@ bool FTermDetection::getTTYSFileEntry()
|
||||||
void FTermDetection::termtypeAnalysis()
|
void FTermDetection::termtypeAnalysis()
|
||||||
{
|
{
|
||||||
// Cygwin console
|
// Cygwin console
|
||||||
if ( std::strncmp(termtype, "cygwin", 6) == 0 )
|
|
||||||
|
if ( termtype.left(6) == "cygwin" )
|
||||||
terminal_type.cygwin = true;
|
terminal_type.cygwin = true;
|
||||||
|
|
||||||
// rxvt terminal emulator (native MS Window System port) on cygwin
|
// 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;
|
terminal_type.rxvt = true;
|
||||||
|
|
||||||
// Ansi terminal
|
// Ansi terminal
|
||||||
if ( std::strncmp(termtype, "ansi", 4) == 0 )
|
if ( termtype.left(4) == "ansi" )
|
||||||
{
|
{
|
||||||
terminal_detection = false;
|
terminal_detection = false;
|
||||||
terminal_type.ansi = true;
|
terminal_type.ansi = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sun Microsystems workstation console
|
// Sun Microsystems workstation console
|
||||||
if ( std::strncmp(termtype, "sun", 3) == 0 )
|
if ( termtype.left(3) == "sun" )
|
||||||
{
|
{
|
||||||
terminal_detection = false;
|
terminal_detection = false;
|
||||||
terminal_type.sun_con = true;
|
terminal_type.sun_con = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kterm
|
// Kterm
|
||||||
if ( std::strncmp(termtype, "kterm", 5) == 0 )
|
if ( termtype.left(5) == "kterm" )
|
||||||
{
|
{
|
||||||
terminal_detection = false;
|
terminal_detection = false;
|
||||||
terminal_type.kterm = true;
|
terminal_type.kterm = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mlterm
|
// mlterm
|
||||||
if ( std::strncmp(termtype, "mlterm", 6) == 0 )
|
if ( termtype.left(6) == "mlterm" )
|
||||||
terminal_type.mlterm = true;
|
terminal_type.mlterm = true;
|
||||||
|
|
||||||
// rxvt
|
// rxvt
|
||||||
if ( std::strncmp(termtype, "rxvt", 4) == 0 )
|
if ( termtype.left(4) == "rxvt" )
|
||||||
terminal_type.rxvt = true;
|
terminal_type.rxvt = true;
|
||||||
|
|
||||||
// urxvt
|
// urxvt
|
||||||
if ( std::strncmp(termtype, "rxvt-unicode", 12) == 0 )
|
if ( termtype.left(12) == "rxvt-unicode" )
|
||||||
terminal_type.urxvt = true;
|
terminal_type.urxvt = true;
|
||||||
|
|
||||||
// screen/tmux
|
// screen/tmux
|
||||||
if ( std::strncmp(termtype, "screen", 6) == 0 )
|
if ( termtype.left(6) == "screen" )
|
||||||
{
|
{
|
||||||
terminal_type.screen = true;
|
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;
|
terminal_type.tmux = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Linux console
|
// Linux console
|
||||||
if ( std::strncmp(termtype, "linux", 5) == 0
|
if ( termtype.left(5) == "linux" || termtype.left(3) == "con" )
|
||||||
|| std::strncmp(termtype, "con", 3) == 0 )
|
|
||||||
terminal_type.linux_con = true;
|
terminal_type.linux_con = true;
|
||||||
|
|
||||||
// NetBSD workstation console
|
// NetBSD workstation console
|
||||||
if ( std::strncmp(termtype, "wsvt25", 6) == 0 )
|
if ( termtype.left(6) == "wsvt25" )
|
||||||
terminal_type.netbsd_con = true;
|
terminal_type.netbsd_con = true;
|
||||||
|
|
||||||
// kitty
|
// kitty
|
||||||
if ( std::strncmp(termtype, "xterm-kitty", 11) == 0 )
|
if ( termtype.left(11) == "xterm-kitty" )
|
||||||
terminal_type.kitty = true;
|
terminal_type.kitty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,12 +305,12 @@ void FTermDetection::detectTerminal()
|
||||||
{
|
{
|
||||||
// Terminal detection
|
// Terminal detection
|
||||||
|
|
||||||
const char* new_termtype{nullptr};
|
FString new_termtype{};
|
||||||
|
|
||||||
if ( terminal_detection )
|
if ( terminal_detection )
|
||||||
{
|
{
|
||||||
FTermios::setCaptureSendCharacters();
|
FTermios::setCaptureSendCharacters();
|
||||||
auto& keyboard = FTerm::getFKeyboard();
|
auto& keyboard = FKeyboard::getInstance();
|
||||||
keyboard.setNonBlockingInput();
|
keyboard.setNonBlockingInput();
|
||||||
|
|
||||||
// Initialize 256 colors terminals
|
// Initialize 256 colors terminals
|
||||||
|
@ -384,28 +334,26 @@ void FTermDetection::detectTerminal()
|
||||||
//
|
//
|
||||||
|
|
||||||
// Test if the terminal is a xterm
|
// Test if the terminal is a xterm
|
||||||
if ( std::strncmp(termtype, "xterm", 5) == 0
|
if ( termtype.left(5) == "xterm" || termtype.left(5) == "Eterm" )
|
||||||
|| std::strncmp(termtype, "Eterm", 5) == 0 )
|
|
||||||
{
|
{
|
||||||
terminal_type.xterm = true;
|
terminal_type.xterm = true;
|
||||||
|
|
||||||
// Each xterm should be able to use at least 16 colors
|
// 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";
|
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;
|
terminal_type.ansi = true;
|
||||||
|
|
||||||
// set the new environment variable TERM
|
// set the new environment variable TERM
|
||||||
if ( new_termtype )
|
if ( new_termtype )
|
||||||
{
|
{
|
||||||
setenv("TERM", new_termtype, 1);
|
setenv("TERM", new_termtype.c_str(), 1);
|
||||||
std::strncpy (termtype, new_termtype, sizeof(termtype));
|
termtype = new_termtype;
|
||||||
termtype[sizeof(termtype) - 1] = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__CYGWIN__)
|
#if defined(__CYGWIN__)
|
||||||
auto& fterm_data = FTerm::getFTermData();
|
auto& fterm_data = FTermData::getInstance();
|
||||||
const auto& termfilename = fterm_data.getTermFileName();
|
const auto& termfilename = fterm_data.getTermFileName();
|
||||||
|
|
||||||
// Fixes problem with mouse input
|
// 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() )
|
if ( get256colorEnvString() )
|
||||||
color256 = true;
|
color256 = true;
|
||||||
else if ( std::strstr (termtype, "256color") )
|
else if ( termtype.includes("256color") )
|
||||||
color256 = true;
|
color256 = true;
|
||||||
else
|
else
|
||||||
color256 = false;
|
color256 = false;
|
||||||
|
@ -429,13 +377,8 @@ const char* FTermDetection::init_256colorTerminal()
|
||||||
new_termtype = termtype_256color_quirks();
|
new_termtype = termtype_256color_quirks();
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if ( new_termtype )
|
if ( ! new_termtype.isEmpty() )
|
||||||
{
|
termtype_256color = new_termtype;
|
||||||
std::strncpy ( termtype_256color
|
|
||||||
, new_termtype
|
|
||||||
, sizeof(termtype_256color) );
|
|
||||||
termtype_256color[sizeof(termtype_256color) - 1] = '\0';
|
|
||||||
}
|
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
|
||||||
return new_termtype;
|
return new_termtype;
|
||||||
|
@ -452,29 +395,28 @@ bool FTermDetection::get256colorEnvString()
|
||||||
color_env.string5 = std::getenv("KONSOLE_DBUS_SESSION");
|
color_env.string5 = std::getenv("KONSOLE_DBUS_SESSION");
|
||||||
color_env.string6 = std::getenv("KONSOLE_DCOP");
|
color_env.string6 = std::getenv("KONSOLE_DCOP");
|
||||||
color_env.string7 = std::getenv("COLORFGBG");
|
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
|
if ( ! color_env.string1.isEmpty()
|
||||||
|| color_env.string2 != nullptr
|
|| ! color_env.string2.isEmpty()
|
||||||
|| color_env.string3 != nullptr
|
|| ! color_env.string3.isEmpty()
|
||||||
|| color_env.string4 != nullptr
|
|| ! color_env.string4.isEmpty()
|
||||||
|| color_env.string5 != nullptr
|
|| ! color_env.string5.isEmpty()
|
||||||
|| color_env.string6 != nullptr
|
|| ! color_env.string6.isEmpty()
|
||||||
|| color_env.string7 != nullptr
|
|| ! color_env.string7.isEmpty()
|
||||||
|| color_env.string8 != nullptr )
|
|| ! color_env.string8.isEmpty() )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
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
|
if ( ! color_env.string2.isEmpty()
|
||||||
|| (color_env.string1
|
|| color_env.string1 == "gnome-terminal" )
|
||||||
&& std::strncmp(color_env.string1, "gnome-terminal", 14) == 0) )
|
|
||||||
{
|
{
|
||||||
terminal_type.gnome_terminal = true;
|
terminal_type.gnome_terminal = true;
|
||||||
// Each gnome-terminal should be able to use 256 colors
|
// Each gnome-terminal should be able to use 256 colors
|
||||||
|
@ -490,46 +432,45 @@ const char* FTermDetection::termtype_256color_quirks()
|
||||||
if ( ! color256 )
|
if ( ! color256 )
|
||||||
return new_termtype;
|
return new_termtype;
|
||||||
|
|
||||||
if ( std::strncmp(termtype, "xterm", 5) == 0 )
|
if ( termtype.left(5) == "xterm" )
|
||||||
new_termtype = "xterm-256color";
|
new_termtype = "xterm-256color";
|
||||||
|
|
||||||
if ( std::strncmp(termtype, "screen", 6) == 0 )
|
if ( termtype.left(6) == "screen" )
|
||||||
new_termtype = "screen-256color";
|
new_termtype = "screen-256color";
|
||||||
|
|
||||||
if ( std::strncmp(termtype, "Eterm", 5) == 0 )
|
if ( termtype.left(5) == "Eterm" )
|
||||||
new_termtype = "Eterm-256color";
|
new_termtype = "Eterm-256color";
|
||||||
|
|
||||||
if ( std::strncmp(termtype, "mlterm", 6) == 0 )
|
if ( termtype.left(6) == "mlterm" )
|
||||||
new_termtype = "mlterm-256color";
|
new_termtype = "mlterm-256color";
|
||||||
|
|
||||||
if ( std::strncmp(termtype, "rxvt", 4) != 0
|
if ( termtype.left(4) == "rxvt"
|
||||||
&& color_env.string1
|
&& color_env.string1.left(8) == "rxvt-xpm" )
|
||||||
&& std::strncmp(color_env.string1, "rxvt-xpm", 8) == 0 )
|
|
||||||
{
|
{
|
||||||
new_termtype = "rxvt-256color";
|
new_termtype = "rxvt-256color";
|
||||||
terminal_type.rxvt = true;
|
terminal_type.rxvt = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (color_env.string5 && std::strlen(color_env.string5) > 0)
|
if ( color_env.string5.getLength() > 0
|
||||||
|| (color_env.string6 && std::strlen(color_env.string6) > 0) )
|
|| color_env.string6.getLength() > 0 )
|
||||||
{
|
{
|
||||||
terminal_type.kde_konsole = true;
|
terminal_type.kde_konsole = true;
|
||||||
new_termtype = "konsole-256color";
|
new_termtype = "konsole-256color";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( color_env.string3 && std::strlen(color_env.string3) > 0 )
|
if ( color_env.string3.getLength() > 0 )
|
||||||
decscusr_support = true;
|
decscusr_support = true;
|
||||||
|
|
||||||
return new_termtype;
|
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
|
// Determine xterm maximum number of colors via OSC 4
|
||||||
|
|
||||||
const char* new_termtype = current_termtype;
|
FString new_termtype{current_termtype};
|
||||||
auto& keyboard = FTerm::getFKeyboard();
|
auto& keyboard = FKeyboard::getInstance();
|
||||||
keyboard.setNonBlockingInput();
|
keyboard.setNonBlockingInput();
|
||||||
|
|
||||||
if ( ! color256
|
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{""};
|
FString color_str{""};
|
||||||
std::array<char, 30> buf{};
|
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 )
|
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
|
// BEL + '\0' = string terminator
|
||||||
if ( n >= 6 && buf[n - 1] == BEL[0] && buf[n] == '\0' )
|
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;
|
FString new_termtype{current_termtype};
|
||||||
auto& keyboard = FTerm::getFKeyboard();
|
auto& keyboard = FKeyboard::getInstance();
|
||||||
keyboard.setNonBlockingInput();
|
keyboard.setNonBlockingInput();
|
||||||
// send ENQ and read the answerback message
|
// send ENQ and read the answerback message
|
||||||
const auto& ans = getAnswerbackMsg();
|
answer_back = getAnswerbackMsg();
|
||||||
keyboard.unsetNonBlockingInput();
|
keyboard.unsetNonBlockingInput();
|
||||||
|
|
||||||
try
|
if ( answer_back == "PuTTY" )
|
||||||
{
|
|
||||||
answer_back = new FString(ans);
|
|
||||||
}
|
|
||||||
catch (const std::bad_alloc&)
|
|
||||||
{
|
|
||||||
badAllocOutput ("FString");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( *answer_back == "PuTTY" )
|
|
||||||
{
|
{
|
||||||
terminal_type.putty = true;
|
terminal_type.putty = true;
|
||||||
|
|
||||||
|
@ -654,20 +585,15 @@ const char* FTermDetection::parseAnswerbackMsg (const char current_termtype[])
|
||||||
std::fflush (stdout);
|
std::fflush (stdout);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if ( new_termtype )
|
if ( ! new_termtype.isEmpty() )
|
||||||
{
|
termtype_Answerback = new_termtype;
|
||||||
std::strncpy ( termtype_Answerback
|
|
||||||
, new_termtype
|
|
||||||
, sizeof(termtype_Answerback) - 1);
|
|
||||||
termtype_Answerback[sizeof(termtype_Answerback) - 1] = '\0';
|
|
||||||
}
|
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
|
||||||
return new_termtype;
|
return new_termtype;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FString FTermDetection::getAnswerbackMsg()
|
FString FTermDetection::getAnswerbackMsg() const
|
||||||
{
|
{
|
||||||
FString answerback{""};
|
FString answerback{""};
|
||||||
fd_set ifds{};
|
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
|
// The Linux console and older cygwin terminals knows no Sec_DA
|
||||||
if ( isLinuxTerm() || isCygwinTerminal() )
|
if ( isLinuxTerm() || isCygwinTerminal() )
|
||||||
return current_termtype;
|
return current_termtype;
|
||||||
|
|
||||||
// Secondary device attributes (SEC_DA) <- decTerminalID string
|
// Secondary device attributes (SEC_DA) <- decTerminalID string
|
||||||
const auto& ans = getSecDA();
|
sec_da = getSecDA();
|
||||||
|
|
||||||
try
|
if ( sec_da.getLength() < 6 )
|
||||||
{
|
|
||||||
// Secondary device attributes (SEC_DA) <- decTerminalID string
|
|
||||||
sec_da = new FString(ans);
|
|
||||||
}
|
|
||||||
catch (const std::bad_alloc&)
|
|
||||||
{
|
|
||||||
badAllocOutput ("FString");
|
|
||||||
return current_termtype;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( sec_da->getLength() < 6 )
|
|
||||||
return current_termtype;
|
return current_termtype;
|
||||||
|
|
||||||
// remove the first 3 bytes ("\033[>")
|
// 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")
|
// remove the last byte ("c")
|
||||||
temp.remove(temp.getLength() - 1, 1);
|
temp.remove(temp.getLength() - 1, 1);
|
||||||
// split into components
|
// split into components
|
||||||
const FStringList sec_da_list = temp.split(';');
|
const auto sec_da_components = temp.split(';');
|
||||||
|
const auto num_components = sec_da_components.size();
|
||||||
const uLong num_components = sec_da_list.size();
|
|
||||||
|
|
||||||
// The second device attribute (SEC_DA) always has 3 parameters,
|
// The second device attribute (SEC_DA) always has 3 parameters,
|
||||||
// otherwise it usually has a copy of the device attribute (primary DA)
|
// otherwise it usually has a copy of the device attribute (primary DA)
|
||||||
if ( num_components < 3 )
|
if ( num_components < 3 )
|
||||||
return current_termtype;
|
return current_termtype;
|
||||||
|
|
||||||
const FString* sec_da_components = &sec_da_list[0];
|
|
||||||
|
|
||||||
if ( sec_da_components[0].isEmpty() )
|
if ( sec_da_components[0].isEmpty() )
|
||||||
return current_termtype;
|
return current_termtype;
|
||||||
|
|
||||||
|
@ -758,21 +670,18 @@ const char* FTermDetection::parseSecDA (const char current_termtype[])
|
||||||
// Read the terminal hardware option
|
// Read the terminal hardware option
|
||||||
secondary_da.terminal_id_hardware = str2int(sec_da_components[2]);
|
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 DEBUG
|
||||||
if ( new_termtype )
|
if ( ! new_termtype.isEmpty() )
|
||||||
{
|
termtype_SecDA = new_termtype;
|
||||||
std::strncpy (termtype_SecDA, new_termtype, sizeof(termtype_SecDA));
|
|
||||||
termtype_SecDA[sizeof(termtype_SecDA) - 1] = '\0';
|
|
||||||
}
|
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
|
||||||
return new_termtype;
|
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.
|
// This is not a general string to integer conversion method.
|
||||||
// It is only used in this class to convert the device attribute
|
// 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;
|
constexpr int ERROR = -1;
|
||||||
|
|
||||||
if ( ! s )
|
if ( s.isEmpty() )
|
||||||
return ERROR;
|
return ERROR;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -802,7 +711,7 @@ int FTermDetection::str2int (const FString& s)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FString FTermDetection::getSecDA()
|
FString FTermDetection::getSecDA() const
|
||||||
{
|
{
|
||||||
FString sec_da_str{""};
|
FString sec_da_str{""};
|
||||||
|
|
||||||
|
@ -813,10 +722,10 @@ FString FTermDetection::getSecDA()
|
||||||
const int stdout_no{FTermios::getStdOut()};
|
const int stdout_no{FTermios::getStdOut()};
|
||||||
fd_set ifds{};
|
fd_set ifds{};
|
||||||
struct timeval tv{};
|
struct timeval tv{};
|
||||||
constexpr auto& SECDA{ESC "[>c"};
|
const std::string SECDA{ESC "[>c"};
|
||||||
|
|
||||||
// Get the secondary device attributes
|
// 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;
|
return sec_da_str;
|
||||||
|
|
||||||
std::fflush(stdout);
|
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 )
|
switch ( secondary_da.terminal_id_type )
|
||||||
{
|
{
|
||||||
|
@ -875,7 +784,7 @@ const char* FTermDetection::secDA_Analysis (const char current_termtype[])
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 32: // Tera Term
|
case 32: // Tera Term
|
||||||
new_termtype = secDA_Analysis_32(current_termtype);
|
new_termtype = secDA_Analysis_32();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 41: // DEC VT420
|
case 41: // DEC VT420
|
||||||
|
@ -888,11 +797,11 @@ const char* FTermDetection::secDA_Analysis (const char current_termtype[])
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 67: // Cygwin
|
case 67: // Cygwin
|
||||||
new_termtype = secDA_Analysis_67(current_termtype);
|
new_termtype = secDA_Analysis_67();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 77: // mintty
|
case 77: // mintty
|
||||||
new_termtype = secDA_Analysis_77(current_termtype);
|
new_termtype = secDA_Analysis_77();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 82: // rxvt
|
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
|
// Terminal ID 0 - DEC VT100
|
||||||
|
|
||||||
const char* new_termtype = current_termtype;
|
FString new_termtype{current_termtype};
|
||||||
|
|
||||||
if ( secondary_da.terminal_id_version == 10
|
if ( secondary_da.terminal_id_version == 10
|
||||||
&& secondary_da.terminal_id_hardware == 1 )
|
&& 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
|
// Terminal ID 1 - DEC VT220
|
||||||
|
|
||||||
const char* new_termtype = current_termtype;
|
FString new_termtype{current_termtype};
|
||||||
|
|
||||||
if ( isKittyTerminal() )
|
if ( isKittyTerminal() )
|
||||||
new_termtype = secDA_Analysis_kitty(new_termtype);
|
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
|
// Terminal ID 24 - DEC VT320
|
||||||
|
|
||||||
const char* new_termtype = current_termtype;
|
FString new_termtype{current_termtype};
|
||||||
|
|
||||||
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
|
#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() )
|
&& FTermOpenBSD::isBSDConsole() )
|
||||||
{
|
{
|
||||||
// NetBSD/OpenBSD workstation console
|
// NetBSD/OpenBSD workstation console
|
||||||
if ( std::strncmp(termtype, "wsvt25", 6) == 0 )
|
if ( termtype.left(6) == "wsvt25" )
|
||||||
terminal_type.netbsd_con = true;
|
terminal_type.netbsd_con = true;
|
||||||
else if ( std::strncmp(termtype, "vt220", 5) == 0 )
|
else if ( termtype.left(5) == "vt220" )
|
||||||
{
|
{
|
||||||
terminal_type.openbsd_con = true;
|
terminal_type.openbsd_con = true;
|
||||||
new_termtype = "pccon";
|
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 ID 32 - Tera Term
|
||||||
|
|
||||||
terminal_type.tera_term = true;
|
terminal_type.tera_term = true;
|
||||||
const char* new_termtype = "teraterm";
|
return "teraterm";
|
||||||
return new_termtype;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
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
|
// 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 ID 67 - cygwin
|
||||||
|
|
||||||
terminal_type.cygwin = true;
|
terminal_type.cygwin = true;
|
||||||
const char* new_termtype = "cygwin";
|
|
||||||
std::fflush(stdout);
|
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 ID 77 - mintty
|
||||||
|
|
||||||
terminal_type.mintty = true;
|
terminal_type.mintty = true;
|
||||||
decscusr_support = true;
|
decscusr_support = true;
|
||||||
const char* new_termtype = "xterm-256color";
|
|
||||||
std::fflush(stdout);
|
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
|
// Terminal ID 82 - rxvt
|
||||||
|
|
||||||
const char* new_termtype{};
|
FString new_termtype{};
|
||||||
terminal_type.rxvt = true;
|
terminal_type.rxvt = true;
|
||||||
|
|
||||||
if ( std::strncmp(termtype, "rxvt-cygwin-native", 18) == 0 )
|
if ( termtype == "rxvt-cygwin-native" )
|
||||||
new_termtype = "rxvt-16color";
|
new_termtype = "rxvt-16color";
|
||||||
else
|
else
|
||||||
new_termtype = "rxvt";
|
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
|
// Terminal ID 83 - screen
|
||||||
|
|
||||||
const char* new_termtype = current_termtype;
|
|
||||||
terminal_type.screen = true;
|
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
|
// Terminal ID 84 - tmux
|
||||||
|
|
||||||
const char* new_termtype = current_termtype;
|
|
||||||
terminal_type.screen = true;
|
terminal_type.screen = true;
|
||||||
terminal_type.tmux = 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
|
// Terminal ID 85 - rxvt-unicode
|
||||||
|
|
||||||
const char* new_termtype{};
|
FString new_termtype{};
|
||||||
terminal_type.rxvt = true;
|
terminal_type.rxvt = true;
|
||||||
terminal_type.urxvt = true;
|
terminal_type.urxvt = true;
|
||||||
|
|
||||||
if ( std::strncmp(termtype, "rxvt-", 5) != 0 )
|
if ( termtype.left(5) == "rxvt-" )
|
||||||
{
|
{
|
||||||
if ( color256 )
|
if ( color256 )
|
||||||
new_termtype = "rxvt-256color";
|
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
|
// VTE terminal library
|
||||||
// (Since VTE ) the terminal ID has changed from 1 to 65)
|
// (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 )
|
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
|
// kitty
|
||||||
|
|
||||||
const char* new_termtype = current_termtype;
|
FString new_termtype{current_termtype};
|
||||||
|
|
||||||
if ( secondary_da.terminal_id_version > 3999 )
|
if ( secondary_da.terminal_id_version > 3999 )
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,6 +46,13 @@ bool FTermFreeBSD::meta_sends_escape{true};
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
// public methods of FTermFreeBSD
|
// public methods of FTermFreeBSD
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
auto FTermFreeBSD::getInstance() -> FTermFreeBSD&
|
||||||
|
{
|
||||||
|
static const auto& freebsd_console = make_unique<FTermFreeBSD>();
|
||||||
|
return *freebsd_console;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FTermFreeBSD::CursorStyle FTermFreeBSD::getCursorStyle()
|
FTermFreeBSD::CursorStyle FTermFreeBSD::getCursorStyle()
|
||||||
{
|
{
|
||||||
|
@ -61,7 +68,7 @@ bool FTermFreeBSD::setCursorStyle (CursorStyle style)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
cursor_style = style;
|
cursor_style = style;
|
||||||
auto& fterm_data = FTerm::getFTermData();
|
auto& fterm_data = FTermData::getInstance();
|
||||||
|
|
||||||
if ( fterm_data.isCursorHidden() )
|
if ( fterm_data.isCursorHidden() )
|
||||||
return false;
|
return false;
|
||||||
|
@ -75,7 +82,7 @@ bool FTermFreeBSD::isFreeBSDConsole()
|
||||||
// Check if it's a FreeBSD console
|
// Check if it's a FreeBSD console
|
||||||
|
|
||||||
keymap_t keymap{};
|
keymap_t keymap{};
|
||||||
const auto& fsystem = FTerm::getFSystem();
|
const auto& fsystem = FSystem::getInstance();
|
||||||
|
|
||||||
if ( fsystem->ioctl(0, GIO_KEYMAP, &keymap) == 0 )
|
if ( fsystem->ioctl(0, GIO_KEYMAP, &keymap) == 0 )
|
||||||
return true;
|
return true;
|
||||||
|
@ -148,7 +155,7 @@ void FTermFreeBSD::initCharMap()
|
||||||
if ( ! isFreeBSDConsole() )
|
if ( ! isFreeBSDConsole() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (auto&& entry : fc::character)
|
for (auto&& entry : FCharMap::getCharEncodeMap())
|
||||||
if ( entry.pc < 0x1c )
|
if ( entry.pc < 0x1c )
|
||||||
entry.pc = entry.ascii;
|
entry.pc = entry.ascii;
|
||||||
}
|
}
|
||||||
|
@ -187,7 +194,7 @@ bool FTermFreeBSD::saveFreeBSDAltKey()
|
||||||
static constexpr int left_alt = 0x38;
|
static constexpr int left_alt = 0x38;
|
||||||
int ret{-1};
|
int ret{-1};
|
||||||
keymap_t keymap{};
|
keymap_t keymap{};
|
||||||
const auto& fsystem = FTerm::getFSystem();
|
const auto& fsystem = FSystem::getInstance();
|
||||||
ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap);
|
ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap);
|
||||||
|
|
||||||
if ( ret < 0 )
|
if ( ret < 0 )
|
||||||
|
@ -206,7 +213,7 @@ bool FTermFreeBSD::setFreeBSDAltKey (uInt key)
|
||||||
static constexpr int left_alt = 0x38;
|
static constexpr int left_alt = 0x38;
|
||||||
int ret{-1};
|
int ret{-1};
|
||||||
keymap_t keymap{};
|
keymap_t keymap{};
|
||||||
const auto& fsystem = FTerm::getFSystem();
|
const auto& fsystem = FSystem::getInstance();
|
||||||
ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap);
|
ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap);
|
||||||
|
|
||||||
if ( ret < 0 )
|
if ( ret < 0 )
|
||||||
|
@ -241,7 +248,7 @@ bool FTermFreeBSD::resetFreeBSDAlt2Meta()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
bool FTermFreeBSD::setFreeBSDCursorStyle (CursorStyle style)
|
bool FTermFreeBSD::setFreeBSDCursorStyle (CursorStyle style)
|
||||||
{
|
{
|
||||||
const auto& fsystem = FTerm::getFSystem();
|
const auto& fsystem = FSystem::getInstance();
|
||||||
|
|
||||||
if ( fsystem->ioctl(0, CONS_CURSORTYPE, &style) == 0 )
|
if ( fsystem->ioctl(0, CONS_CURSORTYPE, &style) == 0 )
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -61,6 +61,13 @@ FTermLinux::~FTermLinux() // destructor
|
||||||
}
|
}
|
||||||
|
|
||||||
// public methods of FTermLinux
|
// public methods of FTermLinux
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
auto FTermLinux::getInstance() -> FTermLinux&
|
||||||
|
{
|
||||||
|
static const auto& linux_console = make_unique<FTermLinux>();
|
||||||
|
return *linux_console;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FTermLinux::CursorStyle FTermLinux::getCursorStyle() const
|
FTermLinux::CursorStyle FTermLinux::getCursorStyle() const
|
||||||
{
|
{
|
||||||
|
@ -90,7 +97,7 @@ bool FTermLinux::setCursorStyle (CursorStyle style)
|
||||||
|
|
||||||
linux_console_cursor_style = style;
|
linux_console_cursor_style = style;
|
||||||
|
|
||||||
if ( FTerm::getFTermData().isCursorHidden() )
|
if ( FTermData::getInstance().isCursorHidden() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
setLinuxCursorStyle(style);
|
setLinuxCursorStyle(style);
|
||||||
|
@ -134,7 +141,7 @@ bool FTermLinux::isLinuxConsole()
|
||||||
|
|
||||||
char arg{0};
|
char arg{0};
|
||||||
int fd_tty = FTerm::getTTYFileDescriptor();
|
int fd_tty = FTerm::getTTYFileDescriptor();
|
||||||
const auto& fsystem = FTerm::getFSystem();
|
const auto& fsystem = FSystem::getInstance();
|
||||||
|
|
||||||
if ( fd_tty < 0 ) // Undefined tty file descriptor
|
if ( fd_tty < 0 ) // Undefined tty file descriptor
|
||||||
fd_tty = 0;
|
fd_tty = 0;
|
||||||
|
@ -150,7 +157,7 @@ void FTermLinux::init()
|
||||||
{
|
{
|
||||||
// Initialize Linux console
|
// Initialize Linux console
|
||||||
|
|
||||||
auto& fterm_data = FTerm::getFTermData();
|
auto& fterm_data = FTermData::getInstance();
|
||||||
screen_unicode_map.entries = nullptr;
|
screen_unicode_map.entries = nullptr;
|
||||||
screen_font.data = nullptr;
|
screen_font.data = nullptr;
|
||||||
fterm_data.supportShadowCharacter (true);
|
fterm_data.supportShadowCharacter (true);
|
||||||
|
@ -163,7 +170,7 @@ void FTermLinux::init()
|
||||||
|
|
||||||
if ( FTerm::openConsole() == 0 )
|
if ( FTerm::openConsole() == 0 )
|
||||||
{
|
{
|
||||||
FTerm::getFTermDetection().setLinuxTerm (isLinuxConsole());
|
FTermDetection::getInstance().setLinuxTerm(isLinuxConsole());
|
||||||
|
|
||||||
if ( FTerm::isLinuxTerm() )
|
if ( FTerm::isLinuxTerm() )
|
||||||
{
|
{
|
||||||
|
@ -208,7 +215,7 @@ void FTermLinux::initCharMap() const
|
||||||
|
|
||||||
if ( screen_unicode_map.entry_ct > 0 && screen_unicode_map.entries )
|
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 auto ucs = entry.unicode;
|
||||||
const sInt16 fontpos = getFontPos(ucs);
|
const sInt16 fontpos = getFontPos(ucs);
|
||||||
|
@ -282,7 +289,7 @@ bool FTermLinux::loadVGAFont()
|
||||||
|
|
||||||
if ( vga_font )
|
if ( vga_font )
|
||||||
{
|
{
|
||||||
auto& fterm_data = FTerm::getFTermData();
|
auto& fterm_data = FTermData::getInstance();
|
||||||
fterm_data.supportShadowCharacter (true);
|
fterm_data.supportShadowCharacter (true);
|
||||||
fterm_data.supportHalfBlockCharacter (true);
|
fterm_data.supportHalfBlockCharacter (true);
|
||||||
}
|
}
|
||||||
|
@ -330,7 +337,7 @@ bool FTermLinux::loadNewFont()
|
||||||
|
|
||||||
if ( new_font )
|
if ( new_font )
|
||||||
{
|
{
|
||||||
auto& fterm_data = FTerm::getFTermData();
|
auto& fterm_data = FTermData::getInstance();
|
||||||
fterm_data.supportShadowCharacter (true);
|
fterm_data.supportShadowCharacter (true);
|
||||||
fterm_data.supportHalfBlockCharacter (true);
|
fterm_data.supportHalfBlockCharacter (true);
|
||||||
}
|
}
|
||||||
|
@ -462,7 +469,7 @@ int FTermLinux::getFramebuffer_bpp() const
|
||||||
const char* fb = "/dev/fb/0";
|
const char* fb = "/dev/fb/0";
|
||||||
struct fb_var_screeninfo fb_var{};
|
struct fb_var_screeninfo fb_var{};
|
||||||
struct fb_fix_screeninfo fb_fix{};
|
struct fb_fix_screeninfo fb_fix{};
|
||||||
const auto& fsystem = FTerm::getFSystem();
|
const auto& fsystem = FSystem::getInstance();
|
||||||
|
|
||||||
if ( (fd = fsystem->open(fb, O_RDWR)) < 0 )
|
if ( (fd = fsystem->open(fb, O_RDWR)) < 0 )
|
||||||
{
|
{
|
||||||
|
@ -521,7 +528,7 @@ bool FTermLinux::getScreenFont()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Font operation
|
// Font operation
|
||||||
const auto& fsystem = FTerm::getFSystem();
|
const auto& fsystem = FSystem::getInstance();
|
||||||
ret = fsystem->ioctl (fd_tty, KDFONTOP, &font);
|
ret = fsystem->ioctl (fd_tty, KDFONTOP, &font);
|
||||||
|
|
||||||
if ( ret != 0 )
|
if ( ret != 0 )
|
||||||
|
@ -552,7 +559,7 @@ bool FTermLinux::getUnicodeMap()
|
||||||
screen_unicode_map.entries = nullptr;
|
screen_unicode_map.entries = nullptr;
|
||||||
|
|
||||||
// Get count
|
// Get count
|
||||||
const auto& fsystem = FTerm::getFSystem();
|
const auto& fsystem = FSystem::getInstance();
|
||||||
ret = fsystem->ioctl (fd_tty, GIO_UNIMAP, &screen_unicode_map);
|
ret = fsystem->ioctl (fd_tty, GIO_UNIMAP, &screen_unicode_map);
|
||||||
|
|
||||||
if ( ret != 0 )
|
if ( ret != 0 )
|
||||||
|
@ -592,7 +599,7 @@ FTermLinux::ModifierKey& FTermLinux::getModifierKey()
|
||||||
// Fill bit field with 0
|
// Fill bit field with 0
|
||||||
std::memset (&mod_key, 0x00, sizeof(mod_key));
|
std::memset (&mod_key, 0x00, sizeof(mod_key));
|
||||||
|
|
||||||
const auto& fsystem = FTerm::getFSystem();
|
const auto& fsystem = FSystem::getInstance();
|
||||||
|
|
||||||
// TIOCLINUX, subcode = 6 (TIOCL_GETSHIFTSTATE)
|
// TIOCLINUX, subcode = 6 (TIOCL_GETSHIFTSTATE)
|
||||||
if ( fsystem->ioctl(0, TIOCLINUX, &subcode) >= 0 )
|
if ( fsystem->ioctl(0, TIOCLINUX, &subcode) >= 0 )
|
||||||
|
@ -658,7 +665,7 @@ int FTermLinux::setScreenFont ( const uChar fontdata[], uInt count
|
||||||
}
|
}
|
||||||
|
|
||||||
// Font operation
|
// Font operation
|
||||||
const auto& fsystem = FTerm::getFSystem();
|
const auto& fsystem = FSystem::getInstance();
|
||||||
ret = fsystem->ioctl (fd_tty, KDFONTOP, &font);
|
ret = fsystem->ioctl (fd_tty, KDFONTOP, &font);
|
||||||
|
|
||||||
if ( ret != 0 && errno != ENOSYS && errno != EINVAL )
|
if ( ret != 0 && errno != ENOSYS && errno != EINVAL )
|
||||||
|
@ -695,7 +702,7 @@ int FTermLinux::setUnicodeMap (struct unimapdesc* unimap) const
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
// Clear the unicode-to-font table
|
// Clear the unicode-to-font table
|
||||||
const auto& fsystem = FTerm::getFSystem();
|
const auto& fsystem = FSystem::getInstance();
|
||||||
ret = fsystem->ioctl (fd_tty, PIO_UNIMAPCLR, &advice);
|
ret = fsystem->ioctl (fd_tty, PIO_UNIMAPCLR, &advice);
|
||||||
|
|
||||||
if ( ret != 0 )
|
if ( ret != 0 )
|
||||||
|
@ -727,7 +734,7 @@ inline uInt16 FTermLinux::getInputStatusRegisterOne() const
|
||||||
{
|
{
|
||||||
// Gets the VGA input-status-register-1
|
// Gets the VGA input-status-register-1
|
||||||
|
|
||||||
const auto& fsystem = FTerm::getFSystem();
|
const auto& fsystem = FSystem::getInstance();
|
||||||
|
|
||||||
// Miscellaneous output (read port)
|
// Miscellaneous output (read port)
|
||||||
static constexpr uInt16 misc_read = 0x3cc;
|
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
|
// 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)
|
// Attribute controller (write port)
|
||||||
static constexpr uInt16 attrib_cntlr_write = 0x3c0;
|
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
|
// 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)
|
// Attribute controller (write port)
|
||||||
static constexpr uInt16 attrib_cntlr_write = 0x3c0;
|
static constexpr uInt16 attrib_cntlr_write = 0x3c0;
|
||||||
|
@ -808,7 +815,7 @@ int FTermLinux::setBlinkAsIntensity (bool enable) const
|
||||||
// Uses blink-bit as background intensity.
|
// Uses blink-bit as background intensity.
|
||||||
// That permits 16 colors for background
|
// That permits 16 colors for background
|
||||||
|
|
||||||
const auto& fsystem = FTerm::getFSystem();
|
const auto& fsystem = FSystem::getInstance();
|
||||||
|
|
||||||
const int fd_tty = FTerm::getTTYFileDescriptor();
|
const int fd_tty = FTerm::getTTYFileDescriptor();
|
||||||
|
|
||||||
|
@ -847,7 +854,7 @@ bool FTermLinux::has9BitCharacters() const
|
||||||
// 0xc0...0xdf - copying the eighth pixel into the ninth pixel
|
// 0xc0...0xdf - copying the eighth pixel into the ninth pixel
|
||||||
// The rest - the ninth pixel has the background color
|
// 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();
|
const int fd_tty = FTerm::getTTYFileDescriptor();
|
||||||
|
|
||||||
if ( fsystem->getuid() != 0 ) // Direct hardware access requires root privileges
|
if ( fsystem->getuid() != 0 ) // Direct hardware access requires root privileges
|
||||||
|
@ -872,7 +879,7 @@ bool FTermLinux::has9BitCharacters() const
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermLinux::getVGAPalette()
|
void FTermLinux::getVGAPalette()
|
||||||
{
|
{
|
||||||
const auto& fsystem = FTerm::getFSystem();
|
const auto& fsystem = FSystem::getInstance();
|
||||||
|
|
||||||
if ( fsystem->ioctl(0, GIO_CMAP, cmap.color.data()) != 0 )
|
if ( fsystem->ioctl(0, GIO_CMAP, cmap.color.data()) != 0 )
|
||||||
setVGADefaultPalette(); // Fallback, if GIO_CMAP does not work
|
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);
|
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 )
|
if ( fsystem->ioctl(0, PIO_CMAP, cmap.color.data()) == 0 )
|
||||||
return true;
|
return true;
|
||||||
|
@ -930,7 +937,7 @@ bool FTermLinux::saveVGAPalette()
|
||||||
{
|
{
|
||||||
// Save the current vga color map
|
// 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 )
|
if ( fsystem->ioctl(0, GIO_CMAP, saved_color_map.color.data()) == 0 )
|
||||||
has_saved_palette = true;
|
has_saved_palette = true;
|
||||||
|
@ -945,7 +952,7 @@ bool FTermLinux::resetVGAPalette()
|
||||||
{
|
{
|
||||||
// Reset the vga color map
|
// Reset the vga color map
|
||||||
|
|
||||||
const auto& fsystem = FTerm::getFSystem();
|
const auto& fsystem = FSystem::getInstance();
|
||||||
|
|
||||||
if ( has_saved_palette )
|
if ( has_saved_palette )
|
||||||
{
|
{
|
||||||
|
@ -1128,7 +1135,7 @@ inline void FTermLinux::shiftCtrlAltKeyCorrection()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FTermLinux::initSpecialCharacter() const
|
inline void FTermLinux::initSpecialCharacter() const
|
||||||
{
|
{
|
||||||
auto& fterm_data = FTerm::getFTermData();
|
auto& fterm_data = FTermData::getInstance();
|
||||||
const auto c1 = wchar_t(UniChar::UpperHalfBlock); // ▀
|
const auto c1 = wchar_t(UniChar::UpperHalfBlock); // ▀
|
||||||
const auto c2 = wchar_t(UniChar::LowerHalfBlock); // ▄
|
const auto c2 = wchar_t(UniChar::LowerHalfBlock); // ▄
|
||||||
const auto c3 = wchar_t(UniChar::FullBlock); // █
|
const auto c3 = wchar_t(UniChar::FullBlock); // █
|
||||||
|
@ -1169,7 +1176,7 @@ void FTermLinux::characterFallback ( wchar_t ucs
|
||||||
, const std::vector<wchar_t>& fallback ) const
|
, const std::vector<wchar_t>& fallback ) const
|
||||||
{
|
{
|
||||||
constexpr sInt16 NOT_FOUND = -1;
|
constexpr sInt16 NOT_FOUND = -1;
|
||||||
auto& fterm_data = FTerm::getFTermData();
|
auto& fterm_data = FTermData::getInstance();
|
||||||
charSubstitution& sub_map = fterm_data.getCharSubstitutionMap();
|
charSubstitution& sub_map = fterm_data.getCharSubstitutionMap();
|
||||||
|
|
||||||
if ( fallback.size() < 2 || ucs != fallback[0] )
|
if ( fallback.size() < 2 || ucs != fallback[0] )
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* *
|
* *
|
||||||
* This file is part of the FINAL CUT widget toolkit *
|
* 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 *
|
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU Lesser General Public License as *
|
* 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
|
// public methods of FTermOpenBSD
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
auto FTermOpenBSD::getInstance() -> FTermOpenBSD&
|
||||||
|
{
|
||||||
|
static const auto& openbsd_console = make_unique<FTermOpenBSD>();
|
||||||
|
return *openbsd_console;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
bool FTermOpenBSD::isBSDConsole()
|
bool FTermOpenBSD::isBSDConsole()
|
||||||
{
|
{
|
||||||
// Check if it's a NetBSD/OpenBSD workstation console
|
// Check if it's a NetBSD/OpenBSD workstation console
|
||||||
|
|
||||||
static kbd_t kbdencoding{};
|
static kbd_t kbdencoding{};
|
||||||
const auto& fsystem = FTerm::getFSystem();
|
const auto& fsystem = FSystem::getInstance();
|
||||||
|
|
||||||
if ( fsystem->ioctl(0, WSKBDIO_GETENCODING, &kbdencoding) == 0 )
|
if ( fsystem->ioctl(0, WSKBDIO_GETENCODING, &kbdencoding) == 0 )
|
||||||
return true;
|
return true;
|
||||||
|
@ -102,7 +109,7 @@ bool FTermOpenBSD::setBeep (int Hz, int ms)
|
||||||
bell.pitch = uInt(Hz);
|
bell.pitch = uInt(Hz);
|
||||||
bell.period = uInt(ms);
|
bell.period = uInt(ms);
|
||||||
bell.volume = 50; // 50% volume
|
bell.volume = 50; // 50% volume
|
||||||
const auto& fsystem = FTerm::getFSystem();
|
const auto& fsystem = FSystem::getInstance();
|
||||||
|
|
||||||
if ( fsystem->ioctl(0, WSKBDIO_SETBELL, &bell) < 0 )
|
if ( fsystem->ioctl(0, WSKBDIO_SETBELL, &bell) < 0 )
|
||||||
return false;
|
return false;
|
||||||
|
@ -114,7 +121,7 @@ bool FTermOpenBSD::setBeep (int Hz, int ms)
|
||||||
bool FTermOpenBSD::resetBeep()
|
bool FTermOpenBSD::resetBeep()
|
||||||
{
|
{
|
||||||
wskbd_bell_data default_bell;
|
wskbd_bell_data default_bell;
|
||||||
const auto& fsystem = FTerm::getFSystem();
|
const auto& fsystem = FSystem::getInstance();
|
||||||
|
|
||||||
// Gets the default setting for the bell
|
// Gets the default setting for the bell
|
||||||
if ( fsystem->ioctl(0, WSKBDIO_GETDEFAULTBELL, &default_bell) < 0 )
|
if ( fsystem->ioctl(0, WSKBDIO_GETDEFAULTBELL, &default_bell) < 0 )
|
||||||
|
@ -147,7 +154,7 @@ bool FTermOpenBSD::saveBSDConsoleEncoding()
|
||||||
static kbd_t k_encoding{};
|
static kbd_t k_encoding{};
|
||||||
int ret{-1};
|
int ret{-1};
|
||||||
|
|
||||||
const auto& fsystem = FTerm::getFSystem();
|
const auto& fsystem = FSystem::getInstance();
|
||||||
ret = fsystem->ioctl (0, WSKBDIO_GETENCODING, &k_encoding);
|
ret = fsystem->ioctl (0, WSKBDIO_GETENCODING, &k_encoding);
|
||||||
|
|
||||||
if ( ret < 0 )
|
if ( ret < 0 )
|
||||||
|
@ -161,7 +168,7 @@ bool FTermOpenBSD::saveBSDConsoleEncoding()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
bool FTermOpenBSD::setBSDConsoleEncoding (kbd_t k_encoding)
|
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 )
|
if ( fsystem->ioctl(0, WSKBDIO_SETENCODING, &k_encoding) < 0 )
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -51,6 +51,13 @@ bool FTermXTerminal::mouse_support{false};
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
// public methods of FTermXTerminal
|
// public methods of FTermXTerminal
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
auto FTermXTerminal::getInstance() -> FTermXTerminal&
|
||||||
|
{
|
||||||
|
static const auto& xterm = make_unique<FTermXTerminal>();
|
||||||
|
return *xterm;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermXTerminal::setCursorStyle (XTermCursorStyle style)
|
void FTermXTerminal::setCursorStyle (XTermCursorStyle style)
|
||||||
{
|
{
|
||||||
|
@ -241,7 +248,7 @@ void FTermXTerminal::resetHighlightBackground()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermXTerminal::resetDefaults()
|
void FTermXTerminal::resetDefaults()
|
||||||
{
|
{
|
||||||
if ( FTerm::getFTermDetection().isPuttyTerminal() )
|
if ( FTermDetection::getInstance().isPuttyTerminal() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Redefines the cursor color if resetCursorColor() doesn't work
|
// Redefines the cursor color if resetCursorColor() doesn't work
|
||||||
|
@ -272,14 +279,14 @@ void FTermXTerminal::resetTitle()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermXTerminal::captureFontAndTitle()
|
void FTermXTerminal::captureFontAndTitle()
|
||||||
{
|
{
|
||||||
const auto& term_detection = FTerm::getFTermDetection();
|
const auto& term_detection = FTermDetection::getInstance();
|
||||||
|
|
||||||
if ( ( term_detection.isXTerminal()
|
if ( ( term_detection.isXTerminal()
|
||||||
|| term_detection.isUrxvtTerminal() )
|
|| term_detection.isUrxvtTerminal() )
|
||||||
&& ! term_detection.isRxvtTerminal() )
|
&& ! term_detection.isRxvtTerminal() )
|
||||||
{
|
{
|
||||||
FTermios::setCaptureSendCharacters();
|
FTermios::setCaptureSendCharacters();
|
||||||
auto& keyboard = FTerm::getFKeyboard();
|
auto& keyboard = FKeyboard::getInstance();
|
||||||
keyboard.setNonBlockingInput();
|
keyboard.setNonBlockingInput();
|
||||||
xterm_font = captureXTermFont();
|
xterm_font = captureXTermFont();
|
||||||
xterm_title = captureXTermTitle();
|
xterm_title = captureXTermTitle();
|
||||||
|
@ -310,7 +317,7 @@ void FTermXTerminal::setXTermCursorStyle()
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const auto& term_detection = FTerm::getFTermDetection();
|
const auto& term_detection = FTermDetection::getInstance();
|
||||||
|
|
||||||
if ( term_detection.isGnomeTerminal()
|
if ( term_detection.isGnomeTerminal()
|
||||||
&& ! term_detection.hasSetCursorStyleSupport() )
|
&& ! term_detection.hasSetCursorStyleSupport() )
|
||||||
|
@ -334,7 +341,7 @@ void FTermXTerminal::setXTermCursorStyle()
|
||||||
void FTermXTerminal::setXTermTitle()
|
void FTermXTerminal::setXTermTitle()
|
||||||
{
|
{
|
||||||
// Set the xterm title
|
// Set the xterm title
|
||||||
const auto& term_detection = FTerm::getFTermDetection();
|
const auto& term_detection = FTermDetection::getInstance();
|
||||||
|
|
||||||
if ( term_detection.isXTerminal()
|
if ( term_detection.isXTerminal()
|
||||||
|| term_detection.isScreenTerm()
|
|| term_detection.isScreenTerm()
|
||||||
|
@ -345,10 +352,6 @@ void FTermXTerminal::setXTermTitle()
|
||||||
|| FTermcap::osc_support )
|
|| FTermcap::osc_support )
|
||||||
{
|
{
|
||||||
oscPrefix();
|
oscPrefix();
|
||||||
|
|
||||||
if ( xterm_title.isNull() )
|
|
||||||
xterm_title = "";
|
|
||||||
|
|
||||||
FTerm::putstringf (OSC "0;%s" BEL, xterm_title.c_str());
|
FTerm::putstringf (OSC "0;%s" BEL, xterm_title.c_str());
|
||||||
oscPostfix();
|
oscPostfix();
|
||||||
std::fflush(stdout);
|
std::fflush(stdout);
|
||||||
|
@ -359,7 +362,7 @@ void FTermXTerminal::setXTermTitle()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermXTerminal::setXTermSize() const
|
void FTermXTerminal::setXTermSize() const
|
||||||
{
|
{
|
||||||
if ( ! FTerm::getFTermDetection().isXTerminal() )
|
if ( ! FTermDetection::getInstance().isXTerminal() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FTerm::putstringf ( CSI "8;%lu;%lut"
|
FTerm::putstringf ( CSI "8;%lu;%lut"
|
||||||
|
@ -373,7 +376,7 @@ void FTermXTerminal::setXTermFont()
|
||||||
{
|
{
|
||||||
// Change the XTerm font (needs the allowFontOps resource)
|
// Change the XTerm font (needs the allowFontOps resource)
|
||||||
|
|
||||||
const auto& term_detection = FTerm::getFTermDetection();
|
const auto& term_detection = FTermDetection::getInstance();
|
||||||
|
|
||||||
if ( term_detection.isXTerminal()
|
if ( term_detection.isXTerminal()
|
||||||
|| term_detection.isScreenTerm()
|
|| term_detection.isScreenTerm()
|
||||||
|
@ -391,7 +394,7 @@ void FTermXTerminal::setXTermForeground()
|
||||||
{
|
{
|
||||||
// Set the XTerm text foreground color
|
// Set the XTerm text foreground color
|
||||||
|
|
||||||
const auto& term_detection = FTerm::getFTermDetection();
|
const auto& term_detection = FTermDetection::getInstance();
|
||||||
|
|
||||||
if ( term_detection.isXTerminal()
|
if ( term_detection.isXTerminal()
|
||||||
|| term_detection.isScreenTerm()
|
|| term_detection.isScreenTerm()
|
||||||
|
@ -411,7 +414,7 @@ void FTermXTerminal::setXTermBackground()
|
||||||
{
|
{
|
||||||
// Set the XTerm text background color
|
// Set the XTerm text background color
|
||||||
|
|
||||||
const auto& term_detection = FTerm::getFTermDetection();
|
const auto& term_detection = FTermDetection::getInstance();
|
||||||
|
|
||||||
if ( term_detection.isXTerminal()
|
if ( term_detection.isXTerminal()
|
||||||
|| term_detection.isScreenTerm()
|
|| term_detection.isScreenTerm()
|
||||||
|
@ -431,7 +434,7 @@ void FTermXTerminal::setXTermCursorColor()
|
||||||
{
|
{
|
||||||
// Set the text cursor color
|
// Set the text cursor color
|
||||||
|
|
||||||
const auto& term_detection = FTerm::getFTermDetection();
|
const auto& term_detection = FTermDetection::getInstance();
|
||||||
|
|
||||||
if ( term_detection.isXTerminal()
|
if ( term_detection.isXTerminal()
|
||||||
|| term_detection.isScreenTerm()
|
|| term_detection.isScreenTerm()
|
||||||
|
@ -451,7 +454,7 @@ void FTermXTerminal::setXTermMouseForeground()
|
||||||
{
|
{
|
||||||
// Set the mouse foreground color
|
// Set the mouse foreground color
|
||||||
|
|
||||||
const auto& term_detection = FTerm::getFTermDetection();
|
const auto& term_detection = FTermDetection::getInstance();
|
||||||
|
|
||||||
if ( term_detection.isXTerminal()
|
if ( term_detection.isXTerminal()
|
||||||
|| term_detection.isScreenTerm()
|
|| term_detection.isScreenTerm()
|
||||||
|
@ -470,7 +473,7 @@ void FTermXTerminal::setXTermMouseBackground()
|
||||||
{
|
{
|
||||||
// Set the mouse background color
|
// Set the mouse background color
|
||||||
|
|
||||||
const auto& term_detection = FTerm::getFTermDetection();
|
const auto& term_detection = FTermDetection::getInstance();
|
||||||
|
|
||||||
if ( term_detection.isXTerminal()
|
if ( term_detection.isXTerminal()
|
||||||
|| term_detection.isScreenTerm()
|
|| term_detection.isScreenTerm()
|
||||||
|
@ -488,7 +491,7 @@ void FTermXTerminal::setXTermHighlightBackground()
|
||||||
{
|
{
|
||||||
// Set the highlight background color
|
// Set the highlight background color
|
||||||
|
|
||||||
const auto& term_detection = FTerm::getFTermDetection();
|
const auto& term_detection = FTermDetection::getInstance();
|
||||||
|
|
||||||
if ( term_detection.isXTerminal()
|
if ( term_detection.isXTerminal()
|
||||||
|| term_detection.isScreenTerm()
|
|| term_detection.isScreenTerm()
|
||||||
|
@ -508,7 +511,7 @@ void FTermXTerminal::setXTerm8ColorDefaults()
|
||||||
// Redefinition of the XTerm default colors
|
// Redefinition of the XTerm default colors
|
||||||
// for the final cut 8 color theme
|
// for the final cut 8 color theme
|
||||||
|
|
||||||
if ( FTerm::getFTermDetection().isPuttyTerminal() )
|
if ( FTermDetection::getInstance().isPuttyTerminal() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
setXTermDefaultsMouseCursor();
|
setXTermDefaultsMouseCursor();
|
||||||
|
@ -528,7 +531,7 @@ void FTermXTerminal::setXTerm16ColorDefaults()
|
||||||
// Redefinition of the XTerm default colors
|
// Redefinition of the XTerm default colors
|
||||||
// for the final cut 16 color theme
|
// for the final cut 16 color theme
|
||||||
|
|
||||||
if ( FTerm::getFTermDetection().isPuttyTerminal() )
|
if ( FTermDetection::getInstance().isPuttyTerminal() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
setXTermDefaultsMouseCursor();
|
setXTermDefaultsMouseCursor();
|
||||||
|
@ -548,14 +551,14 @@ inline void FTermXTerminal::setXTermDefaultsMouseCursor()
|
||||||
setMouseBackground("rgb:ffff/ffff/ffff"); // white
|
setMouseBackground("rgb:ffff/ffff/ffff"); // white
|
||||||
setMouseForeground ("rgb:0000/0000/0000"); // black
|
setMouseForeground ("rgb:0000/0000/0000"); // black
|
||||||
|
|
||||||
if ( ! FTerm::getFTermDetection().isGnomeTerminal() )
|
if ( ! FTermDetection::getInstance().isGnomeTerminal() )
|
||||||
setCursorColor("rgb:ffff/ffff/ffff"); // white
|
setCursorColor("rgb:ffff/ffff/ffff"); // white
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FTermXTerminal::canSetXTermBackground() const
|
inline bool FTermXTerminal::canSetXTermBackground() const
|
||||||
{
|
{
|
||||||
const auto& term_detection = FTerm::getFTermDetection();
|
const auto& term_detection = FTermDetection::getInstance();
|
||||||
|
|
||||||
if ( xterm_default_colors
|
if ( xterm_default_colors
|
||||||
&& ! (term_detection.isMinttyTerm()
|
&& ! (term_detection.isMinttyTerm()
|
||||||
|
@ -572,7 +575,7 @@ void FTermXTerminal::resetXTermColorMap() const
|
||||||
{
|
{
|
||||||
// Reset the entire color table
|
// Reset the entire color table
|
||||||
|
|
||||||
if ( FTerm::getFTermDetection().isMinttyTerm() )
|
if ( FTermDetection::getInstance().isMinttyTerm() )
|
||||||
{
|
{
|
||||||
FTerm::putstring (ESC "c"); // Full Reset (RIS)
|
FTerm::putstring (ESC "c"); // Full Reset (RIS)
|
||||||
}
|
}
|
||||||
|
@ -672,7 +675,7 @@ void FTermXTerminal::resetXTermHighlightBackground() const
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
bool FTermXTerminal::canResetColor() const
|
bool FTermXTerminal::canResetColor() const
|
||||||
{
|
{
|
||||||
const auto& term_detection = FTerm::getFTermDetection();
|
const auto& term_detection = FTermDetection::getInstance();
|
||||||
|
|
||||||
if ( term_detection.isGnomeTerminal()
|
if ( term_detection.isGnomeTerminal()
|
||||||
&& term_detection.getGnomeTerminalID() < 3502 )
|
&& term_detection.getGnomeTerminalID() < 3502 )
|
||||||
|
@ -693,7 +696,7 @@ bool FTermXTerminal::canResetColor() const
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermXTerminal::oscPrefix() const
|
void FTermXTerminal::oscPrefix() const
|
||||||
{
|
{
|
||||||
const auto& term_detection = FTerm::getFTermDetection();
|
const auto& term_detection = FTermDetection::getInstance();
|
||||||
|
|
||||||
if ( term_detection.isTmuxTerm() )
|
if ( term_detection.isTmuxTerm() )
|
||||||
{
|
{
|
||||||
|
@ -710,7 +713,7 @@ void FTermXTerminal::oscPrefix() const
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTermXTerminal::oscPostfix() const
|
void FTermXTerminal::oscPostfix() const
|
||||||
{
|
{
|
||||||
const auto& term_detection = FTerm::getFTermDetection();
|
const auto& term_detection = FTermDetection::getInstance();
|
||||||
|
|
||||||
if ( term_detection.isScreenTerm()
|
if ( term_detection.isScreenTerm()
|
||||||
|| term_detection.isTmuxTerm() )
|
|| term_detection.isTmuxTerm() )
|
||||||
|
@ -723,7 +726,7 @@ void FTermXTerminal::oscPostfix() const
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FString FTermXTerminal::captureXTermFont() const
|
FString FTermXTerminal::captureXTermFont() const
|
||||||
{
|
{
|
||||||
const auto& term_detection = FTerm::getFTermDetection();
|
const auto& term_detection = FTermDetection::getInstance();
|
||||||
|
|
||||||
if ( ! term_detection.isXTerminal()
|
if ( ! term_detection.isXTerminal()
|
||||||
&& ! term_detection.isScreenTerm()
|
&& ! term_detection.isScreenTerm()
|
||||||
|
@ -769,12 +772,12 @@ FString FTermXTerminal::captureXTermFont() const
|
||||||
&& temp[3] == '0' && temp[4] == ';' )
|
&& temp[3] == '0' && temp[4] == ';' )
|
||||||
{
|
{
|
||||||
// Skip leading Esc ] 5 0 ;
|
// Skip leading Esc ] 5 0 ;
|
||||||
char* str = &temp[5];
|
std::string str = &temp[5];
|
||||||
const std::size_t n = std::strlen(str);
|
const std::size_t n = str.length();
|
||||||
|
|
||||||
// BEL + '\0' = string terminator
|
// BEL + '\0' = string terminator
|
||||||
if ( n >= 5 && str[n - 1] == BEL[0] && str[n] == '\0' )
|
if ( n >= 5 && str[n - 1] == BEL[0] && str[n] == '\0' )
|
||||||
str[n - 1] = '\0';
|
str.erase(n - 1);
|
||||||
|
|
||||||
return {str};
|
return {str};
|
||||||
}
|
}
|
||||||
|
@ -785,7 +788,7 @@ FString FTermXTerminal::captureXTermFont() const
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FString FTermXTerminal::captureXTermTitle() const
|
FString FTermXTerminal::captureXTermTitle() const
|
||||||
{
|
{
|
||||||
if ( FTerm::getFTermDetection().isKdeTerminal() )
|
if ( FTermDetection::getInstance().isKdeTerminal() )
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
fd_set ifds{};
|
fd_set ifds{};
|
||||||
|
@ -822,8 +825,8 @@ FString FTermXTerminal::captureXTermTitle() const
|
||||||
if ( pos > 6 && temp[0] == ESC[0] && temp[1] == ']' && temp[2] == 'l' )
|
if ( pos > 6 && temp[0] == ESC[0] && temp[1] == ']' && temp[2] == 'l' )
|
||||||
{
|
{
|
||||||
// Skip leading Esc + ] + l = OSC l
|
// Skip leading Esc + ] + l = OSC l
|
||||||
char* str = &temp[3];
|
std::string str = &temp[3];
|
||||||
const std::size_t n = std::strlen(str);
|
const std::size_t n = str.length();
|
||||||
|
|
||||||
// Esc + \ = OSC string terminator
|
// Esc + \ = OSC string terminator
|
||||||
if ( n >= 2 && str[n - 2] == ESC[0] && str[n - 1] == '\\' )
|
if ( n >= 2 && str[n - 2] == ESC[0] && str[n - 1] == '\\' )
|
||||||
|
@ -831,7 +834,7 @@ FString FTermXTerminal::captureXTermTitle() const
|
||||||
if ( n < 4 )
|
if ( n < 4 )
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
str[n - 2] = '\0';
|
str.erase(n - 2);
|
||||||
return {str};
|
return {str};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,7 +225,7 @@ void FTextView::insert (const FString& str, int pos)
|
||||||
else
|
else
|
||||||
s = FString{str}.rtrim().expandTabs(FTerm::getTabstop());
|
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
|
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)
|
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()) )
|
if ( from > to || from >= int(getRows()) || to >= int(getRows()) )
|
||||||
return;
|
throw std::out_of_range(""); // Invalid range
|
||||||
|
|
||||||
auto iter = data.begin();
|
auto iter = data.begin();
|
||||||
data.erase (iter + from, iter + to + 1);
|
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 *
|
* 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 *
|
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU Lesser General Public License as *
|
* it under the terms of the GNU Lesser General Public License as *
|
||||||
|
@ -383,7 +383,7 @@ void FToggleButton::draw()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FToggleButton::drawLabel()
|
void FToggleButton::drawLabel()
|
||||||
{
|
{
|
||||||
if ( text.isNull() || text.isEmpty() )
|
if ( text.isEmpty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const FString txt(text);
|
const FString txt(text);
|
||||||
|
|
|
@ -42,7 +42,7 @@ FToolTip::FToolTip (FWidget* parent)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FToolTip::FToolTip (const FString& txt, FWidget* parent)
|
FToolTip::FToolTip (const FString& txt, FWidget* parent)
|
||||||
: FWindow{parent}
|
: FWindow{parent}
|
||||||
, text{txt}
|
, text{txt.trim()}
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ FToolTip::~FToolTip() // destructor
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FToolTip::setText (const FString& txt)
|
void FToolTip::setText (const FString& txt)
|
||||||
{
|
{
|
||||||
text.setString(txt);
|
text.setString(txt.trim());
|
||||||
calculateDimensions();
|
calculateDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,14 +61,12 @@ bool FVTerm::force_terminal_update{false};
|
||||||
uInt64 FVTerm::flush_wait{MIN_FLUSH_WAIT};
|
uInt64 FVTerm::flush_wait{MIN_FLUSH_WAIT};
|
||||||
uInt64 FVTerm::flush_average{MIN_FLUSH_WAIT};
|
uInt64 FVTerm::flush_average{MIN_FLUSH_WAIT};
|
||||||
uInt64 FVTerm::flush_median{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::erase_char_length{};
|
||||||
uInt FVTerm::repeat_char_length{};
|
uInt FVTerm::repeat_char_length{};
|
||||||
uInt FVTerm::clr_bol_length{};
|
uInt FVTerm::clr_bol_length{};
|
||||||
uInt FVTerm::clr_eol_length{};
|
uInt FVTerm::clr_eol_length{};
|
||||||
uInt FVTerm::cursor_address_length{};
|
uInt FVTerm::cursor_address_length{};
|
||||||
struct timeval FVTerm::time_last_flush{};
|
TimeValue FVTerm::time_last_flush{};
|
||||||
struct timeval FVTerm::last_term_size_check{};
|
|
||||||
const FVTerm* FVTerm::init_object{nullptr};
|
const FVTerm* FVTerm::init_object{nullptr};
|
||||||
FVTerm::FTermArea* FVTerm::vterm{nullptr};
|
FVTerm::FTermArea* FVTerm::vterm{nullptr};
|
||||||
FVTerm::FTermArea* FVTerm::vdesktop{nullptr};
|
FVTerm::FTermArea* FVTerm::vdesktop{nullptr};
|
||||||
|
@ -185,9 +183,9 @@ void FVTerm::hideCursor (bool enable) const
|
||||||
if ( ! cursor_hideable )
|
if ( ! cursor_hideable )
|
||||||
return;
|
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;
|
return;
|
||||||
|
|
||||||
appendOutputBuffer(FTermControl{visibility_str});
|
appendOutputBuffer(FTermControl{visibility_str});
|
||||||
|
@ -342,8 +340,8 @@ void FVTerm::delPreprocessingHandler (const FVTerm* instance)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
int FVTerm::print (const FString& string)
|
int FVTerm::print (const FString& string)
|
||||||
{
|
{
|
||||||
if ( string.isNull() )
|
if ( string.isEmpty() )
|
||||||
return -1;
|
return 0;
|
||||||
|
|
||||||
FTermBuffer term_buffer{};
|
FTermBuffer term_buffer{};
|
||||||
term_buffer.write(string);
|
term_buffer.write(string);
|
||||||
|
@ -353,7 +351,7 @@ int FVTerm::print (const FString& string)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
int FVTerm::print (FTermArea* area, const FString& string)
|
int FVTerm::print (FTermArea* area, const FString& string)
|
||||||
{
|
{
|
||||||
if ( ! area || string.isNull() )
|
if ( ! area || string.isEmpty() )
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
FTermBuffer term_buffer{};
|
FTermBuffer term_buffer{};
|
||||||
|
@ -601,9 +599,9 @@ void FVTerm::flush() const
|
||||||
}
|
}
|
||||||
|
|
||||||
std::fflush(stdout);
|
std::fflush(stdout);
|
||||||
auto& mouse = FTerm::getFMouseControl();
|
auto& mouse = FMouseControl::getInstance();
|
||||||
mouse.drawPointer();
|
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 x = pos.getX();
|
||||||
const int y = pos.getY();
|
const int y = pos.getY();
|
||||||
int xx = ( x > 0 ) ? x : 0;
|
int xx = std::max(x, 0);
|
||||||
int yy = ( y > 0 ) ? y : 0;
|
int yy = std::max(y, 0);
|
||||||
|
|
||||||
if ( xx >= vterm->width )
|
if ( xx >= vterm->width )
|
||||||
xx = vterm->width - 1;
|
xx = vterm->width - 1;
|
||||||
|
@ -1876,17 +1874,14 @@ void FVTerm::init()
|
||||||
vdesktop->visible = true;
|
vdesktop->visible = true;
|
||||||
active_area = vdesktop;
|
active_area = vdesktop;
|
||||||
|
|
||||||
// Initialize the flush and last terminal size check time
|
// Initialize the last flush time
|
||||||
time_last_flush.tv_sec = 0;
|
time_last_flush = TimeValue{};
|
||||||
time_last_flush.tv_usec = 0;
|
|
||||||
last_term_size_check.tv_sec = 0;
|
|
||||||
last_term_size_check.tv_usec = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FVTerm::init_characterLengths()
|
void FVTerm::init_characterLengths()
|
||||||
{
|
{
|
||||||
const auto& opti_move = FTerm::getFOptiMove();
|
const auto& opti_move = FOptiMove::getInstance();
|
||||||
cursor_address_length = opti_move.getCursorAddressLength();
|
cursor_address_length = opti_move.getCursorAddressLength();
|
||||||
erase_char_length = opti_move.getEraseCharsLength();
|
erase_char_length = opti_move.getEraseCharsLength();
|
||||||
repeat_char_length = opti_move.getRepeatCharLength();
|
repeat_char_length = opti_move.getRepeatCharLength();
|
||||||
|
@ -1920,7 +1915,7 @@ void FVTerm::init_combined_character()
|
||||||
if ( FTerm::getEncoding() != Encoding::UTF8 )
|
if ( FTerm::getEncoding() != Encoding::UTF8 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto& term_detection = FTerm::getFTermDetection();
|
const auto& term_detection = FTermDetection::getInstance();
|
||||||
|
|
||||||
if ( term_detection.isCygwinTerminal() )
|
if ( term_detection.isCygwinTerminal() )
|
||||||
return;
|
return;
|
||||||
|
@ -1944,7 +1939,7 @@ void FVTerm::finish() const
|
||||||
setNormal();
|
setNormal();
|
||||||
|
|
||||||
if ( FTerm::hasAlternateScreen()
|
if ( FTerm::hasAlternateScreen()
|
||||||
&& FTerm::getFTermData().isInAlternateScreen() )
|
&& FTermData::getInstance().isInAlternateScreen() )
|
||||||
clearTerm();
|
clearTerm();
|
||||||
|
|
||||||
forceTerminalUpdate();
|
forceTerminalUpdate();
|
||||||
|
@ -2879,33 +2874,13 @@ bool FVTerm::isInsideTerminal (const FPoint& pos) const
|
||||||
return false;
|
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
|
inline void FVTerm::flushTimeAdjustment() const
|
||||||
{
|
{
|
||||||
timeval now;
|
const auto now = FObject::getCurrentTime();
|
||||||
FObject::getCurrentTime(&now);
|
const auto diff = now - time_last_flush;
|
||||||
timeval 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_wait = MIN_FLUSH_WAIT; // Reset to minimum values after 400 ms
|
||||||
flush_average = MIN_FLUSH_WAIT;
|
flush_average = MIN_FLUSH_WAIT;
|
||||||
|
@ -2913,7 +2888,7 @@ inline void FVTerm::flushTimeAdjustment() const
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto usec = uInt64(diff.tv_usec);
|
auto usec = uInt64(duration_cast<microseconds>(diff).count());
|
||||||
|
|
||||||
if ( usec < MIN_FLUSH_WAIT )
|
if ( usec < MIN_FLUSH_WAIT )
|
||||||
usec = MIN_FLUSH_WAIT;
|
usec = MIN_FLUSH_WAIT;
|
||||||
|
@ -2947,13 +2922,7 @@ inline void FVTerm::flushTimeAdjustment() const
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FVTerm::isFlushTimeout()
|
inline bool FVTerm::isFlushTimeout()
|
||||||
{
|
{
|
||||||
return FObject::isTimeout (&time_last_flush, flush_wait);
|
return FObject::isTimeout (time_last_flush, flush_wait);
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
inline bool FVTerm::isTermSizeCheckTimeout()
|
|
||||||
{
|
|
||||||
return FObject::isTimeout (&last_term_size_check, term_size_check_timeout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -3080,7 +3049,7 @@ inline void FVTerm::appendAttributes (FChar& next_attr) const
|
||||||
// generate attribute string for the next character
|
// generate attribute string for the next character
|
||||||
const auto& attr_str = FTerm::changeAttribute (term_attribute, next_attr);
|
const auto& attr_str = FTerm::changeAttribute (term_attribute, next_attr);
|
||||||
|
|
||||||
if ( attr_str )
|
if ( ! attr_str.empty() )
|
||||||
appendOutputBuffer (FTermControl{attr_str});
|
appendOutputBuffer (FTermControl{attr_str});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
* <http://www.gnu.org/licenses/>. *
|
* <http://www.gnu.org/licenses/>. *
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "final/fapplication.h"
|
#include "final/fapplication.h"
|
||||||
|
@ -84,7 +85,7 @@ FWidget::FWidget (FWidget* parent)
|
||||||
{
|
{
|
||||||
if ( internal::var::root_widget )
|
if ( internal::var::root_widget )
|
||||||
{
|
{
|
||||||
auto& fterm_data = FTerm::getFTermData();
|
auto& fterm_data = FTermData::getInstance();
|
||||||
fterm_data.setExitMessage("FWidget: No parent defined! "
|
fterm_data.setExitMessage("FWidget: No parent defined! "
|
||||||
"There should be only one root object");
|
"There should be only one root object");
|
||||||
FApplication::exit(EXIT_FAILURE);
|
FApplication::exit(EXIT_FAILURE);
|
||||||
|
@ -405,7 +406,7 @@ void FWidget::setPos (const FPoint& p, bool adjust)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! isWindowWidget() )
|
if ( ! isWindowWidget() ) // A widgets must be inside the client area
|
||||||
{
|
{
|
||||||
if ( pos.getX() < 1 )
|
if ( pos.getX() < 1 )
|
||||||
pos.setX(1);
|
pos.setX(1);
|
||||||
|
@ -430,7 +431,7 @@ void FWidget::setWidth (std::size_t width, bool adjust)
|
||||||
if ( getWidth() == width && wsize.getWidth() == width )
|
if ( getWidth() == width && wsize.getWidth() == width )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( width < 1 )
|
if ( width < 1 ) // A width can never be narrower than 1 character
|
||||||
width = 1;
|
width = 1;
|
||||||
|
|
||||||
wsize.setWidth(width);
|
wsize.setWidth(width);
|
||||||
|
@ -452,7 +453,7 @@ void FWidget::setHeight (std::size_t height, bool adjust)
|
||||||
if ( getHeight() == height && wsize.getHeight() == height )
|
if ( getHeight() == height && wsize.getHeight() == height )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( height < 1 )
|
if ( height < 1 ) // A height can never be narrower than 1 character
|
||||||
height = 1;
|
height = 1;
|
||||||
|
|
||||||
wsize.setHeight(height);
|
wsize.setHeight(height);
|
||||||
|
@ -479,10 +480,10 @@ void FWidget::setSize (const FSize& size, bool adjust)
|
||||||
&& getHeight() == height && wsize.getHeight() == height )
|
&& getHeight() == height && wsize.getHeight() == height )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( width < 1 )
|
if ( width < 1 ) // A width can never be narrower than 1 character
|
||||||
width = 1;
|
width = 1;
|
||||||
|
|
||||||
if ( height < 1 )
|
if ( height < 1 ) // A height can never be narrower than 1 character
|
||||||
height = 1;
|
height = 1;
|
||||||
|
|
||||||
wsize.setWidth(width);
|
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 )
|
if ( getPos() == p && getWidth() == w && getHeight() == h )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( ! isWindowWidget() )
|
if ( isWindowWidget() ) // A window widget can be outside
|
||||||
{
|
|
||||||
( x < 1 ) ? wsize.setX(1) : wsize.setX(x);
|
|
||||||
( y < 1 ) ? wsize.setY(1) : wsize.setY(y);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
wsize.setX(x);
|
wsize.setX(x);
|
||||||
wsize.setY(y);
|
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);
|
wsize.setWidth(std::max(w, std::size_t(1u)));
|
||||||
( h < 1 ) ? wsize.setHeight(1) : wsize.setHeight(h);
|
wsize.setHeight(std::max(h, std::size_t(1u)));
|
||||||
|
|
||||||
adjust_wsize = wsize;
|
adjust_wsize = wsize;
|
||||||
const int term_x = getTermX();
|
const int term_x = getTermX();
|
||||||
const int term_y = getTermY();
|
const int term_y = getTermY();
|
||||||
|
@ -851,7 +851,7 @@ bool FWidget::close()
|
||||||
{
|
{
|
||||||
hide();
|
hide();
|
||||||
|
|
||||||
if ( ! flags.modal )
|
if ( ! flags.modal && ! isInFWidgetList(close_widget, this) )
|
||||||
close_widget->push_back(this);
|
close_widget->push_back(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2082,7 +2082,7 @@ void FWidget::initColorTheme()
|
||||||
if ( getColorTheme().use_count() > 0 && ! isDefaultTheme() )
|
if ( getColorTheme().use_count() > 0 && ! isDefaultTheme() )
|
||||||
return; // A user theme is in use
|
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
|
if ( FTerm::getMaxColor() < 16 ) // for 8 color mode
|
||||||
setColorTheme<default8ColorDarkTheme>();
|
setColorTheme<default8ColorDarkTheme>();
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
* <http://www.gnu.org/licenses/>. *
|
* <http://www.gnu.org/licenses/>. *
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "final/fapplication.h"
|
#include "final/fapplication.h"
|
||||||
#include "final/fcolorpair.h"
|
#include "final/fcolorpair.h"
|
||||||
#include "final/fstatusbar.h"
|
#include "final/fstatusbar.h"
|
||||||
|
@ -53,6 +55,16 @@ bool isFocusPrevKey (const FKey key)
|
||||||
return false;
|
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()
|
FApplication* getFApplication()
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* *
|
* *
|
||||||
* This file is part of the FINAL CUT widget toolkit *
|
* 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 *
|
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU Lesser General Public License as *
|
* it under the terms of the GNU Lesser General Public License as *
|
||||||
|
@ -238,7 +238,7 @@ class FApplication : public FWidget
|
||||||
FWidget* clicked_widget{};
|
FWidget* clicked_widget{};
|
||||||
FEventQueue event_queue{};
|
FEventQueue event_queue{};
|
||||||
static uInt64 next_event_wait;
|
static uInt64 next_event_wait;
|
||||||
static timeval time_last_event;
|
static TimeValue time_last_event;
|
||||||
static int loop_level;
|
static int loop_level;
|
||||||
static int quit_code;
|
static int quit_code;
|
||||||
static bool quit_now;
|
static bool quit_now;
|
||||||
|
|
|
@ -120,6 +120,7 @@ class FButton : public FWidget
|
||||||
void onMouseDown (FMouseEvent*) override;
|
void onMouseDown (FMouseEvent*) override;
|
||||||
void onMouseUp (FMouseEvent*) override;
|
void onMouseUp (FMouseEvent*) override;
|
||||||
void onMouseMove (FMouseEvent*) override;
|
void onMouseMove (FMouseEvent*) override;
|
||||||
|
void onWheel (FWheelEvent*) override;
|
||||||
void onTimer (FTimerEvent*) override;
|
void onTimer (FTimerEvent*) override;
|
||||||
void onAccel (FAccelEvent*) override;
|
void onAccel (FAccelEvent*) override;
|
||||||
void onFocusIn (FFocusEvent*) override;
|
void onFocusIn (FFocusEvent*) override;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* *
|
* *
|
||||||
* This file is part of the FINAL CUT widget toolkit *
|
* 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 *
|
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU Lesser General Public License as *
|
* it under the terms of the GNU Lesser General Public License as *
|
||||||
|
@ -30,14 +30,16 @@
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
#include "final/fc.h"
|
#include "final/fc.h"
|
||||||
|
#include "final/fstring.h"
|
||||||
#include "final/ftypes.h"
|
#include "final/ftypes.h"
|
||||||
|
|
||||||
|
|
||||||
namespace finalcut
|
namespace finalcut
|
||||||
{
|
{
|
||||||
|
|
||||||
namespace fc
|
class FCharMap final
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
// Unicode fallback table for VT100, PC, and ASCII
|
// Unicode fallback table for VT100, PC, and ASCII
|
||||||
struct CharEncodeMap
|
struct CharEncodeMap
|
||||||
{
|
{
|
||||||
|
@ -47,14 +49,6 @@ struct CharEncodeMap
|
||||||
wchar_t ascii;
|
wchar_t ascii;
|
||||||
};
|
};
|
||||||
|
|
||||||
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
|
// vt100 <-> utf-8
|
||||||
struct DECSpecialGraphics
|
struct DECSpecialGraphics
|
||||||
{
|
{
|
||||||
|
@ -62,11 +56,37 @@ struct DECSpecialGraphics
|
||||||
UniChar unicode;
|
UniChar unicode;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const std::array<DECSpecialGraphics, 39> dec_special_graphics;
|
// Using-declaration
|
||||||
extern const std::array<std::array<wchar_t, 2>, 256> cp437_ucs;
|
using CharEncodeType = std::array<CharEncodeMap, 115>;
|
||||||
extern const std::array<std::array<wchar_t, 2>, 227> halfwidth_fullwidth;
|
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>;
|
||||||
|
|
||||||
} // namespace fc
|
// Constructors
|
||||||
|
FCharMap() = default;
|
||||||
|
|
||||||
|
// Accessors
|
||||||
|
FString getClassName() const;
|
||||||
|
static auto getInstance() -> FCharMap&;
|
||||||
|
static wchar_t& getCharacter ( CharEncodeMap& char_enc
|
||||||
|
, const Encoding& enc );
|
||||||
|
static CharEncodeType& getCharEncodeMap();
|
||||||
|
static const DECGraphicsType& getDECSpecialGraphics();
|
||||||
|
static const Cp437UcsType& getCP437UCSMap();
|
||||||
|
static const HalfFullWidthType& getHalfFullWidthMap();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Data members
|
||||||
|
static CharEncodeType character;
|
||||||
|
static const DECGraphicsType dec_special_graphics;
|
||||||
|
static const Cp437UcsType cp437_ucs;
|
||||||
|
static const HalfFullWidthType halfwidth_fullwidth;
|
||||||
|
};
|
||||||
|
|
||||||
|
// FCharMap inline functions
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
inline FString FCharMap::getClassName() const
|
||||||
|
{ return "FCharMap"; }
|
||||||
|
|
||||||
} // namespace finalcut
|
} // namespace finalcut
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* *
|
* *
|
||||||
* This file is part of the FINAL CUT widget toolkit *
|
* 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 *
|
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU Lesser General Public License as *
|
* it under the terms of the GNU Lesser General Public License as *
|
||||||
|
@ -60,6 +60,7 @@ class FColorPalette
|
||||||
|
|
||||||
// Accessor
|
// Accessor
|
||||||
virtual FString getClassName() const;
|
virtual FString getClassName() const;
|
||||||
|
static auto getInstance() -> std::shared_ptr<FColorPalette>&;
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
virtual void setColorPalette() = 0;
|
virtual void setColorPalette() = 0;
|
||||||
|
|
|
@ -30,9 +30,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Define to 1 if you have the `getttynam' function. */
|
/* Define to 1 if you have the `getttynam' function. */
|
||||||
#ifndef F_HAVE_GETTTYNAM
|
/* #undef HAVE_GETTTYNAM */
|
||||||
#define F_HAVE_GETTTYNAM 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `getuid' function. */
|
/* Define to 1 if you have the `getuid' function. */
|
||||||
#ifndef F_HAVE_GETUID
|
#ifndef F_HAVE_GETUID
|
||||||
|
@ -50,9 +48,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Define to 1 if GPM mouse is enabled */
|
/* Define to 1 if GPM mouse is enabled */
|
||||||
#ifndef F_HAVE_LIBGPM
|
/* #undef HAVE_LIBGPM */
|
||||||
#define F_HAVE_LIBGPM 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <linux/fb.h> header file. */
|
/* Define to 1 if you have the <linux/fb.h> header file. */
|
||||||
#ifndef F_HAVE_LINUX_FB_H
|
#ifndef F_HAVE_LINUX_FB_H
|
||||||
|
@ -144,9 +140,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Define to 1 if you have the <ttyent.h> header file. */
|
/* Define to 1 if you have the <ttyent.h> header file. */
|
||||||
#ifndef F_HAVE_TTYENT_H
|
/* #undef HAVE_TTYENT_H */
|
||||||
#define F_HAVE_TTYENT_H 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <unistd.h> header file. */
|
/* Define to 1 if you have the <unistd.h> header file. */
|
||||||
#ifndef F_HAVE_UNISTD_H
|
#ifndef F_HAVE_UNISTD_H
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* *
|
* *
|
||||||
* This file is part of the FINAL CUT widget toolkit *
|
* 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 *
|
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU Lesser General Public License as *
|
* it under the terms of the GNU Lesser General Public License as *
|
||||||
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
#include "final/fstring.h"
|
||||||
#include "final/ftypes.h"
|
#include "final/ftypes.h"
|
||||||
|
|
||||||
namespace finalcut
|
namespace finalcut
|
||||||
|
@ -36,35 +37,54 @@ namespace finalcut
|
||||||
|
|
||||||
enum class FKey : uInt32; // forward declaration
|
enum class FKey : uInt32; // forward declaration
|
||||||
|
|
||||||
namespace fc
|
class FKeyMap final
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
struct FKeyCapMap
|
struct KeyCapMap
|
||||||
{
|
{
|
||||||
FKey num;
|
FKey num;
|
||||||
const char* string;
|
const char* string;
|
||||||
char tname[4];
|
char tname[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
extern std::array<FKeyCapMap, 188> fkey_cap_table;
|
struct KeyMap
|
||||||
|
|
||||||
struct FKeyMap
|
|
||||||
{
|
{
|
||||||
FKey num;
|
FKey num;
|
||||||
char string[8];
|
char string[8];
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const std::array<FKeyMap, 232> fkey_table;
|
struct KeyName
|
||||||
|
|
||||||
struct FKeyName
|
|
||||||
{
|
{
|
||||||
FKey num;
|
FKey num;
|
||||||
char string[26];
|
char string[26];
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const std::array<FKeyName, 388> fkeyname;
|
// Using-declaration
|
||||||
|
using KeyCapMapType = std::array<KeyCapMap, 188>;
|
||||||
|
using KeyMapType = std::array<KeyMap, 232>;
|
||||||
|
using KeyNameType = std::array<KeyName, 388>;
|
||||||
|
|
||||||
} // namespace fc
|
// Constructors
|
||||||
|
FKeyMap() = default;
|
||||||
|
|
||||||
|
// Accessors
|
||||||
|
FString getClassName() const;
|
||||||
|
static auto getInstance() -> FKeyMap&;
|
||||||
|
static KeyCapMapType& getKeyCapMap();
|
||||||
|
static const KeyMapType& getKeyMap();
|
||||||
|
static const KeyNameType& getKeyName();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Data members
|
||||||
|
static KeyCapMapType fkey_cap_table;
|
||||||
|
static const KeyMapType fkey_table;
|
||||||
|
static const KeyNameType fkeyname;
|
||||||
|
};
|
||||||
|
|
||||||
|
// FKeyMap inline functions
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
inline FString FKeyMap::getClassName() const
|
||||||
|
{ return "FKeyMap"; }
|
||||||
|
|
||||||
} // namespace finalcut
|
} // namespace finalcut
|
||||||
|
|
||||||
|
|
|
@ -105,10 +105,11 @@ class FKeyboard final
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
FString getClassName() const;
|
FString getClassName() const;
|
||||||
|
static auto getInstance() -> FKeyboard&;
|
||||||
FKey getKey() const;
|
FKey getKey() const;
|
||||||
FString getKeyName (const FKey) const;
|
FString getKeyName (const FKey) const;
|
||||||
keybuffer& getKeyBuffer();
|
keybuffer& getKeyBuffer();
|
||||||
timeval* getKeyPressedTime();
|
TimeValue getKeyPressedTime() const;
|
||||||
static uInt64 getKeypressTimeout();
|
static uInt64 getKeypressTimeout();
|
||||||
static uInt64 getReadBlockingTime();
|
static uInt64 getReadBlockingTime();
|
||||||
|
|
||||||
|
@ -145,7 +146,7 @@ class FKeyboard final
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Using-declaration
|
// Using-declaration
|
||||||
using FKeyMapPtr = std::shared_ptr<decltype(fc::fkey_cap_table)>;
|
using FKeyMapPtr = std::shared_ptr<FKeyMap::KeyCapMapType>;
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
static constexpr FKey NOT_SET = static_cast<FKey>(-1);
|
static constexpr FKey NOT_SET = static_cast<FKey>(-1);
|
||||||
|
@ -162,7 +163,7 @@ class FKeyboard final
|
||||||
static bool isIntervalTimeout();
|
static bool isIntervalTimeout();
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
FKey UTF8decode (const char[]) const;
|
FKey UTF8decode (const std::string&) const;
|
||||||
ssize_t readKey();
|
ssize_t readKey();
|
||||||
void parseKeyBuffer();
|
void parseKeyBuffer();
|
||||||
FKey parseKeyString();
|
FKey parseKeyString();
|
||||||
|
@ -179,7 +180,7 @@ class FKeyboard final
|
||||||
FKeyboardCommand escape_key_cmd{};
|
FKeyboardCommand escape_key_cmd{};
|
||||||
FKeyboardCommand mouse_tracking_cmd{};
|
FKeyboardCommand mouse_tracking_cmd{};
|
||||||
|
|
||||||
static timeval time_keypressed;
|
static TimeValue time_keypressed;
|
||||||
static uInt64 read_blocking_time;
|
static uInt64 read_blocking_time;
|
||||||
static uInt64 read_blocking_time_short;
|
static uInt64 read_blocking_time_short;
|
||||||
static uInt64 key_timeout;
|
static uInt64 key_timeout;
|
||||||
|
@ -214,8 +215,8 @@ inline FKeyboard::keybuffer& FKeyboard::getKeyBuffer()
|
||||||
{ return fifo_buf; }
|
{ return fifo_buf; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline timeval* FKeyboard::getKeyPressedTime()
|
inline TimeValue FKeyboard::getKeyPressedTime() const
|
||||||
{ return &time_keypressed; }
|
{ return time_keypressed; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline uInt64 FKeyboard::getKeypressTimeout()
|
inline uInt64 FKeyboard::getKeypressTimeout()
|
||||||
|
@ -233,8 +234,8 @@ inline void FKeyboard::setTermcapMap (const T& keymap)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FKeyboard::setTermcapMap ()
|
inline void FKeyboard::setTermcapMap ()
|
||||||
{
|
{
|
||||||
using type = decltype(fc::fkey_cap_table);
|
using type = FKeyMap::KeyCapMapType;
|
||||||
key_map = std::make_shared<type>(fc::fkey_cap_table);
|
key_map = std::make_shared<type>(FKeyMap::getKeyCapMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
|
@ -178,7 +178,7 @@ class FListBox : public FWidget
|
||||||
FListBox (Iterator, Iterator, InsertConverter, FWidget* = nullptr);
|
FListBox (Iterator, Iterator, InsertConverter, FWidget* = nullptr);
|
||||||
template <typename Container
|
template <typename Container
|
||||||
, typename LazyConverter>
|
, typename LazyConverter>
|
||||||
FListBox (Container, LazyConverter, FWidget* = nullptr);
|
FListBox (Container, LazyConverter&&, FWidget* = nullptr);
|
||||||
|
|
||||||
// Disable copy constructor
|
// Disable copy constructor
|
||||||
FListBox (const FListBox&) = delete;
|
FListBox (const FListBox&) = delete;
|
||||||
|
@ -235,10 +235,10 @@ class FListBox : public FWidget
|
||||||
template <typename Container
|
template <typename Container
|
||||||
, typename LazyConverter>
|
, typename LazyConverter>
|
||||||
void insert ( const Container&
|
void insert ( const Container&
|
||||||
, const LazyConverter& );
|
, LazyConverter&& );
|
||||||
template <typename Container
|
template <typename Container
|
||||||
, typename LazyConverter>
|
, typename LazyConverter>
|
||||||
void insert (Container*, const LazyConverter&);
|
void insert (Container*, LazyConverter&&);
|
||||||
void insert (const FListBoxItem&);
|
void insert (const FListBoxItem&);
|
||||||
template <typename T
|
template <typename T
|
||||||
, typename DT = std::nullptr_t>
|
, typename DT = std::nullptr_t>
|
||||||
|
@ -417,12 +417,12 @@ inline FListBox::FListBox ( Iterator first
|
||||||
template <typename Container
|
template <typename Container
|
||||||
, typename LazyConverter>
|
, typename LazyConverter>
|
||||||
inline FListBox::FListBox ( Container container
|
inline FListBox::FListBox ( Container container
|
||||||
, LazyConverter convert
|
, LazyConverter&& convert
|
||||||
, FWidget* parent )
|
, FWidget* parent )
|
||||||
: FWidget{parent}
|
: FWidget{parent}
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
insert (container, convert);
|
insert (container, std::forward<LazyConverter>(convert));
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -550,11 +550,11 @@ inline void FListBox::insert ( Iterator first
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template <typename Container
|
template <typename Container
|
||||||
, typename LazyConverter>
|
, typename LazyConverter>
|
||||||
void FListBox::insert (const Container& container, const LazyConverter& converter)
|
void FListBox::insert (const Container& container, LazyConverter&& converter)
|
||||||
{
|
{
|
||||||
conv_type = ConvertType::Lazy;
|
conv_type = ConvertType::Lazy;
|
||||||
source_container = makeFData(container);
|
source_container = makeFData(container);
|
||||||
lazy_inserter = converter;
|
lazy_inserter = std::forward<LazyConverter>(converter);
|
||||||
const std::size_t size = container.size();
|
const std::size_t size = container.size();
|
||||||
|
|
||||||
if ( size > 0 )
|
if ( size > 0 )
|
||||||
|
@ -566,9 +566,9 @@ void FListBox::insert (const Container& container, const LazyConverter& converte
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
template <typename Container
|
template <typename Container
|
||||||
, typename LazyConverter>
|
, 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();
|
bool unsetTreeView();
|
||||||
|
|
||||||
// Methods
|
// 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);
|
virtual int addColumn (const FString&, int = USE_MAX_SIZE);
|
||||||
void hide() override;
|
void hide() override;
|
||||||
iterator insert (FListViewItem*);
|
iterator insert (FListViewItem*);
|
||||||
|
@ -441,9 +447,9 @@ class FListView : public FWidget
|
||||||
void drawScrollbars() const;
|
void drawScrollbars() const;
|
||||||
void drawHeadlines();
|
void drawHeadlines();
|
||||||
void drawList();
|
void drawList();
|
||||||
void drawListLine (const FListViewItem*, bool, bool);
|
void drawListLine (const FListViewItem*, bool, bool, bool, bool);
|
||||||
void clearList();
|
void clearList();
|
||||||
void setLineAttributes (bool, bool) const;
|
void setLineAttributes (bool, bool, bool, bool) const;
|
||||||
FString getCheckBox (const FListViewItem* item) const;
|
FString getCheckBox (const FListViewItem* item) const;
|
||||||
FString getLinePrefix (const FListViewItem*, std::size_t) const;
|
FString getLinePrefix (const FListViewItem*, std::size_t) const;
|
||||||
void drawSortIndicator (std::size_t&, std::size_t);
|
void drawSortIndicator (std::size_t&, std::size_t);
|
||||||
|
@ -498,6 +504,7 @@ class FListView : public FWidget
|
||||||
FObjectList selflist{};
|
FObjectList selflist{};
|
||||||
FObjectList itemlist{};
|
FObjectList itemlist{};
|
||||||
FListViewIterator current_iter{};
|
FListViewIterator current_iter{};
|
||||||
|
FListViewIterator mark_iter{};
|
||||||
FListViewIterator first_visible_line{};
|
FListViewIterator first_visible_line{};
|
||||||
FListViewIterator last_visible_line{};
|
FListViewIterator last_visible_line{};
|
||||||
HeaderItems header{};
|
HeaderItems header{};
|
||||||
|
@ -523,7 +530,7 @@ class FListView : public FWidget
|
||||||
bool tree_view{false};
|
bool tree_view{false};
|
||||||
bool hide_sort_indicator{false};
|
bool hide_sort_indicator{false};
|
||||||
bool has_checkable_items{false};
|
bool has_checkable_items{false};
|
||||||
|
std::vector<FListViewIterator> multi;
|
||||||
// Function Pointer
|
// Function Pointer
|
||||||
bool (*user_defined_ascending) (const FObject*, const FObject*){nullptr};
|
bool (*user_defined_ascending) (const FObject*, const FObject*){nullptr};
|
||||||
bool (*user_defined_descending) (const FObject*, const FObject*){nullptr};
|
bool (*user_defined_descending) (const FObject*, const FObject*){nullptr};
|
||||||
|
|
|
@ -98,12 +98,18 @@ class FMouseData
|
||||||
// Copy constructor
|
// Copy constructor
|
||||||
FMouseData (const FMouseData&) = default;
|
FMouseData (const FMouseData&) = default;
|
||||||
|
|
||||||
|
// Move constructor
|
||||||
|
FMouseData (FMouseData&&) noexcept = default;
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
virtual ~FMouseData() noexcept;
|
virtual ~FMouseData() noexcept;
|
||||||
|
|
||||||
// copy assignment operator (=)
|
// copy assignment operator (=)
|
||||||
FMouseData& operator = (const FMouseData&) = default;
|
FMouseData& operator = (const FMouseData&) = default;
|
||||||
|
|
||||||
|
// Move assignment operator (=)
|
||||||
|
FMouseData& operator = (FMouseData&&) noexcept = default;
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
virtual FString getClassName() const;
|
virtual FString getClassName() const;
|
||||||
const FPoint& getPos() const;
|
const FPoint& getPos() const;
|
||||||
|
@ -201,7 +207,7 @@ class FMouse : public FMouseData
|
||||||
template <typename ClassT>
|
template <typename ClassT>
|
||||||
static FMouse* createMouseObject ();
|
static FMouse* createMouseObject ();
|
||||||
virtual void setRawData (FKeyboard::keybuffer&) = 0;
|
virtual void setRawData (FKeyboard::keybuffer&) = 0;
|
||||||
virtual void processEvent (struct timeval*) = 0;
|
virtual void processEvent (const TimeValue&) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Accessors
|
// Accessors
|
||||||
|
@ -209,17 +215,17 @@ class FMouse : public FMouseData
|
||||||
uInt16 getMaxWidth() const;
|
uInt16 getMaxWidth() const;
|
||||||
uInt16 getMaxHeight() const;
|
uInt16 getMaxHeight() const;
|
||||||
uInt64 getDblclickInterval() const;
|
uInt64 getDblclickInterval() const;
|
||||||
timeval* getMousePressedTime();
|
TimeValue getMousePressedTime() const;
|
||||||
|
|
||||||
// Mutator
|
// Mutator
|
||||||
void setNewPos (int, int);
|
void setNewPos (int, int);
|
||||||
void setPending (bool = true);
|
void setPending (bool = true);
|
||||||
void setEvent();
|
void setEvent();
|
||||||
void setMousePressedTime (const timeval*);
|
void setMousePressedTime (const TimeValue&);
|
||||||
void resetMousePressedTime();
|
void resetMousePressedTime();
|
||||||
|
|
||||||
// Inquiry
|
// Inquiry
|
||||||
bool isDblclickTimeout (const timeval*) const;
|
bool isDblclickTimeout (const TimeValue&) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Data members
|
// Data members
|
||||||
|
@ -228,7 +234,7 @@ class FMouse : public FMouseData
|
||||||
uInt16 max_width{80};
|
uInt16 max_width{80};
|
||||||
uInt16 max_height{25};
|
uInt16 max_height{25};
|
||||||
uInt64 dblclick_interval{500000}; // 500 ms
|
uInt64 dblclick_interval{500000}; // 500 ms
|
||||||
struct timeval time_mousepressed{};
|
TimeValue time_mousepressed{};
|
||||||
FPoint new_mouse_position{};
|
FPoint new_mouse_position{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -263,7 +269,7 @@ class FMouseGPM final : public FMouse
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void setRawData (FKeyboard::keybuffer&) override;
|
void setRawData (FKeyboard::keybuffer&) override;
|
||||||
void processEvent (struct timeval*) override;
|
void processEvent (const TimeValue&) override;
|
||||||
bool gpmMouse (bool = true);
|
bool gpmMouse (bool = true);
|
||||||
bool enableGpmMouse();
|
bool enableGpmMouse();
|
||||||
bool disableGpmMouse();
|
bool disableGpmMouse();
|
||||||
|
@ -321,7 +327,7 @@ class FMouseX11 final : public FMouse
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void setRawData (FKeyboard::keybuffer&) override;
|
void setRawData (FKeyboard::keybuffer&) override;
|
||||||
void processEvent (struct timeval*) override;
|
void processEvent (const TimeValue&) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Enumeration
|
// Enumeration
|
||||||
|
@ -351,7 +357,7 @@ class FMouseX11 final : public FMouse
|
||||||
// Methods
|
// Methods
|
||||||
void setKeyState (int);
|
void setKeyState (int);
|
||||||
void setMoveState (const FPoint&, int);
|
void setMoveState (const FPoint&, int);
|
||||||
void setButtonState (const int, const struct timeval*);
|
void setButtonState (const int, const TimeValue&);
|
||||||
|
|
||||||
// Data member
|
// Data member
|
||||||
char x11_mouse[MOUSE_BUF_SIZE]{'\0'};
|
char x11_mouse[MOUSE_BUF_SIZE]{'\0'};
|
||||||
|
@ -374,7 +380,7 @@ class FMouseSGR final : public FMouse
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void setRawData (FKeyboard::keybuffer&) override;
|
void setRawData (FKeyboard::keybuffer&) override;
|
||||||
void processEvent (struct timeval*) override;
|
void processEvent (const TimeValue&) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Enumeration
|
// Enumeration
|
||||||
|
@ -403,7 +409,7 @@ class FMouseSGR final : public FMouse
|
||||||
// Methods
|
// Methods
|
||||||
void setKeyState (int);
|
void setKeyState (int);
|
||||||
void setMoveState (const FPoint&, int);
|
void setMoveState (const FPoint&, int);
|
||||||
void setPressedButtonState (const int, const struct timeval*);
|
void setPressedButtonState (const int, const TimeValue&);
|
||||||
void setReleasedButtonState (const int);
|
void setReleasedButtonState (const int);
|
||||||
|
|
||||||
// Data members
|
// Data members
|
||||||
|
@ -427,7 +433,7 @@ class FMouseUrxvt final : public FMouse
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void setRawData (FKeyboard::keybuffer&) override;
|
void setRawData (FKeyboard::keybuffer&) override;
|
||||||
void processEvent (struct timeval*) override;
|
void processEvent (const TimeValue&) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Enumeration
|
// Enumeration
|
||||||
|
@ -457,7 +463,7 @@ class FMouseUrxvt final : public FMouse
|
||||||
// Methods
|
// Methods
|
||||||
void setKeyState (int);
|
void setKeyState (int);
|
||||||
void setMoveState (const FPoint&, int);
|
void setMoveState (const FPoint&, int);
|
||||||
void setButtonState (const int, const struct timeval*);
|
void setButtonState (const int, const TimeValue&);
|
||||||
|
|
||||||
// Data members
|
// Data members
|
||||||
char urxvt_mouse[MOUSE_BUF_SIZE]{'\0'};
|
char urxvt_mouse[MOUSE_BUF_SIZE]{'\0'};
|
||||||
|
@ -506,6 +512,7 @@ class FMouseControl
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
virtual FString getClassName() const;
|
virtual FString getClassName() const;
|
||||||
|
static auto getInstance() -> FMouseControl&;
|
||||||
const FPoint& getPos();
|
const FPoint& getPos();
|
||||||
void clearEvent();
|
void clearEvent();
|
||||||
|
|
||||||
|
@ -543,7 +550,7 @@ class FMouseControl
|
||||||
void disable();
|
void disable();
|
||||||
virtual void setRawData ( FMouse::MouseType
|
virtual void setRawData ( FMouse::MouseType
|
||||||
, FKeyboard::keybuffer& );
|
, FKeyboard::keybuffer& );
|
||||||
virtual void processEvent (struct timeval* time);
|
virtual void processEvent (const TimeValue&);
|
||||||
void processQueuedInput();
|
void processQueuedInput();
|
||||||
bool getGpmKeyPressed (bool = true);
|
bool getGpmKeyPressed (bool = true);
|
||||||
void drawPointer();
|
void drawPointer();
|
||||||
|
|
|
@ -44,15 +44,24 @@
|
||||||
#include <sys/time.h> // need for gettimeofday
|
#include <sys/time.h> // need for gettimeofday
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <chrono>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "final/fstring.h"
|
#include "final/fstring.h"
|
||||||
|
#include "final/ftypes.h"
|
||||||
|
|
||||||
namespace finalcut
|
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 forward declaration
|
||||||
class FEvent;
|
class FEvent;
|
||||||
class FKeyEvent;
|
class FKeyEvent;
|
||||||
|
@ -122,7 +131,6 @@ class FObject
|
||||||
bool isDirectChild (const FObject*) const;
|
bool isDirectChild (const FObject*) const;
|
||||||
bool isWidget() const;
|
bool isWidget() const;
|
||||||
bool isInstanceOf (const FString&) const;
|
bool isInstanceOf (const FString&) const;
|
||||||
bool isTimerInUpdating() const;
|
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void removeParent();
|
void removeParent();
|
||||||
|
@ -134,8 +142,8 @@ class FObject
|
||||||
virtual bool event (FEvent*);
|
virtual bool event (FEvent*);
|
||||||
|
|
||||||
// Timer methods
|
// Timer methods
|
||||||
static void getCurrentTime (timeval*);
|
static TimeValue getCurrentTime();
|
||||||
static bool isTimeout (const timeval*, uInt64);
|
static bool isTimeout (const TimeValue&, uInt64);
|
||||||
int addTimer (int);
|
int addTimer (int);
|
||||||
bool delTimer (int) const;
|
bool delTimer (int) const;
|
||||||
bool delOwnTimers() const;
|
bool delOwnTimers() const;
|
||||||
|
@ -145,8 +153,8 @@ class FObject
|
||||||
struct FTimerData
|
struct FTimerData
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
timeval interval;
|
milliseconds interval;
|
||||||
timeval timeout;
|
TimeValue timeout;
|
||||||
FObject* object;
|
FObject* object;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -178,7 +186,6 @@ class FObject
|
||||||
std::size_t max_children{UNLIMITED};
|
std::size_t max_children{UNLIMITED};
|
||||||
bool has_parent{false};
|
bool has_parent{false};
|
||||||
bool widget_object{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
|
inline bool FObject::isInstanceOf (const FString& classname) const
|
||||||
{ return classname == getClassName(); }
|
{ return classname == getClassName(); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
inline bool FObject::isTimerInUpdating() const
|
|
||||||
{ return timer_modify_lock; }
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline FObject::FTimerList* FObject::getTimerList() const
|
inline FObject::FTimerList* FObject::getTimerList() const
|
||||||
{ return globalTimerList().get(); }
|
{ return globalTimerList().get(); }
|
||||||
|
@ -274,61 +277,6 @@ inline FObject::FTimerList* FObject::getTimerList() const
|
||||||
inline void FObject::setWidgetProperty (bool property)
|
inline void FObject::setWidgetProperty (bool property)
|
||||||
{ widget_object = 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
|
} // namespace finalcut
|
||||||
|
|
||||||
#endif // FOBJECT_H
|
#endif // FOBJECT_H
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* *
|
* *
|
||||||
* This file is part of the FINAL CUT widget toolkit *
|
* 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 *
|
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU Lesser General Public License as *
|
* it under the terms of the GNU Lesser General Public License as *
|
||||||
|
@ -39,6 +39,7 @@
|
||||||
#include <algorithm> // need for std::swap
|
#include <algorithm> // need for std::swap
|
||||||
|
|
||||||
#include "final/fstring.h"
|
#include "final/fstring.h"
|
||||||
|
#include "final/ftypes.h"
|
||||||
#include "final/sgr_optimizer.h"
|
#include "final/sgr_optimizer.h"
|
||||||
|
|
||||||
namespace finalcut
|
namespace finalcut
|
||||||
|
@ -107,6 +108,7 @@ class FOptiAttr final
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
FString getClassName() const;
|
FString getClassName() const;
|
||||||
|
static auto getInstance() -> FOptiAttr&;
|
||||||
|
|
||||||
// Mutators
|
// Mutators
|
||||||
void setTermEnvironment (const TermEnv&);
|
void setTermEnvironment (const TermEnv&);
|
||||||
|
@ -156,7 +158,7 @@ class FOptiAttr final
|
||||||
// Methods
|
// Methods
|
||||||
void initialize();
|
void initialize();
|
||||||
static FColor vga2ansi (FColor);
|
static FColor vga2ansi (FColor);
|
||||||
const char* changeAttribute (FChar&, FChar&);
|
std::string changeAttribute (FChar&, FChar&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Capability
|
struct Capability
|
||||||
|
@ -165,9 +167,6 @@ class FOptiAttr final
|
||||||
bool caused_reset;
|
bool caused_reset;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Using-declaration
|
|
||||||
using AttributeBuffer = SGRoptimizer::AttributeBuffer;
|
|
||||||
|
|
||||||
// Enumerations
|
// Enumerations
|
||||||
enum init_reset_tests
|
enum init_reset_tests
|
||||||
{
|
{
|
||||||
|
@ -224,10 +223,7 @@ class FOptiAttr final
|
||||||
bool unsetTermCrossedOut (FChar&);
|
bool unsetTermCrossedOut (FChar&);
|
||||||
bool setTermDoubleUnderline (FChar&);
|
bool setTermDoubleUnderline (FChar&);
|
||||||
bool unsetTermDoubleUnderline (FChar&);
|
bool unsetTermDoubleUnderline (FChar&);
|
||||||
bool setTermAttributes ( FChar&
|
bool setTermAttributes (FChar&, const TCapAttributes&);
|
||||||
, bool, bool, bool
|
|
||||||
, bool, bool, bool
|
|
||||||
, bool, bool, bool );
|
|
||||||
bool unsetTermAttributes (FChar&);
|
bool unsetTermAttributes (FChar&);
|
||||||
bool setTermAltCharset (FChar&);
|
bool setTermAltCharset (FChar&);
|
||||||
bool unsetTermAltCharset (FChar&);
|
bool unsetTermAltCharset (FChar&);
|
||||||
|
@ -303,8 +299,8 @@ class FOptiAttr final
|
||||||
FChar off{};
|
FChar off{};
|
||||||
FChar reset_byte_mask{};
|
FChar reset_byte_mask{};
|
||||||
|
|
||||||
|
std::string attr_buf{};
|
||||||
SGRoptimizer sgr_optimizer{attr_buf};
|
SGRoptimizer sgr_optimizer{attr_buf};
|
||||||
AttributeBuffer attr_buf{};
|
|
||||||
|
|
||||||
int max_color{1};
|
int max_color{1};
|
||||||
int attr_without_color{0};
|
int attr_without_color{0};
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "final/fstring.h"
|
#include "final/fstring.h"
|
||||||
|
|
||||||
|
@ -92,6 +93,7 @@ class FOptiMove final
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
FString getClassName() const;
|
FString getClassName() const;
|
||||||
|
static auto getInstance() -> FOptiMove&;
|
||||||
uInt getCursorHomeLength() const;
|
uInt getCursorHomeLength() const;
|
||||||
uInt getCarriageReturnLength() const;
|
uInt getCarriageReturnLength() const;
|
||||||
uInt getCursorToLLLength() const;
|
uInt getCursorToLLLength() const;
|
||||||
|
@ -143,7 +145,7 @@ class FOptiMove final
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void check_boundaries (int&, int&, int&, int&) const;
|
void check_boundaries (int&, int&, int&, int&) const;
|
||||||
const char* moveCursor (int, int, int, int);
|
std::string moveCursor (int, int, int, int);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Capability
|
struct Capability
|
||||||
|
@ -154,7 +156,7 @@ class FOptiMove final
|
||||||
};
|
};
|
||||||
|
|
||||||
// Constant
|
// Constant
|
||||||
static constexpr std::size_t BUF_SIZE{512};
|
static constexpr std::string::size_type BUF_SIZE{512u};
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
static constexpr int LONG_DURATION{INT_MAX};
|
static constexpr int LONG_DURATION{INT_MAX};
|
||||||
|
@ -166,14 +168,14 @@ class FOptiMove final
|
||||||
void calculateCharDuration();
|
void calculateCharDuration();
|
||||||
int capDuration (const char[], int) const;
|
int capDuration (const char[], int) const;
|
||||||
int capDurationToLength (int) const;
|
int capDurationToLength (int) const;
|
||||||
int repeatedAppend (const Capability&, int, char*) const;
|
int repeatedAppend (std::string&, const Capability&, int) const;
|
||||||
int relativeMove (char[], int, int, int, int) const;
|
int relativeMove (std::string&, int, int, int, int) const;
|
||||||
int verticalMove (char[], int, int) const;
|
int verticalMove (std::string&, int, int) const;
|
||||||
void downMove (char[], int&, int, int) const;
|
void downMove (std::string&, int&, int, int) const;
|
||||||
void upMove (char[], int&, int, int) const;
|
void upMove (std::string&, int&, int, int) const;
|
||||||
int horizontalMove (char[], int, int) const;
|
int horizontalMove (std::string&, int, int) const;
|
||||||
void rightMove (char[], int&, int, int) const;
|
void rightMove (std::string&, int&, int, int) const;
|
||||||
void leftMove (char[], int&, int, int) const;
|
void leftMove (std::string&, int&, int, int) const;
|
||||||
|
|
||||||
bool isWideMove (int, int, int, int) const;
|
bool isWideMove (int, int, int, int) const;
|
||||||
bool isMethod0Faster (int&, int, int);
|
bool isMethod0Faster (int&, int, int);
|
||||||
|
@ -211,7 +213,7 @@ class FOptiMove final
|
||||||
int char_duration{1};
|
int char_duration{1};
|
||||||
int baudrate{9600};
|
int baudrate{9600};
|
||||||
int tabstop{0};
|
int tabstop{0};
|
||||||
char move_buf[BUF_SIZE]{'\0'};
|
std::string move_buf{};
|
||||||
bool automatic_left_margin{false};
|
bool automatic_left_margin{false};
|
||||||
bool eat_nl_glitch{false};
|
bool eat_nl_glitch{false};
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* *
|
* *
|
||||||
* This file is part of the FINAL CUT widget toolkit *
|
* 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 *
|
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU Lesser General Public License as *
|
* it under the terms of the GNU Lesser General Public License as *
|
||||||
|
@ -66,7 +66,7 @@ class FStartOptions final
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
static FString getClassName();
|
static FString getClassName();
|
||||||
static FStartOptions& getFStartOptions();
|
static auto getInstance() -> FStartOptions&;
|
||||||
|
|
||||||
// Mutator
|
// Mutator
|
||||||
void setDefault();
|
void setDefault();
|
||||||
|
|
|
@ -80,10 +80,11 @@ class FString
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Using-declarations
|
// Using-declarations
|
||||||
using iterator = wchar_t*;
|
using iterator = std::wstring::iterator;
|
||||||
using const_iterator = const wchar_t*;
|
using const_iterator = std::wstring::const_iterator;
|
||||||
using reference = wchar_t&;
|
using reference = std::wstring::reference;
|
||||||
using const_reference = const wchar_t&;
|
using const_reference = std::wstring::const_reference;
|
||||||
|
using difference_type = std::wstring::difference_type;
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
FString () = default;
|
FString () = default;
|
||||||
|
@ -167,7 +168,7 @@ class FString
|
||||||
virtual FString getClassName() const;
|
virtual FString getClassName() const;
|
||||||
|
|
||||||
// inquiries
|
// inquiries
|
||||||
bool isNull() const noexcept;
|
bool isNull() const noexcept; // deprecated
|
||||||
bool isEmpty() const noexcept;
|
bool isEmpty() const noexcept;
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
|
@ -245,24 +246,16 @@ class FString
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Constants
|
// Constants
|
||||||
static constexpr uInt FWDBUFFER = 15;
|
|
||||||
static constexpr uInt INPBUFFER = 200;
|
static constexpr uInt INPBUFFER = 200;
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void _initLength (std::size_t);
|
void _assign (std::wstring&);
|
||||||
void _assign (const wchar_t[]);
|
std::string _toCharString (const std::wstring&) const;
|
||||||
void _insert (std::size_t, const wchar_t[]);
|
std::wstring _toWideString (const std::string&) const;
|
||||||
void _insert (std::size_t, std::size_t, const wchar_t[]);
|
|
||||||
void _remove (std::size_t, std::size_t);
|
|
||||||
const char* _to_cstring (const wchar_t[]) const;
|
|
||||||
const wchar_t* _to_wcstring (const char[]) const;
|
|
||||||
const wchar_t* _extractToken (wchar_t*[], const wchar_t[], const wchar_t[]) const;
|
|
||||||
|
|
||||||
// Data members
|
// Data members
|
||||||
wchar_t* string{nullptr};
|
std::wstring string{};
|
||||||
std::size_t length{0};
|
mutable std::string char_string{};
|
||||||
std::size_t bufsize{0};
|
|
||||||
mutable char* c_string{nullptr};
|
|
||||||
static wchar_t null_char;
|
static wchar_t null_char;
|
||||||
static const wchar_t const_null_char;
|
static const wchar_t const_null_char;
|
||||||
|
|
||||||
|
@ -288,7 +281,7 @@ template <typename NumT
|
||||||
inline FString& FString::operator << (const NumT val)
|
inline FString& FString::operator << (const NumT val)
|
||||||
{
|
{
|
||||||
const FString numstr(FString().setNumber(val));
|
const FString numstr(FString().setNumber(val));
|
||||||
_insert (length, numstr.length, numstr.string);
|
string.append(numstr.string);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,10 +289,10 @@ inline FString& FString::operator << (const NumT val)
|
||||||
template <typename IndexT>
|
template <typename IndexT>
|
||||||
inline FString::reference FString::operator [] (const IndexT pos)
|
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
|
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 null_char;
|
||||||
|
|
||||||
return string[std::size_t(pos)];
|
return string[std::size_t(pos)];
|
||||||
|
@ -309,10 +302,10 @@ inline FString::reference FString::operator [] (const IndexT pos)
|
||||||
template <typename IndexT>
|
template <typename IndexT>
|
||||||
inline FString::const_reference FString::operator [] (const IndexT pos) const
|
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
|
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 const_null_char;
|
||||||
|
|
||||||
return string[std::size_t(pos)];
|
return string[std::size_t(pos)];
|
||||||
|
@ -371,63 +364,63 @@ inline FString FString::getClassName() const
|
||||||
{ return "FString"; }
|
{ return "FString"; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FString::isNull() const noexcept
|
inline bool FString::isNull() const noexcept // deprecated
|
||||||
{ return ( bufsize == 0 || (bufsize > 0 && ! string) ); }
|
{ return false; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FString::isEmpty() const noexcept
|
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
|
inline std::size_t FString::getLength() const noexcept
|
||||||
{ return length; }
|
{ return string.length(); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline std::size_t FString::capacity() const noexcept
|
inline std::size_t FString::capacity() const noexcept
|
||||||
{ return ( length > 0 ) ? bufsize - 1 : 0; }
|
{ return string.capacity(); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline FString::iterator FString::begin() noexcept
|
inline FString::iterator FString::begin() noexcept
|
||||||
{ return string; }
|
{ return string.begin(); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline FString::iterator FString::end() noexcept
|
inline FString::iterator FString::end() noexcept
|
||||||
{ return string + length; }
|
{ return string.end(); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline FString::const_iterator FString::begin() const noexcept
|
inline FString::const_iterator FString::begin() const noexcept
|
||||||
{ return string; }
|
{ return string.cbegin(); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline FString::const_iterator FString::end() const noexcept
|
inline FString::const_iterator FString::end() const noexcept
|
||||||
{ return string + length; }
|
{ return string.cend(); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline FString::reference FString::front()
|
inline FString::reference FString::front()
|
||||||
{
|
{
|
||||||
assert ( ! isEmpty() );
|
assert ( ! isEmpty() );
|
||||||
return (*this)[0];
|
return string.front();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline FString::reference FString::back()
|
inline FString::reference FString::back()
|
||||||
{
|
{
|
||||||
assert( ! isEmpty() );
|
assert( ! isEmpty() );
|
||||||
return (*this)[length - 1];
|
return string.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline FString::const_reference FString::front() const
|
inline FString::const_reference FString::front() const
|
||||||
{
|
{
|
||||||
assert ( ! isEmpty() );
|
assert ( ! isEmpty() );
|
||||||
return (*this)[0];
|
return string.front();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline FString::const_reference FString::back() const
|
inline FString::const_reference FString::back() const
|
||||||
{
|
{
|
||||||
assert( ! isEmpty() );
|
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::swprintf ( buf.data(), buf.size(), format.wc_str()
|
||||||
, std::forward<Args>(args)... );
|
, std::forward<Args>(args)... );
|
||||||
_assign(buf.data());
|
setString(buf.data());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,9 @@ class FSystem
|
||||||
// Destructor
|
// Destructor
|
||||||
virtual ~FSystem() noexcept;
|
virtual ~FSystem() noexcept;
|
||||||
|
|
||||||
|
// Accessor
|
||||||
|
static auto getInstance() -> std::unique_ptr<FSystem>&;
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
virtual uChar inPortByte (uShort) = 0;
|
virtual uChar inPortByte (uShort) = 0;
|
||||||
virtual void outPortByte (uChar, uShort) = 0;
|
virtual void outPortByte (uChar, uShort) = 0;
|
||||||
|
|
|
@ -127,31 +127,12 @@ namespace finalcut
|
||||||
|
|
||||||
// class forward declaration
|
// class forward declaration
|
||||||
class FColorPalette;
|
class FColorPalette;
|
||||||
class FKeyboard;
|
|
||||||
class FMouseControl;
|
|
||||||
class FOptiAttr;
|
|
||||||
class FOptiMove;
|
|
||||||
class FPoint;
|
class FPoint;
|
||||||
class FStartOptions;
|
class FStartOptions;
|
||||||
class FSize;
|
class FSize;
|
||||||
class FString;
|
class FString;
|
||||||
class FTermBuffer;
|
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
|
// class FTerm
|
||||||
|
@ -187,31 +168,6 @@ class FTerm final
|
||||||
static std::string getTermFileName();
|
static std::string getTermFileName();
|
||||||
static int getTabstop();
|
static int getTabstop();
|
||||||
static int getMaxColor();
|
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
|
// Inquiries
|
||||||
static bool isNormal (const FChar&);
|
static bool isNormal (const FChar&);
|
||||||
|
@ -268,7 +224,7 @@ class FTerm final
|
||||||
static int openConsole();
|
static int openConsole();
|
||||||
static int closeConsole();
|
static int closeConsole();
|
||||||
static std::string moveCursorString (int, int, int, int);
|
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 detectTermSize();
|
||||||
static void setTermSize (const FSize&);
|
static void setTermSize (const FSize&);
|
||||||
static void setTermTitle (const FString&);
|
static void setTermTitle (const FString&);
|
||||||
|
@ -301,7 +257,7 @@ class FTerm final
|
||||||
|
|
||||||
void initTerminal();
|
void initTerminal();
|
||||||
static void initScreenSettings();
|
static void initScreenSettings();
|
||||||
static const char* changeAttribute (FChar&, FChar&);
|
static std::string changeAttribute (FChar&, FChar&);
|
||||||
static void changeTermSizeFinished();
|
static void changeTermSizeFinished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -336,8 +292,8 @@ class FTerm final
|
||||||
static void restoreColorPalette();
|
static void restoreColorPalette();
|
||||||
static void setInsertCursorStyle();
|
static void setInsertCursorStyle();
|
||||||
static void setOverwriteCursorStyle();
|
static void setOverwriteCursorStyle();
|
||||||
static const char* enableCursorString();
|
static std::string enableCursorString();
|
||||||
static const char* disableCursorString();
|
static std::string disableCursorString();
|
||||||
static void enableMouse();
|
static void enableMouse();
|
||||||
static void disableMouse();
|
static void disableMouse();
|
||||||
static void enableApplicationEscKey();
|
static void enableApplicationEscKey();
|
||||||
|
@ -367,7 +323,7 @@ class FTerm final
|
||||||
// non-member function forward declarations
|
// non-member function forward declarations
|
||||||
// implemented in fterm_functions.cpp
|
// implemented in fterm_functions.cpp
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
uInt env2uint (const char*);
|
uInt env2uint (const std::string&);
|
||||||
bool isReverseNewFontchar (wchar_t);
|
bool isReverseNewFontchar (wchar_t);
|
||||||
bool hasFullWidthSupports();
|
bool hasFullWidthSupports();
|
||||||
wchar_t cp437_to_unicode (uChar);
|
wchar_t cp437_to_unicode (uChar);
|
||||||
|
@ -404,7 +360,7 @@ inline FString FTerm::getClassName()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FTerm::setFSystem (std::unique_ptr<FSystem>& fsystem)
|
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>
|
template <typename ClassT>
|
||||||
inline void FTerm::setColorPaletteTheme (const FSetPalette& f)
|
inline void FTerm::setColorPaletteTheme (const FSetPalette& f)
|
||||||
{
|
{
|
||||||
getColorPaletteTheme() = std::make_shared<ClassT>(f);
|
FColorPalette::getInstance() = std::make_shared<ClassT>(f); // Set instance
|
||||||
getColorPaletteTheme()->setColorPalette();
|
FColorPalette::getInstance()->setColorPalette(); // Set palette
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
|
@ -111,7 +111,7 @@ class FTermBuffer
|
||||||
private:
|
private:
|
||||||
FCharVector data{};
|
FCharVector data{};
|
||||||
void add ( FString::const_iterator&
|
void add ( FString::const_iterator&
|
||||||
, FString::const_iterator&
|
, const FString::const_iterator&
|
||||||
, int& );
|
, int& );
|
||||||
|
|
||||||
// Non-member operators
|
// Non-member operators
|
||||||
|
|
|
@ -41,6 +41,8 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "final/ftypes.h"
|
||||||
|
|
||||||
// FTermcap string macro
|
// FTermcap string macro
|
||||||
#define TCAP(...) FTermcap::strings[int(Termcap::__VA_ARGS__)].string
|
#define TCAP(...) FTermcap::strings[int(Termcap::__VA_ARGS__)].string
|
||||||
|
|
||||||
|
@ -129,7 +131,7 @@ class FTermcap final
|
||||||
static void termcapStrings();
|
static void termcapStrings();
|
||||||
static void termcapKeys();
|
static void termcapKeys();
|
||||||
static std::string encodeParams ( const std::string&
|
static std::string encodeParams ( const std::string&
|
||||||
, const std::vector<int>& );
|
, const std::array<int, 9>& );
|
||||||
template<typename PutChar>
|
template<typename PutChar>
|
||||||
static void delay_output (int, const PutChar&);
|
static void delay_output (int, const PutChar&);
|
||||||
|
|
||||||
|
@ -149,7 +151,9 @@ inline FString FTermcap::getClassName() const
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
std::string FTermcap::encodeParameter (const std::string& cap, Args&&... 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
|
// Accessors
|
||||||
FString getClassName() const;
|
FString getClassName() const;
|
||||||
|
static auto getInstance() -> FTermData&;
|
||||||
EncodingMap& getEncodingList();
|
EncodingMap& getEncodingList();
|
||||||
charSubstitution& getCharSubstitutionMap();
|
charSubstitution& getCharSubstitutionMap();
|
||||||
Encoding getTermEncoding() const;
|
Encoding getTermEncoding() const;
|
||||||
|
@ -170,6 +171,13 @@ class FTermData final
|
||||||
inline FString FTermData::getClassName() const
|
inline FString FTermData::getClassName() const
|
||||||
{ return "FTermData"; }
|
{ return "FTermData"; }
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
inline auto FTermData::getInstance() -> FTermData&
|
||||||
|
{
|
||||||
|
static const auto& data = make_unique<FTermData>();
|
||||||
|
return *data;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline FTermData::EncodingMap& FTermData::getEncodingList()
|
inline FTermData::EncodingMap& FTermData::getEncodingList()
|
||||||
{ return encoding_list; }
|
{ return encoding_list; }
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* *
|
* *
|
||||||
* This file is part of the FINAL CUT widget toolkit *
|
* 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 *
|
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU Lesser General Public License as *
|
* 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."
|
#error "Only <final/final.h> can be included directly."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "final/fstring.h"
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
|
||||||
namespace finalcut
|
namespace finalcut
|
||||||
{
|
{
|
||||||
|
|
||||||
// class forward declaration
|
|
||||||
class FTerm;
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// class FTermDebugData
|
// class FTermDebugData
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -63,16 +62,21 @@ class FTermDebugData final
|
||||||
FTermDebugData& operator = (const FTermDebugData&) = delete;
|
FTermDebugData& operator = (const FTermDebugData&) = delete;
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
|
static FString getClassName();
|
||||||
|
static auto getInstance() -> FTermDebugData&;
|
||||||
const FString& getAnswerbackString();
|
const FString& getAnswerbackString();
|
||||||
const FString& getSecDAString();
|
const FString& getSecDAString();
|
||||||
const char* getTermType_256color();
|
const FString& getTermType_256color();
|
||||||
const char* getTermType_Answerback();
|
const FString& getTermType_Answerback();
|
||||||
const char* getTermType_SecDA();
|
const FString& getTermType_SecDA();
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
int getFramebufferBpp();
|
int getFramebufferBpp();
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline FString FTermDebugData::getClassName()
|
||||||
|
{ return "FTermDebugData"; }
|
||||||
|
|
||||||
} // namespace finalcut
|
} // namespace finalcut
|
||||||
|
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
|
|
@ -79,7 +79,12 @@ class FTermDetection final
|
||||||
uInt8 : 3; // padding bits
|
uInt8 : 3; // padding bits
|
||||||
};
|
};
|
||||||
|
|
||||||
struct kittyVersion; // forward declaration
|
struct kittyVersion
|
||||||
|
{
|
||||||
|
int primary{0};
|
||||||
|
int secondary{0};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
FTermDetection();
|
FTermDetection();
|
||||||
|
@ -94,183 +99,167 @@ class FTermDetection final
|
||||||
FTermDetection& operator = (const FTermDetection&) = delete;
|
FTermDetection& operator = (const FTermDetection&) = delete;
|
||||||
|
|
||||||
// Accessor
|
// Accessor
|
||||||
static FString getClassName();
|
FString getClassName() const;
|
||||||
static const char* getTermType();
|
static auto getInstance() -> FTermDetection&;
|
||||||
static int getGnomeTerminalID();
|
const FString& getTermType() const;
|
||||||
static kittyVersion getKittyVersion();
|
int getGnomeTerminalID() const;
|
||||||
|
kittyVersion getKittyVersion() const;
|
||||||
FTerminalType& getTermTypeStruct();
|
FTerminalType& getTermTypeStruct();
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
static const FString& getAnswerbackString();
|
const FString& getAnswerbackString() const;
|
||||||
static const FString& getSecDAString();
|
const FString& getSecDAString() const;
|
||||||
static const char* getTermType_256color();
|
const FString& getTermType_256color() const;
|
||||||
static const char* getTermType_Answerback();
|
const FString& getTermType_Answerback() const;
|
||||||
static const char* getTermType_SecDA();
|
const FString& getTermType_SecDA() const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Inquiries
|
// Inquiries
|
||||||
static bool isAnsiTerminal();
|
bool isAnsiTerminal() const;
|
||||||
static bool isXTerminal();
|
bool isXTerminal() const;
|
||||||
static bool isRxvtTerminal();
|
bool isRxvtTerminal() const;
|
||||||
static bool isUrxvtTerminal();
|
bool isUrxvtTerminal() const;
|
||||||
static bool isKdeTerminal();
|
bool isKdeTerminal() const;
|
||||||
static bool isGnomeTerminal();
|
bool isGnomeTerminal() const;
|
||||||
static bool isPuttyTerminal();
|
bool isPuttyTerminal() const;
|
||||||
static bool isWindowsTerminal();
|
bool isWindowsTerminal() const;
|
||||||
static bool isTeraTerm();
|
bool isTeraTerm() const;
|
||||||
static bool isCygwinTerminal();
|
bool isCygwinTerminal() const;
|
||||||
static bool isMinttyTerm();
|
bool isMinttyTerm() const;
|
||||||
static bool isLinuxTerm();
|
bool isLinuxTerm() const;
|
||||||
static bool isFreeBSDTerm();
|
bool isFreeBSDTerm() const;
|
||||||
static bool isNetBSDTerm();
|
bool isNetBSDTerm() const;
|
||||||
static bool isOpenBSDTerm();
|
bool isOpenBSDTerm() const;
|
||||||
static bool isSunTerminal();
|
bool isSunTerminal() const;
|
||||||
static bool isScreenTerm();
|
bool isScreenTerm() const;
|
||||||
static bool isTmuxTerm();
|
bool isTmuxTerm() const;
|
||||||
static bool isKtermTerminal();
|
bool isKtermTerminal() const;
|
||||||
static bool isMltermTerminal();
|
bool isMltermTerminal() const;
|
||||||
static bool isKittyTerminal();
|
bool isKittyTerminal() const;
|
||||||
static bool canDisplay256Colors();
|
bool canDisplay256Colors() const;
|
||||||
static bool hasTerminalDetection();
|
bool hasTerminalDetection() const;
|
||||||
static bool hasSetCursorStyleSupport();
|
bool hasSetCursorStyleSupport() const;
|
||||||
|
|
||||||
// Mutators
|
// Mutators
|
||||||
static void setAnsiTerminal (bool = true);
|
void setAnsiTerminal (bool = true);
|
||||||
static void setXTerminal (bool = true);
|
void setXTerminal (bool = true);
|
||||||
static void setRxvtTerminal (bool = true);
|
void setRxvtTerminal (bool = true);
|
||||||
static void setUrxvtTerminal (bool = true);
|
void setUrxvtTerminal (bool = true);
|
||||||
static void setKdeTerminal (bool = true);
|
void setKdeTerminal (bool = true);
|
||||||
static void setGnomeTerminal (bool = true);
|
void setGnomeTerminal (bool = true);
|
||||||
static void setPuttyTerminal (bool = true);
|
void setPuttyTerminal (bool = true);
|
||||||
static void setWindowsTerminal (bool = true);
|
void setWindowsTerminal (bool = true);
|
||||||
static void setTeraTerm (bool = true);
|
void setTeraTerm (bool = true);
|
||||||
static void setCygwinTerminal (bool = true);
|
void setCygwinTerminal (bool = true);
|
||||||
static void setMinttyTerm (bool = true);
|
void setMinttyTerm (bool = true);
|
||||||
static void setLinuxTerm (bool = true);
|
void setLinuxTerm (bool = true);
|
||||||
static void setFreeBSDTerm (bool = true);
|
void setFreeBSDTerm (bool = true);
|
||||||
static void setNetBSDTerm (bool = true);
|
void setNetBSDTerm (bool = true);
|
||||||
static void setOpenBSDTerm (bool = true);
|
void setOpenBSDTerm (bool = true);
|
||||||
static void setSunTerminal (bool = true);
|
void setSunTerminal (bool = true);
|
||||||
static void setScreenTerm (bool = true);
|
void setScreenTerm (bool = true);
|
||||||
static void setTmuxTerm (bool = true);
|
void setTmuxTerm (bool = true);
|
||||||
static void setKtermTerminal (bool = true);
|
void setKtermTerminal (bool = true);
|
||||||
static void setMltermTerminal (bool = true);
|
void setMltermTerminal (bool = true);
|
||||||
static void setKittyTerminal (bool = true);
|
void setKittyTerminal (bool = true);
|
||||||
static void setTerminalDetection (bool = true);
|
void setTerminalDetection (bool = true);
|
||||||
static void setTtyTypeFileName (const char[]);
|
void setTtyTypeFileName (const FString&);
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
static void detect();
|
void detect();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct colorEnv; // forward declaration
|
struct colorEnv
|
||||||
struct secondaryDA; // forward declaration
|
|
||||||
|
|
||||||
// Methods
|
|
||||||
static void deallocation();
|
|
||||||
static void getSystemTermType();
|
|
||||||
static bool getTTYtype();
|
|
||||||
#if F_HAVE_GETTTYNAM
|
|
||||||
static 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[]);
|
|
||||||
|
|
||||||
// Data members
|
|
||||||
#if DEBUG
|
|
||||||
static char termtype_256color[256];
|
|
||||||
static char termtype_Answerback[256];
|
|
||||||
static char termtype_SecDA[256];
|
|
||||||
#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};
|
FString string1{};
|
||||||
char* string2{nullptr};
|
FString string2{};
|
||||||
char* string3{nullptr};
|
FString string3{};
|
||||||
char* string4{nullptr};
|
FString string4{};
|
||||||
char* string5{nullptr};
|
FString string5{};
|
||||||
char* string6{nullptr};
|
FString string6{};
|
||||||
char* string7{nullptr};
|
FString string7{};
|
||||||
char* string8{nullptr};
|
FString string8{};
|
||||||
};
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
struct secondaryDA
|
||||||
// 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_type{-1};
|
||||||
int terminal_id_version{-1};
|
int terminal_id_version{-1};
|
||||||
int terminal_id_hardware{-1};
|
int terminal_id_hardware{-1};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
void getSystemTermType();
|
||||||
|
bool getTTYtype();
|
||||||
|
#if F_HAVE_GETTTYNAM
|
||||||
|
bool getTTYSFileEntry();
|
||||||
|
#endif
|
||||||
|
void termtypeAnalysis();
|
||||||
|
void detectTerminal();
|
||||||
|
FString init_256colorTerminal();
|
||||||
|
bool get256colorEnvString();
|
||||||
|
FString termtype_256color_quirks();
|
||||||
|
FString determineMaxColor (const FString&);
|
||||||
|
FString getXTermColorName (FColor) const;
|
||||||
|
FString parseAnswerbackMsg (const FString&);
|
||||||
|
FString getAnswerbackMsg() const;
|
||||||
|
FString parseSecDA (const FString&);
|
||||||
|
int str2int (const FString&) const;
|
||||||
|
FString getSecDA() const;
|
||||||
|
FString secDA_Analysis (const FString&);
|
||||||
|
FString secDA_Analysis_0 (const FString&);
|
||||||
|
FString secDA_Analysis_1 (const FString&);
|
||||||
|
FString secDA_Analysis_24 (const FString&);
|
||||||
|
FString secDA_Analysis_32 ();
|
||||||
|
FString secDA_Analysis_65 (const FString&);
|
||||||
|
FString secDA_Analysis_67 ();
|
||||||
|
FString secDA_Analysis_77 ();
|
||||||
|
FString secDA_Analysis_82 ();
|
||||||
|
FString secDA_Analysis_83 (const FString&);
|
||||||
|
FString secDA_Analysis_84 (const FString&);
|
||||||
|
FString secDA_Analysis_85 ();
|
||||||
|
FString secDA_Analysis_vte (const FString&);
|
||||||
|
FString secDA_Analysis_kitty (const FString&);
|
||||||
|
|
||||||
|
// Data members
|
||||||
|
#if DEBUG
|
||||||
|
FString termtype_256color{};
|
||||||
|
FString termtype_Answerback{};
|
||||||
|
FString termtype_SecDA{};
|
||||||
|
#endif
|
||||||
|
FString termtype{};
|
||||||
|
FString ttytypename{"/etc/ttytype"}; // Default ttytype file
|
||||||
|
bool decscusr_support{false}; // Preset to false
|
||||||
|
bool terminal_detection{true}; // Preset to true
|
||||||
|
bool color256{};
|
||||||
|
// Gnome terminal id from SecDA
|
||||||
|
// Example: vte version 0.40.0 = 0 * 100 + 40 * 100 + 0 = 4000
|
||||||
|
// a.b.c = a * 100 + b * 100 + c
|
||||||
|
int gnome_terminal_id{0};
|
||||||
|
FString answer_back{};
|
||||||
|
FString sec_da{};
|
||||||
|
FTerminalType terminal_type{};
|
||||||
|
colorEnv color_env{};
|
||||||
|
kittyVersion kitty_version{};
|
||||||
|
secondaryDA secondary_da{};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// FTermDetection inline functions
|
// FTermDetection inline functions
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline FString FTermDetection::getClassName()
|
inline FString FTermDetection::getClassName() const
|
||||||
{ return "FTermDetection"; }
|
{ return "FTermDetection"; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const char* FTermDetection::getTermType()
|
inline const FString& FTermDetection::getTermType() const
|
||||||
{ return termtype; }
|
{ return termtype; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline int FTermDetection::getGnomeTerminalID()
|
inline int FTermDetection::getGnomeTerminalID() const
|
||||||
{ return gnome_terminal_id; }
|
{ return gnome_terminal_id; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline FTermDetection::kittyVersion FTermDetection::getKittyVersion()
|
inline FTermDetection::kittyVersion FTermDetection::getKittyVersion() const
|
||||||
{ return kitty_version; }
|
{ return kitty_version; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -279,112 +268,112 @@ inline FTermDetection::FTerminalType& FTermDetection::getTermTypeStruct()
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const char* FTermDetection::getTermType_256color()
|
inline const FString& FTermDetection::getTermType_256color() const
|
||||||
{ return termtype_256color; }
|
{ return termtype_256color; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const char* FTermDetection::getTermType_Answerback()
|
inline const FString& FTermDetection::getTermType_Answerback() const
|
||||||
{ return termtype_Answerback; }
|
{ return termtype_Answerback; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const char* FTermDetection::getTermType_SecDA()
|
inline const FString& FTermDetection::getTermType_SecDA() const
|
||||||
{ return termtype_SecDA; }
|
{ return termtype_SecDA; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FTermDetection::canDisplay256Colors()
|
inline bool FTermDetection::canDisplay256Colors() const
|
||||||
{ return color256; }
|
{ return color256; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FTermDetection::hasSetCursorStyleSupport()
|
inline bool FTermDetection::hasSetCursorStyleSupport() const
|
||||||
{ return decscusr_support; }
|
{ return decscusr_support; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FTermDetection::isXTerminal()
|
inline bool FTermDetection::isXTerminal() const
|
||||||
{ return terminal_type.xterm; }
|
{ return terminal_type.xterm; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FTermDetection::isAnsiTerminal()
|
inline bool FTermDetection::isAnsiTerminal() const
|
||||||
{ return terminal_type.ansi; }
|
{ return terminal_type.ansi; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FTermDetection::isRxvtTerminal()
|
inline bool FTermDetection::isRxvtTerminal() const
|
||||||
{ return terminal_type.rxvt; }
|
{ return terminal_type.rxvt; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FTermDetection::isUrxvtTerminal()
|
inline bool FTermDetection::isUrxvtTerminal() const
|
||||||
{ return terminal_type.urxvt; }
|
{ return terminal_type.urxvt; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FTermDetection::isMltermTerminal()
|
inline bool FTermDetection::isMltermTerminal() const
|
||||||
{ return terminal_type.mlterm; }
|
{ return terminal_type.mlterm; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FTermDetection::isKittyTerminal()
|
inline bool FTermDetection::isKittyTerminal() const
|
||||||
{ return terminal_type.kitty; }
|
{ return terminal_type.kitty; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FTermDetection::isPuttyTerminal()
|
inline bool FTermDetection::isPuttyTerminal() const
|
||||||
{ return terminal_type.putty; }
|
{ return terminal_type.putty; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FTermDetection::isWindowsTerminal()
|
inline bool FTermDetection::isWindowsTerminal() const
|
||||||
{ return terminal_type.win_terminal; }
|
{ return terminal_type.win_terminal; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FTermDetection::isKdeTerminal()
|
inline bool FTermDetection::isKdeTerminal() const
|
||||||
{ return terminal_type.kde_konsole; }
|
{ return terminal_type.kde_konsole; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FTermDetection::isGnomeTerminal()
|
inline bool FTermDetection::isGnomeTerminal() const
|
||||||
{ return terminal_type.gnome_terminal; }
|
{ return terminal_type.gnome_terminal; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FTermDetection::isKtermTerminal()
|
inline bool FTermDetection::isKtermTerminal() const
|
||||||
{ return terminal_type.kterm; }
|
{ return terminal_type.kterm; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FTermDetection::isTeraTerm()
|
inline bool FTermDetection::isTeraTerm() const
|
||||||
{ return terminal_type.tera_term; }
|
{ return terminal_type.tera_term; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FTermDetection::isCygwinTerminal()
|
inline bool FTermDetection::isCygwinTerminal() const
|
||||||
{ return terminal_type.cygwin; }
|
{ return terminal_type.cygwin; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FTermDetection::isMinttyTerm()
|
inline bool FTermDetection::isMinttyTerm() const
|
||||||
{ return terminal_type.mintty; }
|
{ return terminal_type.mintty; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FTermDetection::isLinuxTerm()
|
inline bool FTermDetection::isLinuxTerm() const
|
||||||
{ return terminal_type.linux_con; }
|
{ return terminal_type.linux_con; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FTermDetection::isFreeBSDTerm()
|
inline bool FTermDetection::isFreeBSDTerm() const
|
||||||
{ return terminal_type.freebsd_con; }
|
{ return terminal_type.freebsd_con; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FTermDetection::isNetBSDTerm()
|
inline bool FTermDetection::isNetBSDTerm() const
|
||||||
{ return terminal_type.netbsd_con; }
|
{ return terminal_type.netbsd_con; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FTermDetection::isOpenBSDTerm()
|
inline bool FTermDetection::isOpenBSDTerm() const
|
||||||
{ return terminal_type.openbsd_con; }
|
{ return terminal_type.openbsd_con; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FTermDetection::isSunTerminal()
|
inline bool FTermDetection::isSunTerminal() const
|
||||||
{ return terminal_type.sun_con; }
|
{ return terminal_type.sun_con; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FTermDetection::isScreenTerm()
|
inline bool FTermDetection::isScreenTerm() const
|
||||||
{ return terminal_type.screen; }
|
{ return terminal_type.screen; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FTermDetection::isTmuxTerm()
|
inline bool FTermDetection::isTmuxTerm() const
|
||||||
{ return terminal_type.tmux; }
|
{ return terminal_type.tmux; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FTermDetection::hasTerminalDetection()
|
inline bool FTermDetection::hasTerminalDetection() const
|
||||||
{ return terminal_detection; }
|
{ return terminal_detection; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
|
@ -83,6 +83,7 @@ class FTermFreeBSD final
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
FString getClassName() const;
|
FString getClassName() const;
|
||||||
|
static auto getInstance() -> FTermFreeBSD&;
|
||||||
static CursorStyle getCursorStyle();
|
static CursorStyle getCursorStyle();
|
||||||
|
|
||||||
// Inquiry
|
// Inquiry
|
||||||
|
|
|
@ -92,6 +92,7 @@ class FTermLinux final
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
FString getClassName() const;
|
FString getClassName() const;
|
||||||
|
static auto getInstance() -> FTermLinux&;
|
||||||
CursorStyle getCursorStyle() const;
|
CursorStyle getCursorStyle() const;
|
||||||
char* getCursorStyleString();
|
char* getCursorStyleString();
|
||||||
int getFramebufferBpp() const;
|
int getFramebufferBpp() const;
|
||||||
|
|
|
@ -73,6 +73,7 @@ class FTermOpenBSD final
|
||||||
public:
|
public:
|
||||||
// Accessor
|
// Accessor
|
||||||
FString getClassName() const;
|
FString getClassName() const;
|
||||||
|
static auto getInstance() -> FTermOpenBSD&;
|
||||||
|
|
||||||
// Inquiries
|
// Inquiries
|
||||||
static bool isBSDConsole();
|
static bool isBSDConsole();
|
||||||
|
|
|
@ -66,6 +66,7 @@ class FTermXTerminal final
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
FString getClassName() const;
|
FString getClassName() const;
|
||||||
|
static auto getInstance() -> FTermXTerminal&;
|
||||||
XTermCursorStyle getCursorStyle() const;
|
XTermCursorStyle getCursorStyle() const;
|
||||||
FString getFont() const;
|
FString getFont() const;
|
||||||
FString getTitle() 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)
|
inline void FTextView::deleteLine (int pos)
|
||||||
{ deleteRange (pos, pos); }
|
{ deleteRange (pos, pos); }
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <chrono>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -68,7 +69,7 @@ using sInt32 = std::int32_t;
|
||||||
using sInt64 = std::int64_t;
|
using sInt64 = std::int64_t;
|
||||||
|
|
||||||
using lDouble = long double;
|
using lDouble = long double;
|
||||||
|
using TimeValue = std::chrono::time_point<std::chrono::system_clock>;
|
||||||
using FCall = std::function<void()>;
|
using FCall = std::function<void()>;
|
||||||
|
|
||||||
namespace finalcut
|
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)...));
|
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>;
|
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
|
struct FCharAttribute
|
||||||
{
|
{
|
||||||
// Attribute byte #0
|
// Attribute byte #0
|
||||||
|
|
|
@ -418,10 +418,8 @@ class FVTerm
|
||||||
bool updateTerminalLine (uInt) const;
|
bool updateTerminalLine (uInt) const;
|
||||||
bool updateTerminalCursor() const;
|
bool updateTerminalCursor() const;
|
||||||
bool isInsideTerminal (const FPoint&) const;
|
bool isInsideTerminal (const FPoint&) const;
|
||||||
bool isTermSizeChanged() const;
|
|
||||||
void flushTimeAdjustment() const;
|
void flushTimeAdjustment() const;
|
||||||
static bool isFlushTimeout();
|
static bool isFlushTimeout();
|
||||||
static bool isTermSizeCheckTimeout();
|
|
||||||
static bool hasPendingUpdates (const FTermArea*);
|
static bool hasPendingUpdates (const FTermArea*);
|
||||||
static void markAsPrinted (uInt, uInt);
|
static void markAsPrinted (uInt, uInt);
|
||||||
static void markAsPrinted (uInt, uInt, uInt);
|
static void markAsPrinted (uInt, uInt, uInt);
|
||||||
|
@ -453,8 +451,7 @@ class FVTerm
|
||||||
static FChar next_attribute;
|
static FChar next_attribute;
|
||||||
static FChar s_ch; // shadow character
|
static FChar s_ch; // shadow character
|
||||||
static FChar i_ch; // inherit background character
|
static FChar i_ch; // inherit background character
|
||||||
static timeval time_last_flush;
|
static TimeValue time_last_flush;
|
||||||
static timeval last_term_size_check;
|
|
||||||
static bool draw_completed;
|
static bool draw_completed;
|
||||||
static bool combined_char_support;
|
static bool combined_char_support;
|
||||||
static bool no_terminal_updates;
|
static bool no_terminal_updates;
|
||||||
|
@ -462,7 +459,6 @@ class FVTerm
|
||||||
static uInt64 flush_wait;
|
static uInt64 flush_wait;
|
||||||
static uInt64 flush_average;
|
static uInt64 flush_average;
|
||||||
static uInt64 flush_median;
|
static uInt64 flush_median;
|
||||||
static uInt64 term_size_check_timeout;
|
|
||||||
static uInt erase_char_length;
|
static uInt erase_char_length;
|
||||||
static uInt repeat_char_length;
|
static uInt repeat_char_length;
|
||||||
static uInt clr_bol_length;
|
static uInt clr_bol_length;
|
||||||
|
|
|
@ -507,6 +507,7 @@ class FWidget : public FVTerm, public FObject
|
||||||
void detectTermSize();
|
void detectTermSize();
|
||||||
bool isFocusNextKey (const FKey);
|
bool isFocusNextKey (const FKey);
|
||||||
bool isFocusPrevKey (const FKey);
|
bool isFocusPrevKey (const FKey);
|
||||||
|
bool isInFWidgetList (const FWidget::FWidgetList*, const FWidget*);
|
||||||
FKey getHotkey (const FString&);
|
FKey getHotkey (const FString&);
|
||||||
std::size_t getHotkeyPos (const FString& src, FString& dest);
|
std::size_t getHotkeyPos (const FString& src, FString& dest);
|
||||||
void setHotkeyViaString (FWidget*, const FString&);
|
void setHotkeyViaString (FWidget*, const FString&);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* *
|
* *
|
||||||
* This file is part of the FINAL CUT widget toolkit *
|
* 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 *
|
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU Lesser General Public License as *
|
* it under the terms of the GNU Lesser General Public License as *
|
||||||
|
@ -49,13 +49,10 @@ class SGRoptimizer final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Constants
|
// Constants
|
||||||
static constexpr std::size_t ATTR_BUF_SIZE{8192};
|
static constexpr std::string::size_type ATTR_BUF_SIZE{8192u};
|
||||||
|
|
||||||
// Using-declaration
|
|
||||||
using AttributeBuffer = std::array<char, ATTR_BUF_SIZE>;
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
explicit SGRoptimizer (AttributeBuffer&);
|
explicit SGRoptimizer (std::string&);
|
||||||
|
|
||||||
// Disable copy constructor
|
// Disable copy constructor
|
||||||
SGRoptimizer (const SGRoptimizer&) = delete;
|
SGRoptimizer (const SGRoptimizer&) = delete;
|
||||||
|
@ -78,7 +75,7 @@ class SGRoptimizer final
|
||||||
void combineParameter();
|
void combineParameter();
|
||||||
|
|
||||||
// Data member
|
// Data member
|
||||||
AttributeBuffer& seq;
|
std::string& seq;
|
||||||
|
|
||||||
struct parameter
|
struct parameter
|
||||||
{
|
{
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue